Commit Graph

2105 Commits

Author SHA1 Message Date
Daniel Huigens
ff8d274b4d Use ArrayStreams 2021-03-25 18:57:29 +01:00
larabr
6cff19c44a
Use consistent name casing (#1268)
- Use PascalCase for classes, with uppercase acronyms.
- Use camelCase for function and variables. First word/acronym is always
  lowercase, otherwise acronyms are uppercase.

Also, make the packet classes' `tag` properties `static`.
2021-03-25 19:56:59 +01:00
larabr
8a57246ec4
Add config.rejectPublicKeyAlgorithms (#1264)
- Add `config.rejectPublicKeyAlgorithms` to disallow using the given algorithms
  to verify, sign or encrypt new messages or third-party certifications.

- Consider `config.minRsaBits` when signing, verifying and encrypting messages
  and third-party certifications, not just on key generation.

- When verifying a message, if the verification key is not found (i.e. not
  provided or too weak), the corresponding `signature` will have
  `signature.valid=false` (used to be `signature.valid=null`).
  `signature.error` will detail whether the key is missing/too weak/etc.

Generating and verifying key certification signatures is still permitted in all cases.
2021-03-25 15:08:49 +01:00
larabr
3e808c1578
Drop support for verification of detached cleartext signatures (#1265)
(Also, use turnstyle to avoid CI browserstack tasks running in parallel.)
2021-03-18 17:17:39 +01:00
Kevin Moutet
eba791e11e
Add key.write() and update type definitions (#1267)
Also, mark key.keyPacket, message.packets and signature.packets private.
2021-03-16 13:45:17 +01:00
larabr
43fb58404d
Simplify algorithm preference selection and normalize config names (#1262)
- Rename `config.compression` to `config.preferredCompressionAlgorithm`
- Rename `config.encryptionCipher` to `config.preferredSymmetricAlgorithm`
- Rename `config.preferHashAlgorithm` to `config.preferredHashAlgorithm`
- Rename `config.aeadMode` to `config.preferredAeadAlgorithm`
- When encrypting to public keys, the compression/aead/symmetric algorithm is selected by:
  - taking the preferred algorithm specified in config, if it is supported by all recipients
  - otherwise, taking the "MUST implement" algorithm specified by rfc4880bis
- When encrypting to passphrases only (no public keys), the preferred algorithms from `config` are always used
- EdDSA signing with a hash algorithm weaker than sha256 is explicitly disallowed (https://tools.ietf.org/id/draft-ietf-openpgp-rfc4880bis-10.html#section-15-7.2)
2021-03-10 18:06:03 +01:00
Daniel Huigens
4379d1856e 5.0.0-1 2021-03-03 20:28:16 +01:00
Daniel Huigens
b9134ed161
Fix unhandled promise rejection when stream-decrypting non-MDC messages (#1260)
Also, add some tests.
2021-03-03 19:38:58 +01:00
larabr
6e2a787ff8
Rename config.ignoreMdcError, drop config.integrityProtect and allow V4 keys to be AEAD-encrypted (#1261)
* Rename `config.ignoreMdcError` to `config.allowUnauthenticatedMessages`

* Do not support creating sym. enc. messages without integrity protection

* Use `config.aeadProtect` to determine SKESK encryption mode
2021-03-03 18:05:40 +01:00
larabr
f41412a5a2
Check critical notations during signature verification instead of parsing (#1259) 2021-03-03 18:03:45 +01:00
Daniel Huigens
30ddc3b90a Remove util from TypeScript definitions 2021-03-01 18:27:30 +01:00
Daniel Huigens
3f494ca797 Remove config.nodeStore 2021-03-01 12:02:39 +01:00
Daniel Huigens
4a8fffdfdf Remove KeyRing class
Keyring handling and storage should be handled in the application, as
localStorage may not meet the durability requirements of the
application, for example.
2021-03-01 11:58:10 +01:00
Daniel Huigens
8e5fe1da4f Remove config.keyserver 2021-03-01 11:43:13 +01:00
Daniel Huigens
7203e6afb6 Move WKD client to openpgpjs/wkd-client 2021-03-01 01:02:16 +01:00
Daniel Huigens
43f0724aeb Move HKP client to openpgpjs/hkp-client 2021-02-28 22:59:16 +01:00
Daniel Huigens
fa3c36fc87 Remove unused devDependencies 2021-02-28 21:58:30 +01:00
Daniel Huigens
e959602a94 Switch packages installed from git to @openpgp scope 2021-02-28 21:45:21 +01:00
Daniel Huigens
9bb65bd1c3 Update web-stream-tools 2021-02-28 21:25:58 +01:00
Daniel Huigens
9e85f75519 Don't mark async function as returning a Promise explicitly
It seems redundant.
2021-02-28 01:47:48 +01:00
Daniel Huigens
2ba04d9f0a Document parameters of Message.fromText/fromBinary 2021-02-28 01:47:48 +01:00
Daniel Huigens
174086a011 Default to empty filename 2021-02-28 01:47:48 +01:00
Daniel Huigens
21e3ba4653 Clean up JSDocs 2021-02-28 00:32:02 +01:00
Daniel Huigens
e2eadd09e4 Fix documentation of top-level function parameters 2021-02-27 23:37:41 +01:00
Daniel Huigens
a50cb9c6b7 Don't include date in documentation
To reduce diffs for each release.
2021-02-27 22:29:08 +01:00
Daniel Huigens
365a5efb63 5.0.0-0 2021-02-27 01:25:52 +01:00
Daniel Huigens
ab419179bc Remove TextEncoder/TextDecoder polyfills
Also, drop support for Node.js 10.
2021-02-27 01:22:13 +01:00
Daniel Huigens
3a42b45ab7 Remove unused config/localStorage module 2021-02-27 01:22:13 +01:00
Daniel Huigens
636c7cf529 Update documentation 2021-02-27 01:22:13 +01:00
larabr
7f37a8aaca
Add config parameter to top-level functions (#1241)
Refactor functions to take the configuration as a parameter.

This allows setting a config option for a single function call, whereas
setting `openpgp.config` could lead to concurrency-related issues when
multiple async function calls are made at the same time.

`openpgp.config` is used as default for unset config values in top-level
functions.
`openpgp.config` is used as default config object in low-level functions
(i.e., when calling a low-level function, it may be required to pass
`{ ...openpgp.config, modifiedConfig: modifiedValue }`).

Also,

- remove `config.rsaBlinding`: blinding is now always applied to RSA decryption
- remove `config.debug`: debugging mode can be enabled by setting
  `process.env.NODE_ENV = 'development'`
- remove `config.useNative`: native crypto is always used when available
2021-02-26 20:04:54 +01:00
larabr
15ee659c9c
Exit with error on unhandled rejections in Node tests (#1251) 2021-02-26 12:46:41 +01:00
Ali Cherry
2000388a80
Return subkey binding signature in SubKey#verify (#1250)
Also, update TypeScript definitions.
2021-02-25 12:58:54 +01:00
Daniel Huigens
ca248ba1a8 CI: Bump browser test timeout 2021-02-24 23:00:25 +01:00
larabr
95dd81381f
CI: Update browser targets (#1249) 2021-02-24 18:15:57 +01:00
Daniel Huigens
e1307b88d0
Consolidate read* functions (#1236)
Make all `read*` functions accept an options object, so that we can add config
options to them later (for #1166). This is necessary so that we can remove the
global `openpgp.config`, which doesn't work that well when importing
individual functions.

Furthermore, merge `readMessage` and `readArmoredMessage` into one function,
et cetera.
2021-02-17 20:36:33 +01:00
Ali Cherry
9ae0aae7a2
Add options to select encryption/signing key IDs (#1238) 2021-02-17 20:06:31 +01:00
Daniel Huigens
b6edfe646b Lint all tests (#1235) 2021-02-12 23:00:22 +01:00
Daniel Huigens
8f8517702e Remove Travis badge 2021-02-12 21:29:24 +01:00
Daniel Huigens
4bff80bc9c Switch to karma-mocha-reporter 2021-02-12 21:13:39 +01:00
Daniel Huigens
ce983e5a2d Switch from Travis to GitHub Workflows (#1234) 2021-02-12 21:13:19 +01:00
Daniel Huigens
01be7b7ec1
CI: Switch to karma for browser tests (#1233)
This should fix the false positives (failures to detect errors).
2021-02-12 13:29:04 +01:00
larabr
051f5ec8cf
BigInteger: throw if modular inverse doesn't exist (#1228) 2021-02-10 14:23:59 +01:00
larabr
ca092c7cd0 Speed up decryptKey and encryptKey (#1192)
Change `openpgp.decryptKey` and `openpgp.encryptKey` to avoid deep cloning the
original key.
2021-02-09 19:25:20 +01:00
larabr
66c06dab3e Check if any (sub)key is decrypted in Key.prototype.isDecrypted (#1182)
`key.isDecrypted()` now returns true if either the primary key or any subkey
is decrypted.

Additionally, implement `SecretKeyPacket.prototype.makeDummy` for encrypted
keys.
2021-02-09 19:25:20 +01:00
larabr
c23ed58387 Require User IDs to be objects; refactor UserIDPacket (#1187)
- `openpgp.generateKey` now expects `userIds` in object format
  (strings are no longer supported)
- Remove `util.parseUserId` and `util.formatUserId`
- Replace `UserIDPacket#format` with `UserIDPacket.fromObject`
2021-02-09 19:25:20 +01:00
larabr
724775816f Add explicit key type parameter in openpgp.generateKey (#1179)
- Changes `openpgp.generateKey` to accept an explicit `type` parameter,
  instead of inferring its value from the `curve` or `rsaBits` params
- Introduces `config.minRsaBits` to set minimum key size of RSA key generation
2021-02-09 19:25:20 +01:00
larabr
92887a0948 Revert to disabling AEAD encryption by default (#1190) 2021-02-09 19:25:20 +01:00
larabr
801430f969 Revert to generating v4 keys by default (#1189) 2021-02-09 19:25:20 +01:00
larabr
2ee36c2984 Drop inconsistent boolean returns and fix type definitions (#1191)
- Remove the boolean return value of various internal functions that throw on
  error (the returned value was unused in most cases)
- Update and fix type definitions
2021-02-09 19:25:20 +01:00
larabr
89f738da45 Fix EOL in streaming tests 2021-02-09 19:25:20 +01:00