@protontech/openpgp 4.10.5 → 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 +41080 -41565
  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 -61067
  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 -40024
  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 -224
  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 -363
  88. package/src/key/index.js +0 -32
  89. package/src/key/key.js +0 -890
  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 -156
  109. package/src/packet/public_subkey.js +0 -44
  110. package/src/packet/secret_key.js +0 -448
  111. package/src/packet/secret_subkey.js +0 -41
  112. package/src/packet/signature.js +0 -782
  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 -88
  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 -3402
  163. package/test/general/keyring.js +0 -336
  164. package/test/general/oid.js +0 -39
  165. package/test/general/openpgp.js +0 -2542
  166. package/test/general/packet.js +0 -937
  167. package/test/general/signature.js +0 -1665
  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
package/src/enums.js DELETED
@@ -1,493 +0,0 @@
1
- /**
2
- * @module enums
3
- */
4
-
5
- const byValue = Symbol('byValue');
6
-
7
- export default {
8
-
9
- /** Maps curve names under various standards to one
10
- * @see {@link https://wiki.gnupg.org/ECC|ECC - GnuPG wiki}
11
- * @enum {String}
12
- * @readonly
13
- */
14
- curve: {
15
- /** NIST P-256 Curve */
16
- "p256": "p256",
17
- "P-256": "p256",
18
- "secp256r1": "p256",
19
- "prime256v1": "p256",
20
- "1.2.840.10045.3.1.7": "p256",
21
- "2a8648ce3d030107": "p256",
22
- "2A8648CE3D030107": "p256",
23
-
24
- /** NIST P-384 Curve */
25
- "p384": "p384",
26
- "P-384": "p384",
27
- "secp384r1": "p384",
28
- "1.3.132.0.34": "p384",
29
- "2b81040022": "p384",
30
- "2B81040022": "p384",
31
-
32
- /** NIST P-521 Curve */
33
- "p521": "p521",
34
- "P-521": "p521",
35
- "secp521r1": "p521",
36
- "1.3.132.0.35": "p521",
37
- "2b81040023": "p521",
38
- "2B81040023": "p521",
39
-
40
- /** SECG SECP256k1 Curve */
41
- "secp256k1": "secp256k1",
42
- "1.3.132.0.10": "secp256k1",
43
- "2b8104000a": "secp256k1",
44
- "2B8104000A": "secp256k1",
45
-
46
- /** Ed25519 */
47
- "ED25519": "ed25519",
48
- "ed25519": "ed25519",
49
- "Ed25519": "ed25519",
50
- "1.3.6.1.4.1.11591.15.1": "ed25519",
51
- "2b06010401da470f01": "ed25519",
52
- "2B06010401DA470F01": "ed25519",
53
-
54
- /** Curve25519 */
55
- "X25519": "curve25519",
56
- "cv25519": "curve25519",
57
- "curve25519": "curve25519",
58
- "Curve25519": "curve25519",
59
- "1.3.6.1.4.1.3029.1.5.1": "curve25519",
60
- "2b060104019755010501": "curve25519",
61
- "2B060104019755010501": "curve25519",
62
-
63
- /** BrainpoolP256r1 Curve */
64
- "brainpoolP256r1": "brainpoolP256r1",
65
- "1.3.36.3.3.2.8.1.1.7": "brainpoolP256r1",
66
- "2b2403030208010107": "brainpoolP256r1",
67
- "2B2403030208010107": "brainpoolP256r1",
68
-
69
- /** BrainpoolP384r1 Curve */
70
- "brainpoolP384r1": "brainpoolP384r1",
71
- "1.3.36.3.3.2.8.1.1.11": "brainpoolP384r1",
72
- "2b240303020801010b": "brainpoolP384r1",
73
- "2B240303020801010B": "brainpoolP384r1",
74
-
75
- /** BrainpoolP512r1 Curve */
76
- "brainpoolP512r1": "brainpoolP512r1",
77
- "1.3.36.3.3.2.8.1.1.13": "brainpoolP512r1",
78
- "2b240303020801010d": "brainpoolP512r1",
79
- "2B240303020801010D": "brainpoolP512r1"
80
- },
81
-
82
- /** KDF parameters flags
83
- * Non-standard extensions (for now) to allow email forwarding
84
- * @enum {Integer}
85
- * @readonly
86
- */
87
- kdfFlags: {
88
- /** Specify fingerprint to use instead of the recipient's */
89
- replace_fingerprint: 0x01,
90
- /** Specify custom parameters to use in the KDF digest computation */
91
- replace_kdf_params: 0x02
92
- },
93
-
94
- /** A string to key specifier type
95
- * @enum {Integer}
96
- * @readonly
97
- */
98
- s2k: {
99
- simple: 0,
100
- salted: 1,
101
- iterated: 3,
102
- gnu: 101
103
- },
104
-
105
- /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.1|RFC4880bis-04, section 9.1}
106
- * @enum {Integer}
107
- * @readonly
108
- */
109
- publicKey: {
110
- /** RSA (Encrypt or Sign) [HAC] */
111
- rsa_encrypt_sign: 1,
112
- /** RSA (Encrypt only) [HAC] */
113
- rsa_encrypt: 2,
114
- /** RSA (Sign only) [HAC] */
115
- rsa_sign: 3,
116
- /** Elgamal (Encrypt only) [ELGAMAL] [HAC] */
117
- elgamal: 16,
118
- /** DSA (Sign only) [FIPS186] [HAC] */
119
- dsa: 17,
120
- /** ECDH (Encrypt only) [RFC6637] */
121
- ecdh: 18,
122
- /** ECDSA (Sign only) [RFC6637] */
123
- ecdsa: 19,
124
- /** EdDSA (Sign only)
125
- * [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
126
- eddsa: 22,
127
- /** Reserved for AEDH */
128
- aedh: 23,
129
- /** Reserved for AEDSA */
130
- aedsa: 24
131
- },
132
-
133
- /** {@link https://tools.ietf.org/html/rfc4880#section-9.2|RFC4880, section 9.2}
134
- * @enum {Integer}
135
- * @readonly
136
- */
137
- symmetric: {
138
- plaintext: 0,
139
- /** Not implemented! */
140
- idea: 1,
141
- '3des': 2,
142
- tripledes: 2,
143
- cast5: 3,
144
- blowfish: 4,
145
- aes128: 7,
146
- aes192: 8,
147
- aes256: 9,
148
- twofish: 10
149
- },
150
-
151
- /** {@link https://tools.ietf.org/html/rfc4880#section-9.3|RFC4880, section 9.3}
152
- * @enum {Integer}
153
- * @readonly
154
- */
155
- compression: {
156
- uncompressed: 0,
157
- /** RFC1951 */
158
- zip: 1,
159
- /** RFC1950 */
160
- zlib: 2,
161
- bzip2: 3
162
- },
163
-
164
- /** {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC4880, section 9.4}
165
- * @enum {Integer}
166
- * @readonly
167
- */
168
- hash: {
169
- md5: 1,
170
- sha1: 2,
171
- ripemd: 3,
172
- sha256: 8,
173
- sha384: 9,
174
- sha512: 10,
175
- sha224: 11
176
- },
177
-
178
- /** A list of hash names as accepted by webCrypto functions.
179
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest|Parameters, algo}
180
- * @enum {String}
181
- */
182
- webHash: {
183
- 'SHA-1': 2,
184
- 'SHA-256': 8,
185
- 'SHA-384': 9,
186
- 'SHA-512': 10
187
- },
188
-
189
- /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-9.6|RFC4880bis-04, section 9.6}
190
- * @enum {Integer}
191
- * @readonly
192
- */
193
- aead: {
194
- eax: 1,
195
- ocb: 2,
196
- experimental_gcm: 100 // Private algorithm
197
- },
198
-
199
- /** A list of packet types and numeric tags associated with them.
200
- * @enum {Integer}
201
- * @readonly
202
- */
203
- packet: {
204
- publicKeyEncryptedSessionKey: 1,
205
- signature: 2,
206
- symEncryptedSessionKey: 3,
207
- onePassSignature: 4,
208
- secretKey: 5,
209
- publicKey: 6,
210
- secretSubkey: 7,
211
- compressed: 8,
212
- symmetricallyEncrypted: 9,
213
- marker: 10,
214
- literal: 11,
215
- trust: 12,
216
- userid: 13,
217
- publicSubkey: 14,
218
- userAttribute: 17,
219
- symEncryptedIntegrityProtected: 18,
220
- modificationDetectionCode: 19,
221
- symEncryptedAEADProtected: 20 // see IETF draft: https://tools.ietf.org/html/draft-ford-openpgp-format-00#section-2.1
222
- },
223
-
224
- /** Data types in the literal packet
225
- * @enum {Integer}
226
- * @readonly
227
- */
228
- literal: {
229
- /** Binary data 'b' */
230
- binary: 'b'.charCodeAt(),
231
- /** Text data 't' */
232
- text: 't'.charCodeAt(),
233
- /** Utf8 data 'u' */
234
- utf8: 'u'.charCodeAt(),
235
- /** MIME message body part 'm' */
236
- mime: 'm'.charCodeAt()
237
- },
238
-
239
-
240
- /** One pass signature packet type
241
- * @enum {Integer}
242
- * @readonly
243
- */
244
- signature: {
245
- /** 0x00: Signature of a binary document. */
246
- binary: 0,
247
- /** 0x01: Signature of a canonical text document.
248
- *
249
- * Canonicalyzing the document by converting line endings. */
250
- text: 1,
251
- /** 0x02: Standalone signature.
252
- *
253
- * This signature is a signature of only its own subpacket contents.
254
- * It is calculated identically to a signature over a zero-lengh
255
- * binary document. Note that it doesn't make sense to have a V3
256
- * standalone signature. */
257
- standalone: 2,
258
- /** 0x10: Generic certification of a User ID and Public-Key packet.
259
- *
260
- * The issuer of this certification does not make any particular
261
- * assertion as to how well the certifier has checked that the owner
262
- * of the key is in fact the person described by the User ID. */
263
- cert_generic: 16,
264
- /** 0x11: Persona certification of a User ID and Public-Key packet.
265
- *
266
- * The issuer of this certification has not done any verification of
267
- * the claim that the owner of this key is the User ID specified. */
268
- cert_persona: 17,
269
- /** 0x12: Casual certification of a User ID and Public-Key packet.
270
- *
271
- * The issuer of this certification has done some casual
272
- * verification of the claim of identity. */
273
- cert_casual: 18,
274
- /** 0x13: Positive certification of a User ID and Public-Key packet.
275
- *
276
- * The issuer of this certification has done substantial
277
- * verification of the claim of identity.
278
- *
279
- * Most OpenPGP implementations make their "key signatures" as 0x10
280
- * certifications. Some implementations can issue 0x11-0x13
281
- * certifications, but few differentiate between the types. */
282
- cert_positive: 19,
283
- /** 0x30: Certification revocation signature
284
- *
285
- * This signature revokes an earlier User ID certification signature
286
- * (signature class 0x10 through 0x13) or direct-key signature
287
- * (0x1F). It should be issued by the same key that issued the
288
- * revoked signature or an authorized revocation key. The signature
289
- * is computed over the same data as the certificate that it
290
- * revokes, and should have a later creation date than that
291
- * certificate. */
292
- cert_revocation: 48,
293
- /** 0x18: Subkey Binding Signature
294
- *
295
- * This signature is a statement by the top-level signing key that
296
- * indicates that it owns the subkey. This signature is calculated
297
- * directly on the primary key and subkey, and not on any User ID or
298
- * other packets. A signature that binds a signing subkey MUST have
299
- * an Embedded Signature subpacket in this binding signature that
300
- * contains a 0x19 signature made by the signing subkey on the
301
- * primary key and subkey. */
302
- subkey_binding: 24,
303
- /** 0x19: Primary Key Binding Signature
304
- *
305
- * This signature is a statement by a signing subkey, indicating
306
- * that it is owned by the primary key and subkey. This signature
307
- * is calculated the same way as a 0x18 signature: directly on the
308
- * primary key and subkey, and not on any User ID or other packets.
309
- *
310
- * When a signature is made over a key, the hash data starts with the
311
- * octet 0x99, followed by a two-octet length of the key, and then body
312
- * of the key packet. (Note that this is an old-style packet header for
313
- * a key packet with two-octet length.) A subkey binding signature
314
- * (type 0x18) or primary key binding signature (type 0x19) then hashes
315
- * the subkey using the same format as the main key (also using 0x99 as
316
- * the first octet). */
317
- key_binding: 25,
318
- /** 0x1F: Signature directly on a key
319
- *
320
- * This signature is calculated directly on a key. It binds the
321
- * information in the Signature subpackets to the key, and is
322
- * appropriate to be used for subpackets that provide information
323
- * about the key, such as the Revocation Key subpacket. It is also
324
- * appropriate for statements that non-self certifiers want to make
325
- * about the key itself, rather than the binding between a key and a
326
- * name. */
327
- key: 31,
328
- /** 0x20: Key revocation signature
329
- *
330
- * The signature is calculated directly on the key being revoked. A
331
- * revoked key is not to be used. Only revocation signatures by the
332
- * key being revoked, or by an authorized revocation key, should be
333
- * considered valid revocation signatures.a */
334
- key_revocation: 32,
335
- /** 0x28: Subkey revocation signature
336
- *
337
- * The signature is calculated directly on the subkey being revoked.
338
- * A revoked subkey is not to be used. Only revocation signatures
339
- * by the top-level signature key that is bound to this subkey, or
340
- * by an authorized revocation key, should be considered valid
341
- * revocation signatures.
342
- *
343
- * Key revocation signatures (types 0x20 and 0x28)
344
- * hash only the key being revoked. */
345
- subkey_revocation: 40,
346
- /** 0x40: Timestamp signature.
347
- * This signature is only meaningful for the timestamp contained in
348
- * it. */
349
- timestamp: 64,
350
- /** 0x50: Third-Party Confirmation signature.
351
- *
352
- * This signature is a signature over some other OpenPGP Signature
353
- * packet(s). It is analogous to a notary seal on the signed data.
354
- * A third-party signature SHOULD include Signature Target
355
- * subpacket(s) to give easy identification. Note that we really do
356
- * mean SHOULD. There are plausible uses for this (such as a blind
357
- * party that only sees the signature, not the key or source
358
- * document) that cannot include a target subpacket. */
359
- third_party: 80
360
- },
361
-
362
- /** Signature subpacket type
363
- * @enum {Integer}
364
- * @readonly
365
- */
366
- signatureSubpacket: {
367
- signature_creation_time: 2,
368
- signature_expiration_time: 3,
369
- exportable_certification: 4,
370
- trust_signature: 5,
371
- regular_expression: 6,
372
- revocable: 7,
373
- key_expiration_time: 9,
374
- placeholder_backwards_compatibility: 10,
375
- preferred_symmetric_algorithms: 11,
376
- revocation_key: 12,
377
- issuer: 16,
378
- notation_data: 20,
379
- preferred_hash_algorithms: 21,
380
- preferred_compression_algorithms: 22,
381
- key_server_preferences: 23,
382
- preferred_key_server: 24,
383
- primary_user_id: 25,
384
- policy_uri: 26,
385
- key_flags: 27,
386
- signers_user_id: 28,
387
- reason_for_revocation: 29,
388
- features: 30,
389
- signature_target: 31,
390
- embedded_signature: 32,
391
- issuer_fingerprint: 33,
392
- preferred_aead_algorithms: 34
393
- },
394
-
395
- /** Key flags
396
- * @enum {Integer}
397
- * @readonly
398
- */
399
- keyFlags: {
400
- /** 0x01 - This key may be used to certify other keys. */
401
- certify_keys: 1,
402
- /** 0x02 - This key may be used to sign data. */
403
- sign_data: 2,
404
- /** 0x04 - This key may be used to encrypt communications. */
405
- encrypt_communication: 4,
406
- /** 0x08 - This key may be used to encrypt storage. */
407
- encrypt_storage: 8,
408
- /** 0x10 - The private component of this key may have been split
409
- * by a secret-sharing mechanism. */
410
- split_private_key: 16,
411
- /** 0x20 - This key may be used for authentication. */
412
- authentication: 32,
413
- /** 0x80 - The private component of this key may be in the
414
- * possession of more than one person. */
415
- shared_private_key: 128
416
- },
417
-
418
- /** Armor type
419
- * @enum {Integer}
420
- * @readonly
421
- */
422
- armor: {
423
- multipart_section: 0,
424
- multipart_last: 1,
425
- signed: 2,
426
- message: 3,
427
- public_key: 4,
428
- private_key: 5,
429
- signature: 6
430
- },
431
-
432
- /** {@link https://tools.ietf.org/html/rfc4880#section-5.2.3.23|RFC4880, section 5.2.3.23}
433
- * @enum {Integer}
434
- * @readonly
435
- */
436
- reasonForRevocation: {
437
- /** No reason specified (key revocations or cert revocations) */
438
- no_reason: 0,
439
- /** Key is superseded (key revocations) */
440
- key_superseded: 1,
441
- /** Key material has been compromised (key revocations) */
442
- key_compromised: 2,
443
- /** Key is retired and no longer used (key revocations) */
444
- key_retired: 3,
445
- /** User ID information is no longer valid (cert revocations) */
446
- userid_invalid: 32
447
- },
448
-
449
- /** {@link https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-04#section-5.2.3.25|RFC4880bis-04, section 5.2.3.25}
450
- * @enum {Integer}
451
- * @readonly
452
- */
453
- features: {
454
- /** 0x01 - Modification Detection (packets 18 and 19) */
455
- modification_detection: 1,
456
- /** 0x02 - AEAD Encrypted Data Packet (packet 20) and version 5
457
- * Symmetric-Key Encrypted Session Key Packets (packet 3) */
458
- aead: 2,
459
- /** 0x04 - Version 5 Public-Key Packet format and corresponding new
460
- * fingerprint format */
461
- v5_keys: 4
462
- },
463
-
464
- /** Asserts validity and converts from string/integer to integer. */
465
- write: function(type, e) {
466
- if (typeof e === 'number') {
467
- e = this.read(type, e);
468
- }
469
-
470
- if (type[e] !== undefined) {
471
- return type[e];
472
- }
473
-
474
- throw new Error('Invalid enum value.');
475
- },
476
-
477
- /** Converts from an integer to string. */
478
- read: function(type, e) {
479
- if (!type[byValue]) {
480
- type[byValue] = [];
481
- Object.entries(type).forEach(([key, value]) => {
482
- type[byValue][value] = key;
483
- });
484
- }
485
-
486
- if (type[byValue][e] !== undefined) {
487
- return type[byValue][e];
488
- }
489
-
490
- throw new Error('Invalid enum value.');
491
- }
492
-
493
- };
package/src/hkp.js DELETED
@@ -1,89 +0,0 @@
1
- // OpenPGP.js - An OpenPGP implementation in javascript
2
- // Copyright (C) 2015 Tankred Hase
3
- //
4
- // This library is free software; you can redistribute it and/or
5
- // modify it under the terms of the GNU Lesser General Public
6
- // License as published by the Free Software Foundation; either
7
- // version 3.0 of the License, or (at your option) any later version.
8
- //
9
- // This library is distributed in the hope that it will be useful,
10
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- // Lesser General Public License for more details.
13
- //
14
- // You should have received a copy of the GNU Lesser General Public
15
- // License along with this library; if not, write to the Free Software
16
- // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
-
18
- /**
19
- * @fileoverview This class implements a client for the OpenPGP HTTP Keyserver Protocol (HKP)
20
- * in order to lookup and upload keys on standard public key servers.
21
- * @module hkp
22
- */
23
-
24
- import config from './config';
25
-
26
- /**
27
- * Initialize the HKP client and configure it with the key server url and fetch function.
28
- * @constructor
29
- * @param {String} keyServerBaseUrl (optional) The HKP key server base url including
30
- * the protocol to use, e.g. 'https://pgp.mit.edu'; defaults to
31
- * openpgp.config.keyserver (https://keyserver.ubuntu.com)
32
- */
33
- function HKP(keyServerBaseUrl) {
34
- this._baseUrl = keyServerBaseUrl || config.keyserver;
35
- this._fetch = typeof global.fetch === 'function' ? global.fetch : require('node-fetch');
36
- }
37
-
38
- /**
39
- * Search for a public key on the key server either by key ID or part of the user ID.
40
- * @param {String} options.keyID The long public key ID.
41
- * @param {String} options.query This can be any part of the key user ID such as name
42
- * or email address.
43
- * @returns {Promise<String>} The ascii armored public key.
44
- * @async
45
- */
46
- HKP.prototype.lookup = function(options) {
47
- let uri = this._baseUrl + '/pks/lookup?op=get&options=mr&search=';
48
- const fetch = this._fetch;
49
-
50
- if (options.keyId) {
51
- uri += '0x' + encodeURIComponent(options.keyId);
52
- } else if (options.query) {
53
- uri += encodeURIComponent(options.query);
54
- } else {
55
- throw new Error('You must provide a query parameter!');
56
- }
57
-
58
- return fetch(uri).then(function(response) {
59
- if (response.status === 200) {
60
- return response.text();
61
- }
62
- }).then(function(publicKeyArmored) {
63
- if (!publicKeyArmored || publicKeyArmored.indexOf('-----END PGP PUBLIC KEY BLOCK-----') < 0) {
64
- return;
65
- }
66
- return publicKeyArmored.trim();
67
- });
68
- };
69
-
70
- /**
71
- * Upload a public key to the server.
72
- * @param {String} publicKeyArmored An ascii armored public key to be uploaded.
73
- * @returns {Promise}
74
- * @async
75
- */
76
- HKP.prototype.upload = function(publicKeyArmored) {
77
- const uri = this._baseUrl + '/pks/add';
78
- const fetch = this._fetch;
79
-
80
- return fetch(uri, {
81
- method: 'post',
82
- headers: {
83
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
84
- },
85
- body: 'keytext=' + encodeURIComponent(publicKeyArmored)
86
- });
87
- };
88
-
89
- export default HKP;