Package list libcryptx-perl / ea35d10
Import original source of CryptX 0.048 Lucas Kanashiro 4 years ago
929 changed file(s) with 132892 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Changes for CryptX
1
2 TODO:
3 - add support for PKCS#8 encrypted RSA+ECC private keys "-----BEGIN ENCRYPTED PRIVATE KEY-----"
4 - RSA|DSA|ECC: verify_key($level) (basic check + extented primality test)
5 - better primality testing: http://questhub.io/realm/perl/quest/519032ee1088c76505000035 (idea: mp_prime_lucas)
6 - DSA: generate_key($p, $q, $g), generate_key(\$dsa_params_der), generate_key($dsa_params_file)
7 - XS croaks should report the "real caller" (Crypt::Mac::*, Crypt::Mode::*, ...)
8 - maybe: add CCM interface for new-add-add-done mode
9 - maybe: add encode_b32/decode_b32
10
11 0.048 2017/05/31
12 - NEW: Crypt::Digest::SHA3_224
13 - NEW: Crypt::Digest::SHA3_256
14 - NEW: Crypt::Digest::SHA3_384
15 - NEW: Crypt::Digest::SHA3_512
16 - NEW: Crypt::Digest::SHAKE
17 - NEW: Crypt::Digest::BLAKE2b_160
18 - NEW: Crypt::Digest::BLAKE2b_256
19 - NEW: Crypt::Digest::BLAKE2b_384
20 - NEW: Crypt::Digest::BLAKE2b_512
21 - NEW: Crypt::Digest::BLAKE2s_128
22 - NEW: Crypt::Digest::BLAKE2s_160
23 - NEW: Crypt::Digest::BLAKE2s_224
24 - NEW: Crypt::Digest::BLAKE2s_256
25 - NEW: Crypt::AuthEnc::ChaCha20Poly1305
26 - NEW: Crypt::Mac::Poly1305
27 - NEW: Crypt::Mac::BLAKE2s
28 - NEW: Crypt::Mac::BLAKE2b
29 - NEW: Crypt::PRNG::ChaCha20
30 - NEW: Crypt::Stream::ChaCha
31 - NEW: Crypt::Stream::RC4
32 - NEW: Crypt::Stream::Sober128
33 - NEW: functions in Crypt::Misc - increment_octets_be, increment_octets_le
34 - Crypt::PRNG now uses chacha20 prng by default
35
36 0.047 2017/04/05
37 - fix #32 Compile "ar" step fails when Perl built with -flto (better version)
38 - fix #33 build fails on freebsd 9.2 and 10.0 (ar: fatal: Numeric group ID too large)
39
40 0.046 2017/04/04
41 - fix #32 Compile "ar" step fails when Perl built with -flto
42
43 0.045 2017/03/31
44 - sync with libtomcrypt/develop
45 - fix #30 fix on SPARC+SolarisStudio
46 - fix #31 Fails tests without '.' in @INC
47 - polish compiler warnings
48
49 0.044 2016/11/28
50 - fix #27 Math::BigInt::LTM compatibility with older Math::BigInt
51
52 0.043 2016/11/27
53 - fix #26 Math::BigInt::LTM compatibility with Math::BigInt 1.999801+
54
55 0.042 2016/11/12
56 - RSA: sign/verify functions now support 'none' padding (INSECURE!)
57 - RC2: min keylen 40bit, used to be 64bit (INSECURE!)
58
59 0.041 2016/10/12
60 - ECC: ltc_ecc_is_point memory leak
61 - DSA: properly handle FIPS 186-4 (4.6 + 4.7)
62 - GCM: counter incrementation isn't stopped at 2^32 blocks, which breaks GCM
63 - fix issue #24 Crypt::PK::ECC needs $VERSION (all *.pm have $VERSION)
64
65 0.040 2016/09/12
66 - fix file permissions
67 - fix compiler warnings
68
69 0.039 2016/08/02
70 - fix build troubles for MacOS / PPC
71
72 0.038 2016/07/06
73 - fix issue #20 DSA/RSA/ECC/DH key2hash - hexadecimal numbers are missing leading zero
74 - Math::BigInt::LTM fixed mp_invmod(a,b,c) for b == 1
75 - Math::BigInt::LTM fixed _log_int()
76 - Math::BigInt::LTM fixed _alen()
77 - fix 'Please specify prototyping behavior for CryptX.xs'
78 - libtomcrypt (renaming *tab.c > *tab.c.inc not needed anymore)
79
80 0.037 2016/06/16
81 - fix issue #18 Minor issue with comment syntax
82 - fix issue #19 t/checksum.t fails on AIX-5.3
83
84 0.036 2016/06/07
85 - fix issue #17 ability to export ecc keys in short/oid form
86
87 0.035 2016/06/03
88 - fix issue #14 Ensure Crypt::PK::ECC->key2hash()->{curve_name} is lowercase
89 - fix issue #15 OpenSSL interoperability broken
90
91 0.034 2016/05/11
92 - Prevent RSA import_key() from altering a JWK hash reference
93
94 0.033 2016/05/09
95 - MSVC6 related fixes (needed for older ActivePerl@MSWin32)
96
97 0.032 2016/05/04
98 - Crypt::PK::DH - accept base/prime values
99 - new: DH methods export_key_raw, import_key_raw, params2hash
100 - enhanced: DH method generate_key
101 - new: Crypt::Checksum, Crypt::Checksum::CRC32, Crypt::Checksum::Adler32
102
103 0.031 2016/05/01
104 - new: RSA+ECC method export_key_jwk_thumbprint()
105 - new: Crypt::Misc functions random_v4uuid + is_v4uuid
106 - fix: RSA+ECC export_key_jwk produces canonical JSON
107 - fix: RSA+DSA public key export now produces PEM/DER compatible with openssl
108 public keys exported be previous version can still be imported
109 - fix: ECC import_key now accepts non-standard JWK curve names e.g. "secp112r1", "secp521r1"
110
111 0.030 2016/04/13
112 - fix: 0.029 + 0.028 by mistake installed *.inc files to perl/(lib|site|vendor)
113
114 0.029 2016/04/13
115 - NEW module: Math::BigInt::LTM
116 - NEW module: Crypt::Misc
117
118 0.028 2016/03/23
119 - IMPORTANT: switch from Module::Build to ExtUtils::MakeMaker
120 - fix for broken DSA key (ssh format) loading
121
122 0.027 2016/01/25
123 - sync with https://github.com/libtom/libtomcrypt (branch develop)
124 - sync with https://github.com/libtom/libtommath (branch develop)
125 - HP-UX related fixes
126 - JSON dependency is now optional (we check JSON::PP, JSON::XS, Cpanel::JSON::XS)
127 - skip jwk.t if no JSON::* module available
128 - does not require MIME::Base64 (we use base64 routines from libtomcrypt)
129
130 0.026 2015/11/28
131 - switch to JSON::MaybeXS
132 - Crypt::PRNG - rand/irand related cosmetics
133 - consistently using UNIX newlines
134
135 0.025 2015/07/07
136 - Crypt::PK::ECC+RSA export_key_jwk() allows to export a perl HASH with JWK structure
137
138 0.024 2015/06/29
139 - new Crypt::PK::ECC methods
140 verify_message_rfc7518()
141 sign_message_rfc7518()
142 curve2hash()
143 - fix for Crypt::PK::RSA - bug in loading private key in JWK format
144
145 0.023 2015/06/10
146 - support for older compilers (gcc3, vc6)
147 - typo in documentation (by tomhukins)
148
149 0.022 2015/05/22
150 - new: Crypt::PK::ECC+RSA export_key_jwk() - exporting JWK format
151 - new: Crypt::Digest::SHA512_224
152 - new: Crypt::Digest::SHA512_256
153 - Crypt::PK::ECC+RSA import_key() - support for:
154 * public/private keys in JWK format
155 * private keys in PKCS8 PEM/DER format (unencrypted only)
156 - Crypt::PK::ECC+RSA+DSA import_key() - support for:
157 * public keys in SSH format
158 * public/private keys as a hashref exported via key2hash
159 - libtomcrypt updated to the latest develop branch, commit aeaa6d4a51 Apr 17 08:59:35 2015 +0200
160 - libtommath updated to the latest develop branch, commit 0fd5e6c17f Dec 11 14:59:35 2014 +0100
161 - documentation fixes
162
163 0.021 2014/01/23
164 - fixed asm(...) related compiler failures
165 - dsa_encrypt_key small correction
166 - optimized ecc_encrypt_key
167
168 0.020 2014/01/18
169 - INCOMPATIBLE CHANGE: huge redesign of Crypt::PK::ECC
170 - ECC now supports curves y^2 = x^3 + a*x + b
171 - ECC you can use custom curves
172 - ECC import/export of keys in DER/PEM format now compatible with openssl
173 - enabling compile options ASM + ECC_TIMING_RESISTANT
174 - added many test vectors (RSA, DSA, EC) for interoperability with openssl
175
176 0.019 2013/10/20
177 - fixed broken CAMELLIA implementation
178
179 0.018 2013/10/18
180 - DSA: make_key + sign_hash fixes
181
182 0.017 2013/09/24
183 - lowering MIME::Base64 version requirement
184 - support for import/export of password protected RSA/DSA keys
185 - RSA: added - export_key_pem('public_x509')
186 - better handling of dh_free/rsa_free/dsa_free/ecc_free
187 - added openssl test vectors
188 - fixed compiler warnings (RSA/DSA/ECC/DH)
189
190 0.016 2013/09/15
191 - added missing test for key2hash, sign_hash, verify_hash
192 - fixed build failures on VC6
193
194 0.015 2013/09/12
195 - only documentation fixes
196
197 0.014 2013/09/11
198 - Crypt::Digest::NNN + Crypt::Mac::NNN - can produce Base64-URL-Safe encoded digest/mac
199 - Crypt::PRNG + Crypt::PRNG::NNN - Base64-URL-Safe encoded random bytes (random_bytes_b64u/bytes_b64u)
200 - Crypt::PK::RSA/DSA/DH/ECC - sign/verify replaced by sign_message/verify_message + sign_hash/verify_hash
201 - Crypt::PK::RSA/DSA/DH/ECC - new method key2hash
202 - documentation fixes
203
204 0.013 2013/08/28
205 - DSA/RSA/ECC/DH - importing keys from string changed - now: $pk->import_key(\$buffer_with_key)
206 - DSA/RSA/ECC/DH - size() and is_private() now return undef if no key loaded
207 - improved RSA doc
208
209 0.012 2013/06/17
210 - README, LICENSE etc. to improve CPANTS score
211 - somehow works with perl 5.6.2
212
213 0.011 2013/06/15
214 - fixing various compiler warnings
215
216 0.009 2013/05/19
217 - doc fixes
218 - requires perl 5.8.8 or higher
219 - INCOMPATIBILITY: all digest related 'xxx_base64' functions renamed to 'xxx_b64'
220
221 0.008 2013/05/02
222 - fixed prng test failures
223 - Crypt::Digest::* croaks with the "real caller" (not a nice solution)
224
225 0.007 2013/04/23
226 - Crypt::PRNG supports add_entropy() - without params
227 - Crypt::PRNG fork-safe & thread-safe
228 - random_string has default $len = 20
229 - doc fixes
230 - cpan tester failure fix for pk_dsa.t
231
232 0.006 2013/04/19
233 - added Crypt::KeyDerivation
234 - Win64 compatibility
235
236 0.005 2013/04/18
237 - added Crypt::PRNG::Fortuna|RC4|Sober128|Yarrow
238 - added Crypt::PK::RSA|DSA|ECC|DH
239
240 0.004 2013/04/16
241 - removing illegal Crypt::Random
242
243 0.003 2013/04/16
244 - added Crypt::Mode::CBC|CFB|CTR|ECB|OFB
245 - added Crypt::AuthEnc::CCM|EAX|GCM|OCB
246
247 0.002 2013/04/11
248 - first release on CPAN
0 #include "EXTERN.h"
1 #include "perl.h"
2 #include "XSUB.h"
3
4 #define NEED_sv_2pvbyte_GLOBAL
5 #define NEED_sv_2pv_flags_GLOBAL
6 #define NEED_newRV_noinc_GLOBAL
7 #include "ppport.h"
8
9 #undef LTC_SOURCE
10 #include "tomcrypt.h"
11 #include "tommath.h"
12
13 typedef adler32_state *Crypt__Checksum__Adler32;
14 typedef crc32_state *Crypt__Checksum__CRC32;
15
16 typedef struct cipher_struct { /* used by Crypt::Cipher */
17 symmetric_key skey;
18 int id;
19 struct ltc_cipher_descriptor *desc;
20 } *Crypt__Cipher;
21
22 typedef struct digest_struct { /* used by Crypt::Digest */
23 hash_state state;
24 int id;
25 struct ltc_hash_descriptor *desc;
26 } *Crypt__Digest;
27
28 typedef struct digest_shake_struct { /* used by Crypt::Digest::SHAKE */
29 hash_state state;
30 int num;
31 } *Crypt__Digest__SHAKE;
32
33 typedef struct ccm_struct { /* used by Crypt::AuthEnc::CCM */
34 ccm_state state;
35 int id;
36 } *Crypt__AuthEnc__CCM;
37
38 typedef struct eax_struct { /* used by Crypt::AuthEnc::EAX */
39 eax_state state;
40 int id;
41 } *Crypt__AuthEnc__EAX;
42
43 typedef struct gcm_struct { /* used by Crypt::AuthEnc::GCM */
44 gcm_state state;
45 int id;
46 } *Crypt__AuthEnc__GCM;
47
48 typedef struct chacha20poly1305_struct {/* used by Crypt::AuthEnc::ChaCha20Poly1305 */
49 chacha20poly1305_state state;
50 int id;
51 } *Crypt__AuthEnc__ChaCha20Poly1305;
52
53 typedef struct ocb_struct { /* used by Crypt::AuthEnc::OCB */
54 ocb3_state state;
55 int id;
56 } *Crypt__AuthEnc__OCB;
57
58 typedef struct chacha_struct { /* used by Crypt::Stream::ChaCha */
59 chacha_state state;
60 int id;
61 } *Crypt__Stream__ChaCha;
62
63 typedef struct rc4_struct { /* used by Crypt::Stream::RC4 */
64 rc4_state state;
65 int id;
66 } *Crypt__Stream__RC4;
67
68 typedef struct sober128_struct { /* used by Crypt::Stream::Sober128 */
69 sober128_state state;
70 int id;
71 } *Crypt__Stream__Sober128;
72
73 typedef struct f9_struct { /* used by Crypt::Mac::F9 */
74 f9_state state;
75 int id;
76 } *Crypt__Mac__F9;
77
78 typedef struct hmac_struct { /* used by Crypt::Mac::HMAC */
79 hmac_state state;
80 int id;
81 } *Crypt__Mac__HMAC;
82
83 typedef struct omac_struct { /* used by Crypt::Mac::OMAC */
84 omac_state state;
85 int id;
86 } *Crypt__Mac__OMAC;
87
88 typedef struct pelican_struct { /* used by Crypt::Mac::Pelican */
89 pelican_state state;
90 int id;
91 } *Crypt__Mac__Pelican;
92
93 typedef struct pmac_struct { /* used by Crypt::Mac::PMAC */
94 pmac_state state;
95 int id;
96 } *Crypt__Mac__PMAC;
97
98 typedef struct xcbc_struct { /* used by Crypt::Mac::XCBC */
99 xcbc_state state;
100 int id;
101 } *Crypt__Mac__XCBC;
102
103 typedef struct poly1305_struct { /* used by Crypt::Mac::Poly1305 */
104 poly1305_state state;
105 int id;
106 } *Crypt__Mac__Poly1305;
107
108 typedef struct blake2s_struct { /* used by Crypt::Mac::BLAKE2s */
109 blake2smac_state state;
110 int id;
111 } *Crypt__Mac__BLAKE2s;
112
113 typedef struct blake2b_struct { /* used by Crypt::Mac::BLAKE2b */
114 blake2bmac_state state;
115 int id;
116 } *Crypt__Mac__BLAKE2b;
117
118 typedef struct cbc_struct { /* used by Crypt::Mode::CBC */
119 int cipher_id, cipher_rounds;
120 symmetric_CBC state;
121 unsigned char pad[MAXBLOCKSIZE];
122 int padlen;
123 int padding_mode;
124 int direction;
125 int id;
126 } *Crypt__Mode__CBC;
127
128 typedef struct ecb_struct { /* used by Crypt::Mode::ECB */
129 int cipher_id, cipher_rounds;
130 symmetric_ECB state;
131 unsigned char pad[MAXBLOCKSIZE];
132 int padlen;
133 int padding_mode;
134 int direction;
135 int id;
136 } *Crypt__Mode__ECB;
137
138 typedef struct cfb_struct { /* used by Crypt::Mode::CFB */
139 int cipher_id, cipher_rounds;
140 symmetric_CFB state;
141 int direction;
142 int id;
143 } *Crypt__Mode__CFB;
144
145 typedef struct ctr_struct { /* used by Crypt::Mode::CTR */
146 int cipher_id, cipher_rounds;
147 int ctr_mode_param;
148 symmetric_CTR state;
149 int direction;
150 int id;
151 } *Crypt__Mode__CTR;
152
153 typedef struct f8_struct { /* used by Crypt::Mode::F8 */
154 int cipher_id, cipher_rounds;
155 symmetric_F8 state;
156 int direction;
157 int id;
158 } *Crypt__Mode__F8;
159
160 typedef struct lrw_struct { /* used by Crypt::Mode::LRW */
161 int cipher_id, cipher_rounds;
162 symmetric_LRW state;
163 int direction;
164 int id;
165 } *Crypt__Mode__LRW;
166
167 typedef struct ofb_struct { /* used by Crypt::Mode::OFB */
168 int cipher_id, cipher_rounds;
169 symmetric_OFB state;
170 int direction;
171 int id;
172 } *Crypt__Mode__OFB;
173
174 typedef struct xts_struct { /* used by Crypt::Mode::XTS */
175 int cipher_id, cipher_rounds;
176 symmetric_xts state;
177 int direction;
178 int id;
179 } *Crypt__Mode__XTS;
180
181 typedef struct prng_struct { /* used by Crypt::PRNG */
182 prng_state state;
183 struct ltc_prng_descriptor *desc;
184 IV last_pid;
185 int id;
186 } *Crypt__PRNG;
187
188 typedef struct rsa_struct { /* used by Crypt::PK::RSA */
189 prng_state pstate;
190 int pindex;
191 rsa_key key;
192 int id;
193 } *Crypt__PK__RSA;
194
195 typedef struct dsa_struct { /* used by Crypt::PK::DSA */
196 prng_state pstate;
197 int pindex;
198 dsa_key key;
199 int id;
200 } *Crypt__PK__DSA;
201
202 typedef struct dh_struct { /* used by Crypt::PK::DH */
203 prng_state pstate;
204 int pindex;
205 dh_key key;
206 int id;
207 } *Crypt__PK__DH;
208
209 typedef struct ecc_struct { /* used by Crypt::PK::ECC */
210 prng_state pstate;
211 int pindex;
212 ecc_key key;
213 ltc_ecc_set_type dp;
214 int id;
215 } *Crypt__PK__ECC;
216
217 int str_add_leading_zero(char *str, int maxlen, int minlen) {
218 int len;
219 len = (int)strlen(str);
220 if (len > 0 && len % 2 && len < maxlen-2) {
221 memmove(str+1, str, len+1); /* incl. NUL byte */
222 *str = '0'; /* add leading zero */
223 }
224 len = (int)strlen(str);
225 if (len < minlen && minlen < maxlen-1) {
226 memmove(str+(minlen-len), str, len+1); /* incl. NUL byte */
227 memset(str, '0', minlen-len); /* add leading zero */
228 }
229 return MP_OKAY;
230 }
231
232 int mp_tohex_with_leading_zero(mp_int * a, char *str, int maxlen, int minlen) {
233 int rv;
234 if (mp_isneg(a) == MP_YES) {
235 *str = '\0';
236 return MP_VAL;
237 }
238 rv = mp_toradix_n(a, str, 16, maxlen);
239 if (rv != MP_OKAY) {
240 *str = '\0';
241 return rv;
242 }
243 return str_add_leading_zero(str, maxlen, minlen);
244 }
245
246 /* Math::BigInt::LTM related */
247 typedef mp_int * Math__BigInt__LTM;
248 STATIC SV * sv_from_mpi(mp_int *mpi) {
249 SV *obj = newSV(0);
250 sv_setref_pv(obj, "Math::BigInt::LTM", (void*)mpi);
251 return obj;
252 }
253
254 ltc_ecc_set_type* _ecc_set_dp_from_SV(ltc_ecc_set_type *dp, SV *curve)
255 {
256 HV *h;
257 SV *param, **pref;
258 SV **sv_cofactor, **sv_prime, **sv_A, **sv_B, **sv_order, **sv_Gx, **sv_Gy;
259 int err;
260 char *ch_name;
261 STRLEN l_name;
262
263 if (SvPOK(curve)) {
264 ch_name = SvPV(curve, l_name);
265 if ((h = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: generate_key_ex: no curve register");
266 if ((pref = hv_fetch(h, ch_name, (U32)l_name, 0)) == NULL) croak("FATAL: generate_key_ex: unknown curve/1 '%s'", ch_name);
267 if (!SvOK(*pref)) croak("FATAL: generate_key_ex: unknown curve/2 '%s'", ch_name);
268 param = *pref;
269 }
270 else if (SvROK(curve)) {
271 param = curve;
272 }
273 else {
274 croak("FATAL: curve has to be a string or a hashref");
275 }
276
277 if ((h = (HV*)(SvRV(param))) == NULL) croak("FATAL: ecparams: param is not valid hashref");
278
279 if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime");
280 if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A");
281 if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B");
282 if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order");
283 if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx");
284 if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy");
285 if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor");
286
287 if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime");
288 if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A");
289 if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B");
290 if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order");
291 if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx");
292 if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy");
293 if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor");
294
295 err = ecc_dp_set( dp,
296 SvPV_nolen(*sv_prime),
297 SvPV_nolen(*sv_A),
298 SvPV_nolen(*sv_B),
299 SvPV_nolen(*sv_order),
300 SvPV_nolen(*sv_Gx),
301 SvPV_nolen(*sv_Gy),
302 (unsigned long)SvUV(*sv_cofactor),
303 NULL, /* we intentionally don't allow setting custom names */
304 NULL /* we intentionally don't allow setting custom OIDs */
305 );
306 return err == CRYPT_OK ? dp : NULL;
307 }
308
309 void _ecc_free_key(ecc_key *key, ltc_ecc_set_type *dp)
310 {
311 if(dp) {
312 ecc_dp_clear(dp);
313 }
314 if (key->type != -1) {
315 ecc_free(key);
316 key->type = -1;
317 key->dp = NULL;
318 }
319 }
320
321 MODULE = CryptX PACKAGE = CryptX PREFIX = CryptX_
322
323 PROTOTYPES: DISABLE
324
325 BOOT:
326 if(register_cipher(&blowfish_desc)==-1) { croak("FATAL: cannot register_cipher blowfish"); }
327 if(register_cipher(&rc5_desc)==-1) { croak("FATAL: cannot register_cipher rc5"); }
328 if(register_cipher(&rc6_desc)==-1) { croak("FATAL: cannot register_cipher rc6"); }
329 if(register_cipher(&rc2_desc)==-1) { croak("FATAL: cannot register_cipher rc2"); }
330 if(register_cipher(&saferp_desc)==-1) { croak("FATAL: cannot register_cipher saferp"); }
331 if(register_cipher(&safer_k64_desc)==-1) { croak("FATAL: cannot register_cipher safer_k64"); }
332 if(register_cipher(&safer_k128_desc)==-1) { croak("FATAL: cannot register_cipher safer_k128"); }
333 if(register_cipher(&safer_sk64_desc)==-1) { croak("FATAL: cannot register_cipher safer_sk64"); }
334 if(register_cipher(&safer_sk128_desc)==-1) { croak("FATAL: cannot register_cipher safer_sk128"); }
335 if(register_cipher(&aes_desc)==-1) { croak("FATAL: cannot register_cipher aes"); }
336 if(register_cipher(&xtea_desc)==-1) { croak("FATAL: cannot register_cipher xtea"); }
337 if(register_cipher(&twofish_desc)==-1) { croak("FATAL: cannot register_cipher twofish"); }
338 if(register_cipher(&des_desc)==-1) { croak("FATAL: cannot register_cipher des"); }
339 if(register_cipher(&des3_desc)==-1) { croak("FATAL: cannot register_cipher des3"); }
340 if(register_cipher(&cast5_desc)==-1) { croak("FATAL: cannot register_cipher cast5"); }
341 if(register_cipher(&noekeon_desc)==-1) { croak("FATAL: cannot register_cipher noekeon"); }
342 if(register_cipher(&skipjack_desc)==-1) { croak("FATAL: cannot register_cipher skipjack"); }
343 if(register_cipher(&khazad_desc)==-1) { croak("FATAL: cannot register_cipher khazad"); }
344 if(register_cipher(&anubis_desc)==-1) { croak("FATAL: cannot register_cipher anubis"); }
345 if(register_cipher(&kseed_desc)==-1) { croak("FATAL: cannot register_cipher kseed"); }
346 if(register_cipher(&kasumi_desc)==-1) { croak("FATAL: cannot register_cipher kasumi"); }
347 if(register_cipher(&multi2_desc)==-1) { croak("FATAL: cannot register_cipher multi2"); }
348 if(register_cipher(&camellia_desc)==-1) { croak("FATAL: cannot register_cipher camellia"); }
349 /* --- */
350 if(register_hash(&chc_desc)==-1) { croak("FATAL: cannot register_hash chc_hash"); }
351 if(register_hash(&md2_desc)==-1) { croak("FATAL: cannot register_hash md2"); }
352 if(register_hash(&md4_desc)==-1) { croak("FATAL: cannot register_hash md4"); }
353 if(register_hash(&md5_desc)==-1) { croak("FATAL: cannot register_hash md5"); }
354 if(register_hash(&rmd128_desc)==-1) { croak("FATAL: cannot register_hash rmd128"); }
355 if(register_hash(&rmd160_desc)==-1) { croak("FATAL: cannot register_hash rmd160"); }
356 if(register_hash(&rmd256_desc)==-1) { croak("FATAL: cannot register_hash rmd256"); }
357 if(register_hash(&rmd320_desc)==-1) { croak("FATAL: cannot register_hash rmd320"); }
358 if(register_hash(&sha1_desc)==-1) { croak("FATAL: cannot register_hash sha1"); }
359 if(register_hash(&sha224_desc)==-1) { croak("FATAL: cannot register_hash sha224"); }
360 if(register_hash(&sha256_desc)==-1) { croak("FATAL: cannot register_hash sha256"); }
361 if(register_hash(&sha384_desc)==-1) { croak("FATAL: cannot register_hash sha384"); }
362 if(register_hash(&sha512_desc)==-1) { croak("FATAL: cannot register_hash sha512"); }
363 if(register_hash(&sha512_224_desc)==-1) { croak("FATAL: cannot register_hash sha512_224"); }
364 if(register_hash(&sha512_256_desc)==-1) { croak("FATAL: cannot register_hash sha512_256"); }
365 if(register_hash(&sha3_224_desc)==-1) { croak("FATAL: cannot register_hash sha3_224"); }
366 if(register_hash(&sha3_256_desc)==-1) { croak("FATAL: cannot register_hash sha3_256"); }
367 if(register_hash(&sha3_384_desc)==-1) { croak("FATAL: cannot register_hash sha3_384"); }
368 if(register_hash(&sha3_512_desc)==-1) { croak("FATAL: cannot register_hash sha3_512"); }
369 if(register_hash(&tiger_desc)==-1) { croak("FATAL: cannot register_hash tiger"); }
370 if(register_hash(&whirlpool_desc)==-1) { croak("FATAL: cannot register_hash whirlpool"); }
371 if(register_hash(&blake2b_160_desc)==-1) { croak("FATAL: cannot register_hash blake2b_160"); }
372 if(register_hash(&blake2b_256_desc)==-1) { croak("FATAL: cannot register_hash blake2b_256"); }
373 if(register_hash(&blake2b_384_desc)==-1) { croak("FATAL: cannot register_hash blake2b_384"); }
374 if(register_hash(&blake2b_512_desc)==-1) { croak("FATAL: cannot register_hash blake2b_512"); }
375 if(register_hash(&blake2s_128_desc)==-1) { croak("FATAL: cannot register_hash blake2s_128"); }
376 if(register_hash(&blake2s_160_desc)==-1) { croak("FATAL: cannot register_hash blake2s_160"); }
377 if(register_hash(&blake2s_224_desc)==-1) { croak("FATAL: cannot register_hash blake2s_224"); }
378 if(register_hash(&blake2s_256_desc)==-1) { croak("FATAL: cannot register_hash blake2s_256"); }
379 /* --- */
380 if(chc_register(find_cipher("aes"))==-1) { croak("FATAL: chc_register failed"); }
381 /* --- */
382 if(register_prng(&fortuna_desc)==-1) { croak("FATAL: cannot register_prng fortuna"); }
383 if(register_prng(&yarrow_desc)==-1) { croak("FATAL: cannot register_prng yarrow"); }
384 if(register_prng(&rc4_desc)==-1) { croak("FATAL: cannot register_prng rc4"); }
385 if(register_prng(&sober128_desc)==-1) { croak("FATAL: cannot register_prng sober128"); }
386 if(register_prng(&chacha20_prng_desc)==-1) { croak("FATAL: cannot register_prng chacha20"); }
387 /* --- */
388 #ifdef TFM_DESC
389 ltc_mp = tfm_desc;
390 #else
391 ltc_mp = ltm_desc;
392 #endif
393
394 SV *
395 CryptX__encode_base64url(SV * in)
396 CODE:
397 {
398 STRLEN in_len;
399 unsigned long out_len;
400 unsigned char *out_data, *in_data;
401 int rv;
402
403 if (!SvPOK(in)) XSRETURN_UNDEF;
404 in_data = (unsigned char *) SvPVbyte(in, in_len);
405 out_len = (unsigned long)(4 * ((in_len + 2) / 3) + 1);
406 Newz(0, out_data, out_len, unsigned char);
407 if (!out_data) croak("FATAL: Newz failed [%ld]", out_len);
408 rv = base64url_encode(in_data, (unsigned long)in_len, out_data, &out_len);
409 RETVAL = (rv == CRYPT_OK) ? newSVpvn((char *)out_data, out_len) : newSVpvn(NULL, 0);
410 Safefree(out_data);
411 }
412 OUTPUT:
413 RETVAL
414
415 SV *
416 CryptX__decode_base64url(SV * in)
417 CODE:
418 {
419 STRLEN in_len;
420 unsigned long out_len;
421 unsigned char *out_data, *in_data;
422 int rv;
423
424 if (!SvPOK(in)) XSRETURN_UNDEF;
425 in_data = (unsigned char *) SvPVbyte(in, in_len);
426 out_len = (unsigned long)in_len;
427 Newz(0, out_data, out_len, unsigned char);
428 if (!out_data) croak("FATAL: Newz failed [%ld]", out_len);
429 rv = base64url_decode(in_data, (unsigned long)in_len, out_data, &out_len);
430 RETVAL = (rv == CRYPT_OK) ? newSVpvn((char *)out_data, out_len) : newSVpvn(NULL, 0);
431 Safefree(out_data);
432 }
433 OUTPUT:
434 RETVAL
435
436 SV *
437 CryptX__encode_base64(SV * in)
438 CODE:
439 {
440 STRLEN in_len;
441 unsigned long out_len;
442 unsigned char *out_data, *in_data;
443 int rv;
444
445 if (!SvPOK(in)) XSRETURN_UNDEF;
446 in_data = (unsigned char *) SvPVbyte(in, in_len);
447 out_len = (unsigned long)(4 * ((in_len + 2) / 3) + 1);
448 Newz(0, out_data, out_len, unsigned char);
449 if (!out_data) croak("FATAL: Newz failed [%ld]", out_len);
450 rv = base64_encode(in_data, (unsigned long)in_len, out_data, &out_len);
451 RETVAL = (rv == CRYPT_OK) ? newSVpvn((char *)out_data, out_len) : newSVpvn(NULL, 0);
452 Safefree(out_data);
453 }
454 OUTPUT:
455 RETVAL
456
457 SV *
458 CryptX__decode_base64(SV * in)
459 CODE:
460 {
461 STRLEN in_len;
462 unsigned long out_len;
463 unsigned char *out_data, *in_data;
464 int rv;
465
466 if (!SvPOK(in)) XSRETURN_UNDEF;
467 in_data = (unsigned char *) SvPVbyte(in, in_len);
468 out_len = (unsigned long)in_len;
469 Newz(0, out_data, out_len, unsigned char);
470 if (!out_data) croak("FATAL: Newz failed [%ld]", out_len);
471 rv = base64_decode(in_data, (unsigned long)in_len, out_data, &out_len);
472 RETVAL = (rv == CRYPT_OK) ? newSVpvn((char *)out_data, out_len) : newSVpvn(NULL, 0);
473 Safefree(out_data);
474 }
475 OUTPUT:
476 RETVAL
477
478 SV *
479 CryptX__increment_octets_le(SV * in)
480 CODE:
481 {
482 STRLEN len, i = 0;
483 unsigned char *out_data, *in_data;
484 int rv;
485
486 if (!SvPOK(in)) XSRETURN_UNDEF;
487 in_data = (unsigned char *) SvPVbyte(in, len);
488 if (len == 0) XSRETURN_UNDEF;
489
490 RETVAL = NEWSV(0, len);
491 SvPOK_only(RETVAL);
492 SvCUR_set(RETVAL, len);
493 out_data = (unsigned char *)SvPV_nolen(RETVAL);
494 Copy(in_data, out_data, len, unsigned char);
495 while (i < len) {
496 out_data[i]++;
497 if (0 != out_data[i]) break;
498 i++;
499 }
500 if (i == len) croak("FATAL: increment_octets_le overflow");
501 }
502 OUTPUT:
503 RETVAL
504
505 SV *
506 CryptX__increment_octets_be(SV * in)
507 CODE:
508 {
509 STRLEN len, i = 0;
510 unsigned char *out_data, *in_data;
511 int rv;
512
513 if (!SvPOK(in)) XSRETURN_UNDEF;
514 in_data = (unsigned char *) SvPVbyte(in, len);
515 if (len == 0) XSRETURN_UNDEF;
516
517 RETVAL = NEWSV(0, len);
518 SvPOK_only(RETVAL);
519 SvCUR_set(RETVAL, len);
520 out_data = (unsigned char *)SvPV_nolen(RETVAL);
521 Copy(in_data, out_data, len, unsigned char);
522 while (i < len) {
523 out_data[len - 1 - i]++;
524 if (0 != out_data[len - 1 - i]) break;
525 i++;
526 }
527 if (i == len) croak("FATAL: increment_octets_le overflow");
528 }
529 OUTPUT:
530 RETVAL
531
532 ###############################################################################
533
534 INCLUDE: inc/CryptX_Digest.xs.inc
535 INCLUDE: inc/CryptX_Digest_SHAKE.xs.inc
536 INCLUDE: inc/CryptX_Cipher.xs.inc
537
538 INCLUDE: inc/CryptX_Checksum_Adler32.xs.inc
539 INCLUDE: inc/CryptX_Checksum_CRC32.xs.inc
540
541 INCLUDE: inc/CryptX_AuthEnc_EAX.xs.inc
542 INCLUDE: inc/CryptX_AuthEnc_GCM.xs.inc
543 INCLUDE: inc/CryptX_AuthEnc_OCB.xs.inc
544 INCLUDE: inc/CryptX_AuthEnc_CCM.xs.inc
545 INCLUDE: inc/CryptX_AuthEnc_ChaCha20Poly1305.xs.inc
546
547 INCLUDE: inc/CryptX_Stream_ChaCha.xs.inc
548 INCLUDE: inc/CryptX_Stream_RC4.xs.inc
549 INCLUDE: inc/CryptX_Stream_Sober128.xs.inc
550
551 INCLUDE: inc/CryptX_Mac_F9.xs.inc
552 INCLUDE: inc/CryptX_Mac_HMAC.xs.inc
553 INCLUDE: inc/CryptX_Mac_OMAC.xs.inc
554 INCLUDE: inc/CryptX_Mac_Pelican.xs.inc
555 INCLUDE: inc/CryptX_Mac_PMAC.xs.inc
556 INCLUDE: inc/CryptX_Mac_XCBC.xs.inc
557 INCLUDE: inc/CryptX_Mac_Poly1305.xs.inc
558 INCLUDE: inc/CryptX_Mac_BLAKE2s.xs.inc
559 INCLUDE: inc/CryptX_Mac_BLAKE2b.xs.inc
560
561 INCLUDE: inc/CryptX_Mode_CBC.xs.inc
562 INCLUDE: inc/CryptX_Mode_ECB.xs.inc
563 INCLUDE: inc/CryptX_Mode_CFB.xs.inc
564 INCLUDE: inc/CryptX_Mode_OFB.xs.inc
565 INCLUDE: inc/CryptX_Mode_CTR.xs.inc
566 #INCLUDE: inc/CryptX_Mode_F8.xs.inc
567 #INCLUDE: inc/CryptX_Mode_LRW.xs.inc
568 #INCLUDE: inc/CryptX_Mode_XTS.xs.inc
569
570 INCLUDE: inc/CryptX_PRNG.xs.inc
571
572 INCLUDE: inc/CryptX_PK_RSA.xs.inc
573 INCLUDE: inc/CryptX_PK_DSA.xs.inc
574 INCLUDE: inc/CryptX_PK_DH.xs.inc
575 INCLUDE: inc/CryptX_PK_ECC.xs.inc
576
577 INCLUDE: inc/CryptX_KeyDerivation.xs.inc
578
579 INCLUDE: inc/CryptX_BigInt_LTM.xs.inc
0 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
0 Changes
1 CryptX.xs
2 inc/CryptX_AuthEnc_CCM.xs.inc
3 inc/CryptX_AuthEnc_ChaCha20Poly1305.xs.inc
4 inc/CryptX_AuthEnc_EAX.xs.inc
5 inc/CryptX_AuthEnc_GCM.xs.inc
6 inc/CryptX_AuthEnc_OCB.xs.inc
7 inc/CryptX_BigInt_LTM.xs.inc
8 inc/CryptX_Checksum_Adler32.xs.inc
9 inc/CryptX_Checksum_CRC32.xs.inc
10 inc/CryptX_Cipher.xs.inc
11 inc/CryptX_Digest.xs.inc
12 inc/CryptX_Digest_SHAKE.xs.inc
13 inc/CryptX_KeyDerivation.xs.inc
14 inc/CryptX_Mac_BLAKE2b.xs.inc
15 inc/CryptX_Mac_BLAKE2s.xs.inc
16 inc/CryptX_Mac_F9.xs.inc
17 inc/CryptX_Mac_HMAC.xs.inc
18 inc/CryptX_Mac_OMAC.xs.inc
19 inc/CryptX_Mac_Pelican.xs.inc
20 inc/CryptX_Mac_PMAC.xs.inc
21 inc/CryptX_Mac_Poly1305.xs.inc
22 inc/CryptX_Mac_XCBC.xs.inc
23 inc/CryptX_Mode_CBC.xs.inc
24 inc/CryptX_Mode_CFB.xs.inc
25 inc/CryptX_Mode_CTR.xs.inc
26 inc/CryptX_Mode_ECB.xs.inc
27 inc/CryptX_Mode_OFB.xs.inc
28 inc/CryptX_PK_DH.xs.inc
29 inc/CryptX_PK_DSA.xs.inc
30 inc/CryptX_PK_ECC.xs.inc
31 inc/CryptX_PK_RSA.xs.inc
32 inc/CryptX_PRNG.xs.inc
33 inc/CryptX_Stream_ChaCha.xs.inc
34 inc/CryptX_Stream_RC4.xs.inc
35 inc/CryptX_Stream_Sober128.xs.inc
36 lib/Crypt/AuthEnc.pm
37 lib/Crypt/AuthEnc/CCM.pm
38 lib/Crypt/AuthEnc/ChaCha20Poly1305.pm
39 lib/Crypt/AuthEnc/EAX.pm
40 lib/Crypt/AuthEnc/GCM.pm
41 lib/Crypt/AuthEnc/OCB.pm
42 lib/Crypt/Checksum.pm
43 lib/Crypt/Checksum/Adler32.pm
44 lib/Crypt/Checksum/CRC32.pm
45 lib/Crypt/Cipher.pm
46 lib/Crypt/Cipher/AES.pm
47 lib/Crypt/Cipher/Anubis.pm
48 lib/Crypt/Cipher/Blowfish.pm
49 lib/Crypt/Cipher/Camellia.pm
50 lib/Crypt/Cipher/CAST5.pm
51 lib/Crypt/Cipher/DES.pm
52 lib/Crypt/Cipher/DES_EDE.pm
53 lib/Crypt/Cipher/KASUMI.pm
54 lib/Crypt/Cipher/Khazad.pm
55 lib/Crypt/Cipher/MULTI2.pm
56 lib/Crypt/Cipher/Noekeon.pm
57 lib/Crypt/Cipher/RC2.pm
58 lib/Crypt/Cipher/RC5.pm
59 lib/Crypt/Cipher/RC6.pm
60 lib/Crypt/Cipher/SAFER_K128.pm
61 lib/Crypt/Cipher/SAFER_K64.pm
62 lib/Crypt/Cipher/SAFER_SK128.pm
63 lib/Crypt/Cipher/SAFER_SK64.pm
64 lib/Crypt/Cipher/SAFERP.pm
65 lib/Crypt/Cipher/SEED.pm
66 lib/Crypt/Cipher/Skipjack.pm
67 lib/Crypt/Cipher/Twofish.pm
68 lib/Crypt/Cipher/XTEA.pm
69 lib/Crypt/Digest.pm
70 lib/Crypt/Digest/BLAKE2b_160.pm
71 lib/Crypt/Digest/BLAKE2b_256.pm
72 lib/Crypt/Digest/BLAKE2b_384.pm
73 lib/Crypt/Digest/BLAKE2b_512.pm
74 lib/Crypt/Digest/BLAKE2s_128.pm
75 lib/Crypt/Digest/BLAKE2s_160.pm
76 lib/Crypt/Digest/BLAKE2s_224.pm
77 lib/Crypt/Digest/BLAKE2s_256.pm
78 lib/Crypt/Digest/CHAES.pm
79 lib/Crypt/Digest/MD2.pm
80 lib/Crypt/Digest/MD4.pm
81 lib/Crypt/Digest/MD5.pm
82 lib/Crypt/Digest/RIPEMD128.pm
83 lib/Crypt/Digest/RIPEMD160.pm
84 lib/Crypt/Digest/RIPEMD256.pm
85 lib/Crypt/Digest/RIPEMD320.pm
86 lib/Crypt/Digest/SHA1.pm
87 lib/Crypt/Digest/SHA224.pm
88 lib/Crypt/Digest/SHA256.pm
89 lib/Crypt/Digest/SHA384.pm
90 lib/Crypt/Digest/SHA3_224.pm
91 lib/Crypt/Digest/SHA3_256.pm
92 lib/Crypt/Digest/SHA3_384.pm
93 lib/Crypt/Digest/SHA3_512.pm
94 lib/Crypt/Digest/SHA512.pm
95 lib/Crypt/Digest/SHA512_224.pm
96 lib/Crypt/Digest/SHA512_256.pm
97 lib/Crypt/Digest/SHAKE.pm
98 lib/Crypt/Digest/Tiger192.pm
99 lib/Crypt/Digest/Whirlpool.pm
100 lib/Crypt/KeyDerivation.pm
101 lib/Crypt/Mac.pm
102 lib/Crypt/Mac/BLAKE2b.pm
103 lib/Crypt/Mac/BLAKE2s.pm
104 lib/Crypt/Mac/F9.pm
105 lib/Crypt/Mac/HMAC.pm
106 lib/Crypt/Mac/OMAC.pm
107 lib/Crypt/Mac/Pelican.pm
108 lib/Crypt/Mac/PMAC.pm
109 lib/Crypt/Mac/Poly1305.pm
110 lib/Crypt/Mac/XCBC.pm
111 lib/Crypt/Misc.pm
112 lib/Crypt/Mode.pm
113 lib/Crypt/Mode/CBC.pm
114 lib/Crypt/Mode/CFB.pm
115 lib/Crypt/Mode/CTR.pm
116 lib/Crypt/Mode/ECB.pm
117 lib/Crypt/Mode/OFB.pm
118 lib/Crypt/PK.pm
119 lib/Crypt/PK/DH.pm
120 lib/Crypt/PK/DSA.pm
121 lib/Crypt/PK/ECC.pm
122 lib/Crypt/PK/RSA.pm
123 lib/Crypt/PRNG.pm
124 lib/Crypt/PRNG/ChaCha20.pm
125 lib/Crypt/PRNG/Fortuna.pm
126 lib/Crypt/PRNG/RC4.pm
127 lib/Crypt/PRNG/Sober128.pm
128 lib/Crypt/PRNG/Yarrow.pm
129 lib/Crypt/Stream/ChaCha.pm
130 lib/Crypt/Stream/RC4.pm
131 lib/Crypt/Stream/Sober128.pm
132 lib/CryptX.pm
133 lib/Math/BigInt/LTM.pm
134 LICENSE
135 Makefile.PL
136 MANIFEST This list of files
137 META.json
138 META.yml
139 ppport.h
140 README
141 src/ltc/ciphers/aes/aes.c
142 src/ltc/ciphers/aes/aes_tab.c
143 src/ltc/ciphers/anubis.c
144 src/ltc/ciphers/blowfish.c
145 src/ltc/ciphers/camellia.c
146 src/ltc/ciphers/cast5.c
147 src/ltc/ciphers/des.c
148 src/ltc/ciphers/kasumi.c
149 src/ltc/ciphers/khazad.c
150 src/ltc/ciphers/kseed.c
151 src/ltc/ciphers/multi2.c
152 src/ltc/ciphers/noekeon.c
153 src/ltc/ciphers/rc2.c
154 src/ltc/ciphers/rc5.c
155 src/ltc/ciphers/rc6.c
156 src/ltc/ciphers/safer/safer.c
157 src/ltc/ciphers/safer/safer_tab.c
158 src/ltc/ciphers/safer/saferp.c
159 src/ltc/ciphers/skipjack.c
160 src/ltc/ciphers/twofish/twofish.c
161 src/ltc/ciphers/twofish/twofish_tab.c
162 src/ltc/ciphers/xtea.c
163 src/ltc/encauth/ccm/ccm_add_aad.c
164 src/ltc/encauth/ccm/ccm_add_nonce.c
165 src/ltc/encauth/ccm/ccm_done.c
166 src/ltc/encauth/ccm/ccm_init.c
167 src/ltc/encauth/ccm/ccm_memory.c
168 src/ltc/encauth/ccm/ccm_process.c
169 src/ltc/encauth/ccm/ccm_reset.c
170 src/ltc/encauth/chachapoly/chacha20poly1305_add_aad.c
171 src/ltc/encauth/chachapoly/chacha20poly1305_decrypt.c
172 src/ltc/encauth/chachapoly/chacha20poly1305_done.c
173 src/ltc/encauth/chachapoly/chacha20poly1305_encrypt.c
174 src/ltc/encauth/chachapoly/chacha20poly1305_init.c
175 src/ltc/encauth/chachapoly/chacha20poly1305_memory.c
176 src/ltc/encauth/chachapoly/chacha20poly1305_setiv.c
177 src/ltc/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c
178 src/ltc/encauth/eax/eax_addheader.c
179 src/ltc/encauth/eax/eax_decrypt.c
180 src/ltc/encauth/eax/eax_decrypt_verify_memory.c
181 src/ltc/encauth/eax/eax_done.c
182 src/ltc/encauth/eax/eax_encrypt.c
183 src/ltc/encauth/eax/eax_encrypt_authenticate_memory.c
184 src/ltc/encauth/eax/eax_init.c
185 src/ltc/encauth/gcm/gcm_add_aad.c
186 src/ltc/encauth/gcm/gcm_add_iv.c
187 src/ltc/encauth/gcm/gcm_done.c
188 src/ltc/encauth/gcm/gcm_gf_mult.c
189 src/ltc/encauth/gcm/gcm_init.c
190 src/ltc/encauth/gcm/gcm_memory.c
191 src/ltc/encauth/gcm/gcm_mult_h.c
192 src/ltc/encauth/gcm/gcm_process.c
193 src/ltc/encauth/gcm/gcm_reset.c
194 src/ltc/encauth/ocb3/ocb3_add_aad.c
195 src/ltc/encauth/ocb3/ocb3_decrypt.c
196 src/ltc/encauth/ocb3/ocb3_decrypt_last.c
197 src/ltc/encauth/ocb3/ocb3_decrypt_verify_memory.c
198 src/ltc/encauth/ocb3/ocb3_done.c
199 src/ltc/encauth/ocb3/ocb3_encrypt.c
200 src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c
201 src/ltc/encauth/ocb3/ocb3_encrypt_last.c
202 src/ltc/encauth/ocb3/ocb3_init.c
203 src/ltc/encauth/ocb3/ocb3_int_aad_add_block.c
204 src/ltc/encauth/ocb3/ocb3_int_calc_offset_zero.c
205 src/ltc/encauth/ocb3/ocb3_int_ntz.c
206 src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c
207 src/ltc/hashes/blake2b.c
208 src/ltc/hashes/blake2s.c
209 src/ltc/hashes/chc/chc.c
210 src/ltc/hashes/helper/hash_file.c
211 src/ltc/hashes/helper/hash_filehandle.c
212 src/ltc/hashes/helper/hash_memory.c
213 src/ltc/hashes/helper/hash_memory_multi.c
214 src/ltc/hashes/md2.c
215 src/ltc/hashes/md4.c
216 src/ltc/hashes/md5.c
217 src/ltc/hashes/rmd128.c
218 src/ltc/hashes/rmd160.c
219 src/ltc/hashes/rmd256.c
220 src/ltc/hashes/rmd320.c
221 src/ltc/hashes/sha1.c
222 src/ltc/hashes/sha2/sha224.c
223 src/ltc/hashes/sha2/sha256.c
224 src/ltc/hashes/sha2/sha384.c
225 src/ltc/hashes/sha2/sha512.c
226 src/ltc/hashes/sha2/sha512_224.c
227 src/ltc/hashes/sha2/sha512_256.c
228 src/ltc/hashes/sha3.c
229 src/ltc/hashes/sha3_test.c
230 src/ltc/hashes/tiger.c
231 src/ltc/hashes/whirl/whirl.c
232 src/ltc/hashes/whirl/whirltab.c
233 src/ltc/headers/tomcrypt.h
234 src/ltc/headers/tomcrypt_argchk.h
235 src/ltc/headers/tomcrypt_cfg.h
236 src/ltc/headers/tomcrypt_cipher.h
237 src/ltc/headers/tomcrypt_custom.h
238 src/ltc/headers/tomcrypt_hash.h
239 src/ltc/headers/tomcrypt_mac.h
240 src/ltc/headers/tomcrypt_macros.h
241 src/ltc/headers/tomcrypt_math.h
242 src/ltc/headers/tomcrypt_misc.h
243 src/ltc/headers/tomcrypt_pk.h
244 src/ltc/headers/tomcrypt_pkcs.h
245 src/ltc/headers/tomcrypt_prng.h
246 src/ltc/mac/blake2/blake2bmac.c
247 src/ltc/mac/blake2/blake2bmac_file.c
248 src/ltc/mac/blake2/blake2bmac_memory.c
249 src/ltc/mac/blake2/blake2bmac_memory_multi.c
250 src/ltc/mac/blake2/blake2smac.c
251 src/ltc/mac/blake2/blake2smac_file.c
252 src/ltc/mac/blake2/blake2smac_memory.c
253 src/ltc/mac/blake2/blake2smac_memory_multi.c
254 src/ltc/mac/f9/f9_done.c
255 src/ltc/mac/f9/f9_file.c
256 src/ltc/mac/f9/f9_init.c
257 src/ltc/mac/f9/f9_memory.c
258 src/ltc/mac/f9/f9_memory_multi.c
259 src/ltc/mac/f9/f9_process.c
260 src/ltc/mac/hmac/hmac_done.c
261 src/ltc/mac/hmac/hmac_file.c
262 src/ltc/mac/hmac/hmac_init.c
263 src/ltc/mac/hmac/hmac_memory.c
264 src/ltc/mac/hmac/hmac_memory_multi.c
265 src/ltc/mac/hmac/hmac_process.c
266 src/ltc/mac/omac/omac_done.c
267 src/ltc/mac/omac/omac_file.c
268 src/ltc/mac/omac/omac_init.c
269 src/ltc/mac/omac/omac_memory.c
270 src/ltc/mac/omac/omac_memory_multi.c
271 src/ltc/mac/omac/omac_process.c
272 src/ltc/mac/pelican/pelican.c
273 src/ltc/mac/pelican/pelican_memory.c
274 src/ltc/mac/pmac/pmac_done.c
275 src/ltc/mac/pmac/pmac_file.c
276 src/ltc/mac/pmac/pmac_init.c
277 src/ltc/mac/pmac/pmac_memory.c
278 src/ltc/mac/pmac/pmac_memory_multi.c
279 src/ltc/mac/pmac/pmac_ntz.c
280 src/ltc/mac/pmac/pmac_process.c
281 src/ltc/mac/pmac/pmac_shift_xor.c
282 src/ltc/mac/poly1305/poly1305.c
283 src/ltc/mac/poly1305/poly1305_file.c
284 src/ltc/mac/poly1305/poly1305_memory.c
285 src/ltc/mac/poly1305/poly1305_memory_multi.c
286 src/ltc/mac/xcbc/xcbc_done.c
287 src/ltc/mac/xcbc/xcbc_file.c
288 src/ltc/mac/xcbc/xcbc_init.c
289 src/ltc/mac/xcbc/xcbc_memory.c
290 src/ltc/mac/xcbc/xcbc_memory_multi.c
291 src/ltc/mac/xcbc/xcbc_process.c
292 src/ltc/math/fp/ltc_ecc_fp_mulmod.c
293 src/ltc/math/ltm_desc.c
294 src/ltc/math/multi.c
295 src/ltc/math/rand_bn.c
296 src/ltc/math/rand_prime.c
297 src/ltc/math/tfm_desc.c
298 src/ltc/misc/adler32.c
299 src/ltc/misc/base64/base64_decode.c
300 src/ltc/misc/base64/base64_encode.c
301 src/ltc/misc/burn_stack.c
302 src/ltc/misc/crc32.c
303 src/ltc/misc/crypt/crypt.c
304 src/ltc/misc/crypt/crypt_argchk.c
305 src/ltc/misc/crypt/crypt_cipher_descriptor.c
306 src/ltc/misc/crypt/crypt_cipher_is_valid.c
307 src/ltc/misc/crypt/crypt_find_cipher.c
308 src/ltc/misc/crypt/crypt_find_cipher_any.c
309 src/ltc/misc/crypt/crypt_find_cipher_id.c
310 src/ltc/misc/crypt/crypt_find_hash.c
311 src/ltc/misc/crypt/crypt_find_hash_any.c
312 src/ltc/misc/crypt/crypt_find_hash_id.c
313 src/ltc/misc/crypt/crypt_find_hash_oid.c
314 src/ltc/misc/crypt/crypt_find_prng.c
315 src/ltc/misc/crypt/crypt_fsa.c
316 src/ltc/misc/crypt/crypt_hash_descriptor.c
317 src/ltc/misc/crypt/crypt_hash_is_valid.c
318 src/ltc/misc/crypt/crypt_inits.c
319 src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c
320 src/ltc/misc/crypt/crypt_prng_descriptor.c
321 src/ltc/misc/crypt/crypt_prng_is_valid.c
322 src/ltc/misc/crypt/crypt_register_cipher.c
323 src/ltc/misc/crypt/crypt_register_hash.c
324 src/ltc/misc/crypt/crypt_register_prng.c
325 src/ltc/misc/crypt/crypt_unregister_cipher.c
326 src/ltc/misc/crypt/crypt_unregister_hash.c
327 src/ltc/misc/crypt/crypt_unregister_prng.c
328 src/ltc/misc/error_to_string.c
329 src/ltc/misc/hkdf/hkdf.c
330 src/ltc/misc/mem_neq.c
331 src/ltc/misc/pk_get_oid.c
332 src/ltc/misc/pkcs5/pkcs_5_1.c
333 src/ltc/misc/pkcs5/pkcs_5_2.c
334 src/ltc/misc/zeromem.c
335 src/ltc/modes/cbc/cbc_decrypt.c
336 src/ltc/modes/cbc/cbc_done.c
337 src/ltc/modes/cbc/cbc_encrypt.c
338 src/ltc/modes/cbc/cbc_getiv.c
339 src/ltc/modes/cbc/cbc_setiv.c
340 src/ltc/modes/cbc/cbc_start.c
341 src/ltc/modes/cfb/cfb_decrypt.c
342 src/ltc/modes/cfb/cfb_done.c
343 src/ltc/modes/cfb/cfb_encrypt.c
344 src/ltc/modes/cfb/cfb_getiv.c
345 src/ltc/modes/cfb/cfb_setiv.c
346 src/ltc/modes/cfb/cfb_start.c
347 src/ltc/modes/ctr/ctr_decrypt.c
348 src/ltc/modes/ctr/ctr_done.c
349 src/ltc/modes/ctr/ctr_encrypt.c
350 src/ltc/modes/ctr/ctr_getiv.c
351 src/ltc/modes/ctr/ctr_setiv.c
352 src/ltc/modes/ctr/ctr_start.c
353 src/ltc/modes/ecb/ecb_decrypt.c
354 src/ltc/modes/ecb/ecb_done.c
355 src/ltc/modes/ecb/ecb_encrypt.c
356 src/ltc/modes/ecb/ecb_start.c
357 src/ltc/modes/ofb/ofb_decrypt.c
358 src/ltc/modes/ofb/ofb_done.c
359 src/ltc/modes/ofb/ofb_encrypt.c
360 src/ltc/modes/ofb/ofb_getiv.c
361 src/ltc/modes/ofb/ofb_setiv.c
362 src/ltc/modes/ofb/ofb_start.c
363 src/ltc/pk/asn1/der/bit/der_decode_bit_string.c
364 src/ltc/pk/asn1/der/bit/der_decode_raw_bit_string.c
365 src/ltc/pk/asn1/der/bit/der_encode_bit_string.c
366 src/ltc/pk/asn1/der/bit/der_encode_raw_bit_string.c
367 src/ltc/pk/asn1/der/bit/der_length_bit_string.c
368 src/ltc/pk/asn1/der/boolean/der_decode_boolean.c
369 src/ltc/pk/asn1/der/boolean/der_encode_boolean.c
370 src/ltc/pk/asn1/der/boolean/der_length_boolean.c
371 src/ltc/pk/asn1/der/choice/der_decode_choice.c
372 src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c
373 src/ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.c
374 src/ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.c
375 src/ltc/pk/asn1/der/ia5/der_decode_ia5_string.c
376 src/ltc/pk/asn1/der/ia5/der_encode_ia5_string.c
377 src/ltc/pk/asn1/der/ia5/der_length_ia5_string.c
378 src/ltc/pk/asn1/der/integer/der_decode_integer.c
379 src/ltc/pk/asn1/der/integer/der_encode_integer.c
380 src/ltc/pk/asn1/der/integer/der_length_integer.c
381 src/ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.c
382 src/ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.c
383 src/ltc/pk/asn1/der/object_identifier/der_length_object_identifier.c
384 src/ltc/pk/asn1/der/octet/der_decode_octet_string.c
385 src/ltc/pk/asn1/der/octet/der_encode_octet_string.c
386 src/ltc/pk/asn1/der/octet/der_length_octet_string.c
387 src/ltc/pk/asn1/der/printable_string/der_decode_printable_string.c
388 src/ltc/pk/asn1/der/printable_string/der_encode_printable_string.c
389 src/ltc/pk/asn1/der/printable_string/der_length_printable_string.c
390 src/ltc/pk/asn1/der/sequence/der_decode_sequence_ex.c
391 src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c
392 src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c
393 src/ltc/pk/asn1/der/sequence/der_decode_subject_public_key_info.c
394 src/ltc/pk/asn1/der/sequence/der_encode_sequence_ex.c
395 src/ltc/pk/asn1/der/sequence/der_encode_sequence_multi.c
396 src/ltc/pk/asn1/der/sequence/der_encode_subject_public_key_info.c
397 src/ltc/pk/asn1/der/sequence/der_length_sequence.c
398 src/ltc/pk/asn1/der/sequence/der_sequence_free.c
399 src/ltc/pk/asn1/der/set/der_encode_set.c
400 src/ltc/pk/asn1/der/set/der_encode_setof.c
401 src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c
402 src/ltc/pk/asn1/der/short_integer/der_encode_short_integer.c
403 src/ltc/pk/asn1/der/short_integer/der_length_short_integer.c
404 src/ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.c
405 src/ltc/pk/asn1/der/teletex_string/der_length_teletex_string.c
406 src/ltc/pk/asn1/der/utctime/der_decode_utctime.c
407 src/ltc/pk/asn1/der/utctime/der_encode_utctime.c
408 src/ltc/pk/asn1/der/utctime/der_length_utctime.c
409 src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c
410 src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c
411 src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c
412 src/ltc/pk/dh/dh.c
413 src/ltc/pk/dh/dh_static.c
414 src/ltc/pk/dh/dh_static.h
415 src/ltc/pk/dh/dh_sys.c
416 src/ltc/pk/dsa/dsa_decrypt_key.c
417 src/ltc/pk/dsa/dsa_encrypt_key.c
418 src/ltc/pk/dsa/dsa_export.c
419 src/ltc/pk/dsa/dsa_free.c
420 src/ltc/pk/dsa/dsa_import.c
421 src/ltc/pk/dsa/dsa_import_radix.c
422 src/ltc/pk/dsa/dsa_make_key.c
423 src/ltc/pk/dsa/dsa_shared_secret.c
424 src/ltc/pk/dsa/dsa_sign_hash.c
425 src/ltc/pk/dsa/dsa_verify_hash.c
426 src/ltc/pk/dsa/dsa_verify_key.c
427 src/ltc/pk/ecc/ecc.c
428 src/ltc/pk/ecc/ecc_ansi_x963_export.c
429 src/ltc/pk/ecc/ecc_ansi_x963_import.c
430 src/ltc/pk/ecc/ecc_decrypt_key.c
431 src/ltc/pk/ecc/ecc_dp_clear.c
432 src/ltc/pk/ecc/ecc_dp_fill_from_sets.c
433 src/ltc/pk/ecc/ecc_dp_from_oid.c
434 src/ltc/pk/ecc/ecc_dp_from_params.c
435 src/ltc/pk/ecc/ecc_dp_init.c
436 src/ltc/pk/ecc/ecc_dp_set.c
437 src/ltc/pk/ecc/ecc_encrypt_key.c
438 src/ltc/pk/ecc/ecc_export.c
439 src/ltc/pk/ecc/ecc_export_full.c
440 src/ltc/pk/ecc/ecc_export_raw.c
441 src/ltc/pk/ecc/ecc_free.c
442 src/ltc/pk/ecc/ecc_get_size.c
443 src/ltc/pk/ecc/ecc_import.c
444 src/ltc/pk/ecc/ecc_import_full.c
445 src/ltc/pk/ecc/ecc_import_pkcs8.c
446 src/ltc/pk/ecc/ecc_import_raw.c
447 src/ltc/pk/ecc/ecc_make_key.c
448 src/ltc/pk/ecc/ecc_shared_secret.c
449 src/ltc/pk/ecc/ecc_sign_hash.c
450 src/ltc/pk/ecc/ecc_sizes.c
451 src/ltc/pk/ecc/ecc_verify_hash.c
452 src/ltc/pk/ecc/ecc_verify_key.c
453 src/ltc/pk/ecc/ltc_ecc_export_point.c
454 src/ltc/pk/ecc/ltc_ecc_import_point.c
455 src/ltc/pk/ecc/ltc_ecc_is_point.c
456 src/ltc/pk/ecc/ltc_ecc_is_point_at_infinity.c
457 src/ltc/pk/ecc/ltc_ecc_is_valid_idx.c
458 src/ltc/pk/ecc/ltc_ecc_map.c
459 src/ltc/pk/ecc/ltc_ecc_mul2add.c
460 src/ltc/pk/ecc/ltc_ecc_mulmod.c
461 src/ltc/pk/ecc/ltc_ecc_mulmod_timing.c
462 src/ltc/pk/ecc/ltc_ecc_points.c
463 src/ltc/pk/ecc/ltc_ecc_projective_add_point.c
464 src/ltc/pk/ecc/ltc_ecc_projective_dbl_point.c
465 src/ltc/pk/pkcs1/pkcs_1_i2osp.c
466 src/ltc/pk/pkcs1/pkcs_1_mgf1.c
467 src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c
468 src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c
469 src/ltc/pk/pkcs1/pkcs_1_os2ip.c
470 src/ltc/pk/pkcs1/pkcs_1_pss_decode.c
471 src/ltc/pk/pkcs1/pkcs_1_pss_encode.c
472 src/ltc/pk/pkcs1/pkcs_1_v1_5_decode.c
473 src/ltc/pk/pkcs1/pkcs_1_v1_5_encode.c
474 src/ltc/pk/rsa/rsa_decrypt_key.c
475 src/ltc/pk/rsa/rsa_encrypt_key.c
476 src/ltc/pk/rsa/rsa_export.c
477 src/ltc/pk/rsa/rsa_exptmod.c
478 src/ltc/pk/rsa/rsa_free.c
479 src/ltc/pk/rsa/rsa_get_size.c
480 src/ltc/pk/rsa/rsa_import.c
481 src/ltc/pk/rsa/rsa_import_pkcs8.c
482 src/ltc/pk/rsa/rsa_import_radix.c
483 src/ltc/pk/rsa/rsa_import_x509.c
484 src/ltc/pk/rsa/rsa_make_key.c
485 src/ltc/pk/rsa/rsa_sign_hash.c
486 src/ltc/pk/rsa/rsa_sign_saltlen_get.c
487 src/ltc/pk/rsa/rsa_verify_hash.c
488 src/ltc/prngs/chacha20.c
489 src/ltc/prngs/fortuna.c
490 src/ltc/prngs/rc4.c
491 src/ltc/prngs/rng_get_bytes.c
492 src/ltc/prngs/rng_make_prng.c
493 src/ltc/prngs/sober128.c
494 src/ltc/prngs/sprng.c
495 src/ltc/prngs/yarrow.c
496 src/ltc/stream/chacha/chacha_crypt.c
497 src/ltc/stream/chacha/chacha_done.c
498 src/ltc/stream/chacha/chacha_ivctr32.c
499 src/ltc/stream/chacha/chacha_ivctr64.c
500 src/ltc/stream/chacha/chacha_keystream.c
501 src/ltc/stream/chacha/chacha_setup.c
502 src/ltc/stream/rc4/rc4.c
503 src/ltc/stream/sober128/sober128.c
504 src/ltc/stream/sober128/sober128tab.c
505 src/ltm/bn_error.c
506 src/ltm/bn_fast_mp_invmod.c
507 src/ltm/bn_fast_mp_montgomery_reduce.c
508 src/ltm/bn_fast_s_mp_mul_digs.c
509 src/ltm/bn_fast_s_mp_mul_high_digs.c
510 src/ltm/bn_fast_s_mp_sqr.c
511 src/ltm/bn_mp_2expt.c
512 src/ltm/bn_mp_abs.c
513 src/ltm/bn_mp_add.c
514 src/ltm/bn_mp_add_d.c
515 src/ltm/bn_mp_addmod.c
516 src/ltm/bn_mp_and.c
517 src/ltm/bn_mp_clamp.c
518 src/ltm/bn_mp_clear.c
519 src/ltm/bn_mp_clear_multi.c
520 src/ltm/bn_mp_cmp.c
521 src/ltm/bn_mp_cmp_d.c
522 src/ltm/bn_mp_cmp_mag.c
523 src/ltm/bn_mp_cnt_lsb.c
524 src/ltm/bn_mp_copy.c
525 src/ltm/bn_mp_count_bits.c
526 src/ltm/bn_mp_div.c
527 src/ltm/bn_mp_div_2.c
528 src/ltm/bn_mp_div_2d.c
529 src/ltm/bn_mp_div_3.c
530 src/ltm/bn_mp_div_d.c
531 src/ltm/bn_mp_dr_is_modulus.c
532 src/ltm/bn_mp_dr_reduce.c
533 src/ltm/bn_mp_dr_setup.c
534 src/ltm/bn_mp_exch.c
535 src/ltm/bn_mp_export.c
536 src/ltm/bn_mp_expt_d.c
537 src/ltm/bn_mp_expt_d_ex.c
538 src/ltm/bn_mp_exptmod.c
539 src/ltm/bn_mp_exptmod_fast.c
540 src/ltm/bn_mp_exteuclid.c
541 src/ltm/bn_mp_fread.c
542 src/ltm/bn_mp_fwrite.c
543 src/ltm/bn_mp_gcd.c
544 src/ltm/bn_mp_get_int.c
545 src/ltm/bn_mp_get_long.c
546 src/ltm/bn_mp_get_long_long.c
547 src/ltm/bn_mp_grow.c
548 src/ltm/bn_mp_import.c
549 src/ltm/bn_mp_init.c
550 src/ltm/bn_mp_init_copy.c
551 src/ltm/bn_mp_init_multi.c
552 src/ltm/bn_mp_init_set.c
553 src/ltm/bn_mp_init_set_int.c
554 src/ltm/bn_mp_init_size.c
555 src/ltm/bn_mp_invmod.c
556 src/ltm/bn_mp_invmod_slow.c
557 src/ltm/bn_mp_is_square.c
558 src/ltm/bn_mp_jacobi.c
559 src/ltm/bn_mp_karatsuba_mul.c
560 src/ltm/bn_mp_karatsuba_sqr.c
561 src/ltm/bn_mp_lcm.c
562 src/ltm/bn_mp_lshd.c
563 src/ltm/bn_mp_mod.c
564 src/ltm/bn_mp_mod_2d.c
565 src/ltm/bn_mp_mod_d.c
566 src/ltm/bn_mp_montgomery_calc_normalization.c
567 src/ltm/bn_mp_montgomery_reduce.c
568 src/ltm/bn_mp_montgomery_setup.c
569 src/ltm/bn_mp_mul.c
570 src/ltm/bn_mp_mul_2.c
571 src/ltm/bn_mp_mul_2d.c
572 src/ltm/bn_mp_mul_d.c
573 src/ltm/bn_mp_mulmod.c
574 src/ltm/bn_mp_n_root.c
575 src/ltm/bn_mp_n_root_ex.c
576 src/ltm/bn_mp_neg.c
577 src/ltm/bn_mp_or.c
578 src/ltm/bn_mp_prime_fermat.c
579 src/ltm/bn_mp_prime_is_divisible.c
580 src/ltm/bn_mp_prime_is_prime.c
581 src/ltm/bn_mp_prime_miller_rabin.c
582 src/ltm/bn_mp_prime_next_prime.c
583 src/ltm/bn_mp_prime_rabin_miller_trials.c
584 src/ltm/bn_mp_prime_random_ex.c
585 src/ltm/bn_mp_radix_size.c
586 src/ltm/bn_mp_radix_smap.c
587 src/ltm/bn_mp_rand.c
588 src/ltm/bn_mp_read_radix.c
589 src/ltm/bn_mp_read_signed_bin.c
590 src/ltm/bn_mp_read_unsigned_bin.c
591 src/ltm/bn_mp_reduce.c
592 src/ltm/bn_mp_reduce_2k.c
593 src/ltm/bn_mp_reduce_2k_l.c
594 src/ltm/bn_mp_reduce_2k_setup.c
595 src/ltm/bn_mp_reduce_2k_setup_l.c
596 src/ltm/bn_mp_reduce_is_2k.c
597 src/ltm/bn_mp_reduce_is_2k_l.c
598 src/ltm/bn_mp_reduce_setup.c
599 src/ltm/bn_mp_rshd.c
600 src/ltm/bn_mp_set.c
601 src/ltm/bn_mp_set_int.c
602 src/ltm/bn_mp_set_long.c
603 src/ltm/bn_mp_set_long_long.c
604 src/ltm/bn_mp_shrink.c
605 src/ltm/bn_mp_signed_bin_size.c
606 src/ltm/bn_mp_sqr.c
607 src/ltm/bn_mp_sqrmod.c
608 src/ltm/bn_mp_sqrt.c
609 src/ltm/bn_mp_sqrtmod_prime.c
610 src/ltm/bn_mp_sub.c
611 src/ltm/bn_mp_sub_d.c
612 src/ltm/bn_mp_submod.c
613 src/ltm/bn_mp_to_signed_bin.c
614 src/ltm/bn_mp_to_signed_bin_n.c
615 src/ltm/bn_mp_to_unsigned_bin.c
616 src/ltm/bn_mp_to_unsigned_bin_n.c
617 src/ltm/bn_mp_toom_mul.c
618 src/ltm/bn_mp_toom_sqr.c
619 src/ltm/bn_mp_toradix.c
620 src/ltm/bn_mp_toradix_n.c
621 src/ltm/bn_mp_unsigned_bin_size.c
622 src/ltm/bn_mp_xor.c
623 src/ltm/bn_mp_zero.c
624 src/ltm/bn_prime_tab.c
625 src/ltm/bn_reverse.c
626 src/ltm/bn_s_mp_add.c
627 src/ltm/bn_s_mp_exptmod.c
628 src/ltm/bn_s_mp_mul_digs.c
629 src/ltm/bn_s_mp_mul_high_digs.c
630 src/ltm/bn_s_mp_sqr.c
631 src/ltm/bn_s_mp_sub.c
632 src/ltm/bncore.c
633 src/ltm/tommath.h
634 src/ltm/tommath_class.h
635 src/ltm/tommath_private.h
636 src/ltm/tommath_superclass.h
637 src/Makefile
638 src/Makefile.nmake
639 t/001_compile.t
640 t/002_all_pm.t
641 t/003_all_pm_pod.t
642 t/auth_enc_ccm.t
643 t/auth_enc_ccm_test_vector_ltc.t
644 t/auth_enc_chacha20poly1305.t
645 t/auth_enc_eax.t
646 t/auth_enc_eax_test_vector_ltc.t
647 t/auth_enc_gcm.t
648 t/auth_enc_gcm_test_vector_ltc.t
649 t/auth_enc_ocb.t
650 t/auth_enc_ocb_test_vectors_ietf.t
651 t/checksum.t
652 t/cipher_aes.t
653 t/cipher_aes_test_vectors_bc.t
654 t/cipher_anubis.t
655 t/cipher_blowfish.t
656 t/cipher_camellia.t
657 t/cipher_cast5.t
658 t/cipher_des.t
659 t/cipher_des_ede.t
660 t/cipher_kasumi.t
661 t/cipher_khazad.t
662 t/cipher_multi2.t
663 t/cipher_multi2_rounds.t
664 t/cipher_noekeon.t
665 t/cipher_rc2.t
666 t/cipher_rc5.t
667 t/cipher_rc6.t
668 t/cipher_safer_k128.t
669 t/cipher_safer_k64.t
670 t/cipher_safer_sk128.t
671 t/cipher_safer_sk64.t
672 t/cipher_saferp.t
673 t/cipher_seed.t
674 t/cipher_seed_test_vectors_bc.t
675 t/cipher_skipjack.t
676 t/cipher_stream.t
677 t/cipher_test_vectors_ltc.t
678 t/cipher_test_vectors_openssl.t
679 t/cipher_twofish.t
680 t/cipher_twofish_test_vectors_bc.t
681 t/cipher_xtea.t
682 t/cipher_xtea_test_vectors_bc.t
683 t/crypt-misc.t
684 t/data/binary-test.file
685 t/data/cryptx_priv_dh1.bin
686 t/data/cryptx_priv_dh2.bin
687 t/data/cryptx_priv_dh_pg1.bin
688 t/data/cryptx_priv_dh_pg2.bin
689 t/data/cryptx_priv_dsa1.der
690 t/data/cryptx_priv_dsa1.pem
691 t/data/cryptx_priv_dsa2.der
692 t/data/cryptx_priv_dsa2.pem
693 t/data/cryptx_priv_ecc1.der
694 t/data/cryptx_priv_ecc1.pem
695 t/data/cryptx_priv_ecc1_OLD.der
696 t/data/cryptx_priv_ecc1_OLD.pem
697 t/data/cryptx_priv_ecc2.der
698 t/data/cryptx_priv_ecc2.pem
699 t/data/cryptx_priv_ecc2_OLD.der
700 t/data/cryptx_priv_ecc2_OLD.pem
701 t/data/cryptx_priv_rsa1.der
702 t/data/cryptx_priv_rsa1.pem
703 t/data/cryptx_priv_rsa2.der
704 t/data/cryptx_priv_rsa2.pem
705 t/data/cryptx_pub_dh1.bin
706 t/data/cryptx_pub_dh2.bin
707 t/data/cryptx_pub_dh_pg1.bin
708 t/data/cryptx_pub_dh_pg2.bin
709 t/data/cryptx_pub_dsa1.der
710 t/data/cryptx_pub_dsa1.pem
711 t/data/cryptx_pub_dsa2.der
712 t/data/cryptx_pub_dsa2.pem
713 t/data/cryptx_pub_ecc1.der
714 t/data/cryptx_pub_ecc1.pem
715 t/data/cryptx_pub_ecc1_OLD.der
716 t/data/cryptx_pub_ecc1_OLD.pem
717 t/data/cryptx_pub_ecc2.der
718 t/data/cryptx_pub_ecc2.pem
719 t/data/cryptx_pub_ecc2_OLD.der
720 t/data/cryptx_pub_ecc2_OLD.pem
721 t/data/cryptx_pub_rsa1.der
722 t/data/cryptx_pub_rsa1.pem
723 t/data/cryptx_pub_rsa2.der
724 t/data/cryptx_pub_rsa2.pem
725 t/data/dsa-aes128.pem
726 t/data/dsa-aes192.pem
727 t/data/dsa-aes256.pem
728 t/data/dsa-camellia128.pem
729 t/data/dsa-camellia192.pem
730 t/data/dsa-camellia256.pem
731 t/data/dsa-des.pem
732 t/data/dsa-des3.pem
733 t/data/dsa-param.pem
734 t/data/dsa-seed.pem
735 t/data/ec-aes128.pem
736 t/data/ec-aes192.pem
737 t/data/ec-aes256.pem
738 t/data/ec-camellia128.pem
739 t/data/ec-camellia192.pem
740 t/data/ec-camellia256.pem
741 t/data/ec-des.pem
742 t/data/ec-des3.pem
743 t/data/ec-seed.pem
744 t/data/jwk_ec-priv1.json
745 t/data/jwk_ec-pub.json
746 t/data/jwk_ec-pub1.json
747 t/data/jwk_rsa-priv.json
748 t/data/jwk_rsa-priv1.json
749 t/data/jwk_rsa-pub1.json
750 t/data/openssl_dsa1.der
751 t/data/openssl_dsa1.pem
752 t/data/openssl_dsa2.der
753 t/data/openssl_dsa2.pem
754 t/data/openssl_ec-short.der
755 t/data/openssl_ec-short.pem
756 t/data/openssl_ec-short.pub.der
757 t/data/openssl_ec-short.pub.pem
758 t/data/openssl_ec1.key.pem
759 t/data/openssl_ec1.pri.der
760 t/data/openssl_ec1.pri.pem
761 t/data/openssl_ec1.pric.der
762 t/data/openssl_ec1.pric.pem
763 t/data/openssl_ec1.pub.der
764 t/data/openssl_ec1.pub.pem
765 t/data/openssl_ec1.pubc.der
766 t/data/openssl_ec1.pubc.pem
767 t/data/openssl_rsa1.der
768 t/data/openssl_rsa1.pem
769 t/data/openssl_rsa1.pubonly.der
770 t/data/openssl_rsa1.pubonly.pem
771 t/data/openssl_rsa2.der
772 t/data/openssl_rsa2.pem
773 t/data/openssl_rsa2.pubonly.der
774 t/data/openssl_rsa2.pubonly.pem
775 t/data/pkcs8.ec-priv-nopass.der
776 t/data/pkcs8.ec-priv-nopass.pem
777 t/data/pkcs8.ec-priv-pass.der
778 t/data/pkcs8.ec-priv-pass.pem
779 t/data/pkcs8.ec-short-priv-nopass.der
780 t/data/pkcs8.ec-short-priv-nopass.pem
781 t/data/pkcs8.ec-short-priv-pass.der
782 t/data/pkcs8.ec-short-priv-pass.pem
783 t/data/pkcs8.rsa-priv-nopass.der
784 t/data/pkcs8.rsa-priv-nopass.pem
785 t/data/pkcs8.rsa-priv-pass.der
786 t/data/pkcs8.rsa-priv-pass.pem
787 t/data/rsa-aes128.pem
788 t/data/rsa-aes192.pem
789 t/data/rsa-aes256.pem
790 t/data/rsa-camellia128.pem
791 t/data/rsa-camellia192.pem
792 t/data/rsa-camellia256.pem
793 t/data/rsa-des.pem
794 t/data/rsa-des3.pem
795 t/data/rsa-seed.pem
796 t/data/ssh/ssh_dsa_1024
797 t/data/ssh/ssh_dsa_1024.pub
798 t/data/ssh/ssh_dsa_1024.pub.pkcs8
799 t/data/ssh/ssh_dsa_1024.pub.rfc4716
800 t/data/ssh/ssh_ecdsa_256
801 t/data/ssh/ssh_ecdsa_256.pub
802 t/data/ssh/ssh_ecdsa_256.pub.pkcs8
803 t/data/ssh/ssh_ecdsa_256.pub.rfc4716
804 t/data/ssh/ssh_ecdsa_384
805 t/data/ssh/ssh_ecdsa_384.pub
806 t/data/ssh/ssh_ecdsa_384.pub.pkcs8
807 t/data/ssh/ssh_ecdsa_384.pub.rfc4716
808 t/data/ssh/ssh_ecdsa_521
809 t/data/ssh/ssh_ecdsa_521.pub
810 t/data/ssh/ssh_ecdsa_521.pub.pkcs8
811 t/data/ssh/ssh_ecdsa_521.pub.rfc4716
812 t/data/ssh/ssh_rsa_1024
813 t/data/ssh/ssh_rsa_1024.pub
814 t/data/ssh/ssh_rsa_1024.pub.pem
815 t/data/ssh/ssh_rsa_1024.pub.pkcs8
816 t/data/ssh/ssh_rsa_1024.pub.rfc4716
817 t/data/ssh/ssh_rsa_1024_passwd
818 t/data/ssh/ssh_rsa_1536
819 t/data/ssh/ssh_rsa_1536.pub
820 t/data/ssh/ssh_rsa_1536.pub.pem
821 t/data/ssh/ssh_rsa_1536.pub.pkcs8
822 t/data/ssh/ssh_rsa_1536.pub.rfc4716
823 t/data/ssh/ssh_rsa_1536_passwd
824 t/data/ssh/ssh_rsa_2048
825 t/data/ssh/ssh_rsa_2048.pub
826 t/data/ssh/ssh_rsa_2048.pub.pem
827 t/data/ssh/ssh_rsa_2048.pub.pkcs8
828 t/data/ssh/ssh_rsa_2048.pub.rfc4716
829 t/data/ssh/ssh_rsa_2048_passwd
830 t/data/ssh/ssh_rsa_4096
831 t/data/ssh/ssh_rsa_4096.pub
832 t/data/ssh/ssh_rsa_4096.pub.pem
833 t/data/ssh/ssh_rsa_4096.pub.pkcs8
834 t/data/ssh/ssh_rsa_4096.pub.rfc4716
835 t/data/ssh/ssh_rsa_4096_passwd
836 t/data/ssh/ssh_rsa_768
837 t/data/ssh/ssh_rsa_768.pub
838 t/data/ssh/ssh_rsa_768.pub.pem
839 t/data/ssh/ssh_rsa_768.pub.pkcs8
840 t/data/ssh/ssh_rsa_768.pub.rfc4716
841 t/data/ssh/ssh_rsa_768_passwd
842 t/data/ssh/ssh_rsa_8192
843 t/data/ssh/ssh_rsa_8192.pub
844 t/data/ssh/ssh_rsa_8192.pub.pem
845 t/data/ssh/ssh_rsa_8192.pub.pkcs8
846 t/data/ssh/ssh_rsa_8192.pub.rfc4716
847 t/data/ssh/ssh_rsa_8192_passwd
848 t/data/text-CR.file
849 t/data/text-CRLF.file
850 t/data/text-LF.file
851 t/digest_blake2b_160.t
852 t/digest_blake2b_256.t
853 t/digest_blake2b_384.t
854 t/digest_blake2b_512.t
855 t/digest_blake2s_128.t
856 t/digest_blake2s_160.t
857 t/digest_blake2s_224.t
858 t/digest_blake2s_256.t
859 t/digest_chaes.t
860 t/digest_md2.t
861 t/digest_md4.t
862 t/digest_md5.t
863 t/digest_ripemd128.t
864 t/digest_ripemd160.t
865 t/digest_ripemd256.t
866 t/digest_ripemd320.t
867 t/digest_sha1.t
868 t/digest_sha224.t
869 t/digest_sha256.t
870 t/digest_sha384.t
871 t/digest_sha3_224.t
872 t/digest_sha3_256.t
873 t/digest_sha3_384.t
874 t/digest_sha3_512.t
875 t/digest_sha512.t
876 t/digest_sha512_224.t
877 t/digest_sha512_256.t
878 t/digest_shake.t
879 t/digest_test_vectors_ltc.t
880 t/digest_tiger192.t
881 t/digest_whirlpool.t
882 t/jwk.t
883 t/key_derivation.t
884 t/mac_blake2b.t
885 t/mac_blake2s.t
886 t/mac_f9.t
887 t/mac_hmac.t
888 t/mac_hmac_test_vectors_ltc.t
889 t/mac_omac.t
890 t/mac_omac_test_vectors_ltc.t
891 t/mac_pelican.t
892 t/mac_pmac.t
893 t/mac_pmac_test_vectors_ltc.t
894 t/mac_poly1305.t
895 t/mac_xcbc.t
896 t/mbi_ltm/bigfltpm.inc
897 t/mbi_ltm/bigintpm.inc
898 t/mbi_ltm_01load.t
899 t/mbi_ltm_bigfltpm.t
900 t/mbi_ltm_bigintg.t
901 t/mbi_ltm_bigintpm.t
902 t/mbi_ltm_biglog.t
903 t/mbi_ltm_bigroot.t
904 t/mbi_ltm_bugs.t
905 t/mbi_ltm_mbi-from-big-scalar.t
906 t/mbi_ltm_storable.t
907 t/mode_cbc.t
908 t/mode_cfb.t
909 t/mode_ctr.t
910 t/mode_ecb.t
911 t/mode_ofb.t
912 t/pk_dh.t
913 t/pk_dsa.t
914 t/pk_dsa_test_vectors_openssl.t
915 t/pk_ecc.t
916 t/pk_ecc_test_vectors_openssl.t
917 t/pk_enc_pem.t
918 t/pk_rsa.t
919 t/pk_rsa_test_vectors_openssl.t
920 t/pkcs8.t
921 t/prng.t
922 t/prng_chacha20.t
923 t/prng_fortuna.t
924 t/prng_rc4.t
925 t/prng_sober128.t
926 t/prng_yarrow.t
927 t/sshkey.t
928 typemap
0 {
1 "abstract" : "Crypto toolkit",
2 "author" : [
3 "Karel Miko"
4 ],
5 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010",
7 "license" : [
8 "perl_5"
9 ],
10 "meta-spec" : {
11 "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
12 "version" : "2"
13 },
14 "name" : "CryptX",
15 "no_index" : {
16 "directory" : [
17 "t",
18 "inc"
19 ]
20 },
21 "prereqs" : {
22 "build" : {
23 "requires" : {
24 "ExtUtils::MakeMaker" : "0"
25 }
26 },
27 "configure" : {
28 "requires" : {
29 "ExtUtils::MakeMaker" : "0"
30 }
31 },
32 "runtime" : {
33 "requires" : {
34 "perl" : "5.006"
35 }
36 }
37 },
38 "release_status" : "stable",
39 "resources" : {
40 "bugtracker" : {
41 "web" : "https://github.com/DCIT/perl-CryptX/issues"
42 },
43 "repository" : {
44 "url" : "https://github.com/DCIT/perl-CryptX"
45 }
46 },
47 "version" : "0.048",
48 "x_serialization_backend" : "JSON::PP version 2.27400"
49 }
0 ---
1 abstract: 'Crypto toolkit'
2 author:
3 - 'Karel Miko'
4 build_requires:
5 ExtUtils::MakeMaker: '0'
6 configure_requires:
7 ExtUtils::MakeMaker: '0'
8 dynamic_config: 1
9 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010'
10 license: perl
11 meta-spec:
12 url: http://module-build.sourceforge.net/META-spec-v1.4.html
13 version: '1.4'
14 name: CryptX
15 no_index:
16 directory:
17 - t
18 - inc
19 requires:
20 perl: '5.006'
21 resources:
22 bugtracker: https://github.com/DCIT/perl-CryptX/issues
23 repository: https://github.com/DCIT/perl-CryptX
24 version: '0.048'
25 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
0 use strict;
1 use warnings;
2 use ExtUtils::MakeMaker;
3 use Config;
4
5 my @myobjs = map { s|.c$|$Config{obj_ext}|; $_ } grep { $_ !~ m|^src/ltc/\.*tab\.c$| } (
6 glob('src/ltm/*.c'),
7 glob('src/ltc/*/*.c'),
8 glob('src/ltc/*/*/*.c'),
9 glob('src/ltc/*/*/*/*.c'),
10 glob('src/ltc/*/*/*/*/*.c'),
11 );
12 my $myextlib = "src/liballinone$Config{lib_ext}";
13 my $mycflags = "$Config{cccdlflags} $Config{ccflags} $Config{optimize} -Iltm -Iltc/headers -DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC";
14
15 #FIX: gcc with -flto is a trouble maker see https://github.com/DCIT/perl-CryptX/issues/32
16 $mycflags =~ s/-flto\b//g;
17
18 #FIX: avoid "ar: fatal: Numeric group ID too large" see https://github.com/DCIT/perl-CryptX/issues/33
19 my $myarflags = '$(AR_STATIC_ARGS)';
20 if ($^O ne 'MSWin32' && $Config{ar}) {
21 # for ar's "deterministic mode" we need GNU binutils 2.20+ (2009-10-16)
22 my $arver = `$Config{ar} --version`;
23 my ($maj, $min) = $arver =~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s;
24 $myarflags = 'rcD' if ($maj && $min && $maj >= 2 && $min >= 20) || $arver=~ /^BSD ar /;
25 }
26
27 my %eumm_args = (
28 NAME => 'CryptX',
29 VERSION_FROM => 'lib/CryptX.pm',
30 AUTHOR => 'Karel Miko',
31 ABSTRACT => 'Crypto toolkit',
32 MIN_PERL_VERSION => '5.006',
33 LICENSE => 'perl_5',
34 META_MERGE => { resources => { repository => 'https://github.com/DCIT/perl-CryptX', bugtracker => 'https://github.com/DCIT/perl-CryptX/issues' } },
35 DEFINE => '-DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC',
36 INC => '-Isrc/ltc/headers -Isrc/ltm',
37 LIBS => [''],
38 MYEXTLIB => $myextlib,
39 clean => { 'FILES' => join(' ', @myobjs, $myextlib) },
40 );
41
42 my $eumm_ver = eval $ExtUtils::MakeMaker::VERSION;
43 delete $eumm_args{MIN_PERL_VERSION} if $eumm_ver < 6.48;
44 delete $eumm_args{META_ADD} if $eumm_ver < 6.46;
45 delete $eumm_args{META_MERGE} if $eumm_ver < 6.46;
46 delete $eumm_args{LICENSE} if $eumm_ver < 6.31;
47
48 WriteMakefile(%eumm_args);
49
50 # ARFLAGS=\$(AR_STATIC_ARGS) RANLIB=\$(RANLIB) AR=\$(AR)
51
52 sub MY::postamble {
53 my $myextlib = qq{
54 \$(MYEXTLIB): src/Makefile
55 cd src && \$(MAKE) ARFLAGS="$myarflags" RANLIB="\$(RANLIB)" AR="\$(AR)" CC="\$(CC)" LIB_EXT=\$(LIB_EXT) OBJ_EXT=\$(OBJ_EXT) CFLAGS="$mycflags"
56 };
57
58 $myextlib = qq{
59 \$(MYEXTLIB): src/Makefile
60 cd src && \$(MAKE) -f Makefile.nmake CFLAGS="$mycflags"
61 } if $^O eq 'MSWin32' && $Config{make} =~ /nmake/ && $Config{cc} =~ /cl/;
62
63 $myextlib = qq{
64 \$(MYEXTLIB): src/Makefile
65 cd src && \$(MAKE) CC="$Config{cc}" CFLAGS="$mycflags"
66 } if $^O eq 'MSWin32' && $Config{cc} =~ /gcc/;
67
68 my $version_patch = q{
69 versionsync:
70 $(NOECHO) perl _generators/version_patch.pl sync
71
72 versioninc:
73 $(NOECHO) perl _generators/version_patch.pl inc
74
75 versionincdev:
76 $(NOECHO) perl _generators/version_patch.pl incdev
77
78 versiondec:
79 $(NOECHO) perl _generators/version_patch.pl dec
80
81 versiondecdev:
82 $(NOECHO) perl _generators/version_patch.pl decdev
83 };
84
85 return "$myextlib\n$version_patch";
86 }
0 NAME
1 CryptX - Crypto toolkit (self-contained no external libraries needed)
2
3 DESCRIPTION
4 Cryptography in CryptX is based on
5 <https://github.com/libtom/libtomcrypt>
6
7 Currently available modules:
8
9 * Ciphers - see Crypt::Cipher and related modules
10
11 Crypt::Cipher::AES, Crypt::Cipher::Anubis, Crypt::Cipher::Blowfish,
12 Crypt::Cipher::Camellia, Crypt::Cipher::CAST5, Crypt::Cipher::DES,
13 Crypt::Cipher::DES_EDE, Crypt::Cipher::KASUMI,
14 Crypt::Cipher::Khazad, Crypt::Cipher::MULTI2,
15 Crypt::Cipher::Noekeon, Crypt::Cipher::RC2, Crypt::Cipher::RC5,
16 Crypt::Cipher::RC6, Crypt::Cipher::SAFERP,
17 Crypt::Cipher::SAFER_K128, Crypt::Cipher::SAFER_K64,
18 Crypt::Cipher::SAFER_SK128, Crypt::Cipher::SAFER_SK64,
19 Crypt::Cipher::SEED, Crypt::Cipher::Skipjack,
20 Crypt::Cipher::Twofish, Crypt::Cipher::XTEA
21
22 * Block cipher modes
23
24 Crypt::Mode::CBC, Crypt::Mode::CFB, Crypt::Mode::CTR,
25 Crypt::Mode::ECB, Crypt::Mode::OFB
26
27 * Authenticated encryption modes
28
29 Crypt::AuthEnc::CCM, Crypt::AuthEnc::EAX, Crypt::AuthEnc::GCM,
30 Crypt::AuthEnc::OCB
31
32 * Hash Functions - see Crypt::Digest and related modules
33
34 Crypt::Digest::CHAES, Crypt::Digest::MD2, Crypt::Digest::MD4,
35 Crypt::Digest::MD5, Crypt::Digest::RIPEMD128,
36 Crypt::Digest::RIPEMD160, Crypt::Digest::RIPEMD256,
37 Crypt::Digest::RIPEMD320, Crypt::Digest::SHA1,
38 Crypt::Digest::SHA224, Crypt::Digest::SHA256, Crypt::Digest::SHA384,
39 Crypt::Digest::SHA512, Crypt::Digest::SHA512_224,
40 Crypt::Digest::SHA512_256, Crypt::Digest::Tiger192,
41 Crypt::Digest::Whirlpool
42
43 * Message Authentication Codes
44
45 Crypt::Mac::F9, Crypt::Mac::HMAC, Crypt::Mac::OMAC,
46 Crypt::Mac::Pelican, Crypt::Mac::PMAC, Crypt::Mac::XCBC
47
48 * Public key cryptography
49
50 Crypt::PK::RSA, Crypt::PK::DSA, Crypt::PK::ECC, Crypt::PK::DH
51
52 * Cryptographically secure random number generators
53
54 Crypt::PRNG, Crypt::PRNG::Fortuna, Crypt::PRNG::Yarrow,
55 Crypt::PRNG::RC4, Crypt::PRNG::Sober128
56
57 * Key derivation functions - PBKDF1, PBKFD2 and HKDF
58
59 Crypt::KeyDerivation
60
61 LICENSE
62 This program is free software; you can redistribute it and/or modify it
63 under the same terms as Perl itself.
64
65 COPYRIGHT
66 Copyright (c) 2013-2015 DCIT, a.s. <http://www.dcit.cz> / Karel Miko
67
0 MODULE = CryptX PACKAGE = Crypt::AuthEnc::CCM
1
2 void
3 _memory_encrypt(char *cipher_name, SV *key, SV *nonce, SV *header, unsigned long tag_len, SV *plaintext)
4 PPCODE:
5 {
6 STRLEN k_len, n_len, h_len, pt_len;
7 unsigned char *k, *n, *h, *pt;
8 int rv, id;
9 unsigned char tag[MAXBLOCKSIZE];
10 SV *ct;
11
12 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
13 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
14 if (!SvPOK(header)) croak("FATAL: header must be string/buffer scalar");
15 if (!SvPOK(plaintext)) croak("FATAL: plaintext must be string/buffer scalar");
16 k = (unsigned char *) SvPVbyte(key, k_len);
17 n = (unsigned char *) SvPVbyte(nonce, n_len);
18 h = (unsigned char *) SvPVbyte(header, h_len);
19 pt = (unsigned char *) SvPVbyte(plaintext, pt_len);
20
21 id = find_cipher(cipher_name);
22 if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
23
24 ct = NEWSV(0, pt_len);
25 SvPOK_only(ct);
26 SvCUR_set(ct, pt_len);
27
28 if(tag_len<4 || tag_len>16) tag_len = 16;
29
30 rv = ccm_memory(id, k, (unsigned long)k_len, NULL, n, (unsigned long)n_len, h, (unsigned long)h_len,
31 pt, (unsigned long)pt_len, (unsigned char *)SvPV_nolen(ct), tag, &tag_len, CCM_ENCRYPT);
32 if (rv != CRYPT_OK) croak("FATAL: ccm_memory failed: %s", error_to_string(rv));
33
34 XPUSHs(sv_2mortal(ct));
35 XPUSHs(sv_2mortal(newSVpvn((char*)tag,tag_len)));
36
37 /* int ccm_memory( int cipher,
38 const unsigned char *key, unsigned long keylen,
39 symmetric_key *uskey,
40 const unsigned char *nonce, unsigned long noncelen,
41 const unsigned char *header, unsigned long headerlen,
42 unsigned char *pt, unsigned long ptlen,
43 unsigned char *ct,
44 unsigned char *tag, unsigned long *taglen,
45 int direction); */
46
47 }
48
49 void
50 _memory_decrypt(char *cipher_name, SV *key, SV *nonce, SV *header, SV *ciphertext, SV *tag)
51 PPCODE:
52 {
53 STRLEN k_len, n_len, h_len, ct_len, t_len;
54 unsigned char *k, *n, *h, *ct, *t;
55 int rv, id;
56 unsigned char xtag[MAXBLOCKSIZE];
57 unsigned long xtag_len;
58 SV *pt;
59
60 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
61 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
62 if (!SvPOK(header)) croak("FATAL: header must be string/buffer scalar");
63 if (!SvPOK(ciphertext)) croak("FATAL: ciphertext must be string/buffer scalar");
64 if (!SvPOK(tag)) croak("FATAL: tag must be string/buffer scalar");
65 k = (unsigned char *) SvPVbyte(key, k_len);
66 n = (unsigned char *) SvPVbyte(nonce, n_len);
67 h = (unsigned char *) SvPVbyte(header, h_len);
68 ct = (unsigned char *) SvPVbyte(ciphertext, ct_len);
69 t = (unsigned char *) SvPVbyte(tag, t_len);
70
71 id = find_cipher(cipher_name);
72 if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
73
74 pt = NEWSV(0, ct_len);
75 SvPOK_only(pt);
76 SvCUR_set(pt, ct_len);
77
78 xtag_len = (unsigned long)t_len;
79 Copy(t, xtag, t_len, unsigned char);
80
81 rv = ccm_memory(id, k, (unsigned long)k_len, NULL, n, (unsigned long)n_len, h, (unsigned long)h_len,
82 (unsigned char *)SvPV_nolen(pt), (unsigned long)ct_len, ct, xtag, &xtag_len, CCM_DECRYPT);
83 if (rv != CRYPT_OK) {
84 XPUSHs(sv_2mortal(newSVpvn(NULL,0))); /* undef */
85 }
86 else {
87 XPUSHs(sv_2mortal(pt));
88 }
89 }
0 MODULE = CryptX PACKAGE = Crypt::AuthEnc::ChaCha20Poly1305
1
2 Crypt::AuthEnc::ChaCha20Poly1305
3 _new(SV * key, SV * nonce = NULL)
4 CODE:
5 {
6 int rv;
7 STRLEN iv_len=0, k_len=0;
8 unsigned char *iv=NULL, *k=NULL;
9
10 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
11 k = (unsigned char *) SvPVbyte(key, k_len);
12 if (nonce) {
13 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
14 iv = (unsigned char *) SvPVbyte(nonce, iv_len);
15 }
16
17 Newz(0, RETVAL, 1, struct chacha20poly1305_struct);
18 if (!RETVAL) croak("FATAL: Newz failed");
19
20 rv = chacha20poly1305_init(&RETVAL->state, k, (unsigned long)k_len);
21 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_init failed: %s", error_to_string(rv));
22
23 if (iv && iv_len > 0) {
24 rv = chacha20poly1305_setiv(&RETVAL->state, iv, (unsigned long)iv_len);
25 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv failed: %s", error_to_string(rv));
26 }
27 }
28 OUTPUT:
29 RETVAL
30
31 void
32 DESTROY(Crypt::AuthEnc::ChaCha20Poly1305 self)
33 CODE:
34 Safefree(self);
35
36 Crypt::AuthEnc::ChaCha20Poly1305
37 clone(Crypt::AuthEnc::ChaCha20Poly1305 self)
38 CODE:
39 Newz(0, RETVAL, 1, struct chacha20poly1305_struct);
40 if (!RETVAL) croak("FATAL: Newz failed");
41 Copy(&self->state, &RETVAL->state, 1, struct chacha20poly1305_struct);
42 OUTPUT:
43 RETVAL
44
45 int
46 set_iv(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * nonce)
47 CODE:
48 {
49 int rv;
50 STRLEN iv_len=0;
51 unsigned char *iv=NULL;
52
53 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
54 iv = (unsigned char *) SvPVbyte(nonce, iv_len);
55 rv = chacha20poly1305_setiv(&self->state, iv, (unsigned long)iv_len);
56 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv failed: %s", error_to_string(rv));
57 RETVAL = rv;
58 }
59 OUTPUT:
60 RETVAL
61
62 int
63 set_iv_rfc7905(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * nonce, UV seqnum)
64 CODE:
65 {
66 int rv;
67 STRLEN iv_len=0;
68 unsigned char *iv=NULL;
69
70 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
71 iv = (unsigned char *) SvPVbyte(nonce, iv_len);
72 rv = chacha20poly1305_setiv_rfc7905(&self->state, iv, (unsigned long)iv_len, (ulong64)seqnum);
73 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv_rfc7905 failed: %s", error_to_string(rv));
74 RETVAL = rv;
75 }
76 OUTPUT:
77 RETVAL
78
79 int
80 adata_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
81 CODE:
82 {
83 int rv;
84 STRLEN in_data_len;
85 unsigned char *in_data;
86
87 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
88 rv = chacha20poly1305_add_aad(&self->state, in_data, (unsigned long)in_data_len);
89 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_add_aad failed: %s", error_to_string(rv));
90 RETVAL = rv;
91 }
92 OUTPUT:
93 RETVAL
94
95 SV *
96 decrypt_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
97 CODE:
98 {
99 int rv;
100 STRLEN in_data_len;
101 unsigned char *in_data, *out_data;
102
103 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
104 if (in_data_len==0) {
105 RETVAL = newSVpvn("", 0);
106 }
107 else {
108 RETVAL = NEWSV(0, in_data_len);
109 SvPOK_only(RETVAL);
110 SvCUR_set(RETVAL, in_data_len);
111 out_data = (unsigned char *)SvPV_nolen(RETVAL);
112 rv = chacha20poly1305_decrypt(&self->state, in_data, (unsigned long)in_data_len, out_data);
113 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_decrypt failed: %s", error_to_string(rv));
114 }
115 }
116 OUTPUT:
117 RETVAL
118
119 SV *
120 encrypt_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
121 CODE:
122 {
123 int rv;
124 STRLEN in_data_len;
125 unsigned char *in_data, *out_data;
126
127 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
128 if (in_data_len==0) {
129 RETVAL = newSVpvn("", 0);
130 }
131 else {
132 RETVAL = NEWSV(0, in_data_len);
133 SvPOK_only(RETVAL);
134 SvCUR_set(RETVAL, in_data_len);
135 out_data = (unsigned char *)SvPV_nolen(RETVAL);
136 rv = chacha20poly1305_encrypt(&self->state, in_data, (unsigned long)in_data_len, out_data);
137 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_encrypt failed: %s", error_to_string(rv));
138 }
139 }
140 OUTPUT:
141 RETVAL
142
143 void
144 encrypt_done(Crypt::AuthEnc::ChaCha20Poly1305 self)
145 PPCODE:
146 {
147 int rv;
148 unsigned char tag[MAXBLOCKSIZE];
149 unsigned long tag_len = sizeof(tag);
150
151 rv = chacha20poly1305_done(&self->state, tag, &tag_len);
152 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_done failed: %s", error_to_string(rv));
153 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
154 }
155
156 void
157 decrypt_done(Crypt::AuthEnc::ChaCha20Poly1305 self, ...)
158 PPCODE:
159 {
160 int rv;
161 unsigned char tag[MAXBLOCKSIZE];
162 unsigned long tag_len = sizeof(tag);
163 STRLEN expected_tag_len;
164 unsigned char *expected_tag;
165
166 rv = chacha20poly1305_done(&self->state, tag, &tag_len);
167 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_done failed: %s", error_to_string(rv));
168 if (items == 1) {
169 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
170 }
171 else {
172 if(!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
173 expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
174 if (expected_tag_len!=tag_len) {
175 XPUSHs(sv_2mortal(newSViv(0))); /* false */
176 }
177 else if (memNE(expected_tag, tag, tag_len)) {
178 XPUSHs(sv_2mortal(newSViv(0))); /* false */
179 }
180 else {
181 XPUSHs(sv_2mortal(newSViv(1))); /* true */
182 }
183 }
184 }
0 MODULE = CryptX PACKAGE = Crypt::AuthEnc::EAX
1
2 Crypt::AuthEnc::EAX
3 _new(char * cipher_name, SV * key, SV * nonce, SV * adata=&PL_sv_undef)
4 CODE:
5 {
6 STRLEN k_len=0;
7 unsigned char *k=NULL;
8 unsigned char *n=NULL;
9 STRLEN n_len=0;
10 unsigned char *h=NULL;
11 STRLEN h_len=0;
12 int id;
13
14 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
15 k = (unsigned char *) SvPVbyte(key, k_len);
16 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
17 n = (unsigned char *) SvPVbyte(nonce, n_len);
18 if(SvOK(adata)) { /* adata is optional param */
19 if(!SvPOK(adata)) croak("FATAL: adata must be string/buffer scalar");
20 h = (unsigned char *) SvPVbyte(adata, h_len);
21 }
22
23 id = find_cipher(cipher_name);
24 if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
25
26 Newz(0, RETVAL, 1, struct eax_struct);
27 if (!RETVAL) croak("FATAL: Newz failed");
28
29 if (eax_init(&RETVAL->state, id, k, (unsigned long)k_len, n, (unsigned long)n_len, h, (unsigned long)h_len) != CRYPT_OK) {
30 croak("FATAL: eax setup failed");
31 }
32 }
33 OUTPUT:
34 RETVAL
35
36 void
37 DESTROY(Crypt::AuthEnc::EAX self)
38 CODE:
39 Safefree(self);
40
41 Crypt::AuthEnc::EAX
42 clone(Crypt::AuthEnc::EAX self)
43 CODE:
44 Newz(0, RETVAL, 1, struct eax_struct);
45 if (!RETVAL) croak("FATAL: Newz failed");
46 Copy(&self->state, &RETVAL->state, 1, struct eax_struct);
47 OUTPUT:
48 RETVAL
49
50 SV *
51 encrypt_add(Crypt::AuthEnc::EAX self, SV * data)
52 CODE:
53 {
54 int rv;
55 STRLEN in_data_len;
56 unsigned char *in_data, *out_data;
57
58 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
59 if (in_data_len==0) {
60 RETVAL = newSVpvn("", 0);
61 }
62 else {
63 RETVAL = NEWSV(0, in_data_len);
64 SvPOK_only(RETVAL);
65 SvCUR_set(RETVAL, in_data_len);
66 out_data = (unsigned char *)SvPV_nolen(RETVAL);
67 rv = eax_encrypt(&self->state, in_data, out_data, (unsigned long)in_data_len);
68 if (rv != CRYPT_OK) croak("FATAL: eax_encrypt failed: %s", error_to_string(rv));
69 }
70 }
71 OUTPUT:
72 RETVAL
73
74 SV *
75 decrypt_add(Crypt::AuthEnc::EAX self, SV * data)
76 CODE:
77 {
78 int rv;
79 STRLEN in_data_len;
80 unsigned char *in_data, *out_data;
81
82 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
83 if (in_data_len==0) {
84 RETVAL = newSVpvn("", 0);
85 }
86 else {
87 RETVAL = NEWSV(0, in_data_len);
88 SvPOK_only(RETVAL);
89 SvCUR_set(RETVAL, in_data_len);
90 out_data = (unsigned char *)SvPV_nolen(RETVAL);
91 rv = eax_decrypt(&self->state, in_data, out_data, (unsigned long)in_data_len);
92 if (rv != CRYPT_OK) croak("FATAL: eax_decrypt failed: %s", error_to_string(rv));
93 }
94 }
95 OUTPUT:
96 RETVAL
97
98 void
99 encrypt_done(Crypt::AuthEnc::EAX self)
100 PPCODE:
101 {
102 int rv;
103 unsigned char tag[MAXBLOCKSIZE];
104 unsigned long tag_len = sizeof(tag);
105
106 rv = eax_done(&self->state, tag, &tag_len);
107 if (rv != CRYPT_OK) croak("FATAL: eax_done failed: %s", error_to_string(rv));
108 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
109 }
110
111 void
112 decrypt_done(Crypt::AuthEnc::EAX self, ...)
113 PPCODE:
114 {
115 int rv;
116 unsigned char tag[MAXBLOCKSIZE];
117 unsigned long tag_len = sizeof(tag);
118 STRLEN expected_tag_len;
119 unsigned char *expected_tag;
120
121 rv = eax_done(&self->state, tag, &tag_len);
122 if (rv != CRYPT_OK) croak("FATAL: eax_done failed: %s", error_to_string(rv));
123 if (items == 1) {
124 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
125 }
126 else {
127 if(!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
128 expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
129 if (expected_tag_len!=tag_len) {
130 XPUSHs(sv_2mortal(newSViv(0))); /* false */
131 }
132 else if (memNE(expected_tag, tag, tag_len)) {
133 XPUSHs(sv_2mortal(newSViv(0))); /* false */
134 }
135 else {
136 XPUSHs(sv_2mortal(newSViv(1))); /* true */
137 }
138 }
139 }
140
141 int
142 aad_add(Crypt::AuthEnc::EAX self, SV * adata)
143 CODE:
144 {
145 STRLEN h_len;
146 unsigned char *h;
147 h = (unsigned char *)SvPVbyte(adata, h_len);
148 RETVAL = eax_addheader(&self->state, h, (unsigned long)h_len);
149 }
150 OUTPUT:
151 RETVAL
0 MODULE = CryptX PACKAGE = Crypt::AuthEnc::GCM
1
2 Crypt::AuthEnc::GCM
3 _new(char * cipher_name, SV * key, SV * nonce = NULL)
4 CODE:
5 {
6 STRLEN k_len = 0, iv_len = 0;
7 unsigned char *k = NULL, *iv = NULL;
8 int id, rv;
9
10 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
11 k = (unsigned char *) SvPVbyte(key, k_len);
12 if (nonce) {
13 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
14 iv = (unsigned char *)SvPVbyte(nonce, iv_len);
15 }
16
17 id = find_cipher(cipher_name);
18 if (id == -1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
19
20 Newz(0, RETVAL, 1, struct gcm_struct);
21 if (!RETVAL) croak("FATAL: Newz failed");
22
23 rv = gcm_init(&RETVAL->state, id, k, (unsigned long)k_len);
24 if (rv != CRYPT_OK) croak("FATAL: gcm_init failed: %s", error_to_string(rv));
25
26 if (iv && iv_len > 0) {
27 rv = gcm_add_iv(&RETVAL->state, iv, (unsigned long)iv_len);
28 if (rv != CRYPT_OK) croak("FATAL: gcm_add_iv failed: %s", error_to_string(rv));
29 }
30 }
31 OUTPUT:
32 RETVAL
33
34 void
35 DESTROY(Crypt::AuthEnc::GCM self)
36 CODE:
37 Safefree(self);
38
39 Crypt::AuthEnc::GCM
40 clone(Crypt::AuthEnc::GCM self)
41 CODE:
42 Newz(0, RETVAL, 1, struct gcm_struct);
43 if (!RETVAL) croak("FATAL: Newz failed");
44 Copy(&self->state, &RETVAL->state, 1, struct gcm_struct);
45 OUTPUT:
46 RETVAL
47
48 int
49 reset(Crypt::AuthEnc::GCM self)
50 CODE:
51 {
52 int rv;
53 rv = gcm_reset(&self->state);
54 if (rv != CRYPT_OK) croak("FATAL: gcm_reset failed: %s", error_to_string(rv));
55 RETVAL = rv;
56 }
57 OUTPUT:
58 RETVAL
59
60 SV *
61 encrypt_add(Crypt::AuthEnc::GCM self, SV * data)
62 CODE:
63 {
64 int rv;
65 STRLEN in_data_len;
66 unsigned char *in_data, *out_data;
67
68 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
69 if (in_data_len==0) {
70 RETVAL = newSVpvn("", 0);
71 }
72 else
73 {
74 RETVAL = NEWSV(0, in_data_len);
75 SvPOK_only(RETVAL);
76 SvCUR_set(RETVAL, in_data_len);
77 out_data = (unsigned char *)SvPV_nolen(RETVAL);
78 rv = gcm_process(&self->state, in_data, (unsigned long)in_data_len, out_data, GCM_ENCRYPT);
79 if (rv != CRYPT_OK) croak("FATAL: encrypt_add/gcm_process failed: %s", error_to_string(rv));
80 }
81 }
82 OUTPUT:
83 RETVAL
84
85 int
86 iv_add(Crypt::AuthEnc::GCM self, SV * data)
87 CODE:
88 {
89 int rv;
90 STRLEN in_data_len;
91 unsigned char *in_data;
92
93 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
94 rv = gcm_add_iv(&self->state, in_data, (unsigned long)in_data_len);
95 if (rv != CRYPT_OK) croak("FATAL: gcm_add_iv failed: %s", error_to_string(rv));
96 RETVAL = rv;
97 }
98 OUTPUT:
99 RETVAL
100
101 int
102 adata_add(Crypt::AuthEnc::GCM self, SV * data)
103 CODE:
104 {
105 int rv;
106 STRLEN in_data_len;
107 unsigned char *in_data;
108
109 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
110 rv = gcm_add_aad(&self->state, in_data, (unsigned long)in_data_len);
111 if (rv != CRYPT_OK) croak("FATAL: gcm_add_aad failed: %s", error_to_string(rv));
112 RETVAL = rv;
113 }
114 OUTPUT:
115 RETVAL
116
117 SV *
118 decrypt_add(Crypt::AuthEnc::GCM self, SV * data)
119 CODE:
120 {
121 int rv;
122 STRLEN in_data_len;
123 unsigned char *in_data, *out_data;
124
125 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
126 if (in_data_len==0) {
127 RETVAL = newSVpvn("", 0);
128 }
129 else {
130 RETVAL = NEWSV(0, in_data_len);
131 SvPOK_only(RETVAL);
132 SvCUR_set(RETVAL, in_data_len);
133 out_data = (unsigned char *)SvPV_nolen(RETVAL);
134 rv = gcm_process(&self->state, out_data, (unsigned long)in_data_len, in_data, GCM_DECRYPT);
135 if (rv != CRYPT_OK) croak("FATAL: encrypt_add/gcm_process failed: %s", error_to_string(rv));
136 }
137 }
138 OUTPUT:
139 RETVAL
140
141
142 void
143 encrypt_done(Crypt::AuthEnc::GCM self)
144 PPCODE:
145 {
146 int rv;
147 unsigned char tag[MAXBLOCKSIZE];
148 unsigned long tag_len = sizeof(tag);
149
150 rv = gcm_done(&self->state, tag, &tag_len);
151 if (rv != CRYPT_OK) croak("FATAL: gcm_done failed: %s", error_to_string(rv));
152 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
153 }
154
155 void
156 decrypt_done(Crypt::AuthEnc::GCM self, ...)
157 PPCODE:
158 {
159 int rv;
160 unsigned char tag[MAXBLOCKSIZE];
161 unsigned long tag_len = sizeof(tag);
162 STRLEN expected_tag_len;
163 unsigned char *expected_tag;
164
165 rv = gcm_done(&self->state, tag, &tag_len);
166 if (rv != CRYPT_OK) croak("FATAL: gcm_done failed: %s", error_to_string(rv));
167 if (items == 1) {
168 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
169 }
170 else {
171 if(!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
172 expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
173 if (expected_tag_len!=tag_len) {
174 XPUSHs(sv_2mortal(newSViv(0))); /* false */
175 }
176 else if (memNE(expected_tag, tag, tag_len)) {
177 XPUSHs(sv_2mortal(newSViv(0))); /* false */
178 }
179 else {
180 XPUSHs(sv_2mortal(newSViv(1))); /* true */
181 }
182 }
183 }
0 MODULE = CryptX PACKAGE = Crypt::AuthEnc::OCB
1
2 Crypt::AuthEnc::OCB
3 _new(char * cipher_name, SV * key, SV * nonce)
4 CODE:
5 {
6 STRLEN k_len=0;
7 unsigned char *k=NULL;
8 unsigned char *n=NULL;
9 STRLEN n_len=0;
10 int id;
11
12 if (!SvPOK(key)) croak("FATAL: key must be string/buffer scalar");
13 k = (unsigned char *) SvPVbyte(key, k_len);
14 if (!SvPOK(nonce)) croak("FATAL: nonce must be string/buffer scalar");
15 n = (unsigned char *) SvPVbyte(nonce, n_len);
16
17 id = find_cipher(cipher_name);
18 if(id==-1) croak("FATAL: find_cipfer failed for '%s'", cipher_name);
19
20 Newz(0, RETVAL, 1, struct ocb_struct);
21 if (!RETVAL) croak("FATAL: Newz failed");
22
23 if (ocb3_init(&RETVAL->state, id, k, (unsigned long)k_len, n, (unsigned long)n_len) != CRYPT_OK) {
24 croak("FATAL: ocb setup failed");
25 }
26 }
27 OUTPUT:
28 RETVAL
29
30 void
31 DESTROY(Crypt::AuthEnc::OCB self)
32 CODE:
33 Safefree(self);
34
35 Crypt::AuthEnc::OCB
36 clone(Crypt::AuthEnc::OCB self)
37 CODE:
38 Newz(0, RETVAL, 1, struct ocb_struct);
39 if (!RETVAL) croak("FATAL: Newz failed");
40 Copy(&self->state, &RETVAL->state, 1, struct ocb_struct);
41 OUTPUT:
42 RETVAL
43
44 void
45 aad_add(Crypt::AuthEnc::OCB self, SV * data)
46 CODE:
47 {
48 int rv;
49 STRLEN in_data_len;
50 unsigned char *in_data;
51
52 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
53
54 if (in_data_len>0) {
55 rv = ocb3_add_aad(&self->state, in_data, (unsigned long)in_data_len);
56 if (rv != CRYPT_OK) croak("FATAL: ocb3_add_aad failed: %s", error_to_string(rv));
57 }
58 }
59
60 SV *
61 encrypt_add(Crypt::AuthEnc::OCB self, SV * data)
62 CODE:
63 {
64 int rv;
65 STRLEN in_data_len;
66 unsigned char *in_data, *out_data;
67
68 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
69 if (in_data_len==0) {
70 RETVAL = newSVpvn("", 0);
71 }
72 else {
73 RETVAL = NEWSV(0, in_data_len);
74 SvPOK_only(RETVAL);
75 SvCUR_set(RETVAL, in_data_len);
76 out_data = (unsigned char *)SvPV_nolen(RETVAL);
77
78 if (in_data_len % (&self->state)->block_len)
79 croak ("FATAL: sizeof(data) should be multiple of blocksize (%d)", (&self->state)->block_len);
80
81 rv = ocb3_encrypt(&self->state, in_data, (unsigned long)in_data_len, out_data);
82 if (rv != CRYPT_OK) croak("FATAL: ocb3_encrypt failed: %s", error_to_string(rv));
83 }
84 }
85 OUTPUT:
86 RETVAL
87
88 SV *
89 encrypt_last(Crypt::AuthEnc::OCB self, SV * data)
90 CODE:
91 {
92 int rv;
93 STRLEN in_data_len;
94 unsigned char *in_data, *out_data;
95
96 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
97 if (in_data_len>0) {
98 RETVAL = NEWSV(0, in_data_len);
99 SvPOK_only(RETVAL);
100 SvCUR_set(RETVAL, in_data_len);
101 out_data = (unsigned char *)SvPV_nolen(RETVAL);
102 }
103 else {
104 RETVAL = newSVpvn("", 0);
105 out_data = NULL;
106 }
107 rv = ocb3_encrypt_last(&self->state, in_data, (unsigned long)in_data_len, out_data);
108 if (rv != CRYPT_OK) croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
109 }
110 OUTPUT:
111 RETVAL
112
113 SV *
114 decrypt_add(Crypt::AuthEnc::OCB self, SV * data)
115 CODE:
116 {
117 int rv;
118 STRLEN in_data_len;
119 unsigned char *in_data, *out_data;
120
121 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
122 if (in_data_len==0) {
123 RETVAL = newSVpvn("", 0);
124 }
125 else {
126 RETVAL = NEWSV(0, in_data_len);
127 SvPOK_only(RETVAL);
128 SvCUR_set(RETVAL, in_data_len);
129 out_data = (unsigned char *)SvPV_nolen(RETVAL);
130
131 if (in_data_len % (&self->state)->block_len)
132 croak ("FATAL: sizeof(data) should be multiple of blocksize (%d)", (&self->state)->block_len);
133
134 rv = ocb3_decrypt(&self->state, in_data, (unsigned long)in_data_len, out_data);
135 if (rv != CRYPT_OK) croak("FATAL: ocb3_decrypt failed: %s", error_to_string(rv));
136 }
137 }
138 OUTPUT:
139 RETVAL
140
141 SV *
142 decrypt_last(Crypt::AuthEnc::OCB self, SV * data)
143 CODE:
144 {
145 int rv;
146 STRLEN in_data_len;
147 unsigned char *in_data, *out_data;
148
149 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
150 if (in_data_len>0) {
151 RETVAL = NEWSV(0, in_data_len);
152 SvPOK_only(RETVAL);
153 SvCUR_set(RETVAL, in_data_len);
154 out_data = (unsigned char *)SvPV_nolen(RETVAL);
155 }
156 else {
157 RETVAL = newSVpvn("", 0);
158 out_data = NULL;
159 }
160 rv = ocb3_decrypt_last(&self->state, in_data, (unsigned long)in_data_len, out_data);
161 if (rv != CRYPT_OK) croak("FATAL: ocb3_encrypt_last failed: %s", error_to_string(rv));
162 }
163 OUTPUT:
164 RETVAL
165
166 void
167 encrypt_done(Crypt::AuthEnc::OCB self)
168 PPCODE:
169 {
170 int rv;
171 unsigned char tag[MAXBLOCKSIZE];
172 unsigned long tag_len = sizeof(tag);
173
174 rv = ocb3_done(&self->state, tag, &tag_len);
175 if (rv != CRYPT_OK) croak("FATAL: ocb3_done_encrypt failed: %s", error_to_string(rv));
176
177 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
178 }
179
180 void
181 decrypt_done(Crypt::AuthEnc::OCB self, ...)
182 PPCODE:
183 {
184 int rv;
185 unsigned char tag[MAXBLOCKSIZE];
186 unsigned long tag_len = sizeof(tag);
187 STRLEN expected_tag_len;
188 unsigned char *expected_tag;
189
190 rv = ocb3_done(&self->state, tag, &tag_len);
191 if (rv != CRYPT_OK) croak("FATAL: ocb3_done_decrypt failed: %s", error_to_string(rv));
192 if (items == 1) {
193 XPUSHs(sv_2mortal(newSVpvn((char*)tag, tag_len)));
194 }
195 else {
196 if(!SvPOK(ST(1))) croak("FATAL: expected_tag must be string/buffer scalar");
197 expected_tag = (unsigned char *) SvPVbyte(ST(1), expected_tag_len);
198 if (expected_tag_len!=tag_len) {
199 XPUSHs(sv_2mortal(newSViv(0))); /* false */
200 }
201 else if (memNE(expected_tag, tag, tag_len)) {
202 XPUSHs(sv_2mortal(newSViv(0))); /* false */
203 }
204 else {
205 XPUSHs(sv_2mortal(newSViv(1))); /* true */
206 }
207 }
208 }
209
210 int
211 blocksize(Crypt::AuthEnc::OCB self)
212 CODE:
213 {
214 RETVAL = (&self->state)->block_len;
215 }
216 OUTPUT:
217 RETVAL
0 MODULE = CryptX PACKAGE = Math::BigInt::LTM
1
2
3 ##############################################################################
4 # _new()
5
6 Math::BigInt::LTM
7 _new(Class, SV *x)
8 CODE:
9 Newz(0, RETVAL, 1, mp_int);
10 mp_init(RETVAL);
11 if ((SvUOK(x) || SvIOK(x)) && (sizeof(UV) <= sizeof(unsigned long) || SvUV(x) == (unsigned long)SvUV(x))) {
12 mp_set_int(RETVAL, (unsigned long)SvUV(x));
13 }
14 else {
15 mp_read_radix(RETVAL, SvPV_nolen(x), 10);
16 }
17 OUTPUT:
18 RETVAL
19
20 ##############################################################################
21 # _from_bin()
22
23 Math::BigInt::LTM
24 _from_bin(Class, SV *x)
25 PREINIT:
26 char *str, *start;
27 CODE:
28 Newz(0, RETVAL, 1, mp_int);
29 mp_init(RETVAL);
30 str = SvPV_nolen(x);
31 start = (strlen(str)>2 && str[0] == '0' && str[1] == 'b') ? str+2 : str;
32 mp_read_radix(RETVAL, start, 2);
33 OUTPUT:
34 RETVAL
35
36 ##############################################################################
37 # _from_hex()
38
39 Math::BigInt::LTM
40 _from_hex(Class, SV *x)
41 PREINIT:
42 char *str, *start;
43 CODE:
44 Newz(0, RETVAL, 1, mp_int);
45 mp_init(RETVAL);
46 str = SvPV_nolen(x);
47 start = (strlen(str)>2 && str[0] == '0' && str[1] == 'x') ? str+2 : str;
48 mp_read_radix(RETVAL, start, 16);
49 OUTPUT:
50 RETVAL
51
52 ##############################################################################
53 # _from_oct()
54
55 Math::BigInt::LTM
56 _from_oct(Class, SV *x)
57 CODE:
58 Newz(0, RETVAL, 1, mp_int);
59 mp_init(RETVAL);
60 mp_read_radix(RETVAL, SvPV_nolen(x), 8);
61 OUTPUT:
62 RETVAL
63
64 ##############################################################################
65 # _set() - set an already existing object to the given scalar value
66
67 void
68 _set(Class, Math::BigInt::LTM n, SV *x)
69 CODE:
70 mp_set_int(n, (unsigned long)SvIV(x));
71
72 ##############################################################################
73 # _zero()
74
75 Math::BigInt::LTM
76 _zero(Class)
77 CODE:
78 Newz(0, RETVAL, 1, mp_int);
79 mp_init(RETVAL);
80 mp_set_int(RETVAL, 0);
81 OUTPUT:
82 RETVAL
83
84 ##############################################################################
85 # _one()
86
87 Math::BigInt::LTM
88 _one(Class)
89 CODE:
90 Newz(0, RETVAL, 1, mp_int);
91 mp_init(RETVAL);
92 mp_set_int(RETVAL, 1);
93 OUTPUT:
94 RETVAL
95
96 ##############################################################################
97 # _two()
98
99 Math::BigInt::LTM
100 _two(Class)
101 CODE:
102 Newz(0, RETVAL, 1, mp_int);
103 mp_init(RETVAL);
104 mp_set_int(RETVAL, 2);
105 OUTPUT:
106 RETVAL
107
108 ##############################################################################
109 # _ten()
110
111 Math::BigInt::LTM
112 _ten(Class)
113 CODE:
114 Newz(0, RETVAL, 1, mp_int);
115 mp_init(RETVAL);
116 mp_set_int(RETVAL, 10);
117 OUTPUT:
118 RETVAL
119
120 ##############################################################################
121 # _1ex()
122
123 Math::BigInt::LTM
124 _1ex(Class, int x)
125 CODE:
126 Newz(0, RETVAL, 1, mp_int);
127 mp_init(RETVAL);
128 mp_set_int(RETVAL, 10);
129 mp_expt_d(RETVAL, x, RETVAL);
130 OUTPUT:
131 RETVAL
132
133 ##############################################################################
134 # DESTROY() - free memory of a GMP number
135
136 void
137 DESTROY(Math::BigInt::LTM n)
138 PPCODE:
139 if (n) {
140 mp_clear(n);
141 Safefree(n);
142 }
143
144 ##############################################################################
145 # _str() - return string so that atof() and atoi() can use it
146
147 SV *
148 _str(Class, Math::BigInt::LTM n)
149 PREINIT:
150 int len;
151 char *buf;
152 CODE:
153 if (mp_iszero(n) == MP_YES) {
154 RETVAL = newSVpv("0", 0);
155 }
156 else {
157 len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
158 Newz(0, buf, len, char);
159 mp_toradix_n(n, buf, 10, len);
160 RETVAL = newSVpv(buf, 0);
161 Safefree(buf);
162 }
163 OUTPUT:
164 RETVAL
165
166 ##############################################################################
167 # _len() - return the length of the number in base 10 (costly)
168
169 int
170 _len(Class, Math::BigInt::LTM n)
171 PREINIT:
172 int len;
173 char *buf;
174 CODE:
175 if (mp_iszero(n) == MP_YES) {
176 RETVAL = 1;
177 }
178 else {
179 len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
180 Newz(0, buf, len, char);
181 mp_toradix_n(n, buf, 10, len);
182 RETVAL = (int)strlen(buf);
183 Safefree(buf);
184 }
185 OUTPUT:
186 RETVAL
187
188 ##############################################################################
189 # _alen() - return the approx. length of the number in base 10 (fast)
190 # _alen() might underestimate, but never overestimate the true value
191 int
192 _alen(Class, Math::BigInt::LTM n)
193 PREINIT:
194 int bits;
195 CODE:
196 bits = mp_count_bits(n);
197 /* alen = round(bits * log(2) / log(10)) */
198 RETVAL = (bits < 5) ? 1 : (int)(bits * 0.301029995663 + 0.499999999999);
199 /* less accurate approximation, but without floating-point calculations
200 RETVAL = (bits < 5) ? 1 : bits / 4 + bits / 32 + bits / 64 + bits / 256;
201 RETVAL = (bits < 5) ? 1 : bits / 4;
202 */
203 OUTPUT:
204 RETVAL
205
206 ##############################################################################
207 # _zeros() - return number of trailing zeros (in decimal form)
208
209 int
210 _zeros(Class, Math::BigInt::LTM n)
211 PREINIT:
212 int len;
213 char *buf;
214 CODE:
215 if (mp_iszero(n) == MP_YES) {
216 RETVAL = 0; /* '0' has no trailing zeros! */
217 }
218 else {
219 len = mp_count_bits(n) / 3 + 3; /* decimal_size ~ (binary_size/3 + 1) +1 for sign +1 for NUL-byte */
220 Newz(0, buf, len, char);
221 mp_toradix_n(n, buf, 10, len);
222 len = (int)strlen(buf);
223 RETVAL = 0;
224 while (len > 0) {
225 if (buf[len-1] != '0') break;
226 RETVAL++;
227 len--;
228 }
229 Safefree(buf);
230 }
231 OUTPUT:
232 RETVAL
233
234 ##############################################################################
235 # _as_hex() - return ref to hexadecimal string (prefixed with 0x)
236
237 SV *
238 _as_hex(Class, Math::BigInt::LTM n)
239 PREINIT:
240 int i, len;
241 char *buf;
242 CODE:
243 len = mp_unsigned_bin_size(n) * 2 + 3;
244 RETVAL = newSV(len);
245 SvPOK_on(RETVAL);
246 buf = SvPVX(RETVAL); /* get ptr to storage */
247 *buf++ = '0'; *buf++ = 'x'; /* prepend '0x' */
248 mp_tohex(n, buf);
249 for (i=0; i<len && buf[i]>0; i++) buf[i] = toLOWER(buf[i]);
250 SvCUR_set(RETVAL, strlen(buf)+2); /* set real length */
251 OUTPUT:
252 RETVAL
253
254 ##############################################################################
255 # _as_bin() - return ref to binary string (prefixed with 0b)
256
257 SV *
258 _as_bin(Class, Math::BigInt::LTM n)
259 PREINIT:
260 int len;
261 char *buf;
262 CODE:
263 len = mp_unsigned_bin_size(n) * 8 + 3;
264 RETVAL = newSV(len);
265 SvPOK_on(RETVAL);
266 buf = SvPVX(RETVAL); /* get ptr to storage */
267 *buf++ = '0'; *buf++ = 'b'; /* prepend '0b' */
268 mp_tobinary(n, buf);
269 SvCUR_set(RETVAL, strlen(buf)+2); /* set real length */
270 OUTPUT:
271 RETVAL
272
273 ##############################################################################
274 # _as_oct() - return ref to octal string (prefixed with 0)
275
276 SV *
277 _as_oct(Class, Math::BigInt::LTM n)
278 PREINIT:
279 int len;
280 char *buf;
281 CODE:
282 len = mp_unsigned_bin_size(n) * 3 + 3;
283 RETVAL = newSV(len);
284 SvPOK_on(RETVAL);
285 buf = SvPVX(RETVAL);
286 *buf++ = '0'; /* prepend '0' */
287 mp_tooctal(n, buf);
288 SvCUR_set(RETVAL, strlen(buf)+1); /* set real length */
289 OUTPUT:
290 RETVAL
291
292 ##############################################################################
293 # _modpow() - ($n ** $exp) % $mod
294
295 Math::BigInt::LTM
296