Commit Graph

685 Commits

Author SHA1 Message Date
Tom J
c5aa647e31 Add TypeScript definitions (#1186) 2021-02-09 19:25:20 +01:00
Daniel Huigens
4c15724caf Appease linter 2021-02-09 19:25:20 +01:00
Daniel Huigens
c2146ce165 Fix CI for older environments 2021-02-09 19:25:20 +01:00
Daniel Huigens
2382482090 [v5] Unexport openpgp.util, openpgp.crypto, and low-level types (#1175) 2021-02-09 19:25:20 +01:00
larabr
479d826533 Remove armor comment and version by default (#1170) 2021-02-09 19:25:20 +01:00
Daniel Huigens
86238e714e Remove unused functions in tests
These functions are unused since e83bc4b4.
2021-02-09 19:25:20 +01:00
Dan Ristea
331a0c27a9 Store named signature parameters (#1158)
Also, remove the now-unnecessary MPI type.
2021-02-09 19:25:20 +01:00
Dan Ristea
400ae63c5e Fix minor JSDoc and style issues (#1156) 2021-02-09 19:25:20 +01:00
Daniel Huigens
a620fc0276 Don't use unexported low-level functions in tests 2021-02-09 19:25:20 +01:00
Daniel Huigens
b3e08fdc26 Don't export default objects / namespaces
Import individual functions, instead.
2021-02-09 19:25:20 +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
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
Wiktor Kwapisiewicz
fe2949f16d Allow parsing keys without User IDs (#1146) 2021-02-09 19:25:20 +01:00
larabr
8d67af729a Use higher level functions in key validation tests (#1128)
Use `key.keyPacket.validate` instead of `crypto.publicKey.validateParams`, see
https://github.com/openpgpjs/openpgpjs/pull/1116#discussion_r447781386.

Also, `key.decrypt` now only throws on error, no other value is returned.

Also, fix typo (rebase error) that caused tests to fail in Safari for p521.
2021-02-09 19:25:20 +01:00
Dan Ristea
10aa1aa5cb JSdoc types & ESLint fixes (#1132) 2021-02-09 19:25:20 +01:00
larabr
f6ee6e959e Finish merging key validation 2021-02-09 19:25:20 +01:00
Daniel Huigens
6a607c7567 Rename SymEncryptedAEADProtectedDataPacket to AEADEncryptedDataPacket 2021-02-09 19:25:20 +01:00
Daniel Huigens
aea7aa953a Use ES6 classes 2021-02-09 19:25:20 +01:00
Daniel Huigens
fb3d23427d Allow dead code elimination 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
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
Daniel Huigens
0e33e641af Switch build system to rollup
Also, default to minimized builds.
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
Ilya Chesnokov
d415bc2546 Rename config option names to camelCase (#1088) 2021-02-09 19:25:20 +01:00
Daniel Huigens
63b6d215e3 Allow key.validate() to pass if it has a GNU dummy primary key
A valid signing subkey is required, in this case.
2021-02-09 19:25:20 +01:00
larabr
8823603396 Remove worker (#1072) 2021-02-09 19:25:20 +01:00
larabr
85d0358d45 Remove 3DES and CAST5 from default preferred symmetric algorithms (#1068) 2021-02-09 19:25:20 +01:00
larabr
20950e5df5 Remove SHA-1 from default preferred hash algorithms (#1067)
Also, remove SHA-1 from the (unused) KDF params constructor defaults.
2021-02-09 19:25:20 +01:00
larabr
5ad19c8da8 Generate ECC keys by default (#1065)
Also, remove the deprecated numBits options of generateKey in favor of rsaBits.
2021-02-09 19:25:20 +01:00
larabr
4c93abb9f9 Use V5 keys by default (#1063) 2021-02-09 19:25:20 +01:00
larabr
a7640bce52 Use AEAD protection by default (#1062) 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
3817cca3c6 Throw on unarmored messages with garbage data appended 2021-02-09 19:25:20 +01:00
Daniel Huigens
76a8f11780 Don't mutate key in openpgp.encryptKey/decryptKey 2021-02-09 19:25:20 +01:00
Daniel Huigens
9394fec1f4 Throw in openpgp.initWorker if worker failed to load 2021-02-09 19:25:20 +01:00
Daniel Huigens
29f29f6c6e Unit tests: Fix autoscroll with skipped tests 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
a9a9a90ae2 Skip test for OpenPGP.js inside an application worker in old Edge
Old Edge doesn't support crypto.getRandomValues inside a Worker.
2021-02-09 19:25:20 +01:00
Daniel Huigens
3a84442b5f Don't use native streams in old Edge 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
37d30c5003 Return strings in Node streams where appropriate 2021-02-09 19:25:20 +01:00
Daniel Huigens
95eb43a3c2 Return data instead of message in encryptSessionKey
Add `armor=true/false` parameter to decide whether `data` is an armored
String or an unarmored Uint8Array.
2021-02-09 19:25:20 +01:00
Daniel Huigens
08d6b276e3 Return data as string in openpgp.verify by default
Add format='utf8'/'binary' param to openpgp.verify in order to be able
to return binary data instead.
2021-02-09 19:25:20 +01:00
Daniel Huigens
7225251af8 Return Uint8Array(Stream) instead of object when armor = false 2021-02-09 19:25:20 +01:00
larabr
38ec5314d4 Fix ElGamal param range and PKCS1 decoding (#1169)
* Fix ElGamal sampling range

* Stricter PKCS1 decoding
2021-01-20 14:09:52 +01:00
larabr
08fc7b32ca
Fix and test dummy key conversion (#1172)
Keys converted using makeDummy() were not serialised correctly as they were
treated as unencrypted keys.
2020-11-10 17:32:44 +01:00
larabr
2eab8a1ebc
Add config option to allow insecure decryption with RSA signing keys (#1148) 2020-08-28 16:09:56 +02:00