Commit Graph

2011 Commits

Author SHA1 Message Date
Daniel Huigens
09e818763e Release new version 2020-01-24 20:05:16 +01:00
Daniel Huigens
786d909f79 Fix worker tests in compat browsers 2020-01-24 19:16:15 +01:00
Daniel Huigens
e8ee70b2a8 Fix UnhandledPromiseRejectionWarnings in Node.js
These were introduced in 9bdeaa9 by `await`ing Promises later than
they're created.
2020-01-24 18:05:50 +01:00
Daniel Huigens
382c05df6f Remove accidental .only in test suite 2020-01-24 17:59:35 +01:00
Daniel Huigens
9bdeaa927a Don't keep entire decrypted message in memory while streaming
(When config.allow_unauthenticated_stream is set or the message is
AEAD-encrypted.)

The issue was that, when hashing the data for verification, we would
only start hashing at the very end (and keep the message in memory)
because nobody was "pulling" the stream containing the hash yet, so
backpressure was keeping the data from being hashed.

Note that, of the two patches in this commit, only the onePassSig.hashed
property actually mattered, for some reason. Also, the minimum
highWaterMark of 1 should have pulled the hashed stream anyway, I think.
I'm not sure why that didn't happen.
2020-01-24 17:58:17 +01:00
Daniel Huigens
6e13604a64 Replace 'window' with 'global'
In order to use Web Crypto in application workers, among other things.
2020-01-24 17:58:04 +01:00
Daniel Huigens
81d6b45ba8 Test loading OpenPGP.js from a Worker in the application 2020-01-24 17:58:04 +01:00
Daniel Huigens
66acd979bf Clear worker key caches in openpgp.destroyWorker() 2020-01-24 17:57:39 +01:00
Daniel Huigens
fb666f0624 Implement openpgp.getWorker().clearKeyCache() 2020-01-24 17:57:39 +01:00
Daniel Huigens
523432334f Implement Key.prototype.clearPrivateParams 2020-01-24 17:57:39 +01:00
Daniel Huigens
26d107b856 Zero out private key parameters in clearPrivateParams 2020-01-24 17:57:39 +01:00
Daniel Huigens
889e0c4930 Allow calling clearPrivateParams on decrypted keys
Calling it on unencrypted keys was already allowed, so this safety check
didn't do much.
2020-01-24 17:57:39 +01:00
Daniel Huigens
6ae6012786 Terminate workers in openpgp.destroyWorker() 2020-01-24 17:57:39 +01:00
Ilya Chesnokov
94a04eaa5c Switch code coverage reporter to nyc (#1005) 2020-01-15 15:46:37 +01:00
Daniel Huigens
1462affe88 Release new version 2020-01-14 18:10:37 +01:00
Daniel Huigens
44a90d9465
Cache key objects in Workers by armor (#1030)
This allows us to use the cached `verified` property on self-signatures,
so that we don't have to repeatedly verify them.
2020-01-14 18:06:09 +01:00
Daniel Huigens
fd6d7b6088
Remove support for legacy encrypted private keys (#1029)
Both those with a 2-byte hash (instead of SHA1 or an AEAD authentication
tag) and those without an S2K specifier (i.e., using MD5 for S2K) -
support for the latter was already broken.

Vulnerabilities can arise not just from generating keys like this, but
from using them as well (if an attacker can tamper with them), hence why
we're removing support.
2020-01-07 18:17:00 +01:00
Daniel Huigens
8f355a75da
Implement key.validate() (#1028)
This function checks whether the private and public key parameters
of the primary key match.

This check is necessary when using your own private key to encrypt
data if the private key was stored on an untrusted medium, and
trust is derived from being able to decrypt the private key.
2020-01-07 18:16:45 +01:00
Ilya Chesnokov
26502e36cd
update asmcrypto.js (#1023)
update asmcrypto.js to version 2.3.2
2019-12-30 14:14:27 +07:00
Alexandre Perrin
0a32f4d5e7 Comment typo fixes (#1022) 2019-12-27 12:47:37 +01:00
Daniel Huigens
ba944c8948 Release new version 2019-12-20 17:39:24 +01:00
Daniel Huigens
3d75efc1dc
Only throw on authorized revocation key when verifying self-signatures (#1017)
This also has the effect that we only throw on them when trying to use
the key, instead of when parsing it, and that we don't throw when the
authorized revocation key is specified in a separate direct-key
signature instead of a User ID self-signature (the spec only specifies
including it in a direct-key signature, so that means that we
effectively don't reject them anymore. This is because users that
wanted to use the key, could remove this separate signature, anyway.)
2019-12-20 17:21:35 +01:00
Tom J
e1b9156e72 Explicitly include 'uncompressed' in preferred compression algos (#1020) 2019-12-20 17:20:18 +01:00
Daniel Huigens
5a62c4f3c3 Release new version 2019-11-29 11:47:49 +01:00
Daniel Huigens
5a24bc7698 Fix verifying RSA signatures with leading zero in Web Crypto 2019-11-29 11:39:38 +01:00
Daniel Huigens
ad0fdcc4da Fix openpgp.config.use_native = false for RSA sign/verify 2019-11-29 11:39:38 +01:00
Ilya Chesnokov
45c2e67624 Use native Node crypto for RSA encryption (#1006) 2019-11-26 16:06:49 +01:00
Ilya Chesnokov
495fe1091c Apply eslint to test/crypto folder (#1003) 2019-11-19 14:29:32 +01:00
Daniel Huigens
bc16d157f0 Release new version 2019-11-18 20:10:50 +01:00
Daniel Huigens
c70d1500a6 Remove browserify caches when releasing 2019-11-18 20:03:20 +01:00
Daniel Huigens
01b077e59c Don't use sed to edit gitignore in release.sh
sed -i is not cross-platform.
2019-11-18 19:45:03 +01:00
Ilya Chesnokov
6e7f399eb3 Use Web Crypto & Node crypto for RSA signing and verifying (#999)
Also, when generating RSA keys in JS, generate them with p < q, as per
the spec.

Also, when generating RSA keys using Web Crypto or Node crypto, swap the
generated p and q around, so that will satisfy p < q in most browsers
(but not old Microsoft Edge, 50% of the time) and so that we can use the
generated u coefficient (p^-1 mod q in OpenPGP, q^-1 mod p in RFC3447).

Then, when signing and verifying, swap p and q again, so that the key
hopefully satisfies Safari's requirement that p > q, and so that we can
keep using u again.
2019-11-18 14:59:01 +01:00
Daniel Huigens
e20d727d76 Always encrypt keys using AES
Even if they were previously encrypted using another algorithm.
2019-11-18 14:13:48 +01:00
Daniel Huigens
5bf0f96163 Fix encrypting keys using non-AES algorithms 2019-11-18 14:13:48 +01:00
Daniel Huigens
afdacfad7d
Merge pull request #1002 from openpgpjs/iterated-s2k-perf
Improve iterated S2K performance
2019-11-09 01:50:56 +01:00
Daniel Huigens
b0914663dd Iterated S2K: always hash the full salt+password at least once
As per the spec:

   The one exception is that if the octet count is less than
   the size of the salt plus passphrase, the full salt plus passphrase
   will be hashed even though that is greater than the octet count.
2019-11-08 20:15:31 +01:00
Daniel Huigens
6ddfca5f14 Refactor S2K function 2019-11-08 19:45:57 +01:00
Daniel Huigens
cd2bfca519 Optimize iterated S2K 2019-11-08 19:12:58 +01:00
Daniel Huigens
a6d7c466e2 Use serialized EdDSA public key when signing instead of deriving it 2019-11-08 17:10:47 +01:00
Daniel Huigens
fd9371a2a4 Mask curve25519 keys during generation (before serializing them)
This was broken in #922 (merged as part of #956).

This would cause GPG to be unable to parse unencrypted secret keys,
thinking they were encrypted.

rfc4880bis-08 hints at this requirement, saying:

o  MPI of an integer representing the secret key, which is a scalar
   of the public EC point.

Since scalar multiplication happens after masking the private key,
this implies that we should serialize the private key after masking,
as well.
2019-11-07 21:34:07 +01:00
Daniel Huigens
563b397391 Don't mask curve25519 private key twice
Also, fix handling of private keys with leading zeros for certain
curves.
2019-10-25 17:32:43 +02:00
Daniel Huigens
a06bf91f35 Fix queued bytes calculation for AEAD concurrency 2019-10-25 16:14:59 +02:00
Ilya Chesnokov
08b7725b8c Create lightweight build that can lazily load indutny/elliptic if needed (#956)
This PR adds four config options to configure whether and how to load
indutny/elliptic: use_indutny_elliptic, external_indutny_elliptic,
indutny_elliptic_path and indutny_elliptic_fetch_options.

Also:

- Use tweetnacl.js instead of indutny/elliptic for curve25519 key generation

- Don't initialize indutny's curve25519, improving performance when using that curve

- Verify NIST signatures using Web Crypto instead of indutny/elliptic when not streaming

- Move KeyPair.sign/verify to ecdsa.js

- Move KeyPair.derive to ecdh.js

- Move keyFromPrivate and keyFromPublic to a new indutnyKey.js file
2019-10-25 16:07:57 +02:00
Ilya Chesnokov
528fbfb017 Switch back to using upstream email-address library (#998) 2019-10-25 13:25:03 +02:00
descampsk
810b8daab2 Fix crypto.random.getRandomBytes when loading openpgp.js inside a worker (#997) 2019-10-25 13:20:54 +02:00
Ilya Chesnokov
114184c6f2 Split up key.js (#972) 2019-10-15 18:42:14 +02:00
Daniel Huigens
2cc3262149 Fix test failing on high-core-count systems due to AEAD concurrency 2019-10-15 18:38:02 +02:00
Daniel Huigens
3ee77f9e50 AEAD: Fix high water mark calculation based on chunk size
Use current packet's chunk size instead of default chunk size.
2019-10-15 18:24:14 +02:00
Daniel Huigens
192893ecf0 Fix util.Uint8Array_to_b64 to not return lone \r characters 2019-10-15 14:24:58 +02:00
Daniel Huigens
c91fcd684d Fix key preferences test when using Worker and use_native=false 2019-10-15 14:21:05 +02:00