Package list libcryptx-perl / 65eb1dc
Update upstream source from tag 'upstream/0.062' Update to upstream version '0.062' with Debian dir 52222931813cb79e949ffdf99d363be814736ea9 gregor herrmann 2 years ago
267 changed file(s) with 4677 addition(s) and 13413 deletion(s). Raw diff Collapse all Expand all
00 Changes for CryptX
1
2 0.062 2018-10-30
3 - bundled libtommath update branch:develop (commit:8b9f98ba 2018-09-23) + stdint.h workaround
4 - bundled libtomcrypt update branch:develop (commit:f413335b 2018-10-29)
5 - fix #45 doc only - sign_message_rfc7518 / sign_message_rfc7518
6 - fix $46 tests only - t/mbi_ltm_bigintpm.t etc. started to fail with latest Math::BigInt
7 - fix #47 gcm_decrypt_verify + chacha20poly1305_decrypt_verify don't verify the tag - SERIOUS SECURITY BUG!
8 - improved CBC/ECB padding (using libtomcrypt's functions: padding_depad + padding_pad)
9 - enable pkcs#8 encrypted RSA keys (supported by the latest libtomcrypt)
10 - exclude wycheproof tests (too big) from dist tarball (via MANIFEST.SKIP)
111
212 0.061 2018-06-07
313 - bundled libtommath update (+stdint.h workaround)
280280 }
281281 }
282282
283 int _ecc_set_dp_from_SV(ecc_key *key, SV *curve)
283 int _ecc_set_curve_from_SV(ecc_key *key, SV *curve)
284284 {
285285 dTHX; /* fetch context */
286286 HV *hc, *h;
316316 /* string - curve name */
317317 const ltc_ecc_curve *cu;
318318 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);
319 if (ecc_find_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv);
320 return ecc_set_curve(cu, key);
321321 }
322322 else {
323323 /* hashref */
352352 cu.Gy = SvPV_nolen(*sv_Gy);
353353 cu.cofactor = (unsigned long)SvUV(*sv_cofactor);
354354
355 if ((err = ecc_set_dp(&cu, key)) != CRYPT_OK) return err;
355 if ((err = ecc_set_curve(&cu, key)) != CRYPT_OK) return err;
356356 if (key->dp.oidlen == 0) _ecc_oid_lookup(key);
357357 return CRYPT_OK;
358358 }
356356 src/ltc/misc/mem_neq.c
357357 src/ltc/misc/padding/padding_depad.c
358358 src/ltc/misc/padding/padding_pad.c
359 src/ltc/misc/pk_get_oid.c
360 src/ltc/misc/pk_oid_str.c
359 src/ltc/misc/pbes/pbes.c
360 src/ltc/misc/pbes/pbes1.c
361 src/ltc/misc/pbes/pbes2.c
362 src/ltc/misc/pkcs12/pkcs12_kdf.c
363 src/ltc/misc/pkcs12/pkcs12_utf8_to_utf16.c
361364 src/ltc/misc/pkcs5/pkcs_5_1.c
362365 src/ltc/misc/pkcs5/pkcs_5_2.c
366 src/ltc/misc/ssh/ssh_decode_sequence_multi.c
367 src/ltc/misc/ssh/ssh_encode_sequence_multi.c
363368 src/ltc/misc/zeromem.c
364369 src/ltc/modes/cbc/cbc_decrypt.c
365370 src/ltc/modes/cbc/cbc_done.c
447452 src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c
448453 src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c
449454 src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c
455 src/ltc/pk/asn1/oid/pk_get_oid.c
456 src/ltc/pk/asn1/oid/pk_oid_cmp.c
457 src/ltc/pk/asn1/oid/pk_oid_str.c
458 src/ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.c
450459 src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c
451460 src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c
452461 src/ltc/pk/dh/dh.c
480489 src/ltc/pk/ecc/ecc_encrypt_key.c
481490 src/ltc/pk/ecc/ecc_export.c
482491 src/ltc/pk/ecc/ecc_export_openssl.c
492 src/ltc/pk/ecc/ecc_find_curve.c
483493 src/ltc/pk/ecc/ecc_free.c
484 src/ltc/pk/ecc/ecc_get_curve.c
485494 src/ltc/pk/ecc/ecc_get_key.c
486495 src/ltc/pk/ecc/ecc_get_oid_str.c
487496 src/ltc/pk/ecc/ecc_get_size.c
490499 src/ltc/pk/ecc/ecc_import_pkcs8.c
491500 src/ltc/pk/ecc/ecc_import_x509.c
492501 src/ltc/pk/ecc/ecc_make_key.c
493 src/ltc/pk/ecc/ecc_set_dp.c
494 src/ltc/pk/ecc/ecc_set_dp_internal.c
502 src/ltc/pk/ecc/ecc_recover_key.c
503 src/ltc/pk/ecc/ecc_set_curve.c
504 src/ltc/pk/ecc/ecc_set_curve_internal.c
495505 src/ltc/pk/ecc/ecc_set_key.c
496506 src/ltc/pk/ecc/ecc_shared_secret.c
497507 src/ltc/pk/ecc/ecc_sign_hash.c
498508 src/ltc/pk/ecc/ecc_sizes.c
509 src/ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.c
499510 src/ltc/pk/ecc/ecc_verify_hash.c
500511 src/ltc/pk/ecc/ltc_ecc_export_point.c
501512 src/ltc/pk/ecc/ltc_ecc_import_point.c
545556 src/ltc/stream/chacha/chacha_ivctr32.c
546557 src/ltc/stream/chacha/chacha_ivctr64.c
547558 src/ltc/stream/chacha/chacha_keystream.c
559 src/ltc/stream/chacha/chacha_memory.c
548560 src/ltc/stream/chacha/chacha_setup.c
549561 src/ltc/stream/rabbit/rabbit.c
562 src/ltc/stream/rabbit/rabbit_memory.c
550563 src/ltc/stream/rc4/rc4_stream.c
564 src/ltc/stream/rc4/rc4_stream_memory.c
551565 src/ltc/stream/salsa20/salsa20_crypt.c
552566 src/ltc/stream/salsa20/salsa20_done.c
553567 src/ltc/stream/salsa20/salsa20_ivctr64.c
554568 src/ltc/stream/salsa20/salsa20_keystream.c
569 src/ltc/stream/salsa20/salsa20_memory.c
555570 src/ltc/stream/salsa20/salsa20_setup.c
571 src/ltc/stream/salsa20/xsalsa20_memory.c
556572 src/ltc/stream/salsa20/xsalsa20_setup.c
557573 src/ltc/stream/sober128/sober128_stream.c
574 src/ltc/stream/sober128/sober128_stream_memory.c
558575 src/ltc/stream/sober128/sober128tab.c
559576 src/ltc/stream/sosemanuk/sosemanuk.c
577 src/ltc/stream/sosemanuk/sosemanuk_memory.c
560578 src/ltm/bn_error.c
561579 src/ltm/bn_fast_mp_invmod.c
562580 src/ltm/bn_fast_mp_montgomery_reduce.c
576594 src/ltm/bn_mp_cmp_d.c
577595 src/ltm/bn_mp_cmp_mag.c
578596 src/ltm/bn_mp_cnt_lsb.c
597 src/ltm/bn_mp_complement.c
579598 src/ltm/bn_mp_copy.c
580599 src/ltm/bn_mp_count_bits.c
581600 src/ltm/bn_mp_div.c
663682 src/ltm/bn_mp_sub.c
664683 src/ltm/bn_mp_sub_d.c
665684 src/ltm/bn_mp_submod.c
685 src/ltm/bn_mp_tc_and.c
686 src/ltm/bn_mp_tc_div_2d.c
687 src/ltm/bn_mp_tc_or.c
688 src/ltm/bn_mp_tc_xor.c
666689 src/ltm/bn_mp_to_signed_bin.c
667690 src/ltm/bn_mp_to_signed_bin_n.c
668691 src/ltm/bn_mp_to_unsigned_bin.c
9931016 t/prng_sober128.t
9941017 t/prng_yarrow.t
9951018 t/sshkey.t
996 t/wycheproof.t
997 t/wycheproof/aes_gcm_test.json
998 t/wycheproof/dsa_test.json
999 t/wycheproof/ecdh_webcrypto_test.json
1000 t/wycheproof/ecdsa_test.json
1001 t/wycheproof/ecdsa_webcrypto_test.json
1002 t/wycheproof/rsa_signature_test.json
10031019 typemap
4444 "url" : "https://github.com/DCIT/perl-CryptX"
4545 }
4646 },
47 "version" : "0.061",
47 "version" : "0.062",
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.061'
24 version: '0.062'
2525 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
100100 } if $^O eq 'MSWin32' && $Config{cc} =~ /gcc/;
101101
102102 $extra_targets .= q{
103 update-libtom:
104 $(NOECHO) perl src/update-libtom.pl
103105 versionsync:
104106 $(NOECHO) perl _generators/version_patch.pl sync
105107 versioninc:
210210 finish(Crypt::Mode::CBC self)
211211 CODE:
212212 {
213 unsigned char tmp_block[MAXBLOCKSIZE], ch;
214 int i, j, rv, blen = (&self->state)->blocklen;
213 unsigned char tmp_block[MAXBLOCKSIZE];
214 int rv;
215 unsigned long blen = (&self->state)->blocklen;
216 unsigned long padmode;
215217
216218 if (self->direction == 1) {
217 if (self->padlen<0 || self->padlen>=blen) croak("FATAL: invalid padlen");
218 if (self->padding_mode == 1) { /* pkcs5|7 padding */
219 i = blen - self->padlen;
220 if (i == 0) i = blen;
221 for(j=self->padlen; j<blen; j++) self->pad[j] = (unsigned char)i;
219 if (self->padlen < 0 || self->padlen >= (int)blen) croak("FATAL: invalid padlen");
220 if (self->padding_mode != 0) {
221 if (self->padding_mode == 1) { padmode = LTC_PAD_PKCS7 | (&self->state)->blocklen; }
222 else if (self->padding_mode == 2) { padmode = LTC_PAD_ONE_AND_ZERO | (&self->state)->blocklen; }
223 else if (self->padding_mode == 3) { padmode = LTC_PAD_ANSI_X923 | (&self->state)->blocklen; }
224 else if (self->padding_mode == 4) { padmode = LTC_PAD_ZERO | (&self->state)->blocklen; }
225 else if (self->padding_mode == 5) { padmode = LTC_PAD_ZERO_ALWAYS | (&self->state)->blocklen; }
226 else { croak("FATAL: unknown padding"); }
227 blen = sizeof(self->pad);
228 rv = padding_pad(self->pad, self->padlen, &blen, padmode);
229 if (rv != CRYPT_OK) croak("FATAL: padding_pad failed: %s", error_to_string(rv));
222230 rv = cbc_encrypt(self->pad, tmp_block, blen, &self->state);
223231 if (rv != CRYPT_OK) croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
224232 }
225 else if (self->padding_mode == 2) { /* oneandzeroes padding */
226 self->pad[self->padlen] = 0x80;
227 for(j=self->padlen+1; j<blen; j++) self->pad[j] = 0;
228 rv = cbc_encrypt(self->pad, tmp_block, blen, &self->state);
229 if (rv != CRYPT_OK) croak("FATAL: cbc_encrypt failed: %s", error_to_string(rv));
230 }
231233 else {
232 if (self->padlen>0) croak("FATAL: cbc_encrypt, input data length not multiple of %d", blen);
234 if (self->padlen > 0) croak("FATAL: cbc_encrypt, input data length not multiple of %d", (int)blen);
233235 blen = 0;
234236 }
235237 }
236238 else if (self->direction == -1) {
237239 if (self->padlen > 0) {
238 if (self->padlen != blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", blen, self->padlen);
240 if (self->padlen != (int)blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", (int)blen, self->padlen);
239241 rv = cbc_decrypt(self->pad, tmp_block, blen, &self->state);
240242 if (rv != CRYPT_OK) croak("FATAL: cbc_decrypt failed: %s", error_to_string(rv));
241 if (self->padding_mode == 0) { /* no padding */
242 /* we already have blen */
243 }
244 else if (self->padding_mode == 1) { /* pkcs5|7 padding */
245 ch = tmp_block[blen-1];
246 blen = blen - (ch > blen ? blen : ch);
247 }
248 else if (self->padding_mode == 2) { /* oneandzeroes padding */
249 while ((unsigned char)tmp_block[blen - 1] == 0x00) blen--;
250 if ((unsigned char)tmp_block[blen - 1] == 0x80) blen--;
251 if (blen < 0) blen = 0;
243 if (self->padding_mode != 0) {
244 if (self->padding_mode == 1) { padmode = LTC_PAD_PKCS7 | (&self->state)->blocklen; }
245 else if (self->padding_mode == 2) { padmode = LTC_PAD_ONE_AND_ZERO | (&self->state)->blocklen; }
246 else if (self->padding_mode == 3) { padmode = LTC_PAD_ANSI_X923 | (&self->state)->blocklen; }
247 else if (self->padding_mode == 4) { padmode = LTC_PAD_ZERO | (&self->state)->blocklen; }
248 else if (self->padding_mode == 5) { padmode = LTC_PAD_ZERO_ALWAYS | (&self->state)->blocklen; }
249 else { croak("FATAL: unknown padding"); }
250 rv = padding_depad(tmp_block, &blen, padmode);
251 if (rv != CRYPT_OK) croak("FATAL: padding_depad failed: %s", error_to_string(rv));
252 }
253 else {
254 /* "no padding" == there is no need to do anything */
252255 }
253256 }
254257 else {
256259 }
257260 }
258261 else {
259 XSRETURN_UNDEF;
262 croak("FATAL: invalid direction");
260263 }
261264
262265 self->direction = 0;
203203 finish(Crypt::Mode::ECB self)
204204 CODE:
205205 {
206 unsigned char tmp_block[MAXBLOCKSIZE], ch;
207 int i, j, rv, blen = (&self->state)->blocklen;
206 unsigned char tmp_block[MAXBLOCKSIZE];
207 int rv;
208 unsigned long blen = (&self->state)->blocklen;
209 unsigned long padmode;
208210
209211 if (self->direction == 1) {
210 if (self->padlen<0 || self->padlen>=blen) croak("FATAL: invalid padlen");
211 if (self->padding_mode == 1) { /* pkcs5|7 padding */
212 i = blen - self->padlen;
213 if (i == 0) i = blen;
214 for(j=self->padlen; j<blen; j++) self->pad[j] = (unsigned char)i;
212 if (self->padlen < 0 || self->padlen >= (int)blen) croak("FATAL: invalid padlen");
213 if (self->padding_mode != 0) {
214 if (self->padding_mode == 1) { padmode = LTC_PAD_PKCS7 | (&self->state)->blocklen; }
215 else if (self->padding_mode == 2) { padmode = LTC_PAD_ONE_AND_ZERO | (&self->state)->blocklen; }
216 else if (self->padding_mode == 3) { padmode = LTC_PAD_ANSI_X923 | (&self->state)->blocklen; }
217 else if (self->padding_mode == 4) { padmode = LTC_PAD_ZERO | (&self->state)->blocklen; }
218 else if (self->padding_mode == 5) { padmode = LTC_PAD_ZERO_ALWAYS | (&self->state)->blocklen; }
219 else { croak("FATAL: unknown padding"); }
220 blen = sizeof(self->pad);
221 rv = padding_pad(self->pad, self->padlen, &blen, padmode);
222 if (rv != CRYPT_OK) croak("FATAL: padding_pad failed: %s", error_to_string(rv));
215223 rv = ecb_encrypt(self->pad, tmp_block, blen, &self->state);
216224 if (rv != CRYPT_OK) croak("FATAL: ecb_encrypt failed: %s", error_to_string(rv));
217225 }
218 else if (self->padding_mode == 2) { /* oneandzeroes padding */
219 self->pad[self->padlen] = 0x80;
220 for(j=self->padlen+1; j<blen; j++) self->pad[j] = 0;
221 rv = ecb_encrypt(self->pad, tmp_block, blen, &self->state);
222 if (rv != CRYPT_OK) croak("FATAL: ecb_encrypt failed: %s", error_to_string(rv));
223 }
224226 else {
225 if (self->padlen>0) croak("FATAL: ecb_encrypt, input data length not multiple of %d", blen);
227 if (self->padlen > 0) croak("FATAL: ecb_encrypt, input data length not multiple of %d", (int)blen);
226228 blen = 0;
227229 }
228230 }
229231 else if (self->direction == -1) {
230232 if (self->padlen > 0) {
231 if (self->padlen != blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", blen, self->padlen);
233 if (self->padlen != (int)blen) croak("FATAL: cipher text length has to be multiple of %d (%d)", (int)blen, self->padlen);
232234 rv = ecb_decrypt(self->pad, tmp_block, blen, &self->state);
233235 if (rv != CRYPT_OK) croak("FATAL: ecb_decrypt failed: %s", error_to_string(rv));
234 if (self->padding_mode == 0) { /* no padding */
235 /* we already have blen */
236 }
237 else if (self->padding_mode == 1) { /* pkcs5|7 padding */
238 ch = tmp_block[blen-1];
239 blen = blen - (ch > blen ? blen : ch);
240 }
241 else if (self->padding_mode == 2) { /* oneandzeroes padding */
242 while ((unsigned char)tmp_block[blen - 1] == 0x00) blen--;
243 if ((unsigned char)tmp_block[blen - 1] == 0x80) blen--;
244 if (blen < 0) blen = 0;
236 if (self->padding_mode != 0) {
237 if (self->padding_mode == 1) { padmode = LTC_PAD_PKCS7 | (&self->state)->blocklen; }
238 else if (self->padding_mode == 2) { padmode = LTC_PAD_ONE_AND_ZERO | (&self->state)->blocklen; }
239 else if (self->padding_mode == 3) { padmode = LTC_PAD_ANSI_X923 | (&self->state)->blocklen; }
240 else if (self->padding_mode == 4) { padmode = LTC_PAD_ZERO | (&self->state)->blocklen; }
241 else if (self->padding_mode == 5) { padmode = LTC_PAD_ZERO_ALWAYS | (&self->state)->blocklen; }
242 else { croak("FATAL: unknown padding"); }
243 rv = padding_depad(tmp_block, &blen, padmode);
244 if (rv != CRYPT_OK) croak("FATAL: padding_depad failed: %s", error_to_string(rv));
245 }
246 else {
247 /* "no padding" == there is no need to do anything */
245248 }
246249 }
247250 else {
249252 }
250253 }
251254 else {
252 XSRETURN_UNDEF;
255 croak("FATAL: invalid direction");
253256 }
254257
255258 self->direction = 0;
2929 {
3030 int rv;
3131 /* setup dp structure */
32 rv = _ecc_set_dp_from_SV(&self->key, curve); /* croaks on error */
33 if (rv != CRYPT_OK) croak("FATAL: ecc_set_dp failed: %s", error_to_string(rv));
32 rv = _ecc_set_curve_from_SV(&self->key, curve); /* croaks on error */
33 if (rv != CRYPT_OK) croak("FATAL: ecc_set_curve failed: %s", error_to_string(rv));
3434 /* gen the key */
3535 rv = ecc_generate_key(&self->pstate, self->pindex, &self->key);
3636 if (rv != CRYPT_OK) croak("FATAL: ecc_generate_key failed: %s", error_to_string(rv));
111111 data = (unsigned char *)SvPVbyte(key_data, data_len);
112112 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
113113 /* setup dp structure */
114 rv = _ecc_set_dp_from_SV(&self->key, curve); /* croaks on error */
115 if (rv != CRYPT_OK) croak("FATAL: ecc_set_dp failed: %s", error_to_string(rv));
114 rv = _ecc_set_curve_from_SV(&self->key, curve); /* croaks on error */
115 if (rv != CRYPT_OK) croak("FATAL: ecc_set_curve failed: %s", error_to_string(rv));
116116 /* import key */
117117 type = (data_len == (STRLEN)ecc_get_size(&self->key)) ? PK_PRIVATE : PK_PUBLIC;
118118 rv = ecc_set_key(data, (unsigned long)data_len, type, &self->key);
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
55
66 ### not used
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use base qw(Crypt::Cipher);
99
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
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.061';
6 our $VERSION = '0.062';
77
88 use Crypt::Cipher;
99
6969 # 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64',
7070 # 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'
7171 # simply any <NAME> for which there exists Crypt::Cipher::<NAME>
72 # $padding .... 0 no padding (plaintext size has to be myltiple of block length)
72 # $padding .... 0 no padding (plaintext size has to be multiple of block length)
7373 # 1 PKCS5 padding, Crypt::CBC's "standard" - DEFAULT
7474 # 2 Crypt::CBC's "oneandzeroes"
75 # 3 ANSI X.923 padding
76 # 4 zero padding
77 # 5 zero padding (+a block of zeros if the output length is divisible by the blocksize)
7578 # $cipher_rounds ... optional num of rounds for given cipher
7679
7780 =head2 encrypt
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use Crypt::Cipher;
99
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use Crypt::Cipher;
99
7070 # 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64',
7171 # 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'
7272 # simply any <NAME> for which there exists Crypt::Cipher::<NAME>
73 # $padding .... 0 no padding (plaintext size has to be myltiple of block length)
73 # $padding .... 0 no padding (plaintext size has to be multiple of block length)
7474 # 1 PKCS5 padding, Crypt::CBC's "standard" - DEFAULT
7575 # 2 Crypt::CBC's "oneandzeroes"
76 # 3 ANSI X.923 padding
77 # 4 zero padding
78 # 5 zero padding (+a block of zeros if the output length is divisible by the blocksize)
7679 # $cipher_rounds ... optional num of rounds for given cipher
7780
7881 =head2 encrypt
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.061';
6 our $VERSION = '0.062';
77
88 use Crypt::Cipher;
99
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 ### not used
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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 )] );
4141 "wap-wsg-idm-ecid-wtls6" => 'secp112r1',
4242 "wap-wsg-idm-ecid-wtls7" => 'secp160r2',
4343 "wap-wsg-idm-ecid-wtls12" => 'secp224r1',
44 # extra aliases
45 'P-256K' => 'secp256k1',
4446 );
4547
4648 our %curve_oid2name = ( # must be "our" as we use it from XS code
8688 '1.2.840.10045.3.1.1' => 'P-192', # secp192r1
8789 '1.3.132.0.33' => 'P-224', # secp224r1
8890 '1.2.840.10045.3.1.7' => 'P-256', # secp256r1
91 '1.3.132.0.10' => 'P-256K',# secp256k1
8992 '1.3.132.0.34' => 'P-384', # secp384r1
9093 '1.3.132.0.35' => 'P-521', # secp521r1
9194 'nistp192' => 'P-192',
98101 'secp192r1' => 'P-192',
99102 'secp224r1' => 'P-224',
100103 'secp256r1' => 'P-256',
104 'secp256k1' => 'P-256K',
101105 'secp384r1' => 'P-384',
102106 'secp521r1' => 'P-521',
103107 );
827831 Same as L<sign_message|/sign_message> only the signature format is as defined by L<https://tools.ietf.org/html/rfc7518>
828832 (JWA - JSON Web Algorithms).
829833
834 B<BEWARE:> This creates signatures according to the structure that RFC 7518 describes but does not apply
835 the RFC logic for the hashing algorithm selection. You'll still need to specify, e.g., SHA256 for a P-256 key
836 to get a fully RFC-7518-compliant signature.
837
830838 =head2 verify_message
831839
832840 my $pk = Crypt::PK::ECC->new($pub_key_filename);
842850
843851 Same as L<verify_message|/verify_message> only the signature format is as defined by L<https://tools.ietf.org/html/rfc7518>
844852 (JWA - JSON Web Algorithms).
853
854 B<BEWARE:> This verifies signatures according to the structure that RFC 7518 describes but does not apply
855 the RFC logic for the hashing algorithm selection. You'll still need to specify, e.g., SHA256 for a P-256 key
856 to get a fully RFC-7518-compliant signature.
845857
846858 =head2 sign_hash
847859
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
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)] );
127127 elsif ($data =~ /-----BEGIN PRIVATE KEY-----(.*?)-----END/sg) {
128128 # PKCS#8 PrivateKeyInfo (PEM header: BEGIN PRIVATE KEY)
129129 $data = pem_to_der($data, $password);
130 return $self->_import_pkcs8($data, $password) if $data;
130 return $self->_import_pkcs8($data, $password);
131131 }
132132 elsif ($data =~ /-----BEGIN ENCRYPTED PRIVATE KEY-----(.*?)-----END/sg) {
133 # XXX-TODO: PKCS#8 EncryptedPrivateKeyInfo (PEM header: BEGIN ENCRYPTED PRIVATE KEY)
134 croak "FATAL: encrypted pkcs8 RSA private keys are not supported";
133 # PKCS#8 PrivateKeyInfo (PEM header: BEGIN ENCRYPTED PRIVATE KEY)
134 $data = pem_to_der($data, $password);
135 return $self->_import_pkcs8($data, $password);
135136 }
136137 elsif ($data =~ /^\s*(\{.*?\})\s*$/s) {
137138 # JSON Web Key (JWK) - http://tools.ietf.org/html/draft-ietf-jose-json-web-key
417418 fyoy4t3yHT+/nw==
418419 -----END PRIVATE KEY-----
419420
420 =item * PKCS#8 encrypted private keys ARE NOT SUPPORTED YET!
421 =item * PKCS#8 encrypted private keys - password protected keys (supported since: CryptX-0.062)
421422
422423 -----BEGIN ENCRYPTED PRIVATE KEY-----
423424 MIICojAcBgoqhkiG9w0BDAEDMA4ECCQk+Rr1yzzcAgIIAASCAoD/mgpUFjxxM/Ty
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use Carp;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
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.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings ;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 require XSLoader;
77 XSLoader::load('CryptX', $VERSION);
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.061';
4 our $VERSION = '0.062';
55
66 use CryptX;
77
4040 ltc/mac/xcbc/xcbc_process.o ltc/math/ltm_desc.o ltc/math/multi.o ltc/math/radix_to_bin.o \
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 \
43 ltc/misc/crc32.o ltc/misc/error_to_string.o ltc/misc/mem_neq.o ltc/misc/pk_get_oid.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 \
54 ltc/misc/crypt/crypt_register_all_hashes.o ltc/misc/crypt/crypt_register_all_prngs.o \
55 ltc/misc/crypt/crypt_register_cipher.o ltc/misc/crypt/crypt_register_hash.o ltc/misc/crypt/crypt_register_prng.o \
56 ltc/misc/crypt/crypt_sizes.o ltc/misc/crypt/crypt_unregister_cipher.o ltc/misc/crypt/crypt_unregister_hash.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 \
43 ltc/misc/crc32.o ltc/misc/error_to_string.o ltc/misc/mem_neq.o ltc/misc/zeromem.o \
44 ltc/misc/base16/base16_decode.o ltc/misc/base16/base16_encode.o ltc/misc/base32/base32_decode.o \
45 ltc/misc/base32/base32_encode.o ltc/misc/base64/base64_decode.o ltc/misc/base64/base64_encode.o \
46 ltc/misc/crypt/crypt.o ltc/misc/crypt/crypt_argchk.o ltc/misc/crypt/crypt_cipher_descriptor.o \
47 ltc/misc/crypt/crypt_cipher_is_valid.o ltc/misc/crypt/crypt_constants.o ltc/misc/crypt/crypt_find_cipher.o \
48 ltc/misc/crypt/crypt_find_cipher_any.o ltc/misc/crypt/crypt_find_cipher_id.o ltc/misc/crypt/crypt_find_hash.o \
49 ltc/misc/crypt/crypt_find_hash_any.o ltc/misc/crypt/crypt_find_hash_id.o ltc/misc/crypt/crypt_find_hash_oid.o \
50 ltc/misc/crypt/crypt_find_prng.o ltc/misc/crypt/crypt_fsa.o ltc/misc/crypt/crypt_hash_descriptor.o \
51 ltc/misc/crypt/crypt_hash_is_valid.o ltc/misc/crypt/crypt_inits.o ltc/misc/crypt/crypt_ltc_mp_descriptor.o \
52 ltc/misc/crypt/crypt_prng_descriptor.o ltc/misc/crypt/crypt_prng_is_valid.o ltc/misc/crypt/crypt_prng_rng_descriptor.o \
53 ltc/misc/crypt/crypt_register_all_ciphers.o ltc/misc/crypt/crypt_register_all_hashes.o \
54 ltc/misc/crypt/crypt_register_all_prngs.o ltc/misc/crypt/crypt_register_cipher.o \
55 ltc/misc/crypt/crypt_register_hash.o ltc/misc/crypt/crypt_register_prng.o ltc/misc/crypt/crypt_sizes.o \
56 ltc/misc/crypt/crypt_unregister_cipher.o ltc/misc/crypt/crypt_unregister_hash.o ltc/misc/crypt/crypt_unregister_prng.o \
57 ltc/misc/hkdf/hkdf.o ltc/misc/padding/padding_depad.o ltc/misc/padding/padding_pad.o \
58 ltc/misc/pbes/pbes.o ltc/misc/pbes/pbes1.o ltc/misc/pbes/pbes2.o ltc/misc/pkcs12/pkcs12_kdf.o \
59 ltc/misc/pkcs12/pkcs12_utf8_to_utf16.o ltc/misc/pkcs5/pkcs_5_1.o ltc/misc/pkcs5/pkcs_5_2.o \
60 ltc/misc/ssh/ssh_decode_sequence_multi.o ltc/misc/ssh/ssh_encode_sequence_multi.o \
5961 ltc/modes/cbc/cbc_decrypt.o ltc/modes/cbc/cbc_done.o ltc/modes/cbc/cbc_encrypt.o \
6062 ltc/modes/cbc/cbc_getiv.o ltc/modes/cbc/cbc_setiv.o ltc/modes/cbc/cbc_start.o ltc/modes/cfb/cfb_decrypt.o \
6163 ltc/modes/cfb/cfb_done.o ltc/modes/cfb/cfb_encrypt.o ltc/modes/cfb/cfb_getiv.o ltc/modes/cfb/cfb_setiv.o \
9294 ltc/pk/asn1/der/utctime/der_decode_utctime.o ltc/pk/asn1/der/utctime/der_encode_utctime.o \
9395 ltc/pk/asn1/der/utctime/der_length_utctime.o ltc/pk/asn1/der/utf8/der_decode_utf8_string.o \
9496 ltc/pk/asn1/der/utf8/der_encode_utf8_string.o ltc/pk/asn1/der/utf8/der_length_utf8_string.o \
95 ltc/pk/asn1/x509/x509_decode_subject_public_key_info.o ltc/pk/asn1/x509/x509_encode_subject_public_key_info.o \
96 ltc/pk/dh/dh.o ltc/pk/dh/dh_check_pubkey.o ltc/pk/dh/dh_export.o ltc/pk/dh/dh_export_key.o \
97 ltc/pk/dh/dh_free.o ltc/pk/dh/dh_generate_key.o ltc/pk/dh/dh_import.o ltc/pk/dh/dh_set.o \
98 ltc/pk/dh/dh_set_pg_dhparam.o ltc/pk/dh/dh_shared_secret.o ltc/pk/dsa/dsa_decrypt_key.o \
99 ltc/pk/dsa/dsa_encrypt_key.o ltc/pk/dsa/dsa_export.o ltc/pk/dsa/dsa_free.o ltc/pk/dsa/dsa_generate_key.o \
100 ltc/pk/dsa/dsa_generate_pqg.o ltc/pk/dsa/dsa_import.o ltc/pk/dsa/dsa_make_key.o ltc/pk/dsa/dsa_set.o \
101 ltc/pk/dsa/dsa_set_pqg_dsaparam.o ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_sign_hash.o \
102 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 \
103 ltc/pk/ecc/ecc_ansi_x963_import.o ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.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 \
97 ltc/pk/asn1/oid/pk_get_oid.o ltc/pk/asn1/oid/pk_oid_cmp.o ltc/pk/asn1/oid/pk_oid_str.o \
98 ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.o ltc/pk/asn1/x509/x509_decode_subject_public_key_info.o \
99 ltc/pk/asn1/x509/x509_encode_subject_public_key_info.o ltc/pk/dh/dh.o ltc/pk/dh/dh_check_pubkey.o \
100 ltc/pk/dh/dh_export.o ltc/pk/dh/dh_export_key.o ltc/pk/dh/dh_free.o ltc/pk/dh/dh_generate_key.o \
101 ltc/pk/dh/dh_import.o ltc/pk/dh/dh_set.o ltc/pk/dh/dh_set_pg_dhparam.o ltc/pk/dh/dh_shared_secret.o \
102 ltc/pk/dsa/dsa_decrypt_key.o ltc/pk/dsa/dsa_encrypt_key.o ltc/pk/dsa/dsa_export.o \
103 ltc/pk/dsa/dsa_free.o ltc/pk/dsa/dsa_generate_key.o ltc/pk/dsa/dsa_generate_pqg.o \
104 ltc/pk/dsa/dsa_import.o ltc/pk/dsa/dsa_make_key.o ltc/pk/dsa/dsa_set.o ltc/pk/dsa/dsa_set_pqg_dsaparam.o \
105 ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_sign_hash.o ltc/pk/dsa/dsa_verify_hash.o \
106 ltc/pk/dsa/dsa_verify_key.o ltc/pk/ecc/ecc.o ltc/pk/ecc/ecc_ansi_x963_export.o ltc/pk/ecc/ecc_ansi_x963_import.o \
107 ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.o ltc/pk/ecc/ecc_export.o \
108 ltc/pk/ecc/ecc_export_openssl.o ltc/pk/ecc/ecc_find_curve.o ltc/pk/ecc/ecc_free.o \
105109 ltc/pk/ecc/ecc_get_key.o ltc/pk/ecc/ecc_get_oid_str.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o \
106110 ltc/pk/ecc/ecc_import_openssl.o ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o \
107 ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_set_dp.o ltc/pk/ecc/ecc_set_dp_internal.o \
108 ltc/pk/ecc/ecc_set_key.o ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o \
109 ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o \
110 ltc/pk/ecc/ltc_ecc_import_point.o ltc/pk/ecc/ltc_ecc_is_point.o ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o \
111 ltc/pk/ecc/ltc_ecc_map.o ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o \
112 ltc/pk/ecc/ltc_ecc_mulmod_timing.o ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o \
113 ltc/pk/ecc/ltc_ecc_projective_dbl_point.o ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o \
114 ltc/pk/pkcs1/pkcs_1_mgf1.o ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o \
115 ltc/pk/pkcs1/pkcs_1_os2ip.o ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o \
116 ltc/pk/pkcs1/pkcs_1_v1_5_decode.o ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o \
117 ltc/pk/rsa/rsa_encrypt_key.o ltc/pk/rsa/rsa_export.o ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o \
118 ltc/pk/rsa/rsa_get_size.o ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \
111 ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_recover_key.o ltc/pk/ecc/ecc_set_curve.o \
112 ltc/pk/ecc/ecc_set_curve_internal.o ltc/pk/ecc/ecc_set_key.o ltc/pk/ecc/ecc_shared_secret.o \
113 ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.o \
114 ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o ltc/pk/ecc/ltc_ecc_import_point.o \
115 ltc/pk/ecc/ltc_ecc_is_point.o ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o ltc/pk/ecc/ltc_ecc_map.o \
116 ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o ltc/pk/ecc/ltc_ecc_mulmod_timing.o \
117 ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o ltc/pk/ecc/ltc_ecc_projective_dbl_point.o \
118 ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o ltc/pk/pkcs1/pkcs_1_mgf1.o \
119 ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o ltc/pk/pkcs1/pkcs_1_os2ip.o \
120 ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o ltc/pk/pkcs1/pkcs_1_v1_5_decode.o \
121 ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o ltc/pk/rsa/rsa_encrypt_key.o \
122 ltc/pk/rsa/rsa_export.o ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o ltc/pk/rsa/rsa_get_size.o \
123 ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \
119124 ltc/pk/rsa/rsa_make_key.o ltc/pk/rsa/rsa_set.o ltc/pk/rsa/rsa_sign_hash.o ltc/pk/rsa/rsa_sign_saltlen_get.o \
120125 ltc/pk/rsa/rsa_verify_hash.o ltc/prngs/chacha20.o ltc/prngs/fortuna.o ltc/prngs/rc4.o \
121126 ltc/prngs/rng_get_bytes.o ltc/prngs/rng_make_prng.o ltc/prngs/sober128.o ltc/prngs/sprng.o \
122127 ltc/prngs/yarrow.o ltc/stream/chacha/chacha_crypt.o ltc/stream/chacha/chacha_done.o \
123128 ltc/stream/chacha/chacha_ivctr32.o ltc/stream/chacha/chacha_ivctr64.o ltc/stream/chacha/chacha_keystream.o \
124 ltc/stream/chacha/chacha_setup.o ltc/stream/rabbit/rabbit.o ltc/stream/rc4/rc4_stream.o \
129 ltc/stream/chacha/chacha_memory.o ltc/stream/chacha/chacha_setup.o ltc/stream/rabbit/rabbit.o \
130 ltc/stream/rabbit/rabbit_memory.o ltc/stream/rc4/rc4_stream.o ltc/stream/rc4/rc4_stream_memory.o \
125131 ltc/stream/salsa20/salsa20_crypt.o ltc/stream/salsa20/salsa20_done.o ltc/stream/salsa20/salsa20_ivctr64.o \
126 ltc/stream/salsa20/salsa20_keystream.o ltc/stream/salsa20/salsa20_setup.o ltc/stream/salsa20/xsalsa20_setup.o \
127 ltc/stream/sober128/sober128_stream.o ltc/stream/sosemanuk/sosemanuk.o ltm/bncore.o \
128 ltm/bn_error.o ltm/bn_fast_mp_invmod.o ltm/bn_fast_mp_montgomery_reduce.o ltm/bn_fast_s_mp_mul_digs.o \
129 ltm/bn_fast_s_mp_mul_high_digs.o ltm/bn_fast_s_mp_sqr.o ltm/bn_mp_2expt.o ltm/bn_mp_abs.o \
130 ltm/bn_mp_add.o ltm/bn_mp_addmod.o ltm/bn_mp_add_d.o ltm/bn_mp_and.o ltm/bn_mp_clamp.o \
131 ltm/bn_mp_clear.o ltm/bn_mp_clear_multi.o ltm/bn_mp_cmp.o ltm/bn_mp_cmp_d.o ltm/bn_mp_cmp_mag.o \
132 ltm/bn_mp_cnt_lsb.o ltm/bn_mp_copy.o ltm/bn_mp_count_bits.o ltm/bn_mp_div.o ltm/bn_mp_div_2.o \
133 ltm/bn_mp_div_2d.o ltm/bn_mp_div_3.o ltm/bn_mp_div_d.o ltm/bn_mp_dr_is_modulus.o \
134 ltm/bn_mp_dr_reduce.o ltm/bn_mp_dr_setup.o ltm/bn_mp_exch.o ltm/bn_mp_export.o ltm/bn_mp_exptmod.o \
135 ltm/bn_mp_exptmod_fast.o ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o \
136 ltm/bn_mp_fread.o ltm/bn_mp_fwrite.o ltm/bn_mp_gcd.o ltm/bn_mp_get_int.o ltm/bn_mp_get_long.o \
137 ltm/bn_mp_grow.o ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \
132 ltc/stream/salsa20/salsa20_keystream.o ltc/stream/salsa20/salsa20_memory.o ltc/stream/salsa20/salsa20_setup.o \
133 ltc/stream/salsa20/xsalsa20_memory.o ltc/stream/salsa20/xsalsa20_setup.o ltc/stream/sober128/sober128_stream.o \
134 ltc/stream/sober128/sober128_stream_memory.o ltc/stream/sosemanuk/sosemanuk.o ltc/stream/sosemanuk/sosemanuk_memory.o \
135 ltm/bncore.o ltm/bn_error.o ltm/bn_fast_mp_invmod.o ltm/bn_fast_mp_montgomery_reduce.o \
136 ltm/bn_fast_s_mp_mul_digs.o ltm/bn_fast_s_mp_mul_high_digs.o ltm/bn_fast_s_mp_sqr.o \
137 ltm/bn_mp_2expt.o ltm/bn_mp_abs.o ltm/bn_mp_add.o ltm/bn_mp_addmod.o ltm/bn_mp_add_d.o \
138 ltm/bn_mp_and.o ltm/bn_mp_clamp.o ltm/bn_mp_clear.o ltm/bn_mp_clear_multi.o ltm/bn_mp_cmp.o \
139 ltm/bn_mp_cmp_d.o ltm/bn_mp_cmp_mag.o ltm/bn_mp_cnt_lsb.o ltm/bn_mp_complement.o \
140 ltm/bn_mp_copy.o ltm/bn_mp_count_bits.o ltm/bn_mp_div.o ltm/bn_mp_div_2.o ltm/bn_mp_div_2d.o \
141 ltm/bn_mp_div_3.o ltm/bn_mp_div_d.o ltm/bn_mp_dr_is_modulus.o ltm/bn_mp_dr_reduce.o \
142 ltm/bn_mp_dr_setup.o ltm/bn_mp_exch.o ltm/bn_mp_export.o ltm/bn_mp_exptmod.o ltm/bn_mp_exptmod_fast.o \
143 ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o ltm/bn_mp_fread.o \
144 ltm/bn_mp_fwrite.o ltm/bn_mp_gcd.o ltm/bn_mp_get_int.o ltm/bn_mp_get_long.o ltm/bn_mp_grow.o \
145 ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \
138146 ltm/bn_mp_init_set.o ltm/bn_mp_init_set_int.o ltm/bn_mp_init_size.o ltm/bn_mp_invmod.o \
139147 ltm/bn_mp_invmod_slow.o ltm/bn_mp_is_square.o ltm/bn_mp_jacobi.o ltm/bn_mp_karatsuba_mul.o \
140148 ltm/bn_mp_karatsuba_sqr.o ltm/bn_mp_lcm.o ltm/bn_mp_lshd.o ltm/bn_mp_mod.o ltm/bn_mp_mod_2d.o \
150158 ltm/bn_mp_reduce_setup.o ltm/bn_mp_rshd.o ltm/bn_mp_set.o ltm/bn_mp_set_int.o ltm/bn_mp_set_long.o \
151159 ltm/bn_mp_shrink.o ltm/bn_mp_signed_bin_size.o ltm/bn_mp_sqr.o ltm/bn_mp_sqrmod.o \
152160 ltm/bn_mp_sqrt.o ltm/bn_mp_sqrtmod_prime.o ltm/bn_mp_sub.o ltm/bn_mp_submod.o ltm/bn_mp_sub_d.o \
153 ltm/bn_mp_toom_mul.o ltm/bn_mp_toom_sqr.o ltm/bn_mp_toradix.o ltm/bn_mp_toradix_n.o \
154 ltm/bn_mp_to_signed_bin.o ltm/bn_mp_to_signed_bin_n.o ltm/bn_mp_to_unsigned_bin.o \
155 ltm/bn_mp_to_unsigned_bin_n.o ltm/bn_mp_unsigned_bin_size.o ltm/bn_mp_xor.o ltm/bn_mp_zero.o \
156 ltm/bn_prime_tab.o ltm/bn_reverse.o ltm/bn_s_mp_add.o ltm/bn_s_mp_exptmod.o ltm/bn_s_mp_mul_digs.o \
157 ltm/bn_s_mp_mul_high_digs.o ltm/bn_s_mp_sqr.o ltm/bn_s_mp_sub.o
161 ltm/bn_mp_tc_and.o ltm/bn_mp_tc_div_2d.o ltm/bn_mp_tc_or.o ltm/bn_mp_tc_xor.o ltm/bn_mp_toom_mul.o \
162 ltm/bn_mp_toom_sqr.o ltm/bn_mp_toradix.o ltm/bn_mp_toradix_n.o ltm/bn_mp_to_signed_bin.o \
163 ltm/bn_mp_to_signed_bin_n.o ltm/bn_mp_to_unsigned_bin.o ltm/bn_mp_to_unsigned_bin_n.o \
164 ltm/bn_mp_unsigned_bin_size.o ltm/bn_mp_xor.o ltm/bn_mp_zero.o ltm/bn_prime_tab.o \
165 ltm/bn_reverse.o ltm/bn_s_mp_add.o ltm/bn_s_mp_exptmod.o ltm/bn_s_mp_mul_digs.o ltm/bn_s_mp_mul_high_digs.o \
166 ltm/bn_s_mp_sqr.o ltm/bn_s_mp_sub.o
158167
159168 LIB_EXT =.a
160169 OBJ_EXT =.o
175184 .SUFFIXES: .o .c
176185
177186 .c$(OBJ_EXT):
178 $(CC) -Iltm -Iltc/headers -DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC $(CFLAGS) -c $< -o $@
187 $(CC) -Iltm -Iltc/headers -DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC $(CFLAGS) -DARGTYPE=4 -c $< -o $@
4343 ltc/mac/xcbc/xcbc_process.obj ltc/math/ltm_desc.obj ltc/math/multi.obj ltc/math/radix_to_bin.obj \
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 \
46 ltc/misc/crc32.obj ltc/misc/error_to_string.obj ltc/misc/mem_neq.obj ltc/misc/pk_get_oid.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 \
51 ltc/misc/crypt/crypt_constants.obj ltc/misc/crypt/crypt_find_cipher.obj ltc/misc/crypt/crypt_find_cipher_any.obj \
52 ltc/misc/crypt/crypt_find_cipher_id.obj ltc/misc/crypt/crypt_find_hash.obj ltc/misc/crypt/crypt_find_hash_any.obj \
53 ltc/misc/crypt/crypt_find_hash_id.obj ltc/misc/crypt/crypt_find_hash_oid.obj ltc/misc/crypt/crypt_find_prng.obj \
54 ltc/misc/crypt/crypt_fsa.obj ltc/misc/crypt/crypt_hash_descriptor.obj ltc/misc/crypt/crypt_hash_is_valid.obj \
55 ltc/misc/crypt/crypt_inits.obj ltc/misc/crypt/crypt_ltc_mp_descriptor.obj ltc/misc/crypt/crypt_prng_descriptor.obj \
46 ltc/misc/crc32.obj ltc/misc/error_to_string.obj ltc/misc/mem_neq.obj ltc/misc/zeromem.obj \
47 ltc/misc/base16/base16_decode.obj ltc/misc/base16/base16_encode.obj ltc/misc/base32/base32_decode.obj \
48 ltc/misc/base32/base32_encode.obj ltc/misc/base64/base64_decode.obj ltc/misc/base64/base64_encode.obj \
49 ltc/misc/crypt/crypt.obj ltc/misc/crypt/crypt_argchk.obj ltc/misc/crypt/crypt_cipher_descriptor.obj \
50 ltc/misc/crypt/crypt_cipher_is_valid.obj ltc/misc/crypt/crypt_constants.obj ltc/misc/crypt/crypt_find_cipher.obj \
51 ltc/misc/crypt/crypt_find_cipher_any.obj ltc/misc/crypt/crypt_find_cipher_id.obj \
52 ltc/misc/crypt/crypt_find_hash.obj ltc/misc/crypt/crypt_find_hash_any.obj ltc/misc/crypt/crypt_find_hash_id.obj \
53 ltc/misc/crypt/crypt_find_hash_oid.obj ltc/misc/crypt/crypt_find_prng.obj ltc/misc/crypt/crypt_fsa.obj \
54 ltc/misc/crypt/crypt_hash_descriptor.obj ltc/misc/crypt/crypt_hash_is_valid.obj ltc/misc/crypt/crypt_inits.obj \
55 ltc/misc/crypt/crypt_ltc_mp_descriptor.obj ltc/misc/crypt/crypt_prng_descriptor.obj \
5656 ltc/misc/crypt/crypt_prng_is_valid.obj ltc/misc/crypt/crypt_prng_rng_descriptor.obj \
5757 ltc/misc/crypt/crypt_register_all_ciphers.obj ltc/misc/crypt/crypt_register_all_hashes.obj \
5858 ltc/misc/crypt/crypt_register_all_prngs.obj ltc/misc/crypt/crypt_register_cipher.obj \
5959 ltc/misc/crypt/crypt_register_hash.obj ltc/misc/crypt/crypt_register_prng.obj ltc/misc/crypt/crypt_sizes.obj \
6060 ltc/misc/crypt/crypt_unregister_cipher.obj ltc/misc/crypt/crypt_unregister_hash.obj \
6161 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 \
62 ltc/misc/padding/padding_pad.obj ltc/misc/pbes/pbes.obj ltc/misc/pbes/pbes1.obj ltc/misc/pbes/pbes2.obj \
63 ltc/misc/pkcs12/pkcs12_kdf.obj ltc/misc/pkcs12/pkcs12_utf8_to_utf16.obj ltc/misc/pkcs5/pkcs_5_1.obj \
64 ltc/misc/pkcs5/pkcs_5_2.obj ltc/misc/ssh/ssh_decode_sequence_multi.obj ltc/misc/ssh/ssh_encode_sequence_multi.obj \
6365 ltc/modes/cbc/cbc_decrypt.obj ltc/modes/cbc/cbc_done.obj ltc/modes/cbc/cbc_encrypt.obj \
6466 ltc/modes/cbc/cbc_getiv.obj ltc/modes/cbc/cbc_setiv.obj ltc/modes/cbc/cbc_start.obj \
6567 ltc/modes/cfb/cfb_decrypt.obj ltc/modes/cfb/cfb_done.obj ltc/modes/cfb/cfb_encrypt.obj \
98100 ltc/pk/asn1/der/utctime/der_decode_utctime.obj ltc/pk/asn1/der/utctime/der_encode_utctime.obj \
99101 ltc/pk/asn1/der/utctime/der_length_utctime.obj ltc/pk/asn1/der/utf8/der_decode_utf8_string.obj \
100102 ltc/pk/asn1/der/utf8/der_encode_utf8_string.obj ltc/pk/asn1/der/utf8/der_length_utf8_string.obj \
101 ltc/pk/asn1/x509/x509_decode_subject_public_key_info.obj ltc/pk/asn1/x509/x509_encode_subject_public_key_info.obj \
102 ltc/pk/dh/dh.obj ltc/pk/dh/dh_check_pubkey.obj ltc/pk/dh/dh_export.obj ltc/pk/dh/dh_export_key.obj \
103 ltc/pk/dh/dh_free.obj ltc/pk/dh/dh_generate_key.obj ltc/pk/dh/dh_import.obj ltc/pk/dh/dh_set.obj \
104 ltc/pk/dh/dh_set_pg_dhparam.obj ltc/pk/dh/dh_shared_secret.obj ltc/pk/dsa/dsa_decrypt_key.obj \
105 ltc/pk/dsa/dsa_encrypt_key.obj ltc/pk/dsa/dsa_export.obj ltc/pk/dsa/dsa_free.obj \
106 ltc/pk/dsa/dsa_generate_key.obj ltc/pk/dsa/dsa_generate_pqg.obj ltc/pk/dsa/dsa_import.obj \
107 ltc/pk/dsa/dsa_make_key.obj ltc/pk/dsa/dsa_set.obj ltc/pk/dsa/dsa_set_pqg_dsaparam.obj \
103 ltc/pk/asn1/oid/pk_get_oid.obj ltc/pk/asn1/oid/pk_oid_cmp.obj ltc/pk/asn1/oid/pk_oid_str.obj \
104 ltc/pk/asn1/pkcs8/pkcs8_decode_flexi.obj ltc/pk/asn1/x509/x509_decode_subject_public_key_info.obj \
105 ltc/pk/asn1/x509/x509_encode_subject_public_key_info.obj ltc/pk/dh/dh.obj ltc/pk/dh/dh_check_pubkey.obj \
106 ltc/pk/dh/dh_export.obj ltc/pk/dh/dh_export_key.obj ltc/pk/dh/dh_free.obj ltc/pk/dh/dh_generate_key.obj \
107 ltc/pk/dh/dh_import.obj ltc/pk/dh/dh_set.obj ltc/pk/dh/dh_set_pg_dhparam.obj ltc/pk/dh/dh_shared_secret.obj \
108 ltc/pk/dsa/dsa_decrypt_key.obj ltc/pk/dsa/dsa_encrypt_key.obj ltc/pk/dsa/dsa_export.obj \
109 ltc/pk/dsa/dsa_free.obj ltc/pk/dsa/dsa_generate_key.obj ltc/pk/dsa/dsa_generate_pqg.obj \
110 ltc/pk/dsa/dsa_import.obj ltc/pk/dsa/dsa_make_key.obj ltc/pk/dsa/dsa_set.obj ltc/pk/dsa/dsa_set_pqg_dsaparam.obj \
108111 ltc/pk/dsa/dsa_shared_secret.obj ltc/pk/dsa/dsa_sign_hash.obj ltc/pk/dsa/dsa_verify_hash.obj \
109112 ltc/pk/dsa/dsa_verify_key.obj ltc/pk/ecc/ecc.obj ltc/pk/ecc/ecc_ansi_x963_export.obj \
110113 ltc/pk/ecc/ecc_ansi_x963_import.obj ltc/pk/ecc/ecc_decrypt_key.obj ltc/pk/ecc/ecc_encrypt_key.obj \
111 ltc/pk/ecc/ecc_export.obj ltc/pk/ecc/ecc_export_openssl.obj ltc/pk/ecc/ecc_free.obj \
112 ltc/pk/ecc/ecc_get_curve.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_oid_str.obj \
114 ltc/pk/ecc/ecc_export.obj ltc/pk/ecc/ecc_export_openssl.obj ltc/pk/ecc/ecc_find_curve.obj \
115 ltc/pk/ecc/ecc_free.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_oid_str.obj \
113116 ltc/pk/ecc/ecc_get_size.obj ltc/pk/ecc/ecc_import.obj ltc/pk/ecc/ecc_import_openssl.obj \
114117 ltc/pk/ecc/ecc_import_pkcs8.obj ltc/pk/ecc/ecc_import_x509.obj ltc/pk/ecc/ecc_make_key.obj \
115 ltc/pk/ecc/ecc_set_dp.obj ltc/pk/ecc/ecc_set_dp_internal.obj ltc/pk/ecc/ecc_set_key.obj \
116 ltc/pk/ecc/ecc_shared_secret.obj ltc/pk/ecc/ecc_sign_hash.obj ltc/pk/ecc/ecc_sizes.obj \
117 ltc/pk/ecc/ecc_verify_hash.obj ltc/pk/ecc/ltc_ecc_export_point.obj ltc/pk/ecc/ltc_ecc_import_point.obj \
118 ltc/pk/ecc/ltc_ecc_is_point.obj ltc/pk/ecc/ltc_ecc_is_point_at_infinity.obj ltc/pk/ecc/ltc_ecc_map.obj \
119 ltc/pk/ecc/ltc_ecc_mul2add.obj ltc/pk/ecc/ltc_ecc_mulmod.obj ltc/pk/ecc/ltc_ecc_mulmod_timing.obj \
120 ltc/pk/ecc/ltc_ecc_points.obj ltc/pk/ecc/ltc_ecc_projective_add_point.obj ltc/pk/ecc/ltc_ecc_projective_dbl_point.obj \
118 ltc/pk/ecc/ecc_recover_key.obj ltc/pk/ecc/ecc_set_curve.obj ltc/pk/ecc/ecc_set_curve_internal.obj \
119 ltc/pk/ecc/ecc_set_key.obj ltc/pk/ecc/ecc_shared_secret.obj ltc/pk/ecc/ecc_sign_hash.obj \
120 ltc/pk/ecc/ecc_sizes.obj ltc/pk/ecc/ecc_ssh_ecdsa_encode_name.obj ltc/pk/ecc/ecc_verify_hash.obj \
121 ltc/pk/ecc/ltc_ecc_export_point.obj ltc/pk/ecc/ltc_ecc_import_point.obj ltc/pk/ecc/ltc_ecc_is_point.obj \
122 ltc/pk/ecc/ltc_ecc_is_point_at_infinity.obj ltc/pk/ecc/ltc_ecc_map.obj ltc/pk/ecc/ltc_ecc_mul2add.obj \
123 ltc/pk/ecc/ltc_ecc_mulmod.obj ltc/pk/ecc/ltc_ecc_mulmod_timing.obj ltc/pk/ecc/ltc_ecc_points.obj \
124 ltc/pk/ecc/ltc_ecc_projective_add_point.obj ltc/pk/ecc/ltc_ecc_projective_dbl_point.obj \
121125 ltc/pk/ecc/ltc_ecc_verify_key.obj ltc/pk/pkcs1/pkcs_1_i2osp.obj ltc/pk/pkcs1/pkcs_1_mgf1.obj \
122126 ltc/pk/pkcs1/pkcs_1_oaep_decode.obj ltc/pk/pkcs1/pkcs_1_oaep_encode.obj ltc/pk/pkcs1/pkcs_1_os2ip.obj \
123127 ltc/pk/pkcs1/pkcs_1_pss_decode.obj ltc/pk/pkcs1/pkcs_1_pss_encode.obj ltc/pk/pkcs1/pkcs_1_v1_5_decode.obj \
129133 ltc/prngs/rng_get_bytes.obj ltc/prngs/rng_make_prng.obj ltc/prngs/sober128.obj ltc/prngs/sprng.obj \
130134 ltc/prngs/yarrow.obj ltc/stream/chacha/chacha_crypt.obj ltc/stream/chacha/chacha_done.obj \
131135 ltc/stream/chacha/chacha_ivctr32.obj ltc/stream/chacha/chacha_ivctr64.obj ltc/stream/chacha/chacha_keystream.obj \
132 ltc/stream/chacha/chacha_setup.obj ltc/stream/rabbit/rabbit.obj ltc/stream/rc4/rc4_stream.obj \
136 ltc/stream/chacha/chacha_memory.obj ltc/stream/chacha/chacha_setup.obj ltc/stream/rabbit/rabbit.obj \
137 ltc/stream/rabbit/rabbit_memory.obj ltc/stream/rc4/rc4_stream.obj ltc/stream/rc4/rc4_stream_memory.obj \
133138 ltc/stream/salsa20/salsa20_crypt.obj ltc/stream/salsa20/salsa20_done.obj ltc/stream/salsa20/salsa20_ivctr64.obj \
134 ltc/stream/salsa20/salsa20_keystream.obj ltc/stream/salsa20/salsa20_setup.obj ltc/stream/salsa20/xsalsa20_setup.obj \
135 ltc/stream/sober128/sober128_stream.obj ltc/stream/sosemanuk/sosemanuk.obj ltm/bncore.obj \
136 ltm/bn_error.obj ltm/bn_fast_mp_invmod.obj ltm/bn_fast_mp_montgomery_reduce.obj ltm/bn_fast_s_mp_mul_digs.obj \
137 ltm/bn_fast_s_mp_mul_high_digs.obj ltm/bn_fast_s_mp_sqr.obj ltm/bn_mp_2expt.obj ltm/bn_mp_abs.obj \
138 ltm/bn_mp_add.obj ltm/bn_mp_addmod.obj ltm/bn_mp_add_d.obj ltm/bn_mp_and.obj ltm/bn_mp_clamp.obj \
139 ltm/bn_mp_clear.obj ltm/bn_mp_clear_multi.obj ltm/bn_mp_cmp.obj ltm/bn_mp_cmp_d.obj \
140 ltm/bn_mp_cmp_mag.obj ltm/bn_mp_cnt_lsb.obj ltm/bn_mp_copy.obj ltm/bn_mp_count_bits.obj \
139 ltc/stream/salsa20/salsa20_keystream.obj ltc/stream/salsa20/salsa20_memory.obj ltc/stream/salsa20/salsa20_setup.obj \
140 ltc/stream/salsa20/xsalsa20_memory.obj ltc/stream/salsa20/xsalsa20_setup.obj ltc/stream/sober128/sober128_stream.obj \
141 ltc/stream/sober128/sober128_stream_memory.obj ltc/stream/sosemanuk/sosemanuk.obj \
142 ltc/stream/sosemanuk/sosemanuk_memory.obj ltm/bncore.obj ltm/bn_error.obj ltm/bn_fast_mp_invmod.obj \
143 ltm/bn_fast_mp_montgomery_reduce.obj ltm/bn_fast_s_mp_mul_digs.obj ltm/bn_fast_s_mp_mul_high_digs.obj \
144 ltm/bn_fast_s_mp_sqr.obj ltm/bn_mp_2expt.obj ltm/bn_mp_abs.obj ltm/bn_mp_add.obj \
145 ltm/bn_mp_addmod.obj ltm/bn_mp_add_d.obj ltm/bn_mp_and.obj ltm/bn_mp_clamp.obj ltm/bn_mp_clear.obj \
146 ltm/bn_mp_clear_multi.obj ltm/bn_mp_cmp.obj ltm/bn_mp_cmp_d.obj ltm/bn_mp_cmp_mag.obj \
147 ltm/bn_mp_cnt_lsb.obj ltm/bn_mp_complement.obj ltm/bn_mp_copy.obj ltm/bn_mp_count_bits.obj \
141148 ltm/bn_mp_div.obj ltm/bn_mp_div_2.obj ltm/bn_mp_div_2d.obj ltm/bn_mp_div_3.obj ltm/bn_mp_div_d.obj \
142149 ltm/bn_mp_dr_is_modulus.obj ltm/bn_mp_dr_reduce.obj ltm/bn_mp_dr_setup.obj ltm/bn_mp_exch.obj \
143150 ltm/bn_mp_export.obj ltm/bn_mp_exptmod.obj ltm/bn_mp_exptmod_fast.obj ltm/bn_mp_expt_d.obj \
160167 ltm/bn_mp_rshd.obj ltm/bn_mp_set.obj ltm/bn_mp_set_int.obj ltm/bn_mp_set_long.obj \
161168 ltm/bn_mp_shrink.obj ltm/bn_mp_signed_bin_size.obj ltm/bn_mp_sqr.obj ltm/bn_mp_sqrmod.obj \
162169 ltm/bn_mp_sqrt.obj ltm/bn_mp_sqrtmod_prime.obj ltm/bn_mp_sub.obj ltm/bn_mp_submod.obj \
163 ltm/bn_mp_sub_d.obj ltm/bn_mp_toom_mul.obj ltm/bn_mp_toom_sqr.obj ltm/bn_mp_toradix.obj \
170 ltm/bn_mp_sub_d.obj ltm/bn_mp_tc_and.obj ltm/bn_mp_tc_div_2d.obj ltm/bn_mp_tc_or.obj \
171 ltm/bn_mp_tc_xor.obj ltm/bn_mp_toom_mul.obj ltm/bn_mp_toom_sqr.obj ltm/bn_mp_toradix.obj \
164172 ltm/bn_mp_toradix_n.obj ltm/bn_mp_to_signed_bin.obj ltm/bn_mp_to_signed_bin_n.obj \
165173 ltm/bn_mp_to_unsigned_bin.obj ltm/bn_mp_to_unsigned_bin_n.obj ltm/bn_mp_unsigned_bin_size.obj \
166174 ltm/bn_mp_xor.obj ltm/bn_mp_zero.obj ltm/bn_prime_tab.obj ltm/bn_reverse.obj ltm/bn_s_mp_add.obj \
177185 $(RM_F) $(OBJS) liballinone.lib
178186
179187 .c.obj:
180 cl /Iltm /Iltc/headers /DLTC_SOURCE /DLTC_NO_TEST /DLTC_NO_PROTOTYPES /DLTM_DESC $(CFLAGS) /c $< /Fo$@
188 cl /Iltm /Iltc/headers /DLTC_SOURCE /DLTC_NO_TEST /DLTC_NO_PROTOTYPES /DLTM_DESC /DARGTYPE=4 $(CFLAGS) /c $< /Fo$@
181189
9090
9191 static ulong32 setup_mix(ulong32 temp)
9292 {
93 return (Te4_3[byte(temp, 2)]) ^
94 (Te4_2[byte(temp, 1)]) ^
95 (Te4_1[byte(temp, 0)]) ^
96 (Te4_0[byte(temp, 3)]);
93 return (Te4_3[LTC_BYTE(temp, 2)]) ^
94 (Te4_2[LTC_BYTE(temp, 1)]) ^
95 (Te4_1[LTC_BYTE(temp, 0)]) ^
96 (Te4_0[LTC_BYTE(temp, 3)]);
9797 }
9898
9999 #ifndef ENCRYPT_ONLY
100100 #ifdef LTC_SMALL_CODE
101101 static ulong32 setup_mix2(ulong32 temp)
102102 {
103 return Td0(255 & Te4[byte(temp, 3)]) ^
104 Td1(255 & Te4[byte(temp, 2)]) ^
105 Td2(255 & Te4[byte(temp, 1)]) ^
106 Td3(255 & Te4[byte(temp, 0)]);
103 return Td0(255 & Te4[LTC_BYTE(temp, 3)]) ^
104 Td1(255 & Te4[LTC_BYTE(temp, 2)]) ^
105 Td2(255 & Te4[LTC_BYTE(temp, 1)]) ^
106 Td3(255 & Te4[LTC_BYTE(temp, 0)]);
107107 }
108108 #endif
109109 #endif
234234 #else
235235 temp = rrk[0];
236236 rk[0] =
237 Tks0[byte(temp, 3)] ^
238 Tks1[byte(temp, 2)] ^
239 Tks2[byte(temp, 1)] ^
240 Tks3[byte(temp, 0)];
237 Tks0[LTC_BYTE(temp, 3)] ^
238 Tks1[LTC_BYTE(temp, 2)] ^
239 Tks2[LTC_BYTE(temp, 1)] ^
240 Tks3[LTC_BYTE(temp, 0)];
241241 temp = rrk[1];
242242 rk[1] =
243 Tks0[byte(temp, 3)] ^
244 Tks1[byte(temp, 2)] ^
245 Tks2[byte(temp, 1)] ^
246 Tks3[byte(temp, 0)];
243 Tks0[LTC_BYTE(temp, 3)] ^
244 Tks1[LTC_BYTE(temp, 2)] ^
245 Tks2[LTC_BYTE(temp, 1)] ^
246 Tks3[LTC_BYTE(temp, 0)];
247247 temp = rrk[2];
248248 rk[2] =
249 Tks0[byte(temp, 3)] ^
250 Tks1[byte(temp, 2)] ^
251 Tks2[byte(temp, 1)] ^
252 Tks3[byte(temp, 0)];
249 Tks0[LTC_BYTE(temp, 3)] ^
250 Tks1[LTC_BYTE(temp, 2)] ^
251 Tks2[LTC_BYTE(temp, 1)] ^
252 Tks3[LTC_BYTE(temp, 0)];
253253 temp = rrk[3];
254254 rk[3] =
255 Tks0[byte(temp, 3)] ^
256 Tks1[byte(temp, 2)] ^
257 Tks2[byte(temp, 1)] ^
258 Tks3[byte(temp, 0)];
255 Tks0[LTC_BYTE(temp, 3)] ^
256 Tks1[LTC_BYTE(temp, 2)] ^
257 Tks2[LTC_BYTE(temp, 1)] ^
258 Tks3[LTC_BYTE(temp, 0)];
259259 #endif
260260
261261 }
310310 for (r = 0; ; r++) {
311311 rk += 4;
312312 t0 =
313 Te0(byte(s0, 3)) ^
314 Te1(byte(s1, 2)) ^
315 Te2(byte(s2, 1)) ^
316 Te3(byte(s3, 0)) ^
313 Te0(LTC_BYTE(s0, 3)) ^
314 Te1(LTC_BYTE(s1, 2)) ^
315 Te2(LTC_BYTE(s2, 1)) ^
316 Te3(LTC_BYTE(s3, 0)) ^
317317 rk[0];
318318 t1 =
319 Te0(byte(s1, 3)) ^
320 Te1(byte(s2, 2)) ^
321 Te2(byte(s3, 1)) ^
322 Te3(byte(s0, 0)) ^
319 Te0(LTC_BYTE(s1, 3)) ^
320 Te1(LTC_BYTE(s2, 2)) ^
321 Te2(LTC_BYTE(s3, 1)) ^
322 Te3(LTC_BYTE(s0, 0)) ^
323323 rk[1];
324324 t2 =
325 Te0(byte(s2, 3)) ^
326 Te1(byte(s3, 2)) ^
327 Te2(byte(s0, 1)) ^
328 Te3(byte(s1, 0)) ^
325 Te0(LTC_BYTE(s2, 3)) ^
326 Te1(LTC_BYTE(s3, 2)) ^
327 Te2(LTC_BYTE(s0, 1)) ^
328 Te3(LTC_BYTE(s1, 0)) ^
329329 rk[2];
330330 t3 =
331 Te0(byte(s3, 3)) ^
332 Te1(byte(s0, 2)) ^
333 Te2(byte(s1, 1)) ^
334 Te3(byte(s2, 0)) ^
331 Te0(LTC_BYTE(s3, 3)) ^
332 Te1(LTC_BYTE(s0, 2)) ^
333 Te2(LTC_BYTE(s1, 1)) ^
334 Te3(LTC_BYTE(s2, 0)) ^
335335 rk[3];
336336 if (r == Nr-2) {
337337 break;
348348 r = Nr >> 1;
349349 for (;;) {
350350 t0 =
351 Te0(byte(s0, 3)) ^
352 Te1(byte(s1, 2)) ^
353 Te2(byte(s2, 1)) ^
354 Te3(byte(s3, 0)) ^
351 Te0(LTC_BYTE(s0, 3)) ^
352 Te1(LTC_BYTE(s1, 2)) ^
353 Te2(LTC_BYTE(s2, 1)) ^
354 Te3(LTC_BYTE(s3, 0)) ^
355355 rk[4];
356356 t1 =
357 Te0(byte(s1, 3)) ^
358 Te1(byte(s2, 2)) ^
359 Te2(byte(s3, 1)) ^
360 Te3(byte(s0, 0)) ^
357 Te0(LTC_BYTE(s1, 3)) ^
358 Te1(LTC_BYTE(s2, 2)) ^
359 Te2(LTC_BYTE(s3, 1)) ^
360 Te3(LTC_BYTE(s0, 0)) ^
361361 rk[5];
362362 t2 =
363 Te0(byte(s2, 3)) ^
364 Te1(byte(s3, 2)) ^
365 Te2(byte(s0, 1)) ^
366 Te3(byte(s1, 0)) ^
363 Te0(LTC_BYTE(s2, 3)) ^
364 Te1(LTC_BYTE(s3, 2)) ^
365 Te2(LTC_BYTE(s0, 1)) ^
366 Te3(LTC_BYTE(s1, 0)) ^
367367 rk[6];
368368 t3 =
369 Te0(byte(s3, 3)) ^
370 Te1(byte(s0, 2)) ^
371 Te2(byte(s1, 1)) ^
372 Te3(byte(s2, 0)) ^
369 Te0(LTC_BYTE(s3, 3)) ^
370 Te1(LTC_BYTE(s0, 2)) ^
371 Te2(LTC_BYTE(s1, 1)) ^
372 Te3(LTC_BYTE(s2, 0)) ^
373373 rk[7];
374374
375375 rk += 8;
378378 }
379379
380380 s0 =
381 Te0(byte(t0, 3)) ^
382 Te1(byte(t1, 2)) ^
383 Te2(byte(t2, 1)) ^
384 Te3(byte(t3, 0)) ^
381 Te0(LTC_BYTE(t0, 3)) ^
382 Te1(LTC_BYTE(t1, 2)) ^
383 Te2(LTC_BYTE(t2, 1)) ^
384 Te3(LTC_BYTE(t3, 0)) ^
385385 rk[0];
386386 s1 =
387 Te0(byte(t1, 3)) ^
388 Te1(byte(t2, 2)) ^
389 Te2(byte(t3, 1)) ^
390 Te3(byte(t0, 0)) ^
387 Te0(LTC_BYTE(t1, 3)) ^
388 Te1(LTC_BYTE(t2, 2)) ^
389 Te2(LTC_BYTE(t3, 1)) ^
390 Te3(LTC_BYTE(t0, 0)) ^
391391 rk[1];
392392 s2 =
393 Te0(byte(t2, 3)) ^
394 Te1(byte(t3, 2)) ^
395 Te2(byte(t0, 1)) ^
396 Te3(byte(t1, 0)) ^
393 Te0(LTC_BYTE(t2, 3)) ^
394 Te1(LTC_BYTE(t3, 2)) ^
395 Te2(LTC_BYTE(t0, 1)) ^
396 Te3(LTC_BYTE(t1, 0)) ^
397397 rk[2];
398398 s3 =
399 Te0(byte(t3, 3)) ^
400 Te1(byte(t0, 2)) ^
401 Te2(byte(t1, 1)) ^
402 Te3(byte(t2, 0)) ^
399 Te0(LTC_BYTE(t3, 3)) ^
400 Te1(LTC_BYTE(t0, 2)) ^
401 Te2(LTC_BYTE(t1, 1)) ^
402 Te3(LTC_BYTE(t2, 0)) ^
403403 rk[3];
404404 }
405405
410410 * map cipher state to byte array block:
411411 */
412412 s0 =
413 (Te4_3[byte(t0, 3)]) ^
414 (Te4_2[byte(t1, 2)]) ^
415 (Te4_1[byte(t2, 1)]) ^
416 (Te4_0[byte(t3, 0)]) ^
413 (Te4_3[LTC_BYTE(t0, 3)]) ^
414 (Te4_2[LTC_BYTE(t1, 2)]) ^
415 (Te4_1[LTC_BYTE(t2, 1)]) ^
416 (Te4_0[LTC_BYTE(t3, 0)]) ^
417417 rk[0];
418418 STORE32H(s0, ct);
419419 s1 =
420 (Te4_3[byte(t1, 3)]) ^
421 (Te4_2[byte(t2, 2)]) ^
422 (Te4_1[byte(t3, 1)]) ^
423 (Te4_0[byte(t0, 0)]) ^
420 (Te4_3[LTC_BYTE(t1, 3)]) ^
421 (Te4_2[LTC_BYTE(t2, 2)]) ^
422 (Te4_1[LTC_BYTE(t3, 1)]) ^
423 (Te4_0[LTC_BYTE(t0, 0)]) ^
424424 rk[1];
425425 STORE32H(s1, ct+4);
426426 s2 =
427 (Te4_3[byte(t2, 3)]) ^
428 (Te4_2[byte(t3, 2)]) ^
429 (Te4_1[byte(t0, 1)]) ^
430 (Te4_0[byte(t1, 0)]) ^
427 (Te4_3[LTC_BYTE(t2, 3)]) ^
428 (Te4_2[LTC_BYTE(t3, 2)]) ^
429 (Te4_1[LTC_BYTE(t0, 1)]) ^
430 (Te4_0[LTC_BYTE(t1, 0)]) ^
431431 rk[2];
432432 STORE32H(s2, ct+8);
433433 s3 =
434 (Te4_3[byte(t3, 3)]) ^
435 (Te4_2[byte(t0, 2)]) ^
436 (Te4_1[byte(t1, 1)]) ^
437 (Te4_0[byte(t2, 0)]) ^
434 (Te4_3[LTC_BYTE(t3, 3)]) ^
435 (Te4_2[LTC_BYTE(t0, 2)]) ^
436 (Te4_1[LTC_BYTE(t1, 1)]) ^
437 (Te4_0[LTC_BYTE(t2, 0)]) ^
438438 rk[3];
439439 STORE32H(s3, ct+12);
440440
489489 for (r = 0; ; r++) {
490490 rk += 4;
491491 t0 =
492 Td0(byte(s0, 3)) ^
493 Td1(byte(s3, 2)) ^
494 Td2(byte(s2, 1)) ^
495 Td3(byte(s1, 0)) ^
492 Td0(LTC_BYTE(s0, 3)) ^
493 Td1(LTC_BYTE(s3, 2)) ^
494 Td2(LTC_BYTE(s2, 1)) ^
495 Td3(LTC_BYTE(s1, 0)) ^
496496 rk[0];
497497 t1 =
498 Td0(byte(s1, 3)) ^
499 Td1(byte(s0, 2)) ^
500 Td2(byte(s3, 1)) ^
501 Td3(byte(s2, 0)) ^
498 Td0(LTC_BYTE(s1, 3)) ^
499 Td1(LTC_BYTE(s0, 2)) ^
500 Td2(LTC_BYTE(s3, 1)) ^
501 Td3(LTC_BYTE(s2, 0)) ^
502502 rk[1];
503503 t2 =
504 Td0(byte(s2, 3)) ^
505 Td1(byte(s1, 2)) ^
506 Td2(byte(s0, 1)) ^
507 Td3(byte(s3, 0)) ^
504 Td0(LTC_BYTE(s2, 3)) ^
505 Td1(LTC_BYTE(s1, 2)) ^
506 Td2(LTC_BYTE(s0, 1)) ^
507 Td3(LTC_BYTE(s3, 0)) ^
508508 rk[2];
509509 t3 =
510 Td0(byte(s3, 3)) ^
511 Td1(byte(s2, 2)) ^
512 Td2(byte(s1, 1)) ^
513 Td3(byte(s0, 0)) ^
510 Td0(LTC_BYTE(s3, 3)) ^
511 Td1(LTC_BYTE(s2, 2)) ^
512 Td2(LTC_BYTE(s1, 1)) ^
513 Td3(LTC_BYTE(s0, 0)) ^
514514 rk[3];
515515 if (r == Nr-2) {
516516 break;
528528 for (;;) {
529529
530530 t0 =
531 Td0(byte(s0, 3)) ^
532 Td1(byte(s3, 2)) ^
533 Td2(byte(s2, 1)) ^
534 Td3(byte(s1, 0)) ^
531 Td0(LTC_BYTE(s0, 3)) ^
532 Td1(LTC_BYTE(s3, 2)) ^
533 Td2(LTC_BYTE(s2, 1)) ^
534 Td3(LTC_BYTE(s1, 0)) ^
535535 rk[4];
536536 t1 =
537 Td0(byte(s1, 3)) ^
538 Td1(byte(s0, 2)) ^
539 Td2(byte(s3, 1)) ^
540 Td3(byte(s2, 0)) ^
537 Td0(LTC_BYTE(s1, 3)) ^
538 Td1(LTC_BYTE(s0, 2)) ^
539 Td2(LTC_BYTE(s3, 1)) ^
540 Td3(LTC_BYTE(s2, 0)) ^
541541 rk[5];
542542 t2 =
543 Td0(byte(s2, 3)) ^
544 Td1(byte(s1, 2)) ^
545 Td2(byte(s0, 1)) ^
546 Td3(byte(s3, 0)) ^
543 Td0(LTC_BYTE(s2, 3)) ^
544 Td1(LTC_BYTE(s1, 2)) ^
545 Td2(LTC_BYTE(s0, 1)) ^
546 Td3(LTC_BYTE(s3, 0)) ^
547547 rk[6];
548548 t3 =
549 Td0(byte(s3, 3)) ^
550 Td1(byte(s2, 2)) ^
551 Td2(byte(s1, 1)) ^
552 Td3(byte(s0, 0)) ^
549 Td0(LTC_BYTE(s3, 3)) ^
550 Td1(LTC_BYTE(s2, 2)) ^
551 Td2(LTC_BYTE(s1, 1)) ^
552 Td3(LTC_BYTE(s0, 0)) ^
553553 rk[7];
554554
555555 rk += 8;
559559
560560
561561 s0 =
562 Td0(byte(t0, 3)) ^
563 Td1(byte(t3, 2)) ^
564 Td2(byte(t2, 1)) ^
565 Td3(byte(t1, 0)) ^
562 Td0(LTC_BYTE(t0, 3)) ^
563 Td1(LTC_BYTE(t3, 2)) ^
564 Td2(LTC_BYTE(t2, 1)) ^
565 Td3(LTC_BYTE(t1, 0)) ^
566566 rk[0];
567567 s1 =
568 Td0(byte(t1, 3)) ^
569 Td1(byte(t0, 2)) ^
570 Td2(byte(t3, 1)) ^
571 Td3(byte(t2, 0)) ^
568 Td0(LTC_BYTE(t1, 3)) ^
569 Td1(LTC_BYTE(t0, 2)) ^
570 Td2(LTC_BYTE(t3, 1)) ^
571 Td3(LTC_BYTE(t2, 0)) ^
572572 rk[1];
573573 s2 =
574 Td0(byte(t2, 3)) ^
575 Td1(byte(t1, 2)) ^
576 Td2(byte(t0, 1)) ^
577 Td3(byte(t3, 0)) ^
574 Td0(LTC_BYTE(t2, 3)) ^
575 Td1(LTC_BYTE(t1, 2)) ^
576 Td2(LTC_BYTE(t0, 1)) ^
577 Td3(LTC_BYTE(t3, 0)) ^
578578 rk[2];
579579 s3 =
580 Td0(byte(t3, 3)) ^
581 Td1(byte(t2, 2)) ^
582 Td2(byte(t1, 1)) ^
583 Td3(byte(t0, 0)) ^
580 Td0(LTC_BYTE(t3, 3)) ^
581 Td1(LTC_BYTE(t2, 2)) ^
582 Td2(LTC_BYTE(t1, 1)) ^
583 Td3(LTC_BYTE(t0, 0)) ^
584584 rk[3];
585585 }
586586 #endif
590590 * map cipher state to byte array block:
591591 */
592592 s0 =
593 (Td4[byte(t0, 3)] & 0xff000000) ^
594 (Td4[byte(t3, 2)] & 0x00ff0000) ^
595 (Td4[byte(t2, 1)] & 0x0000ff00) ^
596 (Td4[byte(t1, 0)] & 0x000000ff) ^
593 (Td4[LTC_BYTE(t0, 3)] & 0xff000000) ^
594 (Td4[LTC_BYTE(t3, 2)] & 0x00ff0000) ^
595 (Td4[LTC_BYTE(t2, 1)] & 0x0000ff00) ^
596 (Td4[LTC_BYTE(t1, 0)] & 0x000000ff) ^
597597 rk[0];
598598 STORE32H(s0, pt);
599599 s1 =
600 (Td4[byte(t1, 3)] & 0xff000000) ^
601 (Td4[byte(t0, 2)] & 0x00ff0000) ^
602 (Td4[byte(t3, 1)] & 0x0000ff00) ^
603 (Td4[byte(t2, 0)] & 0x000000ff) ^
600 (Td4[LTC_BYTE(t1, 3)] & 0xff000000) ^
601 (Td4[LTC_BYTE(t0, 2)] & 0x00ff0000) ^
602 (Td4[LTC_BYTE(t3, 1)] & 0x0000ff00) ^
603 (Td4[LTC_BYTE(t2, 0)] & 0x000000ff) ^
604604 rk[1];
605605 STORE32H(s1, pt+4);
606606 s2 =
607 (Td4[byte(t2, 3)] & 0xff000000) ^
608 (Td4[byte(t1, 2)] & 0x00ff0000) ^
609 (Td4[byte(t0, 1)] & 0x0000ff00) ^
610 (Td4[byte(t3, 0)] & 0x000000ff) ^
607 (Td4[LTC_BYTE(t2, 3)] & 0xff000000) ^
608 (Td4[LTC_BYTE(t1, 2)] & 0x00ff0000) ^
609 (Td4[LTC_BYTE(t0, 1)] & 0x0000ff00) ^
610 (Td4[LTC_BYTE(t3, 0)] & 0x000000ff) ^
611611 rk[2];
612612 STORE32H(s2, pt+8);
613613 s3 =
614 (Td4[byte(t3, 3)] & 0xff000000) ^
615 (Td4[byte(t2, 2)] & 0x00ff0000) ^
616 (Td4[byte(t1, 1)] & 0x0000ff00) ^
617 (Td4[byte(t0, 0)] & 0x000000ff) ^
614 (Td4[LTC_BYTE(t3, 3)] & 0xff000000) ^
615 (Td4[LTC_BYTE(t2, 2)] & 0x00ff0000) ^
616 (Td4[LTC_BYTE(t1, 1)] & 0x0000ff00) ^
617 (Td4[LTC_BYTE(t0, 0)] & 0x000000ff) ^
618618 rk[3];
619619 STORE32H(s3, pt+12);
620620
722722 {
723723 LTC_ARGCHK(keysize != NULL);
724724
725 if (*keysize < 16)
725 if (*keysize < 16) {
726726 return CRYPT_INVALID_KEYSIZE;
727 }
727728 if (*keysize < 24) {
728729 *keysize = 16;
729730 return CRYPT_OK;
730 } else if (*keysize < 32) {
731 }
732 if (*keysize < 32) {
731733 *keysize = 24;
732734 return CRYPT_OK;
733 } else {
734 *keysize = 32;
735 return CRYPT_OK;
736735 }
736 *keysize = 32;
737 return CRYPT_OK;
737738 }
738739
739740 #endif
2929 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
3030 };
3131
32 #define MIN_N 4
3332 #define MAX_N 10
34 #define MIN_ROUNDS (8 + MIN_N)
35 #define MAX_ROUNDS (8 + MAX_N)
36 #define MIN_KEYSIZEB (4*MIN_N)
37 #define MAX_KEYSIZEB (4*MAX_N)
38 #define BLOCKSIZE 128
39 #define BLOCKSIZEB (BLOCKSIZE/8)
40
4133
4234 /*
4335 * Though Anubis is endianness-neutral, the encryption tables are listed
372372 }
373373
374374 #ifndef __GNUC__
375 #define F(x) ((S1[byte(x,3)] + S2[byte(x,2)]) ^ S3[byte(x,1)]) + S4[byte(x,0)]
375 #define F(x) ((S1[LTC_BYTE(x,3)] + S2[LTC_BYTE(x,2)]) ^ S3[LTC_BYTE(x,1)]) + S4[LTC_BYTE(x,0)]
376376 #else
377 #define F(x) ((skey->blowfish.S[0][byte(x,3)] + skey->blowfish.S[1][byte(x,2)]) ^ skey->blowfish.S[2][byte(x,1)]) + skey->blowfish.S[3][byte(x,0)]
377 #define F(x) ((skey->blowfish.S[0][LTC_BYTE(x,3)] + skey->blowfish.S[1][LTC_BYTE(x,2)]) ^ skey->blowfish.S[2][LTC_BYTE(x,1)]) + skey->blowfish.S[3][LTC_BYTE(x,0)]
378378 #endif
379379
380380 /**
579579
580580 if (*keysize < 8) {
581581 return CRYPT_INVALID_KEYSIZE;
582 } else if (*keysize > 56) {
582 }
583 if (*keysize > 56) {
583584 *keysize = 56;
584585 }
585586 return CRYPT_OK;
507507 ulong32 I;
508508 I = (Km + R);
509509 I = ROL(I, Kr);
510 return ((S1[byte(I, 3)] ^ S2[byte(I,2)]) - S3[byte(I,1)]) + S4[byte(I,0)];
510 return ((S1[LTC_BYTE(I, 3)] ^ S2[LTC_BYTE(I,2)]) - S3[LTC_BYTE(I,1)]) + S4[LTC_BYTE(I,0)];
511511 }
512512
513513 INLINE static ulong32 FII(ulong32 R, ulong32 Km, ulong32 Kr)
515515 ulong32 I;
516516 I = (Km ^ R);
517517 I = ROL(I, Kr);
518 return ((S1[byte(I, 3)] - S2[byte(I,2)]) + S3[byte(I,1)]) ^ S4[byte(I,0)];
518 return ((S1[LTC_BYTE(I, 3)] - S2[LTC_BYTE(I,2)]) + S3[LTC_BYTE(I,1)]) ^ S4[LTC_BYTE(I,0)];
519519 }
520520
521521 INLINE static ulong32 FIII(ulong32 R, ulong32 Km, ulong32 Kr)
523523 ulong32 I;
524524 I = (Km - R);
525525 I = ROL(I, Kr);
526 return ((S1[byte(I, 3)] + S2[byte(I,2)]) ^ S3[byte(I,1)]) - S4[byte(I,0)];
526 return ((S1[LTC_BYTE(I, 3)] + S2[LTC_BYTE(I,2)]) ^ S3[LTC_BYTE(I,1)]) - S4[LTC_BYTE(I,0)];
527527 }
528528
529529 /**
706706 LTC_ARGCHK(keysize != NULL);
707707 if (*keysize < 5) {
708708 return CRYPT_INVALID_KEYSIZE;
709 } else if (*keysize > 16) {
709 }
710 if (*keysize > 16) {
710711 *keysize = 16;
711712 }
712713 return CRYPT_OK;
14311431 #else
14321432 {
14331433 ulong64 tmp;
1434 tmp = des_ip[0][byte(leftt, 0)] ^
1435 des_ip[1][byte(leftt, 1)] ^
1436 des_ip[2][byte(leftt, 2)] ^
1437 des_ip[3][byte(leftt, 3)] ^
1438 des_ip[4][byte(right, 0)] ^
1439 des_ip[5][byte(right, 1)] ^
1440 des_ip[6][byte(right, 2)] ^
1441 des_ip[7][byte(right, 3)];
1434 tmp = des_ip[0][LTC_BYTE(leftt, 0)] ^
1435 des_ip[1][LTC_BYTE(leftt, 1)] ^
1436 des_ip[2][LTC_BYTE(leftt, 2)] ^
1437 des_ip[3][LTC_BYTE(leftt, 3)] ^
1438 des_ip[4][LTC_BYTE(right, 0)] ^
1439 des_ip[5][LTC_BYTE(right, 1)] ^
1440 des_ip[6][LTC_BYTE(right, 2)] ^
1441 des_ip[7][LTC_BYTE(right, 3)];
14421442 leftt = (ulong32)(tmp >> 32);
14431443 right = (ulong32)(tmp & 0xFFFFFFFFUL);
14441444 }
14901490 #else
14911491 {
14921492 ulong64 tmp;
1493 tmp = des_fp[0][byte(leftt, 0)] ^
1494 des_fp[1][byte(leftt, 1)] ^
1495 des_fp[2][byte(leftt, 2)] ^
1496 des_fp[3][byte(leftt, 3)] ^
1497 des_fp[4][byte(right, 0)] ^
1498 des_fp[5][byte(right, 1)] ^
1499 des_fp[6][byte(right, 2)] ^
1500 des_fp[7][byte(right, 3)];
1493 tmp = des_fp[0][LTC_BYTE(leftt, 0)] ^
1494 des_fp[1][LTC_BYTE(leftt, 1)] ^
1495 des_fp[2][LTC_BYTE(leftt, 2)] ^
1496 des_fp[3][LTC_BYTE(leftt, 3)] ^
1497 des_fp[4][LTC_BYTE(right, 0)] ^
1498 des_fp[5][LTC_BYTE(right, 1)] ^
1499 des_fp[6][LTC_BYTE(right, 2)] ^
1500 des_fp[7][LTC_BYTE(right, 3)];
15011501 leftt = (ulong32)(tmp >> 32);
15021502 right = (ulong32)(tmp & 0xFFFFFFFFUL);
15031503 }
20672067 int des3_keysize(int *keysize)
20682068 {
20692069 LTC_ARGCHK(keysize != NULL);
2070 if (*keysize < 16)
2070 if (*keysize < 16) {
20712071 return CRYPT_INVALID_KEYSIZE;
2072 }
20722073 if (*keysize < 24) {
20732074 *keysize = 16;
20742075 return CRYPT_OK;
242242 if (*keysize >= 16) {
243243 *keysize = 16;
244244 return CRYPT_OK;
245 } else {
246 return CRYPT_INVALID_KEYSIZE;
247245 }
246 return CRYPT_INVALID_KEYSIZE;
248247 }
249248
250249 int kasumi_test(void)
2929 };
3030
3131 #define R 8
32 #define KEYSIZE 128
33 #define KEYSIZEB (KEYSIZE/8)
34 #define BLOCKSIZE 64
35 #define BLOCKSIZEB (BLOCKSIZE/8)
3632
3733 static const ulong64 T0[256] = {
3834 CONST64(0xbad3d268bbb96a01), CONST64(0x54fc4d19e59a66b1), CONST64(0x2f71bc93e26514cd), CONST64(0x749ccdb925871b51),
842838 if (*keysize >= 16) {
843839 *keysize = 16;
844840 return CRYPT_OK;
845 } else {
846 return CRYPT_INVALID_KEYSIZE;
847841 }
842 return CRYPT_INVALID_KEYSIZE;
848843 }
849844
850845 #endif
313313 LTC_ARGCHK(keysize != NULL);
314314 if (*keysize < 16) {
315315 return CRYPT_INVALID_KEYSIZE;
316 } else {
317 *keysize = 16;
318 return CRYPT_OK;
319 }
316 }
317 *keysize = 16;
318 return CRYPT_OK;
320319 }
321320
322321 #endif
400400 LTC_ARGCHK(keysize != NULL);
401401 if (*keysize < 1) {
402402 return CRYPT_INVALID_KEYSIZE;
403 } else if (*keysize > 128) {
403 }
404 if (*keysize > 128) {
404405 *keysize = 128;
405406 }
406407 return CRYPT_OK;
307307 LTC_ARGCHK(keysize != NULL);
308308 if (*keysize < 8) {
309309 return CRYPT_INVALID_KEYSIZE;
310 } else if (*keysize > 128) {
310 }
311 if (*keysize > 128) {
311312 *keysize = 128;
312313 }
313314 return CRYPT_OK;
317317 LTC_ARGCHK(keysize != NULL);
318318 if (*keysize < 8) {
319319 return CRYPT_INVALID_KEYSIZE;
320 } else if (*keysize > 128) {
320 }
321 if (*keysize > 128) {
321322 *keysize = 128;
322323 }
323324 return CRYPT_OK;
112112 unsigned char ka[LTC_SAFER_BLOCK_LEN + 1];
113113 unsigned char kb[LTC_SAFER_BLOCK_LEN + 1];
114114
115 if (LTC_SAFER_MAX_NOF_ROUNDS < nof_rounds)
115 if (LTC_SAFER_MAX_NOF_ROUNDS < nof_rounds) {
116116 nof_rounds = LTC_SAFER_MAX_NOF_ROUNDS;
117 }
117118 *key++ = (unsigned char)nof_rounds;
118119 ka[LTC_SAFER_BLOCK_LEN] = (unsigned char)0;
119120 kb[LTC_SAFER_BLOCK_LEN] = (unsigned char)0;
175176 }
176177 #endif
177178
178 int safer_k64_setup(const unsigned char *key, int keylen, int numrounds, symmetric_key *skey)
179 int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
179180 {
180181 LTC_ARGCHK(key != NULL);
181182 LTC_ARGCHK(skey != NULL);
182183
183 if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
184 if (num_rounds != 0 && (num_rounds < 6 || num_rounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
184185 return CRYPT_INVALID_ROUNDS;
185186 }
186187
188189 return CRYPT_INVALID_KEYSIZE;
189190 }
190191
191 Safer_Expand_Userkey(key, key, (unsigned int)(numrounds != 0 ?numrounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
192 return CRYPT_OK;
193 }
194
195 int safer_sk64_setup(const unsigned char *key, int keylen, int numrounds, symmetric_key *skey)
192 Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K64_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
193 return CRYPT_OK;
194 }
195
196 int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
196197 {
197198 LTC_ARGCHK(key != NULL);
198199 LTC_ARGCHK(skey != NULL);
199200
200 if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
201 if (num_rounds != 0 && (num_rounds < 6 || num_rounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
201202 return CRYPT_INVALID_ROUNDS;
202203 }
203204
205206 return CRYPT_INVALID_KEYSIZE;
206207 }
207208
208 Safer_Expand_Userkey(key, key, (unsigned int)(numrounds != 0 ?numrounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
209 return CRYPT_OK;
210 }
211
212 int safer_k128_setup(const unsigned char *key, int keylen, int numrounds, symmetric_key *skey)
209 Safer_Expand_Userkey(key, key, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
210 return CRYPT_OK;
211 }
212
213 int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
213214 {
214215 LTC_ARGCHK(key != NULL);
215216 LTC_ARGCHK(skey != NULL);
216217
217 if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
218 if (num_rounds != 0 && (num_rounds < 6 || num_rounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
218219 return CRYPT_INVALID_ROUNDS;
219220 }
220221
222223 return CRYPT_INVALID_KEYSIZE;
223224 }
224225
225 Safer_Expand_Userkey(key, key+8, (unsigned int)(numrounds != 0 ?numrounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
226 return CRYPT_OK;
227 }
228
229 int safer_sk128_setup(const unsigned char *key, int keylen, int numrounds, symmetric_key *skey)
226 Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0 ?num_rounds:LTC_SAFER_K128_DEFAULT_NOF_ROUNDS), 0, skey->safer.key);
227 return CRYPT_OK;
228 }
229
230 int safer_sk128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
230231 {
231232 LTC_ARGCHK(key != NULL);
232233 LTC_ARGCHK(skey != NULL);
233234
234 if (numrounds != 0 && (numrounds < 6 || numrounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
235 if (num_rounds != 0 && (num_rounds < 6 || num_rounds > LTC_SAFER_MAX_NOF_ROUNDS)) {
235236 return CRYPT_INVALID_ROUNDS;
236237 }
237238
239240 return CRYPT_INVALID_KEYSIZE;
240241 }
241242
242 Safer_Expand_Userkey(key, key+8, (unsigned int)(numrounds != 0?numrounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
243 return CRYPT_OK;
244 }
245
246 #ifdef LTC_CLEAN_STACK
247 static int _safer_ecb_encrypt(const unsigned char *block_in,
248 unsigned char *block_out,
243 Safer_Expand_Userkey(key, key+8, (unsigned int)(num_rounds != 0?num_rounds:LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS), 1, skey->safer.key);
244 return CRYPT_OK;
245 }
246
247 #ifdef LTC_CLEAN_STACK
248 static int _safer_ecb_encrypt(const unsigned char *pt,
249 unsigned char *ct,
249250 const symmetric_key *skey)
250251 #else
251 int safer_ecb_encrypt(const unsigned char *block_in,
252 unsigned char *block_out,
252 int safer_ecb_encrypt(const unsigned char *pt,
253 unsigned char *ct,
253254 const symmetric_key *skey)
254255 #endif
255256 { unsigned char a, b, c, d, e, f, g, h, t;
256257 unsigned int round;
257258 const unsigned char *key;
258259
259 LTC_ARGCHK(block_in != NULL);
260 LTC_ARGCHK(block_out != NULL);
260 LTC_ARGCHK(pt != NULL);
261 LTC_ARGCHK(ct != NULL);
261262 LTC_ARGCHK(skey != NULL);
262263
263264 key = skey->safer.key;
264 a = block_in[0]; b = block_in[1]; c = block_in[2]; d = block_in[3];
265 e = block_in[4]; f = block_in[5]; g = block_in[6]; h = block_in[7];
265 a = pt[0]; b = pt[1]; c = pt[2]; d = pt[3];
266 e = pt[4]; f = pt[5]; g = pt[6]; h = pt[7];
266267 if (LTC_SAFER_MAX_NOF_ROUNDS < (round = *key)) round = LTC_SAFER_MAX_NOF_ROUNDS;
267268 while(round-- > 0)
268269 {
279280 }
280281 a ^= *++key; b += *++key; c += *++key; d ^= *++key;
281282 e ^= *++key; f += *++key; g += *++key; h ^= *++key;
282 block_out[0] = a & 0xFF; block_out[1] = b & 0xFF;
283 block_out[2] = c & 0xFF; block_out[3] = d & 0xFF;
284 block_out[4] = e & 0xFF; block_out[5] = f & 0xFF;
285 block_out[6] = g & 0xFF; block_out[7] = h & 0xFF;
283 ct[0] = a & 0xFF; ct[1] = b & 0xFF;
284 ct[2] = c & 0xFF; ct[3] = d & 0xFF;
285 ct[4] = e & 0xFF; ct[5] = f & 0xFF;
286 ct[6] = g & 0xFF; ct[7] = h & 0xFF;
286287 return CRYPT_OK;
287288 }
288289
289290 #ifdef LTC_CLEAN_STACK
290 int safer_ecb_encrypt(const unsigned char *block_in,
291 unsigned char *block_out,
292 const symmetric_key *skey)
293 {
294 int err = _safer_ecb_encrypt(block_in, block_out, skey);
291 int safer_ecb_encrypt(const unsigned char *pt,
292 unsigned char *ct,
293 const symmetric_key *skey)
294 {
295 int err = _safer_ecb_encrypt(pt, ct, skey);
295296 burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
296297 return err;
297298 }
298299 #endif
299300
300301 #ifdef LTC_CLEAN_STACK
301 static int _safer_ecb_decrypt(const unsigned char *block_in,
302 unsigned char *block_out,
302 static int _safer_ecb_decrypt(const unsigned char *ct,
303 unsigned char *pt,
303304 const symmetric_key *skey)
304305 #else
305 int safer_ecb_decrypt(const unsigned char *block_in,
306 unsigned char *block_out,
306 int safer_ecb_decrypt(const unsigned char *ct,
307 unsigned char *pt,
307308 const symmetric_key *skey)
308309 #endif
309310 { unsigned char a, b, c, d, e, f, g, h, t;
310311 unsigned int round;
311312 const unsigned char *key;
312313
313 LTC_ARGCHK(block_in != NULL);
314 LTC_ARGCHK(block_out != NULL);
314 LTC_ARGCHK(ct != NULL);
315 LTC_ARGCHK(pt != NULL);
315316 LTC_ARGCHK(skey != NULL);
316317
317318 key = skey->safer.key;
318 a = block_in[0]; b = block_in[1]; c = block_in[2]; d = block_in[3];
319 e = block_in[4]; f = block_in[5]; g = block_in[6]; h = block_in[7];
319 a = ct[0]; b = ct[1]; c = ct[2]; d = ct[3];
320 e = ct[4]; f = ct[5]; g = ct[6]; h = ct[7];
320321 if (LTC_SAFER_MAX_NOF_ROUNDS < (round = *key)) round = LTC_SAFER_MAX_NOF_ROUNDS;
321322 key += LTC_SAFER_BLOCK_LEN * (1 + 2 * round);
322323 h ^= *key; g -= *--key; f -= *--key; e ^= *--key;
334335 d = LOG(d) ^ *--key; c = EXP(c) - *--key;
335336 b = EXP(b) - *--key; a = LOG(a) ^ *--key;
336337 }
337 block_out[0] = a & 0xFF; block_out[1] = b & 0xFF;
338 block_out[2] = c & 0xFF; block_out[3] = d & 0xFF;
339 block_out[4] = e & 0xFF; block_out[5] = f & 0xFF;
340 block_out[6] = g & 0xFF; block_out[7] = h & 0xFF;
338 pt[0] = a & 0xFF; pt[1] = b & 0xFF;
339 pt[2] = c & 0xFF; pt[3] = d & 0xFF;
340 pt[4] = e & 0xFF; pt[5] = f & 0xFF;
341 pt[6] = g & 0xFF; pt[7] = h & 0xFF;
341342 return CRYPT_OK;
342343 }
343344
344345 #ifdef LTC_CLEAN_STACK
345 int safer_ecb_decrypt(const unsigned char *block_in,
346 unsigned char *block_out,
347 const symmetric_key *skey)
348 {
349 int err = _safer_ecb_decrypt(block_in, block_out, skey);
346 int safer_ecb_decrypt(const unsigned char *ct,
347 unsigned char *pt,
348 const symmetric_key *skey)
349 {
350 int err = _safer_ecb_decrypt(ct, pt, skey);
350351 burn_stack(sizeof(unsigned char) * 9 + sizeof(unsigned int) + sizeof(unsigned char *));
351352 return err;
352353 }
357358 LTC_ARGCHK(keysize != NULL);
358359 if (*keysize < 8) {
359360 return CRYPT_INVALID_KEYSIZE;
360 } else {
361 *keysize = 8;
362 return CRYPT_OK;
363 }
361 }
362 *keysize = 8;
363 return CRYPT_OK;
364364 }
365365
366366 int safer_128_keysize(int *keysize)
368368 LTC_ARGCHK(keysize != NULL);
369369 if (*keysize < 16) {
370370 return CRYPT_INVALID_KEYSIZE;
371 } else {
372 *keysize = 16;
373 return CRYPT_OK;
374 }
371 }
372 *keysize = 16;
373 return CRYPT_OK;
375374 }
376375
377376 int safer_k64_test(void)
546546 {
547547 LTC_ARGCHK(keysize != NULL);
548548
549 if (*keysize < 16)
549 if (*keysize < 16) {
550550 return CRYPT_INVALID_KEYSIZE;
551 }
551552 if (*keysize < 24) {
552553 *keysize = 16;
553554 } else if (*keysize < 32) {
329329 LTC_ARGCHK(keysize != NULL);
330330 if (*keysize < 10) {
331331 return CRYPT_INVALID_KEYSIZE;
332 } else if (*keysize > 10) {
332 }
333 if (*keysize > 10) {
333334 *keysize = 10;
334335 }
335336 return CRYPT_OK;
3636 };
3737
3838 /* the two polynomials */
39 #ifndef LTC_TWOFISH_TABLES
3940 #define MDS_POLY 0x169
41 #endif
42 #ifndef LTC_TWOFISH_ALL_TABLES
4043 #define RS_POLY 0x14D
44 #endif
4145
4246 /* The 4x8 RS Linear Transform */
4347 static const unsigned char RS[4][8] = {
277281 #endif
278282
279283 /* the G function */
280 #define g_func(x, dum) (S1[byte(x,0)] ^ S2[byte(x,1)] ^ S3[byte(x,2)] ^ S4[byte(x,3)])
281 #define g1_func(x, dum) (S2[byte(x,0)] ^ S3[byte(x,1)] ^ S4[byte(x,2)] ^ S1[byte(x,3)])
284 #define g_func(x, dum) (S1[LTC_BYTE(x,0)] ^ S2[LTC_BYTE(x,1)] ^ S3[LTC_BYTE(x,2)] ^ S4[LTC_BYTE(x,3)])
285 #define g1_func(x, dum) (S2[LTC_BYTE(x,0)] ^ S3[LTC_BYTE(x,1)] ^ S4[LTC_BYTE(x,2)] ^ S1[LTC_BYTE(x,3)])
282286
283287 #else
284288
688692 int twofish_keysize(int *keysize)
689693 {
690694 LTC_ARGCHK(keysize);
691 if (*keysize < 16)
695 if (*keysize < 16) {
692696 return CRYPT_INVALID_KEYSIZE;
697 }
693698 if (*keysize < 24) {
694699 *keysize = 16;
695700 return CRYPT_OK;
696 } else if (*keysize < 32) {
701 }
702 if (*keysize < 32) {
697703 *keysize = 24;
698704 return CRYPT_OK;
699 } else {
700 *keysize = 32;
701 return CRYPT_OK;
702 }
703 }
704
705 #endif
706
707
705 }
706 *keysize = 32;
707 return CRYPT_OK;
708 }
709
710 #endif
708711
709712
710713 /* ref: $Format:%D$ */
2828
2929 LTC_ARGCHK(ccm != NULL);
3030 LTC_ARGCHK(key != NULL);
31 LTC_ARGCHK(taglen != 0);
3231
3332 XMEMSET(ccm, 0, sizeof(ccm_state));
3433
4039 return CRYPT_INVALID_CIPHER;
4140 }
4241
43 /* make sure the taglen is even and <= 16 */
44 ccm->taglen = taglen;
45 ccm->taglen &= ~1;
46 if (ccm->taglen > 16) {
47 ccm->taglen = 16;
48 }
49
50 /* can't use < 4 */
51 if (ccm->taglen < 4) {
42 /* make sure the taglen is valid */
43 if (taglen < 4 || taglen > 16 || (taglen % 2) == 1) {
5244 return CRYPT_INVALID_ARG;
5345 }
46 ccm->taglen = taglen;
5447
5548 /* schedule key */
5649 if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, &ccm->K)) != CRYPT_OK) {
7979 return CRYPT_INVALID_CIPHER;
8080 }
8181
82 /* make sure the taglen is even and <= 16 */
83 *taglen &= ~1;
84 if (*taglen > 16) {
85 *taglen = 16;
86 }
87
88 /* can't use < 4 */
89 if (*taglen < 4) {
82 /* make sure the taglen is valid */
83 if (*taglen < 4 || *taglen > 16 || (*taglen % 2) == 1) {
9084 return CRYPT_INVALID_ARG;
9185 }
9286
2424 unsigned long padlen;
2525 int err;
2626
27 if (inlen == 0) return CRYPT_OK; /* nothing to do */
2827 LTC_ARGCHK(st != NULL);
2928
3029 if (st->aadflg) {
2424 unsigned long padlen;
2525 int err;
2626
27 if (inlen == 0) return CRYPT_OK; /* nothing to do */
2827 LTC_ARGCHK(st != NULL);
2928
3029 if ((err = chacha_crypt(&st->chacha, in, inlen, out)) != CRYPT_OK) return err;
4242 LTC_ARGCHK(in != NULL);
4343 LTC_ARGCHK(out != NULL);
4444 LTC_ARGCHK(tag != NULL);
45 LTC_ARGCHK(taglen != NULL);
4546
4647 if ((err = chacha20poly1305_init(&st, key, keylen)) != CRYPT_OK) { goto LBL_ERR; }
4748 if ((err = chacha20poly1305_setiv(&st, iv, ivlen)) != CRYPT_OK) { goto LBL_ERR; }
5051 }
5152 if (direction == CHACHA20POLY1305_ENCRYPT) {
5253 if ((err = chacha20poly1305_encrypt(&st, in, inlen, out)) != CRYPT_OK) { goto LBL_ERR; }
54 if ((err = chacha20poly1305_done(&st, tag, taglen)) != CRYPT_OK) { goto LBL_ERR; }
5355 }
5456 else if (direction == CHACHA20POLY1305_DECRYPT) {
57 unsigned char buf[MAXBLOCKSIZE];
58 unsigned long buflen = sizeof(buf);
5559 if ((err = chacha20poly1305_decrypt(&st, in, inlen, out)) != CRYPT_OK) { goto LBL_ERR; }
60 if ((err = chacha20poly1305_done(&st, buf, &buflen)) != CRYPT_OK) { goto LBL_ERR; }
61 if (buflen != *taglen || XMEM_NEQ(buf, tag, buflen) != 0) {
62 err = CRYPT_ERROR;
63 goto LBL_ERR;
64 }
5665 }
5766 else {
5867 err = CRYPT_INVALID_ARG;
5968 goto LBL_ERR;
6069 }
61 err = chacha20poly1305_done(&st, tag, taglen);
6270 LBL_ERR:
6371 #ifdef LTC_CLEAN_STACK
6472 zeromem(&st, sizeof(chacha20poly1305_state));
9292 if ((err = gcm_process(gcm, pt, ptlen, ct, direction)) != CRYPT_OK) {
9393 goto LTC_ERR;
9494 }
95 err = gcm_done(gcm, tag, taglen);
95 if (direction == GCM_ENCRYPT) {
96 if ((err = gcm_done(gcm, tag, taglen)) != CRYPT_OK) {
97 goto LTC_ERR;
98 }
99 }
100 else if (direction == GCM_DECRYPT) {
101 unsigned char buf[MAXBLOCKSIZE];
102 unsigned long buflen = sizeof(buf);
103 if ((err = gcm_done(gcm, buf, &buflen)) != CRYPT_OK) {
104 goto LTC_ERR;
105 }
106 if (buflen != *taglen || XMEM_NEQ(buf, tag, buflen) != 0) {
107 err = CRYPT_ERROR;
108 }
109 }
110 else {
111 err = CRYPT_INVALID_ARG;
112 }
96113 LTC_ERR:
97114 XFREE(orig);
98115 return err;
6565 /* Checksum_* = Checksum_m xor (P_* || 1 || zeros(127-bitlen(P_*))) */
6666 ocb3_int_xor_blocks(ocb->checksum, ocb->checksum, pt+full_blocks_len, last_block_len);
6767 for(x=last_block_len; x<ocb->block_len; x++) {
68 if (x == last_block_len)
68 if (x == last_block_len) {
6969 ocb->checksum[x] ^= 0x80;
70 else
70 } else {
7171 ocb->checksum[x] ^= 0x00;
72 }
7273 }
7374
7475 /* Tag = ENCIPHER(K, Checksum_* xor Offset_* xor L_$) xor HASH(K,A) */
6767 /* Checksum_* = Checksum_m xor (P_* || 1 || zeros(127-bitlen(P_*))) */
6868 ocb3_int_xor_blocks(ocb->checksum, ocb->checksum, pt+full_blocks_len, last_block_len);
6969 for(x=last_block_len; x<ocb->block_len; x++) {
70 if (x == last_block_len)
70 if (x == last_block_len) {
7171 ocb->checksum[x] ^= 0x80;
72 else
72 } else {
7373 ocb->checksum[x] ^= 0x00;
74 }
7475 }
7576
7677 /* Tag = ENCIPHER(K, Checksum_* xor Offset_* xor L_$) xor HASH(K,A) */
8182 if ((err = cipher_descriptor[ocb->cipher].ecb_encrypt(ocb->tag_part, ocb->tag_part, &ocb->key)) != CRYPT_OK) {
8283 goto LBL_ERR;
8384 }
84 }
85 else {
85 } else {
8686 /* Tag = ENCIPHER(K, Checksum_m xor Offset_m xor L_$) xor HASH(K,A) */
8787 /* at this point we calculate only: Tag_part = ENCIPHER(K, Checksum_m xor Offset_m xor L_$) */
8888 for(x=0; x<ocb->block_len; x++) {
159159
160160 static void blake2b_set_lastblock(hash_state *md)
161161 {
162 if (md->blake2b.last_node)
162 if (md->blake2b.last_node) {
163163 blake2b_set_lastnode(md);
164
164 }
165165 md->blake2b.f[0] = CONST64(0xffffffffffffffff);
166166 }
167167
176176 unsigned long i;
177177 XMEMSET(&md->blake2b, 0, sizeof(md->blake2b));
178178
179 for (i = 0; i < 8; ++i)
179 for (i = 0; i < 8; ++i) {
180180 md->blake2b.h[i] = blake2b_IV[i];
181 }
181182 }
182183
183184 /* init xors IV with input parameter block */
218219
219220 LTC_ARGCHK(md != NULL);
220221
221 if ((!outlen) || (outlen > BLAKE2B_OUTBYTES))
222 if ((!outlen) || (outlen > BLAKE2B_OUTBYTES)) {
222223 return CRYPT_INVALID_ARG;
223
224 if ((key && !keylen) || (keylen && !key) || (keylen > BLAKE2B_KEYBYTES))
224 }
225 if ((key && !keylen) || (keylen && !key) || (keylen > BLAKE2B_KEYBYTES)) {
225226 return CRYPT_INVALID_ARG;
227 }
226228
227229 XMEMSET(P, 0, sizeof(P));
228230
415417
416418 /* if(md->blakebs.outlen != outlen) return CRYPT_INVALID_ARG; */
417419
418 if (blake2b_is_lastblock(md))
420 if (blake2b_is_lastblock(md)) {
419421 return CRYPT_ERROR;
422 }
420423
421424 blake2b_increment_counter(md, md->blake2b.curlen);
422425 blake2b_set_lastblock(md);
423426 XMEMSET(md->blake2b.buf + md->blake2b.curlen, 0, BLAKE2B_BLOCKBYTES - md->blake2b.curlen); /* Padding */
424427 blake2b_compress(md, md->blake2b.buf);
425428
426 for (i = 0; i < 8; ++i) /* Output full hash to temp buffer */
429 for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */
427430 STORE64L(md->blake2b.h[i], buffer + i * 8);
431 }
428432
429433 XMEMCPY(out, buffer, md->blake2b.outlen);
430434 zeromem(md, sizeof(hash_state));
151151
152152 static void blake2s_set_lastblock(hash_state *md)
153153 {
154 if (md->blake2s.last_node)
154 if (md->blake2s.last_node) {
155155 blake2s_set_lastnode(md);
156
156 }
157157 md->blake2s.f[0] = 0xffffffffUL;
158158 }
159159
168168 int i;
169169 XMEMSET(&md->blake2s, 0, sizeof(struct blake2s_state));
170170
171 for (i = 0; i < 8; ++i)
171 for (i = 0; i < 8; ++i) {
172172 md->blake2s.h[i] = blake2s_IV[i];
173 }
173174
174175 return CRYPT_OK;
175176 }
212213
213214 LTC_ARGCHK(md != NULL);
214215
215 if ((!outlen) || (outlen > BLAKE2S_OUTBYTES))
216 if ((!outlen) || (outlen > BLAKE2S_OUTBYTES)) {
216217 return CRYPT_INVALID_ARG;
217
218 if ((key && !keylen) || (keylen && !key) || (keylen > BLAKE2S_KEYBYTES))
218 }
219 if ((key && !keylen) || (keylen && !key) || (keylen > BLAKE2S_KEYBYTES)) {
219220 return CRYPT_INVALID_ARG;
221 }
220222
221223 XMEMSET(P, 0, sizeof(P));
222224
307309 LOAD32L(m[i], buf + i * sizeof(m[i]));
308310 }
309311
310 for (i = 0; i < 8; ++i)
312 for (i = 0; i < 8; ++i) {
311313 v[i] = md->blake2s.h[i];
314 }
312315
313316 v[8] = blake2s_IV[0];
314317 v[9] = blake2s_IV[1];
330333 ROUND(8);
331334 ROUND(9);
332335
333 for (i = 0; i < 8; ++i)
336 for (i = 0; i < 8; ++i) {
334337 md->blake2s.h[i] = md->blake2s.h[i] ^ v[i] ^ v[i + 8];
335
338 }
336339 return CRYPT_OK;
337340 }
338341 #undef G
403406
404407 /* if(md->blake2s.outlen != outlen) return CRYPT_INVALID_ARG; */
405408
406 if (blake2s_is_lastblock(md))
409 if (blake2s_is_lastblock(md)) {
407410 return CRYPT_ERROR;
408
411 }
409412 blake2s_increment_counter(md, md->blake2s.curlen);
410413 blake2s_set_lastblock(md);
411414 XMEMSET(md->blake2s.buf + md->blake2s.curlen, 0, BLAKE2S_BLOCKBYTES - md->blake2s.curlen); /* Padding */
412415 blake2s_compress(md, md->blake2s.buf);
413416
414 for (i = 0; i < 8; ++i) /* Output full hash to temp buffer */
417 for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */
415418 STORE32L(md->blake2s.h[i], buffer + i * 4);
419 }
416420
417421 XMEMCPY(out, buffer, md->blake2s.outlen);
418422 zeromem(md, sizeof(hash_state));
159159 @param len The length of the data (octets)
160160 @return CRYPT_OK if successful
161161 */
162 static int _chc_process(hash_state * md, const unsigned char *buf, unsigned long len);
162 static int _chc_process(hash_state * md, const unsigned char *in, unsigned long inlen);
163163 static HASH_PROCESS(_chc_process, chc_compress, chc, (unsigned long)cipher_blocksize)
164164
165165 /**
166166
167167 for(round = 0; round < SHA3_KECCAK_ROUNDS; round++) {
168168 /* Theta */
169 for(i = 0; i < 5; i++)
169 for(i = 0; i < 5; i++) {
170170 bc[i] = s[i] ^ s[i + 5] ^ s[i + 10] ^ s[i + 15] ^ s[i + 20];
171
171 }
172172 for(i = 0; i < 5; i++) {
173173 t = bc[(i + 4) % 5] ^ ROL64(bc[(i + 1) % 5], 1);
174 for(j = 0; j < 25; j += 5)
174 for(j = 0; j < 25; j += 5) {
175175 s[j + i] ^= t;
176 }
176177 }
177178 /* Rho Pi */
178179 t = s[1];
184185 }
185186 /* Chi */
186187 for(j = 0; j < 25; j += 5) {
187 for(i = 0; i < 5; i++)
188 for(i = 0; i < 5; i++) {
188189 bc[i] = s[j + i];
189 for(i = 0; i < 5; i++)
190 }
191 for(i = 0; i < 5; i++) {
190192 s[j + i] ^= (~bc[(i + 1) % 5]) & bc[(i + 2) % 5];
193 }
191194 }
192195 /* Iota */
193196 s[0] ^= keccakf_rndc[round];
312315 }
313316
314317 #ifdef LTC_SHA3
315 int sha3_done(hash_state *md, unsigned char *hash)
316 {
317 return _done(md, hash, CONST64(0x06));
318 int sha3_done(hash_state *md, unsigned char *out)
319 {
320 return _done(md, out, CONST64(0x06));
318321 }
319322 #endif
320323
321324 #ifdef LTC_KECCAK
322 int keccak_done(hash_state *md, unsigned char *hash)
323 {
324 return _done(md, hash, CONST64(0x01));
325 int keccak_done(hash_state *md, unsigned char *out)
326 {
327 return _done(md, out, CONST64(0x01));
325328 }
326329 #endif
327330
563563 {
564564 ulong64 tmp;
565565 tmp = (*c ^= x);
566 *a -= t1[byte(tmp, 0)] ^ t2[byte(tmp, 2)] ^ t3[byte(tmp, 4)] ^ t4[byte(tmp, 6)];
567 tmp = (*b += t4[byte(tmp, 1)] ^ t3[byte(tmp, 3)] ^ t2[byte(tmp,5)] ^ t1[byte(tmp,7)]);
566 *a -= t1[LTC_BYTE(tmp, 0)] ^ t2[LTC_BYTE(tmp, 2)] ^ t3[LTC_BYTE(tmp, 4)] ^ t4[LTC_BYTE(tmp, 6)];
567 tmp = (*b += t4[LTC_BYTE(tmp, 1)] ^ t3[LTC_BYTE(tmp, 3)] ^ t2[LTC_BYTE(tmp,5)] ^ t1[LTC_BYTE(tmp,7)]);
568568 switch (mul) {
569569 case 5: *b = (tmp << 2) + tmp; break;
570570 case 7: *b = (tmp << 3) - tmp; break;
2626
2727 /* version */
2828 #define CRYPT 0x0118
29 #define SCRYPT "1.18.1-develop"
29 #define SCRYPT "1.18.2-develop"
3030
3131 /* max size of either a cipher/hash block or symmetric key [largest of the two] */
3232 #define MAXBLOCKSIZE 144
3333
34