Commit Graph

108 Commits

Author SHA1 Message Date
Daniel Huigens
1101a05b10 Don't return streams inside unarmored generated keys and signatures
When not requested, we convert the streams to Uint8Arrays.

This makes the generated key safe to pass to a Worker more than once.

Partially reverts 735aa1da.
2018-08-14 16:35:36 +02:00
Daniel Huigens
2b30ab9c8f Replace data with message parameter in encrypt() and sign()
When encrypting/signing a stream, this allows you to indicate whether it's a
stream of Strings or Uint8Arrays (using message.fromText or message.fromBinary,
respectively.)

When signing text, this allows you to control whether to create a cleartext
message or a regular armored text message.

When creating a detached signature, it allows you to control whether it's "meant
for" (verifying against) a cleartext message. A cleartext message has trailing
whitespace trimmed before signing. This fixes the case of passing a detached
signature from sign() to encrypt(). Since encrypt() doesn't create a cleartext
message, the signature would be invalid if the text contained lines with
trailing whitespace.
2018-08-10 14:46:29 +02:00
Daniel Huigens
4e749965f2 Remove support for V3 keys and signatures 2018-08-10 14:46:26 +02:00
Daniel Huigens
37014ecf30 Pass more tests
- Allow leading spaces in headers (since we were already accepting
leading spaces everywhere else in the armored text).
- Read ReadableStreams before passing them to a Worker
2018-08-10 14:44:01 +02:00
Daniel Huigens
0372bf78f1 Make (de)armoring and packet reading asynchronous 2018-08-10 14:44:01 +02:00
Daniel Huigens
15e6f0d654 Replace get(Sub)KeyPackets with get(Sub)Keys 2018-07-19 15:03:25 +02:00
Daniel Huigens
91b7165b78 Add key/subKey.getKeyId, getFingerprint, getAlgorithmInfo, getCreationTime, isDecrypted 2018-07-19 15:03:25 +02:00
Daniel Huigens
8cfe817b18 Remove getEncryptionKeyPacket and getSigningKeyPacket
Also, rename subKey.subKey to keyPacket and alias key.primaryKey as keyPacket.
2018-07-19 13:31:03 +02:00
Daniel Huigens
a49276a158 Allow checking expiry of subkeys by capability, keyId or userId 2018-07-18 14:40:28 +02:00
Sanjana Rajan
53f473bfa7
Merge pull request #734 from twiss/key-revocation
Key revocation
2018-07-13 17:46:48 +02:00
Daniel Huigens
3fd0fa8f68 Various key revocation fixes 2018-07-13 17:45:09 +02:00
Sanjana Rajan
76f583902e name fixes 2018-07-12 15:05:08 +02:00
Sanjana Rajan
8865103e17
Merge pull request #733 from wiktor-k/fix-primary-uid
Fix Key#getPrimaryUser on keys without valid UIDs
2018-07-12 15:03:01 +02:00
Wiktor Kwapisiewicz
c3d4bf3529
Fix Key#getPrimaryUser on keys without valid UIDs
During tests of weird keys [0] it was found out that OpenPGP.js does not
handle keys without valid UIDs well.

There are two issues that this change corrects, first one is adding
filtering of user IDs in `getPrimaryUser` such as only users with self
certifications are considered. Without that change using
`getPrimaryUser` on a key without valid UIDs would throw an exception
(`Cannot read property 'verified' of undefined` [1]).

Second issue is correcting condition whether to throw if no UID was
found. Previous condition checked for `userId` variable, but this is
initialized by default and as such is almost always set. This causes
`key.getPrimaryUser()` (without condition) to throw `Could not find user
that matches that user ID`. The condition has been modified to match the
filter condition (checking if any property of `userId` has been
initialized).

[0]: https://gitlab.com/sequoia-pgp/weird-keys/tree/master/openpgpjs

[1]: 576ed08a54/openpgpjs/results/no-bound-uid.pgp.txt
2018-07-12 14:04:07 +02:00
Daniel Huigens
1ed7943bf9 Create openpgp.revokeKey 2018-07-11 17:57:31 +02:00
Daniel Huigens
368d80245a Subkey revocation 2018-07-11 17:46:49 +02:00
Daniel Huigens
a3484c3116 Key revocation 2018-07-11 17:45:59 +02:00
Sanjana Rajan
1bb86231af camel case some variables 2018-07-11 16:53:12 +02:00
Maximilian Krambach
11029e4162 Key merging with non-UserID user attribute
fix #678
2018-07-09 16:53:55 +02:00
Daniel Huigens
887e832635 Throw when user ID matches no users 2018-05-03 13:04:32 +02:00
Daniel Huigens
fe3c1b4f31 Add fromUserId / toUserId parameters to openpgp.encrypt and sign
To select the user whose algorithm preferences, expiration time etc to use.
2018-05-01 13:39:23 +02:00
Daniel Huigens
6c2fec3450 Parse user IDs
Also, support comments when creating user IDs
2018-05-01 13:39:23 +02:00
Daniel Huigens
49c9fb193d Only call webCrypto.generateKey once in tests 2018-04-30 16:58:39 +02:00
Daniel Huigens
0376f49e01 Deduplicate getPreferredSymAlgo / getPreferredAEADAlgo 2018-04-30 15:55:35 +02:00
Daniel Huigens
e24b46192d Only AEAD-protect when target keys support it 2018-04-27 14:06:18 +02:00
Daniel Huigens
28dbbadcff Add config.aead_protect_version option 2018-04-27 14:06:17 +02:00
Daniel Huigens
997ec1c8db Add AEAD feature flags 2018-04-27 14:06:17 +02:00
Daniel Huigens
5f97a8c937 Implement preferred AEAD algorithms 2018-04-27 14:06:16 +02:00
Daniel Huigens
c2f898279b Implement version 5 Secret-Key Packet Format 2018-04-27 14:06:14 +02:00
Daniel Huigens
122d526f49 Only consider most recent subkey binding signature
This partially reverts 2bda127.
2018-04-18 14:40:06 +02:00
Sanjana Rajan
e4bd27ce2f tests 2018-04-16 10:51:07 -07:00
Sanjana Rajan
2f351985c4 tests 2018-03-19 18:55:30 -07:00
Sanjana Rajan
75cd4e5e6f some fixes, add expired key test 2018-03-17 07:32:56 -07:00
Sanjana Rajan
38508b33d1 if primary key is invalid, so are subkeys 2018-03-12 23:23:03 +01:00
Sanjana Rajan
a94ca90653 add test for key revoked with cert, no revoked subkeys 2018-03-12 23:16:41 +01:00
Mahrud Sayrafi
6fefe22c09 Finished fixing key.js; fixes async tests 2018-03-08 10:01:55 +01:00
Mahrud Sayrafi
0b2817ba39 Last little things become async ... 2018-03-08 10:01:55 +01:00
Mahrud Sayrafi
47006069d1 Added test for encryption with revoked subkey 2018-03-08 10:01:54 +01:00
Mahrud Sayrafi
73a240df6c Simplifies (Key|User|SubKey).isRevoked, API changes in key.js
For User s/revocationCertifications/revocationSignatures/g
For Key/SubKey s/revocationSignature/revocationSignatures/g is now an array.
2018-03-08 10:01:54 +01:00
Mahrud Sayrafi
ec22dabac3 Slightly simplifies key.js; adds key.verifyKeyPackets which should be run before getEncryption/SigningKeyPacket 2018-03-08 10:01:54 +01:00
Bart Butler
f57888fe55 change all calls of getRandomBytes and getRandomBN to be async 2018-03-05 16:31:56 -08:00
BafS
b672f1936a Use let and const ES6 features.
Remove var, for let or const if possible, clean some syntax, enforce one var per declaration and semicolons
2018-02-13 23:33:09 +01:00
BafS
de6ffc2f76 Remove 'user strict'
'use strict' is unnecessary inside modules because module code is always strict mode code. Ref: https://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code
2018-02-13 23:33:09 +01:00
Sanjana Rajan
d5022a3a4a rename vars in old tests 2018-02-12 09:47:51 +01:00
Sanjana Rajan
85f115f889 tests 2018-02-09 16:18:46 +01:00
Mahrud Sayrafi
d02b9c7bf0 Fixes problems with user certificate verification.
TODO: if using lower level functions, key.verifyPrimaryUser() MUST be
called and resolved before calling key.getSigning/EncryptionKeyPacket(),
key.getPrimaryUser(), etc.

Also: adds a flag to allow verification with expired keys from:
(cherry picked from commit b9d175d998)
(cherry picked from commit 50940b2a1e)
2018-01-30 18:36:37 +01:00
Mahrud Sayrafi
e6820d7b2a Passing all tests, on Node, Firefox, and Chrome 2018-01-30 18:34:28 +01:00
Mahrud Sayrafi
1a714cec73 ECC with async/await is 'Done, without errors.' 2018-01-30 18:33:55 +01:00
Sanjana Rajan
26de17150c use internal aes encrypt in key wrap, start refactoring aes to do decryption as well 2018-01-30 18:30:16 +01:00
Sanjana Rajan
3b8cea67a2 some style fixes, update tests 2018-01-30 18:30:15 +01:00