@protontech/openpgp 4.10.6 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +311 -239
- package/dist/lightweight/bn.interface.min.mjs +3 -0
- package/dist/lightweight/bn.interface.min.mjs.map +1 -0
- package/dist/lightweight/bn.interface.mjs +340 -0
- package/dist/lightweight/bn.min.mjs +3 -0
- package/dist/lightweight/bn.min.mjs.map +1 -0
- package/dist/lightweight/bn.mjs +3434 -0
- package/dist/lightweight/elliptic.min.mjs +3 -0
- package/dist/lightweight/elliptic.min.mjs.map +1 -0
- package/dist/lightweight/elliptic.mjs +4313 -0
- package/dist/lightweight/openpgp.min.mjs +3 -0
- package/dist/lightweight/openpgp.min.mjs.map +1 -0
- package/dist/lightweight/openpgp.mjs +31379 -0
- package/dist/lightweight/ponyfill.es6.min.mjs +3 -0
- package/dist/lightweight/ponyfill.es6.min.mjs.map +1 -0
- package/dist/lightweight/ponyfill.es6.mjs +3831 -0
- package/dist/lightweight/web-streams-adapter.min.mjs +17 -0
- package/dist/lightweight/web-streams-adapter.min.mjs.map +1 -0
- package/dist/lightweight/web-streams-adapter.mjs +561 -0
- package/dist/node/openpgp.js +43947 -0
- package/dist/node/openpgp.min.js +17 -0
- package/dist/node/openpgp.min.js.map +1 -0
- package/dist/node/openpgp.min.mjs +17 -0
- package/dist/node/openpgp.min.mjs.map +1 -0
- package/dist/node/openpgp.mjs +43884 -0
- package/dist/openpgp.js +41082 -41563
- package/dist/openpgp.min.js +17 -2
- package/dist/openpgp.min.js.map +1 -0
- package/dist/openpgp.min.mjs +17 -0
- package/dist/openpgp.min.mjs.map +1 -0
- package/dist/openpgp.mjs +43872 -0
- package/lightweight/package.json +5 -0
- package/openpgp.d.ts +890 -0
- package/package.json +63 -57
- package/dist/compat/openpgp.js +0 -61067
- package/dist/compat/openpgp.min.js +0 -2
- package/dist/compat/openpgp.worker.js +0 -173
- package/dist/compat/openpgp.worker.min.js +0 -2
- package/dist/lightweight/elliptic.min.js +0 -5
- package/dist/lightweight/openpgp.js +0 -40024
- package/dist/lightweight/openpgp.min.js +0 -2
- package/dist/lightweight/openpgp.worker.js +0 -173
- package/dist/lightweight/openpgp.worker.min.js +0 -2
- package/dist/openpgp.worker.js +0 -173
- package/dist/openpgp.worker.min.js +0 -2
- package/src/cleartext.js +0 -220
- package/src/config/config.js +0 -224
- package/src/config/index.js +0 -7
- package/src/config/localStorage.js +0 -35
- package/src/crypto/aes_kw.js +0 -153
- package/src/crypto/cfb.js +0 -169
- package/src/crypto/cipher/aes.js +0 -27
- package/src/crypto/cipher/blowfish.js +0 -398
- package/src/crypto/cipher/cast5.js +0 -610
- package/src/crypto/cipher/des.js +0 -476
- package/src/crypto/cipher/index.js +0 -91
- package/src/crypto/cipher/twofish.js +0 -346
- package/src/crypto/cmac.js +0 -98
- package/src/crypto/crypto.js +0 -394
- package/src/crypto/eax.js +0 -172
- package/src/crypto/gcm.js +0 -141
- package/src/crypto/hash/index.js +0 -163
- package/src/crypto/hash/md5.js +0 -205
- package/src/crypto/index.js +0 -57
- package/src/crypto/ocb.js +0 -274
- package/src/crypto/pkcs1.js +0 -170
- package/src/crypto/pkcs5.js +0 -55
- package/src/crypto/public_key/dsa.js +0 -188
- package/src/crypto/public_key/elgamal.js +0 -137
- package/src/crypto/public_key/elliptic/curves.js +0 -385
- package/src/crypto/public_key/elliptic/ecdh.js +0 -414
- package/src/crypto/public_key/elliptic/ecdsa.js +0 -348
- package/src/crypto/public_key/elliptic/eddsa.js +0 -119
- package/src/crypto/public_key/elliptic/index.js +0 -34
- package/src/crypto/public_key/elliptic/indutnyKey.js +0 -85
- package/src/crypto/public_key/index.js +0 -28
- package/src/crypto/public_key/prime.js +0 -275
- package/src/crypto/public_key/rsa.js +0 -597
- package/src/crypto/random.js +0 -145
- package/src/crypto/signature.js +0 -137
- package/src/encoding/armor.js +0 -433
- package/src/encoding/base64.js +0 -96
- package/src/enums.js +0 -493
- package/src/hkp.js +0 -89
- package/src/index.js +0 -161
- package/src/key/factory.js +0 -326
- package/src/key/helper.js +0 -363
- package/src/key/index.js +0 -32
- package/src/key/key.js +0 -890
- package/src/key/subkey.js +0 -187
- package/src/key/user.js +0 -230
- package/src/keyring/index.js +0 -12
- package/src/keyring/keyring.js +0 -229
- package/src/keyring/localstore.js +0 -119
- package/src/lightweight_helper.js +0 -26
- package/src/message.js +0 -825
- package/src/openpgp.js +0 -717
- package/src/packet/all_packets.js +0 -116
- package/src/packet/clone.js +0 -189
- package/src/packet/compressed.js +0 -194
- package/src/packet/index.js +0 -20
- package/src/packet/literal.js +0 -168
- package/src/packet/marker.js +0 -62
- package/src/packet/one_pass_signature.js +0 -156
- package/src/packet/packet.js +0 -300
- package/src/packet/packetlist.js +0 -232
- package/src/packet/public_key.js +0 -280
- package/src/packet/public_key_encrypted_session_key.js +0 -156
- package/src/packet/public_subkey.js +0 -44
- package/src/packet/secret_key.js +0 -448
- package/src/packet/secret_subkey.js +0 -41
- package/src/packet/signature.js +0 -782
- package/src/packet/sym_encrypted_aead_protected.js +0 -189
- package/src/packet/sym_encrypted_integrity_protected.js +0 -139
- package/src/packet/sym_encrypted_session_key.js +0 -204
- package/src/packet/symmetrically_encrypted.js +0 -118
- package/src/packet/trust.js +0 -35
- package/src/packet/user_attribute.js +0 -94
- package/src/packet/userid.js +0 -87
- package/src/polyfills.js +0 -64
- package/src/signature.js +0 -73
- package/src/type/ecdh_symkey.js +0 -69
- package/src/type/kdf_params.js +0 -114
- package/src/type/keyid.js +0 -110
- package/src/type/mpi.js +0 -138
- package/src/type/oid.js +0 -110
- package/src/type/s2k.js +0 -203
- package/src/util.js +0 -836
- package/src/wkd.js +0 -88
- package/src/worker/async_proxy.js +0 -190
- package/src/worker/worker.js +0 -167
- package/test/crypto/aes_kw.js +0 -57
- package/test/crypto/cipher/aes.js +0 -86
- package/test/crypto/cipher/blowfish.js +0 -58
- package/test/crypto/cipher/cast5.js +0 -25
- package/test/crypto/cipher/des.js +0 -143
- package/test/crypto/cipher/index.js +0 -7
- package/test/crypto/cipher/twofish.js +0 -71
- package/test/crypto/crypto.js +0 -383
- package/test/crypto/eax.js +0 -150
- package/test/crypto/ecdh.js +0 -359
- package/test/crypto/elliptic.js +0 -251
- package/test/crypto/elliptic_data.js +0 -102
- package/test/crypto/hash/index.js +0 -5
- package/test/crypto/hash/md5.js +0 -16
- package/test/crypto/hash/ripemd.js +0 -14
- package/test/crypto/hash/sha.js +0 -20
- package/test/crypto/index.js +0 -14
- package/test/crypto/ocb.js +0 -183
- package/test/crypto/pkcs5.js +0 -39
- package/test/crypto/random.js +0 -79
- package/test/crypto/rsa.js +0 -180
- package/test/crypto/validate.js +0 -387
- package/test/general/armor.js +0 -408
- package/test/general/brainpool.js +0 -360
- package/test/general/decompression.js +0 -60
- package/test/general/ecc_nist.js +0 -115
- package/test/general/ecc_secp256k1.js +0 -242
- package/test/general/forwarding.js +0 -43
- package/test/general/hkp.js +0 -165
- package/test/general/index.js +0 -20
- package/test/general/key.js +0 -3402
- package/test/general/keyring.js +0 -336
- package/test/general/oid.js +0 -39
- package/test/general/openpgp.js +0 -2542
- package/test/general/packet.js +0 -937
- package/test/general/signature.js +0 -1665
- package/test/general/streaming.js +0 -944
- package/test/general/testInputs.js +0 -18
- package/test/general/util.js +0 -183
- package/test/general/wkd.js +0 -48
- package/test/general/x25519.js +0 -556
- package/test/unittests.js +0 -64
package/test/general/x25519.js
DELETED
|
@@ -1,556 +0,0 @@
|
|
|
1
|
-
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
|
|
2
|
-
|
|
3
|
-
const elliptic = openpgp.crypto.publicKey.elliptic;
|
|
4
|
-
|
|
5
|
-
const chai = require('chai');
|
|
6
|
-
chai.use(require('chai-as-promised'));
|
|
7
|
-
|
|
8
|
-
const { expect } = chai;
|
|
9
|
-
const input = require('./testInputs');
|
|
10
|
-
|
|
11
|
-
(openpgp.config.ci ? describe.skip : describe)('X25519 Cryptography', function () {
|
|
12
|
-
const data = {
|
|
13
|
-
light: {
|
|
14
|
-
id: '1ecdf026c0245830',
|
|
15
|
-
pass: 'sun',
|
|
16
|
-
pub: [
|
|
17
|
-
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
|
18
|
-
'',
|
|
19
|
-
'mDMEWkN+5BYJKwYBBAHaRw8BAQdAIGqj23Kp273IPkgjwA7ue5MDIRAfWLYRqnFy',
|
|
20
|
-
'c2AFMcC0EUxpZ2h0IDxsaWdodEBzdW4+iJAEExYIADgWIQSGS0GuVELT3Rs0woce',
|
|
21
|
-
'zfAmwCRYMAUCWkN+5AIbAwULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRAezfAm',
|
|
22
|
-
'wCRYMLteAQCFZcl8kBxCH86wmqpc2+KtEA8l/hsfh7jd+JWuyFuuRAD7BOix8Vo1',
|
|
23
|
-
'P/hv8qUYwSn3IRXPeGXucoWVoKGgxRd+zAO4OARaQ37kEgorBgEEAZdVAQUBAQdA',
|
|
24
|
-
'L1KkHCFxtK1CgvZlInT/y6OQeCfXiYzd/i452t2ZR2ADAQgHiHgEGBYIACAWIQSG',
|
|
25
|
-
'S0GuVELT3Rs0wocezfAmwCRYMAUCWkN+5AIbDAAKCRAezfAmwCRYMJ71AQDmoQTg',
|
|
26
|
-
'36pfjrl82srS6XPRJxl3r/6lpWGaNij0VptB2wEA2V10ifOhnwILCw1qBle6On7a',
|
|
27
|
-
'Ba257lrFM+cOSMaEsgo=',
|
|
28
|
-
'=D8HS',
|
|
29
|
-
'-----END PGP PUBLIC KEY BLOCK-----'
|
|
30
|
-
].join('\n'),
|
|
31
|
-
priv: [
|
|
32
|
-
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
|
33
|
-
'',
|
|
34
|
-
'lIYEWkN+5BYJKwYBBAHaRw8BAQdAIGqj23Kp273IPkgjwA7ue5MDIRAfWLYRqnFy',
|
|
35
|
-
'c2AFMcD+BwMCeaL+cNXzgI7uJQ7HBv53TAXO3y5uyJQMonkFtQtldL8YDbNP3pbd',
|
|
36
|
-
'3zzo9fxU12bWAJyFwBlBWJqkrxZN+0jt0ElsG3kp+V67MESJkrRhKrQRTGlnaHQg',
|
|
37
|
-
'PGxpZ2h0QHN1bj6IkAQTFggAOBYhBIZLQa5UQtPdGzTChx7N8CbAJFgwBQJaQ37k',
|
|
38
|
-
'AhsDBQsJCAcCBhUICQoLAgQWAgMBAh4BAheAAAoJEB7N8CbAJFgwu14BAIVlyXyQ',
|
|
39
|
-
'HEIfzrCaqlzb4q0QDyX+Gx+HuN34la7IW65EAPsE6LHxWjU/+G/ypRjBKfchFc94',
|
|
40
|
-
'Ze5yhZWgoaDFF37MA5yLBFpDfuQSCisGAQQBl1UBBQEBB0AvUqQcIXG0rUKC9mUi',
|
|
41
|
-
'dP/Lo5B4J9eJjN3+Ljna3ZlHYAMBCAf+BwMCvyW2D5Yx6dbujE3yHi1XQ9MbhOY5',
|
|
42
|
-
'XRFFgYIUYzzi1qmaL+8Gr9zODsUdeO60XHnMXOmqVa6/sdx32TWo5s3sgS19kRUM',
|
|
43
|
-
'D+pbxS/aZnxvrYh4BBgWCAAgFiEEhktBrlRC090bNMKHHs3wJsAkWDAFAlpDfuQC',
|
|
44
|
-
'GwwACgkQHs3wJsAkWDCe9QEA5qEE4N+qX465fNrK0ulz0ScZd6/+paVhmjYo9Fab',
|
|
45
|
-
'QdsBANlddInzoZ8CCwsNagZXujp+2gWtue5axTPnDkjGhLIK',
|
|
46
|
-
'=wo91',
|
|
47
|
-
'-----END PGP PRIVATE KEY BLOCK-----'
|
|
48
|
-
].join('\n'),
|
|
49
|
-
message: 'Hi, Light wrote this!\n',
|
|
50
|
-
message_signed: [
|
|
51
|
-
'-----BEGIN PGP SIGNED MESSAGE-----',
|
|
52
|
-
'Hash: SHA512',
|
|
53
|
-
'',
|
|
54
|
-
'Hi, Light wrote this!',
|
|
55
|
-
'',
|
|
56
|
-
'-----BEGIN PGP SIGNATURE-----',
|
|
57
|
-
'Version: OpenPGP.js v3.1.0',
|
|
58
|
-
'Comment: https://openpgpjs.org',
|
|
59
|
-
'',
|
|
60
|
-
'wl4EARYKABAFAltbFNAJEB7N8CbAJFgwAAAhcAEA5b2MIQNxQYj8TAMyuhZJ',
|
|
61
|
-
'UvxEgPS8DU59Kxw5F9+oldQBAN4mA+SOJyTxEx4oyyLh+8RD27dqyeDpmXju',
|
|
62
|
-
'xqMRN8oE',
|
|
63
|
-
'=siSU',
|
|
64
|
-
'-----END PGP SIGNATURE-----'
|
|
65
|
-
].join('\n')
|
|
66
|
-
},
|
|
67
|
-
night: {
|
|
68
|
-
id: 'f25e5f24bb372cfa',
|
|
69
|
-
pass: 'moon',
|
|
70
|
-
pub: [
|
|
71
|
-
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
|
72
|
-
'',
|
|
73
|
-
'mDMEWkN/RRYJKwYBBAHaRw8BAQdAM359sYg+LtcQo9G+mzMwxiu6wgY7UTVyip+V',
|
|
74
|
-
'y8CWMhy0Ek5pZ2h0IDxuaWdodEBtb29uPoiQBBMWCAA4FiEEdracm9388E/nI0Df',
|
|
75
|
-
'8l5fJLs3LPoFAlpDf0UCGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQ8l5f',
|
|
76
|
-
'JLs3LPqoFAD+IkES10NVLoInYf6rMcxKY2/Nn+Dg4aYtdvphY8hY0b0A/jl34YEe',
|
|
77
|
-
'cZAQvGWueGa5X2sCJvR1WZEMUWjW9cfR0TIHuDgEWkN/RRIKKwYBBAGXVQEFAQEH',
|
|
78
|
-
'QCeuETdjFsEorruYHXmASKo7VNVgm29EZeA4bgbX1gsVAwEIB4h4BBgWCAAgFiEE',
|
|
79
|
-
'dracm9388E/nI0Df8l5fJLs3LPoFAlpDf0UCGwwACgkQ8l5fJLs3LPojTgEApyg3',
|
|
80
|
-
'Gd7R77zhC8mkSDIssegrFCoLqDgNYOSISgixUdgA/j7tIDGF45C9JC4LQsjfKY9W',
|
|
81
|
-
'Td0I97hWRfub9tYo0P8K',
|
|
82
|
-
'=nbhM',
|
|
83
|
-
'-----END PGP PUBLIC KEY BLOCK-----'
|
|
84
|
-
].join('\n'),
|
|
85
|
-
priv: [
|
|
86
|
-
'-----BEGIN PGP PRIVATE KEY BLOCK-----',
|
|
87
|
-
'',
|
|
88
|
-
'lIYEWkN/RRYJKwYBBAHaRw8BAQdAM359sYg+LtcQo9G+mzMwxiu6wgY7UTVyip+V',
|
|
89
|
-
'y8CWMhz+BwMCxwCG2X+GJp7uQHSoj4fmvArR8d9hzyKBKDX84QsC1nCqMNRARz1v',
|
|
90
|
-
'aSqXfCt4gLzR3sZh4yS0cDUB0UdDfFhh3XiG2j8zRJ3cKkXdV3GcSbQSTmlnaHQg',
|
|
91
|
-
'PG5pZ2h0QG1vb24+iJAEExYIADgWIQR2tpyb3fzwT+cjQN/yXl8kuzcs+gUCWkN/',
|
|
92
|
-
'RQIbAwULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRDyXl8kuzcs+qgUAP4iQRLX',
|
|
93
|
-
'Q1Uugidh/qsxzEpjb82f4ODhpi12+mFjyFjRvQD+OXfhgR5xkBC8Za54ZrlfawIm',
|
|
94
|
-
'9HVZkQxRaNb1x9HRMgeciwRaQ39FEgorBgEEAZdVAQUBAQdAJ64RN2MWwSiuu5gd',
|
|
95
|
-
'eYBIqjtU1WCbb0Rl4DhuBtfWCxUDAQgH/gcDAoeG6mA2BitC7sbt5erYFzAndJx3',
|
|
96
|
-
'fOBDIo9MF2xo/JX1OrL5Z9Fro1UP+A3P+YyZQ3W/PMMVFArfnyiEoJAmQOkashgd',
|
|
97
|
-
'CocKYaKUNrgbYl2IeAQYFggAIBYhBHa2nJvd/PBP5yNA3/JeXyS7Nyz6BQJaQ39F',
|
|
98
|
-
'AhsMAAoJEPJeXyS7Nyz6I04BAKcoNxne0e+84QvJpEgyLLHoKxQqC6g4DWDkiEoI',
|
|
99
|
-
'sVHYAP4+7SAxheOQvSQuC0LI3ymPVk3dCPe4VkX7m/bWKND/Cg==',
|
|
100
|
-
'=NDSU',
|
|
101
|
-
'-----END PGP PRIVATE KEY BLOCK-----'
|
|
102
|
-
].join('\n'),
|
|
103
|
-
message: 'Oh hi, this is a private message from Light to Night!\n',
|
|
104
|
-
message_encrypted: [
|
|
105
|
-
'-----BEGIN PGP MESSAGE-----',
|
|
106
|
-
'',
|
|
107
|
-
'hF4DzfwiGcVT05ISAQdAetSWotgG0+MTEfyKvagrHAeGw0Denjph+Mu2KcpAajIw',
|
|
108
|
-
'kE398hrqnc6qYFdf3p761kzvgjX0auua8L2WFlhAzGh1ULodxHVLmvxwiId4JwHq',
|
|
109
|
-
'0sAzAaM+Vn5hfDM5799p2DpPK8635LN0UvtlOqGIdaNfu5DgfoherMSb3zlBa4YF',
|
|
110
|
-
'WJG1Fa9glfWTOlMNKKoFl4LUh1BUF4TbqUv3a0BR6GcDy6zSp4KRl3NIq22fUD/F',
|
|
111
|
-
'BZWuhPRhnsvDAoBTbvlgjyuActYhtXU5srMAEh4UeVvKyU8xImDfLgJReU4500JU',
|
|
112
|
-
'VjZkMXTileVhAprvE5KCCDWi6YWzV+SSpn+VhtnShAfoF870GI+DOnvFwEnhQlol',
|
|
113
|
-
'JRZdfjq5haoEjWTuqSIS+O40AgmQYPIjnO5ALehFuWTHKLDFVv4EDqx7MatXZidz',
|
|
114
|
-
'drpAMWGi',
|
|
115
|
-
'=erKa',
|
|
116
|
-
'-----END PGP MESSAGE-----'
|
|
117
|
-
].join('\n')
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
async function load_pub_key(name) {
|
|
122
|
-
if (data[name].pub_key) {
|
|
123
|
-
return data[name].pub_key;
|
|
124
|
-
}
|
|
125
|
-
const pub = await openpgp.key.readArmored(data[name].pub);
|
|
126
|
-
expect(pub).to.exist;
|
|
127
|
-
expect(pub.err).to.not.exist;
|
|
128
|
-
expect(pub.keys).to.have.length(1);
|
|
129
|
-
expect(pub.keys[0].getKeyId().toHex()).to.equal(data[name].id);
|
|
130
|
-
data[name].pub_key = pub.keys[0];
|
|
131
|
-
return data[name].pub_key;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async function load_priv_key(name) {
|
|
135
|
-
if (data[name].priv_key) {
|
|
136
|
-
return data[name].priv_key;
|
|
137
|
-
}
|
|
138
|
-
const pk = await openpgp.key.readArmored(data[name].priv);
|
|
139
|
-
expect(pk).to.exist;
|
|
140
|
-
expect(pk.err).to.not.exist;
|
|
141
|
-
expect(pk.keys).to.have.length(1);
|
|
142
|
-
expect(pk.keys[0].getKeyId().toHex()).to.equal(data[name].id);
|
|
143
|
-
expect(await pk.keys[0].decrypt(data[name].pass)).to.be.true;
|
|
144
|
-
data[name].priv_key = pk.keys[0];
|
|
145
|
-
return data[name].priv_key;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
it('Load public key', async function () {
|
|
149
|
-
await load_pub_key('light');
|
|
150
|
-
await load_pub_key('night');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// This test is slow because the keys are generated by GPG2, which
|
|
154
|
-
// by default chooses a larger number for S2K iterations than we do.
|
|
155
|
-
it('Load private key', async function () {
|
|
156
|
-
await load_priv_key('light');
|
|
157
|
-
await load_priv_key('night');
|
|
158
|
-
return true;
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('Verify clear signed message', async function () {
|
|
162
|
-
const name = 'light';
|
|
163
|
-
const pub = await load_pub_key(name);
|
|
164
|
-
const msg = await openpgp.cleartext.readArmored(data[name].message_signed);
|
|
165
|
-
return openpgp.verify({ publicKeys: [pub], message: msg }).then(function(result) {
|
|
166
|
-
expect(result).to.exist;
|
|
167
|
-
expect(result.data).to.equal(data[name].message);
|
|
168
|
-
expect(result.signatures).to.have.length(1);
|
|
169
|
-
expect(result.signatures[0].valid).to.be.true;
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('Sign message', async function () {
|
|
174
|
-
const name = 'light';
|
|
175
|
-
const randomData = input.createSomeMessage();
|
|
176
|
-
const priv = await load_priv_key(name);
|
|
177
|
-
const signed = await openpgp.sign({ privateKeys: [priv], message: openpgp.cleartext.fromText(randomData)});
|
|
178
|
-
const pub = await load_pub_key(name);
|
|
179
|
-
const msg = await openpgp.cleartext.readArmored(signed.data);
|
|
180
|
-
const result = await openpgp.verify({ publicKeys: [pub], message: msg});
|
|
181
|
-
|
|
182
|
-
expect(result).to.exist;
|
|
183
|
-
expect(result.data).to.equal(randomData.replace(/[ \t]+$/mg, ''));
|
|
184
|
-
expect(result.signatures).to.have.length(1);
|
|
185
|
-
expect(result.signatures[0].valid).to.be.true;
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('Decrypt and verify message', async function () {
|
|
189
|
-
const light = await load_pub_key('light');
|
|
190
|
-
const night = await load_priv_key('night');
|
|
191
|
-
const msg = await openpgp.message.readArmored(data.night.message_encrypted);
|
|
192
|
-
const result = await openpgp.decrypt({ privateKeys: night, publicKeys: [light], message: msg });
|
|
193
|
-
|
|
194
|
-
expect(result).to.exist;
|
|
195
|
-
expect(result.data).to.equal(data.night.message);
|
|
196
|
-
expect(result.signatures).to.have.length(1);
|
|
197
|
-
expect(result.signatures[0].valid).to.be.true;
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('Encrypt and sign message', async function () {
|
|
201
|
-
const nightPublic = await load_pub_key('night');
|
|
202
|
-
const lightPrivate = await load_priv_key('light');
|
|
203
|
-
const randomData = input.createSomeMessage();
|
|
204
|
-
const encrypted = await openpgp.encrypt({ publicKeys: [nightPublic], privateKeys: [lightPrivate], message: openpgp.message.fromText(randomData) });
|
|
205
|
-
|
|
206
|
-
const message = await openpgp.message.readArmored(encrypted.data);
|
|
207
|
-
const lightPublic = await load_pub_key('light');
|
|
208
|
-
const nightPrivate = await load_priv_key('night');
|
|
209
|
-
const result = await openpgp.decrypt({ privateKeys: nightPrivate, publicKeys: [lightPublic], message: message });
|
|
210
|
-
|
|
211
|
-
expect(result).to.exist;
|
|
212
|
-
expect(result.data).to.equal(randomData);
|
|
213
|
-
expect(result.signatures).to.have.length(1);
|
|
214
|
-
expect(result.signatures[0].valid).to.be.true;
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
describe('Ed25519 Test Vectors from RFC8032', function () {
|
|
218
|
-
// https://tools.ietf.org/html/rfc8032#section-7.1
|
|
219
|
-
const signature = openpgp.crypto.signature;
|
|
220
|
-
const util = openpgp.util;
|
|
221
|
-
function testVector(vector) {
|
|
222
|
-
const curve = new elliptic.Curve('ed25519');
|
|
223
|
-
const { publicKey } = openpgp.crypto.publicKey.nacl.sign.keyPair.fromSeed(openpgp.util.hex_to_Uint8Array(vector.SECRET_KEY));
|
|
224
|
-
expect(publicKey).to.deep.equal(openpgp.util.hex_to_Uint8Array(vector.PUBLIC_KEY));
|
|
225
|
-
const data = util.str_to_Uint8Array(vector.MESSAGE);
|
|
226
|
-
const keyIntegers = [
|
|
227
|
-
openpgp.OID.fromClone(curve),
|
|
228
|
-
new openpgp.MPI(util.hex_to_str('40'+vector.PUBLIC_KEY)),
|
|
229
|
-
new openpgp.MPI(util.hex_to_str(vector.SECRET_KEY))
|
|
230
|
-
];
|
|
231
|
-
const msg_MPIs = [
|
|
232
|
-
new openpgp.MPI(util.Uint8Array_to_str(util.hex_to_Uint8Array(vector.SIGNATURE.R).reverse())),
|
|
233
|
-
new openpgp.MPI(util.Uint8Array_to_str(util.hex_to_Uint8Array(vector.SIGNATURE.S).reverse()))
|
|
234
|
-
];
|
|
235
|
-
return Promise.all([
|
|
236
|
-
signature.sign(22, undefined, keyIntegers, undefined, data).then(signed => {
|
|
237
|
-
const len = ((signed[0] << 8| signed[1]) + 7) / 8;
|
|
238
|
-
expect(util.hex_to_Uint8Array(vector.SIGNATURE.R)).to.deep.eq(signed.slice(2, 2 + len));
|
|
239
|
-
expect(util.hex_to_Uint8Array(vector.SIGNATURE.S)).to.deep.eq(signed.slice(4 + len));
|
|
240
|
-
}),
|
|
241
|
-
signature.verify(22, undefined, msg_MPIs, keyIntegers, undefined, data).then(result => {
|
|
242
|
-
expect(result).to.be.true;
|
|
243
|
-
})
|
|
244
|
-
]);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
it('Signature of empty string', function () {
|
|
248
|
-
return testVector({
|
|
249
|
-
SECRET_KEY:
|
|
250
|
-
['9d61b19deffd5a60ba844af492ec2cc4',
|
|
251
|
-
'4449c5697b326919703bac031cae7f60'].join(''),
|
|
252
|
-
PUBLIC_KEY:
|
|
253
|
-
['d75a980182b10ab7d54bfed3c964073a',
|
|
254
|
-
'0ee172f3daa62325af021a68f707511a'].join(''),
|
|
255
|
-
MESSAGE: '',
|
|
256
|
-
SIGNATURE:
|
|
257
|
-
{ R: ['e5564300c360ac729086e2cc806e828a',
|
|
258
|
-
'84877f1eb8e5d974d873e06522490155'].join(''),
|
|
259
|
-
S: ['5fb8821590a33bacc61e39701cf9b46b',
|
|
260
|
-
'd25bf5f0595bbe24655141438e7a100b'].join('') }
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('Signature of single byte', function () {
|
|
265
|
-
return testVector({
|
|
266
|
-
SECRET_KEY:
|
|
267
|
-
['4ccd089b28ff96da9db6c346ec114e0f',
|
|
268
|
-
'5b8a319f35aba624da8cf6ed4fb8a6fb'].join(''),
|
|
269
|
-
PUBLIC_KEY:
|
|
270
|
-
['3d4017c3e843895a92b70aa74d1b7ebc',
|
|
271
|
-
'9c982ccf2ec4968cc0cd55f12af4660c'].join(''),
|
|
272
|
-
MESSAGE: util.hex_to_str('72'),
|
|
273
|
-
SIGNATURE:
|
|
274
|
-
{ R: ['92a009a9f0d4cab8720e820b5f642540',
|
|
275
|
-
'a2b27b5416503f8fb3762223ebdb69da'].join(''),
|
|
276
|
-
S: ['085ac1e43e15996e458f3613d0f11d8c',
|
|
277
|
-
'387b2eaeb4302aeeb00d291612bb0c00'].join('') }
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('Signature of two bytes', function () {
|
|
282
|
-
return testVector({
|
|
283
|
-
SECRET_KEY:
|
|
284
|
-
['c5aa8df43f9f837bedb7442f31dcb7b1',
|
|
285
|
-
'66d38535076f094b85ce3a2e0b4458f7'].join(''),
|
|
286
|
-
PUBLIC_KEY:
|
|
287
|
-
['fc51cd8e6218a1a38da47ed00230f058',
|
|
288
|
-
'0816ed13ba3303ac5deb911548908025'].join(''),
|
|
289
|
-
MESSAGE: util.hex_to_str('af82'),
|
|
290
|
-
SIGNATURE:
|
|
291
|
-
{ R: ['6291d657deec24024827e69c3abe01a3',
|
|
292
|
-
'0ce548a284743a445e3680d7db5ac3ac'].join(''),
|
|
293
|
-
S: ['18ff9b538d16f290ae67f760984dc659',
|
|
294
|
-
'4a7c15e9716ed28dc027beceea1ec40a'].join('') }
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('Signature of 1023 bytes', function () {
|
|
299
|
-
return testVector({
|
|
300
|
-
SECRET_KEY:
|
|
301
|
-
['f5e5767cf153319517630f226876b86c',
|
|
302
|
-
'8160cc583bc013744c6bf255f5cc0ee5'].join(''),
|
|
303
|
-
PUBLIC_KEY:
|
|
304
|
-
['278117fc144c72340f67d0f2316e8386',
|
|
305
|
-
'ceffbf2b2428c9c51fef7c597f1d426e'].join(''),
|
|
306
|
-
MESSAGE: util.hex_to_str([
|
|
307
|
-
'08b8b2b733424243760fe426a4b54908',
|
|
308
|
-
'632110a66c2f6591eabd3345e3e4eb98',
|
|
309
|
-
'fa6e264bf09efe12ee50f8f54e9f77b1',
|
|
310
|
-
'e355f6c50544e23fb1433ddf73be84d8',
|
|
311
|
-
'79de7c0046dc4996d9e773f4bc9efe57',
|
|
312
|
-
'38829adb26c81b37c93a1b270b20329d',
|
|
313
|
-
'658675fc6ea534e0810a4432826bf58c',
|
|
314
|
-
'941efb65d57a338bbd2e26640f89ffbc',
|
|
315
|
-
'1a858efcb8550ee3a5e1998bd177e93a',
|
|
316
|
-
'7363c344fe6b199ee5d02e82d522c4fe',
|
|
317
|
-
'ba15452f80288a821a579116ec6dad2b',
|
|
318
|
-
'3b310da903401aa62100ab5d1a36553e',
|
|
319
|
-
'06203b33890cc9b832f79ef80560ccb9',
|
|
320
|
-
'a39ce767967ed628c6ad573cb116dbef',
|
|
321
|
-
'efd75499da96bd68a8a97b928a8bbc10',
|
|
322
|
-
'3b6621fcde2beca1231d206be6cd9ec7',
|
|
323
|
-
'aff6f6c94fcd7204ed3455c68c83f4a4',
|
|
324
|
-
'1da4af2b74ef5c53f1d8ac70bdcb7ed1',
|
|
325
|
-
'85ce81bd84359d44254d95629e9855a9',
|
|
326
|
-
'4a7c1958d1f8ada5d0532ed8a5aa3fb2',
|
|
327
|
-
'd17ba70eb6248e594e1a2297acbbb39d',
|
|
328
|
-
'502f1a8c6eb6f1ce22b3de1a1f40cc24',
|
|
329
|
-
'554119a831a9aad6079cad88425de6bd',
|
|
330
|
-
'e1a9187ebb6092cf67bf2b13fd65f270',
|
|
331
|
-
'88d78b7e883c8759d2c4f5c65adb7553',
|
|
332
|
-
'878ad575f9fad878e80a0c9ba63bcbcc',
|
|
333
|
-
'2732e69485bbc9c90bfbd62481d9089b',
|
|
334
|
-
'eccf80cfe2df16a2cf65bd92dd597b07',
|
|
335
|
-
'07e0917af48bbb75fed413d238f5555a',
|
|
336
|
-
'7a569d80c3414a8d0859dc65a46128ba',
|
|
337
|
-
'b27af87a71314f318c782b23ebfe808b',
|
|
338
|
-
'82b0ce26401d2e22f04d83d1255dc51a',
|
|
339
|
-
'ddd3b75a2b1ae0784504df543af8969b',
|
|
340
|
-
'e3ea7082ff7fc9888c144da2af58429e',
|
|
341
|
-
'c96031dbcad3dad9af0dcbaaaf268cb8',
|
|
342
|
-
'fcffead94f3c7ca495e056a9b47acdb7',
|
|
343
|
-
'51fb73e666c6c655ade8297297d07ad1',
|
|
344
|
-
'ba5e43f1bca32301651339e22904cc8c',
|
|
345
|
-
'42f58c30c04aafdb038dda0847dd988d',
|
|
346
|
-
'cda6f3bfd15c4b4c4525004aa06eeff8',
|
|
347
|
-
'ca61783aacec57fb3d1f92b0fe2fd1a8',
|
|
348
|
-
'5f6724517b65e614ad6808d6f6ee34df',
|
|
349
|
-
'f7310fdc82aebfd904b01e1dc54b2927',
|
|
350
|
-
'094b2db68d6f903b68401adebf5a7e08',
|
|
351
|
-
'd78ff4ef5d63653a65040cf9bfd4aca7',
|
|
352
|
-
'984a74d37145986780fc0b16ac451649',
|
|
353
|
-
'de6188a7dbdf191f64b5fc5e2ab47b57',
|
|
354
|
-
'f7f7276cd419c17a3ca8e1b939ae49e4',
|
|
355
|
-
'88acba6b965610b5480109c8b17b80e1',
|
|
356
|
-
'b7b750dfc7598d5d5011fd2dcc5600a3',
|
|
357
|
-
'2ef5b52a1ecc820e308aa342721aac09',
|
|
358
|
-
'43bf6686b64b2579376504ccc493d97e',
|
|
359
|
-
'6aed3fb0f9cd71a43dd497f01f17c0e2',
|
|
360
|
-
'cb3797aa2a2f256656168e6c496afc5f',
|
|
361
|
-
'b93246f6b1116398a346f1a641f3b041',
|
|
362
|
-
'e989f7914f90cc2c7fff357876e506b5',
|
|
363
|
-
'0d334ba77c225bc307ba537152f3f161',
|
|
364
|
-
'0e4eafe595f6d9d90d11faa933a15ef1',
|
|
365
|
-
'369546868a7f3a45a96768d40fd9d034',
|
|
366
|
-
'12c091c6315cf4fde7cb68606937380d',
|
|
367
|
-
'b2eaaa707b4c4185c32eddcdd306705e',
|
|
368
|
-
'4dc1ffc872eeee475a64dfac86aba41c',
|
|
369
|
-
'0618983f8741c5ef68d3a101e8a3b8ca',
|
|
370
|
-
'c60c905c15fc910840b94c00a0b9d0'
|
|
371
|
-
].join('')),
|
|
372
|
-
SIGNATURE:
|
|
373
|
-
{ R: ['0aab4c900501b3e24d7cdf4663326a3a',
|
|
374
|
-
'87df5e4843b2cbdb67cbf6e460fec350'].join(''),
|
|
375
|
-
S: ['aa5371b1508f9f4528ecea23c436d94b',
|
|
376
|
-
'5e8fcd4f681e30a6ac00a9704a188a03'].join('') }
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it('Signature of SHA(abc)', function () {
|
|
381
|
-
return testVector({
|
|
382
|
-
SECRET_KEY:
|
|
383
|
-
['833fe62409237b9d62ec77587520911e',
|
|
384
|
-
'9a759cec1d19755b7da901b96dca3d42'].join(''),
|
|
385
|
-
PUBLIC_KEY:
|
|
386
|
-
['ec172b93ad5e563bf4932c70e1245034',
|
|
387
|
-
'c35467ef2efd4d64ebf819683467e2bf'].join(''),
|
|
388
|
-
MESSAGE: util.hex_to_str([
|
|
389
|
-
'ddaf35a193617abacc417349ae204131',
|
|
390
|
-
'12e6fa4e89a97ea20a9eeee64b55d39a',
|
|
391
|
-
'2192992a274fc1a836ba3c23a3feebbd',
|
|
392
|
-
'454d4423643ce80e2a9ac94fa54ca49f'
|
|
393
|
-
].join('')),
|
|
394
|
-
SIGNATURE:
|
|
395
|
-
{ R: ['dc2a4459e7369633a52b1bf277839a00',
|
|
396
|
-
'201009a3efbf3ecb69bea2186c26b589'].join(''),
|
|
397
|
-
S: ['09351fc9ac90b3ecfdfbc7c66431e030',
|
|
398
|
-
'3dca179c138ac17ad9bef1177331a704'].join('') }
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
/* TODO how does GPG2 accept this?
|
|
404
|
-
it('Should handle little-endian parameters in EdDSA', function () {
|
|
405
|
-
const pubKey = [
|
|
406
|
-
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
|
407
|
-
'Version: OpenPGP.js v3.0.0',
|
|
408
|
-
'Comment: https://openpgpjs.org',
|
|
409
|
-
'',
|
|
410
|
-
'xjMEWnRgnxYJKwYBBAHaRw8BAQdAZ8gxxCdUxIv4tBwhfUMW2uoEb1KvOfP8',
|
|
411
|
-
'D+0ObBtsLnfNDkhpIDxoaUBoZWwubG8+wnYEEBYKACkFAlp0YJ8GCwkHCAMC',
|
|
412
|
-
'CRDAYsFlymHCFQQVCAoCAxYCAQIZAQIbAwIeAQAAswsA/3qNZnwBn/ef4twv',
|
|
413
|
-
'uvmFicYK//DDX1jIkpDiQ+/okLUEAPdAr3J/Z2WA7OD0d36trHNB06WLXJUu',
|
|
414
|
-
'aCVm1TwoJHcNzjgEWnRgnxIKKwYBBAGXVQEFAQEHQPBVH+skap0NHMBw2HMe',
|
|
415
|
-
'xWYUQ67I9Did3KoJuuEJ/ctQAwEIB8JhBBgWCAATBQJadGCfCRDAYsFlymHC',
|
|
416
|
-
'FQIbDAAAhNQBAKmy4gPorjbwTwy5usylHttP28XnTdaGkZ1E7Rc3G9luAQCs',
|
|
417
|
-
'Gbm1oe83ZB+0aSp5m34YkpHQNb80y8PGFy7nIexiAA==',
|
|
418
|
-
'=xeG/',
|
|
419
|
-
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
|
420
|
-
const hi = (await openpgp.key.readArmored(pubKey)).keys[0];
|
|
421
|
-
const results = hi.getPrimaryUser();
|
|
422
|
-
expect(results).to.exist;
|
|
423
|
-
expect(results.user).to.exist;
|
|
424
|
-
const user = results.user;
|
|
425
|
-
expect(user.selfCertifications[0].verify(
|
|
426
|
-
hi.primaryKey, {userId: user.userId, key: hi.primaryKey}
|
|
427
|
-
)).to.eventually.be.true;
|
|
428
|
-
await user.verifyCertificate(
|
|
429
|
-
hi.primaryKey, user.selfCertifications[0], [hi]
|
|
430
|
-
);
|
|
431
|
-
}); */
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
// TODO export, then reimport key and validate
|
|
435
|
-
function omnibus() {
|
|
436
|
-
it('Omnibus Ed25519/Curve25519 Test', function() {
|
|
437
|
-
const options = {
|
|
438
|
-
userIds: { name: "Hi", email: "hi@hel.lo" },
|
|
439
|
-
curve: "ed25519"
|
|
440
|
-
};
|
|
441
|
-
return openpgp.generateKey(options).then(async function(firstKey) {
|
|
442
|
-
expect(firstKey).to.exist;
|
|
443
|
-
expect(firstKey.privateKeyArmored).to.exist;
|
|
444
|
-
expect(firstKey.publicKeyArmored).to.exist;
|
|
445
|
-
expect(firstKey.key).to.exist;
|
|
446
|
-
expect(firstKey.key.primaryKey).to.exist;
|
|
447
|
-
expect(firstKey.key.subKeys).to.have.length(1);
|
|
448
|
-
expect(firstKey.key.subKeys[0].keyPacket).to.exist;
|
|
449
|
-
|
|
450
|
-
const hi = firstKey.key;
|
|
451
|
-
const primaryKey = hi.primaryKey;
|
|
452
|
-
const subKey = hi.subKeys[0];
|
|
453
|
-
expect(hi.getAlgorithmInfo().curve).to.equal('ed25519');
|
|
454
|
-
expect(hi.getAlgorithmInfo().algorithm).to.equal('eddsa');
|
|
455
|
-
expect(subKey.getAlgorithmInfo().curve).to.equal('curve25519');
|
|
456
|
-
expect(subKey.getAlgorithmInfo().algorithm).to.equal('ecdh');
|
|
457
|
-
|
|
458
|
-
// Self Certificate is valid
|
|
459
|
-
const user = hi.users[0];
|
|
460
|
-
await expect(user.selfCertifications[0].verify(
|
|
461
|
-
primaryKey, openpgp.enums.signature.cert_generic, { userId: user.userId, key: primaryKey }
|
|
462
|
-
)).to.eventually.be.true;
|
|
463
|
-
await user.verifyCertificate(
|
|
464
|
-
primaryKey, user.selfCertifications[0], [hi.toPublic()]
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
const options = {
|
|
468
|
-
userIds: { name: "Bye", email: "bye@good.bye" },
|
|
469
|
-
curve: "curve25519"
|
|
470
|
-
};
|
|
471
|
-
return openpgp.generateKey(options).then(async function(secondKey) {
|
|
472
|
-
const bye = secondKey.key;
|
|
473
|
-
expect(bye.getAlgorithmInfo().curve).to.equal('ed25519');
|
|
474
|
-
expect(bye.getAlgorithmInfo().algorithm).to.equal('eddsa');
|
|
475
|
-
expect(bye.subKeys[0].getAlgorithmInfo().curve).to.equal('curve25519');
|
|
476
|
-
expect(bye.subKeys[0].getAlgorithmInfo().algorithm).to.equal('ecdh');
|
|
477
|
-
|
|
478
|
-
// Self Certificate is valid
|
|
479
|
-
const user = bye.users[0];
|
|
480
|
-
await expect(user.selfCertifications[0].verify(
|
|
481
|
-
bye.primaryKey, openpgp.enums.signature.cert_generic, { userId: user.userId, key: bye.primaryKey }
|
|
482
|
-
)).to.eventually.be.true;
|
|
483
|
-
await user.verifyCertificate(
|
|
484
|
-
bye.primaryKey, user.selfCertifications[0], [bye.toPublic()]
|
|
485
|
-
);
|
|
486
|
-
|
|
487
|
-
return Promise.all([
|
|
488
|
-
// Hi trusts Bye!
|
|
489
|
-
bye.toPublic().signPrimaryUser([hi]).then(trustedBye => {
|
|
490
|
-
expect(trustedBye.users[0].otherCertifications[0].verify(
|
|
491
|
-
primaryKey, openpgp.enums.signature.cert_generic, { userId: user.userId, key: bye.toPublic().primaryKey }
|
|
492
|
-
)).to.eventually.be.true;
|
|
493
|
-
}),
|
|
494
|
-
// Signing message
|
|
495
|
-
openpgp.sign(
|
|
496
|
-
{ message: openpgp.cleartext.fromText('Hi, this is me, Hi!'), privateKeys: hi }
|
|
497
|
-
).then(async signed => {
|
|
498
|
-
const msg = await openpgp.cleartext.readArmored(signed.data);
|
|
499
|
-
// Verifying signed message
|
|
500
|
-
return Promise.all([
|
|
501
|
-
openpgp.verify(
|
|
502
|
-
{ message: msg, publicKeys: hi.toPublic() }
|
|
503
|
-
).then(output => expect(output.signatures[0].valid).to.be.true),
|
|
504
|
-
// Verifying detached signature
|
|
505
|
-
openpgp.verify(
|
|
506
|
-
{
|
|
507
|
-
message: openpgp.message.fromText('Hi, this is me, Hi!'),
|
|
508
|
-
publicKeys: hi.toPublic(),
|
|
509
|
-
signature: await openpgp.signature.readArmored(signed.data)
|
|
510
|
-
}
|
|
511
|
-
).then(output => expect(output.signatures[0].valid).to.be.true)
|
|
512
|
-
]);
|
|
513
|
-
}),
|
|
514
|
-
// Encrypting and signing
|
|
515
|
-
openpgp.encrypt(
|
|
516
|
-
{
|
|
517
|
-
message: openpgp.message.fromText('Hi, Hi wrote this but only Bye can read it!'),
|
|
518
|
-
publicKeys: [bye.toPublic()],
|
|
519
|
-
privateKeys: [hi]
|
|
520
|
-
}
|
|
521
|
-
).then(async encrypted => {
|
|
522
|
-
const msg = await openpgp.message.readArmored(encrypted.data);
|
|
523
|
-
// Decrypting and verifying
|
|
524
|
-
return openpgp.decrypt(
|
|
525
|
-
{
|
|
526
|
-
message: msg,
|
|
527
|
-
privateKeys: bye,
|
|
528
|
-
publicKeys: [hi.toPublic()]
|
|
529
|
-
}
|
|
530
|
-
).then(output => {
|
|
531
|
-
expect(output.data).to.equal('Hi, Hi wrote this but only Bye can read it!');
|
|
532
|
-
expect(output.signatures[0].valid).to.be.true;
|
|
533
|
-
});
|
|
534
|
-
})
|
|
535
|
-
]);
|
|
536
|
-
});
|
|
537
|
-
});
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
tryTests('X25519 Omnibus Tests', omnibus, {
|
|
542
|
-
if: !openpgp.config.ci
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
tryTests('X25519 Omnibus Tests - Worker', omnibus, {
|
|
546
|
-
if: typeof window !== 'undefined' && window.Worker,
|
|
547
|
-
before: async function() {
|
|
548
|
-
await openpgp.initWorker({ path: '../dist/openpgp.worker.js' });
|
|
549
|
-
},
|
|
550
|
-
beforeEach: function() {
|
|
551
|
-
openpgp.config.use_native = true;
|
|
552
|
-
},
|
|
553
|
-
after: function() {
|
|
554
|
-
openpgp.destroyWorker();
|
|
555
|
-
}
|
|
556
|
-
});
|
package/test/unittests.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// Old browser polyfills
|
|
2
|
-
if (typeof Symbol === 'undefined') {
|
|
3
|
-
require('core-js/fn/symbol');
|
|
4
|
-
}
|
|
5
|
-
if (typeof Promise === 'undefined') {
|
|
6
|
-
require('core-js/fn/promise');
|
|
7
|
-
}
|
|
8
|
-
if (typeof TransformStream === 'undefined') {
|
|
9
|
-
require('@mattiasbuelens/web-streams-polyfill');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
(typeof window !== 'undefined' ? window : global).resolves = function(val) {
|
|
13
|
-
return new Promise(function(res) { res(val); });
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
(typeof window !== 'undefined' ? window : global).rejects = function(val) {
|
|
17
|
-
return new Promise(function(res, rej) { rej(val); });
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
(typeof window !== 'undefined' ? window : global).tryTests = function(name, tests, options) {
|
|
21
|
-
if (options.if) {
|
|
22
|
-
describe(name, function() {
|
|
23
|
-
if (options.before) { before(options.before); }
|
|
24
|
-
if (options.beforeEach) { beforeEach(options.beforeEach); }
|
|
25
|
-
|
|
26
|
-
tests();
|
|
27
|
-
|
|
28
|
-
if (options.afterEach) { afterEach(options.afterEach); }
|
|
29
|
-
if (options.after) { after(options.after); }
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
describe.skip(name + ' (no support --> skipping tests)', tests);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
describe('Unit Tests', function () {
|
|
37
|
-
|
|
38
|
-
if (typeof window !== 'undefined') {
|
|
39
|
-
openpgp.config.s2k_iteration_count_byte = 0;
|
|
40
|
-
openpgp.config.indutny_elliptic_path = '../dist/elliptic.min.js';
|
|
41
|
-
|
|
42
|
-
afterEach(function () {
|
|
43
|
-
if (window.scrollY >= document.body.scrollHeight - window.innerHeight - 100
|
|
44
|
-
|| openpgp.config.ci) {
|
|
45
|
-
window.scrollTo(0, document.body.scrollHeight);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
window.location.search.substr(1).split('&').forEach(param => {
|
|
50
|
-
const [key, value] = param.split('=');
|
|
51
|
-
if (key && key !== 'grep') {
|
|
52
|
-
openpgp.config[key] = decodeURIComponent(value);
|
|
53
|
-
try {
|
|
54
|
-
openpgp.config[key] = eval(openpgp.config[key]);
|
|
55
|
-
} catch(e) {}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
require('./crypto');
|
|
61
|
-
require('./general');
|
|
62
|
-
require('./worker');
|
|
63
|
-
require('./security');
|
|
64
|
-
});
|