@onekeyfe/react-native-bundle-update 1.1.21

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 (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/ReactNativeBundleUpdate.podspec +34 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +139 -0
  6. package/android/gradle.properties +4 -0
  7. package/android/src/main/AndroidManifest.xml +1 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/reactnativebundleupdate/ReactNativeBundleUpdate.kt +1409 -0
  10. package/android/src/main/java/com/margelo/nitro/reactnativebundleupdate/ReactNativeBundleUpdatePackage.kt +24 -0
  11. package/ios/Frameworks/Gopenpgp.xcframework/Info.plist +52 -0
  12. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Gopenpgp +0 -0
  13. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Armor.objc.h +96 -0
  14. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Constants.objc.h +197 -0
  15. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Crypto.objc.h +1963 -0
  16. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Gopenpgp.h +23 -0
  17. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Mime.objc.h +59 -0
  18. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Mobile.objc.h +252 -0
  19. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Profile.objc.h +107 -0
  20. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Universe.objc.h +29 -0
  21. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/ref.h +35 -0
  22. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Info.plist +20 -0
  23. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Modules/module.modulemap +13 -0
  24. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Gopenpgp +0 -0
  25. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Armor.objc.h +96 -0
  26. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Constants.objc.h +197 -0
  27. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Crypto.objc.h +1963 -0
  28. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Gopenpgp.h +23 -0
  29. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Mime.objc.h +59 -0
  30. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Mobile.objc.h +252 -0
  31. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Profile.objc.h +107 -0
  32. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Universe.objc.h +29 -0
  33. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/ref.h +35 -0
  34. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Info.plist +20 -0
  35. package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Modules/module.modulemap +13 -0
  36. package/ios/ReactNativeBundleUpdate.swift +1338 -0
  37. package/lib/module/ReactNativeBundleUpdate.nitro.js +4 -0
  38. package/lib/module/ReactNativeBundleUpdate.nitro.js.map +1 -0
  39. package/lib/module/index.js +6 -0
  40. package/lib/module/index.js.map +1 -0
  41. package/lib/module/package.json +1 -0
  42. package/lib/typescript/package.json +1 -0
  43. package/lib/typescript/src/ReactNativeBundleUpdate.nitro.d.ts +101 -0
  44. package/lib/typescript/src/ReactNativeBundleUpdate.nitro.d.ts.map +1 -0
  45. package/lib/typescript/src/index.d.ts +4 -0
  46. package/lib/typescript/src/index.d.ts.map +1 -0
  47. package/nitro.json +17 -0
  48. package/nitrogen/generated/android/c++/JAscFileInfo.hpp +65 -0
  49. package/nitrogen/generated/android/c++/JBundleDownloadASCParams.hpp +77 -0
  50. package/nitrogen/generated/android/c++/JBundleDownloadEvent.hpp +65 -0
  51. package/nitrogen/generated/android/c++/JBundleDownloadParams.hpp +73 -0
  52. package/nitrogen/generated/android/c++/JBundleDownloadResult.hpp +73 -0
  53. package/nitrogen/generated/android/c++/JBundleInstallParams.hpp +69 -0
  54. package/nitrogen/generated/android/c++/JBundleSwitchParams.hpp +65 -0
  55. package/nitrogen/generated/android/c++/JBundleVerifyASCParams.hpp +73 -0
  56. package/nitrogen/generated/android/c++/JBundleVerifyParams.hpp +69 -0
  57. package/nitrogen/generated/android/c++/JFallbackBundleInfo.hpp +65 -0
  58. package/nitrogen/generated/android/c++/JFunc_void_BundleDownloadEvent.hpp +78 -0
  59. package/nitrogen/generated/android/c++/JHybridReactNativeBundleUpdateSpec.cpp +486 -0
  60. package/nitrogen/generated/android/c++/JHybridReactNativeBundleUpdateSpec.hpp +89 -0
  61. package/nitrogen/generated/android/c++/JLocalBundleInfo.hpp +61 -0
  62. package/nitrogen/generated/android/c++/JTestResult.hpp +61 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/AscFileInfo.kt +44 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleDownloadASCParams.kt +53 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleDownloadEvent.kt +44 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleDownloadParams.kt +50 -0
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleDownloadResult.kt +50 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleInstallParams.kt +47 -0
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleSwitchParams.kt +44 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleVerifyASCParams.kt +50 -0
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/BundleVerifyParams.kt +47 -0
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/FallbackBundleInfo.kt +44 -0
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/Func_void_BundleDownloadEvent.kt +80 -0
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/HybridReactNativeBundleUpdateSpec.kt +159 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/LocalBundleInfo.kt +41 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/TestResult.kt +41 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundleupdate/reactnativebundleupdateOnLoad.kt +35 -0
  78. package/nitrogen/generated/android/reactnativebundleupdate+autolinking.cmake +81 -0
  79. package/nitrogen/generated/android/reactnativebundleupdate+autolinking.gradle +27 -0
  80. package/nitrogen/generated/android/reactnativebundleupdateOnLoad.cpp +46 -0
  81. package/nitrogen/generated/android/reactnativebundleupdateOnLoad.hpp +25 -0
  82. package/nitrogen/generated/ios/ReactNativeBundleUpdate+autolinking.rb +60 -0
  83. package/nitrogen/generated/ios/ReactNativeBundleUpdate-Swift-Cxx-Bridge.cpp +113 -0
  84. package/nitrogen/generated/ios/ReactNativeBundleUpdate-Swift-Cxx-Bridge.hpp +513 -0
  85. package/nitrogen/generated/ios/ReactNativeBundleUpdate-Swift-Cxx-Umbrella.hpp +83 -0
  86. package/nitrogen/generated/ios/ReactNativeBundleUpdateAutolinking.mm +33 -0
  87. package/nitrogen/generated/ios/ReactNativeBundleUpdateAutolinking.swift +25 -0
  88. package/nitrogen/generated/ios/c++/HybridReactNativeBundleUpdateSpecSwift.cpp +11 -0
  89. package/nitrogen/generated/ios/c++/HybridReactNativeBundleUpdateSpecSwift.hpp +304 -0
  90. package/nitrogen/generated/ios/swift/AscFileInfo.swift +58 -0
  91. package/nitrogen/generated/ios/swift/BundleDownloadASCParams.swift +91 -0
  92. package/nitrogen/generated/ios/swift/BundleDownloadEvent.swift +58 -0
  93. package/nitrogen/generated/ios/swift/BundleDownloadParams.swift +80 -0
  94. package/nitrogen/generated/ios/swift/BundleDownloadResult.swift +80 -0
  95. package/nitrogen/generated/ios/swift/BundleInstallParams.swift +69 -0
  96. package/nitrogen/generated/ios/swift/BundleSwitchParams.swift +58 -0
  97. package/nitrogen/generated/ios/swift/BundleVerifyASCParams.swift +80 -0
  98. package/nitrogen/generated/ios/swift/BundleVerifyParams.swift +69 -0
  99. package/nitrogen/generated/ios/swift/FallbackBundleInfo.swift +58 -0
  100. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  101. package/nitrogen/generated/ios/swift/Func_void_BundleDownloadEvent.swift +47 -0
  102. package/nitrogen/generated/ios/swift/Func_void_BundleDownloadResult.swift +47 -0
  103. package/nitrogen/generated/ios/swift/Func_void_TestResult.swift +47 -0
  104. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  105. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  106. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  107. package/nitrogen/generated/ios/swift/Func_void_std__vector_AscFileInfo_.swift +47 -0
  108. package/nitrogen/generated/ios/swift/Func_void_std__vector_FallbackBundleInfo_.swift +47 -0
  109. package/nitrogen/generated/ios/swift/Func_void_std__vector_LocalBundleInfo_.swift +47 -0
  110. package/nitrogen/generated/ios/swift/HybridReactNativeBundleUpdateSpec.swift +80 -0
  111. package/nitrogen/generated/ios/swift/HybridReactNativeBundleUpdateSpec_cxx.swift +595 -0
  112. package/nitrogen/generated/ios/swift/LocalBundleInfo.swift +47 -0
  113. package/nitrogen/generated/ios/swift/TestResult.swift +47 -0
  114. package/nitrogen/generated/shared/c++/AscFileInfo.hpp +83 -0
  115. package/nitrogen/generated/shared/c++/BundleDownloadASCParams.hpp +95 -0
  116. package/nitrogen/generated/shared/c++/BundleDownloadEvent.hpp +83 -0
  117. package/nitrogen/generated/shared/c++/BundleDownloadParams.hpp +91 -0
  118. package/nitrogen/generated/shared/c++/BundleDownloadResult.hpp +91 -0
  119. package/nitrogen/generated/shared/c++/BundleInstallParams.hpp +87 -0
  120. package/nitrogen/generated/shared/c++/BundleSwitchParams.hpp +83 -0
  121. package/nitrogen/generated/shared/c++/BundleVerifyASCParams.hpp +91 -0
  122. package/nitrogen/generated/shared/c++/BundleVerifyParams.hpp +87 -0
  123. package/nitrogen/generated/shared/c++/FallbackBundleInfo.hpp +83 -0
  124. package/nitrogen/generated/shared/c++/HybridReactNativeBundleUpdateSpec.cpp +45 -0
  125. package/nitrogen/generated/shared/c++/HybridReactNativeBundleUpdateSpec.hpp +124 -0
  126. package/nitrogen/generated/shared/c++/LocalBundleInfo.hpp +79 -0
  127. package/nitrogen/generated/shared/c++/TestResult.hpp +79 -0
  128. package/package.json +169 -0
  129. package/src/ReactNativeBundleUpdate.nitro.ts +143 -0
  130. package/src/index.tsx +8 -0
@@ -0,0 +1,1963 @@
1
+ // Objective-C API for talking to github.com/ProtonMail/gopenpgp/v3/crypto Go package.
2
+ // gobind -lang=objc github.com/ProtonMail/gopenpgp/v3/crypto
3
+ //
4
+ // File is generated by gobind. Do not edit.
5
+
6
+ #ifndef __Crypto_H__
7
+ #define __Crypto_H__
8
+
9
+ @import Foundation;
10
+ #include "ref.h"
11
+ #include "Universe.objc.h"
12
+
13
+ #include "Profile.objc.h"
14
+ #include "Constants.objc.h"
15
+ #include "Armor.objc.h"
16
+
17
+ @class CryptoDecryptionHandleBuilder;
18
+ @class CryptoEncryptionHandleBuilder;
19
+ @class CryptoIdentity;
20
+ @class CryptoKey;
21
+ @class CryptoKeyGenerationBuilder;
22
+ @class CryptoKeyRing;
23
+ @class CryptoLiteralMetadata;
24
+ @class CryptoPGPHandle;
25
+ @class CryptoPGPMessage;
26
+ @class CryptoPGPMessageBuffer;
27
+ @class CryptoSessionKey;
28
+ @class CryptoSignHandleBuilder;
29
+ @class CryptoSignatureVerificationError;
30
+ @class CryptoSigningContext;
31
+ @class CryptoVerificationContext;
32
+ @class CryptoVerifiedDataResult;
33
+ @class CryptoVerifiedSignature;
34
+ @class CryptoVerifyCleartextResult;
35
+ @class CryptoVerifyDataReader;
36
+ @class CryptoVerifyHandleBuilder;
37
+ @class CryptoVerifyResult;
38
+ @protocol CryptoEncryptionProfile;
39
+ @class CryptoEncryptionProfile;
40
+ @protocol CryptoKeyEncryptionProfile;
41
+ @class CryptoKeyEncryptionProfile;
42
+ @protocol CryptoKeyGenerationProfile;
43
+ @class CryptoKeyGenerationProfile;
44
+ @protocol CryptoPGPDecryption;
45
+ @class CryptoPGPDecryption;
46
+ @protocol CryptoPGPEncryption;
47
+ @class CryptoPGPEncryption;
48
+ @protocol CryptoPGPKeyGeneration;
49
+ @class CryptoPGPKeyGeneration;
50
+ @protocol CryptoPGPSign;
51
+ @class CryptoPGPSign;
52
+ @protocol CryptoPGPSplitReader;
53
+ @class CryptoPGPSplitReader;
54
+ @protocol CryptoPGPSplitWriter;
55
+ @class CryptoPGPSplitWriter;
56
+ @protocol CryptoPGPVerify;
57
+ @class CryptoPGPVerify;
58
+ @protocol CryptoReader;
59
+ @class CryptoReader;
60
+ @protocol CryptoSignProfile;
61
+ @class CryptoSignProfile;
62
+ @protocol CryptoWriteCloser;
63
+ @class CryptoWriteCloser;
64
+ @protocol CryptoWriter;
65
+ @class CryptoWriter;
66
+
67
+ @protocol CryptoEncryptionProfile <NSObject>
68
+ // skipped method EncryptionProfile.CompressionConfig with unsupported parameter or return types
69
+
70
+ // skipped method EncryptionProfile.EncryptionConfig with unsupported parameter or return types
71
+
72
+ @end
73
+
74
+ @protocol CryptoKeyEncryptionProfile <NSObject>
75
+ // skipped method KeyEncryptionProfile.KeyEncryptionConfig with unsupported parameter or return types
76
+
77
+ @end
78
+
79
+ @protocol CryptoKeyGenerationProfile <NSObject>
80
+ // skipped method KeyGenerationProfile.KeyGenerationConfig with unsupported parameter or return types
81
+
82
+ @end
83
+
84
+ @protocol CryptoPGPDecryption <NSObject>
85
+ /**
86
+ * ClearPrivateParams clears all private key material contained in EncryptionHandle from memory.
87
+ */
88
+ - (void)clearPrivateParams;
89
+ /**
90
+ * Decrypt decrypts an encrypted pgp message.
91
+ Returns a VerifiedDataResult, which can be queried for potential signature verification errors,
92
+ and the plaintext data. Note that on a signature error, the method does not return an error.
93
+ Instead, the signature error is stored within the VerifiedDataResult.
94
+ The encoding indicates if the input message should be unarmored or not, i.e., Bytes/Armor/Auto
95
+ where Auto tries to detect automatically.
96
+ */
97
+ - (CryptoVerifiedDataResult* _Nullable)decrypt:(NSData* _Nullable)pgpMessage encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
98
+ /**
99
+ * DecryptDetached provides the same functionality as Decrypt but allows
100
+ to supply an encrypted detached signature that should be decrypted and verified
101
+ against the data in the pgp message. If encDetachedSignature is nil, the behavior is similar
102
+ to Decrypt. The encoding indicates if the input message should be unarmored or not,
103
+ i.e., Bytes/Armor/Auto where Auto tries to detect automatically.
104
+ */
105
+ - (CryptoVerifiedDataResult* _Nullable)decryptDetached:(NSData* _Nullable)pgpMessage encDetachedSignature:(NSData* _Nullable)encDetachedSignature encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
106
+ /**
107
+ * DecryptSessionKey decrypts an encrypted session key.
108
+ To decrypt a session key, the decryption handle must contain either a decryption key or a password.
109
+ */
110
+ - (CryptoSessionKey* _Nullable)decryptSessionKey:(NSData* _Nullable)keyPackets error:(NSError* _Nullable* _Nullable)error;
111
+ /**
112
+ * DecryptingReader returns a wrapper around underlying encryptedMessage Reader,
113
+ such that any read-operation via the wrapper results in a read from the decrypted pgp message.
114
+ The returned VerifyDataReader has to be fully read before any potential signatures can be verified.
115
+ Either read the message fully end then call VerifySignature or use the helper method ReadAllAndVerifySignature.
116
+ The encoding indicates if the input message should be unarmored or not, i.e., Bytes/Armor/Auto
117
+ where Auto tries to detect automatically.
118
+ If encryptedMessage is of type PGPSplitReader, the method tries to verify an encrypted detached signature
119
+ that is read from the separate reader.
120
+ */
121
+ - (CryptoVerifyDataReader* _Nullable)decryptingReader:(id<CryptoReader> _Nullable)encryptedMessage encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
122
+ @end
123
+
124
+ @protocol CryptoPGPEncryption <NSObject>
125
+ /**
126
+ * ClearPrivateParams clears all private key material contained in EncryptionHandle from memory.
127
+ */
128
+ - (void)clearPrivateParams;
129
+ /**
130
+ * Encrypt encrypts a plaintext message.
131
+ */
132
+ - (CryptoPGPMessage* _Nullable)encrypt:(NSData* _Nullable)message error:(NSError* _Nullable* _Nullable)error;
133
+ /**
134
+ * EncryptSessionKey encrypts a session key with the encryption handle.
135
+ To encrypt a session key, the handle must contain either recipients or a password.
136
+ */
137
+ - (NSData* _Nullable)encryptSessionKey:(CryptoSessionKey* _Nullable)sessionKey error:(NSError* _Nullable* _Nullable)error;
138
+ /**
139
+ * EncryptingWriter returns a wrapper around underlying output Writer,
140
+ such that any write-operation via the wrapper results in a write to an encrypted pgp message.
141
+ If the output Writer is of type PGPSplitWriter, the output can be split to multiple writers
142
+ for different parts of the message. For example to write key packets and encrypted data packets
143
+ to different writers or to write a detached signature separately.
144
+ The encoding argument defines the output encoding, i.e., Bytes or Armored
145
+ The returned pgp message WriteCloser must be closed after the plaintext has been written.
146
+ */
147
+ - (id<CryptoWriteCloser> _Nullable)encryptingWriter:(id<CryptoWriter> _Nullable)output encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
148
+ /**
149
+ * GenerateSessionKey generates a random session key for the given encryption handle
150
+ considering the algorithm preferences of the recipient keys.
151
+ */
152
+ - (CryptoSessionKey* _Nullable)generateSessionKey:(NSError* _Nullable* _Nullable)error;
153
+ @end
154
+
155
+ @protocol CryptoPGPKeyGeneration <NSObject>
156
+ /**
157
+ * GenerateKey generates a pgp key with the standard security level.
158
+ */
159
+ - (CryptoKey* _Nullable)generateKey:(NSError* _Nullable* _Nullable)error;
160
+ /**
161
+ * GenerateKeyWithSecurity generates a pgp key with the given security level.
162
+ The argument security allows to set the security level, either standard or high.
163
+ */
164
+ - (CryptoKey* _Nullable)generateKeyWithSecurity:(int8_t)securityLevel error:(NSError* _Nullable* _Nullable)error;
165
+ @end
166
+
167
+ @protocol CryptoPGPSign <NSObject>
168
+ /**
169
+ * ClearPrivateParams clears all secret key material contained in the PGPSign from memory.
170
+ */
171
+ - (void)clearPrivateParams;
172
+ /**
173
+ * Sign creates a detached or inline signature from the provided byte slice.
174
+ The encoding argument defines the output encoding, i.e., Bytes or Armored
175
+ */
176
+ - (NSData* _Nullable)sign:(NSData* _Nullable)message encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
177
+ /**
178
+ * SignCleartext produces an armored cleartext message according to the specification.
179
+ Returns an armored message even if the PGPSign is not configured for armored output.
180
+ */
181
+ - (NSData* _Nullable)signCleartext:(NSData* _Nullable)message error:(NSError* _Nullable* _Nullable)error;
182
+ /**
183
+ * SigningWriter returns a wrapper around underlying output Writer,
184
+ such that any write-operation via the wrapper results in a write to a detached or inline signature message.
185
+ The encoding argument defines the output encoding, i.e., Bytes or Armored
186
+ Once close is called on the returned WriteCloser the final signature is written to the output.
187
+ Thus, the returned WriteCloser must be closed after the plaintext has been written.
188
+ */
189
+ - (id<CryptoWriteCloser> _Nullable)signingWriter:(id<CryptoWriter> _Nullable)output encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
190
+ @end
191
+
192
+ @protocol CryptoPGPSplitReader <NSObject>
193
+ - (BOOL)read:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
194
+ - (id<CryptoReader> _Nullable)signature;
195
+ @end
196
+
197
+ @protocol CryptoPGPSplitWriter <NSObject>
198
+ /**
199
+ * Keys returns the Writer to which the key packets are written to.
200
+ */
201
+ - (id<CryptoWriter> _Nullable)keys;
202
+ /**
203
+ * Signature returns the Writer to which an encrypted detached signature is written to.
204
+ */
205
+ - (id<CryptoWriter> _Nullable)signature;
206
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
207
+ @end
208
+
209
+ @protocol CryptoPGPVerify <NSObject>
210
+ /**
211
+ * VerifyCleartext verifies an armored cleartext message
212
+ and returns a VerifyCleartextResult. The VerifyCleartextResult can be checked for failure
213
+ and allows access the contained message
214
+ Note that an error is only returned if it is not a signature error.
215
+ */
216
+ - (CryptoVerifyCleartextResult* _Nullable)verifyCleartext:(NSData* _Nullable)cleartext error:(NSError* _Nullable* _Nullable)error;
217
+ /**
218
+ * VerifyDetached verifies a detached signature pgp message
219
+ and returns a VerifyResult. The VerifyResult can be checked for failure
220
+ and allows access to information about the signatures.
221
+ Note that an error is only returned if it is not a signature error.
222
+ The encoding indicates if the input signature message should be unarmored or not,
223
+ i.e., Bytes/Armor/Auto where Auto tries to detect it automatically.
224
+ */
225
+ - (CryptoVerifyResult* _Nullable)verifyDetached:(NSData* _Nullable)data signature:(NSData* _Nullable)signature encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
226
+ /**
227
+ * VerifyInline verifies an inline signed pgp message
228
+ and returns a VerifiedDataResult. The VerifiedDataResult can be checked for failure,
229
+ allows access to information about the signatures, and includes the plain message.
230
+ Note that an error is only returned if it is not a signature error.
231
+ The encoding indicates if the input message should be unarmored or not, i.e., Bytes/Armor/Auto
232
+ where Auto tries to detect it automatically.
233
+ */
234
+ - (CryptoVerifiedDataResult* _Nullable)verifyInline:(NSData* _Nullable)message encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
235
+ /**
236
+ * VerifyingReader wraps a reader with a signature verify reader.
237
+ Once all data is read from the returned verify reader, the signature can be verified
238
+ with (VerifyDataReader).VerifySignature().
239
+ Note that an error is only returned if it is not a signature error.
240
+ The encoding indicates if the input signature message should be unarmored or not,
241
+ i.e., Bytes/Armor/Auto where Auto tries to detect it automatically.
242
+ If detachedData is nil, signatureMessage is treated as an inline signature message.
243
+ Thus, it is expected that signatureMessage contains the data to be verified.
244
+ If detachedData is not nil, signatureMessage must contain a detached signature,
245
+ which is verified against the detachedData.
246
+ */
247
+ - (CryptoVerifyDataReader* _Nullable)verifyingReader:(id<CryptoReader> _Nullable)detachedData signatureMessage:(id<CryptoReader> _Nullable)signatureMessage encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
248
+ @end
249
+
250
+ @protocol CryptoReader <NSObject>
251
+ - (BOOL)read:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
252
+ @end
253
+
254
+ @protocol CryptoSignProfile <NSObject>
255
+ // skipped method SignProfile.SignConfig with unsupported parameter or return types
256
+
257
+ @end
258
+
259
+ @protocol CryptoWriteCloser <NSObject>
260
+ - (BOOL)close:(NSError* _Nullable* _Nullable)error;
261
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
262
+ @end
263
+
264
+ @protocol CryptoWriter <NSObject>
265
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
266
+ @end
267
+
268
+ /**
269
+ * DecryptionHandleBuilder allows to configure a decryption handle
270
+ to decrypt a pgp message.
271
+ */
272
+ @interface CryptoDecryptionHandleBuilder : NSObject <goSeqRefInterface> {
273
+ }
274
+ @property(strong, readonly) _Nonnull id _ref;
275
+
276
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
277
+ - (nonnull instancetype)init;
278
+ - (CryptoDecryptionHandleBuilder* _Nullable)decryptionKey:(CryptoKey* _Nullable)decryptionKey;
279
+ /**
280
+ * DecryptionKeys sets the secret keys for decrypting the pgp message.
281
+ Assumes that the message was encrypted towards one of the secret keys.
282
+ Triggers the hybrid decryption mode.
283
+ If not set, set another field for the type of decryption: SessionKey or Password.
284
+ */
285
+ - (CryptoDecryptionHandleBuilder* _Nullable)decryptionKeys:(CryptoKeyRing* _Nullable)decryptionKeyRing;
286
+ /**
287
+ * DisableAutomaticTextSanitize indicates that automatic text sanitization should be disabled.
288
+ If not disabled, the output will be sanitized if a text signature is present.
289
+ */
290
+ - (CryptoDecryptionHandleBuilder* _Nullable)disableAutomaticTextSanitize;
291
+ /**
292
+ * DisableIntendedRecipients indicates if the signature verification should not check if
293
+ the decryption key matches the intended recipients of the message.
294
+ If disabled, the decryption methods throw no error in a non-matching case.
295
+ */
296
+ - (CryptoDecryptionHandleBuilder* _Nullable)disableIntendedRecipients;
297
+ /**
298
+ * DisableStrictMessageParsing disables the check that decryption inputs conform
299
+ to the OpenPGP Message grammar.
300
+ If set, the decryption methods return no error if the message does not conform to the
301
+ OpenPGP message grammar.
302
+ */
303
+ - (CryptoDecryptionHandleBuilder* _Nullable)disableStrictMessageParsing;
304
+ /**
305
+ * DisableVerifyTimeCheck disables the check for comparing the signature creation time
306
+ against the verification time.
307
+ */
308
+ - (CryptoDecryptionHandleBuilder* _Nullable)disableVerifyTimeCheck;
309
+ - (BOOL)error:(NSError* _Nullable* _Nullable)error;
310
+ /**
311
+ * InsecureAllowDecryptionWithSigningKeys enables decryption of messages using keys
312
+ that are designated solely as signing keys.
313
+ While using the same key for both encryption and signing is discouraged
314
+ due to reduced security, this flag is useful for decrypting legacy messages.
315
+ This is because some older libraries did not respect key flags when
316
+ selecting a key for encryption.
317
+ SECURITY HAZARD: Use with care.
318
+ */
319
+ - (CryptoDecryptionHandleBuilder* _Nullable)insecureAllowDecryptionWithSigningKeys;
320
+ /**
321
+ * InsecureDisableUnauthenticatedMessagesCheck enables to read
322
+ encrypted messages without Modification Detection Code (MDC).
323
+ MDC is mandated by the latest standard and has long been implemented
324
+ in most OpenPGP implementations. Messages without MDC are considered unnecessarily
325
+ insecure and should be prevented whenever possible.
326
+ In case one needs to deal with messages from very old OpenPGP implementations, there
327
+ might be no other way than to tolerate the missing MDC. Setting this flag, allows this
328
+ mode of operation. It should be considered a measure of last resort.
329
+ SECURITY HAZARD: Use with care.
330
+ */
331
+ - (CryptoDecryptionHandleBuilder* _Nullable)insecureDisableUnauthenticatedMessagesCheck;
332
+ /**
333
+ * MaxDecompressedMessageSize defines the maximum number of bytes allowed for a message
334
+ after decompression. An error is thrown if the decompressed data exceeds this limit.
335
+ */
336
+ - (CryptoDecryptionHandleBuilder* _Nullable)maxDecompressedMessageSize:(int64_t)size;
337
+ /**
338
+ * New creates a DecryptionHandle and checks that the given
339
+ combination of parameters is valid. If one of the parameters are invalid
340
+ the latest error is returned.
341
+ */
342
+ - (id<CryptoPGPDecryption> _Nullable)new:(NSError* _Nullable* _Nullable)error;
343
+ /**
344
+ * Password sets a password that is used to derive a key to decrypt the pgp message.
345
+ Assumes that the message was encrypted with a key derived from the password.
346
+ Triggers the password decryption mode.
347
+ If not set, set another field for the type of decryption: DecryptionKeys or SessionKey.
348
+ */
349
+ - (CryptoDecryptionHandleBuilder* _Nullable)password:(NSData* _Nullable)password;
350
+ // skipped method DecryptionHandleBuilder.Passwords with unsupported parameter or return types
351
+
352
+ /**
353
+ * PlainDetachedSignature indicates that the detached signature to verify is not decrypted
354
+ and can be verified as is.
355
+ */
356
+ - (CryptoDecryptionHandleBuilder* _Nullable)plainDetachedSignature;
357
+ /**
358
+ * RetrieveSessionKey sets the flag to indicate if the session key used for decryption
359
+ should be returned to the caller of the decryption function.
360
+ */
361
+ - (CryptoDecryptionHandleBuilder* _Nullable)retrieveSessionKey;
362
+ /**
363
+ * SessionKey sets a session key for decrypting the pgp message.
364
+ Assumes that the message was encrypted with session key provided.
365
+ Triggers the session key decryption mode.
366
+ If not set, set another field for the type of decryption: DecryptionKeys or Password.
367
+ */
368
+ - (CryptoDecryptionHandleBuilder* _Nullable)sessionKey:(CryptoSessionKey* _Nullable)sessionKey;
369
+ // skipped method DecryptionHandleBuilder.SessionKeys with unsupported parameter or return types
370
+
371
+ /**
372
+ * Utf8 indicates if the output plaintext is Utf8 and
373
+ should be sanitized from canonicalised line endings.
374
+ */
375
+ - (CryptoDecryptionHandleBuilder* _Nullable)utf8;
376
+ /**
377
+ * VerificationContext sets a verification context for signatures of the pgp message, if any.
378
+ Only considered if VerifyKeys are set.
379
+ */
380
+ - (CryptoDecryptionHandleBuilder* _Nullable)verificationContext:(CryptoVerificationContext* _Nullable)verifyContext;
381
+ /**
382
+ * VerificationKey sets the public key for verifying the signatures of the pgp message, if any.
383
+ If not set, the signatures cannot be verified.
384
+ */
385
+ - (CryptoDecryptionHandleBuilder* _Nullable)verificationKey:(CryptoKey* _Nullable)key;
386
+ /**
387
+ * VerificationKeys sets the public keys for verifying the signatures of the pgp message, if any.
388
+ If not set, the signatures cannot be verified.
389
+ */
390
+ - (CryptoDecryptionHandleBuilder* _Nullable)verificationKeys:(CryptoKeyRing* _Nullable)keys;
391
+ /**
392
+ * VerifyTime sets the verification time to the provided timestamp.
393
+ If not set, the systems current time is used for signature verification.
394
+ */
395
+ - (CryptoDecryptionHandleBuilder* _Nullable)verifyTime:(int64_t)unixTime;
396
+ @end
397
+
398
+ /**
399
+ * EncryptionHandleBuilder allows to configure a decryption handle to decrypt an OpenPGP message.
400
+ */
401
+ @interface CryptoEncryptionHandleBuilder : NSObject <goSeqRefInterface> {
402
+ }
403
+ @property(strong, readonly) _Nonnull id _ref;
404
+
405
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
406
+ - (nonnull instancetype)init;
407
+ /**
408
+ * Compress indicates if the plaintext should be compressed before encryption.
409
+ Compression affects security and opens the door for side-channel attacks, which
410
+ might allow to extract the plaintext data without a decryption key.
411
+ RFC9580 recommends to not use compression.
412
+ */
413
+ - (CryptoEncryptionHandleBuilder* _Nullable)compress;
414
+ /**
415
+ * CompressWith indicates if the plaintext should be compressed before encryption.
416
+ Compression affects security and opens the door for side-channel attacks, which
417
+ might allow to extract the plaintext data without a decryption key.
418
+ RFC9580 recommends to not use compression.
419
+ Allowed config options:
420
+ constants.NoCompression: none, constants.DefaultCompression: profile default
421
+ constants.ZIPCompression: zip, constants.ZLIBCompression: zlib.
422
+ */
423
+ - (CryptoEncryptionHandleBuilder* _Nullable)compressWith:(int8_t)config;
424
+ /**
425
+ * DetachedSignature indicates that the message should be signed,
426
+ but the signature should not be included in the same pgp message as the input data.
427
+ Instead the detached signature is encrypted in a separate pgp message.
428
+ */
429
+ - (CryptoEncryptionHandleBuilder* _Nullable)detachedSignature;
430
+ /**
431
+ * EncryptionTime allows to specify a separate time for selecting encryption keys
432
+ instead of the internal clock (also used for signing). Note that the internal clock can be changed with SignTime.
433
+ If the input unixTime is 0 no expiration checks are performed on the encryption keys.
434
+ */
435
+ - (CryptoEncryptionHandleBuilder* _Nullable)encryptionTime:(int64_t)unixTime;
436
+ /**
437
+ * Error returns an errors that occurred within the builder.
438
+ */
439
+ - (BOOL)error:(NSError* _Nullable* _Nullable)error;
440
+ /**
441
+ * HiddenRecipient sets a public key to which the message should be encrypted to.
442
+ Triggers hybrid encryption with public keys of the recipients and hidden recipients.
443
+ The hidden recipients are NOT included in the intended recipient fingerprint list
444
+ of the signature, if a signature is present.
445
+ If not set, set another type of encryption: Recipients, SessionKey, or Password.
446
+ */
447
+ - (CryptoEncryptionHandleBuilder* _Nullable)hiddenRecipient:(CryptoKey* _Nullable)key;
448
+ /**
449
+ * HiddenRecipients sets the public keys to which the message should be encrypted to.
450
+ Triggers hybrid encryption with public keys of the recipients and hidden recipients.
451
+ The hidden recipients are NOT included in the intended recipient fingerprint list
452
+ of the signature, if a signature is present.
453
+ If not set, set another type of encryption: Recipients, SessionKey, or Password.
454
+ */
455
+ - (CryptoEncryptionHandleBuilder* _Nullable)hiddenRecipients:(CryptoKeyRing* _Nullable)hiddenRecipients;
456
+ /**
457
+ * IncludeExternalSignature indicates that the provided signature should be included
458
+ in the produced encrypted message.
459
+ Special feature: should not be used in normal use-cases,
460
+ can lead to broken or invalid PGP messages.
461
+ */
462
+ - (CryptoEncryptionHandleBuilder* _Nullable)includeExternalSignature:(NSData* _Nullable)signature;
463
+ /**
464
+ * New creates an EncryptionHandle and checks that the given
465
+ combination of parameters is valid. If the parameters are invalid
466
+ an error is returned.
467
+ */
468
+ - (id<CryptoPGPEncryption> _Nullable)new:(NSError* _Nullable* _Nullable)error;
469
+ /**
470
+ * Password sets a password the message should be encrypted with.
471
+ Triggers password based encryption with a key derived from the password.
472
+ If not set, set another the type of encryption: Recipients, HiddenRecipients, or SessionKey.
473
+ */
474
+ - (CryptoEncryptionHandleBuilder* _Nullable)password:(NSData* _Nullable)password;
475
+ /**
476
+ * PlainDetachedSignature indicates that the message should be signed,
477
+ but the signature should not be included in the same pgp message as the input data.
478
+ Instead the detached signature is a separate signature pgp message.
479
+ If DetachedSignature signature is set (i.e., the detached signature is encrypted), this option is ignored.
480
+ NOTE: A plaintext detached signature might reveal information about the encrypted plaintext. Thus, use with care.
481
+ */
482
+ - (CryptoEncryptionHandleBuilder* _Nullable)plainDetachedSignature;
483
+ /**
484
+ * Recipient sets the public key to which the message should be encrypted to.
485
+ Triggers hybrid encryption with public keys of the recipients and hidden recipients.
486
+ The recipients are included in the intended recipient fingerprint list
487
+ of the signature, if a signature is present.
488
+ If not set, set another type of encryption: HiddenRecipients, SessionKey, or Password.
489
+ */
490
+ - (CryptoEncryptionHandleBuilder* _Nullable)recipient:(CryptoKey* _Nullable)key;
491
+ /**
492
+ * Recipients sets the public keys to which the message should be encrypted to.
493
+ Triggers hybrid encryption with public keys of the recipients and hidden recipients.
494
+ The recipients are included in the intended recipient fingerprint list
495
+ of the signature, if a signature is present.
496
+ If not set, set another type of encryption: HiddenRecipients, SessionKey, or Password.
497
+ */
498
+ - (CryptoEncryptionHandleBuilder* _Nullable)recipients:(CryptoKeyRing* _Nullable)recipients;
499
+ /**
500
+ * SessionKey sets the session key the message should be encrypted with.
501
+ Triggers session key encryption with the included session key.
502
+ If not set, set another the type of encryption: Recipients, HiddenRecipients, or Password.
503
+ */
504
+ - (CryptoEncryptionHandleBuilder* _Nullable)sessionKey:(CryptoSessionKey* _Nullable)sessionKey;
505
+ /**
506
+ * SignTime sets the internal clock to always return
507
+ the supplied unix time for signing instead of the system time.
508
+ */
509
+ - (CryptoEncryptionHandleBuilder* _Nullable)signTime:(int64_t)unixTime;
510
+ /**
511
+ * SigningContext provides a signing context for the signature in the message.
512
+ Triggers that each signature includes the sining context.
513
+ SigningKeys have to be set if a SigningContext is provided.
514
+ */
515
+ - (CryptoEncryptionHandleBuilder* _Nullable)signingContext:(CryptoSigningContext* _Nullable)siningContext;
516
+ /**
517
+ * SigningKey sets the signing key that are used to create signature of the message.
518
+ Triggers that signatures are created for each signing key.
519
+ If not set, no signature is included.
520
+ */
521
+ - (CryptoEncryptionHandleBuilder* _Nullable)signingKey:(CryptoKey* _Nullable)key;
522
+ /**
523
+ * SigningKeys sets the signing keys that are used to create signature of the message.
524
+ Triggers that signatures are created for each signing key.
525
+ If not set, no signature is included.
526
+ */
527
+ - (CryptoEncryptionHandleBuilder* _Nullable)signingKeys:(CryptoKeyRing* _Nullable)signingKeys;
528
+ /**
529
+ * Utf8 indicates if the plaintext should be signed with a text type
530
+ signature. If set, the plaintext is signed after canonicalising the line endings.
531
+ */
532
+ - (CryptoEncryptionHandleBuilder* _Nullable)utf8;
533
+ @end
534
+
535
+ /**
536
+ * Identity contains the name and the email of a key holder.
537
+ */
538
+ @interface CryptoIdentity : NSObject <goSeqRefInterface> {
539
+ }
540
+ @property(strong, readonly) _Nonnull id _ref;
541
+
542
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
543
+ - (nonnull instancetype)init;
544
+ @property (nonatomic) NSString* _Nonnull name;
545
+ @property (nonatomic) NSString* _Nonnull email;
546
+ @end
547
+
548
+ /**
549
+ * Key contains a single private or public key.
550
+ */
551
+ @interface CryptoKey : NSObject <goSeqRefInterface> {
552
+ }
553
+ @property(strong, readonly) _Nonnull id _ref;
554
+
555
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
556
+ /**
557
+ * NewKey creates a new key from the first key in the unarmored or armored binary data.
558
+ Clones the binKeys data for go-mobile compatibility.
559
+ */
560
+ - (nullable instancetype)init:(NSData* _Nullable)binKeys;
561
+ /**
562
+ * NewKeyFromArmored creates a new key from the first key in an armored string.
563
+ */
564
+ - (nullable instancetype)initFromArmored:(NSString* _Nullable)armored;
565
+ // skipped constructor Key.NewKeyFromEntity with unsupported parameter or return types
566
+
567
+ // skipped constructor Key.NewKeyFromReader with unsupported parameter or return types
568
+
569
+ // skipped constructor Key.NewKeyFromReaderExplicit with unsupported parameter or return types
570
+
571
+ /**
572
+ * NewKeyWithCloneFlag creates a new key from the first key in the unarmored or armored binary data.
573
+ */
574
+ - (nullable instancetype)initWithCloneFlag:(NSData* _Nullable)binKeys clone:(BOOL)clone;
575
+ /**
576
+ * Armor returns the armored key as a string with default gopenpgp headers.
577
+ */
578
+ - (NSString* _Nonnull)armor:(NSError* _Nullable* _Nullable)error;
579
+ /**
580
+ * ArmorWithCustomHeaders returns the armored key as a string, with
581
+ the given headers. Empty parameters are omitted from the headers.
582
+ */
583
+ - (NSString* _Nonnull)armorWithCustomHeaders:(NSString* _Nullable)comment version:(NSString* _Nullable)version error:(NSError* _Nullable* _Nullable)error;
584
+ /**
585
+ * CanEncrypt returns true if any of the subkeys can be used for encryption.
586
+ */
587
+ - (BOOL)canEncrypt:(int64_t)unixTime;
588
+ /**
589
+ * CanVerify returns true if any of the subkeys can be used for verification.
590
+ */
591
+ - (BOOL)canVerify:(int64_t)unixTime;
592
+ /**
593
+ * Check verifies if the public keys match the private key parameters by
594
+ signing and verifying.
595
+ Deprecated: all keys are now checked on parsing.
596
+ */
597
+ - (BOOL)check:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error;
598
+ /**
599
+ * ClearPrivateParams zeroes the sensitive data in the key.
600
+ */
601
+ - (BOOL)clearPrivateParams;
602
+ /**
603
+ * Copy creates a deep copy of the key.
604
+ */
605
+ - (CryptoKey* _Nullable)copy:(NSError* _Nullable* _Nullable)error;
606
+ /**
607
+ * GetArmoredPublicKey returns the armored public keys from this keyring.
608
+ */
609
+ - (NSString* _Nonnull)getArmoredPublicKey:(NSError* _Nullable* _Nullable)error;
610
+ /**
611
+ * GetArmoredPublicKeyWithCustomHeaders returns the armored public key as a string, with
612
+ the given headers. Empty parameters are omitted from the headers.
613
+ */
614
+ - (NSString* _Nonnull)getArmoredPublicKeyWithCustomHeaders:(NSString* _Nullable)comment version:(NSString* _Nullable)version error:(NSError* _Nullable* _Nullable)error;
615
+ // skipped method Key.GetEntity with unsupported parameter or return types
616
+
617
+ /**
618
+ * GetFingerprint gets the fingerprint from the key.
619
+ */
620
+ - (NSString* _Nonnull)getFingerprint;
621
+ /**
622
+ * GetFingerprintBytes gets the fingerprint from the key as a byte slice.
623
+ */
624
+ - (NSData* _Nullable)getFingerprintBytes;
625
+ /**
626
+ * GetHexKeyID returns the key ID, hex encoded as a string.
627
+ */
628
+ - (NSString* _Nonnull)getHexKeyID;
629
+ /**
630
+ * GetJsonSHA256Fingerprints returns the SHA256 fingerprints of key and subkeys
631
+ encoded in JSON, for gomobile clients that cannot handle arrays.
632
+ */
633
+ - (NSData* _Nullable)getJsonSHA256Fingerprints:(NSError* _Nullable* _Nullable)error;
634
+ // skipped method Key.GetKeyID with unsupported parameter or return types
635
+
636
+ /**
637
+ * GetPublicKey returns the unarmored public keys from this keyring.
638
+ */
639
+ - (NSData* _Nullable)getPublicKey:(NSError* _Nullable* _Nullable)error;
640
+ /**
641
+ * GetSHA256Fingerprint computes the SHA256 fingerprint of the primary key.
642
+ */
643
+ - (NSString* _Nonnull)getSHA256Fingerprint;
644
+ // skipped method Key.GetSHA256Fingerprints with unsupported parameter or return types
645
+
646
+ /**
647
+ * GetVersion returns the OpenPGP key packet version of this key.
648
+ */
649
+ - (long)getVersion;
650
+ /**
651
+ * IsExpired checks whether the key is expired.
652
+ */
653
+ - (BOOL)isExpired:(int64_t)unixTime;
654
+ /**
655
+ * IsLocked checks if a private key is locked.
656
+ */
657
+ - (BOOL)isLocked:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error;
658
+ /**
659
+ * IsPrivate returns true if the key is private.
660
+ */
661
+ - (BOOL)isPrivate;
662
+ /**
663
+ * IsRevoked checks whether the key or the primary identity has a valid revocation signature.
664
+ */
665
+ - (BOOL)isRevoked:(int64_t)unixTime;
666
+ /**
667
+ * IsUnlocked checks if a private key is unlocked.
668
+ */
669
+ - (BOOL)isUnlocked:(BOOL* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error;
670
+ /**
671
+ * PrintFingerprints is a debug helper function that prints the key and subkey fingerprints.
672
+ */
673
+ - (void)printFingerprints;
674
+ - (NSData* _Nullable)serialize:(NSError* _Nullable* _Nullable)error;
675
+ /**
676
+ * ToPublic returns the corresponding public key of the given private key.
677
+ */
678
+ - (CryptoKey* _Nullable)toPublic:(NSError* _Nullable* _Nullable)error;
679
+ /**
680
+ * Unlock unlocks a copy of the key.
681
+ */
682
+ - (CryptoKey* _Nullable)unlock:(NSData* _Nullable)passphrase error:(NSError* _Nullable* _Nullable)error;
683
+ @end
684
+
685
+ /**
686
+ * KeyGenerationBuilder allows to configure a key generation handle to generate OpenPGP keys.
687
+ */
688
+ @interface CryptoKeyGenerationBuilder : NSObject <goSeqRefInterface> {
689
+ }
690
+ @property(strong, readonly) _Nonnull id _ref;
691
+
692
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
693
+ - (nonnull instancetype)init;
694
+ /**
695
+ * AddUserId adds the provided user identity to any generated key.
696
+ */
697
+ - (CryptoKeyGenerationBuilder* _Nullable)addUserId:(NSString* _Nullable)name email:(NSString* _Nullable)email;
698
+ /**
699
+ * GenerationTime sets the key generation time to the given unixTime.
700
+ */
701
+ - (CryptoKeyGenerationBuilder* _Nullable)generationTime:(int64_t)unixTime;
702
+ /**
703
+ * Lifetime sets the key lifetime to the given value in seconds.
704
+ The lifetime defaults to zero i.e., infinite lifetime.
705
+ */
706
+ - (CryptoKeyGenerationBuilder* _Nullable)lifetime:(int32_t)seconds;
707
+ /**
708
+ * New creates a new key generation handle from the internal configuration
709
+ that allows to generate pgp keys.
710
+ */
711
+ - (id<CryptoPGPKeyGeneration> _Nullable)new;
712
+ /**
713
+ * OverrideProfileAlgorithm allows to override the algorithm of the output key instead of using the profile's
714
+ algorithm with the respective security level.
715
+
716
+ Allowed inputs (integer enum for go-mobile compatibility):
717
+ crypto.KeyGenerationRSA4096, crypto.KeyGenerationC25519, crypto.KeyGenerationC25519Refresh
718
+ crypto.KeyGenerationC448, crypto.KeyGenerationC448Refresh.
719
+ */
720
+ - (CryptoKeyGenerationBuilder* _Nullable)overrideProfileAlgorithm:(long)algorithm;
721
+ @end
722
+
723
+ /**
724
+ * KeyRing contains multiple private and public keys.
725
+ */
726
+ @interface CryptoKeyRing : NSObject <goSeqRefInterface> {
727
+ }
728
+ @property(strong, readonly) _Nonnull id _ref;
729
+
730
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
731
+ /**
732
+ * NewKeyRing creates a new KeyRing, empty if key is nil.
733
+ */
734
+ - (nullable instancetype)init:(CryptoKey* _Nullable)key;
735
+ /**
736
+ * NewKeyRingFromBinary creates a new keyring with all the keys contained in the unarmored binary data.
737
+ Note that it accepts only unlocked or public keys, as KeyRing cannot contain locked keys.
738
+ */
739
+ - (nullable instancetype)initFromBinary:(NSData* _Nullable)binKeys;
740
+ /**
741
+ * FirstKeyID as obtained from API to match salt
742
+ */
743
+ @property (nonatomic) NSString* _Nonnull firstKeyID;
744
+ /**
745
+ * AddKey adds the given key to the keyring.
746
+ */
747
+ - (BOOL)addKey:(CryptoKey* _Nullable)key error:(NSError* _Nullable* _Nullable)error;
748
+ /**
749
+ * CanEncrypt returns true if any of the keys in the keyring can be used for encryption.
750
+ */
751
+ - (BOOL)canEncrypt:(int64_t)unixTime;
752
+ /**
753
+ * CanVerify returns true if any of the keys in the keyring can be used for verification.
754
+ */
755
+ - (BOOL)canVerify:(int64_t)unixTime;
756
+ - (void)clearPrivateParams;
757
+ /**
758
+ * Copy creates a deep copy of the keyring.
759
+ */
760
+ - (CryptoKeyRing* _Nullable)copy:(NSError* _Nullable* _Nullable)error;
761
+ /**
762
+ * CountDecryptionEntities returns the number of entities in the keyring.
763
+ Takes the current time for checking the keys in unix time format.
764
+ If the unix time is zero, time checks are ignored.
765
+ */
766
+ - (long)countDecryptionEntities:(int64_t)unixTime;
767
+ /**
768
+ * CountEntities returns the number of entities in the keyring.
769
+ */
770
+ - (long)countEntities;
771
+ /**
772
+ * FirstKey returns a KeyRing with only the first key of the original one.
773
+ */
774
+ - (CryptoKeyRing* _Nullable)firstKey:(NSError* _Nullable* _Nullable)error;
775
+ /**
776
+ * GetHexKeyIDsJson returns an IDs of keys in this KeyRing as a json array.
777
+ Key ids are encoded as hexadecimal and nil is returned if an error occurs.
778
+ Helper function for go-mobile clients.
779
+ */
780
+ - (NSData* _Nullable)getHexKeyIDsJson;
781
+ // skipped method KeyRing.GetIdentities with unsupported parameter or return types
782
+
783
+ /**
784
+ * GetIdentitiesJson returns the list of identities associated with this key ring encoded as json.
785
+ Returns nil if an encoding error occurs.
786
+ Helper function for go-mobile clients.
787
+ */
788
+ - (NSData* _Nullable)getIdentitiesJson;
789
+ /**
790
+ * GetKey returns the n-th openpgp key contained in this KeyRing.
791
+ */
792
+ - (CryptoKey* _Nullable)getKey:(long)n error:(NSError* _Nullable* _Nullable)error;
793
+ // skipped method KeyRing.GetKeyIDs with unsupported parameter or return types
794
+
795
+ // skipped method KeyRing.GetKeys with unsupported parameter or return types
796
+
797
+ /**
798
+ * Serialize serializes a KeyRing to binary data.
799
+ */
800
+ - (NSData* _Nullable)serialize:(NSError* _Nullable* _Nullable)error;
801
+ @end
802
+
803
+ @interface CryptoLiteralMetadata : NSObject <goSeqRefInterface> {
804
+ }
805
+ @property(strong, readonly) _Nonnull id _ref;
806
+
807
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
808
+ - (nonnull instancetype)init;
809
+ /**
810
+ * The file's latest modification time
811
+ */
812
+ @property (nonatomic) int64_t modTime;
813
+ /**
814
+ * Filename returns the filename of the literal metadata.
815
+ */
816
+ - (NSString* _Nonnull)filename;
817
+ /**
818
+ * IsUtf8 returns whether the literal metadata is annotated with utf-8.
819
+ */
820
+ - (BOOL)isUtf8;
821
+ - (int64_t)time;
822
+ @end
823
+
824
+ @interface CryptoPGPHandle : NSObject <goSeqRefInterface> {
825
+ }
826
+ @property(strong, readonly) _Nonnull id _ref;
827
+
828
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
829
+ - (nonnull instancetype)init;
830
+ /**
831
+ * Decryption returns a builder to create a DecryptionHandle
832
+ for decrypting pgp messages.
833
+ */
834
+ - (CryptoDecryptionHandleBuilder* _Nullable)decryption;
835
+ /**
836
+ * Encryption returns a builder to create an EncryptionHandle
837
+ for encrypting messages.
838
+ */
839
+ - (CryptoEncryptionHandleBuilder* _Nullable)encryption;
840
+ /**
841
+ * GenerateSessionKey generates a random session key for the profile.
842
+ Use GenerateSessionKey on the encryption handle, if the PGP encryption keys are known.
843
+ This function only considers the profile to determine the session key type.
844
+ */
845
+ - (CryptoSessionKey* _Nullable)generateSessionKey:(NSError* _Nullable* _Nullable)error;
846
+ /**
847
+ * KeyGeneration returns a builder to create a KeyGeneration handle.
848
+ */
849
+ - (CryptoKeyGenerationBuilder* _Nullable)keyGeneration;
850
+ /**
851
+ * LockKey encrypts the private parts of a copy of the input key with the given passphrase.
852
+ */
853
+ - (CryptoKey* _Nullable)lockKey:(CryptoKey* _Nullable)key passphrase:(NSData* _Nullable)passphrase error:(NSError* _Nullable* _Nullable)error;
854
+ /**
855
+ * Sign returns a builder to create a SignHandle
856
+ for signing messages.
857
+ */
858
+ - (CryptoSignHandleBuilder* _Nullable)sign;
859
+ /**
860
+ * Verify returns a builder to create an VerifyHandle
861
+ for verifying signatures.
862
+ */
863
+ - (CryptoVerifyHandleBuilder* _Nullable)verify;
864
+ @end
865
+
866
+ /**
867
+ * PGPMessage stores a PGP-encrypted message.
868
+ */
869
+ @interface CryptoPGPMessage : NSObject <goSeqRefInterface> {
870
+ }
871
+ @property(strong, readonly) _Nonnull id _ref;
872
+
873
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
874
+ /**
875
+ * NewPGPMessage generates a new PGPMessage from the unarmored binary data.
876
+ Clones the data for go-mobile compatibility.
877
+ */
878
+ - (nullable instancetype)init:(NSData* _Nullable)data;
879
+ /**
880
+ * NewPGPMessageFromArmored generates a new PGPMessage from an armored string ready for decryption.
881
+ */
882
+ - (nullable instancetype)initFromArmored:(NSString* _Nullable)armored;
883
+ /**
884
+ * NewPGPMessageWithCloneFlag generates a new PGPMessage from the unarmored binary data.
885
+ */
886
+ - (nullable instancetype)initWithCloneFlag:(NSData* _Nullable)data doClone:(BOOL)doClone;
887
+ /**
888
+ * KeyPacket references the PKESK and SKESK packets of the message
889
+ */
890
+ @property (nonatomic) NSData* _Nullable keyPacket;
891
+ /**
892
+ * DataPacket references the SEIPD or AEAD protected packet of the message
893
+ */
894
+ @property (nonatomic) NSData* _Nullable dataPacket;
895
+ /**
896
+ * DetachedSignature stores the encrypted detached signature.
897
+ Nil when the signature is embedded in the data packet or not present.
898
+ */
899
+ @property (nonatomic) NSData* _Nullable detachedSignature;
900
+ /**
901
+ * Armor returns the armored message as a string.
902
+ */
903
+ - (NSString* _Nonnull)armor:(NSError* _Nullable* _Nullable)error;
904
+ /**
905
+ * ArmorBytes returns the armored message as a string.
906
+ */
907
+ - (NSData* _Nullable)armorBytes:(NSError* _Nullable* _Nullable)error;
908
+ /**
909
+ * ArmorWithCustomHeaders returns the armored message as a string, with
910
+ the given headers. Empty parameters are omitted from the headers.
911
+ */
912
+ - (NSString* _Nonnull)armorWithCustomHeaders:(NSString* _Nullable)comment version:(NSString* _Nullable)version error:(NSError* _Nullable* _Nullable)error;
913
+ /**
914
+ * BinaryDataPacket returns the unarmored binary datapacket as a []byte.
915
+ */
916
+ - (NSData* _Nullable)binaryDataPacket;
917
+ /**
918
+ * BinaryKeyPacket returns the unarmored binary keypacket as a []byte.
919
+ */
920
+ - (NSData* _Nullable)binaryKeyPacket;
921
+ /**
922
+ * Bytes returns the unarmored binary content of the message as a []byte.
923
+ */
924
+ - (NSData* _Nullable)bytes;
925
+ /**
926
+ * EncryptedDetachedSignature returns the encrypted detached signature of this message
927
+ as a PGPMessage where the data is the encrypted signature.
928
+ If no detached signature is present in this message, it returns nil.
929
+ */
930
+ - (CryptoPGPMessage* _Nullable)encryptedDetachedSignature;
931
+ // skipped method PGPMessage.EncryptionKeyIDs with unsupported parameter or return types
932
+
933
+ /**
934
+ * GetNumberOfKeyPackets returns the number of keys packets in this message.
935
+ */
936
+ - (BOOL)getNumberOfKeyPackets:(long* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error;
937
+ // skipped method PGPMessage.HexEncryptionKeyIDs with unsupported parameter or return types
938
+
939
+ /**
940
+ * HexEncryptionKeyIDsJson returns the key IDs of the keys to which the session key is encrypted as a JSON array.
941
+ If an error occurs it returns nil.
942
+ Helper function for go-mobile clients.
943
+ */
944
+ - (NSData* _Nullable)hexEncryptionKeyIDsJson;
945
+ // skipped method PGPMessage.HexSignatureKeyIDs with unsupported parameter or return types
946
+
947
+ /**
948
+ * HexSignatureKeyIDsJson returns the key IDs of the keys to which the session key is encrypted as a JSON array.
949
+ If an error occurs it returns nil.
950
+ Helper function for go-mobile clients.
951
+ */
952
+ - (NSData* _Nullable)hexSignatureKeyIDsJson;
953
+ // skipped method PGPMessage.NewReader with unsupported parameter or return types
954
+
955
+ /**
956
+ * PlainDetachedSignature returns the plaintext detached signature of this message.
957
+ If no plaintext detached signature is present in this message, it returns an error.
958
+ */
959
+ - (NSData* _Nullable)plainDetachedSignature:(NSError* _Nullable* _Nullable)error;
960
+ /**
961
+ * PlainDetachedSignatureArmor returns the armored plaintext detached signature of this message.
962
+ If no plaintext detached signature is present or armoring fails it returns an error.
963
+ */
964
+ - (NSData* _Nullable)plainDetachedSignatureArmor:(NSError* _Nullable* _Nullable)error;
965
+ // skipped method PGPMessage.SignatureKeyIDs with unsupported parameter or return types
966
+
967
+ @end
968
+
969
+ @interface CryptoPGPMessageBuffer : NSObject <goSeqRefInterface, CryptoPGPSplitWriter, CryptoWriter> {
970
+ }
971
+ @property(strong, readonly) _Nonnull id _ref;
972
+
973
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
974
+ /**
975
+ * NewPGPMessageBuffer creates a message buffer.
976
+ */
977
+ - (nullable instancetype)init;
978
+ - (id<CryptoWriter> _Nullable)keys;
979
+ /**
980
+ * PGPMessage returns the PGPMessage extracted from the internal buffers.
981
+ */
982
+ - (CryptoPGPMessage* _Nullable)pgpMessage;
983
+ /**
984
+ * PGPMessageWithOptions returns the PGPMessage extracted from the internal buffers.
985
+ The isPlain flag indicates wether the detached signature is encrypted or plaintext, if any.
986
+ */
987
+ - (CryptoPGPMessage* _Nullable)pgpMessageWithOptions:(BOOL)isPlain omitArmorChecksum:(BOOL)omitArmorChecksum;
988
+ - (id<CryptoWriter> _Nullable)signature;
989
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
990
+ @end
991
+
992
+ /**
993
+ * SessionKey stores a decrypted session key.
994
+ */
995
+ @interface CryptoSessionKey : NSObject <goSeqRefInterface> {
996
+ }
997
+ @property(strong, readonly) _Nonnull id _ref;
998
+
999
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1000
+ /**
1001
+ * NewSessionKeyFromToken creates a SessionKey struct with the given token and algorithm.
1002
+ Clones the token for compatibility with go-mobile.
1003
+ */
1004
+ - (nullable instancetype)initFromToken:(NSData* _Nullable)token algo:(NSString* _Nullable)algo;
1005
+ /**
1006
+ * NewSessionKeyFromTokenWithAead creates a SessionKey struct with the given token and algorithm.
1007
+ If aead is set to true, the key is used with v6 PKESK or SKESK, and SEIPDv2 packets.
1008
+ */
1009
+ - (nullable instancetype)initFromTokenWithAead:(NSData* _Nullable)token algo:(NSString* _Nullable)algo aead:(BOOL)aead;
1010
+ /**
1011
+ * Key defines the decrypted binary session key.
1012
+ */
1013
+ @property (nonatomic) NSData* _Nullable key;
1014
+ /**
1015
+ * Algo defines the symmetric encryption algorithm used with this key.
1016
+ Only present if the key was not parsed from a v6 packet.
1017
+ */
1018
+ @property (nonatomic) NSString* _Nonnull algo;
1019
+ - (BOOL)clear;
1020
+ /**
1021
+ * GetBase64Key returns the session key as base64 encoded string.
1022
+ */
1023
+ - (NSString* _Nonnull)getBase64Key;
1024
+ // skipped method SessionKey.GetCipherFunc with unsupported parameter or return types
1025
+
1026
+ /**
1027
+ * GetCipherFuncInt returns the cipher function as int8 corresponding to the algorithm used
1028
+ with this SessionKey.
1029
+ The int8 type is used for go-mobile clients, see constant.Cipher...
1030
+ */
1031
+ - (BOOL)getCipherFuncInt:(int8_t* _Nullable)ret0_ error:(NSError* _Nullable* _Nullable)error;
1032
+ /**
1033
+ * IsV6 indicates if the session key can be used with SEIPDv2, PKESKv6/SKESKv6.
1034
+ */
1035
+ - (BOOL)isV6;
1036
+ @end
1037
+
1038
+ /**
1039
+ * SignHandleBuilder allows to configure a sign handle
1040
+ to sign data with OpenPGP.
1041
+ */
1042
+ @interface CryptoSignHandleBuilder : NSObject <goSeqRefInterface> {
1043
+ }
1044
+ @property(strong, readonly) _Nonnull id _ref;
1045
+
1046
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1047
+ - (nonnull instancetype)init;
1048
+ /**
1049
+ * ArmorHeader indicates that the produced signature should be armored
1050
+ with the given version and comment as header.
1051
+ Note that this option only affects the method SignHandle.SigningWriter
1052
+ and the headers in SignHandle.SignCleartext.
1053
+ */
1054
+ - (CryptoSignHandleBuilder* _Nullable)armorHeader:(NSString* _Nullable)version comment:(NSString* _Nullable)comment;
1055
+ /**
1056
+ * Detached indicates if a detached signature should be produced.
1057
+ The sign output will be a detached signature message without the data included.
1058
+ */
1059
+ - (CryptoSignHandleBuilder* _Nullable)detached;
1060
+ /**
1061
+ * Error returns any errors that occurred within the builder.
1062
+ */
1063
+ - (BOOL)error:(NSError* _Nullable* _Nullable)error;
1064
+ /**
1065
+ * New creates a SignHandle and checks that the given
1066
+ combination of parameters is valid. If the parameters are invalid
1067
+ an error is returned.
1068
+ */
1069
+ - (id<CryptoPGPSign> _Nullable)new:(NSError* _Nullable* _Nullable)error;
1070
+ /**
1071
+ * SignTime sets the internal clock to always return
1072
+ the supplied unix time for signing instead of the device time.
1073
+ */
1074
+ - (CryptoSignHandleBuilder* _Nullable)signTime:(int64_t)unixTime;
1075
+ /**
1076
+ * SigningContext provides a signing context for the signature in the message.
1077
+ Triggers that each signature includes the sining context.
1078
+ */
1079
+ - (CryptoSignHandleBuilder* _Nullable)signingContext:(CryptoSigningContext* _Nullable)signingContext;
1080
+ /**
1081
+ * SigningKey sets the signing key that is used to create signature of the message.
1082
+ */
1083
+ - (CryptoSignHandleBuilder* _Nullable)signingKey:(CryptoKey* _Nullable)key;
1084
+ /**
1085
+ * SigningKeys sets the signing keys that are used to create signature of the message.
1086
+ */
1087
+ - (CryptoSignHandleBuilder* _Nullable)signingKeys:(CryptoKeyRing* _Nullable)signingKeys;
1088
+ /**
1089
+ * Utf8 indicates if the plaintext should be signed with a text type
1090
+ signature. If set, the plaintext is signed after
1091
+ canonicalising the line endings.
1092
+ */
1093
+ - (CryptoSignHandleBuilder* _Nullable)utf8;
1094
+ @end
1095
+
1096
+ /**
1097
+ * SignatureVerificationError is returned from Decrypt and VerifyDetached
1098
+ functions when signature verification fails.
1099
+ */
1100
+ @interface CryptoSignatureVerificationError : NSObject <goSeqRefInterface> {
1101
+ }
1102
+ @property(strong, readonly) _Nonnull id _ref;
1103
+
1104
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1105
+ - (nonnull instancetype)init;
1106
+ @property (nonatomic) long status;
1107
+ @property (nonatomic) NSString* _Nonnull message;
1108
+ @property (nonatomic) NSError* _Nullable cause;
1109
+ /**
1110
+ * Error is the base method for all errors.
1111
+ */
1112
+ - (NSString* _Nonnull)error;
1113
+ /**
1114
+ * Unwrap returns the cause of failure.
1115
+ */
1116
+ - (BOOL)unwrap:(NSError* _Nullable* _Nullable)error;
1117
+ @end
1118
+
1119
+ /**
1120
+ * SigningContext gives the context that will be
1121
+ included in the signature's notation data.
1122
+ */
1123
+ @interface CryptoSigningContext : NSObject <goSeqRefInterface> {
1124
+ }
1125
+ @property(strong, readonly) _Nonnull id _ref;
1126
+
1127
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1128
+ /**
1129
+ * NewSigningContext creates a new signing context.
1130
+ The value is set to the notation data.
1131
+ isCritical controls whether the notation is flagged as a critical packet.
1132
+ */
1133
+ - (nullable instancetype)init:(NSString* _Nullable)value isCritical:(BOOL)isCritical;
1134
+ @property (nonatomic) NSString* _Nonnull value;
1135
+ @property (nonatomic) BOOL isCritical;
1136
+ @end
1137
+
1138
+ /**
1139
+ * VerificationContext gives the context that will be
1140
+ used to verify the signature.
1141
+ */
1142
+ @interface CryptoVerificationContext : NSObject <goSeqRefInterface> {
1143
+ }
1144
+ @property(strong, readonly) _Nonnull id _ref;
1145
+
1146
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1147
+ /**
1148
+ * NewVerificationContext creates a new verification context.
1149
+ The value is checked against the signature's notation data.
1150
+ If isRequired is false, the signature is allowed to have no context set.
1151
+ If requiredAfter is != 0, the signature is allowed to have no context set if it
1152
+ was created before the unix time set in requiredAfter.
1153
+ */
1154
+ - (nullable instancetype)init:(NSString* _Nullable)value isRequired:(BOOL)isRequired requiredAfter:(int64_t)requiredAfter;
1155
+ @property (nonatomic) NSString* _Nonnull value;
1156
+ @property (nonatomic) BOOL isRequired;
1157
+ @property (nonatomic) int64_t requiredAfter;
1158
+ @end
1159
+
1160
+ /**
1161
+ * VerifiedDataResult is a result that contains data and
1162
+ the result of a potential signature verification on the data.
1163
+ */
1164
+ @interface CryptoVerifiedDataResult : NSObject <goSeqRefInterface> {
1165
+ }
1166
+ @property(strong, readonly) _Nonnull id _ref;
1167
+
1168
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1169
+ - (nonnull instancetype)init;
1170
+ // skipped field VerifiedDataResult.VerifyResult with unsupported type: github.com/ProtonMail/gopenpgp/v3/crypto.VerifyResult
1171
+
1172
+ /**
1173
+ * Bytes returns the result data as bytes.
1174
+ */
1175
+ - (NSData* _Nullable)bytes;
1176
+ - (void)constrainToTimeRange:(int64_t)unixFrom unixTo:(int64_t)unixTo;
1177
+ /**
1178
+ * Metadata returns the associated literal metadata of the data.
1179
+ */
1180
+ - (CryptoLiteralMetadata* _Nullable)metadata;
1181
+ /**
1182
+ * SessionKey returns the session key the data is decrypted with.
1183
+ Returns nil, if the data was not encrypted or
1184
+ session key caching was not enabled.
1185
+ */
1186
+ - (CryptoSessionKey* _Nullable)sessionKey;
1187
+ - (NSData* _Nullable)signature:(NSError* _Nullable* _Nullable)error;
1188
+ - (int64_t)signatureCreationTime;
1189
+ - (BOOL)signatureError:(NSError* _Nullable* _Nullable)error;
1190
+ - (CryptoSignatureVerificationError* _Nullable)signatureErrorExplicit;
1191
+ - (NSData* _Nullable)signedByFingerprint;
1192
+ - (CryptoKey* _Nullable)signedByKey;
1193
+ // skipped method VerifiedDataResult.SignedByKeyId with unsupported parameter or return types
1194
+
1195
+ - (NSString* _Nonnull)signedByKeyIdHex;
1196
+ // skipped method VerifiedDataResult.SignedWithType with unsupported parameter or return types
1197
+
1198
+ - (int8_t)signedWithTypeInt8;
1199
+ /**
1200
+ * String returns the result data as string.
1201
+ */
1202
+ - (NSString* _Nonnull)string;
1203
+ @end
1204
+
1205
+ /**
1206
+ * VerifiedSignature is a result of a signature verification.
1207
+ */
1208
+ @interface CryptoVerifiedSignature : NSObject <goSeqRefInterface> {
1209
+ }
1210
+ @property(strong, readonly) _Nonnull id _ref;
1211
+
1212
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1213
+ - (nonnull instancetype)init;
1214
+ // skipped field VerifiedSignature.Signature with unsupported type: *github.com/ProtonMail/go-crypto/openpgp/packet.Signature
1215
+
1216
+ @property (nonatomic) CryptoKey* _Nullable signedBy;
1217
+ @property (nonatomic) CryptoSignatureVerificationError* _Nullable signatureError;
1218
+ @end
1219
+
1220
+ /**
1221
+ * VerifyCleartextResult is a result of a cleartext message verification.
1222
+ */
1223
+ @interface CryptoVerifyCleartextResult : NSObject <goSeqRefInterface> {
1224
+ }
1225
+ @property(strong, readonly) _Nonnull id _ref;
1226
+
1227
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1228
+ - (nonnull instancetype)init;
1229
+ // skipped field VerifyCleartextResult.VerifyResult with unsupported type: github.com/ProtonMail/gopenpgp/v3/crypto.VerifyResult
1230
+
1231
+ /**
1232
+ * Cleartext returns the parsed plain text of the result.
1233
+ */
1234
+ - (NSData* _Nullable)cleartext;
1235
+ - (void)constrainToTimeRange:(int64_t)unixFrom unixTo:(int64_t)unixTo;
1236
+ - (NSData* _Nullable)signature:(NSError* _Nullable* _Nullable)error;
1237
+ - (int64_t)signatureCreationTime;
1238
+ - (BOOL)signatureError:(NSError* _Nullable* _Nullable)error;
1239
+ - (CryptoSignatureVerificationError* _Nullable)signatureErrorExplicit;
1240
+ - (NSData* _Nullable)signedByFingerprint;
1241
+ - (CryptoKey* _Nullable)signedByKey;
1242
+ // skipped method VerifyCleartextResult.SignedByKeyId with unsupported parameter or return types
1243
+
1244
+ - (NSString* _Nonnull)signedByKeyIdHex;
1245
+ // skipped method VerifyCleartextResult.SignedWithType with unsupported parameter or return types
1246
+
1247
+ - (int8_t)signedWithTypeInt8;
1248
+ @end
1249
+
1250
+ /**
1251
+ * VerifyDataReader is used for reading data that should be verified with a signature.
1252
+ It further contains additional information about the parsed pgp message where the read
1253
+ data stems from.
1254
+ */
1255
+ @interface CryptoVerifyDataReader : NSObject <goSeqRefInterface, CryptoReader> {
1256
+ }
1257
+ @property(strong, readonly) _Nonnull id _ref;
1258
+
1259
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1260
+ - (nonnull instancetype)init;
1261
+ /**
1262
+ * DiscardAll reads all data from the reader and discards it.
1263
+ */
1264
+ - (BOOL)discardAll:(NSError* _Nullable* _Nullable)error;
1265
+ /**
1266
+ * DiscardAllAndVerifySignature reads all plaintext data from the reader but discards it.
1267
+ Returns a verification result for signature verification on the read data.
1268
+ */
1269
+ - (CryptoVerifyResult* _Nullable)discardAllAndVerifySignature:(NSError* _Nullable* _Nullable)error;
1270
+ /**
1271
+ * GetMetadata returns the metadata of the literal data packet that
1272
+ this reader reads from. Can be nil, if the data is not read from
1273
+ a literal data packet.
1274
+ */
1275
+ - (CryptoLiteralMetadata* _Nullable)getMetadata;
1276
+ /**
1277
+ * Read is used read data from the pgp message.
1278
+ Makes VerifyDataReader implement the Reader interface.
1279
+ */
1280
+ - (BOOL)read:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
1281
+ /**
1282
+ * ReadAll reads all plaintext data from the reader
1283
+ and returns it as a byte slice.
1284
+ */
1285
+ - (NSData* _Nullable)readAll:(NSError* _Nullable* _Nullable)error;
1286
+ /**
1287
+ * ReadAllAndVerifySignature reads all plaintext data from the reader
1288
+ and tries to verify the signatures included in the message.
1289
+ Returns the data in a VerifiedDataResult struct, which can be checked for signature errors.
1290
+ */
1291
+ - (CryptoVerifiedDataResult* _Nullable)readAllAndVerifySignature:(NSError* _Nullable* _Nullable)error;
1292
+ /**
1293
+ * SessionKey returns the session key the data is decrypted with.
1294
+ Returns nil, if this reader does not read from an encrypted message or
1295
+ session key caching was not enabled.
1296
+ */
1297
+ - (CryptoSessionKey* _Nullable)sessionKey;
1298
+ /**
1299
+ * VerifySignature is used to verify that the embedded signatures are valid.
1300
+ This method needs to be called once all the data has been read.
1301
+ It will return an error if the signature is invalid, no verifying keys are accessible,
1302
+ or if the message hasn't been read entirely.
1303
+ */
1304
+ - (CryptoVerifyResult* _Nullable)verifySignature:(NSError* _Nullable* _Nullable)error;
1305
+ @end
1306
+
1307
+ /**
1308
+ * VerifyHandleBuilder configures a VerifyHandle handle.
1309
+ */
1310
+ @interface CryptoVerifyHandleBuilder : NSObject <goSeqRefInterface> {
1311
+ }
1312
+ @property(strong, readonly) _Nonnull id _ref;
1313
+
1314
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1315
+ - (nonnull instancetype)init;
1316
+ /**
1317
+ * DisableAutomaticTextSanitize indicates that automatic text sanitization should be disabled.
1318
+ If not disabled, the output will be sanitized if a text signature is present.
1319
+ */
1320
+ - (CryptoVerifyHandleBuilder* _Nullable)disableAutomaticTextSanitize;
1321
+ /**
1322
+ * DisableStrictMessageParsing disables the check that the inputs conform
1323
+ to the OpenPGP message grammar.
1324
+ If set, no error is thrown if the input message does not conform to the
1325
+ OpenPGP specification.
1326
+ */
1327
+ - (CryptoVerifyHandleBuilder* _Nullable)disableStrictMessageParsing;
1328
+ /**
1329
+ * DisableVerifyTimeCheck disables the check for comparing the signature expiration time
1330
+ against the verification time.
1331
+ */
1332
+ - (CryptoVerifyHandleBuilder* _Nullable)disableVerifyTimeCheck;
1333
+ /**
1334
+ * Error returns any errors that occurred within the builder.
1335
+ */
1336
+ - (BOOL)error:(NSError* _Nullable* _Nullable)error;
1337
+ /**
1338
+ * MaxDecompressedMessageSize specifies the maximum allowed size, in bytes,
1339
+ for a message after decompression within an inline-signed message.
1340
+ If the decompressed message exceeds this limit, an error is returned.
1341
+ */
1342
+ - (CryptoVerifyHandleBuilder* _Nullable)maxDecompressedMessageSize:(int64_t)size;
1343
+ /**
1344
+ * New creates a VerifyHandle and checks that the given
1345
+ combination of parameters is valid. If the parameters are invalid,
1346
+ an error is returned.
1347
+ */
1348
+ - (id<CryptoPGPVerify> _Nullable)new:(NSError* _Nullable* _Nullable)error;
1349
+ /**
1350
+ * Utf8 indicates if the output plaintext is Utf8 and
1351
+ should be sanitized from canonicalised line endings.
1352
+ If enabled for detached verification, it canonicalises the input
1353
+ before verification independent of the signature type.
1354
+ */
1355
+ - (CryptoVerifyHandleBuilder* _Nullable)utf8;
1356
+ /**
1357
+ * VerificationContext sets a verification context for signatures of the pgp message, if any.
1358
+ Only considered if VerifyKeys are set.
1359
+ */
1360
+ - (CryptoVerifyHandleBuilder* _Nullable)verificationContext:(CryptoVerificationContext* _Nullable)verifyContext;
1361
+ /**
1362
+ * VerificationKey sets the public key for verifying the signatures.
1363
+ */
1364
+ - (CryptoVerifyHandleBuilder* _Nullable)verificationKey:(CryptoKey* _Nullable)key;
1365
+ /**
1366
+ * VerificationKeys sets the public keys for verifying the signatures.
1367
+ */
1368
+ - (CryptoVerifyHandleBuilder* _Nullable)verificationKeys:(CryptoKeyRing* _Nullable)keys;
1369
+ /**
1370
+ * VerifyTime sets the verification time to the provided timestamp.
1371
+ If not set, the systems current time is used for signature verification.
1372
+ */
1373
+ - (CryptoVerifyHandleBuilder* _Nullable)verifyTime:(int64_t)unixTime;
1374
+ @end
1375
+
1376
+ /**
1377
+ * VerifyResult is a result of a pgp message signature verification.
1378
+ */
1379
+ @interface CryptoVerifyResult : NSObject <goSeqRefInterface> {
1380
+ }
1381
+ @property(strong, readonly) _Nonnull id _ref;
1382
+
1383
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1384
+ - (nonnull instancetype)init;
1385
+ // skipped field VerifyResult.Signatures with unsupported type: []*github.com/ProtonMail/gopenpgp/v3/crypto.VerifiedSignature
1386
+
1387
+ /**
1388
+ * ConstrainToTimeRange updates the signature result to only consider
1389
+ signatures with a creation time within the given time frame.
1390
+ unixFrom and unixTo are in unix time and are inclusive.
1391
+ */
1392
+ - (void)constrainToTimeRange:(int64_t)unixFrom unixTo:(int64_t)unixTo;
1393
+ /**
1394
+ * Signature returns the serialized openpgp signature packet of the selected signature.
1395
+ */
1396
+ - (NSData* _Nullable)signature:(NSError* _Nullable* _Nullable)error;
1397
+ /**
1398
+ * SignatureCreationTime returns the creation time of
1399
+ the selected verified signature if found, else returns 0.
1400
+ */
1401
+ - (int64_t)signatureCreationTime;
1402
+ /**
1403
+ * SignatureError returns nil if no signature err occurred else
1404
+ the signature error.
1405
+ */
1406
+ - (BOOL)signatureError:(NSError* _Nullable* _Nullable)error;
1407
+ /**
1408
+ * SignatureErrorExplicit returns nil if no signature err occurred else
1409
+ the explicit signature error.
1410
+ */
1411
+ - (CryptoSignatureVerificationError* _Nullable)signatureErrorExplicit;
1412
+ /**
1413
+ * SignedByFingerprint returns the key fingerprint of the key that was used to verify the selected signature,
1414
+ if found, else returns nil.
1415
+ */
1416
+ - (NSData* _Nullable)signedByFingerprint;
1417
+ /**
1418
+ * SignedByKey returns the key that was used to verify the selected signature,
1419
+ if found, else returns nil.
1420
+ */
1421
+ - (CryptoKey* _Nullable)signedByKey;
1422
+ // skipped method VerifyResult.SignedByKeyId with unsupported parameter or return types
1423
+
1424
+ /**
1425
+ * SignedByKeyIdHex returns the key id of the key that was used to verify the selected signature
1426
+ as a hex encoded string.
1427
+ Helper for go-mobile.
1428
+ */
1429
+ - (NSString* _Nonnull)signedByKeyIdHex;
1430
+ // skipped method VerifyResult.SignedWithType with unsupported parameter or return types
1431
+
1432
+ /**
1433
+ * SignedWithTypeInt8 returns the type of the signature as int8 type if found, else returns 0.
1434
+ See constants.SigType... for the different types.
1435
+ */
1436
+ - (int8_t)signedWithTypeInt8;
1437
+ @end
1438
+
1439
+ /**
1440
+ * PGPEncoding determines the message encoding.
1441
+ The type is int8 for compatibility with gomobile.
1442
+ */
1443
+ FOUNDATION_EXPORT const int8_t CryptoArmor;
1444
+ /**
1445
+ * PGPEncoding determines the message encoding.
1446
+ The type is int8 for compatibility with gomobile.
1447
+ */
1448
+ FOUNDATION_EXPORT const int8_t CryptoAuto;
1449
+ /**
1450
+ * PGPEncoding determines the message encoding.
1451
+ The type is int8 for compatibility with gomobile.
1452
+ */
1453
+ FOUNDATION_EXPORT const int8_t CryptoBytes;
1454
+ /**
1455
+ * KeyGenerationCurve25519 allows to override the output key algorithm in key generation to curve25519 (as defined in RFC9580).
1456
+ */
1457
+ FOUNDATION_EXPORT const long CryptoKeyGenerationCurve25519;
1458
+ /**
1459
+ * KeyGenerationCurve25519Legacy allows to override the output key algorithm in key generation to curve25519 legacy (as defined in RFC4880bis).
1460
+ */
1461
+ FOUNDATION_EXPORT const long CryptoKeyGenerationCurve25519Legacy;
1462
+ /**
1463
+ * KeyGenerationCurve448 allows to override the output key algorithm in key generation to curve448 (as defined in RFC9580).
1464
+ */
1465
+ FOUNDATION_EXPORT const long CryptoKeyGenerationCurve448;
1466
+ /**
1467
+ * KeyGenerationRSA4096 allows to override the output key algorithm in key generation to rsa 4096.
1468
+ */
1469
+ FOUNDATION_EXPORT const long CryptoKeyGenerationRSA4096;
1470
+
1471
+ // skipped function FilterExpiredKeys with unsupported parameter or return types
1472
+
1473
+
1474
+ /**
1475
+ * GenerateSessionKeyAlgo generates a random key of the correct length for the
1476
+ specified algorithm.
1477
+ */
1478
+ FOUNDATION_EXPORT CryptoSessionKey* _Nullable CryptoGenerateSessionKeyAlgo(NSString* _Nullable algo, NSError* _Nullable* _Nullable error);
1479
+
1480
+ /**
1481
+ * IsPGPMessage checks if data if has armored PGP message format.
1482
+ */
1483
+ FOUNDATION_EXPORT BOOL CryptoIsPGPMessage(NSString* _Nullable data);
1484
+
1485
+ // skipped function NewConstantClock with unsupported parameter or return types
1486
+
1487
+
1488
+ /**
1489
+ * NewFileMetadata creates literal metadata.
1490
+ */
1491
+ FOUNDATION_EXPORT CryptoLiteralMetadata* _Nullable CryptoNewFileMetadata(BOOL isUTF8, NSString* _Nullable filename, int64_t modTime);
1492
+
1493
+ /**
1494
+ * NewKey creates a new key from the first key in the unarmored or armored binary data.
1495
+ Clones the binKeys data for go-mobile compatibility.
1496
+ */
1497
+ FOUNDATION_EXPORT CryptoKey* _Nullable CryptoNewKey(NSData* _Nullable binKeys, NSError* _Nullable* _Nullable error);
1498
+
1499
+ /**
1500
+ * NewKeyFromArmored creates a new key from the first key in an armored string.
1501
+ */
1502
+ FOUNDATION_EXPORT CryptoKey* _Nullable CryptoNewKeyFromArmored(NSString* _Nullable armored, NSError* _Nullable* _Nullable error);
1503
+
1504
+ // skipped function NewKeyFromEntity with unsupported parameter or return types
1505
+
1506
+
1507
+ // skipped function NewKeyFromReader with unsupported parameter or return types
1508
+
1509
+
1510
+ // skipped function NewKeyFromReaderExplicit with unsupported parameter or return types
1511
+
1512
+
1513
+ /**
1514
+ * NewKeyRing creates a new KeyRing, empty if key is nil.
1515
+ */
1516
+ FOUNDATION_EXPORT CryptoKeyRing* _Nullable CryptoNewKeyRing(CryptoKey* _Nullable key, NSError* _Nullable* _Nullable error);
1517
+
1518
+ /**
1519
+ * NewKeyRingFromBinary creates a new keyring with all the keys contained in the unarmored binary data.
1520
+ Note that it accepts only unlocked or public keys, as KeyRing cannot contain locked keys.
1521
+ */
1522
+ FOUNDATION_EXPORT CryptoKeyRing* _Nullable CryptoNewKeyRingFromBinary(NSData* _Nullable binKeys, NSError* _Nullable* _Nullable error);
1523
+
1524
+ /**
1525
+ * NewKeyWithCloneFlag creates a new key from the first key in the unarmored or armored binary data.
1526
+ */
1527
+ FOUNDATION_EXPORT CryptoKey* _Nullable CryptoNewKeyWithCloneFlag(NSData* _Nullable binKeys, BOOL clone, NSError* _Nullable* _Nullable error);
1528
+
1529
+ /**
1530
+ * NewMetadata creates new default literal metadata with utf-8 set to isUTF8.
1531
+ */
1532
+ FOUNDATION_EXPORT CryptoLiteralMetadata* _Nullable CryptoNewMetadata(BOOL isUTF8);
1533
+
1534
+ /**
1535
+ * NewPGPMessage generates a new PGPMessage from the unarmored binary data.
1536
+ Clones the data for go-mobile compatibility.
1537
+ */
1538
+ FOUNDATION_EXPORT CryptoPGPMessage* _Nullable CryptoNewPGPMessage(NSData* _Nullable data);
1539
+
1540
+ /**
1541
+ * NewPGPMessageBuffer creates a message buffer.
1542
+ */
1543
+ FOUNDATION_EXPORT CryptoPGPMessageBuffer* _Nullable CryptoNewPGPMessageBuffer(void);
1544
+
1545
+ /**
1546
+ * NewPGPMessageFromArmored generates a new PGPMessage from an armored string ready for decryption.
1547
+ */
1548
+ FOUNDATION_EXPORT CryptoPGPMessage* _Nullable CryptoNewPGPMessageFromArmored(NSString* _Nullable armored, NSError* _Nullable* _Nullable error);
1549
+
1550
+ /**
1551
+ * NewPGPMessageWithCloneFlag generates a new PGPMessage from the unarmored binary data.
1552
+ */
1553
+ FOUNDATION_EXPORT CryptoPGPMessage* _Nullable CryptoNewPGPMessageWithCloneFlag(NSData* _Nullable data, BOOL doClone);
1554
+
1555
+ /**
1556
+ * NewPGPSplitMessage generates a new PGPSplitMessage from the binary unarmored keypacket and datapacket.
1557
+ Clones the slices for go-mobile compatibility.
1558
+ */
1559
+ FOUNDATION_EXPORT CryptoPGPMessage* _Nullable CryptoNewPGPSplitMessage(NSData* _Nullable keyPacket, NSData* _Nullable dataPacket);
1560
+
1561
+ /**
1562
+ * NewPGPSplitWriter creates a type that implements the PGPSplitWriter interface
1563
+ for encrypting a plaintext where the output PGP packets should be written to the different streams provided.
1564
+ Key packets are written to keyPackets whereas the encrypted data packets are written to encPackets.
1565
+ The encrypted detached signature data is written to encSigPacket.
1566
+ */
1567
+ FOUNDATION_EXPORT id<CryptoPGPSplitWriter> _Nullable CryptoNewPGPSplitWriter(id<CryptoWriter> _Nullable keyPackets, id<CryptoWriter> _Nullable encPackets, id<CryptoWriter> _Nullable encSigPacket);
1568
+
1569
+ /**
1570
+ * NewPGPSplitWriterDetachedSignature creates a type that implements the PGPSplitWriter interface
1571
+ for encrypting a plaintext where the output PGP messages should be written to the different streams provided.
1572
+ The encrypted data message is written to encMessage whereas the encrypted detached signature is written to
1573
+ encSigMessage.
1574
+ */
1575
+ FOUNDATION_EXPORT id<CryptoPGPSplitWriter> _Nullable CryptoNewPGPSplitWriterDetachedSignature(id<CryptoWriter> _Nullable encMessage, id<CryptoWriter> _Nullable encSigMessage);
1576
+
1577
+ /**
1578
+ * NewPGPSplitWriterFromWriter creates a type that implements the PGPSplitWriter interface
1579
+ for encrypting a plaintext where the output PGP messages to the provided Writer.
1580
+ */
1581
+ FOUNDATION_EXPORT id<CryptoPGPSplitWriter> _Nullable CryptoNewPGPSplitWriterFromWriter(id<CryptoWriter> _Nullable writer);
1582
+
1583
+ /**
1584
+ * NewPGPSplitWriterKeyAndData creates a type that implements the PGPSplitWriter interface
1585
+ for encrypting a plaintext where the output PGP packets should be written to the different streams provided.
1586
+ Key packets are written to keyPackets whereas the encrypted data packets are written to encPackets.
1587
+ */
1588
+ FOUNDATION_EXPORT id<CryptoPGPSplitWriter> _Nullable CryptoNewPGPSplitWriterKeyAndData(id<CryptoWriter> _Nullable keyPackets, id<CryptoWriter> _Nullable encPackets);
1589
+
1590
+ /**
1591
+ * NewPrivateKeyFromArmored creates a new secret key from the first key in an armored string
1592
+ and unlocks it with the password.
1593
+ */
1594
+ FOUNDATION_EXPORT CryptoKey* _Nullable CryptoNewPrivateKeyFromArmored(NSString* _Nullable armored, NSData* _Nullable password, NSError* _Nullable* _Nullable error);
1595
+
1596
+ /**
1597
+ * NewSessionKeyFromToken creates a SessionKey struct with the given token and algorithm.
1598
+ Clones the token for compatibility with go-mobile.
1599
+ */
1600
+ FOUNDATION_EXPORT CryptoSessionKey* _Nullable CryptoNewSessionKeyFromToken(NSData* _Nullable token, NSString* _Nullable algo);
1601
+
1602
+ /**
1603
+ * NewSessionKeyFromTokenWithAead creates a SessionKey struct with the given token and algorithm.
1604
+ If aead is set to true, the key is used with v6 PKESK or SKESK, and SEIPDv2 packets.
1605
+ */
1606
+ FOUNDATION_EXPORT CryptoSessionKey* _Nullable CryptoNewSessionKeyFromTokenWithAead(NSData* _Nullable token, NSString* _Nullable algo, BOOL aead);
1607
+
1608
+ /**
1609
+ * NewSigningContext creates a new signing context.
1610
+ The value is set to the notation data.
1611
+ isCritical controls whether the notation is flagged as a critical packet.
1612
+ */
1613
+ FOUNDATION_EXPORT CryptoSigningContext* _Nullable CryptoNewSigningContext(NSString* _Nullable value, BOOL isCritical);
1614
+
1615
+ /**
1616
+ * NewVerificationContext creates a new verification context.
1617
+ The value is checked against the signature's notation data.
1618
+ If isRequired is false, the signature is allowed to have no context set.
1619
+ If requiredAfter is != 0, the signature is allowed to have no context set if it
1620
+ was created before the unix time set in requiredAfter.
1621
+ */
1622
+ FOUNDATION_EXPORT CryptoVerificationContext* _Nullable CryptoNewVerificationContext(NSString* _Nullable value, BOOL isRequired, int64_t requiredAfter);
1623
+
1624
+ /**
1625
+ * PGP creates a PGPHandle to interact with the API.
1626
+ Uses the default profile for configuration.
1627
+ */
1628
+ FOUNDATION_EXPORT CryptoPGPHandle* _Nullable CryptoPGP(void);
1629
+
1630
+ /**
1631
+ * PGPWithProfile creates a PGPHandle to interact with the API.
1632
+ Uses the provided profile for configuration.
1633
+ */
1634
+ FOUNDATION_EXPORT CryptoPGPHandle* _Nullable CryptoPGPWithProfile(ProfileCustom* _Nullable profile);
1635
+
1636
+ /**
1637
+ * RandomToken generates a random token with the specified key size.
1638
+ */
1639
+ FOUNDATION_EXPORT NSData* _Nullable CryptoRandomToken(long size, NSError* _Nullable* _Nullable error);
1640
+
1641
+ // skipped function SignatureHexKeyIDs with unsupported parameter or return types
1642
+
1643
+
1644
+ // skipped function SignatureKeyIDs with unsupported parameter or return types
1645
+
1646
+
1647
+ // skipped function ZeroClock with unsupported parameter or return types
1648
+
1649
+
1650
+ @class CryptoEncryptionProfile;
1651
+
1652
+ @class CryptoKeyEncryptionProfile;
1653
+
1654
+ @class CryptoKeyGenerationProfile;
1655
+
1656
+ @class CryptoPGPDecryption;
1657
+
1658
+ @class CryptoPGPEncryption;
1659
+
1660
+ @class CryptoPGPKeyGeneration;
1661
+
1662
+ @class CryptoPGPSign;
1663
+
1664
+ @class CryptoPGPSplitReader;
1665
+
1666
+ @class CryptoPGPSplitWriter;
1667
+
1668
+ @class CryptoPGPVerify;
1669
+
1670
+ @class CryptoReader;
1671
+
1672
+ @class CryptoSignProfile;
1673
+
1674
+ @class CryptoWriteCloser;
1675
+
1676
+ @class CryptoWriter;
1677
+
1678
+ @interface CryptoEncryptionProfile : NSObject <goSeqRefInterface, CryptoEncryptionProfile> {
1679
+ }
1680
+ @property(strong, readonly) _Nonnull id _ref;
1681
+
1682
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1683
+ // skipped method EncryptionProfile.CompressionConfig with unsupported parameter or return types
1684
+
1685
+ // skipped method EncryptionProfile.EncryptionConfig with unsupported parameter or return types
1686
+
1687
+ @end
1688
+
1689
+ @interface CryptoKeyEncryptionProfile : NSObject <goSeqRefInterface, CryptoKeyEncryptionProfile> {
1690
+ }
1691
+ @property(strong, readonly) _Nonnull id _ref;
1692
+
1693
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1694
+ // skipped method KeyEncryptionProfile.KeyEncryptionConfig with unsupported parameter or return types
1695
+
1696
+ @end
1697
+
1698
+ @interface CryptoKeyGenerationProfile : NSObject <goSeqRefInterface, CryptoKeyGenerationProfile> {
1699
+ }
1700
+ @property(strong, readonly) _Nonnull id _ref;
1701
+
1702
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1703
+ // skipped method KeyGenerationProfile.KeyGenerationConfig with unsupported parameter or return types
1704
+
1705
+ @end
1706
+
1707
+ /**
1708
+ * PGPDecryption is an interface for decrypting pgp messages with GopenPGP.
1709
+ Use the DecryptionHandleBuilder to create a handle that implements PGPDecryption.
1710
+ */
1711
+ @interface CryptoPGPDecryption : NSObject <goSeqRefInterface, CryptoPGPDecryption> {
1712
+ }
1713
+ @property(strong, readonly) _Nonnull id _ref;
1714
+
1715
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1716
+ /**
1717
+ * ClearPrivateParams clears all private key material contained in EncryptionHandle from memory.
1718
+ */
1719
+ - (void)clearPrivateParams;
1720
+ /**
1721
+ * Decrypt decrypts an encrypted pgp message.
1722
+ Returns a VerifiedDataResult, which can be queried for potential signature verification errors,
1723
+ and the plaintext data. Note that on a signature error, the method does not return an error.
1724
+ Instead, the signature error is stored within the VerifiedDataResult.
1725
+ The encoding indicates if the input message should be unarmored or not, i.e., Bytes/Armor/Auto
1726
+ where Auto tries to detect automatically.
1727
+ */
1728
+ - (CryptoVerifiedDataResult* _Nullable)decrypt:(NSData* _Nullable)pgpMessage encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1729
+ /**
1730
+ * DecryptDetached provides the same functionality as Decrypt but allows
1731
+ to supply an encrypted detached signature that should be decrypted and verified
1732
+ against the data in the pgp message. If encDetachedSignature is nil, the behavior is similar
1733
+ to Decrypt. The encoding indicates if the input message should be unarmored or not,
1734
+ i.e., Bytes/Armor/Auto where Auto tries to detect automatically.
1735
+ */
1736
+ - (CryptoVerifiedDataResult* _Nullable)decryptDetached:(NSData* _Nullable)pgpMessage encDetachedSignature:(NSData* _Nullable)encDetachedSignature encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1737
+ /**
1738
+ * DecryptSessionKey decrypts an encrypted session key.
1739
+ To decrypt a session key, the decryption handle must contain either a decryption key or a password.
1740
+ */
1741
+ - (CryptoSessionKey* _Nullable)decryptSessionKey:(NSData* _Nullable)keyPackets error:(NSError* _Nullable* _Nullable)error;
1742
+ /**
1743
+ * DecryptingReader returns a wrapper around underlying encryptedMessage Reader,
1744
+ such that any read-operation via the wrapper results in a read from the decrypted pgp message.
1745
+ The returned VerifyDataReader has to be fully read before any potential signatures can be verified.
1746
+ Either read the message fully end then call VerifySignature or use the helper method ReadAllAndVerifySignature.
1747
+ The encoding indicates if the input message should be unarmored or not, i.e., Bytes/Armor/Auto
1748
+ where Auto tries to detect automatically.
1749
+ If encryptedMessage is of type PGPSplitReader, the method tries to verify an encrypted detached signature
1750
+ that is read from the separate reader.
1751
+ */
1752
+ - (CryptoVerifyDataReader* _Nullable)decryptingReader:(id<CryptoReader> _Nullable)encryptedMessage encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1753
+ @end
1754
+
1755
+ /**
1756
+ * PGPEncryption is an interface for encrypting messages with GopenPGP.
1757
+ Use an EncryptionHandleBuilder to create a PGPEncryption handle.
1758
+ */
1759
+ @interface CryptoPGPEncryption : NSObject <goSeqRefInterface, CryptoPGPEncryption> {
1760
+ }
1761
+ @property(strong, readonly) _Nonnull id _ref;
1762
+
1763
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1764
+ /**
1765
+ * ClearPrivateParams clears all private key material contained in EncryptionHandle from memory.
1766
+ */
1767
+ - (void)clearPrivateParams;
1768
+ /**
1769
+ * Encrypt encrypts a plaintext message.
1770
+ */
1771
+ - (CryptoPGPMessage* _Nullable)encrypt:(NSData* _Nullable)message error:(NSError* _Nullable* _Nullable)error;
1772
+ /**
1773
+ * EncryptSessionKey encrypts a session key with the encryption handle.
1774
+ To encrypt a session key, the handle must contain either recipients or a password.
1775
+ */
1776
+ - (NSData* _Nullable)encryptSessionKey:(CryptoSessionKey* _Nullable)sessionKey error:(NSError* _Nullable* _Nullable)error;
1777
+ /**
1778
+ * EncryptingWriter returns a wrapper around underlying output Writer,
1779
+ such that any write-operation via the wrapper results in a write to an encrypted pgp message.
1780
+ If the output Writer is of type PGPSplitWriter, the output can be split to multiple writers
1781
+ for different parts of the message. For example to write key packets and encrypted data packets
1782
+ to different writers or to write a detached signature separately.
1783
+ The encoding argument defines the output encoding, i.e., Bytes or Armored
1784
+ The returned pgp message WriteCloser must be closed after the plaintext has been written.
1785
+ */
1786
+ - (id<CryptoWriteCloser> _Nullable)encryptingWriter:(id<CryptoWriter> _Nullable)output encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1787
+ /**
1788
+ * GenerateSessionKey generates a random session key for the given encryption handle
1789
+ considering the algorithm preferences of the recipient keys.
1790
+ */
1791
+ - (CryptoSessionKey* _Nullable)generateSessionKey:(NSError* _Nullable* _Nullable)error;
1792
+ @end
1793
+
1794
+ /**
1795
+ * PGPKeyGeneration is an interface for generating pgp keys with GopenPGP.
1796
+ Use the KeyGenerationBuilder to create a handle that implements PGPKeyGeneration.
1797
+ */
1798
+ @interface CryptoPGPKeyGeneration : NSObject <goSeqRefInterface, CryptoPGPKeyGeneration> {
1799
+ }
1800
+ @property(strong, readonly) _Nonnull id _ref;
1801
+
1802
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1803
+ /**
1804
+ * GenerateKey generates a pgp key with the standard security level.
1805
+ */
1806
+ - (CryptoKey* _Nullable)generateKey:(NSError* _Nullable* _Nullable)error;
1807
+ /**
1808
+ * GenerateKeyWithSecurity generates a pgp key with the given security level.
1809
+ The argument security allows to set the security level, either standard or high.
1810
+ */
1811
+ - (CryptoKey* _Nullable)generateKeyWithSecurity:(int8_t)securityLevel error:(NSError* _Nullable* _Nullable)error;
1812
+ @end
1813
+
1814
+ /**
1815
+ * PGPSign is an interface for creating signature messages with GopenPGP.
1816
+ */
1817
+ @interface CryptoPGPSign : NSObject <goSeqRefInterface, CryptoPGPSign> {
1818
+ }
1819
+ @property(strong, readonly) _Nonnull id _ref;
1820
+
1821
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1822
+ /**
1823
+ * ClearPrivateParams clears all secret key material contained in the PGPSign from memory.
1824
+ */
1825
+ - (void)clearPrivateParams;
1826
+ /**
1827
+ * Sign creates a detached or inline signature from the provided byte slice.
1828
+ The encoding argument defines the output encoding, i.e., Bytes or Armored
1829
+ */
1830
+ - (NSData* _Nullable)sign:(NSData* _Nullable)message encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1831
+ /**
1832
+ * SignCleartext produces an armored cleartext message according to the specification.
1833
+ Returns an armored message even if the PGPSign is not configured for armored output.
1834
+ */
1835
+ - (NSData* _Nullable)signCleartext:(NSData* _Nullable)message error:(NSError* _Nullable* _Nullable)error;
1836
+ /**
1837
+ * SigningWriter returns a wrapper around underlying output Writer,
1838
+ such that any write-operation via the wrapper results in a write to a detached or inline signature message.
1839
+ The encoding argument defines the output encoding, i.e., Bytes or Armored
1840
+ Once close is called on the returned WriteCloser the final signature is written to the output.
1841
+ Thus, the returned WriteCloser must be closed after the plaintext has been written.
1842
+ */
1843
+ - (id<CryptoWriteCloser> _Nullable)signingWriter:(id<CryptoWriter> _Nullable)output encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1844
+ @end
1845
+
1846
+ @interface CryptoPGPSplitReader : NSObject <goSeqRefInterface, CryptoPGPSplitReader> {
1847
+ }
1848
+ @property(strong, readonly) _Nonnull id _ref;
1849
+
1850
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1851
+ - (BOOL)read:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
1852
+ - (id<CryptoReader> _Nullable)signature;
1853
+ @end
1854
+
1855
+ /**
1856
+ * PGPSplitWriter is an interface to write different parts of a PGP message
1857
+ (i.e., packets) to different streams.
1858
+ */
1859
+ @interface CryptoPGPSplitWriter : NSObject <goSeqRefInterface, CryptoPGPSplitWriter> {
1860
+ }
1861
+ @property(strong, readonly) _Nonnull id _ref;
1862
+
1863
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1864
+ /**
1865
+ * Keys returns the Writer to which the key packets are written to.
1866
+ */
1867
+ - (id<CryptoWriter> _Nullable)keys;
1868
+ /**
1869
+ * Signature returns the Writer to which an encrypted detached signature is written to.
1870
+ */
1871
+ - (id<CryptoWriter> _Nullable)signature;
1872
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
1873
+ @end
1874
+
1875
+ /**
1876
+ * PGPVerify is an interface for verifying detached signatures with GopenPGP.
1877
+ */
1878
+ @interface CryptoPGPVerify : NSObject <goSeqRefInterface, CryptoPGPVerify> {
1879
+ }
1880
+ @property(strong, readonly) _Nonnull id _ref;
1881
+
1882
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1883
+ /**
1884
+ * VerifyCleartext verifies an armored cleartext message
1885
+ and returns a VerifyCleartextResult. The VerifyCleartextResult can be checked for failure
1886
+ and allows access the contained message
1887
+ Note that an error is only returned if it is not a signature error.
1888
+ */
1889
+ - (CryptoVerifyCleartextResult* _Nullable)verifyCleartext:(NSData* _Nullable)cleartext error:(NSError* _Nullable* _Nullable)error;
1890
+ /**
1891
+ * VerifyDetached verifies a detached signature pgp message
1892
+ and returns a VerifyResult. The VerifyResult can be checked for failure
1893
+ and allows access to information about the signatures.
1894
+ Note that an error is only returned if it is not a signature error.
1895
+ The encoding indicates if the input signature message should be unarmored or not,
1896
+ i.e., Bytes/Armor/Auto where Auto tries to detect it automatically.
1897
+ */
1898
+ - (CryptoVerifyResult* _Nullable)verifyDetached:(NSData* _Nullable)data signature:(NSData* _Nullable)signature encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1899
+ /**
1900
+ * VerifyInline verifies an inline signed pgp message
1901
+ and returns a VerifiedDataResult. The VerifiedDataResult can be checked for failure,
1902
+ allows access to information about the signatures, and includes the plain message.
1903
+ Note that an error is only returned if it is not a signature error.
1904
+ The encoding indicates if the input message should be unarmored or not, i.e., Bytes/Armor/Auto
1905
+ where Auto tries to detect it automatically.
1906
+ */
1907
+ - (CryptoVerifiedDataResult* _Nullable)verifyInline:(NSData* _Nullable)message encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1908
+ /**
1909
+ * VerifyingReader wraps a reader with a signature verify reader.
1910
+ Once all data is read from the returned verify reader, the signature can be verified
1911
+ with (VerifyDataReader).VerifySignature().
1912
+ Note that an error is only returned if it is not a signature error.
1913
+ The encoding indicates if the input signature message should be unarmored or not,
1914
+ i.e., Bytes/Armor/Auto where Auto tries to detect it automatically.
1915
+ If detachedData is nil, signatureMessage is treated as an inline signature message.
1916
+ Thus, it is expected that signatureMessage contains the data to be verified.
1917
+ If detachedData is not nil, signatureMessage must contain a detached signature,
1918
+ which is verified against the detachedData.
1919
+ */
1920
+ - (CryptoVerifyDataReader* _Nullable)verifyingReader:(id<CryptoReader> _Nullable)detachedData signatureMessage:(id<CryptoReader> _Nullable)signatureMessage encoding:(int8_t)encoding error:(NSError* _Nullable* _Nullable)error;
1921
+ @end
1922
+
1923
+ @interface CryptoReader : NSObject <goSeqRefInterface, CryptoReader> {
1924
+ }
1925
+ @property(strong, readonly) _Nonnull id _ref;
1926
+
1927
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1928
+ - (BOOL)read:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
1929
+ @end
1930
+
1931
+ @interface CryptoSignProfile : NSObject <goSeqRefInterface, CryptoSignProfile> {
1932
+ }
1933
+ @property(strong, readonly) _Nonnull id _ref;
1934
+
1935
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1936
+ // skipped method SignProfile.SignConfig with unsupported parameter or return types
1937
+
1938
+ @end
1939
+
1940
+ /**
1941
+ * WriteCloser replicates the io.WriteCloser interface for go-mobile.
1942
+ */
1943
+ @interface CryptoWriteCloser : NSObject <goSeqRefInterface, CryptoWriteCloser> {
1944
+ }
1945
+ @property(strong, readonly) _Nonnull id _ref;
1946
+
1947
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1948
+ - (BOOL)close:(NSError* _Nullable* _Nullable)error;
1949
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
1950
+ @end
1951
+
1952
+ /**
1953
+ * Writer replicates the io.Writer interface for go-mobile.
1954
+ */
1955
+ @interface CryptoWriter : NSObject <goSeqRefInterface, CryptoWriter> {
1956
+ }
1957
+ @property(strong, readonly) _Nonnull id _ref;
1958
+
1959
+ - (nonnull instancetype)initWithRef:(_Nonnull id)ref;
1960
+ - (BOOL)write:(NSData* _Nullable)b n:(long* _Nullable)n error:(NSError* _Nullable* _Nullable)error;
1961
+ @end
1962
+
1963
+ #endif