Commit Graph

131 Commits

Author SHA1 Message Date
Daniel Huigens
b3e08fdc26 Don't export default objects / namespaces
Import individual functions, instead.
2021-02-09 19:25:20 +01:00
larabr
3a75eadaa0 Store named key params in key objects (#1141)
- Store private and public params separately and by name in objects,
  instead of as an array

- Do not keep params in MPI form, but convert them to Uint8Arrays when
  generating/parsing the key

- Modify low-level crypto functions to always accept and return
  Uint8Arrays instead of BigIntegers

- Move PKCS1 padding to lower level functions
2021-02-09 19:25:20 +01:00
larabr
8854b097b4 Use native BigInt when available instead of bn.js (#1119)
In the lightweight build, lazily load bn.js only when necessary.

Also, use Uint8Arrays instead of strings in PKCS1 padding functions, and
check that the leading zero is present when decoding EME-PKCS1 padding.
2021-02-09 19:25:20 +01:00
Dan Ristea
10aa1aa5cb JSdoc types & ESLint fixes (#1132) 2021-02-09 19:25:20 +01:00
Daniel Huigens
cde282d4f1 Replace 'global' with 'globalThis' 2021-02-09 19:25:20 +01:00
Daniel Huigens
0e33e641af Switch build system to rollup
Also, default to minimized builds.
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
Ilya Chesnokov
d415bc2546 Rename config option names to camelCase (#1088) 2021-02-09 19:25:20 +01:00
larabr
8823603396 Remove worker (#1072) 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
Daniel Huigens
5d71ae8691 Fix normalizing \n after \r\n
Broken in c4a7455.
2020-04-22 19:09:50 +02:00
Daniel Huigens
c4a7455cb5 Fix memory usage when non-streaming-en/decrypting large files
Broken in #1071.
2020-04-20 18:05:07 +02:00
larabr
e39216424f Drop support for \r as EOL (#1073) 2020-04-20 18:05:07 +02:00
larabr
6119dbb08e
Support verification of text signatures on non-UTF-8 messages (#1071) 2020-03-30 12:51:07 +02:00
Daniel Huigens
2ff4fbb0e8 Optimize base64 encoding and decoding 2020-02-25 15:06:38 +01:00
Daniel Huigens
8c3bcd1f21 Reject signatures using insecure hash algorithms
Also, switch from returning false to throwing errors in most verify*()
functions, as well as in `await signatures[*].verified`, in order to be
able to show more informative error messages.
2020-02-25 15:06:15 +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
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
Ilya Chesnokov
528fbfb017 Switch back to using upstream email-address library (#998) 2019-10-25 13:25:03 +02:00
Daniel Huigens
192893ecf0 Fix util.Uint8Array_to_b64 to not return lone \r characters 2019-10-15 14:24:58 +02:00
Ilya Chesnokov
5d9629d6a3 Style fixes; add spaces around all infix operators, remove new Buffer (#954)
* Add "space-infix-ops": "error" rule

* Remove deprecated Buffer constructor

* Resolve new-cap eslint rule

* @twiss: Clarify code that selects curve and algorithm
2019-08-30 12:27:30 +02:00
Ilya Chesnokov
a0e9c608ba DSA: Fix intermittent generation of invalid signatures (#938) 2019-08-07 17:42:55 +02:00
Ilya Chesnokov
29d67415e2 Accept @ in User ID names (#930) 2019-07-18 15:45:54 +02:00
Ilya Chesnokov
6d626ea70c Style fixes and new style rules for eslint (#919) 2019-06-28 15:33:18 +02:00
Sam
c7fb8d8fe7 Node detection: base on process instead of window (#911) 2019-06-21 15:43:56 +02:00
Daniel Huigens
df8364930b Fix one-pass signature verification when using a Worker 2019-05-03 18:40:31 +02:00
Si Feng
d2c38693f5 Put comment before email when generating UIDs (#892) 2019-05-01 13:12:52 +02:00
Daniel Huigens
d91b064e14 Optimize util.removeTrailingSpaces (#848)
Backtracking regexes have pathological worst-case performance when
a long line contains a large amount of whitespace not followed by
a newline, since the regex engine will attempt to match the regex
at each whitespace character, read ahead to the non-whitespace non-
newline, declare no match, and try again at the next whitespace.

E.g. try running

    util.removeTrailingSpaces(new Array(1e6).join(' ') + 'a').length

which would hang V8.
2019-01-27 00:22:47 +00:00
Daniel Huigens
77055f6dfe Don't zero-copy transfer buffers in Safari 11.1 and Chrome < 56
See https://bugs.webkit.org/show_bug.cgi?id=184254
and https://bugs.chromium.org/p/chromium/issues/detail?id=334408.
2019-01-15 20:16:59 +01:00
Daniel Huigens
fe69cb882d Zero-copy transfer buffers when passing streams to workers 2019-01-09 15:18:59 +01:00
Daniel Huigens
625c6ea4b3 Zero-copy transfer buffers from the worker to the main thread 2019-01-09 15:18:56 +01:00
Sanjana Rajan
37bc379663
Merge pull request #828 from tomholub/patch-1
Fix various JSDoc typos etc
2019-01-03 06:55:42 -08:00
Sanjana Rajan
9b599c86b2
Merge pull request #827 from estelendur/double_is_readonly
Double is readonly
2019-01-02 15:15:22 -08:00
Daniel Huigens
5c5da1d86f Fix passing streams to workers in Safari 9
Safari 9 does not expose the MessagePort object in workers
(but does expose it on window, and also exposes MessageChannel
in workers).
2019-01-02 14:07:36 +01:00
Tom J
1054ed46d8
Fix util.js jsdoc Uint8Array typos 2018-12-29 11:44:26 +00:00
Esty Thomas
08fdb351d1
Renames var to prevent "double is read-only" error
Under some build systems, the function `double` produces an error:
```SyntaxError: "double" is read-only"```
The error goes away if the variable named `double` inside the function
named `double` is renamed. This commit renames it to `double_var` for
simplicity's sake.
2018-12-27 12:27:42 -05:00
Daniel Huigens
9691dc9c99 Fix getExpirationTime with capabilities and an expired signing subkey
When the latest subkey with the requested capabilities is expired,
and the primary key has the requested capabilities, return the
primary key expiry instead.

Also, change isExpired/isDataExpired to still return false at the
date returned by getExpirationTime, so that the latter returns the
last date that the key can still be used.
2018-12-21 12:49:22 -05:00
Daniel Huigens
a250ee9f91 Clean up checksum calculation 2018-11-01 14:47:22 +01:00
Daniel Huigens
baaa0716b4 Fix performance issue with handling large messages 2018-10-19 15:09:33 +02:00
Daniel Huigens
00a2c0c0c2 Support unicode surrogate code points 2018-08-14 17:24:40 +02:00
Daniel Huigens
52c4fa9639 Move streams library to a separate package 2018-08-14 16:35:40 +02:00
Daniel Huigens
252da44419 Don't depend on util in stream.js 2018-08-14 16:35:40 +02:00
Daniel Huigens
29271accef Enable Transferables in IE11
Reverts 11ff845c.
2018-08-14 16:35:40 +02:00
Daniel Huigens
c75e2323c0 Support IE11 for streaming 2018-08-14 16:35:39 +02:00
Daniel Huigens
721e522b17 Don't increase buffering in transformWithCancel
Keep backpressure the same as in default TransformStream().
2018-08-14 16:35:39 +02:00
Daniel Huigens
d844b8b06c Add minimum AEAD buffer size
This enables parallelism for streaming AEAD chunked encryption.

The reason we can't do so at the very end of the pipe chain
(e.g., in `readToEnd`) is because requests for increased
buffering (i.e. `desiredSize > 1`) do not propagate backwards,
only requests for backpressure (i.e. `desiredSize <= 0`) do.
2018-08-14 16:35:39 +02:00
Daniel Huigens
ca537e439d Comments & code style 2018-08-14 16:35:38 +02:00
Daniel Huigens
0cabf72682 Add TextDecoder polyfill 2018-08-10 14:46:27 +02:00
Daniel Huigens
4d82d25559 Pass more tests
We now use streams internally in more places.
2018-08-10 14:46:26 +02:00