react-native-quick-crypto 0.7.3 → 1.0.0-beta.2

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 (309) hide show
  1. package/QuickCrypto.podspec +34 -0
  2. package/README.md +13 -46
  3. package/android/CMakeLists.txt +32 -64
  4. package/android/build.gradle +52 -125
  5. package/android/gradle.properties +4 -4
  6. package/android/src/main/cpp/cpp-adapter.cpp +9 -54
  7. package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +38 -0
  8. package/cpp/random/HybridRandom.cpp +34 -0
  9. package/cpp/random/HybridRandom.hpp +44 -0
  10. package/cpp/utils/Utils.hpp +9 -0
  11. package/ios/QuickCryptoOnLoad.mm +19 -0
  12. package/lib/commonjs/index.js +39 -39
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/random.js +26 -12
  15. package/lib/commonjs/random.js.map +1 -1
  16. package/lib/commonjs/{NativeQuickCrypto/rsa.js → specs/random.nitro.js} +1 -1
  17. package/lib/commonjs/{NativeQuickCrypto/aes.js.map → specs/random.nitro.js.map} +1 -1
  18. package/lib/commonjs/utils/conversion.js +22 -0
  19. package/lib/commonjs/utils/conversion.js.map +1 -0
  20. package/lib/commonjs/utils/index.js +12 -0
  21. package/lib/commonjs/utils/index.js.map +1 -0
  22. package/lib/commonjs/utils/types.js +2 -0
  23. package/lib/{module/NativeQuickCrypto/aes.js.map → commonjs/utils/types.js.map} +1 -1
  24. package/lib/module/index.js +38 -38
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/random.js +26 -12
  27. package/lib/module/random.js.map +1 -1
  28. package/lib/module/specs/random.nitro.js +4 -0
  29. package/lib/module/{NativeQuickCrypto/rsa.js.map → specs/random.nitro.js.map} +1 -1
  30. package/lib/module/utils/conversion.js +16 -0
  31. package/lib/module/utils/conversion.js.map +1 -0
  32. package/lib/module/utils/index.js +8 -0
  33. package/lib/module/utils/index.js.map +1 -0
  34. package/lib/module/utils/types.js +2 -0
  35. package/lib/{commonjs/NativeQuickCrypto/rsa.js.map → module/utils/types.js.map} +1 -1
  36. package/lib/tsconfig.tsbuildinfo +1 -0
  37. package/lib/typescript/index.d.ts +10 -141
  38. package/lib/typescript/index.d.ts.map +1 -1
  39. package/lib/typescript/random.d.ts +4 -5
  40. package/lib/typescript/random.d.ts.map +1 -1
  41. package/lib/typescript/specs/random.nitro.d.ts +9 -0
  42. package/lib/typescript/specs/random.nitro.d.ts.map +1 -0
  43. package/lib/typescript/utils/conversion.d.ts +4 -0
  44. package/lib/typescript/utils/conversion.d.ts.map +1 -0
  45. package/lib/typescript/utils/index.d.ts +6 -0
  46. package/lib/typescript/utils/index.d.ts.map +1 -0
  47. package/lib/typescript/utils/types.d.ts +5 -0
  48. package/lib/typescript/utils/types.d.ts.map +1 -0
  49. package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +45 -0
  50. package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +26 -0
  51. package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +57 -0
  52. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +9 -0
  53. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +25 -0
  54. package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +29 -0
  55. package/nitrogen/generated/shared/c++/HybridRandomSpec.cpp +23 -0
  56. package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +62 -0
  57. package/package.json +50 -106
  58. package/src/index.ts +38 -48
  59. package/src/random.ts +51 -48
  60. package/src/specs/random.nitro.ts +14 -0
  61. package/src/utils/conversion.ts +16 -0
  62. package/src/utils/index.ts +6 -0
  63. package/src/utils/types.ts +15 -0
  64. package/LICENSE +0 -27
  65. package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +0 -70
  66. package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoPackage.java +0 -25
  67. package/cpp/Cipher/MGLCipherHostObject.cpp +0 -663
  68. package/cpp/Cipher/MGLCipherHostObject.h +0 -90
  69. package/cpp/Cipher/MGLCreateCipherInstaller.cpp +0 -75
  70. package/cpp/Cipher/MGLCreateCipherInstaller.h +0 -22
  71. package/cpp/Cipher/MGLCreateDecipherInstaller.cpp +0 -77
  72. package/cpp/Cipher/MGLCreateDecipherInstaller.h +0 -17
  73. package/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp +0 -134
  74. package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +0 -35
  75. package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp +0 -63
  76. package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +0 -37
  77. package/cpp/Cipher/MGLPublicCipher.h +0 -124
  78. package/cpp/Cipher/MGLPublicCipherInstaller.h +0 -107
  79. package/cpp/Cipher/MGLRsa.cpp +0 -573
  80. package/cpp/Cipher/MGLRsa.h +0 -109
  81. package/cpp/HMAC/MGLHmacHostObject.cpp +0 -95
  82. package/cpp/HMAC/MGLHmacHostObject.h +0 -39
  83. package/cpp/HMAC/MGLHmacInstaller.cpp +0 -43
  84. package/cpp/HMAC/MGLHmacInstaller.h +0 -20
  85. package/cpp/Hash/MGLHashHostObject.cpp +0 -147
  86. package/cpp/Hash/MGLHashHostObject.h +0 -53
  87. package/cpp/Hash/MGLHashInstaller.cpp +0 -44
  88. package/cpp/Hash/MGLHashInstaller.h +0 -20
  89. package/cpp/JSIUtils/MGLJSIMacros.h +0 -110
  90. package/cpp/JSIUtils/MGLJSIUtils.h +0 -41
  91. package/cpp/JSIUtils/MGLSmartHostObject.cpp +0 -43
  92. package/cpp/JSIUtils/MGLSmartHostObject.h +0 -46
  93. package/cpp/JSIUtils/MGLThreadAwareHostObject.cpp +0 -24
  94. package/cpp/JSIUtils/MGLThreadAwareHostObject.h +0 -43
  95. package/cpp/JSIUtils/MGLTypedArray.cpp +0 -325
  96. package/cpp/JSIUtils/MGLTypedArray.h +0 -160
  97. package/cpp/MGLKeys.cpp +0 -1426
  98. package/cpp/MGLKeys.h +0 -203
  99. package/cpp/MGLQuickCryptoHostObject.cpp +0 -127
  100. package/cpp/MGLQuickCryptoHostObject.h +0 -30
  101. package/cpp/Random/MGLRandomHostObject.cpp +0 -96
  102. package/cpp/Random/MGLRandomHostObject.h +0 -27
  103. package/cpp/Sig/MGLSignHostObjects.cpp +0 -757
  104. package/cpp/Sig/MGLSignHostObjects.h +0 -128
  105. package/cpp/Sig/MGLSignInstaller.cpp +0 -24
  106. package/cpp/Sig/MGLSignInstaller.h +0 -29
  107. package/cpp/Sig/MGLVerifyInstaller.cpp +0 -24
  108. package/cpp/Sig/MGLVerifyInstaller.h +0 -22
  109. package/cpp/Utils/MGLDispatchQueue.cpp +0 -75
  110. package/cpp/Utils/MGLDispatchQueue.h +0 -55
  111. package/cpp/Utils/MGLUtils.cpp +0 -295
  112. package/cpp/Utils/MGLUtils.h +0 -358
  113. package/cpp/Utils/base64.h +0 -320
  114. package/cpp/Utils/logs.h +0 -38
  115. package/cpp/Utils/node.h +0 -13
  116. package/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp +0 -164
  117. package/cpp/fastpbkdf2/MGLPbkdf2HostObject.h +0 -29
  118. package/cpp/fastpbkdf2/fastpbkdf2.c +0 -352
  119. package/cpp/fastpbkdf2/fastpbkdf2.h +0 -68
  120. package/cpp/webcrypto/MGLWebCrypto.cpp +0 -125
  121. package/cpp/webcrypto/MGLWebCrypto.h +0 -32
  122. package/cpp/webcrypto/crypto_aes.cpp +0 -516
  123. package/cpp/webcrypto/crypto_aes.h +0 -79
  124. package/cpp/webcrypto/crypto_ec.cpp +0 -424
  125. package/cpp/webcrypto/crypto_ec.h +0 -78
  126. package/cpp/webcrypto/crypto_keygen.cpp +0 -86
  127. package/cpp/webcrypto/crypto_keygen.h +0 -38
  128. package/ios/QuickCrypto.xcodeproj/project.pbxproj +0 -274
  129. package/ios/QuickCryptoModule.h +0 -5
  130. package/ios/QuickCryptoModule.mm +0 -42
  131. package/lib/commonjs/Cipher.js +0 -502
  132. package/lib/commonjs/Cipher.js.map +0 -1
  133. package/lib/commonjs/Hash.js +0 -99
  134. package/lib/commonjs/Hash.js.map +0 -1
  135. package/lib/commonjs/Hashnames.js +0 -87
  136. package/lib/commonjs/Hashnames.js.map +0 -1
  137. package/lib/commonjs/Hmac.js +0 -79
  138. package/lib/commonjs/Hmac.js.map +0 -1
  139. package/lib/commonjs/NativeQuickCrypto/Cipher.js +0 -30
  140. package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +0 -1
  141. package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js +0 -52
  142. package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
  143. package/lib/commonjs/NativeQuickCrypto/aes.js +0 -6
  144. package/lib/commonjs/NativeQuickCrypto/hash.js +0 -2
  145. package/lib/commonjs/NativeQuickCrypto/hash.js.map +0 -1
  146. package/lib/commonjs/NativeQuickCrypto/hmac.js +0 -2
  147. package/lib/commonjs/NativeQuickCrypto/hmac.js.map +0 -1
  148. package/lib/commonjs/NativeQuickCrypto/keygen.js +0 -6
  149. package/lib/commonjs/NativeQuickCrypto/keygen.js.map +0 -1
  150. package/lib/commonjs/NativeQuickCrypto/pbkdf2.js +0 -2
  151. package/lib/commonjs/NativeQuickCrypto/pbkdf2.js.map +0 -1
  152. package/lib/commonjs/NativeQuickCrypto/random.js +0 -2
  153. package/lib/commonjs/NativeQuickCrypto/random.js.map +0 -1
  154. package/lib/commonjs/NativeQuickCrypto/sig.js +0 -19
  155. package/lib/commonjs/NativeQuickCrypto/sig.js.map +0 -1
  156. package/lib/commonjs/NativeQuickCrypto/webcrypto.js +0 -6
  157. package/lib/commonjs/NativeQuickCrypto/webcrypto.js.map +0 -1
  158. package/lib/commonjs/Utils.js +0 -608
  159. package/lib/commonjs/Utils.js.map +0 -1
  160. package/lib/commonjs/aes.js +0 -281
  161. package/lib/commonjs/aes.js.map +0 -1
  162. package/lib/commonjs/constants.js +0 -85
  163. package/lib/commonjs/constants.js.map +0 -1
  164. package/lib/commonjs/ec.js +0 -276
  165. package/lib/commonjs/ec.js.map +0 -1
  166. package/lib/commonjs/keygen.js +0 -56
  167. package/lib/commonjs/keygen.js.map +0 -1
  168. package/lib/commonjs/keys.js +0 -492
  169. package/lib/commonjs/keys.js.map +0 -1
  170. package/lib/commonjs/pbkdf2.js +0 -90
  171. package/lib/commonjs/pbkdf2.js.map +0 -1
  172. package/lib/commonjs/rsa.js +0 -248
  173. package/lib/commonjs/rsa.js.map +0 -1
  174. package/lib/commonjs/sig.js +0 -129
  175. package/lib/commonjs/sig.js.map +0 -1
  176. package/lib/commonjs/subtle.js +0 -448
  177. package/lib/commonjs/subtle.js.map +0 -1
  178. package/lib/commonjs/webcrypto.js +0 -14
  179. package/lib/commonjs/webcrypto.js.map +0 -1
  180. package/lib/module/Cipher.js +0 -491
  181. package/lib/module/Cipher.js.map +0 -1
  182. package/lib/module/Hash.js +0 -93
  183. package/lib/module/Hash.js.map +0 -1
  184. package/lib/module/Hashnames.js +0 -85
  185. package/lib/module/Hashnames.js.map +0 -1
  186. package/lib/module/Hmac.js +0 -74
  187. package/lib/module/Hmac.js.map +0 -1
  188. package/lib/module/NativeQuickCrypto/Cipher.js +0 -26
  189. package/lib/module/NativeQuickCrypto/Cipher.js.map +0 -1
  190. package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js +0 -49
  191. package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
  192. package/lib/module/NativeQuickCrypto/aes.js +0 -4
  193. package/lib/module/NativeQuickCrypto/hash.js +0 -2
  194. package/lib/module/NativeQuickCrypto/hash.js.map +0 -1
  195. package/lib/module/NativeQuickCrypto/hmac.js +0 -2
  196. package/lib/module/NativeQuickCrypto/hmac.js.map +0 -1
  197. package/lib/module/NativeQuickCrypto/keygen.js +0 -4
  198. package/lib/module/NativeQuickCrypto/keygen.js.map +0 -1
  199. package/lib/module/NativeQuickCrypto/pbkdf2.js +0 -2
  200. package/lib/module/NativeQuickCrypto/pbkdf2.js.map +0 -1
  201. package/lib/module/NativeQuickCrypto/random.js +0 -2
  202. package/lib/module/NativeQuickCrypto/random.js.map +0 -1
  203. package/lib/module/NativeQuickCrypto/rsa.js +0 -4
  204. package/lib/module/NativeQuickCrypto/sig.js +0 -17
  205. package/lib/module/NativeQuickCrypto/sig.js.map +0 -1
  206. package/lib/module/NativeQuickCrypto/webcrypto.js +0 -4
  207. package/lib/module/NativeQuickCrypto/webcrypto.js.map +0 -1
  208. package/lib/module/Utils.js +0 -539
  209. package/lib/module/Utils.js.map +0 -1
  210. package/lib/module/aes.js +0 -274
  211. package/lib/module/aes.js.map +0 -1
  212. package/lib/module/constants.js +0 -81
  213. package/lib/module/constants.js.map +0 -1
  214. package/lib/module/ec.js +0 -267
  215. package/lib/module/ec.js.map +0 -1
  216. package/lib/module/keygen.js +0 -49
  217. package/lib/module/keygen.js.map +0 -1
  218. package/lib/module/keys.js +0 -477
  219. package/lib/module/keys.js.map +0 -1
  220. package/lib/module/pbkdf2.js +0 -84
  221. package/lib/module/pbkdf2.js.map +0 -1
  222. package/lib/module/rsa.js +0 -242
  223. package/lib/module/rsa.js.map +0 -1
  224. package/lib/module/sig.js +0 -124
  225. package/lib/module/sig.js.map +0 -1
  226. package/lib/module/subtle.js +0 -443
  227. package/lib/module/subtle.js.map +0 -1
  228. package/lib/module/webcrypto.js +0 -10
  229. package/lib/module/webcrypto.js.map +0 -1
  230. package/lib/typescript/Cipher.d.ts +0 -81
  231. package/lib/typescript/Cipher.d.ts.map +0 -1
  232. package/lib/typescript/Hash.d.ts +0 -44
  233. package/lib/typescript/Hash.d.ts.map +0 -1
  234. package/lib/typescript/Hashnames.d.ts +0 -11
  235. package/lib/typescript/Hashnames.d.ts.map +0 -1
  236. package/lib/typescript/Hmac.d.ts +0 -37
  237. package/lib/typescript/Hmac.d.ts.map +0 -1
  238. package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +0 -44
  239. package/lib/typescript/NativeQuickCrypto/Cipher.d.ts.map +0 -1
  240. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +0 -33
  241. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +0 -1
  242. package/lib/typescript/NativeQuickCrypto/aes.d.ts +0 -5
  243. package/lib/typescript/NativeQuickCrypto/aes.d.ts.map +0 -1
  244. package/lib/typescript/NativeQuickCrypto/hash.d.ts +0 -7
  245. package/lib/typescript/NativeQuickCrypto/hash.d.ts.map +0 -1
  246. package/lib/typescript/NativeQuickCrypto/hmac.d.ts +0 -6
  247. package/lib/typescript/NativeQuickCrypto/hmac.d.ts.map +0 -1
  248. package/lib/typescript/NativeQuickCrypto/keygen.d.ts +0 -4
  249. package/lib/typescript/NativeQuickCrypto/keygen.d.ts.map +0 -1
  250. package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts +0 -5
  251. package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts.map +0 -1
  252. package/lib/typescript/NativeQuickCrypto/random.d.ts +0 -5
  253. package/lib/typescript/NativeQuickCrypto/random.d.ts.map +0 -1
  254. package/lib/typescript/NativeQuickCrypto/rsa.d.ts +0 -5
  255. package/lib/typescript/NativeQuickCrypto/rsa.d.ts.map +0 -1
  256. package/lib/typescript/NativeQuickCrypto/sig.d.ts +0 -23
  257. package/lib/typescript/NativeQuickCrypto/sig.d.ts.map +0 -1
  258. package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts +0 -39
  259. package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts.map +0 -1
  260. package/lib/typescript/Utils.d.ts +0 -48
  261. package/lib/typescript/Utils.d.ts.map +0 -1
  262. package/lib/typescript/aes.d.ts +0 -22
  263. package/lib/typescript/aes.d.ts.map +0 -1
  264. package/lib/typescript/constants.d.ts +0 -76
  265. package/lib/typescript/constants.d.ts.map +0 -1
  266. package/lib/typescript/ec.d.ts +0 -7
  267. package/lib/typescript/ec.d.ts.map +0 -1
  268. package/lib/typescript/keygen.d.ts +0 -6
  269. package/lib/typescript/keygen.d.ts.map +0 -1
  270. package/lib/typescript/keys.d.ts +0 -206
  271. package/lib/typescript/keys.d.ts.map +0 -1
  272. package/lib/typescript/pbkdf2.d.ts +0 -12
  273. package/lib/typescript/pbkdf2.d.ts.map +0 -1
  274. package/lib/typescript/rsa.d.ts +0 -12
  275. package/lib/typescript/rsa.d.ts.map +0 -1
  276. package/lib/typescript/sig.d.ts +0 -21
  277. package/lib/typescript/sig.d.ts.map +0 -1
  278. package/lib/typescript/subtle.d.ts +0 -15
  279. package/lib/typescript/subtle.d.ts.map +0 -1
  280. package/lib/typescript/webcrypto.d.ts +0 -9
  281. package/lib/typescript/webcrypto.d.ts.map +0 -1
  282. package/react-native-quick-crypto.podspec +0 -40
  283. package/src/Cipher.ts +0 -832
  284. package/src/Hash.ts +0 -132
  285. package/src/Hashnames.ts +0 -93
  286. package/src/Hmac.ts +0 -106
  287. package/src/NativeQuickCrypto/Cipher.ts +0 -102
  288. package/src/NativeQuickCrypto/NativeQuickCrypto.ts +0 -102
  289. package/src/NativeQuickCrypto/aes.ts +0 -14
  290. package/src/NativeQuickCrypto/hash.ts +0 -10
  291. package/src/NativeQuickCrypto/hmac.ts +0 -9
  292. package/src/NativeQuickCrypto/keygen.ts +0 -7
  293. package/src/NativeQuickCrypto/pbkdf2.ts +0 -16
  294. package/src/NativeQuickCrypto/random.ts +0 -12
  295. package/src/NativeQuickCrypto/rsa.ts +0 -12
  296. package/src/NativeQuickCrypto/sig.ts +0 -44
  297. package/src/NativeQuickCrypto/webcrypto.ts +0 -72
  298. package/src/Utils.ts +0 -777
  299. package/src/aes.ts +0 -402
  300. package/src/constants.ts +0 -79
  301. package/src/ec.ts +0 -375
  302. package/src/keygen.ts +0 -80
  303. package/src/keys.ts +0 -787
  304. package/src/pbkdf2.ts +0 -169
  305. package/src/rsa.ts +0 -370
  306. package/src/sig.ts +0 -164
  307. package/src/subtle.ts +0 -639
  308. package/src/webcrypto.ts +0 -8
  309. /package/android/src/main/{AndroidManifestNew.xml → AndroidManifest.xml} +0 -0
package/src/Utils.ts DELETED
@@ -1,777 +0,0 @@
1
- import { Buffer } from '@craftzdog/react-native-buffer';
2
- import type {
3
- AnyAlgorithm,
4
- DeriveBitsAlgorithm,
5
- DigestAlgorithm,
6
- EncryptDecryptAlgorithm,
7
- EncryptDecryptParams,
8
- KeyPairAlgorithm,
9
- KeyUsage,
10
- SecretKeyAlgorithm,
11
- SignVerifyAlgorithm,
12
- SubtleAlgorithm,
13
- } from './keys';
14
- import { type CipherKey } from 'crypto'; // @types/node
15
-
16
- export type BufferLike = ArrayBuffer | Buffer | ArrayBufferView;
17
- export type BinaryLike = string | ArrayBuffer | Buffer | TypedArray;
18
- export type BinaryLikeNode = CipherKey | BinaryLike;
19
-
20
- export type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary';
21
- export type CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
22
- export type LegacyCharacterEncoding = 'ascii' | 'binary' | 'ucs2' | 'ucs-2';
23
- export type Encoding =
24
- | BinaryToTextEncoding
25
- | CharacterEncoding
26
- | LegacyCharacterEncoding;
27
-
28
- // TODO(osp) should buffer be part of the Encoding type?
29
- export type CipherEncoding = Encoding | 'buffer';
30
-
31
- export type TypedArray =
32
- | Uint8Array
33
- | Uint8ClampedArray
34
- | Uint16Array
35
- | Uint32Array
36
- | Int8Array
37
- | Int16Array
38
- | Int32Array
39
- | Float32Array
40
- | Float64Array;
41
-
42
- type DOMName =
43
- | string
44
- | {
45
- name: string;
46
- cause: any;
47
- };
48
-
49
- // Mimics node behavior for default global encoding
50
- let defaultEncoding: CipherEncoding = 'buffer';
51
-
52
- export function setDefaultEncoding(encoding: CipherEncoding) {
53
- defaultEncoding = encoding;
54
- }
55
-
56
- export function getDefaultEncoding(): CipherEncoding {
57
- return defaultEncoding;
58
- }
59
-
60
- export const kEmptyObject = Object.freeze(Object.create(null));
61
-
62
- // Should be used by Cipher (or any other module that requires valid encodings)
63
- // function slowCases(enc: string) {
64
- // switch (enc.length) {
65
- // case 4:
66
- // if (enc === 'UTF8') return 'utf8';
67
- // if (enc === 'ucs2' || enc === 'UCS2') return 'utf16le';
68
- // enc = `${enc}`.toLowerCase();
69
- // if (enc === 'utf8') return 'utf8';
70
- // if (enc === 'ucs2') return 'utf16le';
71
- // break;
72
- // case 3:
73
- // if (enc === 'hex' || enc === 'HEX' || `${enc}`.toLowerCase() === 'hex')
74
- // return 'hex';
75
- // break;
76
- // case 5:
77
- // if (enc === 'ascii') return 'ascii';
78
- // if (enc === 'ucs-2') return 'utf16le';
79
- // if (enc === 'UTF-8') return 'utf8';
80
- // if (enc === 'ASCII') return 'ascii';
81
- // if (enc === 'UCS-2') return 'utf16le';
82
- // enc = `${enc}`.toLowerCase();
83
- // if (enc === 'utf-8') return 'utf8';
84
- // if (enc === 'ascii') return 'ascii';
85
- // if (enc === 'ucs-2') return 'utf16le';
86
- // break;
87
- // case 6:
88
- // if (enc === 'base64') return 'base64';
89
- // if (enc === 'latin1' || enc === 'binary') return 'latin1';
90
- // if (enc === 'BASE64') return 'base64';
91
- // if (enc === 'LATIN1' || enc === 'BINARY') return 'latin1';
92
- // enc = `${enc}`.toLowerCase();
93
- // if (enc === 'base64') return 'base64';
94
- // if (enc === 'latin1' || enc === 'binary') return 'latin1';
95
- // break;
96
- // case 7:
97
- // if (
98
- // enc === 'utf16le' ||
99
- // enc === 'UTF16LE' ||
100
- // `${enc}`.toLowerCase() === 'utf16le'
101
- // )
102
- // return 'utf16le';
103
- // break;
104
- // case 8:
105
- // if (
106
- // enc === 'utf-16le' ||
107
- // enc === 'UTF-16LE' ||
108
- // `${enc}`.toLowerCase() === 'utf-16le'
109
- // )
110
- // return 'utf16le';
111
- // break;
112
- // case 9:
113
- // if (
114
- // enc === 'base64url' ||
115
- // enc === 'BASE64URL' ||
116
- // `${enc}`.toLowerCase() === 'base64url'
117
- // )
118
- // return 'base64url';
119
- // break;
120
- // default:
121
- // if (enc === '') return 'utf8';
122
- // }
123
- // }
124
-
125
- // // Return undefined if there is no match.
126
- // // Move the "slow cases" to a separate function to make sure this function gets
127
- // // inlined properly. That prioritizes the common case.
128
- // export function normalizeEncoding(enc?: string) {
129
- // if (enc == null || enc === 'utf8' || enc === 'utf-8') return 'utf8';
130
- // return slowCases(enc);
131
- // }
132
-
133
- export function toArrayBuffer(buf: Buffer): ArrayBuffer {
134
- if (buf?.buffer?.slice) {
135
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
136
- }
137
- const ab = new ArrayBuffer(buf.length);
138
- const view = new Uint8Array(ab);
139
- for (let i = 0; i < buf.length; ++i) {
140
- view[i] = buf[i]!;
141
- }
142
- return ab;
143
- }
144
-
145
- export function bufferLikeToArrayBuffer(buf: BufferLike): ArrayBuffer {
146
- return Buffer.isBuffer(buf)
147
- ? buf.buffer
148
- : ArrayBuffer.isView(buf)
149
- ? buf.buffer
150
- : buf;
151
- }
152
-
153
- export function binaryLikeToArrayBuffer(
154
- input: BinaryLikeNode, // CipherKey adds compat with node types
155
- encoding: string = 'utf-8'
156
- ): ArrayBuffer {
157
- if (typeof input === 'string') {
158
- if (encoding === 'buffer') {
159
- throw new Error(
160
- 'Cannot create a buffer from a string with a buffer encoding'
161
- );
162
- }
163
-
164
- const buffer = Buffer.from(input, encoding);
165
-
166
- return buffer.buffer.slice(
167
- buffer.byteOffset,
168
- buffer.byteOffset + buffer.byteLength
169
- );
170
- }
171
-
172
- if (Buffer.isBuffer(input)) {
173
- return toArrayBuffer(input);
174
- }
175
-
176
- // TODO add further binary types to BinaryLike, UInt8Array and so for have this array as property
177
- if (ArrayBuffer.isView(input)) {
178
- return input.buffer;
179
- }
180
-
181
- if (!(input instanceof ArrayBuffer)) {
182
- try {
183
- // this is a strange fallback case and input is unknown at this point
184
- // @ts-expect-error
185
- const buffer = Buffer.from(input);
186
- return buffer.buffer.slice(
187
- buffer.byteOffset,
188
- buffer.byteOffset + buffer.byteLength
189
- );
190
- } catch {
191
- throw 'error';
192
- }
193
- }
194
-
195
- // TODO: handle if input is KeyObject?
196
-
197
- return input;
198
- }
199
-
200
- export function ab2str(buf: ArrayBuffer, encoding: string = 'hex') {
201
- return Buffer.from(buf).toString(encoding);
202
- }
203
-
204
- export function validateString(str: any, name?: string): str is string {
205
- const isString = typeof str === 'string';
206
- if (!isString) {
207
- throw new Error(`${name} is not a string`);
208
- }
209
- return isString;
210
- }
211
-
212
- export function validateFunction(f: any): boolean {
213
- return f !== null && typeof f === 'function';
214
- }
215
-
216
- export function isStringOrBuffer(val: any): val is string | ArrayBuffer {
217
- return (
218
- typeof val === 'string' ||
219
- ArrayBuffer.isView(val) ||
220
- val instanceof ArrayBuffer
221
- );
222
- }
223
-
224
- export function validateObject<T>(
225
- value: any,
226
- name: string,
227
- options?: {
228
- allowArray: boolean;
229
- allowFunction: boolean;
230
- nullable: boolean;
231
- } | null
232
- ): value is T {
233
- const useDefaultOptions = options == null;
234
- const allowArray = useDefaultOptions ? false : options.allowArray;
235
- const allowFunction = useDefaultOptions ? false : options.allowFunction;
236
- const nullable = useDefaultOptions ? false : options.nullable;
237
- if (
238
- (!nullable && value === null) ||
239
- (!allowArray && Array.isArray(value)) ||
240
- (typeof value !== 'object' &&
241
- (!allowFunction || typeof value !== 'function'))
242
- ) {
243
- throw new Error(`${name} is not a valid object $${value}`);
244
- }
245
- return true;
246
- }
247
-
248
- export function validateInt32(
249
- value: any,
250
- name: string,
251
- min = -2147483648,
252
- max = 2147483647
253
- ) {
254
- // The defaults for min and max correspond to the limits of 32-bit integers.
255
- if (typeof value !== 'number') {
256
- throw new Error(`Invalid argument - ${name} is not a number: ${value}`);
257
- }
258
- if (!Number.isInteger(value)) {
259
- throw new Error(
260
- `Argument out of range - ${name} out of integer range: ${value}`
261
- );
262
- }
263
- if (value < min || value > max) {
264
- throw new Error(
265
- `Invalid argument - ${name} out of range >= ${min} && <= ${max}: ${value}`
266
- );
267
- }
268
- }
269
-
270
- export function validateUint32(
271
- value: number,
272
- name: string,
273
- positive?: boolean
274
- ) {
275
- if (typeof value !== 'number') {
276
- // throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
277
- throw new Error(`Invalid argument - ${name} is not a number: ${value}`);
278
- }
279
- if (!Number.isInteger(value)) {
280
- // throw new ERR_OUT_OF_RANGE(name, 'an integer', value);
281
- throw new Error(
282
- `Argument out of range - ${name} out of integer range: ${value}`
283
- );
284
- }
285
- const min = positive ? 1 : 0;
286
- // 2 ** 32 === 4294967296
287
- const max = 4294967295;
288
- if (value < min || value > max) {
289
- // throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
290
- throw new Error(
291
- `Invalid argument - ${name} out of range >= ${min} && <= ${max}: ${value}`
292
- );
293
- }
294
- }
295
-
296
- export function hasAnyNotIn(set: string[], checks: string[]) {
297
- for (const s of set) {
298
- if (!checks.includes(s)) {
299
- return true;
300
- }
301
- }
302
- return false;
303
- }
304
-
305
- export function lazyDOMException(message: string, domName: DOMName): Error {
306
- let cause = '';
307
- if (typeof domName !== 'string') {
308
- cause = `\nCaused by: ${domName.cause}`;
309
- }
310
-
311
- return new Error(`[${domName}]: ${message}${cause}`);
312
- }
313
-
314
- // from lib/internal/crypto/util.js
315
-
316
- // The maximum buffer size that we'll support in the WebCrypto impl
317
- const kMaxBufferLength = 2 ** 31 - 1;
318
-
319
- // // The EC named curves that we currently support via the Web Crypto API.
320
- // const kNamedCurveAliases = {
321
- // 'P-256': 'prime256v1',
322
- // 'P-384': 'secp384r1',
323
- // 'P-521': 'secp521r1',
324
- // };
325
-
326
- // const kAesKeyLengths = [128, 192, 256];
327
-
328
- // // These are the only hash algorithms we currently support via
329
- // // the Web Crypto API.
330
- // const kHashTypes = ['SHA-1', 'SHA-256', 'SHA-384', 'SHA-512'];
331
-
332
- type SupportedAlgorithm<Type extends string> = {
333
- [key in Type]: string | null;
334
- };
335
-
336
- type SupportedAlgorithms = {
337
- 'digest': SupportedAlgorithm<DigestAlgorithm>;
338
- 'generateKey': SupportedAlgorithm<KeyPairAlgorithm | SecretKeyAlgorithm>;
339
- 'sign': SupportedAlgorithm<SignVerifyAlgorithm>;
340
- 'verify': SupportedAlgorithm<SignVerifyAlgorithm>;
341
- 'importKey': SupportedAlgorithm<
342
- KeyPairAlgorithm | 'PBKDF2' | SecretKeyAlgorithm | 'HKDF'
343
- >;
344
- 'deriveBits': SupportedAlgorithm<DeriveBitsAlgorithm>;
345
- 'encrypt': SupportedAlgorithm<EncryptDecryptAlgorithm>;
346
- 'decrypt': SupportedAlgorithm<EncryptDecryptAlgorithm>;
347
- 'get key length': SupportedAlgorithm<SecretKeyAlgorithm | 'PBKDF2' | 'HKDF'>;
348
- 'wrapKey': SupportedAlgorithm<'AES-KW'>;
349
- 'unwrapKey': SupportedAlgorithm<'AES-KW'>;
350
- };
351
-
352
- export type Operation =
353
- | 'digest'
354
- | 'generateKey'
355
- | 'sign'
356
- | 'verify'
357
- | 'importKey'
358
- | 'deriveBits'
359
- | 'encrypt'
360
- | 'decrypt'
361
- | 'get key length'
362
- | 'wrapKey'
363
- | 'unwrapKey';
364
-
365
- const kSupportedAlgorithms: SupportedAlgorithms = {
366
- 'digest': {
367
- 'SHA-1': null,
368
- 'SHA-256': null,
369
- 'SHA-384': null,
370
- 'SHA-512': null,
371
- },
372
- 'generateKey': {
373
- 'RSASSA-PKCS1-v1_5': 'RsaHashedKeyGenParams',
374
- 'RSA-PSS': 'RsaHashedKeyGenParams',
375
- 'RSA-OAEP': 'RsaHashedKeyGenParams',
376
- 'ECDSA': 'EcKeyGenParams',
377
- 'ECDH': 'EcKeyGenParams',
378
- 'AES-CTR': 'AesKeyGenParams',
379
- 'AES-CBC': 'AesKeyGenParams',
380
- 'AES-GCM': 'AesKeyGenParams',
381
- 'AES-KW': 'AesKeyGenParams',
382
- 'HMAC': 'HmacKeyGenParams',
383
- 'X25519': null,
384
- 'Ed25519': null,
385
- 'X448': null,
386
- 'Ed448': null,
387
- },
388
- 'sign': {
389
- 'RSASSA-PKCS1-v1_5': null,
390
- 'RSA-PSS': 'RsaPssParams',
391
- 'ECDSA': 'EcdsaParams',
392
- 'HMAC': null,
393
- 'Ed25519': null,
394
- 'Ed448': 'Ed448Params',
395
- },
396
- 'verify': {
397
- 'RSASSA-PKCS1-v1_5': null,
398
- 'RSA-PSS': 'RsaPssParams',
399
- 'ECDSA': 'EcdsaParams',
400
- 'HMAC': null,
401
- 'Ed25519': null,
402
- 'Ed448': 'Ed448Params',
403
- },
404
- 'importKey': {
405
- 'RSASSA-PKCS1-v1_5': 'RsaHashedImportParams',
406
- 'RSA-PSS': 'RsaHashedImportParams',
407
- 'RSA-OAEP': 'RsaHashedImportParams',
408
- 'ECDSA': 'EcKeyImportParams',
409
- 'ECDH': 'EcKeyImportParams',
410
- 'HMAC': 'HmacImportParams',
411
- 'HKDF': null,
412
- 'PBKDF2': null,
413
- 'AES-CTR': null,
414
- 'AES-CBC': null,
415
- 'AES-GCM': null,
416
- 'AES-KW': null,
417
- 'Ed25519': null,
418
- 'X25519': null,
419
- 'Ed448': null,
420
- 'X448': null,
421
- },
422
- 'deriveBits': {
423
- HKDF: 'HkdfParams',
424
- PBKDF2: 'Pbkdf2Params',
425
- ECDH: 'EcdhKeyDeriveParams',
426
- X25519: 'EcdhKeyDeriveParams',
427
- X448: 'EcdhKeyDeriveParams',
428
- },
429
- 'encrypt': {
430
- 'RSA-OAEP': 'RsaOaepParams',
431
- 'AES-CBC': 'AesCbcParams',
432
- 'AES-GCM': 'AesGcmParams',
433
- 'AES-CTR': 'AesCtrParams',
434
- },
435
- 'decrypt': {
436
- 'RSA-OAEP': 'RsaOaepParams',
437
- 'AES-CBC': 'AesCbcParams',
438
- 'AES-GCM': 'AesGcmParams',
439
- 'AES-CTR': 'AesCtrParams',
440
- },
441
- 'get key length': {
442
- 'AES-CBC': 'AesDerivedKeyParams',
443
- 'AES-CTR': 'AesDerivedKeyParams',
444
- 'AES-GCM': 'AesDerivedKeyParams',
445
- 'AES-KW': 'AesDerivedKeyParams',
446
- 'HMAC': 'HmacImportParams',
447
- 'HKDF': null,
448
- 'PBKDF2': null,
449
- },
450
- 'wrapKey': {
451
- 'AES-KW': null,
452
- },
453
- 'unwrapKey': {
454
- 'AES-KW': null,
455
- },
456
- };
457
-
458
- type AlgorithmDictionaries = {
459
- [key in string]: Object;
460
- };
461
-
462
- const simpleAlgorithmDictionaries: AlgorithmDictionaries = {
463
- AesGcmParams: { iv: 'BufferSource', additionalData: 'BufferSource' },
464
- RsaHashedKeyGenParams: { hash: 'HashAlgorithmIdentifier' },
465
- EcKeyGenParams: {},
466
- HmacKeyGenParams: { hash: 'HashAlgorithmIdentifier' },
467
- RsaPssParams: {},
468
- EcdsaParams: { hash: 'HashAlgorithmIdentifier' },
469
- HmacImportParams: { hash: 'HashAlgorithmIdentifier' },
470
- HkdfParams: {
471
- hash: 'HashAlgorithmIdentifier',
472
- salt: 'BufferSource',
473
- info: 'BufferSource',
474
- },
475
- Ed448Params: { context: 'BufferSource' },
476
- Pbkdf2Params: { hash: 'HashAlgorithmIdentifier', salt: 'BufferSource' },
477
- RsaOaepParams: { label: 'BufferSource' },
478
- RsaHashedImportParams: { hash: 'HashAlgorithmIdentifier' },
479
- EcKeyImportParams: {},
480
- };
481
-
482
- export const validateMaxBufferLength = (
483
- data: BinaryLike | BufferLike,
484
- name: string
485
- ): void => {
486
- const length = typeof data === 'string' ? data.length : data.byteLength;
487
- if (length > kMaxBufferLength) {
488
- throw lazyDOMException(
489
- `${name} must be less than ${kMaxBufferLength + 1} bits`,
490
- 'OperationError'
491
- );
492
- }
493
- };
494
-
495
- // https://w3c.github.io/webcrypto/#algorithm-normalization-normalize-an-algorithm
496
- // adapted for Node.js from Deno's implementation
497
- // https://github.com/denoland/deno/blob/v1.29.1/ext/crypto/00_crypto.js#L195
498
- export const normalizeAlgorithm = (
499
- algorithm: SubtleAlgorithm | EncryptDecryptParams | AnyAlgorithm,
500
- op: Operation
501
- ): SubtleAlgorithm | EncryptDecryptParams => {
502
- if (typeof algorithm === 'string') {
503
- return normalizeAlgorithm({ name: algorithm }, op);
504
- }
505
-
506
- // 1.
507
- const registeredAlgorithms = kSupportedAlgorithms[op];
508
- // 2. 3.
509
- // commented, because typescript takes care of this for us 🤞👀
510
- // const initialAlg = webidl.converters.Algorithm(algorithm, {
511
- // prefix: 'Failed to normalize algorithm',
512
- // context: 'passed algorithm',
513
- // });
514
-
515
- // 4.
516
- let algName = algorithm.name;
517
- // @ts-expect-error
518
- if (algName === undefined) return { name: undefined };
519
-
520
- // 5.
521
- let desiredType: string | null | undefined;
522
- for (const key in registeredAlgorithms) {
523
- if (!registeredAlgorithms.hasOwnProperty(key)) {
524
- continue;
525
- }
526
- if (key.toUpperCase() === algName.toUpperCase()) {
527
- algName = key as AnyAlgorithm;
528
- // @ts-ignore
529
- desiredType = registeredAlgorithms[algName];
530
- }
531
- }
532
- if (desiredType === undefined)
533
- throw lazyDOMException('Unrecognized algorithm name', 'NotSupportedError');
534
-
535
- // Fast path everything below if the registered dictionary is null
536
- if (desiredType === null) return { name: algName };
537
-
538
- // 6.
539
- const normalizedAlgorithm = algorithm;
540
- // TODO: implement this? Maybe via typescript?
541
- // webidl.converters[desiredType](algorithm, {
542
- // prefix: 'Failed to normalize algorithm',
543
- // context: 'passed algorithm',
544
- // });
545
- // 7.
546
- normalizedAlgorithm.name = algName;
547
-
548
- // 9.
549
- const dict = simpleAlgorithmDictionaries[desiredType];
550
- // 10.
551
- const dictKeys = dict ? Object.keys(dict) : [];
552
- for (let i = 0; i < dictKeys.length; i++) {
553
- const member = dictKeys[i] || '';
554
- if (!dict?.hasOwnProperty(member)) continue;
555
- // TODO: implement this? Maybe via typescript?
556
- // const idlType = dict[member];
557
- // const idlValue = normalizedAlgorithm[member];
558
- // 3.
559
- // if (idlType === 'BufferSource' && idlValue) {
560
- // const isView = ArrayBufferIsView(idlValue);
561
- // normalizedAlgorithm[member] = TypedArrayPrototypeSlice(
562
- // new Uint8Array(
563
- // isView ? getDataViewOrTypedArrayBuffer(idlValue) : idlValue,
564
- // isView ? getDataViewOrTypedArrayByteOffset(idlValue) : 0,
565
- // isView
566
- // ? getDataViewOrTypedArrayByteLength(idlValue)
567
- // : ArrayBufferPrototypeGetByteLength(idlValue)
568
- // )
569
- // );
570
- // } else if (idlType === 'HashAlgorithmIdentifier') {
571
- // normalizedAlgorithm[member] = normalizeAlgorithm(idlValue, 'digest');
572
- // } else if (idlType === 'AlgorithmIdentifier') {
573
- // // This extension point is not used by any supported algorithm (yet?)
574
- // throw lazyDOMException('Not implemented.', 'NotSupportedError');
575
- // }
576
- }
577
-
578
- return normalizedAlgorithm;
579
- };
580
-
581
- export const validateBitLength = (
582
- length: number,
583
- name: string,
584
- required: boolean = false
585
- ) => {
586
- if (length !== undefined || required) {
587
- // validateNumber(length, name);
588
- if (length < 0) throw new Error(`${name} > 0`);
589
- if (length % 8) {
590
- throw lazyDOMException(
591
- `${name}'s length (${length}) must be a multiple of 8`,
592
- 'InvalidArgument'
593
- );
594
- }
595
- }
596
- };
597
-
598
- export const validateByteLength = (
599
- buf: BufferLike,
600
- name: string,
601
- target: number
602
- ) => {
603
- if (buf.byteLength !== target) {
604
- throw lazyDOMException(
605
- `${name} must contain exactly ${target} bytes`,
606
- 'OperationError'
607
- );
608
- }
609
- };
610
-
611
- export const getUsagesUnion = (usageSet: KeyUsage[], ...usages: KeyUsage[]) => {
612
- const newset: KeyUsage[] = [];
613
- for (let n = 0; n < usages.length; n++) {
614
- if (!usages[n] || usages[n] === undefined) continue;
615
- if (usageSet.includes(usages[n] as KeyUsage))
616
- newset.push(usages[n] as KeyUsage);
617
- }
618
- return newset;
619
- };
620
-
621
- const kKeyOps: {
622
- [key in KeyUsage]: number;
623
- } = {
624
- sign: 1,
625
- verify: 2,
626
- encrypt: 3,
627
- decrypt: 4,
628
- wrapKey: 5,
629
- unwrapKey: 6,
630
- deriveKey: 7,
631
- deriveBits: 8,
632
- };
633
-
634
- export const validateKeyOps = (
635
- keyOps: KeyUsage[] | undefined,
636
- usagesSet: KeyUsage[]
637
- ) => {
638
- if (keyOps === undefined) return;
639
- if (!Array.isArray(keyOps)) {
640
- throw lazyDOMException('keyData.key_ops', 'InvalidArgument');
641
- }
642
- let flags = 0;
643
- for (let n = 0; n < keyOps.length; n++) {
644
- const op: KeyUsage = keyOps[n] as KeyUsage;
645
- const op_flag = kKeyOps[op];
646
- // Skipping unknown key ops
647
- if (op_flag === undefined) continue;
648
- // Have we seen it already? if so, error
649
- // eslint-disable-next-line no-bitwise
650
- if (flags & (1 << op_flag))
651
- throw lazyDOMException('Duplicate key operation', 'DataError');
652
- // eslint-disable-next-line no-bitwise
653
- flags |= 1 << op_flag;
654
-
655
- // TODO(@jasnell): RFC7517 section 4.3 strong recommends validating
656
- // key usage combinations. Specifically, it says that unrelated key
657
- // ops SHOULD NOT be used together. We're not yet validating that here.
658
- }
659
-
660
- if (usagesSet !== undefined) {
661
- for (const use of usagesSet) {
662
- if (!keyOps.includes(use)) {
663
- throw lazyDOMException(
664
- 'Key operations and usage mismatch',
665
- 'DataError'
666
- );
667
- }
668
- }
669
- }
670
- };
671
-
672
- // In WebCrypto, the publicExponent option in RSA is represented as a
673
- // WebIDL "BigInteger"... that is, a Uint8Array that allows an arbitrary
674
- // number of leading zero bits. Our conventional APIs for reading
675
- // an unsigned int from a Buffer are not adequate. The implementation
676
- // here is adapted from the chromium implementation here:
677
- // https://github.com/chromium/chromium/blob/HEAD/third_party/blink/public/platform/web_crypto_algorithm_params.h, but ported to JavaScript
678
- // Returns undefined if the conversion was unsuccessful.
679
- export const bigIntArrayToUnsignedInt = (
680
- input: Uint8Array
681
- ): number | undefined => {
682
- let result = 0;
683
-
684
- for (let n = 0; n < input.length; ++n) {
685
- const n_reversed = input.length - n - 1;
686
- if (n_reversed >= 4 && input[n]) return; // Too large
687
- // @ts-ignore
688
- // eslint-disable-next-line no-bitwise
689
- result |= input[n] << (8 * n_reversed);
690
- }
691
-
692
- return result;
693
- };
694
-
695
- // TODO: these used to be shipped by crypto-browserify in quickcrypto v0.6
696
- // could instead fetch from OpenSSL if needed and handle breaking changes
697
- export const getHashes = () => [
698
- 'sha1',
699
- 'sha224',
700
- 'sha256',
701
- 'sha384',
702
- 'sha512',
703
- 'md5',
704
- 'rmd160',
705
- 'sha224WithRSAEncryption',
706
- 'RSA-SHA224',
707
- 'sha256WithRSAEncryption',
708
- 'RSA-SHA256',
709
- 'sha384WithRSAEncryption',
710
- 'RSA-SHA384',
711
- 'sha512WithRSAEncryption',
712
- 'RSA-SHA512',
713
- 'RSA-SHA1',
714
- 'ecdsa-with-SHA1',
715
- 'sha256',
716
- 'sha224',
717
- 'sha384',
718
- 'sha512',
719
- 'DSA-SHA',
720
- 'DSA-SHA1',
721
- 'DSA',
722
- 'DSA-WITH-SHA224',
723
- 'DSA-SHA224',
724
- 'DSA-WITH-SHA256',
725
- 'DSA-SHA256',
726
- 'DSA-WITH-SHA384',
727
- 'DSA-SHA384',
728
- 'DSA-WITH-SHA512',
729
- 'DSA-SHA512',
730
- 'DSA-RIPEMD160',
731
- 'ripemd160WithRSA',
732
- 'RSA-RIPEMD160',
733
- 'md5WithRSAEncryption',
734
- 'RSA-MD5',
735
- ];
736
-
737
- // TODO: these used to be shipped by crypto-browserify in quickcrypto v0.6
738
- // could instead fetch from OpenSSL if needed and handle breaking changes
739
- export const getCiphers = () => [
740
- 'des-ecb',
741
- 'des',
742
- 'des-cbc',
743
- 'des3',
744
- 'des-ede3-cbc',
745
- 'des-ede3',
746
- 'des-ede-cbc',
747
- 'des-ede',
748
- 'aes-128-ecb',
749
- 'aes-192-ecb',
750
- 'aes-256-ecb',
751
- 'aes-128-cbc',
752
- 'aes-192-cbc',
753
- 'aes-256-cbc',
754
- 'aes128',
755
- 'aes192',
756
- 'aes256',
757
- 'aes-128-cfb',
758
- 'aes-192-cfb',
759
- 'aes-256-cfb',
760
- 'aes-128-cfb8',
761
- 'aes-192-cfb8',
762
- 'aes-256-cfb8',
763
- 'aes-128-cfb1',
764
- 'aes-192-cfb1',
765
- 'aes-256-cfb1',
766
- 'aes-128-ofb',
767
- 'aes-192-ofb',
768
- 'aes-256-ofb',
769
- 'aes-128-ctr',
770
- 'aes-192-ctr',
771
- 'aes-256-ctr',
772
- 'aes-128-gcm',
773
- 'aes-192-gcm',
774
- 'aes-256-gcm',
775
- ];
776
-
777
- export * from './Hashnames';