Commit Graph

162 Commits

Author SHA1 Message Date
larabr
3886358592
Remove valid and error from the verification result of openpgp.verify and decrypt (#1348)
This change is to make the code more consistent between the streaming and
non-streaming cases.
The validity of a signature (or the corresponding verification error) can be
determined through the existing `verified` property.
2021-07-09 17:44:34 +02:00
larabr
40542fd08a
Simplify return value of generateKey, reformatKey and revokeKey and add support for binary output (#1345)
- `openpgp.generateKey`, `reformatKey` and `revokeKey` take a new `format`
option, whose possible values are: `'armor', 'binary', 'object'` (default is 
`'armor'`).
- `generateKey` and `reformatKey` now return an object of the form `{
publicKey, privateKey, revocationCertificate }`, where the type of `publicKey`
and `privateKey` depends on `options.format`:
    * if `format: 'armor'` then `privateKey, publicKey` are armored strings;
    * if `format: 'binary'` then `privateKey, publicKey` are `Uint8Array`;
    * if `format: 'object'` then `privateKey, publicKey` are `PrivateKey` and
`PublicKey` objects respectively;
- `revokeKey` now returns `{ publicKey, privateKey }`, where:
    * if a `PrivateKey` is passed as `key` input,  `privateKey, publicKey` are of the
requested format;
    * if a `PublicKey` is passed as `key` input, `publicKey` is of the requested format,
while `privateKey` is `null` (previously, in this case the `privateKey` field
was not defined).

Breaking changes:
- In `revokeKey`, if no `format` option is specified, the returned `publicKey,
privateKey` are armored strings (they used to be objects).
- In `generateKey` and `reformatKey`, the `key` value is no longer returned.
- For all three functions, the `publicKeyArmored` and `privateKeyArmored`
values are no longer returned.
2021-06-24 17:14:39 +02:00
Ali Cherry
ab7dedf0a5
Update README to reflect parameter name changes (#1323)
Also, update the detached sign/verify example to use a Message rather
than a CleartextMessage.
2021-06-08 13:08:53 +02:00
Daniel Huigens
12e5c96607
Update BrowserStack status badge key 2021-06-01 17:07:11 +02:00
Yash Murty
3349fab89e
Fix link in README's table of contents (#1307) 2021-05-21 18:07:52 +02:00
Daniel Huigens
93b77669bc
Unexport openpgp.stream (#1291)
This change allows us to only load the `ReadableStream` polyfill when
needed without behaving inconsistently in the external API.

Users of the library should use the global `ReadableStream` or Node.js
`stream.Readable` instead, or import a polyfill if needed. This patch
loosens the detection criteria such that polyfilled streams are better
detected.
2021-05-05 20:20:20 +02:00
larabr
0654bbe505
Remove Key.prototype.encrypt() and Key.prototype.decrypt() (#1285)
To encrypt/decrypt a key, the top-level functions `openpgp.encryptKey` and
`openpgp.decryptKey` should be used instead: these don't mutate the key;
instead, they either return a new encrypted/decrypted key object or throw an
error.

With `Key.prototype.encrypt` and `decrypt`, which mutated the key, it was
possible to end up in an inconsistent state if some (sub)keys could be
decrypted but others couldn't, they would both mutate the key and throw an
error, which is unexpected.

Note that the `keyID` parameter is not supported by `encryptKey`/`decryptKey`,
since partial key decryption is not recommended. If you still need to decrypt
a single subkey or primary key `k`, you can call `k.keyPacket.decrypt(...)`,
followed by `k.keyPacket.validate(...)`. Similarly, for encryption, call
`k.keyPacket.encrypt(...)`.

Additionally, `openpgp.generateKey` now requires `options.userIDs` again,
since otherwise the key is basically unusable. This was a regression from v4,
since we now allow parsing keys without user IDs (but still not using them).
2021-04-23 15:43:38 +02:00
larabr
2e19f1401c
Add expectSigned option to openpgp.decrypt and openpgp.verify (#1275)
If `expectSigned` is set:
- `openpgp.decrypt` throws immediately if public keys or signatures are
  missing, or if the signatures are invalid and streaming is not used.
- `openpgp.verify` throws immediately if signatures are missing, or if the
  signatures are invalid and streaming is not used.
- If the signatures are invalid and streaming is used, reading the returned
  data stream will eventually throw.
2021-03-31 14:24:29 +02:00
will Farrell
5016cd5677
Fix streaming verification example in README (#1269) 2021-03-29 15:46:02 +02:00
Daniel Huigens
91bd9e2c15 Replace Message.fromText and Message.fromBinary with createMessage
Also, replace CleartextMessage.fromText with createCleartextMessage.
2021-03-26 10:56:02 +01:00
Daniel Huigens
18ec54bf4b Fetch Streams ponyfill on demand in lightweight build 2021-03-26 10:56:02 +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
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
43f0724aeb Move HKP client to openpgpjs/hkp-client 2021-02-28 22:59:16 +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
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
Daniel Huigens
8f8517702e Remove Travis badge 2021-02-12 21:29:24 +01:00
Daniel Huigens
f276e1ef51 Export key, message, signature, cleartext functions and classes directly
Instead of as modules.

Replace *.read with read*, *.readArmored with readArmored*, etc.
Replace cleartext.readArmored with readArmoredCleartextMessage.
Replace message.fromText with Message.fromText, etc.
2021-02-09 19:25:20 +01:00
Daniel Huigens
6516602d7b Add shortcut to import 'openpgp/lightweight' 2021-02-09 19:25:20 +01:00
Daniel Huigens
f3b16386dc Use dynamic import in lightweight build
Instead of dynamically loading a <script> tag.

This also removes the non-module lightweight build.
2021-02-09 19:25:20 +01:00
Daniel Huigens
4edd85be69 Drop Node.js 8 support and Travis test
It should still work, but we can no longer test it
because rollup requires Node.js 10+.

Also, remove "allowed failures".
2021-02-09 19:25:20 +01:00
Daniel Huigens
175eac5670 Remove compat polyfills 2021-02-09 19:25:20 +01:00
Daniel Huigens
0c5598a0fc Replace remaining grunt tasks with npm scripts 2021-02-09 19:25:20 +01:00
Ilya Chesnokov
6e648b1cbc Rename enums to use camelCase (#1093) 2021-02-09 19:25:20 +01:00
Ilya Chesnokov
e16807505f Switch util function names to camelCase (#1091) 2021-02-09 19:25:20 +01:00
larabr
8823603396 Remove worker (#1072) 2021-02-09 19:25:20 +01:00
Daniel Huigens
2bc24f354b Return only one key in key.read[Armored], add readAll[Armored] 2021-02-09 19:25:20 +01:00
Daniel Huigens
ef7c38860b Don't unnecessarily return objects in top-level functions
openpgp.encrypt, sign, encryptSessionKey, encryptKey and decryptKey now
return their result directly without wrapping it in a "result" object.

Also, remove the `detached` and `returnSessionKey` options of
openpgp.encrypt.
2021-02-09 19:25:20 +01:00
Daniel Huigens
2fffc76060 Don't overwrite Web Streams Polyfill to globals
Instead, use the ponyfill that's now included in web-stream-tools.
Also, convert back to native ReadableStream when we used the ponyfill.
2021-02-09 19:25:20 +01:00
chenlhlinux
b76c67aba8
Fix signature verification examples in the README (#1058) 2020-03-12 20:13:22 +01:00
Stig P
21c7d69f56
Fix typo in symmetric encryption example in README.md (#1042) 2020-02-03 15:10:19 +01:00
Daniel Huigens
e14a3c78b7 Add instructions to pipe unarmored encrypted data on Node.js 2020-02-02 16:51:01 +01:00
Daniel Huigens
b49e787ba9 Update setup instructions 2020-02-02 16:51:01 +01:00
Daniel Huigens
7000d9db4b Clean up README.md 2020-02-02 16:51:01 +01:00
Daniel Huigens
fbbeaa3cd9
Rename numBits and bits to rsaBits (#970)
Keep supporting the old names as well though in `openpgp.generateKey`
and `getAlgorithmInfo`, but not in `openpgp.key.generate` (as it is
recommended that developers use `openpgp.generateKey` instead, and
it now throws when using `numBits` instead of `rsaBits`, so there's
no risk of silent key security downgrade).

The old names are now deprecated, and might be removed in v5.
2019-09-18 13:40:44 +02:00
Daniel Huigens
9b5124d5cd
Switch from Sauce Labs to Browserstack (#965)
* Switch from Sauce Labs to Browserstack

* Don't run all tests on CI
2019-09-16 14:59:06 +02:00
Daniel Huigens
8f54c00fd3 Bump link to draft spec in README.md 2019-08-12 17:46:37 +02:00
Daniel Huigens
a184ef6ec4 Remove support for the previous draft00 AEAD 2019-08-12 17:46:37 +02:00
Remy
b035f2ea46 Fix nodejs API crypto link (#909) 2019-06-07 14:57:09 +02:00
Daniel Huigens
34e6eacb2f Don't attempt to use workers if they fail to load 2019-05-02 12:08:08 +02:00
rash0
3edc6e7501 ++ Add another Domain for HKP server (#855)
* ++ Add another Domain for HKP server

the pgp.mit.edu domain is most of the time down and responds with time out...so i discovered this ubuntu domain for the same database...but its much faster and never falls....i think too much traffic over the bit one :(

* Update hkp.js

* Change HKP server url

* Defined the default HKP server

* Update README.md

Co-Authored-By: rash0 <40761345+rash0@users.noreply.github.com>

* ++ Add revocation certificate test

didn't know if i should use the revocation certificate in the test/key.js file or generate a new one...so i generated a test one and used it...
2019-02-11 11:33:24 +01:00
Chris Cunningham
bd964334cd
Update README.md: Fix error
I was seeing this error: 

```
index.js:29
            message: await openpgp.message.readArmored(encrypted),    // parse armored message
                           ^^^^^^^
```

And I think it's because the async was missing.
2019-01-15 20:51:30 -08:00
Ben Holden-Crowther
53237392f2
Added link to license for informational purposes 2019-01-09 12:03:49 +00:00
Ben Holden-Crowther
e52504b0fd
Removed broken links
Removed broken links in readme
2019-01-05 21:30:21 +00:00
Ben Holden-Crowther
fe3c9a0602
grammar improvement
built-in vs builtin
2019-01-03 14:24:47 +00:00
Daniel Huigens
9b7a9d7a41
Add links to Gitter 2018-12-18 15:36:00 -05:00
Meitar M
cd61531b41
Fix revocation example in README, use revocationCertificate.
There is no longer any `revocationSignature` member of OpenPGP.js `key`
objects, and the `options` object passed to the `revokeKey()` method no
longer accepts a `revocationSignature` member, either. These have been
changed to `revocationCertificate`, so this commit updates the examples
that use this part of the API to reflect the current implementation.
2018-12-15 15:14:40 -05:00
Daniel Huigens
08f48bfc2c Switch to seek-bzip 2018-11-05 12:49:53 +01:00
nickmi
cdec95cb21
Update README.md 2018-10-23 23:05:24 +03:00