charm-crypto-framework 0.61.1__cp313-cp313-macosx_10_13_universal2.whl

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 (323) hide show
  1. charm/__init__.py +5 -0
  2. charm/adapters/__init__.py +0 -0
  3. charm/adapters/abenc_adapt_hybrid.py +90 -0
  4. charm/adapters/dabenc_adapt_hybrid.py +145 -0
  5. charm/adapters/ibenc_adapt_hybrid.py +72 -0
  6. charm/adapters/ibenc_adapt_identityhash.py +80 -0
  7. charm/adapters/kpabenc_adapt_hybrid.py +91 -0
  8. charm/adapters/pkenc_adapt_bchk05.py +121 -0
  9. charm/adapters/pkenc_adapt_chk04.py +91 -0
  10. charm/adapters/pkenc_adapt_hybrid.py +98 -0
  11. charm/adapters/pksig_adapt_naor01.py +89 -0
  12. charm/config.py +7 -0
  13. charm/core/__init__.py +0 -0
  14. charm/core/benchmark/benchmark_util.c +353 -0
  15. charm/core/benchmark/benchmark_util.h +61 -0
  16. charm/core/benchmark/benchmarkmodule.c +476 -0
  17. charm/core/benchmark/benchmarkmodule.h +162 -0
  18. charm/core/benchmark.cpython-313-darwin.so +0 -0
  19. charm/core/crypto/AES/AES.c +1464 -0
  20. charm/core/crypto/AES.cpython-313-darwin.so +0 -0
  21. charm/core/crypto/DES/DES.c +113 -0
  22. charm/core/crypto/DES.cpython-313-darwin.so +0 -0
  23. charm/core/crypto/DES3/DES3.c +26 -0
  24. charm/core/crypto/DES3.cpython-313-darwin.so +0 -0
  25. charm/core/crypto/__init__.py +0 -0
  26. charm/core/crypto/cryptobase/XOR.c +80 -0
  27. charm/core/crypto/cryptobase/_counter.c +496 -0
  28. charm/core/crypto/cryptobase/_counter.h +54 -0
  29. charm/core/crypto/cryptobase/block_template.c +900 -0
  30. charm/core/crypto/cryptobase/block_template.h +69 -0
  31. charm/core/crypto/cryptobase/cryptobasemodule.c +220 -0
  32. charm/core/crypto/cryptobase/libtom/tomcrypt.h +90 -0
  33. charm/core/crypto/cryptobase/libtom/tomcrypt_argchk.h +44 -0
  34. charm/core/crypto/cryptobase/libtom/tomcrypt_cfg.h +186 -0
  35. charm/core/crypto/cryptobase/libtom/tomcrypt_cipher.h +941 -0
  36. charm/core/crypto/cryptobase/libtom/tomcrypt_custom.h +556 -0
  37. charm/core/crypto/cryptobase/libtom/tomcrypt_des.c +1912 -0
  38. charm/core/crypto/cryptobase/libtom/tomcrypt_hash.h +407 -0
  39. charm/core/crypto/cryptobase/libtom/tomcrypt_mac.h +496 -0
  40. charm/core/crypto/cryptobase/libtom/tomcrypt_macros.h +435 -0
  41. charm/core/crypto/cryptobase/libtom/tomcrypt_math.h +534 -0
  42. charm/core/crypto/cryptobase/libtom/tomcrypt_misc.h +103 -0
  43. charm/core/crypto/cryptobase/libtom/tomcrypt_pk.h +653 -0
  44. charm/core/crypto/cryptobase/libtom/tomcrypt_pkcs.h +90 -0
  45. charm/core/crypto/cryptobase/libtom/tomcrypt_prng.h +199 -0
  46. charm/core/crypto/cryptobase/stream_template.c +271 -0
  47. charm/core/crypto/cryptobase/strxor.c +229 -0
  48. charm/core/crypto/cryptobase.cpython-313-darwin.so +0 -0
  49. charm/core/engine/__init__.py +5 -0
  50. charm/core/engine/protocol.py +293 -0
  51. charm/core/engine/util.py +174 -0
  52. charm/core/math/__init__.py +0 -0
  53. charm/core/math/elliptic_curve/ecmodule.c +1986 -0
  54. charm/core/math/elliptic_curve/ecmodule.h +230 -0
  55. charm/core/math/elliptic_curve.cpython-313-darwin.so +0 -0
  56. charm/core/math/elliptic_curve.pyi +63 -0
  57. charm/core/math/integer/integermodule.c +2539 -0
  58. charm/core/math/integer/integermodule.h +145 -0
  59. charm/core/math/integer.cpython-313-darwin.so +0 -0
  60. charm/core/math/integer.pyi +76 -0
  61. charm/core/math/pairing/miracl/miracl_config.h +37 -0
  62. charm/core/math/pairing/miracl/miracl_interface.h +118 -0
  63. charm/core/math/pairing/miracl/miracl_interface2.h +126 -0
  64. charm/core/math/pairing/miracl/pairingmodule2.c +2094 -0
  65. charm/core/math/pairing/miracl/pairingmodule2.h +307 -0
  66. charm/core/math/pairing/pairingmodule.c +2230 -0
  67. charm/core/math/pairing/pairingmodule.h +241 -0
  68. charm/core/math/pairing/relic/pairingmodule3.c +1853 -0
  69. charm/core/math/pairing/relic/pairingmodule3.h +233 -0
  70. charm/core/math/pairing/relic/relic_interface.c +1337 -0
  71. charm/core/math/pairing/relic/relic_interface.h +217 -0
  72. charm/core/math/pairing/relic/test_relic.c +171 -0
  73. charm/core/math/pairing.cpython-313-darwin.so +0 -0
  74. charm/core/math/pairing.pyi +69 -0
  75. charm/core/utilities/base64.c +248 -0
  76. charm/core/utilities/base64.h +15 -0
  77. charm/schemes/__init__.py +0 -0
  78. charm/schemes/abenc/__init__.py +0 -0
  79. charm/schemes/abenc/abenc_accountability_jyjxgd20.py +647 -0
  80. charm/schemes/abenc/abenc_bsw07.py +146 -0
  81. charm/schemes/abenc/abenc_ca_cpabe_ar17.py +684 -0
  82. charm/schemes/abenc/abenc_dacmacs_yj14.py +298 -0
  83. charm/schemes/abenc/abenc_lsw08.py +159 -0
  84. charm/schemes/abenc/abenc_maabe_rw15.py +236 -0
  85. charm/schemes/abenc/abenc_maabe_yj14.py +297 -0
  86. charm/schemes/abenc/abenc_tbpre_lww14.py +309 -0
  87. charm/schemes/abenc/abenc_unmcpabe_yahk14.py +223 -0
  88. charm/schemes/abenc/abenc_waters09.py +144 -0
  89. charm/schemes/abenc/abenc_yct14.py +208 -0
  90. charm/schemes/abenc/abenc_yllc15.py +178 -0
  91. charm/schemes/abenc/ac17.py +248 -0
  92. charm/schemes/abenc/bsw07.py +141 -0
  93. charm/schemes/abenc/cgw15.py +277 -0
  94. charm/schemes/abenc/dabe_aw11.py +204 -0
  95. charm/schemes/abenc/dfa_fe12.py +144 -0
  96. charm/schemes/abenc/pk_hve08.py +179 -0
  97. charm/schemes/abenc/waters11.py +143 -0
  98. charm/schemes/aggrsign_MuSig.py +150 -0
  99. charm/schemes/aggrsign_bls.py +267 -0
  100. charm/schemes/blindsig_ps16.py +654 -0
  101. charm/schemes/chamhash_adm05.py +113 -0
  102. charm/schemes/chamhash_rsa_hw09.py +100 -0
  103. charm/schemes/commit/__init__.py +0 -0
  104. charm/schemes/commit/commit_gs08.py +77 -0
  105. charm/schemes/commit/commit_pedersen92.py +53 -0
  106. charm/schemes/encap_bchk05.py +62 -0
  107. charm/schemes/grpsig/__init__.py +0 -0
  108. charm/schemes/grpsig/groupsig_bgls04.py +114 -0
  109. charm/schemes/grpsig/groupsig_bgls04_var.py +115 -0
  110. charm/schemes/hibenc/__init__.py +0 -0
  111. charm/schemes/hibenc/hibenc_bb04.py +105 -0
  112. charm/schemes/hibenc/hibenc_lew11.py +193 -0
  113. charm/schemes/ibenc/__init__.py +0 -0
  114. charm/schemes/ibenc/clpkc_rp03.py +119 -0
  115. charm/schemes/ibenc/ibenc_CW13_z.py +168 -0
  116. charm/schemes/ibenc/ibenc_bb03.py +94 -0
  117. charm/schemes/ibenc/ibenc_bf01.py +121 -0
  118. charm/schemes/ibenc/ibenc_ckrs09.py +120 -0
  119. charm/schemes/ibenc/ibenc_cllww12_z.py +172 -0
  120. charm/schemes/ibenc/ibenc_lsw08.py +120 -0
  121. charm/schemes/ibenc/ibenc_sw05.py +238 -0
  122. charm/schemes/ibenc/ibenc_waters05.py +144 -0
  123. charm/schemes/ibenc/ibenc_waters05_z.py +164 -0
  124. charm/schemes/ibenc/ibenc_waters09.py +107 -0
  125. charm/schemes/ibenc/ibenc_waters09_z.py +147 -0
  126. charm/schemes/joye_scheme.py +106 -0
  127. charm/schemes/lem_scheme.py +207 -0
  128. charm/schemes/pk_fre_ccv11.py +107 -0
  129. charm/schemes/pk_vrf.py +127 -0
  130. charm/schemes/pkenc/__init__.py +0 -0
  131. charm/schemes/pkenc/pkenc_cs98.py +108 -0
  132. charm/schemes/pkenc/pkenc_elgamal85.py +122 -0
  133. charm/schemes/pkenc/pkenc_gm82.py +98 -0
  134. charm/schemes/pkenc/pkenc_paillier99.py +118 -0
  135. charm/schemes/pkenc/pkenc_rabin.py +254 -0
  136. charm/schemes/pkenc/pkenc_rsa.py +186 -0
  137. charm/schemes/pksig/__init__.py +0 -0
  138. charm/schemes/pksig/pksig_CW13_z.py +135 -0
  139. charm/schemes/pksig/pksig_bls04.py +87 -0
  140. charm/schemes/pksig/pksig_boyen.py +156 -0
  141. charm/schemes/pksig/pksig_chch.py +97 -0
  142. charm/schemes/pksig/pksig_chp.py +70 -0
  143. charm/schemes/pksig/pksig_cl03.py +150 -0
  144. charm/schemes/pksig/pksig_cl04.py +87 -0
  145. charm/schemes/pksig/pksig_cllww12_z.py +142 -0
  146. charm/schemes/pksig/pksig_cyh.py +132 -0
  147. charm/schemes/pksig/pksig_dsa.py +76 -0
  148. charm/schemes/pksig/pksig_ecdsa.py +71 -0
  149. charm/schemes/pksig/pksig_hess.py +104 -0
  150. charm/schemes/pksig/pksig_hw.py +110 -0
  151. charm/schemes/pksig/pksig_lamport.py +63 -0
  152. charm/schemes/pksig/pksig_ps01.py +135 -0
  153. charm/schemes/pksig/pksig_ps02.py +124 -0
  154. charm/schemes/pksig/pksig_ps03.py +119 -0
  155. charm/schemes/pksig/pksig_rsa_hw09.py +206 -0
  156. charm/schemes/pksig/pksig_schnorr91.py +77 -0
  157. charm/schemes/pksig/pksig_waters.py +115 -0
  158. charm/schemes/pksig/pksig_waters05.py +121 -0
  159. charm/schemes/pksig/pksig_waters09.py +121 -0
  160. charm/schemes/pre_mg07.py +150 -0
  161. charm/schemes/prenc/pre_afgh06.py +126 -0
  162. charm/schemes/prenc/pre_bbs98.py +123 -0
  163. charm/schemes/prenc/pre_nal16.py +216 -0
  164. charm/schemes/protocol_a01.py +272 -0
  165. charm/schemes/protocol_ao00.py +215 -0
  166. charm/schemes/protocol_cns07.py +274 -0
  167. charm/schemes/protocol_schnorr91.py +125 -0
  168. charm/schemes/sigma1.py +64 -0
  169. charm/schemes/sigma2.py +129 -0
  170. charm/schemes/sigma3.py +126 -0
  171. charm/schemes/threshold/__init__.py +59 -0
  172. charm/schemes/threshold/dkls23_dkg.py +556 -0
  173. charm/schemes/threshold/dkls23_presign.py +1089 -0
  174. charm/schemes/threshold/dkls23_sign.py +761 -0
  175. charm/schemes/threshold/xrpl_wallet.py +967 -0
  176. charm/test/__init__.py +0 -0
  177. charm/test/adapters/__init__.py +0 -0
  178. charm/test/adapters/abenc_adapt_hybrid_test.py +29 -0
  179. charm/test/adapters/dabenc_adapt_hybrid_test.py +56 -0
  180. charm/test/adapters/ibenc_adapt_hybrid_test.py +36 -0
  181. charm/test/adapters/ibenc_adapt_identityhash_test.py +32 -0
  182. charm/test/adapters/kpabenc_adapt_hybrid_test.py +30 -0
  183. charm/test/benchmark/abenc_yllc15_bench.py +92 -0
  184. charm/test/benchmark/benchmark_test.py +148 -0
  185. charm/test/benchmark_threshold.py +260 -0
  186. charm/test/conftest.py +38 -0
  187. charm/test/fuzz/__init__.py +1 -0
  188. charm/test/fuzz/conftest.py +5 -0
  189. charm/test/fuzz/fuzz_policy_parser.py +76 -0
  190. charm/test/fuzz/fuzz_serialization.py +83 -0
  191. charm/test/schemes/__init__.py +0 -0
  192. charm/test/schemes/abenc/__init__.py +0 -0
  193. charm/test/schemes/abenc/abenc_bsw07_test.py +39 -0
  194. charm/test/schemes/abenc/abenc_dacmacs_yj14_test.py +16 -0
  195. charm/test/schemes/abenc/abenc_lsw08_test.py +33 -0
  196. charm/test/schemes/abenc/abenc_maabe_yj14_test.py +16 -0
  197. charm/test/schemes/abenc/abenc_tbpre_lww14_test.py +16 -0
  198. charm/test/schemes/abenc/abenc_waters09_test.py +38 -0
  199. charm/test/schemes/abenc/abenc_yllc15_test.py +74 -0
  200. charm/test/schemes/chamhash_adm05_test.py +31 -0
  201. charm/test/schemes/chamhash_rsa_hw09_test.py +29 -0
  202. charm/test/schemes/commit/__init__.py +0 -0
  203. charm/test/schemes/commit/commit_gs08_test.py +24 -0
  204. charm/test/schemes/commit/commit_pedersen92_test.py +26 -0
  205. charm/test/schemes/dabe_aw11_test.py +45 -0
  206. charm/test/schemes/encap_bchk05_test.py +21 -0
  207. charm/test/schemes/grpsig/__init__.py +0 -0
  208. charm/test/schemes/grpsig/groupsig_bgls04_test.py +35 -0
  209. charm/test/schemes/grpsig/groupsig_bgls04_var_test.py +39 -0
  210. charm/test/schemes/hibenc/__init__.py +0 -0
  211. charm/test/schemes/hibenc/hibenc_bb04_test.py +28 -0
  212. charm/test/schemes/ibenc/__init__.py +0 -0
  213. charm/test/schemes/ibenc/ibenc_bb03_test.py +26 -0
  214. charm/test/schemes/ibenc/ibenc_bf01_test.py +24 -0
  215. charm/test/schemes/ibenc/ibenc_ckrs09_test.py +25 -0
  216. charm/test/schemes/ibenc/ibenc_lsw08_test.py +31 -0
  217. charm/test/schemes/ibenc/ibenc_sw05_test.py +32 -0
  218. charm/test/schemes/ibenc/ibenc_waters05_test.py +31 -0
  219. charm/test/schemes/ibenc/ibenc_waters09_test.py +27 -0
  220. charm/test/schemes/pk_vrf_test.py +29 -0
  221. charm/test/schemes/pkenc/__init__.py +0 -0
  222. charm/test/schemes/pkenc_test.py +255 -0
  223. charm/test/schemes/pksig/__init__.py +0 -0
  224. charm/test/schemes/pksig_test.py +376 -0
  225. charm/test/schemes/rsa_alg_test.py +340 -0
  226. charm/test/schemes/threshold_test.py +1792 -0
  227. charm/test/serialize/__init__.py +0 -0
  228. charm/test/serialize/serialize_test.py +40 -0
  229. charm/test/toolbox/__init__.py +0 -0
  230. charm/test/toolbox/conversion_test.py +30 -0
  231. charm/test/toolbox/ecgroup_test.py +53 -0
  232. charm/test/toolbox/integer_arithmetic_test.py +441 -0
  233. charm/test/toolbox/paddingschemes_test.py +238 -0
  234. charm/test/toolbox/policy_parser_stress_test.py +969 -0
  235. charm/test/toolbox/secretshare_test.py +28 -0
  236. charm/test/toolbox/symcrypto_test.py +108 -0
  237. charm/test/toolbox/test_policy_expression.py +16 -0
  238. charm/test/vectors/__init__.py +1 -0
  239. charm/test/vectors/test_bls_vectors.py +289 -0
  240. charm/test/vectors/test_pedersen_vectors.py +315 -0
  241. charm/test/vectors/test_schnorr_vectors.py +368 -0
  242. charm/test/zkp_compiler/__init__.py +9 -0
  243. charm/test/zkp_compiler/benchmark_zkp.py +258 -0
  244. charm/test/zkp_compiler/test_and_proof.py +240 -0
  245. charm/test/zkp_compiler/test_batch_verify.py +248 -0
  246. charm/test/zkp_compiler/test_dleq_proof.py +264 -0
  247. charm/test/zkp_compiler/test_or_proof.py +231 -0
  248. charm/test/zkp_compiler/test_proof_serialization.py +121 -0
  249. charm/test/zkp_compiler/test_range_proof.py +241 -0
  250. charm/test/zkp_compiler/test_representation_proof.py +325 -0
  251. charm/test/zkp_compiler/test_schnorr_proof.py +221 -0
  252. charm/test/zkp_compiler/test_thread_safety.py +169 -0
  253. charm/test/zkp_compiler/test_zkp_parser.py +139 -0
  254. charm/toolbox/ABEnc.py +26 -0
  255. charm/toolbox/ABEncMultiAuth.py +66 -0
  256. charm/toolbox/ABEnumeric.py +800 -0
  257. charm/toolbox/Commit.py +24 -0
  258. charm/toolbox/DFA.py +89 -0
  259. charm/toolbox/FSA.py +1254 -0
  260. charm/toolbox/Hash.py +39 -0
  261. charm/toolbox/IBEnc.py +62 -0
  262. charm/toolbox/IBSig.py +64 -0
  263. charm/toolbox/PKEnc.py +66 -0
  264. charm/toolbox/PKSig.py +56 -0
  265. charm/toolbox/PREnc.py +32 -0
  266. charm/toolbox/ZKProof.py +289 -0
  267. charm/toolbox/__init__.py +0 -0
  268. charm/toolbox/bitstring.py +49 -0
  269. charm/toolbox/broadcast.py +220 -0
  270. charm/toolbox/conversion.py +100 -0
  271. charm/toolbox/eccurve.py +149 -0
  272. charm/toolbox/ecgroup.py +143 -0
  273. charm/toolbox/enum.py +60 -0
  274. charm/toolbox/hash_module.py +91 -0
  275. charm/toolbox/integergroup.py +323 -0
  276. charm/toolbox/iterate.py +22 -0
  277. charm/toolbox/matrixops.py +76 -0
  278. charm/toolbox/mpc_utils.py +296 -0
  279. charm/toolbox/msp.py +175 -0
  280. charm/toolbox/mta.py +985 -0
  281. charm/toolbox/node.py +120 -0
  282. charm/toolbox/ot/__init__.py +22 -0
  283. charm/toolbox/ot/base_ot.py +374 -0
  284. charm/toolbox/ot/dpf.py +642 -0
  285. charm/toolbox/ot/mpfss.py +228 -0
  286. charm/toolbox/ot/ot_extension.py +589 -0
  287. charm/toolbox/ot/silent_ot.py +378 -0
  288. charm/toolbox/paddingschemes.py +423 -0
  289. charm/toolbox/paddingschemes_test.py +238 -0
  290. charm/toolbox/pairingcurves.py +85 -0
  291. charm/toolbox/pairinggroup.py +186 -0
  292. charm/toolbox/policy_expression_spec.py +70 -0
  293. charm/toolbox/policytree.py +189 -0
  294. charm/toolbox/reCompiler.py +346 -0
  295. charm/toolbox/redundancyschemes.py +65 -0
  296. charm/toolbox/schemebase.py +188 -0
  297. charm/toolbox/secretshare.py +104 -0
  298. charm/toolbox/secretutil.py +174 -0
  299. charm/toolbox/securerandom.py +73 -0
  300. charm/toolbox/sigmaprotocol.py +46 -0
  301. charm/toolbox/specialprimes.py +45 -0
  302. charm/toolbox/symcrypto.py +279 -0
  303. charm/toolbox/threshold_sharing.py +553 -0
  304. charm/toolbox/xmlserialize.py +94 -0
  305. charm/toolbox/zknode.py +105 -0
  306. charm/zkp_compiler/__init__.py +89 -0
  307. charm/zkp_compiler/and_proof.py +460 -0
  308. charm/zkp_compiler/batch_verify.py +324 -0
  309. charm/zkp_compiler/dleq_proof.py +423 -0
  310. charm/zkp_compiler/or_proof.py +305 -0
  311. charm/zkp_compiler/range_proof.py +417 -0
  312. charm/zkp_compiler/representation_proof.py +466 -0
  313. charm/zkp_compiler/schnorr_proof.py +273 -0
  314. charm/zkp_compiler/thread_safe.py +150 -0
  315. charm/zkp_compiler/zk_demo.py +489 -0
  316. charm/zkp_compiler/zkp_factory.py +330 -0
  317. charm/zkp_compiler/zkp_generator.py +370 -0
  318. charm/zkp_compiler/zkparser.py +269 -0
  319. charm_crypto_framework-0.61.1.dist-info/METADATA +337 -0
  320. charm_crypto_framework-0.61.1.dist-info/RECORD +323 -0
  321. charm_crypto_framework-0.61.1.dist-info/WHEEL +5 -0
  322. charm_crypto_framework-0.61.1.dist-info/licenses/LICENSE.txt +165 -0
  323. charm_crypto_framework-0.61.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,941 @@
1
+ /* ---- SYMMETRIC KEY STUFF -----
2
+ *
3
+ * We put each of the ciphers scheduled keys in their own structs then we put all of
4
+ * the key formats in one union. This makes the function prototypes easier to use.
5
+ */
6
+ #ifdef LTC_BLOWFISH
7
+ struct blowfish_key {
8
+ ulong32 S[4][256];
9
+ ulong32 K[18];
10
+ };
11
+ #endif
12
+
13
+ #ifdef LTC_RC5
14
+ struct rc5_key {
15
+ int rounds;
16
+ ulong32 K[50];
17
+ };
18
+ #endif
19
+
20
+ #ifdef LTC_RC6
21
+ struct rc6_key {
22
+ ulong32 K[44];
23
+ };
24
+ #endif
25
+
26
+ #ifdef LTC_SAFERP
27
+ struct saferp_key {
28
+ unsigned char K[33][16];
29
+ long rounds;
30
+ };
31
+ #endif
32
+
33
+ #ifdef LTC_RIJNDAEL
34
+ struct rijndael_key {
35
+ ulong32 eK[60], dK[60];
36
+ int Nr;
37
+ };
38
+ #endif
39
+
40
+ #ifdef LTC_KSEED
41
+ struct kseed_key {
42
+ ulong32 K[32], dK[32];
43
+ };
44
+ #endif
45
+
46
+ #ifdef LTC_KASUMI
47
+ struct kasumi_key {
48
+ ulong32 KLi1[8], KLi2[8],
49
+ KOi1[8], KOi2[8], KOi3[8],
50
+ KIi1[8], KIi2[8], KIi3[8];
51
+ };
52
+ #endif
53
+
54
+ #ifdef LTC_XTEA
55
+ struct xtea_key {
56
+ unsigned long A[32], B[32];
57
+ };
58
+ #endif
59
+
60
+ #ifdef LTC_TWOFISH
61
+ #ifndef LTC_TWOFISH_SMALL
62
+ struct twofish_key {
63
+ ulong32 S[4][256], K[40];
64
+ };
65
+ #else
66
+ struct twofish_key {
67
+ ulong32 K[40];
68
+ unsigned char S[32], start;
69
+ };
70
+ #endif
71
+ #endif
72
+
73
+ #ifdef LTC_SAFER
74
+ #define LTC_SAFER_K64_DEFAULT_NOF_ROUNDS 6
75
+ #define LTC_SAFER_K128_DEFAULT_NOF_ROUNDS 10
76
+ #define LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS 8
77
+ #define LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS 10
78
+ #define LTC_SAFER_MAX_NOF_ROUNDS 13
79
+ #define LTC_SAFER_BLOCK_LEN 8
80
+ #define LTC_SAFER_KEY_LEN (1 + LTC_SAFER_BLOCK_LEN * (1 + 2 * LTC_SAFER_MAX_NOF_ROUNDS))
81
+ typedef unsigned char safer_block_t[LTC_SAFER_BLOCK_LEN];
82
+ typedef unsigned char safer_key_t[LTC_SAFER_KEY_LEN];
83
+ struct safer_key { safer_key_t key; };
84
+ #endif
85
+
86
+ #ifdef LTC_RC2
87
+ struct rc2_key { unsigned xkey[64]; };
88
+ #endif
89
+
90
+ #ifdef LTC_DES
91
+ struct des_key {
92
+ ulong32 ek[32], dk[32];
93
+ };
94
+
95
+ struct des3_key {
96
+ ulong32 ek[3][32], dk[3][32];
97
+ };
98
+ #endif
99
+
100
+ #ifdef LTC_CAST5
101
+ struct cast5_key {
102
+ ulong32 K[32], keylen;
103
+ };
104
+ #endif
105
+
106
+ #ifdef LTC_NOEKEON
107
+ struct noekeon_key {
108
+ ulong32 K[4], dK[4];
109
+ };
110
+ #endif
111
+
112
+ #ifdef LTC_SKIPJACK
113
+ struct skipjack_key {
114
+ unsigned char key[10];
115
+ };
116
+ #endif
117
+
118
+ #ifdef LTC_KHAZAD
119
+ struct khazad_key {
120
+ ulong64 roundKeyEnc[8 + 1];
121
+ ulong64 roundKeyDec[8 + 1];
122
+ };
123
+ #endif
124
+
125
+ #ifdef LTC_ANUBIS
126
+ struct anubis_key {
127
+ int keyBits;
128
+ int R;
129
+ ulong32 roundKeyEnc[18 + 1][4];
130
+ ulong32 roundKeyDec[18 + 1][4];
131
+ };
132
+ #endif
133
+
134
+ #ifdef LTC_MULTI2
135
+ struct multi2_key {
136
+ int N;
137
+ ulong32 uk[8];
138
+ };
139
+ #endif
140
+
141
+ #ifdef LTC_CAMELLIA
142
+ struct camellia_key {
143
+ int R;
144
+ ulong64 kw[4], k[24], kl[6];
145
+ };
146
+ #endif
147
+
148
+ typedef union Symmetric_key {
149
+ #ifdef LTC_DES
150
+ struct des_key des;
151
+ struct des3_key des3;
152
+ #endif
153
+ #ifdef LTC_RC2
154
+ struct rc2_key rc2;
155
+ #endif
156
+ #ifdef LTC_SAFER
157
+ struct safer_key safer;
158
+ #endif
159
+ #ifdef LTC_TWOFISH
160
+ struct twofish_key twofish;
161
+ #endif
162
+ #ifdef LTC_BLOWFISH
163
+ struct blowfish_key blowfish;
164
+ #endif
165
+ #ifdef LTC_RC5
166
+ struct rc5_key rc5;
167
+ #endif
168
+ #ifdef LTC_RC6
169
+ struct rc6_key rc6;
170
+ #endif
171
+ #ifdef LTC_SAFERP
172
+ struct saferp_key saferp;
173
+ #endif
174
+ #ifdef LTC_RIJNDAEL
175
+ struct rijndael_key rijndael;
176
+ #endif
177
+ #ifdef LTC_XTEA
178
+ struct xtea_key xtea;
179
+ #endif
180
+ #ifdef LTC_CAST5
181
+ struct cast5_key cast5;
182
+ #endif
183
+ #ifdef LTC_NOEKEON
184
+ struct noekeon_key noekeon;
185
+ #endif
186
+ #ifdef LTC_SKIPJACK
187
+ struct skipjack_key skipjack;
188
+ #endif
189
+ #ifdef LTC_KHAZAD
190
+ struct khazad_key khazad;
191
+ #endif
192
+ #ifdef LTC_ANUBIS
193
+ struct anubis_key anubis;
194
+ #endif
195
+ #ifdef LTC_KSEED
196
+ struct kseed_key kseed;
197
+ #endif
198
+ #ifdef LTC_KASUMI
199
+ struct kasumi_key kasumi;
200
+ #endif
201
+ #ifdef LTC_MULTI2
202
+ struct multi2_key multi2;
203
+ #endif
204
+ #ifdef LTC_CAMELLIA
205
+ struct camellia_key camellia;
206
+ #endif
207
+ void *data;
208
+ } symmetric_key;
209
+
210
+ #ifdef LTC_ECB_MODE
211
+ /** A block cipher ECB structure */
212
+ typedef struct {
213
+ /** The index of the cipher chosen */
214
+ int cipher,
215
+ /** The block size of the given cipher */
216
+ blocklen;
217
+ /** The scheduled key */
218
+ symmetric_key key;
219
+ } symmetric_ECB;
220
+ #endif
221
+
222
+ #ifdef LTC_CFB_MODE
223
+ /** A block cipher CFB structure */
224
+ typedef struct {
225
+ /** The index of the cipher chosen */
226
+ int cipher,
227
+ /** The block size of the given cipher */
228
+ blocklen,
229
+ /** The padding offset */
230
+ padlen;
231
+ /** The current IV */
232
+ unsigned char IV[MAXBLOCKSIZE],
233
+ /** The pad used to encrypt/decrypt */
234
+ pad[MAXBLOCKSIZE];
235
+ /** The scheduled key */
236
+ symmetric_key key;
237
+ } symmetric_CFB;
238
+ #endif
239
+
240
+ #ifdef LTC_OFB_MODE
241
+ /** A block cipher OFB structure */
242
+ typedef struct {
243
+ /** The index of the cipher chosen */
244
+ int cipher,
245
+ /** The block size of the given cipher */
246
+ blocklen,
247
+ /** The padding offset */
248
+ padlen;
249
+ /** The current IV */
250
+ unsigned char IV[MAXBLOCKSIZE];
251
+ /** The scheduled key */
252
+ symmetric_key key;
253
+ } symmetric_OFB;
254
+ #endif
255
+
256
+ #ifdef LTC_CBC_MODE
257
+ /** A block cipher CBC structure */
258
+ typedef struct {
259
+ /** The index of the cipher chosen */
260
+ int cipher,
261
+ /** The block size of the given cipher */
262
+ blocklen;
263
+ /** The current IV */
264
+ unsigned char IV[MAXBLOCKSIZE];
265
+ /** The scheduled key */
266
+ symmetric_key key;
267
+ } symmetric_CBC;
268
+ #endif
269
+
270
+
271
+ #ifdef LTC_CTR_MODE
272
+ /** A block cipher CTR structure */
273
+ typedef struct {
274
+ /** The index of the cipher chosen */
275
+ int cipher,
276
+ /** The block size of the given cipher */
277
+ blocklen,
278
+ /** The padding offset */
279
+ padlen,
280
+ /** The mode (endianess) of the CTR, 0==little, 1==big */
281
+ mode,
282
+ /** counter width */
283
+ ctrlen;
284
+
285
+ /** The counter */
286
+ unsigned char ctr[MAXBLOCKSIZE],
287
+ /** The pad used to encrypt/decrypt */
288
+ pad[MAXBLOCKSIZE];
289
+ /** The scheduled key */
290
+ symmetric_key key;
291
+ } symmetric_CTR;
292
+ #endif
293
+
294
+
295
+ #ifdef LTC_LRW_MODE
296
+ /** A LRW structure */
297
+ typedef struct {
298
+ /** The index of the cipher chosen (must be a 128-bit block cipher) */
299
+ int cipher;
300
+
301
+ /** The current IV */
302
+ unsigned char IV[16],
303
+
304
+ /** the tweak key */
305
+ tweak[16],
306
+
307
+ /** The current pad, it's the product of the first 15 bytes against the tweak key */
308
+ pad[16];
309
+
310
+ /** The scheduled symmetric key */
311
+ symmetric_key key;
312
+
313
+ #ifdef LTC_LRW_TABLES
314
+ /** The pre-computed multiplication table */
315
+ unsigned char PC[16][256][16];
316
+ #endif
317
+ } symmetric_LRW;
318
+ #endif
319
+
320
+ #ifdef LTC_F8_MODE
321
+ /** A block cipher F8 structure */
322
+ typedef struct {
323
+ /** The index of the cipher chosen */
324
+ int cipher,
325
+ /** The block size of the given cipher */
326
+ blocklen,
327
+ /** The padding offset */
328
+ padlen;
329
+ /** The current IV */
330
+ unsigned char IV[MAXBLOCKSIZE],
331
+ MIV[MAXBLOCKSIZE];
332
+ /** Current block count */
333
+ ulong32 blockcnt;
334
+ /** The scheduled key */
335
+ symmetric_key key;
336
+ } symmetric_F8;
337
+ #endif
338
+
339
+
340
+ /** cipher descriptor table, last entry has "name == NULL" to mark the end of table */
341
+ extern struct ltc_cipher_descriptor {
342
+ /** name of cipher */
343
+ char *name;
344
+ /** internal ID */
345
+ unsigned char ID;
346
+ /** min keysize (octets) */
347
+ int min_key_length,
348
+ /** max keysize (octets) */
349
+ max_key_length,
350
+ /** block size (octets) */
351
+ block_length,
352
+ /** default number of rounds */
353
+ default_rounds;
354
+ /** Setup the cipher
355
+ @param key The input symmetric key
356
+ @param keylen The length of the input key (octets)
357
+ @param num_rounds The requested number of rounds (0==default)
358
+ @param skey [out] The destination of the scheduled key
359
+ @return CRYPT_OK if successful
360
+ */
361
+ int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
362
+ /** Encrypt a block
363
+ @param pt The plaintext
364
+ @param ct [out] The ciphertext
365
+ @param skey The scheduled key
366
+ @return CRYPT_OK if successful
367
+ */
368
+ int (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
369
+ /** Decrypt a block
370
+ @param ct The ciphertext
371
+ @param pt [out] The plaintext
372
+ @param skey The scheduled key
373
+ @return CRYPT_OK if successful
374
+ */
375
+ int (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
376
+ /** Test the block cipher
377
+ @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
378
+ */
379
+ int (*test)(void);
380
+
381
+ /** Terminate the context
382
+ @param skey The scheduled key
383
+ */
384
+ void (*done)(symmetric_key *skey);
385
+
386
+ /** Determine a key size
387
+ @param keysize [in/out] The size of the key desired and the suggested size
388
+ @return CRYPT_OK if successful
389
+ */
390
+ int (*keysize)(int *keysize);
391
+
392
+ /** Accelerators **/
393
+ /** Accelerated ECB encryption
394
+ @param pt Plaintext
395
+ @param ct Ciphertext
396
+ @param blocks The number of complete blocks to process
397
+ @param skey The scheduled key context
398
+ @return CRYPT_OK if successful
399
+ */
400
+ int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey);
401
+
402
+ /** Accelerated ECB decryption
403
+ @param pt Plaintext
404
+ @param ct Ciphertext
405
+ @param blocks The number of complete blocks to process
406
+ @param skey The scheduled key context
407
+ @return CRYPT_OK if successful
408
+ */
409
+ int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey);
410
+
411
+ /** Accelerated CBC encryption
412
+ @param pt Plaintext
413
+ @param ct Ciphertext
414
+ @param blocks The number of complete blocks to process
415
+ @param IV The initial value (input/output)
416
+ @param skey The scheduled key context
417
+ @return CRYPT_OK if successful
418
+ */
419
+ int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
420
+
421
+ /** Accelerated CBC decryption
422
+ @param pt Plaintext
423
+ @param ct Ciphertext
424
+ @param blocks The number of complete blocks to process
425
+ @param IV The initial value (input/output)
426
+ @param skey The scheduled key context
427
+ @return CRYPT_OK if successful
428
+ */
429
+ int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
430
+
431
+ /** Accelerated CTR encryption
432
+ @param pt Plaintext
433
+ @param ct Ciphertext
434
+ @param blocks The number of complete blocks to process
435
+ @param IV The initial value (input/output)
436
+ @param mode little or big endian counter (mode=0 or mode=1)
437
+ @param skey The scheduled key context
438
+ @return CRYPT_OK if successful
439
+ */
440
+ int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey);
441
+
442
+ /** Accelerated LRW
443
+ @param pt Plaintext
444
+ @param ct Ciphertext
445
+ @param blocks The number of complete blocks to process
446
+ @param IV The initial value (input/output)
447
+ @param tweak The LRW tweak
448
+ @param skey The scheduled key context
449
+ @return CRYPT_OK if successful
450
+ */
451
+ int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey);
452
+
453
+ /** Accelerated LRW
454
+ @param ct Ciphertext
455
+ @param pt Plaintext
456
+ @param blocks The number of complete blocks to process
457
+ @param IV The initial value (input/output)
458
+ @param tweak The LRW tweak
459
+ @param skey The scheduled key context
460
+ @return CRYPT_OK if successful
461
+ */
462
+ int (*accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey);
463
+
464
+ /** Accelerated CCM packet (one-shot)
465
+ @param key The secret key to use
466
+ @param keylen The length of the secret key (octets)
467
+ @param uskey A previously scheduled key [optional can be NULL]
468
+ @param nonce The session nonce [use once]
469
+ @param noncelen The length of the nonce
470
+ @param header The header for the session
471
+ @param headerlen The length of the header (octets)
472
+ @param pt [out] The plaintext
473
+ @param ptlen The length of the plaintext (octets)
474
+ @param ct [out] The ciphertext
475
+ @param tag [out] The destination tag
476
+ @param taglen [in/out] The max size and resulting size of the authentication tag
477
+ @param direction Encrypt or Decrypt direction (0 or 1)
478
+ @return CRYPT_OK if successful
479
+ */
480
+ int (*accel_ccm_memory)(
481
+ const unsigned char *key, unsigned long keylen,
482
+ symmetric_key *uskey,
483
+ const unsigned char *nonce, unsigned long noncelen,
484
+ const unsigned char *header, unsigned long headerlen,
485
+ unsigned char *pt, unsigned long ptlen,
486
+ unsigned char *ct,
487
+ unsigned char *tag, unsigned long *taglen,
488
+ int direction);
489
+
490
+ /** Accelerated GCM packet (one shot)
491
+ @param key The secret key
492
+ @param keylen The length of the secret key
493
+ @param IV The initial vector
494
+ @param IVlen The length of the initial vector
495
+ @param adata The additional authentication data (header)
496
+ @param adatalen The length of the adata
497
+ @param pt The plaintext
498
+ @param ptlen The length of the plaintext (ciphertext length is the same)
499
+ @param ct The ciphertext
500
+ @param tag [out] The MAC tag
501
+ @param taglen [in/out] The MAC tag length
502
+ @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT)
503
+ @return CRYPT_OK on success
504
+ */
505
+ int (*accel_gcm_memory)(
506
+ const unsigned char *key, unsigned long keylen,
507
+ const unsigned char *IV, unsigned long IVlen,
508
+ const unsigned char *adata, unsigned long adatalen,
509
+ unsigned char *pt, unsigned long ptlen,
510
+ unsigned char *ct,
511
+ unsigned char *tag, unsigned long *taglen,
512
+ int direction);
513
+
514
+ /** Accelerated one shot LTC_OMAC
515
+ @param key The secret key
516
+ @param keylen The key length (octets)
517
+ @param in The message
518
+ @param inlen Length of message (octets)
519
+ @param out [out] Destination for tag
520
+ @param outlen [in/out] Initial and final size of out
521
+ @return CRYPT_OK on success
522
+ */
523
+ int (*omac_memory)(
524
+ const unsigned char *key, unsigned long keylen,
525
+ const unsigned char *in, unsigned long inlen,
526
+ unsigned char *out, unsigned long *outlen);
527
+
528
+ /** Accelerated one shot XCBC
529
+ @param key The secret key
530
+ @param keylen The key length (octets)
531
+ @param in The message
532
+ @param inlen Length of message (octets)
533
+ @param out [out] Destination for tag
534
+ @param outlen [in/out] Initial and final size of out
535
+ @return CRYPT_OK on success
536
+ */
537
+ int (*xcbc_memory)(
538
+ const unsigned char *key, unsigned long keylen,
539
+ const unsigned char *in, unsigned long inlen,
540
+ unsigned char *out, unsigned long *outlen);
541
+
542
+ /** Accelerated one shot F9
543
+ @param key The secret key
544
+ @param keylen The key length (octets)
545
+ @param in The message
546
+ @param inlen Length of message (octets)
547
+ @param out [out] Destination for tag
548
+ @param outlen [in/out] Initial and final size of out
549
+ @return CRYPT_OK on success
550
+ @remark Requires manual padding
551
+ */
552
+ int (*f9_memory)(
553
+ const unsigned char *key, unsigned long keylen,
554
+ const unsigned char *in, unsigned long inlen,
555
+ unsigned char *out, unsigned long *outlen);
556
+
557
+ /** Accelerated XTS encryption
558
+ @param pt Plaintext
559
+ @param ct Ciphertext
560
+ @param blocks The number of complete blocks to process
561
+ @param tweak The 128-bit encryption tweak (input/output).
562
+ The tweak should not be encrypted on input, but
563
+ next tweak will be copied encrypted on output.
564
+ @param skey1 The first scheduled key context
565
+ @param skey2 The second scheduled key context
566
+ @return CRYPT_OK if successful
567
+ */
568
+ int (*accel_xts_encrypt)(const unsigned char *pt, unsigned char *ct,
569
+ unsigned long blocks, unsigned char *tweak, symmetric_key *skey1,
570
+ symmetric_key *skey2);
571
+
572
+ /** Accelerated XTS decryption
573
+ @param ct Ciphertext
574
+ @param pt Plaintext
575
+ @param blocks The number of complete blocks to process
576
+ @param tweak The 128-bit encryption tweak (input/output).
577
+ The tweak should not be encrypted on input, but
578
+ next tweak will be copied encrypted on output.
579
+ @param skey1 The first scheduled key context
580
+ @param skey2 The second scheduled key context
581
+ @return CRYPT_OK if successful
582
+ */
583
+ int (*accel_xts_decrypt)(const unsigned char *ct, unsigned char *pt,
584
+ unsigned long blocks, unsigned char *tweak, symmetric_key *skey1,
585
+ symmetric_key *skey2);
586
+ } cipher_descriptor[];
587
+
588
+ #ifdef LTC_BLOWFISH
589
+ int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
590
+ int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
591
+ int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
592
+ int blowfish_test(void);
593
+ void blowfish_done(symmetric_key *skey);
594
+ int blowfish_keysize(int *keysize);
595
+ extern const struct ltc_cipher_descriptor blowfish_desc;
596
+ #endif
597
+
598
+ #ifdef LTC_RC5
599
+ int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
600
+ int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
601
+ int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
602
+ int rc5_test(void);
603
+ void rc5_done(symmetric_key *skey);
604
+ int rc5_keysize(int *keysize);
605
+ extern const struct ltc_cipher_descriptor rc5_desc;
606
+ #endif
607
+
608
+ #ifdef LTC_RC6
609
+ int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
610
+ int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
611
+ int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
612
+ int rc6_test(void);
613
+ void rc6_done(symmetric_key *skey);
614
+ int rc6_keysize(int *keysize);
615
+ extern const struct ltc_cipher_descriptor rc6_desc;
616
+ #endif
617
+
618
+ #ifdef LTC_RC2
619
+ int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
620
+ int rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
621
+ int rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
622
+ int rc2_test(void);
623
+ void rc2_done(symmetric_key *skey);
624
+ int rc2_keysize(int *keysize);
625
+ extern const struct ltc_cipher_descriptor rc2_desc;
626
+ #endif
627
+
628
+ #ifdef LTC_SAFERP
629
+ int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
630
+ int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
631
+ int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
632
+ int saferp_test(void);
633
+ void saferp_done(symmetric_key *skey);
634
+ int saferp_keysize(int *keysize);
635
+ extern const struct ltc_cipher_descriptor saferp_desc;
636
+ #endif
637
+
638
+ #ifdef LTC_SAFER
639
+ int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
640
+ int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
641
+ int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
642
+ int safer_sk128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
643
+ int safer_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key);
644
+ int safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key);
645
+ int safer_k64_test(void);
646
+ int safer_sk64_test(void);
647
+ int safer_sk128_test(void);
648
+ void safer_done(symmetric_key *skey);
649
+ int safer_64_keysize(int *keysize);
650
+ int safer_128_keysize(int *keysize);
651
+ extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc;
652
+ #endif
653
+
654
+ #ifdef LTC_RIJNDAEL
655
+
656
+ /* make aes an alias */
657
+ #define aes_setup rijndael_setup
658
+ #define aes_ecb_encrypt rijndael_ecb_encrypt
659
+ #define aes_ecb_decrypt rijndael_ecb_decrypt
660
+ #define aes_test rijndael_test
661
+ #define aes_done rijndael_done
662
+ #define aes_keysize rijndael_keysize
663
+
664
+ #define aes_enc_setup rijndael_enc_setup
665
+ #define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt
666
+ #define aes_enc_keysize rijndael_enc_keysize
667
+
668
+ int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
669
+ int rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
670
+ int rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
671
+ int rijndael_test(void);
672
+ void rijndael_done(symmetric_key *skey);
673
+ int rijndael_keysize(int *keysize);
674
+ int rijndael_enc_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
675
+ int rijndael_enc_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
676
+ void rijndael_enc_done(symmetric_key *skey);
677
+ int rijndael_enc_keysize(int *keysize);
678
+ extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc;
679
+ extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc;
680
+ #endif
681
+
682
+ #ifdef LTC_XTEA
683
+ int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
684
+ int xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
685
+ int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
686
+ int xtea_test(void);
687
+ void xtea_done(symmetric_key *skey);
688
+ int xtea_keysize(int *keysize);
689
+ extern const struct ltc_cipher_descriptor xtea_desc;
690
+ #endif
691
+
692
+ #ifdef LTC_TWOFISH
693
+ int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
694
+ int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
695
+ int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
696
+ int twofish_test(void);
697
+ void twofish_done(symmetric_key *skey);
698
+ int twofish_keysize(int *keysize);
699
+ extern const struct ltc_cipher_descriptor twofish_desc;
700
+ #endif
701
+
702
+ #ifdef LTC_DES
703
+ int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
704
+ int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
705
+ int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
706
+ int des_test(void);
707
+ void des_done(symmetric_key *skey);
708
+ int des_keysize(int *keysize);
709
+ int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
710
+ int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
711
+ int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
712
+ int des3_test(void);
713
+ void des3_done(symmetric_key *skey);
714
+ int des3_keysize(int *keysize);
715
+ extern const struct ltc_cipher_descriptor des_desc, des3_desc;
716
+ #endif
717
+
718
+ #ifdef LTC_CAST5
719
+ int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
720
+ int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
721
+ int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
722
+ int cast5_test(void);
723
+ void cast5_done(symmetric_key *skey);
724
+ int cast5_keysize(int *keysize);
725
+ extern const struct ltc_cipher_descriptor cast5_desc;
726
+ #endif
727
+
728
+ #ifdef LTC_NOEKEON
729
+ int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
730
+ int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
731
+ int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
732
+ int noekeon_test(void);
733
+ void noekeon_done(symmetric_key *skey);
734
+ int noekeon_keysize(int *keysize);
735
+ extern const struct ltc_cipher_descriptor noekeon_desc;
736
+ #endif
737
+
738
+ #ifdef LTC_SKIPJACK
739
+ int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
740
+ int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
741
+ int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
742
+ int skipjack_test(void);
743
+ void skipjack_done(symmetric_key *skey);
744
+ int skipjack_keysize(int *keysize);
745
+ extern const struct ltc_cipher_descriptor skipjack_desc;
746
+ #endif
747
+
748
+ #ifdef LTC_KHAZAD
749
+ int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
750
+ int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
751
+ int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
752
+ int khazad_test(void);
753
+ void khazad_done(symmetric_key *skey);
754
+ int khazad_keysize(int *keysize);
755
+ extern const struct ltc_cipher_descriptor khazad_desc;
756
+ #endif
757
+
758
+ #ifdef LTC_ANUBIS
759
+ int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
760
+ int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
761
+ int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
762
+ int anubis_test(void);
763
+ void anubis_done(symmetric_key *skey);
764
+ int anubis_keysize(int *keysize);
765
+ extern const struct ltc_cipher_descriptor anubis_desc;
766
+ #endif
767
+
768
+ #ifdef LTC_KSEED
769
+ int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
770
+ int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
771
+ int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
772
+ int kseed_test(void);
773
+ void kseed_done(symmetric_key *skey);
774
+ int kseed_keysize(int *keysize);
775
+ extern const struct ltc_cipher_descriptor kseed_desc;
776
+ #endif
777
+
778
+ #ifdef LTC_KASUMI
779
+ int kasumi_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
780
+ int kasumi_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
781
+ int kasumi_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
782
+ int kasumi_test(void);
783
+ void kasumi_done(symmetric_key *skey);
784
+ int kasumi_keysize(int *keysize);
785
+ extern const struct ltc_cipher_descriptor kasumi_desc;
786
+ #endif
787
+
788
+
789
+ #ifdef LTC_MULTI2
790
+ int multi2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
791
+ int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
792
+ int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
793
+ int multi2_test(void);
794
+ void multi2_done(symmetric_key *skey);
795
+ int multi2_keysize(int *keysize);
796
+ extern const struct ltc_cipher_descriptor multi2_desc;
797
+ #endif
798
+
799
+ #ifdef LTC_CAMELLIA
800
+ int camellia_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
801
+ int camellia_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
802
+ int camellia_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
803
+ int camellia_test(void);
804
+ void camellia_done(symmetric_key *skey);
805
+ int camellia_keysize(int *keysize);
806
+ extern const struct ltc_cipher_descriptor camellia_desc;
807
+ #endif
808
+
809
+ #ifdef LTC_ECB_MODE
810
+ int ecb_start(int cipher, const unsigned char *key,
811
+ int keylen, int num_rounds, symmetric_ECB *ecb);
812
+ int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb);
813
+ int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb);
814
+ int ecb_done(symmetric_ECB *ecb);
815
+ #endif
816
+
817
+ #ifdef LTC_CFB_MODE
818
+ int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
819
+ int keylen, int num_rounds, symmetric_CFB *cfb);
820
+ int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb);
821
+ int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb);
822
+ int cfb_getiv(unsigned char *IV, unsigned long *len, symmetric_CFB *cfb);
823
+ int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb);
824
+ int cfb_done(symmetric_CFB *cfb);
825
+ #endif
826
+
827
+ #ifdef LTC_OFB_MODE
828
+ int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key,
829
+ int keylen, int num_rounds, symmetric_OFB *ofb);
830
+ int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb);
831
+ int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb);
832
+ int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb);
833
+ int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb);
834
+ int ofb_done(symmetric_OFB *ofb);
835
+ #endif
836
+
837
+ #ifdef LTC_CBC_MODE
838
+ int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key,
839
+ int keylen, int num_rounds, symmetric_CBC *cbc);
840
+ int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc);
841
+ int cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CBC *cbc);
842
+ int cbc_getiv(unsigned char *IV, unsigned long *len, symmetric_CBC *cbc);
843
+ int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc);
844
+ int cbc_done(symmetric_CBC *cbc);
845
+ #endif
846
+
847
+ #ifdef LTC_CTR_MODE
848
+
849
+ #define CTR_COUNTER_LITTLE_ENDIAN 0x0000
850
+ #define CTR_COUNTER_BIG_ENDIAN 0x1000
851
+ #define LTC_CTR_RFC3686 0x2000
852
+
853
+ int ctr_start( int cipher,
854
+ const unsigned char *IV,
855
+ const unsigned char *key, int keylen,
856
+ int num_rounds, int ctr_mode,
857
+ symmetric_CTR *ctr);
858
+ int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr);
859
+ int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr);
860
+ int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr);
861
+ int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr);
862
+ int ctr_done(symmetric_CTR *ctr);
863
+ int ctr_test(void);
864
+ #endif
865
+
866
+ #ifdef LTC_LRW_MODE
867
+
868
+ #define LRW_ENCRYPT 0
869
+ #define LRW_DECRYPT 1
870
+
871
+ int lrw_start( int cipher,
872
+ const unsigned char *IV,
873
+ const unsigned char *key, int keylen,
874
+ const unsigned char *tweak,
875
+ int num_rounds,
876
+ symmetric_LRW *lrw);
877
+ int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw);
878
+ int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw);
879
+ int lrw_getiv(unsigned char *IV, unsigned long *len, symmetric_LRW *lrw);
880
+ int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw);
881
+ int lrw_done(symmetric_LRW *lrw);
882
+ int lrw_test(void);
883
+
884
+ /* don't call */
885
+ int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw);
886
+ #endif
887
+
888
+ #ifdef LTC_F8_MODE
889
+ int f8_start( int cipher, const unsigned char *IV,
890
+ const unsigned char *key, int keylen,
891
+ const unsigned char *salt_key, int skeylen,
892
+ int num_rounds, symmetric_F8 *f8);
893
+ int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_F8 *f8);
894
+ int f8_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_F8 *f8);
895
+ int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8);
896
+ int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8);
897
+ int f8_done(symmetric_F8 *f8);
898
+ int f8_test_mode(void);
899
+ #endif
900
+
901
+ #ifdef LTC_XTS_MODE
902
+ typedef struct {
903
+ symmetric_key key1, key2;
904
+ int cipher;
905
+ } symmetric_xts;
906
+
907
+ int xts_start( int cipher,
908
+ const unsigned char *key1,
909
+ const unsigned char *key2,
910
+ unsigned long keylen,
911
+ int num_rounds,
912
+ symmetric_xts *xts);
913
+
914
+ int xts_encrypt(
915
+ const unsigned char *pt, unsigned long ptlen,
916
+ unsigned char *ct,
917
+ unsigned char *tweak,
918
+ symmetric_xts *xts);
919
+ int xts_decrypt(
920
+ const unsigned char *ct, unsigned long ptlen,
921
+ unsigned char *pt,
922
+ unsigned char *tweak,
923
+ symmetric_xts *xts);
924
+
925
+ void xts_done(symmetric_xts *xts);
926
+ int xts_test(void);
927
+ void xts_mult_x(unsigned char *I);
928
+ #endif
929
+
930
+ int find_cipher(const char *name);
931
+ int find_cipher_any(const char *name, int blocklen, int keylen);
932
+ int find_cipher_id(unsigned char ID);
933
+ int register_cipher(const struct ltc_cipher_descriptor *cipher);
934
+ int unregister_cipher(const struct ltc_cipher_descriptor *cipher);
935
+ int cipher_is_valid(int idx);
936
+
937
+ LTC_MUTEX_PROTO(ltc_cipher_mutex)
938
+
939
+ /* $Source$ */
940
+ /* $Revision$ */
941
+ /* $Date$ */