Package list libcryptx-perl / 74c06e1
New upstream version 0.060 gregor herrmann 3 years ago
283 changed file(s) with 2869 addition(s) and 2047 deletion(s). Raw diff Collapse all Expand all
00 Changes for CryptX
1
2 0.060 2018-05-01
3 - bundled libtomcrypt update
4 - Math::BigInt::LTM - remove buggy tests failing with the latest Math::BigInt
5 - basically no changes to the perl modules
16
27 0.059 2018-03-25
38 - new Crypt::Digest::Keccak(224|256|384|512)
174174 }
175175
176176 return MP_OKAY;
177 }
178
179 int _base16_encode(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
180 {
181 unsigned long i;
182 const char alphabet[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
183
184 if (*outlen < inlen * 2) {
185 *outlen = inlen * 2;
186 return CRYPT_BUFFER_OVERFLOW;
187 }
188
189 for (i = 0; i < inlen; i++) {
190 out[i*2] = (unsigned char)alphabet[in[i] >> 4];
191 out[i*2+1] = (unsigned char)alphabet[in[i] & 0xF];
192 }
193
194 *outlen = inlen * 2;
195 return CRYPT_OK;
196177 }
197178
198179 size_t _find_start(const char *name, char *ltcname, size_t ltclen)
259240 void _ecc_oid_lookup(ecc_key *key)
260241 {
261242 int err;
262 unsigned i;
243 unsigned i, j;
263244 void *tmp;
264 const ltc_ecc_set_type *set;
245 const ltc_ecc_curve *cu;
265246
266247 key->dp.oidlen = 0;
267248 if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return;
268 for (set = ltc_ecc_sets; set->name != NULL; set++) {
269 if ((err = mp_read_radix(tmp, set->prime, 16)) != CRYPT_OK) continue;
270 if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue;
271 if ((err = mp_read_radix(tmp, set->order, 16)) != CRYPT_OK) continue;
272 if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue;
273 if ((err = mp_read_radix(tmp, set->A, 16)) != CRYPT_OK) continue;
274 if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue;
275 if ((err = mp_read_radix(tmp, set->B, 16)) != CRYPT_OK) continue;
276 if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue;
277 if ((err = mp_read_radix(tmp, set->Gx, 16)) != CRYPT_OK) continue;
278 if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue;
279 if ((err = mp_read_radix(tmp, set->Gy, 16)) != CRYPT_OK) continue;
280 if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue;
281 if (key->dp.cofactor != set->cofactor) continue;
249 for (cu = ltc_ecc_curves; cu->prime != NULL; cu++) {
250 if ((err = mp_read_radix(tmp, cu->prime, 16)) != CRYPT_OK) continue;
251 if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue;
252 if ((err = mp_read_radix(tmp, cu->order, 16)) != CRYPT_OK) continue;
253 if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue;
254 if ((err = mp_read_radix(tmp, cu->A, 16)) != CRYPT_OK) continue;
255 if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue;
256 if ((err = mp_read_radix(tmp, cu->B, 16)) != CRYPT_OK) continue;
257 if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue;
258 if ((err = mp_read_radix(tmp, cu->Gx, 16)) != CRYPT_OK) continue;
259 if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue;
260 if ((err = mp_read_radix(tmp, cu->Gy, 16)) != CRYPT_OK) continue;
261 if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue;
262 if (key->dp.cofactor != cu->cofactor) continue;
282263 break; /* found */
283264 }
284265 ltc_mp.deinit(tmp);
285 if (set->name != NULL) {
286 key->dp.oidlen = set->oidlen;
287 for(i = 0; i < set->oidlen; i++) key->dp.oid[i] = set->oid[i];
266 if (cu->prime && cu->OID) {
267 for (i = 0; i < 16; i++) key->dp.oid[i] = 0;
268 for (i = 0, j = 0; i < strlen(cu->OID); i++) {
269 if (cu->OID[i] == '.') {
270 if (++j >= 16) return;
271 }
272 else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') {
273 key->dp.oid[j] = key->dp.oid[j] * 10 + (cu->OID[i] - '0');
274 }
275 else {
276 return;
277 }
278 }
279 key->dp.oidlen = j + 1;
288280 }
289281 }
290282
291283 int _ecc_set_dp_from_SV(ecc_key *key, SV *curve)
292284 {
293285 dTHX; /* fetch context */
294 HV *hc, *hl, *h;
286 HV *hc, *h;
295287 SV *sv_crv, **pref;
296288 SV **sv_cofactor, **sv_prime, **sv_A, **sv_B, **sv_order, **sv_Gx, **sv_Gy, **sv_oid;
297 char *ch_name;
298 STRLEN l_name, i, j;
289 char *ptr_crv;
290 STRLEN len_crv;
299291 int err;
300292
301293 if (!SvOK(curve)) croak("FATAL: undefined curve");
302294
303295 if (SvPOK(curve)) {
304296 /* string */
305 ch_name = SvPV(curve, l_name);
306 if ((hl = get_hv("Crypt::PK::ECC::curve2ltc", 0)) == NULL) croak("FATAL: no curve2ltc register");
307 pref = hv_fetch(hl, ch_name, (U32)l_name, 0);
297 ptr_crv = SvPV(curve, len_crv);
298 if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register");
299 pref = hv_fetch(hc, ptr_crv, (U32)len_crv, 0);
308300 if (pref && SvOK(*pref)) {
309 sv_crv = *pref; /* found in %cutve2ltc */
301 sv_crv = *pref; /* found in %curve */
310302 }
311303 else {
312 if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register");
313 pref = hv_fetch(hc, ch_name, (U32)l_name, 0);
314 if (pref && SvOK(*pref)) {
315 sv_crv = *pref; /* found in %curve */
316 }
317 else {
318 sv_crv = curve;
319 }
304 sv_crv = curve;
320305 }
321306 }
322307 else if (SvROK(curve)) {
329314
330315 if (SvPOK(sv_crv)) {
331316 /* string - curve name */
332 const ltc_ecc_set_type *dp;
333 ch_name = SvPV(sv_crv, l_name);
334 if (ecc_get_set_by_name(ch_name, &dp) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ch_name);
335 return ecc_set_dp(dp, key);
317 const ltc_ecc_curve *cu;
318 ptr_crv = SvPV(sv_crv, len_crv);
319 if (ecc_get_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv);
320 return ecc_set_dp(cu, key);
336321 }
337322 else {
338323 /* hashref */
339 ltc_ecc_set_type set = { 0 };
324 ltc_ecc_curve cu = { 0 };
340325
341326 if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref");
342327
356341 if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy");
357342 if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor");
358343
359 set.prime = SvPV_nolen(*sv_prime);
360 set.A = SvPV_nolen(*sv_A);
361 set.B = SvPV_nolen(*sv_B);
362 set.order = SvPV_nolen(*sv_order);
363 set.Gx = SvPV_nolen(*sv_Gx);
364 set.Gy = SvPV_nolen(*sv_Gy);
365 set.cofactor = (unsigned long)SvUV(*sv_cofactor),
366 set.name = NULL;
367 set.oidlen = 0;
368
369 sv_oid = hv_fetchs(h, "oid", 0);
370 if (sv_oid && SvPOK(*sv_oid)) {
371 ch_name = SvPV(*sv_oid, l_name);
372 for (i = 0, j = 0; i < l_name; i++) {
373 if (ch_name[i] == '.') {
374 if (++j >= 16) return CRYPT_ERROR;
375 }
376 else if(ch_name[i] >= '0' && ch_name[i] <= '9') {
377 set.oid[j] = set.oid[j] * 10 + (ch_name[i] - '0');
378 }
379 else {
380 return CRYPT_ERROR;
381 }
382 }
383 if (j == 0) return CRYPT_ERROR;
384 set.oidlen = j + 1;
385 }
386
387 if ((err = ecc_set_dp(&set, key)) != CRYPT_OK) return err;
344 sv_oid = hv_fetchs(h, "oid", 0); /* 'oid' is optional */
345 cu.OID = (sv_oid && SvOK(*sv_oid)) ? SvPV_nolen(*sv_oid) : NULL;
346
347 cu.prime = SvPV_nolen(*sv_prime);
348 cu.A = SvPV_nolen(*sv_A);
349 cu.B = SvPV_nolen(*sv_B);
350 cu.order = SvPV_nolen(*sv_order);
351 cu.Gx = SvPV_nolen(*sv_Gx);
352 cu.Gy = SvPV_nolen(*sv_Gy);
353 cu.cofactor = (unsigned long)SvUV(*sv_cofactor);
354
355 if ((err = ecc_set_dp(&cu, key)) != CRYPT_OK) return err;
388356 if (key->dp.oidlen == 0) _ecc_oid_lookup(key);
389357 return CRYPT_OK;
390358 }
512480 int rv;
513481 STRLEN in_len;
514482 unsigned long out_len;
515 unsigned char *out_data, *in_data;
483 unsigned char *in_data;
484 char *out_data;
516485
517486 if (!SvPOK(in)) XSRETURN_UNDEF;
518487 in_data = (unsigned char *) SvPVbyte(in, in_len);
523492 out_len = (unsigned long)(4 * ((in_len + 2) / 3) + 1);
524493 RETVAL = NEWSV(0, out_len); /* avoid zero! */
525494 SvPOK_only(RETVAL);
526 out_data = (unsigned char *)SvPVX(RETVAL);
495 out_data = SvPVX(RETVAL);
527496 if (ix == 1)
528497 rv = base64url_encode(in_data, (unsigned long)in_len, out_data, &out_len);
529498 else
547516 int rv;
548517 STRLEN in_len;
549518 unsigned long out_len;
550 unsigned char *out_data, *in_data;
519 unsigned char *out_data;
520 char *in_data;
551521
552522 if (!SvPOK(in)) XSRETURN_UNDEF;
553 in_data = (unsigned char *)SvPVbyte(in, in_len);
523 in_data = SvPVbyte(in, in_len);
554524 if (in_len == 0) {
555525 RETVAL = newSVpvn("", 0);
556526 }
560530 SvPOK_only(RETVAL);
561531 out_data = (unsigned char *)SvPVX(RETVAL);
562532 if (ix == 1)
563 rv = base64url_decode(in_data, (unsigned long)in_len, out_data, &out_len);
533 rv = base64url_sane_decode(in_data, (unsigned long)in_len, out_data, &out_len);
564534 else
565 rv = base64_decode(in_data, (unsigned long)in_len, out_data, &out_len);
535 rv = base64_sane_decode(in_data, (unsigned long)in_len, out_data, &out_len);
566536 if (rv != CRYPT_OK) {
567537 SvREFCNT_dec(RETVAL);
568538 XSRETURN_UNDEF;
583553 {
584554 STRLEN in_len;
585555 unsigned long out_len;
586 unsigned char *out_data, *in_data;
587 int id = -1;
556 unsigned char *in_data;
557 char *out_data;
558 int id = -1, err;
588559
589560 if (!SvPOK(in)) XSRETURN_UNDEF;
590561 if (ix == 0) id = BASE32_RFC4648;
597568 RETVAL = newSVpvn("", 0);
598569 }
599570 else {
600 out_len = (unsigned long)((8 * in_len + 4) / 5);
571 out_len = (unsigned long)((8 * in_len + 4) / 5 + 1);
601572 RETVAL = NEWSV(0, out_len); /* avoid zero! */
602573 SvPOK_only(RETVAL);
603 out_data = (unsigned char *)SvPVX(RETVAL);
604 if (base32_encode(in_data, (unsigned long)in_len, out_data, &out_len, id) != CRYPT_OK) {
574 out_data = SvPVX(RETVAL);
575 err = base32_encode(in_data, (unsigned long)in_len, out_data, &out_len, id);
576 if (err != CRYPT_OK) {
605577 SvREFCNT_dec(RETVAL);
606578 XSRETURN_UNDEF;
607579 }
621593 {
622594 STRLEN in_len;
623595 unsigned long out_len;
624 unsigned char *out_data, *in_data;
625 int id = -1;
596 unsigned char *out_data;
597 char *in_data;
598 int id = -1, err;
626599
627600 if (!SvPOK(in)) XSRETURN_UNDEF;
628601 if (ix == 0) id = BASE32_RFC4648;
630603 if (ix == 2) id = BASE32_ZBASE32;
631604 if (ix == 3) id = BASE32_CROCKFORD;
632605 if (id == -1) XSRETURN_UNDEF;
633 in_data = (unsigned char *)SvPVbyte(in, in_len);
606 in_data = SvPVbyte(in, in_len);
634607 if (in_len == 0) {
635608 RETVAL = newSVpvn("", 0);
636609 }
639612 RETVAL = NEWSV(0, out_len); /* avoid zero! */
640613 SvPOK_only(RETVAL);
641614 out_data = (unsigned char *)SvPVX(RETVAL);
642 if (base32_decode(in_data, (unsigned long)in_len, out_data, &out_len, id) != CRYPT_OK) {
615 err = base32_decode(in_data, (unsigned long)in_len, out_data, &out_len, id);
616 if (err != CRYPT_OK) {
643617 SvREFCNT_dec(RETVAL);
644618 XSRETURN_UNDEF;
645619 }
309309 src/ltc/math/rand_prime.c
310310 src/ltc/math/tfm_desc.c
311311 src/ltc/misc/adler32.c
312 src/ltc/misc/base16/base16_decode.c
313 src/ltc/misc/base16/base16_encode.c
312314 src/ltc/misc/base32/base32_decode.c
313315 src/ltc/misc/base32/base32_encode.c
314316 src/ltc/misc/base64/base64_decode.c
351353 src/ltc/misc/error_to_string.c
352354 src/ltc/misc/hkdf/hkdf.c
353355 src/ltc/misc/mem_neq.c
356 src/ltc/misc/padding/padding_depad.c
357 src/ltc/misc/padding/padding_pad.c
354358 src/ltc/misc/pk_get_oid.c
359 src/ltc/misc/pk_oid_str.c
355360 src/ltc/misc/pkcs5/pkcs_5_1.c
356361 src/ltc/misc/pkcs5/pkcs_5_2.c
357362 src/ltc/misc/zeromem.c
475480 src/ltc/pk/ecc/ecc_export.c
476481 src/ltc/pk/ecc/ecc_export_openssl.c
477482 src/ltc/pk/ecc/ecc_free.c
483 src/ltc/pk/ecc/ecc_get_curve.c
478484 src/ltc/pk/ecc/ecc_get_key.c
479 src/ltc/pk/ecc/ecc_get_set.c
480485 src/ltc/pk/ecc/ecc_get_size.c
481486 src/ltc/pk/ecc/ecc_import.c
482487 src/ltc/pk/ecc/ecc_import_openssl.c
4444 "url" : "https://github.com/DCIT/perl-CryptX"
4545 }
4646 },
47 "version" : "0.059",
47 "version" : "0.060",
4848 "x_serialization_backend" : "JSON::PP version 2.94"
4949 }
2121 resources:
2222 bugtracker: https://github.com/DCIT/perl-CryptX/issues
2323 repository: https://github.com/DCIT/perl-CryptX
24 version: '0.059'
24 version: '0.060'
2525 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
4949 my ($maj, $min) = $arver =~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s;
5050 $myarflags = 'rcD' if ($maj && $min && $maj >= 2 && $min >= 20) || $arver=~ /^BSD ar /;
5151 }
52
53 # turn on extra warnings in AUTHOR_MODE (it is gcc only!!)
54 $mycflags = "$mycflags -Wall -Werror -Wextra" if $ENV{AUTHOR_MODE};
55
5256 @EUMM_INC_LIB = (
53 INC => '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm',
57 INC => $ENV{AUTHOR_MODE} ? '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm -Wall -Werror -Wextra' #gcc only!!
58 : '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm',
5459 MYEXTLIB => "src/liballinone$Config{lib_ext}",
5560 clean => { 'FILES' => join(' ', @myobjs, "src/liballinone$Config{lib_ext}") },
5661 );
5858 CODE:
5959 {
6060 int rv;
61 unsigned char hash[4], out[8];
62 unsigned long outlen = 8;
61 unsigned char hash[4];
62 char out[9];
63 unsigned long outlen = 9;
6364 unsigned int ui32;
6465
6566 adler32_finish(self, hash, 4); /* returns void */
6667 if (ix == 1) {
67 rv = _base16_encode(hash, 4, out, &outlen);
68 rv = base16_encode(hash, 4, out, &outlen, 0);
6869 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
69 RETVAL = newSVpvn((char *)out, outlen);
70 RETVAL = newSVpvn(out, outlen);
7071 }
7172 else if (ix == 2) {
7273 LOAD32H(ui32, hash);
8889 {
8990 adler32_state st;
9091 int rv, j;
91 unsigned char hash[4], out[8], *in;
92 unsigned long outlen = 8;
92 unsigned char hash[4], *in;
93 char out[9];
94 unsigned long outlen = 9;
9395 unsigned int ui32;
9496 STRLEN inlen;
9597
102104 }
103105 adler32_finish(&st, hash, 4); /* returns void */
104106 if (ix == 1) {
105 rv = _base16_encode(hash, 4, out, &outlen);
107 rv = base16_encode(hash, 4, out, &outlen, 0);
106108 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
107 RETVAL = newSVpvn((char *)out, outlen);
109 RETVAL = newSVpvn(out, outlen);
108110 }
109111 else if (ix == 2) {
110112 LOAD32H(ui32, hash);
5858 CODE:
5959 {
6060 int rv;
61 unsigned char hash[4], out[8];
62 unsigned long outlen = 8;
61 unsigned char hash[4];
62 char out[9];
63 unsigned long outlen = 9;
6364 unsigned int ui32;
6465
6566 crc32_finish(self, hash, 4); /* returns void */
6667 if (ix == 1) {
67 rv = _base16_encode(hash, 4, out, &outlen);
68 rv = base16_encode(hash, 4, out, &outlen, 0);
6869 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
69 RETVAL = newSVpvn((char *)out, outlen);
70 RETVAL = newSVpvn(out, outlen);
7071 }
7172 else if (ix == 2) {
7273 LOAD32H(ui32, hash);
8889 {
8990 crc32_state st;
9091 int rv, j;
91 unsigned char hash[4], out[8], *in;
92 unsigned long outlen = 8;
92 unsigned char hash[4], *in;
93 char out[9];
94 unsigned long outlen = 9;
9395 unsigned int ui32;
9496 STRLEN inlen;
9597
102104 }
103105 crc32_finish(&st, hash, 4); /* returns void */
104106 if (ix == 1) {
105 rv = _base16_encode(hash, 4, out, &outlen);
107 rv = base16_encode(hash, 4, out, &outlen, 0);
106108 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
107 RETVAL = newSVpvn((char *)out, outlen);
109 RETVAL = newSVpvn(out, outlen);
108110 }
109111 else if (ix == 2) {
110112 LOAD32H(ui32, hash);
7878 int rv;
7979 unsigned long outlen;
8080 unsigned char hash[MAXBLOCKSIZE];
81 char out[MAXBLOCKSIZE*2];
81 char out[MAXBLOCKSIZE*2+1];
8282
8383 rv = self->desc->done(&self->state, hash);
8484 if (rv != CRYPT_OK) croak("FATAL: digest done failed: %s", error_to_string(rv));
8585
8686 outlen = sizeof(out);
8787 if (ix == 3) {
88 rv = base64url_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen);
88 rv = base64url_encode(hash, self->desc->hashsize, out, &outlen);
8989 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
9090 RETVAL = newSVpvn(out, outlen);
9191 }
9292 else if (ix == 2) {
93 rv = base64_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen);
93 rv = base64_encode(hash, self->desc->hashsize, out, &outlen);
9494 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
9595 RETVAL = newSVpvn(out, outlen);
9696 }
9797 else if (ix == 1) {
98 rv = _base16_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen);
98 rv = base16_encode(hash, self->desc->hashsize, out, &outlen, 0);
9999 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
100100 RETVAL = newSVpvn(out, outlen);
101101 }
118118 int rv, id, i;
119119 unsigned char *in, hash[MAXBLOCKSIZE];
120120 unsigned long len = sizeof(hash), outlen;
121 char out[MAXBLOCKSIZE*2];
121 char out[MAXBLOCKSIZE*2+1];
122122 hash_state md;
123123
124124 id = _find_hash(digest_name);
140140
141141 outlen = sizeof(out);
142142 if (ix == 3) {
143 rv = base64url_encode(hash, len, (unsigned char *)out, &outlen);
143 rv = base64url_encode(hash, len, out, &outlen);
144144 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
145 RETVAL = newSVpvn((char *) out, outlen);
145 RETVAL = newSVpvn(out, outlen);
146146 }
147147 else if (ix == 2) {
148 rv = base64_encode(hash, len, (unsigned char *)out, &outlen);
148 rv = base64_encode(hash, len, out, &outlen);
149149 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
150 RETVAL = newSVpvn((char *) out, outlen);
150 RETVAL = newSVpvn(out, outlen);
151151 }
152152 else if (ix == 1) {
153 rv = _base16_encode(hash, len, (unsigned char *)out, &outlen);
153 rv = base16_encode(hash, len, out, &outlen, 0);
154154 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
155 RETVAL = newSVpvn((char *) out, outlen);
155 RETVAL = newSVpvn(out, outlen);
156156 }
157157 else {
158158 RETVAL = newSVpvn((char *) hash, len);
6969 unsigned char mac[MAXBLOCKSIZE];
7070 unsigned long maclen, outlen;
7171 int rv;
72 char out[MAXBLOCKSIZE*2];
72 char out[MAXBLOCKSIZE*2+1];
7373
7474 maclen = sizeof(mac);
7575 rv = blake2bmac_done(self, mac, &maclen);
7676 if (rv != CRYPT_OK) croak("FATAL: blake2bmac_done failed: %s", error_to_string(rv));
7777 outlen = sizeof(out);
7878 if (ix == 3) {
79 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
79 rv = base64url_encode(mac, maclen, out, &outlen);
8080 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8181 RETVAL = newSVpvn(out, outlen);
8282 }
8383 if (ix == 2) {
84 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
84 rv = base64_encode(mac, maclen, out, &outlen);
8585 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
8686 RETVAL = newSVpvn(out, outlen);
8787 }
8888 if (ix == 1) {
89 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
89 rv = base16_encode(mac, maclen, out, &outlen, 0);
9090 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9191 RETVAL = newSVpvn(out, outlen);
9292 }
129129
130130 outlen = sizeof(out);
131131 if (ix == 3) {
132 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
132 rv = base64url_encode(mac, len, out, &outlen);
133133 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
134134 RETVAL = newSVpvn((char *) out, outlen);
135135 }
136136 else if (ix == 2) {
137 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
139 RETVAL = newSVpvn((char *) out, outlen);
139 RETVAL = newSVpvn(out, outlen);
140140 }
141141 else if (ix == 1) {
142 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base16_encode(mac, len, out, &outlen, 0);
143143 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else {
147147 RETVAL = newSVpvn((char *) mac, len);
6969 unsigned char mac[MAXBLOCKSIZE];
7070 unsigned long maclen, outlen;
7171 int rv;
72 char out[MAXBLOCKSIZE*2];
72 char out[MAXBLOCKSIZE*2+1];
7373
7474 maclen = sizeof(mac);
7575 rv = blake2smac_done(self, mac, &maclen);
7676 if (rv != CRYPT_OK) croak("FATAL: blake2smac_done failed: %s", error_to_string(rv));
7777 outlen = sizeof(out);
7878 if (ix == 3) {
79 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
79 rv = base64url_encode(mac, maclen, out, &outlen);
8080 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8181 RETVAL = newSVpvn(out, outlen);
8282 }
8383 if (ix == 2) {
84 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
84 rv = base64_encode(mac, maclen, out, &outlen);
8585 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
8686 RETVAL = newSVpvn(out, outlen);
8787 }
8888 if (ix == 1) {
89 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
89 rv = base16_encode(mac, maclen, out, &outlen, 0);
9090 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9191 RETVAL = newSVpvn(out, outlen);
9292 }
129129
130130 outlen = sizeof(out);
131131 if (ix == 3) {
132 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
132 rv = base64url_encode(mac, len, out, &outlen);
133133 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
134134 RETVAL = newSVpvn((char *) out, outlen);
135135 }
136136 else if (ix == 2) {
137 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
139 RETVAL = newSVpvn((char *) out, outlen);
139 RETVAL = newSVpvn(out, outlen);
140140 }
141141 else if (ix == 1) {
142 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base16_encode(mac, len, out, &outlen, 0);
143143 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else {
147147 RETVAL = newSVpvn((char *) mac, len);
7373 unsigned char mac[MAXBLOCKSIZE];
7474 unsigned long maclen, outlen;
7575 int rv;
76 char out[MAXBLOCKSIZE*2];
76 char out[MAXBLOCKSIZE*2+1];
7777
7878 maclen = sizeof(mac);
7979 rv = f9_done(self, mac, &maclen);
8080 if (rv != CRYPT_OK) croak("FATAL: f9_done failed: %s", error_to_string(rv));
8181 outlen = sizeof(out);
8282 if (ix == 3) {
83 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
83 rv = base64url_encode(mac, maclen, out, &outlen);
8484 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8585 RETVAL = newSVpvn(out, outlen);
8686 }
8787 if (ix == 2) {
88 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
88 rv = base64_encode(mac, maclen, out, &outlen);
8989 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
9090 RETVAL = newSVpvn(out, outlen);
9191 }
9292 if (ix == 1) {
93 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
93 rv = base16_encode(mac, maclen, out, &outlen, 0);
9494 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9595 RETVAL = newSVpvn(out, outlen);
9696 }
134134
135135 outlen = sizeof(out);
136136 if (ix == 3) {
137 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64url_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
139139 RETVAL = newSVpvn((char *) out, outlen);
140140 }
141141 else if (ix == 2) {
142 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base64_encode(mac, len, out, &outlen);
143143 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else if (ix == 1) {
147 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
147 rv = base16_encode(mac, len, out, &outlen, 0);
148148 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
149 RETVAL = newSVpvn((char *) out, outlen);
149 RETVAL = newSVpvn(out, outlen);
150150 }
151151 else {
152152 RETVAL = newSVpvn((char *) mac, len);
7373 unsigned char mac[MAXBLOCKSIZE];
7474 unsigned long maclen, outlen;
7575 int rv;
76 char out[MAXBLOCKSIZE*2];
76 char out[MAXBLOCKSIZE*2+1];
7777
7878 maclen = sizeof(mac);
7979 rv = hmac_done(self, mac, &maclen);
8080 if (rv != CRYPT_OK) croak("FATAL: hmac_done failed: %s", error_to_string(rv));
8181 outlen = sizeof(out);
8282 if (ix == 3) {
83 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
83 rv = base64url_encode(mac, maclen, out, &outlen);
8484 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8585 RETVAL = newSVpvn(out, outlen);
8686 }
8787 if (ix == 2) {
88 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
88 rv = base64_encode(mac, maclen, out, &outlen);
8989 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
9090 RETVAL = newSVpvn(out, outlen);
9191 }
9292 if (ix == 1) {
93 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
93 rv = base16_encode(mac, maclen, out, &outlen, 0);
9494 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9595 RETVAL = newSVpvn(out, outlen);
9696 }
134134
135135 outlen = sizeof(out);
136136 if (ix == 3) {
137 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64url_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
139139 RETVAL = newSVpvn((char *) out, outlen);
140140 }
141141 else if (ix == 2) {
142 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base64_encode(mac, len, out, &outlen);
143143 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else if (ix == 1) {
147 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
147 rv = base16_encode(mac, len, out, &outlen, 0);
148148 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
149 RETVAL = newSVpvn((char *) out, outlen);
149 RETVAL = newSVpvn(out, outlen);
150150 }
151151 else {
152152 RETVAL = newSVpvn((char *) mac, len);
7373 unsigned char mac[MAXBLOCKSIZE];
7474 unsigned long maclen, outlen;
7575 int rv;
76 char out[MAXBLOCKSIZE*2];
76 char out[MAXBLOCKSIZE*2+1];
7777
7878 maclen = sizeof(mac);
7979 rv = omac_done(self, mac, &maclen);
8080 if (rv != CRYPT_OK) croak("FATAL: omac_done failed: %s", error_to_string(rv));
8181 outlen = sizeof(out);
8282 if (ix == 3) {
83 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
83 rv = base64url_encode(mac, maclen, out, &outlen);
8484 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8585 RETVAL = newSVpvn(out, outlen);
8686 }
8787 if (ix == 2) {
88 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
88 rv = base64_encode(mac, maclen, out, &outlen);
8989 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
9090 RETVAL = newSVpvn(out, outlen);
9191 }
9292 if (ix == 1) {
93 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
93 rv = base16_encode(mac, maclen, out, &outlen, 0);
9494 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9595 RETVAL = newSVpvn(out, outlen);
9696 }
134134
135135 outlen = sizeof(out);
136136 if (ix == 3) {
137 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64url_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
139139 RETVAL = newSVpvn((char *) out, outlen);
140140 }
141141 else if (ix == 2) {
142 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base64_encode(mac, len, out, &outlen);
143143 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else if (ix == 1) {
147 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
147 rv = base16_encode(mac, len, out, &outlen, 0);
148148 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
149 RETVAL = newSVpvn((char *) out, outlen);
149 RETVAL = newSVpvn(out, outlen);
150150 }
151151 else {
152152 RETVAL = newSVpvn((char *) mac, len);
7373 unsigned char mac[MAXBLOCKSIZE];
7474 unsigned long maclen, outlen;
7575 int rv;
76 char out[MAXBLOCKSIZE*2];
76 char out[MAXBLOCKSIZE*2+1];
7777
7878 maclen = sizeof(mac);
7979 rv = pmac_done(self, mac, &maclen);
8080 if (rv != CRYPT_OK) croak("FATAL: pmac_done failed: %s", error_to_string(rv));
8181 outlen = sizeof(out);
8282 if (ix == 3) {
83 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
83 rv = base64url_encode(mac, maclen, out, &outlen);
8484 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8585 RETVAL = newSVpvn(out, outlen);
8686 }
8787 if (ix == 2) {
88 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
88 rv = base64_encode(mac, maclen, out, &outlen);
8989 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
9090 RETVAL = newSVpvn(out, outlen);
9191 }
9292 if (ix == 1) {
93 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
93 rv = base16_encode(mac, maclen, out, &outlen, 0);
9494 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9595 RETVAL = newSVpvn(out, outlen);
9696 }
134134
135135 outlen = sizeof(out);
136136 if (ix == 3) {
137 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64url_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
139139 RETVAL = newSVpvn((char *) out, outlen);
140140 }
141141 else if (ix == 2) {
142 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base64_encode(mac, len, out, &outlen);
143143 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else if (ix == 1) {
147 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
147 rv = base16_encode(mac, len, out, &outlen, 0);
148148 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
149 RETVAL = newSVpvn((char *) out, outlen);
149 RETVAL = newSVpvn(out, outlen);
150150 }
151151 else {
152152 RETVAL = newSVpvn((char *) mac, len);
6969 unsigned char mac[MAXBLOCKSIZE];
7070 unsigned long maclen, outlen;
7171 int rv;
72 char out[MAXBLOCKSIZE*2];
72 char out[MAXBLOCKSIZE*2+1];
7373
7474 maclen = 16;
7575 rv = pelican_done(self, mac);
7676 if (rv != CRYPT_OK) croak("FATAL: pelican_done failed: %s", error_to_string(rv));
7777 outlen = sizeof(out);
7878 if (ix == 3) {
79 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
79 rv = base64url_encode(mac, maclen, out, &outlen);
8080 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8181 RETVAL = newSVpvn(out, outlen);
8282 }
8383 if (ix == 2) {
84 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
84 rv = base64_encode(mac, maclen, out, &outlen);
8585 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
8686 RETVAL = newSVpvn(out, outlen);
8787 }
8888 if (ix == 1) {
89 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
89 rv = base16_encode(mac, maclen, out, &outlen, 0);
9090 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9191 RETVAL = newSVpvn(out, outlen);
9292 }
129129
130130 outlen = sizeof(out);
131131 if (ix == 3) {
132 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
132 rv = base64url_encode(mac, len, out, &outlen);
133133 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
134134 RETVAL = newSVpvn((char *) out, outlen);
135135 }
136136 else if (ix == 2) {
137 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
139 RETVAL = newSVpvn((char *) out, outlen);
139 RETVAL = newSVpvn(out, outlen);
140140 }
141141 else if (ix == 1) {
142 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base16_encode(mac, len, out, &outlen, 0);
143143 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else {
147147 RETVAL = newSVpvn((char *) mac, len);
6969 unsigned char mac[MAXBLOCKSIZE];
7070 unsigned long maclen, outlen;
7171 int rv;
72 char out[MAXBLOCKSIZE*2];
72 char out[MAXBLOCKSIZE*2+1];
7373
7474 maclen = sizeof(mac);
7575 rv = poly1305_done(self, mac, &maclen);
7676 if (rv != CRYPT_OK) croak("FATAL: poly1305_done failed: %s", error_to_string(rv));
7777 outlen = sizeof(out);
7878 if (ix == 3) {
79 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
79 rv = base64url_encode(mac, maclen, out, &outlen);
8080 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8181 RETVAL = newSVpvn(out, outlen);
8282 }
8383 if (ix == 2) {
84 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
84 rv = base64_encode(mac, maclen, out, &outlen);
8585 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
8686 RETVAL = newSVpvn(out, outlen);
8787 }
8888 if (ix == 1) {
89 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
89 rv = base16_encode(mac, maclen, out, &outlen, 0);
9090 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9191 RETVAL = newSVpvn(out, outlen);
9292 }
128128
129129 outlen = sizeof(out);
130130 if (ix == 3) {
131 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
131 rv = base64url_encode(mac, len, out, &outlen);
132132 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
133133 RETVAL = newSVpvn((char *) out, outlen);
134134 }
135135 else if (ix == 2) {
136 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
136 rv = base64_encode(mac, len, out, &outlen);
137137 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
138 RETVAL = newSVpvn((char *) out, outlen);
138 RETVAL = newSVpvn(out, outlen);
139139 }
140140 else if (ix == 1) {
141 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
141 rv = base16_encode(mac, len, out, &outlen, 0);
142142 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
143 RETVAL = newSVpvn((char *) out, outlen);
143 RETVAL = newSVpvn(out, outlen);
144144 }
145145 else {
146146 RETVAL = newSVpvn((char *) mac, len);
7373 unsigned char mac[MAXBLOCKSIZE];
7474 unsigned long maclen, outlen;
7575 int rv;
76 char out[MAXBLOCKSIZE*2];
76 char out[MAXBLOCKSIZE*2+1];
7777
7878 maclen = sizeof(mac);
7979 rv = xcbc_done(self, mac, &maclen);
8080 if (rv != CRYPT_OK) croak("FATAL: xcbc_done failed: %s", error_to_string(rv));
8181 outlen = sizeof(out);
8282 if (ix == 3) {
83 rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen);
83 rv = base64url_encode(mac, maclen, out, &outlen);
8484 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
8585 RETVAL = newSVpvn(out, outlen);
8686 }
8787 if (ix == 2) {
88 rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen);
88 rv = base64_encode(mac, maclen, out, &outlen);
8989 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
9090 RETVAL = newSVpvn(out, outlen);
9191 }
9292 if (ix == 1) {
93 rv = _base16_encode(mac, maclen, (unsigned char *)out, &outlen);
93 rv = base16_encode(mac, maclen, out, &outlen, 0);
9494 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
9595 RETVAL = newSVpvn(out, outlen);
9696 }
134134
135135 outlen = sizeof(out);
136136 if (ix == 3) {
137 rv = base64url_encode(mac, len, (unsigned char *)out, &outlen);
137 rv = base64url_encode(mac, len, out, &outlen);
138138 if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv));
139139 RETVAL = newSVpvn((char *) out, outlen);
140140 }
141141 else if (ix == 2) {
142 rv = base64_encode(mac, len, (unsigned char *)out, &outlen);
142 rv = base64_encode(mac, len, out, &outlen);
143143 if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv));
144 RETVAL = newSVpvn((char *) out, outlen);
144 RETVAL = newSVpvn(out, outlen);
145145 }
146146 else if (ix == 1) {
147 rv = _base16_encode(mac, len, (unsigned char *)out, &outlen);
147 rv = base16_encode(mac, len, out, &outlen, 0);
148148 if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv));
149 RETVAL = newSVpvn((char *) out, outlen);
149 RETVAL = newSVpvn(out, outlen);
150150 }
151151 else {
152152 RETVAL = newSVpvn((char *) mac, len);
201201 not_used = hv_store(rv_hash, "curve_oid", 9, oid, 0);
202202
203203 /* curve name -> "curve_name" */
204 if ((h = get_hv("Crypt::PK::ECC::curve2ltc", 0)) != NULL) {
204 if ((h = get_hv("Crypt::PK::ECC::curve_oid2name", 0)) != NULL) {
205205 pref = hv_fetch(h, oid_ptr, (U32)strlen(oid_ptr), 0);
206206 if (pref) {
207207 cname_ptr = SvPV(*pref, cname_len);
208208 cname = newSVpv(cname_ptr, cname_len);
209209 cname_ptr = SvPVX(cname);
210 for (i=0; i<cname_len && cname_ptr[i]>0; i++) cname_ptr[i] = toLOWER(cname_ptr[i]);
211210 not_used = hv_store(rv_hash, "curve_name", 10, cname, 0);
212211 }
213212 }
104104 IV curpid = (IV)PerlProc_getpid();
105105 int rv_len, rv;
106106 unsigned long len;
107 unsigned char *rdata, *tmp;
107 unsigned char *tmp;
108 char *rdata;
108109 unsigned char entropy_buf[40];
109110
110111 if (output_len == 0) {
123124 if (tmp == NULL) croak("FATAL: Newz failed");
124125 rv_len = (self->desc->read)(tmp, (unsigned long)output_len, &self->state);
125126 if ((UV)rv_len != output_len) croak("FATAL: PRNG_read failed");
126 RETVAL = NEWSV(0, output_len * 2); /* avoid zero! */
127 RETVAL = NEWSV(0, output_len * 2 + 1); /* avoid zero! */
127128 SvPOK_only(RETVAL);
128 SvCUR_set(RETVAL, output_len * 2);
129 rdata = (unsigned char *)SvPVX(RETVAL);
130 len = output_len * 2;
131 rv = _base16_encode(tmp, output_len, rdata, &len);
129 SvCUR_set(RETVAL, output_len * 2 + 1);
130 rdata = SvPVX(RETVAL);
131 len = output_len * 2 + 1;
132 rv = base16_encode(tmp, output_len, rdata, &len, 0);
133 SvCUR_set(RETVAL, len);
132134 Safefree(tmp);
133135 if (rv != CRYPT_OK) {
134136 SvREFCNT_dec(RETVAL);
144146 RETVAL = NEWSV(0, output_len * 2); /* avoid zero! */
145147 SvPOK_only(RETVAL);
146148 SvCUR_set(RETVAL, output_len * 2);
147 rdata = (unsigned char *)SvPVX(RETVAL);
149 rdata = SvPVX(RETVAL);
148150 len = output_len * 2;
149151 rv = ix == 3 ? base64url_encode(tmp, output_len, rdata, &len) :
150152 base64_encode(tmp, output_len, rdata, &len);
160162 RETVAL = NEWSV(0, output_len); /* avoid zero! */
161163 SvPOK_only(RETVAL);
162164 SvCUR_set(RETVAL, output_len);
163 rdata = (unsigned char *)SvPVX(RETVAL);
164 rv_len = (self->desc->read)(rdata, (unsigned long)output_len, &self->state);
165 rdata = SvPVX(RETVAL);
166 rv_len = (self->desc->read)((unsigned char*)rdata, (unsigned long)output_len, &self->state);
165167 if ((UV)rv_len != output_len) {
166168 SvREFCNT_dec(RETVAL);
167169 croak("FATAL: PRNG_read failed");
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 ### not used
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::Checksum Exporter);
77 our %EXPORT_TAGS = ( all => [qw( adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::Checksum Exporter);
77 our %EXPORT_TAGS = ( all => [qw( crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Cipher);
99
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( chaes chaes_hex chaes_b64 chaes_b64u chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak384 keccak384_hex keccak384_b64 keccak384_b64u keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( keccak512 keccak512_hex keccak512_b64 keccak512_b64u keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( md2 md2_hex md2_b64 md2_b64u md2_file md2_file_hex md2_file_b64 md2_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( md4 md4_hex md4_b64 md4_b64u md4_file md4_file_hex md4_file_b64 md4_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( md5 md5_hex md5_b64 md5_b64u md5_file md5_file_hex md5_file_b64 md5_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha1 sha1_hex sha1_b64 sha1_b64u sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha224 sha224_hex sha224_b64 sha224_b64u sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha256 sha256_hex sha256_b64 sha256_b64u sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha384 sha384_hex sha384_b64 sha384_b64u sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha512 sha512_hex sha512_b64 sha512_b64u sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha512_224 sha512_224_hex sha512_224_b64 sha512_224_b64u sha512_224_file sha512_224_file_hex sha512_224_file_b64 sha512_224_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( tiger192 tiger192_hex tiger192_b64 tiger192_b64u tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Digest Exporter);
99 our %EXPORT_TAGS = ( all => [qw( whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw(pbkdf1 pbkdf2 hkdf hkdf_expand hkdf_extract)] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2b blake2b_hex blake2b_b64 blake2b_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( f9 f9_hex f9_b64 f9_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( hmac hmac_hex hmac_b64 hmac_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 omac_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( pmac pmac_hex pmac_b64 pmac_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( pelican pelican_hex pelican_b64 pelican_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( poly1305 poly1305_hex poly1305_b64 poly1305_b64u )] );
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use base qw(Crypt::Mac Exporter);
99 our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 xcbc_b64u )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 use Carp 'croak';
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.059';
6 our $VERSION = '0.060';
77
88 use Crypt::Cipher;
99
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 ### not used
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( dh_shared_secret )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( dsa_encrypt dsa_decrypt dsa_sign_message dsa_verify_message dsa_sign_hash dsa_verify_hash )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( ecc_encrypt ecc_decrypt ecc_sign_message ecc_verify_message ecc_sign_hash ecc_verify_hash ecc_shared_secret )] );
1515 use Crypt::Misc qw(read_rawfile encode_b64u decode_b64u encode_b64 decode_b64 pem_to_der der_to_pem);
1616 use Crypt::PK;
1717
18 our %curve = (
19 # extra curves not recognized by libtomcrypt
20 'wap-wsg-idm-ecid-wtls8' => {
21 prime => "FFFFFFFFFFFFFFFFFFFFFFFFFDE7",
22 A => "0000000000000000000000000000",
23 B => "0000000000000000000000000003",
24 order => "0100000000000001ECEA551AD837E9",
25 Gx => "0000000000000000000000000001",
26 Gy => "0000000000000000000000000002",
27 cofactor => 1,
28 oid => '2.23.43.1.4.8',
29 },
30 'wap-wsg-idm-ecid-wtls9' => {
31 prime => "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC808F",
32 A => "0000000000000000000000000000000000000000",
33 B => "0000000000000000000000000000000000000003",
34 order => "0100000000000000000001CDC98AE0E2DE574ABF33",
35 Gx => "0000000000000000000000000000000000000001",
36 Gy => "0000000000000000000000000000000000000002",
37 cofactor => 1,
38 oid => '2.23.43.1.4.9',
39 },
18 our %curve = ( # must be "our" as we use it from XS code
19 # extra curves not recognized by libtomcrypt
20 'wap-wsg-idm-ecid-wtls8' => {
21 prime => "FFFFFFFFFFFFFFFFFFFFFFFFFDE7",
22 A => "0000000000000000000000000000",
23 B => "0000000000000000000000000003",
24 order => "0100000000000001ECEA551AD837E9",
25 Gx => "0000000000000000000000000001",
26 Gy => "0000000000000000000000000002",
27 cofactor => 1,
28 oid => '2.23.43.1.4.8',
29 },
30 'wap-wsg-idm-ecid-wtls9' => {
31 prime => "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC808F",
32 A => "0000000000000000000000000000000000000000",
33 B => "0000000000000000000000000000000000000003",
34 order => "0100000000000000000001CDC98AE0E2DE574ABF33",
35 Gx => "0000000000000000000000000000000000000001",
36 Gy => "0000000000000000000000000000000000000002",
37 cofactor => 1,
38 oid => '2.23.43.1.4.9',
39 },
40 # some unusual openssl names
41 "wap-wsg-idm-ecid-wtls6" => 'secp112r1',
42 "wap-wsg-idm-ecid-wtls7" => 'secp160r2',
43 "wap-wsg-idm-ecid-wtls12" => 'secp224r1',
4044 );
4145
42 my %jwk2curve = (
43 'P-192' => 'secp192r1',
44 'P-224' => 'secp224r1',
45 'P-256' => 'secp256r1',
46 'P-384' => 'secp384r1',
47 'P-521' => 'secp521r1',
46 our %curve_oid2name = ( # must be "our" as we use it from XS code
47 # the following are used to derive curve_name from OID in key2hash()
48 "1.2.840.10045.3.1.1" => "secp192r1",
49 "1.2.840.10045.3.1.2" => "prime192v2",
50 "1.2.840.10045.3.1.3" => "prime192v3",
51 "1.2.840.10045.3.1.4" => "prime239v1",
52 "1.2.840.10045.3.1.5" => "prime239v2",
53 "1.2.840.10045.3.1.6" => "prime239v3",
54 "1.2.840.10045.3.1.7" => "secp256r1",
55 "1.3.132.0.6" => "secp112r1",
56 "1.3.132.0.7" => "secp112r2",
57 "1.3.132.0.8" => "secp160r1",
58 "1.3.132.0.9" => "secp160k1",
59 "1.3.132.0.10" => "secp256k1",
60 "1.3.132.0.28" => "secp128r1",
61 "1.3.132.0.29" => "secp128r2",
62 "1.3.132.0.30" => "secp160r2",
63 "1.3.132.0.31" => "secp192k1",
64 "1.3.132.0.32" => "secp224k1",
65 "1.3.132.0.33" => "secp224r1",
66 "1.3.132.0.34" => "secp384r1",
67 "1.3.132.0.35" => "secp521r1",
68 "1.3.36.3.3.2.8.1.1.1" => "brainpoolp160r1",
69 "1.3.36.3.3.2.8.1.1.2" => "brainpoolp160t1",
70 "1.3.36.3.3.2.8.1.1.3" => "brainpoolp192r1",
71 "1.3.36.3.3.2.8.1.1.4" => "brainpoolp192t1",
72 "1.3.36.3.3.2.8.1.1.5" => "brainpoolp224r1",
73 "1.3.36.3.3.2.8.1.1.6" => "brainpoolp224t1",
74 "1.3.36.3.3.2.8.1.1.7" => "brainpoolp256r1",
75 "1.3.36.3.3.2.8.1.1.8" => "brainpoolp256t1",
76 "1.3.36.3.3.2.8.1.1.9" => "brainpoolp320r1",
77 "1.3.36.3.3.2.8.1.1.10" => "brainpoolp320t1",
78 "1.3.36.3.3.2.8.1.1.11" => "brainpoolp384r1",
79 "1.3.36.3.3.2.8.1.1.12" => "brainpoolp384t1",
80 "1.3.36.3.3.2.8.1.1.13" => "brainpoolp512r1",
81 "1.3.36.3.3.2.8.1.1.14" => "brainpoolp512t1",
4882 );
4983
5084 my %curve2jwk = (
85 # necessary for conversion of curve_name_or_OID >> P-NNN
5186 '1.2.840.10045.3.1.1' => 'P-192', # secp192r1
5287 '1.3.132.0.33' => 'P-224', # secp224r1
5388 '1.2.840.10045.3.1.7' => 'P-256', # secp256r1
65100 'secp256r1' => 'P-256',
66101 'secp384r1' => 'P-384',
67102 'secp521r1' => 'P-521',
68 );
69
70 our %curve2ltc = ( # must be "our" as we use it from XS code
71 # OIDs
72 "1.2.840.10045.3.1.1" => "SECP192R1",
73 "1.2.840.10045.3.1.2" => "PRIME192V2",
74 "1.2.840.10045.3.1.3" => "PRIME192V3",
75 "1.2.840.10045.3.1.4" => "PRIME239V1",
76 "1.2.840.10045.3.1.5" => "PRIME239V2",
77 "1.2.840.10045.3.1.6" => "PRIME239V3",
78 "1.2.840.10045.3.1.7" => "SECP256R1",
79 "1.3.132.0.10" => "SECP256K1",
80 "1.3.132.0.28" => "SECP128R1",
81 "1.3.132.0.29" => "SECP128R2",
82 "1.3.132.0.30" => "SECP160R2",
83 "1.3.132.0.31" => "SECP192K1",
84 "1.3.132.0.32" => "SECP224K1",
85 "1.3.132.0.33" => "SECP224R1",
86 "1.3.132.0.34" => "SECP384R1",
87 "1.3.132.0.35" => "SECP521R1",
88 "1.3.132.0.6" => "SECP112R1",
89 "1.3.132.0.7" => "SECP112R2",
90 "1.3.132.0.8" => "SECP160R1",
91 "1.3.132.0.9" => "SECP160K1",
92 "1.3.36.3.3.2.8.1.1.1" => "BRAINPOOLP160R1",
93 "1.3.36.3.3.2.8.1.1.11" => "BRAINPOOLP384R1",
94 "1.3.36.3.3.2.8.1.1.13" => "BRAINPOOLP512R1",
95 "1.3.36.3.3.2.8.1.1.3" => "BRAINPOOLP192R1",
96 "1.3.36.3.3.2.8.1.1.5" => "BRAINPOOLP224R1",
97 "1.3.36.3.3.2.8.1.1.7" => "BRAINPOOLP256R1",
98 "1.3.36.3.3.2.8.1.1.9" => "BRAINPOOLP320R1",
99 "1.3.36.3.3.2.8.1.1.10" => "BRAINPOOLP320T1",
100 "1.3.36.3.3.2.8.1.1.12" => "BRAINPOOLP384T1",
101 "1.3.36.3.3.2.8.1.1.14" => "BRAINPOOLP512T1",
102 "1.3.36.3.3.2.8.1.1.2" => "BRAINPOOLP160T1",
103 "1.3.36.3.3.2.8.1.1.4" => "BRAINPOOLP192T1",
104 "1.3.36.3.3.2.8.1.1.6" => "BRAINPOOLP224T1",
105 "1.3.36.3.3.2.8.1.1.8" => "BRAINPOOLP256T1",
106 # JWT names
107 "P-192" => "SECP192R1",
108 "P-224" => "SECP224R1",
109 "P-256" => "SECP256R1",
110 "P-384" => "SECP384R1",
111 "P-521" => "SECP521R1",
112 # openssl names
113 "brainpoolp160r1" => "BRAINPOOLP160R1",
114 "brainpoolp192r1" => "BRAINPOOLP192R1",
115 "brainpoolp224r1" => "BRAINPOOLP224R1",
116 "brainpoolp256r1" => "BRAINPOOLP256R1",
117 "brainpoolp320r1" => "BRAINPOOLP320R1",
118 "brainpoolp384r1" => "BRAINPOOLP384R1",
119 "brainpoolp512r1" => "BRAINPOOLP512R1",
120 "brainpoolp160t1" => "BRAINPOOLP160T1",
121 "brainpoolp192t1" => "BRAINPOOLP192T1",
122 "brainpoolp224t1" => "BRAINPOOLP224T1",
123 "brainpoolp256t1" => "BRAINPOOLP256T1",
124 "brainpoolp320t1" => "BRAINPOOLP320T1",
125 "brainpoolp384t1" => "BRAINPOOLP384T1",
126 "brainpoolp512t1" => "BRAINPOOLP512T1",
127 "nistp192" => "SECP192R1",
128 "nistp224" => "SECP224R1",
129 "nistp256" => "SECP256R1",
130 "nistp384" => "SECP384R1",
131 "nistp521" => "SECP521R1",
132 "prime192v1" => "SECP192R1",
133 "prime192v2" => "PRIME192V2",
134 "prime192v3" => "PRIME192V3",
135 "prime239v1" => "PRIME239V1",
136 "prime239v2" => "PRIME239V2",
137 "prime239v3" => "PRIME239V3",
138 "prime256v1" => "SECP256R1",
139 "secp112r1" => "SECP112R1",
140 "secp112r2" => "SECP112R2",
141 "secp128r1" => "SECP128R1",
142 "secp128r2" => "SECP128R2",
143 "secp160k1" => "SECP160K1",
144 "secp160r1" => "SECP160R1",
145 "secp160r2" => "SECP160R2",
146 "secp192k1" => "SECP192K1",
147 "secp192r1" => "SECP192R1",
148 "secp224k1" => "SECP224K1",
149 "secp224r1" => "SECP224R1",
150 "secp256k1" => "SECP256K1",
151 "secp256r1" => "SECP256R1",
152 "secp384r1" => "SECP384R1",
153 "secp521r1" => "SECP521R1",
154 "wap-wsg-idm-ecid-wtls6" => 'SECP112R1',
155 "wap-wsg-idm-ecid-wtls7" => 'SECP160R2',
156 "wap-wsg-idm-ecid-wtls12" => 'SECP224R1',
157103 );
158104
159105 sub _import_hex {
249195 for (qw/x y d/) {
250196 $key->{$_} = eval { unpack("H*", decode_b64u($key->{$_})) } if exists $key->{$_};
251197 }
252 if (my $curve_name = $jwk2curve{$key->{crv}}) {
253 return $self->_import_hex($key->{x}, $key->{y}, $key->{d}, $curve_name);
254 }
255 # curve is not JWK compliant e.g. P-192 P-224 P-256 P-384 P-521 (we'll try to import anyway)
198 # names P-192 P-224 P-256 P-384 P-521 are recognized by libtomcrypt
256199 return $self->_import_hex($key->{x}, $key->{y}, $key->{d}, $key->{crv});
257200 }
258201 croak "FATAL: unexpected ECC key hash";
290233 for (qw/x y d/) {
291234 $h->{$_} = eval { unpack("H*", decode_b64u($h->{$_})) } if exists $h->{$_};
292235 }
293 if (my $curve_name = $jwk2curve{$h->{crv}}) {
294 return $self->_import_hex($h->{x}, $h->{y}, $h->{d}, $curve_name);
295 }
296 # curve is not JWK compliant e.g. P-192 P-224 P-256 P-384 P-521 (we'll try to import anyway)
236 # names P-192 P-224 P-256 P-384 P-521 are recognized by libtomcrypt
297237 return $self->_import_hex($h->{x}, $h->{y}, $h->{d}, $h->{crv});
298238 }
299239 }
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw(rsa_encrypt rsa_decrypt rsa_sign_message rsa_verify_message rsa_sign_hash rsa_verify_hash)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use Carp;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use base qw(Crypt::PRNG Exporter);
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand)] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings ;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 require XSLoader;
77 XSLoader::load('CryptX', $VERSION);
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.059';
4 our $VERSION = '0.060';
55
66 use CryptX;
77
4141 ltc/math/rand_bn.o ltc/math/rand_prime.o ltc/math/tfm_desc.o ltc/math/fp/ltc_ecc_fp_mulmod.o \
4242 ltc/misc/adler32.o ltc/misc/burn_stack.o ltc/misc/compare_testvector.o ltc/misc/copy_or_zeromem.o \
4343 ltc/misc/crc32.o ltc/misc/error_to_string.o ltc/misc/mem_neq.o ltc/misc/pk_get_oid.o \
44 ltc/misc/zeromem.o ltc/misc/base32/base32_decode.o ltc/misc/base32/base32_encode.o \
45 ltc/misc/base64/base64_decode.o ltc/misc/base64/base64_encode.o ltc/misc/crypt/crypt.o \
46 ltc/misc/crypt/crypt_argchk.o ltc/misc/crypt/crypt_cipher_descriptor.o ltc/misc/crypt/crypt_cipher_is_valid.o \
47 ltc/misc/crypt/crypt_constants.o ltc/misc/crypt/crypt_find_cipher.o ltc/misc/crypt/crypt_find_cipher_any.o \
48 ltc/misc/crypt/crypt_find_cipher_id.o ltc/misc/crypt/crypt_find_hash.o ltc/misc/crypt/crypt_find_hash_any.o \
49 ltc/misc/crypt/crypt_find_hash_id.o ltc/misc/crypt/crypt_find_hash_oid.o ltc/misc/crypt/crypt_find_prng.o \
50 ltc/misc/crypt/crypt_fsa.o ltc/misc/crypt/crypt_hash_descriptor.o ltc/misc/crypt/crypt_hash_is_valid.o \
51 ltc/misc/crypt/crypt_inits.o ltc/misc/crypt/crypt_ltc_mp_descriptor.o ltc/misc/crypt/crypt_prng_descriptor.o \
52 ltc/misc/crypt/crypt_prng_is_valid.o ltc/misc/crypt/crypt_prng_rng_descriptor.o ltc/misc/crypt/crypt_register_all_ciphers.o \
44 ltc/misc/pk_oid_str.o ltc/misc/zeromem.o ltc/misc/base16/base16_decode.o ltc/misc/base16/base16_encode.o \
45 ltc/misc/base32/base32_decode.o ltc/misc/base32/base32_encode.o ltc/misc/base64/base64_decode.o \
46 ltc/misc/base64/base64_encode.o ltc/misc/crypt/crypt.o ltc/misc/crypt/crypt_argchk.o \
47 ltc/misc/crypt/crypt_cipher_descriptor.o ltc/misc/crypt/crypt_cipher_is_valid.o ltc/misc/crypt/crypt_constants.o \
48 ltc/misc/crypt/crypt_find_cipher.o ltc/misc/crypt/crypt_find_cipher_any.o ltc/misc/crypt/crypt_find_cipher_id.o \
49 ltc/misc/crypt/crypt_find_hash.o ltc/misc/crypt/crypt_find_hash_any.o ltc/misc/crypt/crypt_find_hash_id.o \
50 ltc/misc/crypt/crypt_find_hash_oid.o ltc/misc/crypt/crypt_find_prng.o ltc/misc/crypt/crypt_fsa.o \
51 ltc/misc/crypt/crypt_hash_descriptor.o ltc/misc/crypt/crypt_hash_is_valid.o ltc/misc/crypt/crypt_inits.o \
52 ltc/misc/crypt/crypt_ltc_mp_descriptor.o ltc/misc/crypt/crypt_prng_descriptor.o ltc/misc/crypt/crypt_prng_is_valid.o \
53 ltc/misc/crypt/crypt_prng_rng_descriptor.o ltc/misc/crypt/crypt_register_all_ciphers.o \
5354 ltc/misc/crypt/crypt_register_all_hashes.o ltc/misc/crypt/crypt_register_all_prngs.o \
5455 ltc/misc/crypt/crypt_register_cipher.o ltc/misc/crypt/crypt_register_hash.o ltc/misc/crypt/crypt_register_prng.o \
5556 ltc/misc/crypt/crypt_sizes.o ltc/misc/crypt/crypt_unregister_cipher.o ltc/misc/crypt/crypt_unregister_hash.o \
56 ltc/misc/crypt/crypt_unregister_prng.o ltc/misc/hkdf/hkdf.o ltc/misc/pkcs5/pkcs_5_1.o \
57 ltc/misc/pkcs5/pkcs_5_2.o ltc/modes/cbc/cbc_decrypt.o ltc/modes/cbc/cbc_done.o ltc/modes/cbc/cbc_encrypt.o \
57 ltc/misc/crypt/crypt_unregister_prng.o ltc/misc/hkdf/hkdf.o ltc/misc/padding/padding_depad.o \
58 ltc/misc/padding/padding_pad.o ltc/misc/pkcs5/pkcs_5_1.o ltc/misc/pkcs5/pkcs_5_2.o \
59 ltc/modes/cbc/cbc_decrypt.o ltc/modes/cbc/cbc_done.o ltc/modes/cbc/cbc_encrypt.o \
5860 ltc/modes/cbc/cbc_getiv.o ltc/modes/cbc/cbc_setiv.o ltc/modes/cbc/cbc_start.o ltc/modes/cfb/cfb_decrypt.o \
5961 ltc/modes/cfb/cfb_done.o ltc/modes/cfb/cfb_encrypt.o ltc/modes/cfb/cfb_getiv.o ltc/modes/cfb/cfb_setiv.o \
6062 ltc/modes/cfb/cfb_start.o ltc/modes/ctr/ctr_decrypt.o ltc/modes/ctr/ctr_done.o ltc/modes/ctr/ctr_encrypt.o \
99101 ltc/pk/dsa/dsa_set_pqg_dsaparam.o ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_sign_hash.o \
100102 ltc/pk/dsa/dsa_verify_hash.o ltc/pk/dsa/dsa_verify_key.o ltc/pk/ecc/ecc.o ltc/pk/ecc/ecc_ansi_x963_export.o \
101103 ltc/pk/ecc/ecc_ansi_x963_import.o ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.o \
102 ltc/pk/ecc/ecc_export.o ltc/pk/ecc/ecc_export_openssl.o ltc/pk/ecc/ecc_free.o ltc/pk/ecc/ecc_get_key.o \
103 ltc/pk/ecc/ecc_get_set.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o ltc/pk/ecc/ecc_import_openssl.o \
104 ltc/pk/ecc/ecc_export.o ltc/pk/ecc/ecc_export_openssl.o ltc/pk/ecc/ecc_free.o ltc/pk/ecc/ecc_get_curve.o \
105 ltc/pk/ecc/ecc_get_key.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o ltc/pk/ecc/ecc_import_openssl.o \
104106 ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o ltc/pk/ecc/ecc_make_key.o \
105107 ltc/pk/ecc/ecc_set_dp.o ltc/pk/ecc/ecc_set_dp_internal.o ltc/pk/ecc/ecc_set_key.o \
106108 ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o \
4444 ltc/math/rand_bn.obj ltc/math/rand_prime.obj ltc/math/tfm_desc.obj ltc/math/fp/ltc_ecc_fp_mulmod.obj \
4545 ltc/misc/adler32.obj ltc/misc/burn_stack.obj ltc/misc/compare_testvector.obj ltc/misc/copy_or_zeromem.obj \
4646 ltc/misc/crc32.obj ltc/misc/error_to_string.obj ltc/misc/mem_neq.obj ltc/misc/pk_get_oid.obj \
47 ltc/misc/zeromem.obj ltc/misc/base32/base32_decode.obj ltc/misc/base32/base32_encode.obj \
48 ltc/misc/base64/base64_decode.obj ltc/misc/base64/base64_encode.obj ltc/misc/crypt/crypt.obj \
49 ltc/misc/crypt/crypt_argchk.obj ltc/misc/crypt/crypt_cipher_descriptor.obj ltc/misc/crypt/crypt_cipher_is_valid.obj \
47 ltc/misc/pk_oid_str.obj ltc/misc/zeromem.obj ltc/misc/base16/base16_decode.obj ltc/misc/base16/base16_encode.obj \
48 ltc/misc/base32/base32_decode.obj ltc/misc/base32/base32_encode.obj ltc/misc/base64/base64_decode.obj \
49 ltc/misc/base64/base64_encode.obj ltc/misc/crypt/crypt.obj ltc/misc/crypt/crypt_argchk.obj \
50 ltc/misc/crypt/crypt_cipher_descriptor.obj ltc/misc/crypt/crypt_cipher_is_valid.obj \
5051 ltc/misc/crypt/crypt_constants.obj ltc/misc/crypt/crypt_find_cipher.obj ltc/misc/crypt/crypt_find_cipher_any.obj \
5152 ltc/misc/crypt/crypt_find_cipher_id.obj ltc/misc/crypt/crypt_find_hash.obj ltc/misc/crypt/crypt_find_hash_any.obj \
5253 ltc/misc/crypt/crypt_find_hash_id.obj ltc/misc/crypt/crypt_find_hash_oid.obj ltc/misc/crypt/crypt_find_prng.obj \
5758 ltc/misc/crypt/crypt_register_all_prngs.obj ltc/misc/crypt/crypt_register_cipher.obj \
5859 ltc/misc/crypt/crypt_register_hash.obj ltc/misc/crypt/crypt_register_prng.obj ltc/misc/crypt/crypt_sizes.obj \
5960 ltc/misc/crypt/crypt_unregister_cipher.obj ltc/misc/crypt/crypt_unregister_hash.obj \
60 ltc/misc/crypt/crypt_unregister_prng.obj ltc/misc/hkdf/hkdf.obj ltc/misc/pkcs5/pkcs_5_1.obj \
61 ltc/misc/pkcs5/pkcs_5_2.obj ltc/modes/cbc/cbc_decrypt.obj ltc/modes/cbc/cbc_done.obj \
62 ltc/modes/cbc/cbc_encrypt.obj ltc/modes/cbc/cbc_getiv.obj ltc/modes/cbc/cbc_setiv.obj \
63 ltc/modes/cbc/cbc_start.obj ltc/modes/cfb/cfb_decrypt.obj ltc/modes/cfb/cfb_done.obj \
64 ltc/modes/cfb/cfb_encrypt.obj ltc/modes/cfb/cfb_getiv.obj ltc/modes/cfb/cfb_setiv.obj \
65 ltc/modes/cfb/cfb_start.obj ltc/modes/ctr/ctr_decrypt.obj ltc/modes/ctr/ctr_done.obj \
66 ltc/modes/ctr/ctr_encrypt.obj ltc/modes/ctr/ctr_getiv.obj ltc/modes/ctr/ctr_setiv.obj \
67 ltc/modes/ctr/ctr_start.obj ltc/modes/ecb/ecb_decrypt.obj ltc/modes/ecb/ecb_done.obj \
68 ltc/modes/ecb/ecb_encrypt.obj ltc/modes/ecb/ecb_start.obj ltc/modes/ofb/ofb_decrypt.obj \
69 ltc/modes/ofb/ofb_done.obj ltc/modes/ofb/ofb_encrypt.obj ltc/modes/ofb/ofb_getiv.obj \
70 ltc/modes/ofb/ofb_setiv.obj ltc/modes/ofb/ofb_start.obj ltc/pk/asn1/der/bit/der_decode_bit_string.obj \
71 ltc/pk/asn1/der/bit/der_decode_raw_bit_string.obj ltc/pk/asn1/der/bit/der_encode_bit_string.obj \
72 ltc/pk/asn1/der/bit/der_encode_raw_bit_string.obj ltc/pk/asn1/der/bit/der_length_bit_string.obj \
73 ltc/pk/asn1/der/boolean/der_decode_boolean.obj ltc/pk/asn1/der/boolean/der_encode_boolean.obj \
74 ltc/pk/asn1/der/boolean/der_length_boolean.obj ltc/pk/asn1/der/choice/der_decode_choice.obj \
75 ltc/pk/asn1/der/custom_type/der_decode_custom_type.obj ltc/pk/asn1/der/custom_type/der_encode_custom_type.obj \
76 ltc/pk/asn1/der/custom_type/der_length_custom_type.obj ltc/pk/asn1/der/general/der_asn1_maps.obj \
77 ltc/pk/asn1/der/general/der_decode_asn1_identifier.obj ltc/pk/asn1/der/general/der_decode_asn1_length.obj \
78 ltc/pk/asn1/der/general/der_encode_asn1_identifier.obj ltc/pk/asn1/der/general/der_encode_asn1_length.obj \
79 ltc/pk/asn1/der/general/der_length_asn1_identifier.obj ltc/pk/asn1/der/general/der_length_asn1_length.obj \
80 ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.obj ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.obj \
81 ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.obj ltc/pk/asn1/der/ia5/der_decode_ia5_string.obj \
82 ltc/pk/asn1/der/ia5/der_encode_ia5_string.obj ltc/pk/asn1/der/ia5/der_length_ia5_string.obj \
83 ltc/pk/asn1/der/integer/der_decode_integer.obj ltc/pk/asn1/der/integer/der_encode_integer.obj \
84 ltc/pk/asn1/der/integer/der_length_integer.obj ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.obj \
85 ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.obj ltc/pk/asn1/der/object_identifier/der_length_object_identifier.obj \
86 ltc/pk/asn1/der/octet/der_decode_octet_string.obj ltc/pk/asn1/der/octet/der_encode_octet_string.obj \
87 ltc/pk/asn1/der/octet/der_length_octet_string.obj ltc/pk/asn1/der/printable_string/der_decode_printable_string.obj \
88 ltc/pk/asn1/der/printable_string/der_encode_printable_string.obj ltc/pk/asn1/der/printable_string/der_length_printable_string.obj \
89 ltc/pk/asn1/der/sequence/der_decode_sequence_ex.obj ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.obj \
90 ltc/pk/asn1/der/sequence/der_decode_sequence_multi.obj ltc/pk/asn1/der/sequence/der_encode_sequence_ex.obj \
91 ltc/pk/asn1/der/sequence/der_encode_sequence_multi.obj ltc/pk/asn1/der/sequence/der_length_sequence.obj \
92 ltc/pk/asn1/der/sequence/der_sequence_free.obj ltc/pk/asn1/der/sequence/der_sequence_shrink.obj \
93 ltc/pk/asn1/der/set/der_encode_set.obj ltc/pk/asn1/der/set/der_encode_setof.obj ltc/pk/asn1/der/short_integer/der_decode_short_integer.obj \
61 ltc/misc/crypt/crypt_unregister_prng.obj ltc/misc/hkdf/hkdf.obj ltc/misc/padding/padding_depad.obj \
62 ltc/misc/padding/padding_pad.obj ltc/misc/pkcs5/pkcs_5_1.obj ltc/misc/pkcs5/pkcs_5_2.obj \
63 ltc/modes/cbc/cbc_decrypt.obj ltc/modes/cbc/cbc_done.obj ltc/modes/cbc/cbc_encrypt.obj \
64 ltc/modes/cbc/cbc_getiv.obj ltc/modes/cbc/cbc_setiv.obj ltc/modes/cbc/cbc_start.obj \
65 ltc/modes/cfb/cfb_decrypt.obj ltc/modes/cfb/cfb_done.obj ltc/modes/cfb/cfb_encrypt.obj \
66 ltc/modes/cfb/cfb_getiv.obj ltc/modes/cfb/cfb_setiv.obj ltc/modes/cfb/cfb_start.obj \
67 ltc/modes/ctr/ctr_decrypt.obj ltc/modes/ctr/ctr_done.obj ltc/modes/ctr/ctr_encrypt.obj \
68 ltc/modes/ctr/ctr_getiv.obj ltc/modes/ctr/ctr_setiv.obj ltc/modes/ctr/ctr_start.obj \
69 ltc/modes/ecb/ecb_decrypt.obj ltc/modes/ecb/ecb_done.obj ltc/modes/ecb/ecb_encrypt.obj \
70 ltc/modes/ecb/ecb_start.obj ltc/modes/ofb/ofb_decrypt.obj ltc/modes/ofb/ofb_done.obj \
71 ltc/modes/ofb/ofb_encrypt.obj ltc/modes/ofb/ofb_getiv.obj ltc/modes/ofb/ofb_setiv.obj \
72 ltc/modes/ofb/ofb_start.obj ltc/pk/asn1/der/bit/der_decode_bit_string.obj ltc/pk/asn1/der/bit/der_decode_raw_bit_string.obj \
73 ltc/pk/asn1/der/bit/der_encode_bit_string.obj ltc/pk/asn1/der/bit/der_encode_raw_bit_string.obj \
74 ltc/pk/asn1/der/bit/der_length_bit_string.obj ltc/pk/asn1/der/boolean/der_decode_boolean.obj \
75 ltc/pk/asn1/der/boolean/der_encode_boolean.obj ltc/pk/asn1/der/boolean/der_length_boolean.obj \
76 ltc/pk/asn1/der/choice/der_decode_choice.obj ltc/pk/asn1/der/custom_type/der_decode_custom_type.obj \
77 ltc/pk/asn1/der/custom_type/der_encode_custom_type.obj ltc/pk/asn1/der/custom_type/der_length_custom_type.obj \
78 ltc/pk/asn1/der/general/der_asn1_maps.obj ltc/pk/asn1/der/general/der_decode_asn1_identifier.obj \
79 ltc/pk/asn1/der/general/der_decode_asn1_length.obj ltc/pk/asn1/der/general/der_encode_asn1_identifier.obj \
80 ltc/pk/asn1/der/general/der_encode_asn1_length.obj ltc/pk/asn1/der/general/der_length_asn1_identifier.obj \
81 ltc/pk/asn1/der/general/der_length_asn1_length.obj ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.obj \
82 ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.obj ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.obj \
83 ltc/pk/asn1/der/ia5/der_decode_ia5_string.obj ltc/pk/asn1/der/ia5/der_encode_ia5_string.obj \
84 ltc/pk/asn1/der/ia5/der_length_ia5_string.obj ltc/pk/asn1/der/integer/der_decode_integer.obj \
85 ltc/pk/asn1/der/integer/der_encode_integer.obj ltc/pk/asn1/der/integer/der_length_integer.obj \
86 ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.obj ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.obj \
87 ltc/pk/asn1/der/object_identifier/der_length_object_identifier.obj ltc/pk/asn1/der/octet/der_decode_octet_string.obj \
88 ltc/pk/asn1/der/octet/der_encode_octet_string.obj ltc/pk/asn1/der/octet/der_length_octet_string.obj \
89 ltc/pk/asn1/der/printable_string/der_decode_printable_string.obj ltc/pk/asn1/der/printable_string/der_encode_printable_string.obj \
90 ltc/pk/asn1/der/printable_string/der_length_printable_string.obj ltc/pk/asn1/der/sequence/der_decode_sequence_ex.obj \
91 ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.obj ltc/pk/asn1/der/sequence/der_decode_sequence_multi.obj \
92 ltc/pk/asn1/der/sequence/der_encode_sequence_ex.obj ltc/pk/asn1/der/sequence/der_encode_sequence_multi.obj \
93 ltc/pk/asn1/der/sequence/der_length_sequence.obj ltc/pk/asn1/der/sequence/der_sequence_free.obj \
94 ltc/pk/asn1/der/sequence/der_sequence_shrink.obj ltc/pk/asn1/der/set/der_encode_set.obj \
95 ltc/pk/asn1/der/set/der_encode_setof.obj ltc/pk/asn1/der/short_integer/der_decode_short_integer.obj \
9496 ltc/pk/asn1/der/short_integer/der_encode_short_integer.obj ltc/pk/asn1/der/short_integer/der_length_short_integer.obj \
9597 ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.obj ltc/pk/asn1/der/teletex_string/der_length_teletex_string.obj \
9698 ltc/pk/asn1/der/utctime/der_decode_utctime.obj ltc/pk/asn1/der/utctime/der_encode_utctime.obj \
107109 ltc/pk/dsa/dsa_verify_key.obj ltc/pk/ecc/ecc.obj ltc/pk/ecc/ecc_ansi_x963_export.obj \
108110 ltc/pk/ecc/ecc_ansi_x963_import.obj ltc/pk/ecc/ecc_decrypt_key.obj ltc/pk/ecc/ecc_encrypt_key.obj \
109111 ltc/pk/ecc/ecc_export.obj ltc/pk/ecc/ecc_export_openssl.obj ltc/pk/ecc/ecc_free.obj \
110 ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_set.obj ltc/pk/ecc/ecc_get_size.obj \
112 ltc/pk/ecc/ecc_get_curve.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_size.obj \
111113 ltc/pk/ecc/ecc_import.obj ltc/pk/ecc/ecc_import_openssl.obj ltc/pk/ecc/ecc_import_pkcs8.obj \
112114 ltc/pk/ecc/ecc_import_x509.obj ltc/pk/ecc/ecc_make_key.obj ltc/pk/ecc/ecc_set_dp.obj \
113115 ltc/pk/ecc/ecc_set_dp_internal.obj ltc/pk/ecc/ecc_set_key.obj ltc/pk/ecc/ecc_shared_secret.obj \
280280 @return CRYPT_OK if successful
281281 */
282282 #ifdef LTC_CLEAN_STACK
283 static int _rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
283 static int _rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
284284 #else
285 int ECB_ENC(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
286 #endif
287 {
288 ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk;
285 int ECB_ENC(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
286 #endif
287 {
288 ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
289 const ulong32 *rk;
289290 int Nr, r;
290291
291292 LTC_ARGCHK(pt != NULL);
441442 }
442443
443444 #ifdef LTC_CLEAN_STACK
444 int ECB_ENC(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
445 int ECB_ENC(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
445446 {
446447 int err = _rijndael_ecb_encrypt(pt, ct, skey);
447448 burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2);
459460 @return CRYPT_OK if successful
460461 */
461462 #ifdef LTC_CLEAN_STACK
462 static int _rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
463 static int _rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
463464 #else
464 int ECB_DEC(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
465 #endif
466 {
467 ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk;
465 int ECB_DEC(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
466 #endif
467 {
468 ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
469 const ulong32 *rk;
468470 int Nr, r;
469471
470472 LTC_ARGCHK(pt != NULL);
621623
622624
623625 #ifdef LTC_CLEAN_STACK
624 int ECB_DEC(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
626 int ECB_DEC(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
625627 {
626628 int err = _rijndael_ecb_decrypt(ct, pt, skey);
627629 burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2);
9393 0x7bb0b0cbUL, 0xa85454fcUL, 0x6dbbbbd6UL, 0x2c16163aUL,
9494 };
9595
96 #ifndef PELI_TAB
96 #if !defined(PELI_TAB) && defined(LTC_SMALL_CODE)
9797 static const ulong32 Te4[256] = {
9898 0x63636363UL, 0x7c7c7c7cUL, 0x77777777UL, 0x7b7b7b7bUL,
9999 0xf2f2f2f2UL, 0x6b6b6b6bUL, 0x6f6f6f6fUL, 0xc5c5c5c5UL,
10161016
10171017 #endif /* SMALL CODE */
10181018
1019 #ifndef PELI_TAB
10191020 static const ulong32 rcon[] = {
10201021 0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL,
10211022 0x10000000UL, 0x20000000UL, 0x40000000UL, 0x80000000UL,
10221023 0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
10231024 };
1025 #endif
10241026
10251027 #endif /* __LTC_AES_TAB_C__ */
10261028
10341034
10351035
10361036 static void anubis_crypt(const unsigned char *plaintext, unsigned char *ciphertext,
1037 ulong32 roundKey[18 + 1][4], int R) {
1037 const ulong32 roundKey[18 + 1][4], int R) {
10381038 int i, pos, r;
10391039 ulong32 state[4];
10401040 ulong32 inter[4];
11331133 @param skey The key as scheduled
11341134 @return CRYPT_OK if successful
11351135 */
1136 int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
1136 int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
11371137 {
11381138 LTC_ARGCHK(pt != NULL);
11391139 LTC_ARGCHK(ct != NULL);
11491149 @param skey The key as scheduled
11501150 @return CRYPT_OK if successful
11511151 */
1152 int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
1152 int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
11531153 {
11541154 LTC_ARGCHK(pt != NULL);
11551155 LTC_ARGCHK(ct != NULL);
385385 @return CRYPT_OK if successful
386386 */
387387 #ifdef LTC_CLEAN_STACK
388 static int _blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
388 static int _blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
389389 #else
390 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
390 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
391391 #endif
392392 {
393393 ulong32 L, R;
431431 }
432432
433433 #ifdef LTC_CLEAN_STACK
434 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
434 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
435435 {
436436 int err = _blowfish_ecb_encrypt(pt, ct, skey);
437437 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
447447 @return CRYPT_OK if successful
448448 */
449449 #ifdef LTC_CLEAN_STACK
450 static int _blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
450 static int _blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
451451 #else
452 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
452 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
453453 #endif
454454 {
455455 ulong32 L, R;
492492 }
493493
494494 #ifdef LTC_CLEAN_STACK
495 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
495 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
496496 {
497497 int err = _blowfish_ecb_decrypt(ct, pt, skey);
498498 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
192192 return ((ulong64)U) | (((ulong64)D) << CONST64(32));
193193 }
194194
195 static void rot_128(unsigned char *in, unsigned count, unsigned char *out)
195 static void rot_128(const unsigned char *in, unsigned count, unsigned char *out)
196196 {
197197 unsigned x, w, b;
198198
435435 return CRYPT_OK;
436436 }
437437
438 int camellia_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
438 int camellia_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
439439 {
440440 ulong64 L, R;
441441 ulong32 a, b;
529529 return CRYPT_OK;
530530 }
531531
532 int camellia_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
532 int camellia_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
533533 {
534534 ulong64 L, R;
535535 ulong32 a, b;
533533 @param skey The key as scheduled
534534 */
535535 #ifdef LTC_CLEAN_STACK
536 static int _cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
536 static int _cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
537537 #else
538 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
538 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
539539 #endif
540540 {
541541 ulong32 R, L;
571571
572572
573573 #ifdef LTC_CLEAN_STACK
574 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
574 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
575575 {
576576 int err =_cast5_ecb_encrypt(pt,ct,skey);
577577 burn_stack(sizeof(ulong32)*3);
586586 @param skey The key as scheduled
587587 */
588588 #ifdef LTC_CLEAN_STACK
589 static int _cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
589 static int _cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
590590 #else
591 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
591 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
592592 #endif
593593 {
594594 ulong32 R, L;
624624 }
625625
626626 #ifdef LTC_CLEAN_STACK
627 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
627 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
628628 {
629629 int err = _cast5_ecb_decrypt(ct,pt,skey);
630630 burn_stack(sizeof(ulong32)*3);
15911591 @param skey The key as scheduled
15921592 @return CRYPT_OK if successful
15931593 */
1594 int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
1594 int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
15951595 {
15961596 ulong32 work[2];
15971597 LTC_ARGCHK(pt != NULL);
16121612 @param skey The key as scheduled
16131613 @return CRYPT_OK if successful
16141614 */
1615 int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
1615 int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
16161616 {
16171617 ulong32 work[2];
16181618 LTC_ARGCHK(pt != NULL);
16331633 @param skey The key as scheduled
16341634 @return CRYPT_OK if successful
16351635 */
1636 int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
1636 int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
16371637 {
16381638 ulong32 work[2];
16391639
16571657 @param skey The key as scheduled
16581658 @return CRYPT_OK if successful
16591659 */
1660 int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
1660 int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
16611661 {
16621662 ulong32 work[2];
16631663 LTC_ARGCHK(pt != NULL);
103103 return CRYPT_OK;
104104 }
105105
106 static int _process_block(const unsigned char *in, unsigned char *out, ushort16 *m_key)
106 static int _process_block(const unsigned char *in, unsigned char *out, const ushort16 *m_key)
107107 {
108108 int i;
109109 ushort16 x0, x1, x2, x3, t0, t1;
154154 return _setup_key(key, skey);
155155 }
156156
157 int idea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
157 int idea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
158158 {
159159 int err = _process_block(pt, ct, skey->idea.ek);
160160 #ifdef LTC_CLEAN_STACK
163163 return err;
164164 }
165165
166 int idea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
166 int idea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
167167 {
168168 int err = _process_block(ct, pt, skey->idea.dk);
169169 #ifdef LTC_CLEAN_STACK
9595 return (u16)(seven<<9) + nine;
9696 }
9797
98 static ulong32 FO( ulong32 in, int round_no, symmetric_key *key)
98 static ulong32 FO( ulong32 in, int round_no, const symmetric_key *key)
9999 {
100100 u16 left, right;
101101
119119 return (((ulong32)right)<<16)+left;
120120 }
121121
122 static ulong32 FL( ulong32 in, int round_no, symmetric_key *key )
122 static ulong32 FL( ulong32 in, int round_no, const symmetric_key *key )
123123 {
124124 u16 l, r, a, b;
125125 /* split out the left and right halves */
135135 return (((ulong32)l)<<16) + r;
136136 }
137137
138 int kasumi_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
138 int kasumi_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
139139 {
140140 ulong32 left, right, temp;
141141 int n;
162162 return CRYPT_OK;
163163 }
164164
165 int kasumi_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
165 int kasumi_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
166166 {
167167 ulong32 left, right, temp;
168168 int n;
740740 @param skey The key as scheduled
741741 @return CRYPT_OK if successful
742742 */
743 int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
743 int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
744744 {
745745 LTC_ARGCHK(pt != NULL);
746746 LTC_ARGCHK(ct != NULL);
756756 @param skey The key as scheduled
757757 @return CRYPT_OK if successful
758758 */
759 int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
759 int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
760760 {
761761 LTC_ARGCHK(pt != NULL);
762762 LTC_ARGCHK(ct != NULL);
235235 return CRYPT_OK;
236236 }
237237
238 static void rounds(ulong32 *P, ulong32 *K)
238 static void rounds(ulong32 *P, const ulong32 *K)
239239 {
240240 ulong32 T, T2;
241241 int i;
253253 @param skey The key as scheduled
254254 @return CRYPT_OK if successful
255255 */
256 int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
256 int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
257257 {
258258 ulong32 P[4];
259259 LOAD32H(P[0], pt);
275275 @param skey The key as scheduled
276276 @return CRYPT_OK if successful
277277 */
278 int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
278 int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
279279 {
280280 ulong32 P[4];
281281 LOAD32H(P[0], ct);
1919 p[1] ^= p[0];
2020 }
2121
22 static void pi2(ulong32 *p, ulong32 *k)
22 static void pi2(ulong32 *p, const ulong32 *k)
2323 {
2424 ulong32 t;
2525 t = (p[1] + k[0]) & 0xFFFFFFFFUL;
2828 p[0] ^= t;
2929 }
3030
31 static void pi3(ulong32 *p, ulong32 *k)
31 static void pi3(ulong32 *p, const ulong32 *k)
3232 {
3333 ulong32 t;
3434 t = p[0] + k[1];
4040 p[1] ^= t;
4141 }
4242
43 static void pi4(ulong32 *p, ulong32 *k)
43 static void pi4(ulong32 *p, const ulong32 *k)
4444 {
4545 ulong32 t;
4646 t = (p[1] + k[3]) & 0xFFFFFFFFUL;
4848 p[0] ^= t;
4949 }
5050
51 static void setup(ulong32 *dk, ulong32 *k, ulong32 *uk)
51 static void setup(const ulong32 *dk, const ulong32 *k, ulong32 *uk)
5252 {
5353 int n, t;
5454 ulong32 p[2];
7676 uk[n++] = p[1];
7777 }
7878
79 static void encrypt(ulong32 *p, int N, ulong32 *uk)
79 static void encrypt(ulong32 *p, int N, const ulong32 *uk)
8080 {
8181 int n, t;
8282 for (t = n = 0; ; ) {
8888 }
8989 }
9090
91 static void decrypt(ulong32 *p, int N, ulong32 *uk)
91 static void decrypt(ulong32 *p, int N, const ulong32 *uk)
9292 {
9393 int n, t;
9494 for (t = 4*(((N-1)>>2)&1), n = N; ; ) {
147147 @param skey The key as scheduled
148148 @return CRYPT_OK if successful
149149 */
150 int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
150 int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
151151 {
152152 ulong32 p[2];
153153 LTC_ARGCHK(pt != NULL);
168168 @param skey The key as scheduled
169169 @return CRYPT_OK if successful
170170 */
171 int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
171 int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
172172 {
173173 ulong32 p[2];
174174 LTC_ARGCHK(pt != NULL);
107107 @return CRYPT_OK if successful
108108 */
109109 #ifdef LTC_CLEAN_STACK
110 static int _noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
110 static int _noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
111111 #else
112 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
112 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
113113 #endif
114114 {
115115 ulong32 a,b,c,d,temp;
145145 }
146146
147147 #ifdef LTC_CLEAN_STACK
148 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
148 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
149149 {
150150 int err = _noekeon_ecb_encrypt(pt, ct, skey);
151151 burn_stack(sizeof(ulong32) * 5 + sizeof(int));
161161 @return CRYPT_OK if successful
162162 */
163163 #ifdef LTC_CLEAN_STACK
164 static int _noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
164 static int _noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
165165 #else
166 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
166 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
167167 #endif
168168 {
169169 ulong32 a,b,c,d, temp;
198198 }
199199
200200 #ifdef LTC_CLEAN_STACK
201 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
201 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
202202 {
203203 int err = _noekeon_ecb_decrypt(ct, pt, skey);
204204 burn_stack(sizeof(ulong32) * 5 + sizeof(int));
146146 #ifdef LTC_CLEAN_STACK
147147 static int _rc2_ecb_encrypt( const unsigned char *pt,
148148 unsigned char *ct,
149 symmetric_key *skey)
149 const symmetric_key *skey)
150150 #else
151151 int rc2_ecb_encrypt( const unsigned char *pt,
152152 unsigned char *ct,
153 symmetric_key *skey)
154 #endif
155 {
156 unsigned *xkey;
153 const symmetric_key *skey)
154 #endif
155 {
156 const unsigned *xkey;
157157 unsigned x76, x54, x32, x10, i;
158158
159159 LTC_ARGCHK(pt != NULL);
203203 #ifdef LTC_CLEAN_STACK
204204 int rc2_ecb_encrypt( const unsigned char *pt,
205205 unsigned char *ct,
206 symmetric_key *skey)
206 const symmetric_key *skey)
207207 {
208208 int err = _rc2_ecb_encrypt(pt, ct, skey);
209209 burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 5);
224224 #ifdef LTC_CLEAN_STACK
225225 static int _rc2_ecb_decrypt( const unsigned char *ct,
226226 unsigned char *pt,
227 symmetric_key *skey)
227 const symmetric_key *skey)
228228 #else
229229 int rc2_ecb_decrypt( const unsigned char *ct,
230230 unsigned char *pt,
231 symmetric_key *skey)
231 const symmetric_key *skey)
232232 #endif
233233 {
234234 unsigned x76, x54, x32, x10;
235 unsigned *xkey;
235 const unsigned *xkey;
236236 int i;
237237
238238 LTC_ARGCHK(pt != NULL);
282282 #ifdef LTC_CLEAN_STACK
283283 int rc2_ecb_decrypt( const unsigned char *ct,
284284 unsigned char *pt,
285 symmetric_key *skey)
285 const symmetric_key *skey)
286286 {
287287 int err = _rc2_ecb_decrypt(ct, pt, skey);
288288 burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 4 + sizeof(int));
123123 @return CRYPT_OK if successful
124124 */
125125 #ifdef LTC_CLEAN_STACK
126 static int _rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
126 static int _rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
127127 #else
128 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
129 #endif
130 {
131 ulong32 A, B, *K;
128 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
129 #endif
130 {
131 ulong32 A, B;
132 const ulong32 *K;
132133 int r;
133134 LTC_ARGCHK(skey != NULL);
134135 LTC_ARGCHK(pt != NULL);
162163 }
163164
164165 #ifdef LTC_CLEAN_STACK
165 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
166 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
166167 {
167168 int err = _rc5_ecb_encrypt(pt, ct, skey);
168169 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
178179 @return CRYPT_OK if successful
179180 */
180181 #ifdef LTC_CLEAN_STACK
181 static int _rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
182 static int _rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
182183 #else
183 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
184 #endif
185 {
186 ulong32 A, B, *K;
184 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
185 #endif
186 {
187 ulong32 A, B;
188 const ulong32 *K;
187189 int r;
188190 LTC_ARGCHK(skey != NULL);
189191 LTC_ARGCHK(pt != NULL);
218220 }
219221
220222 #ifdef LTC_CLEAN_STACK
221 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
223 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
222224 {
223225 int err = _rc5_ecb_decrypt(ct, pt, skey);
224226 burn_stack(sizeof(ulong32) * 2 + sizeof(int));
117117 @param skey The key as scheduled
118118 */
119119 #ifdef LTC_CLEAN_STACK
120 static int _rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
120 static int _rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
121121 #else
122 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
123 #endif
124 {
125 ulong32 a,b,c,d,t,u, *K;
122 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
123 #endif
124 {
125 ulong32 a,b,c,d,t,u;
126 const ulong32 *K;
126127 int r;
127128
128129 LTC_ARGCHK(skey != NULL);
156157 }
157158
158159 #ifdef LTC_CLEAN_STACK
159 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
160 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
160161 {
161162 int err = _rc6_ecb_encrypt(pt, ct, skey);
162163 burn_stack(sizeof(ulong32) * 6 + sizeof(int));
171172 @param skey The key as scheduled
172173 */
173174 #ifdef LTC_CLEAN_STACK
174 static int _rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
175 static int _rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
175176 #else
176 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
177 #endif
178 {
179 ulong32 a,b,c,d,t,u, *K;
177 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
178 #endif
179 {
180 ulong32 a,b,c,d,t,u;
181 const ulong32 *K;
180182 int r;
181183
182184 LTC_ARGCHK(skey != NULL);
212214 }
213215
214216 #ifdef LTC_CLEAN_STACK
215 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
217 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmetric_key *skey)
216218 {
217219 int err = _rc6_ecb_decrypt(ct, pt, skey);
218220 burn_stack(sizeof(ulong32) * 6 + sizeof(int));
246246 #ifdef LTC_CLEAN_STACK
247247 static int _safer_ecb_encrypt(const unsigned char *block_in,
248248 unsigned char *block_out,
249 symmetric_key *skey)
249 const symmetric_key *skey)
250250 #else
251251 int safer_ecb_encrypt(const unsigned char *block_in,
252252 unsigned char *block_out,
253 symmetric_key *skey)
253 const symmetric_key *skey)
254254 #endif
255255 { unsigned char a, b, c, d, e, f, g, h, t;
256256 unsigned int round;
257 unsigned char *key;
257 const unsigned char *key;
258258
259259 LTC_ARGCHK(block_in != NULL);
260260 LTC_ARGCHK(block_out != NULL);
289289 #ifdef LTC_CLEAN_STACK
290290 int safer_ecb_encrypt(const unsigned char *block_in,
291291 unsigned char *block_out,
292 symmetric_key *skey)
292 const symmetric_key *skey)
293293 {
294294 int err = _safer_ecb_encrypt(block_in, block_out, skey);
295295 burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
300300 #ifdef LTC_CLEAN_STACK
301301 static int _safer_ecb_decrypt(const unsigned char *block_in,
302302 unsigned char *block_out,
303 symmetric_key *skey)
303 const symmetric_key *skey)
304304 #else
305305 int safer_ecb_decrypt(const unsigned char *block_in,
306306 unsigned char *block_out,
307 symmetric_key *skey)
307 const symmetric_key *skey)
308308 #endif
309309 { unsigned char a, b, c, d, e, f, g, h, t;
310310 unsigned int round;
311 unsigned char *key;
311 const unsigned char *key;
312312
313313 LTC_ARGCHK(block_in != NULL);
314314 LTC_ARGCHK(block_out != NULL);
344344 #ifdef LTC_CLEAN_STACK
345345 int safer_ecb_decrypt(const unsigned char *block_in,
346346 unsigned char *block_out,
347 symmetric_key *skey)
347 const symmetric_key *skey)
348348 {
349349 int err = _safer_ecb_decrypt(block_in, block_out, skey);
350350 burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
142142
143143 #ifdef LTC_SMALL_CODE
144144
145 static void _round(unsigned char *b, int i, symmetric_key *skey)
145 static void _round(unsigned char *b, int i, const symmetric_key *skey)
146146 {
147147 ROUND(b, i);
148148 }
149149
150 static void _iround(unsigned char *b, int i, symmetric_key *skey)
150 static void _iround(unsigned char *b, int i, const symmetric_key *skey)
151151 {
152152 iROUND(b, i);
153153 }
337337 @param skey The key as scheduled
338338 @return CRYPT_OK if successful
339339 */
340 int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
340 int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmetric_key *skey)
341341 {