@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.
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 +31379 -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 +43947 -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 +43884 -0
  26. package/dist/openpgp.js +41082 -41563
  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 +43872 -0
  32. package/lightweight/package.json +5 -0
  33. package/openpgp.d.ts +890 -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/openpgp.d.ts ADDED
@@ -0,0 +1,890 @@
1
+ /**
2
+ * Type definitions for OpenPGP.js http://openpgpjs.org/
3
+ *
4
+ * Contributors:
5
+ * - FlowCrypt a. s. <https://flowcrypt.com>
6
+ * - Guillaume Lacasa <https://blog.lacasa.fr>
7
+ * - Errietta Kostala <https://github.com/errietta>
8
+ */
9
+
10
+ import type { WebStream as GenericWebStream, NodeStream as GenericNodeStream } from '@openpgp/web-stream-tools';
11
+
12
+ /* ############## v5 KEY #################### */
13
+ // The Key and PublicKey types can be used interchangably since TS cannot detect the difference, as they have the same class properties.
14
+ // The declared readKey(s) return type is Key instead of a PublicKey since it seems more obvious that a Key can be cast to a PrivateKey.
15
+ export function readKey(options: { armoredKey: string, config?: PartialConfig }): Promise<Key>;
16
+ export function readKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<Key>;
17
+ export function readKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<Key[]>;
18
+ export function readKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<Key[]>;
19
+ export function readPrivateKey(options: { armoredKey: string, config?: PartialConfig }): Promise<PrivateKey>;
20
+ export function readPrivateKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<PrivateKey>;
21
+ export function readPrivateKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<PrivateKey[]>;
22
+ export function readPrivateKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<PrivateKey[]>;
23
+ export function generateKey(options: GenerateKeyOptions & { format?: 'armored' }): Promise<SerializedKeyPair<string> & { revocationCertificate: string }>;
24
+ export function generateKey(options: GenerateKeyOptions & { format: 'binary' }): Promise<SerializedKeyPair<Uint8Array> & { revocationCertificate: string }>;
25
+ export function generateKey(options: GenerateKeyOptions & { format: 'object' }): Promise<KeyPair & { revocationCertificate: string }>;
26
+ export function decryptKey(options: { privateKey: PrivateKey; passphrase?: MaybeArray<string>; config?: PartialConfig }): Promise<PrivateKey>;
27
+ export function encryptKey(options: { privateKey: PrivateKey; passphrase?: MaybeArray<string>; config?: PartialConfig }): Promise<PrivateKey>;
28
+ export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string> & { revocationCertificate: string }>;
29
+ export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array> & { revocationCertificate: string }>;
30
+ export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair & { revocationCertificate: string }>;
31
+ export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string>>;
32
+ export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array>>;
33
+ export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair>;
34
+ export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string>>;
35
+ export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array>>;
36
+ export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair>;
37
+ export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<{ publicKey: string, privateKey: null }>;
38
+ export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<{ publicKey: Uint8Array, privateKey: null }>;
39
+ export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'object', config?: PartialConfig }): Promise<{ publicKey: PublicKey, privateKey: null }>;
40
+
41
+ export abstract class Key {
42
+ public readonly keyPacket: PublicKeyPacket | SecretKeyPacket;
43
+ public subkeys: Subkey[]; // do not add/replace users directly
44
+ public users: User[]; // do not add/replace subkeys directly
45
+ public revocationSignatures: SignaturePacket[];
46
+ public write(): Uint8Array;
47
+ public armor(config?: Config): string;
48
+ public getExpirationTime(userID?: UserID, config?: Config): Promise<Date | typeof Infinity | null>;
49
+ public getKeyIDs(): KeyID[];
50
+ public getPrimaryUser(date?: Date, userID?: UserID, config?: Config): Promise<PrimaryUser>; // throws on error
51
+ public getUserIDs(): string[];
52
+ public isPrivate(): this is PrivateKey;
53
+ public toPublic(): PublicKey;
54
+ // NB: the order of the `update` declarations matters, since PublicKey includes PrivateKey
55
+ public update(sourceKey: PrivateKey, date?: Date, config?: Config): Promise<PrivateKey>;
56
+ public update(sourceKey: PublicKey, date?: Date, config?: Config): Promise<PublicKey>;
57
+ public signPrimaryUser(privateKeys: PrivateKey[], date?: Date, userID?: UserID, config?: Config): Promise<this>
58
+ public signAllUsers(privateKeys: PrivateKey[], date?: Date, config?: Config): Promise<this>
59
+ public verifyPrimaryKey(date?: Date, userID?: UserID, config?: Config): Promise<void>; // throws on error
60
+ public verifyPrimaryUser(publicKeys: PublicKey[], date?: Date, userIDs?: UserID, config?: Config): Promise<{ keyID: KeyID, valid: boolean | null }[]>;
61
+ public verifyAllUsers(publicKeys: PublicKey[], date?: Date, config?: Config): Promise<{ userID: string, keyID: KeyID, valid: boolean | null }[]>;
62
+ public isRevoked(signature?: SignaturePacket, key?: AnyKeyPacket, date?: Date, config?: Config): Promise<boolean>;
63
+ public getRevocationCertificate(date?: Date, config?: Config): Promise<MaybeStream<string> | undefined>;
64
+ public getEncryptionKey(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<this | Subkey>;
65
+ public getSigningKey(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<this | Subkey>;
66
+ public getKeys(keyID?: KeyID): (this | Subkey)[];
67
+ public getSubkeys(keyID?: KeyID): Subkey[];
68
+ public getFingerprint(): string;
69
+ public getCreationTime(): Date;
70
+ public getAlgorithmInfo(): AlgorithmInfo;
71
+ public getKeyID(): KeyID;
72
+ public toPacketList(): PacketList<AllowedKeyPackets>;
73
+ }
74
+
75
+ type AllowedKeyPackets = PublicKeyPacket | PublicSubkeyPacket | SecretKeyPacket | SecretSubkeyPacket | UserIDPacket | UserAttributePacket | SignaturePacket;
76
+ export class PublicKey extends Key {
77
+ constructor(packetlist: PacketList<AnyPacket>);
78
+ }
79
+
80
+ export class PrivateKey extends PublicKey {
81
+ constructor(packetlist: PacketList<AnyPacket>);
82
+ public revoke(reason?: ReasonForRevocation, date?: Date, config?: Config): Promise<PrivateKey>;
83
+ public isDecrypted(): boolean;
84
+ public addSubkey(options: SubkeyOptions): Promise<PrivateKey>;
85
+ public getDecryptionKeys(keyID?: KeyID, date?: Date | null, userID?: UserID, config?: Config): Promise<PrivateKey | Subkey>
86
+ public update(sourceKey: PublicKey, date?: Date, config?: Config): Promise<PrivateKey>;
87
+ }
88
+
89
+ export class Subkey {
90
+ constructor(subkeyPacket: SecretSubkeyPacket | PublicSubkeyPacket, mainKey: PublicKey);
91
+ public readonly keyPacket: SecretSubkeyPacket | PublicSubkeyPacket;
92
+ public readonly mainKey: PublicKey;
93
+ public bindingSignatures: SignaturePacket[];
94
+ public revocationSignatures: SignaturePacket[];
95
+ public verify(date?: Date, config?: Config): Promise<SignaturePacket>;
96
+ public isDecrypted(): boolean;
97
+ public getFingerprint(): string;
98
+ public getCreationTime(): Date;
99
+ public getAlgorithmInfo(): AlgorithmInfo;
100
+ public getKeyID(): KeyID;
101
+ }
102
+
103
+ export interface User {
104
+ userID: UserIDPacket | null;
105
+ userAttribute: UserAttributePacket | null;
106
+ selfCertifications: SignaturePacket[];
107
+ otherCertifications: SignaturePacket[];
108
+ revocationSignatures: SignaturePacket[];
109
+ }
110
+
111
+ export interface PrimaryUser {
112
+ index: number;
113
+ user: User;
114
+ }
115
+
116
+ type AlgorithmInfo = {
117
+ algorithm: enums.publicKeyNames;
118
+ bits?: number;
119
+ curve?: EllipticCurveName;
120
+ };
121
+
122
+ /* ############## v5 SIG #################### */
123
+
124
+ export function readSignature(options: { armoredSignature: string, config?: PartialConfig }): Promise<Signature>;
125
+ export function readSignature(options: { binarySignature: Uint8Array, config?: PartialConfig }): Promise<Signature>;
126
+
127
+ export class Signature {
128
+ public readonly packets: PacketList<SignaturePacket>;
129
+ constructor(packetlist: PacketList<SignaturePacket>);
130
+ public write(): MaybeStream<Uint8Array>;
131
+ public armor(config?: Config): string;
132
+ public getSigningKeyIDs(): Array<KeyID>;
133
+ }
134
+
135
+ interface VerificationResult {
136
+ keyID: KeyID;
137
+ verified: Promise<true>; // throws on invalid signature
138
+ signature: Promise<Signature>;
139
+ }
140
+
141
+ /* ############## v5 CLEARTEXT #################### */
142
+
143
+ export function readCleartextMessage(options: { cleartextMessage: string, config?: PartialConfig }): Promise<CleartextMessage>;
144
+
145
+ export function createCleartextMessage(options: { text: string }): Promise<CleartextMessage>;
146
+
147
+ /** Class that represents an OpenPGP cleartext signed message.
148
+ */
149
+ export class CleartextMessage {
150
+ /** Returns ASCII armored text of cleartext signed message
151
+ */
152
+ armor(config?: Config): string;
153
+
154
+ /** Returns the key IDs of the keys that signed the cleartext message
155
+ */
156
+ getSigningKeyIDs(): KeyID[];
157
+
158
+ /** Get cleartext
159
+ */
160
+ getText(): string;
161
+
162
+ /** Sign the cleartext message
163
+ *
164
+ * @param privateKeys private keys with decrypted secret key data for signing
165
+ */
166
+ sign(privateKeys: PrivateKey[], signature?: Signature, signingKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): void;
167
+
168
+ /** Verify signatures of cleartext signed message
169
+ * @param keys array of keys to verify signatures
170
+ */
171
+ verify(keys: PublicKey[], date?: Date, config?: Config): Promise<VerificationResult[]>;
172
+ }
173
+
174
+ /* ############## v5 MSG #################### */
175
+ export function generateSessionKey(options: { encryptionKeys: MaybeArray<PublicKey>, date?: Date, encryptionUserIDs?: MaybeArray<UserID>, config?: PartialConfig }): Promise<SessionKey>;
176
+ export function encryptSessionKey(options: EncryptSessionKeyOptions & { format?: 'armored' }): Promise<string>;
177
+ export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'binary' }): Promise<Uint8Array>;
178
+ export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'object' }): Promise<Message<Data>>;
179
+ export function decryptSessionKeys<T extends MaybeStream<Data>>(options: { message: Message<T>, decryptionKeys?: MaybeArray<PrivateKey>, passwords?: MaybeArray<string>, date?: Date, config?: PartialConfig }): Promise<SessionKey[]>;
180
+
181
+ export function readMessage<T extends MaybeStream<string>>(options: { armoredMessage: T, config?: PartialConfig }): Promise<Message<T>>;
182
+ export function readMessage<T extends MaybeStream<Uint8Array>>(options: { binaryMessage: T, config?: PartialConfig }): Promise<Message<T>>;
183
+
184
+ export function createMessage<T extends MaybeStream<string>>(options: { text: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
185
+ export function createMessage<T extends MaybeStream<Uint8Array>>(options: { binary: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
186
+
187
+ export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<
188
+ T extends WebStream<infer X> ? WebStream<string> :
189
+ T extends NodeStream<infer X> ? NodeStream<string> :
190
+ string
191
+ >;
192
+ export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'binary' }): Promise<
193
+ T extends WebStream<infer X> ? WebStream<Uint8Array> :
194
+ T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
195
+ Uint8Array
196
+ >;
197
+ export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
198
+
199
+ export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format?: 'armored' }): Promise<
200
+ T extends WebStream<infer X> ? WebStream<string> :
201
+ T extends NodeStream<infer X> ? NodeStream<string> :
202
+ string
203
+ >;
204
+ export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'binary' }): Promise<
205
+ T extends WebStream<infer X> ? WebStream<Uint8Array> :
206
+ T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
207
+ Uint8Array
208
+ >;
209
+ export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
210
+ export function sign(options: SignOptions & { message: CleartextMessage, format?: 'armored' }): Promise<string>;
211
+ export function sign(options: SignOptions & { message: CleartextMessage, format: 'object' }): Promise<CleartextMessage>;
212
+
213
+ export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T>, format: 'binary' }): Promise<DecryptMessageResult & {
214
+ data:
215
+ T extends WebStream<infer X> ? WebStream<Uint8Array> :
216
+ T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
217
+ Uint8Array
218
+ }>;
219
+ export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T> }): Promise<DecryptMessageResult & {
220
+ data:
221
+ T extends WebStream<infer X> ? WebStream<string> :
222
+ T extends NodeStream<infer X> ? NodeStream<string> :
223
+ string
224
+ }>;
225
+
226
+ export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T>, format: 'binary' }): Promise<VerifyMessageResult & {
227
+ data:
228
+ T extends WebStream<infer X> ? WebStream<Uint8Array> :
229
+ T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
230
+ Uint8Array
231
+ }>;
232
+ export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult & {
233
+ data:
234
+ T extends WebStream<infer X> ? WebStream<string> :
235
+ T extends NodeStream<infer X> ? NodeStream<string> :
236
+ string
237
+ }>;
238
+
239
+ /** Class that represents an OpenPGP message. Can be an encrypted message, signed message, compressed message or literal message
240
+ */
241
+ export class Message<T extends MaybeStream<Data>> {
242
+
243
+ public readonly packets: PacketList<AnyPacket>;
244
+ constructor(packetlist: PacketList<AnyPacket>);
245
+
246
+ /** Returns binary representation of message
247
+ */
248
+ public write(): MaybeStream<Uint8Array>;
249
+
250
+ /** Returns ASCII armored text of message
251
+ */
252
+ public armor(config?: Config): string;
253
+
254
+ /** Decrypt the message
255
+ @param decryptionKeys array of private keys with decrypted secret data
256
+ */
257
+ public decrypt(decryptionKeys?: PrivateKey[], passwords?: string[], sessionKeys?: SessionKey[], date?: Date, config?: Config): Promise<Message<MaybeStream<Data>>>;
258
+
259
+ /** Encrypt the message
260
+ @param encryptionKeys array of public keys, used to encrypt the message
261
+ */
262
+ public encrypt(encryptionKeys?: PublicKey[], passwords?: string[], sessionKeys?: SessionKey[], wildcard?: boolean, encryptionKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<MaybeStream<Data>>>;
263
+
264
+ /** Returns the key IDs of the keys to which the session key is encrypted
265
+ */
266
+ public getEncryptionKeyIDs(): KeyID[];
267
+
268
+ /** Get literal data that is the body of the message
269
+ */
270
+ public getLiteralData(): (T extends Stream<Data> ? WebStream<Uint8Array> : Uint8Array) | null;
271
+
272
+ /** Returns the key IDs of the keys that signed the message
273
+ */
274
+ public getSigningKeyIDs(): KeyID[];
275
+
276
+ /** Get literal data as text
277
+ */
278
+ public getText(): (T extends Stream<Data> ? WebStream<string> : string) | null;
279
+
280
+ public getFilename(): string | null;
281
+
282
+ /** Sign the message (the literal data packet of the message)
283
+ @param signingKeys private keys with decrypted secret key data for signing
284
+ */
285
+ public sign(signingKeys: PrivateKey[], signature?: Signature, signingKeyIDs?: KeyID[], date?: Date, userIDs?: UserID[], config?: Config): Promise<Message<T>>;
286
+
287
+ /** Unwrap compressed message
288
+ */
289
+ public unwrapCompressed(): Message<T>;
290
+
291
+ /** Verify message signatures
292
+ @param verificationKeys array of public keys to verify signatures
293
+ */
294
+ public verify(verificationKeys: PublicKey[], date?: Date, config?: Config): Promise<VerificationResult[]>;
295
+
296
+ /**
297
+ * Append signature to unencrypted message object
298
+ * @param {String|Uint8Array} detachedSignature - The detached ASCII-armored or Uint8Array PGP signature
299
+ */
300
+ public appendSignature(detachedSignature: string | Uint8Array, config?: Config): Promise<void>;
301
+ }
302
+
303
+
304
+ /* ############## v5 CONFIG #################### */
305
+
306
+ interface Config {
307
+ preferredHashAlgorithm: enums.hash;
308
+ preferredSymmetricAlgorithm: enums.symmetric;
309
+ preferredCompressionAlgorithm: enums.compression;
310
+ showVersion: boolean;
311
+ showComment: boolean;
312
+ deflateLevel: number;
313
+ aeadProtect: boolean;
314
+ allowUnauthenticatedMessages: boolean;
315
+ allowUnauthenticatedStream: boolean;
316
+ checksumRequired: boolean;
317
+ minRSABits: number;
318
+ passwordCollisionCheck: boolean;
319
+ revocationsExpire: boolean;
320
+ ignoreUnsupportedPackets: boolean;
321
+ ignoreMalformedPackets: boolean;
322
+ versionString: string;
323
+ commentString: string;
324
+ allowInsecureDecryptionWithSigningKeys: boolean;
325
+ allowInsecureVerificationWithReformattedKeys: boolean;
326
+ constantTimePKCS1Decryption: boolean;
327
+ constantTimePKCS1DecryptionSupportedSymmetricAlgorithms: Set<enums.symmetric>;
328
+ v5Keys: boolean;
329
+ preferredAEADAlgorithm: enums.aead;
330
+ aeadChunkSizeByte: number;
331
+ s2kIterationCountByte: number;
332
+ minBytesForWebCrypto: number;
333
+ maxUserIDLength: number;
334
+ knownNotations: string[];
335
+ useIndutnyElliptic: boolean;
336
+ rejectHashAlgorithms: Set<enums.hash>;
337
+ rejectMessageHashAlgorithms: Set<enums.hash>;
338
+ rejectPublicKeyAlgorithms: Set<enums.publicKey>;
339
+ rejectCurves: Set<enums.curve>;
340
+ }
341
+ export var config: Config;
342
+
343
+ // PartialConfig has the same properties as Config, but declared as optional.
344
+ // This interface is relevant for top-level functions, which accept a subset of configuration options
345
+ interface PartialConfig extends Partial<Config> {}
346
+
347
+ /* ############## v5 PACKET #################### */
348
+
349
+ declare abstract class BasePacket {
350
+ static readonly tag: enums.packet;
351
+ public read(bytes: Uint8Array): void;
352
+ public write(): Uint8Array;
353
+ }
354
+
355
+ /**
356
+ * The relationship between the KeyPacket classes is modeled by considering the following:
357
+ * - A Secret (Sub)Key Packet can always be used when a Public one is expected.
358
+ * - A Subkey Packet cannot always be used when a Primary Key Packet is expected (and vice versa).
359
+ */
360
+ declare abstract class BasePublicKeyPacket extends BasePacket {
361
+ public algorithm: enums.publicKey;
362
+ public created: Date;
363
+ public version: number;
364
+ public getAlgorithmInfo(): AlgorithmInfo;
365
+ public getFingerprint(): string;
366
+ public getFingerprintBytes(): Uint8Array | null;
367
+ public hasSameFingerprintAs(other: BasePublicKeyPacket): boolean;
368
+ public getCreationTime(): Date;
369
+ public getKeyID(): KeyID;
370
+ public isDecrypted(): boolean;
371
+ public publicParams: object;
372
+ // `isSubkey` is a dummy method to ensure that Subkey packets are not accepted as Key one, and vice versa.
373
+ // The key class hierarchy is already modelled to cover this, but the concrete key packet classes
374
+ // have compatible structure and TS can't detect the difference.
375
+ protected isSubkey(): boolean;
376
+ }
377
+
378
+ export class PublicKeyPacket extends BasePublicKeyPacket {
379
+ static readonly tag: enums.packet.publicKey;
380
+ protected isSubkey(): false;
381
+ }
382
+
383
+ export class PublicSubkeyPacket extends BasePublicKeyPacket {
384
+ static readonly tag: enums.packet.publicSubkey;
385
+ protected isSubkey(): true;
386
+ }
387
+
388
+ declare abstract class BaseSecretKeyPacket extends BasePublicKeyPacket {
389
+ public privateParams: object | null;
390
+ public encrypt(passphrase: string, config?: Config): Promise<void>; // throws on error
391
+ public decrypt(passphrase: string): Promise<void>; // throws on error
392
+ public validate(): Promise<void>; // throws on error
393
+ public isDummy(): boolean;
394
+ public makeDummy(config?: Config): void;
395
+ }
396
+
397
+ export class SecretKeyPacket extends BaseSecretKeyPacket {
398
+ static readonly tag: enums.packet.secretKey;
399
+ protected isSubkey(): false;
400
+ }
401
+
402
+ export class SecretSubkeyPacket extends BaseSecretKeyPacket {
403
+ static readonly tag: enums.packet.secretSubkey;
404
+ protected isSubkey(): true;
405
+ }
406
+
407
+ export class CompressedDataPacket extends BasePacket {
408
+ static readonly tag: enums.packet.compressedData;
409
+ private compress(): void;
410
+ private decompress(config?: Config): void;
411
+ }
412
+
413
+ export class SymEncryptedIntegrityProtectedDataPacket extends BasePacket {
414
+ static readonly tag: enums.packet.symEncryptedIntegrityProtectedData;
415
+ }
416
+
417
+ export class AEADEncryptedDataPacket extends BasePacket {
418
+ static readonly tag: enums.packet.aeadEncryptedData;
419
+ private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
420
+ private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
421
+ private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>
422
+ }
423
+
424
+ export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
425
+ static readonly tag: enums.packet.publicKeyEncryptedSessionKey;
426
+ private decrypt(keyPacket: SecretKeyPacket): void; // throws on error
427
+ private encrypt(keyPacket: PublicKeyPacket): void; // throws on error
428
+ }
429
+
430
+ export class SymEncryptedSessionKey extends BasePacket {
431
+ static readonly tag: enums.packet.symEncryptedSessionKey;
432
+ private decrypt(passphrase: string): Promise<void>;
433
+ private encrypt(passphrase: string, config?: Config): Promise<void>;
434
+ }
435
+
436
+ export class LiteralDataPacket extends BasePacket {
437
+ static readonly tag: enums.packet.literalData;
438
+ private getText(clone?: boolean): MaybeStream<string>;
439
+ private getBytes(clone?: boolean): MaybeStream<Uint8Array>;
440
+ private setText(text: MaybeStream<string>, format?: enums.literal);
441
+ private setBytes(bytes: MaybeStream<Uint8Array>, format: enums.literal);
442
+ private setFilename(filename: string);
443
+ private getFilename(): string;
444
+ private writeHeader(): Uint8Array;
445
+ }
446
+
447
+ export class SymmetricallyEncryptedDataPacket extends BasePacket {
448
+ static readonly tag: enums.packet.symmetricallyEncryptedData;
449
+ private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
450
+ private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
451
+ }
452
+
453
+ export class MarkerPacket extends BasePacket {
454
+ static readonly tag: enums.packet.marker;
455
+ }
456
+
457
+ export class UserAttributePacket extends BasePacket {
458
+ static readonly tag: enums.packet.userAttribute;
459
+ private equals(packet: UserAttributePacket): boolean;
460
+ }
461
+
462
+ export class OnePassSignaturePacket extends BasePacket {
463
+ static readonly tag: enums.packet.onePassSignature;
464
+ public correspondingSig?: Promise<SignaturePacket>;
465
+ private verify: SignaturePacket['verify'];
466
+ }
467
+
468
+ export class UserIDPacket extends BasePacket {
469
+ static readonly tag: enums.packet.userID;
470
+ public readonly name: string;
471
+ public readonly comment: string;
472
+ public readonly email: string;
473
+ public readonly userID: string;
474
+ static fromObject(userID: UserID): UserIDPacket;
475
+ }
476
+
477
+ export class SignaturePacket extends BasePacket {
478
+ static readonly tag: enums.packet.signature;
479
+ public version: number;
480
+ public signatureType: enums.signature | null;
481
+ public hashAlgorithm: enums.hash | null;
482
+ public publicKeyAlgorithm: enums.publicKey | null;
483
+ public signatureData: null | Uint8Array;
484
+ public unhashedSubpackets: null | Uint8Array;
485
+ public signedHashValue: null | Uint8Array;
486
+ public created: Date | null;
487
+ public signatureExpirationTime: null | number;
488
+ public signatureNeverExpires: boolean;
489
+ public exportable: null | boolean;
490
+ public trustLevel: null | number;
491
+ public trustAmount: null | number;
492
+ public regularExpression: null | number;
493
+ public revocable: null | boolean;
494
+ public keyExpirationTime: null | number;
495
+ public keyNeverExpires: null | boolean;
496
+ public preferredSymmetricAlgorithms: enums.symmetric[] | null;
497
+ public revocationKeyClass: null | number;
498
+ public revocationKeyAlgorithm: null | enums.publicKey;
499
+ public revocationKeyFingerprint: null | Uint8Array;
500
+ public issuerKeyID: KeyID;
501
+ public notation: null | { [name: string]: string };
502
+ public preferredHashAlgorithms: enums.hash[] | null;
503
+ public preferredCompressionAlgorithms: enums.compression[] | null;
504
+ public keyServerPreferences: null | number[];
505
+ public preferredKeyServer: null | string;
506
+ public isPrimaryUserID: null | boolean;
507
+ public policyURI: null | string;
508
+ public keyFlags: Uint8Array | null;
509
+ public signersUserID: null | string;
510
+ public reasonForRevocationFlag: null | enums.reasonForRevocation;
511
+ public reasonForRevocationString: null | string;
512
+ public features: Uint8Array | null;
513
+ public signatureTargetPublicKeyAlgorithm: enums.publicKey | null;
514
+ public signatureTargetHashAlgorithm: enums.hash | null;
515
+ public signatureTargetHash: null | string;
516
+ public embeddedSignature: null | SignaturePacket;
517
+ public issuerKeyVersion: null | number;
518
+ public issuerFingerprint: null | Uint8Array;
519
+ public preferredAEADAlgorithms: enums.aead[] | null;
520
+ public revoked: null | boolean;
521
+ public sign(key: AnySecretKeyPacket, data: Uint8Array, date?: Date, detached?: boolean): Promise<void>;
522
+ public verify(key: AnyKeyPacket, signatureType: enums.signature, data: Uint8Array | object, date?: Date, detached?: boolean, config?: Config): Promise<void>; // throws on error
523
+ public isExpired(date?: Date): boolean;
524
+ public getExpirationTime(): Date | typeof Infinity;
525
+ }
526
+
527
+ export class TrustPacket extends BasePacket {
528
+ static readonly tag: enums.packet.trust;
529
+ }
530
+
531
+ export class UnparseablePacket {
532
+ tag: enums.packet;
533
+ write: () => Uint8Array;
534
+ }
535
+
536
+ export type AnyPacket = BasePacket | UnparseablePacket;
537
+ export type AnySecretKeyPacket = SecretKeyPacket | SecretSubkeyPacket;
538
+ export type AnyKeyPacket = BasePublicKeyPacket;
539
+
540
+ type AllowedPackets = Map<enums.packet, object>; // mapping to Packet classes (i.e. typeof LiteralDataPacket etc.)
541
+ export class PacketList<T extends AnyPacket> extends Array<T> {
542
+ static fromBinary(bytes: MaybeStream<Uint8Array>, allowedPackets: AllowedPackets, config?: Config): PacketList<AnyPacket>; // the packet types depend on`allowedPackets`
543
+ public read(bytes: MaybeStream<Uint8Array>, allowedPackets: AllowedPackets, config?: Config): void;
544
+ public write(): Uint8Array;
545
+ public filterByTag(...args: enums.packet[]): PacketList<T>;
546
+ public indexOfTag(...tags: enums.packet[]): number[];
547
+ public findPacket(tag: enums.packet): T | undefined;
548
+ }
549
+
550
+ /* ############## v5 STREAM #################### */
551
+
552
+ type Data = Uint8Array | string;
553
+ export interface WebStream<T extends Data> extends GenericWebStream<T> {}
554
+ export interface NodeStream<T extends Data> extends GenericNodeStream<T> {}
555
+ export type Stream<T extends Data> = WebStream<T> | NodeStream<T>;
556
+ export type MaybeStream<T extends Data> = T | Stream<T>;
557
+
558
+ /* ############## v5 GENERAL #################### */
559
+ type MaybeArray<T> = T | Array<T>;
560
+
561
+ export interface UserID { name?: string; email?: string; comment?: string; }
562
+ export interface SessionKey {
563
+ data: Uint8Array;
564
+ algorithm: enums.symmetricNames;
565
+ aeadAlgorithm?: enums.aeadNames;
566
+ }
567
+
568
+ export interface ReasonForRevocation { flag?: enums.reasonForRevocation, string?: string }
569
+
570
+ interface EncryptOptions {
571
+ /** message to be encrypted as created by createMessage */
572
+ message: Message<MaybeStream<Data>>;
573
+ /** (optional) array of keys or single key, used to encrypt the message */
574
+ encryptionKeys?: MaybeArray<PublicKey>;
575
+ /** (optional) private keys for signing. If omitted message will not be signed */
576
+ signingKeys?: MaybeArray<PrivateKey>;
577
+ /** (optional) array of passwords or a single password to encrypt the message */
578
+ passwords?: MaybeArray<string>;
579
+ /** (optional) session key */
580
+ sessionKey?: SessionKey;
581
+ /** if the return values should be ascii armored or the message/signature objects */
582
+ format?: 'armored' | 'binary' | 'object';
583
+ /** (optional) if the signature should be detached (if true, signature will be added to returned object) */
584
+ signature?: Signature;
585
+ /** (optional) encrypt as of a certain date */
586
+ date?: Date;
587
+ /** (optional) use a key ID of 0 instead of the public key IDs */
588
+ wildcard?: boolean;
589
+ /** (optional) Array of key IDs to use for signing. Each `signingKeyIDs[i]` corresponds to `signingKeys[i]` */
590
+ signingKeyIDs?: MaybeArray<KeyID>;
591
+ /** (optional) Array of key IDs to use for encryption. Each `encryptionKeyIDs[i]` corresponds to `encryptionKeys[i]`*/
592
+ encryptionKeyIDs?: MaybeArray<KeyID>;
593
+ /** (optional) Array of user IDs to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } */
594
+ signingUserIDs?: MaybeArray<UserID>;
595
+ /** (optional) array of user IDs to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } */
596
+ encryptionUserIDs?: MaybeArray<UserID>;
597
+ config?: PartialConfig;
598
+ }
599
+
600
+ interface DecryptOptions {
601
+ /** the message object with the encrypted data */
602
+ message: Message<MaybeStream<Data>>;
603
+ /** (optional) private keys with decrypted secret key data or session key */
604
+ decryptionKeys?: MaybeArray<PrivateKey>;
605
+ /** (optional) passwords to decrypt the message */
606
+ passwords?: MaybeArray<string>;
607
+ /** (optional) session keys in the form: { data:Uint8Array, algorithm:String } */
608
+ sessionKeys?: MaybeArray<SessionKey>;
609
+ /** (optional) array of public keys or single key, to verify signatures */
610
+ verificationKeys?: MaybeArray<PublicKey>;
611
+ /** (optional) whether data decryption should fail if the message is not signed with the provided publicKeys */
612
+ expectSigned?: boolean;
613
+ /** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
614
+ format?: 'utf8' | 'binary';
615
+ /** (optional) detached signature for verification */
616
+ signature?: Signature;
617
+ /** (optional) use the given date for verification instead of the current time */
618
+ date?: Date;
619
+ config?: PartialConfig;
620
+ }
621
+
622
+ interface SignOptions {
623
+ message: CleartextMessage | Message<MaybeStream<Data>>;
624
+ signingKeys: MaybeArray<PrivateKey>;
625
+ format?: 'armored' | 'binary' | 'object';
626
+ detached?: boolean;
627
+ signingKeyIDs?: MaybeArray<KeyID>;
628
+ date?: Date;
629
+ signingUserIDs?: MaybeArray<UserID>;
630
+ config?: PartialConfig;
631
+ }
632
+
633
+ interface VerifyOptions {
634
+ /** (cleartext) message object with signatures */
635
+ message: CleartextMessage | Message<MaybeStream<Data>>;
636
+ /** array of publicKeys or single key, to verify signatures */
637
+ verificationKeys: MaybeArray<PublicKey>;
638
+ /** (optional) whether verification should throw if the message is not signed with the provided publicKeys */
639
+ expectSigned?: boolean;
640
+ /** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
641
+ format?: 'utf8' | 'binary';
642
+ /** (optional) detached signature for verification */
643
+ signature?: Signature;
644
+ /** (optional) use the given date for verification instead of the current time */
645
+ date?: Date;
646
+ config?: PartialConfig;
647
+ }
648
+
649
+ interface EncryptSessionKeyOptions extends SessionKey {
650
+ encryptionKeys?: MaybeArray<PublicKey>,
651
+ passwords?: MaybeArray<string>,
652
+ format?: 'armored' | 'binary' | 'object',
653
+ date?: Date,
654
+ wildcard?: boolean,
655
+ encryptionKeyIDs?: MaybeArray<KeyID>,
656
+ encryptionUserIDs?: MaybeArray<UserID>,
657
+ config?: PartialConfig
658
+ }
659
+
660
+ interface SerializedKeyPair<T extends string|Uint8Array> {
661
+ privateKey: T;
662
+ publicKey: T;
663
+ }
664
+ interface KeyPair {
665
+ privateKey: PrivateKey;
666
+ publicKey: PublicKey;
667
+ }
668
+
669
+ export type EllipticCurveName = 'ed25519' | 'curve25519' | 'p256' | 'p384' | 'p521' | 'secp256k1' | 'brainpoolP256r1' | 'brainpoolP384r1' | 'brainpoolP512r1';
670
+
671
+ interface GenerateKeyOptions {
672
+ userIDs: MaybeArray<UserID>;
673
+ passphrase?: string;
674
+ type?: 'ecc' | 'rsa';
675
+ curve?: EllipticCurveName;
676
+ rsaBits?: number;
677
+ keyExpirationTime?: number;
678
+ date?: Date;
679
+ subkeys?: SubkeyOptions[];
680
+ format?: 'armored' | 'object' | 'binary';
681
+ config?: PartialConfig;
682
+ }
683
+ export type KeyOptions = GenerateKeyOptions;
684
+
685
+ interface SubkeyOptions {
686
+ type?: 'ecc' | 'rsa';
687
+ curve?: EllipticCurveName;
688
+ rsaBits?: number;
689
+ keyExpirationTime?: number;
690
+ date?: Date;
691
+ sign?: boolean;
692
+ config?: PartialConfig;
693
+ }
694
+
695
+ declare class KeyID {
696
+ bytes: string;
697
+ equals(keyID: KeyID, matchWildcard?: boolean): boolean;
698
+ toHex(): string;
699
+ static fromID(hex: string): KeyID;
700
+ }
701
+
702
+ interface DecryptMessageResult {
703
+ data: MaybeStream<Data>;
704
+ signatures: VerificationResult[];
705
+ filename: string;
706
+ }
707
+
708
+ interface VerifyMessageResult {
709
+ data: MaybeStream<Data>;
710
+ signatures: VerificationResult[];
711
+ }
712
+
713
+
714
+ /**
715
+ * Armor an OpenPGP binary packet block
716
+ */
717
+ export function armor(messagetype: enums.armor, body: object, partindex: number, parttotal: number, config?: Config): string;
718
+
719
+ /**
720
+ * DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
721
+ */
722
+ export function unarmor(input: string, config?: Config): Promise<{ text: string, data: Stream<Uint8Array>, type: enums.armor }>;
723
+
724
+ /* ############## v5 ENUMS #################### */
725
+
726
+ export namespace enums {
727
+ function read(type: typeof armor, e: armor): armorNames;
728
+ function read(type: typeof compression, e: compression): compressionNames;
729
+ function read(type: typeof hash, e: hash): hashNames;
730
+ function read(type: typeof packet, e: packet): packetNames;
731
+ function read(type: typeof publicKey, e: publicKey): publicKeyNames;
732
+ function read(type: typeof symmetric, e: symmetric): symmetricNames;
733
+ function read(type: typeof keyStatus, e: keyStatus): keyStatusNames;
734
+ function read(type: typeof keyFlags, e: keyFlags): keyFlagsNames;
735
+
736
+ export type armorNames = 'multipartSection' | 'multipartLast' | 'signed' | 'message' | 'publicKey' | 'privateKey';
737
+ enum armor {
738
+ multipartSection = 0,
739
+ multipartLast = 1,
740
+ signed = 2,
741
+ message = 3,
742
+ publicKey = 4,
743
+ privateKey = 5,
744
+ signature = 6,
745
+ }
746
+
747
+ enum reasonForRevocation {
748
+ noReason = 0, // No reason specified (key revocations or cert revocations)
749
+ keySuperseded = 1, // Key is superseded (key revocations)
750
+ keyCompromised = 2, // Key material has been compromised (key revocations)
751
+ keyRetired = 3, // Key is retired and no longer used (key revocations)
752
+ userIDInvalid = 32, // User ID information is no longer valid (cert revocations)
753
+ }
754
+
755
+ export type compressionNames = 'uncompressed' | 'zip' | 'zlib' | 'bzip2';
756
+ enum compression {
757
+ uncompressed = 0,
758
+ zip = 1,
759
+ zlib = 2,
760
+ bzip2 = 3,
761
+ }
762
+
763
+ export type hashNames = 'md5' | 'sha1' | 'ripemd' | 'sha256' | 'sha384' | 'sha512' | 'sha224';
764
+ enum hash {
765
+ md5 = 1,
766
+ sha1 = 2,
767
+ ripemd = 3,
768
+ sha256 = 8,
769
+ sha384 = 9,
770
+ sha512 = 10,
771
+ sha224 = 11,
772
+ }
773
+
774
+ export type packetNames = 'publicKeyEncryptedSessionKey' | 'signature' | 'symEncryptedSessionKey' | 'onePassSignature' | 'secretKey' | 'publicKey'
775
+ | 'secretSubkey' | 'compressed' | 'symmetricallyEncrypted' | 'marker' | 'literal' | 'trust' | 'userID' | 'publicSubkey' | 'userAttribute'
776
+ | 'symEncryptedIntegrityProtected' | 'modificationDetectionCode' | 'AEADEncryptedDataPacket';
777
+ enum packet {
778
+ publicKeyEncryptedSessionKey = 1,
779
+ signature = 2,
780
+ symEncryptedSessionKey = 3,
781
+ onePassSignature = 4,
782
+ secretKey = 5,
783
+ publicKey = 6,
784
+ secretSubkey = 7,
785
+ compressedData = 8,
786
+ symmetricallyEncryptedData = 9,
787
+ marker = 10,
788
+ literalData = 11,
789
+ trust = 12,
790
+ userID = 13,
791
+ publicSubkey = 14,
792
+ userAttribute = 17,
793
+ symEncryptedIntegrityProtectedData = 18,
794
+ modificationDetectionCode = 19,
795
+ aeadEncryptedData = 20,
796
+ }
797
+
798
+ export type publicKeyNames = 'rsaEncryptSign' | 'rsaEncrypt' | 'rsaSign' | 'elgamal' | 'dsa' | 'ecdh' | 'ecdsa' | 'eddsa' | 'aedh' | 'aedsa';
799
+ enum publicKey {
800
+ rsaEncryptSign = 1,
801
+ rsaEncrypt = 2,
802
+ rsaSign = 3,
803
+ elgamal = 16,
804
+ dsa = 17,
805
+ ecdh = 18,
806
+ ecdsa = 19,
807
+ eddsa = 22,
808
+ aedh = 23,
809
+ aedsa = 24,
810
+ }
811
+
812
+ enum curve {
813
+ p256 = 'p256',
814
+ p384 = 'p384',
815
+ p521 = 'p521',
816
+ ed25519 = 'ed25519',
817
+ curve25519 = 'curve25519',
818
+ secp256k1 = 'secp256k1',
819
+ brainpoolP256r1 = 'brainpoolP256r1',
820
+ brainpoolP384r1 = 'brainpoolP384r1',
821
+ brainpoolP512r1 = 'brainpoolP512r1'
822
+ }
823
+
824
+ export type symmetricNames = 'plaintext' | 'idea' | 'tripledes' | 'cast5' | 'blowfish' | 'aes128' | 'aes192' | 'aes256' | 'twofish';
825
+ enum symmetric {
826
+ plaintext = 0,
827
+ idea = 1,
828
+ tripledes = 2,
829
+ cast5 = 3,
830
+ blowfish = 4,
831
+ aes128 = 7,
832
+ aes192 = 8,
833
+ aes256 = 9,
834
+ twofish = 10,
835
+ }
836
+
837
+ export type keyStatusNames = 'invalid' | 'expired' | 'revoked' | 'valid' | 'noSelfCert';
838
+ enum keyStatus {
839
+ invalid = 0,
840
+ expired = 1,
841
+ revoked = 2,
842
+ valid = 3,
843
+ noSelfCert = 4,
844
+ }
845
+
846
+ export type keyFlagsNames = 'certifyKeys' | 'signData' | 'encryptCommunication' | 'encryptStorage' | 'splitPrivateKey' | 'authentication'
847
+ | 'sharedPrivateKey';
848
+ enum keyFlags {
849
+ certifyKeys = 1,
850
+ signData = 2,
851
+ encryptCommunication = 4,
852
+ encryptStorage = 8,
853
+ splitPrivateKey = 16,
854
+ authentication = 32,
855
+ sharedPrivateKey = 128,
856
+ }
857
+
858
+ enum signature {
859
+ binary = 0,
860
+ text = 1,
861
+ standalone = 2,
862
+ certGeneric = 16,
863
+ certPersona = 17,
864
+ certCasual = 18,
865
+ certPositive = 19,
866
+ certRevocation = 48,
867
+ subkeyBinding = 24,
868
+ keyBinding = 25,
869
+ key = 31,
870
+ keyRevocation = 32,
871
+ subkeyRevocation = 40,
872
+ timestamp = 64,
873
+ thirdParty = 80
874
+ }
875
+
876
+ export type aeadNames = 'eax' | 'ocb' | 'gcm';
877
+ enum aead {
878
+ eax = 1,
879
+ ocb = 2,
880
+ experimentalGCM = 100 // Private algorithm
881
+ }
882
+
883
+ export type literalFormatNames = 'utf8' | 'binary' | 'text' | 'mime'
884
+ enum literal {
885
+ binary = 98,
886
+ text = 116,
887
+ utf8 = 117,
888
+ mime = 109
889
+ }
890
+ }