Compare commits

..

2064 Commits
v0.6.2 ... main

Author SHA1 Message Date
dependabot[bot]
88310fe69d
Bump playwright from 1.51.0 to 1.51.1 (#1834)
Bumps [playwright](https://github.com/microsoft/playwright) from 1.51.0 to 1.51.1.
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](https://github.com/microsoft/playwright/compare/v1.51.0...v1.51.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-18 13:56:54 +01:00
dependabot[bot]
c2526c8a88
Tests: bump playwright from 1.50.1 to 1.51.0 (#1831)
Bumps [playwright](https://github.com/microsoft/playwright) from 1.50.1 to 1.51.0.
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](https://github.com/microsoft/playwright/compare/v1.50.1...v1.51.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-07 15:53:39 +01:00
larabr
1848f51a4c
Merge pull request #1829
Re-enable using WebCrypto for X25519 when available.
2025-03-05 11:51:40 +01:00
larabr
4762d2c762 CI: do not test Webkit on Linux
The tests work correctly in Epiphany, but not in the WebKit build,
where the native X25519 implementation throws non-standard errors on
importKey (DataError) and generateKey (OperationError).
Patching this would be simply a matter of catching such errors and falling back
to the JS implementation, but since only the CI WebKit build seems to be
affected, we prefer not to relax fallback checks in the context of crypto
operations without issues reported in the wild.
2025-02-26 13:00:14 +01:00
larabr
d5689894f6 Re-enable using WebCrypto for X25519 when available
Reverting commit ccb040ae96acd127a29161ffaf3b82b5b18c062f .
Firefox has fixed support in v132 (https://bugzilla.mozilla.org/show_bug.cgi?id=1918354)
usage of v130 and 131, which have a broken implementation, is now below 1%.

Also, Chrome has released support in v133.
2025-02-26 12:15:17 +01:00
Carlos Alexandro Becker
6d4a86295e
Make Issuer Key ID signature subpacket non-critical (#1828)
RPM <=4.16 does not support it.

See also:
- https://github.com/ProtonMail/go-crypto/pull/175
- https://github.com/ProtonMail/go-crypto/issues/263
2025-02-26 10:19:25 +01:00
dependabot[bot]
8a2062d342
Bump the noble group with 3 updates (#1825)
Bumps the noble group with 3 updates: [@noble/ciphers](https://github.com/paulmillr/noble-ciphers), [@noble/curves](https://github.com/paulmillr/noble-curves) and [@noble/hashes](https://github.com/paulmillr/noble-hashes).

Also:
* Internal: OCB: do not reuse AES-CBC instance (Noble is now preventing instance reuse).
* Tests: update error message following noble-curve change


Updates `@noble/ciphers` from 1.0.0 to 1.2.1
- [Release notes](https://github.com/paulmillr/noble-ciphers/releases)
- [Commits](https://github.com/paulmillr/noble-ciphers/compare/1.0.0...1.2.1)

Updates `@noble/curves` from 1.6.0 to 1.8.1
- [Release notes](https://github.com/paulmillr/noble-curves/releases)
- [Commits](https://github.com/paulmillr/noble-curves/compare/1.6.0...1.8.1)

Updates `@noble/hashes` from 1.5.0 to 1.7.1
- [Release notes](https://github.com/paulmillr/noble-hashes/releases)
- [Commits](https://github.com/paulmillr/noble-hashes/compare/1.5.0...1.7.1)

---

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: larabr <7375870+larabr@users.noreply.github.com>
2025-02-12 13:20:20 +01:00
dependabot[bot]
e9fe979649
Bump fflate from 0.7.4 to 0.8.2 (#1826)
Bumps [fflate](https://github.com/101arrowz/fflate) from 0.7.4 to 0.8.2.
- [Release notes](https://github.com/101arrowz/fflate/releases)
- [Changelog](https://github.com/101arrowz/fflate/blob/master/CHANGELOG.md)
- [Commits](https://github.com/101arrowz/fflate/compare/v0.7.4...v0.8.2)

---
updated-dependencies:
- dependency-name: fflate
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-11 13:59:09 +01:00
dependabot[bot]
1ab6f27fc9
Bump playwright from 1.48.2 to 1.50.1 (#1824)
Bumps [playwright](https://github.com/microsoft/playwright) from 1.48.2 to 1.50.1.
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](https://github.com/microsoft/playwright/compare/v1.48.2...v1.50.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-11 13:27:41 +01:00
larabr
a7660cc43b CI: fix (again) Dependabot setup: add workaround to set different schedules for npm updates 2025-02-11 11:38:06 +01:00
larabr
b583bcad23
CI: fix Dependabot setup (#1823)
Typo in filename resulting in bot not actually working.
2025-02-10 19:20:03 +01:00
larabr
a3a9e06802
CI: add reconnection mechanism for Browserstack on testsStartTimeout (#1822)
iOS tests sometimes fail to start due to some "server disconnect" issue on BS side.
This seems more prominent on certain devices (e.g. iPhone 16 with iOS 18).
So, we also change the 'iOS latest' target to a more stable one.
2025-02-10 19:15:43 +01:00
Daniel Huigens
965e63b672
Only push new tags when running npm version (#1821) 2025-02-03 14:27:39 +01:00
Daniel Huigens
96b13a468b
6.1.0 2025-01-30 14:15:35 +01:00
Daniel Huigens
432856ff0e
Fix signing using keys without preferred hash algorithms (#1820) 2025-01-29 16:45:32 +01:00
larabr
b2bd8a0fdd
Merge pull request #1812
Improve internal tree-shaking and lazy load md5
2024-11-25 11:13:15 +01:00
larabr
6db98f1e47 Internal: improve tree-shaking in armor module 2024-11-22 14:34:18 +01:00
larabr
8e5da78971 Internal: improve tree-shaking of web-stream-tools
Import single functions instead of entire lib.
2024-11-22 14:34:18 +01:00
larabr
a5d894f514 Internal: avoid importing enums in legacy_cipher chunk
To avoid issues with the lightweight build:
for now it works fine, but it could mess up chunking in the future,
and it already results in a circular import.
2024-11-22 14:34:18 +01:00
larabr
a16160fc66 Use noble-hashes for md5
The existing md5 module brought in the util module,
which messed up the chunking structure in the lightweight build;
inlining those functions is an option, but the noble-hashes code
is also more modern and readable.
2024-11-22 14:32:42 +01:00
larabr
abe750cf7c Lightweight build: lazy load md5 hashing module
Used by old, legacy messages only
2024-11-22 14:32:42 +01:00
larabr
2a8969b437 Internal: improve tree-shaking for crypto modules
Every submodule under the 'crypto' directory was exported-imported
even if a handful of functions where actually needed.
We now only export entire modules behind default exports if it makes
sense for readability and if the different submodules would be
imported together anyway (e.g. `cipherMode` exports are all needed
by the SEIPD class).

We've also dropped exports that are not used outside of the crypto modules,
e.g. pkcs5 helpers.
2024-11-22 14:32:39 +01:00
larabr
bf85deedb8
Merge pull request #1811 2024-11-22 14:30:41 +01:00
larabr
6c3b02872d Throw on encryption using non-standard experimentalGCM AEAD algo
The `enums.aead.gcm` ID standardized by RFC9580 should be used instead.
2024-11-22 14:29:14 +01:00
larabr
4d2d8740dc Fix decryption support for non-standard, legacy AEAD messages and keys that used experimentalGCM
This adds back support for decrypting password-protected messages which
were encrypted in OpenPGP.js v5 with custom config settings
`config.aeadProtect = true` together with
`config.preferredAEADAlgorithm = openpgp.enums.aead.experimentalGCM`.

Public-key-encrypted messages are affected if they were encrypted using the same config, while also providing `encryptionKeys` that declared `experimentalGCM` in their AEAD prefs.
Such keys could be generated in OpenPGP.js v5 by setting the aforementioned config values.
2024-11-22 10:15:20 +01:00
larabr
bbdaad0cba TS: add gcm to enums.aead, mark non-standard experimentalGCM as deprecated
`experimentalGCM` should not be used anymore,
as a different a different algorithm ID was standardized
for GCM, and using the experimental value could give
interoperability issues with e.g. SEIPDv2 and AEAD-encrypted keys.
2024-11-22 10:15:20 +01:00
larabr
daeaf6b1da CI: disable Browserstack concurrency to improve reliability 2024-11-21 18:11:10 +01:00
larabr
67faffafff 6.0.1 2024-11-21 17:16:29 +01:00
larabr
f75447afaa Fix ES imports for webpack: declare exports.browser entrypoint as higher priority than import
We could also drop the browser's directive `"./dist/node/openpgp.min.cjs": "./dist/openpgp.min.js"`,
since that build cannot be used with `require()`, and it's instead meant
to be the target of <script> tags.
But we keep it around for now to avoid potentially breaking changes, in case it's
used in some setups.
2024-11-21 16:43:15 +01:00
larabr
121b478312 Tests: drop unused, unnecessary error assertion
The `expect().to.not.throw` check as written is a no-op.
In fact, `throw` should have been called as a function.

We drop the relevant check altogether since if the wrapped
operation throws, the test will naturally fail due to the
unexpected error.
2024-11-13 19:44:06 +01:00
larabr
088d5f3638
Merge pull request #1807 2024-11-11 20:46:51 +01:00
Daniel Huigens
ac1bfc0d60
Fix openpgp.verify/decrypt with expectSigned: true and format: 'binary' (#1805) 2024-11-11 15:42:33 +01:00
larabr
287104aafb TS: fix PrivateKey.getDecryptionKeys() return type 2024-11-11 14:20:18 +01:00
larabr
2d65d1d553 TS: generateKey: fix options.type definitions to accept 'curve25519' and 'curve448' 2024-11-11 13:28:05 +01:00
Daniel Huigens
3f060660c2
Update hash algorithm preferences order (#1804)
Prefer SHA3_512 over SHA3_256 for consistency.
2024-11-07 15:19:20 +01:00
larabr
01b62399af Revert "CI: temporarily enable for PRs to v6 branch" [skip ci] 2024-11-05 12:56:39 +01:00
larabr
dd01ee00cb 6.0.0 2024-11-04 17:35:18 +01:00
Daniel Huigens
a5645e1d6c Spaces after "RFC" in README 2024-11-04 17:03:36 +01:00
Daniel Huigens
09800741f0 Document required Web Crypto support in README 2024-11-04 17:02:04 +01:00
Daniel Huigens
31a7e2616b
Merge pull request #1629 from openpgpjs/v6
V6
2024-11-04 12:11:19 +01:00
larabr
42d504a69a
Switch to SHA512 as default preferred hash algo (config.preferredHashAlgorithm) (#1801)
This affects the preferences of newly generated keys, which by default will
have SHA512 as first hash algo preference.
SHA512 will also be used when signing, as long as the recipient keys declare
support for the algorithm.
2024-10-31 00:24:19 +01:00
larabr
fb72ea449a
Merge pull request #1802
Determine signature hash prefs based on recipient keys instead of signing key
2024-10-31 00:16:40 +01:00
larabr
f9a3e54364 openpgp.sign: add recipientKeys option to get the signing prefs from
If given, the signature will be generated using the preferred hash algo from the recipient keys.
Otherwise, the signing key preferences are used (this was also the existing behavior).

Note: when signing through `openpgp.encrypt`, the `encryptionKeys` are automatically used as recipient keys.
2024-10-30 19:06:44 +01:00
larabr
d3e75de23d openpgp.encrypt: use encryptionKeys to determine preferred hash algo when signing
In `openpgp.sign`, the signing key preferences are considered instead,
since no "recipient keys" are available.

The hash algo selection logic has been reworked as follows:
if `config.preferredHashAlgo` appears in the prefs of all recipients, we pick it;
otherwise, we use the strongest supported algo (note: SHA256 is always implicitly supported by all keys),
as long as it is compatible with the signing key (e.g. ECC keys require minimum digest sizes).

Previously, only the preferences of the signing key were used to determine the hash algo to use,
but this is in contrast to the RFC: https://www.rfc-editor.org/rfc/rfc9580.html#section-5.2.3.16-2 .
Also, an algo stronger than `config.preferredHashAlgo` would be used, if the signing key
declared it as first preference.

With this change, `config.preferredHashAlgo` is picked even if it's weaker than the
preferences of the recipient keys.
2024-10-30 19:06:44 +01:00
larabr
12274a1543 Update README [skip ci] 2024-10-28 18:01:07 +01:00
larabr
0138b69356 CI: update Browserstack project id to include target branch 2024-10-28 13:38:59 +01:00
larabr
821f260ba9 Lightweight build: lazy load bzip decompression lib 2024-10-28 13:38:59 +01:00
larabr
09095ced4f Run npm update
as well as npm audit
2024-10-28 13:38:59 +01:00
larabr
d7f5736d67
Merge pull request #1794 2024-10-25 12:16:02 +02:00
larabr
693adb417e CI: run browser tests also on Linux
To test platform potential specific code of e.g. the WebCrypto API

Testing on Windows would be nice too, but all browsers fail to fetch resources
from the web-test-runner server.
2024-10-25 11:38:52 +02:00
larabr
013dffce70 CI: test latest Webkit on macOS, as a replacement for testing Safari on Browserstack
We were previously testing the webkit engine on Linux, which however relies on a
different WebCrypto API implementation compared to the macOS version (behind Safari).

Also, increase mocha timeouts, as the argon2 memory-heavy test takes longer in Firefox.
2024-10-24 20:12:11 +02:00
larabr
59c809c943 CI: Browserstack: test only iOS latest and min supported version (iOS 14)
Dropping Safari since Web Secure Sockets do not seem to work with
the 'networkLogs' capability, which is in turn required for the HTTPS
connection to work without insecure certs warnings.
2024-10-24 15:39:20 +02:00
larabr
4ddadd4f53 CI: setup HTTPS in web-test-runner for BrowserStack tests
To have tests work Browserstack Safari (also below iOS 15), as the tests are run in an iframe,
rewriting localhost as hostname, making WebCrypto not available.

We keep HTTP for the non-browserstack tests so that in local testing,
generating self-signed certs is not required.
2024-10-24 15:39:14 +02:00
larabr
ae5698c621 CI: fix playwright version parsing
Only look at direct dependency
2024-10-23 18:03:54 +02:00
larabr
4b017f6c67 Tests: drop karma (deprecated) in favor of web-test-runner 2024-10-23 18:03:51 +02:00
larabr
e924a50c31
Merge pull request #1799 2024-10-22 14:32:31 +02:00
larabr
88f20974dd Tests: add support for RNG mocking in browser tests
The affected tests were previously only run in Node.
2024-10-22 12:40:15 +02:00
larabr
05fbc63732 Use WebCrypto.getRandomValues in Node
To move towards uniform code with across platforms.
2024-10-22 12:40:15 +02:00
larabr
3cdaab7894 Check session key size on v3 SKESK and PKESK packet decryption
For v3 SKESK and PKESK packets, the session key algorithm is part of the payload,
so we can check the session key size on packet decryption.
This is helpful to catch errors early, when using e.g. `decryptSessionKeys`.

In v6 packets, the session key size check can only be done on SEIPDv2 decryption.
2024-10-22 12:40:15 +02:00
larabr
e58c02d5ee Check session key size on SEIPD decryption
This is especially important for SEIPDv2 session keys,
as a key derivation step is run where the resulting key
will always match the expected cipher size,
but we want to ensure that the input key isn't e.g. too short.
2024-10-22 12:40:15 +02:00
larabr
a57bffc84a
Fix key and signature parsing of EdDSALegacy entities with unsupported curves (e.g. Curve448Legacy) (#1798)
Signature parsing would fail in case of unexpected payload sizes, causing key parsing to always throw
when processing e.g. an (unsupported) Curve448Legacy subkey instead of ignoring it.

To address this, we now throw on signature verification instead of parsing (as done for ECDSA).

NB: the bug and this fix are not relevant for the new Ed25519/Ed448 entities as standardized by the crypto-refresh.
2024-10-14 12:15:33 +02:00
larabr
5ee854140a CI: update SOP test suite docker image to v1.1.12
Includes rsop with crypto-refresh support
2024-10-03 16:44:55 +02:00
larabr
ada794cab6 Throw on (unexpected) low order points in ECDH over Curve25519/448
These points do not pose a security threat in the context of OpenPGP ECDH,
and would simply result in an all-zero shared secret being generated.
However, they represent unexpected inputs, so we prefer to warn the user.
2024-09-12 13:32:14 +02:00
larabr
e80d71bdfc CI: setup Dependabot to update non-dev dependencies
We unfortunately need to manually list them as they are still
declared as dev dependencies in the package.json, due to the fact
that we bundle them.
2024-09-11 19:41:57 +02:00
larabr
e454faab0c CI: setup Dependabot to update playwright and test latest browser versions 2024-09-11 19:35:47 +02:00
larabr
6ac17dc71c 6.0.0-beta.3.patch.1 2024-09-11 10:57:20 +02:00
larabr
148fff91e8 Docs: fix type tag warnings 2024-09-11 10:56:08 +02:00
larabr
ccb040ae96 Revert to not using the WebCrypto for X25519 (ECDH only)
Due to missing support in WebKit and Chrome (without experimental flags),
and broken support in Firefox, for now we go back to using a JS implementation.

This change only affects encryption and decryption using X25519.
For signing and verification using Ed25519 we keep relying on
WebCrypto when available (namely in WebKit, Firefox, and Node).
2024-09-11 10:56:08 +02:00
larabr
2b9a07e840 Run npm audit 2024-09-11 10:42:37 +02:00
larabr
0255fcba86 CI: update playwright to test latest browser versions 2024-09-11 10:39:51 +02:00
larabr
f2818429db 6.0.0-beta.3.patch.0 2024-09-09 11:47:41 +02:00
larabr
8d8033383b Fix regression in x25519 (legacy) key generation: store clamped secret scalar
Fixes regression from changes in #1782, as the spec mandates that
legacy x25519 store the secret scalar already clamped.
Keys generated using v6.0.0-beta.3 are still expected to be functional,
since the scalar is to be clamped before computing the ECDH shared secret.
2024-09-09 11:20:59 +02:00
larabr
a3839f6db5 6.0.0-beta.3 2024-09-05 13:24:51 +02:00
larabr
1bcce67c68 CI: test also on Node 22 2024-09-05 13:20:56 +02:00
larabr
e7b7f6c6b1 Run npm update 2024-09-05 13:20:56 +02:00
larabr
ab8445116c CI: update SOP test suite docker image to v1.1.10
Add rsop to tested libraries.
2024-09-05 13:20:56 +02:00
larabr
f36be640cc Fallback to js implementation on WebCrypto EdDSA key generation failure
Workaround random failures in WebKit (Linux).
2024-09-04 17:47:55 +02:00
larabr
2f185481a7
PrivateKey.getDecryptionKeys: throw if no decryption key is found (#1789)
To avoid returning dummy key packets, and improving error reporting.
This new behavior is also better aligned with that of `Key.getSigningKey()`.

This is a breaking change for apps that call `getDecryptionKeys()` directly.
The related error messages returned by `openpgp.decrypt` have also changed,
becoming more specific.

This change is also made in preparation of supporting private keys with
public key packets.
2024-09-03 14:40:06 +02:00
larabr
5fd7ef370f
Drop asmcrypto.js for AES fallbacks in favor of noble-ciphers (#1785)
Asm.js has now been deprecated for many years, and no performance gain is
recorded for AES compared to vanilla JS.
The relevant AES fallback code is primarily used if the WebCrypto (resp.
NodeCrypto) implementation is not available.
2024-08-21 12:59:23 +02:00
larabr
79014f00f0
Merge pull request #1782 2024-08-21 12:53:13 +02:00
larabr
5c583341d7 Update README 2024-08-14 16:28:56 +02:00
larabr
db82968b48 Tests: do not test RFC8032 test vectors on Safari
As it implements a different RFC for non-deterministic signature generation
2024-08-14 16:22:01 +02:00
larabr
7698790d1c Use WebCrypto for x25519 when available 2024-08-14 16:22:01 +02:00
larabr
bcaaa7e2d2 Use WebCrypto for ed25519 when available 2024-08-14 16:22:00 +02:00
Daniel Huigens
fca699373a
Try more AEAD ciphersuites for SEIPDv2 (#1781)
Stick more closely to the algorithm preferences when creating an SEIPDv2
message, by trying additional combinations of the preferred symmetric algorithm
and the preferred AEAD algorithm. If one of them is supported but not the
other, we still use it (with the mandatory-to-implement algorithm for the other
one).
2024-08-12 11:52:52 +02:00
larabr
efb0324330 TS: add definition for config.enableParsingV5Entities [skip ci] 2024-07-15 15:14:27 +02:00
larabr
c0b35306cb 6.0.0-beta.2 2024-07-05 15:12:14 +02:00
larabr
35a1e1f23b Run npm audit 2024-07-05 15:10:29 +02:00
larabr
b9c5c8df59
Allow parsing legacy AEAD messages regardless of config.enableParsingV5Entities (#1779)
As legacy AEAD messages have been in circulation for longer.
2024-07-05 14:38:16 +02:00
Daniel Huigens
857b794e13
Disallow using forbidden S2K modes (#1777)
RFC9580 says that:

    Argon2 is only used with AEAD (S2K usage octet 253).  An
    implementation MUST NOT create and MUST reject as malformed any
    secret key packet where the S2K usage octet is not AEAD (253) and
    the S2K specifier type is Argon2.

Therefore, we disallow reading and writing Argon2 keys without AEAD.

And:

    [The Simple and Salted S2K methods] are used only for reading in
    backwards compatibility mode.
    
Since v6 keys don't need backwards compatibility, we also disallow
reading Simple S2K there. We still allow reading Salted S2K since the
spec says it may be used "when [the password] is high entropy".
2024-07-05 13:52:45 +02:00
Daniel Huigens
00e147f5c1
Use preferred AEAD mode for secret key encryption (#1776)
When config.aeadProtect is enabled, use config.preferredAEADAlgorithm
to decide the AEAD mode when encrypting secret keys.
2024-07-05 13:50:11 +02:00
Daniel Huigens
42938c871a
Fix legacy AEAD secret key encryption of v5 keys (#1775) 2024-07-04 19:41:39 +02:00
larabr
40b6427658 Tests: fix stream polyfilling in legacy browsers
web-streams-polyfill v4 has a different entrypoint for the polyfills.
2024-07-04 14:51:59 +02:00
larabr
f729d2bfa7
Fix ECDH fingerprint size of v6 keys (#1771)
Fingerprint should not be truncated, unlike for v5 keys.
2024-07-04 14:28:43 +02:00
larabr
5268c484e9
Disable support for parsing v5 entities by default (add config.enableParsingV5Entities) (#1774)
Parsing of v5 keys, v5 signatures and AEAD-encrypted data packets now requires turning on
the corresponding config flag.
The affected entities are non-standard, and in the crypto-refresh RFC they have been superseded by
v6 keys, v6 signatures and SEIPDv2 encrypted data, respectively.
However, generation of v5 entities was supported behind config flag in OpenPGP.js v5, and some other libraries,
hence parsing them might be necessary in some cases.
2024-07-04 13:59:40 +02:00
Daniel Huigens
9efdaf14b1 Let hard revocations apply at any time (#1773)
"Hard" revocations (i.e. key compromise, and unknown reasons) apply
at any time, even before the revocation was created.

Co-authored-by: larabr <larabr+github@protonmail.com>
2024-07-04 13:51:35 +02:00
larabr
8d11c5fd0f Drop support for Node 16 and 17 2024-06-26 12:01:10 +02:00
larabr
7af16be62b
Use positive cert for self-signatures (#1769)
To uniform behaviour with other openpgp libs.
2024-06-25 12:50:26 +02:00
larabr
4026e24585 Merge branch 'main' into v6 2024-06-18 19:21:16 +02:00
larabr
a0337780b7 5.11.2 2024-06-18 17:53:56 +02:00
larabr
3eba29dba8
Merge pull request #1762
`openpgp.verify`: fix bug preventing verification of detached signatures over streamed data
2024-06-18 17:39:21 +02:00
larabr
12fb916360 Pass curve object instead of oid to checkPublicPointEnconding 2024-06-18 17:09:23 +02:00
larabr
cf94380e26 Read wireFormatLeadingByte value from curve object 2024-06-18 17:09:23 +02:00
larabr
52611e7f26 Detect unexpected eddsaLegacy OID on parsing 2024-06-18 17:09:23 +02:00
larabr
f8d0e6052f Detect invalid ECDSA, EdDSA and ECDH public key point encodings on usage
We now throw on unexpected leading byte.
This change is primarily intended to help with debugging, in case of malformed params.
In fact, in case of wrong point size, the operations would already fail anyway,
just in lower-level functions.
2024-06-18 17:09:23 +02:00
larabr
08b71487c5 Detect invalid PKESK public point encoding on decryption
We got a report of a message including a PKESK packet where
the ECDH x25519Legacy point was missing the leading byte (0x40).
While decryption naturally would naturally fail afterwards, this
change ensures we fail at a higher level, and do not blindly pass
down invalid data to the low-level crypto functions.
2024-06-18 17:09:23 +02:00
larabr
75f10955e6 Tests: move away from global streamed data
To improve readability
2024-06-18 17:07:41 +02:00
larabr
1ce2df1119 Avoid using stream.clone over polyfilled steam in test
Gives issues in Node and Safari < 14.1
2024-06-18 16:36:31 +02:00
larabr
6ace4a00f5 Update web-stream-tools to fix passiveClone cancellation race condition in tests
Affecting tests over streamed detached verification
2024-06-18 10:16:33 +02:00
Daniel Huigens
9f5ff66c3d
Store unhashed subpackets in a more structured format (#1767)
To match the new `unknownSubpackets` property.
2024-06-17 16:52:28 +02:00
Daniel Huigens
b1e27a1430
Delay checking unknown critical signature subpackets (#1766)
Throw when verifying signatures with unknown critical subpackets,
instead of when parsing them.
2024-06-17 12:31:31 +02:00
larabr
a315c46583 openpgp.verify: fix bug preventing verification of detached signature over streamed data
When given a streamed `message` and a detached `signature` in input,
the function would return an empty array as `data` instead of
the input stream, meaning it was not possible to pull it, causing
the `verified` promise to hang indefinitely.

The above issue was introduced v5.0.0-2, and thus affects all v5 releases
up to v5.11.1.
2024-05-31 15:58:42 +02:00
larabr
d138b5290b 6.0.0-beta.1 2024-05-17 14:13:46 +02:00
larabr
1d732c34ff Run npm update 2024-05-17 13:04:47 +02:00
larabr
6a306a1797 Lint: add support for dep imports that use exports declarations 2024-05-17 13:00:37 +02:00
larabr
676c31b748 CI: update SOP actions to Node 20 2024-05-16 17:21:36 +02:00
larabr
727c7cad37 read[Private]Key: support parsing key blocks (return first parsable key)
Previously, `readKey` and `readPrivateKey` would throw when given a block
of keys as input.
With this change, the first parsable key is returned by both functions:
the behaviour is equivalent to calling `readKeys` (resp. `readPrivateKeys`)
and taking the first array entry.
2024-05-16 14:07:39 +02:00
larabr
ad7165dfd0 readPrivateKeys: support parsing key block with mix of private and public keys
Previously, parsing a key block where a public key followed a private one would fail.
2024-05-16 14:07:39 +02:00
larabr
cf0285add5 Drop BigInteger class, use standalone helpers 2024-05-16 13:59:11 +02:00
larabr
90495522f7 CI: update Browserstack legacy targets (drop Safari 13) 2024-05-16 13:59:11 +02:00
larabr
2985b0f470 Lint: add support for TS files, fix errors 2024-05-16 13:59:11 +02:00
larabr
5bfff907b4 Move Brainpool curves implementation from noble-curves fork
The main repo doesn't implement them
2024-05-16 13:59:11 +02:00
larabr
ec52bdea83 Point to official noble-hashes and noble-curve libs 2024-05-16 13:59:11 +02:00
larabr
d1a24d1758 Drop support for platforms without native BigInt (e.g. Safari <14)
Remove BN.js fallback, and only keep native BigInteger interface
(for algorithmic constant-time functions).
Also, add support for TS modules, to move some over from the forked
noble repos.
2024-05-16 13:59:11 +02:00
larabr
7e2ea3f871 CI: update cache actions to Node 20 2024-05-02 21:45:58 +02:00
larabr
f3f1ab931b Tests: update SEIPD version check to no longer depend on config.aeadProtect
The logic was updated in github.com/openpgpjs/openpgpjs/pull/1678 .
The tests worked anyway thanks to the config option matching the (monkey patched)
keys' feature flags, which are the deciding factor for whether to use AEAD.
2024-05-02 21:45:58 +02:00
larabr
2bf7c92469 6.0.0-beta.0 2024-04-12 14:28:06 +02:00
larabr
5464caa6f7
Fix email address validity check to still allow unicode values, and further relax constraints (#1739)
We relaxed constraints in a previous commit, but excluded unicode chars, which are however allowed in v5.

We now drop almost all email address constraints, by primarily rejecting
control and spaces char classes.
Library users are strongly encouraged to implement additional checks as needed,
based on their supported email address format.

NB: the validity checks in question affect the userID inputs accepted by e.g.
`generateKey` and `reformatKey`, not the values parsed from existing entities,
e.g. using `readKey` (where almost no validation is performed).
2024-04-12 13:47:52 +02:00
larabr
231fbbe8ca Run npm update 2024-04-09 19:07:58 +02:00
larabr
9a53ac15df Tests: bump Sinon to v17 2024-04-09 18:57:53 +02:00
larabr
a05c23b507 Key.getRevocationCertificate(): apply config settings when armoring
The `config` input was not passed down to the armor function due to an oversight.
2024-04-09 18:40:51 +02:00
larabr
90c8fbbf00
Add back armor checksum for non-v6 artifacts (#1741)
We need to include the checksum to work around a GnuPG bug where data fails to
be decoded if the base64 ends with no padding chars (=) (see https://dev.gnupg.org/T7071).
Pure v6 artifacts are unaffected and won't include the checksum, as mandated by
the spec.

Breaking change:
`openpgp.armor` takes an additional `emitChecksum` argument (defaults to
false).
NB: some types of data must not include the checksum, but compliance is left as
responsibility of the caller: this function does not carry out any checks.
Refer to the crypto-refresh RFC for more details.

---------

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2024-04-09 17:12:44 +02:00
larabr
e9e843280b CI: update to sop-openpgp-v2 to test different v6 profiles
The implemented profiles do not work on v5, hence for now they need to be manually
disabled in the config of 'sop-openpgpjs-main'.
2024-04-05 17:25:54 +02:00
larabr
c68bd960ce
Randomise v4 and v5 signatures via custom notation, add config.nonDeterministicSignaturesViaNotation to disable feature (#1737)
EdDSA is known to be vulnerable to fault attacks which can lead to secret key
extraction if two signatures over the same data can be collected. Randomly
occurring bitflips in specific parts of the computation might in principle
result in vulnerable faulty signatures being generated.
To protect signatures generated using v4 and v5 keys from this possibility, we
randomise each signature by adding a custom notation with a random value,
functioning as a salt. 
For simplicity, we add the salt to all algos, not just EdDSA, as it may also
serve as protection in case of weaknesses in the hash algo, potentially
hindering e.g. some chosen-prefix attacks.
v6 signatures do not need to rely on this, as they are non-deterministic by
design.

While this notation solution is interoperable, it will reveal that the
signature has been generated using OpenPGP.js, which may not be desirable in
some cases.
For this reason, the option `config.nonDeterministicSignaturesViaNotation`
(defaulting to true) has been added to turn off the feature.
2024-04-02 17:37:57 +02:00
larabr
aa222fecb2
Drop config.revocationsExpire, always honour revocation expiration instead (#1736)
Unclear motivation for adding the original config option; if an expiration is there, it should
be honoured.

Breaking change:
the option used to default to `false`, and ignore revocation expirations. We now honour
those expirations, namely match the behaviour resulting from setting the option to `true`.
2024-03-28 14:24:23 +01:00
larabr
6ebd179ed5 Fix encrypting to a key with no declared features 2024-03-22 17:12:45 +01:00
larabr
2574795d37
Fix wrong serialization of PKESK v6 for x25519/x448 (#1734)
The cleartext session key symmetric algorithm was accidentally included in the packet.
As a result, the generated messages may fail to parse and/or decrypt in other implementations.
The messages would still decrypt successfully in OpenPGP.js, due to an overly permissive parsing procedure,
which simply discarded the unused additional byte.

We know also throw on unexpected cleartext symmetric algo in PKESK v6.
2024-03-22 17:10:27 +01:00
larabr
b41298a3f6 Add back armor checksum to detached signatures for GPG compatibility
GPG v2 fails to parse detached signatures without the checksum
2024-03-22 16:21:55 +01:00
larabr
cb97c8fcb9 CI: fix sop test result comparison 2024-03-22 16:14:18 +01:00
larabr
aba61efa70 CI: update interop test suite: fix sop-openpgpjs, include crypto-refresh tests, and compare with gopenpgp v3
sop-openpgpjs did not correctly apply the `OPENPGPJS_PATH` env variable; as a result,
it did not actually test the code from either the PR and base branch, but always from
the hardcoded version bundled with it.
2024-03-22 16:14:18 +01:00
larabr
147d043a32 6.0.0-alpha.1 2024-02-28 13:22:22 +01:00
larabr
df59dec319 Update README 2024-02-28 13:22:22 +01:00
larabr
f5cebfe6fd CI: update Playwright browser installation 2024-02-28 13:06:22 +01:00
larabr
15adf84a7d Run npm update 2024-02-28 12:44:05 +01:00
larabr
d4fd9c8d43 Merge branch 'main' into v6 2024-02-28 12:00:01 +01:00
larabr
151f15e282
Node: drop asn1.js dependency (#1722)
asn1.js is a fairly large lib and was simply needed to handle DER encodings in
some NodeCrypto operations.
This change replaces the dependency by moving to:

- JWT encoding for RSA (support added in Node v15)
- a much lighter dependency (eckey-utils) for ECDSA, where JWT cannot be used
for now, as Node has yet to add decoding support for Brainpool curves.

The change also allows us to drop BN.js as a direct dependency, optimising the
BigInteger-related chunking in the lightweight build.
2024-02-27 14:56:07 +01:00
larabr
a6283e64cc Drop internal cipher/aes module
The module was barely used, and its presence confusing, since
WebCrypto or asmcrypto are often directly used and usable instead.
Also, use AES_CBC instead of AES_ECB for single-block encryption,
so that we can drop support for the latter in the asmcrypto lib.
2024-02-27 14:43:24 +01:00
larabr
9c75845944 Use WebCrypto for AES-KW
Fallback needed for AES192, due to missing Chromium support.
2024-02-27 14:43:24 +01:00
larabr
db15f6d6a1
Import legacy ciphers (CAST5, TwoFish, BlowFish, DES) only on demand (#1723)
This primarily affects the lightweight build, which will not include these
(fairly large) modules in the main bundle file.
2024-02-26 15:37:50 +01:00
larabr
026b348cf8 5.11.1 2024-02-19 17:23:54 +01:00
larabr
711c41826a Run npm audit 2024-02-19 17:22:15 +01:00
larabr
a4e2c56c49
Use JS fallback code for RSA message decryption in Node if PKCS#1 is not supported (#1728)
Necessary as Node v18.19.1, 20.11.1 and 21.6.2 have disabled support for PKCS#1 decryption.
2024-02-19 17:14:55 +01:00
Mingye Wang
7a6b41fbd4
README: replace "IETF proposal" with "RFC4880bis proposal" (#1726) 2024-02-19 15:17:40 +01:00
larabr
17bbab44c9 README: clarify web-stream-tools version to install for TypeScript projects [skip ci] 2024-02-19 13:52:30 +01:00
larabr
b413a113f9 CI: update actions to Node 20 2024-02-12 13:53:46 +01:00
larabr
280828dae6 Throw if WebCrypto API is not available
It was already required, this simply makes errors more clear.
2024-02-06 16:00:35 +01:00
larabr
3320eaccb2
Relax constraints for UserID email address validity (#1641)
New checks align with the HTML5 W3C spec and should be more lax than the
existing ones (meaning, addresses which passed validation before should
continue to be valid).
Addresses such as `@localhost` are now allowed too, since presence of "." is no
longer enforced.

These checks should not be considered exhaustive: library users are encouraged
to implement separate checks for email validity if needed.

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2024-02-02 15:04:34 +01:00
larabr
22c2682574
Ensure primary key meets strength and algo requirements when encrypting/verifying/signing using subkeys (#1719)
Breaking change: the requirements of `config.minRSABits`, `rejectPublicKeyAlgorithms` and `rejectCurves`
are now applied to the primary key, aside from the selected subkey.

The motivation is that the subkeys are certified by the primary key, but if the latter is
weak, arbitrary subkeys could potentially be added.

Note that the change does not affect decryption, to allow decrypting older messages.
2024-02-02 14:50:32 +01:00
larabr
f64dc3f35f
enums.curve: rename NIST curves (p256,p384,p521`) and clean up unused internal values (#1721)
This is a breaking change, as NIST curves identifiers and values in
`enums.curves` have been renamed:
- the identifiers `enums.curve.p256`, `.p384`, `.p521` are now marked as
`@deprecated`
- the new identifiers are, respectively: `enums.curve.nistP256`, `.nistP384`,
`.nistP521`.
- the corresponding values have been changed from `'p256'`,`'p384'`,`'p521'` to
`'nistP256'`, `'nistP384'`, `'nistP521'`.

Affected high-level API functions:
- in `generateKey`, the `options.curve` argument will expect the updated string
values
- `Key.getAlgorithmInfo()` will return the updated `curve` values
2024-02-02 12:54:24 +01:00
larabr
6370e0b2d3 CI: fix typescript test runner issues by switching to tsx from ts-node
ts-node is still needed for mocha to work with the different versions of Node
(passing --import in NODE_OPTIONS is not supported in older versions).
2024-02-01 10:38:01 +01:00
larabr
6bfb557ca6 Update Rollup to v4 2024-02-01 10:23:50 +01:00
larabr
959956cfc9
Use Compression Stream API when available, drop config.deflateLevel (#1717)
Breaking change: the `config.deflateLevel` is removed as the API does not accept a deflate level
in input, and the setting is of limited importance. Plus, using compression
is discouraged on security grounds.
2024-02-01 09:42:16 +01:00
larabr
99899d1d5c
Drop support for native Node Readable stream: require passing Node Web Streams (#1716)
Breaking change: all functions taking streams as inputs will now require passing Web Streams in Node.js . If given a native `stream.Readable` input, they will throw. The browser build is unaffected by this change.

Utils to convert from and to Web Streams in Node are available from v17,
see https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options .
Previously, we automatically converted between Node native streams and custom, Web-like Readable streams.
This led to occasional issues.
2024-01-26 17:52:29 +01:00
larabr
591b9399a8
Skip key validation for keys encrypted with non-legacy AEAD mechanism (#1713)
The public key material integrity is guaranteed by the new encryption mechanism,
hence `.validate()` does not need to run further checks.
2024-01-15 15:07:09 +01:00
larabr
f77da9cdb0
Add config.parseAEADEncryptedV4KeysAsLegacy to support AEAD-encrypted v4 keys from OpenPGP.js v5 or older (#1672)
The config option must be set when reading v4 private keys (e.g. those
generated in OpenPGP.js by default, without setting `config.v5Keys = true`)
which were encrypted by OpenPGP.js v5 (or older) using `config.aeadProtect = true`.
Otherwise, key parsing and/or key decryption will fail.

Additional context: OpenPGP.js up to v5 used to support encrypting v4 keys
using AEAD as specified by draft RFC4880bis
(https://www.ietf.org/archive/id/draft-ietf-openpgp-rfc4880bis-10.html#section-5.5.3-3.5).
Said AEAD mechanism was not standardized as-is, and it's been replaced in the
crypto-refresh with a new version that guarantees full key integrity on decryption.
The legacy AEAD format is incompatible, but fundamentally indistinguishable,
from that of the crypto-refresh for v4 keys. Thus, we rely on the caller to
instruct us to process the key as legacy, via the new config flag.

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2024-01-12 16:29:56 +01:00
larabr
19cb6ee521 Lint: make 'space-before-function-paren' rule stricter to reflect enforced style 2023-12-18 15:52:19 +01:00
larabr
e92b44bc84 CI (temp): fix typescript test runner failure due to ts-node bug
This fix triggers some warnings about experimental features,
and it's meant to be temporary until ts-node shares a long-term solutio .

See https://github.com/TypeStrong/ts-node/issues/2094.
2023-12-08 15:10:27 +01:00
larabr
c754fac10f CI: replace nyc with c8 as coverage tool
Unclear if nyc is still actively maintained, and it does not seem
to work with ESM out of the box.
2023-12-08 14:53:19 +01:00
larabr
90a2af9fe2 Tests: fix flaky elliptic curve test in Node
`genKeyPair()` does not pad the returned values. This caused random test failures in Node
as some secret keys are 1 byte short.
2023-12-08 14:46:41 +01:00
larabr
ff4181ad5a Add back zlib and zip to preferred compression algos on key generation
To signal support, despite "no compression" being preferred by default,
for security reasons.
2023-12-08 14:00:22 +01:00
larabr
e93702bb8d Fix types path for lightweight build [skip ci] 2023-11-21 17:34:59 +01:00
Ryan
54fc2c8fbd
Add SHA3-256 and SHA3-512 to preferred hash algos on key generation (#1696)
This is to signal support to senders who wish to use these algos.
Note  that SHA256 remains as first default preference, followed by SHA512,
as in the context of OpenPGP signatures they provide
better performance/security ratio than their SHA3 counterparts.
2023-11-02 14:16:40 +01:00
larabr
7881b850ec 6.0.0-alpha.0 2023-10-25 12:55:43 +02:00
larabr
0da131cd9a Update README 2023-10-25 12:53:15 +02:00
larabr
30635c72e8 Lint: error on unnecessary switch-case braces
Also fix some indent issues with armoring code detected after required ESLint update.

s
2023-10-25 12:53:15 +02:00
larabr
917faa56f5 Rename internal functions, filter key algos on decryption 2023-10-25 12:53:14 +02:00
larabr
690346a854 Refuse to use keys without key flags, add config.allowMissingKeyFlags
Key flags are needed to restrict key usage to specific purposes:
https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-10.html#section-5.2.3.29 .
Some older keys (e.g. from OpenPGP.js v1) do not declare any key flags.
In previous OpenPGP.js versions, we've allowed such keys to be used for any operation for which they were compatible.
This behaviour has now changed, and these keys are not allowed to be used for any operation.

The setting  `config.allowMissingKeyFlags` has been added to selectively revert to the past behaviour.
2023-10-25 12:53:14 +02:00
larabr
9a547b4553 Update rollup to v3 2023-10-25 12:53:14 +02:00
larabr
86f5a8b71b Rollup: use preserveEntrySignatures = 'exports-only' setting in lightweight build
This is the default setting and it ensures that the main chunk does not include
additional exports, which is is important when importing the module as `import *`
as shown in the readme.
In practice, this change does not affect the chunking with the current code.
2023-10-25 12:53:14 +02:00
larabr
4ee9deae62 Switch back to using standard BigInteger class instead of wrapper
Using a wrapper requires adding some handling code to fix race conditions,
but it does not provide advantages until we switch to TS.
2023-10-25 12:53:14 +02:00
larabr
9e1962f006 Import noble-hashes, noble-curves and BN.js only on demand
This primarily affects the lightweight build, which will not include these
(fairly large) libs in the main bundle file. This allows fetching their code only if required:
- Noble-curves is only needed for curves other than curve25519.
- Noble-hashes is needed for streamed hashing and e.g. SHA3 on web.
- BN.js is used by the above libs, and it's also separately needed for platforms
without native BigInt support.
2023-10-25 12:53:14 +02:00
larabr
5456211266 Simplify userID parsing based on conventions, drop third-party parsing lib
Follow conventions as per https://datatracker.ietf.org/doc/draft-dkg-openpgp-userid-conventions
2023-10-25 12:53:14 +02:00
larabr
a56a4a16e8 Use internal tweetnacl SHA-512 implementation
Instead of relying on externally provided one (no async loading supported)
2023-10-25 12:53:14 +02:00
larabr
7295a2e7b3 Rename config.useIndutnyElliptic to .useEllipticFallback
To reflect change of underlying library
2023-10-25 12:53:14 +02:00
larabr
909d44f436 Add back support for verification of some invalid ECDSA sigs affected by old lib bug
At some point we used to generate invalid ECDSA sigs with the js (non-native) elliptic lib,
if the signature digest had leading zeros: https://github.com/openpgpjs/openpgpjs/pull/948 .

Brainpool curves are the most likely to have been affected by the bug, since they do not
have WebCrypto support (unlike NIST curves).
This commit reintroduces support on web to verify such invalid signatures
(support for this was previously built-in in the indutny-elliptic library).
It also expands the fix to work in Node.
2023-10-25 12:53:14 +02:00
larabr
a9fae5ff12 Replace indutny-elliptic lib with noble-curves
Unlike elliptic, noble-curves targets algorithmic constant time, and
it relies on the native BigInts when available, resulting in a smaller bundle
and improved performance.

Also, expand testing of fallback elliptic implementation.
2023-10-25 12:53:14 +02:00
larabr
01df8ca889 Rename values of enums.curve.{curve, ed}25519Legacy from '{curve. ed}25519' to '{curve. ed}25519Legacy'
To reflect the crypto-refresh naming, after the standardisation of the new EdDSA
key types.
2023-10-25 12:53:14 +02:00
larabr
d6d8576700 Prevent generating v6 keys using legacy curve25519 2023-10-25 12:53:14 +02:00
larabr
c7efef60ac Throw when parsing v6 keys using legacy curve25519 2023-10-25 12:53:14 +02:00
larabr
7c2248151d Default to generating new curve25519 format for v6 keys
As per the spec, v6 keys must not use the legacy curve25519 format.
The new format is not used by default with v4 keys as it's not compatible with OpenPGP.js older than v5.10.0 .
However, v6 keys already break compatibility, so if the user requests them via config flag, we can safely use the new curve format as well.
2023-10-25 12:53:14 +02:00
larabr
360a44f57b addSubkey: match primary key version
As required by the spec.
2023-10-25 12:53:14 +02:00
larabr
0b7a5f69fa Drop enums.publicKey.eddsa in favour of enums.publicKey.eddsaLegacy
The crypto-refresh has standardised a new key format for EdDSA, whose algorithm
identifier are `enums.publicKey.ed25519` and `.ed448`
2023-10-25 12:53:14 +02:00
larabr
24c644207d Support generating Curve448 and Curve25519 keys (new format)
Neither type is set as default for now, since they are not widely supported.
2023-10-25 12:53:14 +02:00
larabr
1509364a49 Throw on unexpected param sizes in secret keys, session keys and signatures
Detect extra bytes in secret key material, as well as missing bytes in other parameters.
2023-10-25 12:53:14 +02:00
larabr
2afa19db01 Run npm audit 2023-10-25 12:53:13 +02:00
larabr
d291ce6d0f Update Curve448 tests using inputs from gopenpgp 2023-10-25 12:53:13 +02:00
larabr
089a14f9e0 Internal: refactor uint8ArrayToHex for performance and to avoid branching 2023-10-25 12:53:13 +02:00
larabr
56cd448a32 crypto-refresh: add support for X448 2023-10-25 12:53:13 +02:00
larabr
1ebf7034f5 crypto-refresh: add support for Ed448 2023-10-25 12:53:13 +02:00
larabr
105b3cdde4 Disregard config.aeadProtect when encrypting to public keys (#1678)
Determine whether AEAD should be used for encryption solely based the encryption key preferences.
Previously, the config flag was also used to control the behaviour, since AEAD messages were not standardised nor widely supported.

To generate keys that declare AEAD in their preferences, use `generateKey` with `config.aeadProtect = true`.
2023-10-25 12:53:13 +02:00
larabr
97ebd14829 Fix parsing of v6 signatures with unknown hash algorithm (#1683)
Fail on verification rather than parsing, also for unexpected salt size.
2023-10-25 12:53:13 +02:00
Ryan
53e1ec023f Add SHA-3 signature support (#1680)
To support parsing, signing and verifying SHA3 signatures over messages and
keys.
2023-10-25 12:53:12 +02:00
larabr
8fe04c99c6 Remove unused enums.symmetric.plaintext
This special cipher value can be relevant for unencrypted private keys:
https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-10.html#section-12.2.1 .
However, it is no longer used internally, and on the contrary it could cause
confusion on SKESK decryption, where "random" cipher algos are returned in case
of wrong password.

This change also fixes a flaky test on password-based decryption, caused by the
PKESK v6 changes which add support for `null` cipher algos. The code did not
distinguish between a `null` and a `0` (plaintext) algo identifier, and would
break when the latter was returned on SKESK decryption.
2023-10-25 12:53:12 +02:00
larabr
278a61adab Add SEIP.fromObject
To avoid defaulting to v1
2023-10-25 12:53:12 +02:00
larabr
1423bdd564 Add PKESK.fromObject 2023-10-25 12:53:12 +02:00
Lukas Burkhalter
79b3687424 Only emit Hash header below V6 for cleartext messages
The latest version of the crypto refresh (i.e., !313, !314) specifies that
the "Hash" header is depricated. This commit changes that the Hash header
is only generated if a cleartext message contains a non-V6 signature.
2023-10-25 12:53:12 +02:00
Lukas Burkhalter
1ddf4e151c Accept cleartext messages without hash header
The latest version of the crypto refresh (i.e., !313, !314) specifies that
the  "Hash" header is deprecated, and that an implementation that is verifying
a cleartext signed message MUST ignore this header.
However, we go against this directive, and keep the checks in place to avoid
arbitrary injection of text as part of the "Hash" header payload.
We also mandate that if the hash header is present, the declared
algorithm matches the signature algorithm. This is again to avoid
a spoofing attack where e.g. a SHA1 signature is presented as
using SHA512.
Related CVEs: CVE-2019-11841, CVE-2023-41037.

This commit does not change the writing part of cleartext messages.

# Conflicts:
#	src/cleartext.js
2023-10-25 12:53:12 +02:00
Lukas Burkhalter
af96628855 Add support for v6 one-pass signature packets
Introduces v6 one-pass signature packets required for v6 signatures.
Includes the changes from !305 of the crypto refresh:
https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/305

Also, introduce `OnePassSignaturePacket.fromSignaturePacket` to simplify
OPS generation.
2023-10-25 12:53:12 +02:00
larabr
0b8501427b Implement packet criticality check
The Packet Tag space is now partitioned into critical packets and non-critical packets.
If an implementation encounters a critical packet where the packet type is unknown in a packet sequence,
it MUST reject the whole packet sequence. On the other hand, an unknown non-critical packet MUST be ignored.

See https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-10.html#section-4.3.1 .
2023-10-25 12:53:12 +02:00
larabr
95fd04db8e Support AEAD encryption for v4 and v6 private keys 2023-10-25 12:53:12 +02:00
Daniel Huigens
21343f2bb8 Appease linter 2023-10-25 12:53:12 +02:00
larabr
33af3debc4 Throw intelligible error on GCM authentication failure, fix/refactor test for modification detection on decryption
Also, address race condition in error handling as part of AEAD message decryption,
which would cause non-uniform errors during testing.
2023-10-25 12:53:12 +02:00
Daniel Huigens
0e08abb3e2 When decrypting a v6 PKESK in constant-time, use the v2 SEIPD algorithm
Rather than using the config to determine which algorithms to try
to decrypt session keys for, try the algorithm we know the message
was encrypted with.
2023-10-25 12:53:12 +02:00
Daniel Huigens
7e382e6e43 Add support for PKESK v6
Also, set version in PKESK constructor to null,
requiring to explicitly set all fields.

Co-authored-by: Lukas Burkhalter <lukas.burkhalter@proton.ch>
2023-10-25 12:53:12 +02:00
Daniel Huigens
f77ed0c0ed Look up preferred ciphersuite in one go
Instead of calling getPreferredAlgo('symmetric') and
getPreferredAlgo('aead'), we define and call getPreferredCipherSuite()
to determine the preferred symmetric and AEAD algorithm.

Additionally, we remove isAEADSupported(), instead we return
aeadAlgorithm: undefined from getPreferredCipherSuite() if AEAD is not
supported (CFB is used instead).

And finally, we define getPreferredCompressionAlgo() to replace
getPreferredAlgo('compression').
2023-10-25 12:53:12 +02:00
Daniel Huigens
e5fe84dc2e Support SKESK v6 as per the latest crypto refresh
The latest crypto refresh specifies an HKDF step to be used for
deriving the key to encrypt the session key with.

It also specifies two additional length fields.
2023-10-25 12:53:12 +02:00
Daniel Huigens
6ae87b9208 Implement Padding Packet 2023-10-25 12:53:12 +02:00
Daniel Huigens
9d85938ed7 Implement SEIPD v2 2023-10-25 12:53:12 +02:00
Daniel Huigens
939622e827 Remove armor checksum check
The crypto refresh says that we MUST NOT reject messages where the
CRC24 checksum is incorrect. So, we remove the check for it.

Also, remove the checksumRequired config.
2023-10-25 12:53:12 +02:00
Daniel Huigens
6f1eb06119 For v6 keys, check direct-key signature for key properties
Key flags, expiration time, algorithm preferences, et cetera, are now
read from the direct-key signature instead of the primary User ID
binding signature for v6 keys.

This also requires a direct-key signature to be present for v6 keys.
2023-10-25 12:53:12 +02:00
Daniel Huigens
5391bcc1bc Update fallback (mandatory) AEAD algorithm to OCB
This has been changed in the crypto refresh.
2023-10-25 12:53:12 +02:00
Daniel Huigens
f21e327e69 Tests: update expected algorithm preferences 2023-10-25 12:53:12 +02:00
Daniel Huigens
2419e6b4c5 Remove compression algorithms from preferences 2023-10-25 12:53:12 +02:00
Daniel Huigens
762775bc03 Don't generate armor checksum lines 2023-10-25 12:53:12 +02:00
Daniel Huigens
b077504b3c Remove AES-192 from preferred symmetric algorithms
Chrome's Web Crypto implementation doesn't support it, and it
seems unnecessary to list it when AES-256 is available.
2023-10-25 12:53:12 +02:00
Daniel Huigens
5008f07808 Add preferred ciphersuites subpacket
This subpacket replaces both symmetric algorithm preferences and
AEAD algorithm preferences when AEAD is supported, by providing
sets of preferred symmetric and AEAD algorithm pairs.

We still keep the symmetric algorithm preferences in case AEAD is
not supported.
2023-10-25 12:53:11 +02:00
Daniel Huigens
b6dc112eb3 Add (non-experimental) GCM
Also, set it as the preferred AEAD algorithm.
2023-10-25 12:53:11 +02:00
Daniel Huigens
5078b8a66d Generate SEIPD v2 flag instead of AEAD flag
The AEAD Encrypted Data packet has been removed from the draft
in favor of version 2 of the Sym. Encrypted Integrity Protected
Data packet. It also has a new feature flag to match.
2023-10-25 12:53:11 +02:00
Daniel Huigens
bafdab20cf Don't require User IDs for v6 keys 2023-10-25 12:53:11 +02:00
Daniel Huigens
3ea21f6c6a For v6 keys, create direct-key signature for key properties
Store key flags, features and preferences in a direct-key signature
instead of user ID signatures, for V6 keys.
2023-10-25 12:53:11 +02:00
larabr
091be036f4 Rename enums.signatureSubpacket.issuer to .issuerKeyID
To reflect the subpacket rename in the crypto-refresh.
2023-10-25 12:53:11 +02:00
larabr
71ac6aff2f Only parse Issuer Key ID subpacket in v4 signatures
This packet must not be included in newer signature versions, but if it is
present it can cause internal inconsistencies, so we avoid parsing it.
2023-10-25 12:53:11 +02:00
Daniel Huigens
a5f1ab8a1c Add support for v6 signatures
Compared to v5 signatures, v6 signatures include a salt, and the
subpacket lengths are increased from 2 to 4 bytes.
2023-10-25 12:53:11 +02:00
Daniel Huigens
8816bd7541 Replace config.v5Keys with config.v6Keys flag
Also, don't generate v5 keys flag, which has been removed from the draft specification.
2023-10-25 12:53:11 +02:00
Daniel Huigens
31c2a2575d Add support for v6 key packets
Compared to v5 keys, v6 keys contain additional length fields to aid in
parsing the key, but omit the secret key material length field.

Additionally, unencrypted v6 secret key packets don't include the count
of the optional fields, as per the updated crypto refresh. Since they
are always absent, the count is not needed.

Finally, unencrypted v6 secret keys do not include the two-byte checksum.
2023-10-25 12:53:11 +02:00
larabr
4521de2bea HKDF: remove fallback for Node 14
v6 drops support for Node 14, which does not include SubtleCrypto
2023-10-25 12:53:11 +02:00
larabr
538b5b6304 Set Node 16 as minimum supported version in package.json 2023-10-25 12:53:11 +02:00
larabr
97b73489d1 Replace internal BigInteger code with that from noble-hashes
The noble-hashes fork uses the same fallback implementation,
except BN.js is always imported (due to lib contraints), so a dynamic import is now superfluous
2023-10-25 12:53:11 +02:00
larabr
6ef4392fb1 Lint: update config to support ESM imports 2023-10-25 12:53:11 +02:00
larabr
e07a0c432a Replace hash.js with noble-hashes 2023-10-25 12:53:11 +02:00
larabr
7c9549ce88 Drop config.minBytesForWebCrypto
WebCrypto performance is now on-par or better than non-native libs even for small messages
2023-10-25 12:53:11 +02:00
larabr
b3ef95e60e Tests: update sinon 2023-10-25 12:53:11 +02:00
larabr
b3574d6b3e CI: test all Node.js version even if some fail 2023-10-25 12:53:10 +02:00
larabr
6d477ea509 Add time benchmark test for streamed sign (testing hashing performance) 2023-10-25 12:53:10 +02:00
larabr
2377b2958d Use WebCrypto for streamed CFB encryption; for CFB/GCM/EAX, fallback to asmcrypto only if key size is not supported
CFB decryption is too slow using WebCrypto (CBC mode), since every block needs to be decrypted separately
2023-10-25 12:53:10 +02:00
larabr
21a6d83ec8 Update asmcrypto.js, use for AES only (move to noble-hashes for sha1, sha256) 2023-10-25 12:53:10 +02:00
larabr
0b2767fe4c Replace pako with fflate as compression lib
fflate already supports ESM and is actively maintained
2023-10-25 12:53:10 +02:00
larabr
1aefed9602 Fix streaming tests for browser, drop NodeReadableStream tests in Node.js
Unclear why the Node tests fails, but we're planning to drop support
2023-10-25 12:53:10 +02:00
larabr
b094274d98 Remove @private JSDoc directives interfering with TS 2023-10-25 12:53:10 +02:00
larabr
ae4ed1fbf3 Tests: explicitly share openpgp instance used in tests
Also, init config before any code is run in tests
2023-10-25 12:53:10 +02:00
larabr
d49d92e5cb Update to Mocha v10 in tests, declare lib as module and add exports to package.json
Mocha v10 requires the lib to be esm compliant.
ESM mandates the use of file extensions in imports, so to minimize the
changes (for now), we rely on the flag `experimental-specifier-resolution=node`
and on `ts-node` (needed only for Node 20).

Breaking changes:
downstream bundlers might be affected by the package.json changes depending on
how they load the library.
NB: legacy package.json entrypoints are still available.
2023-10-25 12:53:10 +02:00
larabr
3520a357f5 CI: drop Node 14 2023-10-25 12:53:10 +02:00
larabr
ebf22f2ee7 crypto-refresh: add support for Argon2 S2K (#1597)
In terms of API, this feature is backwards compatible, no breaking changes.
However, since a Wasm module is loaded for the Argon2 computation, browser apps
might need to make changes to their CSP policy in order to use the feature.

Newly introduced config fields:
- `config.s2kType` (defaulting to `enums.s2k.iterated`): s2k to use on
password-based encryption as well as private key encryption;
- `config.s2kArgon2Params` (defaulting to "uniformly safe settings" from Argon
RFC): parameters to use on encryption when `config.s2kType` is set to
`enums.s2k.argon2`;
2023-10-25 12:53:10 +02:00
larabr
204f32791d CI: temporarily enable for PRs to v6 branch 2023-10-25 12:53:10 +02:00
Daniel Huigens
e1ba0b2373 Use globalThis for setting test helper functions globals 2023-10-25 12:53:10 +02:00
Daniel Huigens
95c73738fa Update ESLint globals syntax 2023-10-25 12:53:10 +02:00
Daniel Huigens
de5549ff69 Remove embedded Web Streams ponyfill
Require the application to load a polyfill instead.
2023-10-25 12:53:10 +02:00
Daniel Huigens
cec4e029f0 Update web-stream-tools 2023-10-25 12:53:10 +02:00
larabr
7003d19c71 5.11.0 2023-10-25 12:04:48 +02:00
oofdog
111132238d
TS: Allow nullable date in VerifyOptions (#1644) 2023-10-23 13:39:33 +02:00
larabr
fe420d0bf9 Rename enums.curve.x25519Legacy to .curve25519Legacy
To keep name aligned with the spec.
2023-10-19 15:41:02 +02:00
larabr
410dbcf1d5
Fix Node 20 tests: always use NodeCrypto over WebCrypto (#1692)
This is also to uniform behaviour across Node versions for now.
2023-10-12 10:10:28 +02:00
larabr
96d6e76c05
Fix stream closure when using Node's stream.pipeline (#1691) 2023-10-11 17:30:36 +02:00
larabr
ed482a17c5
Merge pull request #1687
`crypto-refresh`: minor fixes and updates for X25519/Ed25519 (new format)
2023-10-10 13:06:09 +02:00
larabr
99ba76c695 Add enums.curve.ed25519Legacy and .x25519Legacy
Set to replace `enums.curve.ed25519` (resp. `.curve25519`), which can still be used everywhere,
but it will be dropped in v6.
Deprecation notices have been added to ease transition.
2023-10-10 11:36:47 +02:00
larabr
a12ca976a0 Reject signatures with hash digest shorter than 256-bit for ed25519
As mandated by the new crypto-refresh spec.
This applies to both the new and legacy EdDSA format.
For the legacy signatures, it is not expected to be a breaking change, since the spec
already mandated the use SHA-256 (or stronger).
2023-10-10 11:36:47 +02:00
larabr
c0f57dffb2 Do not clamp generated private key in X25519 (new format)
This was required by legacy ECDH over curve25519, but not for the new format.
Relevant spec: https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-10.html#name-curve25519legacy-ecdh-secre
2023-10-10 11:36:47 +02:00
larabr
b6fbab0443 Internally use createSignaturePacket helper whenever possible 2023-10-10 11:36:46 +02:00
larabr
1fd9d2f0c5 Fix binding signature generation using shorter hash than expected for some ECDSA subkeys
The required hash size was determined based on the subkey algo rather than the primary key.
As a result, if the subkey being certified required a shorter hash size than the ECDSA primary key,
the issued signature would include a shorter digest than expected.

This issue is not expected to have practical security impact, and
it only affected keys with ECDSA subkeys with smaller key sizes than their ECDSA primary key
(e.g. NIST p521 primary key and NIST p256 subkey).
2023-10-03 18:50:40 +02:00
larabr
01b02d6092 Always select SHA-256 or longer hash for Ed25519 signatures (new format)
Due to a bug, a shorter hash could be selected, and signing would throw as a result.
This change fixes the issue by automatically picking SHA-256, if needed.
The same was already done for legacy EdDSA signatures.
2023-10-03 18:50:40 +02:00
larabr
5b283550b7 Add enums.publicKey.eddsaLegacy
Set to replace `enums.publicKey.eddsa`, which can still be used everywhere,
but it will be dropped in v6.
Deprecation notices have been added to ease transition.
2023-10-03 18:50:36 +02:00
larabr
d6145ac73e 5.10.2 2023-09-18 14:47:25 +02:00
larabr
f90c53ae65 Minor: fix packet validity check for new curve25519 keys without key flags
The code used to wrongly consider e.g. x25519 keys without key flags as valid signing keys.
Keys without key flags are very rare nowadays, so this fix has low impact.
2023-09-18 14:25:45 +02:00
larabr
2ba8229d23
Fix CFB decryption performance in JS fallback for ciphers other than AES (#1679)
This issue affected non-AES ciphers (legacy), such as Cast5, in Node 18+ and in browser.
2023-09-18 14:14:49 +02:00
larabr
5d02e3a03e 5.10.1 2023-08-29 16:52:34 +02:00
larabr
6b43e02a25
Merge pull request from GHSA-ch3c-v47x-4pgp
Reject cleartext messages with extraneous data preceeding hash header
2023-08-29 16:49:28 +02:00
larabr
11b59994cf Reject cleartext messages with extraneous data preceeding hash header
Parsing of such messages will fail, as the data in the header is not verified,
and allowing it opens up the possibility of signature spoofing.
2023-08-29 16:30:35 +02:00
larabr
4df86e53a7 5.10.0 2023-08-29 14:59:17 +02:00
larabr
8d4dd349ae
Merge pull request #1620
Add support for new Ed25519/X25519 keys, signatures and messages,
as per crypto-refresh document.
2023-07-26 10:08:41 +02:00
larabr
5ae2846d97 CI: test on iOS Safari 14 instead of 15 to have access to SubtleCrypto
SubtleCrypto not available in the latter due to stricter secure context checks
2023-07-25 10:18:05 +02:00
larabr
b164190f6a Internal: rename Curves to CurvesWithOID
Following the addition of the new format for Montgomery curves,
which do not rely on OIDs.
2023-07-25 10:18:05 +02:00
larabr
ef953ce81e Add HKDF fallback for Node 14, where SubtleCrypto is not available 2023-07-25 10:18:00 +02:00
larabr
ee4ad89451 Enforce AES with PKESK v3 using x25519 (new format)
Fail on PKESK parsing as well as session key generation and encryption
2023-07-25 10:17:17 +02:00
larabr
1c07d268b8 crypto-refresh: add support for new X25519 key and PKESK format
As specified in openpgp-crypto-refresh-09.

Instead of encoding the symmetric key algorithm in the PKESK ciphertext (requiring padding),
the symmetric key algorithm is left unencrypted.

Co-authored-by: Lukas Burkhalter <lukas.burkhalter@proton.ch>
2023-07-25 10:17:09 +02:00
larabr
3f44082457 crypto-refresh: add support for new Ed25519 key and signature format
This addition is backwards compatible. We offer no way to generate v4 keys in the new format.
2023-07-13 11:58:40 +02:00
larabr
b6170aa40d
Merge pull request #1656
Fix forward compatibility of keys, SKESKs, and detached/cleartext signatures and ECDH.

Relevant for forward compatibility when:
- verifying **detached** or cleartext signatures that include e.g. v4 and v6 packets.
  Non-detached signatures are not affected.
- parsing messages with sym. encrypted session keys (SKESK) that rely on unsupported S2K types (e.g. argon2)
- parsing keys that include ECDH subkeys with unknown KDF params version
  (e.g. end-to-end encrypted forwarding use-case)
2023-07-10 19:38:39 +02:00
larabr
32caf41929 Fix parsing of ECDH with unknown KDFParam version
Keys with such subkeys should still be usable, as long as they have
a supported primary key.
2023-07-10 15:26:39 +02:00
larabr
f5b5b73f07 Fix parsing of messages with unsupported SKESK s2k type
These messages should still be decrypt-able if they include at least one
supported ESK packet.
2023-07-10 15:26:39 +02:00
larabr
9ed1135d74 Fix verification of cleartext signatures that include unknown signature packet versions 2023-07-10 15:26:39 +02:00
larabr
de2ffaf8e5 Fix verification of detached signatures that include unknown signature packet versions
Relevant for forward compatibility when verifying detached signatures
that include e.g. v4 and v6 packets
2023-07-10 15:26:39 +02:00
larabr
d72cece54a
Support parsing encrypted key with unknown s2k types or cipher algos (#1658)
Such keys are still capable of encryption and signature verification.
This change is relevant for forward compatibility of v4 keys encrypted using e.g. argon2.
2023-07-10 15:23:47 +02:00
larabr
400b163f84 5.9.0 2023-05-15 16:47:20 +02:00
larabr
33c19542af
Allow email addresses with trailing numbers in domain (#1642)
Domains such as .com09 are valid (see RFC1123)
2023-05-15 16:21:51 +02:00
larabr
1eb0b42387
TS: add declaration for verify with CleartextMessage input (#1640)
Also, make `VerifyMessageResult` generic. This change should be backwards
compatible since a default type is set.
2023-05-15 16:21:05 +02:00
Mart G
29d2b701c9
Add support for verifying User Attributes in verifyAllUsers (#1637)
Previously, `verifyAllUsers` would fail on keys with User Attributes.
Now, it returns a list of objects that have a either a non-null `userID`
property (in the case of User IDs) or a non-null `userAttribute`
property that contains the User Attribute packet.

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2023-05-15 15:40:53 +02:00
haryu703
785d24d0d2
Add revoke to Subkey in type definition (#1639) 2023-05-02 16:59:14 +02:00
Daniel Huigens
726ee55de4 5.8.0 2023-04-18 19:21:24 +02:00
Thomas Oberndörfer
ac223bb8a6
Fix shorthand check on user revoked status in getPrimaryUser method (#1623) 2023-04-04 14:57:34 +02:00
marinthiercelin
e63ab3db4f
CI: update SOP test suite docker image (#1628)
This new release uses Node v18 instead of v12.
2023-04-03 13:44:41 +02:00
Thomas Oberndörfer
0d025d8c3d
Add additionalAllowedPackets config option (#1618)
This config option allows parsing additional packet types when parsing
a packet list or armored object, in contexts where they are normally
not expected to appear, by passing a list of packet classes
(e.g. `additionalAllowedPackets: [PublicKeyPacket]`).
2023-03-30 15:52:11 +02:00
marinthiercelin
f72e34fefa
CI: add OpenPGP interoperability test suite (#1603) 2023-03-15 11:52:51 +01:00
Daniel Huigens
c60f2e3490 5.7.0 2023-02-21 19:14:36 +01:00
larabr
bb0c1f8a08
Merge pull request #1602 from larabr/update-deps-feb23 2023-02-21 19:00:03 +01:00
larabr
8ffd7aa1d4 Remove import cycles 2023-02-21 18:27:59 +01:00
larabr
94868e606a ESLint: drop unnecessary rules
Most rules are derived from the `airbnb` template.
Some "bad" rule exceptions remain, but they require too many changes to fix, so
we leave it to a future refactoring.
2023-02-21 18:27:59 +01:00
larabr
705f238e1e Update ESlint 2023-02-21 18:27:56 +01:00
larabr
1b17132631 Update deps 2023-02-21 18:25:28 +01:00
larabr
080b49a4ce
Merge pull request #1549 from larabr/test-update-karma-browsers 2023-02-21 16:16:55 +01:00
Daniel Huigens
0ffcc4970f
Remove default known notations (#1600)
Since we don't interpret these notations, it is up to the caller
to handle them, and thus also to decide whether they are "known".
If they are marked as critical, and aren't handled by the caller,
we should consider the signature unverified.
2023-02-20 19:05:30 +01:00
larabr
66844826c6 Skip native Crypto tests if native lib is not available 2023-02-20 16:08:19 +01:00
larabr
dcd28fadc6 CI: test latest Safari 2023-02-20 16:08:19 +01:00
larabr
18333999a2 CI: test latest browsers without Browserstack, cache build step across jobs 2023-02-20 16:08:10 +01:00
larabr
b083e1d067 Update Karma 2023-02-20 15:34:39 +01:00
Roman
5b92b80f79
Add selfCertification property to PrimaryUser interface definition (#1594)
Also, mark the `publicKeys` parameter of `Key.verifyAllUsers` as optional.
2023-02-17 17:03:32 +01:00
LucienLeMagicien
3e6e8d03a4
Docs: mark global generateSessionKeys's encryptionKeys as optional (#1596) 2023-02-17 13:05:25 +01:00
Daniel Huigens
71fef439ed
Add support for creating critical signature subpackets (#1599)
Assign most signature subpacket types a criticality based on whether
failing to interpret their meaning would negatively impact security.

For Notation Data subpackets, let the user indicate their criticality
using the `signatureNotations[*].critical` property.
2023-02-17 12:21:03 +01:00
Daniel Huigens
0307111993 5.6.0 2023-02-16 14:32:01 +01:00
Daniel Huigens
64ca5af879
Merge pull request #1598 from twiss/sig-notation-creation
Add support for creating Notation Data subpackets when signing or encrypting messages
2023-02-16 13:48:20 +01:00
Daniel Huigens
70778bc4c4 Test non-ASCII notation name 2023-02-16 11:47:38 +01:00
Daniel Huigens
911e0f5330 Use UTF-8 encoding for strings in signature subpackets 2023-02-16 11:46:37 +01:00
Daniel Huigens
fbd71f8dfe Update type definitions 2023-02-16 11:24:11 +01:00
Daniel Huigens
809deee3a6 Add signatureNotations option to sign and encrypt
This allows adding Notation Data signature subpackets when signing or
encrypting a message.
2023-02-15 19:42:45 +01:00
Daniel Huigens
375b03dcd4 Make signaturePacket.rawNotations[*].critical a boolean 2023-02-15 19:42:07 +01:00
Daniel Huigens
3a6e2d1661 Fix Notation Data signature subpacket creation 2023-02-15 19:42:07 +01:00
Fabien FORESTIER
2e4e05369c
TypeScript: add missing function definitions to Subkey class (#1588)
Add types for `Subkey.getExpirationTime()`, `.isRevoked()`, `.update()`
2023-02-09 23:15:18 +01:00
larabr
126ab53840
Remove internal, unused RandomBuffer (#1593)
The changes do not affect the public API:
`RandomBuffer` was used internally for secure randomness generation before
`crypto.getRandomValues` was made available to WebWorkers, requiring
generating randomness in the main thread.
As a result of the change, the internal `getRandomBytes()` and some functions
that use it are no longer async.
2023-02-09 23:11:53 +01:00
larabr
9175b76887
Docs: clarify Key.clone() behaviour (#1589) 2023-02-09 23:07:27 +01:00
Markus Wolf
50ea1ac889
README: add TypeScript setup notice (#1586)
Mention that the library needs types from `@openpgp/web-stream-tools`.
2023-01-30 14:35:47 +01:00
Thomas Oberndörfer
4dbfcc5043
Add revoke method to User (#1584) 2023-01-24 16:34:58 +01:00
Roman
7a1a67c718
TypeScript: fix signature of armor function: add customComment (#1585) 2023-01-19 16:45:18 +01:00
Roman
2bc07996fa
TypeScript: fix SymEncryptedSessionKeyPacket type name (#1583)
Co-authored-by: DESKTOP-KRJIM7J\Roman <rrrooommmaaa@outlook.com>
2023-01-04 17:41:58 +01:00
Leo Kotschenreuther
4379bfb7ec
TypeScript: fix signature of armor function (#1576)
The `partIndex` and `partTotal` params of the `armor` function are
optional. This commit updates the openpgp.d.ts file to reflect this.
2022-11-16 14:18:06 +01:00
Leo Kotschenreuther
2f8a8c1c9a
TypeScript: add SignaturePacket.rawNotations (#1571) 2022-10-24 14:23:37 +02:00
larabr
04488af790 Bump package lock version 2022-10-24 14:15:04 +02:00
larabr
9a935ed559 CI: move away from Node.js v12
Github is deprecating it in Actions, and it's already past EOL
2022-10-24 14:15:04 +02:00
Daniel Huigens
5957bab2e2
Allow use of Brainpool curves by default (#1563)
These curves have been merged back into the editor's draft of the
crypto refresh.
2022-10-12 13:15:56 +02:00
Daniel Huigens
d0be98feb9 5.5.0 2022-08-31 13:56:51 +02:00
Daniel Huigens
9f3985d398
Hash all signature subpackets (#1562)
Move the Issuer, Issuer Fingerprint, and Embedded Signature subpackets
to the hashed subpackets for new signatures. While we allow these to be
unhashed, it's safer to hash them, and this simplifies the code as well.
2022-08-30 16:36:17 +02:00
wussler
000e1335a2
Leave unhashed subpackets as-is when re-serializing signatures (#1561)
When re-serializing a signature packet, don't add Issuer, Issuer
Fingerprint, and Embedded Signature subpackets to the unhashed
subpackets if they weren't already there.

Also, store all unhashed subpackets in `signature.unhashedSubpackets`,
not just the "disallowed" ones.
2022-08-30 13:46:05 +02:00
Daniel Huigens
5e6dd8b1ed
Remove leading newline from clearsigned messages armoring (#1560) 2022-08-30 13:40:57 +02:00
Celine Moredo
4d2cf85a51
Ignore improperly formatted armor headers (#1557)
Show a debug warning instead of throwing an error on malformed headers.
2022-08-22 15:30:33 +02:00
larabr
93644b7c58
printDebug: add label to identify source of the log (#1555) 2022-08-17 18:54:53 +02:00
larabr
ca60884c05 5.4.0 2022-08-08 13:49:52 +02:00
larabr
50fa974dcc
CI: run worker tests first to give enough time to download the required scripts (#1550)
This should fix issues with Safari 13 not managing to load the worker in BrowserStack Automate.
2022-08-08 13:28:40 +02:00
larabr
08eef424a0
TypeScript: add missing allowInsecureVerificationWithReformattedKeys field to Config (#1551) 2022-08-04 18:55:51 +02:00
larabr
dc85a5088f
Fix CleartextMessage signature generation over text with trailing whitespace and \r\n line endings
Signing a `CleartextMessage` containing trailing whitespace and \r\n line
endings (as opposed to \n) would result in an unverifiable signature. The issue
seems to have been present since v3.0.9 . These broken signatures were
unverifiable even in the OpenPGP.js version(s) that generated them.
2022-08-02 17:50:45 +02:00
larabr
e862d5f20b
Throw in encryptSessionKey if no keys or passwords are provided (#1547)
Previously, the operation would return an empty message.
2022-07-27 17:47:47 +02:00
Daniel Huigens
bd1a7db46f Use npm ci instead of npm install in release script
In order not to update the package-lock.json file during releases.
2022-06-29 21:15:18 +02:00
Daniel Huigens
dd2aa7c5ec Revert package lock version bump 2022-06-29 21:07:10 +02:00
Daniel Huigens
5c02953b1c 5.3.1 2022-06-29 21:02:15 +02:00
Daniel Huigens
04e806e0b4
Support Node.js 18 (#1542)
Recent Node.js seems to have dropped support for ripemd160.
Thus, properly check the availability of hashes before using them.

Also, add Node.js 18 to CI.
2022-06-29 20:59:38 +02:00
Daniel Huigens
e69d8b24fc
Fix armor error handling (#1541)
Fix unhandled promise rejections when parsing armor with malformed footers.
2022-06-29 20:09:30 +02:00
Daniel Huigens
449ec3a367 Fix CNAME and make docs script portable 2022-06-09 12:54:22 +02:00
larabr
b677ab5949 5.3.0 2022-06-08 16:10:17 +02:00
larabr
6c32b62ef3
Throw on decryption of messages that don't contain any encrypted data packet (#1529)
Calling `openpgp.decrypt` with a message that contains encrypted session keys
followed by a non-encrypted packet (e.g. Literal or Compressed Data packet)
used to succeed, even if a wrong passphrase/key was provided.
With this change, the operation will always fail, and the user is warned that
the data was not encrypted.

NB: a message that did not contain any encrypted session key packet would fail
to decrypt even prior to this change.
2022-06-07 14:29:31 +02:00
larabr
ef066183dd
Throw UnsupportedError on unknown algorithm in keys, signatures and encrypted session keys (#1523)
The relevant packets will be considered unsupported instead of malformed.
Hence, parsing them will succeed by default (based on
`config.ignoreUnsupportedPackets`).
2022-06-07 13:51:58 +02:00
Justin Lovell
a822dd817b
Add memory benchmark tests for streamed decryption of large files (#1462)
Also, provide more details about `config.allowUnauthenticatedStream`.
2022-06-02 17:29:27 +02:00
larabr
775dade80f
Add UnparseablePacket to properly deal with key blocks that include malformed/unsupported packets (#1522)
When parsing errors are being ignored, packets that fail to parse are now
included in the resulting packet list as `UnparseablePacket`s . This way, when
parsing keys that contain unparsable (sub)key, we avoid associating the
following non-key packets to the wrong key entity.

On serialization, `UnparseablePacket`s are also included by writing their raw
packet body as it was read.
2022-05-24 20:12:57 +02:00
larabr
cb8901c16d
Fix loading browser built in JSDom environment (#1518) 2022-05-12 17:29:52 +02:00
larabr
4713282bb1
Throw on empty passphrase in encryptKey and SecretKeyPacket.encrypt (#1508)
Breaking change: `openpgp.encryptKey` now throws if an empty string is given as
passphrase. The operation used to succeed, but the resulting key was left in an
inconsistent state, and e.g. serialization would not be possible.

Non-breaking changes:
- `options.passphrase` in `generateKey` and `reformatKey` now defaults to
`undefined` instead of empty string. Passing an empty string does not throw for
now, but this might change in the future to align with `encryptKey`'s
behaviour.
- In TS, add `GenerateKeyOptions` as alias of `KeyOptions`, to clarify its
scope.
2022-03-22 15:11:51 +01:00
Daniel Huigens
d677c30359 5.2.1 2022-03-15 14:59:45 +01:00
larabr
36985c92dc
Lint: error if imported value not found in module (#1507) 2022-03-14 21:40:16 +01:00
larabr
2e867956eb
Fix AES encryption error in browsers for messages larger than 3MB (#1506)
In browsers, encryption of messages larger than 3MB (or a custom value
based on `config.minBytesForWebCrypto`) would throw the error `Error encrypting
message: 'crypto.getCipher' is not a function`.

The issue was introduced in v5.1 .
2022-03-14 19:39:15 +01:00
larabr
d89cc48bf3
TypeScript: rely on new web-stream-tools types, fix SignOptions (#1502)
The updated stream types improve type inference and checks, in particular when
using ReadableStreams.

Also:
- add `EncryptSessionKeyOptions` to make it easier to declare wrapper functions
of `encryptSessionKey`;
- tighter output type inference in `Message.getText()` and `.getLiteralData()`.
2022-03-09 17:00:12 +01:00
Daniel Huigens
a1ef5f509f 5.2.0 2022-03-02 21:35:43 +01:00
larabr
7aaa34ddfc
CI: update mocha (#1503)
Update to mocha@8 instead of 9 because the latter dropped support for `--require
esm`, hence using it would require more extensive changes.
2022-03-01 16:34:52 +01:00
Ivan Pizhenko
e5c7c77362
TypeScript: fix data argument type in SignaturePacket.verify() (#1494) 2022-02-18 20:20:50 +01:00
Daniel Huigens
f93f59e2e5
Check existence of navigator before using it (#1475) 2022-02-11 13:33:43 +01:00
Daniel Huigens
f54b133085
Drop MS Edge Legacy support (#1474) 2022-02-10 21:31:32 +01:00
Ivan Pizhenko
255926ab19
TypeScript: mark signature arg as optional in Key.isRevoked() and remove SignaturePacket.verified (#1486) 2022-02-10 21:13:34 +01:00
Daniel Huigens
717f6bffe4 Update web-stream-tools 2022-02-01 16:24:52 +01:00
Daniel Huigens
917b5e51c2 Persist docs/CNAME after release 2022-01-25 18:53:32 +01:00
Daniel Huigens
d5d8de36f5
Create CNAME 2022-01-25 12:17:49 +01:00
Daniel Huigens
bd13edfc88 5.1.0 2022-01-24 18:38:46 +01:00
larabr
22a68878e4
Add support for constant-time decryption of PKCS#1 v1.5-encoded session keys (#1445)
Implement optional constant-time decryption flow to hinder Bleichenbacher-like
attacks against RSA- and ElGamal public-key encrypted session keys.

Changes:
- Add `config.constantTimePKCS1Decryption` to enable the constant-time
processing (defaults to `false`). The constant-time option is off by default
since it has measurable performance impact on message decryption, and it is
only helpful in specific application scenarios (more info below).
- Add `config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms`
(defaults to the AES algorithms). The set of supported ciphers is restricted by
default since the number of algorithms negatively affects performance.

Bleichenbacher-like attacks are of concern for applications where both of the
following conditions are met:
1. new/incoming messages are automatically decrypted (without user
interaction);
2. an attacker can determine how long it takes to decrypt each message (e.g.
due to decryption errors being logged remotely).
2022-01-19 19:05:43 +01:00
Austin Schmidli
a6c849166d
Update documentation link (#1455) 2021-12-21 11:32:31 +01:00
Hexagon
ce5174dd21
Initial Deno support (#1448) 2021-12-07 14:07:46 +01:00
larabr
d6139daa79
CI: use Node v16 instead of v15 2021-12-01 17:40:33 +01:00
larabr
6fc005f19c
Check key requirements in PrivateKey.addSubkey() (#1423)
Breaking change:
when generating new subkeys through `key.addSubkey()`, we now check
`config.rejectCurves` and prevent adding subkeys using the corresponding
curves.
By default, `config.rejectCurves` includes the brainpool curves
(`brainpoolP256r1`, `brainpoolP384r1`, `brainpoolP512r1`) and the Bitcoin curve
(`secp256k1`).

This is a follow up to #1395 , which introduced the same check to
`openpgp.generateKey`.
2021-12-01 17:04:02 +01:00
Bart Butler
2894b35d66 Create CNAME 2021-11-29 13:10:57 +01:00
Daniel Huigens
9e547bf6e4 Rename master branch to main 2021-11-23 12:10:57 +01:00
larabr
6da1c53de7
Replace strings with integer algorithm identifiers in packet classes (#1410)
In several packet classes, we used to store string identifiers for public-key,
aead, cipher or hash algorithms. To make the code consistent and to avoid
having to convert to/from string values, we now always store integer values
instead, e.g. `enums.symmetric.aes128` is used instead of `'aes128'`.

This is not expected to be a breaking change for most library users. Note that
the type of `Key.getAlgorithmInfo()` and of the session key objects returned
and accepted by top-level functions remain unchanged.

Affected classes (type changes for some properties and method's arguments):
- `PublicKeyPacket`, `PublicSubkeyPacket`, `SecretKeyPacket`,
`SecretSubkeyPacket`
- `SymEncryptedIntegrityProtectedDataPacket`, `AEADEncryptedDataPacket`,
`SymmetricallyEncryptedDataPacket`
- `LiteralDataPacket`, `CompressedDataPacket`
- `PublicKeyEncryptedSessionKey`, `SymEncryptedSessionKeyPacket`
- `SignaturePacket`

Other potentially breaking changes:
- Removed property `AEADEncryptedDataPacket.aeadAlgo`, since it was redudant
given `.aeadAlgorithm`.
- Renamed `AEADEncryptedDataPacket.cipherAlgo` -> `.cipherAlgorithm`
2021-11-22 11:51:27 +01:00
larabr
03fa68dbb6
CI: create annotations on performance regression warnings/errors (#1441) 2021-11-18 14:24:16 +01:00
Daniel Huigens
05e435aae7 5.0.1 2021-11-17 21:46:14 +01:00
Daniel Huigens
1d2093ab0a
Update web stream tools and improve performance (#1439)
Optimize reading literal data packet from ArrayStreams, and update
web-stream-tools (with various performance improvements).
2021-11-17 21:34:04 +01:00
Daniel Huigens
a17a7200b8
Remove line terminators from randomly generated test messages (#1440)
Remove line separators (U+2028) and paragraph separators (U+2029)
from randomly generated test messages. These messages cause the
test to fail due to the difference in handling them between
multiline regexes and OpenPGP.js-internal functions.
2021-11-17 12:11:54 +01:00
larabr
cfeef41d61
Do not include checksum values in error messages when armor integrity check fails (#1428) 2021-10-21 16:14:46 +02:00
larabr
88b1380a54
Add config.allowInsecureVerificationWithReformattedKeys (#1422)
Using `openpgp.reformatKey` with the default `date` option would render
messages signed with the original key unverifiable by OpenPGP.js v5 (not v4),
since the signing key would not be considered valid at the time of signing (due
to its self-certification signature being in the future, compared to the
message signature creation time).

This commit adds `config.allowInsecureVerificationWithReformattedKeys` (false
by default) to make it possible to still verify such messages with the
reformatted key provided the key is valid at the `date` specified for
verification (which defaults to the current time).
2021-10-18 18:10:04 +02:00
larabr
b7527f7966
CI: Add memory usage regression monitoring for pull requests (#1415) 2021-10-15 16:16:34 +02:00
larabr
421733e21b
CI: Add performance regression monitoring for pull requests (#1411) 2021-10-14 18:59:14 +02:00
lee-orr
df7e690469
Try to use process.env.NODE_ENV directly (#1402)
Support build processes that replace `process.env.NODE_ENV` with a
constant string (such as webpack and Vite) by using
`process.env.NODE_ENV` directly, instead of `globalThis.process &&
globalThis.process.env.NODE_ENV`, but do so inside a try/catch in case
`process` is not defined.

Co-authored-by: Daniel Huigens <d.huigens@protonmail.com>
2021-10-07 18:02:49 +02:00
Kevin Moutet
fc42c38706
Remove stream from type definitions (#1413) 2021-09-06 11:22:32 +02:00
Daniel Huigens
acafb28661 5.0.0 2021-09-02 17:09:02 +02:00
Daniel Huigens
4f1c474433 5.0.0-6 2021-08-20 15:34:03 +02:00
larabr
a599638ce2
Docs: clarify content of returned signatures value in openpgp.verify and decrypt 2021-08-19 17:58:52 +02:00
larabr
3fa778abe2
Add config.rejectCurves and prevent generating keys using blacklisted algorithms (#1395)
Breaking changes:
- throw error on key generation if the requested public key algorithm is
included in `config.rejectPublicKeyAlgorithms`;
- add `config.rejectCurves` to blacklist a set of ECC curves, to prevent keys
using those curves from being generated, or being used to
encrypt/decrypt/sign/verify messages.
By default, `config.rejectCurves` includes the brainpool curves
(`brainpoolP256r1`, `brainpoolP384r1`, `brainpoolP512r1`) and the Bitcoin curve
(`secp256k1`). This is because it's unclear whether these curves will be
standardised[1], and we prefer to blacklist them already, rather than introduce
a breaking change after release.

[1] https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/47#note_634199141
2021-08-19 17:58:16 +02:00
larabr
f57d3527d3
Set default config.minRSABits to 2047 (#1392)
Lower the default allowed RSA key size to ensure that (most) keys generated in
v4 without WebCrypto are supported (see #1336).
2021-08-19 17:53:06 +02:00
Daniel Huigens
f59b0dec60 5.0.0-5 2021-07-23 19:00:19 +02:00
larabr
da60fa0047
Add security policy (#1388) 2021-07-23 14:06:34 +02:00
larabr
d9829fce06
Throw on unrecognised configuration in top-level functions (#1387)
Breaking change: passing non-existing configuration options to top-level
functions now results in an error, to make users aware that the given
configuration cannot be applied.
2021-07-23 14:00:08 +02:00
larabr
4b6189b91b
Rename config.tolerant to config.ignoreUnsupportedPackets, add config.ignoreMalformedPackets (#1386)
Configuration options related to parsing have been changed to make it possible
to try to read messages containing malformed packets. Changes:
- rename `config.tolerant` to `config.ignoreUnsupportedPackets`. This still
defaults to `true`.
- Add `config.ignoreMalformedPackets` to ignore packets that fail to parse
(when possible). This option was not available before and it defaults to `false`.
2021-07-23 13:22:18 +02:00
Lucas Longarini
3cd61ff1b4
TypeScript: add missing config options to the type definitions (#1385) 2021-07-23 13:07:07 +02:00
larabr
7ebdd6a2a6
Update dependencies (#1383) 2021-07-23 12:59:39 +02:00
Daniel Huigens
1837077012 5.0.0-4 2021-07-20 19:41:10 +02:00
Daniel Huigens
5e997605b3 Update web-stream-tools 2021-07-20 19:06:31 +02:00
Ali Cherry
85d129af77
Export Subkey class (#1381) 2021-07-20 10:54:29 +02:00
larabr
1ac71a94a5
Github: add ISSUE_TEMPLATES (#1369) 2021-07-19 19:16:01 +02:00
larabr
b604458ba8
Rename format: 'armor' option to format: 'armored' in top-level functions (#1377)
The `format` option in `openpgp.generateKey, reformatKey, revokeKey, encrypt,
sign, encryptSessionKey` now expects the value `'armored'` instead of `'armor'`
to output armored data. The other format options (i.e. `'binary'` and
`'object'`) remain unchanged.
2021-07-19 19:08:49 +02:00
larabr
ce70484738
Replace armor option with format in openpgp.encrypt, sign and encryptSessionKey (#1354)
Breaking changes:
- a new `format` option has been added to `openpgp.encrypt`, `sign` and
`encryptSessionKey` to select the format of the output message. `format`
replaces the existing `armor` option, and accepts three values:
   * if `format: 'armor'` (default), an armored signed/encrypted message is
returned (same as `armor: true`).
   * if `format: 'binary'`,  a binary signed/encrypted message is returned (same
as `armor: false`).
   * if `format: 'object'`, a Message or Signature object is returned (this was
not supported before).
This change is to uniform the output format selection across all top-level
functions (following up to #1345).

- All top-level functions now throw if unrecognised options are passed, to make
library users aware that those options are not being applied.
2021-07-19 18:12:42 +02:00
Nick Darvey
53f54e1e19
Extend BaseStream<> from AsyncIterable<> (#1373)
Both Web ReadableStreams and Node.js streams are async iterable objects.
2021-07-15 13:09:29 +02:00
Akihito Mikazuki
e450582888
Update README to use openpgp.readPrivateKey() where applicable (#1362) 2021-07-09 18:05:09 +02:00
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
ed8db3d31e
CI: Ignore unhandled rejections in tests in Safari 14.1 (#1371)
The tests fail in Safari 14.1 due to unhandled rejections that have no clear
cause. The problem is likely related to the native TransformStream
implementation added in Safari 14.1 (in fact, using a polyfilled
TransformStream solves all issues).
2021-07-09 16:35:40 +02:00
larabr
ab22fe86da
Lint: enforce single quotes and do not error on class methods without this (#1341) 2021-06-24 22:58:15 +02:00
larabr
d238a023c1
Support using Key.isPrivate() for type inference, remove Key.isPublic() (#1347)
API changes:
- `Key.isPublic()` has been removed, since it was redundant and it would
introduce TypeScript issues. Call `!Key.isPrivate()` instead.

TypeScript changes:
- the `openpgp.readKey(s)` functions are now declared as returning a `Key`
instead of a `PublicKey`. This is just a readability improvement to make it
clearer that the result could also be a `PrivateKey`.
- All `Key` methods that return a key object now have the narrowest possible
return type.
- The `Key.isPrivate()` method can now be used for type inference, allowing the
compiler to distinguish between `PrivateKey` and `PublicKey`. 

Calling `key.isPrivate()` is the recommended way of distinguishing between a
`PrivateKey` and `PublicKey` at runtime, over using `key instanceof ...`, since
the latter depends on the specifics of the `Key` class hierarchy.
2021-06-24 19:53:10 +02:00
larabr
f50abd81a1
Support passing a non-array value to encryption/signingKeyIDs in top-level functions (#1342)
- Support passing a single Key ID directly to the `encryption/signingKeyIDs`
options of `openpgp.encrypt`, `sign`, `generateSessionKey` and
`encryptSessionKey`.
- Add type definitions for `openpgp.encryptSessionKey` and `decryptSessionKeys`.
2021-06-24 17:51:18 +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
b862e139fc
TypeScript: make packets, keyPacket and mainKey readonly properties (#1337)
The following fields are now `readonly` instead of `private`:
- `Key.keyPacket`
- `Subkey.keyPacket` and `Subkey.mainKey`
- `Signature.packets`
- `Message.packets`
2021-06-23 12:36:37 +02:00
larabr
b76236755a
Ignore Trust and Marker packets on parsing and always throw on unexpected packets (#1340)
- When parsing, throw on unexpected packets even if `config.tolerant = true`
(e.g. if a Public Key packet is found when reading a signature).
- Always ignore Trust and Marker packets on parsing.
- Fix #1145: correctly verify signatures that include Marker packets when
`config.tolerant = false`.
2021-06-23 12:17:29 +02:00
Dan Habot
a9252c6649
Add Signature#getSigningKeyIDs method to get Issuer Key IDs from a Signature (#1331) 2021-06-16 11:46:49 +02:00
larabr
619d02d78c
Drop capabilities, keyID args in Key.getExpirationTime() and consider direct-key sigs (#1319)
- Fix #1159: `Key.verifyPrimaryKey` considers expiration time subpackets in
direct-key signatures to determine whether the key is expired.
- `Key.getExpirationTime()` does not take the `capabilities` and `keyID` arguments
anymore, and simply returns the expiration date of the primary key. Also, like
for `verifyPrimaryKey`, direct-key signatures are now taken into account.
- Keys and signatures are considered expired at the time of expiry, instead of
one second later.

Breaking change:
`Key.getExpirationTime(capabilities, keyID, userID, config)` ->
`.getExpirationTime(userID, config)`
2021-06-15 19:16:52 +02:00
larabr
bccdabbc45
Always generate RSA keys of exact bit length (#1336)
Fix RSA key generation code used when no native crypto library is available
(i.e. no NodeCrypto or WebCrypto). Now generated keys are always of exact bit
length. This was not guaranteed before, and it was common for keys to be one
bit shorter than expected.

Also, remove leftover code related to legacy WebCrypto interfaces (for IE11 and
Safari 10).
2021-06-15 18:07:36 +02:00
larabr
1166de205c
Remove primaryKey argument from User methods, rename User.sign to User.certify (#1329)
- Add `User.mainKey` field to store a reference to the corresponding `Key`,
allowing to simplify calling some `User` methods.
- Rename `User.sign` to `User.certify`, since it's used for third-party
certifications and not as a counterpart of `User.verify`, which deals with
self-signatures.
- Change `Key.update` behaviour to store a copy of newly added users and
subkeys. Pointing to the same instance could give issues as the lists of
certifications and signatures could be altered by both the source key and the
updated one.

Breaking changes in `User` methods:
- `User.constructor(userPacket)` -> `constructor(userPacket, mainKey)`
- `User.sign(primaryKey, signingKeys, date, config)` -> `.certify(signingKeys,
date, config)`
- `User.verify(primaryKey, date = new Date(), config)` -> `.verify(date = new
Date(), config)`
- `User.verifyCertificate(primaryKey, certificate, verificationKeys, date = new
Date(), config)` -> `.verifyCertificate(certificate, verificationKeys, date =
new Date(), config)`
- `User.verifyAllCertifications(primaryKey, verificationKeys, date = new
Date(), config)` -> `.verifyAllCertifications(verificationKeys, date = new
Date(), config)`
- `User.isRevoked(primaryKey, certificate, keyPacket, date = new Date(),
config)` -> `.isRevoked(certificate, keyPacket, date = new Date(), config)`
- `User.update(sourceUser, primaryKey, date, config)` -> `.update(sourceUser,
date, config)`
2021-06-15 17:42:00 +02:00
larabr
e785df4c8f
Require keys in openpgp.sign and make all top-level functions fully async (#1318)
- `openpgp.sign` throws if no signing keys are given, instead of returning a
non-signed literal packet.
- Any top-level function error will cause Promise rejection, and can thus be
handled with `.catch()`.
2021-06-15 17:21:18 +02:00
larabr
b4e53b3ff7
CI: Detect unhandled rejections in browser tests (#1333)
Also, target the Safari release for macOS Big Sur in Browserstack.
2021-06-15 16:39:56 +02:00
Daniel Huigens
df2240ba08
CI: Check that JSDoc comments are valid (#1328)
Also, fix a JSDoc comment.
2021-06-14 11:15:37 +02:00
larabr
1484df9b8f
Uniform casing of subkey(s): rename Key.subKeys to Key.subkeys (#1310)
Also, rename `SubKey` class to `Subkey`
2021-06-10 11:25:43 +02:00
Ali Cherry
ead266507e Throw if privateKeys/publicKeys are passed to top-level functions (#1327) 2021-06-09 13:23:13 +02:00
larabr
0e088aec28
Fix various signature verification issues (#1302)
- Throw on signature parsing (e.g. in `openpgp.readSignature`) if the
  creation time subpacket is missing
- `SignaturePacket.verify` now directly checks for signature creation
  and expiration times. This makes it easier to thoroughly check the
  validity of signatures. Also:
  - `openpgp.revokeKey` now takes a `date` to check the provided
    revocation certificate
  - `openpgp.decryptSessionKeys` now takes a `date` to check the
    validity of the provided private keys
  - whenever a `date` is used internally, the function accepts a
    `date` param to allow passing the correct date
- Add tests for all of the above
- Like `openpgp.generateKey`, `openpgp.reformatKey` now also requires
  `options.userIDs`
- Simplify calling `SubKey.isRevoked/update/getExpirationTime` by
  adding the `SubKey.mainKey` field to hold the reference of the
  corresponding `Key`

Breaking changes in low-level functions:
- Added/removed `date` params:
  - `Key.update(key, config)` -> `update(key, date, config)`
  - `Key.applyRevocationCertificate(revocationCertificate, config)` ->
    `applyRevocationCertificate(revocationCertificate, date, config)`
  - `Key.signAllUsers(privateKeys, config)` ->
    `signAllUsers(privateKeys, date, config)`
  - `Key.verifyAllUsers(keys, config)` ->
    `verifyAllUsers(keys, date, config)`
  - `new SignaturePacket(date)` -> `new SignaturePacket()`
  - `SignaturePacket.sign(key, data, detached)` ->
    `sign(key, data, date, detached)`
  - `Message.sign(primaryKey, privateKeys, config)` ->
    `sign(primaryKey, privateKeys, date, config)`
  - `Message.decrypt(privateKeys, passwords, sessionKeys, config)` ->
    `decrypt(privateKeys, passwords, sessionKeys, date, config)`
  - `Message.decryptSessionKeys(privateKeys, passwords, config)` ->
    `decryptSessionKeys(privateKeys, passwords, date, config)`
- Removed `primaryKey` params:
  - `SubKey.isRevoked(primaryKey, signature, key, date, config)` ->
    `isRevoked(signature, key, date, config)`
  - `SubKey.update(subKey, primaryKey, date, config)` ->
    `update(subKey, date, config)`
  - `SubKey.getExpirationTime(primaryKey, date, config)` ->
    `getExpirationTime(date, config)`
2021-06-08 18:12:48 +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
Daniel Huigens
1bff8aad50 5.0.0-3 2021-05-28 17:36:43 +02:00
Daniel Huigens
1836c40468 Fix JSDoc type 2021-05-28 17:34:59 +02:00
Daniel Huigens
0ca83cf121 Switch from Uint8Array.from to new Uint8Array 2021-05-28 17:08:13 +02:00
Daniel Huigens
5ae7fc4444 Update pako 2021-05-26 10:51:25 +02:00
larabr
f028026217
Replace Key with PrivateKey and PublicKey classes (#1300)
- Add `PrivateKey` and `PublicKey` classes. A `PrivateKey` can always
  be passed where a `PublicKey` key is expected, but not vice versa.
- Unexport `Key`, and export `PrivateKey` and `PublicKey`. 
- Rename `Key.packetlist2structure` to `Key.packetListToStructure`.
- Change `Key.update` to return a new updated key, rather than
  modifying the destination one in place.
- Add `openpgp.readPrivateKey` and `openpgp.readPrivateKeys` to avoid
  having to downcast the result of `readKey(s)` in TypeScript.
2021-05-25 19:18:47 +02:00
Yash Murty
3349fab89e
Fix link in README's table of contents (#1307) 2021-05-21 18:07:52 +02:00
Ali Cherry
6299c6dd77
Rename public/privateKeys to encryption/decryption/signing/verificationKeys (#1299)
- Rename `publicKeys` to `encryptionKeys` or `verificationKeys` depending on their use
- Rename `privateKeys` to `decryptionKeys` or `signingKeys` depending on their use
- Similarly, rename `toUserIDs` to `encryptionUserIDs` and `fromUserIDs` to `signingUserIDs`
2021-05-17 18:56:28 +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
31fe960261
Only ignore unsupported packets when config.tolerant is set (#1298)
Don't ignore parse errors if `config.tolerant` is enabled. This leads to
more useful error messages in most cases, as ignoring these errors will
most likely still lead to an error down the line (e.g. if a key binding
signature is missing). Unsupported and unknown packets and packets with
an unsupported or unknown version are still ignored, for forward
compatibility.

Also, make `PKESK.encrypt`/`decrypt` void.
2021-05-05 19:51:33 +02:00
larabr
02a1ed2d78
Make key fingerprint computation async (#1297)
- Make fingerprint and key ID computation async, and rely on Web Crypto
  for hashing if available
- Always set fingerprint and keyID on key parsing / generation
- Introduce `*KeyPacket.computeFingerprint()` and
  `*KeyPacket.computeFingerprintAndKeyID()` 
- Change `getKeyID` and `getFingerprint*` functions to return the
  pre-computed key ID and fingerprint, respectively
- Make `PublicKeyPacket.read` async
2021-05-05 17:39:19 +02:00
larabr
247ad58344
Add PacketList.fromBinary and add missing config param in some functions (#1294)
- Add `PacketList.fromBinary` which parses binary data and returns a
  `PacketList`. Using it instead of `PacketList.read` avoids being left
  with partially read data in case of errors.
- Rename `toPacketlist` to `toPacketList` in `Key`, `Subkey` and `User`
  classes
- In `readMessage`, pass down `config` to `PacketList.read`
- Add `config` param to `CompressedDataPacket.decompress`,
  `AEADEncryptedDataPacket.decrypt` and `Message.appendSignature`
2021-05-05 16:56:11 +02:00
larabr
aeddac438e
Make PacketList a valid subtype of Array and update Packet.tag types (#1289)
Changes:
- Implementation:
  - Remove `PacketList.prototype.concat` and `push`
    (we solely rely on `Array.push` instead)
  - Fix https://github.com/openpgpjs/openpgpjs/issues/907 by
    correctly handling result of `filterByTag`
  - Implement `write()` method for `Trust` and `Marker` packets,
    to make them compatible with the `BasePacket` interface
- Types:
  - Simplify and updated `PacketList` type definitions
  - Fix types for `Packet.tag`, which is `static` since
    https://github.com/openpgpjs/openpgpjs/pull/1268
  - Prevent passing SubkeyPackets where KeyPackets are expected,
    and vice versa
2021-04-29 17:18:39 +02:00
Daniel Huigens
2d07c43030 5.0.0-2 2021-04-27 14:00:54 +02:00
Daniel Huigens
28c5902419 Fix JSDoc types 2021-04-27 13:58:39 +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
Kostis Andrikopoulos
39aa742c7a
Fix encoded length in unencrypted v5 secret key packets (#1278)
When unencrypted secret key packets are serialized, a 2-byte checksum is
appended after the key material. According to rfc4880bis, these 2 bytes are
not included in the length of the key material (this encoded length is a new
addition of rfc4880bis, specific to v5 keys). We erroneously included them,
causing other implementations to fail to parse unencrypted v5 private keys
generated by OpenPGP.js.
2021-04-06 15:00:45 +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
5299561aa3 Clean up async function JSDocs 2021-03-28 16:07:56 +02:00
Daniel Huigens
e3cfa4f9dd Revert "Don't mark async function as returning a Promise explicitly"
This reverts commit 9e85f75519dbb65c391bee08ee20b9e5a8284733.

It made VS Code / TypeScript complain about unnecessary `await`s.
2021-03-28 15:39:19 +02:00
Kevin Moutet
b8c07d6343
Fix createMessage return type in type definitions (#1276) 2021-03-27 22:22:33 +01:00
Daniel Huigens
eb496d2018 CI: Test type definitions
Also, fix a typo in the typings.
2021-03-27 11:35:02 +01:00
Daniel Huigens
e1fc91958c Disallow passing streams to readKey[s], readSignature and readCleartextMessage 2021-03-26 10:56:02 +01:00
Daniel Huigens
e7594f7d6a Remove unused util functions 2021-03-26 10:56:02 +01:00
Daniel Huigens
e599cee6c8 Remove top-level streaming options
Only return a stream if a stream was passed.
2021-03-26 10:56:02 +01: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
Daniel Huigens
940ebba54f Speed up Node.js tests 2021-03-25 19:23:58 +01:00
Daniel Huigens
97e9cdefe9 Remove unnecessary Buffer.from calls 2021-03-25 19:23:58 +01:00
Daniel Huigens
06aef92752 Remove internal streaming parameters 2021-03-25 19:23:58 +01:00
Daniel Huigens
ff8d274b4d Use ArrayStreams 2021-03-25 18:57:29 +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
8a57246ec4
Add config.rejectPublicKeyAlgorithms (#1264)
- Add `config.rejectPublicKeyAlgorithms` to disallow using the given algorithms
  to verify, sign or encrypt new messages or third-party certifications.

- Consider `config.minRsaBits` when signing, verifying and encrypting messages
  and third-party certifications, not just on key generation.

- When verifying a message, if the verification key is not found (i.e. not
  provided or too weak), the corresponding `signature` will have
  `signature.valid=false` (used to be `signature.valid=null`).
  `signature.error` will detail whether the key is missing/too weak/etc.

Generating and verifying key certification signatures is still permitted in all cases.
2021-03-25 15:08:49 +01:00
larabr
3e808c1578
Drop support for verification of detached cleartext signatures (#1265)
(Also, use turnstyle to avoid CI browserstack tasks running in parallel.)
2021-03-18 17:17:39 +01:00
Kevin Moutet
eba791e11e
Add key.write() and update type definitions (#1267)
Also, mark key.keyPacket, message.packets and signature.packets private.
2021-03-16 13:45:17 +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
4379d1856e 5.0.0-1 2021-03-03 20:28:16 +01:00
Daniel Huigens
b9134ed161
Fix unhandled promise rejection when stream-decrypting non-MDC messages (#1260)
Also, add some tests.
2021-03-03 19:38:58 +01:00
larabr
6e2a787ff8
Rename config.ignoreMdcError, drop config.integrityProtect and allow V4 keys to be AEAD-encrypted (#1261)
* Rename `config.ignoreMdcError` to `config.allowUnauthenticatedMessages`

* Do not support creating sym. enc. messages without integrity protection

* Use `config.aeadProtect` to determine SKESK encryption mode
2021-03-03 18:05:40 +01:00
larabr
f41412a5a2
Check critical notations during signature verification instead of parsing (#1259) 2021-03-03 18:03:45 +01:00
Daniel Huigens
30ddc3b90a Remove util from TypeScript definitions 2021-03-01 18:27:30 +01:00
Daniel Huigens
3f494ca797 Remove config.nodeStore 2021-03-01 12:02:39 +01:00
Daniel Huigens
4a8fffdfdf Remove KeyRing class
Keyring handling and storage should be handled in the application, as
localStorage may not meet the durability requirements of the
application, for example.
2021-03-01 11:58:10 +01:00
Daniel Huigens
8e5fe1da4f Remove config.keyserver 2021-03-01 11:43:13 +01:00
Daniel Huigens
7203e6afb6 Move WKD client to openpgpjs/wkd-client 2021-03-01 01:02:16 +01:00
Daniel Huigens
43f0724aeb Move HKP client to openpgpjs/hkp-client 2021-02-28 22:59:16 +01:00
Daniel Huigens
fa3c36fc87 Remove unused devDependencies 2021-02-28 21:58:30 +01:00
Daniel Huigens
e959602a94 Switch packages installed from git to @openpgp scope 2021-02-28 21:45:21 +01:00
Daniel Huigens
9bb65bd1c3 Update web-stream-tools 2021-02-28 21:25:58 +01:00
Daniel Huigens
9e85f75519 Don't mark async function as returning a Promise explicitly
It seems redundant.
2021-02-28 01:47:48 +01:00
Daniel Huigens
2ba04d9f0a Document parameters of Message.fromText/fromBinary 2021-02-28 01:47:48 +01:00
Daniel Huigens
174086a011 Default to empty filename 2021-02-28 01:47:48 +01:00
Daniel Huigens
21e3ba4653 Clean up JSDocs 2021-02-28 00:32:02 +01:00
Daniel Huigens
e2eadd09e4 Fix documentation of top-level function parameters 2021-02-27 23:37:41 +01:00
Daniel Huigens
a50cb9c6b7 Don't include date in documentation
To reduce diffs for each release.
2021-02-27 22:29:08 +01:00
Daniel Huigens
365a5efb63 5.0.0-0 2021-02-27 01:25:52 +01:00
Daniel Huigens
ab419179bc Remove TextEncoder/TextDecoder polyfills
Also, drop support for Node.js 10.
2021-02-27 01:22:13 +01:00
Daniel Huigens
3a42b45ab7 Remove unused config/localStorage module 2021-02-27 01:22:13 +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
larabr
15ee659c9c
Exit with error on unhandled rejections in Node tests (#1251) 2021-02-26 12:46:41 +01:00
Ali Cherry
2000388a80
Return subkey binding signature in SubKey#verify (#1250)
Also, update TypeScript definitions.
2021-02-25 12:58:54 +01:00
Daniel Huigens
ca248ba1a8 CI: Bump browser test timeout 2021-02-24 23:00:25 +01:00
larabr
95dd81381f
CI: Update browser targets (#1249) 2021-02-24 18:15:57 +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
Ali Cherry
9ae0aae7a2
Add options to select encryption/signing key IDs (#1238) 2021-02-17 20:06:31 +01:00
Daniel Huigens
b6edfe646b Lint all tests (#1235) 2021-02-12 23:00:22 +01:00
Daniel Huigens
8f8517702e Remove Travis badge 2021-02-12 21:29:24 +01:00
Daniel Huigens
4bff80bc9c Switch to karma-mocha-reporter 2021-02-12 21:13:39 +01:00
Daniel Huigens
ce983e5a2d Switch from Travis to GitHub Workflows (#1234) 2021-02-12 21:13:19 +01:00
Daniel Huigens
01be7b7ec1
CI: Switch to karma for browser tests (#1233)
This should fix the false positives (failures to detect errors).
2021-02-12 13:29:04 +01:00
larabr
051f5ec8cf
BigInteger: throw if modular inverse doesn't exist (#1228) 2021-02-10 14:23:59 +01:00
larabr
ca092c7cd0 Speed up decryptKey and encryptKey (#1192)
Change `openpgp.decryptKey` and `openpgp.encryptKey` to avoid deep cloning the
original key.
2021-02-09 19:25:20 +01:00
larabr
66c06dab3e Check if any (sub)key is decrypted in Key.prototype.isDecrypted (#1182)
`key.isDecrypted()` now returns true if either the primary key or any subkey
is decrypted.

Additionally, implement `SecretKeyPacket.prototype.makeDummy` for encrypted
keys.
2021-02-09 19:25:20 +01:00
larabr
c23ed58387 Require User IDs to be objects; refactor UserIDPacket (#1187)
- `openpgp.generateKey` now expects `userIds` in object format
  (strings are no longer supported)
- Remove `util.parseUserId` and `util.formatUserId`
- Replace `UserIDPacket#format` with `UserIDPacket.fromObject`
2021-02-09 19:25:20 +01:00
larabr
724775816f Add explicit key type parameter in openpgp.generateKey (#1179)
- Changes `openpgp.generateKey` to accept an explicit `type` parameter,
  instead of inferring its value from the `curve` or `rsaBits` params
- Introduces `config.minRsaBits` to set minimum key size of RSA key generation
2021-02-09 19:25:20 +01:00
larabr
92887a0948 Revert to disabling AEAD encryption by default (#1190) 2021-02-09 19:25:20 +01:00
larabr
801430f969 Revert to generating v4 keys by default (#1189) 2021-02-09 19:25:20 +01:00
larabr
2ee36c2984 Drop inconsistent boolean returns and fix type definitions (#1191)
- Remove the boolean return value of various internal functions that throw on
  error (the returned value was unused in most cases)
- Update and fix type definitions
2021-02-09 19:25:20 +01:00
larabr
89f738da45 Fix EOL in streaming tests 2021-02-09 19:25:20 +01:00
larabr
286d991265 Fix parsing of short P-521 keys and EdDSA, RSA signatures (#1185)
Also, strip leading zeros when serializing MPIs, as per the spec.
2021-02-09 19:25:20 +01:00
larabr
c34dede6de Use \n instead of \r\n for EOL when armoring (#1183) 2021-02-09 19:25:20 +01:00
larabr
4efeac3ad1 Unexport low-level key functions (#1188) 2021-02-09 19:25:20 +01:00
Tom J
c5aa647e31 Add TypeScript definitions (#1186) 2021-02-09 19:25:20 +01:00
Dan Ristea
fe51f97b79 Re-enable linting in CI (#1160) 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
1f1ffedaf4 [v5] Update asmcrypto.js; fix CI (#1178) 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
Marco
ad7d654f2b Fixed description of generateSessionKey (#1165) 2021-02-09 19:25:20 +01:00
Daniel Huigens
6df714a708 Add openpgp/lightweight to npm build 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
d5dd247b2c Store named session key parameters (#1157)
Change session key parameter handling to mirror key parameters.
Parameters are stored as an object rather than an array. MPIs are
always stored as Uint8Arrays.
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
Dan Ristea
b9afd26912 Fix comments on symmetric- and public-key encrypted session keys (#1120) 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
17fc32ba51 Appease linter 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
c20b75252b Add --build-only parameter to filter build outputs
Also, don't generate test bundle by default, but provide
`npm run build-test` instead.
2021-02-09 19:25:20 +01:00
Daniel Huigens
6a3d04ade6 Only produce source maps for minified dist builds 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
8457639004 CI: for lightweight build, only run tests tagged '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
7dbd393071 Remove src and test directory from npm package 2021-02-09 19:25:20 +01:00
Daniel Huigens
f936abec9d Bump Browserstack test to iOS 12 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
4f77990859 Polyfill globalThis 2021-02-09 19:25:20 +01:00
Daniel Huigens
89923dad17 Remove bower.json 2021-02-09 19:25:20 +01:00
Daniel Huigens
175eac5670 Remove compat polyfills 2021-02-09 19:25:20 +01:00
Daniel Huigens
ed9a029fcf Replace release.sh with npm version scripts 2021-02-09 19:25:20 +01:00
Daniel Huigens
defa1283cb Link to source code on GitHub from documentation
Instead of including the entire source code in the documentation.
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
cde282d4f1 Replace 'global' with 'globalThis' 2021-02-09 19:25:20 +01:00
Daniel Huigens
5b148089c3 Switch to ES8 build of asmcrypto.js 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
Daniel Huigens
c48070def6 Remove default export 2021-02-09 19:25:20 +01:00
Daniel Huigens
bdad8e3eec Remove dist folder from GitHub 2021-02-09 19:25:20 +01:00
Daniel Huigens
064e813f3f Build OpenPGP.js on local npm install 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
Daniel Huigens
ad33660da8 Fix lightweight build and browserstack test (#1092) 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
ec720cc096 Remove browsers that always fail from Browserstack tests 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
35c13212dd Remove unnecessary calls to convertStreams() 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
be7b174df4 Add openpgp.generateSessionKey 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
430145a8b1 Update web-stream-tools
Fixes reading Node streams in some cases.
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
Daniel Huigens
1f237e6a9c Release new version 2021-01-24 16:47:40 +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
Daniel Huigens
d5373ef361 Update tweetnacl-js 2021-01-20 14:09:10 +01:00
Daniel Huigens
21f4ba46f8 Release new version 2020-12-07 20:31:43 +01:00
Yarmo Mackenbach
a4b56c944a
WKD: Fix "TypeError: fetch is not a function" in Node.js environment (#1181) 2020-11-17 10:03:25 +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
Chen Longhao
929b016948
Fix documentation of the HKP keyId option (#1151) 2020-09-09 12:26:03 +02:00
Daniel Huigens
aa89893773 Release new version 2020-08-28 16:42:25 +02:00
larabr
2eab8a1ebc
Add config option to allow insecure decryption with RSA signing keys (#1148) 2020-08-28 16:09:56 +02:00
larabr
cc1bdcbae8
Allow decryption with revoked keys (#1135)
However, when decrypting session keys, check that the public key
algorithm matches that of the decryption key.
2020-08-18 15:49:27 +02:00
Wiktor Kwapisiewicz
2e26509723
Add test case for unknown binary notations (#1140) 2020-08-18 13:37:36 +02:00
Wiktor Kwapisiewicz
0712e8af2d
Support non-human-readable notation values (#983)
This change adds support for binary (non-human-readable) values in
signature notations through `rawNotations` property on signature objects.
Human-readable notations will additionally appear in `notations` object
where the value of the notation will be deserialized into a string.

Additionally the check for human-readable flag was modified to check the
existence of the flag instead of comparison with the whole value.
2020-08-18 11:07:58 +02:00
larabr
25bf080871
Add SecretKey.prototype.makeDummy (#1131) 2020-08-03 15:52:50 +02:00
larabr
e29de76dc1 Use correct algorithm in ECC validation tests 2020-07-23 19:21:34 +02:00
Daniel Huigens
34b0928cca Release new version 2020-07-21 15:21:20 +02:00
larabr
14f244a80f Fix decryption tests 2020-07-17 15:14:21 +02:00
Yarmo Mackenbach
de360e200c
Handle CORS errors during WKD lookup (#1125)
Also, throw an error instead of returning null when the server returned
an error status.
2020-07-17 14:22:54 +02:00
larabr
8783caa828 Fix key validation tests 2020-07-16 22:56:06 +02:00
Yarmo Mackenbach
5801169432
Refactor WKD lookup code (#1123)
* Replace chained then by await

* Improve fetch fallback flow
2020-07-15 15:12:55 +02:00
Daniel Huigens
20c468cbd7 Release new version 2020-07-14 18:22:46 +02:00
Daniel Huigens
3218f7b7f8 Don't zero-copy transfer buffers from the worker by default 2020-07-14 18:15:08 +02:00
Daniel Huigens
1c41c72520 Release new version 2020-07-13 20:24:55 +02:00
Yarmo Mackenbach
4af9b51915
Add support for advanced WKD lookup (#1115) 2020-07-13 20:08:30 +02:00
larabr
00c5f38689
Cipher-specific key validation (#1116)
Also, check binding signatures for decryption keys.

Also, do not always fallback on Web Crypto ECC errors.
2020-07-13 19:57:33 +02:00
cpupower
6988fdfee1
Fix stream-encrypting+signing a message using the Worker (#1112)
- Include fromStream property when cloning a Message
- Restore fromStream property in packetlistCloneToMessage
2020-06-25 12:53:27 +02:00
larabr
35b0012f2f
Pass around KDF params as object (#1104) 2020-06-03 14:16:54 +02:00
Matthew Shaylor
320efc2435
Fix keyId types in JSDoc comments (#1100) 2020-05-18 12:22:31 +02:00
Roman Zechmeister
1b91d428f0
Also create issuer fingerprint subpacket for v4 keys (#1097)
Do not limit creation of signatures with issuer fingerprint subpacket to v5 keys.
2020-05-11 21:45:04 +02:00
Daniel Huigens
2c6cbc4cb2 Release new version 2020-04-22 19:28:01 +02:00
Daniel Huigens
5d71ae8691 Fix normalizing \n after \r\n
Broken in c4a7455.
2020-04-22 19:09:50 +02:00
Daniel Huigens
35b4380909 Release new version 2020-04-21 16:05:49 +02:00
Ilya Chesnokov
674e0217fc
Support compressed data packets with algorithm=uncompressed (#1085) 2020-04-21 16:00:38 +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
Daniel Huigens
90ff60cbb1
Fix verification of EdDSA signatures with short MPIs (#1083)
We would fail to verify EdDSA signatures with leading zeros, when
encoded according to the spec (without leading zeros, leading to
short MPIs). OpenPGP.js itself encodes them with leading zeros.
This is accepted by many implementations, but not valid according
to the spec. We will fix that in a future version.
2020-04-16 17:03:49 +02:00
Daniel Huigens
b69d0d0228
Support PKCS5 padding longer than 8 bytes (#1081)
This is allowed by the spec to hide the length of the session key:

    For example, assuming that an AES algorithm is
    used for the session key, the sender MAY use 21, 13, and 5 bytes of
    padding for AES-128, AES-192, and AES-256, respectively, to provide
    the same number of octets, 40 total, as an input to the key wrapping
    method.
2020-04-15 19:33:04 +02:00
Daniel Huigens
04fb053fc8 Release new version 2020-04-15 11:34:10 +02:00
Daniel Huigens
9b51349ce3
Unpublish npm-shrinkwrap.json (#1079) 2020-04-15 11:25:27 +02:00
larabr
6119dbb08e
Support verification of text signatures on non-UTF-8 messages (#1071) 2020-03-30 12:51:07 +02:00
larabr
34f9f705e9
Update dependencies (#1061) 2020-03-26 18:05:07 +01:00
Ilya Chesnokov
69f14023f2
Update grunt; fix lodash vulnerability warning (#1060) 2020-03-17 13:39:30 +01:00
chenlhlinux
b76c67aba8
Fix signature verification examples in the README (#1058) 2020-03-12 20:13:22 +01:00
Makoto Sakaguchi
66d83db51b
Fix "TypeError: fetch is not a function" in Node.js environment (#1052) 2020-03-03 14:50:28 +01:00
Daniel Huigens
b6a6f52ad8 Release new version 2020-02-27 17:17:23 +01:00
Daniel Huigens
e986c47ed5 Remove no-op revocationCertificate option from reformatKey 2020-02-27 16:04:06 +01:00
Daniel Huigens
60822d87d9 Fix generating keys with a date in the future
This was broken in 8c3bcd1.

(Before then, the revocation certificate was already broken when
generating a key with a date in the future.)
2020-02-27 16:04:07 +01:00
Daniel Huigens
f6507c30e1 Release new version 2020-02-25 15:58:04 +01:00
Daniel Huigens
2131fb0978 Fix error message for legacy encrypted private keys 2020-02-25 15:07:43 +01:00
Daniel Huigens
c6ed05d2c3 Optimize crc24 calculation 2020-02-25 15:06:38 +01:00
Daniel Huigens
2ff4fbb0e8 Optimize base64 encoding and decoding 2020-02-25 15:06:38 +01:00
Daniel Huigens
15202d9d40 Don't use polyfilled Set in compat build
All methods of sets we need are available in all browsers we support.
2020-02-25 15:06:15 +01:00
Daniel Huigens
4bd22eb17a Unit tests: eval config query parameters instead of parsing as JSON 2020-02-25 15:06:15 +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
3af8e32bf0 Release new version 2020-02-17 14:40:22 +01:00
Daniel Huigens
92eda27e61 Binary signature on text message: sign and verify text as UTF-8 2020-02-17 12:49:20 +01:00
Daniel Huigens
de6ab1db49 Add inline sourceMap in minified files in grunt build --dev 2020-02-07 20:41:44 +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
93c5bed64b Release new version 2020-02-02 20:15:24 +01:00
Daniel Huigens
dc9660f2ae Add tests with old and new Blowfish encrypted messages 2020-02-02 16:51:56 +01:00
Daniel Huigens
84a1287e50 Fix Blowfish block size 2020-02-02 16:51:56 +01:00
Daniel Huigens
801b44f2e7 Don't use Node symmetric crypto when !config.use_native 2020-02-02 16:51:56 +01:00
Daniel Huigens
fc0052e35a Implement streaming non-AES encryption and decryption 2020-02-02 16:51:56 +01:00
Daniel Huigens
2ec8831abf Use native Node crypto for non-AES encryption and decryption 2020-02-02 16:51:56 +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
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
Daniel Huigens
9f8a139624 Fix openpgp.revokeKey().publicKey when using the Worker 2019-10-15 14:15:41 +02:00
Ilya Chesnokov
1e37b27673 Use rsaBits=2048 in addSubkey tests when using Web Crypto (#971)
Fix tests failing in old browsers due to too low rsaBits.

Also, always throw in addSubkey when rsaBits is too low.
2019-09-24 13:53:12 +02: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
Ilya Chesnokov
7f40ab0940 Implement Key.prototype.addSubkey (#963) 2019-09-16 15:53:19 +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
91aa8b0d4c Only store newly created signatures as valid in the non-streaming case
When streaming, we're not actually sure yet that signing won't fail.
2019-09-12 14:03:29 +02:00
Daniel Huigens
2877bac018 Release new version 2019-09-12 01:17:37 +02:00
Daniel Huigens
aa8d37a82c
Fix verifying one-pass signatures in the compat build (#968)
This was broken in 735d6d0.

See babel/babel#10431.
2019-09-12 00:42:35 +02:00
Daniel Huigens
a14b09c89b Release new version 2019-09-11 18:45:16 +02:00
Daniel Huigens
67e98e8fb5
Merge pull request #967 from twiss/keygen-fixes
Fix generating signing subkeys
2019-09-11 18:29:19 +02:00
Daniel Huigens
18474bdfb6 Fix decrypting newly generated key object when using the Worker 2019-09-11 18:11:16 +02:00
Daniel Huigens
a731a607ce Fix writing newly generated embedded primary key binding signatures 2019-09-11 18:11:15 +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
b23ee190c7 Fix intermittent Brainpool sign/verify bug (#948)
Fix #854
2019-08-23 14:09:25 +02:00
Daniel Huigens
a7cc71e35e
Throw when trying to encrypt a key that's already encrypted (#950) 2019-08-19 13:27:52 +02:00
Tom J
d27060e508 Use native Node crypto for RSA key generation (#947) 2019-08-16 13:11:04 +02:00
Daniel Huigens
c685e34c76 Release new version 2019-08-12 19:18:04 +02:00
Daniel Huigens
8d4440a369
Merge pull request #895 from twiss/fix-unencrypted-v5-keys
Implement V5 signatures and update V5 keys to rfc4880bis-07

Also, remove support for `openpgp.config.aead_protect_version = 0`.
2019-08-12 18:55:32 +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
Daniel Huigens
80c535eeb7 Separate config option to use V5 keys from AEAD config option 2019-08-12 17:46:37 +02:00
Daniel Huigens
9bb1710a9f Remove unused writeOldHeader function 2019-08-12 17:46:37 +02:00
Daniel Huigens
8312399f9d Update V5 key hashing for signatures to rfc4880bis-07 2019-08-12 17:46:37 +02:00
Daniel Huigens
c8729a0295 Fix serializing GNU stripped-keys 2019-08-12 17:46:37 +02:00
Daniel Huigens
735d6d088f Implement V5 signatures 2019-08-12 17:46:37 +02:00
Daniel Huigens
f629ddcb31 Fix reading and writing unencrypted V5 secret key packets 2019-08-12 17:46:37 +02:00
Ilya Chesnokov
dff1a8aed8 Fix test failing due to expired key (#941) 2019-08-12 17:45:35 +02:00
Daniel Huigens
cbe88a54e9
Disable HKP tests (#940)
keyserver.ubuntu.com no longer serves CORS headers.
2019-08-09 20:03:40 +02:00
Ilya Chesnokov
a0e9c608ba DSA: Fix intermittent generation of invalid signatures (#938) 2019-08-07 17:42:55 +02:00
Tom J
3be779e0a1 Fix comment describing RSA coefficient u (#937) 2019-08-07 17:39:57 +02:00
Daniel Huigens
8585ad8924
Merge pull request #935 from twiss/fix-armor-checksum-errors
Fix armor checksum errors being ignored when not streaming
2019-07-19 20:08:16 +02:00
Daniel Huigens
562783df01 Fix armor checksum mismatch error message with allow_unauthenticated_stream 2019-07-19 19:06:19 +02:00
Daniel Huigens
9166d6737c Don't babelify ES6 in unit tests when testing in modern browsers 2019-07-19 19:06:19 +02:00
Daniel Huigens
2a5ab75fca Decrypt message with multiple keys in parallel
Don't keep the entire message in memory.

This also fixes an unhandled promise rejection when the input
stream contains an error (e.g. an armor checksum mismatch).
2019-07-19 19:05:26 +02:00
Daniel Huigens
10cbd307c3 Add test for throwing on armor modifications 2019-07-19 19:05:26 +02:00
Daniel Huigens
237db2c7f3 Fix armor checksum errors being ignored when not streaming 2019-07-19 19:05:26 +02:00
Ilya Chesnokov
29d67415e2 Accept @ in User ID names (#930) 2019-07-18 15:45:54 +02:00
Ilya Chesnokov
70cf2d60ff Implement ECDH using Node crypto (#921) 2019-07-09 20:45:28 +02:00
Ilya Chesnokov
6d626ea70c Style fixes and new style rules for eslint (#919) 2019-06-28 15:33:18 +02:00
chesnokovilya
1bd5689d75 Implement ECDH using Web Crypto for supported (NIST) curves (#914) 2019-06-27 19:21:32 +02:00
Daniel Huigens
32b4f2bd27
Fix grunt-saucelabs (#917)
Update Sauce Labs Tunnel
2019-06-26 23:32:21 +02:00
Daniel Huigens
3a7db8ea60 Release new version 2019-06-24 20:17:15 +02:00
Daniel Huigens
6a60d92e8a Update web-stream-tools 2019-06-24 20:09:43 +02:00
Daniel Huigens
17c994865b Release new version 2019-06-21 16:23:53 +02:00
Sam
c7fb8d8fe7 Node detection: base on process instead of window (#911) 2019-06-21 15:43:56 +02:00
Remy
b035f2ea46 Fix nodejs API crypto link (#909) 2019-06-07 14:57:09 +02:00
Daniel Huigens
f00f256f50 Release new version 2019-06-06 16:17:05 +02:00
Daniel Huigens
5a17648922 Fix error message when reformatting a GNU stripped-key with a passphrase 2019-06-06 16:08:22 +02:00
Daniel Huigens
43441bfe0d openpgp.reformatKey: Fix key preferences for signing subkeys 2019-05-23 17:37:20 +02:00
Daniel Huigens
72e3b491d7 Release new version 2019-05-16 16:23:36 +02:00
Daniel Huigens
5987e99c5b
Merge pull request #901 from wiktor-k/notations
Expose all signature notations
2019-05-16 13:31:47 +02:00
Wiktor Kwapisiewicz
82799390de
Fix signatures with critical notations
Previously the signature parsing function ignored critical bit on
notations.

This change checks for notations that are marked "critical" but are not
on the known notations list (controlled by config array
`openpgp.config.known_notations`) and triggers parse error if such
a notation have been encountered.

See: #897.
2019-05-16 09:57:58 +02:00
Wiktor Kwapisiewicz
16b12d7f55
Expose all signature notations
Previous implementation used an object to hold notations so if multiple
notations had the same key name only the last one was visible.

After this change notations are exposed as an array of key-value pairs
that can be converted to a map through `new Map(notations)`.

See #897.
2019-05-09 12:12:22 +02:00
Daniel Huigens
54f3eb5870 Release new version 2019-05-06 13:17:19 +02:00
Daniel Huigens
ee01883a52
Merge pull request #894 from twiss/dont-throw-verification-errors-workers
Fix one-pass signature verification when using a Worker
2019-05-05 00:01:14 +02:00
Daniel Huigens
e3bcce275e
Merge pull request #865 from twiss/gnu-stripped-keys
Support GNU export-secret-subkeys extension
2019-05-05 00:00:38 +02:00
Daniel Huigens
df8364930b Fix one-pass signature verification when using a Worker 2019-05-03 18:40:31 +02:00
Daniel Huigens
1090464a70 Throw more informative error when trying to use a key with missing params
E.g. when trying to sign with a GPG stripped key without a valid signing
subkey.
2019-05-03 14:29:43 +02:00
Daniel Huigens
19d14b521b Add test for signing with GNU stripped key 2019-05-03 14:07:10 +02:00
Daniel Huigens
bc756d0ed4 Make key.isDecrypted() and key.encrypt() consistent for gnu-dummy keys 2019-05-03 12:39:28 +02:00
Daniel Huigens
10e10effb6 Support GNU export-secret-subkeys extension 2019-05-03 12:39:28 +02:00
Daniel Huigens
dff2dcd9a7 Release new version 2019-05-02 14:01:48 +02:00
Daniel Huigens
39bb4dde92
Merge pull request #893 from twiss/tweetnacl
Use tweetnacl's 25519 implementation
2019-05-02 12:57:18 +02:00
Daniel Huigens
6689f93465 Fix flaky test in Edge 2019-05-02 12:55:08 +02:00
Daniel Huigens
f322aaf715 CI: Require Chrome instead of Firefox to succeed
Sauce Labs seems to be having issues with Firefox.
2019-05-02 12:08:08 +02:00
Daniel Huigens
34e6eacb2f Don't attempt to use workers if they fail to load 2019-05-02 12:08:08 +02:00
Daniel Huigens
ecc8ae2a09 Don't include package.json 2019-05-02 12:08:08 +02:00
Daniel Huigens
ffa8344809 Only include tweetnacl functions we need 2019-05-02 12:08:08 +02:00
Daniel Huigens
caa712c337 Fix using local dependencies 2019-05-02 12:08:08 +02:00
Daniel Huigens
e637e75891 Clean up ECDH API 2019-05-02 12:08:08 +02:00
Daniel Huigens
ca0322bbea Use tweetnacl's X25519 implementation 2019-05-02 12:08:08 +02:00
Daniel Huigens
be1b4df140 Use tweetnacl's Ed25519 implementation 2019-05-02 12:08:08 +02:00
Si Feng
d2c38693f5 Put comment before email when generating UIDs (#892) 2019-05-01 13:12:52 +02:00
Daniel Huigens
cc4a9119a3
Add Node 12 to CI (#889) 2019-04-29 15:58:59 +02:00
Daniel Huigens
d5e87dc6f4
Move non-external dependencies to devDependencies (#888)
They are not needed to use the dist file.
2019-04-29 13:45:58 +02:00
Daniel Huigens
7fb2901ede
Fix detached signing of messages created from streams (#887) 2019-04-29 13:45:09 +02:00
Thomas Oberndörfer
038d8466fe Add date parameter to user.verifyAllCertifications and user.verify methods (#871)
Also, in user.verifyCertificate, fix certificate.isExpired check for keys with future creation date.
2019-03-08 17:33:36 +01:00
Sanjana Rajan
1ac84484bd Release new version 2019-03-04 06:32:51 -08:00
Daniel Huigens
a9599fea42
Work around go crypto bug in ECDH messages (#869) 2019-03-04 13:53:19 +01:00
Sanjana Rajan
10d3bca6d3 Release new version 2019-02-28 10:39:10 -08:00
Thomas Oberndörfer
b1be7d1202 Fix merging multiple subkey binding signatures (#868) 2019-02-28 10:34:46 -08:00
Sanjana Rajan
b9abf80d5a Release new version 2019-02-25 13:33:56 -08:00
Daniel Huigens
76ce33d96b Use ES6 build of web-streams-polyfill in non-compat builds 2019-02-25 20:56:33 +01:00
Daniel Huigens
ab0892bd64 Update web-streams-polyfill
Fixes a memory leak in Node.js (see
https://github.com/MattiasBuelens/web-streams-polyfill/pull/8).
2019-02-25 20:56:33 +01:00
Stephen Simpson
e17ad669a1 Expand git hashes in dependencies
Expanded the git hashes as pnpm cannot install via short hashes.
2019-02-25 20:55:59 +01:00
Daniel Huigens
a291a803fb Fix reading indeterminate-length packets in IE11
Broken in 5dcaf85.
2019-02-25 04:41:58 +01:00
Daniel Huigens
cd6eadd6e0 Fix reading empty partial body part (again)
Broken in 5dcaf85.
2019-02-25 04:34:28 +01:00
Daniel Huigens
5dcaf85f5a Optimize reading large messages with lots of tiny partial body parts (#864)
* Fix pako decompression

* Optimize base64-decoding

* Don't stream-parse packets when not stream-reading data
2019-02-21 08:33:55 -08:00
Daniel Huigens
54fc1dde3d Throw error before decrypting in non-MDC packets 2019-02-12 11:49:38 +01:00
Daniel Huigens
40360b4955 Fix streaming/signed encryption with config.integrity_protect=false 2019-02-12 11:49:38 +01: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
Sanjana Rajan
e2d19a7414 Release new version 2019-02-06 19:45:15 +01:00
Daniel Huigens
9d7db98362 Specify git commits in package.json 2019-02-05 13:46:59 +01:00
Daniel Huigens
352dd5639e Fix async describe() in test suite that always runs 2019-02-05 13:46:59 +01:00
Daniel Huigens
1dd168e7a2 Fix ECDH message encryption for some session keys 2019-02-05 13:46:59 +01:00
Daniel Huigens
cd9fd860fd Update openpgpjs/elliptic 2019-02-05 13:46:59 +01: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
wussler
f018f60b9c ECDHE tests (#846)
* Ellyptic curves tests

* Re-run tests
2019-01-27 00:19:36 +00:00
Sanjana Rajan
b0ac142f2e
Merge pull request #847 from twiss/dont-throw-verification-errors
Don't throw on signature verification errors in openpgp.decrypt/verify
2019-01-27 00:18:41 +00:00
Daniel Huigens
9e4cc1acfe Don't throw on signature verification errors in openpgp.decrypt/verify 2019-01-26 11:41:44 +01:00
Sanjana Rajan
96eca0c281 Release new version 2019-01-24 10:16:36 +01:00
Sanjana Rajan
2b17ffba84
Merge pull request #844 from wussler/master
Make ephemeral secret available from ECDH module
2019-01-24 10:12:32 +01:00
Sanjana Rajan
bced4513ca
Merge pull request #843 from crcunningham/patch-1
Update README.md: Fix error
2019-01-24 10:10:38 +01:00
wussler
6b19af0a63
new BN, fix doc 2019-01-22 16:50:06 +01:00
wussler
2975e49dd0
genPublicEphemeralKey to return Uint8Array 2019-01-22 16:24:55 +01:00
wussler
6d9160dd87
Fix mistake in documentation 2019-01-22 16:22:05 +01:00
Aron Wussler
1face482ba Naming 2019-01-21 15:35:45 +01:00
Aron Wussler
4c809a4846 Fix to returns 2019-01-21 14:57:02 +01:00
Daniel Huigens
31f72fb64d
Update src/crypto/public_key/elliptic/ecdh.js
Co-Authored-By: wussler <aron@wussler.it>
2019-01-18 16:40:31 +01:00
Daniel Huigens
680aa03bcd
Update src/crypto/public_key/elliptic/ecdh.js
Co-Authored-By: wussler <aron@wussler.it>
2019-01-18 16:40:22 +01:00
Daniel Huigens
f77ebc7605
Update src/crypto/public_key/elliptic/ecdh.js
Co-Authored-By: wussler <aron@wussler.it>
2019-01-18 16:40:13 +01:00
Aron Wussler
06952b4e30 Make ephemeral secret available from ECDH module 2019-01-18 16:06:57 +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
Sanjana Rajan
1ec216a6b4 Release new version 2019-01-15 11:46:22 -08:00
Daniel Huigens
49a7deacd4 Don't run AsyncProxy tests in browsers that don't fully support workers 2019-01-15 20:16:59 +01: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
Sanjana Rajan
b904aef3a7 Release new version 2019-01-15 02:51:28 -08:00
Sanjana Rajan
a87d03a7bd
Merge pull request #838 from twiss/worker-buffer-transfer
Transfer buffers in workers
2019-01-15 01:24:00 -08:00
Sanjana Rajan
e3cae6c34f
Merge pull request #837 from benhc123/patch-3
Added link to license for informational purposes
2019-01-15 01:20:27 -08:00
Sanjana Rajan
df72a3e826
Merge pull request #840 from mmso/fix/minification
Upgrade to terser-js
2019-01-15 01:18:30 -08:00
mmso
9ce5b7ca0c
Upgrade to terser-js 2019-01-15 10:10:49 +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
Daniel Huigens
c73b4536be Fix error handling in worker delegation 2019-01-09 15:06:15 +01:00
Ben Holden-Crowther
53237392f2
Added link to license for informational purposes 2019-01-09 12:03:49 +00:00
Sanjana Rajan
1fc0b254bf
Merge pull request #835 from benhc123/patch-2
Removed broken links
2019-01-08 16:02:40 -08:00
Ben Holden-Crowther
e52504b0fd
Removed broken links
Removed broken links in readme
2019-01-05 21:30:21 +00:00
Sanjana Rajan
92ba73402a Release new version 2019-01-03 07:03:26 -08:00
Sanjana Rajan
ffeb43ef04
Merge pull request #831 from twiss/web-crypto-cfb
Web Crypto CFB encryption, revision 2
2019-01-03 06:56:40 -08: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
b94031416d
Merge pull request #834 from benhc123/patch-1
Grammar improvement
2019-01-03 06:55:00 -08:00
Ben Holden-Crowther
fe3c9a0602
grammar improvement
built-in vs builtin
2019-01-03 14:24:47 +00:00
Sanjana Rajan
9b599c86b2
Merge pull request #827 from estelendur/double_is_readonly
Double is readonly
2019-01-02 15:15:22 -08:00
Esty Thomas
4458ea77f8
Revert "Adds dist changes derived from previous commit."
This reverts commit 6cd5152b16100819d9942283f41864268cf51455.
2019-01-02 18:01:22 -05:00
Sanjana Rajan
83623b3d32 Release new version 2019-01-02 14:46:49 -08:00
Daniel Huigens
1e5935dff3 Require recent Firefox on Sauce Labs to pass
We want at least one browser to pass. Firefox usually passes, so use
it to gauge whether the browsers pass.
2019-01-02 15:44:47 +01:00
Sanjana Rajan
4ce2dd28e1 update CFB tests 2019-01-02 15:44:45 +01:00
Daniel Huigens
31931c9b0d Simplify MDC verification 2019-01-02 15:13:00 +01:00
Daniel Huigens
3f1734ae7a Move CFB optimizations into cfb.js
So that uses of CFB other than sym_encrypted_integrity_protected.js
can benefit from them.

Also, implement CFB resync mode in terms of normal CFB rather than
separately (and duplicated).
2019-01-02 15:12:53 +01:00
Daniel Huigens
a891e0b4ea Web Crypto CFB encryption 2019-01-02 15:12:48 +01:00
Daniel Huigens
3e12314418 Add old Firefox back to Sauce Labs tests
To test compatibility with Pale Moon 27.
2019-01-02 15:11:26 +01:00
Daniel Huigens
3ed5bb3f31 Add Safari 9 to Sauce Labs tests 2019-01-02 14:12:30 +01: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
cf6278ddc9
Promisify hash.digest return value in jsdoc 2018-12-30 16:52:57 +00:00
Tom J
1054ed46d8
Fix util.js jsdoc Uint8Array typos 2018-12-29 11:44:26 +00:00
Esty Thomas
6cd5152b16
Adds dist changes derived from previous commit. 2018-12-27 12:30:43 -05: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
Sanjana Rajan
ae1af189ef Release new version 2018-12-23 22:03:40 +01:00
Sanjana Rajan
6cd3eea099
Merge pull request #823 from openpgpjs/revert-820-web-crypto-cfb
Revert "Web Crypto CFB encryption"
2018-12-23 21:32:46 +01:00
Sanjana Rajan
836ad2805a
Revert "Web Crypto CFB encryption" 2018-12-23 18:42:24 +01:00
Sanjana Rajan
6c02b25aa5
Merge pull request #820 from twiss/web-crypto-cfb
Web Crypto CFB encryption
2018-12-23 17:55:25 +01:00
Sanjana Rajan
b105dc9b40
Merge pull request #812 from KAYLukas/fix/non-primary-non-revoked-sub-user
Prefer a non-revoked primary user
2018-12-23 17:52:07 +01:00
Sanjana Rajan
529973f2a2
Merge branch 'master' into fix/non-primary-non-revoked-sub-user 2018-12-23 17:52:01 +01:00
Sanjana Rajan
1bee091f2a
Merge pull request #815 from twiss/userIds
Make fromUserIds/toUserIds params plural, and accept arrays of User IDs
2018-12-23 17:50:46 +01:00
Sanjana Rajan
d8a22d87f6
Merge pull request #818 from openpgpjs/gitter
Add links to Gitter
2018-12-23 17:44:12 +01:00
Daniel Huigens
113c4a5f1e Add CAST5 to always-allowed algorithms
Golang's OpenPGP implementation uses CAST5 as its fallback.
(The spec mandates TripleDES as fallback.)

Fixes #819.
2018-12-22 00:00:47 -05:00
Daniel Huigens
95cc9cecf0 Disable Web Workers on browsers without MessageChannel support
For compatibility with old Firefox / Pale Moon 27
2018-12-21 23:09:41 -05:00
Daniel Huigens
3a2408d0f1 Fix stream.slice() in old Firefox 2018-12-21 17:00:45 -05:00
Daniel Huigens
2c5cb6ad9f Fix armor parsing in edge case where reader.readToEnd() returns new Uint8Array([]) 2018-12-21 17:00:45 -05:00
Daniel Huigens
cfe7ff9bb8 Simplify MDC verification 2018-12-21 13:04:23 -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
668264aa9a Move CFB optimizations into cfb.js
So that uses of CFB other than sym_encrypted_integrity_protected.js
can benefit from them.

Also, implement CFB resync mode in terms of normal CFB rather than
separately (and duplicated).
2018-12-20 17:50:01 -05:00
Daniel Huigens
3c10c582e2 Web Crypto CFB encryption 2018-12-20 12:27:23 -05:00
Daniel Huigens
937150b5bd Update web-stream-tools
Fix #784
2018-12-20 11:26:39 -05:00
Daniel Huigens
9b7a9d7a41
Add links to Gitter 2018-12-18 15:36:00 -05:00
Sanjana Rajan
d24bdd5fa2 Release new version 2018-12-17 19:44:08 +01:00
Daniel Huigens
f0f9a5c2a4 Fix key generation tests on Node
The Node tests set the key bit size to 512, which is not big enough
to sign a SHA384 hash + header.
2018-12-17 13:32:27 -05:00
Daniel Huigens
b1b19946d8
Merge pull request #816 from twiss/security-fixes
Security fixes
2018-12-17 18:55:30 +01:00
Daniel Huigens
804e91140a Add config values to preferred algorithms 2018-12-17 12:52:30 -05:00
Daniel Huigens
926047f0b3 Default to RFC4880bis-mandated symmetric algos 2018-12-17 12:27:09 -05:00
Daniel Huigens
06608318d4 Fix CMAC of the empty string
This is currently never called, as EAX always adds a prefix to
the CMAC'ed message.
2018-12-17 12:27:08 -05:00
Daniel Huigens
9b83f6fcb2 Return generic error on PKESK checksum mismatch when decrypting 2018-12-17 12:27:07 -05:00
Daniel Huigens
e727097bb0 Always look at the same literal data packet in getText() and verify() 2018-12-17 12:27:05 -05:00
Daniel Huigens
8720adcf65 Check signature public key algorithm against issuer key algorithm 2018-12-17 12:27:04 -05:00
Daniel Huigens
3b9676f2e9 Reject messages encrypted with a symmetric algo not in preferred algos 2018-12-17 12:27:03 -05:00
Sanjana Rajan
a173e568af
Merge pull request #817 from meitar/revkey-readme-fix
Fix revocation example in README, use `revocationCertificate`.
2018-12-17 14:40:59 +01: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
19be0831b9 Add userIds parameter to signPrimaryUser and verifyPrimaryUser 2018-12-14 17:49:09 +01:00
Daniel Huigens
cb3f644708 Validate ECC public keys 2018-12-14 17:21:12 +01:00
Daniel Huigens
d74a2af4d3 Return primary key expiry based on userId param in getExpirationTime 2018-12-14 16:54:55 +01:00
Daniel Huigens
65772d86b3 Make fromUserIds/toUserIds params plural, and accept arrays of User IDs
Each User ID object is used for the key object at the corresponding index
in the privateKeys/publicKeys arrays.
2018-12-14 16:54:44 +01:00
Daniel Huigens
d4d94c6fb7 Remove non-AES CFB quick check 2018-12-11 14:05:26 +01:00
Kay Lukas
2dbb8582d7 Add testcases 2018-12-10 20:21:55 +01:00
Kay Lukas
3c0b22268d Prefer a non-revoked primary user 2018-12-10 17:50:21 +01:00
Daniel Huigens
c7339f6f78 Check whether signing key was non-expired at signature creation time 2018-12-10 16:34:44 +01:00
Daniel Huigens
787965981a Check whether message signatures are expired when verifying them 2018-12-10 15:20:24 +01:00
Daniel Huigens
92230d2055 Consider non-expired signatures from expired keys to still be valid 2018-12-10 15:20:11 +01:00
Daniel Huigens
ff86b00315 Fix undefined behavior when reading 3des algo 2018-12-10 14:21:52 +01:00
Sanjana Rajan
6c1738ff34 Release new version 2018-12-07 13:51:03 +01:00
Sanjana Rajan
798ac529df
Merge pull request #810 from KAYLukas/fix/pako-missing-eof
Handle end of stream in compression correctly
2018-12-07 11:52:25 +01:00
Kay Lukas
a49529d243 Handle end of stream in compression correctly 2018-12-07 11:47:52 +01:00
Sanjana Rajan
9d585cd35d
Merge pull request #808 from mailvelope/rev-key-fix
Move key revocation check to key class. Evaluate only self-signatures.
2018-12-01 11:32:23 +00:00
Thomas Oberndörfer
a7bae10fe8 Revise check on key revocation sub packet: throwing the exception should only be done on single keys and not discard the whole armored block with possibly multiple keys. Evaluate only self-signatures. 2018-11-30 11:45:31 +01:00
Sanjana Rajan
47e6e2fc28
Merge pull request #805 from Frontwise/no_arrow_func_in_compat_build
Compat build: specify target browsers
2018-11-28 11:54:28 +01:00
Simon Epskamp
44d81aabff Compat build: specify target browsers
To make compat build more deterministic. Fixes #804
2018-11-26 10:27:22 +01:00
Sanjana Rajan
161b034367
Merge pull request #802 from KAYLukas/feat/3-des
Support 3des as a valid algorithmname in a session key
2018-11-06 17:43:37 +01:00
Kay Lukas
c952e833d3 Support 3des as a session key algorithm 2018-11-06 17:38:17 +01:00
Sanjana Rajan
65de9b3e28 Release new version 2018-11-06 13:42:15 +01:00
Sanjana Rajan
86225cb1fa
Merge pull request #799 from twiss/signature-data
Compute signed data based on expected signature type
2018-11-06 13:38:42 +01:00
Daniel Huigens
79124a9680 Fix security test generating signing subkey on Safari 10 2018-11-06 11:48:16 +01:00
Daniel Huigens
c037b96037 Babelify seek-bzip for compat build 2018-11-05 18:00:21 +01:00
Daniel Huigens
f96bf45fb2 Lower S2K iteration count parameter in tests 2018-11-05 18:00:20 +01:00
Daniel Huigens
997f3e8e38 Compute signed data based on expected signature type 2018-11-05 17:13:40 +01:00
Daniel Huigens
1071cb9bca Fix cloning embedded signatures 2018-11-05 16:32:30 +01:00
Sanjana Rajan
a6e20d7abd Release new version 2018-11-05 14:14:49 +01:00
Sanjana Rajan
67de70fa01
Merge pull request #798 from twiss/seek-bzip
Remove bzip2 compression
2018-11-05 12:58:50 +01:00
Daniel Huigens
08f48bfc2c Switch to seek-bzip 2018-11-05 12:49:53 +01:00
Sanjana Rajan
0be9113366
Merge pull request #797 from twiss/security-fixes
Security fixes
2018-11-05 11:58:31 +01:00
Daniel Huigens
9a7fe9cd45 Bump S2K iteration count parameter 2018-11-05 11:47:46 +01:00
Daniel Huigens
d314a20e0f Don't return keys with an authorized revocation key 2018-11-05 11:47:45 +01:00
Daniel Huigens
8fa3aadea2 Add and require primary key binding signatures on signing keys
Also, fix keyFlags of signing subkeys.

Also, store Issuer Key ID and Embedded Signature in unhashed rather
than hashed subpackets.
2018-11-05 11:47:45 +01:00
Daniel Huigens
8c97112449 Throw on critical unknown signature subpackets 2018-11-05 11:47:44 +01:00
Daniel Huigens
47138eed61 Don't trust unhashed signature subpackets
Also, export packet.Signature.prototype.read_sub_packets.
2018-11-05 11:47:43 +01:00
Daniel Huigens
327d3e5392 Only accept binary or text signatures when verifying messages 2018-11-05 11:47:39 +01:00
Sanjana Rajan
17f639bc8d
Merge pull request #795 from twiss/web-crypto-hashing
Web Crypto hashing
2018-11-05 11:38:41 +01:00
Daniel Huigens
2245df6023 Don't return streams in openpgp.revokeKey() 2018-11-05 11:15:39 +01:00
Daniel Huigens
4faa84daa0 Inline iterated S2K loop 2018-11-01 15:40:04 +01:00
Daniel Huigens
a250ee9f91 Clean up checksum calculation 2018-11-01 14:47:22 +01:00
Daniel Huigens
e8a2c45390 Only use Web Crypto for hashing beyond a treshold number of bytes
Sending data to the Web Crypto API involves some latency.
2018-11-01 14:47:22 +01:00
Daniel Huigens
7253df1632 Don't hash when comparing key fingerprints 2018-11-01 14:47:21 +01:00
Daniel Huigens
abce79b509 Use Web Crypto for hashing 2018-11-01 14:11:22 +01:00
Sanjana Rajan
3c45b6f18a
Merge pull request #793 from twiss/signature-errors
Check that one-pass signatures match their corresponding signature
2018-11-01 12:13:02 +01:00
Daniel Huigens
11fd2313a7 Fix unhandled promise rejection when decrypting non-MDC message 2018-11-01 11:46:43 +01:00
Daniel Huigens
13c29b1fc9 Fix decryption with multiple passwords 2018-11-01 11:46:27 +01:00
Sanjana Rajan
09def1208d
Merge pull request #790 from nickmi/master
fixed key lookup example on  README.md
2018-11-01 11:41:12 +01:00
Daniel Huigens
d442b6bad7 Throw when signature packet does not correspond to one pass signature packet 2018-10-29 11:47:39 +01:00
Daniel Huigens
9c82bf491e Reject signatures[*].verified and signatures[*].signature on read errors
However, don't throw "unhandled promise rejection" when not using these
properties at all, or when they reject before the user has a chance to
handle them.
2018-10-29 11:47:36 +01:00
Daniel Huigens
c3419e5cd0 Don't return streams in openpgp.reformatKey() 2018-10-25 19:41:59 +02:00
nickmi
cdec95cb21
Update README.md 2018-10-23 23:05:24 +03:00
nickmi
50e522f34a
Update README.md 2018-10-23 18:58:17 +03:00
Sanjana Rajan
3c1d89bbb5 Release new version 2018-10-20 19:03:51 +02:00
Sanjana Rajan
7a2e0dcdf2
Merge pull request #787 from twiss/perf-fix-large-msgs
Fix performance issue with handling large messages
2018-10-20 18:59:21 +02:00
Daniel Huigens
baaa0716b4 Fix performance issue with handling large messages 2018-10-19 15:09:33 +02:00
Sanjana Rajan
f15b648b01 edit README wording 2018-10-12 17:27:09 +02:00
Sanjana Rajan
b972bd8e09
Merge pull request #782 from ZelphirKaltstahl/master
added helpful comment about default encryption and decryption of U8in…
2018-10-12 17:13:51 +02:00
Hans-Werner Roitzsch
12418921d0 adapted comment for pull request 2018-10-12 16:19:22 +02:00
Hans-Werner Roitzsch
2f1f901fdf added helpful comment about default encryption and decryption of U8intArray with password 2018-10-11 11:51:23 +02:00
Daniel Huigens
6f9670cc65 Clarify comment explaining packetlist's usage of supportsStreaming 2018-10-10 18:21:02 +02:00
Sanjana Rajan
c3b33c4251
Merge pull request #781 from evildvl/patch-1
Multiple public keys code
2018-10-10 18:20:21 +02:00
Sanjana Rajan
1e3f223e8b
Merge pull request #779 from twiss/throw-parse-errors
Throw on parse errors in integrity protected encrypted packets
2018-10-10 18:16:59 +02:00
Stanislav Mikhaylov
a4276677b8
Update function to be clear
Update function to be clear and without hardcoded payload
2018-10-09 11:10:27 +03:00
Stanislav Mikhaylov
9f8c93dc04
Multiple public keys example 2018-10-09 10:51:38 +03:00
Stanislav Mikhaylov
ee1bcce275
Multiple public keys code
Update README.md with the code example by @avimar (https://github.com/openpgpjs/openpgpjs/issues/271#issuecomment-274901731). Think that it's too hard to find and missed in documentation.
2018-10-08 18:23:54 +03:00
Daniel Huigens
bc6118980f Throw on parse errors in integrity protected encrypted packets 2018-10-05 12:40:05 +02:00
Sanjana Rajan
a6e3ada438 Release new version 2018-10-04 23:43:46 -07:00
Sanjana Rajan
28ca741561
Merge pull request #778 from twiss/missing-sig-packet
Don't hang when signature packet corresponding to one-pass sig is missing
2018-10-04 23:21:02 -07:00
Daniel Huigens
3751731330 Don't hang when signature packet corresponding to one-pass sig is missing 2018-10-04 22:13:10 +02:00
Sanjana Rajan
150222bee5 Release new version 2018-09-25 16:38:51 -07:00
Sanjana Rajan
a35b4d28e0
Merge pull request #772 from twiss/getLatestValidSignature
Check validity and keyid of signatures before using them
2018-09-22 16:27:07 -07:00
Daniel Huigens
ac6b57781b Make isValid*KeyPacket inner functions 2018-09-22 23:03:10 +02:00
Daniel Huigens
bbcdacef8d Small documentation fixes 2018-09-22 23:03:10 +02:00
Daniel Huigens
b3af56b8a3 Ignore third-party revocation signatures
This check was removed in ec22dab.
2018-09-22 23:03:10 +02:00
Daniel Huigens
a1c47ecdea Indicate an error when parsing a key with an authorized revocation key
Since we will ignore revocation signatures from authorized revocation keys,
it is dangerous to use these keys.
2018-09-22 23:03:10 +02:00
Daniel Huigens
5cf61daa19 Check validity of signatures before using them 2018-09-22 23:03:10 +02:00
Sanjana Rajan
9614e8fc21
Merge pull request #773 from KAYLukas/master
Add missing browserify command
2018-09-20 12:18:03 -07:00
Kay Lukas
7a167fcccb Add missing browserify command 2018-09-20 14:20:47 +02:00
Sanjana Rajan
cccebd0272 Release new version 2018-09-17 13:18:05 -07:00
Sanjana Rajan
528e544d04
Merge pull request #771 from twiss/publish-compat-npm
Publish compat files to npm
2018-09-17 12:56:44 -04:00
Sanjana Rajan
7ad492783a
Merge pull request #769 from twiss/armor-newlines-consistency
Make newlines in armored objects consistent
2018-09-17 12:56:25 -04:00
Daniel Huigens
682548485a Publish compat files to npm 2018-09-14 14:30:58 +02:00
Daniel Huigens
d8840294cf Make newlines in armored objects consistent
- Don't add an extraneous newline at the end of base64-encoded data
  if it is a multiple of 60 characters long.
- Generate \r\n instead of \n in base64-encoded data.
- Generate one newline instead of two after END PGP PUBLIC KEY BLOCK
  for consistency with the other footers.
2018-09-13 14:32:35 +02:00
Sanjana Rajan
585ee3ff44
Merge pull request #766 from twiss/split-saucelabs-tests
Split Sauce Labs JS unit tests into multiple parts for slow browsers
2018-09-11 11:37:50 -07:00
Daniel Huigens
0a5461b8ba Split Sauce Labs JS unit tests into multiple parts for slow browsers
Sauce Labs has a timeout of 5 minutes (including emulator/browser
startup time).
2018-09-10 19:27:13 +02:00
Sanjana Rajan
aab04c2ad2 Release new version 2018-09-03 22:57:08 -07:00
Sanjana Rajan
d43437473f bugfix - when a requested key capability is not present, return null expiration 2018-09-03 21:59:58 -07:00
Sanjana Rajan
e616f8a242
Merge pull request #763 from twiss/decrypt-performance-fix
Decryption performance fix
2018-09-03 15:20:19 -07:00
Daniel Huigens
ca2f6d03b6 Slightly optimize base64 decoding 2018-09-03 18:23:38 +02:00
Daniel Huigens
dc722770d0 Don't process armored message data line per line
This cuts down on the overhead of streaming by reducing the amount
of calls to reader.read() and writer.write().
2018-09-03 18:23:38 +02:00
Sanjana Rajan
b004ddecb2
Merge pull request #699 from twiss/saucelabs-browsers
Update Sauce Labs browsers
2018-08-29 10:46:46 -07:00
Daniel Huigens
8a254b6001 Update Sauce Labs browsers 2018-08-29 17:34:38 +02:00
Daniel Huigens
564c645064 Fix intermittent "Data did not arrive early" test failure 2018-08-24 13:31:44 +02:00
Sanjana Rajan
8681ce8706
Merge pull request #755 from DanielRuf/test/add-nodejs-10
test: add Node.js 10 and remove Node.js 9
2018-08-22 12:44:29 -07:00
Daniel Ruf
aa0f1320ff
tests: force npm install instead of npm ci 2018-08-19 21:18:14 +02:00
Daniel Ruf
d94a3b8735
test: add Node.js 10 and remove Node.js 9 2018-08-17 15:43:12 +02:00
Sanjana Rajan
22c66c13a6 Release new version 2018-08-14 15:37:17 -07:00
Sanjana Rajan
d3236434b8 update release script 2018-08-14 15:34:54 -07:00
Daniel Huigens
7a4df6912b Fix intermittent failures of tests for stream error detection on Node 2018-08-14 21:49:17 +02:00
Sanjana Rajan
6214459dfb
Merge pull request #709 from twiss/stream
WIP: Streaming
2018-08-14 09:23:38 -07:00
Daniel Huigens
e055d86062 Update documentation 2018-08-14 17:50:26 +02:00
Daniel Huigens
6134b0dcaf Update README.md 2018-08-14 17:50:25 +02:00
Daniel Huigens
80453d29ad Update release script 2018-08-14 17:24:41 +02:00
Daniel Huigens
e5a3095894 Fix GCM and EAX in Edge
Web Crypto AES-GCM in Edge seems to require non-empty ADATA and an
explicit tagLength.

AES-CTR doesn't seem to be supported at all, so this disables Web Crypto
for EAX in Edge.
2018-08-14 17:24:41 +02:00
Daniel Huigens
08216bab13 Add npm run build to build both compat and non-compat files 2018-08-14 17:24:41 +02:00
Daniel Huigens
a2044a2833 Fix Sauce Labs Edge 2018-08-14 17:24:41 +02:00
Daniel Huigens
4bdc5e92ab Add --compat option
Without it, the generated build is for recent versions of
Chrome, Firefox, Safari and Edge.

With it, the generated build is for IE11+.
2018-08-14 17:24:41 +02:00
Daniel Huigens
8170682e54 Replace build_debug target with --dev option
The --dev option also works with browsertest and any other targets
that depend on a build.
2018-08-14 17:24:40 +02:00
Daniel Huigens
c705f475b7 Switch back to hash.js SHA512
asmcrypto.js SHA512 is huge (75kB, 7kB gzipped).

This partially reverts fadcc4b5.
2018-08-14 17:24:40 +02:00
Daniel Huigens
d1626a7a51 Disable some tests on Sauce Labs
Since we still run the full test suite on Node.js, this would
only no longer catch bugs which are specific to

- Browser non-draft04 GCM (and don't manifest in draft04 GCM,
  and don't manifest in Node.js non-draft04 GCM)
- Browser OCB (which is not natively implemented in the browser)
- Browser V5 Keys
2018-08-14 17:24:40 +02:00
Daniel Huigens
00a2c0c0c2 Support unicode surrogate code points 2018-08-14 17:24:40 +02:00
Daniel Huigens
a2f53b2ce2 Speed up initial builds 2018-08-14 17:24:40 +02:00
Daniel Huigens
9bf7bbf45e Don't generate a new key for each encryption mode in tests 2018-08-14 17:24:39 +02:00
Daniel Huigens
67b067b1da Remove duplicate tests
Many tests would run for every encryption mode, or for both V4 and V5 keys,
without there being any difference between the different test runs.

`grunt coverage` before and after this commit reports almost identical
statistics, providing some confidence that no code coverage was lost.
2018-08-14 17:24:39 +02:00
Daniel Huigens
225f586970 Make ECC tests less idiosyncratic 2018-08-14 17:19:55 +02:00
Daniel Huigens
aa3ede94ec Fix intermittent failure of tests detecting checksum errors 2018-08-14 17:19:55 +02:00
Daniel Huigens
68016b22a5 Always scroll down unit tests on Sauce Labs 2018-08-14 17:19:54 +02:00
Daniel Huigens
8c7e4386af Fix stream-reading zero-length (partial) packets 2018-08-14 17:19:54 +02:00
Daniel Huigens
6fdfb2cd9d Don't include Node Buffer in browserified version 2018-08-14 17:19:54 +02:00
Daniel Huigens
7756e4dc99 Update npm-shrinkwrap 2018-08-14 17:19:54 +02:00
Daniel Huigens
052fa444be Support Node streams 2018-08-14 17:19:54 +02:00
Daniel Huigens
0ddff3ae7d Rename asStream to streaming
Also, break up `postProcess`.
2018-08-14 17:19:51 +02:00
Daniel Huigens
b35b167e63 Add openpgp.cleartext.fromText
For symmetry with message.fromText
2018-08-14 16:35:41 +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
bb15ffc2a0 Fix streaming verify when using Worker and streams polyfill 2018-08-14 16:35:40 +02:00
Daniel Huigens
61a0e3fa69 Fix tests on IE11 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
0b0112d1e6 En/decrypt all AEAD chunks in parallel when not returning a stream 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
54d5bd7d39 Add testcase for verifying messages without one-pass-signatures 2018-08-14 16:35:39 +02:00
Daniel Huigens
ca537e439d Comments & code style 2018-08-14 16:35:38 +02:00
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
85223093a4 Switch to fork of asmcrypto.js
Fixes performance issues in Firefox.
2018-08-10 14:46:30 +02:00
Daniel Huigens
d489f3369f Update to asmcrypto.js 2 2018-08-10 14:46:30 +02:00
Daniel Huigens
e66d44e42d Rename config.unsafe_stream to allow_unauthenticated_stream 2018-08-10 14:46:29 +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
95413cc6ed Fix signatures of messages with leading/trailing whitespace 2018-08-10 14:46:29 +02:00
Daniel Huigens
160b03451f Fix key generation in Firefox
Previously broken by daa0188e.
2018-08-10 14:46:29 +02:00
Daniel Huigens
9f0f00e087 Make signature.verified a Promise instead of result.signatures
Also, fix verifying detached signatures
2018-08-10 14:46:28 +02:00
Daniel Huigens
0db32bea39 Backpressure and cancellation in sign/verify 2018-08-10 14:46:28 +02:00
Daniel Huigens
d2ba6b3c6c Wait for data to be read before resolving signatures 2018-08-10 14:46:28 +02:00
Daniel Huigens
3113976dd2 Don't throw in result.signatures
- The caller might not await them, in which case you get an "unhandled rejection"
- The caller might await them but only after reading the data, in which case you
  get an unhandled rejection if there's an error before the end of the data
2018-08-10 14:46:27 +02:00
Daniel Huigens
b6e988b6a6 Convert result.signatures to a Promise
Also, throw armor checksum errors inside the data stream
2018-08-10 14:46:27 +02:00
Daniel Huigens
0cabf72682 Add TextDecoder polyfill 2018-08-10 14:46:27 +02:00
Daniel Huigens
ad92ac7c3a Fix signature type of one-pass signatures when passing a signature
If the type of the signature passed to openpgp.encrypt() did not
match the "expected" type (text for literal text packets, etc)
the signature type would be set incorrectly.
2018-08-10 14:46:26 +02:00
Daniel Huigens
4d82d25559 Pass more tests
We now use streams internally in more places.
2018-08-10 14:46:26 +02:00
Daniel Huigens
4e749965f2 Remove support for V3 keys and signatures 2018-08-10 14:46:26 +02:00
Daniel Huigens
eb72d4dd63 Don't use asmcrypto's streaming API when not necessary
Optimization for Firefox
2018-08-10 14:46:26 +02:00
Daniel Huigens
e1a8b17753 Fix literalPacket.getText()
We now close streams after reading them, so we can no longer use
stream.locked for a proxy for "has been read". What we want is the
internal [[disturbed]] property, but we can't access it for native
streams.

Since we always read the stream when calling getText(), it's not
an issue.
2018-08-10 14:46:25 +02:00
Daniel Huigens
411b626149 Work around timing difference between Chrome and polyfill
When piping a stream to a writable stream and erroring that,
the input (readable) stream only gets cancelled after pipeTo()
returns in Chrome.
2018-08-10 14:46:25 +02:00
Daniel Huigens
55fd292fba Fix armor errors
Also, fix error handling in transformPair()
2018-08-10 14:46:25 +02:00
Daniel Huigens
304cbf4783 Fix backpressure 2018-08-10 14:46:25 +02:00
Daniel Huigens
589b666ac7 Don't clone stream in packet.parse() 2018-08-10 14:46:24 +02:00
Daniel Huigens
ddda6a0b16 Implement cancellation by manually linking together input and output streams 2018-08-10 14:46:24 +02:00
Daniel Huigens
de2971d84a Use TransformStreams 2018-08-10 14:46:24 +02:00
Daniel Huigens
51c897b073 Cancelling 2018-08-10 14:46:23 +02:00
Daniel Huigens
a6a701df7f Streaming signing 2018-08-10 14:46:23 +02:00
Daniel Huigens
9c1c28bc59 Add option to read unauthenticated data from stream 2018-08-10 14:46:23 +02:00
Daniel Huigens
1effe19c1d Allow simultaneously reading data and waiting for signature verification
This makes openpgp.{decrypt,verify}().signatures a Promise when passing a
stream or when asStream=true
2018-08-10 14:46:22 +02:00
Daniel Huigens
4bbbdaee9f Rename stream.subarray() to stream.slice()
Also, support ReadableStream[String] in stream.* and reader.* functions
2018-08-10 14:46:22 +02:00
Daniel Huigens
56ec5b3a8d Don't keep extra copies of streams in memory 2018-08-10 14:46:22 +02:00
Daniel Huigens
78a0ca937e Cache browserified modules
Adding asmcrypto's SHA1 and SHA512 made browserify a lot slower,
this makes it a lot faster on the second run at least.
2018-08-10 14:46:21 +02:00
Daniel Huigens
f79a3f718d Fix streaming UTF8 decoding 2018-08-10 14:44:01 +02:00
Daniel Huigens
f0633f00ea Don't repeatedly decrypt the same key in unit tests 2018-08-10 14:44:01 +02:00
Daniel Huigens
253e1c572b Switch to asmcrypto for hashing where available 2018-08-10 14:44:01 +02:00
Daniel Huigens
ade2627bca Streaming verify one-pass signatures 2018-08-10 14:44:01 +02:00
Daniel Huigens
ead3ddd706 Streaming decrypt old-format packets 2018-08-10 14:44:01 +02:00
Daniel Huigens
9fcc075f0b Streaming decrypt non-partial-length-encoded packets 2018-08-10 14:44:01 +02:00
Daniel Huigens
fb155ffae0 Streaming support on Node 2018-08-10 14:44:01 +02:00
Daniel Huigens
8658816b90 Add Web Streams polyfill 2018-08-10 14:44:01 +02:00
Daniel Huigens
802e1b8d94 Transfer Streams to Workers
Also, add a "asStream" parameter to high-level functions to control
whether the return value is a Stream; defaulting to whether the
parameter passed was a Stream.
2018-08-10 14:44:01 +02:00
Daniel Huigens
58eca571bf Fix integrity_protect = false 2018-08-10 14:44:01 +02:00
Daniel Huigens
d67526338e Streaming (de)compression (Web)
compressjs has a streaming API, but it is synchronous, so we can't use it
(at least in the browser).
2018-08-10 14:44:01 +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
05479e6e6b Don't warn about await in loops 2018-08-10 14:44:01 +02:00
Daniel Huigens
db39e616ca Replace stream.tee() with stream.clone()
Also some other fixes to pass more tests.
2018-08-10 14:44:01 +02:00
Daniel Huigens
3475843d82 Don't hack util.concatUint8Array() to handle Streams
Use util.concat() instead.
2018-08-10 14:44:01 +02:00
Daniel Huigens
16ba26c298 Streaming AEAD 2018-08-10 14:44:01 +02:00
Daniel Huigens
1f30556674 Split stream.transform into using two helper functions 2018-08-10 14:44:01 +02:00
Daniel Huigens
4ada3fa590 Don't mutate prototypes of Uint8Array, ReadableStream and ReadableStreamDefaultWriter 2018-08-10 14:44:01 +02:00
Daniel Huigens
70f0e1d2f5 Finish streaming armoring 2018-08-10 14:44:01 +02:00
Daniel Huigens
0af4742a14 Signatures 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
403bdc5346 Streaming decryption (Web) 2018-08-10 14:44:01 +02:00
Daniel Huigens
b4f5976242 Writing partial lengths 2018-08-10 14:44:01 +02:00
Daniel Huigens
9853d3d830 Streaming encryption (Web) 2018-08-10 14:44:01 +02:00
Daniel Huigens
9302fdcc56 Don't cache literal.getBytes() when signing with textMode=false
This partially reverts bcfb9c0.
2018-08-10 14:44:01 +02:00
Sanjana Rajan
5be838f9bb Release new version 2018-08-03 14:55:04 +02:00
Sanjana Rajan
c79bda1d37 bugfix - compare create time from key packet 2018-08-03 14:21:15 +02:00
Sanjana Rajan
16762d02f0 Release new version 2018-08-01 17:50:23 +03:00
Sanjana Rajan
8f01d4b0b5 clean up tests 2018-08-01 17:47:07 +03:00
Sanjana Rajan
adb0148ca1 fix #748, signature cloning in verification objects 2018-07-30 15:32:17 +03:00
Sanjana Rajan
d1416cbe2c
Merge pull request #746 from KAYLukas/fix/worker
Fix multiple workers
2018-07-27 10:41:35 +02:00
Sanjana Rajan
01abfc507d remove unnecessary trims 2018-07-27 09:50:54 +02:00
Kay Lukas
6f176f8b30 Fix multiple workers 2018-07-26 18:33:30 +02:00
Sanjana Rajan
438d47f634 handle case where primary user doesn't exist when getting exp time 2018-07-24 17:17:12 +02:00
Sanjana Rajan
49153db63b
Merge pull request #742 from wiktor-k/fix-uat-verification
Fix verification of User Attributes
2018-07-24 14:18:14 +02:00
Wiktor Kwapisiewicz
19e3c344fd
Fix verification of User Attributes
This change corrects verification of certifications over User Attributes
(such as photos).

Before this change the code did not differentiate between User IDs and
User Attributes as both of them were stored in `data.userid` [0] and
incorrectly used the User ID constant (0xB4) for both cases.

This change fixes the bug by storing User IDs in `userId` property and
User Attributes in `userAttribute` property. The check for property
existence has been modified to avoid comparisons with `undefined` as the
`User` class sets `null` for not assigned packets instead of
`undefined`.

Only data structures for signing and verification were modified and not
the properties used in the `User` class.

[0]: 11b2d2de3c/src/key.js (L872)
2018-07-24 13:03:46 +02:00
Sanjana Rajan
5c574d92ca remove package-lock 2018-07-23 15:12:01 +02:00
Sanjana Rajan
21449ebd50 Release new version 2018-07-19 18:13:51 +02:00
Sanjana Rajan
11b2d2de3c
Merge pull request #739 from twiss/key-expiry-capabilities
Allow checking expiry of key by capabilities
2018-07-19 15:23:25 +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
Daniel Huigens
06746b6a77 Use latest created subkey when possible 2018-07-18 14:29:59 +02:00
Daniel Huigens
8f3e448fa6 Remove obsolete JSDoc comment 2018-07-13 18:15:53 +02:00
Sanjana Rajan
21c908a86a Release new version 2018-07-13 18:00: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
e411839ae3 Deduplicate signature packet creation 2018-07-11 18:05:01 +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
Sanjana Rajan
5455b4f546
Merge pull request #728 from MaximilianKrambach/user_packets_678
Key merging with non-UserID user attribute
2018-07-11 15:42:07 +02:00
Maximilian Krambach
11029e4162 Key merging with non-UserID user attribute
fix #678
2018-07-09 16:53:55 +02:00
Sanjana Rajan
96c1c2158e Release new version 2018-07-02 11:55:53 +02:00
Sanjana Rajan
99d3849ff3 style fix 2018-07-02 11:44:06 +02:00
Sanjana Rajan
b56afca063
Merge pull request #725 from FlowCrypt/master
configurable max uid length | close #724
2018-07-02 11:44:38 +02:00
Tom James Holub
35260cb5db configurable max uid length | close #724 2018-06-30 04:35:08 +00:00
Sanjana Rajan
7736db7acb
Merge pull request #723 from wiktor-k/fix-signersuid
Fix reading signersUserId packet in signatures
2018-06-29 23:38:03 +02:00
Wiktor Kwapisiewicz
0099c373d2
Fix reading signersUserId packet in signatures
This bug caused all signersUserIds strings to be prefixed with `"null"`
string. Changed to use only the last value for this packet type.

Previous implementation probably assumed that there will be more than one
signersUserId packet but I haven't been able to generate such signature
using gpg (only last user id was embedded). Moreover signature
serialization function `write_all_sub_packets` writes only one value of
this packet as a UTF-8 string.
2018-06-27 12:17:19 +02:00
Sanjana Rajan
c7a65ccd16 fix #716 2018-06-13 15:05:10 +02:00
Sanjana Rajan
0248604a96 more helpful error messages when rsa message and sig sizes exceed that of modulus 2018-06-13 13:06:07 +02:00
Sanjana Rajan
c83c81ca56
Merge pull request #708 from MaximilianKrambach/tests
Run tests with randomly generated strings
2018-06-08 09:06:43 -07:00
Maximilian Krambach
4beb31333e change some variable names in tests to camelCase 2018-06-04 12:33:01 +02:00
Sanjana Rajan
75f291839e
Merge pull request #714 from wiktor-k/wkd
Add support for Web Key Directory lookups
2018-05-29 14:37:05 -07:00
Wiktor Kwapisiewicz
043e77a6ea
Add Web Key Directory lookup
This change implements Web Key Directory lookup using user's e-mail
address. The target host is the same as the e-mail's domain and the
local-part is hashed with SHA-1 and encoded using Z-Base32 encoding.

Implemented is basic flow of version 06 of OpenPGP Web Key Directory
draft [0].

It was necessary to update node-fetch package to allow returning array
buffers from HTTP responses.

If openpgpjs is used in the browser all keys retrieved from Web Key
Directory should have `Access-Control-Allow-Origin` header set to `*`
(including 404 Not found responses).

[0]: https://datatracker.ietf.org/doc/draft-koch-openpgp-webkey-service/
2018-05-29 21:21:24 +02:00
Wiktor Kwapisiewicz
da98ccb421
Add ZBase32 encoding function
See: https://tools.ietf.org/html/rfc6189#section-5.1.6
2018-05-29 09:55:47 +02:00
Sanjana Rajan
be26302d99
Merge pull request #703 from nguyendviet/master
new Encrypt and decrypt String data with PGP keys example
2018-05-28 15:17:24 -07:00
Sanjana Rajan
bf428b80d4 Release new version 2018-05-22 17:39:26 -07:00
Sanjana Rajan
80aab5d94f Merge pull request #712 from openpgpjs/signature_formatting
Fix #710
2018-05-22 17:32:22 -07:00
Sanjana Rajan
bcfb9c037a fix case with binary signatures on text data 2018-05-22 14:58:13 -07:00
Sanjana Rajan
5111a2ba43
Merge pull request #705 from mmso/fix/ie11
Fix IE11 support
2018-05-19 12:50:54 -07:00
mmso
11ff845c3e
Don't include transferable on IE11 on postMessage 2018-05-18 09:16:57 +02:00
Maximilian Krambach
1eb3902a96 Run tests with randomly generated strings 2018-05-17 12:40:30 +02:00
Sanjana Rajan
7cd2aded63 Release new version 2018-05-15 00:05:10 -07:00
Sanjana Rajan
33d5b158f8 fix #706 - if ignore_mdc_error is set to false then MDC is required for all symmetrically encrypted data 2018-05-15 00:04:58 -07:00
Viet Nguyen
65be3ed77a new Encrypt and decrypt String data with PGP keys example 2018-05-09 21:48:00 -04:00
Sanjana Rajan
6efcce1069 prioritize signing with subkeys when possible 2018-05-09 12:23:35 -07:00
Sanjana Rajan
4926667cf9
Merge pull request #694 from twiss/eslint-cleanup
Remove some ESLint silencers
2018-05-03 08:05:57 -07:00
Sanjana Rajan
244a71162d
Merge pull request #698 from twiss/fix-aead-instructions
Fix AEAD instructions
2018-05-03 08:05:30 -07:00
Sanjana Rajan
4c9d025193
Merge pull request #693 from twiss/userid
Parse user IDs & allow selecting user when encrypting/signing
2018-05-03 08:05:12 -07:00
Daniel Huigens
3ffcc7bb76 Fix AEAD instructions 2018-05-03 16:05:31 +02:00
Daniel Huigens
b5c6e655de Warn about console usage 2018-05-03 13:07:52 +02:00
Daniel Huigens
4afaae13ca Remove unused variables 2018-05-03 13:07:52 +02:00
Daniel Huigens
6e27e3145c Micro-optimize DSA signing 2018-05-03 13:07:52 +02:00
Daniel Huigens
0ae427060f Add Object.assign polyfill 2018-05-03 13:07:51 +02:00
Daniel Huigens
887e832635 Throw when user ID matches no users 2018-05-03 13:04:32 +02:00
Daniel Huigens
95b9e5188a Remove some ESLint silencers 2018-05-01 17:36:15 +02:00
Daniel Huigens
94b27c9a02 Don't repeatedly loop enums in enums.read 2018-05-01 16:43:29 +02:00
Daniel Huigens
3c224379f6 Remove util.isUserId()
It was not really correct anyway; a user id can just be an email address
without < > brackets.
2018-05-01 13:39:24 +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
Sanjana Rajan
cf3c2790f2 Release new version 2018-04-30 14:58:14 -07:00
Sanjana Rajan
9a5583fd25 clarifying comments 2018-04-30 13:30:48 -07:00
Sanjana Rajan
d562c147f9
Merge pull request #691 from twiss/draft04
Implement RFC4880bis-04
2018-04-30 12:16:20 -07:00
Daniel Huigens
a16d1a6a1d iOS does not support GCM-en/decrypting empty messages 2018-04-30 19:09:48 +02:00
Daniel Huigens
2627755b49 iOS Safari doesn't allow setting Error.message 2018-04-30 16:58:39 +02:00
Daniel Huigens
49c9fb193d Only call webCrypto.generateKey once in tests 2018-04-30 16:58:39 +02:00
Daniel Huigens
8ec01ae07a Reduce duplicate tests 2018-04-30 16:58:38 +02:00
Daniel Huigens
a7fce27424 Safari 8 compatibility 2018-04-30 16:58:37 +02:00
Daniel Huigens
cc1f7a4765 Lower chunk_size_byte to 12 (256KiB)
- In anticipation of streaming decryption
- Firefox 34 does not support chunk_size_byte > 24

256KiB is almost as fast as no chunks (although both of those can be up to
~1.5x slower than optimally using threads for very large message sizes).
The optimal chunk size would be something like:

    max(data.length / navigator.hardwareConcurrency, 128KiB)

But we don't do so currently because

- We don't know the hardwareConcurrency of the decrypting machine
- Smaller chunk sizes are better for streaming decryption
2018-04-30 16:58:36 +02:00
Daniel Huigens
550b758d57 Fall back to asm for CTR and CBC in old Safari 2018-04-30 16:58:35 +02:00
Daniel Huigens
b8191388cd Bump "old Chrome" version from 38 to 41 2018-04-30 16:58:34 +02:00
Daniel Huigens
48cbb97d19 Bump Sauce Labs timeout 2018-04-30 16:58:33 +02:00
Daniel Huigens
7ce3f5521f Set default draft version to 4 2018-04-30 15:55:38 +02:00
Daniel Huigens
04651e359a Rename enums.aead.gcm to experimental_gcm
So that (1) if the spec ever defines GCM differently than we do, we have a
clean upgrade path and (2) it makes it clear that it's experimental.
2018-04-30 15:55:37 +02:00
Daniel Huigens
bbf71d149b Deduplicate OCB encrypt / decrypt 2018-04-30 15:55:37 +02:00
Daniel Huigens
e8adeef278 Implement Issuer Fingerprint subpacket 2018-04-30 15:55:37 +02:00
Daniel Huigens
310d8dd9b9 Fix V5 key fingerprint in ECDH parameters 2018-04-30 15:55:36 +02:00
Daniel Huigens
be62b0cf65 Add algorithm IDs for AEDH and AEDSA 2018-04-30 15:55:36 +02:00
Daniel Huigens
0376f49e01 Deduplicate getPreferredSymAlgo / getPreferredAEADAlgo 2018-04-30 15:55:35 +02:00
Daniel Huigens
4568d080d5 Fix decryption with multiple chunks 2018-04-30 15:55:34 +02:00
Daniel Huigens
485cb17e95 Deduplicate SymEncryptedAEADProtected encrypt / decrypt 2018-04-30 15:55:34 +02:00
Daniel Huigens
343c64eca0 Add tests for signing and verifying messages with trailing spaces 2018-04-30 15:55:33 +02:00
Daniel Huigens
ebeedd3443 Fix removing whitespace from the last line of cleartext signed messages
Also, move normalizing line endings and removing whitespace to util functions
2018-04-30 15:55:33 +02:00
Daniel Huigens
4e204d7331 Update AEAD instructions in README 2018-04-30 15:55:32 +02:00
Daniel Huigens
d7efead337 Update Web Worker selection logic for AEAD 2018-04-30 15:55:32 +02:00
Daniel Huigens
e061df113c Implement GCM mode in the new draft
Also, implement additional data for GCM
2018-04-30 15:55:31 +02:00
Daniel Huigens
d5a7cb3037 Constant-time double() in OCB 2018-04-27 14:06:20 +02:00
Daniel Huigens
69762f95de Code style 2018-04-27 14:06:20 +02:00
Daniel Huigens
51d7860622 Native CMAC 2018-04-27 14:06:19 +02:00
Daniel Huigens
6f2abdc2cf Implement MIME message type (Literal Data Packet format 'm') 2018-04-27 14:06:19 +02:00
Daniel Huigens
3b81088aaf Decouple signature type from data packet type
Instead of creating a text signature for text packets and a binary signature for
binary packets, we determine the signature type based on whether a String or
Uint8Array was originally passed. This is useful for the new MIME data packet
type (implemented in the next commit) which you can pass in either format.

This also partly reverts a22c9e4. Instead of canonicalizing the literal data
packet, we canonicalize the data when signing. This fixes a hypothetical case
where an uncanonicalized text packet has both a text and a binary signature.

This also partly reverts c28f7ad. GPG does not strip trailing whitespace when
creating text signatures of literal data packets.
2018-04-27 14:06:19 +02:00
Daniel Huigens
2f849063f9 Allow reusing EAX/OCB instances with the same key
This is useful for chunked encryption in draft04
2018-04-27 14:06:19 +02:00
Daniel Huigens
e24b46192d Only AEAD-protect when target keys support it 2018-04-27 14:06:18 +02:00
Daniel Huigens
e9a360019c Update table of supported native ECC curves 2018-04-27 14:06:18 +02:00
Daniel Huigens
e44fbbccab Add more OCB tests 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
d5d4c97228 Fix config.use_native 2018-04-27 14:06:17 +02:00
Daniel Huigens
53d6f20b72 Reduce allocations in OCB mode 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
f225f994ec Add AEAD-OCB test vector 2018-04-27 14:06:16 +02:00
Daniel Huigens
5f97a8c937 Implement preferred AEAD algorithms 2018-04-27 14:06:16 +02:00
Daniel Huigens
93f75f398f Reuse CMAC in EAX mode 2018-04-27 14:06:16 +02:00
Daniel Huigens
627a6ef46e Only calculate AES key schedules once in cipher/aes.js 2018-04-27 14:06:15 +02:00
Daniel Huigens
c6ba83c4a3 Allow configuring openpgp in unit tests using query params (e.g. ?debug=true&use_native=false) 2018-04-27 14:06:15 +02:00
Daniel Huigens
ba2b761da4 Implement OCB mode 2018-04-27 14:06:15 +02:00
Daniel Huigens
cc4cc38fe7 Add util.print_debug_hexarray_dump 2018-04-27 14:06:15 +02:00
Daniel Huigens
f40489aa43 Implement getLeftNBits, shiftLeft and shiftRight for Uint8Arrays 2018-04-27 14:06:14 +02:00
Daniel Huigens
5f891d28d6 Switch cipher/aes.js to Uint8Arrays 2018-04-27 14:06:14 +02:00
Daniel Huigens
c2f898279b Implement version 5 Secret-Key Packet Format 2018-04-27 14:06:14 +02:00
Daniel Huigens
5d43b44e50 Log swallowed errors in debug mode 2018-04-27 14:06:14 +02:00
Daniel Huigens
7c3bbe9278 Don't auto-scroll unit tests if you scrolled up 2018-04-27 14:06:13 +02:00
Daniel Huigens
17ad654d60 Implement version 5 Symmetric-Key Encrypted Session Key packet 2018-04-27 14:06:13 +02:00
Sanjana Rajan
92542e3ee4 fix #636 2018-04-26 13:19:02 -07:00
Daniel Huigens
7b3f51c0d4 Implement AEAD Encrypted Data Packet 2018-04-25 20:12:10 +02:00
Daniel Huigens
85a1b9859b Implement EAX mode 2018-04-25 20:12:10 +02:00
Sanjana Rajan
dbc195d4ce Release new version 2018-04-25 11:11:57 -07:00
Sanjana Rajan
2376c8329c
Merge pull request #692 from twiss/fix-dash-escaping
Fix dash-escaping the first line of cleartext signed messages
2018-04-25 11:03:41 -07:00
Daniel Huigens
c63ed980a1 Fix dash-escaping the first line of cleartext signed messages 2018-04-25 19:46:43 +02:00
Sanjana Rajan
ce973be6ba
Merge pull request #685 from twiss/workers-random
Use crypto.getRandomValues in Workers
2018-04-23 12:42:49 -07:00
Sanjana Rajan
6b2514f587
Merge pull request #687 from twiss/use-recent-binding
Only use the most recent self-signature
2018-04-23 12:42:36 -07:00
Daniel Huigens
ceec57672e Use most recent primary user 2018-04-23 14:17:09 +02:00
Daniel Huigens
bfc047da36 Don't request randomness from main thread in workers by default 2018-04-19 14:25:13 +02:00
Sanjana Rajan
61f20fde12
Merge pull request #688 from KAYLukas/master
Support compression in the WebWorker
2018-04-18 09:10:39 -07:00
KAYLukas
187cc6b05a Support compression in the WebWorker 2018-04-18 18:08:36 +02:00
Daniel Huigens
39c7374d70 Only consider most recent user self certification 2018-04-18 14:40:07 +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
840a9811b4 Release new version 2018-04-17 08:44:25 -07:00
Sanjana Rajan
c28f7ad4d7 always remove trailing whitespace from lines when canonicalizing 2018-04-17 08:41:52 -07:00
Daniel Huigens
20a9bccb41 Use crypto.getRandomValues in Workers 2018-04-17 14:01:42 +02:00
Sanjana Rajan
d785df3325 Release new version 2018-04-16 15:19:27 -07:00
Sanjana Rajan
f9fba4a2a5 Release new version 2018-04-16 14:20:12 -07:00
Sanjana Rajan
2de426e0bc
Merge pull request #683 from openpgpjs/generate_key_refactor
More generateKey options
2018-04-16 14:13:13 -07:00
Sanjana Rajan
2bd540026f add multiple passphrase options to key encrypt and decrypt 2018-04-16 12:52:17 -07:00
Sanjana Rajan
e4bd27ce2f tests 2018-04-16 10:51:07 -07:00
Sanjana Rajan
ad2472b45b
Merge pull request #684 from KAYLukas/master
RandomRequested is never turned off
2018-04-16 09:45:30 -07:00
KAYLukas
d0ed5134d7 randomRequested is never turned off 2018-04-16 17:05:44 +02:00
Sanjana Rajan
24119f4fb1 keygen update 2018-04-15 12:38:18 -07:00
Sanjana Rajan
f1714fd9b5 Release new version 2018-04-05 07:20:48 -07:00
Bart Butler
c13960a9aa
Merge pull request #680 from twiss/native-brainpool-node
Add native Brainpool support on Node.js
2018-03-26 12:36:53 -07:00
Daniel Huigens
cfb0fdbbb1 Check length tag in DER-encoded OIDs 2018-03-26 19:06:15 +02:00
Daniel Huigens
59b608f0a6 Enable native Brainpool crypto on Node 2018-03-26 16:18:21 +02:00
Sanjana Rajan
8d0953875b
Merge pull request #679 from openpgpjs/text_sigs
When signature type is text, canonicalize line endings
2018-03-22 16:55:53 -07:00
Sanjana Rajan
614640ee42 add comment 2018-03-22 16:55:40 -07:00
Sanjana Rajan
8778490061 tests 2018-03-22 16:11:39 -07:00
Sanjana Rajan
a22c9e4770 WIP text signatures 2018-03-22 16:10:21 -07:00
Sanjana Rajan
c9d837cf8a
Merge pull request #677 from openpgpjs/keygen_date
Date parameter for generateKey
2018-03-20 04:25:14 -07:00
Sanjana Rajan
6fe73033a4 docs 2018-03-19 19:11:20 -07:00
Sanjana Rajan
2f351985c4 tests 2018-03-19 18:55:30 -07:00
Sanjana Rajan
eb96d44298 add date parameter to generateKey function 2018-03-19 18:55:15 -07:00
Sanjana Rajan
afc9164e7d Release new version 2018-03-19 00:15:58 -07:00
Sanjana Rajan
f88c1bc8a4
Merge pull request #672 from openpgpjs/feat/brainpool
Adds Brainpool Curves + tests + docs
2018-03-19 00:09:23 -07:00
Sanjana Rajan
401edab455 add brainpool gpg compatibility tests 2018-03-18 22:36:36 -07:00
Sanjana Rajan
7dcc74b295
Merge pull request #674 from cheme/master
Fix parsing of revocation subkey fingerprint
2018-03-18 12:54:14 -07:00
Emeric Chevalier
e257e7a570 Fix parsing of revocation subkey fingerprint 2018-03-18 19:45:12 +01:00
Mahrud Sayrafi
944dece506
Adds Brainpool Curves + tests + docs 2018-03-18 10:12:29 -07:00
Sanjana Rajan
66f9faaa63
Merge pull request #673 from openpgpjs/exp_time
Calculate expiration time of already expired keys
2018-03-17 09:05:10 -07:00
Sanjana Rajan
75cd4e5e6f some fixes, add expired key test 2018-03-17 07:32:56 -07:00
Sanjana Rajan
c0ceffe998 some refactoring, calculate exp time of expired keys 2018-03-17 04:59:58 -07:00
Bart Butler
4eab6e68e9 Release new version 2018-03-16 12:29:33 -07:00
Sanjana Rajan
a41fc29b44 typo fix 2018-03-16 11:52:45 -07:00
Sanjana Rajan
7408e824cb fix sort function for choosing primary user 2018-03-16 11:50:20 -07:00
Bart Butler
8dd4b3f256 Release new version 2018-03-15 11:32:09 -07:00
Sanjana Rajan
b4055f494f fix #670 2018-03-15 09:05:36 +01:00
Sanjana Rajan
4d40c603cc
Merge pull request #668 from openpgpjs/rev_fixes
invalid primary key -> all subkeys are invalid
2018-03-13 08:34:48 +01:00
Mahrud Sayrafi
96c9cd0d73
Fixes dead links in the documentation 2018-03-13 00:13:04 -07:00
Sanjana Rajan
3945912b29 remove some redundant code 2018-03-13 01:44:22 +01: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
4ded3f9d58
Documentation improvements in src/packet 2018-03-09 08:01:06 -08:00
Mahrud Sayrafi
a5e7562066
Many documentation improvements; more to come 2018-03-08 19:27:57 -08:00
Sanjana Rajan
184a988d0d Release new version 2018-03-08 22:01:56 +01:00
Mahrud Sayrafi
08da24de27
documentation fixes 2018-03-08 10:55:58 -08:00
Sanjana Rajan
d3f42b2fc1 update comments 2018-03-08 15:36:40 +01:00
Sanjana Rajan
c5b5bf7826 utils fix 2018-03-08 14:28:50 +01:00
Sanjana Rajan
6c7a73b5d0 README formatting 2018-03-08 13:10:19 +01:00
Sanjana Rajan
843d94fd60
Merge pull request #660 from openpgpjs/bug/subkey-revocations
Renovates revocationSignature handling, removes hacks around getPrimaryUser
2018-03-08 10:44:53 +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
23a4141ce9 Addresses @sanjanarajan's comments 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
Sanjana Rajan
354b961b67 primegen bugfix, recalculate i 2018-03-07 08:32:52 +01:00
Sanjana Rajan
dd4c05ae84
Merge pull request #662 from KAYLukas/feat/rand-prime-perf
randomProbablePrime: Don't consider multiples of 3 and 5
2018-03-07 01:07:10 +01:00
Sanjana Rajan
1875ad3048 don't lint compression folder 2018-03-07 01:05:05 +01:00
KAYLukas
59d2973c05 ESLint 2018-03-07 00:50:26 +01:00
Mahrud Sayrafi
0684fb760e
Using small_primes from gpg2 2018-03-06 14:28:01 -08:00
KAYLukas
389d6410c9 Don't consider multiples of 3 and 5 2018-03-06 23:11:49 +01:00
Bart Butler
3c420312a0
Merge pull request #661 from openpgpjs/random_workers
Eliminate running out of random bytes in workers, allow N workers
2018-03-06 10:13:18 -08:00
Bart Butler
1cd9018346 some cleanup 2018-03-06 10:04:33 -08:00
Bart Butler
2bb5db2cf4 multiple web workers 2018-03-05 21:36:53 -08:00
Bart Butler
572abadc91 random number web worker buffer automatic refill 2018-03-05 17:57:35 -08:00
Bart Butler
433ae5cce7 remove extraneous file 2018-03-05 16:32:16 -08:00
Bart Butler
f57888fe55 change all calls of getRandomBytes and getRandomBN to be async 2018-03-05 16:31:56 -08:00
Bart Butler
b088f005da simplify random.js 2018-03-05 12:18:04 -08:00
Sanjana Rajan
3df1d849b3 missing brackets 2018-03-05 17:49:09 +01:00
Mahrud Sayrafi
2077d8487f
Wait for browser to finish ECC functions to make sure it succeeds 2018-03-01 15:47:50 -08:00
Bart Butler
20a0e76998 Merge branch 'master' of github.com:openpgpjs/openpgpjs 2018-03-01 11:55:17 -08:00
Bart Butler
5564b67cc8 remove readSignedContent in favor of appendSignature 2018-03-01 11:55:09 -08:00
Mahrud Sayrafi
30bd6102d5
OID's stored as Uint8Array 2018-03-01 11:35:16 -08:00
Mahrud Sayrafi
5e857e131e
Bugfix in Native ECC in Node 2018-03-01 01:28:03 -08:00
Bart Butler
5fac00eddb
Merge pull request #654 from openpgpjs/feat/asmcrypto
Modernizes MPI handling and public key algorithms; jsbn.js is dead, long live bn.js!
2018-02-28 16:10:24 -08:00
Mahrud Sayrafi
9e1236c04c
Modernizes util.js 2018-02-28 15:49:41 -08:00
Mahrud Sayrafi
9275119dbc
Enables JSDoc Markdown Plugin 2018-02-28 14:13:44 -08:00
Mahrud Sayrafi
7eef65926a
Simplifies elliptic/curve.js 2018-02-28 00:58:50 -08:00
Mahrud Sayrafi
746d5032e8
Provide our own randomness to elliptic 2018-02-27 17:40:41 -08:00
Mahrud Sayrafi
ecc38d0c6e
Adds worker tests for NIST P-256 and X25519 2018-02-27 16:40:28 -08:00
Mahrud Sayrafi
f04273cd8d
Merge branch 'master' into feat/asmcrypto 2018-02-27 14:57:34 -08:00
Sanjana Rajan
51adfcc244 fromClone function for ecdh symkey 2018-02-27 23:15:42 +01:00
Mahrud Sayrafi
a79acf0386
Loopless getRandomBN using extra random bits 2018-02-27 13:10:52 -08:00
Mahrud Sayrafi
d529edfdda
Addresses @sanjanarajan's review comments 2018-02-27 13:04:45 -08:00
Mahrud Sayrafi
b518d27ff0
Added Fixed-Base Miller-Rabin 2018-02-27 00:23:51 -08:00
Mahrud Sayrafi
d418b4aa40
MPI stores data as Uint8Array instead of BN 2018-02-27 00:19:34 -08:00
Mahrud Sayrafi
3df0997f4d
Cleanups 2018-02-26 20:01:01 -05:00
Bart Butler
0186ca8a24 tree shake sinon to just get what we need 2018-02-26 14:45:05 -08:00
Mahrud Sayrafi
378fb85733
Optimizes getRandomBN, Brings back IE11 KeyOperation helper 2018-02-26 16:56:42 -05:00
Mahrud Sayrafi
2e95335825
millerRabin set to 40 iterations; doc fixes 2018-02-25 09:30:19 -05:00
Mahrud Sayrafi
7a3a75a7df
JavaScript RSA using bn.js, without asmcrypto.js 2018-02-25 00:11:29 -05:00
Mahrud Sayrafi
9943379cb7
Added Native RSA Key Generation 2018-02-24 22:10:36 -05:00
Mahrud Sayrafi
168a6b0bb8
New probabilistic random number generation algorithms; UNTESTED 2018-02-22 18:27:34 -08:00
Mahrud Sayrafi
3b912d2fae
Cleaning mpi.js; TODO: store MPI.data as Uint8Array instead of BN
Also improved asynchronousity in packet tests
2018-02-22 14:51:57 -08:00
Mahrud Sayrafi
d40e8fe428
Use asmcrypto.js directly + quickfix 2018-02-22 11:51:21 -08:00
Bart Butler
8c4fa07dd5
babelify asmcrypto.js 2018-02-22 00:37:43 -08:00
Bart Butler
1b66b9cf60
fix worker tests 2018-02-22 00:37:43 -08:00
Mahrud Sayrafi
a2868a5c14
Begone jsbn.js! I tell you begonegit status 2018-02-22 00:37:43 -08:00
Mahrud Sayrafi
1812166a53
RSA using asmcrypto with asmcrypto bignum 2018-02-22 00:37:42 -08:00
Mahrud Sayrafi
605021af3b
Various quickfixes and cleanups 2018-02-22 00:37:42 -08:00
BafS
b794956691
Update engine field to support Node.js v8+ 2018-02-22 00:37:42 -08:00
BafS
10c49be91d
Use ES6 modules for exports 2018-02-22 00:37:42 -08:00
Mahrud Sayrafi
e1d85ba682
ElGamal and MPI use bn.js; TODO: RSA Key Generation 2018-02-22 00:37:42 -08:00
Mahrud Sayrafi
490b1dc0f0
ECDH, ECDSA, EdDSA are all on BN.js; TODO: ElGamal & type_mpi 2018-02-22 00:37:42 -08:00
Mahrud Sayrafi
9200f026f3
Starting to change MPI 2018-02-22 00:37:42 -08:00
Mahrud Sayrafi
2f3c0a86e9
DSA uses BN.js
added toBN for type_mpi
2018-02-22 00:37:41 -08:00
Mahrud Sayrafi
b126fd5be7
RSA encrypt/decrypt use asmcrypto as well
TODO: RSA key generation, removing jsbn from dsa, elgamal, mpi, etc.
2018-02-22 00:37:41 -08:00
Mahrud Sayrafi
aee8974ef5
RSA signatures now use asmcrypto.js; various fixes and tweaks 2018-02-22 00:37:41 -08:00
Mahrud Sayrafi
ed4cef102a
This branch uses the current version of asmcrypto.js 2018-02-22 00:37:41 -08:00
Bart Butler
e939d9b1ab
Merge pull request #647 from KAYLukas/feat/time-param
Add a date parameter to the sign/verify/encrypt/decrypt functions
2018-02-21 16:58:17 -08:00
KAYLukas
a5b30468ef Check creation time in expiration checks 2018-02-22 00:41:12 +01:00
KAYLukas
56ad9a00e0 Fix testcases 2018-02-21 22:32:09 +01:00
KAYLukas
6b4d44dbb1 Fix browser tests 2018-02-19 22:12:24 +01:00
KAYLukas
454ca1d879 Address comments 2018-02-18 11:50:27 +01:00
KAYLukas
071fc35f38 Check created time to be valid and discard milliseconds from date objects 2018-02-17 11:28:04 +01:00
Bart Butler
ce71c3d2ef try raising max-duration for saucelabs test 2018-02-16 18:00:42 -08:00
Bart Butler
f803b17859 remove time limit from loading x25519 private keys 2018-02-16 08:46:26 -08:00
KAYLukas
6ca8bc2180 Add timeparameter for verification and remove verify_expired_keys 2018-02-16 17:20:48 +01:00
KAYLukas
7e66ea20db Add timeparameter to signing and encryption 2018-02-16 17:20:48 +01:00
Bart Butler
be7973b904 add polyfills for test bundle 2018-02-15 21:28:26 -08:00
Bart Butler
3c2871a0e4 only access window.crypto.webkitSubtle in fallback 2018-02-15 15:34:32 -08:00
Bart Butler
79d2e9d6bf fix skipped asmCrypto test 2018-02-15 15:33:46 -08:00
Bart Butler
7286116f1c add deflate_level to config 2018-02-15 09:44:31 -08:00
Bart Butler
7e1731f2bb remove excess compression testing, fix cleartext signing with multiple keys test 2018-02-14 15:19:52 -08:00
Bart Butler
c8adaff826 change JS zlib to pako, use Node zlib if available 2018-02-14 14:21:53 -08:00
Bart Butler
fa2672fcc1
Merge pull request #642 from mmso/feat/bzip2
Fix #607 - Add support for bzip2 de/compression
2018-02-14 11:00:56 -08:00
Sanjana Rajan
6393a236da
Merge pull request #644 from openpgpjs/cleartext_hash
Cleartext hashing fixes
2018-02-14 19:02:48 +01:00
Sanjana Rajan
b5d19b6f8d pull out common signature code 2018-02-14 19:00:13 +01:00
Sanjana Rajan
38a11d7aaf reuse createVerificationObjects for cleartext 2018-02-14 17:55:54 +01:00
Sanjana Rajan
2ffd81553d test multiple private key signing cleartext 2018-02-14 17:30:35 +01:00
mmso
e255f6d820
Update compressjs location 2018-02-14 17:14:18 +01:00
Sanjana Rajan
94b12e566b correctly handle cleartext headers with no hash specified 2018-02-14 17:07:39 +01:00
mmso
8808fdb8ed
Fix #607 - Add support for bzip2 de/compression 2018-02-14 14:14:07 +01:00
Bart Butler
8dd27722a3 unify hash libraries 2018-02-13 22:29:57 -08:00
Bart Butler
0271da0d09
Merge pull request #640 from BafS/master
Modernize syntax to ES6
2018-02-13 15:38:19 -08:00
BafS
9eb574b6c4 Hotfix - change var for const 2018-02-13 23:46:44 +01:00
BafS
6f39abb47b Merge branch 'master' of https://github.com/BafS/openpgpjs 2018-02-13 23:33:55 +01:00
BafS
a53f2b3780 Update packages, add lint script, remove useless eslint-plugins 2018-02-13 23:33:09 +01: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
6b65640ac7 Radix should be specified
Part of the best practices https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt and https://eslint.org/docs/rules/radix
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
BafS
5519f2ae30 Update packages, add lint script, remove useless eslint-plugins 2018-02-13 23:30:39 +01:00
BafS
fa177141eb 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 22:38:10 +01:00
Bart Butler
790799f2e7
Merge pull request #639 from openpgpjs/alg_info
Add getAlgorithmInfo function for public key
2018-02-13 12:35:40 -08:00
BafS
08949b0326 Radix should be specified
Part of the best practices https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt and https://eslint.org/docs/rules/radix
2018-02-13 21:26:02 +01:00
BafS
8505924f34 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 21:26:02 +01:00
Sanjana Rajan
de51d418d2 algorithm info for public key, include curve for ecc and bits for non-ecc 2018-02-13 21:23:13 +01:00
Bart Butler
a09066e5ca
Merge pull request #637 from mmso/feat/compression
Feat/compression
2018-02-13 11:01:46 -08:00
Bart Butler
8873ed0ff1
Update openpgp.js
doc fix
2018-02-13 11:01:09 -08:00
Bart Butler
c855fd4e4e
Update message.js
doc fix
2018-02-13 10:58:55 -08:00
mmso
2a504e4e1a
Disable spy call expecations on the web worker 2018-02-13 17:21:20 +01:00
mmso
7a2c3578bf
Update README 2018-02-13 15:25:20 +01:00
mmso
9f7466ef45
Add compression support for the encrypt function 2018-02-13 15:08:41 +01:00
Bart Butler
90337debfb
Merge pull request #635 from openpgpjs/multiple_keys_dec
Allow decryption with multiple keys/passwords
2018-02-12 10:34:39 -08:00
Sanjana Rajan
62015c2c8d useWildcard -> wildcard 2018-02-12 19:31:47 +01:00
Mahrud Sayrafi
f113078f65
Fixes detached signing/verification example in README.md; Closes #622 2018-02-12 10:27:47 -08:00
Sanjana Rajan
989ad5077e cleanup, docs 2018-02-12 13:40:23 +01:00
Sanjana Rajan
417af8c6bc tests 2018-02-12 09:47:51 +01:00
Sanjana Rajan
7365ffc9b7 wildcard implementation 2018-02-12 09:47:51 +01:00
Sanjana Rajan
d5022a3a4a rename vars in old tests 2018-02-12 09:47:51 +01:00
Sanjana Rajan
e5e49901a7 change var names 2018-02-12 09:47:51 +01:00
Bart Butler
6578a57968
Merge pull request #634 from openpgpjs/reformat_subkey_bug
Allow keys with no subkeys to be reformatted
2018-02-09 11:52:25 -08:00
Sanjana Rajan
85f115f889 tests 2018-02-09 16:18:46 +01:00
Sanjana Rajan
18e46ed6cf gracefully handle reformatting keys with no subkey packets 2018-02-09 16:18:27 +01:00
Bart Butler
0a4e9461ca
Merge pull request #632 from openpgpjs/ripemd_license_issue
use different, MIT-licensed RIPEMD library, closing #625
2018-02-08 21:10:04 -08:00
Bart Butler
bf8b4e940c fix browsers 2018-02-08 16:33:53 -08:00
Bart Butler
7bd78585fd
Merge pull request #629 from dkg/http-to-https
move from http to https where possible.
2018-02-08 13:36:14 -08:00
Bart Butler
0378bf8617 ripemd160 should not be a dev dependency 2018-02-08 13:31:34 -08:00
Bart Butler
fa208e8308
Merge pull request #630 from dkg/speling
Fix typos
2018-02-08 11:51:12 -08:00
Bart Butler
7975c86508 use different, MIT-licensed RIPEMD library, closing #625 2018-02-08 11:49:10 -08:00
Mahrud Sayrafi
d851398b0c
Merge branch 'master' into http-to-https 2018-02-08 10:56:46 -08:00
Bart Butler
c2a7ea2a20
Merge pull request #593 from laurinenas/inform-user-invalid-numBits-size
Add a console error when numBits param too low
2018-02-08 10:51:21 -08:00
Mahrud Sayrafi
0ebe0972e7
Merge branch 'master' into speling 2018-02-08 10:46:42 -08:00
Bart Butler
819f136d06 remove minified files from bower.json 2018-02-08 10:37:28 -08:00
Bart Butler
aa476b4905
Merge pull request #537 from nauadratti/patch-1
Allow punycode encoded TLDs in email
2018-02-07 23:26:18 -08:00
Bart Butler
0f4d81bf2c add test for signing with multiple keys, align signature packet order with high-level API private key order 2018-02-07 18:16:54 -08:00
Sanjana Rajan
a57d94072c
Merge pull request #628 from openpgpjs/ecc_nist
Support for curves P256, P384, P521, SECP256K1, Ed25519/Curve25519
2018-02-07 14:27:07 +01:00
Mahrud Sayrafi
1383107202
Fixed and unmuted a few eslint errors, ~10 remain 2018-02-07 04:23:16 -08:00
Mahrud Sayrafi
b2e39ccaf9
Documentation and cleanups 2018-02-07 03:25:28 -08:00
Bart Butler
602bbb707d rename decryptSessionKey to decryptSessionKeys, return only unique session keys 2018-02-06 21:25:49 -08:00
Bart Butler
210ec26ed3 fix sporadic two password decryption failure 2018-02-06 16:43:51 -08:00
Bart Butler
bdf1ce8d64 add some more polyfills for old browsers 2018-02-06 10:56:29 -08:00
Bart Butler
89f86d83d5 fix obsolete browser tests, add some polyfills 2018-02-05 22:17:41 -08:00
Bart Butler
1d82046bb8 revert to Chrome 38 2018-02-05 16:05:39 -08:00
Bart Butler
d6cc82027e add extendedDebugging correctly 2018-02-05 15:46:18 -08:00
Bart Butler
0b198b5b08 add extendedDebugging to saucelabs tests 2018-02-05 15:03:01 -08:00
Bart Butler
ac440b9ae6 use ES6 polyfill for worker and tests, not in openpgp.js 2018-02-05 14:21:35 -08:00
Mahrud Sayrafi
37eec2bde2
Added Ed25519 Test Vectors from RFC8032 2018-02-04 02:44:05 -08:00
Mahrud Sayrafi
115d1c0949
A better patch for EdDSA truncation issue.
The last test in test/general/x25519.js is commented, as it seems to defy logic.
Yet it can be successfully imported by GPG2. TODO: How?
2018-02-03 14:36:20 -08:00
Mahrud Sayrafi
3370eaa2aa
Expands truncated little-endian parameters in EdDSA 2018-02-02 05:42:54 -08:00
Mahrud Sayrafi
9cbfbf453b
Added contingency for when browser does not support NIST curves 2018-02-01 14:31:17 -08:00
Bart Butler
9e6005ee39 auto-scroll browser unit tests 2018-02-01 10:34:48 -08:00
Daniel Kahn Gillmor
1799107aac Fix typos
This patch contains several trivial/inconsequential orthographic
fixes.
2018-02-01 10:03:41 -05:00
Daniel Kahn Gillmor
4da28fcc29 move from http to https where possible.
There are dozens of links in the OpenPGP.js codebase that are http but
could be replaced with https links.  I've converted as many of them as
i could find.
2018-02-01 09:58:06 -05:00
Sanjana Rajan
41f1e697b5 remove isValid 2018-02-01 13:41:19 +01:00
Sanjana Rajan
5a6e65c00f verification when decoding pkcs5 2018-02-01 13:14:26 +01:00
Bart Butler
40a8c54342 exclude jwk-to-pem 2018-01-31 19:38:07 -08:00
Bart Butler
76d7fac967 eliminate openpgp_browser.js 2018-01-31 19:27:00 -08:00
Bart Butler
496a45a97c
Update eddsa.js 2018-01-31 19:04:26 -08:00
Mahrud Sayrafi
a4134b9f55
Addresses various review comments by @bartbutler + some cleanups 2018-01-31 17:52:38 -08:00
Mahrud Sayrafi
d97bc064ea
Cleanups and doc fixes 2018-01-31 12:24:21 -08:00
Mahrud Sayrafi
aba8a7a647 Switches to asmcrypto-lite for AES 2018-01-30 18:36:38 +01:00
Mahrud Sayrafi
be2c605e5b Improves secret key encryption/decryption performance by 35% 2018-01-30 18:36:38 +01:00
Mahrud Sayrafi
bf00fbd3ea added ECC curve options to docs 2018-01-30 18:36:38 +01:00
Mahrud Sayrafi
2d1a1130d7 Fixes bug in isRevoked, removes isValidSelfCertificate, adds verifyCertificate 2018-01-30 18:36:38 +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 b9d175d99853f0f50cb0d45d5dac29fc421d12f1)
(cherry picked from commit 50940b2a1e1d087aa6ac07784ae9751ed28c22b8)
2018-01-30 18:36:37 +01:00
Sanjana Rajan
fa5805eaf7 don't assume all mpi type for encsessionkey 2018-01-30 18:36:26 +01:00
Sanjana Rajan
a173a63b16 doc fixes 2018-01-30 18:36:26 +01:00
Sanjana Rajan
3ce6309788 cleanup 2018-01-30 18:36:26 +01:00
Mahrud Sayrafi
5cb89f4f25 Addresses various review comments by @sanjanarajan
* Various FIXME tags are removed
 * In curve.js:
  - webCrypto/nodeCrypto fallback bug is fixed
  - Curve25519 has keyType ecdsa (won't be used for signing, but technically can be)
  - webGenKeyPair is simplifed
 * In base64.js:
  - documentation added and arguments simplified
 * In ecdsa.js and eddsa.js:
  - hash_algo is now at least as strong as the default curve hash
  - simplified the code by moving webSign/nodeSign and webVerify/nodeVerify to live in key.js (ht @ismaelbej)
 * In message.js:
  - in decryptSessionKey, loops break once a key packet is decrypted
 * In key.js:
  - getPreferredHashAlgorithm returns the best hash algorithm
  - enums are used for curve selection
2018-01-30 18:36:26 +01:00
Mahrud Sayrafi
3129e7c4e3 Adds X25519 tests and updates README.md 2018-01-30 18:35:29 +01:00
Mahrud Sayrafi
3e1d9c4d0d Fixes ECDH with Curve25519 and key import/export problems 2018-01-30 18:35:06 +01:00
Mahrud Sayrafi
35f18444b0 keygen and sign/verify with ed25519 works 2018-01-30 18:34:54 +01:00
Mahrud Sayrafi
e6820d7b2a Passing all tests, on Node, Firefox, and Chrome 2018-01-30 18:34:28 +01:00
Mahrud Sayrafi
dcff16d32b npm test and grunt browsertest can run side by side now; npm tests pass, browser stuck on problem related to asn1.js 2018-01-30 18:34:07 +01:00
Mahrud Sayrafi
21ae66c604 encrypt/decrypt/sign/verify will always return promises
Note: publicKeyEncryptedSessionKey uses promises, symEncryptedSessionKey does not
2018-01-30 18:33:55 +01:00
Mahrud Sayrafi
1a714cec73 ECC with async/await is 'Done, without errors.' 2018-01-30 18:33:55 +01:00
Mahrud Sayrafi
12eb037ba7 Everything in test/crypto/elliptic.js passes; working on test/general/ecc.js 2018-01-30 18:31:39 +01:00
Mahrud Sayrafi
11a2d0070b ESLint is happy! 2018-01-30 18:31:30 +01:00
Mahrud Sayrafi
370a15e2a1 Remove jshint/jscs and fix babelify
(cherry picked from commit e4b810fe412bd5e383507668ef2d60320c31b1ca)
2018-01-30 18:31:18 +01:00
Mahrud Sayrafi
6886cd648a elliptic/curves.js uses native code for genkey and sign/verify; sign/verify use async/await 2018-01-30 18:31:07 +01:00
Sanjana Rajan
c443988ec4 restore package.json 2018-01-30 18:30:31 +01:00
Sanjana Rajan
8794446a66 change some variable names, add some curve parameters 2018-01-30 18:30:17 +01:00
Sanjana Rajan
311d288bb7 clone processing 2018-01-30 18:30:16 +01:00
Sanjana Rajan
86e15dbd0a aes kw update 2018-01-30 18:30:16 +01:00
Sanjana Rajan
f8bfde7447 comments, docs 2018-01-30 18:30:16 +01:00
Sanjana Rajan
cbe61e6feb key expansion for aes decryption keys, aesdecrypt function 2018-01-30 18:30:16 +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
b40408d42f standardize packet reading code, make pkcs5 function names same as pkcs1 2018-01-30 18:30:16 +01:00
Sanjana Rajan
b718cf359d simplify packet parsing using type maps 2018-01-30 18:30:16 +01:00
Sanjana Rajan
cdc7004b96 refactor mpi, generalize mpi to params to account for non-mpi algorithm-specific data 2018-01-30 18:30:15 +01:00
Sanjana Rajan
840c0229f8 move hex2Uint8array to utils 2018-01-30 18:30:15 +01:00
Sanjana Rajan
fade832619 remove material parameter for now 2018-01-30 18:30:15 +01:00
Sanjana Rajan
0de9eecdc8 distinguish between key and subkey type, when refactoring key just grab type from packets 2018-01-30 18:30:15 +01:00
Sanjana Rajan
3b8cea67a2 some style fixes, update tests 2018-01-30 18:30:15 +01:00
Sanjana Rajan
fdcfcf3a54 refactor formatUserIds 2018-01-30 18:30:15 +01:00
Ismael Bejarano
ea1b0a1088 Readme for modifications to support RFC 6637 - Elliptic Curve Cryptography (ECC) in OpenPGP 2018-01-30 18:30:15 +01:00
Ismael Bejarano
f87e759cb0 Create key from provided material 2018-01-30 18:30:14 +01:00
Ismael Bejarano
a5d9e6d09e Generation of keys for elliptic curves 2018-01-30 18:30:14 +01:00
Ismael Bejarano
075d7f8e0e Encrypt, decrypt, sign and verify with elliptic curve certificates 2018-01-30 18:30:14 +01:00
Ismael Bejarano
38a53c1bb1 Parse and create ECDH packets 2018-01-30 18:30:14 +01:00
Ismael Bejarano
585a2bd69d Functions to encrypt and decrypt ECDH keys 2018-01-30 18:30:14 +01:00
Ismael Bejarano
673151ec87 Read and write ECDSA packets 2018-01-30 18:30:14 +01:00
Ismael Bejarano
ba2f49234e Signature creation and verification 2018-01-30 18:30:14 +01:00
Ismael Bejarano
a8e8271185 Support functions for Elliptic Curve Cryptography 2018-01-30 18:30:13 +01:00
Ismael Bejarano
54b79be0b0 Add and remove PKCS5 padding 2018-01-30 18:30:13 +01:00
Ismael Bejarano
2f69d22130 Key Wrap and Unwrap from RFC 3394 2018-01-30 18:30:13 +01:00
Ismael Bejarano
26c6ab9b97 Parameters for the ECDH key derivation function 2018-01-30 18:30:13 +01:00
Ismael Bejarano
d8b1e3359a Result of wrapping a session key for ECDH key 2018-01-30 18:30:13 +01:00
Ismael Bejarano
01be192a35 Object identifier type 2018-01-30 18:30:13 +01:00
Bart Butler
b22f84f9b9 Release new version 2018-01-21 23:13:22 -08:00
Bart Butler
2e4861e0e0
Merge pull request #621 from openpgpjs/allowExpired
Add flag to enable/disable allowing message signature verification with expired keys
2018-01-19 01:15:38 +01:00
Sanjana Rajan
b9d175d998 tests 2018-01-17 19:36:51 +01:00
Sanjana Rajan
50940b2a1e flag to allow verification with expired keys 2018-01-17 18:37:25 +01:00
Bart Butler
3d2c0d784e add null string test 2017-12-22 22:17:36 -08:00
Bart Butler
18c08c2f0b Release new version 2017-12-22 13:53:20 -08:00
Bart Butler
1682787152 deal with empty encrypted data correctly 2017-12-22 13:26:53 -08:00
Bart Butler
70fff1e268 Merge branch 'master' of github.com:openpgpjs/openpgpjs 2017-12-05 11:44:50 -08:00
Bart Butler
81a59b76b1 do not echo data back to caller for detached signing 2017-12-05 11:44:01 -08:00
Giovanni Pellerano
cb12ca8a2e Add revised selection of browser tests 2017-12-04 01:07:15 +01:00
Bart Butler
2ffa221b21 Release new version 2017-12-02 22:03:17 -08:00
Bart Butler
e91129aeeb
Merge pull request #611 from openpgpjs/encrypt_session_key
Option to pass in custom session key in top-level encrypt function
2017-12-02 13:27:59 -08:00
Sanjana Rajan
135bd3d46a doc update 2017-12-02 11:48:14 -08:00
Sanjana Rajan
0e254a8c8c simplify 2017-12-02 11:17:39 -08:00
Sanjana Rajan
6189cd4568 returnSessionKey flag in encrypt function 2017-12-02 11:04:29 -08:00
Giovanni Pellerano
5caea56763 Put all browsertesting in .travis.yml allow failures 2017-12-02 10:21:06 +01:00
Sanjana Rajan
f0d65780ad wording 2017-12-01 21:30:19 -08:00
Sanjana Rajan
7e03410bc9 allow sessionKey param in top level encrypt 2017-12-01 21:25:43 -08:00
Giovanni Pellerano
31d381fb27 Update npm dependencies and shrinkwrap 2017-12-01 21:20:17 +01:00
Giovanni Pellerano
46082b391b Update versions of browser used during test execution 2017-12-01 21:20:12 +01:00
Bart Butler
e7e18777b0 Release new version 2017-11-28 14:06:25 -08:00
Bart Butler
6c707057d5 webCrypto in webkit needs 2048 bits minimum for keygen 2017-11-28 11:26:52 -08:00
Bart Butler
59d99fc0c7 do not replace stack in async_proxy, add as workerStack 2017-11-28 10:25:16 -08:00
Bart Butler
318d86e5e9 do not use arrow syntax for tests (old node/browser versions) 2017-11-28 10:18:26 -08:00
Bart Butler
80c6d3d390
Merge pull request #610 from openpgpjs/fix_tests
Unit test fixes
2017-11-27 22:45:05 -08:00
Sanjana Rajan
a724649f30 fix assert is not defined issue 2017-11-27 22:17:13 -08:00
Sanjana Rajan
e2c15fe558 don't use done inside promises 2017-11-27 22:17:13 -08:00
Bart Butler
7a9c3b0ddd remove stack trace concatenation (non-standard), modify error message only 2017-11-27 19:06:25 -08:00
Bart Butler
617c1c9ee9 include error message in stack trace for Safari/Firefox 2017-11-27 16:50:18 -08:00
Bart Butler
49695ff50c Error object cannot be used with structured clone, pass stack 2017-11-27 15:44:04 -08:00
Bart Butler
2a9a1b4846
Merge pull request #606 from FlowCrypt/issue_602_reformatkey_error
reformatKey: Key not decrypted error + test | #602
2017-11-27 13:22:17 -08:00
Bart Butler
f666e400fa
Merge pull request #605 from FlowCrypt/issue_598_armor_headers
improve armor header validation + tests | #598
2017-11-27 13:21:42 -08:00
Bart Butler
8aeb08054f
Merge pull request #604 from justinmchase/fix/590-preserve-error-stack
Fix/590 preserve error stack
2017-11-27 13:19:27 -08:00
Justin Chase
589fbb19d6 Added a test to verify error message 2017-11-25 12:24:53 -06:00
Justin Chase
a5a913419b Also concat stacks 2017-11-25 10:45:58 -06:00
Tom James Holub
d0d0874268 reformatKey: Key not decrypted error | #602 2017-11-25 12:24:44 +08:00
Tom James Holub
4495df0f42 improve armor header validation + tests | #598 2017-11-25 10:57:41 +08:00
Justin Chase
15e39a51b0 Minor whitespace changes 2017-11-24 19:56:15 -06:00
Justin Chase
f4cf6d7382 Remove lambda in test 2017-11-24 17:54:44 -06:00
Justin Chase
567d212204 Dont join stacks 2017-11-24 16:16:42 -06:00
Justin Chase
bf6c2b9319 Added a test verifying innerError 2017-11-24 16:12:37 -06:00
Bart Butler
bee9928e54 Release new version 2017-11-06 13:46:54 -08:00
Bart Butler
58031cfaca add openpgp.key.read() function for unarmored serialized keys 2017-11-06 13:42:07 -08:00
Andrius Laurinėnas
1d287cd9a9 Add a console error when numBits param too low 2017-10-13 19:50:48 +03:00
Bart Butler
63b387d5b9 Release new version 2017-10-10 10:49:23 -07:00
Bart Butler
c3afff5888 Merge pull request #591 from openpgpjs/clone_fix
account for non-cleartext sign/verify message parameters
2017-10-10 10:42:49 -07:00
Sanjana Rajan
9893d602e2 account for non-cleartext sign/verify message parameters 2017-10-09 17:27:02 -07:00
Bart Butler
417470d36a Release new version 2017-09-20 10:25:54 -07:00
Bart Butler
75e5ce5fc0 Merge pull request #586 from openpgpjs/webkit_subtle_fix
Use hash param in RSA key generation with webkit subtle
2017-09-20 10:20:27 -07:00
Sanjana Rajan
b756d35b8f use hash param in rsa key gen with webkit subtle 2017-09-20 18:28:37 +02:00
Bart Butler
0fadd8e188 Merge pull request #582 from kellym/fix/key-expiration
Replace expired subkeys with three other subkeys,
2017-09-15 11:04:53 -07:00
Kelly Martin
c413d09069 Replace expired subkeys with three other subkeys,
One is an expired key for encryption, one is a non-expiring key for
only signatures, and one is a non-expiring key for encryption.
2017-09-15 11:35:37 -05:00
Bart Butler
82ea7a025c Release new version 2017-08-30 13:09:51 -07:00
Bart Butler
42d531f9b5 Merge pull request #576 from mailvelope/subkey_expiration_time
Set keyExpirationTime for subkey binding signature
2017-08-30 12:50:46 -07:00
Thomas Oberndörfer
e3eb298ab7 Set keyExpirationTime for subkey binding signature 2017-08-30 16:09:53 +02:00
Bart Butler
5ee8d7505d Release new version 2017-08-20 16:44:35 -07:00
Bart Butler
199cad031f Merge pull request #574 from pbrunschwig/master
Fix for issue 573: Don't throw with unknown Armor Headers
2017-08-20 16:38:29 -07:00
Patrick Brunschwig
99bb7e7eb2 Merge branch 'master' of https://github.com/pbrunschwig/openpgpjs 2017-08-19 22:09:44 +02:00
Patrick Brunschwig
79c8a83cea fixed broken Testcase for improperly formatted Armor Header 2017-08-19 22:07:36 +02:00
Bart Butler
ad029f1929 Update armor.js
Only console.log if debug mode on
2017-08-19 10:52:36 -07:00
Bart Butler
1e8bd4315b Update armor.js
Small tweak
2017-08-19 10:49:36 -07:00
Patrick Brunschwig
93d823abb4 Fix for issue 573: don't throw with unknown Armor Headers, but just
with invalid ones
2017-08-19 18:32:02 +02:00
Bart Butler
dc2d38d355 Merge pull request #566 from FlowCrypt/master
util.readNumber: stop overflowing until full range of uint32 for 4 byte numbers | #497
2017-07-22 09:58:00 -07:00
Bart Butler
265fa62601 Correct misspelling 2017-07-22 09:38:44 -07:00
Tom James Holub
bcf4a114a7 util.readNumber: overflow test added | #497 2017-07-22 09:27:36 -07:00
Tom James Holub
ce9dee9370 util.readNumber: stop overflowing until full range of uint32 | #497 2017-07-22 09:26:30 -07:00
Bart Butler
7b7c1b08fe Release new version 2017-07-21 22:06:51 -07:00
Bart Butler
93bbf0faca Merge pull request #565 from FlowCrypt/master
work with multiple binding signatures per subkey #527
2017-07-21 22:02:04 -07:00
Tom James Holub
812e8ffe31 test added: find a valid subkey binding signature among many invalid ones | #527 2017-07-21 21:39:48 -07:00
Tom James Holub
2bda12731b subKey.bindingSignature -> subKey.bindingSignatures[] - process all | #527 2017-07-21 21:38:33 -07:00
Bart Butler
28abf77a18 Release new version 2017-07-21 18:58:00 -07:00
Bart Butler
dd1ae4d325 Merge pull request #564 from FlowCrypt/master
process blocks that miss a checksum | #563
2017-07-21 18:52:20 -07:00
Tom James Holub
3f40a36081 do not remove equal sign at the end of armored body when missing checksum 2017-07-21 17:39:19 -07:00
Tom James Holub
ac055d69d2 fixed outdated annotations in armor.js 2017-07-21 15:39:06 -07:00
Tom James Holub
10896c2cbf added missing checksum test with traling armor newline 2017-07-21 15:37:25 -07:00
Tom James Holub
841b03d6cd improved armor behavior - trailing newline 2017-07-21 15:35:27 -07:00
Tom James Holub
80742bdfbe tests extended - armor checksum validation | #563 2017-07-21 10:15:49 -07:00
Tom James Holub
c27725782c do not fail when missing armor checksum | #563 2017-07-21 10:13:33 -07:00
Bart Butler
b3077235f9 Release new version 2017-07-13 10:13:17 -07:00
Bart Butler
046fae963f Merge pull request #562 from openpgpjs/sign_byte_arrays
Remove console logs from tests
2017-07-13 10:07:45 -07:00
Sanjana Rajan
a896003fda remove console logs 2017-07-13 12:07:12 +02:00
Bart Butler
d737f65ccc Merge pull request #559 from openpgpjs/sign_byte_arrays
Sign Uint8 arrays
2017-07-12 19:45:53 -07:00
Sanjana Rajan
e53cbe8417 remove extra spaces 2017-07-08 13:26:20 +02:00
Sanjana Rajan
95c5e3af01 use message obj when signing uint8 array 2017-07-08 13:25:24 +02:00
Bart Butler
cc909f098c Release new version 2017-07-06 16:27:44 -07:00
Bart Butler
d33c46a33c minor bugfix 2017-07-06 15:27:45 -07:00
Sanjana Rajan
d061af1fc3 style fixes 2017-07-06 16:29:25 +02:00
Sanjana Rajan
cc831cde4a more tests 2017-07-04 21:08:48 -07:00
Sanjana Rajan
697eab19cd add tests 2017-07-04 17:03:56 -07:00
Sanjana Rajan
a9bb3f1839 armor based on text vs. bytes 2017-07-04 16:47:23 -07:00
Sanjana Rajan
28e5f5d3f4 allow cleartext msg data to be string or byte array 2017-07-04 14:15:39 -07:00
Bart Butler
402e26d98c Merge pull request #557 from openpgpjs/decode_single_line
allow body + checksum on same line in splitChecksum
2017-06-27 23:47:03 -07:00
Sanjana Rajan
a7702a74d3 support split checksum where body and checksum are on the same line 2017-06-27 16:41:53 -07:00
Bart Butler
ddf6eb5783 change URL to https 2017-04-25 14:09:31 +02:00
Bart Butler
dc04af4a63 Merge pull request #543 from frankcash/patch-1
Update README.md
2017-04-13 23:41:33 -07:00
Frank Cash
3588ef8f18 Update README.md 2017-04-12 21:05:13 -04:00
Bart Butler
151e07e16c Merge pull request #542 from darkyen/patch-1
Fix documentation
2017-04-08 14:49:25 -07:00
Abhishek Hingnikar
472294ec84 Fix documentation
The storeHandler seems to need loadPublic, loadPrivate, storePublic, storePrivate methods but the current documentation only mentions load and store.
2017-04-08 16:12:47 +05:30
Bart Butler
a5728c1280 Merge pull request #541 from BAKFR/simplify-crc24
Simplify code of CRC24 checksum in armor encoding
2017-04-06 11:19:45 -07:00
Kévin Bernard-Allies
342bc8fe01 Simplify code of CRC24 checksum in armor encoding 2017-04-06 13:12:45 +02:00
Bart Butler
e00cdd138e Release new version 2017-04-05 22:40:17 -07:00
Bart Butler
5db776c254 Merge pull request #540 from openpgpjs/err_handling
Tolerant flag for suppressing packet read errors
2017-04-05 16:38:20 -07:00
Sanjana Rajan
c3958b0270 tolerant default to true 2017-04-05 16:36:29 -07:00
Sanjana Rajan
b51b8ad341 add tolerant mode which suppresses errors in reading non-data packets 2017-04-05 07:54:08 -07:00
nauadratti
f56d557036 Add a test for punycode encoded domains 2017-03-30 19:29:50 +00:00
nauadratti
3673e21a77 Allow punycode encoded TLDs in email
Closes #500
2017-03-30 19:05:22 +00:00
Bart Butler
a8c29d4a03 Release new version 2017-03-29 16:32:10 -07:00
Bart Butler
5fb23ac833 use web worker for reformatKey 2017-03-29 16:27:16 -07:00
Bart Butler
4044501d6d Release new version 2017-03-28 13:17:39 -07:00
Bart Butler
e4cb79640b Merge pull request #536 from openpgpjs/document_key_decryption
Include key decryption step in README
2017-03-28 13:09:15 -07:00
Sanjana Rajan
3c1a82759d include key decryption step in README 2017-03-28 13:04:36 -07:00
Bart Butler
a1ff93f1fc not all platforms implement TypedArray.slice 2017-03-28 11:44:04 -07:00
Bart Butler
62c24ed227 Merge pull request #534 from openpgpjs/signature_input
Accept signature object as an input to encrypt function
2017-03-28 10:43:00 -07:00
Bart Butler
69da0974ca Merge pull request #522 from danenania/patch-1
Readme - add warning about config.aead_protect potentially breaking compatibility
2017-03-28 10:40:06 -07:00
Bart Butler
a4190061d9 optimize Uint8Array2str function for large payloads 2017-03-28 10:35:20 -07:00
Sanjana Rajan
16c6d2f162 signatureInput -> signature 2017-03-23 13:01:12 -07:00
Sanjana Rajan
484d5aa1ab improve test 2017-03-23 12:04:32 -07:00
Sanjana Rajan
d04c09687d spacing 2017-03-23 11:16:16 -07:00
Sanjana Rajan
0f967331c6 upper level tests 2017-03-22 17:14:57 -07:00
Sanjana Rajan
25d16046c2 add one pass in case where no priv keys are passed in for signing 2017-03-22 17:14:30 -07:00
Sanjana Rajan
79160abcc9 allow signature as input in high level encrypt 2017-03-22 17:04:21 -07:00
Bart Butler
83d40d29ed Merge pull request #533 from openpgpjs/detached_sig_docs
Documentation updates
2017-03-17 16:59:26 -07:00
Sanjana Rajan
af211f63c0 update README to demonstrate detached signature use, some documentation fixes 2017-03-17 16:54:34 -07:00
Bart Butler
fd38c8a4de Release new version 2017-03-15 19:56:22 -07:00
Bart Butler
a4c75772e9 Merge pull request #529 from openpgpjs/init_publicKeys
Initialize public key array during decryption
2017-03-15 19:51:10 -07:00
Sanjana Rajan
e4621fc688 initialize publicKeys to empty array, test case where signed message is decrypted without public keys to verify 2017-03-15 17:44:43 -07:00
Bart Butler
3522bcf2fe remove useless test 2017-03-14 19:13:17 -07:00
Bart Butler
875e475221 small test bugfix 2017-03-14 18:49:05 -07:00
Bart Butler
3ba381694a Release new version 2017-03-14 18:34:15 -07:00
Bart Butler
e925331a99 Merge pull request #528 from openpgpjs/detached
Detached Signatures
2017-03-14 18:15:24 -07:00
Sanjana Rajan
4ec07672a7 return signature object inside verification object 2017-03-10 10:38:59 -08:00
Sanjana Rajan
da9e3c6264 small fixes 2017-03-07 19:10:33 -08:00
Sanjana Rajan
465d4643a8 add clone to packetlist support for signature objects 2017-03-07 16:51:08 -08:00
Sanjana Rajan
7d02154dc9 small fixes 2017-03-07 13:59:18 -08:00
Sanjana Rajan
7bf697769d added detached sig tests for high level openpgpjs functions 2017-03-07 13:59:18 -08:00
Sanjana Rajan
43355e079f add detached sig option to upper level functions 2017-03-07 13:59:18 -08:00
Sanjana Rajan
c3908cbec0 add detached sign/verify options to cleartext 2017-03-07 13:59:18 -08:00
Sanjana Rajan
4fd4c13ddd refactor cleartext message to use signature object instead of packetlist 2017-03-07 13:59:17 -08:00
Sanjana Rajan
4ed7f25836 more tests 2017-03-07 13:59:17 -08:00
Sanjana Rajan
7b58cd9200 add tests 2017-03-07 13:59:17 -08:00
Sanjana Rajan
57d07091e8 add support for detached signatures 2017-03-07 13:59:17 -08:00
Bart Butler
7e96225820 Release new version 2017-03-05 12:30:15 -08:00
Bart Butler
ebc37f3a7d Merge pull request #417 from zartdinov/master
Added ability to sign and verify public keys
2017-03-05 12:24:37 -08:00
Aydar Zartdinov
be776c61b1 Validate signatures by all suitable keys 2017-03-04 19:27:27 +00:00
Aydar Zartdinov
d5e88c7c79 Prevent self signing by fingerprint instead of keyId 2017-03-04 18:47:33 +00:00
Bart Butler
c6372cc57b Release new version 2017-02-27 11:09:41 -08:00
Bart Butler
ea90304649 fix key test 2017-02-27 11:06:36 -08:00
Bart Butler
b0c1a854fd move SHA1 to the bottom of the preferred hash algorithm list 2017-02-27 10:30:39 -08:00
Dane Schneider
7dc7308604 Warning about config.aead_protect potentially breaking compatibility 2017-02-18 15:00:50 -05:00
Bart Butler
3d03b3403d Merge pull request #520 from openpgpjs/fix_519
Fixes the typo addressed in #519
2017-02-15 13:21:43 -08:00
Sanjana Rajan
e90161c2d1 add missing parentheses 2017-02-15 13:06:18 -08:00
Aydar Zartdinov
d9cb8e681d Array.prototype.find replaced for Node.js 0.12 and IE 11 2017-02-15 21:31:05 +03:00
Aydar Zartdinov
3fa4c0c760 Base functionality moved to User.prototype 2017-02-15 21:08:17 +03:00
Aydar Zartdinov
715f98bb38 Reverted top level api changes 2017-02-15 21:04:50 +03:00
Aydar Zartdinov
5140a946e5 Added ability to sign and verify public keys 2017-02-15 21:04:50 +03:00
Bart Butler
3d32898250 tests cannot use ES6 features 2017-02-13 22:25:46 -08:00
Bart Butler
aecb8eaf35 Release new version 2017-02-13 16:17:07 -08:00
Bart Butler
6be9ddde59 Merge pull request #517 from openpgpjs/userID
Key reformatting and resigning
2017-02-13 16:11:17 -08:00
Bart Butler
54d45f73f0 Merge pull request #516 from alax/fix-v3-signatures
Generate valid version 3 signatures
2017-02-13 15:59:19 -08:00
Sanjana Rajan
37b26cf3ef add test with reformatted key signing and encryption 2017-01-31 15:07:51 -08:00
Sanjana Rajan
11e1040a30 remove extra input param 2017-01-31 14:18:13 -08:00
Sanjana Rajan
1c361cd4e1 add some reformatting key tests 2017-01-31 14:16:34 -08:00
Sanjana Rajan
a902c421eb add upper level refactorKey function 2017-01-31 14:14:27 -08:00
Sanjana Rajan
9de579a29d remove extra space, typo 2017-01-30 19:41:43 -08:00
Sanjana Rajan
9d59351007 reformatKey function 2017-01-30 19:38:49 -08:00
Alax Villmann
e526cf0a3b Generate valid version 3 signatures 2017-01-26 12:49:49 -08:00
Bart Butler
b6c59afac0 Release new version 2017-01-25 15:26:29 -08:00
Bart Butler
7d4044c0d1 Merge pull request #514 from Consensas/master
implement keyExpirationTime
2017-01-25 14:56:53 -08:00
David Janes
d6abdfe4ec replace with old versions 2017-01-25 07:30:55 -05:00
David Janes
c223b88829 implement keyExpirationTime 2017-01-24 16:54:52 -05:00
Bart Butler
bc69357ab5 Merge pull request #498 from larshp/master
S2K - Only generate what is needed
2017-01-22 23:36:36 -08:00
Bart Butler
281ec11901 Merge pull request #508 from wmhilton/doc-detached-sigs
Adds cleartext and detached signature examples
2017-01-09 12:28:01 -08:00
Bart Butler
0d950d0a8a Merge pull request #509 from alax/fix-v3-headers
V3 header generation was concat()-ing non-Uint8 arrays
2017-01-09 12:26:30 -08:00
Alax Villmann
0989015ed2 V3 header generation was concat()-ing non-Uint8 arrays 2017-01-09 10:30:31 -08:00
Will Hilton
f13c341713
Add detached binary signature example to README 2017-01-06 00:06:44 -05:00
Will Hilton
5fa35ea1c0
Add cleartext signing example to README 2017-01-05 23:50:07 -05:00
Bart Butler
5ffb532f9e Merge pull request #505 from openpgpjs/user_id_formatting
don't allow leading spaces when generating userid
2016-12-15 14:15:57 -08:00
Sanjana Rajan
d65d629264 trim name 2016-12-15 10:39:29 -08:00
Sanjana Rajan
d058523e9e clearer syntax 2016-12-15 10:01:50 -08:00
Sanjana Rajan
109f8a5d20 don't allow leading spaces in user id 2016-12-14 12:38:01 -08:00
Lars Hvam
c69a92d694 only generate what is needed 2016-11-20 09:54:00 -05:00
Bart Butler
a6b81b127b Merge pull request #494 from openpgpjs/invalidate_expired_primary_keys
Invalidate expired primary keys
2016-10-27 12:48:57 -07:00
Sanjana Rajan
344294659e invalidate expired primary keys 2016-10-27 11:50:30 -07:00
Bart Butler
d64665e5fe Release new version 2016-10-26 17:05:14 -07:00
Bart Butler
659c6f23d2 Merge pull request #493 from openpgpjs/armored_decrypted_key_fix
Reset secret key's encrypted field to null after decryption
2016-10-26 16:58:07 -07:00
Bart Butler
6abf7ffcc0 Fix rare race condition with webworker tasks, fix minified web worker filename default 2016-10-26 16:56:21 -07:00
Sanjana Rajan
8620220cfb reset encrypted field to null when decrypting secret key 2016-10-26 16:55:49 -07:00
Bart Butler
778f1b1be2 Release new version 2016-10-21 16:27:49 -07:00
Bart Butler
caf53935f6 Merge pull request #491 from iamolivinius/master
Add plugin to derequire browserifyed dist files.
2016-10-21 19:22:22 -04:00
Unknown
9086c6e4f0 Add plugin to derequire browserifyed dist files. 2016-10-18 21:20:13 +02:00
Bart Butler
64d9233095 Release new version 2016-08-17 12:29:41 -07:00
Bart Butler
68cdc0069d Merge pull request #483 from ProtonMail/one-pass-sig-last
Properly set one-pass signature packet flag
2016-08-17 12:18:14 -07:00
emersion
e9940eb100
Properly set one-pass signture packet flag 2016-08-17 13:03:56 +02:00
Tankred Hase
e84276eefa Merge pull request #476 from openpgpjs/issue/475
Issue/475
2016-06-26 23:13:32 +02:00
Giovanni Pellerano
79ad8f014c Update npm dependencies and shrinkwrap 2016-06-26 11:36:24 +02:00
Giovanni Pellerano
a79e2fd787 Update jscs configuration that do not accept in the configuration redundant variables set to the default 2016-06-26 11:36:24 +02:00
Giovanni Pellerano
445cbcc1c0 Update dependencies versions to latest stable versions 2016-06-26 11:36:24 +02:00
Giovanni Pellerano
f8c5c84469 Simplify test/unittests.html removing old stuff related to phantomjs 2016-06-26 11:35:43 +02:00
evilaliv3
ee22c023f1 Remove browsers beta versions from testing
it does not make any sense to test a browser versions that we do not know
2016-06-24 17:10:58 +02:00
Tankred Hase
3267bd534f Release new version 2016-06-08 11:58:28 +02:00
Tankred Hase
bb7fcf2107 Use latest/default npm publish tag 2016-06-08 11:52:18 +02:00
Tankred Hase
42e1171589 Add support for old-version releases 2016-06-08 11:51:01 +02:00
Tankred Hase
e3cbaba33a Be sure to only pop unsupported packet if already pushed 2016-06-08 11:30:53 +02:00
Tankred Hase
fb10fa075a Release new version 2016-06-07 18:25:49 +02:00
Tankred Hase
490d8e4e90 Bugfix: drop unsupported packets in packetlist.read()
add unit test for RSA key with ECC subkey
2016-06-07 18:21:31 +02:00
Tankred Hase
377b81a121 Merge pull request #462 from openpgpjs/worker-cleanup
Cleanup and document worker.js
2016-05-24 17:59:33 +02:00
Tankred Hase
87b4bfefd8 Fix error handling 2016-05-24 17:22:15 +02:00
Tankred Hase
4fd9fd3c7f Cleanup and document worker.js 2016-05-24 13:12:39 +02:00
Tankred Hase
ceee85ef35 Release new version 2016-05-03 19:52:58 +02:00
Thomas Oberndörfer
9c76df73ff Merge pull request #446 from openpgpjs/issue/443
Implement feature #443
2016-05-03 10:01:48 +02:00
evilaliv3
4e3937f1e2 Replace isDecrypted=false with keys[i].clearPrivateMPIs() 2016-04-28 17:40:14 +02:00
evilaliv3
0d93127186 Simplify code-flow of Key.encrypt 2016-04-28 16:01:33 +02:00
evilaliv3
a5fdc36062 Cleanup API for key.decrypt and align unit tests 2016-04-27 16:06:52 +02:00
evilaliv3
1007637f39 Mark isDecrypted flag when the key is encrypted 2016-04-25 18:35:57 +02:00
evilaliv3
61470ad068 Apply edits as suggested in review of pull #446 2016-04-25 18:35:50 +02:00
Tankred Hase
fd218ef52d Add comments to preferred algorithms 2016-04-25 13:08:00 +02:00
evilaliv3
afc2c95238 Implement feature #443 2016-04-25 00:54:16 +02:00
Tankred Hase
528b5f2fe6 Release new version 2016-04-24 00:40:56 +02:00
Tankred Hase
bedd8f6902 Fix commas in README 2016-04-22 20:35:02 +02:00
Tankred Hase
73ab545c3e Improve example with password encryption in README 2016-04-22 15:40:50 +02:00
Tankred Hase
a6dd8a9d2c Remove unused codeclimate badges from README 2016-04-20 21:42:13 +02:00
Tankred Hase
8589e8bd42 Release new version 2016-04-12 09:48:50 +02:00
Thomas Oberndörfer
acf66eb012 Merge pull request #437 from openpgpjs/keyid_fix
Fix Keyid.fromId()
2016-04-12 09:40:34 +02:00
Tankred Hase
e3b146b9d9 Fix Keyid.fromId() 2016-04-11 12:11:35 +02:00
Giovanni Pellerano
b80a172834 Merge pull request #434 from thofmann/patch-1
Fix typo in README
2016-03-29 00:38:30 +02:00
Trevin Hofmann
40433a14fc Fix typo in README
Replaces "minifed" with "minified".
2016-03-28 17:29:38 -05:00
Tankred Hase
0016859e41 Link GCM PR in README 2016-03-26 23:43:42 +08:00
Tankred Hase
acbaec2e6c Release new version 2016-03-25 16:52:10 +08:00
Tankred Hase
515dbd9f2e Merge pull request #433 from openpgpjs/integrity_protected_cleanup
Cleanup of AES-CFB code in integrity protected packet
2016-03-25 16:39:29 +08:00
Tankred Hase
4070e27959 Cleanup of AES-CFB code in integrity protected packet 2016-03-25 16:10:27 +08:00
Tankred Hase
10bf9ec41e Merge pull request #430 from openpgpjs/aes_gcm
Implement AES-GCM proposal (IETF draft)
2016-03-25 14:35:19 +08:00
Tankred Hase
031218313e Minor Update to README 2016-03-25 14:34:33 +08:00
Tankred Hase
cb89069002 Add unstable IE11 travis build to allow_failures[D 2016-03-25 11:04:02 +08:00
Tankred Hase
c42556920e Update README 2016-03-25 00:12:23 +08:00
Tankred Hase
843fba0d40 Use underscore instead of camelcase in config
zeroCopy —> zero_copy
useNative —> use_native
Remove unnecessary tests from build
2016-03-24 21:02:29 +08:00
Tankred Hase
72c8bf5ea7 Deactivate GCM by default 2016-03-24 20:47:42 +08:00
Tankred Hase
d95282977f Add GCM config usage in README 2016-03-24 15:09:53 +08:00
Tankred Hase
969e39dcf2 Rename useAEAD --> nativeAEAD 2016-03-24 13:49:26 +08:00
Tankred Hase
2dce233d10 Fix: activate native tests under node.js 2016-03-24 13:34:12 +08:00
Tankred Hase
da3fbf8965 Test CFB, GCM, worker, asm.js, native cases 2016-03-24 13:25:35 +08:00
Tankred Hase
f4fc274f14 Fix: use worker for CFB w/ webcrypto support 2016-03-24 13:24:18 +08:00
Tankred Hase
c8569e0cd5 Add version attribute to the AEAD packet 2016-03-24 10:53:35 +08:00
Tankred Hase
8b46a117ab Prefer aes128 over aes192 (no WebCrypto support) 2016-03-24 10:53:30 +08:00
Tankred Hase
979f212305 Cleanup Promise code 2016-03-24 09:29:41 +08:00
Tankred Hase
ddedb5cb42 Cleanup public api 2016-03-23 21:36:48 +08:00
Tankred Hase
1e3d6468d6 Wrap code into promises to globally catch errors 2016-03-23 21:19:02 +08:00
Tankred Hase
453a9cee07 Use web worker for encrypt/decrypt if no native gcm 2016-03-23 21:17:36 +08:00
Tankred Hase
26bf7b62c7 Prevent native crypto for worker tests. 2016-03-23 19:15:04 +08:00
Tankred Hase
760bdb8f00 Use only standard window.crypto.subtle in gcm.js
There is currently no support for AES-GCM in IE11 and Safari/iOSqq
2016-03-23 17:27:09 +08:00
Tankred Hase
9b2823aa67 Fix unit tests under node 2016-03-23 16:43:40 +08:00
Tankred Hase
963648c6ea Fix unit tests for browsers 2016-03-23 15:39:51 +08:00
Tankred Hase
e5e76d2eb7 Cleanup gcm.js 2016-03-23 14:32:48 +08:00
Tankred Hase
a225027a6b Wrap message.sign into a promise in openpgp.encrypt 2016-03-23 13:43:12 +08:00
Tankred Hase
7fabe02e03 Fix GCM under node.js 2016-03-23 13:43:06 +08:00
evilaliv3
ae969a9a10 Add .codeclimate.yml to limit the audit to the library sources 2016-03-22 20:23:33 +01:00
Tankred Hase
8f8218e9de Cleanup and test AEAD protected packet 2016-03-22 17:45:19 +08:00
Tankred Hase
8aa15b66a9 Cleanup and unit test gcm.js 2016-03-22 17:45:19 +08:00
Tankred Hase
49faca83c5 Upgrade to asmcrypto-lite@1.1.0 in npm-shrinkwrap.json 2016-03-22 17:45:19 +08:00
Tankred Hase
365a9d2107 Fix link to IEFT draft packet tag in enums.js 2016-03-22 17:45:18 +08:00
Tankred Hase
2e4d8547a0 Fix typo in src/crypto/index.js 2016-03-22 17:45:18 +08:00
Tankred Hase
149f5d5191 Use promise api in sym_encrypted_* packets 2016-03-22 17:45:18 +08:00
Tankred Hase
ded8926b27 Support AES-GCM with AEAD Protected Data Packets
Closes openpgpjs/openpgpjs#421
2016-03-22 17:44:22 +08:00
Tankred Hase
c9b20c96e0 Add unit test link to readme 2016-03-11 12:18:13 +08:00
Tankred Hase
35c5afe94c Remove mailing list from readme 2016-03-11 10:53:10 +08:00
Tankred Hase
b5618fd63d Remove redundant util.emailRegEx 2016-02-19 11:17:35 +07:00
Tankred Hase
aff1b682ac Add comment to keygen example in README 2016-02-19 10:39:10 +07:00
Tankred Hase
5f7ce38be7 Fix examples in README 2016-02-18 12:57:16 +07:00
Tankred Hase
5fc6167730 Release new version 2016-02-18 11:44:54 +07:00
Tankred Hase
a1ab02adc8 Revert "Point to TLS/HSTS secured .com domain"
This reverts commit 177d701f5bf426aa0f986e6794a2d58cdb5e5606.
2016-02-18 11:38:12 +07:00
Tankred Hase
3bbbe2538e Update npm dependencies and shrinkwrap 2016-02-18 11:36:58 +07:00
Tankred Hase
3aecb46f72 Add grunt connect:dev job 2016-02-18 11:31:02 +07:00
Tankred Hase
25425d6a87 Update to current es6-promise polyfill
This no longer causes trouble in PhantomJS 2.x
2016-02-18 11:18:25 +07:00
Tankred Hase
506e36c9cc Remove function bind polyfill from worker.js
This is no longer required in Phantom.js 2.x
2016-02-18 11:15:59 +07:00
Tankred Hase
58bd52559c Use node v4.x instead of v4.2 in travis (current LTS) 2016-02-17 19:33:24 +07:00
Tankred Hase
5a1af6e698 Release new version 2016-02-15 19:46:51 +07:00
Tankred Hase
177d701f5b Point to TLS/HSTS secured .com domain 2016-02-15 14:06:31 +07:00
Tankred Hase
8a0f6f9bfd Cleanup uglify banner 2016-02-15 14:03:41 +07:00
Tankred Hase
01061b8fe9 Update README.md 2016-02-15 09:10:56 +07:00
Tankred Hase
e562a33c91 Merge pull request #377 from hmarr/support-cr-eols
Handle carriage-return-only newlines
2016-02-14 23:03:21 +07:00
Harry Marr
68d1b5a35c Handle carriage-return only newlines
Newlines are normalised to \r\n, but that previously assumed that only
\r\n and \n newline characters could be used. Even though \r newlines
are rarely used in the wild, it's be helpful to support them. Currently,
they're just removed entirely.
2016-02-14 12:01:19 +00:00
Tankred Hase
d517017ec0 Fix typo in readme, link asmcrypto-lite github 2016-02-14 10:31:18 +07:00
Tankred Hase
1962760344 Release new version 2016-02-13 16:57:44 +07:00
Tankred Hase
e4b2b8208e Add jsdoc annotations to openpgp.js 2016-02-13 16:54:43 +07:00
Tankred Hase
68abf04bce Merge pull request #406 from openpgpjs/v2.x
v2.x merge to master
2016-02-13 15:16:16 +07:00
Tankred Hase
80f302924c Use ES5 syntax in the examples 2016-02-11 18:41:21 +07:00
Tankred Hase
24c213d8d9 Add better examples for binary data use. Fix message docs 2016-02-11 17:36:24 +07:00
Tankred Hase
6c954e19c0 Update README.md with v2.x api examples
Minor cleanup in public api, fix typos in docs
2016-02-11 13:41:53 +07:00
Tankred Hase
d399cb8c47 Fix public api doc whitespaces 2016-02-10 23:19:13 +07:00
Tankred Hase
c1a7a59bad Update npm dependencies and shrinkwrap 2016-02-10 15:58:58 +07:00
Tankred Hase
a8fd179843 Fix key and signature tests 2016-02-10 15:41:04 +07:00
Tankred Hase
000c3b3686 Revert "Decode utf8 text only for correct format in Literal.getText()"
This reverts commit 83fcbaa63396d30fcde81c828987776c7ddca70b.
2016-02-10 15:33:45 +07:00
Tankred Hase
707b3919e1 Move most test high lvl api test code to test/openpgp.js, cleanup 2016-02-10 15:07:05 +07:00
Tankred Hase
d5a2e0fb81 Delete plaintext sessionKey from packet after calling message.encryptSessionKey 2016-02-10 12:58:12 +07:00
Tankred Hase
25131e0df9 Added unit tests for util.getTransferables 2016-02-10 12:52:13 +07:00
Tankred Hase
6547b4ef68 Test encrypt/decryptSessionKey and finalize api, review docs 2016-02-10 12:52:13 +07:00
Tankred Hase
128a95ace4 rearrange test order and fix web worker detection 2016-02-10 06:38:35 +07:00
Tankred Hase
6ff470a36a Cleanup worker.js 2016-02-09 20:35:23 +07:00
Tankred Hase
9d37a83a79 Api tests work under node.js 2016-02-09 19:14:43 +07:00
Tankred Hase
7d97bcec58 Implement openpgp.decryptKey 2016-02-09 19:04:31 +07:00
Tankred Hase
4f6e036a07 Cleanup packet list clonong --> src/packet/clone.js 2016-02-09 19:01:30 +07:00
Tankred Hase
450a7321d1 Fix typo in util 2016-02-09 17:38:16 +07:00
Tankred Hase
860ffbe278 Fix redundant deactivation of transferable objects in test 2016-02-09 17:14:00 +07:00
Tankred Hase
ab68d4b997 Support transferable objects in web worker for zero copy support 2016-02-09 17:01:48 +07:00
Tankred Hase
89df70cbe0 Cleanup src/openpgp.js 2016-02-09 15:37:13 +07:00
Tankred Hase
4e07cd1662 Set version to 2.0.0-dev in package.json 2016-02-09 12:57:52 +07:00
Tankred Hase
206f1f9c0f Add 'armor' parameter to sign api 2016-02-09 12:57:23 +07:00
Tankred Hase
c0cc0ee991 Use 'armor' param in encrypt api instead of 'packets' to return full message object 2016-02-09 11:32:35 +07:00
Tankred Hase
994b8d2354 Use generic AsyncProxy.delegate for all public apis 2016-02-09 09:15:52 +07:00
Tankred Hase
f5375ef700 Drastically simplify async_proxy with generic delegate function 2016-02-09 08:46:18 +07:00
Tankred Hase
227a412ca0 Run tests both with and without web worker 2016-02-09 07:53:31 +07:00
Tankred Hase
ee07b77320 Fail gracefully when no web worker support on initWorker 2016-02-09 07:52:08 +07:00
Tankred Hase
9634440341 Remove redundant old tests from test/general/basic.js 2016-02-09 07:49:51 +07:00
Tankred Hase
b1f6266cc8 Write tests for new api: openpgp.encrypt/decrypt 2016-02-08 23:28:54 +07:00
Tankred Hase
a44e1e5024 Write tests for new api: openpgp.generateKey 2016-02-08 19:32:42 +07:00
Tankred Hase
c38d41036e Add sinon to devDeps for mocking 2016-02-08 15:02:02 +07:00
Tankred Hase
33d8d0fd11 Add grunt watch task 2016-02-08 14:23:50 +07:00
Tankred Hase
c7a6a88098 Add type validation util functions 2016-02-08 13:36:21 +07:00
Tankred Hase
1405ec8d1c Return filename for utf8 message 2016-02-08 10:18:37 +07:00
Tankred Hase
f72b4522ad Rename openpgp api: generateKeyPair --> generateKey 2016-02-07 18:01:10 +07:00
Tankred Hase
735ec3df74 Rename openpgp apis: signCleartext --> sign, verifyCleartext --> verify 2016-02-07 17:36:48 +07:00
Tankred Hase
f3ae671a57 Fix @fileoverview comment in hkp module 2016-02-07 08:15:33 +07:00
Tankred Hase
4aaa1d3184 Update copyright notice due to complete rewrite of src/openpgp.js 2016-02-07 08:08:47 +07:00
Tankred Hase
2ad425294c Second draft of public api 2016-02-06 22:58:43 +07:00
Tankred Hase
0f8bfe2dca Rename keys to publicKeys in message.encrypt() 2016-02-06 22:58:43 +07:00
Tankred Hase
31df9c07da Allow either privateKey, session key or password for message.decrypt() 2016-02-06 22:58:43 +07:00
Tankred Hase
83fcbaa633 Decode utf8 text only for correct format in Literal.getText() 2016-02-06 22:58:43 +07:00
Tankred Hase
2754bfef54 Cleanup public api 2016-02-06 22:58:38 +07:00
Tankred Hase
8777289b77 Cleanup config 2016-02-06 19:11:58 +07:00
Tankred Hase
8d82a18c19 Fix bug in message.decryptSessionKey where it would return this (msg obj)
Cleanup message code
2016-02-06 15:03:04 +07:00
Tankred Hase
55110c3409 Remove sessionKeyAlgorithm parameter from message.decrypt()
See: 2010456a19 (commitcomment-12397926)
2016-02-06 14:33:10 +07:00
Tankred Hase
c4bc9b2fe0 Use global this in src/worker/worker.js and add to linting 2016-02-06 14:28:05 +07:00
Tankred Hase
d40c3e81d9 Cleanup code of src/packet/literal.js 2016-02-06 14:22:19 +07:00
Tankred Hase
9da63d56b3 Cleanup style inconsistencies in cfb.js and random.js 2016-02-06 13:36:19 +07:00
Tankred Hase
1997e445f9 Use ES6 destructuring and default parameters in public api 2016-02-05 17:23:17 +07:00
Tankred Hase
c75a39e9b8 Remove 'self' from .jshintrc 2016-02-05 17:09:22 +07:00
Tankred Hase
f87d8d0433 Fix parsing packets from tag in web worker 2016-02-05 15:39:11 +07:00
Tankred Hase
8728db2b08 Finish refactoring src/**/*.js to use import & export 2016-02-05 15:23:11 +07:00
Tankred Hase
70ac662073 Refactor src/packet/*.js to use import & export 2016-02-05 14:44:22 +07:00
Tankred Hase
9ebe31a4ec Refactor src/worker/*.js to use import and export 2016-02-05 13:20:05 +07:00
Tankred Hase
444128829a Refactor src/keyring/*.js to use import & export 2016-02-05 13:16:42 +07:00
Tankred Hase
acabca9585 Fix config path in hkp.js 2016-02-05 12:45:45 +07:00
Tankred Hase
1157cd2ac8 Move src/hkp/hkp.js -> src/hkp.js
Delete src/hkp/index.js
2016-02-05 12:45:40 +07:00
Tankred Hase
8559cd2bff Refactor src/encoding/*.js and src/hkp/*.js to use import 2016-02-05 12:40:30 +07:00
Tankred Hase
509d6c67ee Refactor src/type/*.js to use import 2016-02-05 10:37:15 +07:00
Tankred Hase
dea42df209 Refactor src/crypto/**/*.js to use import & export 2016-02-05 10:36:09 +07:00
Tankred Hase
3aed324d51 Refactor src/crypto/hash/*.js to use import & export 2016-02-05 09:30:24 +07:00
Tankred Hase
19a97bf117 Refactor src/crypto/cipher/*.js to use import & export 2016-02-05 09:09:04 +07:00
Tankred Hase
60b23169ac Refactor src/config/*.js to use import 2016-02-05 09:09:04 +07:00
Tankred Hase
f06e5aea55 Refactor src/*.js to use import 2016-02-05 09:09:04 +07:00
Tankred Hase
185d575ba3 Refactor src/index.js to re-export ES6 module 2016-02-05 09:09:04 +07:00
Tankred Hase
8d383a1b7c Update npm dependencies and shrinkwrap 2016-02-05 09:03:53 +07:00
Tankred Hase
01b0cd8387 Enable ES6 support by using babelify transform in browserify build
* Add babelify as dev dependency
* Add babelify transform to browserify build
* Enable es6 support for jshint
* Ignore minified js files in babel transform
2016-02-05 00:47:07 +07:00
Tankred Hase
d725abd5b6 Remove debuggind comments from util 2016-02-04 22:06:48 +07:00
Tankred Hase
0b69697699 Update npm dependencies and shrinkwrap 2016-02-04 22:00:33 +07:00
Tankred Hase
bcfc8ef7f7 Use npm published asmcrypto-lite module 2016-02-04 21:47:40 +07:00
Tankred Hase
3bf421206b Further cleanup of sym_encrypted_integrity_protected.js 2016-02-04 16:41:40 +07:00
Tankred Hase
261db8035d Remove redundant message.symEncrypt/symDecrypt 2016-02-04 16:41:39 +07:00
Tankred Hase
c840fabc7d Further cleanup of hash module 2016-02-04 16:41:39 +07:00
Tankred Hase
d67efe22eb Only log errors when config.debug is true 2016-02-04 16:41:38 +07:00
Tankred Hase
316a37a1cd Cleanup hash index.js 2016-02-04 16:41:38 +07:00
Tankred Hase
642f754169 Add more files to linting, make strict mode optional for each file 2016-02-04 16:41:37 +07:00
Tankred Hase
b8f353abe8 Include rusha via npm 2016-02-04 10:05:19 +07:00
Tankred Hase
cfe058596f Include asmCrypto via npm 2016-02-04 09:42:49 +07:00
Tankred Hase
edd51d6052 Ignore buffer node module in test bundle 2016-02-04 00:39:17 +07:00
Tankred Hase
90a7457b71 Refactor most src files to strict mode, delint 2016-02-04 00:37:00 +07:00
Tankred Hase
346aa8f11a Cleanup node.js api detection 2016-02-03 20:24:54 +07:00
Tankred Hase
3919441bbc Fix unit test using strict mode for random.js 2016-02-03 20:24:54 +07:00
Tankred Hase
2f74acc94f Cleanup src/crypto/index.js 2016-02-03 20:24:54 +07:00
Tankred Hase
68d298c948 Fix node.js detection 2016-02-03 20:24:54 +07:00
Tankred Hase
00ea3918c5 Cleanup and linting on all *.js 2016-02-03 20:24:54 +07:00
Tankred Hase
4d325ca65c Cleanup RSA and util code 2016-02-03 20:24:54 +07:00
Tankred Hase
55bd9757e7 Refactor config.useWebCrypto to config.useNative 2016-02-03 20:24:54 +07:00
Tankred Hase
5358c6f9fe [TODO] Check why code coverage fails 2016-02-03 20:24:54 +07:00
Tankred Hase
2aa8b143bd Ignore MDC error in unit test for symmetrically encrypted packet 2016-02-03 20:24:54 +07:00
Bart Butler
469a6be31a Rebase for upload to main openpgpjs repo 2016-02-03 20:24:54 +07:00
Bart Butler
f56b6887d9 native crypto and hash for nodeJS 2016-02-03 20:24:54 +07:00
Bart Butler
4c82568fad hash performance fix 2016-02-03 20:24:54 +07:00
Bart Butler
88a7534b8a Add asmCrypto, native node crypto calls for faster AES 2016-02-03 20:24:54 +07:00
Bart Butler
11038dd946 Add Rusha for fast SHA hashes 2016-02-03 20:24:54 +07:00
Bart Butler
5711028449 does not pass tests yet 2016-02-03 20:24:54 +07:00
Bart Butler
1c6e777a3d bugfixes 2016-02-03 20:24:54 +07:00
Bart Butler
b4916e29a3 binary strings to typed arrays in most places 2016-02-03 20:24:54 +07:00
Bart Butler
b310877c7d fixes 2016-02-03 20:24:54 +07:00
Bart Butler
11a8a99aef add filename to return object when decrypting binary file 2016-02-03 20:24:54 +07:00
Bart Butler
60fb6ba18d direct session key manipulation and encryption/decryption 2016-02-03 20:24:54 +07:00
Bart Butler
91d35ff99c initial modifications 2016-02-03 20:24:54 +07:00
Bart Butler
2e4e9387a0 Fixes for symmetrically encrypted session keys 2016-02-03 20:24:54 +07:00
Tankred Hase
6c4e0ed6a0 Reorder travis jobs to run required first 2016-02-03 20:22:43 +07:00
Tankred Hase
d707164857 Fix unit tests on Safari, Closes openpgpjs/openpgpjs#399 2016-02-03 19:33:08 +07:00
Tankred Hase
74763c155d Turn node_modules caching back on 2016-02-03 19:27:36 +07:00
Tankred Hase
6821f1f8bb Update npm dependencies and shrinkwrap 2016-02-02 15:28:29 +07:00
Tankred Hase
9a06ca2eb3 Check code coverage only under node v0.12 => faster 2016-02-02 15:04:13 +07:00
Tankred Hase
fbccbc9b14 Run browser tests under node v4.2 2016-02-02 15:04:13 +07:00
Tankred Hase
35ed0f2d42 Add node v4.2 and v5 to the required travis builds 2016-02-02 15:04:13 +07:00
Giovanni Pellerano
cc66703763 Merge pull request #393 from openpgpjs/codeclimate
Codeclimate
2016-02-01 11:18:49 +01:00
Tankred Hase
7538878506 Set codecliamte repo token 2016-02-01 14:55:09 +07:00
evilaliv3
6523155d65 Replace coveralls bagdge with codeclimate coverage badge and add codeclimate badge for tracking code quality 2016-02-01 14:44:51 +07:00
evilaliv3
15da6c14da Replace coveralls with codeclimate coverage by means of codeclimate-test-reporter 2016-02-01 14:44:51 +07:00
Giovanni Pellerano
bdf4edb138 Merge pull request #401 from openpgpjs/travis-builds
Add Chrome, Firefox and IE11 to required tests
2016-02-01 03:57:56 +01:00
Tankred Hase
a5f9f8e89f Add Chrome, Firefox and IE11 to required tests 2016-02-01 08:42:15 +07:00
Tankred Hase
1ba1427f58 Skip performance test 2016-02-01 08:23:17 +07:00
Tankred Hase
b89d069f05 Merge pull request #400 from openpgpjs/linting
Add linting to grunt test job
2016-01-31 07:57:23 +07:00
Tankred Hase
be6bea843d Update npm dependencies and shrinkwrap 2016-01-31 07:35:24 +07:00
Tankred Hase
5f55c7ab20 Add linting to grunt test job
* Add grunt-jscs and .jscsrc (lint trailing whitespaces and indentation length)
* Cleanup .jshintrc (use globals instead of deprecated predefs)
* Add Gruntfile.js and *.json linting to npm test

N.B. This does not lint the whole src/ directory during grunt test but
this should definitely be our goal. Please try to de-lint any js files
you touch during development using a texteditor that support linting
(Sublime Text 3 and SublimeLinter 3 with jshint/jscs plugins work great)
2016-01-31 07:32:13 +07:00
Tankred Hase
a49b5ce1c5 Release new version 2016-01-31 07:20:31 +07:00
Tankred Hase
3730289b55 Fix shrinkwrap for use on node v4.2 LTS
* Remove fsevents as optional dependency in package.json
* Update npm dependencies and shrinkwrap
2016-01-31 07:17:08 +07:00
Tankred Hase
06a1c1afe0 Release new version 2016-01-30 18:45:18 +07:00
Tankred Hase
5f8899a207 Create seperate update_dep.sh script to avoid up 2016-01-30 18:44:17 +07:00
Tankred Hase
678b318926 Update npm dependencies and shrinkwrap 2016-01-30 18:38:51 +07:00
Tankred Hase
a41a087616 Merge pull request #398 from openpgpjs/promise-polyfill
Promise polyfill
2016-01-30 17:55:30 +07:00
Tankred Hase
f240feac4b Always polyfill ES6 Promises
Go back to v1.0.0 for Promise polyfill

Add node v5.x to travis build
2016-01-30 16:02:59 +07:00
Tankred Hase
cec41bfa70 Release new version 2016-01-30 02:02:43 +07:00
Tankred Hase
b62c2ff31f Fix shrinkwrap by removing fsevents and making it an optional dependency 2016-01-30 01:25:37 +07:00
Tankred Hase
3705f5b87a Release new version 2016-01-29 20:20:46 +07:00
Tankred Hase
dec7881f93 Don't inject fetch polyfill in hkp module anymore 2016-01-29 20:03:11 +07:00
Tankred Hase
8070120b45 Shrinkwrap dependencies on new release 2016-01-29 19:25:17 +07:00
Tankred Hase
539b445890 Release new version 2016-01-29 19:06:51 +07:00
Tankred Hase
7a636396be Remove from npm-shrinkwrap.json files package.json 2016-01-29 19:05:02 +07:00
Tankred Hase
d966e72b95 Move node-fetch to dependencies in package.json 2016-01-29 19:03:06 +07:00
Tankred Hase
f67be9ea9f Release new version 2016-01-29 18:49:59 +07:00
Tankred Hase
56ecc9e0cd Release new version 2016-01-29 18:40:12 +07:00
Giovanni Pellerano
c2c73a4fd1 Merge pull request #396 from openpgpjs/revert-395-es6
Revert "Enable ES6 support by using babelify transform in browserify build"
2016-01-26 15:17:13 +01:00
Tankred Hase
b8fad5aba5 Revert "Enable ES6 support by using babelify transform in browserify build" 2016-01-26 20:53:34 +07:00
Giovanni Pellerano
e64c4d7965 Merge pull request #395 from openpgpjs/es6
Enable ES6 support by using babelify transform in browserify build
2016-01-25 12:17:22 +01:00
Tankred Hase
62890e9fdb Merge pull request #394 from openpgpjs/remove-ripped-outeaded-jsdoc-template
Remove ripped and outdated jdoc template
2016-01-25 08:36:36 +07:00
evilaliv3
e23b62c4d3 Remove ripped and outdated jdoc template 2016-01-24 21:25:36 +01:00
Tankred Hase
ed2a93f1ed Enable ES6 support by using babelify transform in browserify build
* Add babelify as dev dependency
* Add babelify transform to browserify build
* Enable es6 support for jshint
* Ignore minified js files in babel transform
2016-01-24 20:51:20 +07:00
Tankred Hase
bc5eb03ccd Add var declaration to des.js and use strict mode 2016-01-24 19:55:20 +07:00
Tankred Hase
05e441b8ad Remove unneeded browserify devDependency 2016-01-23 19:00:20 +07:00
Tankred Hase
73134fa181 Release new version 2016-01-23 09:28:47 +07:00
Tankred Hase
c7174600ed Merge pull request #390 from openpgpjs/fix/387-dist
Fix 'openpgp' module not being found after clean checkout and build.
2016-01-23 08:47:40 +07:00
Tankred Hase
f729efa873 Use dist/openpgp instead of src/index because of future ES6 transpilation under node 2016-01-23 07:05:59 +07:00
evilaliv3
86f042c480 Refactor Grunt.js following the unittests packaging changes 2016-01-22 23:47:11 +01:00
evilaliv3
af4a9ba6ad Revert few of the changes done in a4598f3bd4 2016-01-22 23:47:11 +01:00
Tankred Hase
e907777760 Remove unused npm_pack grunt task 2016-01-22 23:47:11 +01:00
evilaliv3
6d12e3142d Update dev dependencies to latest versions 2016-01-22 23:47:06 +01:00
Tankred Hase
024dddbd91 Remove caching of node_modules in travis build 2016-01-22 20:31:49 +01:00
Tankred Hase
a6e4e7c415 Point to dist/openpgp.js bundle in package.json main attribute for node.js use 2016-01-22 20:31:49 +01:00
Tankred Hase
f36e8862c8 Remove unecessary whitespace in package.json 2016-01-22 20:31:49 +01:00
evilaliv3
b92efd6087 Remove unneded build actions 2016-01-21 18:39:41 +01:00
evilaliv3
1f995bea22 Fix scope of variables used by des_createKeys in src/crypto/cipher/des.js 2016-01-18 11:58:43 +01:00
evilaliv3
808ae07a18 Refactor travis.sh in order to correctly use the exit code of background test process 2016-01-09 18:21:48 +01:00
evilaliv3
6dd054efe7 Bump node-localstorage to 1.1.2 2016-01-09 16:50:22 +01:00
evilaliv3
ff8d410bbf Cleanup README.md badges 2016-01-09 01:22:28 +01:00
evilaliv3
79034f8dde Change port used for testing to 3000 cause of safari issues in using 9000 2016-01-09 01:22:28 +01:00
evilaliv3
954540ff22 Implement custom travis_wait in order to have command output still printed on the command line 2016-01-09 01:22:28 +01:00
evilaliv3
dc6f91971f Add travis_wait to grunt saucelabs in order to deal with the long long long firefox execution 2016-01-09 01:22:28 +01:00
evilaliv3
ec2a3990ff Fix order of logFailure definition and its usage in unittests.html 2016-01-09 01:22:28 +01:00
evilaliv3
e2e72e8de4 Set node_js 0.12 in place of 0.12.2 in .travis.yml 2016-01-09 01:22:28 +01:00
evilaliv3
5a28ada5ee Add license to package.json and correct bower.json 2016-01-09 01:22:28 +01:00
evilaliv3
b526d16aeb Update dev dependencies to latest versions 2016-01-09 01:22:24 +01:00
evilaliv3
a730d3f7ad Replace check for detecting that an object is a promise 2016-01-07 18:28:40 +01:00
evilaliv3
1a4a75501a Raise unittests.html mocha.timeout to 240000 as for other timeouts 2016-01-07 15:35:47 +01:00
Thomas Oberndörfer
a968f60f0b Keyring: support plain email addresses (without name) as user IDs. 2016-01-07 15:35:47 +01:00
ReadmeCritic
ade3a35f42 Update README URLs based on HTTP redirects 2016-01-07 15:35:47 +01:00
Nick Doiron
ef566b6a3c Specify a filename in encrypt fromBinary [Closes #284] 2016-01-07 15:35:47 +01:00
Thomas Oberndörfer
6f8a3abdfa Support multiple user IDs for key generation 2016-01-07 15:35:47 +01:00
Matthew Shaylor
37ce176d42 If you attempt to store an empty keylist then delete the storage key 2016-01-07 15:35:47 +01:00
Artem Chudinov
068d38d832 Use RegExp.prototype.test instead of String.prototype.match where it is OK
There is no sense in using String.prototype.match if the retrieved matched results
are not used.

By the way, if a bit of performance (especially RAM usage) is preferred over
unification, then, obviously, conditions like
if (/SIGNED MESSAGE/.test(header[1])) {
can be changed to
if (header[1].indexOf('SIGNED MESSAGE') !== -1) {
2016-01-07 15:35:47 +01:00
Artem Chudinov
30926e4738 message.js: Don't use variable signingKeyPacket out of scope 2016-01-07 15:35:47 +01:00
Artem Chudinov
3e2f34ac62 Add missing semicolons 2016-01-07 15:35:47 +01:00
Thomas Oberndörfer
d0297e1b81 Test cases for MDC error 2016-01-07 15:35:47 +01:00
Thomas Oberndörfer
2ee347154c Symmetrically encrypted packet: raise error if MDC is missing for modern cipher. 2016-01-07 15:35:47 +01:00
evilaliv3
9589fa0b52 Apply mixed code review thanks to webstorm inspector 2016-01-07 14:46:55 +01:00
Tankred Hase
85efb463cf Check http status when uploading key 2015-12-27 16:27:55 +07:00
Tankred Hase
2fe10749a1 Release new version 2015-12-19 15:25:50 +07:00
Tankred Hase
450fddaf8e Call encodeURIComponent on hkp query parameters 2015-12-19 15:23:00 +07:00
evilaliv3
b60bea547b Re-add node_js 4.2 (LTS) under unit testing but marked with allow_failures flag 2015-12-12 10:00:14 +01:00
Tankred Hase
e159fd77b4 Add example for key upload to readme 2015-12-12 12:17:08 +07:00
Tankred Hase
5b937a6712 Release new version 2015-12-12 10:57:23 +07:00
Tankred Hase
bcde9bfa1a Add HKP lookup example to README 2015-12-12 10:39:38 +07:00
Tankred Hase
f46696a915 Remove node v4.2 from travis build
I decided to remove node v4.2 from the travis build. It turns out it's too slow and break the build more often than it actually provides value.
2015-12-11 16:41:57 +07:00
Tankred Hase
6634abf326 Add basic HKP lookup and upload support 2015-12-11 13:12:34 +07:00
evilaliv3
2d262d8095 Add node_modules directory to travisCI cache 2015-12-07 01:26:40 +01:00
evilaliv3
8b2c66eeb2 Properly set the BUILD_ID in grunt saucelabs script 2015-12-02 14:47:24 +01:00
evilaliv3
727cb9f237 Fix allow_failures usage in .travis.yml 2015-11-30 17:35:41 +01:00
evilaliv3
ff086355dd Fix syntax error in travis.sh 2015-11-30 15:17:33 +01:00
Mithgol
0e8cedae46 put sudo: false in .travis.yml 2015-11-30 15:12:31 +01:00
evilaliv3
831c0a14d5 Allow travisCI to fast_finish the build result as soon as unit tests are completed 2015-11-30 02:24:42 +01:00
evilaliv3
46d2b6e66d Reduce duration unit testing implementing their parallelization
Starting from two pull requests by @tanx and @Mithgol this commit implement the following:
- add testing of node version 4.2 LTS;
- move testing to the new TravisCI environment that is expected to be more fast;
- parallelize tests making possible to end first and to test more lasting less;
- make possible for browsertests to fail without impacting on the overall result.
2015-11-30 02:13:39 +01:00
evilaliv3
e02bc7c2f5 Update README.md with openpgpjs repository badges 2015-11-28 18:49:47 +01:00
evilaliv3
641f4c8098 Improve unit testing by means of Coveralls and Saucelabs 2015-11-28 12:53:03 +01:00
Thomas Oberndörfer
0958a9ec02 Release new version 2015-10-05 09:35:19 +02:00
Thomas Oberndörfer
668a9bbe70 Throw exception on unsupported S2K type. 2015-10-03 15:57:03 +02:00
Alex
c266c01b80 Merge pull request #354 from gmontalvoriv/master
added mailock project link
2015-09-23 09:47:26 +02:00
Gabriel Montalvo
2e10231d09 added mailock project link 2015-09-22 19:22:22 -04:00
Giovanni Pellerano
42554146e3 Merge pull request #347 from arzeth/master
Fix running in Node.js (and io.js) with enforced strict mode
2015-08-19 21:17:08 +02:00
Artem Chudinov
9de55b49f3 s2k.js,async_proxy.js: Initialize variable data properly
It fixes error when running the example code (in Node.js with enforced strict
mode) from README.md:

[ReferenceError: data is not defined]
Error: Error generating keypair using js fallback!
    at /tmp/fff/node_modules/openpgp/src/openpgp.js:266:13
    at process._tickDomainCallback (node.js:399:9)
2015-08-19 22:32:06 +05:00
Artem Chudinov
1ee96a3f40 md5.js: Remove an unused variable to support enforced strict mode
The problem was:
arzeth /tmp/test % npm install openpgp
openpgp@1.2.0 node_modules/openpgp
├── node-localstorage@0.3.6
├── es6-promise@1.0.0
└── zlibjs@0.2.0

arzeth /tmp/test % node --version
v3.0.0

arzeth /tmp/test % node
> var openpgp = require('openpgp');
undefined
>

arzeth /tmp/test % node --use_strict
> var openpgp = require('openpgp');
ReferenceError: txt is not defined
    at md51 (/tmp/test/node_modules/openpgp/src/crypto/hash/md5.js:135:7)
    at md5 (/tmp/test/node_modules/openpgp/src/crypto/hash/md5.js:198:14)
    at Object.<anonymous> (/tmp/test/node_modules/openpgp/src/crypto/hash/md5.js:211:5)
    at Module._compile (module.js:430:26)
    at Object.Module._extensions..js (module.js:448:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/tmp/test/node_modules/openpgp/src/crypto/hash/index.js:10:8)
2015-08-19 22:15:21 +05:00
Tankred Hase
6faa98fab8 Add remark about security audits 2015-07-27 11:48:58 +02:00
Tankred Hase
e2e04b04ea Release new version 2015-06-12 16:41:00 +02:00
Tankred Hase
58cac452db Merge pull request #329 from 1and1/master
Optimized memory footprint for encrypting and decrypting
2015-06-11 10:18:55 +02:00
Peter Breitling
07e4278a3a Optimized memory footprint for encrypting and decrypting 2015-06-10 21:12:55 +02:00
Tankred Hase
ac8d991bc3 Release new version 2015-06-09 16:50:39 +02:00
Tankred Hase
a12d2ee27e Merge pull request #296 from bartbutler/ie11_keygen
Support for crypto API keygen in IE11 on Windows 7 and 8
2015-06-09 15:43:40 +02:00
Bart Butler
51dbbe2090 tanx update 2 2015-05-22 12:03:59 -07:00
Bart Butler
2a89baa837 tanx updates 2015-05-22 12:02:23 -07:00
Alex
291b9f2cd2 Update README.md 2015-05-16 21:04:33 +02:00
Tankred Hase
85133393e3 Use 2048 bit keysize in tests in case of webcrypto support 2015-05-13 14:06:48 +02:00
Thomas Oberndörfer
60c2593649 Merge pull request #309 from openpgpjs/symmetric_key_message_encryption
Implement Symmetric-Key Message Encryption using a passphrase
2015-04-23 16:43:32 +02:00
Tankred Hase
4d6a34faa1 Implement Symmetric-Key Message Encryption using a passphrase
See https://tools.ietf.org/html/rfc4880#section-3.7.2.2
2015-04-22 01:41:00 +02:00
Tankred Hase
05cd04f060 Release new version 2015-04-01 12:29:09 +02:00
Tankred Hase
957d346968 Revert "Upate ES6 promise polyfill"
This reverts commit 7bd9642818223217448eaaa2185f198b91977814.
2015-04-01 12:20:26 +02:00
Tankred Hase
2b833c110e Update README.md 2015-03-18 13:53:25 +01:00
Tankred Hase
262ae2b092 Update README.md 2015-03-18 13:52:16 +01:00
Tankred Hase
d11d138313 Release new version 2015-03-15 11:19:09 +01:00
Tankred Hase
7bd9642818 Upate ES6 promise polyfill 2015-03-15 11:08:14 +01:00
Tankred Hase
c15b798252 Merge pull request #300 from mailvelope/email_regex_escape
Add unit tests for checkEmail method in keyring
2015-03-05 16:03:01 +01:00
Thomas Oberndörfer
90d9edd497 Add unit tests for checkEmail method in keyring 2015-03-05 14:40:59 +01:00
Tankred Hase
350c5891a1 Merge pull request #299 from mailvelope/email_regex_escape
Escape email before using as regular expression in emailCheck method.
2015-03-05 13:45:58 +01:00
Thomas Oberndörfer
be6ae2c464 Escape email before using as regular expression in emailCheck method. 2015-03-05 13:32:44 +01:00
Tankred Hase
37091175b1 Release new version 2015-03-04 07:27:01 +01:00
Tankred Hase
fca5f7de2b Merge pull request #298 from mailvelope/sig_verify_sub_bind_check
Check validity of key packet before signature verification
2015-03-04 07:17:51 +01:00
Thomas Oberndörfer
a33b8c035d Check validity of key packet before signature verification 2015-03-03 18:15:17 +01:00
Bart Butler
e8465350fc Support for crypto API keygen in IE11 on Windows 7 and 8 2015-02-28 03:43:39 -08:00
bartbutler
f0808c6e0c Merge pull request #1 from openpgpjs/master
Pull updates
2015-02-27 23:52:46 -08:00
Tankred Hase
9ad364781f Release new version 2015-02-16 11:02:39 +01:00
Tankred Hase
dfc15e492a Merge pull request #291 from openpgpjs/webkit-webcrypto
Add native RSA keygen (WebCrypto) support for Safari/iOS
2015-02-16 10:53:06 +01:00
Tankred Hase
cb3cc86a88 Add native RSA keygen (WebCrypto) support for Safari/iOS 2015-02-13 22:14:27 +01:00
Tankred Hase
6835ff0872 Release new version 2015-02-13 10:14:28 +01:00
Tankred Hase
2defd7f66b Release new version 2015-02-13 08:16:02 +01:00
Tankred Hase
8100ecebd2 Update readme 2015-02-13 05:02:48 +01:00
Tankred Hase
5b4931d926 Release new version 2015-02-13 04:56:39 +01:00
Tankred Hase
d3576b6eb6 Fix build 2015-02-13 04:49:08 +01:00
Tankred Hase
2b682125bb Merge pull request #290 from openpgpjs/bower
Add compiled v0.10.0 file to git for bower
2015-02-13 04:23:40 +01:00
Tankred Hase
fcf7242c10 Add release shell script for automated build, tagging, and releasing to npm 2015-02-13 04:21:26 +01:00
Tankred Hase
d25c90bff1 Fix AsyncProxy tests 2015-02-11 14:20:42 +01:00
Tankred Hase
da3dbf7acc Set config in AsyncProxy 2015-02-11 14:01:08 +01:00
Sergey Ratiashvili
c9e019d20e fix worker instance misconfiguration 2015-02-11 13:08:13 +01:00
Tankred Hase
1cc3f4fe2e Merge pull request #285 from bartbutler/master
Comparison fix for broken getRandomBigIntegerInRange function
2015-02-11 11:31:58 +01:00
Tankred Hase
06b66d7f62 Merge pull request #274 from mailvelope/get-worker
Add getter method for worker to high level API. Initialization options for AsyncProxy: path and worker.
2015-02-11 11:05:36 +01:00
Tankred Hase
1728ad48bc Merge pull request #288 from koto/dsafix
Correctly check parameters range in DSA verify. Fixes #286
2015-02-11 11:00:30 +01:00
Krzysztof Kotowicz
587127acd1 Correctly check parameters range in DSA verify. 2015-02-10 12:01:22 +01:00
Bart Butler
0ce32bec92 Need to use compareTo when comparing BigIntegers, otherwise get a string comparison with lexical order 2015-02-08 21:20:07 -08:00
Thomas Oberndörfer
712f807e50 Restore path parameter of initWorker method 2015-01-24 14:44:06 +01:00
Tankred Hase
168b184a1a Merge pull request #277 from mailvelope/keyring_emailcheck
Keyring: fix exception if userid does not contain an email address
2015-01-08 13:19:47 +01:00
Thomas Oberndörfer
a642640cf1 Keyring: use regex for email check. Fix exception if userid does not contain an email address. 2014-12-18 16:28:38 +01:00
Thomas Oberndörfer
de0a6d1259 Helper method: get Keyid object from hex keyid. 2014-12-15 14:34:02 +01:00
Thomas Oberndörfer
c9b4f7532e Add getter method for worker to high level API. Initialization options for AsyncProxy: path and worker. 2014-12-15 14:33:13 +01:00
Thomas Oberndörfer
eb7f854afe Add useWebCrypto to config and set to true 2014-12-15 14:30:22 +01:00
Tankred Hase
f79ce008b7 Merge pull request #268 from bantu/typo-unknow
Typo: Unknow -> Unknown
2014-12-09 16:35:49 +01:00
Tankred Hase
782d7dee6e bump version 2014-12-09 15:50:47 +01:00
Tankred Hase
bed393063d Merge pull request #272 from laktak/compress
Compression Support
2014-12-09 15:36:41 +01:00
Christian Zangl
da650e2d63 add compression support (for zip & zlib) using https://github.com/imaya/zlib.js
add zlibjs dependency, grunt task
fix compData vs compdata bug
2014-12-04 22:29:33 +01:00
Tankred Hase
5184d45444 Merge pull request #267 from laktak/fix-symkey
fix symkey version
2014-12-04 21:43:17 +01:00
Andreas Fischer
b00ce34e90 Typo: Unknow -> Unknown 2014-11-17 12:31:04 +01:00
Christian Zangl
8d08d0bd1a fix symkey version 2014-11-12 16:47:32 +01:00
Tankred Hase
9aca150fca Merge pull request #265 from yoshuawuyts/patch-1
readme: add syntax highlighting
2014-11-09 12:15:32 +01:00
Yoshua Wuyts
5ca1801208 readme: add syntax highlighting
This PR adds syntax highlighting to the readme. Thanks!
2014-11-09 09:51:07 +01:00
Tankred Hase
eedb722d7b Fall back to js crypto in case native RSA keygen fails 2014-10-29 18:17:03 +01:00
Tankred Hase
d38fc07578 Fix promise documentation 2014-10-28 10:46:49 +01:00
Tankred Hase
2a01399cb3 Update documentation to make returned promises clearer 2014-10-28 10:38:11 +01:00
Tankred Hase
f4682599be Return correct promise in error case 2014-10-20 18:30:26 +02:00
Tankred Hase
e62f8c83f8 Bump dev version 2014-10-20 17:46:52 +02:00
Tankred Hase
2362cce642 Merge pull request #259 from openpgpjs/promises
Refactor public api to use ES6 Promises
2014-10-20 16:12:13 +02:00
Tankred Hase
e3b6903eb1 Use global error catch 2014-10-20 16:10:09 +02:00
Tankred Hase
628663caac Upgrade license to LGPL version 3.0 or later. 2014-10-11 11:11:12 +02:00
Tankred Hase
39e1e145e4 Add es6-promise polyfill to build step so users don't have to. 2014-10-02 10:55:27 +02:00
Tankred Hase
562831d6dc Merge pull request #245 from inovari/master
Bugfix in packet_length calculation
2014-10-02 00:24:23 +02:00
Tankred Hase
4cd664a919 Fix tests on travis ci. 2014-10-02 00:02:56 +02:00
Tankred Hase
2ca369a3f2 Upadte readme to error handling 2014-10-01 22:32:34 +02:00
Tankred Hase
bf1cb6d521 Add high level error messages to public api. 2014-10-01 22:20:28 +02:00
Tankred Hase
bdbd7819f4 Fix phantom.js web worker tests that use promises 2014-10-01 21:55:50 +02:00
Tankred Hase
d5a0e18d13 Update README with documentation on promises. 2014-10-01 21:32:23 +02:00
Tankred Hase
f08fc0a4f7 Refactor web worker async proxy to use promises. 2014-10-01 21:18:05 +02:00
Tankred Hase
7f2573c77d Refactor complete public api to use promises 2014-10-01 19:12:39 +02:00
Tankred Hase
0ac58356b5 Refactor keygen to use promises (Work in progress) 2014-10-01 13:13:09 +02:00
Tankred Hase
5d07ee1eb1 Add documentation to getWebCrypto 2014-10-01 11:23:34 +02:00
Tankred Hase
72cb1cfc49 Make WebCrypto optional with config.useWebCrypto 2014-10-01 11:17:48 +02:00
Tankred Hase
e6f66b9039 Cleanup promise error handling 2014-10-01 08:40:26 +02:00
Tankred Hase
0af12b81a3 Fix typo 2014-10-01 07:40:02 +02:00
Tankred Hase
7c2cf89589 Fix decoding of JWK. Webcrypto works. 2014-09-30 21:57:46 +02:00
Tankred Hase
85d2199971 Activate web crypto api (still fails tests)
* Remove api support for safari
* Fix error handling
2014-09-30 19:31:12 +02:00
Tankred Hase
cbe4a17ccb Refactor key generation to use callback
* TODO: reactive native web crypto in rsa.js:142
* TODO: generate publicExponent Uint8Array from argument E in rsa.js:148
* TODO: signing with generated web crypto key fails with "Could not find valid key packet for signing in key"
2014-09-30 18:22:17 +02:00
Thomas Oberndörfer
d6963f2017 map JWK parameters to local BigInteger 2014-09-30 18:20:26 +02:00
Tankred Hase
15edf09972 Add RSA keygen example using WebCrypto Api 2014-09-30 18:20:26 +02:00
Tankred Hase
bbe174828f Upgrade license to LGPL version 3.0 or later. 2014-09-30 18:16:58 +02:00
Tankred Hase
6636d83aa9 Merge pull request #253 from toberndo/fix_getPrimaryUser
Fix sorting of primary users
2014-09-13 15:35:47 +02:00
Thomas Oberndörfer
dabd96e5df Merge pull request #252 from omeid/master
Add bower support.
2014-09-03 16:45:29 +02:00
Thomas Oberndörfer
069b97d16f Fix sorting of primary users 2014-09-03 14:38:31 +02:00
omeid
3779739a63 Add bower support 2014-09-02 01:26:25 +10:00
Tankred Hase
58322c299d Use svg in travis badge 2014-08-05 13:38:25 +02:00
Tankred Hase
42cf0e5bf6 Merge pull request #249 from adhintz/master
add grunt-cli to devDependencies
2014-08-05 12:20:55 +02:00
Drew Hintz
e13302e35e add grunt-cli to devDependencies by running npm install --save-dev grunt-cli 2014-08-05 07:35:20 +00:00
Tankred Hase
132bd054de bump version 2014-07-30 17:09:34 +02:00
Tankred Hase
7a0fa12dc6 Merge pull request #248 from openpgpjs/clearPrivateMPIs
Key generation: do not clear private MPIs for keys without passphrase.
2014-07-30 17:02:53 +02:00
Thomas Oberndörfer
060da64aab Key generation: do not clear private MPIs for keys without passphrase. 2014-07-30 16:36:01 +02:00
inovari
91ccbeed80 Bugfix in packet_length calculation
One of the bitshifts used to construct tmplen (lines 230-231) was inconsistent with the other expressions:

(input[mypos2++].charCodeAt() << 8)

causing following error:

TypeError: Cannot call method 'charCodeAt' of undefined
    at Object.module.exports.read (/home/scott/dev/keystone/fetch/node_modules/openpgp/src/packet/packet.js:231:16)

Corrected to 

(input.charCodeAt(mypos2++) << 8)
2014-07-16 15:37:06 -04:00
Tankred Hase
8a27866225 release version 2014-07-07 12:25:28 +02:00
Tankred Hase
e885fb1433 Use same signature array structure in verify for ClearSignedMessages as Message 2014-07-07 12:02:13 +02:00
Tankred Hase
571ed67624 Merge pull request #241 from openpgpjs/detached-signature
Implement content verification using detached signatures
2014-07-03 15:30:38 +02:00
Tankred Hase
de3ba18400 Implement content verification using detached signatures 2014-07-03 14:57:52 +02:00
Tankred Hase
74959b83b6 New release 2014-07-02 15:15:03 +02:00
Tankred Hase
f5f16b841e Merge pull request #239 from openpgpjs/empty-signatures
Iterate over signature not keys to allow empty signatures array in case ...
2014-07-02 15:14:15 +02:00
Tankred Hase
396199f631 Iterate over signature not keys to allow empty signatures array in case the message has no signatures. 2014-07-02 12:52:14 +02:00
Tankred Hase
5f24b461e7 bump version 2014-07-01 16:33:52 +02:00
Tankred Hase
2cbc232b0f new release 2014-07-01 16:28:58 +02:00
Tankred Hase
38ad1dc914 Merge pull request #238 from openpgpjs/no-passphrase
No passphrase
2014-07-01 16:27:43 +02:00
Tankred Hase
8c93688b0e Warn user with signature null for wrong public key instead of exception. 2014-07-01 16:22:09 +02:00
Tankred Hase
62debad52d Allow removal of passphrase protection by calling encrypt with an empty passphrase 2014-07-01 15:02:09 +02:00
Tankred Hase
3ffe8699e2 bump version for dev 2014-06-30 19:30:02 +02:00
Tankred Hase
ecb6798441 Throw an error if a wrong public key is used to verify a signature. 2014-06-30 19:26:33 +02:00
Tankred Hase
dbbb207211 bump version 2014-06-28 16:56:25 +02:00
313 changed files with 168280 additions and 19839 deletions

4
.eslintignore Normal file
View File

@ -0,0 +1,4 @@
dist
test/lib/
test/typescript/
docs

142
.eslintrc.cjs Normal file
View File

@ -0,0 +1,142 @@
module.exports = {
'extends': [
'airbnb-base',
'airbnb-typescript/base'
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaVersion': 11,
'sourceType': 'module',
'project': 'tsconfig.json'
},
'env': {
'browser': true,
'es6': true,
'node': true
},
'plugins': [
'@typescript-eslint',
'chai-friendly',
'import',
'unicorn'
],
'settings': {
'import/resolver': {
'typescript': {}
}
},
'globals': { // TODO are all these necessary?
'globalThis': true,
'console': true,
'Promise': true,
'importScripts': true,
'process': true,
'Event': true,
'describe': true,
'it': true,
'mocha': true,
'before': true,
'beforeEach': true,
'after': true,
'afterEach': true,
'escape': true,
'unescape': true,
'resolves': true,
'rejects': true,
'TransformStream': true,
'BigInt': true
},
'rules': {
'arrow-body-style': 'off',
'arrow-parens': ['error','as-needed'],
'class-methods-use-this': 'off',
'@typescript-eslint/comma-dangle': ['error', 'never'],
'@typescript-eslint/comma-spacing': 'off',
'consistent-return': 'off',
'default-case': 'off',
'@typescript-eslint/default-param-last': 'off',
'eol-last': ['error', 'always'],
'function-call-argument-newline': 'off',
'func-names': ['error', 'never'],
'function-paren-newline': 'off',
'global-require': 'off',
'key-spacing': 'off',
'keyword-spacing': 'error',
'max-classes-per-file': 'off',
'max-len': 'off',
'newline-per-chained-call': 'off',
'no-bitwise': 'off',
'no-continue': 'off',
'no-else-return': 'off',
'no-empty': ['error', { 'allowEmptyCatch': true }],
'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF':0 }],
'no-nested-ternary': 'off',
'no-param-reassign': 'off', // TODO get rid of this
'no-plusplus': 'off',
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'object-curly-newline': 'off',
'@typescript-eslint/no-shadow': 'off', // TODO get rid of this
'object-property-newline': [
'error',
{
'allowMultiplePropertiesPerLine': true
}
],
'object-shorthand': 'off',
'operator-assignment': 'off',
'operator-linebreak': [
'error',
'after'
],
'padded-blocks': 'off',
'prefer-arrow-callback': 'off',
'prefer-destructuring': 'off',
'prefer-rest-params': 'off', // TODO get rid of this
'prefer-spread': 'off', // TODO get rid of this
'prefer-template': 'off',
'quote-props': 'off',
'quotes': ['error', 'single', { 'avoidEscape': true }],
'@typescript-eslint/space-before-function-paren': ['error', { 'anonymous': 'ignore', 'named': 'never', 'asyncArrow': 'always' }],
'spaced-comment': 'off',
'indent': 'off',
'@typescript-eslint/indent': ['error', 2, { 'SwitchCase': 1 }],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
// eslint-plugin-import rules:
'import/named': 'error',
'import/extensions': 'off', // temporary: we use them in tests (ESM compliant), but not in the lib (to limit diff)
'import/first': 'off',
'import/no-extraneous-dependencies': ['error', { 'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false }],
'import/no-unassigned-import': 'error',
'import/no-unresolved': 'error',
'import/prefer-default-export': 'off',
// Custom silencers:
'no-multi-assign': 'off',
'no-underscore-dangle': 'off',
'no-await-in-loop': 'off',
'camelcase': 'off', // snake_case used in tests, need to fix separately
'@typescript-eslint/naming-convention': 'off', // supersedes 'camelcase' rule
'@typescript-eslint/lines-between-class-members': 'off',
// Custom errors:
'@typescript-eslint/no-use-before-define': ['error', { 'functions': false, 'classes': true, 'variables': false, 'allowNamedExports': true }],
'no-constant-condition': [2, { 'checkLoops': false }],
'new-cap': [2, { 'properties': false, 'capIsNewExceptionPattern': 'EAX|OCB|GCM|CMAC|CBC|OMAC|CTR', 'newIsCapExceptionPattern': 'type|hash*' }],
'max-lines': [2, { 'max': 620, 'skipBlankLines': true, 'skipComments': true }],
'@typescript-eslint/no-unused-expressions': 0,
'chai-friendly/no-unused-expressions': [2, { 'allowShortCircuit': true }],
'unicorn/switch-case-braces': ['error', 'avoid'],
// Custom warnings:
'no-console': 1
}
};

10
.github/ISSUE_TEMPLATE/BUG_REPORT.md vendored Normal file
View File

@ -0,0 +1,10 @@
---
name: Bug report
about: Report an issue with this library
---
<!-- Please search existing issues and discussions to avoid creating duplicates. -->
- OpenPGP.js version:
- Affected platform (Browser or Node.js version):
<!-- Describe the bug you have encountered -->

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Feature request
url: https://github.com/openpgpjs/openpgpjs/discussions/categories/ideas
about: Suggest an idea for this project
- name: Question
url: https://github.com/openpgpjs/openpgpjs/discussions/categories/q-a
about: Please ask any questions here

33
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,33 @@
version: 2
updates:
- package-ecosystem: "npm"
# The redundant target-branch directive is needed to set two different update schedules for npm,
# working around a dependabot limitation:
# see https://github.com/dependabot/dependabot-core/issues/1778#issuecomment-1988140219 .
target-branch: main
directory: "/"
schedule:
interval: "daily"
allow:
- dependency-name: "playwright"
versioning-strategy: increase
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
allow:
- dependency-name: "@noble*"
- dependency-name: "fflate"
versioning-strategy: increase
groups:
# Any packages matching the pattern @noble* where the highest resolvable
# version is minor or patch will be grouped together.
# Grouping rules apply to version updates only.
noble:
applies-to: version-updates
patterns:
- "@noble*"
update-types:
- "minor"
- "patch"

39
.github/test-suite/config.json.template vendored Normal file
View File

@ -0,0 +1,39 @@
{
"drivers": [
{
"id": "sop-openpgpjs-branch",
"path": "__SOP_OPENPGPJS__",
"env": {
"OPENPGPJS_PATH": "__OPENPGPJS_BRANCH__"
}
},
{
"id": "sop-openpgpjs-main",
"path": "__SOP_OPENPGPJS__",
"env": {
"OPENPGPJS_PATH": "__OPENPGPJS_MAIN__",
"DISABLE_PROFILES": "true"
}
},
{
"path": "__SQOP__"
},
{
"path": "__GPGME_SOP__"
},
{
"id": "gosop-v2",
"path": "__GOSOP_V2__"
},
{
"path": "__RNP_SOP__"
},
{
"path": "__RSOP__"
}
],
"rlimits": {
"DATA": 1073741824
}
}

14
.github/test-suite/prepare_config.sh vendored Executable file
View File

@ -0,0 +1,14 @@
CONFIG_TEMPLATE=$1
CONFIG_OUTPUT=$2
OPENPGPJS_BRANCH=$3
OPENPGPJS_MAIN=$4
cat $CONFIG_TEMPLATE \
| sed "s@__OPENPGPJS_BRANCH__@${OPENPGPJS_BRANCH}@g" \
| sed "s@__OPENPGPJS_MAIN__@${OPENPGPJS_MAIN}@g" \
| sed "s@__SQOP__@${SQOP}@g" \
| sed "s@__GPGME_SOP__@${GPGME_SOP}@g" \
| sed "s@__GOSOP_V2__@${GOSOP_V2}@g" \
| sed "s@__SOP_OPENPGPJS__@${SOP_OPENPGPJS_V2}@g" \
| sed "s@__RNP_SOP__@${RNP_SOP}@g" \
| sed "s@__RSOP__@${RSOP}@g" \
> $CONFIG_OUTPUT

67
.github/workflows/benchmark.yml vendored Normal file
View File

@ -0,0 +1,67 @@
name: Performance Regression Test
on:
pull_request:
branches: [main]
jobs:
benchmark:
name: Time and memory usage benchmark
runs-on: ubuntu-latest
steps:
# check out pull request branch
- uses: actions/checkout@v4
with:
path: pr
# check out main branch (to compare performance)
- uses: actions/checkout@v4
with:
ref: main
path: main
- uses: actions/setup-node@v4
with:
node-version: '>=20.6.0'
- name: Run pull request time benchmark
run: cd pr && npm install && npm run --silent benchmark-time > benchmarks.txt && cat benchmarks.txt
- name: Run pull request memory usage benchmark
run: cd pr && npm run --silent benchmark-memory-usage > memory_usage.txt && cat memory_usage.txt
- name: Run time benchmark on main (baseline)
run: cd main && npm install && npm run --silent benchmark-time > benchmarks.txt && cat benchmarks.txt
- name: Run memory usage benchmark on main (baseline)
run: cd main && npm run --silent benchmark-memory-usage > memory_usage.txt && cat memory_usage.txt
- name: Compare time benchmark result
uses: openpgpjs/github-action-pull-request-benchmark@v1
with:
tool: 'benchmarkjs'
name: 'Time benchmark'
pr-benchmark-file-path: pr/benchmarks.txt
base-benchmark-file-path: main/benchmarks.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
# trigger alert comment if 1.3 times slower
alert-threshold: '130%'
comment-on-alert: false
# fail workdlow if 1.5 times slower
fail-threshold: '150%'
fail-on-alert: true
file-to-annotate: ${{ github.workspace }}/test/benchmarks/time.js
- name: Compare memory usage benchmark result
uses: openpgpjs/github-action-pull-request-benchmark@v1
with:
tool: 'raw'
name: 'Memory usage benchmark'
pr-benchmark-file-path: pr/memory_usage.txt
base-benchmark-file-path: main/memory_usage.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
alert-threshold: '102%'
comment-on-alert: false
fail-threshold: '110%'
fail-on-alert: true
file-to-annotate: ${{ github.workspace }}/test/benchmarks/memory_usage.js

19
.github/workflows/docs.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Documentation
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
name: JSDoc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci --ignore-scripts
- run: npm run docs

87
.github/workflows/sop-test-suite.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: SOP interoperability test suite
on:
pull_request:
branches: [ main ]
jobs:
test-suite:
name: Run interoperability test suite
runs-on: ubuntu-latest
container:
image: ghcr.io/protonmail/openpgp-interop-test-docker:v1.1.12
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
# check out repo for scripts
- uses: actions/checkout@v4
# check out pull request branch
- name: Checkout openpgpjs-branch
uses: actions/checkout@v4
with:
path: openpgpjs-branch
- name: Install openpgpjs-branch
run: cd openpgpjs-branch && npm install
- name: Print openpgpjs-branch version
run: $SOP_OPENPGPJS_V2 version --extended
env:
OPENPGPJS_PATH: ${{ github.workspace }}/openpgpjs-branch
# check out main branch
- name: Checkout openpgpjs-main
uses: actions/checkout@v4
with:
ref: main
path: openpgpjs-main
- name: Install openpgpjs-main
run: cd openpgpjs-main && npm install
- name: Print openpgpjs-main version
run: $SOP_OPENPGPJS_V2 version --extended
env:
OPENPGPJS_PATH: ${{ github.workspace }}/openpgpjs-main
# Run test suite
- name: Prepare test configuration
run: ./.github/test-suite/prepare_config.sh $CONFIG_TEMPLATE $CONFIG_OUTPUT $GITHUB_WORKSPACE/openpgpjs-branch $GITHUB_WORKSPACE/openpgpjs-main
env:
CONFIG_TEMPLATE: .github/test-suite/config.json.template
CONFIG_OUTPUT: .github/test-suite/config.json
- name: Display configuration
run: cat .github/test-suite/config.json
- name: Run interoperability test suite
run: cd $TEST_SUITE_DIR && $TEST_SUITE --config $GITHUB_WORKSPACE/$CONFIG --json-out $GITHUB_WORKSPACE/$RESULTS_JSON --html-out $GITHUB_WORKSPACE/$RESULTS_HTML
env:
CONFIG: .github/test-suite/config.json
RESULTS_JSON: .github/test-suite/test-suite-results.json
RESULTS_HTML: .github/test-suite/test-suite-results.html
# Upload results
- name: Upload test results json artifact
uses: actions/upload-artifact@v4
with:
name: test-suite-results.json
path: .github/test-suite/test-suite-results.json
- name: Upload test results html artifact
uses: actions/upload-artifact@v4
with:
name: test-suite-results.html
path: .github/test-suite/test-suite-results.html
compare-with-main:
name: Compare with main
runs-on: ubuntu-latest
needs: test-suite
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download test results json artifact
id: download-test-results
uses: actions/download-artifact@v4
with:
name: test-suite-results.json
- name: Compare with baseline
uses: ProtonMail/openpgp-interop-test-analyzer@v2
with:
results: ${{ steps.download-test-results.outputs.download-path }}/test-suite-results.json
output: baseline-comparison.json
baseline: sop-openpgpjs-main
target: sop-openpgpjs-branch

206
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,206 @@
name: Code Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build: # cache both dist and tests (non-lightweight only), based on commit hash
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Check for cached folders
id: cache-full
uses: actions/cache@v4
with:
path: |
dist
test/lib
key: cache-${{ github.sha }}
- name: Build dist and tests
if: steps.cache-full.outputs.cache-hit != 'true'
run: |
npm ci
npm run build-test
node:
strategy:
fail-fast: false # if tests for one version fail, continue with the rest
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
name: Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci --ignore-scripts # for mocha
- name: Retrieve cached folders
uses: actions/cache/restore@v4
id: cache-full
with:
# test/lib is not needed, but the path must be specified fully for a cache-hit
path: |
dist
test/lib
key: cache-${{ github.sha }}
# ignore cache miss, since it was taken care of the `build` step and it should never occur here
- run: npm test
test-browsers-latest:
name: Browsers (latest)
needs: build
strategy:
fail-fast: false # if tests for one version fail, continue with the rest
matrix:
# run on all main platforms to test platform-specific code, if present
# (e.g. webkit's WebCrypto API implementation is different in macOS vs Linux)
# TODO: windows-latest fails to fetch resources from the wtr server; investigate if the problem is with path declaration or permissions
runner: ['ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Retrieve cached built folders
uses: actions/cache/restore@v4
id: cache-full
with:
path: |
dist
test/lib
key: cache-${{ github.sha }}
- name: Install dependencies
# cannot use `--ignore-scripts` since playwright seems to use it to set ENV vars
run: |
npm pkg delete scripts.prepare
npm ci
- name: Get Playwright version and cache location
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(npm ls playwright --depth=0 | grep playwright | sed 's/.*@//')
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
PLAYWRIGHT_CACHE=${{ fromJSON('{"ubuntu-latest": "~/.cache/ms-playwright", "macos-latest": "~/Library/Caches/ms-playwright"}')[matrix.runner] }}
echo "playwright_cache=$PLAYWRIGHT_CACHE" >> $GITHUB_OUTPUT
- name: Check for cached browsers
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ${{ steps.playwright-version.outputs.playwright_cache }}
key: playwright-browsers-${{ matrix.runner }}-${{ steps.playwright-version.outputs.version }}
- name: Install browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: |
npx playwright install --with-deps chromium
npx playwright install --with-deps firefox
- name: Install WebKit # caching not possible, external shared libraries required
if: ${{ matrix.runner == 'macos-latest' }} # do not install on ubuntu, since the X25519 WebCrypto implementation has issues
run: npx playwright install --with-deps webkit
- name: Run browser tests
run: npm run test-browser:ci -- --static-logging
- name: Run browser tests (lightweight) # overwrite test/lib
run: |
npm run build-test --lightweight
npm run test-browser:ci -- --static-logging
test-browsers-compatibility:
name: Browsers (older, on Browserstack)
runs-on: ubuntu-latest
needs: test-browsers-latest
env: # credentials need hardcoding for now since Github secrets aren't accessible on pull requests from forks
BROWSERSTACK_USERNAME: openpgpjs_PlY4Uq885CQ
BROWSERSTACK_ACCESS_KEY: VjgBVRMxNVBj7SjJFiau
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Generate self-signed HTTPS certificates for web-test-runner server
uses: kofemann/action-create-certificate@v0.0.4
with:
hostcert: '127.0.0.1.pem'
hostkey: '127.0.0.1-key.pem'
cachain: 'ca-chain.pem'
- name: Adjust HTTPS certificates permissions
run: sudo chown runner:docker *.pem
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Retrieve cached dist folder
uses: actions/cache/restore@v4
id: cache-full
with:
path: |
dist
test/lib
key: cache-${{ github.sha }}
- name: Wait for other Browserstack tests to finish
uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 30
abort-after-seconds: 900
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run browserstack tests
run: npm run test-browserstack -- --static-logging
- name: Run browserstack tests (lightweight) # overwrite test/lib
run: |
npm run build-test --lightweight
npm run test-browserstack -- --static-logging
env:
LIGHTWEIGHT: true
types:
name: Type definitions
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci --ignore-scripts # TS
- name: Retrieve cached folders
uses: actions/cache/restore@v4
id: cache-full
with:
path: |
dist
test/lib
key: cache-${{ github.sha }}
- run: npm run test-type-definitions
lint:
name: ESLint
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci --ignore-scripts # linter
- name: Retrieve cached folders
uses: actions/cache/restore@v4
id: cache-full
with:
path: |
dist
test/lib
key: cache-${{ github.sha }}
- run: npm run lint

4
.gitignore vendored
View File

@ -1,8 +1,8 @@
build/
.DS_Store .DS_Store
node_modules/ node_modules/
npm* npm*
test/lib/ test/lib/
test/typescript/definitions.js
dist/ dist/
openpgp.store/ openpgp.store/
doc/ coverage

17
.jsdocrc.cjs Normal file
View File

@ -0,0 +1,17 @@
const pkg = require('./package.json');
module.exports = {
plugins: ['plugins/markdown'],
markdown: {
idInHeadings: true
},
templates: {
default: {
includeDate: false,
outputSourceFiles: false,
externalSourceLinks: {
urlPrefix: `${pkg.repository.url}/blob/v${pkg.version}/src/`
}
}
}
};

6
.mocharc.json Normal file
View File

@ -0,0 +1,6 @@
{
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}

View File

@ -1,5 +0,0 @@
language: node_js
node_js:
- "0.10"
before_install:
- npm install -g grunt-cli

View File

@ -1,186 +0,0 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
openpgp: {
files: {
'dist/openpgp.js': [ './src/index.js' ]
},
options: {
standalone: 'openpgp',
external: [ 'crypto', 'node-localstorage' ]
}
},
openpgp_debug: {
files: {
'dist/openpgp_debug.js': [ './src/index.js' ]
},
options: {
debug: true,
standalone: 'openpgp',
external: [ 'crypto', 'node-localstorage' ]
}
},
worker: {
files: {
'dist/openpgp.worker.js': [ './src/worker/worker.js' ]
}
},
worker_min: {
files: {
'dist/openpgp.worker.min.js': [ './src/worker/worker.js' ]
}
},
unittests: {
files: {
'test/lib/unittests-bundle.js': [ './test/unittests.js' ]
},
options: {
external: [ 'openpgp', 'crypto', 'node-localstorage' ]
}
}
},
replace: {
openpgp: {
src: ['dist/openpgp.js'],
dest: ['dist/openpgp.js'],
replacements: [{
from: /OpenPGP.js VERSION/g,
to: 'OpenPGP.js v<%= pkg.version %>'
}]
},
openpgp_debug: {
src: ['dist/openpgp_debug.js'],
dest: ['dist/openpgp_debug.js'],
replacements: [{
from: /OpenPGP.js VERSION/g,
to: 'OpenPGP.js v<%= pkg.version %>'
}]
},
worker_min: {
src: ['dist/openpgp.worker.min.js'],
dest: ['dist/openpgp.worker.min.js'],
replacements: [{
from: "importScripts('openpgp.js')",
to: "importScripts('openpgp.min.js')"
}]
}
},
uglify: {
openpgp: {
files: {
'dist/openpgp.min.js' : [ 'dist/openpgp.js' ],
'dist/openpgp.worker.min.js' : [ 'dist/openpgp.worker.min.js' ]
}
},
options: {
banner: '/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */'
}
},
jsbeautifier: {
files: ['src/**/*.js'],
options: {
indent_size: 2,
preserve_newlines: true,
keep_array_indentation: false,
keep_function_indentation: false,
wrap_line_length: 120
}
},
jshint: {
all: ['src/**/*.js']
},
jsdoc: {
dist: {
src: ['README.md', 'src'],
options: {
destination: 'doc',
recurse: true,
template: 'jsdoc.template'
}
}
},
mochaTest: {
unittests: {
options: {
reporter: 'spec'
},
src: [ 'test/unittests.js' ]
}
},
copy: {
npm: {
expand: true,
flatten: true,
cwd: 'node_modules/',
src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js'],
dest: 'test/lib/'
}
},
clean: ['dist/'],
connect: {
dev: {
options: {
port: 8588,
base: '.',
keepalive: true
}
}
}
});
// Load the plugin(s)
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', 'Build OpenPGP.js', function() {
grunt.task.run(['clean', 'browserify', 'replace', 'uglify', 'npm_pack']);
//TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun
grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.');
});
grunt.registerTask('documentation', ['jsdoc']);
// Alias the `mocha_phantomjs` task to run `mocha-phantomjs`
grunt.registerTask('mocha_phantomjs', 'mocha-phantomjs', function () {
var done = this.async();
var mocha = require('child_process').exec('node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/unittests.html', function (err) {
done(err);
});
mocha.stdout.pipe(process.stdout);
mocha.stderr.pipe(process.stderr);
});
// Alias the `npm_pack` task to run `npm pack`
grunt.registerTask('npm_pack', 'npm pack', function () {
var done = this.async();
var npm = require('child_process').exec('npm pack ../', { cwd: 'dist'}, function (err, stdout) {
var package = stdout;
if (err === null) {
var install = require('child_process').exec('npm install dist/' + package, function (err) {
done(err);
});
install.stdout.pipe(process.stdout);
install.stderr.pipe(process.stderr);
} else {
done(err);
}
});
npm.stdout.pipe(process.stdout);
npm.stderr.pipe(process.stderr);
});
// Test/Dev tasks
grunt.registerTask('test', ['copy', 'mochaTest', 'mocha_phantomjs']);
};

615
LICENSE
View File

@ -1,502 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999 Version 3, 29 June 2007
Copyright (C) 1991, 1999 Free Software Foundation, Inc. Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
The licenses for most software are designed to take away your 0. Additional Definitions.
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some As used herein, "this License" refers to version 3 of the GNU Lesser
specially designated software packages--typically libraries--of the General Public License, and the "GNU GPL" refers to version 3 of the GNU
Free Software Foundation and other authors who decide to use it. You General Public License.
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use, "The Library" refers to a covered work governed by this License,
not price. Our General Public Licenses are designed to make sure that other than an Application or a Combined Work as defined below.
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid An "Application" is any work that makes use of an interface provided
distributors to deny you these rights or to ask you to surrender these by the Library, but which is not otherwise based on the Library.
rights. These restrictions translate to certain responsibilities for Defining a subclass of a class defined by the Library is deemed a mode
you if you distribute copies of the library or if you modify it. of using an interface provided by the Library.
For example, if you distribute copies of the library, whether gratis A "Combined Work" is a work produced by combining or linking an
or for a fee, you must give the recipients all the rights that we gave Application with the Library. The particular version of the Library
you. You must make sure that they, too, receive or can get the source with which the Combined Work was made is also called the "Linked
code. If you link other code with the library, you must provide Version".
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the The "Minimal Corresponding Source" for a Combined Work means the
library, and (2) we offer you this license, which gives you legal Corresponding Source for the Combined Work, excluding any source code
permission to copy, distribute and/or modify the library. for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
To protect each distributor, we want to make it very clear that The "Corresponding Application Code" for a Combined Work means the
there is no warranty for the free library. Also, if the library is object code and/or source code for the Application, including any data
modified by someone else and passed on, the recipients should know and utility programs needed for reproducing the Combined Work from the
that what they have is not the original version, so that the original Application, but excluding the System Libraries of the Combined Work.
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the 1. Exception to Section 3 of the GNU GPL.
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using You may convey a covered work under sections 3 and 4 of this License
a shared library, the combination of the two is legally speaking a without being bound by section 3 of the GNU GPL.
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it 2. Conveying Modified Versions.
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to If you modify a copy of the Library, and, in your modifications, a
encourage the widest possible use of a certain library, so that it becomes facility refers to a function or data to be supplied by an Application
a de-facto standard. To achieve this, non-free programs must be that uses the facility (other than as an argument passed when the
allowed to use the library. A more frequent case is that a free facility is invoked), then you may convey a copy of the modified
library does the same job as widely used non-free libraries. In this version:
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free a) under this License, provided that you make a good faith effort to
programs enables a greater number of people to use a large body of ensure that, in the event an Application does not supply the
free software. For example, permission to use the GNU C Library in function or data, the facility still operates, and performs
non-free programs enables many more people to use the whole GNU whatever part of its purpose remains meaningful, or
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the b) under the GNU GPL, with none of the additional permissions of
users' freedom, it does ensure that the user of a program that is this License applicable to that copy.
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and 3. Object Code Incorporating Material from Library Header Files.
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other The object code form of an Application may incorporate material from
program which contains a notice placed by the copyright holder or a header file that is part of the Library. You may convey such object
other authorized party saying it may be distributed under the terms of code under terms of your choice, provided that, if the incorporated
this Lesser General Public License (also called "this License"). material is not limited to numerical parameters, data structure
Each licensee is addressed as "you". layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
A "library" means a collection of software functions and/or data a) Give prominent notice with each copy of the object code that the
prepared so as to be conveniently linked with application programs Library is used in it and that the Library and its use are
(which use some of those functions and data) to form executables. covered by this License.
The "Library", below, refers to any such software library or work b) Accompany the object code with a copy of the GNU GPL and this license
which has been distributed under these terms. A "work based on the document.
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for 4. Combined Works.
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not You may convey a Combined Work under terms of your choice that,
covered by this License; they are outside its scope. The act of taken together, effectively do not restrict modification of the
running a program using the Library is not restricted, and output from portions of the Library contained in the Combined Work and reverse
such a program is covered only if its contents constitute a work based engineering for debugging such modifications, if you also do each of
on the Library (independent of the use of the Library in a tool for the following:
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's a) Give prominent notice with each copy of the Combined Work that
complete source code as you receive it, in any medium, provided that the Library is used in it and that the Library and its use are
you conspicuously and appropriately publish on each copy an covered by this License.
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any b) Accompany the Combined Work with a copy of the GNU GPL and this license
warranty; and distribute a copy of this License along with the document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library. Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

692
README.md
View File

@ -1,77 +1,677 @@
OpenPGP.js OpenPGP.js [![Join the chat on Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/openpgpjs/openpgpjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
========== ==========
[OpenPGP.js](http://openpgpjs.org/) is a Javascript implementation of the OpenPGP protocol. This is defined in [RFC 4880](http://tools.ietf.org/html/rfc4880). [OpenPGP.js](https://openpgpjs.org/) is a JavaScript implementation of the OpenPGP protocol. It implements [RFC 9580](https://datatracker.ietf.org/doc/rfc9580/) (superseding [RFC 4880](https://tools.ietf.org/html/rfc4880) and [RFC 4880bis](https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-10)).
[![Build Status](https://secure.travis-ci.org/openpgpjs/openpgpjs.png?branch=master,v0.1.x)](http://travis-ci.org/openpgpjs/openpgpjs) **Table of Contents**
### Node support - [OpenPGP.js](#openpgpjs)
- [Platform Support](#platform-support)
- [Performance](#performance)
- [Getting started](#getting-started)
- [Node.js](#nodejs)
- [Deno (experimental)](#deno-experimental)
- [Browser (webpack)](#browser-webpack)
- [Browser (plain files)](#browser-plain-files)
- [Examples](#examples)
- [Encrypt and decrypt *Uint8Array* data with a password](#encrypt-and-decrypt-uint8array-data-with-a-password)
- [Encrypt and decrypt *String* data with PGP keys](#encrypt-and-decrypt-string-data-with-pgp-keys)
- [Encrypt symmetrically with compression](#encrypt-symmetrically-with-compression)
- [Streaming encrypt *Uint8Array* data with a password](#streaming-encrypt-uint8array-data-with-a-password)
- [Streaming encrypt and decrypt *String* data with PGP keys](#streaming-encrypt-and-decrypt-string-data-with-pgp-keys)
- [Generate new key pair](#generate-new-key-pair)
- [Revoke a key](#revoke-a-key)
- [Sign and verify cleartext messages](#sign-and-verify-cleartext-messages)
- [Create and verify *detached* signatures](#create-and-verify-detached-signatures)
- [Streaming sign and verify *Uint8Array* data](#streaming-sign-and-verify-uint8array-data)
- [Documentation](#documentation)
- [Security Audit](#security-audit)
- [Security recommendations](#security-recommendations)
- [Development](#development)
- [How do I get involved?](#how-do-i-get-involved)
- [License](#license)
For server side use, install via npm: ### Platform Support
npm install openpgp * The `dist/openpgp.min.js` (or `.mjs`) bundle works with recent versions of Chrome, Firefox, Edge and Safari 14+.
* The `dist/node/openpgp.min.mjs` (or `.cjs`) bundle works in Node.js v18+: it is used by default when you `import ... from 'openpgp'` (or `require('openpgp')`, respectively).
* Support for the [Web Cryptography API](https://w3c.github.io/webcrypto/)'s `SubtleCrypto` is required.
* In browsers, `SubtleCrypto` is only available in [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).
* In supported versions of Node.js, `SubtleCrypto` is always available.
* Support for the [Web Streams API](https://streams.spec.whatwg.org/) is required.
* In browsers: the latest versions of Chrome, Firefox, Edge and Safari support Streams, including `TransformStream`s.
These are needed if you use the library with stream inputs.
In previous versions of OpenPGP.js, Web Streams were automatically polyfilled by the library,
but from v6 this task is left up to the library user, due to the more extensive browser support, and the
polyfilling side-effects. If you're working with [older browsers versions which do not implement e.g. TransformStreams](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream#browser_compatibility), you can manually
load the [Web Streams polyfill](https://github.com/MattiasBuelens/web-streams-polyfills).
Please note that when you load the polyfills, the global `ReadableStream` property (if it exists) gets overwritten with the polyfill version.
In some edge cases, you might need to use the native
`ReadableStream` (for example when using it to create a `Response`
object), in which case you should store a reference to it before loading
the polyfills. There is also the [web-streams-adapter](https://github.com/MattiasBuelens/web-streams-adapter)
library to convert back and forth between them.
* In Node.js: OpenPGP.js v6 no longer supports native Node `Readable` streams in inputs, and instead expects (and outputs) [Node's Web Streams](https://nodejs.org/api/webstreams.html#class-readablestream). [Node v17+ includes utilities to convert from and to Web Streams](https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options).
### Performance
* Version 3.0.0 of the library introduced support for public-key cryptography using [elliptic curves](https://wiki.gnupg.org/ECC). We use native implementations on browsers and Node.js when available. Compared to RSA, elliptic curve cryptography provides stronger security per bits of key, which allows for much faster operations. Currently the following curves are supported:
| Curve | Encryption | Signature | NodeCrypto | WebCrypto | Constant-Time |
|:---------------:|:----------:|:---------:|:----------:|:---------:|:-----------------:|
| curve25519 | ECDH | N/A | No | No | Algorithmically |
| ed25519 | N/A | EdDSA | No | Yes* | If native** |
| nistP256 | ECDH | ECDSA | Yes* | Yes* | If native** |
| nistP384 | ECDH | ECDSA | Yes* | Yes* | If native** |
| nistP521 | ECDH | ECDSA | Yes* | Yes* | If native** |
| brainpoolP256r1 | ECDH | ECDSA | Yes* | No | If native** |
| brainpoolP384r1 | ECDH | ECDSA | Yes* | No | If native** |
| brainpoolP512r1 | ECDH | ECDSA | Yes* | No | If native** |
| secp256k1 | ECDH | ECDSA | Yes* | No | If native** |
\* when available
\** these curves are only constant-time if the underlying native implementation is available and constant-time
* The platform's [native Web Crypto API](https://w3c.github.io/webcrypto/) is used for performance. On Node.js the native [crypto module](https://nodejs.org/api/crypto.html#crypto_crypto) is also used, in cases where it offers additional functionality.
* The library implements authenticated encryption (AEAD) as per [RFC 9580](https://datatracker.ietf.org/doc/rfc9580/) using AES-GCM, OCB, or EAX. This makes symmetric encryption faster on platforms with native implementations. However, since the specification is very recent and other OpenPGP implementations are in the process of adopting it, the feature is currently behind a flag. **Note: activating this setting can break compatibility with other OpenPGP implementations which have yet to implement the feature.** You can enable it by setting `openpgp.config.aeadProtect = true`.
Note that this setting has a different effect from the one in OpenPGP.js v5, which implemented support for a provisional version of AEAD from [RFC 4880bis](https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-10), which was modified in RFC 9580.
You can change the AEAD mode by setting one of the following options:
```
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.gcm; // Default, native in WebCrypto and Node.js
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.ocb; // Non-native, but supported across RFC 9580 implementations
openpgp.config.preferredAEADAlgorithm = openpgp.enums.aead.eax; // Native in Node.js
```
### Getting started
#### Node.js
Install OpenPGP.js using npm and save it in your dependencies:
```sh
npm install --save openpgp
```
And import it as an ES module, from a .mjs file:
```js
import * as openpgp from 'openpgp';
```
Or as a CommonJS module:
```js
const openpgp = require('openpgp');
```
#### Deno (experimental)
Import as an ES6 module, using /dist/openpgp.mjs.
```js
import * as openpgp from './openpgpjs/dist/openpgp.mjs';
```
#### Browser (webpack)
Install OpenPGP.js using npm and save it in your devDependencies:
```sh
npm install --save-dev openpgp
```
And import it as an ES6 module:
```js
import * as openpgp from 'openpgp';
```
You can also only import the functions you need, as follows:
```js
import { readMessage, decrypt } from 'openpgp';
```
Or, if you want to use the lightweight build (which is smaller, and lazily loads non-default curves on demand):
```js
import * as openpgp from 'openpgp/lightweight';
```
To test whether the lazy loading works, try to generate a key with a non-standard curve:
```js
import { generateKey } from 'openpgp/lightweight';
await generateKey({ curve: 'brainpoolP512r1', userIDs: [{ name: 'Test', email: 'test@test.com' }] });
```
For more examples of how to generate a key, see [Generate new key pair](#generate-new-key-pair). It is recommended to use `curve25519` instead of `brainpoolP512r1` by default.
#### Browser (plain files)
Grab `openpgp.min.js` from [unpkg.com/openpgp/dist](https://unpkg.com/openpgp/dist/), and load it in a script tag:
```html
<script src="openpgp.min.js"></script>
```
Or, to load OpenPGP.js as an ES6 module, grab `openpgp.min.mjs` from [unpkg.com/openpgp/dist](https://unpkg.com/openpgp/dist/), and import it as follows:
```html
<script type="module">
import * as openpgp from './openpgp.min.mjs';
</script>
```
To offload cryptographic operations off the main thread, you can implement a Web Worker in your application and load OpenPGP.js from there. For an example Worker implementation, see `test/worker/worker_example.js`.
#### TypeScript
Since TS is not fully integrated in the library, TS-only dependencies are currently listed as `devDependencies`, so to compile the project youll need to add `@openpgp/web-stream-tools` manually:
```sh
npm install --save-dev @openpgp/web-stream-tools
```
If you notice missing or incorrect type definitions, feel free to open a PR.
### Examples ### Examples
#### Encryption Here are some examples of how to use OpenPGP.js v6. For more elaborate examples and working code, please check out the [public API unit tests](https://github.com/openpgpjs/openpgpjs/blob/main/test/general/openpgp.js). If you're upgrading from v4 it might help to check out the [changelog](https://github.com/openpgpjs/openpgpjs/wiki/v6-Changelog) and [documentation](https://github.com/openpgpjs/openpgpjs#documentation).
var openpgp = require('openpgp');
var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
var publicKey = openpgp.key.readArmored(key);
var pgpMessage = openpgp.encryptMessage(publicKey.keys, 'Hello, World!');
#### Decryption #### Encrypt and decrypt *Uint8Array* data with a password
var openpgp = require('openpgp');
var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
var privateKey = openpgp.key.readArmored(key).keys[0];
privateKey.decrypt('passphrase');
var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
pgpMessage = openpgp.message.readArmored(pgpMessage);
var plaintext = openpgp.decryptMessage(privateKey, pgpMessage);
### Browser support Encryption will use the algorithm specified in config.preferredSymmetricAlgorithm (defaults to aes256), and decryption will use the algorithm used for encryption.
Fetch a minified build under [releases](https://github.com/openpgpjs/openpgpjs/releases). The library can be loaded via AMD/require.js or accessed globally via `window.openpgp`. ```js
(async () => {
const message = await openpgp.createMessage({ binary: new Uint8Array([0x01, 0x01, 0x01]) });
const encrypted = await openpgp.encrypt({
message, // input as Message object
passwords: ['secret stuff'], // multiple passwords possible
format: 'binary' // don't ASCII armor (for Uint8Array output)
});
console.log(encrypted); // Uint8Array
OpenPGP.js currently only fully supports browsers that implement `window.crypto.getRandomValues`. If you can help us support more browsers and runtimes, please chip in! const encryptedMessage = await openpgp.readMessage({
binaryMessage: encrypted // parse encrypted bytes
});
const { data: decrypted } = await openpgp.decrypt({
message: encryptedMessage,
passwords: ['secret stuff'], // decrypt with password
format: 'binary' // output as Uint8Array
});
console.log(decrypted); // Uint8Array([0x01, 0x01, 0x01])
})();
```
#### Encrypt and decrypt *String* data with PGP keys
Encryption will use the algorithm preferred by the public (encryption) key (defaults to aes256 for keys generated in OpenPGP.js), and decryption will use the algorithm used for encryption.
```js
const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp
(async () => {
// put keys in backtick (``) to avoid errors caused by spaces or tabs
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`;
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
const encrypted = await openpgp.encrypt({
message: await openpgp.createMessage({ text: 'Hello, World!' }), // input as Message object
encryptionKeys: publicKey,
signingKeys: privateKey // optional
});
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
const message = await openpgp.readMessage({
armoredMessage: encrypted // parse armored message
});
const { data: decrypted, signatures } = await openpgp.decrypt({
message,
verificationKeys: publicKey, // optional
decryptionKeys: privateKey
});
console.log(decrypted); // 'Hello, World!'
// check signature validity (signed messages only)
try {
await signatures[0].verified; // throws on invalid signature
console.log('Signature is valid');
} catch (e) {
throw new Error('Signature could not be verified: ' + e.message);
}
})();
```
Encrypt to multiple public keys:
```js
(async () => {
const publicKeysArmored = [
`-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`,
`-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`
];
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const plaintext = 'Hello, World!';
const publicKeys = await Promise.all(publicKeysArmored.map(armoredKey => openpgp.readKey({ armoredKey })));
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readKey({ armoredKey: privateKeyArmored }),
passphrase
});
const message = await openpgp.createMessage({ text: plaintext });
const encrypted = await openpgp.encrypt({
message, // input as Message object
encryptionKeys: publicKeys,
signingKeys: privateKey // optional
});
console.log(encrypted); // '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
})();
```
If you expect an encrypted message to be signed with one of the public keys you have, and do not want to trust the decrypted data otherwise, you can pass the decryption option `expectSigned = true`, so that the decryption operation will fail if no valid signature is found:
```js
(async () => {
// put keys in backtick (``) to avoid errors caused by spaces or tabs
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`;
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
const encryptedAndSignedMessage = `-----BEGIN PGP MESSAGE-----
...
-----END PGP MESSAGE-----`;
const message = await openpgp.readMessage({
armoredMessage: encryptedAndSignedMessage // parse armored message
});
// decryption will fail if all signatures are invalid or missing
const { data: decrypted, signatures } = await openpgp.decrypt({
message,
decryptionKeys: privateKey,
expectSigned: true,
verificationKeys: publicKey, // mandatory with expectSigned=true
});
console.log(decrypted); // 'Hello, World!'
})();
```
#### Encrypt symmetrically with compression
By default, `encrypt` will not use any compression when encrypting symmetrically only (i.e. when no `encryptionKeys` are given).
It's possible to change that behaviour by enabling compression through the config, either for the single encryption:
```js
(async () => {
const message = await openpgp.createMessage({ binary: new Uint8Array([0x01, 0x02, 0x03]) }); // or createMessage({ text: 'string' })
const encrypted = await openpgp.encrypt({
message,
passwords: ['secret stuff'], // multiple passwords possible
config: { preferredCompressionAlgorithm: openpgp.enums.compression.zlib } // compress the data with zlib
});
})();
```
or by changing the default global configuration:
```js
openpgp.config.preferredCompressionAlgorithm = openpgp.enums.compression.zlib
```
Where the value can be any of:
* `openpgp.enums.compression.zip`
* `openpgp.enums.compression.zlib`
* `openpgp.enums.compression.uncompressed` (default)
#### Streaming encrypt *Uint8Array* data with a password
```js
(async () => {
const readableStream = new ReadableStream({
start(controller) {
controller.enqueue(new Uint8Array([0x01, 0x02, 0x03]));
controller.close();
}
});
const message = await openpgp.createMessage({ binary: readableStream });
const encrypted = await openpgp.encrypt({
message, // input as Message object
passwords: ['secret stuff'], // multiple passwords possible
format: 'binary' // don't ASCII armor (for Uint8Array output)
});
console.log(encrypted); // raw encrypted packets as ReadableStream<Uint8Array>
// Either pipe the above stream somewhere, pass it to another function,
// or read it manually as follows:
for await (const chunk of encrypted) {
console.log('new chunk:', chunk); // Uint8Array
}
})();
```
For more information on using ReadableStreams (both in browsers and Node.js), see [the MDN Documentation on the
Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) .
#### Streaming encrypt and decrypt *String* data with PGP keys
```js
(async () => {
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`; // Public key
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // Encrypted private key
const passphrase = `yourPassphrase`; // Password that private key is encrypted with
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
const readableStream = new ReadableStream({
start(controller) {
controller.enqueue('Hello, world!');
controller.close();
}
});
const encrypted = await openpgp.encrypt({
message: await openpgp.createMessage({ text: readableStream }), // input as Message object
encryptionKeys: publicKey,
signingKeys: privateKey // optional
});
console.log(encrypted); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
const message = await openpgp.readMessage({
armoredMessage: encrypted // parse armored message
});
const decrypted = await openpgp.decrypt({
message,
verificationKeys: publicKey, // optional
decryptionKeys: privateKey
});
const chunks = [];
for await (const chunk of decrypted.data) {
chunks.push(chunk);
}
const plaintext = chunks.join('');
console.log(plaintext); // 'Hello, World!'
})();
```
#### Generate new key pair
ECC keys (smaller and faster to generate):
Possible values for `curve` are: `curve25519`, `ed25519`, `nistP256`, `nistP384`, `nistP521`,
`brainpoolP256r1`, `brainpoolP384r1`, `brainpoolP512r1`, and `secp256k1`.
Note that both the `curve25519` and `ed25519` options generate a primary key for signing using Ed25519
and a subkey for encryption using Curve25519.
```js
(async () => {
const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({
type: 'ecc', // Type of the key, defaults to ECC
curve: 'curve25519', // ECC curve name, defaults to curve25519
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
passphrase: 'super long and hard to guess secret', // protects the private key
format: 'armored' // output key format, defaults to 'armored' (other options: 'binary' or 'object')
});
console.log(privateKey); // '-----BEGIN PGP PRIVATE KEY BLOCK ... '
console.log(publicKey); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
console.log(revocationCertificate); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
})();
```
RSA keys (increased compatibility):
```js
(async () => {
const { privateKey, publicKey } = await openpgp.generateKey({
type: 'rsa', // Type of the key
rsaBits: 4096, // RSA key size (defaults to 4096 bits)
userIDs: [{ name: 'Jon Smith', email: 'jon@example.com' }], // you can pass multiple user IDs
passphrase: 'super long and hard to guess secret' // protects the private key
});
})();
```
#### Revoke a key
Using a revocation certificate:
```js
(async () => {
const { publicKey: revokedKeyArmored } = await openpgp.revokeKey({
key: await openpgp.readKey({ armoredKey: publicKeyArmored }),
revocationCertificate,
format: 'armored' // output armored keys
});
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
})();
```
Using the private key:
```js
(async () => {
const { publicKey: revokedKeyArmored } = await openpgp.revokeKey({
key: await openpgp.readKey({ armoredKey: privateKeyArmored }),
format: 'armored' // output armored keys
});
console.log(revokedKeyArmored); // '-----BEGIN PGP PUBLIC KEY BLOCK ... '
})();
```
#### Sign and verify cleartext messages
```js
(async () => {
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`;
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
const unsignedMessage = await openpgp.createCleartextMessage({ text: 'Hello, World!' });
const cleartextMessage = await openpgp.sign({
message: unsignedMessage, // CleartextMessage or Message object
signingKeys: privateKey
});
console.log(cleartextMessage); // '-----BEGIN PGP SIGNED MESSAGE ... END PGP SIGNATURE-----'
const signedMessage = await openpgp.readCleartextMessage({
cleartextMessage // parse armored message
});
const verificationResult = await openpgp.verify({
message: signedMessage,
verificationKeys: publicKey
});
const { verified, keyID } = verificationResult.signatures[0];
try {
await verified; // throws on invalid signature
console.log('Signed by key id ' + keyID.toHex());
} catch (e) {
throw new Error('Signature could not be verified: ' + e.message);
}
})();
```
#### Create and verify *detached* signatures
```js
(async () => {
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`;
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
const message = await openpgp.createMessage({ text: 'Hello, World!' });
const detachedSignature = await openpgp.sign({
message, // Message object
signingKeys: privateKey,
detached: true
});
console.log(detachedSignature);
const signature = await openpgp.readSignature({
armoredSignature: detachedSignature // parse detached signature
});
const verificationResult = await openpgp.verify({
message, // Message object
signature,
verificationKeys: publicKey
});
const { verified, keyID } = verificationResult.signatures[0];
try {
await verified; // throws on invalid signature
console.log('Signed by key id ' + keyID.toHex());
} catch (e) {
throw new Error('Signature could not be verified: ' + e.message);
}
})();
```
#### Streaming sign and verify *Uint8Array* data
```js
(async () => {
var readableStream = new ReadableStream({
start(controller) {
controller.enqueue(new Uint8Array([0x01, 0x02, 0x03]));
controller.close();
}
});
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`;
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
const message = await openpgp.createMessage({ binary: readableStream }); // or createMessage({ text: ReadableStream<String> })
const signatureArmored = await openpgp.sign({
message,
signingKeys: privateKey
});
console.log(signatureArmored); // ReadableStream containing '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----'
const verificationResult = await openpgp.verify({
message: await openpgp.readMessage({ armoredMessage: signatureArmored }), // parse armored signature
verificationKeys: await openpgp.readKey({ armoredKey: publicKeyArmored })
});
for await (const chunk of verificationResult.data) {}
// Note: you *have* to read `verificationResult.data` in some way or other,
// even if you don't need it, as that is what triggers the
// verification of the data.
try {
await verificationResult.signatures[0].verified; // throws on invalid signature
console.log('Signed by key id ' + verificationResult.signatures[0].keyID.toHex());
} catch (e) {
throw new Error('Signature could not be verified: ' + e.message);
}
})();
```
### Documentation
The full documentation is available at [openpgpjs.org](https://docs.openpgpjs.org/).
### Security Audit
To date the OpenPGP.js code base has undergone two complete security audits from [Cure53](https://cure53.de). The first audit's report has been published [here](https://github.com/openpgpjs/openpgpjs/wiki/Cure53-security-audit).
### Security recommendations ### Security recommendations
It should be noted that js crypto apps deployed via regular web hosting (a.k.a. [**host-based security**](https://www.schneier.com/blog/archives/2012/08/cryptocat.html)) provide users with less security than installable apps with auditable static versions. Installable apps can be deployed as a [Firefox](https://developer.mozilla.org/en-US/Marketplace/Publishing/Packaged_apps) or [Chrome](http://developer.chrome.com/apps/about_apps.html) packaged app. These apps are basically signed zip files and their runtimes typically enforce a strict [Content Security Policy (CSP)](http://www.html5rocks.com/en/tutorials/security/content-security-policy/) to protect users against [XSS](http://en.wikipedia.org/wiki/Cross-site_scripting). This [blogpost](http://tonyarcieri.com/whats-wrong-with-webcrypto) explains the trust model of the web quite well. It should be noted that js crypto apps deployed via regular web hosting (a.k.a. [**host-based security**](https://www.schneier.com/blog/archives/2012/08/cryptocat.html)) provide users with less security than installable apps with auditable static versions. Installable apps can be deployed as a [Firefox](https://developer.mozilla.org/en-US/Marketplace/Options/Packaged_apps) or [Chrome](https://developer.chrome.com/apps/about_apps.html) packaged app. These apps are basically signed zip files and their runtimes typically enforce a strict [Content Security Policy (CSP)](https://www.html5rocks.com/en/tutorials/security/content-security-policy/) to protect users against [XSS](https://en.wikipedia.org/wiki/Cross-site_scripting). This [blogpost](https://tankredhase.com/2014/04/13/heartbleed-and-javascript-crypto/) explains the trust model of the web quite well.
It is also recommended to set a strong passphrase that protects the user's private key on disk. It is also recommended to set a strong passphrase that protects the user's private key on disk.
### Development ### Development
To create your own build of the library, just run the following command after cloning the git repo. This will download all dependencies, run the tests and create a minifed bundle under `dist/openpgp.min.js` to use in your project: To create your own build of the library, just run the following command after cloning the git repo. This will download all dependencies, run the tests and create a minified bundle under `dist/openpgp.min.js` to use in your project:
npm install && npm test npm install && npm test
### Documentation For debugging browser errors, run the following command:
A jsdoc build of our code comments is available at [doc/index.html](http://openpgpjs.org/openpgpjs/doc/index.html). Public calls should generally be made through the OpenPGP object [doc/openpgp.html](http://openpgpjs.org/openpgpjs/doc/module-openpgp.html). npm run browsertest
### Mailing List
You can [sign up](http://list.openpgpjs.org/) for our mailing list and ask for help there. We've recently worked on getting our [archive up and running](http://www.mail-archive.com/list@openpgpjs.org/).
### How do I get involved? ### How do I get involved?
You want to help, great! Go ahead and fork our repo, make your changes and send us a pull request. You want to help, great! It's probably best to send us a message on [Gitter](https://gitter.im/openpgpjs/openpgpjs) before you start your undertaking, to make sure nobody else is working on it, and so we can discuss the best course of action. Other than that, just go ahead and fork our repo, make your changes and send us a pull request! :)
### License ### License
GNU Lesser General Public License (2.1). Please take a look at the [LICENSE](LICENSE) file for more information. [GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0.en.html) (3.0 or any later version). Please take a look at the [LICENSE](LICENSE) file for more information.
### Resources
Below is a collection of resources, many of these were projects that were in someway a precursor to the current OpenPGP.js project. If you'd like to add your link here, please do so in a pull request or email to the list.
* [http://www.hanewin.net/encrypt/](http://www.hanewin.net/encrypt/)
* [https://github.com/seancolyer/gmail-crypt](https://github.com/seancolyer/gmail-crypt)
* [https://github.com/mete0r/openpgp-js](https://github.com/mete0r/openpgp-js)
* [http://fitblip.github.com/JSPGP-Stuffs/](http://fitblip.github.com/JSPGP-Stuffs/)
* [http://qooxdoo.org/contrib/project/crypto](http://qooxdoo.org/contrib/project/crypto)
* [https://github.com/GPGTools/Mobile/wiki/Introduction](https://github.com/GPGTools/Mobile/wiki/Introduction)
* [http://gpg4browsers.recurity.com/](http://gpg4browsers.recurity.com/)

7
SECURITY.md Normal file
View File

@ -0,0 +1,7 @@
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
If you believe you have found a security vulnerability in OpenPGP.js, please report it via email to [security@openpgpjs.org](mailto:security@openpgpjs.org). If possible, encrypt your message with our PGP key: it can be downloaded automatically using [WKD](https://wiki.gnupg.org/WKD), or manually on [openpgpjs.org](https://openpgpjs.org/.well-known/openpgpkey/hu/t5s8ztdbon8yzntexy6oz5y48etqsnbb?l=security).
You should receive a response within 2 working days.

File diff suppressed because one or more lines are too long

986
docs/Argon2S2K.html Normal file

File diff suppressed because one or more lines are too long

1
docs/CNAME Normal file
View File

@ -0,0 +1 @@
docs.openpgpjs.org

1366
docs/CleartextMessage.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5397
docs/Key.html Normal file

File diff suppressed because one or more lines are too long

1590
docs/LiteralDataPacket.html Normal file

File diff suppressed because one or more lines are too long

348
docs/MarkerPacket.html Normal file

File diff suppressed because one or more lines are too long

4870
docs/Message.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1283
docs/PacketList.html Normal file

File diff suppressed because one or more lines are too long

600
docs/PaddingPacket.html Normal file

File diff suppressed because one or more lines are too long

1893
docs/PrivateKey.html Normal file

File diff suppressed because one or more lines are too long

618
docs/PublicKey.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2472
docs/PublicKeyPacket.html Normal file

File diff suppressed because one or more lines are too long

2586
docs/PublicSubkeyPacket.html Normal file

File diff suppressed because one or more lines are too long

3852
docs/SecretKeyPacket.html Normal file

File diff suppressed because one or more lines are too long

3921
docs/SecretSubkeyPacket.html Normal file

File diff suppressed because one or more lines are too long

629
docs/Signature.html Normal file

File diff suppressed because one or more lines are too long

1848
docs/SignaturePacket.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

277
docs/TrustPacket.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

668
docs/UserIDPacket.html Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

11739
docs/global.html Normal file

File diff suppressed because one or more lines are too long

723
docs/index.html Normal file

File diff suppressed because one or more lines are too long

4015
docs/module-config.html Normal file

File diff suppressed because one or more lines are too long

184
docs/module-crypto.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5702
docs/module-enums.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

92
docs/module-key_User.html Normal file

File diff suppressed because one or more lines are too long

2891
docs/module-key_helper.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More