@protontech/openpgp 4.10.8 → 5.3.1

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.
Files changed (173) hide show
  1. package/README.md +311 -239
  2. package/dist/lightweight/bn.interface.min.mjs +3 -0
  3. package/dist/lightweight/bn.interface.min.mjs.map +1 -0
  4. package/dist/lightweight/bn.interface.mjs +340 -0
  5. package/dist/lightweight/bn.min.mjs +3 -0
  6. package/dist/lightweight/bn.min.mjs.map +1 -0
  7. package/dist/lightweight/bn.mjs +3434 -0
  8. package/dist/lightweight/elliptic.min.mjs +3 -0
  9. package/dist/lightweight/elliptic.min.mjs.map +1 -0
  10. package/dist/lightweight/elliptic.mjs +4313 -0
  11. package/dist/lightweight/openpgp.min.mjs +3 -0
  12. package/dist/lightweight/openpgp.min.mjs.map +1 -0
  13. package/dist/lightweight/openpgp.mjs +31375 -0
  14. package/dist/lightweight/ponyfill.es6.min.mjs +3 -0
  15. package/dist/lightweight/ponyfill.es6.min.mjs.map +1 -0
  16. package/dist/lightweight/ponyfill.es6.mjs +3831 -0
  17. package/dist/lightweight/web-streams-adapter.min.mjs +17 -0
  18. package/dist/lightweight/web-streams-adapter.min.mjs.map +1 -0
  19. package/dist/lightweight/web-streams-adapter.mjs +561 -0
  20. package/dist/node/openpgp.js +43943 -0
  21. package/dist/node/openpgp.min.js +17 -0
  22. package/dist/node/openpgp.min.js.map +1 -0
  23. package/dist/node/openpgp.min.mjs +17 -0
  24. package/dist/node/openpgp.min.mjs.map +1 -0
  25. package/dist/node/openpgp.mjs +43880 -0
  26. package/dist/openpgp.js +41077 -41609
  27. package/dist/openpgp.min.js +17 -2
  28. package/dist/openpgp.min.js.map +1 -0
  29. package/dist/openpgp.min.mjs +17 -0
  30. package/dist/openpgp.min.mjs.map +1 -0
  31. package/dist/openpgp.mjs +43868 -0
  32. package/lightweight/package.json +5 -0
  33. package/openpgp.d.ts +889 -0
  34. package/package.json +63 -57
  35. package/dist/compat/openpgp.js +0 -61152
  36. package/dist/compat/openpgp.min.js +0 -2
  37. package/dist/compat/openpgp.worker.js +0 -173
  38. package/dist/compat/openpgp.worker.min.js +0 -2
  39. package/dist/lightweight/elliptic.min.js +0 -5
  40. package/dist/lightweight/openpgp.js +0 -40071
  41. package/dist/lightweight/openpgp.min.js +0 -2
  42. package/dist/lightweight/openpgp.worker.js +0 -173
  43. package/dist/lightweight/openpgp.worker.min.js +0 -2
  44. package/dist/openpgp.worker.js +0 -173
  45. package/dist/openpgp.worker.min.js +0 -2
  46. package/src/cleartext.js +0 -220
  47. package/src/config/config.js +0 -232
  48. package/src/config/index.js +0 -7
  49. package/src/config/localStorage.js +0 -35
  50. package/src/crypto/aes_kw.js +0 -153
  51. package/src/crypto/cfb.js +0 -169
  52. package/src/crypto/cipher/aes.js +0 -27
  53. package/src/crypto/cipher/blowfish.js +0 -398
  54. package/src/crypto/cipher/cast5.js +0 -610
  55. package/src/crypto/cipher/des.js +0 -476
  56. package/src/crypto/cipher/index.js +0 -91
  57. package/src/crypto/cipher/twofish.js +0 -346
  58. package/src/crypto/cmac.js +0 -98
  59. package/src/crypto/crypto.js +0 -394
  60. package/src/crypto/eax.js +0 -172
  61. package/src/crypto/gcm.js +0 -141
  62. package/src/crypto/hash/index.js +0 -163
  63. package/src/crypto/hash/md5.js +0 -205
  64. package/src/crypto/index.js +0 -57
  65. package/src/crypto/ocb.js +0 -274
  66. package/src/crypto/pkcs1.js +0 -170
  67. package/src/crypto/pkcs5.js +0 -55
  68. package/src/crypto/public_key/dsa.js +0 -188
  69. package/src/crypto/public_key/elgamal.js +0 -137
  70. package/src/crypto/public_key/elliptic/curves.js +0 -385
  71. package/src/crypto/public_key/elliptic/ecdh.js +0 -414
  72. package/src/crypto/public_key/elliptic/ecdsa.js +0 -348
  73. package/src/crypto/public_key/elliptic/eddsa.js +0 -119
  74. package/src/crypto/public_key/elliptic/index.js +0 -34
  75. package/src/crypto/public_key/elliptic/indutnyKey.js +0 -85
  76. package/src/crypto/public_key/index.js +0 -28
  77. package/src/crypto/public_key/prime.js +0 -275
  78. package/src/crypto/public_key/rsa.js +0 -597
  79. package/src/crypto/random.js +0 -145
  80. package/src/crypto/signature.js +0 -137
  81. package/src/encoding/armor.js +0 -433
  82. package/src/encoding/base64.js +0 -96
  83. package/src/enums.js +0 -493
  84. package/src/hkp.js +0 -89
  85. package/src/index.js +0 -161
  86. package/src/key/factory.js +0 -326
  87. package/src/key/helper.js +0 -378
  88. package/src/key/index.js +0 -32
  89. package/src/key/key.js +0 -888
  90. package/src/key/subkey.js +0 -187
  91. package/src/key/user.js +0 -230
  92. package/src/keyring/index.js +0 -12
  93. package/src/keyring/keyring.js +0 -229
  94. package/src/keyring/localstore.js +0 -119
  95. package/src/lightweight_helper.js +0 -26
  96. package/src/message.js +0 -825
  97. package/src/openpgp.js +0 -717
  98. package/src/packet/all_packets.js +0 -116
  99. package/src/packet/clone.js +0 -189
  100. package/src/packet/compressed.js +0 -194
  101. package/src/packet/index.js +0 -20
  102. package/src/packet/literal.js +0 -168
  103. package/src/packet/marker.js +0 -62
  104. package/src/packet/one_pass_signature.js +0 -156
  105. package/src/packet/packet.js +0 -300
  106. package/src/packet/packetlist.js +0 -232
  107. package/src/packet/public_key.js +0 -280
  108. package/src/packet/public_key_encrypted_session_key.js +0 -161
  109. package/src/packet/public_subkey.js +0 -44
  110. package/src/packet/secret_key.js +0 -468
  111. package/src/packet/secret_subkey.js +0 -41
  112. package/src/packet/signature.js +0 -786
  113. package/src/packet/sym_encrypted_aead_protected.js +0 -189
  114. package/src/packet/sym_encrypted_integrity_protected.js +0 -139
  115. package/src/packet/sym_encrypted_session_key.js +0 -204
  116. package/src/packet/symmetrically_encrypted.js +0 -118
  117. package/src/packet/trust.js +0 -35
  118. package/src/packet/user_attribute.js +0 -94
  119. package/src/packet/userid.js +0 -87
  120. package/src/polyfills.js +0 -64
  121. package/src/signature.js +0 -73
  122. package/src/type/ecdh_symkey.js +0 -69
  123. package/src/type/kdf_params.js +0 -114
  124. package/src/type/keyid.js +0 -110
  125. package/src/type/mpi.js +0 -138
  126. package/src/type/oid.js +0 -110
  127. package/src/type/s2k.js +0 -203
  128. package/src/util.js +0 -836
  129. package/src/wkd.js +0 -84
  130. package/src/worker/async_proxy.js +0 -190
  131. package/src/worker/worker.js +0 -167
  132. package/test/crypto/aes_kw.js +0 -57
  133. package/test/crypto/cipher/aes.js +0 -86
  134. package/test/crypto/cipher/blowfish.js +0 -58
  135. package/test/crypto/cipher/cast5.js +0 -25
  136. package/test/crypto/cipher/des.js +0 -143
  137. package/test/crypto/cipher/index.js +0 -7
  138. package/test/crypto/cipher/twofish.js +0 -71
  139. package/test/crypto/crypto.js +0 -383
  140. package/test/crypto/eax.js +0 -150
  141. package/test/crypto/ecdh.js +0 -359
  142. package/test/crypto/elliptic.js +0 -251
  143. package/test/crypto/elliptic_data.js +0 -102
  144. package/test/crypto/hash/index.js +0 -5
  145. package/test/crypto/hash/md5.js +0 -16
  146. package/test/crypto/hash/ripemd.js +0 -14
  147. package/test/crypto/hash/sha.js +0 -20
  148. package/test/crypto/index.js +0 -14
  149. package/test/crypto/ocb.js +0 -183
  150. package/test/crypto/pkcs5.js +0 -39
  151. package/test/crypto/random.js +0 -79
  152. package/test/crypto/rsa.js +0 -180
  153. package/test/crypto/validate.js +0 -387
  154. package/test/general/armor.js +0 -408
  155. package/test/general/brainpool.js +0 -360
  156. package/test/general/decompression.js +0 -60
  157. package/test/general/ecc_nist.js +0 -115
  158. package/test/general/ecc_secp256k1.js +0 -242
  159. package/test/general/forwarding.js +0 -43
  160. package/test/general/hkp.js +0 -165
  161. package/test/general/index.js +0 -20
  162. package/test/general/key.js +0 -3491
  163. package/test/general/keyring.js +0 -336
  164. package/test/general/oid.js +0 -39
  165. package/test/general/openpgp.js +0 -2577
  166. package/test/general/packet.js +0 -950
  167. package/test/general/signature.js +0 -1715
  168. package/test/general/streaming.js +0 -944
  169. package/test/general/testInputs.js +0 -18
  170. package/test/general/util.js +0 -183
  171. package/test/general/wkd.js +0 -48
  172. package/test/general/x25519.js +0 -556
  173. package/test/unittests.js +0 -64
@@ -1,336 +0,0 @@
1
- const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
2
-
3
- const chai = require('chai');
4
-
5
- const { expect } = chai;
6
-
7
- const keyring = new openpgp.Keyring();
8
-
9
- describe("Keyring", async function() {
10
- const user = 'whiteout.test@t-online.de';
11
- const passphrase = 'asdf';
12
- const keySize = 512;
13
- const keyId = 'f6f60e9b42cdff4c';
14
- const keyFingerP = '5856cef789c3a307e8a1b976f6f60e9b42cdff4c';
15
- const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\n' +
16
- 'Version: OpenPGP.js v.1.20131011\n' +
17
- 'Comment: https://openpgpjs.org\n' +
18
- '\n' +
19
- 'xk0EUlhMvAEB/2MZtCUOAYvyLFjDp3OBMGn3Ev8FwjzyPbIF0JUw+L7y2XR5\n' +
20
- 'RVGvbK88unV3cU/1tOYdNsXI6pSp/Ztjyv7vbBUAEQEAAc0pV2hpdGVvdXQg\n' +
21
- 'VXNlciA8d2hpdGVvdXQudGVzdEB0LW9ubGluZS5kZT7CXAQQAQgAEAUCUlhM\n' +
22
- 'vQkQ9vYOm0LN/0wAAAW4Af9C+kYW1AvNWmivdtr0M0iYCUjM9DNOQH1fcvXq\n' +
23
- 'IiN602mWrkd8jcEzLsW5IUNzVPLhrFIuKyBDTpLnC07Loce1\n' +
24
- '=6XMW\n' +
25
- '-----END PGP PUBLIC KEY BLOCK-----';
26
- const privkey = '-----BEGIN PGP PRIVATE KEY BLOCK-----\n' +
27
- 'Version: OpenPGP.js v.1.20131011\n' +
28
- 'Comment: https://openpgpjs.org\n' +
29
- '\n' +
30
- 'xcBeBFJYTLwBAf9jGbQlDgGL8ixYw6dzgTBp9xL/BcI88j2yBdCVMPi+8tl0\n' +
31
- 'eUVRr2yvPLp1d3FP9bTmHTbFyOqUqf2bY8r+72wVABEBAAH+AwMIhNB4ivtv\n' +
32
- 'Y2xg6VeMcjjHxZayESHACV+nQx5Tx6ev6xzIF1Qh72fNPDppLhFSFOuTTMsU\n' +
33
- 'kTN4c+BVYt29spH+cA1jcDAxQ2ULrNAXo+hheOqhpedTs8aCbcLFkJAS16hk\n' +
34
- 'YSk4OnJgp/z24rVju1SHRSFbgundPzmNgXeX9e8IkviGhhQ11Wc5YwVkx03t\n' +
35
- 'Z3MdDMF0jyhopbPIoBdyJB0dhvBh98w3JmwpYh9wjUA9MBHD1tvHpRmSZ3BM\n' +
36
- 'UCmATn2ZLWBRWiYqFbgDnL1GM80pV2hpdGVvdXQgVXNlciA8d2hpdGVvdXQu\n' +
37
- 'dGVzdEB0LW9ubGluZS5kZT7CXAQQAQgAEAUCUlhMvQkQ9vYOm0LN/0wAAAW4\n' +
38
- 'Af9C+kYW1AvNWmivdtr0M0iYCUjM9DNOQH1fcvXqIiN602mWrkd8jcEzLsW5\n' +
39
- 'IUNzVPLhrFIuKyBDTpLnC07Loce1\n' +
40
- '=ULta\n' +
41
- '-----END PGP PRIVATE KEY BLOCK-----';
42
- const keyId2 = 'ba993fc2aee18a3a';
43
- const keyFingerP2 = '560b7a7f3f9ab516b233b299ba993fc2aee18a3a';
44
- const subkeyId2 = 'f47c5210a8cc2740';
45
- const subkeyFingerP2 = '2a20c371141e000833848d85f47c5210a8cc2740';
46
- const pubkey2 =
47
- ['-----BEGIN PGP PUBLIC KEY BLOCK-----',
48
- 'Version: GnuPG v2.0.22 (GNU/Linux)',
49
- '',
50
- 'mQMuBFLVgdQRCACOlpq0cd1IazNjOEpWPZvx/O3JMbdDs3B3iCG0Mo5OUZ8lpKU5',
51
- 'EslVgTd8IcUU14ZMOO7y91dw0KP4q61b4OIy7oVxzfFfKCC1s0Dc7GTay+qo5afJ',
52
- 'wbWcgTyCIahTRmi5UepU7xdRHRMlqAclOwY2no8fw0JRQfFwRFCjbMdmvzC/k+Wo',
53
- 'A42nn8YaSAG2v7OqF3rkYjkv/7iak48PO/l0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K-----'].join('\n');
86
- const user3 = 'plain@email.org';
87
- const keyFingerP3 = 'f9972bf320a86a93c6614711ed241e1de755d53c';
88
- const pubkey3 =
89
- ['-----BEGIN PGP PUBLIC KEY BLOCK-----',
90
- '',
91
- 'xo0EVe6wawEEAKG4LDE9946jdvvbfVTF9qWtOyxHYjb40z7hgcZsPEGd6QfN',
92
- 'XbfNJBeQ5S9j/2jRu8NwBgdXIpMp4QwB2Q/cEp1rbw5kUVuRbhfsb2BzuiBr',
93
- 'Q5jHa5oZSGbbLWRoOXTvJH8VE2gbKSj/km1VaXzq2Qmv+YIHxav1it7vNmg5',
94
- 'E2kBABEBAAHND3BsYWluQGVtYWlsLm9yZ8K1BBABCAApBQJV7rBrBgsJCAcD',
95
- 'AgkQ7SQeHedV1TwEFQgCCgMWAgECGQECGwMCHgEAAGJmBACVJPoFtW96UkIW',
96
- 'GX1bgW99c4K87Me+5ZCHqPOdXFpRinAPBdJT9vkBWLb/aOQQCDWJvdVXKFLD',
97
- 'FCbSBjcohR71n6145F5im8b0XzXnKh+MRRv/0UHiHGtB/Pkg38jbLeXbVfCM',
98
- '9JJm+s+PFef+8wN84sEtD/MX2cj61teuPf2VEs6NBFXusGsBBACoJW/0y5Ea',
99
- 'FH0nJOuoenrEBZkFtGbdwo8A4ufCCrm9ppFHVVnw4uTPH9dOjw8IAnNy7wA8',
100
- '8yZCkreQ491em09knR7k2YdJccWwW8mGRILHQDDEPetZO1dSVW+MA9X7Pcle',
101
- 'wbFEHCIkWEgymn3zenie1LXIljPzizHje5vWBrSlFwARAQABwp8EGAEIABMF',
102
- 'AlXusGsJEO0kHh3nVdU8AhsMAACB2AP/eRJFAVTyiP5MnMjsSBuNMNBp1X0Y',
103
- '+RrWDpO9H929+fm9oFTedohf/Ja5w9hsRk2VzjLOXe/uHdrcgaBmAdFunbvv',
104
- 'IWneczohBvLOarevZj1J+H3Ej/DVF2W7kJZLpvPfh7eo0biClS/GQUVw1rlE',
105
- 'ph10hhUaSJ326LsFJccT3jk=',
106
- '=4jat',
107
- '-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
108
-
109
- it('Import key pair', async function() {
110
- await keyring.load();
111
- // clear any keys already in the keychain
112
- keyring.clear();
113
- await keyring.store();
114
- await keyring.publicKeys.importKey(pubkey);
115
- await keyring.publicKeys.importKey(pubkey2);
116
- await keyring.privateKeys.importKey(privkey);
117
- });
118
-
119
- it('getKeysForId() - unknown id', function() {
120
- const keys = keyring.getKeysForId('01234567890123456');
121
- expect(keys).to.be.null;
122
- });
123
-
124
- it('getKeysForId() - valid id', function() {
125
- const keys = keyring.getKeysForId(keyId);
126
- // we get public and private key
127
- expect(keys).to.exist.and.have.length(2);
128
- expect(keys[0].getKeyId().toHex()).equals(keyId);
129
- });
130
-
131
- it('publicKeys.getForId() - unknown id', function() {
132
- const key = keyring.publicKeys.getForId('01234567890123456');
133
- expect(key).to.be.null;
134
- });
135
-
136
- it('publicKeys.getForId() - valid id', function() {
137
- const key = keyring.publicKeys.getForId(keyId);
138
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
139
- expect(key.getKeyId().toHex()).equals(keyId);
140
- });
141
-
142
- it('privateKeys.getForId() - unknown id', function() {
143
- const key = keyring.privateKeys.getForId('01234567890123456');
144
- expect(key).to.be.null;
145
- });
146
-
147
- it('privateKeys.getForId() - valid id', function() {
148
- const key = keyring.privateKeys.getForId(keyId);
149
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
150
- expect(key.getKeyId().toHex()).equals(keyId);
151
- });
152
-
153
- it('publicKeys.getForId() - subkey id', function() {
154
- const key = keyring.publicKeys.getForId(subkeyId2);
155
- expect(key).to.be.null;
156
- });
157
-
158
- it('publicKeys.getForId() - deep, including subkeys - subkey id', function() {
159
- const key = keyring.publicKeys.getForId(subkeyId2, true);
160
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
161
- expect(key.getKeyId().toHex()).equals(keyId2);
162
- });
163
-
164
- it('getKeysForId() - unknown fingerprint', function() {
165
- const keys = keyring.getKeysForId('71130e8383bef9526e062600d5e9f93acbbc7275');
166
- expect(keys).to.be.null;
167
- });
168
-
169
- it('getKeysForId() - valid fingerprint', function() {
170
- const keys = keyring.getKeysForId(keyFingerP2);
171
- expect(keys).to.exist.and.have.length(1);
172
- expect(keys[0].getKeyId().toHex()).equals(keyId2);
173
- });
174
-
175
- it('publicKeys.getForId() - unknown fingerprint', function() {
176
- const key = keyring.publicKeys.getForId('71130e8383bef9526e062600d5e9f93acbbc7275');
177
- expect(key).to.be.null;
178
- });
179
-
180
- it('publicKeys.getForId() - valid fingerprint', function() {
181
- const key = keyring.publicKeys.getForId(keyFingerP2);
182
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
183
- expect(key.getKeyId().toHex()).equals(keyId2);
184
- });
185
-
186
- it('publicKeys.getForId() - subkey fingerprint', function() {
187
- const key = keyring.publicKeys.getForId(subkeyFingerP2);
188
- expect(key).to.be.null;
189
- });
190
-
191
- it('publicKeys.getForId() - deep, including subkeys - subkey fingerprint', function() {
192
- const key = keyring.publicKeys.getForId(subkeyFingerP2, true);
193
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
194
- expect(key.getKeyId().toHex()).equals(keyId2);
195
- });
196
-
197
- it('publicKeys.getForAddress() - unknown address', function() {
198
- const keys = keyring.publicKeys.getForAddress('nobody@example.com');
199
- expect(keys).to.be.empty;
200
- });
201
-
202
- it('publicKeys.getForAddress() - valid address', function() {
203
- const keys = keyring.publicKeys.getForAddress(user);
204
- expect(keys).to.exist.and.have.length(1);
205
- });
206
-
207
- it('publicKeys.getForAddress() - valid address, plain email user id', async function() {
208
- await keyring.publicKeys.importKey(pubkey3);
209
- const keys = keyring.publicKeys.getForAddress(user3);
210
- keyring.removeKeysForId(keyFingerP3);
211
- expect(keys).to.exist.and.have.length(1);
212
- });
213
-
214
- it('publicKeys.getForAddress() - address with regex special char |', function() {
215
- const keys = keyring.publicKeys.getForAddress('whiteout.test|not@t-online.de');
216
- expect(keys).to.be.empty;
217
- });
218
-
219
- it('publicKeys.getForAddress() - address with regex special char .', function() {
220
- const keys = keyring.publicKeys.getForAddress('wh.t.out.test@t-online.de');
221
- expect(keys).to.be.empty;
222
- });
223
-
224
- it('privateKeys.getForAddress() - unknown address', function() {
225
- const key = keyring.privateKeys.getForAddress('nobody@example.com');
226
- expect(key).to.be.empty;
227
- });
228
-
229
- it('privateKeys.getForAddress() - valid address', function() {
230
- const key = keyring.privateKeys.getForAddress(user);
231
- expect(key).to.exist.and.have.length(1);
232
- });
233
-
234
- it('store keys in localstorage', async function(){
235
- await keyring.store();
236
- });
237
-
238
- it('after loading from localstorage: getKeysForKeyId() - valid id', async function() {
239
- const keyring = new openpgp.Keyring();
240
- await keyring.load();
241
- const keys = keyring.getKeysForId(keyId);
242
- // we expect public and private key
243
- expect(keys).to.exist.and.have.length(2);
244
- });
245
-
246
- it('publicKeys.removeForId() - unknown id', function() {
247
- const key = keyring.publicKeys.removeForId('01234567890123456');
248
- expect(key).to.be.null;
249
- });
250
-
251
- it('publicKeys.removeForId() - valid id', function() {
252
- const key = keyring.publicKeys.removeForId(keyId);
253
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
254
- expect(key.getKeyId().toHex()).equals(keyId);
255
- expect(keyring.publicKeys.keys).to.exist.and.have.length(1);
256
- });
257
-
258
- it('publicKeys.removeForId() - unknown fingerprint', function() {
259
- const key = keyring.publicKeys.removeForId('71130e8383bef9526e062600d5e9f93acbbc7275');
260
- expect(key).to.be.null;
261
- expect(keyring.publicKeys.keys).to.exist.and.have.length(1);
262
- });
263
-
264
- it('publicKeys.removeForId() - valid fingerprint', function() {
265
- const key = keyring.publicKeys.removeForId(keyFingerP2);
266
- expect(key).to.exist.and.be.an.instanceof(openpgp.key.Key);
267
- expect(key.getKeyId().toHex()).equals(keyId2);
268
- expect(keyring.publicKeys.keys).to.be.empty;
269
- });
270
-
271
- it('customize localstorage itemname', async function() {
272
- const localstore1 = new openpgp.Keyring.localstore('my-custom-prefix-');
273
- const localstore2 = new openpgp.Keyring.localstore('my-custom-prefix-');
274
- const localstore3 = new openpgp.Keyring.localstore();
275
- await localstore3.storePublic([]);
276
- const key = (await openpgp.key.readArmored(pubkey)).keys[0];
277
- await localstore1.storePublic([key]);
278
- expect((await localstore2.loadPublic())[0].getKeyId().equals(key.getKeyId())).to.be.true;
279
- expect(await localstore3.loadPublic()).to.have.length(0);
280
- });
281
-
282
- it('emptying keyring and storing removes keys', async function() {
283
- const key = (await openpgp.key.readArmored(pubkey)).keys[0];
284
-
285
- const localstore = new openpgp.Keyring.localstore('remove-prefix-');
286
-
287
- await localstore.storePublic([]);
288
- expect(localstore.storage.getItem('remove-prefix-public-keys')).to.be.null;
289
-
290
- await localstore.storePublic([key]);
291
- expect(localstore.storage.getItem('remove-prefix-public-keys')).to.be.not.null;
292
-
293
- await localstore.storePublic([]);
294
- expect(localstore.storage.getItem('remove-prefix-public-keys')).to.be.null;
295
- });
296
-
297
- it('removeKeysForId() - unknown id', async function() {
298
- await keyring.publicKeys.importKey(pubkey);
299
- await keyring.publicKeys.importKey(pubkey2);
300
- await keyring.privateKeys.importKey(privkey);
301
- expect(keyring.publicKeys.keys).to.have.length(2);
302
- expect(keyring.privateKeys.keys).to.have.length(1);
303
- const keys = keyring.removeKeysForId('01234567890123456');
304
- expect(keys).to.be.null;
305
- expect(keyring.publicKeys.keys).to.have.length(2);
306
- expect(keyring.privateKeys.keys).to.have.length(1);
307
- });
308
-
309
- it('removeKeysForId() - valid id', function() {
310
- const keys = keyring.removeKeysForId(keyId);
311
- expect(keys).to.have.length(2);
312
- expect(keyring.publicKeys.keys).to.have.length(1);
313
- expect(keyring.privateKeys.keys).to.have.length(0);
314
- });
315
-
316
- it('removeKeysForId() - unknown fingerprint', async function() {
317
- await keyring.publicKeys.importKey(pubkey);
318
- await keyring.publicKeys.importKey(pubkey2);
319
- await keyring.privateKeys.importKey(privkey);
320
- expect(keyring.publicKeys.keys).to.have.length(2);
321
- expect(keyring.privateKeys.keys).to.have.length(1);
322
- const keys = keyring.removeKeysForId('71130e8383bef9526e062600d5e9f93acbbc7275');
323
- expect(keys).to.be.null;
324
- expect(keyring.publicKeys.keys).to.have.length(2);
325
- expect(keyring.privateKeys.keys).to.have.length(1);
326
- });
327
-
328
- it('removeKeysForId() - valid fingerprint', function() {
329
- const keys = keyring.removeKeysForId(keyFingerP);
330
- expect(keys).to.have.length(2);
331
- expect(keyring.publicKeys.keys).to.have.length(1);
332
- expect(keyring.privateKeys.keys).to.have.length(0);
333
- });
334
-
335
- });
336
-
@@ -1,39 +0,0 @@
1
- const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../../dist/openpgp');
2
-
3
- const expect = require('chai').expect;
4
-
5
- describe('Oid tests', function() {
6
- const OID = openpgp.OID;
7
- const util = openpgp.util;
8
- const p256_oid = new Uint8Array([0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07]);
9
- const p384_oid = new Uint8Array([0x2B, 0x81, 0x04, 0x00, 0x22]);
10
- const p521_oid = new Uint8Array([0x2B, 0x81, 0x04, 0x00, 0x23]);
11
- it('Constructing', function() {
12
- const oids = [p256_oid, p384_oid, p521_oid];
13
- oids.forEach(function (data) {
14
- const oid = new OID(data);
15
- expect(oid).to.exist;
16
- expect(oid.oid).to.exist;
17
- expect(oid.oid).to.have.length(data.length);
18
- expect(oid.toHex()).to.equal(util.Uint8Array_to_hex(data));
19
- });
20
- });
21
- it('Reading and writing', function() {
22
- const oids = [p256_oid, p384_oid, p521_oid];
23
- oids.forEach(function (data) {
24
- data = openpgp.util.concatUint8Array([new Uint8Array([data.length]), data]);
25
- const oid = new OID();
26
- expect(oid.read(data)).to.equal(data.length);
27
- expect(oid.oid).to.exist;
28
- expect(oid.oid).to.have.length(data.length-1);
29
- expect(oid.toHex()).to.equal(util.Uint8Array_to_hex(data.subarray(1)));
30
- const result = oid.write();
31
- expect(result).to.exist;
32
- expect(result).to.have.length(data.length);
33
- expect(result[0]).to.equal(data.length-1);
34
- expect(
35
- util.Uint8Array_to_hex(result.subarray(1))
36
- ).to.equal(util.Uint8Array_to_hex(data.subarray(1)));
37
- });
38
- });
39
- });