Codebase list libcryptx-perl / 496d9b3
New upstream version 0.054 Damyan Ivanov 6 years ago
523 changed file(s) with 18125 addition(s) and 5510 deletion(s). Raw diff Collapse all Expand all
00 Changes for CryptX
11
22 TODO:
3 - add support for PKCS#8 encrypted RSA+ECC private keys "-----BEGIN ENCRYPTED PRIVATE KEY-----"
4 - RSA|DSA|ECC: verify_key($level) (basic check + extented primality test)
5 - better primality testing: http://questhub.io/realm/perl/quest/519032ee1088c76505000035 (idea: mp_prime_lucas)
6 - DSA: generate_key($p, $q, $g), generate_key(\$dsa_params_der), generate_key($dsa_params_file)
73 - XS croaks should report the "real caller" (Crypt::Mac::*, Crypt::Mode::*, ...)
8 - maybe: add CCM interface for new-add-add-done mode
9 - maybe: add encode_b32/decode_b32
10
11 0.048 2017/05/31
4 - CCM interface new-add-add-done
5
6 0.054 2017-10-12
7 - fix Crypt::PK::DSA verify
8 - libtomcrypt updated to 1.18 (+ some extra patches)
9 - documentation fixes
10
11 0.053 2017-09-15
12 - fix Crypt::PK::DSA generate_key
13
14 0.051 2017-08-08
15 - INCOMPATIBLE CHANGE: Crypt::AuthEnc::OCB is now compliant with RFC 7253
16
17 0.050 2017-07-18
18 - fix cpantesters failures/warnings
19
20 0.049 2017-07-18
21 - libtomcrypt updated to 1.18-rc2 (+ some extra patches)
22 - REMOVED: Crypt::PK::DH encrypt decrypt sign_message verify_message sign_hash verify_hash
23 - NEW: Crypt::Misc - encode_b32*, decode_b32*, encode_b58*, decode_b58*
24 - Crypt::PK::RSA: import public key from X509 certificate
25 - Crypt::PK::DSA: improved generate_key()
26 - Crypt::PK::DH: improved generate_key()
27 - fix #36 aad_add is obsolete for all EncAuth algs (correct is adata_add)
28 - fix #37 GCM - Encryption of the empty string
29
30 0.048 2017-05-31
1231 - NEW: Crypt::Digest::SHA3_224
1332 - NEW: Crypt::Digest::SHA3_256
1433 - NEW: Crypt::Digest::SHA3_384
3352 - NEW: functions in Crypt::Misc - increment_octets_be, increment_octets_le
3453 - Crypt::PRNG now uses chacha20 prng by default
3554
36 0.047 2017/04/05
55 0.047 2017-04-05
3756 - fix #32 Compile "ar" step fails when Perl built with -flto (better version)
3857 - fix #33 build fails on freebsd 9.2 and 10.0 (ar: fatal: Numeric group ID too large)
3958
40 0.046 2017/04/04
59 0.046 2017-04-04
4160 - fix #32 Compile "ar" step fails when Perl built with -flto
4261
43 0.045 2017/03/31
62 0.045 2017-03-31
4463 - sync with libtomcrypt/develop
4564 - fix #30 fix on SPARC+SolarisStudio
4665 - fix #31 Fails tests without '.' in @INC
4766 - polish compiler warnings
4867
49 0.044 2016/11/28
68 0.044 2016-11-28
5069 - fix #27 Math::BigInt::LTM compatibility with older Math::BigInt
5170
52 0.043 2016/11/27
71 0.043 2016-11-27
5372 - fix #26 Math::BigInt::LTM compatibility with Math::BigInt 1.999801+
5473
55 0.042 2016/11/12
74 0.042 2016-11-12
5675 - RSA: sign/verify functions now support 'none' padding (INSECURE!)
5776 - RC2: min keylen 40bit, used to be 64bit (INSECURE!)
5877
59 0.041 2016/10/12
78 0.041 2016-10-12
6079 - ECC: ltc_ecc_is_point memory leak
6180 - DSA: properly handle FIPS 186-4 (4.6 + 4.7)
6281 - GCM: counter incrementation isn't stopped at 2^32 blocks, which breaks GCM
6382 - fix issue #24 Crypt::PK::ECC needs $VERSION (all *.pm have $VERSION)
6483
65 0.040 2016/09/12
84 0.040 2016-09-12
6685 - fix file permissions
6786 - fix compiler warnings
6887
69 0.039 2016/08/02
88 0.039 2016-08-02
7089 - fix build troubles for MacOS / PPC
7190
72 0.038 2016/07/06
91 0.038 2016-07-06
7392 - fix issue #20 DSA/RSA/ECC/DH key2hash - hexadecimal numbers are missing leading zero
7493 - Math::BigInt::LTM fixed mp_invmod(a,b,c) for b == 1
7594 - Math::BigInt::LTM fixed _log_int()
7796 - fix 'Please specify prototyping behavior for CryptX.xs'
7897 - libtomcrypt (renaming *tab.c > *tab.c.inc not needed anymore)
7998
80 0.037 2016/06/16
99 0.037 2016-06-16
81100 - fix issue #18 Minor issue with comment syntax
82101 - fix issue #19 t/checksum.t fails on AIX-5.3
83102
84 0.036 2016/06/07
103 0.036 2016-06-07
85104 - fix issue #17 ability to export ecc keys in short/oid form
86105
87 0.035 2016/06/03
106 0.035 2016-06-03
88107 - fix issue #14 Ensure Crypt::PK::ECC->key2hash()->{curve_name} is lowercase
89108 - fix issue #15 OpenSSL interoperability broken
90109
91 0.034 2016/05/11
110 0.034 2016-05-11
92111 - Prevent RSA import_key() from altering a JWK hash reference
93112
94 0.033 2016/05/09
113 0.033 2016-05-09
95114 - MSVC6 related fixes (needed for older ActivePerl@MSWin32)
96115
97 0.032 2016/05/04
116 0.032 2016-05-04
98117 - Crypt::PK::DH - accept base/prime values
99118 - new: DH methods export_key_raw, import_key_raw, params2hash
100119 - enhanced: DH method generate_key
101120 - new: Crypt::Checksum, Crypt::Checksum::CRC32, Crypt::Checksum::Adler32
102121
103 0.031 2016/05/01
122 0.031 2016-05-01
104123 - new: RSA+ECC method export_key_jwk_thumbprint()
105124 - new: Crypt::Misc functions random_v4uuid + is_v4uuid
106125 - fix: RSA+ECC export_key_jwk produces canonical JSON
108127 public keys exported be previous version can still be imported
109128 - fix: ECC import_key now accepts non-standard JWK curve names e.g. "secp112r1", "secp521r1"
110129
111 0.030 2016/04/13
130 0.030 2016-04-13
112131 - fix: 0.029 + 0.028 by mistake installed *.inc files to perl/(lib|site|vendor)
113132
114 0.029 2016/04/13
133 0.029 2016-04-13
115134 - NEW module: Math::BigInt::LTM
116135 - NEW module: Crypt::Misc
117136
118 0.028 2016/03/23
137 0.028 2016-03-23
119138 - IMPORTANT: switch from Module::Build to ExtUtils::MakeMaker
120139 - fix for broken DSA key (ssh format) loading
121140
122 0.027 2016/01/25
141 0.027 2016-01-25
123142 - sync with https://github.com/libtom/libtomcrypt (branch develop)
124143 - sync with https://github.com/libtom/libtommath (branch develop)
125144 - HP-UX related fixes
127146 - skip jwk.t if no JSON::* module available
128147 - does not require MIME::Base64 (we use base64 routines from libtomcrypt)
129148
130 0.026 2015/11/28
149 0.026 2015-11-28
131150 - switch to JSON::MaybeXS
132151 - Crypt::PRNG - rand/irand related cosmetics
133152 - consistently using UNIX newlines
134153
135 0.025 2015/07/07
154 0.025 2015-07-07
136155 - Crypt::PK::ECC+RSA export_key_jwk() allows to export a perl HASH with JWK structure
137156
138 0.024 2015/06/29
157 0.024 2015-06-29
139158 - new Crypt::PK::ECC methods
140159 verify_message_rfc7518()
141160 sign_message_rfc7518()
142161 curve2hash()
143162 - fix for Crypt::PK::RSA - bug in loading private key in JWK format
144163
145 0.023 2015/06/10
164 0.023 2015-06-10
146165 - support for older compilers (gcc3, vc6)
147166 - typo in documentation (by tomhukins)
148167
149 0.022 2015/05/22
168 0.022 2015-05-22
150169 - new: Crypt::PK::ECC+RSA export_key_jwk() - exporting JWK format
151170 - new: Crypt::Digest::SHA512_224
152171 - new: Crypt::Digest::SHA512_256
160179 - libtommath updated to the latest develop branch, commit 0fd5e6c17f Dec 11 14:59:35 2014 +0100
161180 - documentation fixes
162181
163 0.021 2014/01/23
182 0.021 2014-01-23
164183 - fixed asm(...) related compiler failures
165184 - dsa_encrypt_key small correction
166185 - optimized ecc_encrypt_key
167186
168 0.020 2014/01/18
187 0.020 2014-01-18
169188 - INCOMPATIBLE CHANGE: huge redesign of Crypt::PK::ECC
170189 - ECC now supports curves y^2 = x^3 + a*x + b
171190 - ECC you can use custom curves
173192 - enabling compile options ASM + ECC_TIMING_RESISTANT
174193 - added many test vectors (RSA, DSA, EC) for interoperability with openssl
175194
176 0.019 2013/10/20
195 0.019 2013-10-20
177196 - fixed broken CAMELLIA implementation
178197
179 0.018 2013/10/18
198 0.018 2013-10-18
180199 - DSA: make_key + sign_hash fixes
181200
182 0.017 2013/09/24
201 0.017 2013-09-24
183202 - lowering MIME::Base64 version requirement
184203 - support for import/export of password protected RSA/DSA keys
185204 - RSA: added - export_key_pem('public_x509')
187206 - added openssl test vectors
188207 - fixed compiler warnings (RSA/DSA/ECC/DH)
189208
190 0.016 2013/09/15
209 0.016 2013-09-15
191210 - added missing test for key2hash, sign_hash, verify_hash
192211 - fixed build failures on VC6
193212
194 0.015 2013/09/12
213 0.015 2013-09-12
195214 - only documentation fixes
196215
197 0.014 2013/09/11
216 0.014 2013-09-11
198217 - Crypt::Digest::NNN + Crypt::Mac::NNN - can produce Base64-URL-Safe encoded digest/mac
199218 - Crypt::PRNG + Crypt::PRNG::NNN - Base64-URL-Safe encoded random bytes (random_bytes_b64u/bytes_b64u)
200219 - Crypt::PK::RSA/DSA/DH/ECC - sign/verify replaced by sign_message/verify_message + sign_hash/verify_hash
201220 - Crypt::PK::RSA/DSA/DH/ECC - new method key2hash
202221 - documentation fixes
203222
204 0.013 2013/08/28
223 0.013 2013-08-28
205224 - DSA/RSA/ECC/DH - importing keys from string changed - now: $pk->import_key(\$buffer_with_key)
206225 - DSA/RSA/ECC/DH - size() and is_private() now return undef if no key loaded
207226 - improved RSA doc
208227
209 0.012 2013/06/17
228 0.012 2013-06-17
210229 - README, LICENSE etc. to improve CPANTS score
211230 - somehow works with perl 5.6.2
212231
213 0.011 2013/06/15
232 0.011 2013-06-15
214233 - fixing various compiler warnings
215234
216 0.009 2013/05/19
235 0.009 2013-05-19
217236 - doc fixes
218237 - requires perl 5.8.8 or higher
219238 - INCOMPATIBILITY: all digest related 'xxx_base64' functions renamed to 'xxx_b64'
220239
221 0.008 2013/05/02
240 0.008 2013-05-02
222241 - fixed prng test failures
223242 - Crypt::Digest::* croaks with the "real caller" (not a nice solution)
224243
225 0.007 2013/04/23
244 0.007 2013-04-23
226245 - Crypt::PRNG supports add_entropy() - without params
227246 - Crypt::PRNG fork-safe & thread-safe
228247 - random_string has default $len = 20
229248 - doc fixes
230249 - cpan tester failure fix for pk_dsa.t
231250
232 0.006 2013/04/19
251 0.006 2013-04-19
233252 - added Crypt::KeyDerivation
234253 - Win64 compatibility
235254
236 0.005 2013/04/18
255 0.005 2013-04-18
237256 - added Crypt::PRNG::Fortuna|RC4|Sober128|Yarrow
238257 - added Crypt::PK::RSA|DSA|ECC|DH
239258
240 0.004 2013/04/16
259 0.004 2013-04-16
241260 - removing illegal Crypt::Random
242261
243 0.003 2013/04/16
262 0.003 2013-04-16
244263 - added Crypt::Mode::CBC|CFB|CTR|ECB|OFB
245264 - added Crypt::AuthEnc::CCM|EAX|GCM|OCB
246265
247 0.002 2013/04/11
266 0.002 2013-04-11
248267 - first release on CPAN
481481 {
482482 STRLEN len, i = 0;
483483 unsigned char *out_data, *in_data;
484 int rv;
485484
486485 if (!SvPOK(in)) XSRETURN_UNDEF;
487486 in_data = (unsigned char *) SvPVbyte(in, len);
508507 {
509508 STRLEN len, i = 0;
510509 unsigned char *out_data, *in_data;
511 int rv;
512510
513511 if (!SvPOK(in)) XSRETURN_UNDEF;
514512 in_data = (unsigned char *) SvPVbyte(in, len);
529527 OUTPUT:
530528 RETVAL
531529
530 SV *
531 CryptX__radix_to_bin(char *in, int radix)
532 CODE:
533 {
534 STRLEN len;
535 unsigned char *out_data;
536 mp_int mpi;
537
538 if (in == NULL || strlen(in) == 0) XSRETURN_UNDEF;
539
540 if (mp_init(&mpi) != CRYPT_OK) XSRETURN_UNDEF;
541
542 if (mp_read_radix(&mpi, in, radix) == CRYPT_OK) {
543 len = mp_unsigned_bin_size(&mpi);
544 RETVAL = NEWSV(0, len);
545 SvPOK_only(RETVAL);
546 SvCUR_set(RETVAL, len);
547 out_data = (unsigned char *)SvPV_nolen(RETVAL);
548 mp_to_unsigned_bin(&mpi, out_data);
549 mp_clear(&mpi);
550 }
551 else {
552 XSRETURN_UNDEF;
553 }
554 }
555 OUTPUT:
556 RETVAL
557
558 SV *
559 CryptX__bin_to_radix(SV *in, int radix)
560 CODE:
561 {
562 STRLEN len;
563 unsigned char *in_data;
564 char *out_data;
565 mp_int mpi, tmp;
566 mp_digit d;
567 int digits = 0;
568
569 if (!SvPOK(in) || radix < 2 || radix > 64) XSRETURN_UNDEF;
570 in_data = (unsigned char *) SvPVbyte(in, len);
571 if (len == 0) XSRETURN_UNDEF;
572
573 mp_init(&mpi);
574 if (mp_read_unsigned_bin(&mpi, in_data, len) == CRYPT_OK) {
575 mp_init_copy(&tmp, &mpi);
576 while (mp_iszero(&tmp) == MP_NO) {
577 mp_div_d(&tmp, (mp_digit)radix, &tmp, &d);
578 digits++;
579 }
580 mp_clear(&tmp);
581
582 RETVAL = NEWSV(0, digits + 1);
583 SvPOK_only(RETVAL);
584 out_data = SvPV_nolen(RETVAL);
585 mp_toradix(&mpi, out_data, radix);
586 SvCUR_set(RETVAL, digits);
587 mp_clear(&mpi);
588 }
589 else {
590 XSRETURN_UNDEF;
591 }
592 }
593 OUTPUT:
594 RETVAL
595
596 SV *
597 CryptX__encode_b32(SV *bytes, unsigned idx)
598 CODE:
599 {
600 STRLEN inlen, outlen, i, leven;
601 unsigned char *out, *in, *codes;
602 char *alphabet[] = {
603 "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", /* rfc4648 */
604 "0123456789ABCDEFGHIJKLMNOPQRSTUV", /* base32hex */
605 "ybndrfg8ejkmcpqxot1uwisza345h769", /* zbase32 */
606 "0123456789ABCDEFGHJKMNPQRSTVWXYZ" /* crockford */
607 };
608
609 if (!SvOK(bytes)) {
610 /* for undefined input return "" (empty string) */
611 RETVAL = newSVpv("", 0);
612 }
613 else {
614 if (!SvPOK(bytes) || idx > 3) XSRETURN_UNDEF; /* error */
615 in = (unsigned char *) SvPVbyte(bytes, inlen);
616 if (in == NULL) XSRETURN_UNDEF; /* error */
617 if (inlen == 0) {
618 RETVAL = newSVpv("", 0);
619 }
620 else {
621 codes = (unsigned char*)alphabet[idx];
622 outlen = (8 * inlen + 4) / 5;
623 RETVAL = NEWSV(0, outlen);
624 SvPOK_only(RETVAL);
625 SvCUR_set(RETVAL, outlen);
626 out = (unsigned char *)SvPV_nolen(RETVAL);
627
628 leven = 5 * (inlen / 5);
629 for (i = 0; i < leven; i += 5) {
630 *out++ = codes[(in[0] >> 3) & 0x1F];
631 *out++ = codes[(((in[0] & 0x7) << 2) + (in[1] >> 6)) & 0x1F];
632 *out++ = codes[(in[1] >> 1) & 0x1F];
633 *out++ = codes[(((in[1] & 0x1) << 4) + (in[2] >> 4)) & 0x1F];
634 *out++ = codes[(((in[2] & 0xF) << 1) + (in[3] >> 7)) & 0x1F];
635 *out++ = codes[(in[3] >> 2) & 0x1F];
636 *out++ = codes[(((in[3] & 0x3) << 3) + (in[4] >> 5)) & 0x1F];
637 *out++ = codes[in[4] & 0x1F];
638 in += 5;
639 }
640 if (i < inlen) {
641 unsigned a = in[0];
642 unsigned b = (i+1 < inlen) ? in[1] : 0;
643 unsigned c = (i+2 < inlen) ? in[2] : 0;
644 unsigned d = (i+3 < inlen) ? in[3] : 0;
645 *out++ = codes[(a >> 3) & 0x1F];
646 *out++ = codes[(((a & 0x7) << 2) + (b >> 6)) & 0x1F];
647 if (i+1 < inlen) {
648 *out++ = codes[(b >> 1) & 0x1F];
649 *out++ = codes[(((b & 0x1) << 4) + (c >> 4)) & 0x1F];
650 }
651 if (i+2 < inlen) {
652 *out++ = codes[(((c & 0xF) << 1) + (d >> 7)) & 0x1F];
653 *out++ = codes[(d >> 2) & 0x1F];
654 }
655 if (i+3 < inlen) {
656 *out++ = codes[((d & 0x3) << 3) & 0x1F];
657 }
658 }
659 }
660 }
661 }
662 OUTPUT:
663 RETVAL
664
665 SV *
666 CryptX__decode_b32(SV *base32, unsigned idx)
667 CODE:
668 {
669 STRLEN x, inlen, outlen;
670 int y = 0;
671 ulong64 t = 0;
672 unsigned char c, *in, *out, *map;
673 unsigned char tables[4][43] = {
674 { /* rfc4648 ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 */
675 99/*0*/,99/*1*/,26/*2*/,27/*3*/,28/*4*/,29/*5*/,30/*6*/,31/*7*/,99/*8*/,99/*9*/,
676 99/*:*/,99/*;*/,99/*<*/,99/*=*/,99/*>*/,99/*?*/,99/*@*/,
677 0/*A*/, 1/*B*/, 2/*C*/, 3/*D*/, 4/*E*/, 5/*F*/, 6/*G*/, 7/*H*/, 8/*I*/, 9/*J*/,10/*K*/,11/*L*/,12/*M*/,
678 13/*N*/,14/*O*/,15/*P*/,16/*Q*/,17/*R*/,18/*S*/,19/*T*/,20/*U*/,21/*V*/,22/*W*/,23/*X*/,24/*Y*/,25/*Z*/
679 },
680 { /* base32hex 0123456789ABCDEFGHIJKLMNOPQRSTUV */
681 0/*0*/, 1/*1*/, 2/*2*/, 3/*3*/, 4/*4*/, 5/*5*/, 6/*6*/, 7/*7*/, 8/*8*/, 9/*9*/,
682 99/*:*/,99/*;*/,99/*<*/,99/*=*/,99/*>*/,99/*?*/,99/*@*/,
683 10/*A*/,11/*B*/,12/*C*/,13/*D*/,14/*E*/,15/*F*/,16/*G*/,17/*H*/,18/*I*/,19/*J*/,20/*K*/,21/*L*/,22/*M*/,
684 23/*N*/,24/*O*/,25/*P*/,26/*Q*/,27/*R*/,28/*S*/,29/*T*/,30/*U*/,31/*V*/,99/*W*/,99/*X*/,99/*Y*/,99/*Z*/
685 },
686 { /* zbase32 YBNDRFG8EJKMCPQXOT1UWISZA345H769 */
687 99/*0*/,18/*1*/,99/*2*/,25/*3*/,26/*4*/,27/*5*/,30/*6*/,29/*7*/, 7/*8*/,31/*9*/,
688 99/*:*/,99/*;*/,99/*<*/,99/*=*/,99/*>*/,99/*?*/,99/*@*/,
689 24/*A*/, 1/*B*/,12/*C*/, 3/*D*/, 8/*E*/, 5/*F*/, 6/*G*/,28/*H*/,21/*I*/, 9/*J*/,10/*K*/,99/*L*/,11/*M*/,
690 2/*N*/,16/*O*/,13/*P*/,14/*Q*/, 4/*R*/,22/*S*/,17/*T*/,19/*U*/,99/*V*/,20/*W*/,15/*X*/, 0/*Y*/,23/*Z*/
691 },
692 { /* crockford 0123456789ABCDEFGHJKMNPQRSTVWXYZ + O=>0 + IL=>1 */
693 0/*0*/, 1/*1*/, 2/*2*/, 3/*3*/, 4/*4*/, 5/*5*/, 6/*6*/, 7/*7*/, 8/*8*/, 9/*9*/,
694 99/*:*/,99/*;*/,99/*<*/,99/*=*/,99/*>*/,99/*?*/,99/*@*/,
695 10/*A*/,11/*B*/,12/*C*/,13/*D*/,14/*E*/,15/*F*/,16/*G*/,17/*H*/, 1/*I*/,18/*J*/,19/*K*/, 1/*L*/,20/*M*/,
696 21/*N*/, 0/*O*/,22/*P*/,23/*Q*/,24/*R*/,25/*S*/,26/*T*/,99/*U*/,27/*V*/,28/*W*/,29/*X*/,30/*Y*/,31/*Z*/
697 }
698 };
699
700 if (!SvOK(base32)) {
701 /* for undefined input return "" (empty string) */
702 RETVAL = newSVpv("", 0);
703 }
704 else {
705 if (!SvPOK(base32) || idx > 3) XSRETURN_UNDEF; /* error */
706 in = (unsigned char *) SvPVbyte(base32, inlen);
707 if (in == NULL) XSRETURN_UNDEF; /* error */
708
709 while (inlen>0 && in[inlen-1] == '=') inlen--;
710 if (inlen == 0) {
711 RETVAL = newSVpv("", 0);
712 }
713 else {
714 x = inlen % 8;
715 if (x == 1 || x == 3 || x == 6) XSRETURN_UNDEF; /* error */
716 outlen = (inlen * 5) / 8;
717 RETVAL = NEWSV(0, outlen);
718 SvPOK_only(RETVAL);
719 SvCUR_set(RETVAL, outlen);
720 out = (unsigned char *)SvPV_nolen(RETVAL);
721 map = tables[idx];
722 for (x = 0; x < inlen; x++) {
723 c = in[x];
724 /* convert to upper case */
725 if ((c >= 'a') && (c <= 'z')) c -= 32;
726 /* '0' = 48 .. 'Z' = 90 */
727 if (c < 48 || c > 90 || map[c-48] > 31) XSRETURN_UNDEF; /* error */
728 t = (t<<5)|map[c-48];
729 if (++y == 8) {
730 *out++ = (unsigned char)((t>>32) & 255);
731 *out++ = (unsigned char)((t>>24) & 255);
732 *out++ = (unsigned char)((t>>16) & 255);
733 *out++ = (unsigned char)((t>> 8) & 255);
734 *out++ = (unsigned char)( t & 255);
735 y = 0;
736 t = 0;
737 }
738 }
739 if (y > 0) {
740 t = t << (5 * (8 - y));
741 if (y >= 2) *out++ = (unsigned char)((t>>32) & 255);
742 if (y >= 4) *out++ = (unsigned char)((t>>24) & 255);
743 if (y >= 5) *out++ = (unsigned char)((t>>16) & 255);
744 if (y >= 7) *out++ = (unsigned char)((t>> 8) & 255);
745 }
746 }
747 }
748 }
749 OUTPUT:
750 RETVAL
751
752 SV *
753 CryptX__ltc_build_settings()
754 CODE:
755 RETVAL = newSVpv(crypt_build_settings, 0);
756 OUTPUT:
757 RETVAL
758
759 SV *
760 CryptX__ltc_mp_name()
761 CODE:
762 RETVAL = newSVpv(ltc_mp.name, 0);
763 OUTPUT:
764 RETVAL
765
766 int
767 CryptX__ltc_mp_bits_per_digit()
768 CODE:
769 RETVAL = ltc_mp.bits_per_digit;
770 OUTPUT:
771 RETVAL
772
532773 ###############################################################################
533774
534775 INCLUDE: inc/CryptX_Digest.xs.inc
535 INCLUDE: inc/CryptX_Digest_SHAKE.xs.inc
776 INCLUDE: inc/CryptX_Digest_SHAKE.xs.inc
536777 INCLUDE: inc/CryptX_Cipher.xs.inc
537778
538779 INCLUDE: inc/CryptX_Checksum_Adler32.xs.inc
137137 META.json
138138 META.yml
139139 ppport.h
140 README
140 README.md
141141 src/ltc/ciphers/aes/aes.c
142142 src/ltc/ciphers/aes/aes_tab.c
143143 src/ltc/ciphers/anubis.c
200200 src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c
201201 src/ltc/encauth/ocb3/ocb3_encrypt_last.c
202202 src/ltc/encauth/ocb3/ocb3_init.c
203 src/ltc/encauth/ocb3/ocb3_int_aad_add_block.c
204 src/ltc/encauth/ocb3/ocb3_int_calc_offset_zero.c
205203 src/ltc/encauth/ocb3/ocb3_int_ntz.c
206204 src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c
207205 src/ltc/hashes/blake2b.c
292290 src/ltc/math/fp/ltc_ecc_fp_mulmod.c
293291 src/ltc/math/ltm_desc.c
294292 src/ltc/math/multi.c
293 src/ltc/math/radix_to_bin.c
295294 src/ltc/math/rand_bn.c
296295 src/ltc/math/rand_prime.c
297296 src/ltc/math/tfm_desc.c
299298 src/ltc/misc/base64/base64_decode.c
300299 src/ltc/misc/base64/base64_encode.c
301300 src/ltc/misc/burn_stack.c
301 src/ltc/misc/compare_testvector.c
302302 src/ltc/misc/crc32.c
303303 src/ltc/misc/crypt/crypt.c
304304 src/ltc/misc/crypt/crypt_argchk.c
305305 src/ltc/misc/crypt/crypt_cipher_descriptor.c
306306 src/ltc/misc/crypt/crypt_cipher_is_valid.c
307 src/ltc/misc/crypt/crypt_constants.c
307308 src/ltc/misc/crypt/crypt_find_cipher.c
308309 src/ltc/misc/crypt/crypt_find_cipher_any.c
309310 src/ltc/misc/crypt/crypt_find_cipher_id.c
319320 src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c
320321 src/ltc/misc/crypt/crypt_prng_descriptor.c
321322 src/ltc/misc/crypt/crypt_prng_is_valid.c
323 src/ltc/misc/crypt/crypt_prng_rng_descriptor.c
324 src/ltc/misc/crypt/crypt_register_all_ciphers.c
325 src/ltc/misc/crypt/crypt_register_all_hashes.c
326 src/ltc/misc/crypt/crypt_register_all_prngs.c
322327 src/ltc/misc/crypt/crypt_register_cipher.c
323328 src/ltc/misc/crypt/crypt_register_hash.c
324329 src/ltc/misc/crypt/crypt_register_prng.c
330 src/ltc/misc/crypt/crypt_sizes.c
325331 src/ltc/misc/crypt/crypt_unregister_cipher.c
326332 src/ltc/misc/crypt/crypt_unregister_hash.c
327333 src/ltc/misc/crypt/crypt_unregister_prng.c
396402 src/ltc/pk/asn1/der/sequence/der_encode_subject_public_key_info.c
397403 src/ltc/pk/asn1/der/sequence/der_length_sequence.c
398404 src/ltc/pk/asn1/der/sequence/der_sequence_free.c
405 src/ltc/pk/asn1/der/sequence/der_sequence_shrink.c
399406 src/ltc/pk/asn1/der/set/der_encode_set.c
400407 src/ltc/pk/asn1/der/set/der_encode_setof.c
401408 src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c
410417 src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c
411418 src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c
412419 src/ltc/pk/dh/dh.c
413 src/ltc/pk/dh/dh_static.c
414 src/ltc/pk/dh/dh_static.h
415 src/ltc/pk/dh/dh_sys.c
420 src/ltc/pk/dh/dh_check_pubkey.c
421 src/ltc/pk/dh/dh_export.c
422 src/ltc/pk/dh/dh_export_key.c
423 src/ltc/pk/dh/dh_free.c
424 src/ltc/pk/dh/dh_generate_key.c
425 src/ltc/pk/dh/dh_import.c
426 src/ltc/pk/dh/dh_set.c
427 src/ltc/pk/dh/dh_set_pg_dhparam.c
428 src/ltc/pk/dh/dh_shared_secret.c
416429 src/ltc/pk/dsa/dsa_decrypt_key.c
417430 src/ltc/pk/dsa/dsa_encrypt_key.c
418431 src/ltc/pk/dsa/dsa_export.c
419432 src/ltc/pk/dsa/dsa_free.c
433 src/ltc/pk/dsa/dsa_generate_key.c
434 src/ltc/pk/dsa/dsa_generate_pqg.c
420435 src/ltc/pk/dsa/dsa_import.c
421 src/ltc/pk/dsa/dsa_import_radix.c
422436 src/ltc/pk/dsa/dsa_make_key.c
437 src/ltc/pk/dsa/dsa_set.c
438 src/ltc/pk/dsa/dsa_set_pqg_dsaparam.c
423439 src/ltc/pk/dsa/dsa_shared_secret.c
424440 src/ltc/pk/dsa/dsa_sign_hash.c
425441 src/ltc/pk/dsa/dsa_verify_hash.c
479495 src/ltc/pk/rsa/rsa_get_size.c
480496 src/ltc/pk/rsa/rsa_import.c
481497 src/ltc/pk/rsa/rsa_import_pkcs8.c
482 src/ltc/pk/rsa/rsa_import_radix.c
483498 src/ltc/pk/rsa/rsa_import_x509.c
484499 src/ltc/pk/rsa/rsa_make_key.c
500 src/ltc/pk/rsa/rsa_set.c
485501 src/ltc/pk/rsa/rsa_sign_hash.c
486502 src/ltc/pk/rsa/rsa_sign_saltlen_get.c
487503 src/ltc/pk/rsa/rsa_verify_hash.c
764780 t/data/openssl_ec1.pub.pem
765781 t/data/openssl_ec1.pubc.der
766782 t/data/openssl_ec1.pubc.pem
783 t/data/openssl_rsa-x509.der
784 t/data/openssl_rsa-x509.pem
767785 t/data/openssl_rsa1.der
768786 t/data/openssl_rsa1.pem
769787 t/data/openssl_rsa1.pubonly.der
925943 t/prng_sober128.t
926944 t/prng_yarrow.t
927945 t/sshkey.t
946 t/wycheproof.t
947 t/wycheproof/aes_gcm_test.json
948 t/wycheproof/dsa_test.json
949 t/wycheproof/ecdh_webcrypto_test.json
950 t/wycheproof/ecdsa_test.json
951 t/wycheproof/ecdsa_webcrypto_test.json
952 t/wycheproof/rsa_signature_test.json
928953 typemap
33 "Karel Miko"
44 ],
55 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010",
6 "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010",
77 "license" : [
88 "perl_5"
99 ],
1010 "meta-spec" : {
1111 "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
12 "version" : "2"
12 "version" : 2
1313 },
1414 "name" : "CryptX",
1515 "no_index" : {
4444 "url" : "https://github.com/DCIT/perl-CryptX"
4545 }
4646 },
47 "version" : "0.048",
48 "x_serialization_backend" : "JSON::PP version 2.27400"
47 "version" : "0.054",
48 "x_serialization_backend" : "JSON::PP version 2.94"
4949 }
66 configure_requires:
77 ExtUtils::MakeMaker: '0'
88 dynamic_config: 1
9 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010'
9 generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010'
1010 license: perl
1111 meta-spec:
1212 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2121 resources:
2222 bugtracker: https://github.com/DCIT/perl-CryptX/issues
2323 repository: https://github.com/DCIT/perl-CryptX
24 version: '0.048'
24 version: '0.054'
2525 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
1010 glob('src/ltc/*/*/*/*/*.c'),
1111 );
1212 my $myextlib = "src/liballinone$Config{lib_ext}";
13 my $mycflags = "$Config{cccdlflags} $Config{ccflags} $Config{optimize} -Iltm -Iltc/headers -DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC";
13 my $mycflags = "$Config{ccflags} $Config{cccdlflags} $Config{optimize}";
1414
1515 #FIX: gcc with -flto is a trouble maker see https://github.com/DCIT/perl-CryptX/issues/32
1616 $mycflags =~ s/-flto\b//g;
17
18 #FIX: avoid -Wwrite-strings -Wcast-qual -pedantic -pedantic-errors -ansi -std=c89
19 $mycflags =~ s/-pedantic\b//g;
20 $mycflags =~ s/-pedantic-errors\b//g;
21 $mycflags =~ s/-std=c89\b//g;
22 $mycflags =~ s/-ansi\b//g;
23 $mycflags =~ s/-Wwrite-strings\b//g;
24 $mycflags =~ s/-Wcast-qual\b//g;
1725
1826 #FIX: avoid "ar: fatal: Numeric group ID too large" see https://github.com/DCIT/perl-CryptX/issues/33
1927 my $myarflags = '$(AR_STATIC_ARGS)';
2028 if ($^O ne 'MSWin32' && $Config{ar}) {
2129 # for ar's "deterministic mode" we need GNU binutils 2.20+ (2009-10-16)
22 my $arver = `$Config{ar} --version`;
30 my $arver = `$Config{ar} --version 2>/dev/null`;
2331 my ($maj, $min) = $arver =~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s;
2432 $myarflags = 'rcD' if ($maj && $min && $maj >= 2 && $min >= 20) || $arver=~ /^BSD ar /;
2533 }
3240 MIN_PERL_VERSION => '5.006',
3341 LICENSE => 'perl_5',
3442 META_MERGE => { resources => { repository => 'https://github.com/DCIT/perl-CryptX', bugtracker => 'https://github.com/DCIT/perl-CryptX/issues' } },
35 DEFINE => '-DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC',
36 INC => '-Isrc/ltc/headers -Isrc/ltm',
37 LIBS => [''],
38 MYEXTLIB => $myextlib,
39 clean => { 'FILES' => join(' ', @myobjs, $myextlib) },
43 dist => { 'PREOP' => 'perldoc -u lib/CryptX.pm | pod2markdown > README.md' },
44 ($ENV{CRYPTX_CFLAGS} || $ENV{CRYPTX_LDFLAGS})
45 ?
46 (
47 # e.g. CRYPTX_LDFLAGS='-L/usr/local/lib -ltommath -ltomcrypt' CRYPTX_CFLAGS='-DLTM_DESC -I/usr/local/include' perl Makefile.PL
48 INC => $ENV{CRYPTX_CFLAGS},
49 LIBS => [ $ENV{CRYPTX_LDFLAGS} ],
50 )
51 :
52 (
53 # bundled libtomcrypt + libtommath
54 INC => '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm',
55 MYEXTLIB => $myextlib,
56 clean => { 'FILES' => join(' ', @myobjs, $myextlib) },
57 )
4058 );
4159
4260 my $eumm_ver = eval $ExtUtils::MakeMaker::VERSION;
+0
-68
README less more
0 NAME
1 CryptX - Crypto toolkit (self-contained no external libraries needed)
2
3 DESCRIPTION
4 Cryptography in CryptX is based on
5 <https://github.com/libtom/libtomcrypt>
6
7 Currently available modules:
8
9 * Ciphers - see Crypt::Cipher and related modules
10
11 Crypt::Cipher::AES, Crypt::Cipher::Anubis, Crypt::Cipher::Blowfish,
12 Crypt::Cipher::Camellia, Crypt::Cipher::CAST5, Crypt::Cipher::DES,
13 Crypt::Cipher::DES_EDE, Crypt::Cipher::KASUMI,
14 Crypt::Cipher::Khazad, Crypt::Cipher::MULTI2,
15 Crypt::Cipher::Noekeon, Crypt::Cipher::RC2, Crypt::Cipher::RC5,
16 Crypt::Cipher::RC6, Crypt::Cipher::SAFERP,
17 Crypt::Cipher::SAFER_K128, Crypt::Cipher::SAFER_K64,
18 Crypt::Cipher::SAFER_SK128, Crypt::Cipher::SAFER_SK64,
19 Crypt::Cipher::SEED, Crypt::Cipher::Skipjack,
20 Crypt::Cipher::Twofish, Crypt::Cipher::XTEA
21
22 * Block cipher modes
23
24 Crypt::Mode::CBC, Crypt::Mode::CFB, Crypt::Mode::CTR,
25 Crypt::Mode::ECB, Crypt::Mode::OFB
26
27 * Authenticated encryption modes
28
29 Crypt::AuthEnc::CCM, Crypt::AuthEnc::EAX, Crypt::AuthEnc::GCM,
30 Crypt::AuthEnc::OCB
31
32 * Hash Functions - see Crypt::Digest and related modules
33
34 Crypt::Digest::CHAES, Crypt::Digest::MD2, Crypt::Digest::MD4,
35 Crypt::Digest::MD5, Crypt::Digest::RIPEMD128,
36 Crypt::Digest::RIPEMD160, Crypt::Digest::RIPEMD256,
37 Crypt::Digest::RIPEMD320, Crypt::Digest::SHA1,
38 Crypt::Digest::SHA224, Crypt::Digest::SHA256, Crypt::Digest::SHA384,
39 Crypt::Digest::SHA512, Crypt::Digest::SHA512_224,
40 Crypt::Digest::SHA512_256, Crypt::Digest::Tiger192,
41 Crypt::Digest::Whirlpool
42
43 * Message Authentication Codes
44
45 Crypt::Mac::F9, Crypt::Mac::HMAC, Crypt::Mac::OMAC,
46 Crypt::Mac::Pelican, Crypt::Mac::PMAC, Crypt::Mac::XCBC
47
48 * Public key cryptography
49
50 Crypt::PK::RSA, Crypt::PK::DSA, Crypt::PK::ECC, Crypt::PK::DH
51
52 * Cryptographically secure random number generators
53
54 Crypt::PRNG, Crypt::PRNG::Fortuna, Crypt::PRNG::Yarrow,
55 Crypt::PRNG::RC4, Crypt::PRNG::Sober128
56
57 * Key derivation functions - PBKDF1, PBKFD2 and HKDF
58
59 Crypt::KeyDerivation
60
61 LICENSE
62 This program is free software; you can redistribute it and/or modify it
63 under the same terms as Perl itself.
64
65 COPYRIGHT
66 Copyright (c) 2013-2015 DCIT, a.s. <http://www.dcit.cz> / Karel Miko
67
0 # NAME
1
2 CryptX - Crypto toolkit (self-contained no external libraries needed)
3
4 # DESCRIPTION
5
6 Cryptography in CryptX is based on [https://github.com/libtom/libtomcrypt](https://github.com/libtom/libtomcrypt)
7
8 Currently available modules:
9
10 - Ciphers - see [Crypt::Cipher](https://metacpan.org/pod/Crypt::Cipher) and related modules
11
12 [Crypt::Cipher::AES](https://metacpan.org/pod/Crypt::Cipher::AES), [Crypt::Cipher::Anubis](https://metacpan.org/pod/Crypt::Cipher::Anubis), [Crypt::Cipher::Blowfish](https://metacpan.org/pod/Crypt::Cipher::Blowfish), [Crypt::Cipher::Camellia](https://metacpan.org/pod/Crypt::Cipher::Camellia), [Crypt::Cipher::CAST5](https://metacpan.org/pod/Crypt::Cipher::CAST5), [Crypt::Cipher::DES](https://metacpan.org/pod/Crypt::Cipher::DES),
13 [Crypt::Cipher::DES\_EDE](https://metacpan.org/pod/Crypt::Cipher::DES_EDE), [Crypt::Cipher::KASUMI](https://metacpan.org/pod/Crypt::Cipher::KASUMI), [Crypt::Cipher::Khazad](https://metacpan.org/pod/Crypt::Cipher::Khazad), [Crypt::Cipher::MULTI2](https://metacpan.org/pod/Crypt::Cipher::MULTI2), [Crypt::Cipher::Noekeon](https://metacpan.org/pod/Crypt::Cipher::Noekeon), [Crypt::Cipher::RC2](https://metacpan.org/pod/Crypt::Cipher::RC2),
14 [Crypt::Cipher::RC5](https://metacpan.org/pod/Crypt::Cipher::RC5), [Crypt::Cipher::RC6](https://metacpan.org/pod/Crypt::Cipher::RC6), [Crypt::Cipher::SAFERP](https://metacpan.org/pod/Crypt::Cipher::SAFERP), [Crypt::Cipher::SAFER\_K128](https://metacpan.org/pod/Crypt::Cipher::SAFER_K128), [Crypt::Cipher::SAFER\_K64](https://metacpan.org/pod/Crypt::Cipher::SAFER_K64), [Crypt::Cipher::SAFER\_SK128](https://metacpan.org/pod/Crypt::Cipher::SAFER_SK128),
15 [Crypt::Cipher::SAFER\_SK64](https://metacpan.org/pod/Crypt::Cipher::SAFER_SK64), [Crypt::Cipher::SEED](https://metacpan.org/pod/Crypt::Cipher::SEED), [Crypt::Cipher::Skipjack](https://metacpan.org/pod/Crypt::Cipher::Skipjack), [Crypt::Cipher::Twofish](https://metacpan.org/pod/Crypt::Cipher::Twofish), [Crypt::Cipher::XTEA](https://metacpan.org/pod/Crypt::Cipher::XTEA)
16
17 - Block cipher modes
18
19 [Crypt::Mode::CBC](https://metacpan.org/pod/Crypt::Mode::CBC), [Crypt::Mode::CFB](https://metacpan.org/pod/Crypt::Mode::CFB), [Crypt::Mode::CTR](https://metacpan.org/pod/Crypt::Mode::CTR), [Crypt::Mode::ECB](https://metacpan.org/pod/Crypt::Mode::ECB), [Crypt::Mode::OFB](https://metacpan.org/pod/Crypt::Mode::OFB)
20
21 - Stream ciphers
22
23 [Crypt::Stream::RC4](https://metacpan.org/pod/Crypt::Stream::RC4), [Crypt::Stream::ChaCha](https://metacpan.org/pod/Crypt::Stream::ChaCha), [Crypt::Stream::Sober128](https://metacpan.org/pod/Crypt::Stream::Sober128)
24
25 - Authenticated encryption modes
26
27 [Crypt::AuthEnc::CCM](https://metacpan.org/pod/Crypt::AuthEnc::CCM), [Crypt::AuthEnc::EAX](https://metacpan.org/pod/Crypt::AuthEnc::EAX), [Crypt::AuthEnc::GCM](https://metacpan.org/pod/Crypt::AuthEnc::GCM), [Crypt::AuthEnc::OCB](https://metacpan.org/pod/Crypt::AuthEnc::OCB), [Crypt::AuthEnc::ChaCha20Poly1305](https://metacpan.org/pod/Crypt::AuthEnc::ChaCha20Poly1305)
28
29 - Hash Functions - see [Crypt::Digest](https://metacpan.org/pod/Crypt::Digest) and related modules
30
31 [Crypt::Digest::BLAKE2b\_160](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_160), [Crypt::Digest::BLAKE2b\_256](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_256), [Crypt::Digest::BLAKE2b\_384](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_384), [Crypt::Digest::BLAKE2b\_512](https://metacpan.org/pod/Crypt::Digest::BLAKE2b_512),
32 [Crypt::Digest::BLAKE2s\_128](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_128), [Crypt::Digest::BLAKE2s\_160](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_160), [Crypt::Digest::BLAKE2s\_224](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_224), [Crypt::Digest::BLAKE2s\_256](https://metacpan.org/pod/Crypt::Digest::BLAKE2s_256),
33 [Crypt::Digest::CHAES](https://metacpan.org/pod/Crypt::Digest::CHAES), [Crypt::Digest::MD2](https://metacpan.org/pod/Crypt::Digest::MD2), [Crypt::Digest::MD4](https://metacpan.org/pod/Crypt::Digest::MD4), [Crypt::Digest::MD5](https://metacpan.org/pod/Crypt::Digest::MD5), [Crypt::Digest::RIPEMD128](https://metacpan.org/pod/Crypt::Digest::RIPEMD128), [Crypt::Digest::RIPEMD160](https://metacpan.org/pod/Crypt::Digest::RIPEMD160),
34 [Crypt::Digest::RIPEMD256](https://metacpan.org/pod/Crypt::Digest::RIPEMD256), [Crypt::Digest::RIPEMD320](https://metacpan.org/pod/Crypt::Digest::RIPEMD320), [Crypt::Digest::SHA1](https://metacpan.org/pod/Crypt::Digest::SHA1), [Crypt::Digest::SHA224](https://metacpan.org/pod/Crypt::Digest::SHA224), [Crypt::Digest::SHA256](https://metacpan.org/pod/Crypt::Digest::SHA256), [Crypt::Digest::SHA384](https://metacpan.org/pod/Crypt::Digest::SHA384),
35 [Crypt::Digest::SHA512](https://metacpan.org/pod/Crypt::Digest::SHA512), [Crypt::Digest::SHA512\_224](https://metacpan.org/pod/Crypt::Digest::SHA512_224), [Crypt::Digest::SHA512\_256](https://metacpan.org/pod/Crypt::Digest::SHA512_256), [Crypt::Digest::Tiger192](https://metacpan.org/pod/Crypt::Digest::Tiger192), [Crypt::Digest::Whirlpool](https://metacpan.org/pod/Crypt::Digest::Whirlpool),
36 [Crypt::Digest::SHA3\_224](https://metacpan.org/pod/Crypt::Digest::SHA3_224), [Crypt::Digest::SHA3\_256](https://metacpan.org/pod/Crypt::Digest::SHA3_256), [Crypt::Digest::SHA3\_384](https://metacpan.org/pod/Crypt::Digest::SHA3_384), [Crypt::Digest::SHA3\_512](https://metacpan.org/pod/Crypt::Digest::SHA3_512), [Crypt::Digest::SHAKE](https://metacpan.org/pod/Crypt::Digest::SHAKE)
37
38 - Message Authentication Codes
39
40 [Crypt::Mac::F9](https://metacpan.org/pod/Crypt::Mac::F9), [Crypt::Mac::HMAC](https://metacpan.org/pod/Crypt::Mac::HMAC), [Crypt::Mac::OMAC](https://metacpan.org/pod/Crypt::Mac::OMAC), [Crypt::Mac::Pelican](https://metacpan.org/pod/Crypt::Mac::Pelican), [Crypt::Mac::PMAC](https://metacpan.org/pod/Crypt::Mac::PMAC), [Crypt::Mac::XCBC](https://metacpan.org/pod/Crypt::Mac::XCBC), [Crypt::Mac::Poly1305](https://metacpan.org/pod/Crypt::Mac::Poly1305)
41
42 - Public key cryptography
43
44 [Crypt::PK::RSA](https://metacpan.org/pod/Crypt::PK::RSA), [Crypt::PK::DSA](https://metacpan.org/pod/Crypt::PK::DSA), [Crypt::PK::ECC](https://metacpan.org/pod/Crypt::PK::ECC), [Crypt::PK::DH](https://metacpan.org/pod/Crypt::PK::DH)
45
46 - Cryptographically secure random number generators
47
48 [Crypt::PRNG](https://metacpan.org/pod/Crypt::PRNG), [Crypt::PRNG::Fortuna](https://metacpan.org/pod/Crypt::PRNG::Fortuna), [Crypt::PRNG::Yarrow](https://metacpan.org/pod/Crypt::PRNG::Yarrow), [Crypt::PRNG::RC4](https://metacpan.org/pod/Crypt::PRNG::RC4), [Crypt::PRNG::Sober128](https://metacpan.org/pod/Crypt::PRNG::Sober128), [Crypt::PRNG::ChaCha20](https://metacpan.org/pod/Crypt::PRNG::ChaCha20)
49
50 - Key derivation functions - PBKDF1, PBKFD2 and HKDF
51
52 [Crypt::KeyDerivation](https://metacpan.org/pod/Crypt::KeyDerivation)
53
54 - Other handy functions related to cryptography
55
56 [Crypt::Misc](https://metacpan.org/pod/Crypt::Misc)
57
58 # LICENSE
59
60 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
61
62 # COPYRIGHT
63
64 Copyright (c) 2013+ DCIT, a.s. [http://www.dcit.cz](http://www.dcit.cz) / Karel Miko
4242 OUTPUT:
4343 RETVAL
4444
45 int
45 void
4646 set_iv(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * nonce)
47 CODE:
47 PPCODE:
4848 {
4949 int rv;
5050 STRLEN iv_len=0;
5454 iv = (unsigned char *) SvPVbyte(nonce, iv_len);
5555 rv = chacha20poly1305_setiv(&self->state, iv, (unsigned long)iv_len);
5656 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv failed: %s", error_to_string(rv));
57 RETVAL = rv;
57 XPUSHs(ST(0)); /* return self */;
5858 }
59 OUTPUT:
60 RETVAL
6159
62 int
60 void
6361 set_iv_rfc7905(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * nonce, UV seqnum)
64 CODE:
62 PPCODE:
6563 {
6664 int rv;
6765 STRLEN iv_len=0;
7169 iv = (unsigned char *) SvPVbyte(nonce, iv_len);
7270 rv = chacha20poly1305_setiv_rfc7905(&self->state, iv, (unsigned long)iv_len, (ulong64)seqnum);
7371 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_setiv_rfc7905 failed: %s", error_to_string(rv));
74 RETVAL = rv;
72 XPUSHs(ST(0)); /* return self */
7573 }
76 OUTPUT:
77 RETVAL
7874
79 int
75 void
8076 adata_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
81 CODE:
77 PPCODE:
8278 {
8379 int rv;
8480 STRLEN in_data_len;
8783 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
8884 rv = chacha20poly1305_add_aad(&self->state, in_data, (unsigned long)in_data_len);
8985 if (rv != CRYPT_OK) croak("FATAL: chacha20poly1305_add_aad failed: %s", error_to_string(rv));
90 RETVAL = rv;
86 XPUSHs(ST(0)); /* return self */
9187 }
92 OUTPUT:
93 RETVAL
9488
9589 SV *
9690 decrypt_add(Crypt::AuthEnc::ChaCha20Poly1305 self, SV * data)
138138 }
139139 }
140140
141 int
142 aad_add(Crypt::AuthEnc::EAX self, SV * adata)
143 CODE:
141 void
142 adata_add(Crypt::AuthEnc::EAX self, SV * adata)
143 PPCODE:
144144 {
145145 STRLEN h_len;
146 int rv;
146147 unsigned char *h;
147148 h = (unsigned char *)SvPVbyte(adata, h_len);
148 RETVAL = eax_addheader(&self->state, h, (unsigned long)h_len);
149 rv = eax_addheader(&self->state, h, (unsigned long)h_len);
150 if (rv != CRYPT_OK) croak("FATAL: eax_addheader failed: %s", error_to_string(rv));
151 XPUSHs(ST(0)); /* return self */
149152 }
150 OUTPUT:
151 RETVAL
4545 OUTPUT:
4646 RETVAL
4747
48 int
48 void
4949 reset(Crypt::AuthEnc::GCM self)
50 CODE:
50 PPCODE:
5151 {
5252 int rv;
5353 rv = gcm_reset(&self->state);
5454 if (rv != CRYPT_OK) croak("FATAL: gcm_reset failed: %s", error_to_string(rv));
55 RETVAL = rv;
55 XPUSHs(ST(0)); /* return self */
5656 }
57 OUTPUT:
58 RETVAL
5957
6058 SV *
6159 encrypt_add(Crypt::AuthEnc::GCM self, SV * data)
8280 OUTPUT:
8381 RETVAL
8482
85 int
83 void
8684 iv_add(Crypt::AuthEnc::GCM self, SV * data)
87 CODE:
85 PPCODE:
8886 {
8987 int rv;
9088 STRLEN in_data_len;
9391 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
9492 rv = gcm_add_iv(&self->state, in_data, (unsigned long)in_data_len);
9593 if (rv != CRYPT_OK) croak("FATAL: gcm_add_iv failed: %s", error_to_string(rv));
96 RETVAL = rv;
94 XPUSHs(ST(0)); /* return self */
9795 }
98 OUTPUT:
99 RETVAL
10096
101 int
97 void
10298 adata_add(Crypt::AuthEnc::GCM self, SV * data)
103 CODE:
99 PPCODE:
104100 {
105101 int rv;
106102 STRLEN in_data_len;
109105 in_data = (unsigned char *)SvPVbyte(data, in_data_len);
110106 rv = gcm_add_aad(&self->state, in_data, (unsigned long)in_data_len);
111107 if (rv != CRYPT_OK) croak("FATAL: gcm_add_aad failed: %s", error_to_string(rv));
112 RETVAL = rv;
108 XPUSHs(ST(0)); /* return self */
113109 }
114 OUTPUT:
115 RETVAL
116110
117111 SV *
118112 decrypt_add(Crypt::AuthEnc::GCM self, SV * data)
00 MODULE = CryptX PACKAGE = Crypt::AuthEnc::OCB
11
22 Crypt::AuthEnc::OCB
3 _new(char * cipher_name, SV * key, SV * nonce)
3 _new(char * cipher_name, SV * key, SV * nonce, unsigned long taglen)
44 CODE:
55 {
66 STRLEN k_len=0;
2020 Newz(0, RETVAL, 1, struct ocb_struct);
2121 if (!RETVAL) croak("FATAL: Newz failed");
2222
23 if (ocb3_init(&RETVAL->state, id, k, (unsigned long)k_len, n, (unsigned long)n_len) != CRYPT_OK) {
23 if (ocb3_init(&RETVAL->state, id, k, (unsigned long)k_len, n, (unsigned long)n_len, taglen) != CRYPT_OK) {
2424 croak("FATAL: ocb setup failed");
2525 }
2626 }
4242 RETVAL
4343
4444 void
45 aad_add(Crypt::AuthEnc::OCB self, SV * data)
46 CODE:
45 adata_add(Crypt::AuthEnc::OCB self, SV * data)
46 PPCODE:
4747 {
4848 int rv;
4949 STRLEN in_data_len;
5555 rv = ocb3_add_aad(&self->state, in_data, (unsigned long)in_data_len);
5656 if (rv != CRYPT_OK) croak("FATAL: ocb3_add_aad failed: %s", error_to_string(rv));
5757 }
58 XPUSHs(ST(0)); /* return self */
5859 }
5960
6061 SV *
1515
1616 void
1717 reset(Crypt::Checksum::Adler32 self)
18 CODE:
18 PPCODE:
19 {
1920 adler32_init(self);
21 XPUSHs(ST(0)); /* return self */
22 }
2023
2124 Crypt::Checksum::Adler32
2225 clone(Crypt::Checksum::Adler32 self)
1515
1616 void
1717 reset(Crypt::Checksum::CRC32 self)
18 CODE:
18 PPCODE:
19 {
1920 crc32_init(self);
21 XPUSHs(ST(0)); /* return self */
22 }
2023
2124 Crypt::Checksum::CRC32
2225 clone(Crypt::Checksum::CRC32 self)
3030 void
3131 reset(self)
3232 Crypt::Digest self
33 CODE:
33 PPCODE:
3434 {
3535 int rv;
3636 rv = self->desc->init(&self->state);
3737 if (rv != CRYPT_OK) croak("FATAL: digest init failed: %s", error_to_string(rv));
38 XPUSHs(ST(0)); /* return self */
3839 }
3940
4041 Crypt::Digest
2222
2323 void
2424 reset(Crypt::Digest::SHAKE self)
25 CODE:
25 PPCODE:
2626 {
2727 int rv;
2828 rv = sha3_shake_init(&self->state, self->num);
2929 if (rv != CRYPT_OK) croak("FATAL: sha3_shake_init failed: %s", error_to_string(rv));
30 XPUSHs(ST(0)); /* return self */
3031 }
3132
3233 Crypt::Digest::SHAKE
1616 RETVAL
1717
1818 void
19 _generate_key(Crypt::PK::DH self, int key_size=256)
20 PPCODE:
21 {
22 int rv;
19 _generate_key_size(Crypt::PK::DH self, int groupsize=256)
20 PPCODE:
21 {
22 int rv;
23 rv = dh_set_pg_groupsize(groupsize, &self->key);
24 if (rv != CRYPT_OK) croak("FATAL: dh_set_pg_groupsize failed: %s", error_to_string(rv));
25 rv = dh_generate_key(&self->pstate, self->pindex, &self->key);
26 if (rv != CRYPT_OK) croak("FATAL: dh_generate_key failed: %s", error_to_string(rv));
27 XPUSHs(ST(0)); /* return self */
28 }
29
30 void
31 _generate_key_gp(Crypt::PK::DH self, char *g, char *p)
32 PPCODE:
33 {
34 int rv;
35 unsigned char pbin[1024], gbin[512];
36 unsigned long plen=sizeof(pbin), glen=sizeof(gbin);
37
38 if (p && strlen(p) > 0 && g && strlen(g) > 0) {
39 rv = radix_to_bin(p, 16, pbin, &plen);
40 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
41 rv = radix_to_bin(g, 16, gbin, &glen);
42 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
43
44 rv = dh_set_pg(pbin, plen, gbin, glen, &self->key);
45 if (rv != CRYPT_OK) croak("FATAL: dh_set_pg failed: %s", error_to_string(rv));
46 rv = dh_generate_key(&self->pstate, self->pindex, &self->key);
47 if (rv != CRYPT_OK) croak("FATAL: dh_generate_key failed: %s", error_to_string(rv));
48 }
49
50 XPUSHs(ST(0)); /* return self */
51 }
52
53 void
54 _generate_key_dhparam(Crypt::PK::DH self, SV * dhparam)
55 PPCODE:
56 {
57 int rv;
58 unsigned char *data=NULL;
59 STRLEN data_len=0;
60 data = (unsigned char *)SvPVbyte(dhparam, data_len);
61 /* load d p q */
62 rv = dh_set_pg_dhparam(data, data_len, &self->key);
63 if (rv != CRYPT_OK) croak("FATAL: dh_set_pg_dhparam failed: %s", error_to_string(rv));
2364 /* gen the key */
24 rv = dh_make_key(&self->pstate, self->pindex, key_size, &self->key);
25 if (rv != CRYPT_OK) croak("FATAL: dh_make_key failed: %s", error_to_string(rv));
26 XPUSHs(ST(0)); /* return self */
27 }
28
29 void
30 _generate_key_ex(Crypt::PK::DH self, SV * g, SV * p)
31 PPCODE:
32 {
33 int rv;
34 STRLEN p_len = 0;
35 STRLEN g_len = 0;
36 unsigned char *p_ptr=NULL;
37 unsigned char *g_ptr=NULL;
38
39 p_ptr = (unsigned char *)SvPVbyte(p, p_len);
40 g_ptr = (unsigned char *)SvPVbyte(g, g_len);
41
42 /* gen the key */
43 rv = dh_make_key_ex(&self->pstate, self->pindex, (const char *) g_ptr, (const char *) p_ptr, &self->key);
44 if (rv != CRYPT_OK) croak("FATAL: dh_make_key_ex failed: %s", error_to_string(rv));
65 rv = dh_generate_key(&self->pstate, self->pindex, &self->key);
66 if (rv != CRYPT_OK) croak("FATAL: dh_generate_key failed: %s", error_to_string(rv));
4567 XPUSHs(ST(0)); /* return self */
4668 }
4769
6789 int rv;
6890 unsigned char *data=NULL;
6991 STRLEN data_len=0;
92 unsigned char pbin[1024], gbin[512];
93 unsigned long plen=sizeof(pbin), glen=sizeof(gbin);
7094
7195 data = (unsigned char *)SvPVbyte(raw_key, data_len);
7296 if (self->key.type != -1) { dh_free(&self->key); self->key.type = -1; }
73 /* public */
74 if (type == 0) {
75 rv = dh_import_raw(data, (unsigned long)data_len, PK_PUBLIC, g, p, &self->key);
76 if (rv != CRYPT_OK) croak("FATAL: dh_import_raw failed: %s", error_to_string(rv));
77 }
78 /* private */
79 else if (type == 1) {
80 rv = dh_import_raw(data, (unsigned long)data_len, PK_PRIVATE, g, p, &self->key);
81 if (rv != CRYPT_OK) croak("FATAL: dh_import_raw failed: %s", error_to_string(rv));
82 }
83 else {
84 croak("FATAL: import_raw invalid type '%d'", type);
97
98 if (p && strlen(p) > 0 && g && strlen(g) > 0) {
99 rv = radix_to_bin(p, 16, pbin, &plen);
100 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
101 rv = radix_to_bin(g, 16, gbin, &glen);
102 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
103
104 rv = dh_set_pg(pbin, plen, gbin, glen, &self->key);
105 if (rv != CRYPT_OK) croak("FATAL: dh_set_pg failed: %s", error_to_string(rv));
106
107 if (type == 0) {
108 /* public */
109 rv = dh_set_key(data, (unsigned long)data_len, PK_PUBLIC, &self->key);
110 if (rv != CRYPT_OK) croak("FATAL: dh_set_key failed: %s", error_to_string(rv));
111 }
112 else if (type == 1) {
113 /* private */
114 rv = dh_set_key(data, (unsigned long)data_len, PK_PRIVATE, &self->key);
115 if (rv != CRYPT_OK) croak("FATAL: dh_set_key failed: %s", error_to_string(rv));
116 }
117 else {
118 croak("FATAL: import_raw invalid type '%d'", type);
119 }
85120 }
86121
87122 XPUSHs(ST(0)); /* return self */
99134 size(Crypt::PK::DH self)
100135 CODE:
101136 if (self->key.type == -1) XSRETURN_UNDEF;
102 RETVAL = dh_get_size(&self->key);
137 RETVAL = dh_get_groupsize(&self->key);
103138 OUTPUT:
104139 RETVAL
105140
163198 not_used = hv_store(rv_hash, "g", 1, newSVpv("", 0), 0);
164199 }
165200 /* =====> size */
166 not_used = hv_store(rv_hash, "size", 4, newSViv(dh_get_size(&self->key)), 0);
201 not_used = hv_store(rv_hash, "size", 4, newSViv(dh_get_groupsize(&self->key)), 0);
167202 /* =====> type */
168203 not_used = hv_store(rv_hash, "type", 4, newSViv(self->key.type), 0);
169204 if (not_used) not_used = NULL; /* just silence the warning: variable 'not_used' set but not used */
238273 RETVAL
239274
240275 SV *
241 _encrypt(Crypt::PK::DH self, SV * data, char * hash_name)
242 CODE:
243 {
244 int rv, hash_id;
245 unsigned char *data_ptr=NULL;
246 STRLEN data_len=0;
247 unsigned long buffer_len = 1024;
248 unsigned char buffer[1024];
249
250 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
251
252 hash_id = find_hash(hash_name);
253 if(hash_id==-1) croak("FATAL: find_hash failed for '%s'", hash_name);
254 rv = dh_encrypt_key(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
255 &self->pstate, self->pindex,
256 hash_id, &self->key);
257 if (rv != CRYPT_OK) croak("FATAL: dh_encrypt_key failed: %s", error_to_string(rv));
258 RETVAL = newSVpvn((char*)buffer, buffer_len);
259 }
260 OUTPUT:
261 RETVAL
262
263 SV *
264 _decrypt(Crypt::PK::DH self, SV * data)
265 CODE:
266 {
267 int rv;
268 unsigned char *data_ptr=NULL;
269 STRLEN data_len=0;
270 unsigned long buffer_len = 1024;
271 unsigned char buffer[1024];
272
273 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
274
275 rv = dh_decrypt_key(data_ptr, (unsigned long)data_len, buffer, &buffer_len, &self->key);
276 if (rv != CRYPT_OK) croak("FATAL: dh_decrypt_key failed: %s", error_to_string(rv));
277 RETVAL = newSVpvn((char*)buffer, buffer_len);
278 }
279 OUTPUT:
280 RETVAL
281
282 SV *
283 _sign(Crypt::PK::DH self, SV * data)
284 CODE:
285 {
286 int rv;
287 unsigned char *data_ptr=NULL;
288 STRLEN data_len=0;
289 unsigned long buffer_len = 1024;
290 unsigned char buffer[1024];
291
292 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
293
294 rv = dh_sign_hash(data_ptr, (unsigned long)data_len, buffer, &buffer_len,
295 &self->pstate, self->pindex,
296 &self->key);
297 if (rv != CRYPT_OK) croak("FATAL: dh_sign_hash failed: %s", error_to_string(rv));
298 RETVAL = newSVpvn((char*)buffer, buffer_len);
299 }
300 OUTPUT:
301 RETVAL
302
303 int
304 _verify(Crypt::PK::DH self, SV * sig, SV * data)
305 CODE:
306 {
307 int rv, stat;
308 unsigned char *data_ptr=NULL;
309 STRLEN data_len=0;
310 unsigned char *sig_ptr=NULL;
311 STRLEN sig_len=0;
312
313 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
314 sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
315
316 RETVAL = 1;
317 rv = dh_verify_hash(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, &stat, &self->key);
318 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
319 }
320 OUTPUT:
321 RETVAL
322
323 SV *
324276 shared_secret(Crypt::PK::DH self, Crypt::PK::DH pubkey)
325277 CODE:
326278 {
340292 CODE:
341293 {
342294 int rv;
343 unsigned long len, buffer_len = 1024;
344 unsigned char buffer[1024];
345 void *key;
295 unsigned char out[1024];
296 unsigned long out_len = 1024;
346297
347298 RETVAL = newSVpvn(NULL, 0); /* undef */
348299 if (strnEQ(type, "private", 7)) {
349 key = self->key.x;
300 rv = dh_export_key(out, &out_len, PK_PRIVATE, &self->key);
301 if (rv != CRYPT_OK) croak("FATAL: dh_export_key(PK_PRIVATE) failed: %s", error_to_string(rv));
302 RETVAL = newSVpvn((char*)out, out_len);
350303 }
351304 else if (strnEQ(type, "public", 6)) {
352 key = self->key.y;
305 rv = dh_export_key(out, &out_len, PK_PUBLIC, &self->key);
306 if (rv != CRYPT_OK) croak("FATAL: dh_export_key(PK_PUBLIC) failed: %s", error_to_string(rv));
307 RETVAL = newSVpvn((char*)out, out_len);
353308 }
354309 else {
355310 croak("FATAL: export_key_raw: invalid type '%s'", type);
356311 }
357
358 len = (unsigned long)mp_unsigned_bin_size(key);
359 if (buffer_len < len) {
360 croak("FATAL: %s", error_to_string(CRYPT_BUFFER_OVERFLOW));
361 }
362 rv = mp_to_unsigned_bin(key, buffer);
363 if (rv != CRYPT_OK) croak("FATAL: %s", error_to_string(rv));
364 RETVAL = newSVpvn((char*)buffer, len);
365 }
366 OUTPUT:
367 RETVAL
368
369 int
370 _is_pubkey_valid(Crypt::PK::DH self);
371 CODE:
372 {
373 int rv, i, bits_set = 0;
374 mp_int one, two, p1, *y;
375 mp_digit digit;
376
377 if ((rv = mp_init_multi(&one, &two, &p1, NULL)) != MP_OKAY) {
378 croak("FATAL: %s", error_to_string(rv));
379 }
380
381 y = self->key.y;
382 mp_set(&one, 1);
383 mp_set(&two, 2);
384
385 /* p1 = p-1 */
386 if ((rv = mp_sub(self->key.prime, &one, &p1)) != MP_OKAY) {
387 croak("FATAL: %s", error_to_string(rv));
388 }
389 /* valid public key cannot be negative */
390 if (y->sign == MP_NEG) {
391 RETVAL = 0;
392 }
393 /* valid public key != 1 */
394 else if (mp_cmp(y, &one) == MP_EQ) {
395 RETVAL = 0;
396 }
397 /* public key cannot be > p-1 */
398 else if (mp_cmp(y, &p1) == MP_GT) {
399 RETVAL = 0;
400 }
401 /* if base == 2, public must have more than one bit set */
402 else if (mp_cmp(self->key.base, &two) == MP_EQ) {
403 for (i = 0; i < y->used; i++) {
404 digit = y->dp[i];
405 while (digit > ((mp_digit) 0)) {
406 if (digit & ((mp_digit) 1))
407 bits_set++;
408 digit >>= ((mp_digit) 1);
409 }
410 }
411 if (bits_set > 1)
412 RETVAL = 1;
413 else RETVAL = 0;
414 }
415 else RETVAL = 1;
416312 }
417313 OUTPUT:
418314 RETVAL
422318 CODE:
423319 if (self->key.type != -1) { dh_free(&self->key); self->key.type = -1; }
424320 Safefree(self);
425
1616 RETVAL
1717
1818 void
19 generate_key(Crypt::PK::DSA self, int group_size=30, int modulus_size=256)
19 _generate_key_size(Crypt::PK::DSA self, int group_size=30, int modulus_size=256)
2020 PPCODE:
2121 {
2222 int rv;
2323 /* gen the key */
2424 rv = dsa_make_key(&self->pstate, self->pindex, group_size, modulus_size, &self->key);
2525 if (rv != CRYPT_OK) croak("FATAL: dsa_make_key failed: %s", error_to_string(rv));
26 XPUSHs(ST(0)); /* return self */
27 }
28
29 void
30 _generate_key_dsaparam(Crypt::PK::DSA self, SV * dsaparam)
31 PPCODE:
32 {
33 int rv;
34 unsigned char *data=NULL;
35 STRLEN data_len=0;
36 data = (unsigned char *)SvPVbyte(dsaparam, data_len);
37 /* load d p q */
38 rv = dsa_set_pqg_dsaparam(data, data_len, &self->key);
39 if (rv != CRYPT_OK) croak("FATAL: dsa_set_pqg_dsaparam failed: %s", error_to_string(rv));
40 /* gen the key */
41 rv = dsa_generate_key(&self->pstate, self->pindex, &self->key);
42 if (rv != CRYPT_OK) croak("FATAL: dsa_generate_key failed: %s", error_to_string(rv));
43 XPUSHs(ST(0)); /* return self */
44 }
45
46 void
47 _generate_key_pqg_hex(Crypt::PK::DSA self, char *p, char *q, char *g)
48 PPCODE:
49 {
50 int rv;
51 unsigned char pbin[512], qbin[512], gbin[512];
52 unsigned long plen=sizeof(pbin), qlen=sizeof(qbin), glen=sizeof(gbin);
53 if (!p || !strlen(p) || !q || !strlen(q) || !g || !strlen(g)) {
54 croak("FATAL: generate_key_pqg_hex incomplete args");
55 }
56 /* set p q g */
57 rv = radix_to_bin(p, 16, pbin, &plen);
58 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
59 rv = radix_to_bin(q, 16, qbin, &qlen);
60 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
61 rv = radix_to_bin(g, 16, gbin, &glen);
62 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
63 rv = dsa_set_pqg(pbin, plen, qbin, qlen, gbin, glen, &self->key);
64 if (rv != CRYPT_OK) croak("FATAL: dsa_set_pqg failed: %s", error_to_string(rv));
65 /* gen the key */
66 rv = dsa_generate_key(&self->pstate, self->pindex, &self->key);
67 if (rv != CRYPT_OK) croak("FATAL: dsa_generate_key failed: %s", error_to_string(rv));
2668 XPUSHs(ST(0)); /* return self */
2769 }
2870
4688 PPCODE:
4789 {
4890 int rv;
91 unsigned char pbin[512], qbin[512], gbin[512], xbin[512], ybin[512];
92 unsigned long plen=sizeof(pbin), qlen=sizeof(qbin), glen=sizeof(gbin), xlen=sizeof(xbin), ylen=sizeof(ybin);
93
4994 if (self->key.type != -1) { dsa_free(&self->key); self->key.type = -1; }
50 rv = dsa_import_radix(16, p, q, g, x, y, &self->key);
51 if (rv != CRYPT_OK) croak("FATAL: dsa_import_radix failed: %s", error_to_string(rv));
95
96 if (p && strlen(p) > 0 && q && strlen(q) > 0 && g && strlen(g) > 0 && y && strlen(y) > 0) {
97 rv = radix_to_bin(p, 16, pbin, &plen);
98 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
99 rv = radix_to_bin(q, 16, qbin, &qlen);
100 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
101 rv = radix_to_bin(g, 16, gbin, &glen);
102 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(g) failed: %s", error_to_string(rv));
103 rv = dsa_set_pqg(pbin, plen, qbin, qlen, gbin, glen, &self->key);
104 if (rv != CRYPT_OK) croak("FATAL: dsa_set_pqg failed: %s", error_to_string(rv));
105
106 rv = radix_to_bin(y, 16, ybin, &ylen);
107 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(y) failed: %s", error_to_string(rv));
108 if (x && strlen(x) > 0) {
109 /* private */
110 rv = radix_to_bin(x, 16, xbin, &xlen);
111 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(x) failed: %s", error_to_string(rv));
112 rv = dsa_set_key(xbin, xlen, PK_PRIVATE, &self->key);
113 if (rv != CRYPT_OK) croak("FATAL: dsa_set_key failed: %s", error_to_string(rv));
114 }
115 else {
116 /* public */
117 rv = dsa_set_key(ybin, ylen, PK_PUBLIC, &self->key);
118 if (rv != CRYPT_OK) croak("FATAL: dsa_set_key failed: %s", error_to_string(rv));
119 }
120 }
121
52122 XPUSHs(ST(0)); /* return self */
53123 }
54124
260330 sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
261331
262332 RETVAL = 1;
333 stat = 0;
263334 rv = dsa_verify_hash(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, &stat, &self->key);
264335 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
265336 }
4545 }
4646
4747 void
48 _import_pkcs8(Crypt::PK::ECC self, SV * key_data)
48 _import_pkcs8(Crypt::PK::ECC self, SV * key_data, SV * passwd)
49 PPCODE:
50 {
51 int rv;
52 unsigned char *data=NULL, *pwd=NULL;
53 STRLEN data_len=0, pwd_len=0;
54
55 data = (unsigned char *)SvPVbyte(key_data, data_len);
56 if (SvOK(passwd)) {
57 pwd = (unsigned char *)SvPVbyte(passwd, pwd_len);
58 }
59 _ecc_free_key(&self->key, &self->dp);
60 rv = ecc_import_pkcs8(data, (unsigned long)data_len, pwd, pwd_len, &self->key, &self->dp);
61 if (rv != CRYPT_OK) croak("FATAL: ecc_import_pkcs8 failed: %s", error_to_string(rv));
62 XPUSHs(ST(0)); /* return self */
63 }
64
65 void
66 import_key_raw(Crypt::PK::ECC self, SV * key_data, SV * curve)
4967 PPCODE:
5068 {
5169 int rv;
5472
5573 data = (unsigned char *)SvPVbyte(key_data, data_len);
5674 _ecc_free_key(&self->key, &self->dp);
57 rv = ecc_import_pkcs8(data, (unsigned long)data_len, NULL, 0, &self->key, &self->dp);
58 if (rv != CRYPT_OK) croak("FATAL: ecc_import_pkcs8 failed: %s", error_to_string(rv));
59 XPUSHs(ST(0)); /* return self */
60 }
61
62 void
63 import_key_raw(Crypt::PK::ECC self, SV * key_data, SV * curve)
64 PPCODE:
65 {
66 int rv;
67 unsigned char *data=NULL;
68 STRLEN data_len=0;
69
70 data = (unsigned char *)SvPVbyte(key_data, data_len);
71 _ecc_free_key(&self->key, &self->dp);
72
75
7376 _ecc_set_dp_from_SV(&self->dp, curve); /* croaks on error */
74
77
7578 rv = ecc_import_raw(data, (unsigned long)data_len, &self->key, &self->dp);
7679 if (rv != CRYPT_OK) croak("FATAL: ecc_import_raw failed: %s", error_to_string(rv));
7780 XPUSHs(ST(0)); /* return self */
251254 RETVAL = newSVpvn((char*)out, out_len);
252255 }
253256 else if (strnEQ(type, "public_compressed", 17)) {
254 rv = ecc_export_raw(out, &out_len, PK_PUBLIC_COMPRESSED, &self->key);
257 rv = ecc_export_raw(out, &out_len, PK_PUBLIC|PK_COMPRESSED, &self->key);
255258 if (rv != CRYPT_OK) croak("FATAL: ecc_export_raw(public_compressed) failed: %s", error_to_string(rv));
256259 RETVAL = newSVpvn((char*)out, out_len);
257260 }
355358 sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
356359
357360 RETVAL = 1;
361 stat = 0;
358362 if (ix == 1) {
359363 rv = ecc_verify_hash_rfc7518(sig_ptr, (unsigned long)sig_len, data_ptr, (unsigned long)data_len, &stat, &self->key);
360364 }
4343 }
4444
4545 void
46 _import_pkcs8(Crypt::PK::RSA self, SV * key_data)
46 _import_pkcs8(Crypt::PK::RSA self, SV * key_data, SV * passwd)
47 PPCODE:
48 {
49 int rv;
50 unsigned char *data=NULL, *pwd=NULL;
51 STRLEN data_len=0, pwd_len=0;
52
53 data = (unsigned char *)SvPVbyte(key_data, data_len);
54 if (SvOK(passwd)) {
55 pwd = (unsigned char *)SvPVbyte(passwd, pwd_len);
56 }
57 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
58 rv = rsa_import_pkcs8(data, (unsigned long)data_len, pwd, pwd_len, &self->key);
59 if (rv != CRYPT_OK) croak("FATAL: rsa_import_pkcs8 failed: %s", error_to_string(rv));
60 XPUSHs(ST(0)); /* return self */
61 }
62
63 void
64 _import_x509(Crypt::PK::RSA self, SV * key_data)
4765 PPCODE:
4866 {
4967 int rv;
5270
5371 data = (unsigned char *)SvPVbyte(key_data, data_len);
5472 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
55 rv = rsa_import_pkcs8(data, (unsigned long)data_len, NULL, 0, &self->key);
56 if (rv != CRYPT_OK) croak("FATAL: rsa_import_pkcs8 failed: %s", error_to_string(rv));
73 rv = rsa_import_x509(data, (unsigned long)data_len, &self->key);
74 if (rv != CRYPT_OK) croak("FATAL: rsa_import_x509 failed: %s", error_to_string(rv));
5775 XPUSHs(ST(0)); /* return self */
5876 }
5977
6280 PPCODE:
6381 {
6482 int rv;
65 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
66 rv = rsa_import_radix(16, N, e, d, p, q, dP, dQ, qP, &self->key);
67 if (rv != CRYPT_OK) croak("FATAL: rsa_import_radix failed: %s", error_to_string(rv));
83 unsigned char Nbin[1024], ebin[128], dbin[1024], pbin[512], qbin[512], dPbin[512], dQbin[512], qPbin[512];
84 unsigned long Nlen=sizeof(Nbin), elen=sizeof(ebin), dlen=sizeof(dbin), plen=sizeof(pbin),
85 qlen=sizeof(qbin), dPlen=sizeof(dPbin), dQlen=sizeof(dQbin), qPlen=sizeof(qPbin);
86
87 rv = radix_to_bin(N, 16, Nbin, &Nlen);
88 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(N) failed: %s", error_to_string(rv));
89 rv = radix_to_bin(e, 16, ebin, &elen);
90 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(e) failed: %s", error_to_string(rv));
91
92 if (d && strlen(d) > 0) {
93 /* private */
94 rv = radix_to_bin(d, 16, dbin, &dlen);
95 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(d) failed: %s", error_to_string(rv));
96 rv = rsa_set_key(Nbin, Nlen, ebin, elen, dbin, dlen, &self->key);
97 if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv));
98 }
99 else {
100 /* public */
101 rv = rsa_set_key(Nbin, Nlen, ebin, elen, NULL, 0, &self->key);
102 if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv));
103 }
104
105 if (p && strlen(p) > 0 && q && strlen(q) > 0) {
106 /* private only */
107 rv = radix_to_bin(p, 16, pbin, &plen);
108 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
109 rv = radix_to_bin(q, 16, qbin, &qlen);
110 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
111 rv = rsa_set_factors(pbin, plen, qbin, qlen, &self->key);
112 if (rv != CRYPT_OK) croak("FATAL: rsa_set_factors failed: %s", error_to_string(rv));
113 }
114
115 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
116 /* private only */
117 rv = radix_to_bin(dP, 16, dPbin, &dPlen);
118 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dP) failed: %s", error_to_string(rv));
119 rv = radix_to_bin(dQ, 16, dQbin, &dQlen);
120 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dQ) failed: %s", error_to_string(rv));
121 rv = radix_to_bin(qP, 16, qPbin, &qPlen);
122 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(qP) failed: %s", error_to_string(rv));
123 rv = rsa_set_crt_params(dPbin, dPlen, dQbin, dQlen, qPbin, qPlen, &self->key);
124 if (rv != CRYPT_OK) croak("FATAL: rsa_set_crt_params failed: %s", error_to_string(rv));
125 }
126
68127 XPUSHs(ST(0)); /* return self */
69128 }
70129
206265 {
207266 int rv;
208267 unsigned char out[4096];
209 unsigned long int out_len = 4096;
268 unsigned long out_len = 4096;
210269
211270 RETVAL = newSVpvn(NULL, 0); /* undef */
212271 if (strnEQ(type, "private", 7)) {
376435 sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
377436
378437 RETVAL = 1;
438 stat = 0;
379439 if (strnEQ(padding, "pss", 3)) {
380440 hash_id = find_hash(hash_name);
381441 if(hash_id==-1) croak("FATAL: find_hash failed for '%s'", hash_name);
415475 CODE:
416476 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
417477 Safefree(self);
418
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use base qw(Crypt::AuthEnc Exporter);
77 our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] );
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use base qw(Crypt::AuthEnc Exporter);
77 our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] );
4444
4545 =head1 NAME
4646
47 Crypt::AuthEnc::ChaCha20Poly1305 - Authenticated encryption in ChaCha20Poly1305 mode
47 Crypt::AuthEnc::ChaCha20Poly1305 - Authenticated encryption in ChaCha20-Poly1305 mode
4848
4949 =head1 SYNOPSIS
5050
5353
5454 # encrypt and authenticate
5555 my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
56 $ae->aad_add('additional_authenticated_data1');
57 $ae->aad_add('additional_authenticated_data2');
56 $ae->adata_add('additional_authenticated_data1');
57 $ae->adata_add('additional_authenticated_data2');
5858 $ct = $ae->encrypt_add('data1');
5959 $ct = $ae->encrypt_add('data2');
6060 $ct = $ae->encrypt_add('data3');
6262
6363 # decrypt and verify
6464 my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
65 $ae->aad_add('additional_authenticated_data1');
66 $ae->aad_add('additional_authenticated_data2');
65 $ae->adata_add('additional_authenticated_data1');
66 $ae->adata_add('additional_authenticated_data2');
6767 $pt = $ae->decrypt_add('ciphertext1');
6868 $pt = $ae->decrypt_add('ciphertext2');
6969 $pt = $ae->decrypt_add('ciphertext3');
116116 # $key ..... encryption key of proper length (128 or 256 bits / 16 or 32 bytes)
117117 # $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
118118
119 =head2 aad_add
119 =head2 adata_add
120120
121 Add B<additional authenticated data>.
121122 Can be called before the first C<encrypt_add> or C<decrypt_add>;
122123
123 $ae->aad_add($aad_data); #can be called multiple times
124 $ae->adata_add($aad_data); #can be called multiple times
124125
125126 =head2 encrypt_add
126127
140141 #or
141142 my $tag = $ae->decrypt_done; # returns $tag value
142143
144 =head2 set_iv
145
146 my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key)->set_iv($iv);
147 # $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
148
149 =head2 set_iv_rfc7905
150
151 See L<https://tools.ietf.org/html/rfc7905>
152
153 my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key)->set_iv_rfc7905($iv, $seqnum);
154 # $iv ...... initialization vector (96 bits / 12 bytes)
155 # $seqnum .. 64bit integer (sequence number)
156
143157 =head2 clone
144158
145159 my $ae_new = $ae->clone;
146
147 =head2 set_iv
148
149 $ae->set_iv($iv);
150
151 =head2 set_iv_rfc7905
152
153 $ae->set_iv_rfc7905($iv, $seqnum);
154160
155161 =head1 SEE ALSO
156162
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use base qw(Crypt::AuthEnc Exporter);
77 our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] );
1919 # - encrypt_done
2020 # - decrypt_add
2121 # - decrypt_done
22 # - aad_add
22 # - adata_add
2323
2424 sub new { my $class = shift; _new(Crypt::Cipher::_trans_cipher_name(shift), @_) }
2525
3131 my $plaintext = shift;
3232
3333 my $m = Crypt::AuthEnc::EAX->new($cipher_name, $key, $iv);
34 $m->aad_add($adata) if defined $adata;
34 $m->adata_add($adata) if defined $adata;
3535 my $ct = $m->encrypt_add($plaintext);
3636 my $tag = $m->encrypt_done;
3737 return ($ct, $tag);
4646 my $tag = shift;
4747
4848 my $m = Crypt::AuthEnc::EAX->new($cipher_name, $key, $iv);
49 $m->aad_add($adata) if defined $adata;
49 $m->adata_add($adata) if defined $adata;
5050 my $ct = $m->decrypt_add($ciphertext);
5151 return $m->decrypt_done($tag) ? $ct : undef;
5252 }
5353
54 sub header_add {
55 # obsolete, only for backwards compatibility
56 shift->aad_add(@_);
57 }
54 # obsolete, only for backwards compatibility
55 sub header_add { goto &adata_add }
56 sub aad_add { goto &adata_add }
5857
5958 1;
6059
7170
7271 # encrypt and authenticate
7372 my $ae = Crypt::AuthEnc::EAX->new("AES", $key, $iv);
74 $ae->aad_add('additional_authenticated_data1');
75 $ae->aad_add('additional_authenticated_data2');
73 $ae->adata_add('additional_authenticated_data1');
74 $ae->adata_add('additional_authenticated_data2');
7675 $ct = $ae->encrypt_add('data1');
7776 $ct = $ae->encrypt_add('data2');
7877 $ct = $ae->encrypt_add('data3');
8079
8180 # decrypt and verify
8281 my $ae = Crypt::AuthEnc::EAX->new("AES", $key, $iv);
83 $ae->aad_add('additional_authenticated_data1');
84 $ae->aad_add('additional_authenticated_data2');
82 $ae->adata_add('additional_authenticated_data1');
83 $ae->adata_add('additional_authenticated_data2');
8584 $pt = $ae->decrypt_add('ciphertext1');
8685 $pt = $ae->decrypt_add('ciphertext2');
8786 $pt = $ae->decrypt_add('ciphertext3');
141140 # $iv ...... unique initialization vector (no need to keep it secret)
142141 # $adata ... additional authenticated data (optional)
143142
144 =head2 aad_add
143 =head2 adata_add
145144
146 $ae->aad_add($adata); #can be called multiple times
145 $ae->adata_add($adata); #can be called multiple times
147146
148147 =head2 encrypt_add
149148
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use base qw(Crypt::AuthEnc Exporter);
77 our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] );
6464
6565 # encrypt and authenticate
6666 my $ae = Crypt::AuthEnc::GCM->new("AES", $key, $iv);
67 $ae->aad_add('additional_authenticated_data1');
68 $ae->aad_add('additional_authenticated_data2');
67 $ae->adata_add('additional_authenticated_data1');
68 $ae->adata_add('additional_authenticated_data2');
6969 $ct = $ae->encrypt_add('data1');
7070 $ct = $ae->encrypt_add('data2');
7171 $ct = $ae->encrypt_add('data3');
7373
7474 # decrypt and verify
7575 my $ae = Crypt::AuthEnc::GCM->new("AES", $key, $iv);
76 $ae->aad_add('additional_authenticated_data1');
77 $ae->aad_add('additional_authenticated_data2');
76 $ae->adata_add('additional_authenticated_data1');
77 $ae->adata_add('additional_authenticated_data2');
7878 $pt = $ae->decrypt_add('ciphertext1');
7979 $pt = $ae->decrypt_add('ciphertext2');
8080 $pt = $ae->decrypt_add('ciphertext3');
133133
134134 =head2 iv_add
135135
136 $ae->iv_add($iv_data); #can be called multiple times
136 Set initialization vector (IV).
137137
138 =head2 aad_add
138 $ae->iv_add($iv_data); #can be called multiple times
139139
140 Can be called B<after> all C<iv_add> calls but before the first C<encrypt_add> or C<decrypt_add>;
140 =head2 adata_add
141141
142 $ae->aad_add($aad_data); #can be called multiple times
142 Add B<additional authenticated data>.
143 Can be called B<after> all C<iv_add> calls but before the first C<encrypt_add> or C<decrypt_add>.
144
145 $ae->adata_add($aad_data); #can be called multiple times
143146
144147 =head2 encrypt_add
145148
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use base qw(Crypt::AuthEnc Exporter);
77 our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] );
1818 my $key = shift;
1919 my $nonce = shift;
2020 my $adata = shift;
21 my $tag_len = shift;
2122 my $plaintext = shift;
2223
23 my $m = Crypt::AuthEnc::OCB->new($cipher_name, $key, $nonce);
24 $m->aad_add($adata) if defined $adata;
24 my $m = Crypt::AuthEnc::OCB->new($cipher_name, $key, $nonce, $tag_len);
25 $m->adata_add($adata) if defined $adata;
2526 my $ct = $m->encrypt_last($plaintext);
2627 my $tag = $m->encrypt_done;
2728 return ($ct, $tag);
3536 my $ciphertext = shift;
3637 my $tag = shift;
3738
38 my $m = Crypt::AuthEnc::OCB->new($cipher_name, $key, $nonce);
39 $m->aad_add($adata) if defined $adata;
39 my $m = Crypt::AuthEnc::OCB->new($cipher_name, $key, $nonce, length($tag));
40 $m->adata_add($adata) if defined $adata;
4041 my $ct = $m->decrypt_last($ciphertext);
4142 return $m->decrypt_done($tag) ? $ct : undef;
4243 }
4344
44 sub adata_add {
45 # obsolete, only for backwards compatibility
46 shift->aad_add(@_);
47 }
45 # obsolete, only for backwards compatibility
46 sub aad_add { goto &adata_add }
4847
4948 1;
5049
6059 use Crypt::AuthEnc::OCB;
6160
6261 # encrypt and authenticate
63 my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce);
64 $ae->aad_add('additional_authenticated_data1');
65 $ae->aad_add('additional_authenticated_data2');
62 my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce, $tag_len);
63 $ae->adata_add('additional_authenticated_data1');
64 $ae->adata_add('additional_authenticated_data2');
6665 $ct = $ae->encrypt_add('data1');
6766 $ct = $ae->encrypt_add('data2');
6867 $ct = $ae->encrypt_add('data3');
7069 ($ct,$tag) = $ae->encrypt_done();
7170
7271 # decrypt and verify
73 my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce);
74 $ae->aad_add('additional_authenticated_data1');
75 $ae->aad_add('additional_authenticated_data2');
72 my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce, $tag_len);
73 $ae->adata_add('additional_authenticated_data1');
74 $ae->adata_add('additional_authenticated_data2');
7675 $pt = $ae->decrypt_add('ciphertext1');
7776 $pt = $ae->decrypt_add('ciphertext2');
7877 $pt = $ae->decrypt_add('ciphertext3');
8281 ### functional interface
8382 use Crypt::AuthEnc::OCB qw(ocb_encrypt_authenticate ocb_decrypt_verify);
8483
85 my ($ciphertext, $tag) = ocb_encrypt_authenticate('AES', $key, $nonce, $adata, $plaintext);
84 my ($ciphertext, $tag) = ocb_encrypt_authenticate('AES', $key, $nonce, $adata, $tag_len, $plaintext);
8685 my $plaintext = ocb_decrypt_verify('AES', $key, $nonce, $adata, $ciphertext, $tag);
8786
8887 =head1 DESCRIPTION
8988
90 This module implements OCB version 3 according http://datatracker.ietf.org/doc/draft-irtf-cfrg-ocb/
89 This module implements OCB v3 according to L<https://tools.ietf.org/html/rfc7253>
9190
9291 =head1 EXPORT
9392
101100
102101 =head2 ocb_encrypt_authenticate
103102
104 my ($ciphertext, $tag) = ocb_encrypt_authenticate($cipher, $key, $nonce, $adata, $plaintext);
103 my ($ciphertext, $tag) = ocb_encrypt_authenticate($cipher, $key, $nonce, $adata, $tag_len, $plaintext);
105104
106105 # $cipher .. 'AES' or name of any other cipher with 16-byte block len
107106 # $key ..... AES key of proper length (128/192/256bits)
108107 # $nonce ... unique nonce/salt (no need to keep it secret)
109108 # $adata ... additional authenticated data
109 # $tag_len . required length of output tag
110110
111111 =head2 ocb_decrypt_verify
112112
118118
119119 =head2 new
120120
121 my $ae = Crypt::AuthEnc::OCB->new($cipher, $key, $nonce);
121 my $ae = Crypt::AuthEnc::OCB->new($cipher, $key, $nonce, $tag_len);
122122
123123 # $cipher .. 'AES' or name of any other cipher with 16-byte block len
124124 # $key ..... AES key of proper length (128/192/256bits)
125125 # $nonce ... unique nonce/salt (no need to keep it secret)
126 # $tag_len . required length of output tag
126127
127 =head2 aad_add
128 =head2 adata_add
128129
129 $ae->aad_add($adata); #can be called multiple times
130 $ae->adata_add($adata); #can be called multiple times
130131
131132 =head2 encrypt_add
132133
168169
169170 =item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>
170171
171 =item * L<https://en.wikipedia.org/wiki/OCB_mode|https://en.wikipedia.org/wiki/OCB_mode>
172 =item * L<https://en.wikipedia.org/wiki/OCB_mode>
173
174 =item * L<https://tools.ietf.org/html/rfc7253>
172175
173176 =back
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 sub CLONE_SKIP { 1 } # prevent cloning
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55 use Carp;
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55 use Carp;
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw/
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('AES');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::AES;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Anubis');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Anubis;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Blowfish');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Blowfish;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('CAST5');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::CAST5;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Camellia');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Camellia;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('DES');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::DES;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('DES_EDE');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::DES_EDE;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('KASUMI');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::KASUMI;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Khazad');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Khazad;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('MULTI2');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::MULTI2;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Noekeon');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Noekeon;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
2020
2121 =head1 NAME
2222
23 Crypt::Cipher::RC2 - Symetric cipher RC2, key size: 64-1024 bits (Crypt::CBC compliant)
23 Crypt::Cipher::RC2 - Symetric cipher RC2, key size: 40-1024 bits (Crypt::CBC compliant)
2424
2525 =head1 SYNOPSIS
2626
3232 my $cbc = Crypt::Mode::CBC->new('RC2');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::RC2;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('RC5');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::RC5;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('RC6');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::RC6;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('SAFERP');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::SAFERP;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('SAFER_K128');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::SAFER_K128;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('SAFER_K64');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::SAFER_K64;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('SAFER_SK128');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::SAFER_SK128;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('SAFER_SK64');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::SAFER_SK64;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('SEED');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::SEED;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Skipjack');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Skipjack;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('Twofish');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::Twofish;
3838
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use CryptX;
99 use base 'Crypt::Cipher';
3232 my $cbc = Crypt::Mode::CBC->new('XTEA');
3333 my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
3434
35 ### example 2
35 ### example 2 (slower)
3636 use Crypt::CBC;
3737 use Crypt::Cipher::XTEA;
3838
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55 use CryptX;
66
77 ### the following methods/functions are implemented in XS:
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
55
66 use Carp;
77 $Carp::Internal{(__PACKAGE__)}++;
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
6 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
77 our %EXPORT_TAGS = ( all => [qw( mac mac_hex )] );
4747
4848 =head1 NAME
4949
50 Crypt::mode - [internal only]
50 Crypt::Mac - [internal only]
5151
5252 =cut
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
77 use Carp 'croak';
8 our %EXPORT_TAGS = ( all => [qw(encode_b64 decode_b64 encode_b64u decode_b64u
9 pem_to_der der_to_pem
10 read_rawfile write_rawfile
8 our %EXPORT_TAGS = ( all => [qw(encode_b64 decode_b64
9 encode_b64u decode_b64u
10 encode_b58b decode_b58b
11 encode_b58f decode_b58f
12 encode_b58r decode_b58r
13 encode_b58t decode_b58t
14 encode_b58s decode_b58s
15 encode_b32r decode_b32r
16 encode_b32b decode_b32b
17 encode_b32z decode_b32z
18 encode_b32c decode_b32c
19 pem_to_der der_to_pem
20 read_rawfile write_rawfile
1121 slow_eq is_v4uuid random_v4uuid
1222 increment_octets_be increment_octets_le
1323 )] );
4050 CryptX::_decode_base64url(@_);
4151 }
4252
53 sub _encode_b58 {
54 my ($bytes, $alphabet) = @_;
55
56 return '' if !defined $bytes || length($bytes) == 0;
57
58 # handle leading zero-bytes
59 my $base58 = '';
60 if ($bytes =~ /^(\x00+)/) {
61 $base58 = ('0' x length($1));
62 }
63 $base58 .= CryptX::_bin_to_radix($bytes, 58);
64
65 if (defined $alphabet) {
66 my $default = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv";
67 return undef if $alphabet !~ /^[a-zA-Z0-9]{58}$/;
68 eval "\$base58 =~ tr/$default/$alphabet/"; # HACK: https://stackoverflow.com/questions/11415045/using-a-char-variable-in-tr
69 return undef if $@;
70 }
71
72 return $base58;
73 }
74
75 sub _decode_b58 {
76 my ($base58, $alphabet) = @_;
77
78 return '' if !defined $base58 || length($base58) == 0;
79
80 my $default = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv";
81 if (defined $alphabet) {
82 return undef if $alphabet !~ /^[a-zA-Z0-9]{58}$/;
83 eval "\$base58 =~ tr/$alphabet/$default/"; # HACK: https://stackoverflow.com/questions/11415045/using-a-char-variable-in-tr
84 return undef if $@;
85 }
86 return undef if $base58 !~ /^[$default]+$/;
87
88 # handle leading zeroes
89 my $bytes = '';
90 if ($base58 =~ /^(0+)(.*)$/) {
91 $base58 = $2;
92 $bytes = ("\x00" x length($1));
93 }
94 $bytes .= CryptX::_radix_to_bin($base58, 58) if defined $base58 && length($base58) > 0;
95
96 return $bytes;
97 }
98
99 sub decode_b58b { _decode_b58(shift, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") } # Bitcoin
100 sub decode_b58f { _decode_b58(shift, "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ") } # Flickr
101 sub decode_b58r { _decode_b58(shift, "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz") } # Ripple
102 sub decode_b58t { _decode_b58(shift, "RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz") } # Tipple
103 sub decode_b58s { _decode_b58(shift, "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz") } # Stellar
104
105 sub encode_b58b { _encode_b58(shift, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") } # Bitcoin
106 sub encode_b58f { _encode_b58(shift, "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ") } # Flickr
107 sub encode_b58r { _encode_b58(shift, "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz") } # Ripple
108 sub encode_b58t { _encode_b58(shift, "RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz") } # Tipple
109 sub encode_b58s { _encode_b58(shift, "gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz") } # Stellar
110
111 sub encode_b32r { CryptX::_encode_b32(shift, 0) } # rfc4648
112 sub encode_b32b { CryptX::_encode_b32(shift, 1) } # base32hex
113 sub encode_b32z { CryptX::_encode_b32(shift, 2) } # zbase32
114 sub encode_b32c { CryptX::_encode_b32(shift, 3) } # crockford
115
116 sub decode_b32r { CryptX::_decode_b32(shift, 0) } # rfc4648
117 sub decode_b32b { CryptX::_decode_b32(shift, 1) } # base32hex
118 sub decode_b32z { CryptX::_decode_b32(shift, 2) } # zbase32
119 sub decode_b32c { CryptX::_decode_b32(shift, 3) } # crockford
120
121
43122 sub increment_octets_be {
44123 CryptX::_increment_octets_be(@_);
45124 #$_[0] = CryptX::_increment_octets_be($_[0]);
53132 sub pem_to_der {
54133 my ($data, $password) = @_;
55134
56 my ($begin, $obj1, $content, $end, $obj2) = $data =~ m/(----[- ]BEGIN ([^\r\n\-]+KEY)[ -]----)(.*?)(----[- ]END ([^\r\n\-]+)[ -]----)/s;
135 my ($begin, $obj1, $content, $end, $obj2);
136 # first try to load KEY (e.g. EC pem files might contain more parts)
137 ($begin, $obj1, $content, $end, $obj2) = $data =~ m/(----[- ]BEGIN ([^\r\n\-]+KEY)[ -]----)(.*?)(----[- ]END ([^\r\n\-]+)[ -]----)/s;
138 # if failed then try to load anything
139 ($begin, $obj1, $content, $end, $obj2) = $data =~ m/(----[- ]BEGIN ([^\r\n\-]+)[ -]----)(.*?)(----[- ]END ([^\r\n\-]+)[ -]----)/s unless $content;
57140 return undef unless $content;
58141
59142 $content =~ s/^\s+//sg;
234317
235318 use Crypt::Misc ':all';
236319
237 =head2 encode_b64
238
239 I<Since: CryptX-0.029>
240
241 $base64string = encode_b64($rawdata);
242
243 Encode $rawbytes into Base64 string, no line-endings in the output string.
244
245 =head2 decode_b64
246
247 I<Since: CryptX-0.029>
248
249 $rawdata = encode_b64($base64string);
250
251 Decode a Base64 string.
252
253 =head2 encode_b64u
254
255 I<Since: CryptX-0.029>
256
257 $base64url_string = encode_b64($rawdata);
258
259 Encode $rawbytes into Base64/URL-Safe string, no line-endings in the output string.
260
261 =head2 decode_b64u
262
263 I<Since: CryptX-0.029>
264
265 $rawdata = encode_b64($base64url_string);
266
267 Decode a Base64/URL-Safe string.
268
269320 =head2 read_rawfile
270321
271 I<Since: CryptX-0.029>
322 I<Since: 0.029>
272323
273324 $rawdata = read_rawfile($filename);
274325
276327
277328 =head2 write_rawfile
278329
279 I<Since: CryptX-0.029>
330 I<Since: 0.029>
280331
281332 write_rawfile($filename, $rawdata);
282333
283 Write C<$rawdata> to file <$filename> as binary data.
334 Write C<$rawdata> to file C<$filename> as binary data.
284335
285336 =head2 slow_eq
286337
287 I<Since: CryptX-0.029>
338 I<Since: 0.029>
288339
289340 if (slow_eq($data1, $data2)) { ... }
290341
292343
293344 =head2 pem_to_der
294345
295 I<Since: CryptX-0.029>
346 I<Since: 0.029>
296347
297348 $der_data = pem_to_der($pem_data);
298349 #or
302353
303354 =head2 der_to_pem
304355
305 I<Since: CryptX-0.029>
306
307 $pem_data = der_to_pem($pem_data, $header_name);
356 I<Since: 0.029>
357
358 $pem_data = der_to_pem($der_data, $header_name);
308359 #or
309 $pem_data = der_to_pem($pem_data, $header_name, $password);
360 $pem_data = der_to_pem($der_data, $header_name, $password);
310361 #or
311 $pem_data = der_to_pem($pem_data, $header_name, $passord, $cipher_name);
362 $pem_data = der_to_pem($der_data, $header_name, $passord, $cipher_name);
312363
313364 # $header_name e.g. "PUBLIC KEY", "RSA PRIVATE KEY" ...
314365 # $cipher_name e.g. "DES-EDE3-CBC", "AES-256-CBC" (DEFAULT) ...
317368
318369 =head2 random_v4uuid
319370
320 I<Since: CryptX-0.031>
371 I<Since: 0.031>
321372
322373 my $uuid = random_v4uuid();
323374
327378
328379 =head2 is_v4uuid
329380
330 I<Since: CryptX-0.031>
381 I<Since: 0.031>
331382
332383 if (is_v4uuid($uuid)) {
333384 ...
337388
338389 =head2 increment_octets_le
339390
340 I<Since: CryptX-0.048>
391 I<Since: 0.048>
341392
342393 $octects = increment_octets_le($octets);
343394
345396
346397 =head2 increment_octets_be
347398
348 I<Since: CryptX-0.048>
399 I<Since: 0.048>
349400
350401 $octects = increment_octets_be($octets);
351402
352403 Take input C<$octets> as a big-endian big number and return an increment.
353404
405 =head2 encode_b64
406
407 I<Since: 0.029>
408
409 $base64string = encode_b64($rawdata);
410
411 Encode $rawbytes into Base64 string, no line-endings in the output string.
412
413 =head2 decode_b64
414
415 I<Since: 0.029>
416
417 $rawdata = decode_b64($base64string);
418
419 Decode a Base64 string.
420
421 =head2 encode_b64u
422
423 I<Since: 0.029>
424
425 $base64url_string = encode_b64($rawdata);
426
427 Encode $rawbytes into Base64/URL-Safe string, no line-endings in the output string.
428
429 =head2 decode_b64u
430
431 I<Since: 0.029>
432
433 $rawdata = decode_b64($base64url_string);
434
435 Decode a Base64/URL-Safe string.
436
437 =head2 encode_b32r
438
439 I<Since: 0.049>
440
441 $string = encode_b32r($rawdata);
442
443 Encode bytes into Base32 (rfc4648 alphabet) string, without "=" padding.
444
445 =head2 decode_b32r
446
447 I<Since: 0.049>
448
449 $rawdata = decode_b32r($string);
450
451 Decode a Base32 (rfc4648 alphabet) string into bytes.
452
453 =head2 encode_b32b
454
455 I<Since: 0.049>
456
457 $string = encode_b32b($rawdata);
458
459 Encode bytes into Base32 (base32hex alphabet) string, without "=" padding.
460
461 =head2 decode_b32b
462
463 I<Since: 0.049>
464
465 $rawdata = decode_b32b($string);
466
467 Decode a Base32 (base32hex alphabet) string into bytes.
468
469 =head2 encode_b32z
470
471 I<Since: 0.049>
472
473 $string = encode_b32z($rawdata);
474
475 Encode bytes into Base32 (zbase32 alphabet) string.
476
477 =head2 decode_b32z
478
479 I<Since: 0.049>
480
481 $rawdata = decode_b32z($string);
482
483 Decode a Base32 (zbase32 alphabet) string into bytes.
484
485 =head2 encode_b32c
486
487 I<Since: 0.049>
488
489 $string = encode_b32c($rawdata);
490
491 Encode bytes into Base32 (crockford alphabet) string.
492
493 =head2 decode_b32c
494
495 I<Since: 0.049>
496
497 $rawdata = decode_b32c($string);
498
499 Decode a Base32 (crockford alphabet) string into bytes.
500
501 =head2 encode_b58b
502
503 I<Since: 0.049>
504
505 $string = encode_b58b($rawdata);
506
507 Encode bytes into Base58 (Bitcoin alphabet) string.
508
509 =head2 decode_b58b
510
511 I<Since: 0.049>
512
513 $rawdata = decode_b58b($string);
514
515 Decode a Base58 (Bitcoin alphabet) string into bytes.
516
517 =head2 encode_b58f
518
519 I<Since: 0.049>
520
521 $string = encode_b58f($rawdata);
522
523 Encode bytes into Base58 (Flickr alphabet) string.
524
525 =head2 decode_b58f
526
527 I<Since: 0.049>
528
529 $rawdata = decode_b58f($string);
530
531 Decode a Base58 (Flickr alphabet) string into bytes.
532
533 =head2 encode_b58r
534
535 I<Since: 0.049>
536
537 $string = encode_b58r($rawdata);
538
539 Encode bytes into Base58 (Ripple alphabet) string.
540
541 =head2 decode_b58r
542
543 I<Since: 0.049>
544
545 $rawdata = decode_b58r($string);
546
547 Decode a Base58 (Ripple alphabet) string into bytes.
548
549 =head2 encode_b58t
550
551 I<Since: 0.049>
552
553 $string = encode_b58t($rawdata);
554
555 Encode bytes into Base58 (Tipple alphabet) string.
556
557 =head2 decode_b58t
558
559 I<Since: 0.049>
560
561 $rawdata = decode_b58t($string);
562
563 Decode a Base58 (Tipple alphabet) string into bytes.
564
565 =head2 encode_b58s
566
567 I<Since: 0.049>
568
569 $string = encode_b58s($rawdata);
570
571 Encode bytes into Base58 (Stellar alphabet) string.
572
573 =head2 decode_b58s
574
575 I<Since: 0.049>
576
577 $rawdata = decode_b58s($string);
578
579 Decode a Base58 (Stellar alphabet) string into bytes.
580
354581 =head1 SEE ALSO
355582
356583 =over
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use Crypt::Cipher;
99 use base 'Crypt::Mode';
6868
6969 =head2 start_encrypt
7070
71 See example below L</finish>.
71 $m->start_encrypt($key, $iv);
7272
7373 =head2 start_decrypt
7474
75 See example below L</finish>.
75 $m->start_decrypt($key, $iv);
7676
7777 =head2 add
7878
79 See example below L</finish>.
79 # in encrypt mode
80 my $plaintext = $m->add($ciphertext);
81
82 # in decrypt mode
83 my $ciphertext = $m->add($plaintext);
8084
8185 =head2 finish
8286
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use Crypt::Cipher;
99 use base 'Crypt::Mode';
6161
6262 =head2 start_encrypt
6363
64 See example below L</finish>.
64 $m->start_encrypt($key, $iv);
6565
6666 =head2 start_decrypt
6767
68 See example below L</finish>.
68 $m->start_decrypt($key, $iv);
6969
7070 =head2 add
7171
72 See example below L</finish>.
72 # in encrypt mode
73 my $plaintext = $m->add($ciphertext);
7374
74 =head2 finish
75
76 #encrypt more chunks
77 $m->start_encrypt($key, $iv);
78 my $ciphertext = '';
79 $ciphertext .= $m->add('some data');
80 $ciphertext .= $m->add('more data');
81
82 #decrypt more chunks
83 $m->start_decrypt($key, $iv);
84 my $plaintext = '';
85 $plaintext .= $m->add($some_ciphertext);
86 $plaintext .= $m->add($more_ciphertext);
75 # in decrypt mode
76 my $ciphertext = $m->add($plaintext);
8777
8878 =head1 SEE ALSO
8979
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use Crypt::Cipher;
99 use base 'Crypt::Mode';
6868
6969 =head2 start_encrypt
7070
71 See example below L</finish>.
71 $m->start_encrypt($key, $iv);
7272
7373 =head2 start_decrypt
7474
75 See example below L</finish>.
75 $m->start_decrypt($key, $iv);
7676
7777 =head2 add
7878
79 See example below L</finish>.
79 # in encrypt mode
80 my $plaintext = $m->add($ciphertext);
8081
81 =head2 finish
82
83 #encrypt more chunks
84 $m->start_encrypt($key, $iv);
85 my $ciphertext = '';
86 $ciphertext .= $m->add('some data');
87 $ciphertext .= $m->add('more data');
88
89 #decrypt more chunks
90 $m->start_decrypt($key, $iv);
91 my $plaintext = '';
92 $plaintext .= $m->add($some_ciphertext);
93 $plaintext .= $m->add($more_ciphertext);
82 # in decrypt mode
83 my $ciphertext = $m->add($plaintext);
9484
9585 =head1 SEE ALSO
9686
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use Crypt::Cipher;
99 use base 'Crypt::Mode';
6969
7070 =head2 start_encrypt
7171
72 See example below L</finish>.
72 $m->start_encrypt($key);
7373
7474 =head2 start_decrypt
7575
76 See example below L</finish>.
76 $m->start_decrypt($key);
7777
7878 =head2 add
7979
80 See example below L</finish>.
80 # in encrypt mode
81 my $plaintext = $m->add($ciphertext);
82
83 # in decrypt mode
84 my $ciphertext = $m->add($plaintext);
8185
8286 =head2 finish
8387
33
44 use strict;
55 use warnings;
6 our $VERSION = '0.048';
6 our $VERSION = '0.054';
77
88 use Crypt::Cipher;
99 use base 'Crypt::Mode';
6161
6262 =head2 start_encrypt
6363
64 See example below L</finish>.
64 $m->start_encrypt($key, $iv);
6565
6666 =head2 start_decrypt
6767
68 See example below L</finish>.
68 $m->start_decrypt($key, $iv);
6969
7070 =head2 add
7171
72 See example below L</finish>.
72 # in encrypt mode
73 my $plaintext = $m->add($ciphertext);
7374
74 =head2 finish
75
76 #encrypt more chunks
77 $m->start_encrypt($key, $iv);
78 my $ciphertext = '';
79 $ciphertext .= $m->add('some data');
80 $ciphertext .= $m->add('more data');
81
82 #decrypt more chunks
83 $m->start_decrypt($key, $iv);
84 my $plaintext = '';
85 $plaintext .= $m->add($some_ciphertext);
86 $plaintext .= $m->add($more_ciphertext);
75 # in decrypt mode
76 my $ciphertext = $m->add($plaintext);
8777
8878 =head1 SEE ALSO
8979
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 ### METHODS
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 require Exporter; our @ISA = qw(Exporter); ### use Exporter 'import';
7 our %EXPORT_TAGS = ( all => [qw( dh_encrypt dh_decrypt dh_sign_message dh_verify_message dh_sign_hash dh_verify_hash dh_shared_secret )] );
7 our %EXPORT_TAGS = ( all => [qw( dh_shared_secret )] );
88 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
99 our @EXPORT = qw();
1010
1111 use Carp;
1212 use CryptX;
1313 use Crypt::Digest 'digest_data';
14 use Crypt::Misc qw(read_rawfile);
14 use Crypt::Misc qw(read_rawfile pem_to_der);
15 use Scalar::Util 'looks_like_number';
1516
1617 my %DH_PARAMS = (
1718 ike768 => { g => 2, p => 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1'.
214215 croak "FATAL: invalid key type '$type'";
215216 }
216217 my $rv = $self->_import_raw($raw_bytes, $type, $g, $p);
217 croak "FATAL: invalid public key" unless $self->_is_pubkey_valid;
218218 return $rv;
219219 }
220220
221 sub encrypt {
222 my ($self, $data, $hash_name) = @_;
223 $hash_name = Crypt::Digest::_trans_digest_name($hash_name||'SHA1');
224 return $self->_encrypt($data, $hash_name);
225 }
226
227 sub decrypt {
228 my ($self, $data) = @_;
229 return $self->_decrypt($data);
230 }
231
232 sub sign_message {
233 my ($self, $data, $hash_name) = @_;
234 $hash_name ||= 'SHA1';
235 my $data_hash = digest_data($hash_name, $data);
236 return $self->_sign($data_hash);
237 }
238
239 sub verify_message {
240 my ($self, $sig, $data, $hash_name) = @_;
241 $hash_name ||= 'SHA1';
242 my $data_hash = digest_data($hash_name, $data);
243 return $self->_verify($sig, $data_hash);
244 }
245
246 sub sign_hash {
247 my ($self, $data_hash) = @_;
248 return $self->_sign($data_hash);
249 }
250
251 sub verify_hash {
252 my ($self, $sig, $data_hash) = @_;
253 return $self->_verify($sig, $data_hash);
254 }
255
256221 sub generate_key {
257 my ($key,$param) = @_;
222 my ($self, $param) = @_;
258223
259224 if (!ref $param) {
260 if (my $dhparam = $DH_PARAMS{$param}) {
261 $param = $dhparam;
262 } else {
263 croak "FATAL: invalid key length" unless ($param >= 96 || $param <= 512);
264 return $key->_generate_key($param);
265 }
266 }
267 my $g = $param->{g} or croak "FATAL: 'g' param not specified";
268 my $p = $param->{p} or croak "FATAL: 'p' param not specified";
269 $g =~ s/^0x//;
270 $p =~ s/^0x//;
271 return $key->_generate_key_ex($g, $p);
225 # group name
226 return $self->_generate_key_gp($DH_PARAMS{$param}{g}, $DH_PARAMS{$param}{p}) if $DH_PARAMS{$param};
227 # size
228 return $self->_generate_key_size($param) if looks_like_number($param);
229 }
230 elsif (ref $param eq 'SCALAR') {
231 my $data = $$param;
232 $data = pem_to_der($data) if $data =~ /-----BEGIN DH PARAMETERS-----\s*(.+)\s*-----END DH PARAMETERS-----/s;
233 return $self->_generate_key_dhparam($data);
234 }
235 elsif (ref $param eq 'HASH') {
236 my $g = $param->{g} or croak "FATAL: 'g' param not specified";
237 my $p = $param->{p} or croak "FATAL: 'p' param not specified";
238 $g =~ s/^0x//;
239 $p =~ s/^0x//;
240 return $self->_generate_key_gp($g, $p);
241 }
242 croak "FATAL: DH generate_key - invalid args";
272243 }
273244
274245 ### FUNCTIONS
275
276 sub dh_encrypt {
277 my $key = shift;
278 $key = __PACKAGE__->new($key) unless ref $key;
279 carp "FATAL: invalid 'key' param" unless ref($key) eq __PACKAGE__;
280 return $key->encrypt(@_);
281 }
282
283 sub dh_decrypt {
284 my $key = shift;
285 $key = __PACKAGE__->new($key) unless ref $key;
286 carp "FATAL: invalid 'key' param" unless ref($key) eq __PACKAGE__;
287 return $key->decrypt(@_);
288 }
289
290 sub dh_sign_message {
291 my $key = shift;
292 $key = __PACKAGE__->new($key) unless ref $key;
293 carp "FATAL: invalid 'key' param" unless ref($key) eq __PACKAGE__;
294 return $key->sign_message(@_);
295 }
296
297 sub dh_verify_message {
298 my $key = shift;
299 $key = __PACKAGE__->new($key) unless ref $key;
300 carp "FATAL: invalid 'key' param" unless ref($key) eq __PACKAGE__;
301 return $key->verify_message(@_);
302 }
303
304 sub dh_sign_hash {
305 my $key = shift;
306 $key = __PACKAGE__->new($key) unless ref $key;
307 carp "FATAL: invalid 'key' param" unless ref($key) eq __PACKAGE__;
308 return $key->sign_hash(@_);
309 }
310
311 sub dh_verify_hash {
312 my $key = shift;
313 $key = __PACKAGE__->new($key) unless ref $key;
314 carp "FATAL: invalid 'key' param" unless ref($key) eq __PACKAGE__;
315 return $key->verify_hash(@_);
316 }
317246
318247 sub dh_shared_secret {
319248 my ($privkey, $pubkey) = @_;
326255
327256 sub CLONE_SKIP { 1 } # prevent cloning
328257
258 ### DEPRECATED functions/methods
259
260 sub encrypt { croak "Crypt::DH::encrypt is deprecated (removed in v0.049)" }
261 sub decrypt { croak "Crypt::DH::decrypt is deprecated (removed in v0.049)" }
262 sub sign_message { croak "Crypt::DH::sign_message is deprecated (removed in v0.049)" }
263 sub verify_message { croak "Crypt::DH::verify_message is deprecated (removed in v0.049)" }
264 sub sign_hash { croak "Crypt::DH::sign_hash is deprecated (removed in v0.049)" }
265 sub verify_hash { croak "Crypt::DH::verify_hash is deprecated (removed in v0.049)" }
266 sub dh_encrypt { croak "Crypt::DH::dh_encrypt is deprecated (removed in v0.049)" }
267 sub dh_decrypt { croak "Crypt::DH::dh_decrypt is deprecated (removed in v0.049)" }
268 sub dh_sign_message { croak "Crypt::DH::dh_sign_message is deprecated (removed in v0.049)" }
269 sub dh_verify_message { croak "Crypt::DH::dh_verify_message is deprecated (removed in v0.049)" }
270 sub dh_sign_hash { croak "Crypt::DH::dh_sign_hash is deprecated (removed in v0.049)" }
271 sub dh_verify_hash { croak "Crypt::DH::dh_verify_hash is deprecated (removed in v0.049)" }
272
329273 1;
330274
331275 =pod
337281 =head1 SYNOPSIS
338282
339283 ### OO interface
340
341 #Encryption: Alice
342 my $pub = Crypt::PK::DH->new('Bob_pub_dh1.key');
343 my $ct = $pub->encrypt("secret message");
344 #
345 #Encryption: Bob (received ciphertext $ct)
346 my $priv = Crypt::PK::DH->new('Bob_priv_dh1.key');
347 my $pt = $priv->decrypt($ct);
348
349 #Signature: Alice
350 my $priv = Crypt::PK::DH->new('Alice_priv_dh1.key');
351 my $sig = $priv->sign_message($message);
352 #
353 #Signature: Bob (received $message + $sig)
354 my $pub = Crypt::PK::DH->new('Alice_pub_dh1.key');
355 $pub->verify_message($sig, $message) or die "ERROR";
356284
357285 #Shared secret
358286 my $priv = Crypt::PK::DH->new('Alice_priv_dh1.key');
381309
382310 ### Functional interface
383311
384 #Encryption: Alice
385 my $ct = dh_encrypt('Bob_pub_dh1.key', "secret message");
386 #Encryption: Bob (received ciphertext $ct)
387 my $pt = dh_decrypt('Bob_priv_dh1.key', $ct);
388
389 #Signature: Alice
390 my $sig = dh_sign_message('Alice_priv_dh1.key', $message);
391 #Signature: Bob (received $message + $sig)
392 dh_verify_message('Alice_pub_dh1.key', $sig, $message) or die "ERROR";
393
394312 #Shared secret
395313 my $shared_secret = dh_shared_secret('Alice_priv_dh1.key', 'Bob_pub_dh1.key');
396314
409327 Uses Yarrow-based cryptographically strong random number generator seeded with
410328 random data taken from C</dev/random> (UNIX) or C<CryptGenRandom> (Win32).
411329
412 $pk->generate_key($keysize);
413 ### $keysize (in bytes) corresponds to DH params (p, g) predefined by libtomcrypt
330 $pk->generate_key($groupsize);
331 ### $groupsize (in bytes) corresponds to DH params (p, g) predefined by libtomcrypt
414332 # 96 => DH-768
415333 # 128 => DH-1024
416 # 160 => DH-1280
417334 # 192 => DH-1536
418 # 224 => DH-1792
419335 # 256 => DH-2048
420 # 320 => DH-2560
421336 # 384 => DH-3072
422337 # 512 => DH-4096
338 # 768 => DH-6144
339 # 1024 => DH-8192
423340
424341 The following variants are available since CryptX-0.032
425342
426 $pk->generate_key($name)
427 ### $name corresponds to values defined in RFC7296 and RFC3526
428 # ike768 => 768-bit MODP (Group 1)
429 # ike1024 => 1024-bit MODP (Group 2)
430 # ike1536 => 1536-bit MODP (Group 5)
431 # ike2048 => 2048-bit MODP (Group 14)
432 # ike3072 => 3072-bit MODP (Group 15)
433 # ike4096 => 4096-bit MODP (Group 16)
434 # ike6144 => 6144-bit MODP (Group 17)
435 # ike8192 => 8192-bit MODP (Group 18)
343 $pk->generate_key($groupname)
344 ### $groupname corresponds to values defined in RFC7296 and RFC3526
345 # 'ike768' => 768-bit MODP (Group 1)
346 # 'ike1024' => 1024-bit MODP (Group 2)
347 # 'ike1536' => 1536-bit MODP (Group 5)
348 # 'ike2048' => 2048-bit MODP (Group 14)
349 # 'ike3072' => 3072-bit MODP (Group 15)
350 # 'ike4096' => 4096-bit MODP (Group 16)
351 # 'ike6144' => 6144-bit MODP (Group 17)
352 # 'ike8192' => 8192-bit MODP (Group 18)
436353
437354 $pk->generate_key($param_hash)
438 ## $param_hash is { g => $g, p => $p }
439 ## where $g is the generator (base) in a hex string and $p is the prime in a hex string
355 # $param_hash is { g => $g, p => $p }
356 # where $g is the generator (base) in a hex string and $p is the prime in a hex string
357
358 $pk->generate_key(\$dh_param)
359 # $dh_param is the content of DER or PEM file with DH params
360 # e.g. openssl dhparam 2048
440361
441362 =head2 import_key
442363
458379
459380 =head2 export_key
460381
382 B<BEWARE:> DH key format change - since v0.049 it is compatible with libtocrypt 1.18.
383
461384 my $private = $pk->export_key('private');
462385 #or
463386 my $public = $pk->export_key('public');
469392 $raw_bytes = $dh->export_key_raw('public')
470393 #or
471394 $raw_bytes = $dh->export_key_raw('private')
472
473 =head2 encrypt
474
475 my $pk = Crypt::PK::DH->new($pub_key_filename);
476 my $ct = $pk->encrypt($message);
477 #or
478 my $ct = $pk->encrypt($message, $hash_name);
479
480 #NOTE: $hash_name can be 'SHA1' (DEFAULT), 'SHA256' or any other hash supported by Crypt::Digest
481
482 =head2 decrypt
483
484 my $pk = Crypt::PK::DH->new($priv_key_filename);
485 my $pt = $pk->decrypt($ciphertext);
486
487 =head2 sign_message
488
489 my $pk = Crypt::PK::DH->new($priv_key_filename);
490 my $signature = $priv->sign_message($message);
491 #or
492 my $signature = $priv->sign_message($message, $hash_name);
493
494 #NOTE: $hash_name can be 'SHA1' (DEFAULT), 'SHA256' or any other hash supported by Crypt::Digest
495
496 =head2 verify_message
497
498 my $pk = Crypt::PK::DH->new($pub_key_filename);
499 my $valid = $pub->verify_message($signature, $message)
500 #or
501 my $valid = $pub->verify_message($signature, $message, $hash_name);
502
503 #NOTE: $hash_name can be 'SHA1' (DEFAULT), 'SHA256' or any other hash supported by Crypt::Digest
504
505 =head2 sign_hash
506
507 my $pk = Crypt::PK::DH->new($priv_key_filename);
508 my $signature = $priv->sign_hash($message_hash);
509
510 =head2 verify_hash
511
512 my $pk = Crypt::PK::DH->new($pub_key_filename);
513 my $valid = $pub->verify_hash($signature, $message_hash);
514395
515396 =head2 shared_secret
516397
564445
565446 =head1 FUNCTIONS
566447
567 =head2 dh_encrypt
568
569 DH based encryption as implemented by libtomcrypt. See method L</encrypt> below.
570
571 my $ct = dh_encrypt($pub_key_filename, $message);
572 #or
573 my $ct = dh_encrypt(\$buffer_containing_pub_key, $message);
574 #or
575 my $ct = dh_encrypt($pub_key_filename, $message, $hash_name);
576
577 #NOTE: $hash_name can be 'SHA1' (DEFAULT), 'SHA256' or any other hash supported by Crypt::Digest
578
579 Encryption works similar to the L<Crypt::PK::ECC> encryption whereas shared DH key is computed, and
580 the hash of the shared key XOR'ed against the plaintext forms the ciphertext.
581
582 =head2 dh_decrypt
583
584 DH based decryption as implemented by libtomcrypt. See method L</decrypt> below.
585
586 my $pt = dh_decrypt($priv_key_filename, $ciphertext);
587 #or
588 my $pt = dh_decrypt(\$buffer_containing_priv_key, $ciphertext);
589
590 =head2 dh_sign_message
591
592 Generate DH signature as implemented by libtomcrypt. See method L</sign_message> below.
593
594 my $sig = dh_sign_message($priv_key_filename, $message);
595 #or
596 my $sig = dh_sign_message(\$buffer_containing_priv_key, $message);
597 #or
598 my $sig = dh_sign_message($priv_key, $message, $hash_name);
599
600 =head2 dh_verify_message
601
602 Verify DH signature as implemented by libtomcrypt. See method L</verify_message> below.
603
604 dh_verify_message($pub_key_filename, $signature, $message) or die "ERROR";
605 #or
606 dh_verify_message(\$buffer_containing_pub_key, $signature, $message) or die "ERROR";
607 #or
608 dh_verify_message($pub_key, $signature, $message, $hash_name) or die "ERROR";
609
610 =head2 dh_sign_hash
611
612 Generate DH signature as implemented by libtomcrypt. See method L</sign_hash> below.
613
614 my $sig = dh_sign_hash($priv_key_filename, $message_hash);
615 #or
616 my $sig = dh_sign_hash(\$buffer_containing_priv_key, $message_hash);
617
618 =head2 dh_verify_hash
619
620 Verify DH signature as implemented by libtomcrypt. See method L</verify_hash> below.
621
622 dh_verify_hash($pub_key_filename, $signature, $message_hash) or die "ERROR";
623 #or
624 dh_verify_hash(\$buffer_containing_pub_key, $signature, $message_hash) or die "ERROR";
625
626448 =head2 dh_shared_secret
627449
628450 DH based shared secret generation. See method L</shared_secret> below.
633455 #on Bob side
634456 my $shared_secret = dh_shared_secret('Bob_priv_dh1.key', 'Alice_pub_dh1.key');
635457
458 =head1 DEPRECATED INTERFACE
459
460 The following functions/methods were removed in removed in v0.049:
461
462 encrypt
463 decrypt
464 sign_message
465 verify_message
466 sign_hash
467 verify_hash
468
469 dh_encrypt
470 dh_decrypt
471 dh_sign_message
472 dh_verify_message
473 dh_sign_hash
474 dh_verify_hash
475
636476 =head1 SEE ALSO
637477
638478 =over
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
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 )] );
99 our @EXPORT = qw();
1010
1111 use Carp;
12 use CryptX qw(_encode_json _decode_json);
12 use CryptX;
1313 use Crypt::Digest 'digest_data';
1414 use Crypt::Misc qw(read_rawfile encode_b64u decode_b64u encode_b64 decode_b64 pem_to_der der_to_pem);
1515 use Crypt::PK;
1919 my $self = _new();
2020 $self->import_key($f, $p) if $f;
2121 return $self;
22 }
23
24 sub generate_key {
25 my $self = shift;
26 return $self->_generate_key_size(@_) if @_ == 2;
27 if (@_ == 1 && ref $_[0] eq 'HASH') {
28 my $param = shift;
29 my $p = $param->{p} or croak "FATAL: 'p' param not specified";
30 my $q = $param->{q} or croak "FATAL: 'q' param not specified";
31 my $g = $param->{g} or croak "FATAL: 'g' param not specified";
32 $p =~ s/^0x//;
33 $q =~ s/^0x//;
34 $g =~ s/^0x//;
35 return $self->_generate_key_pqg_hex($p, $q, $g);
36 }
37 elsif (@_ == 1 && ref $_[0] eq 'SCALAR') {
38 my $data = ${$_[0]};
39 $data = pem_to_der($data) if $data =~ /-----BEGIN DSA PARAMETERS-----\s*(.+)\s*-----END DSA PARAMETERS-----/s;
40 return $self->_generate_key_dsaparam($data);
41 }
42 croak "FATAL: DSA generate_key - invalid args";
2243 }
2344
2445 sub export_key_pem {
251272 # L = 2048, N = 256 => generate_key(32, 256)
252273 # L = 3072, N = 256 => generate_key(32, 384)
253274
275 $pk->generate_key($param_hash)
276 # $param_hash is { d => $d, p => $p, q => $q }
277 # where $d, $p, $q are hex strings
278
279 $pk->generate_key(\$dsa_param)
280 # $dsa_param is the content of DER or PEM file with DSA params
281 # e.g. openssl dsaparam 2048
282
254283 =head2 import_key
255284
256285 Loads private or public key in DER or PEM format.
539568
540569 use Crypt::PK::DSA;
541570 use Crypt::Digest 'digest_file';
542 use File::Slurp 'read_file';
571 use Crypt::Misc 'read_rawfile';
543572
544573 my $pkdsa = Crypt::PK::DSA->new("dsakey.pub.pem");
545 my $signature = read_file("input.sha1-dsa.sig", binmode=>':raw');
574 my $signature = read_rawfile("input.sha1-dsa.sig");
546575 my $valid = $pkdsa->verify_hash($signature, digest_file("SHA1", "input.data"), "SHA1", "v1.5");
547576 print $valid ? "SUCCESS" : "FAILURE";
548577
552581
553582 use Crypt::PK::DSA;
554583 use Crypt::Digest 'digest_file';
555 use File::Slurp 'write_file';
584 use Crypt::Misc 'write_rawfile';
556585
557586 my $pkdsa = Crypt::PK::DSA->new("dsakey.priv.pem");
558587 my $signature = $pkdsa->sign_hash(digest_file("SHA1", "input.data"), "SHA1", "v1.5");
559 write_file("input.sha1-dsa.sig", {binmode=>':raw'}, $signature);
588 write_rawfile("input.sha1-dsa.sig", $signature);
560589
561590 Verify signature (from commandline):
562591
567596 Generate keys (Perl code):
568597
569598 use Crypt::PK::DSA;
570 use File::Slurp 'write_file';
599 use Crypt::Misc 'write_rawfile';
571600
572601 my $pkdsa = Crypt::PK::DSA->new;
573602 $pkdsa->generate_key(20, 128);
574 write_file("dsakey.pub.der", {binmode=>':raw'}, $pkdsa->export_key_der('public'));
575 write_file("dsakey.priv.der", {binmode=>':raw'}, $pkdsa->export_key_der('private'));
576 write_file("dsakey.pub.pem", $pkdsa->export_key_pem('public_x509'));
577 write_file("dsakey.priv.pem", $pkdsa->export_key_pem('private'));
578 write_file("dsakey-passwd.priv.pem", $pkdsa->export_key_pem('private', 'secret'));
603 write_rawfile("dsakey.pub.der", $pkdsa->export_key_der('public'));
604 write_rawfile("dsakey.priv.der", $pkdsa->export_key_der('private'));
605 write_rawfile("dsakey.pub.pem", $pkdsa->export_key_pem('public_x509'));
606 write_rawfile("dsakey.priv.pem", $pkdsa->export_key_pem('private'));
607 write_rawfile("dsakey-passwd.priv.pem", $pkdsa->export_key_pem('private', 'secret'));
579608
580609 Use keys by OpenSSL:
581610
598627 Load keys (Perl code):
599628
600629 use Crypt::PK::DSA;
601 use File::Slurp 'write_file';
602630
603631 my $pkdsa = Crypt::PK::DSA->new;
604632 $pkdsa->import_key("dsakey.pub.der");
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
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 )] );
99 our @EXPORT = qw();
1010
1111 use Carp;
12 use CryptX qw(_encode_json _decode_json);
12 use CryptX;
1313 use Crypt::Digest qw(digest_data digest_data_b64u);
1414 use Crypt::Misc qw(read_rawfile encode_b64u decode_b64u encode_b64 decode_b64 pem_to_der der_to_pem);
1515 use Crypt::PK;
460460 y => encode_b64u(pack("H*", $kh->{pub_y})),
461461 d => encode_b64u(pack("H*", $kh->{k})),
462462 };
463 return $wanthash ? $hash : _encode_json($hash);
463 return $wanthash ? $hash : CryptX::_encode_json($hash);
464464 }
465465 elsif ($type && $type eq 'public') {
466466 return unless $kh->{pub_x} && $kh->{pub_y};
472472 x => encode_b64u(pack("H*", $kh->{pub_x})),
473473 y => encode_b64u(pack("H*", $kh->{pub_y})),
474474 };
475 return $wanthash ? $hash : _encode_json($hash);
475 return $wanthash ? $hash : CryptX::_encode_json($hash);
476476 }
477477 }
478478
480480 my ($self, $hash_name) = @_;
481481 $hash_name ||= 'SHA256';
482482 my $h = $self->export_key_jwk('public', 1);
483 my $json = _encode_json({crv=>$h->{crv}, kty=>$h->{kty}, x=>$h->{x}, y=>$h->{y}});
483 my $json = CryptX::_encode_json({crv=>$h->{crv}, kty=>$h->{kty}, x=>$h->{x}, y=>$h->{y}});
484484 return digest_data_b64u($hash_name, $json);
485485 }
486486
529529 }
530530 elsif ($data =~ /-----BEGIN PRIVATE KEY-----(.*?)-----END/sg) {
531531 $data = pem_to_der($data, $password);
532 return $self->_import_pkcs8($data);
532 return $self->_import_pkcs8($data, $password);
533533 }
534534 elsif ($data =~ /-----BEGIN ENCRYPTED PRIVATE KEY-----(.*?)-----END/sg) {
535535 # XXX-TODO: pkcs#8 encrypted private key
538538 elsif ($data =~ /^\s*(\{.*?\})\s*$/s) {
539539 # JSON Web Key (JWK) - http://tools.ietf.org/html/draft-ietf-jose-json-web-key
540540 my $json = "$1";
541 my $h = _decode_json($json);
541 my $h = CryptX::_decode_json($json);
542542 if ($h && $h->{kty} eq "EC") {
543543 for (qw/x y d/) {
544544 $h->{$_} = eval { unpack("H*", decode_b64u($h->{$_})) } if exists $h->{$_};
561561 return $self->import_key_raw($pubkey, "$2") if $pubkey && $typ =~ /^ecdsa-(.+?)-(.*)$/;
562562 }
563563 else {
564 my $rv = eval { $self->_import($data) } || eval { $self->_import_pkcs8($data) };
564 my $rv = eval { $self->_import($data) } || eval { $self->_import_pkcs8($data, $password) };
565565 return $rv if $rv;
566566 }
567567 croak "FATAL: invalid or unsupported EC key format";
10871087
10881088 Exports the key's JSON Web Key Thumbprint as a string.
10891089
1090 If you don't know what this is, see RFC 7638 (C<https://tools.ietf.org/html/rfc7638>).
1090 If you don't know what this is, see RFC 7638 L<https://tools.ietf.org/html/rfc7638>.
10911091
10921092 my $thumbprint = $pk->export_key_jwk_thumbprint('SHA256');
10931093
13121312
13131313 use Crypt::PK::ECC;
13141314 use Crypt::Digest 'digest_file';
1315 use File::Slurp 'read_file';
1315 use Crypt::Misc 'read_rawfile';
13161316
13171317 my $pkec = Crypt::PK::ECC->new("eckey.pub.pem");
1318 my $signature = read_file("input.sha1-ec.sig", binmode=>':raw');
1318 my $signature = read_rawfile("input.sha1-ec.sig");
13191319 my $valid = $pkec->verify_hash($signature, digest_file("SHA1", "input.data"), "SHA1", "v1.5");
13201320 print $valid ? "SUCCESS" : "FAILURE";
13211321
13251325
13261326 use Crypt::PK::ECC;
13271327 use Crypt::Digest 'digest_file';
1328 use File::Slurp 'write_file';
1328 use Crypt::Misc 'write_rawfile';
13291329
13301330 my $pkec = Crypt::PK::ECC->new("eckey.priv.pem");
13311331 my $signature = $pkec->sign_hash(digest_file("SHA1", "input.data"), "SHA1", "v1.5");
1332 write_file("input.sha1-ec.sig", {binmode=>':raw'}, $signature);
1332 write_rawfile("input.sha1-ec.sig", $signature);
13331333
13341334 Verify signature (from commandline):
13351335
13401340 Generate keys (Perl code):
13411341
13421342 use Crypt::PK::ECC;
1343 use File::Slurp 'write_file';
1343 use Crypt::Misc 'write_rawfile';
13441344
13451345 my $pkec = Crypt::PK::ECC->new;
13461346 $pkec->generate_key('secp160k1');
1347 write_file("eckey.pub.der", {binmode=>':raw'}, $pkec->export_key_der('public'));
1348 write_file("eckey.priv.der", {binmode=>':raw'}, $pkec->export_key_der('private'));
1349 write_file("eckey.pub.pem", $pkec->export_key_pem('public'));
1350 write_file("eckey.priv.pem", $pkec->export_key_pem('private'));
1351 write_file("eckey-passwd.priv.pem", $pkec->export_key_pem('private', 'secret'));
1347 write_rawfile("eckey.pub.der", $pkec->export_key_der('public'));
1348 write_rawfile("eckey.priv.der", $pkec->export_key_der('private'));
1349 write_rawfile("eckey.pub.pem", $pkec->export_key_pem('public'));
1350 write_rawfile("eckey.priv.pem", $pkec->export_key_pem('private'));
1351 write_rawfile("eckey-passwd.priv.pem", $pkec->export_key_pem('private', 'secret'));
13521352
13531353 Use keys by OpenSSL:
13541354
13731373 Load keys (Perl code):
13741374
13751375 use Crypt::PK::ECC;
1376 use File::Slurp 'write_file';
13771376
13781377 my $pkec = Crypt::PK::ECC->new;
13791378 $pkec->import_key("eckey.pub.der");
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
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)] );
99 our @EXPORT = qw();
1010
1111 use Carp;
12 use CryptX qw(_encode_json _decode_json);
12 use CryptX;
1313 use Crypt::Digest qw(digest_data digest_data_b64u);
1414 use Crypt::Misc qw(read_rawfile encode_b64u decode_b64u encode_b64 decode_b64 pem_to_der der_to_pem);
1515 use Crypt::PK;
5656 dq => encode_b64u(pack("H*", $kh->{dQ})),
5757 qi => encode_b64u(pack("H*", $kh->{qP})),
5858 };
59 return $wanthash ? $hash : _encode_json($hash);
59 return $wanthash ? $hash : CryptX::_encode_json($hash);
6060 }
6161 elsif ($type eq 'public') {
6262 return unless $kh->{N} && $kh->{e};
6868 n => encode_b64u(pack("H*", $kh->{N})),
6969 e => encode_b64u(pack("H*", $kh->{e})),
7070 };
71 return $wanthash ? $hash : _encode_json($hash);
71 return $wanthash ? $hash : CryptX::_encode_json($hash);
7272 }
7373 }
7474
7676 my ($self, $hash_name) = @_;
7777 $hash_name ||= 'SHA256';
7878 my $h = $self->export_key_jwk('public', 1);
79 my $json = _encode_json({kty=>$h->{kty}, n=>$h->{n}, e=>$h->{e}});
79 my $json = CryptX::_encode_json({kty=>$h->{kty}, n=>$h->{n}, e=>$h->{e}});
8080 return digest_data_b64u($hash_name, $json);
8181 }
8282
124124 elsif ($data =~ /-----BEGIN PRIVATE KEY-----(.*?)-----END/sg) {
125125 # PKCS#8 PrivateKeyInfo (PEM header: BEGIN PRIVATE KEY)
126126 $data = pem_to_der($data, $password);
127 return $self->_import_pkcs8($data) if $data;
127 return $self->_import_pkcs8($data, $password) if $data;
128128 }
129129 elsif ($data =~ /-----BEGIN ENCRYPTED PRIVATE KEY-----(.*?)-----END/sg) {
130130 # XXX-TODO: PKCS#8 EncryptedPrivateKeyInfo (PEM header: BEGIN ENCRYPTED PRIVATE KEY)
133133 elsif ($data =~ /^\s*(\{.*?\})\s*$/s) {
134134 # JSON Web Key (JWK) - http://tools.ietf.org/html/draft-ietf-jose-json-web-key
135135 my $json = "$1";
136 my $h = _decode_json($json);
136 my $h = CryptX::_decode_json($json);
137137 if ($h && $h->{kty} eq "RSA") {
138138 for (qw/n e d p q dp dq qi/) {
139139 $h->{$_} = eval { unpack("H*", decode_b64u($h->{$_})) } if exists $h->{$_};
141141 return $self->_import_hex($h->{n}, $h->{e}, $h->{d}, $h->{p}, $h->{q}, $h->{dp}, $h->{dq}, $h->{qi}) if $h->{n} && $h->{e};
142142 }
143143 }
144 elsif ($data =~ /-----BEGIN CERTIFICATE-----(.*?)-----END CERTIFICATE-----/sg) {
145 $data = pem_to_der($data);
146 return $self->_import_x509($data);
147 }
144148 elsif ($data =~ /---- BEGIN SSH2 PUBLIC KEY ----(.*?)---- END SSH2 PUBLIC KEY ----/sg) {
145149 $data = pem_to_der($data);
146150 my ($typ, $N, $e) = Crypt::PK::_ssh_parse($data);
153157 }
154158 else {
155159 # DER format
156 my $rv = eval { $self->_import($data) } || eval { $self->_import_pkcs8($data) };
160 my $rv = eval { $self->_import($data) } || eval { $self->_import_pkcs8($data, $password) } || eval { $self->_import_x509($data) };
157161 return $rv if $rv;
158162 }
159163
478482 1HPwZX2d
479483 -----END ENCRYPTED PRIVATE KEY-----
480484
485 =item * RSA public key from X509 certificate
486
487 -----BEGIN CERTIFICATE-----
488 MIIC8zCCAdugAwIBAgIJAPi+LvMU3uGWMA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNV
489 BAMMBXBva3VzMB4XDTE3MDcxNDE0MTAyMFoXDTIwMDQwOTE0MTAyMFowEDEOMAwG
490 A1UEAwwFcG9rdXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCQima
491 SUIMIdz5uVevzcScbcj06xs1OLaFKUoPJ8v+xP6Ut61BQhAvc8GYuw2uRx223hZC
492 r3HYLfSdWIfmOIAtlL8cPYPVoSivJtpSGE6fBG1tlBjVgXWRmJGR/oxx6Y5QDwcB
493 Q4GZKga8TtHQoY5idZuatYOFZGfMIcIUC0Uoda+YSypnw7A90F/JvlpcTUh3Fnem
494 VinqEA6XOegU9dCZk/29sXqauBjbdGihh8DvpklOhY16eQoiR3909AywQ0KUmI+R
495 Sa9E8oIsmUDetFuXEvana+sD3y42tU+cd2nhBPRETbSXPcum0B3uF4yKgweuJy5D
496 cvtVQIFVkkh4+AWNAgMBAAGjUDBOMB0GA1UdDgQWBBSS6V5PVGyN92NoB0AVLcOb
497 pzR3SzAfBgNVHSMEGDAWgBSS6V5PVGyN92NoB0AVLcObpzR3SzAMBgNVHRMEBTAD
498 AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBIszrBjoJ39axsS6Btbvwvo8vAmgiSWsav
499 7AmjXOAwknHPaCcDmrdOys5POD0DNRwNeRsnxFiZ/UL8Vmj2JGDLgAw+/v32MwfX
500 Ig7m+oIbO8KqDzlYvS5kd3suJ5C21hHy1/JUtfofZLovZH7ZRzhTAoRvCYaodW90
501 2o8ZqmyCdcXPzjFmoJ2xYzs/Sf8/E1cHfb+4HjOpeRnKxDvG0gwWzcsXpUrw2pNO
502 Oztj6Rd0THNrf/anIeYVtAHX4aqZA8Kbv2TyJd+9g78usFw1cn+8vfmilm6Pn0DQ
503 a+I5GyGd7BJI8wYuWqIStzvrJHbQQaNrSk7hgjWYiYlcsPh6w2QP
504 -----END CERTIFICATE-----
505
481506 =item * SSH public RSA keys
482507
483508 ssh-rsa AAAAB3NzaC1yc2EAAAADAQA...6mdYs5iJNGu/ltUdc=
585610
586611 Exports the key's JSON Web Key Thumbprint as a string.
587612
588 If you don't know what this is, see RFC 7638 (C<https://tools.ietf.org/html/rfc7638>).
613 If you don't know what this is, see RFC 7638 L<https://tools.ietf.org/html/rfc7638>.
589614
590615 my $thumbprint = $pk->export_key_jwk_thumbprint('SHA256');
591616
828853 Decrypt file (Perl code):
829854
830855 use Crypt::PK::RSA;
831 use File::Slurp 'read_file';
856 use Crypt::Misc 'read_rawfile';
832857
833858 my $pkrsa = Crypt::PK::RSA->new("rsakey.priv.pem");
834 my $encfile = read_file("input.encrypted.rsa", binmode=>':raw');
859 my $encfile = read_rawfile("input.encrypted.rsa");
835860 my $plaintext = $pkrsa->decrypt($encfile, 'v1.5');
836861 print $plaintext;
837862
840865 Create encrypted file (Perl code):
841866
842867 use Crypt::PK::RSA;
843 use File::Slurp 'write_file';
868 use Crypt::Misc 'write_rawfile';
844869
845870 my $plaintext = 'secret message';
846871 my $pkrsa = Crypt::PK::RSA->new("rsakey.pub.pem");
847872 my $encrypted = $pkrsa->encrypt($plaintext, 'v1.5');
848 write_file("input.encrypted.rsa", {binmode=>':raw'}, $encrypted);
873 write_rawfile("input.encrypted.rsa", $encrypted);
849874
850875 Decrypt file (from commandline):
851876
861886
862887 use Crypt::PK::RSA;
863888 use Crypt::Digest 'digest_file';
864 use File::Slurp 'read_file';
889 use Crypt::Misc 'read_rawfile';
865890
866891 my $pkrsa = Crypt::PK::RSA->new("rsakey.pub.pem");
867 my $signature = read_file("input.sha1-rsa.sig", binmode=>':raw');
892 my $signature = read_rawfile("input.sha1-rsa.sig");
868893 my $valid = $pkrsa->verify_hash($signature, digest_file("SHA1", "input.data"), "SHA1", "v1.5");
869894 print $valid ? "SUCCESS" : "FAILURE";
870895
874899
875900 use Crypt::PK::RSA;
876901 use Crypt::Digest 'digest_file';
877 use File::Slurp 'write_file';
902 use Crypt::Misc 'write_rawfile';
878903
879904 my $pkrsa = Crypt::PK::RSA->new("rsakey.priv.pem");
880905 my $signature = $pkrsa->sign_hash(digest_file("SHA1", "input.data"), "SHA1", "v1.5");
881 write_file("input.sha1-rsa.sig", {binmode=>':raw'}, $signature);
906 write_rawfile("input.sha1-rsa.sig", $signature);
882907
883908 Verify signature (from commandline):
884909
889914 Generate keys (Perl code):
890915
891916 use Crypt::PK::RSA;
892 use File::Slurp 'write_file';
917 use Crypt::Misc 'write_rawfile';
893918
894919 my $pkrsa = Crypt::PK::RSA->new;
895920 $pkrsa->generate_key(256, 65537);
896 write_file("rsakey.pub.der", {binmode=>':raw'}, $pkrsa->export_key_der('public'));
897 write_file("rsakey.priv.der", {binmode=>':raw'}, $pkrsa->export_key_der('private'));
898 write_file("rsakey.pub.pem", $pkrsa->export_key_pem('public_x509'));
899 write_file("rsakey.priv.pem", $pkrsa->export_key_pem('private'));
900 write_file("rsakey-passwd.priv.pem", $pkrsa->export_key_pem('private', 'secret'));
921 write_rawfile("rsakey.pub.der", $pkrsa->export_key_der('public'));
922 write_rawfile("rsakey.priv.der", $pkrsa->export_key_der('private'));
923 write_rawfile("rsakey.pub.pem", $pkrsa->export_key_pem('public_x509'));
924 write_rawfile("rsakey.priv.pem", $pkrsa->export_key_pem('private'));
925 write_rawfile("rsakey-passwd.priv.pem", $pkrsa->export_key_pem('private', 'secret'));
901926
902927 Use keys by OpenSSL:
903928
920945 Load keys (Perl code):
921946
922947 use Crypt::PK::RSA;
923 use File::Slurp 'write_file';
924948
925949 my $pkrsa = Crypt::PK::RSA->new;
926950 $pkrsa->import_key("rsakey.pub.der");
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use Carp;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
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.048';
4 our $VERSION = '0.054';
55
66 use base qw(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.048';
4 our $VERSION = '0.054';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use CryptX;
77
11
22 use strict;
33 use warnings ;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use base qw(Exporter);
7 our @EXPORT_OK = qw( _decode_json _encode_json);
7 our @EXPORT_OK = qw();
88
99 require XSLoader;
1010 XSLoader::load('CryptX', $VERSION);
8181
8282 =item * Hash Functions - see L<Crypt::Digest> and related modules
8383
84 L<Crypt::Digest::BLAKE2b_160>, L<Crypt::Digest::BLAKE2b_256>, L<Crypt::Digest::BLAKE2b_384>, L<Crypt::Digest::BLAKE2b_512>,
85 L<Crypt::Digest::BLAKE2s_128>, L<Crypt::Digest::BLAKE2s_160>, L<Crypt::Digest::BLAKE2s_224>, L<Crypt::Digest::BLAKE2s_256>,
8486 L<Crypt::Digest::CHAES>, L<Crypt::Digest::MD2>, L<Crypt::Digest::MD4>, L<Crypt::Digest::MD5>, L<Crypt::Digest::RIPEMD128>, L<Crypt::Digest::RIPEMD160>,
8587 L<Crypt::Digest::RIPEMD256>, L<Crypt::Digest::RIPEMD320>, L<Crypt::Digest::SHA1>, L<Crypt::Digest::SHA224>, L<Crypt::Digest::SHA256>, L<Crypt::Digest::SHA384>,
8688 L<Crypt::Digest::SHA512>, L<Crypt::Digest::SHA512_224>, L<Crypt::Digest::SHA512_256>, L<Crypt::Digest::Tiger192>, L<Crypt::Digest::Whirlpool>,
102104
103105 L<Crypt::KeyDerivation>
104106
107 =item * Other handy functions related to cryptography
108
109 L<Crypt::Misc>
110
105111 =back
106112
107113 =head1 LICENSE
11
22 use strict;
33 use warnings;
4 our $VERSION = '0.048';
4 our $VERSION = '0.054';
55
66 use CryptX;
77
+264
-104
ppport.h less more
33 /*
44 ----------------------------------------------------------------------
55
6 ppport.h -- Perl/Pollution/Portability Version 3.31
7
8 Automatically created by Devel::PPPort running under perl 5.018002.
6 ppport.h -- Perl/Pollution/Portability Version 3.36
7
8 Automatically created by Devel::PPPort running under perl 5.022003.
99
1010 Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
1111 includes in parts/inc/ instead.
2020
2121 =head1 NAME
2222
23 ppport.h - Perl/Pollution/Portability version 3.31
23 ppport.h - Perl/Pollution/Portability version 3.36
2424
2525 =head1 SYNOPSIS
2626
218218 -----------------------------------------------------------------------------------------
219219 PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL
220220 PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL
221 SvRX() NEED_SvRX NEED_SvRX_GLOBAL
221222 caller_cx() NEED_caller_cx NEED_caller_cx_GLOBAL
222223 eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL
223224 grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL
225226 grok_number() NEED_grok_number NEED_grok_number_GLOBAL
226227 grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL
227228 grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL
229 gv_fetchpvn_flags() NEED_gv_fetchpvn_flags NEED_gv_fetchpvn_flags_GLOBAL
228230 load_module() NEED_load_module NEED_load_module_GLOBAL
229231 mg_findext() NEED_mg_findext NEED_mg_findext_GLOBAL
230232 my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL
380382 # Disable broken TRIE-optimization
381383 BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 }
382384
383 my $VERSION = 3.31;
385 my $VERSION = 3.36;
384386
385387 my %opt = (
386388 quiet => 0,
450452 ASCII_TO_NEED||5.007001|n
451453 AvFILLp|5.004050||p
452454 AvFILL|||
453 BhkDISABLE||5.021008|
454 BhkENABLE||5.021008|
455 BhkENTRY_set||5.021008|
455 BhkDISABLE||5.024000|
456 BhkENABLE||5.024000|
457 BhkENTRY_set||5.024000|
456458 BhkENTRY|||
457459 BhkFLAGS|||
458460 CALL_BLOCK_HOOKS|||
460462 CPERLscope|5.005000||p
461463 CX_CURPAD_SAVE|||
462464 CX_CURPAD_SV|||
465 C_ARRAY_END|5.013002||p
466 C_ARRAY_LENGTH|5.008001||p
463467 CopFILEAV|5.006000||p
464468 CopFILEGV_set|5.006000||p
465469 CopFILEGV|5.006000||p
476480 CvPADLIST||5.008001|
477481 CvSTASH|||
478482 CvWEAKOUTSIDE|||
483 DECLARATION_FOR_LC_NUMERIC_MANIPULATION||5.021010|n
479484 DEFSV_set|5.010001||p
480485 DEFSV|5.004050||p
486 DO_UTF8||5.006000|
481487 END_EXTERN_C|5.005000||p
482488 ENTER|||
483489 ERRSV|5.004050||p
499505 GvAV|||
500506 GvCV|||
501507 GvHV|||
502 GvSVn|5.009003||p
503508 GvSV|||
504509 Gv_AMupdate||5.011000|
505510 HEf_SVKEY|5.003070||p
538543 LINKLIST||5.013006|
539544 LVRET|||
540545 MARK|||
541 MULTICALL||5.021008|
546 MULTICALL||5.024000|
542547 MUTABLE_PTR|5.010001||p
543548 MUTABLE_SV|5.010001||p
544549 MY_CXT_CLONE|5.009002||p
567572 OP_TYPE_IS_OR_WAS||5.019010|
568573 OP_TYPE_IS||5.019007|
569574 ORIGMARK|||
570 OpHAS_SIBLING||5.021007|
571 OpSIBLING_set||5.021007|
572 OpSIBLING||5.021007|
575 OpHAS_SIBLING|5.021007||p
576 OpLASTSIB_set|5.021011||p
577 OpMAYBESIB_set|5.021011||p
578 OpMORESIB_set|5.021011||p
579 OpSIBLING|5.021007||p
573580 PAD_BASE_SV|||
574581 PAD_CLONE_VARS|||
575582 PAD_COMPNAME_FLAGS|||
589596 PERLIO_FUNCS_CAST|5.009003||p
590597 PERLIO_FUNCS_DECL|5.009003||p
591598 PERL_ABS|5.008001||p
592 PERL_BCDVERSION|5.021008||p
599 PERL_BCDVERSION|5.024000||p
593600 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
594601 PERL_HASH|5.003070||p
595602 PERL_INT_MAX|5.003070||p
607614 PERL_MAGIC_env|5.007002||p
608615 PERL_MAGIC_ext|5.007002||p
609616 PERL_MAGIC_fm|5.007002||p
610 PERL_MAGIC_glob|5.021008||p
617 PERL_MAGIC_glob|5.024000||p
611618 PERL_MAGIC_isaelem|5.007002||p
612619 PERL_MAGIC_isa|5.007002||p
613 PERL_MAGIC_mutex|5.021008||p
620 PERL_MAGIC_mutex|5.024000||p
614621 PERL_MAGIC_nkeys|5.007002||p
615 PERL_MAGIC_overload_elem|5.021008||p
622 PERL_MAGIC_overload_elem|5.024000||p
616623 PERL_MAGIC_overload_table|5.007002||p
617 PERL_MAGIC_overload|5.021008||p
624 PERL_MAGIC_overload|5.024000||p
618625 PERL_MAGIC_pos|5.007002||p
619626 PERL_MAGIC_qr|5.007002||p
620627 PERL_MAGIC_regdata|5.007002||p
662669 PERL_SUBVERSION|5.006000||p
663670 PERL_SYS_INIT3||5.006000|
664671 PERL_SYS_INIT|||
665 PERL_SYS_TERM||5.021008|
672 PERL_SYS_TERM||5.024000|
666673 PERL_UCHAR_MAX|5.003070||p
667674 PERL_UCHAR_MIN|5.003070||p
668675 PERL_UINT_MAX|5.003070||p
672679 PERL_UNUSED_ARG|5.009003||p
673680 PERL_UNUSED_CONTEXT|5.009004||p
674681 PERL_UNUSED_DECL|5.007002||p
682 PERL_UNUSED_RESULT|5.021001||p
675683 PERL_UNUSED_VAR|5.007002||p
676684 PERL_UQUAD_MAX|5.003070||p
677685 PERL_UQUAD_MIN|5.003070||p
684692 PL_DBsub|||pn
685693 PL_DBtrace|||pn
686694 PL_Sv|5.005000||p
687 PL_bufend|5.021008||p
688 PL_bufptr|5.021008||p
695 PL_bufend|5.024000||p
696 PL_bufptr|5.024000||p
689697 PL_check||5.006000|
690698 PL_compiling|5.004050||p
691699 PL_comppad_name||5.017004|
692700 PL_comppad||5.008001|
693 PL_copline|5.021008||p
701 PL_copline|5.024000||p
694702 PL_curcop|5.004050||p
695703 PL_curpad||5.005000|
696704 PL_curstash|5.004050||p
700708 PL_dirty|5.004050||p
701709 PL_dowarn|||pn
702710 PL_errgv|5.004050||p
703 PL_error_count|5.021008||p
704 PL_expect|5.021008||p
711 PL_error_count|5.024000||p
712 PL_expect|5.024000||p
705713 PL_hexdigit|5.005000||p
706714 PL_hints|5.005000||p
707 PL_in_my_stash|5.021008||p
708 PL_in_my|5.021008||p
715 PL_in_my_stash|5.024000||p
716 PL_in_my|5.024000||p
709717 PL_keyword_plugin||5.011002|
710718 PL_last_in_gv|||n
711719 PL_laststatval|5.005000||p
712 PL_lex_state|5.021008||p
713 PL_lex_stuff|5.021008||p
714 PL_linestr|5.021008||p
720 PL_lex_state|5.024000||p
721 PL_lex_stuff|5.024000||p
722 PL_linestr|5.024000||p
715723 PL_modglobal||5.005000|n
716724 PL_na|5.004050||pn
717725 PL_no_modify|5.006000||p
723731 PL_perldb|5.004050||p
724732 PL_ppaddr|5.006000||p
725733 PL_rpeepp||5.013005|n
726 PL_rsfp_filters|5.021008||p
727 PL_rsfp|5.021008||p
734 PL_rsfp_filters|5.024000||p
735 PL_rsfp|5.024000||p
728736 PL_rs|||n
729737 PL_signals|5.008001||p
730738 PL_stack_base|5.004050||p
737745 PL_sv_yes|5.004050||pn
738746 PL_tainted|5.004050||p
739747 PL_tainting|5.004050||p
740 PL_tokenbuf|5.021008||p
741 POP_MULTICALL||5.021008|
748 PL_tokenbuf|5.024000||p
749 POP_MULTICALL||5.024000|
742750 POPi|||n
743751 POPl|||n
744752 POPn|||n
746754 POPpx||5.005030|n
747755 POPp|||n
748756 POPs|||n
757 POPul||5.006000|n
758 POPu||5.004000|n
749759 PTR2IV|5.006000||p
750760 PTR2NV|5.006000||p
751761 PTR2UV|5.006000||p
753763 PTR2ul|5.007001||p
754764 PTRV|5.006000||p
755765 PUSHMARK|||
756 PUSH_MULTICALL||5.021008|
766 PUSH_MULTICALL||5.024000|
757767 PUSHi|||
758768 PUSHmortal|5.009002||p
759769 PUSHn|||
761771 PUSHs|||
762772 PUSHu|5.004000||p
763773 PUTBACK|||
764 PadARRAY||5.021008|
765 PadMAX||5.021008|
766 PadlistARRAY||5.021008|
767 PadlistMAX||5.021008|
768 PadlistNAMESARRAY||5.021008|
769 PadlistNAMESMAX||5.021008|
770 PadlistNAMES||5.021008|
774 PadARRAY||5.024000|
775 PadMAX||5.024000|
776 PadlistARRAY||5.024000|
777 PadlistMAX||5.024000|
778 PadlistNAMESARRAY||5.024000|
779 PadlistNAMESMAX||5.024000|
780 PadlistNAMES||5.024000|
771781 PadlistREFCNT||5.017004|
772782 PadnameIsOUR|||
773783 PadnameIsSTATE|||
774 PadnameLEN||5.021008|
784 PadnameLEN||5.024000|
775785 PadnameOURSTASH|||
776786 PadnameOUTER|||
777 PadnamePV||5.021008|
778 PadnameREFCNT_dec||5.021008|
779 PadnameREFCNT||5.021008|
780 PadnameSV||5.021008|
787 PadnamePV||5.024000|
788 PadnameREFCNT_dec||5.024000|
789 PadnameREFCNT||5.024000|
790 PadnameSV||5.024000|
781791 PadnameTYPE|||
782792 PadnameUTF8||5.021007|
783 PadnamelistARRAY||5.021008|
784 PadnamelistMAX||5.021008|
785 PadnamelistREFCNT_dec||5.021008|
786 PadnamelistREFCNT||5.021008|
793 PadnamelistARRAY||5.024000|
794 PadnamelistMAX||5.024000|
795 PadnamelistREFCNT_dec||5.024000|
796 PadnamelistREFCNT||5.024000|
787797 PerlIO_clearerr||5.007003|
788798 PerlIO_close||5.007003|
789799 PerlIO_context_layers||5.009004|
815825 PoisonWith|5.009004||p
816826 Poison|5.008000||p
817827 READ_XDIGIT||5.017006|
828 RESTORE_LC_NUMERIC||5.024000|
818829 RETVAL|||n
819830 Renewc|||
820831 Renew|||
829840 START_MY_CXT|5.007003||p
830841 STMT_END|||p
831842 STMT_START|||p
843 STORE_LC_NUMERIC_FORCE_TO_UNDERLYING||5.024000|
844 STORE_LC_NUMERIC_SET_TO_NEEDED||5.024000|
832845 STR_WITH_LEN|5.009003||p
833846 ST|||
834847 SV_CONST_RETURN|5.009003||p
966979 SvROK|||
967980 SvRV_set|5.009003||p
968981 SvRV|||
969 SvRXOK||5.009005|
970 SvRX||5.009005|
982 SvRXOK|5.009005||p
983 SvRX|5.009005||p
971984 SvSETMAGIC|||
972985 SvSHARED_HASH|5.009003||p
973986 SvSHARE||5.007003|
10011014 SvVSTRING_mg|5.009004||p
10021015 THIS|||n
10031016 UNDERBAR|5.009002||p
1017 UTF8SKIP||5.006000|
10041018 UTF8_MAXBYTES|5.009002||p
1019 UVCHR_SKIP||5.022000|
10051020 UVSIZE|5.006000||p
10061021 UVTYPE|5.006000||p
10071022 UVXf|5.007001||p
10101025 UVxf|5.006000||p
10111026 WARN_ALL|5.006000||p
10121027 WARN_AMBIGUOUS|5.006000||p
1013 WARN_ASSERTIONS|5.021008||p
1028 WARN_ASSERTIONS|5.024000||p
10141029 WARN_BAREWORD|5.006000||p
10151030 WARN_CLOSED|5.006000||p
10161031 WARN_CLOSURE|5.006000||p
10831098 XST_mUNDEF|||
10841099 XST_mUV|5.008001||p
10851100 XST_mYES|||
1086 XS_APIVERSION_BOOTCHECK||5.021008|
1087 XS_EXTERNAL||5.021008|
1088 XS_INTERNAL||5.021008|
1089 XS_VERSION_BOOTCHECK||5.021008|
1101 XS_APIVERSION_BOOTCHECK||5.024000|
1102 XS_EXTERNAL||5.024000|
1103 XS_INTERNAL||5.024000|
1104 XS_VERSION_BOOTCHECK||5.024000|
10901105 XS_VERSION|||
10911106 XSprePUSH|5.006000||p
10921107 XS|||
1093 XopDISABLE||5.021008|
1094 XopENABLE||5.021008|
1095 XopENTRYCUSTOM||5.021008|
1096 XopENTRY_set||5.021008|
1097 XopENTRY||5.021008|
1108 XopDISABLE||5.024000|
1109 XopENABLE||5.024000|
1110 XopENTRYCUSTOM||5.024000|
1111 XopENTRY_set||5.024000|
1112 XopENTRY||5.024000|
10981113 XopFLAGS||5.013007|
10991114 ZeroD|5.009002||p
11001115 Zero|||
11051120 _get_encoding|||
11061121 _get_regclass_nonbitmap_data|||
11071122 _get_swash_invlist|||
1123 _invlistEQ|||
11081124 _invlist_array_init|||n
11091125 _invlist_contains_cp|||n
1110 _invlist_contents|||
11111126 _invlist_dump|||
11121127 _invlist_intersection_maybe_complement_2nd|||
11131128 _invlist_intersection|||
11371152 _new_invlist_C_array|||
11381153 _new_invlist|||
11391154 _pMY_CXT|5.007003||p
1155 _setlocale_debug_string|||n
11401156 _setup_canned_invlist|||
11411157 _swash_inversion_hash|||
11421158 _swash_to_invlist|||
11431159 _to_fold_latin1|||
11441160 _to_uni_fold_flags||5.014000|
11451161 _to_upper_title_latin1|||
1162 _to_utf8_case|||
11461163 _to_utf8_fold_flags||5.019009|
11471164 _to_utf8_lower_flags||5.019009|
11481165 _to_utf8_title_flags||5.019009|
11501167 _warn_problematic_locale|||n
11511168 aMY_CXT_|5.007003||p
11521169 aMY_CXT|5.007003||p
1153 aTHXR_|5.021008||p
1154 aTHXR|5.021008||p
1170 aTHXR_|5.024000||p
1171 aTHXR|5.024000||p
11551172 aTHX_|5.006000||p
11561173 aTHX|5.006000||p
1157 aassign_common_vars|||
11581174 add_above_Latin1_folds|||
11591175 add_cp_to_invlist|||
11601176 add_data|||n
11611177 add_multi_match|||
11621178 add_utf16_textfilter|||
11631179 adjust_size_and_find_bucket|||n
1180 advance_one_LB|||
11641181 advance_one_SB|||
11651182 advance_one_WB|||
11661183 alloc_maybe_populate_EXACT|||
12081225 av_undef|||
12091226 av_unshift|||
12101227 ax|||n
1228 backup_one_LB|||
12111229 backup_one_SB|||
12121230 backup_one_WB|||
12131231 bad_type_gv|||
12241242 bytes_cmp_utf8||5.013007|
12251243 bytes_from_utf8||5.007001|
12261244 bytes_to_utf8||5.006001|
1245 cBOOL|5.013000||p
12271246 call_argv|5.006000||p
12281247 call_atexit||5.006000|
12291248 call_list||5.004000|
12521271 ckwarn_common|||
12531272 ckwarn_d||5.009003|
12541273 ckwarn||5.009003|
1274 clear_defarray||5.023008|
12551275 clear_placeholders|||
12561276 clear_special_blocks|||
12571277 clone_params_del|||n
12791299 cophh_fetch_pv||5.013007|
12801300 cophh_fetch_sv||5.013007|
12811301 cophh_free||5.013007|
1282 cophh_new_empty||5.021008|
1302 cophh_new_empty||5.024000|
12831303 cophh_store_pvn||5.013007|
12841304 cophh_store_pvs||5.013007|
12851305 cophh_store_pv||5.013007|
12861306 cophh_store_sv||5.013007|
12871307 core_prototype|||
12881308 coresub_op|||
1289 could_it_be_a_POSIX_class|||n
12901309 cr_textfilter|||
12911310 create_eval_scope|||
12921311 croak_memory_wrap||5.019003|n
13231342 cvstash_set|||
13241343 cx_dump||5.005000|
13251344 cx_dup|||
1345 cx_popblock||5.023008|
1346 cx_popeval||5.023008|
1347 cx_popformat||5.023008|
1348 cx_popgiven||5.023008|
1349 cx_poploop||5.023008|
1350 cx_popsub_args||5.023008|
1351 cx_popsub_common||5.023008|
1352 cx_popsub||5.023008|
1353 cx_popwhen||5.023008|
1354 cx_pushblock||5.023008|
1355 cx_pusheval||5.023008|
1356 cx_pushformat||5.023008|
1357 cx_pushgiven||5.023008|
1358 cx_pushloop_for||5.023008|
1359 cx_pushloop_plain||5.023008|
1360 cx_pushsub||5.023008|
1361 cx_pushwhen||5.023008|
1362 cx_topblock||5.023008|
13261363 cxinc|||
13271364 dAXMARK|5.009003||p
13281365 dAX|5.007002||p
13351372 dORIGMARK|||
13361373 dSP|||
13371374 dTHR|5.004050||p
1338 dTHXR|5.021008||p
1375 dTHXR|5.024000||p
13391376 dTHXa|5.006000||p
13401377 dTHXoa|5.006000||p
13411378 dTHX|5.006000||p
14231460 do_vecset|||
14241461 do_vop|||
14251462 docatch|||
1426 doeval|||
1463 doeval_compile|||
14271464 dofile|||
14281465 dofindlabel|||
14291466 doform|||
14321469 doopen_pm|||
14331470 doparseform|||
14341471 dopoptoeval|||
1435 dopoptogiven|||
1472 dopoptogivenfor|||
14361473 dopoptolabel|||
14371474 dopoptoloop|||
14381475 dopoptosub_at|||
14421479 dowantarray|||
14431480 drand48_init_r|||n
14441481 drand48_r|||n
1482 dtrace_probe_call|||
1483 dtrace_probe_load|||
1484 dtrace_probe_op|||
1485 dtrace_probe_phase|||
14451486 dump_all_perl|||
14461487 dump_all||5.006000|
14471488 dump_c_backtrace|||
14611502 dump_vindent||5.006000|
14621503 dumpuntil|||
14631504 dup_attrlist|||
1505 edit_distance|||n
14641506 emulate_cop_io|||
14651507 eval_pv|5.006000||p
14661508 eval_sv|5.006000||p
14851527 find_lexical_cv|||
14861528 find_runcv_where|||
14871529 find_runcv||5.008001|
1488 find_rundefsv2|||
14891530 find_rundefsvoffset||5.009002|
14901531 find_rundefsv||5.013002|
14911532 find_script|||
15241565 get_c_backtrace_dump|||
15251566 get_c_backtrace|||
15261567 get_context||5.006000|n
1527 get_cvn_flags|5.009005||p
1568 get_cvn_flags|||
15281569 get_cvs|5.011000||p
15291570 get_cv|5.006000||p
15301571 get_db_sub|||
15981639 gv_fetchpvn_flags|5.009002||p
15991640 gv_fetchpvs|5.009004||p
16001641 gv_fetchpv|||
1601 gv_fetchsv|5.009002||p
1642 gv_fetchsv|||
16021643 gv_fullname3||5.003070|
16031644 gv_fullname4||5.006001|
16041645 gv_fullname|||
16051646 gv_handler||5.007001|
1606 gv_init_pvn||5.015004|
1647 gv_init_pvn|||
16071648 gv_init_pv||5.015004|
16081649 gv_init_svtype|||
16091650 gv_init_sv||5.015004|
16211662 gv_stashsvpvn_cached|||
16221663 gv_stashsv|||
16231664 gv_try_downgrade|||
1665 handle_named_backref|||
1666 handle_possible_posix|||
16241667 handle_regex_sets|||
16251668 he_dup|||
16261669 hek_dup|||
17081751 intuit_more|||
17091752 invert|||
17101753 invlist_array|||n
1754 invlist_clear|||
17111755 invlist_clone|||
1756 invlist_contents|||
17121757 invlist_extend|||
17131758 invlist_highest|||n
17141759 invlist_is_iterating|||n
17171762 invlist_iternext|||n
17181763 invlist_max|||n
17191764 invlist_previous_index|||n
1765 invlist_replace_list_destroys_src|||
17201766 invlist_set_len|||
17211767 invlist_set_previous_index|||n
17221768 invlist_trim|||n
17341780 isFOO_utf8_lc|||
17351781 isGCB|||n
17361782 isGRAPH|5.006000||p
1737 isGV_with_GP|5.009004||p
17381783 isIDCONT||5.017008|
17391784 isIDFIRST_lazy||5.021001|
17401785 isIDFIRST|||
1786 isLB|||
17411787 isLOWER|||
17421788 isOCTAL||5.013005|
17431789 isPRINT|5.004000||p
18241870 join_exact|||
18251871 keyword_plugin_standard|||
18261872 keyword|||
1827 leave_common|||
1873 leave_adjust_stacks||5.023008|
18281874 leave_scope|||
18291875 lex_bufutf8||5.011002|
18301876 lex_discard_to||5.011002|
19311977 memNEs|5.009005||p
19321978 memNE|5.004000||p
19331979 mem_collxfrm|||
1980 mem_log_alloc|||n
19341981 mem_log_common|||n
1982 mem_log_free|||n
1983 mem_log_realloc|||n
19351984 mess_alloc|||
19361985 mess_nocontext|||vn
19371986 mess_sv||5.013001|
19802029 my_atof2||5.007002|
19812030 my_atof||5.006000|
19822031 my_attrs|||
1983 my_bcopy|||n
2032 my_bcopy||5.004050|n
19842033 my_bytes_to_utf8|||n
19852034 my_bzero|||n
19862035 my_chsize|||
19952044 my_fork||5.007003|n
19962045 my_kid|||
19972046 my_lstat_flags|||
1998 my_lstat||5.021008|
2047 my_lstat||5.024000|
19992048 my_memcmp|||n
20002049 my_memset|||n
20012050 my_pclose||5.003070|
20072056 my_socketpair||5.007003|n
20082057 my_sprintf|5.009003||pvn
20092058 my_stat_flags|||
2010 my_stat||5.021008|
2059 my_stat||5.024000|
20112060 my_strerror||5.021001|
20122061 my_strftime||5.007002|
20132062 my_strlcat|5.009004||pn
21362185 op_lvalue_flags|||
21372186 op_lvalue||5.013007|
21382187 op_null||5.007002|
2139 op_parent||5.021002|n
2188 op_parent|||n
21402189 op_prepend_elem||5.013006|
21412190 op_refcnt_dec|||
21422191 op_refcnt_inc|||
21542203 opslab_force_free|||
21552204 opslab_free_nopad|||
21562205 opslab_free|||
2206 output_or_return_posix_warnings|||
21572207 pMY_CXT_|5.007003||p
21582208 pMY_CXT|5.007003||p
21592209 pTHX_|5.006000||p
22532303 ptr_table_split||5.009005|
22542304 ptr_table_store||5.009005|
22552305 push_scope|||
2306 put_charclass_bitmap_innards_common|||
2307 put_charclass_bitmap_innards_invlist|||
22562308 put_charclass_bitmap_innards|||
22572309 put_code_point|||
22582310 put_range|||
22672319 re_compile||5.009005|
22682320 re_croak2|||
22692321 re_dup_guts|||
2322 re_exec_indentf|||v
2323 re_indentf|||v
22702324 re_intuit_start||5.019001|
22712325 re_intuit_string||5.006000|
22722326 re_op_compile|||
2327 re_printf|||v
22732328 realloc||5.007002|n
2274 reentrant_free||5.021008|
2275 reentrant_init||5.021008|
2276 reentrant_retry||5.021008|vn
2277 reentrant_size||5.021008|
2329 reentrant_free||5.024000|
2330 reentrant_init||5.024000|
2331 reentrant_retry||5.024000|vn
2332 reentrant_size||5.024000|
22782333 ref_array_or_hash|||
22792334 refcounted_he_chain_2hv|||
22802335 refcounted_he_fetch_pvn|||
22902345 refcounted_he_value|||
22912346 refkids|||
22922347 refto|||
2293 ref||5.021008|
2348 ref||5.024000|
22942349 reg2Lanode|||
22952350 reg_check_named_buff_matched|||n
22962351 reg_named_buff_all||5.009005|
23222377 regdump_intflags|||
23232378 regdump||5.005000|
23242379 regdupe_internal|||
2380 regex_set_precedence|||n
23252381 regexec_flags||5.005000|
23262382 regfree_internal||5.009005|
23272383 reghop3|||n
23332389 regmatch|||
23342390 regnext||5.005000|
23352391 regnode_guts|||
2336 regpatws|||n
23372392 regpiece|||
2338 regpposixcc|||
23392393 regprop|||
23402394 regrepeat|||
23412395 regtail_study|||
23762430 save_adelete||5.011000|
23772431 save_aelem_flags||5.011000|
23782432 save_aelem||5.004050|
2379 save_aliased_sv|||
23802433 save_alloc||5.006000|
23812434 save_aptr|||
23822435 save_ary|||
24332486 savestack_grow_cnt||5.008001|
24342487 savestack_grow|||
24352488 savesvpv||5.009002|
2489 savetmps||5.023008|
24362490 sawparens|||
24372491 scalar_mod_type|||n
24382492 scalarboolean|||
24742528 si_dup|||
24752529 sighandler|||n
24762530 simplify_sort|||
2531 skip_to_be_ignored_text|||
24772532 skipspace_flags|||
24782533 softref2xv|||
24792534 sortcv_stacked|||
26152670 sv_len_utf8_nomg|||
26162671 sv_len_utf8||5.006000|
26172672 sv_len|||
2618 sv_magic_portable|5.021008|5.004000|p
2673 sv_magic_portable|5.024000|5.004000|p
26192674 sv_magicext_mglob|||
26202675 sv_magicext||5.007003|
26212676 sv_magic|||
26522707 sv_pv||5.006000|
26532708 sv_recode_to_utf8||5.007003|
26542709 sv_reftype|||
2655 sv_ref|||
2656 sv_release_COW|||
2710 sv_ref||5.015004|
26572711 sv_replace|||
26582712 sv_report_used|||
26592713 sv_resetpvn|||
26792733 sv_setref_iv|||
26802734 sv_setref_nv|||
26812735 sv_setref_pvn|||
2682 sv_setref_pvs||5.021008|
2736 sv_setref_pvs||5.024000|
26832737 sv_setref_pv|||
26842738 sv_setref_uv||5.007001|
26852739 sv_setsv_cow|||
27352789 taint_proper|||
27362790 tied_method|||v
27372791 tmps_grow_p|||
2738 toFOLD_uni||5.007003|
27392792 toFOLD_utf8||5.019001|
2793 toFOLD_uvchr||5.023009|
27402794 toFOLD||5.019001|
27412795 toLOWER_L1||5.019001|
27422796 toLOWER_LC||5.004000|
2743 toLOWER_uni||5.007003|
27442797 toLOWER_utf8||5.015007|
2798 toLOWER_uvchr||5.023009|
27452799 toLOWER|||
2746 toTITLE_uni||5.007003|
27472800 toTITLE_utf8||5.015007|
2801 toTITLE_uvchr||5.023009|
27482802 toTITLE||5.019001|
2749 toUPPER_uni||5.007003|
27502803 toUPPER_utf8||5.015007|
2804 toUPPER_uvchr||5.023009|
27512805 toUPPER|||
27522806 to_byte_substr|||
27532807 to_lower_latin1|||n
41464200 #ifndef Newxz
41474201 # define Newxz(v,n,t) Newz(0,v,n,t)
41484202 #endif
4203 #ifndef PERL_MAGIC_qr
4204 # define PERL_MAGIC_qr 'r'
4205 #endif
4206 #ifndef cBOOL
4207 # define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
4208 #endif
4209
4210 #ifndef OpHAS_SIBLING
4211 # define OpHAS_SIBLING(o) (cBOOL((o)->op_sibling))
4212 #endif
4213
4214 #ifndef OpSIBLING
4215 # define OpSIBLING(o) (0 + (o)->op_sibling)
4216 #endif
4217
4218 #ifndef OpMORESIB_set
4219 # define OpMORESIB_set(o, sib) ((o)->op_sibling = (sib))
4220 #endif
4221
4222 #ifndef OpLASTSIB_set
4223 # define OpLASTSIB_set(o, parent) ((o)->op_sibling = NULL)
4224 #endif
4225
4226 #ifndef OpMAYBESIB_set
4227 # define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib))
4228 #endif
4229
4230 #ifndef SvRX
4231 #if defined(NEED_SvRX)
4232 static void * DPPP_(my_SvRX)(pTHX_ SV *rv);
4233 static
4234 #else
4235 extern void * DPPP_(my_SvRX)(pTHX_ SV *rv);
4236 #endif
4237
4238 #ifdef SvRX
4239 # undef SvRX
4240 #endif
4241 #define SvRX(a) DPPP_(my_SvRX)(aTHX_ a)
4242
4243 #if defined(NEED_SvRX) || defined(NEED_SvRX_GLOBAL)
4244
4245 void *
4246 DPPP_(my_SvRX)(pTHX_ SV *rv)
4247 {
4248 if (SvROK(rv)) {
4249 SV *sv = SvRV(rv);
4250 if (SvMAGICAL(sv)) {
4251 MAGIC *mg = mg_find(sv, PERL_MAGIC_qr);
4252 if (mg && mg->mg_obj) {
4253 return mg->mg_obj;
4254 }
4255 }
4256 }
4257 return 0;
4258 }
4259 #endif
4260 #endif
4261 #ifndef SvRXOK
4262 # define SvRXOK(sv) (!!SvRX(sv))
4263 #endif
41494264
41504265 #ifndef PERL_UNUSED_DECL
41514266 # ifdef HASATTRIBUTE
41774292 # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl)
41784293 # else
41794294 # define PERL_UNUSED_CONTEXT
4295 # endif
4296 #endif
4297
4298 #ifndef PERL_UNUSED_RESULT
4299 # if defined(__GNUC__) && defined(HASATTRIBUTE_WARN_UNUSED_RESULT)
4300 # define PERL_UNUSED_RESULT(v) STMT_START { __typeof__(v) z = (v); (void)sizeof(z); } STMT_END
4301 # else
4302 # define PERL_UNUSED_RESULT(v) ((void)(v))
41804303 # endif
41814304 #endif
41824305 #ifndef NOOP
45124635 (U32)HeKUTF8(he))
45134636 #endif
45144637
4638 #endif
4639 #ifndef C_ARRAY_LENGTH
4640 # define C_ARRAY_LENGTH(a) (sizeof(a)/sizeof((a)[0]))
4641 #endif
4642
4643 #ifndef C_ARRAY_END
4644 # define C_ARRAY_END(a) ((a) + C_ARRAY_LENGTH(a))
45154645 #endif
45164646
45174647 #ifndef PERL_SIGNALS_UNSAFE_FLAG
46334763 /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */
46344764 /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf
46354765 * Do not use this variable unless you know exactly what you're
4636 * doint. It is internal to the perl parser and may change or even
4766 * doing. It is internal to the perl parser and may change or even
46374767 * be removed in the future. As of perl 5.9.5, you have to check
46384768 * for (PL_parser != NULL) for this variable to have any effect.
46394769 * An always non-NULL PL_parser dummy is provided for earlier
58355965 #ifndef HvNAMELEN_get
58365966 # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0)
58375967 #endif
5968
5969 #ifndef gv_fetchpvn_flags
5970 #if defined(NEED_gv_fetchpvn_flags)
5971 static GV* DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types);
5972 static
5973 #else
5974 extern GV* DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types);
5975 #endif
5976
5977 #ifdef gv_fetchpvn_flags
5978 # undef gv_fetchpvn_flags
5979 #endif
5980 #define gv_fetchpvn_flags(a,b,c,d) DPPP_(my_gv_fetchpvn_flags)(aTHX_ a,b,c,d)
5981 #define Perl_gv_fetchpvn_flags DPPP_(my_gv_fetchpvn_flags)
5982
5983 #if defined(NEED_gv_fetchpvn_flags) || defined(NEED_gv_fetchpvn_flags_GLOBAL)
5984
5985 GV*
5986 DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types) {
5987 char *namepv = savepvn(name, len);
5988 GV* stash = gv_fetchpv(namepv, TRUE, SVt_PVHV);
5989 Safefree(namepv);
5990 return stash;
5991 }
5992
5993 #endif
5994 #endif
58385995 #ifndef GvSVn
58395996 # define GvSVn(gv) GvSV(gv)
58405997 #endif
58436000 # define isGV_with_GP(gv) isGV(gv)
58446001 #endif
58456002
5846 #ifndef gv_fetchpvn_flags
5847 # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt)
5848 #endif
5849
58506003 #ifndef gv_fetchsv
58516004 # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt)
58526005 #endif
58536006 #ifndef get_cvn_flags
58546007 # define get_cvn_flags(name, namelen, flags) get_cv(name, flags)
6008 #endif
6009
6010 #ifndef gv_init_pvn
6011 # define gv_init_pvn(gv, stash, ptr, len, flags) gv_init(gv, stash, ptr, len, flags & GV_ADDMULTI ? TRUE : FALSE)
58556012 #endif
58566013 #ifndef WARN_ALL
58576014 # define WARN_ALL 0
61406297 # define HEf_SVKEY -2
61416298 #endif
61426299
6300 #ifndef MUTABLE_PTR
61436301 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
61446302 # define MUTABLE_PTR(p) ({ void *_p = (p); _p; })
61456303 #else
61466304 # define MUTABLE_PTR(p) ((void *) (p))
61476305 #endif
6148
6149 #define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p))
6306 #endif
6307 #ifndef MUTABLE_SV
6308 # define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p))
6309 #endif
61506310
61516311 /* end of random bits */
61526312 #ifndef PERL_MAGIC_sv
1616 ltc/encauth/ocb3/ocb3_add_aad.o ltc/encauth/ocb3/ocb3_decrypt.o ltc/encauth/ocb3/ocb3_decrypt_last.o \
1717 ltc/encauth/ocb3/ocb3_decrypt_verify_memory.o ltc/encauth/ocb3/ocb3_done.o ltc/encauth/ocb3/ocb3_encrypt.o \
1818 ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.o ltc/encauth/ocb3/ocb3_encrypt_last.o \
19 ltc/encauth/ocb3/ocb3_init.o ltc/encauth/ocb3/ocb3_int_aad_add_block.o ltc/encauth/ocb3/ocb3_int_calc_offset_zero.o \
20 ltc/encauth/ocb3/ocb3_int_ntz.o ltc/encauth/ocb3/ocb3_int_xor_blocks.o ltc/hashes/blake2b.o \
21 ltc/hashes/blake2s.o ltc/hashes/md2.o ltc/hashes/md4.o ltc/hashes/md5.o ltc/hashes/rmd128.o \
22 ltc/hashes/rmd160.o ltc/hashes/rmd256.o ltc/hashes/rmd320.o ltc/hashes/sha1.o ltc/hashes/sha3.o \
23 ltc/hashes/sha3_test.o ltc/hashes/tiger.o ltc/hashes/chc/chc.o ltc/hashes/helper/hash_file.o \
24 ltc/hashes/helper/hash_filehandle.o ltc/hashes/helper/hash_memory.o ltc/hashes/helper/hash_memory_multi.o \
25 ltc/hashes/sha2/sha224.o ltc/hashes/sha2/sha256.o ltc/hashes/sha2/sha384.o ltc/hashes/sha2/sha512.o \
26 ltc/hashes/sha2/sha512_224.o ltc/hashes/sha2/sha512_256.o ltc/hashes/whirl/whirl.o \
27 ltc/mac/blake2/blake2bmac.o ltc/mac/blake2/blake2bmac_file.o ltc/mac/blake2/blake2bmac_memory.o \
28 ltc/mac/blake2/blake2bmac_memory_multi.o ltc/mac/blake2/blake2smac.o ltc/mac/blake2/blake2smac_file.o \
29 ltc/mac/blake2/blake2smac_memory.o ltc/mac/blake2/blake2smac_memory_multi.o ltc/mac/f9/f9_done.o \
30 ltc/mac/f9/f9_file.o ltc/mac/f9/f9_init.o ltc/mac/f9/f9_memory.o ltc/mac/f9/f9_memory_multi.o \
31 ltc/mac/f9/f9_process.o ltc/mac/hmac/hmac_done.o ltc/mac/hmac/hmac_file.o ltc/mac/hmac/hmac_init.o \
32 ltc/mac/hmac/hmac_memory.o ltc/mac/hmac/hmac_memory_multi.o ltc/mac/hmac/hmac_process.o \
33 ltc/mac/omac/omac_done.o ltc/mac/omac/omac_file.o ltc/mac/omac/omac_init.o ltc/mac/omac/omac_memory.o \
34 ltc/mac/omac/omac_memory_multi.o ltc/mac/omac/omac_process.o ltc/mac/pelican/pelican.o \
35 ltc/mac/pelican/pelican_memory.o ltc/mac/pmac/pmac_done.o ltc/mac/pmac/pmac_file.o \
36 ltc/mac/pmac/pmac_init.o ltc/mac/pmac/pmac_memory.o ltc/mac/pmac/pmac_memory_multi.o \
19 ltc/encauth/ocb3/ocb3_init.o ltc/encauth/ocb3/ocb3_int_ntz.o ltc/encauth/ocb3/ocb3_int_xor_blocks.o \
20 ltc/hashes/blake2b.o ltc/hashes/blake2s.o ltc/hashes/md2.o ltc/hashes/md4.o ltc/hashes/md5.o \
21 ltc/hashes/rmd128.o ltc/hashes/rmd160.o ltc/hashes/rmd256.o ltc/hashes/rmd320.o ltc/hashes/sha1.o \
22 ltc/hashes/sha3.o ltc/hashes/sha3_test.o ltc/hashes/tiger.o ltc/hashes/chc/chc.o \
23 ltc/hashes/helper/hash_file.o ltc/hashes/helper/hash_filehandle.o ltc/hashes/helper/hash_memory.o \
24 ltc/hashes/helper/hash_memory_multi.o ltc/hashes/sha2/sha224.o ltc/hashes/sha2/sha256.o \
25 ltc/hashes/sha2/sha384.o ltc/hashes/sha2/sha512.o ltc/hashes/sha2/sha512_224.o ltc/hashes/sha2/sha512_256.o \
26 ltc/hashes/whirl/whirl.o ltc/mac/blake2/blake2bmac.o ltc/mac/blake2/blake2bmac_file.o \
27 ltc/mac/blake2/blake2bmac_memory.o ltc/mac/blake2/blake2bmac_memory_multi.o ltc/mac/blake2/blake2smac.o \
28 ltc/mac/blake2/blake2smac_file.o ltc/mac/blake2/blake2smac_memory.o ltc/mac/blake2/blake2smac_memory_multi.o \
29 ltc/mac/f9/f9_done.o ltc/mac/f9/f9_file.o ltc/mac/f9/f9_init.o ltc/mac/f9/f9_memory.o \
30 ltc/mac/f9/f9_memory_multi.o ltc/mac/f9/f9_process.o ltc/mac/hmac/hmac_done.o ltc/mac/hmac/hmac_file.o \
31 ltc/mac/hmac/hmac_init.o ltc/mac/hmac/hmac_memory.o ltc/mac/hmac/hmac_memory_multi.o \
32 ltc/mac/hmac/hmac_process.o ltc/mac/omac/omac_done.o ltc/mac/omac/omac_file.o ltc/mac/omac/omac_init.o \
33 ltc/mac/omac/omac_memory.o ltc/mac/omac/omac_memory_multi.o ltc/mac/omac/omac_process.o \
34 ltc/mac/pelican/pelican.o ltc/mac/pelican/pelican_memory.o ltc/mac/pmac/pmac_done.o \
35 ltc/mac/pmac/pmac_file.o ltc/mac/pmac/pmac_init.o ltc/mac/pmac/pmac_memory.o ltc/mac/pmac/pmac_memory_multi.o \
3736 ltc/mac/pmac/pmac_ntz.o ltc/mac/pmac/pmac_process.o ltc/mac/pmac/pmac_shift_xor.o \
3837 ltc/mac/poly1305/poly1305.o ltc/mac/poly1305/poly1305_file.o ltc/mac/poly1305/poly1305_memory.o \
3938 ltc/mac/poly1305/poly1305_memory_multi.o ltc/mac/xcbc/xcbc_done.o ltc/mac/xcbc/xcbc_file.o \
4039 ltc/mac/xcbc/xcbc_init.o ltc/mac/xcbc/xcbc_memory.o ltc/mac/xcbc/xcbc_memory_multi.o \
41 ltc/mac/xcbc/xcbc_process.o ltc/math/ltm_desc.o ltc/math/multi.o ltc/math/rand_bn.o \
42 ltc/math/rand_prime.o ltc/math/tfm_desc.o ltc/math/fp/ltc_ecc_fp_mulmod.o ltc/misc/adler32.o \
43 ltc/misc/burn_stack.o ltc/misc/crc32.o ltc/misc/error_to_string.o ltc/misc/mem_neq.o \
44 ltc/misc/pk_get_oid.o ltc/misc/zeromem.o ltc/misc/base64/base64_decode.o ltc/misc/base64/base64_encode.o \
45 ltc/misc/crypt/crypt.o ltc/misc/crypt/crypt_argchk.o ltc/misc/crypt/crypt_cipher_descriptor.o \
46 ltc/misc/crypt/crypt_cipher_is_valid.o ltc/misc/crypt/crypt_find_cipher.o ltc/misc/crypt/crypt_find_cipher_any.o \
40 ltc/mac/xcbc/xcbc_process.o ltc/math/ltm_desc.o ltc/math/multi.o ltc/math/radix_to_bin.o \
41 ltc/math/rand_bn.o ltc/math/rand_prime.o ltc/math/tfm_desc.o ltc/math/fp/ltc_ecc_fp_mulmod.o \
42 ltc/misc/adler32.o ltc/misc/burn_stack.o ltc/misc/compare_testvector.o ltc/misc/crc32.o \
43 ltc/misc/error_to_string.o ltc/misc/mem_neq.o ltc/misc/pk_get_oid.o ltc/misc/zeromem.o \
44 ltc/misc/base64/base64_decode.o ltc/misc/base64/base64_encode.o ltc/misc/crypt/crypt.o \
45 ltc/misc/crypt/crypt_argchk.o ltc/misc/crypt/crypt_cipher_descriptor.o ltc/misc/crypt/crypt_cipher_is_valid.o \
46 ltc/misc/crypt/crypt_constants.o ltc/misc/crypt/crypt_find_cipher.o ltc/misc/crypt/crypt_find_cipher_any.o \
4747 ltc/misc/crypt/crypt_find_cipher_id.o ltc/misc/crypt/crypt_find_hash.o ltc/misc/crypt/crypt_find_hash_any.o \
4848 ltc/misc/crypt/crypt_find_hash_id.o ltc/misc/crypt/crypt_find_hash_oid.o ltc/misc/crypt/crypt_find_prng.o \
4949 ltc/misc/crypt/crypt_fsa.o ltc/misc/crypt/crypt_hash_descriptor.o ltc/misc/crypt/crypt_hash_is_valid.o \
5050 ltc/misc/crypt/crypt_inits.o ltc/misc/crypt/crypt_ltc_mp_descriptor.o ltc/misc/crypt/crypt_prng_descriptor.o \
51 ltc/misc/crypt/crypt_prng_is_valid.o ltc/misc/crypt/crypt_register_cipher.o ltc/misc/crypt/crypt_register_hash.o \
52 ltc/misc/crypt/crypt_register_prng.o ltc/misc/crypt/crypt_unregister_cipher.o ltc/misc/crypt/crypt_unregister_hash.o \
51 ltc/misc/crypt/crypt_prng_is_valid.o ltc/misc/crypt/crypt_prng_rng_descriptor.o ltc/misc/crypt/crypt_register_all_ciphers.o \
52 ltc/misc/crypt/crypt_register_all_hashes.o ltc/misc/crypt/crypt_register_all_prngs.o \
53 ltc/misc/crypt/crypt_register_cipher.o ltc/misc/crypt/crypt_register_hash.o ltc/misc/crypt/crypt_register_prng.o \
54 ltc/misc/crypt/crypt_sizes.o ltc/misc/crypt/crypt_unregister_cipher.o ltc/misc/crypt/crypt_unregister_hash.o \
5355 ltc/misc/crypt/crypt_unregister_prng.o ltc/misc/hkdf/hkdf.o ltc/misc/pkcs5/pkcs_5_1.o \
5456 ltc/misc/pkcs5/pkcs_5_2.o ltc/modes/cbc/cbc_decrypt.o ltc/modes/cbc/cbc_done.o ltc/modes/cbc/cbc_encrypt.o \
5557 ltc/modes/cbc/cbc_getiv.o ltc/modes/cbc/cbc_setiv.o ltc/modes/cbc/cbc_start.o ltc/modes/cfb/cfb_decrypt.o \
7678 ltc/pk/asn1/der/sequence/der_decode_subject_public_key_info.o ltc/pk/asn1/der/sequence/der_encode_sequence_ex.o \
7779 ltc/pk/asn1/der/sequence/der_encode_sequence_multi.o ltc/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \
7880 ltc/pk/asn1/der/sequence/der_length_sequence.o ltc/pk/asn1/der/sequence/der_sequence_free.o \
79 ltc/pk/asn1/der/set/der_encode_set.o ltc/pk/asn1/der/set/der_encode_setof.o ltc/pk/asn1/der/short_integer/der_decode_short_integer.o \
81 ltc/pk/asn1/der/sequence/der_sequence_shrink.o ltc/pk/asn1/der/set/der_encode_set.o \
82 ltc/pk/asn1/der/set/der_encode_setof.o ltc/pk/asn1/der/short_integer/der_decode_short_integer.o \
8083 ltc/pk/asn1/der/short_integer/der_encode_short_integer.o ltc/pk/asn1/der/short_integer/der_length_short_integer.o \
8184 ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.o ltc/pk/asn1/der/teletex_string/der_length_teletex_string.o \
8285 ltc/pk/asn1/der/utctime/der_decode_utctime.o ltc/pk/asn1/der/utctime/der_encode_utctime.o \
8386 ltc/pk/asn1/der/utctime/der_length_utctime.o ltc/pk/asn1/der/utf8/der_decode_utf8_string.o \
8487 ltc/pk/asn1/der/utf8/der_encode_utf8_string.o ltc/pk/asn1/der/utf8/der_length_utf8_string.o \
85 ltc/pk/dh/dh.o ltc/pk/dh/dh_static.o ltc/pk/dh/dh_sys.o ltc/pk/dsa/dsa_decrypt_key.o \
86 ltc/pk/dsa/dsa_encrypt_key.o ltc/pk/dsa/dsa_export.o ltc/pk/dsa/dsa_free.o ltc/pk/dsa/dsa_import.o \
87 ltc/pk/dsa/dsa_import_radix.o ltc/pk/dsa/dsa_make_key.o ltc/pk/dsa/dsa_shared_secret.o \
88 ltc/pk/dsa/dsa_sign_hash.o ltc/pk/dsa/dsa_verify_hash.o ltc/pk/dsa/dsa_verify_key.o \
89 ltc/pk/ecc/ecc.o ltc/pk/ecc/ecc_ansi_x963_export.o ltc/pk/ecc/ecc_ansi_x963_import.o \
90 ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_dp_clear.o ltc/pk/ecc/ecc_dp_fill_from_sets.o \
91 ltc/pk/ecc/ecc_dp_from_oid.o ltc/pk/ecc/ecc_dp_from_params.o ltc/pk/ecc/ecc_dp_init.o \
92 ltc/pk/ecc/ecc_dp_set.o ltc/pk/ecc/ecc_encrypt_key.o ltc/pk/ecc/ecc_export.o ltc/pk/ecc/ecc_export_full.o \
93 ltc/pk/ecc/ecc_export_raw.o ltc/pk/ecc/ecc_free.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o \
94 ltc/pk/ecc/ecc_import_full.o ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_raw.o \
95 ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o \
96 ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ecc_verify_key.o ltc/pk/ecc/ltc_ecc_export_point.o \
97 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 \
98 ltc/pk/ecc/ltc_ecc_is_valid_idx.o ltc/pk/ecc/ltc_ecc_map.o ltc/pk/ecc/ltc_ecc_mul2add.o \
99 ltc/pk/ecc/ltc_ecc_mulmod.o ltc/pk/ecc/ltc_ecc_mulmod_timing.o ltc/pk/ecc/ltc_ecc_points.o \
100 ltc/pk/ecc/ltc_ecc_projective_add_point.o ltc/pk/ecc/ltc_ecc_projective_dbl_point.o \
88 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 \
89 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 \
90 ltc/pk/dh/dh_set_pg_dhparam.o ltc/pk/dh/dh_shared_secret.o ltc/pk/dsa/dsa_decrypt_key.o \
91 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 \
92 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 \
93 ltc/pk/dsa/dsa_set_pqg_dsaparam.o ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_sign_hash.o \
94 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 \
95 ltc/pk/ecc/ecc_ansi_x963_import.o ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_dp_clear.o \
96 ltc/pk/ecc/ecc_dp_fill_from_sets.o ltc/pk/ecc/ecc_dp_from_oid.o ltc/pk/ecc/ecc_dp_from_params.o \
97 ltc/pk/ecc/ecc_dp_init.o ltc/pk/ecc/ecc_dp_set.o ltc/pk/ecc/ecc_encrypt_key.o ltc/pk/ecc/ecc_export.o \
98 ltc/pk/ecc/ecc_export_full.o ltc/pk/ecc/ecc_export_raw.o ltc/pk/ecc/ecc_free.o ltc/pk/ecc/ecc_get_size.o \
99 ltc/pk/ecc/ecc_import.o ltc/pk/ecc/ecc_import_full.o ltc/pk/ecc/ecc_import_pkcs8.o \
100 ltc/pk/ecc/ecc_import_raw.o ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_shared_secret.o \
101 ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ecc_verify_key.o \
102 ltc/pk/ecc/ltc_ecc_export_point.o ltc/pk/ecc/ltc_ecc_import_point.o ltc/pk/ecc/ltc_ecc_is_point.o \
103 ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o ltc/pk/ecc/ltc_ecc_is_valid_idx.o ltc/pk/ecc/ltc_ecc_map.o \
104 ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o ltc/pk/ecc/ltc_ecc_mulmod_timing.o \
105 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 \
101106 ltc/pk/pkcs1/pkcs_1_i2osp.o ltc/pk/pkcs1/pkcs_1_mgf1.o ltc/pk/pkcs1/pkcs_1_oaep_decode.o \
102107 ltc/pk/pkcs1/pkcs_1_oaep_encode.o ltc/pk/pkcs1/pkcs_1_os2ip.o ltc/pk/pkcs1/pkcs_1_pss_decode.o \
103108 ltc/pk/pkcs1/pkcs_1_pss_encode.o ltc/pk/pkcs1/pkcs_1_v1_5_decode.o ltc/pk/pkcs1/pkcs_1_v1_5_encode.o \
104109 ltc/pk/rsa/rsa_decrypt_key.o ltc/pk/rsa/rsa_encrypt_key.o ltc/pk/rsa/rsa_export.o \
105110 ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o ltc/pk/rsa/rsa_get_size.o ltc/pk/rsa/rsa_import.o \
106 ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_radix.o ltc/pk/rsa/rsa_import_x509.o \
107 ltc/pk/rsa/rsa_make_key.o ltc/pk/rsa/rsa_sign_hash.o ltc/pk/rsa/rsa_sign_saltlen_get.o \
111 ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o ltc/pk/rsa/rsa_make_key.o \
112 ltc/pk/rsa/rsa_set.o ltc/pk/rsa/rsa_sign_hash.o ltc/pk/rsa/rsa_sign_saltlen_get.o \
108113 ltc/pk/rsa/rsa_verify_hash.o ltc/prngs/chacha20.o ltc/prngs/fortuna.o ltc/prngs/rc4.o \
109114 ltc/prngs/rng_get_bytes.o ltc/prngs/rng_make_prng.o ltc/prngs/sober128.o ltc/prngs/sprng.o \
110115 ltc/prngs/yarrow.o ltc/stream/chacha/chacha_crypt.o ltc/stream/chacha/chacha_done.o \
161166 .SUFFIXES: .o .c
162167
163168 .c$(OBJ_EXT):
164 $(CC) $(CFLAGS) -c $< -o $@
169 $(CC) -Iltm -Iltc/headers -DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC $(CFLAGS) -c $< -o $@
1717 ltc/encauth/gcm/gcm_reset.obj ltc/encauth/ocb3/ocb3_add_aad.obj ltc/encauth/ocb3/ocb3_decrypt.obj \
1818 ltc/encauth/ocb3/ocb3_decrypt_last.obj ltc/encauth/ocb3/ocb3_decrypt_verify_memory.obj \
1919 ltc/encauth/ocb3/ocb3_done.obj ltc/encauth/ocb3/ocb3_encrypt.obj ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.obj \
20 ltc/encauth/ocb3/ocb3_encrypt_last.obj ltc/encauth/ocb3/ocb3_init.obj ltc/encauth/ocb3/ocb3_int_aad_add_block.obj \
21 ltc/encauth/ocb3/ocb3_int_calc_offset_zero.obj ltc/encauth/ocb3/ocb3_int_ntz.obj \
20 ltc/encauth/ocb3/ocb3_encrypt_last.obj ltc/encauth/ocb3/ocb3_init.obj ltc/encauth/ocb3/ocb3_int_ntz.obj \
2221 ltc/encauth/ocb3/ocb3_int_xor_blocks.obj ltc/hashes/blake2b.obj ltc/hashes/blake2s.obj \
2322 ltc/hashes/md2.obj ltc/hashes/md4.obj ltc/hashes/md5.obj ltc/hashes/rmd128.obj ltc/hashes/rmd160.obj \
2423 ltc/hashes/rmd256.obj ltc/hashes/rmd320.obj ltc/hashes/sha1.obj ltc/hashes/sha3.obj \
4140 ltc/mac/poly1305/poly1305.obj ltc/mac/poly1305/poly1305_file.obj ltc/mac/poly1305/poly1305_memory.obj \
4241 ltc/mac/poly1305/poly1305_memory_multi.obj ltc/mac/xcbc/xcbc_done.obj ltc/mac/xcbc/xcbc_file.obj \
4342 ltc/mac/xcbc/xcbc_init.obj ltc/mac/xcbc/xcbc_memory.obj ltc/mac/xcbc/xcbc_memory_multi.obj \
44 ltc/mac/xcbc/xcbc_process.obj ltc/math/ltm_desc.obj ltc/math/multi.obj ltc/math/rand_bn.obj \
45 ltc/math/rand_prime.obj ltc/math/tfm_desc.obj ltc/math/fp/ltc_ecc_fp_mulmod.obj ltc/misc/adler32.obj \
46 ltc/misc/burn_stack.obj ltc/misc/crc32.obj ltc/misc/error_to_string.obj ltc/misc/mem_neq.obj \
47 ltc/misc/pk_get_oid.obj ltc/misc/zeromem.obj ltc/misc/base64/base64_decode.obj ltc/misc/base64/base64_encode.obj \
48 ltc/misc/crypt/crypt.obj ltc/misc/crypt/crypt_argchk.obj ltc/misc/crypt/crypt_cipher_descriptor.obj \
49 ltc/misc/crypt/crypt_cipher_is_valid.obj ltc/misc/crypt/crypt_find_cipher.obj ltc/misc/crypt/crypt_find_cipher_any.obj \
43 ltc/mac/xcbc/xcbc_process.obj ltc/math/ltm_desc.obj ltc/math/multi.obj ltc/math/radix_to_bin.obj \
44 ltc/math/rand_bn.obj ltc/math/rand_prime.obj ltc/math/tfm_desc.obj ltc/math/fp/ltc_ecc_fp_mulmod.obj \
45 ltc/misc/adler32.obj ltc/misc/burn_stack.obj ltc/misc/compare_testvector.obj ltc/misc/crc32.obj \
46 ltc/misc/error_to_string.obj ltc/misc/mem_neq.obj ltc/misc/pk_get_oid.obj ltc/misc/zeromem.obj \
47 ltc/misc/base64/base64_decode.obj ltc/misc/base64/base64_encode.obj ltc/misc/crypt/crypt.obj \
48 ltc/misc/crypt/crypt_argchk.obj ltc/misc/crypt/crypt_cipher_descriptor.obj ltc/misc/crypt/crypt_cipher_is_valid.obj \
49 ltc/misc/crypt/crypt_constants.obj ltc/misc/crypt/crypt_find_cipher.obj ltc/misc/crypt/crypt_find_cipher_any.obj \
5050 ltc/misc/crypt/crypt_find_cipher_id.obj ltc/misc/crypt/crypt_find_hash.obj ltc/misc/crypt/crypt_find_hash_any.obj \
5151 ltc/misc/crypt/crypt_find_hash_id.obj ltc/misc/crypt/crypt_find_hash_oid.obj ltc/misc/crypt/crypt_find_prng.obj \
5252 ltc/misc/crypt/crypt_fsa.obj ltc/misc/crypt/crypt_hash_descriptor.obj ltc/misc/crypt/crypt_hash_is_valid.obj \
5353 ltc/misc/crypt/crypt_inits.obj ltc/misc/crypt/crypt_ltc_mp_descriptor.obj ltc/misc/crypt/crypt_prng_descriptor.obj \
54 ltc/misc/crypt/crypt_prng_is_valid.obj ltc/misc/crypt/crypt_register_cipher.obj ltc/misc/crypt/crypt_register_hash.obj \
55 ltc/misc/crypt/crypt_register_prng.obj ltc/misc/crypt/crypt_unregister_cipher.obj \
56 ltc/misc/crypt/crypt_unregister_hash.obj ltc/misc/crypt/crypt_unregister_prng.obj \
57 ltc/misc/hkdf/hkdf.obj ltc/misc/pkcs5/pkcs_5_1.obj ltc/misc/pkcs5/pkcs_5_2.obj ltc/modes/cbc/cbc_decrypt.obj \
58 ltc/modes/cbc/cbc_done.obj ltc/modes/cbc/cbc_encrypt.obj ltc/modes/cbc/cbc_getiv.obj \
59 ltc/modes/cbc/cbc_setiv.obj ltc/modes/cbc/cbc_start.obj ltc/modes/cfb/cfb_decrypt.obj \
60 ltc/modes/cfb/cfb_done.obj ltc/modes/cfb/cfb_encrypt.obj ltc/modes/cfb/cfb_getiv.obj \
61 ltc/modes/cfb/cfb_setiv.obj ltc/modes/cfb/cfb_start.obj ltc/modes/ctr/ctr_decrypt.obj \
62 ltc/modes/ctr/ctr_done.obj ltc/modes/ctr/ctr_encrypt.obj ltc/modes/ctr/ctr_getiv.obj \
63 ltc/modes/ctr/ctr_setiv.obj ltc/modes/ctr/ctr_start.obj ltc/modes/ecb/ecb_decrypt.obj \
64 ltc/modes/ecb/ecb_done.obj ltc/modes/ecb/ecb_encrypt.obj ltc/modes/ecb/ecb_start.obj \
65 ltc/modes/ofb/ofb_decrypt.obj ltc/modes/ofb/ofb_done.obj ltc/modes/ofb/ofb_encrypt.obj \
66 ltc/modes/ofb/ofb_getiv.obj ltc/modes/ofb/ofb_setiv.obj ltc/modes/ofb/ofb_start.obj \
67 ltc/pk/asn1/der/bit/der_decode_bit_string.obj ltc/pk/asn1/der/bit/der_decode_raw_bit_string.obj \
68 ltc/pk/asn1/der/bit/der_encode_bit_string.obj ltc/pk/asn1/der/bit/der_encode_raw_bit_string.obj \
69 ltc/pk/asn1/der/bit/der_length_bit_string.obj ltc/pk/asn1/der/boolean/der_decode_boolean.obj \
70 ltc/pk/asn1/der/boolean/der_encode_boolean.obj ltc/pk/asn1/der/boolean/der_length_boolean.obj \
71 ltc/pk/asn1/der/choice/der_decode_choice.obj ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.obj \
72 ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.obj ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.obj \
73 ltc/pk/asn1/der/ia5/der_decode_ia5_string.obj ltc/pk/asn1/der/ia5/der_encode_ia5_string.obj \
74 ltc/pk/asn1/der/ia5/der_length_ia5_string.obj ltc/pk/asn1/der/integer/der_decode_integer.obj \
75 ltc/pk/asn1/der/integer/der_encode_integer.obj ltc/pk/asn1/der/integer/der_length_integer.obj \
76 ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.obj ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.obj \
77 ltc/pk/asn1/der/object_identifier/der_length_object_identifier.obj ltc/pk/asn1/der/octet/der_decode_octet_string.obj \
78 ltc/pk/asn1/der/octet/der_encode_octet_string.obj ltc/pk/asn1/der/octet/der_length_octet_string.obj \
79 ltc/pk/asn1/der/printable_string/der_decode_printable_string.obj ltc/pk/asn1/der/printable_string/der_encode_printable_string.obj \
80 ltc/pk/asn1/der/printable_string/der_length_printable_string.obj ltc/pk/asn1/der/sequence/der_decode_sequence_ex.obj \
81 ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.obj ltc/pk/asn1/der/sequence/der_decode_sequence_multi.obj \
82 ltc/pk/asn1/der/sequence/der_decode_subject_public_key_info.obj ltc/pk/asn1/der/sequence/der_encode_sequence_ex.obj \
83 ltc/pk/asn1/der/sequence/der_encode_sequence_multi.obj ltc/pk/asn1/der/sequence/der_encode_subject_public_key_info.obj \
84 ltc/pk/asn1/der/sequence/der_length_sequence.obj ltc/pk/asn1/der/sequence/der_sequence_free.obj \
54 ltc/misc/crypt/crypt_prng_is_valid.obj ltc/misc/crypt/crypt_prng_rng_descriptor.obj \
55 ltc/misc/crypt/crypt_register_all_ciphers.obj ltc/misc/crypt/crypt_register_all_hashes.obj \
56 ltc/misc/crypt/crypt_register_all_prngs.obj ltc/misc/crypt/crypt_register_cipher.obj \
57 ltc/misc/crypt/crypt_register_hash.obj ltc/misc/crypt/crypt_register_prng.obj ltc/misc/crypt/crypt_sizes.obj \
58 ltc/misc/crypt/crypt_unregister_cipher.obj ltc/misc/crypt/crypt_unregister_hash.obj \
59 ltc/misc/crypt/crypt_unregister_prng.obj ltc/misc/hkdf/hkdf.obj ltc/misc/pkcs5/pkcs_5_1.obj \
60 ltc/misc/pkcs5/pkcs_5_2.obj ltc/modes/cbc/cbc_decrypt.obj ltc/modes/cbc/cbc_done.obj \
61 ltc/modes/cbc/cbc_encrypt.obj ltc/modes/cbc/cbc_getiv.obj ltc/modes/cbc/cbc_setiv.obj \
62 ltc/modes/cbc/cbc_start.obj ltc/modes/cfb/cfb_decrypt.obj ltc/modes/cfb/cfb_done.obj \
63 ltc/modes/cfb/cfb_encrypt.obj ltc/modes/cfb/cfb_getiv.obj ltc/modes/cfb/cfb_setiv.obj \
64 ltc/modes/cfb/cfb_start.obj ltc/modes/ctr/ctr_decrypt.obj ltc/modes/ctr/ctr_done.obj \
65 ltc/modes/ctr/ctr_encrypt.obj ltc/modes/ctr/ctr_getiv.obj ltc/modes/ctr/ctr_setiv.obj \
66 ltc/modes/ctr/ctr_start.obj ltc/modes/ecb/ecb_decrypt.obj ltc/modes/ecb/ecb_done.obj \
67 ltc/modes/ecb/ecb_encrypt.obj ltc/modes/ecb/ecb_start.obj ltc/modes/ofb/ofb_decrypt.obj \
68 ltc/modes/ofb/ofb_done.obj ltc/modes/ofb/ofb_encrypt.obj ltc/modes/ofb/ofb_getiv.obj \
69 ltc/modes/ofb/ofb_setiv.obj ltc/modes/ofb/ofb_start.obj ltc/pk/asn1/der/bit/der_decode_bit_string.obj \
70 ltc/pk/asn1/der/bit/der_decode_raw_bit_string.obj ltc/pk/asn1/der/bit/der_encode_bit_string.obj \
71 ltc/pk/asn1/der/bit/der_encode_raw_bit_string.obj ltc/pk/asn1/der/bit/der_length_bit_string.obj \
72 ltc/pk/asn1/der/boolean/der_decode_boolean.obj ltc/pk/asn1/der/boolean/der_encode_boolean.obj \
73 ltc/pk/asn1/der/boolean/der_length_boolean.obj ltc/pk/asn1/der/choice/der_decode_choice.obj \
74 ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.obj ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.obj \
75 ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.obj ltc/pk/asn1/der/ia5/der_decode_ia5_string.obj \
76 ltc/pk/asn1/der/ia5/der_encode_ia5_string.obj ltc/pk/asn1/der/ia5/der_length_ia5_string.obj \
77 ltc/pk/asn1/der/integer/der_decode_integer.obj ltc/pk/asn1/der/integer/der_encode_integer.obj \
78 ltc/pk/asn1/der/integer/der_length_integer.obj ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.obj \
79 ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.obj ltc/pk/asn1/der/object_identifier/der_length_object_identifier.obj \
80 ltc/pk/asn1/der/octet/der_decode_octet_string.obj ltc/pk/asn1/der/octet/der_encode_octet_string.obj \
81 ltc/pk/asn1/der/octet/der_length_octet_string.obj ltc/pk/asn1/der/printable_string/der_decode_printable_string.obj \
82 ltc/pk/asn1/der/printable_string/der_encode_printable_string.obj ltc/pk/asn1/der/printable_string/der_length_printable_string.obj \
83 ltc/pk/asn1/der/sequence/der_decode_sequence_ex.obj ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.obj \
84 ltc/pk/asn1/der/sequence/der_decode_sequence_multi.obj ltc/pk/asn1/der/sequence/der_decode_subject_public_key_info.obj \
85 ltc/pk/asn1/der/sequence/der_encode_sequence_ex.obj ltc/pk/asn1/der/sequence/der_encode_sequence_multi.obj \
86 ltc/pk/asn1/der/sequence/der_encode_subject_public_key_info.obj ltc/pk/asn1/der/sequence/der_length_sequence.obj \
87 ltc/pk/asn1/der/sequence/der_sequence_free.obj ltc/pk/asn1/der/sequence/der_sequence_shrink.obj \
8588 ltc/pk/asn1/der/set/der_encode_set.obj ltc/pk/asn1/der/set/der_encode_setof.obj ltc/pk/asn1/der/short_integer/der_decode_short_integer.obj \
8689 ltc/pk/asn1/der/short_integer/der_encode_short_integer.obj ltc/pk/asn1/der/short_integer/der_length_short_integer.obj \
8790 ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.obj ltc/pk/asn1/der/teletex_string/der_length_teletex_string.obj \
8891 ltc/pk/asn1/der/utctime/der_decode_utctime.obj ltc/pk/asn1/der/utctime/der_encode_utctime.obj \
8992 ltc/pk/asn1/der/utctime/der_length_utctime.obj ltc/pk/asn1/der/utf8/der_decode_utf8_string.obj \
9093 ltc/pk/asn1/der/utf8/der_encode_utf8_string.obj ltc/pk/asn1/der/utf8/der_length_utf8_string.obj \
91 ltc/pk/dh/dh.obj ltc/pk/dh/dh_static.obj ltc/pk/dh/dh_sys.obj ltc/pk/dsa/dsa_decrypt_key.obj \
94 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 \
95 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 \
96 ltc/pk/dh/dh_set_pg_dhparam.obj ltc/pk/dh/dh_shared_secret.obj ltc/pk/dsa/dsa_decrypt_key.obj \
9297 ltc/pk/dsa/dsa_encrypt_key.obj ltc/pk/dsa/dsa_export.obj ltc/pk/dsa/dsa_free.obj \
93 ltc/pk/dsa/dsa_import.obj ltc/pk/dsa/dsa_import_radix.obj ltc/pk/dsa/dsa_make_key.obj \
98 ltc/pk/dsa/dsa_generate_key.obj ltc/pk/dsa/dsa_generate_pqg.obj ltc/pk/dsa/dsa_import.obj \
99 ltc/pk/dsa/dsa_make_key.obj ltc/pk/dsa/dsa_set.obj ltc/pk/dsa/dsa_set_pqg_dsaparam.obj \
94100 ltc/pk/dsa/dsa_shared_secret.obj ltc/pk/dsa/dsa_sign_hash.obj ltc/pk/dsa/dsa_verify_hash.obj \
95101 ltc/pk/dsa/dsa_verify_key.obj ltc/pk/ecc/ecc.obj ltc/pk/ecc/ecc_ansi_x963_export.obj \
96102 ltc/pk/ecc/ecc_ansi_x963_import.obj ltc/pk/ecc/ecc_decrypt_key.obj ltc/pk/ecc/ecc_dp_clear.obj \
110116 ltc/pk/pkcs1/pkcs_1_pss_encode.obj ltc/pk/pkcs1/pkcs_1_v1_5_decode.obj ltc/pk/pkcs1/pkcs_1_v1_5_encode.obj \
111117 ltc/pk/rsa/rsa_decrypt_key.obj ltc/pk/rsa/rsa_encrypt_key.obj ltc/pk/rsa/rsa_export.obj \
112118 ltc/pk/rsa/rsa_exptmod.obj ltc/pk/rsa/rsa_free.obj ltc/pk/rsa/rsa_get_size.obj ltc/pk/rsa/rsa_import.obj \
113 ltc/pk/rsa/rsa_import_pkcs8.obj ltc/pk/rsa/rsa_import_radix.obj ltc/pk/rsa/rsa_import_x509.obj \
114 ltc/pk/rsa/rsa_make_key.obj ltc/pk/rsa/rsa_sign_hash.obj ltc/pk/rsa/rsa_sign_saltlen_get.obj \
119 ltc/pk/rsa/rsa_import_pkcs8.obj ltc/pk/rsa/rsa_import_x509.obj ltc/pk/rsa/rsa_make_key.obj \
120 ltc/pk/rsa/rsa_set.obj ltc/pk/rsa/rsa_sign_hash.obj ltc/pk/rsa/rsa_sign_saltlen_get.obj \
115121 ltc/pk/rsa/rsa_verify_hash.obj ltc/prngs/chacha20.obj ltc/prngs/fortuna.obj ltc/prngs/rc4.obj \
116122 ltc/prngs/rng_get_bytes.obj ltc/prngs/rng_make_prng.obj ltc/prngs/sober128.obj ltc/prngs/sprng.obj \
117123 ltc/prngs/yarrow.obj ltc/stream/chacha/chacha_crypt.obj ltc/stream/chacha/chacha_done.obj \
162168 $(RM_F) $(OBJS) liballinone.lib
163169
164170 .c.obj:
165 cl $(CFLAGS) /c $< /Fo$@
171 cl /Iltm /Iltc/headers /DLTC_SOURCE /DLTC_NO_TEST /DLTC_NO_PROTOTYPES /DLTM_DESC $(CFLAGS) /c $< /Fo$@
166172
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* AES implementation by Tom St Denis
686684
687685 rijndael_ecb_encrypt(tests[i].pt, tmp[0], &key);
688686 rijndael_ecb_decrypt(tmp[0], tmp[1], &key);
689 if (XMEMCMP(tmp[0], tests[i].ct, 16) || XMEMCMP(tmp[1], tests[i].pt, 16)) {
690 #if 0
691 printf("\n\nTest %d failed\n", i);
692 if (XMEMCMP(tmp[0], tests[i].ct, 16)) {
693 printf("CT: ");
694 for (i = 0; i < 16; i++) {
695 printf("%02x ", tmp[0][i]);
696 }
697 printf("\n");
698 } else {
699 printf("PT: ");
700 for (i = 0; i < 16; i++) {
701 printf("%02x ", tmp[1][i]);
702 }
703 printf("\n");
704 }
705 #endif
687 if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i) ||
688 compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
706689 return CRYPT_FAIL_TESTVECTOR;
707690 }
708691
754737 #endif
755738
756739
757 /* $Source$ */
758 /* $Revision$ */
759 /* $Date$ */
740 /* ref: $Format:%D$ */
741 /* git commit: $Format:%H$ */
742 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /* The precomputed tables for AES */
119 /*
10261024
10271025 #endif /* __LTC_AES_TAB_C__ */
10281026
1029 /* $Source$ */
1030 /* $Revision$ */
1031 /* $Date$ */
1027 /* ref: $Format:%D$ */
1028 /* git commit: $Format:%H$ */
1029 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
898896 {
899897 int N, R, i, pos, r;
900898 ulong32 kappa[MAX_N];
901 ulong32 inter[MAX_N];
899 ulong32 inter[MAX_N] = { 0 }; /* initialize as all zeroes */
902900 ulong32 v, K0, K1, K2, K3;
903901
904902 LTC_ARGCHK(key != NULL);
14991497 anubis_setup(tests[x].key, tests[x].keylen, 0, &skey);
15001498 anubis_ecb_encrypt(tests[x].pt, buf[0], &skey);
15011499 anubis_ecb_decrypt(buf[0], buf[1], &skey);
1502 if (XMEMCMP(buf[0], tests[x].ct, 16) || XMEMCMP(buf[1], tests[x].pt, 16)) {
1500 if (compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis Encrypt", x) ||
1501 compare_testvector(buf[1], 16, tests[x].pt, 16, "Anubis Decrypt", x)) {
15031502 return CRYPT_FAIL_TESTVECTOR;
15041503 }
15051504
15061505 for (y = 0; y < 1000; y++) anubis_ecb_encrypt(buf[0], buf[0], &skey);
15071506 for (y = 0; y < 1000; y++) anubis_ecb_decrypt(buf[0], buf[0], &skey);
1508 if (XMEMCMP(buf[0], tests[x].ct, 16)) {
1507 if (compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis 1000", 1000)) {
15091508 return CRYPT_FAIL_TESTVECTOR;
15101509 }
15111510
15531552 #endif
15541553
15551554
1556 /* $Source$ */
1557 /* $Revision$ */
1558 /* $Date$ */
1555 /* ref: $Format:%D$ */
1556 /* git commit: $Format:%H$ */
1557 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @file blowfish.c
547545 blowfish_ecb_decrypt(tmp[0], tmp[1], &key);
548546
549547 /* compare */
550 if ((XMEMCMP(tmp[0], tests[x].ct, 8) != 0) || (XMEMCMP(tmp[1], tests[x].pt, 8) != 0)) {
548 if ((compare_testvector(tmp[0], 8, tests[x].ct, 8, "Blowfish Encrypt", x) != 0) ||
549 (compare_testvector(tmp[1], 8, tests[x].pt, 8, "Blowfish Decrypt", x) != 0)) {
551550 return CRYPT_FAIL_TESTVECTOR;
552551 }
553552
589588 #endif
590589
591590
592 /* $Source$ */
593 /* $Revision$ */
594 /* $Date$ */
591 /* ref: $Format:%D$ */
592 /* git commit: $Format:%H$ */
593 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
698696 return err;
699697 }
700698 camellia_done(&skey);
701 if (XMEMCMP(tests[x].ct, buf[0], 16) || XMEMCMP(tests[x].pt, buf[1], 16)) {
702 #if 0
703 int i, j;
704 printf ("\n\nLTC_CAMELLIA failed for x=%d, I got:\n", x);
705 for (i = 0; i < 2; i++) {
706 const unsigned char *expected, *actual;
707 expected = (i ? tests[x].pt : tests[x].ct);
708 actual = buf[i];
709 printf ("expected actual (%s)\n", (i ? "plaintext" : "ciphertext"));
710 for (j = 0; j < 16; j++) {
711 const char *eq = (expected[j] == actual[j] ? "==" : "!=");
712 printf (" %02x %s %02x\n", expected[j], eq, actual[j]);
713 }
714 printf ("\n");
715 }
716 #endif
699 if (compare_testvector(tests[x].ct, 16, buf[0], 16, "Camellia Encrypt", x) ||
700 compare_testvector(tests[x].pt, 16, buf[1], 16, "Camellia Decrypt", x)) {
717701 return CRYPT_FAIL_TESTVECTOR;
718702 }
719703 }
736720
737721 #endif
738722
739 /* $Source$ */
740 /* $Revision$ */
741 /* $Date$ */
723 /* ref: $Format:%D$ */
724 /* git commit: $Format:%H$ */
725 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
675673 }
676674 cast5_ecb_encrypt(tests[i].pt, tmp[0], &key);
677675 cast5_ecb_decrypt(tmp[0], tmp[1], &key);
678 if ((XMEMCMP(tmp[0], tests[i].ct, 8) != 0) || (XMEMCMP(tmp[1], tests[i].pt, 8) != 0)) {
676 if ((compare_testvector(tmp[0], 8, tests[i].ct, 8, "CAST5 Encrypt", i) != 0) ||
677 (compare_testvector(tmp[1], 8, tests[i].pt, 8, "CAST5 Decrypt", i) != 0)) {
679678 return CRYPT_FAIL_TESTVECTOR;
680679 }
681680 /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
715714
716715 #endif
717716
718 /* $Source$ */
719 /* $Revision$ */
720 /* $Date$ */
717 /* ref: $Format:%D$ */
718 /* git commit: $Format:%H$ */
719 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
19781976 des_ecb_decrypt(cases[i].txt, tmp, &des);
19791977 }
19801978
1981 if (XMEMCMP(cases[i].out, tmp, sizeof(tmp)) != 0) {
1979 if (compare_testvector(cases[i].out, sizeof(tmp), tmp, sizeof(tmp), "DES", i) != 0) {
19821980 return CRYPT_FAIL_TESTVECTOR;
19831981 }
19841982
20212019 des3_ecb_encrypt(pt, ct, &skey);
20222020 des3_ecb_decrypt(ct, tmp, &skey);
20232021
2024 if (XMEMCMP(pt, tmp, 8) != 0) {
2022 if (compare_testvector(pt, 8, tmp, 8, "3DES", 0) != 0) {
20252023 return CRYPT_FAIL_TESTVECTOR;
20262024 }
20272025
20792077 #endif
20802078
20812079
2082 /* $Source$ */
2083 /* $Revision$ */
2084 /* $Date$ */
2080 /* ref: $Format:%D$ */
2081 /* git commit: $Format:%H$ */
2082 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
303301 if ((err = kasumi_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
304302 return err;
305303 }
306 if (XMEMCMP(tests[x].pt, buf[1], 8) || XMEMCMP(tests[x].ct, buf[0], 8)) {
304 if (compare_testvector(buf[1], 8, tests[x].pt, 8, "Kasumi Decrypt", x) ||
305 compare_testvector(buf[0], 8, tests[x].ct, 8, "Kasumi Encrypt", x)) {
307306 return CRYPT_FAIL_TESTVECTOR;
308307 }
309308 }
313312
314313 #endif
315314
316 /* $Source$ */
317 /* $Revision$ */
318 /* $Date$ */
315 /* ref: $Format:%D$ */
316 /* git commit: $Format:%H$ */
317 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
809807 khazad_setup(tests[x].key, 16, 0, &skey);
810808 khazad_ecb_encrypt(tests[x].pt, buf[0], &skey);
811809 khazad_ecb_decrypt(buf[0], buf[1], &skey);
812 if (XMEMCMP(buf[0], tests[x].ct, 8) || XMEMCMP(buf[1], tests[x].pt, 8)) {
810 if (compare_testvector(buf[0], 8, tests[x].ct, 8, "Khazad Encrypt", x) ||
811 compare_testvector(buf[1], 8, tests[x].pt, 8, "Khazad Decrypt", x)) {
813812 return CRYPT_FAIL_TESTVECTOR;
814813 }
815814
816815 for (y = 0; y < 1000; y++) khazad_ecb_encrypt(buf[0], buf[0], &skey);
817816 for (y = 0; y < 1000; y++) khazad_ecb_decrypt(buf[0], buf[0], &skey);
818 if (XMEMCMP(buf[0], tests[x].ct, 8)) {
817 if (compare_testvector(buf[0], 8, tests[x].ct, 8, "Khazad 1000", 1000)) {
819818 return CRYPT_FAIL_TESTVECTOR;
820819 }
821820
850849
851850 #endif
852851
853 /* $Source$ */
854 /* $Revision$ */
855 /* $Date$ */
852 /* ref: $Format:%D$ */
853 /* git commit: $Format:%H$ */
854 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
345343 kseed_setup(tests[x].key, 16, 0, &skey);
346344 kseed_ecb_encrypt(tests[x].pt, buf[0], &skey);
347345 kseed_ecb_decrypt(buf[0], buf[1], &skey);
348 if (XMEMCMP(buf[0], tests[x].ct, 16) || XMEMCMP(buf[1], tests[x].pt, 16)) {
349 #if 0
350 int i, j;
351 printf ("\n\nLTC_KSEED failed for x=%d, I got:\n", x);
352 for (i = 0; i < 2; i++) {
353 const unsigned char *expected, *actual;
354 expected = (i ? tests[x].pt : tests[x].ct);
355 actual = buf[i];
356 printf ("expected actual (%s)\n", (i ? "plaintext" : "ciphertext"));
357 for (j = 0; j < 16; j++) {
358 const char *eq = (expected[j] == actual[j] ? "==" : "!=");
359 printf (" %02x %s %02x\n", expected[j], eq, actual[j]);
360 }
361 printf ("\n");
362 }
363 #endif
346 if (compare_testvector(buf[0], 16, tests[x].ct, 16, "KSEED Encrypt", x) ||
347 compare_testvector(buf[1], 16, tests[x].pt, 16, "KSEED Decrypt", x)) {
364348 return CRYPT_FAIL_TESTVECTOR;
365349 }
366350 }
386370
387371 #endif
388372
389 /* $Source$ */
390 /* $Revision$ */
391 /* $Date$ */
373 /* ref: $Format:%D$ */
374 /* git commit: $Format:%H$ */
375 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
257255 return err;
258256 }
259257
260 if (XMEMCMP(buf, tests[x].ct, 8)) {
258 if (compare_testvector(buf, 8, tests[x].ct, 8, "Multi2 Encrypt", x)) {
261259 return CRYPT_FAIL_TESTVECTOR;
262260 }
263261
264262 if ((err = multi2_ecb_decrypt(buf, buf, &skey)) != CRYPT_OK) {
265263 return err;
266264 }
267 if (XMEMCMP(buf, tests[x].pt, 8)) {
265 if (compare_testvector(buf, 8, tests[x].pt, 8, "Multi2 Decrypt", x)) {
268266 return CRYPT_FAIL_TESTVECTOR;
269267 }
270268 }
281279 if ((err = multi2_ecb_decrypt(ct, buf, &skey)) != CRYPT_OK) {
282280 return err;
283281 }
284 if (XMEMCMP(buf, tests[0].pt, 8)) {
282 if (compare_testvector(buf, 8, tests[0].pt, 8, "Multi2 Rounds", x)) {
285283 return CRYPT_FAIL_TESTVECTOR;
286284 }
287285 }
315313
316314 #endif
317315
318 /* $Source$ */
319 /* $Revision$ */
320 /* $Date$ */
316 /* ref: $Format:%D$ */
317 /* git commit: $Format:%H$ */
318 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @file noekeon.c
282280
283281 noekeon_ecb_encrypt(tests[i].pt, tmp[0], &key);
284282 noekeon_ecb_decrypt(tmp[0], tmp[1], &key);
285 if (XMEMCMP(tmp[0], tests[i].ct, 16) || XMEMCMP(tmp[1], tests[i].pt, 16)) {
286 #if 0
287 printf("\n\nTest %d failed\n", i);
288 if (XMEMCMP(tmp[0], tests[i].ct, 16)) {
289 printf("CT: ");
290 for (i = 0; i < 16; i++) {
291 printf("%02x ", tmp[0][i]);
292 }
293 printf("\n");
294 } else {
295 printf("PT: ");
296 for (i = 0; i < 16; i++) {
297 printf("%02x ", tmp[1][i]);
298 }
299 printf("\n");
300 }
301 #endif
283 if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "Noekeon Encrypt", i) ||
284 compare_testvector(tmp[1], 16, tests[i].pt, 16, "Noekeon Decrypt", i)) {
302285 return CRYPT_FAIL_TESTVECTOR;
303286 }
304287
339322 #endif
340323
341324
342 /* $Source$ */
343 /* $Revision$ */
344 /* $Date$ */
325 /* ref: $Format:%D$ */
326 /* git commit: $Format:%H$ */
327 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**********************************************************************\
119 * To commemorate the 1996 RSA Data Security Conference, the following *
1715 * Thanks to CodeView, SoftIce, and D86 for helping bring this code to *
1816 * the public. *
1917 \**********************************************************************/
20 #include <tomcrypt.h>
18 #include "tomcrypt.h"
2119
2220 /**
2321 @file rc2.c
413411
414412
415413
416 /* $Source$ */
417 /* $Revision$ */
418 /* $Date$ */
414 /* ref: $Format:%D$ */
415 /* git commit: $Format:%H$ */
416 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
274272 rc5_ecb_decrypt(tmp[0], tmp[1], &key);
275273
276274 /* compare */
277 if (XMEMCMP(tmp[0], tests[x].ct, 8) != 0 || XMEMCMP(tmp[1], tests[x].pt, 8) != 0) {
275 if (compare_testvector(tmp[0], 8, tests[x].ct, 8, "RC5 Encrypt", x) != 0 ||
276 compare_testvector(tmp[1], 8, tests[x].pt, 8, "RC5 Decrypt", x) != 0) {
278277 return CRYPT_FAIL_TESTVECTOR;
279278 }
280279
317316
318317
319318
320 /* $Source$ */
321 /* $Revision$ */
322 /* $Date$ */
319 /* ref: $Format:%D$ */
320 /* git commit: $Format:%H$ */
321 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
284282 rc6_ecb_decrypt(tmp[0], tmp[1], &key);
285283
286284 /* compare */
287 if (XMEMCMP(tmp[0], tests[x].ct, 16) || XMEMCMP(tmp[1], tests[x].pt, 16)) {
288 #if 0
289 printf("\n\nFailed test %d\n", x);
290 if (XMEMCMP(tmp[0], tests[x].ct, 16)) {
291 printf("Ciphertext: ");
292 for (y = 0; y < 16; y++) printf("%02x ", tmp[0][y]);
293 printf("\nExpected : ");
294 for (y = 0; y < 16; y++) printf("%02x ", tests[x].ct[y]);
295 printf("\n");
296 }
297 if (XMEMCMP(tmp[1], tests[x].pt, 16)) {
298 printf("Plaintext: ");
299 for (y = 0; y < 16; y++) printf("%02x ", tmp[0][y]);
300 printf("\nExpected : ");
301 for (y = 0; y < 16; y++) printf("%02x ", tests[x].pt[y]);
302 printf("\n");
303 }
304 #endif
285 if (compare_testvector(tmp[0], 16, tests[x].ct, 16, "RC6 Encrypt", x) ||
286 compare_testvector(tmp[1], 16, tests[x].pt, 16, "RC6 Decrypt", x)) {
305287 return CRYPT_FAIL_TESTVECTOR;
306288 }
307289
343325
344326
345327
346 /* $Source$ */
347 /* $Revision$ */
348 /* $Date$ */
328 /* ref: $Format:%D$ */
329 /* git commit: $Format:%H$ */
330 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /*******************************************************************************
2725 *
2826 *******************************************************************************/
2927
30 #include <tomcrypt.h>
28 #include "tomcrypt.h"
3129
3230 #ifdef LTC_SAFER
3331
3432 #define __LTC_SAFER_TAB_C__
3533 #include "safer_tab.c"
3634
37 const struct ltc_cipher_descriptor
38 safer_k64_desc = {
35 const struct ltc_cipher_descriptor safer_k64_desc = {
3936 "safer-k64",
4037 8, 8, 8, 8, LTC_SAFER_K64_DEFAULT_NOF_ROUNDS,
4138 &safer_k64_setup,
397394 safer_ecb_encrypt(k64_pt, buf[0], &skey);
398395 safer_ecb_decrypt(buf[0], buf[1], &skey);
399396
400 if (XMEMCMP(buf[0], k64_ct, 8) != 0 || XMEMCMP(buf[1], k64_pt, 8) != 0) {
397 if (compare_testvector(buf[0], 8, k64_ct, 8, "Safer K64 Encrypt", 0) != 0 ||
398 compare_testvector(buf[1], 8, k64_pt, 8, "Safer K64 Decrypt", 0) != 0) {
401399 return CRYPT_FAIL_TESTVECTOR;
402400 }
403401
427425 safer_ecb_encrypt(sk64_pt, buf[0], &skey);
428426 safer_ecb_decrypt(buf[0], buf[1], &skey);
429427
430 if (XMEMCMP(buf[0], sk64_ct, 8) != 0 || XMEMCMP(buf[1], sk64_pt, 8) != 0) {
428 if (compare_testvector(buf[0], 8, sk64_ct, 8, "Safer SK64 Encrypt", 0) != 0 ||
429 compare_testvector(buf[1], 8, sk64_pt, 8, "Safer SK64 Decrypt", 0) != 0) {
431430 return CRYPT_FAIL_TESTVECTOR;
432431 }
433432
470469 safer_ecb_encrypt(sk128_pt, buf[0], &skey);
471470 safer_ecb_decrypt(buf[0], buf[1], &skey);
472471
473 if (XMEMCMP(buf[0], sk128_ct, 8) != 0 || XMEMCMP(buf[1], sk128_pt, 8) != 0) {
472 if (compare_testvector(buf[0], 8, sk128_ct, 8, "Safer SK128 Encrypt", 0) != 0 ||
473 compare_testvector(buf[1], 8, sk128_pt, 8, "Safer SK128 Decrypt", 0) != 0) {
474474 return CRYPT_FAIL_TESTVECTOR;
475475 }
476476
489489
490490
491491
492 /* $Source$ */
493 /* $Revision$ */
494 /* $Date$ */
492 /* ref: $Format:%D$ */
493 /* git commit: $Format:%H$ */
494 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
6058
6159
6260
63 /* $Source$ */
64 /* $Revision$ */
65 /* $Date$ */
61 /* ref: $Format:%D$ */
62 /* git commit: $Format:%H$ */
63 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
515513 saferp_ecb_decrypt(tmp[0], tmp[1], &skey);
516514
517515 /* compare */
518 if (XMEMCMP(tmp[0], tests[i].ct, 16) || XMEMCMP(tmp[1], tests[i].pt, 16)) {
516 if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "Safer+ Encrypt", i) ||
517 compare_testvector(tmp[1], 16, tests[i].pt, 16, "Safer+ Decrypt", i)) {
519518 return CRYPT_FAIL_TESTVECTOR;
520519 }
521520
563562
564563
565564
566 /* $Source$ */
567 /* $Revision$ */
568 /* $Date$ */
565 /* ref: $Format:%D$ */
566 /* git commit: $Format:%H$ */
567 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
297295 skipjack_ecb_decrypt(buf[0], buf[1], &key);
298296
299297 /* compare */
300 if (XMEMCMP(buf[0], tests[x].ct, 8) != 0 || XMEMCMP(buf[1], tests[x].pt, 8) != 0) {
298 if (compare_testvector(buf[0], 8, tests[x].ct, 8, "Skipjack Encrypt", x) != 0 ||
299 compare_testvector(buf[1], 8, tests[x].pt, 8, "Skipjack Decrypt", x) != 0) {
301300 return CRYPT_FAIL_TESTVECTOR;
302301 }
303302
338337
339338 #endif
340339
341 /* $Source$ */
342 /* $Revision$ */
343 /* $Date$ */
340 /* ref: $Format:%D$ */
341 /* git commit: $Format:%H$ */
342 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
658656 }
659657 twofish_ecb_encrypt(tests[i].pt, tmp[0], &key);
660658 twofish_ecb_decrypt(tmp[0], tmp[1], &key);
661 if (XMEMCMP(tmp[0], tests[i].ct, 16) != 0 || XMEMCMP(tmp[1], tests[i].pt, 16) != 0) {
662 #if 0
663 printf("Twofish failed test %d, %d, %d\n", i, XMEMCMP(tmp[0], tests[i].ct, 16), XMEMCMP(tmp[1], tests[i].pt, 16));
664 #endif
659 if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "Twofish Encrypt", i) != 0 ||
660 compare_testvector(tmp[1], 16, tests[i].pt, 16, "Twofish Decrypt", i) != 0) {
665661 return CRYPT_FAIL_TESTVECTOR;
666662 }
667663 /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
709705
710706
711707
712 /* $Source$ */
713 /* $Revision$ */
714 /* $Date$ */
708 /* ref: $Format:%D$ */
709 /* git commit: $Format:%H$ */
710 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
492490 #endif /* __LTC_TWOFISH_TAB_C__ */
493491 #endif
494492
495 /* $Source$ */
496 /* $Revision$ */
497 /* $Date$ */
493 /* ref: $Format:%D$ */
494 /* git commit: $Format:%H$ */
495 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
212210 xtea_ecb_encrypt(tests[i].pt, tmp[0], &skey);
213211 xtea_ecb_decrypt(tmp[0], tmp[1], &skey);
214212
215 if (XMEMCMP(tmp[0], tests[i].ct, 8) != 0 || XMEMCMP(tmp[1], tests[i].pt, 8) != 0) {
216 #if 0
217 printf("\n\nTest %d failed\n", i);
218 if (XMEMCMP(tmp[0], tests[i].ct, 8)) {
219 printf("CT: ");
220 for (i = 0; i < 8; i++) {
221 printf("%02x ", tmp[0][i]);
222 }
223 printf("\n");
224 } else {
225 printf("PT: ");
226 for (i = 0; i < 8; i++) {
227 printf("%02x ", tmp[1][i]);
228 }
229 printf("\n");
230 }
231 #endif
213 if (compare_testvector(tmp[0], 8, tests[i].ct, 8, "XTEA Encrypt", i) != 0 ||
214 compare_testvector(tmp[1], 8, tests[i].pt, 8, "XTEA Decrypt", i) != 0) {
232215 return CRYPT_FAIL_TESTVECTOR;
233216 }
234217
272255
273256
274257
275 /* $Source$ */
276 /* $Revision$ */
277 /* $Date$ */
258 /* ref: $Format:%D$ */
259 /* git commit: $Format:%H$ */
260 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5856 }
5957
6058 #endif
59
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
108106 }
109107
110108 #endif
109
110 /* ref: $Format:%D$ */
111 /* git commit: $Format:%H$ */
112 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6058 }
6159
6260 #endif
61
62 /* ref: $Format:%D$ */
63 /* git commit: $Format:%H$ */
64 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7674 }
7775
7876 #endif
77
78 /* ref: $Format:%D$ */
79 /* git commit: $Format:%H$ */
80 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5351 int err;
5452 unsigned long len, L, x, y, z, CTRlen;
5553 #ifdef LTC_FAST
56 LTC_FAST_TYPE fastMask = -1; /* initialize fastMask at all zeroes */
54 LTC_FAST_TYPE fastMask = ~0; /* initialize fastMask at all zeroes */
5755 #endif
5856 unsigned char mask = 0xff; /* initialize mask at all zeroes */
5957
143141 }
144142
145143 /* initialize buffer for pt */
146 if (direction == CCM_DECRYPT) {
144 if (direction == CCM_DECRYPT && ptlen > 0) {
147145 pt_work = XMALLOC(ptlen);
148146 if (pt_work == NULL) {
149147 goto error;
377375 }
378376
379377 #ifdef LTC_CLEAN_STACK
378 #ifdef LTC_FAST
380379 fastMask = 0;
380 #endif
381381 mask = 0;
382382 zeromem(skey, sizeof(*skey));
383383 zeromem(PAD, sizeof(PAD));
399399
400400 #endif
401401
402 /* $Source$ */
403 /* $Revision$ */
404 /* $Date$ */
402 /* ref: $Format:%D$ */
403 /* git commit: $Format:%H$ */
404 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8381 }
8482
8583 #endif
84
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3028 }
3129
3230 #endif
31
32 /* ref: $Format:%D$ */
33 /* git commit: $Format:%H$ */
34 /* commit time: $Format:%ai$ */
3131 }
3232
3333 #endif
34
35 /* ref: $Format:%D$ */
36 /* git commit: $Format:%H$ */
37 /* commit time: $Format:%ai$ */
2828 LTC_ARGCHK(st != NULL);
2929
3030 if (st->aadflg) {
31 padlen = 16 - (st->aadlen % 16);
31 padlen = 16 - (unsigned long)(st->aadlen % 16);
3232 if (padlen < 16) {
3333 if ((err = poly1305_process(&st->poly, padzero, padlen)) != CRYPT_OK) return err;
3434 }
4242 }
4343
4444 #endif
45
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */
2626
2727 LTC_ARGCHK(st != NULL);
2828
29 padlen = 16 - (st->ctlen % 16);
29 padlen = 16 - (unsigned long)(st->ctlen % 16);
3030 if (padlen < 16) {
3131 if ((err = poly1305_process(&st->poly, padzero, padlen)) != CRYPT_OK) return err;
3232 }
3939 }
4040
4141 #endif
42
43 /* ref: $Format:%D$ */
44 /* git commit: $Format:%H$ */
45 /* commit time: $Format:%ai$ */
2929
3030 if ((err = chacha_crypt(&st->chacha, in, inlen, out)) != CRYPT_OK) return err;
3131 if (st->aadflg) {
32 padlen = 16 - (st->aadlen % 16);
32 padlen = 16 - (unsigned long)(st->aadlen % 16);
3333 if (padlen < 16) {
3434 if ((err = poly1305_process(&st->poly, padzero, padlen)) != CRYPT_OK) return err;
3535 }
4141 }
4242
4343 #endif
44
45 /* ref: $Format:%D$ */
46 /* git commit: $Format:%H$ */
47 /* commit time: $Format:%ai$ */
2323 }
2424
2525 #endif
26
27 /* ref: $Format:%D$ */
28 /* git commit: $Format:%H$ */
29 /* commit time: $Format:%ai$ */
1414 Process an entire GCM packet in one call.
1515 @param key The secret key
1616 @param keylen The length of the secret key
17 @param iv The initial vector
18 @param ivlen The length of the initial vector
17 @param iv The initialization vector
18 @param ivlen The length of the initialization vector
1919 @param aad The additional authentication data (header)
2020 @param aadlen The length of the aad
2121 @param in The plaintext
6767 }
6868
6969 #endif
70
71 /* ref: $Format:%D$ */
72 /* git commit: $Format:%H$ */
73 /* commit time: $Format:%ai$ */
1414 Set IV + counter data to the ChaCha20Poly1305 state and reset the context
1515 @param st The ChaCha20Poly1305 state
1616 @param iv The IV data to add
17 @param inlen The length of the IV (must be 12 or 8)
17 @param ivlen The length of the IV (must be 12 or 8)
1818 @return CRYPT_OK on success
1919 */
2020 int chacha20poly1305_setiv(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen)
6161 }
6262
6363 #endif
64
65 /* ref: $Format:%D$ */
66 /* git commit: $Format:%H$ */
67 /* commit time: $Format:%ai$ */
1414 Set IV + counter data (with RFC7905-magic) to the ChaCha20Poly1305 state and reset the context
1515 @param st The ChaCha20Poly1305 state
1616 @param iv The IV data to add
17 @param inlen The length of the IV (must be 12 or 8)
17 @param ivlen The length of the IV (must be 12 or 8)
1818 @param sequence_number 64bit sequence number which is incorporated into IV as described in RFC7905
1919 @return CRYPT_OK on success
2020 */
3333 }
3434
3535 #endif
36
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @file eax_addheader.c
3230
3331 #endif
3432
35 /* $Source$ */
36 /* $Revision$ */
37 /* $Date$ */
33 /* ref: $Format:%D$ */
34 /* git commit: $Format:%H$ */
35 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4442
4543 #endif
4644
47 /* $Source$ */
48 /* $Revision$ */
49 /* $Date$ */
45 /* ref: $Format:%D$ */
46 /* git commit: $Format:%H$ */
47 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5654 /* default to zero */
5755 *stat = 0;
5856
57 /* limit taglen */
58 taglen = MIN(taglen, MAXBLOCKSIZE);
59
5960 /* allocate ram */
6061 buf = XMALLOC(taglen);
6162 eax = XMALLOC(sizeof(*eax));
8384 }
8485
8586 /* compare tags */
86 if (buflen >= taglen && XMEMCMP(buf, tag, taglen) == 0) {
87 if (buflen >= taglen && XMEM_NEQ(buf, tag, taglen) == 0) {
8788 *stat = 1;
8889 }
8990
102103
103104 #endif
104105
105 /* $Source$ */
106 /* $Revision$ */
107 /* $Date$ */
106 /* ref: $Format:%D$ */
107 /* git commit: $Format:%H$ */
108 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
8886
8987 #endif
9088
91 /* $Source$ */
92 /* $Revision$ */
93 /* $Date$ */
89 /* ref: $Format:%D$ */
90 /* git commit: $Format:%H$ */
91 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4543 #endif
4644
4745
48 /* $Source$ */
49 /* $Revision$ */
50 /* $Date$ */
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
7674
7775 #endif
7876
79 /* $Source$ */
80 /* $Revision$ */
81 /* $Date$ */
77 /* ref: $Format:%D$ */
78 /* git commit: $Format:%H$ */
79 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
138136
139137 #endif
140138
141 /* $Source$ */
142 /* $Revision$ */
143 /* $Date$ */
139 /* ref: $Format:%D$ */
140 /* git commit: $Format:%H$ */
141 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4745
4846 /* in IV mode? */
4947 if (gcm->mode == LTC_GCM_MODE_IV) {
48 /* IV length must be > 0 */
49 if (gcm->buflen == 0 && gcm->totlen == 0) return CRYPT_ERROR;
5050 /* let's process the IV */
5151 if (gcm->ivmode || gcm->buflen != 12) {
5252 for (x = 0; x < (unsigned long)gcm->buflen; x++) {
118118 #endif
119119
120120
121 /* $Source$ */
122 /* $Revision$ */
123 /* $Date$ */
121 /* ref: $Format:%D$ */
122 /* git commit: $Format:%H$ */
123 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
8886 #endif
8987
9088
91 /* $Source$ */
92 /* $Revision$ */
93 /* $Date$ */
89 /* ref: $Format:%D$ */
90 /* git commit: $Format:%H$ */
91 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4139 return err;
4240 }
4341
42 if (gcm->mode == LTC_GCM_MODE_IV) {
43 /* let's process the IV */
44 if ((err = gcm_add_aad(gcm, NULL, 0)) != CRYPT_OK) return err;
45 }
46
47 if (gcm->mode == LTC_GCM_MODE_AAD) {
48 /* let's process the AAD */
49 if ((err = gcm_process(gcm, NULL, 0, NULL, 0)) != CRYPT_OK) return err;
50 }
4451
4552 if (gcm->mode != LTC_GCM_MODE_TEXT) {
4653 return CRYPT_INVALID_ARG;
7784 #endif
7885
7986
80 /* $Source$ */
81 /* $Revision$ */
82 /* $Date$ */
87 /* ref: $Format:%D$ */
88 /* git commit: $Format:%H$ */
89 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5957
6058 #ifndef LTC_FAST
6159 /* right shift */
62 static void gcm_rightshift(unsigned char *a)
60 static void _gcm_rightshift(unsigned char *a)
6361 {
6462 int x;
6563 for (x = 15; x > 0; x--) {
9391 }
9492 }
9593 z = V[15] & 0x01;
96 gcm_rightshift(V);
94 _gcm_rightshift(V);
9795 V[0] ^= poly[z];
9896 }
9997 XMEMCPY(c, Z, 16);
214212
215213 #endif
216214
217 /* $Source$ */
218 /* $Revision$ */
219 /* $Date$ */
220
215 /* ref: $Format:%D$ */
216 /* git commit: $Format:%H$ */
217 /* commit time: $Format:%ai$ */
218
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
10199
102100 #endif
103101
104 /* $Source$ */
105 /* $Revision$ */
106 /* $Date$ */
102 /* ref: $Format:%D$ */
103 /* git commit: $Format:%H$ */
104 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
2119 @param cipher Index of cipher to use
2220 @param key The secret key
2321 @param keylen The length of the secret key
24 @param IV The initial vector
25 @param IVlen The length of the initial vector
22 @param IV The initialization vector
23 @param IVlen The length of the initialization vector
2624 @param adata The additional authentication data (header)
2725 @param adatalen The length of the adata
2826 @param pt The plaintext
102100 #endif
103101
104102
105 /* $Source$ */
106 /* $Revision$ */
107 /* $Date$ */
103 /* ref: $Format:%D$ */
104 /* git commit: $Format:%H$ */
105 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5351 }
5452 #endif
5553
56 /* $Source$ */
57 /* $Revision$ */
58 /* $Date$ */
54 /* ref: $Format:%D$ */
55 /* git commit: $Format:%H$ */
56 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
5149 /* 0xFFFFFFFE0 = ((2^39)-256)/8 */
5250 if (gcm->pttotlen / 8 + (ulong64)gcm->buflen + (ulong64)ptlen >= CONST64(0xFFFFFFFE0)) {
5351 return CRYPT_INVALID_ARG;
52 }
53
54 if (gcm->mode == LTC_GCM_MODE_IV) {
55 /* let's process the IV */
56 if ((err = gcm_add_aad(gcm, NULL, 0)) != CRYPT_OK) return err;
5457 }
5558
5659 /* in AAD mode? */
151154
152155 #endif
153156
154 /* $Source$ */
155 /* $Revision$ */
156 /* $Date$ */
157 /* ref: $Format:%D$ */
158 /* git commit: $Format:%H$ */
159 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
3836
3937 #endif
4038
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */
1515 #ifdef LTC_OCB3_MODE
1616
1717 /**
18 Add one block of AAD data (internal function)
19 @param ocb The OCB state
20 @param aad_block [in] AAD data (block_len size)
21 @return CRYPT_OK if successful
22 */
23 static int _ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
24 {
25 unsigned char tmp[MAXBLOCKSIZE];
26 int err;
27
28 /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */
29 ocb3_int_xor_blocks(ocb->aOffset_current, ocb->aOffset_current, ocb->L_[ocb3_int_ntz(ocb->ablock_index)], ocb->block_len);
30
31 /* Sum_i = Sum_{i-1} xor ENCIPHER(K, A_i xor Offset_i) */
32 ocb3_int_xor_blocks(tmp, aad_block, ocb->aOffset_current, ocb->block_len);
33 if ((err = cipher_descriptor[ocb->cipher].ecb_encrypt(tmp, tmp, &ocb->key)) != CRYPT_OK) {
34 return err;
35 }
36 ocb3_int_xor_blocks(ocb->aSum_current, ocb->aSum_current, tmp, ocb->block_len);
37
38 ocb->ablock_index++;
39
40 return CRYPT_OK;
41 }
42
43 /**
1844 Add AAD - additional associated data
1945 @param ocb The OCB state
2046 @param aad The AAD data
2753 unsigned char *data;
2854 unsigned long datalen, l;
2955
30 LTC_ARGCHK(ocb != NULL);
31 LTC_ARGCHK(aad != NULL);
32
56 LTC_ARGCHK(ocb != NULL);
3357 if (aadlen == 0) return CRYPT_OK;
58 LTC_ARGCHK(aad != NULL);
3459
3560 if (ocb->adata_buffer_bytes > 0) {
3661 l = ocb->block_len - ocb->adata_buffer_bytes;
3964 ocb->adata_buffer_bytes += l;
4065
4166 if (ocb->adata_buffer_bytes == ocb->block_len) {
42 if ((err = ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
67 if ((err = _ocb3_int_aad_add_block(ocb, ocb->adata_buffer)) != CRYPT_OK) {
4368 return err;
4469 }
4570 ocb->adata_buffer_bytes = 0;
6085 last_block_len = datalen - full_blocks_len;
6186
6287 for (x=0; x<full_blocks; x++) {
63 if ((err = ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
88 if ((err = _ocb3_int_aad_add_block(ocb, data+x*ocb->block_len)) != CRYPT_OK) {
6489 return err;
6590 }
6691 }
75100
76101 #endif
77102
78 /* $Source$ */
79 /* $Revision$ */
80 /* $Date$ */
103 /* ref: $Format:%D$ */
104 /* git commit: $Format:%H$ */
105 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
3129 unsigned char *pt_b, *ct_b;
3230
3331 LTC_ARGCHK(ocb != NULL);
34 LTC_ARGCHK(pt != NULL);
35 LTC_ARGCHK(ct != NULL);
32 if (ctlen == 0) return CRYPT_OK; /* no data, nothing to do */
33 LTC_ARGCHK(ct != NULL);
34 LTC_ARGCHK(pt != NULL);
35
3636 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) {
3737 return err;
3838 }
8080
8181 #endif
8282
83 /* $Source$ */
84 /* $Revision$ */
85 /* $Date$ */
83 /* ref: $Format:%D$ */
84 /* git commit: $Format:%H$ */
85 /* commit time: $Format:%ai$ */
2929 int err, x, full_blocks, full_blocks_len, last_block_len;
3030
3131 LTC_ARGCHK(ocb != NULL);
32 LTC_ARGCHK(ct != NULL);
32 if (ct == NULL) LTC_ARGCHK(ctlen == 0);
33 if (ctlen != 0) {
34 LTC_ARGCHK(ct != NULL);
35 LTC_ARGCHK(pt != NULL);
36 }
37
3338 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) {
3439 goto LBL_ERR;
3540 }
99104
100105 #endif
101106
102 /* $Source$ */
103 /* $Revision$ */
104 /* $Date$ */
107 /* ref: $Format:%D$ */
108 /* git commit: $Format:%H$ */
109 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4745 unsigned char *buf;
4846 unsigned long buflen;
4947
50 LTC_ARGCHK(key != NULL);
51 LTC_ARGCHK(nonce != NULL);
52 LTC_ARGCHK(pt != NULL);
53 LTC_ARGCHK(ct != NULL);
54 LTC_ARGCHK(tag != NULL);
5548 LTC_ARGCHK(stat != NULL);
5649
5750 /* default to zero */
5851 *stat = 0;
52
53 /* limit taglen */
54 taglen = MIN(taglen, MAXBLOCKSIZE);
5955
6056 /* allocate memory */
6157 buf = XMALLOC(taglen);
7066 return CRYPT_MEM;
7167 }
7268
73 if ((err = ocb3_init(ocb, cipher, key, keylen, nonce, noncelen)) != CRYPT_OK) {
69 if ((err = ocb3_init(ocb, cipher, key, keylen, nonce, noncelen, taglen)) != CRYPT_OK) {
7470 goto LBL_ERR;
7571 }
7672
77 if ((err = ocb3_add_aad(ocb, adata, adatalen)) != CRYPT_OK) {
78 goto LBL_ERR;
73 if (adata != NULL || adatalen != 0) {
74 if ((err = ocb3_add_aad(ocb, adata, adatalen)) != CRYPT_OK) {
75 goto LBL_ERR;
76 }
7977 }
8078
8179 if ((err = ocb3_decrypt_last(ocb, ct, ctlen, pt)) != CRYPT_OK) {
8886 }
8987
9088 /* compare tags */
91 if (buflen >= taglen && XMEMCMP(buf, tag, taglen) == 0) {
89 if (buflen >= taglen && XMEM_NEQ(buf, tag, taglen) == 0) {
9290 *stat = 1;
9391 }
9492
106104
107105 #endif
108106
109 /* $Source$ */
110 /* $Revision$ */
111 /* $Date$ */
107 /* ref: $Format:%D$ */
108 /* git commit: $Format:%H$ */
109 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
3331 LTC_ARGCHK(taglen != NULL);
3432 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) {
3533 goto LBL_ERR;
34 }
35
36 /* check taglen */
37 if ((int)*taglen < ocb->tag_len) {
38 *taglen = (unsigned long)ocb->tag_len;
39 return CRYPT_BUFFER_OVERFLOW;
3640 }
3741
3842 /* finalize AAD processing */
6569 /* tag = tag ^ HASH(K, A) */
6670 ocb3_int_xor_blocks(tmp, ocb->tag_part, ocb->aSum_current, ocb->block_len);
6771
68 /* fix taglen if needed */
69 if ((int)*taglen > ocb->block_len) {
70 *taglen = (unsigned long)ocb->block_len;
71 }
72
7372 /* copy tag bytes */
74 for(x=0; x<(int)*taglen; x++) tag[x] = tmp[x];
73 for(x = 0; x < ocb->tag_len; x++) tag[x] = tmp[x];
74 *taglen = (unsigned long)ocb->tag_len;
7575
7676 err = CRYPT_OK;
7777
8686
8787 #endif
8888
89 /* $Source$ */
90 /* $Revision$ */
91 /* $Date$ */
89 /* ref: $Format:%D$ */
90 /* git commit: $Format:%H$ */
91 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
3129 unsigned char *pt_b, *ct_b;
3230
3331 LTC_ARGCHK(ocb != NULL);
34 LTC_ARGCHK(pt != NULL);
35 LTC_ARGCHK(ct != NULL);
32 if (ptlen == 0) return CRYPT_OK; /* no data, nothing to do */
33 LTC_ARGCHK(pt != NULL);
34 LTC_ARGCHK(ct != NULL);
35
3636 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) {
3737 return err;
3838 }
8080
8181 #endif
8282
83 /* $Source$ */
84 /* $Revision$ */
85 /* $Date$ */
83 /* ref: $Format:%D$ */
84 /* git commit: $Format:%H$ */
85 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
4341 int err;
4442 ocb3_state *ocb;
4543
46 LTC_ARGCHK(key != NULL);
47 LTC_ARGCHK(nonce != NULL);
48 LTC_ARGCHK(pt != NULL);
49 LTC_ARGCHK(ct != NULL);
50 LTC_ARGCHK(tag != NULL);
5144 LTC_ARGCHK(taglen != NULL);
5245
5346 /* allocate memory */
5649 return CRYPT_MEM;
5750 }
5851
59 if ((err = ocb3_init(ocb, cipher, key, keylen, nonce, noncelen)) != CRYPT_OK) {
52 if ((err = ocb3_init(ocb, cipher, key, keylen, nonce, noncelen, *taglen)) != CRYPT_OK) {
6053 goto LBL_ERR;
6154 }
6255
63 if ((err = ocb3_add_aad(ocb, adata, adatalen)) != CRYPT_OK) {
64 goto LBL_ERR;
56 if (adata != NULL || adatalen != 0) {
57 if ((err = ocb3_add_aad(ocb, adata, adatalen)) != CRYPT_OK) {
58 goto LBL_ERR;
59 }
6560 }
6661
6762 if ((err = ocb3_encrypt_last(ocb, pt, ptlen, ct)) != CRYPT_OK) {
8176
8277 #endif
8378
84 /* $Source$ */
85 /* $Revision$ */
86 /* $Date$ */
79 /* ref: $Format:%D$ */
80 /* git commit: $Format:%H$ */
81 /* commit time: $Format:%ai$ */
2929 int err, x, full_blocks, full_blocks_len, last_block_len;
3030
3131 LTC_ARGCHK(ocb != NULL);
32 LTC_ARGCHK(pt != NULL);
32 if (pt == NULL) LTC_ARGCHK(ptlen == 0);
33 if (ptlen != 0) {
34 LTC_ARGCHK(pt != NULL);
35 LTC_ARGCHK(ct != NULL);
36 }
37
3338 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) {
3439 goto LBL_ERR;
3540 }
101106
102107 #endif
103108
104 /* $Source$ */
105 /* $Revision$ */
106 /* $Date$ */
109 /* ref: $Format:%D$ */
110 /* git commit: $Format:%H$ */
111 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
1614
1715 #ifdef LTC_OCB3_MODE
1816
17 static void _ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen, unsigned long taglen)
18 {
19 int x, y, bottom;
20 int idx, shift;
21 unsigned char iNonce[MAXBLOCKSIZE];
22 unsigned char iKtop[MAXBLOCKSIZE];
23 unsigned char iStretch[MAXBLOCKSIZE+8];
24
25 /* Nonce = zeros(127-bitlen(N)) || 1 || N */
26 zeromem(iNonce, sizeof(iNonce));
27 for (x = ocb->block_len-1, y=0; y<(int)noncelen; x--, y++) {
28 iNonce[x] = nonce[noncelen-y-1];
29 }
30 iNonce[x] = 0x01;
31 iNonce[0] |= ((taglen*8) % 128) << 1;
32
33 /* bottom = str2num(Nonce[123..128]) */
34 bottom = iNonce[ocb->block_len-1] & 0x3F;
35
36 /* Ktop = ENCIPHER(K, Nonce[1..122] || zeros(6)) */
37 iNonce[ocb->block_len-1] = iNonce[ocb->block_len-1] & 0xC0;
38 if ((cipher_descriptor[ocb->cipher].ecb_encrypt(iNonce, iKtop, &ocb->key)) != CRYPT_OK) {
39 zeromem(ocb->Offset_current, ocb->block_len);
40 return;
41 }
42
43 /* Stretch = Ktop || (Ktop[1..64] xor Ktop[9..72]) */
44 for (x = 0; x < ocb->block_len; x++) {
45 iStretch[x] = iKtop[x];
46 }
47 for (y = 0; y < 8; y++) {
48 iStretch[x+y] = iKtop[y] ^ iKtop[y+1];
49 }
50
51 /* Offset_0 = Stretch[1+bottom..128+bottom] */
52 idx = bottom / 8;
53 shift = (bottom % 8);
54 for (x = 0; x < ocb->block_len; x++) {
55 ocb->Offset_current[x] = iStretch[idx+x] << shift;
56 if (shift > 0) {
57 ocb->Offset_current[x] |= iStretch[idx+x+1] >> (8-shift);
58 }
59 }
60 }
61
1962 static const struct {
2063 int len;
21 unsigned char poly_div[MAXBLOCKSIZE],
22 poly_mul[MAXBLOCKSIZE];
64 unsigned char poly_mul[MAXBLOCKSIZE];
2365 } polys[] = {
2466 {
2567 8,
26 { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D },
2768 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B }
2869 }, {
2970 16,
30 { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43 },
3271 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87 }
3473 }
4180 @param key The secret key
4281 @param keylen The length of the secret key (octets)
4382 @param nonce The session nonce
44 @param noncelen The length of the session nonce (octets)
83 @param noncelen The length of the session nonce (octets, up to 15)
84 @param taglen The length of the tag (octets, up to 16)
4585 @return CRYPT_OK if successful
4686 */
4787 int ocb3_init(ocb3_state *ocb, int cipher,
4888 const unsigned char *key, unsigned long keylen,
49 const unsigned char *nonce, unsigned long noncelen)
89 const unsigned char *nonce, unsigned long noncelen,
90 unsigned long taglen)
5091 {
5192 int poly, x, y, m, err;
5293 unsigned char *previous, *current;
60101 return err;
61102 }
62103 ocb->cipher = cipher;
104
105 /* Valid Nonce?
106 * As of RFC7253: "string of no more than 120 bits" */
107 if (noncelen > (120/8)) {
108 return CRYPT_INVALID_ARG;
109 }
110
111 /* The blockcipher must have a 128-bit blocksize */
112 if (cipher_descriptor[cipher].block_length != 16) {
113 return CRYPT_INVALID_ARG;
114 }
115
116 /* The TAGLEN may be any value up to 128 (bits) */
117 if (taglen > 16) {
118 return CRYPT_INVALID_ARG;
119 }
120 ocb->tag_len = taglen;
63121
64122 /* determine which polys to use */
65123 ocb->block_len = cipher_descriptor[cipher].block_length;
113171 }
114172
115173 /* initialize ocb->Offset_current = Offset_0 */
116 ocb3_int_calc_offset_zero(ocb, nonce, noncelen);
174 _ocb3_int_calc_offset_zero(ocb, nonce, noncelen, taglen);
117175
118176 /* initialize checksum to all zeros */
119177 zeromem(ocb->checksum, ocb->block_len);
132190
133191 #endif
134192
135 /* $Source$ */
136 /* $Revision$ */
137 /* $Date$ */
193 /* ref: $Format:%D$ */
194 /* git commit: $Format:%H$ */
195 /* commit time: $Format:%ai$ */
+0
-49
src/ltc/encauth/ocb3/ocb3_int_aad_add_block.c less more
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 /**
10 @file ocb3_int_aad_add_block.c
11 OCB implementation, INTERNALL ONLY helper, by Karel Miko
12 */
13 #include "tomcrypt.h"
14
15 #ifdef LTC_OCB3_MODE
16
17 /**
18 Add one block of AAD data (internal function)
19 @param ocb The OCB state
20 @param aad_block [in] AAD data (block_len size)
21 @return CRYPT_OK if successful
22 */
23 int ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block)
24 {
25 unsigned char tmp[MAXBLOCKSIZE];
26 int err;
27
28 /* Offset_i = Offset_{i-1} xor L_{ntz(i)} */
29 ocb3_int_xor_blocks(ocb->aOffset_current, ocb->aOffset_current, ocb->L_[ocb3_int_ntz(ocb->ablock_index)], ocb->block_len);
30
31 /* Sum_i = Sum_{i-1} xor ENCIPHER(K, A_i xor Offset_i) */
32 ocb3_int_xor_blocks(tmp, aad_block, ocb->aOffset_current, ocb->block_len);
33 if ((err = cipher_descriptor[ocb->cipher].ecb_encrypt(tmp, tmp, &ocb->key)) != CRYPT_OK) {
34 return err;
35 }
36 ocb3_int_xor_blocks(ocb->aSum_current, ocb->aSum_current, tmp, ocb->block_len);
37
38 ocb->ablock_index++;
39
40 return CRYPT_OK;
41 }
42
43 #endif
44
45
46 /* $Source$ */
47 /* $Revision$ */
48 /* $Date$ */
+0
-72
src/ltc/encauth/ocb3/ocb3_int_calc_offset_zero.c less more
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 /**
10 @file ocb3_int_calc_offset_zero.c
11 OCB implementation, INTERNAL ONLY helper, by Karel Miko
12 */
13 #include "tomcrypt.h"
14
15 #ifdef LTC_OCB3_MODE
16
17 /**
18 Sets 'ocb->Offset_current' to 'Offset_0' value (internal function)
19 @param ocb The OCB state
20 @param nonce The session nonce
21 @param noncelen The length of the session nonce (octets)
22 */
23 void ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen)
24 {
25 int x, y, bottom;
26 int idx, shift;
27 unsigned char iNonce[MAXBLOCKSIZE];
28 unsigned char iKtop[MAXBLOCKSIZE];
29 unsigned char iStretch[MAXBLOCKSIZE+8];
30
31 /* Nonce = zeros(127-bitlen(N)) || 1 || N */
32 zeromem(iNonce, sizeof(iNonce));
33 for (x = ocb->block_len-1, y=0; y<(int)noncelen; x--, y++) {
34 iNonce[x] = nonce[noncelen-y-1];
35 }
36 iNonce[x] = 0x01;
37
38 /* bottom = str2num(Nonce[123..128]) */
39 bottom = iNonce[ocb->block_len-1] & 0x3F;
40
41 /* Ktop = ENCIPHER(K, Nonce[1..122] || zeros(6)) */
42 iNonce[ocb->block_len-1] = iNonce[ocb->block_len-1] & 0xC0;
43 if ((cipher_descriptor[ocb->cipher].ecb_encrypt(iNonce, iKtop, &ocb->key)) != CRYPT_OK) {
44 zeromem(ocb->Offset_current, ocb->block_len);
45 return;
46 }
47
48 /* Stretch = Ktop || (Ktop[1..64] xor Ktop[9..72]) */
49 for (x = 0; x < ocb->block_len; x++) {
50 iStretch[x] = iKtop[x];
51 }
52 for (y = 0; y < 8; y++) {
53 iStretch[x+y] = iKtop[y] ^ iKtop[y+1];
54 }
55
56 /* Offset_0 = Stretch[1+bottom..128+bottom] */
57 idx = bottom / 8;
58 shift = (bottom % 8);
59 for (x = 0; x < ocb->block_len; x++) {
60 ocb->Offset_current[x] = iStretch[idx+x] << shift;
61 if (shift > 0) {
62 ocb->Offset_current[x] |= iStretch[idx+x+1] >> (8-shift);
63 }
64 }
65 }
66
67 #endif
68
69 /* $Source$ */
70 /* $Revision$ */
71 /* $Date$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
3533
3634 #endif
3735
38 /* $Source$ */
39 /* $Revision$ */
40 /* $Date$ */
36 /* ref: $Format:%D$ */
37 /* git commit: $Format:%H$ */
38 /* commit time: $Format:%ai$ */
3434
3535 #endif
3636
37 /* $Source$ */
38 /* $Revision$ */
39 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
341341 unsigned long fill = BLAKE2B_BLOCKBYTES - left;
342342 if (inlen > fill) {
343343 md->blake2b.curlen = 0;
344 XMEMCPY(md->blake2b.buf + left, in, fill); /* Fill buffer */
344 XMEMCPY(md->blake2b.buf + (left % sizeof(md->blake2b.buf)), in, fill); /* Fill buffer */
345345 blake2b_increment_counter(md, BLAKE2B_BLOCKBYTES);
346346 blake2b_compress(md, md->blake2b.buf); /* Compress */
347347 in += fill;
398398 return CRYPT_NOP;
399399 #else
400400 static const struct {
401 char *msg;
401 const char *msg;
402402 unsigned char hash[64];
403403 } tests[] = {
404404 { "",
431431 blake2b_512_init(&md);
432432 blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
433433 blake2b_done(&md, tmp);
434 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_512", i))
434 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_512", i)) {
435435 return CRYPT_FAIL_TESTVECTOR;
436 }
436437 }
437438 return CRYPT_OK;
438439 #endif
448449 return CRYPT_NOP;
449450 #else
450451 static const struct {
451 char *msg;
452 const char *msg;
452453 unsigned char hash[48];
453454 } tests[] = {
454455 { "",
477478 blake2b_384_init(&md);
478479 blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
479480 blake2b_done(&md, tmp);
480 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_384", i))
481 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_384", i)) {
481482 return CRYPT_FAIL_TESTVECTOR;
483 }
482484 }
483485 return CRYPT_OK;
484486 #endif
494496 return CRYPT_NOP;
495497 #else
496498 static const struct {
497 char *msg;
499 const char *msg;
498500 unsigned char hash[32];
499501 } tests[] = {
500502 { "",
529531 blake2b_256_init(&md);
530532 blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
531533 blake2b_done(&md, tmp);
532 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_256", i))
534 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_256", i)) {
533535 return CRYPT_FAIL_TESTVECTOR;
536 }
534537 }
535538 return CRYPT_OK;
536539 #endif
546549 return CRYPT_NOP;
547550 #else
548551 static const struct {
549 char *msg;
552 const char *msg;
550553 unsigned char hash[20];
551554 } tests[] = {
552555 { "",
569572 blake2b_160_init(&md);
570573 blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
571574 blake2b_done(&md, tmp);
572 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_160", i))
575 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_160", i)) {
573576 return CRYPT_FAIL_TESTVECTOR;
574 }
575 return CRYPT_OK;
576 #endif
577 }
578
579 #endif
577 }
578 }
579 return CRYPT_OK;
580 #endif
581 }
582
583 #endif
584
585 /* ref: $Format:%D$ */
586 /* git commit: $Format:%H$ */
587 /* commit time: $Format:%ai$ */
329329 unsigned long fill = BLAKE2S_BLOCKBYTES - left;
330330 if (inlen > fill) {
331331 md->blake2s.curlen = 0;
332 XMEMCPY(md->blake2s.buf + left, in, fill); /* Fill buffer */
332 XMEMCPY(md->blake2s.buf + (left % sizeof(md->blake2s.buf)), in, fill); /* Fill buffer */
333333 blake2s_increment_counter(md, BLAKE2S_BLOCKBYTES);
334334 blake2s_compress(md, md->blake2s.buf); /* Compress */
335335 in += fill;
386386 return CRYPT_NOP;
387387 #else
388388 static const struct {
389 char *msg;
389 const char *msg;
390390 unsigned char hash[32];
391391 } tests[] = {
392392 { "",
421421 blake2s_256_init(&md);
422422 blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
423423 blake2s_done(&md, tmp);
424 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_256", i))
424 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_256", i)) {
425425 return CRYPT_FAIL_TESTVECTOR;
426 }
426427
427428 }
428429 return CRYPT_OK;
439440 return CRYPT_NOP;
440441 #else
441442 static const struct {
442 char *msg;
443 const char *msg;
443444 unsigned char hash[28];
444445 } tests[] = {
445446 { "",
464465 blake2s_224_init(&md);
465466 blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
466467 blake2s_done(&md, tmp);
467 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_224", i))
468 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_224", i)) {
468469 return CRYPT_FAIL_TESTVECTOR;
470 }
469471
470472 }
471473 return CRYPT_OK;
482484 return CRYPT_NOP;
483485 #else
484486 static const struct {
485 char *msg;
487 const char *msg;
486488 unsigned char hash[20];
487489 } tests[] = {
488490 { "",
505507 blake2s_160_init(&md);
506508 blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
507509 blake2s_done(&md, tmp);
508 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_160", i))
510 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_160", i)) {
509511 return CRYPT_FAIL_TESTVECTOR;
512 }
510513
511514 }
512515 return CRYPT_OK;
523526 return CRYPT_NOP;
524527 #else
525528 static const struct {
526 char *msg;
529 const char *msg;
527530 unsigned char hash[16];
528531 } tests[] = {
529532 { "",
544547 blake2s_128_init(&md);
545548 blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
546549 blake2s_done(&md, tmp);
547 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_128", i))
550 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_128", i)) {
548551 return CRYPT_FAIL_TESTVECTOR;
549 }
550 return CRYPT_OK;
551 #endif
552 }
553
554 #endif
552 }
553 }
554 return CRYPT_OK;
555 #endif
556 }
557
558 #endif
559
560 /* ref: $Format:%D$ */
561 /* git commit: $Format:%H$ */
562 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 #include "tomcrypt.h"
154152 return CRYPT_OK;
155153 }
156154
157 /* function for processing blocks */
155 /**
156 Function for processing blocks
157 @param md The hash state
158 @param buf The data to hash
159 @param len The length of the data (octets)
160 @return CRYPT_OK if successful
161 */
158162 static int _chc_process(hash_state * md, const unsigned char *buf, unsigned long len);
159163 static HASH_PROCESS(_chc_process, chc_compress, chc, (unsigned long)cipher_blocksize)
160164
255259 #else
256260 static const struct {
257261 unsigned char *msg,
258 md[MAXBLOCKSIZE];
262 hash[MAXBLOCKSIZE];
259263 int len;
260264 } tests[] = {
261265 {
265269 16
266270 }
267271 };
268 int x, oldhashidx, idx;
269 unsigned char out[MAXBLOCKSIZE];
272 int i, oldhashidx, idx;
273 unsigned char tmp[MAXBLOCKSIZE];
270274 hash_state md;
271275
272276 /* AES can be under rijndael or aes... try to find it */
278282 oldhashidx = cipher_idx;
279283 chc_register(idx);
280284
281 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
285 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
282286 chc_init(&md);
283 chc_process(&md, tests[x].msg, strlen((char *)tests[x].msg));
284 chc_done(&md, out);
285 if (XMEMCMP(out, tests[x].md, tests[x].len)) {
287 chc_process(&md, tests[i].msg, strlen((char *)tests[i].msg));
288 chc_done(&md, tmp);
289 if (compare_testvector(tmp, tests[i].len, tests[i].hash, tests[i].len, "CHC", i)) {
286290 return CRYPT_FAIL_TESTVECTOR;
287291 }
288292 }
296300
297301 #endif
298302
299 /* $Source$ */
300 /* $Revision$ */
301 /* $Date$ */
303 /* ref: $Format:%D$ */
304 /* git commit: $Format:%H$ */
305 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4947 #endif /* #ifndef LTC_NO_FILE */
5048
5149
52 /* $Source$ */
53 /* $Revision$ */
54 /* $Date$ */
50 /* ref: $Format:%D$ */
51 /* git commit: $Format:%H$ */
52 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5149 goto LBL_ERR;
5250 }
5351
54 *outlen = hash_descriptor[hash].hashsize;
5552 do {
5653 x = fread(buf, 1, LTC_FILE_READ_BUFSIZE, in);
5754 if ((err = hash_descriptor[hash].process(&md, buf, (unsigned long)x)) != CRYPT_OK) {
5855 goto LBL_CLEANBUF;
5956 }
6057 } while (x == LTC_FILE_READ_BUFSIZE);
61 err = hash_descriptor[hash].done(&md, out);
58 if ((err = hash_descriptor[hash].done(&md, out)) == CRYPT_OK) {
59 *outlen = hash_descriptor[hash].hashsize;
60 }
6261
6362 LBL_CLEANBUF:
6463 zeromem(buf, LTC_FILE_READ_BUFSIZE);
6968 #endif /* #ifndef LTC_NO_FILE */
7069
7170
72 /* $Source$ */
73 /* $Revision$ */
74 /* $Date$ */
71 /* ref: $Format:%D$ */
72 /* git commit: $Format:%H$ */
73 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6563 }
6664 #endif /* #ifdef LTC_HASH_HELPERS */
6765
68 /* $Source$ */
69 /* $Revision$ */
70 /* $Date$ */
66 /* ref: $Format:%D$ */
67 /* git commit: $Format:%H$ */
68 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
8482 }
8583 #endif /* #ifdef LTC_HASH_HELPERS */
8684
87 /* $Source$ */
88 /* $Revision$ */
89 /* $Date$ */
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
192190 return CRYPT_NOP;
193191 #else
194192 static const struct {
195 char *msg;
196 unsigned char md[16];
193 const char *msg;
194 unsigned char hash[16];
197195 } tests[] = {
198196 { "",
199197 {0x83,0x50,0xe5,0xa3,0xe2,0x4c,0x15,0x3d,
226224 }
227225 }
228226 };
227
229228 int i;
229 unsigned char tmp[16];
230230 hash_state md;
231 unsigned char buf[16];
232231
233232 for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
234233 md2_init(&md);
235234 md2_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
236 md2_done(&md, buf);
237 if (XMEMCMP(buf, tests[i].md, 16) != 0) {
235 md2_done(&md, tmp);
236 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD2", i)) {
238237 return CRYPT_FAIL_TESTVECTOR;
239238 }
240239 }
245244 #endif
246245
247246
248 /* $Source$ */
249 /* $Revision$ */
250 /* $Date$ */
247 /* ref: $Format:%D$ */
248 /* git commit: $Format:%H$ */
249 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
255253 return CRYPT_NOP;
256254 #else
257255 static const struct md4_test_case {
258 char *input;
259 unsigned char digest[16];
260 } cases[] = {
256 const char *input;
257 unsigned char hash[16];
258 } tests[] = {
261259 { "",
262260 {0x31, 0xd6, 0xcf, 0xe0, 0xd1, 0x6a, 0xe9, 0x31,
263261 0xb7, 0x3c, 0x59, 0xd7, 0xe0, 0xc0, 0x89, 0xc0} },
280278 {0xe3, 0x3b, 0x4d, 0xdc, 0x9c, 0x38, 0xf2, 0x19,
281279 0x9c, 0x3e, 0x7b, 0x16, 0x4f, 0xcc, 0x05, 0x36} },
282280 };
281
283282 int i;
283 unsigned char tmp[16];
284284 hash_state md;
285 unsigned char digest[16];
286
287 for(i = 0; i < (int)(sizeof(cases) / sizeof(cases[0])); i++) {
285
286 for(i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
288287 md4_init(&md);
289 md4_process(&md, (unsigned char *)cases[i].input, (unsigned long)strlen(cases[i].input));
290 md4_done(&md, digest);
291 if (XMEMCMP(digest, cases[i].digest, 16) != 0) {
288 md4_process(&md, (unsigned char *)tests[i].input, (unsigned long)strlen(tests[i].input));
289 md4_done(&md, tmp);
290 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD4", i)) {
292291 return CRYPT_FAIL_TESTVECTOR;
293292 }
294293
301300
302301
303302
304 /* $Source$ */
305 /* $Revision$ */
306 /* $Date$ */
303 /* ref: $Format:%D$ */
304 /* git commit: $Format:%H$ */
305 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
315313 return CRYPT_NOP;
316314 #else
317315 static const struct {
318 char *msg;
316 const char *msg;
319317 unsigned char hash[16];
320318 } tests[] = {
321319 { "",
350348 md5_init(&md);
351349 md5_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
352350 md5_done(&md, tmp);
353 if (XMEMCMP(tmp, tests[i].hash, 16) != 0) {
351 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD5", i)) {
354352 return CRYPT_FAIL_TESTVECTOR;
355353 }
356354 }
362360
363361
364362
365 /* $Source$ */
366 /* $Revision$ */
367 /* $Date$ */
363 /* ref: $Format:%D$ */
364 /* git commit: $Format:%H$ */
365 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
354352 return CRYPT_NOP;
355353 #else
356354 static const struct {
357 char *msg;
358 unsigned char md[16];
355 const char *msg;
356 unsigned char hash[16];
359357 } tests[] = {
360358 { "",
361359 { 0xcd, 0xf2, 0x62, 0x13, 0xa1, 0x50, 0xdc, 0x3e,
382380 0xae, 0xa4, 0x62, 0x4c, 0x60, 0xc5, 0xc7, 0x02 }
383381 }
384382 };
385 int x;
386 unsigned char buf[16];
383
384 int i;
385 unsigned char tmp[16];
387386 hash_state md;
388387
389 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
388 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
390389 rmd128_init(&md);
391 rmd128_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg));
392 rmd128_done(&md, buf);
393 if (XMEMCMP(buf, tests[x].md, 16) != 0) {
394 #if 0
395 printf("Failed test %d\n", x);
396 #endif
390 rmd128_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
391 rmd128_done(&md, tmp);
392 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD128", i)) {
397393 return CRYPT_FAIL_TESTVECTOR;
398394 }
399395 }
404400 #endif
405401
406402
407 /* $Source$ */
408 /* $Revision$ */
409 /* $Date$ */
403 /* ref: $Format:%D$ */
404 /* git commit: $Format:%H$ */
405 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
413411 return CRYPT_NOP;
414412 #else
415413 static const struct {
416 char *msg;
417 unsigned char md[20];
414 const char *msg;
415 unsigned char hash[20];
418416 } tests[] = {
419417 { "",
420418 { 0x9c, 0x11, 0x85, 0xa5, 0xc5, 0xe9, 0xfc, 0x54, 0x61, 0x28,
441439 0xa0, 0x6c, 0x27, 0xdc, 0xf4, 0x9a, 0xda, 0x62, 0xeb, 0x2b }
442440 }
443441 };
444 int x;
445 unsigned char buf[20];
442
443 int i;
444 unsigned char tmp[20];
446445 hash_state md;
447446
448 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
447 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
449448 rmd160_init(&md);
450 rmd160_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg));
451 rmd160_done(&md, buf);
452 if (XMEMCMP(buf, tests[x].md, 20) != 0) {
453 #if 0
454 printf("Failed test %d\n", x);
455 #endif
449 rmd160_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
450 rmd160_done(&md, tmp);
451 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD160", i)) {
456452 return CRYPT_FAIL_TESTVECTOR;
457453 }
458454 }
463459 #endif
464460
465461
466 /* $Source$ */
467 /* $Revision$ */
468 /* $Date$ */
462 /* ref: $Format:%D$ */
463 /* git commit: $Format:%H$ */
464 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
367365 return CRYPT_NOP;
368366 #else
369367 static const struct {
370 char *msg;
371 unsigned char md[32];
368 const char *msg;
369 unsigned char hash[32];
372370 } tests[] = {
373371 { "",
374372 { 0x02, 0xba, 0x4c, 0x4e, 0x5f, 0x8e, 0xcd, 0x18,
407405 0xa8, 0x9f, 0x7e, 0xa6, 0xde, 0x77, 0xa0, 0xb8 }
408406 }
409407 };
410 int x;
411 unsigned char buf[32];
408
409 int i;
410 unsigned char tmp[32];
412411 hash_state md;
413412
414 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
413 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
415414 rmd256_init(&md);
416 rmd256_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg));
417 rmd256_done(&md, buf);
418 if (XMEMCMP(buf, tests[x].md, 32) != 0) {
419 #if 0
420 printf("Failed test %d\n", x);
421 #endif
415 rmd256_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
416 rmd256_done(&md, tmp);
417 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD256", i)) {
422418 return CRYPT_FAIL_TESTVECTOR;
423419 }
424420 }
428424
429425 #endif
430426
427 /* ref: $Format:%D$ */
428 /* git commit: $Format:%H$ */
429 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
432430 return CRYPT_NOP;
433431 #else
434432 static const struct {
435 char *msg;
436 unsigned char md[40];
433 const char *msg;
434 unsigned char hash[40];
437435 } tests[] = {
438436 { "",
439437 { 0x22, 0xd6, 0x5d, 0x56, 0x61, 0x53, 0x6c, 0xdc, 0x75, 0xc1,
472470 0xbc, 0x74, 0x70, 0xa9, 0x69, 0xc9, 0xd0, 0x72, 0xa1, 0xac }
473471 }
474472 };
475 int x;
476 unsigned char buf[40];
473
474 int i;
475 unsigned char tmp[40];
477476 hash_state md;
478477
479 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
478 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
480479 rmd320_init(&md);
481 rmd320_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg));
482 rmd320_done(&md, buf);
483 if (XMEMCMP(buf, tests[x].md, 40) != 0) {
484 #if 0
485 printf("Failed test %d\n", x);
486 #endif
480 rmd320_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
481 rmd320_done(&md, tmp);
482 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD320", i)) {
487483 return CRYPT_FAIL_TESTVECTOR;
488484 }
489485 }
493489
494490 #endif
495491
492 /* ref: $Format:%D$ */
493 /* git commit: $Format:%H$ */
494 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
247245 return CRYPT_NOP;
248246 #else
249247 static const struct {
250 char *msg;
248 const char *msg;
251249 unsigned char hash[20];
252250 } tests[] = {
253251 { "abc",
270268 sha1_init(&md);
271269 sha1_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
272270 sha1_done(&md, tmp);
273 if (XMEMCMP(tmp, tests[i].hash, 20) != 0) {
271 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA1", i)) {
274272 return CRYPT_FAIL_TESTVECTOR;
275273 }
276274 }
282280
283281
284282
285 /* $Source$ */
286 /* $Revision$ */
287 /* $Date$ */
283 /* ref: $Format:%D$ */
284 /* git commit: $Format:%H$ */
285 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @param sha224.c
8987 return CRYPT_NOP;
9088 #else
9189 static const struct {
92 char *msg;
90 const char *msg;
9391 unsigned char hash[28];
9492 } tests[] = {
9593 { "abc",
114112 sha224_init(&md);
115113 sha224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
116114 sha224_done(&md, tmp);
117 if (XMEMCMP(tmp, tests[i].hash, 28) != 0) {
115 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA224", i)) {
118116 return CRYPT_FAIL_TESTVECTOR;
119117 }
120118 }
125123 #endif /* defined(LTC_SHA224) && defined(LTC_SHA256) */
126124
127125
128 /* $Source$ */
129 /* $Revision$ */
130 /* $Date$ */
126 /* ref: $Format:%D$ */
127 /* git commit: $Format:%H$ */
128 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
293291 return CRYPT_NOP;
294292 #else
295293 static const struct {
296 char *msg;
294 const char *msg;
297295 unsigned char hash[32];
298296 } tests[] = {
299297 { "abc",
318316 sha256_init(&md);
319317 sha256_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
320318 sha256_done(&md, tmp);
321 if (XMEMCMP(tmp, tests[i].hash, 32) != 0) {
319 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA256", i)) {
322320 return CRYPT_FAIL_TESTVECTOR;
323321 }
324322 }
330328
331329
332330
333 /* $Source$ */
334 /* $Revision$ */
335 /* $Date$ */
331 /* ref: $Format:%D$ */
332 /* git commit: $Format:%H$ */
333 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @param sha384.c
9189 return CRYPT_NOP;
9290 #else
9391 static const struct {
94 char *msg;
92 const char *msg;
9593 unsigned char hash[48];
9694 } tests[] = {
9795 { "abc",
120118 sha384_init(&md);
121119 sha384_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
122120 sha384_done(&md, tmp);
123 if (XMEMCMP(tmp, tests[i].hash, 48) != 0) {
121 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA384", i)) {
124122 return CRYPT_FAIL_TESTVECTOR;
125123 }
126124 }
130128
131129 #endif /* defined(LTC_SHA384) && defined(LTC_SHA512) */
132130
133 /* $Source$ */
134 /* $Revision$ */
135 /* $Date$ */
131 /* ref: $Format:%D$ */
132 /* git commit: $Format:%H$ */
133 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
263261 return CRYPT_NOP;
264262 #else
265263 static const struct {
266 char *msg;
264 const char *msg;
267265 unsigned char hash[64];
268266 } tests[] = {
269267 { "abc",
296294 sha512_init(&md);
297295 sha512_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
298296 sha512_done(&md, tmp);
299 if (XMEMCMP(tmp, tests[i].hash, 64) != 0) {
297 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512", i)) {
300298 return CRYPT_FAIL_TESTVECTOR;
301299 }
302300 }
309307
310308
311309
312 /* $Source$ */
313 /* $Revision$ */
314 /* $Date$ */
310 /* ref: $Format:%D$ */
311 /* git commit: $Format:%H$ */
312 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @param sha512_224.c
9189 return CRYPT_NOP;
9290 #else
9391 static const struct {
94 char *msg;
92 const char *msg;
9593 unsigned char hash[28];
9694 } tests[] = {
9795 { "abc",
116114 sha512_224_init(&md);
117115 sha512_224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
118116 sha512_224_done(&md, tmp);
119 if (XMEMCMP(tmp, tests[i].hash, 28) != 0) {
117 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-224", i)) {
120118 return CRYPT_FAIL_TESTVECTOR;
121119 }
122120 }
126124
127125 #endif /* defined(LTC_SHA384) && defined(LTC_SHA512) */
128126
129 /* $Source$ */
130 /* $Revision$ */
131 /* $Date$ */
127 /* ref: $Format:%D$ */
128 /* git commit: $Format:%H$ */
129 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 /**
119 @param sha512_256.c
9189 return CRYPT_NOP;
9290 #else
9391 static const struct {
94 char *msg;
92 const char *msg;
9593 unsigned char hash[32];
9694 } tests[] = {
9795 { "abc",
116114 sha512_256_init(&md);
117115 sha512_256_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
118116 sha512_256_done(&md, tmp);
119 if (XMEMCMP(tmp, tests[i].hash, 32) != 0) {
117 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-265", i)) {
120118 return CRYPT_FAIL_TESTVECTOR;
121119 }
122120 }
126124
127125 #endif /* defined(LTC_SHA384) && defined(LTC_SHA512) */
128126
129 /* $Source$ */
130 /* $Revision$ */
131 /* $Date$ */
127 /* ref: $Format:%D$ */
128 /* git commit: $Format:%H$ */
129 /* commit time: $Format:%ai$ */
240240 keccakf(md->sha3.s);
241241
242242 /* store sha3.s[] as little-endian bytes into sha3.sb */
243 for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) STORE64L(md->sha3.s[i], md->sha3.sb + i * 8);
243 for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) {
244 STORE64L(md->sha3.s[i], md->sha3.sb + i * 8);
245 }
244246
245247 XMEMCPY(hash, md->sha3.sb, md->sha3.capacity_words * 4);
246248 return CRYPT_OK;
262264 md->sha3.s[SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words - 1] ^= CONST64(0x8000000000000000);
263265 keccakf(md->sha3.s);
264266 /* store sha3.s[] as little-endian bytes into sha3.sb */
265 for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) STORE64L(md->sha3.s[i], md->sha3.sb + i * 8);
267 for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) {
268 STORE64L(md->sha3.s[i], md->sha3.sb + i * 8);
269 }
266270 md->sha3.byte_index = 0;
267271 md->sha3.xof_flag = 1;
268272 }
271275 if(md->sha3.byte_index >= (SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words) * 8) {
272276 keccakf(md->sha3.s);
273277 /* store sha3.s[] as little-endian bytes into sha3.sb */
274 for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) STORE64L(md->sha3.s[i], md->sha3.sb + i * 8);
278 for(i = 0; i < SHA3_KECCAK_SPONGE_WORDS; i++) {
279 STORE64L(md->sha3.s[i], md->sha3.sb + i * 8);
280 }
275281 md->sha3.byte_index = 0;
276282 }
277283 out[idx] = md->sha3.sb[md->sha3.byte_index++];
293299 }
294300
295301 #endif
302
303 /* ref: $Format:%D$ */
304 /* git commit: $Format:%H$ */
305 /* commit time: $Format:%ai$ */
1717 #ifndef LTC_TEST
1818 return CRYPT_NOP;
1919 #else
20 unsigned char buf[200], hash[200];
20 unsigned char buf[200], hash[224 / 8];
2121 int i;
2222 hash_state c;
2323 const unsigned char c1 = 0xa3;
4141 /* SHA3-224 on an empty buffer */
4242 sha3_224_init(&c);
4343 sha3_done(&c, hash);
44 if(XMEMCMP(sha3_224_empty, hash, sizeof(sha3_224_empty)) != 0) {
45 printf("SHA3-224() failed\n");
44 if (compare_testvector(hash, sizeof(hash), sha3_224_empty, sizeof(sha3_224_empty), "SHA3-224", 0)) {
4645 return CRYPT_FAIL_TESTVECTOR;
4746 }
4847
5150 sha3_process(&c, buf, sizeof(buf) / 2);
5251 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
5352 sha3_done(&c, hash);
54 if(XMEMCMP(sha3_224_0xa3_200_times, hash, sizeof(sha3_224_0xa3_200_times)) != 0) {
55 printf("SHA3-224( 0xa3 ... [200 times] ) failed (2 steps)\n");
53 if (compare_testvector(hash, sizeof(hash), sha3_224_0xa3_200_times, sizeof(sha3_224_0xa3_200_times), "SHA3-224", 1)) {
5654 return CRYPT_FAIL_TESTVECTOR;
5755 }
5856
6361 sha3_process(&c, &c1, 1);
6462 }
6563 sha3_done(&c, hash);
66 if(XMEMCMP(sha3_224_0xa3_200_times, hash, sizeof(sha3_224_0xa3_200_times)) != 0) {
67 printf("SHA3-224( 0xa3 ... [200 times] ) failed (200 steps)\n");
64 if (compare_testvector(hash, sizeof(hash), sha3_224_0xa3_200_times, sizeof(sha3_224_0xa3_200_times), "SHA3-224", 2)) {
6865 return CRYPT_FAIL_TESTVECTOR;
6966 }
7067
7774 #ifndef LTC_TEST
7875 return CRYPT_NOP;
7976 #else
80 unsigned char buf[200], hash[200];
77 unsigned char buf[200], hash[256 / 8];
8178 int i;
8279 hash_state c;
8380 const unsigned char c1 = 0xa3;
10097 /* SHA3-256 on an empty buffer */
10198 sha3_256_init(&c);
10299 sha3_done(&c, hash);
103 if(XMEMCMP(sha3_256_empty, hash, sizeof(sha3_256_empty)) != 0) {
104 printf("SHA3-256() failed\n");
100 if (compare_testvector(hash, sizeof(hash), sha3_256_empty, sizeof(sha3_256_empty), "SHA3-256", 0)) {
105101 return CRYPT_FAIL_TESTVECTOR;
106102 }
107103
109105 sha3_256_init(&c);
110106 sha3_process(&c, buf, sizeof(buf));
111107 sha3_done(&c, hash);
112 if(XMEMCMP(sha3_256_0xa3_200_times, hash, sizeof(sha3_256_0xa3_200_times)) != 0) {
113 printf("SHA3-256( 0xa3 ... [200 times] ) failed (1 buffer)\n");
108 if (compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 1)) {
114109 return CRYPT_FAIL_TESTVECTOR;
115110 }
116111
119114 sha3_process(&c, buf, sizeof(buf) / 2);
120115 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
121116 sha3_done(&c, hash);
122 if(XMEMCMP(sha3_256_0xa3_200_times, hash, sizeof(sha3_256_0xa3_200_times)) != 0) {
123 printf("SHA3-256( 0xa3 ... [200 times] ) failed (2 steps)\n");
117 if (compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 2)) {
124118 return CRYPT_FAIL_TESTVECTOR;
125119 }
126120
131125 sha3_process(&c, &c1, 1);
132126 }
133127 sha3_done(&c, hash);
134 if(XMEMCMP(sha3_256_0xa3_200_times, hash, sizeof(sha3_256_0xa3_200_times)) != 0) {
135 printf("SHA3-256( 0xa3 ... [200 times] ) failed (200 steps)\n");
128 if (compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 3)) {
136129 return CRYPT_FAIL_TESTVECTOR;
137130 }
138131
158151 "\x76\x3d\x52\xdb\x98\xd9\x49\xd3"
159152 "\xb0\xfe\xd6\xa8\x05\x2f\xbb", 1080 / 8);
160153 sha3_done(&c, hash);
161 if(XMEMCMP(hash, "\xa1\x9e\xee\x92\xbb\x20\x97\xb6"
162 "\x4e\x82\x3d\x59\x77\x98\xaa\x18"
163 "\xbe\x9b\x7c\x73\x6b\x80\x59\xab"
164 "\xfd\x67\x79\xac\x35\xac\x81\xb5", 256 / 8) != 0) {
165 printf("SHA3-256( b771 ... ) doesn't match the known answer\n");
154 if(compare_testvector(hash, sizeof(hash),
155 "\xa1\x9e\xee\x92\xbb\x20\x97\xb6"
156 "\x4e\x82\x3d\x59\x77\x98\xaa\x18"
157 "\xbe\x9b\x7c\x73\x6b\x80\x59\xab"
158 "\xfd\x67\x79\xac\x35\xac\x81\xb5", 256 / 8, "SHA3-256", 4)) {
166159 return CRYPT_FAIL_TESTVECTOR;
167160 }
168161
175168 #ifndef LTC_TEST
176169 return CRYPT_NOP;
177170 #else
178 unsigned char buf[200], hash[200];
171 unsigned char buf[200], hash[384 / 8];
179172 int i;
180173 hash_state c;
181174 const unsigned char c1 = 0xa3;
195188 sha3_384_init(&c);
196189 sha3_process(&c, buf, sizeof(buf));
197190 sha3_done(&c, hash);
198 if(XMEMCMP(sha3_384_0xa3_200_times, hash, sizeof(sha3_384_0xa3_200_times)) != 0) {
199 printf("SHA3-384( 0xa3 ... [200 times] ) failed (1 buffer)\n");
191 if (compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 0)) {
200192 return CRYPT_FAIL_TESTVECTOR;
201193 }
202194
205197 sha3_process(&c, buf, sizeof(buf) / 2);
206198 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
207199 sha3_done(&c, hash);
208 if(XMEMCMP(sha3_384_0xa3_200_times, hash, sizeof(sha3_384_0xa3_200_times)) != 0) {
209 printf("SHA3-384( 0xa3 ... [200 times] ) failed (2 steps)\n");
200 if (compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 1)) {
210201 return CRYPT_FAIL_TESTVECTOR;
211202 }
212203
217208 sha3_process(&c, &c1, 1);
218209 }
219210 sha3_done(&c, hash);
220 if(XMEMCMP(sha3_384_0xa3_200_times, hash, sizeof(sha3_384_0xa3_200_times)) != 0) {
221 printf("SHA3-384( 0xa3 ... [200 times] ) failed (200 steps)\n");
211 if (compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 2)) {
222212 return CRYPT_FAIL_TESTVECTOR;
223213 }
224214
231221 #ifndef LTC_TEST
232222 return CRYPT_NOP;
233223 #else
234 unsigned char buf[200], hash[200];
224 unsigned char buf[200], hash[512 / 8];
235225 int i;
236226 hash_state c;
237227 const unsigned char c1 = 0xa3;
253243 sha3_512_init(&c);
254244 sha3_process(&c, buf, sizeof(buf));
255245 sha3_done(&c, hash);
256 if(XMEMCMP(sha3_512_0xa3_200_times, hash, sizeof(sha3_512_0xa3_200_times)) != 0) {
257 printf("SHA3-512( 0xa3 ... [200 times] ) failed (1 buffer)\n");
246 if (compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 0)) {
258247 return CRYPT_FAIL_TESTVECTOR;
259248 }
260249
263252 sha3_process(&c, buf, sizeof(buf) / 2);
264253 sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
265254 sha3_done(&c, hash);
266 if(XMEMCMP(sha3_512_0xa3_200_times, hash, sizeof(sha3_512_0xa3_200_times)) != 0) {
267 printf("SHA3-512( 0xa3 ... [200 times] ) failed (2 steps)\n");
255 if (compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 1)) {
268256 return CRYPT_FAIL_TESTVECTOR;
269257 }
270258
275263 sha3_process(&c, &c1, 1);
276264 }
277265 sha3_done(&c, hash);
278 if(XMEMCMP(sha3_512_0xa3_200_times, hash, sizeof(sha3_512_0xa3_200_times)) != 0) {
279 printf("SHA3-512( 0xa3 ... [200 times] ) failed (200 steps)\n");
266 if (compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 2)) {
280267 return CRYPT_FAIL_TESTVECTOR;
281268 }
282269
325312 /* SHAKE256 on an empty buffer */
326313 sha3_shake_init(&c, 256);
327314 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
328 if(XMEMCMP(shake256_empty, hash, sizeof(shake256_empty)) != 0) {
329 printf("SHAKE256('') failed\n");
315 if (compare_testvector(hash, sizeof(shake256_empty), shake256_empty, sizeof(shake256_empty), "SHAKE256", 0)) {
330316 return CRYPT_FAIL_TESTVECTOR;
331317 }
332318
333319 /* SHAKE256 via sha3_shake_memory [FIPS 202] */
334320 len = 512;
335321 sha3_shake_memory(256, buf, sizeof(buf), hash, &len);
336 if(XMEMCMP(shake256_0xa3_200_times, hash + 480, sizeof(shake256_0xa3_200_times)) != 0) {
337 printf("SHAKE256( 0xa3 ... [200 times] ) failed (sha3_shake_memory)\n");
322 if (compare_testvector(hash + 480, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 1)) {
338323 return CRYPT_FAIL_TESTVECTOR;
339324 }
340325
342327 sha3_shake_init(&c, 256);
343328 sha3_shake_process(&c, buf, sizeof(buf));
344329 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
345 if(XMEMCMP(shake256_0xa3_200_times, hash, sizeof(shake256_0xa3_200_times)) != 0) {
346 printf("SHAKE256( 0xa3 ... [200 times] ) failed (1 buffer)\n");
330 if (compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 2)) {
347331 return CRYPT_FAIL_TESTVECTOR;
348332 }
349333
352336 sha3_shake_process(&c, buf, sizeof(buf) / 2);
353337 sha3_shake_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
354338 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
355 if(XMEMCMP(shake256_0xa3_200_times, hash, sizeof(shake256_0xa3_200_times)) != 0) {
356 printf("SHAKE256( 0xa3 ... [200 times] ) failed (2 steps)\n");
339 if (compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 3)) {
357340 return CRYPT_FAIL_TESTVECTOR;
358341 }
359342
362345 sha3_shake_init(&c, 256);
363346 while (i--) sha3_shake_process(&c, &c1, 1);
364347 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
365 if(XMEMCMP(shake256_0xa3_200_times, hash, sizeof(shake256_0xa3_200_times)) != 0) {
366 printf("SHAKE256( 0xa3 ... [200 times] ) failed (200 steps)\n");
348 if (compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 4)) {
367349 return CRYPT_FAIL_TESTVECTOR;
368350 }
369351
370352 /* SHAKE128 on an empty buffer */
371353 sha3_shake_init(&c, 128);
372354 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
373 if(XMEMCMP(shake128_empty, hash, sizeof(shake128_empty)) != 0) {
374 printf("SHAKE128() failed\n");
355 if (compare_testvector(hash, sizeof(shake128_empty), shake128_empty, sizeof(shake128_empty), "SHAKE128", 0)) {
375356 return CRYPT_FAIL_TESTVECTOR;
376357 }
377358
378359 /* SHAKE128 via sha3_shake_memory [FIPS 202] */
379360 len = 512;
380361 sha3_shake_memory(128, buf, sizeof(buf), hash, &len);
381 if(XMEMCMP(shake128_0xa3_200_times, hash + 480, sizeof(shake128_0xa3_200_times)) != 0) {
382 printf("SHAKE128( 0xa3 ... [200 times] ) failed (sha3_shake_memory)\n");
362 if (compare_testvector(hash + 480, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 1)) {
383363 return CRYPT_FAIL_TESTVECTOR;
384364 }
385365
387367 sha3_shake_init(&c, 128);
388368 sha3_shake_process(&c, buf, sizeof(buf));
389369 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
390 if(XMEMCMP(shake128_0xa3_200_times, hash, sizeof(shake128_0xa3_200_times)) != 0) {
391 printf("SHAKE128( 0xa3 ... [200 times] ) failed (1 buffer)\n");
370 if (compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 2)) {
392371 return CRYPT_FAIL_TESTVECTOR;
393372 }
394373
397376 sha3_shake_process(&c, buf, sizeof(buf) / 2);
398377 sha3_shake_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
399378 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
400 if(XMEMCMP(shake128_0xa3_200_times, hash, sizeof(shake128_0xa3_200_times)) != 0) {
401 printf("SHAKE128( 0xa3 ... [200 times] ) failed (2 steps)\n");
379 if (compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 3)) {
402380 return CRYPT_FAIL_TESTVECTOR;
403381 }
404382
407385 sha3_shake_init(&c, 128);
408386 while (i--) sha3_shake_process(&c, &c1, 1);
409387 for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
410 if(XMEMCMP(shake128_0xa3_200_times, hash, sizeof(shake128_0xa3_200_times)) != 0) {
411 printf("SHAKE128( 0xa3 ... [200 times] ) failed (200 steps)\n");
388 if (compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 4)) {
412389 return CRYPT_FAIL_TESTVECTOR;
413390 }
414391
417394 }
418395
419396 #endif
397
398 /* ref: $Format:%D$ */
399 /* git commit: $Format:%H$ */
400 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 #include "tomcrypt.h"
736734 return CRYPT_NOP;
737735 #else
738736 static const struct {
739 char *msg;
737 const char *msg;
740738 unsigned char hash[24];
741739 } tests[] = {
742740 { "",
774772 tiger_init(&md);
775773 tiger_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
776774 tiger_done(&md, tmp);
777 if (XMEMCMP(tmp, tests[i].hash, 24) != 0) {
775 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "TIGER", i)) {
778776 return CRYPT_FAIL_TESTVECTOR;
779777 }
780778 }
808806
809807
810808
811 /* $Source$ */
812 /* $Revision$ */
813 /* $Date$ */
809 /* ref: $Format:%D$ */
810 /* git commit: $Format:%H$ */
811 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /**
290288 whirlpool_init(&md);
291289 whirlpool_process(&md, (unsigned char *)tests[i].msg, tests[i].len);
292290 whirlpool_done(&md, tmp);
293 if (XMEMCMP(tmp, tests[i].hash, 64) != 0) {
294 #if 0
295 printf("\nFailed test %d\n", i);
296 for (i = 0; i < 64; ) {
297 printf("%02x ", tmp[i]);
298 if (!(++i & 15)) printf("\n");
299 }
300 #endif
291 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "WHIRLPOOL", i)) {
301292 return CRYPT_FAIL_TESTVECTOR;
302293 }
303294 }
309300 #endif
310301
311302
312 /* $Source$ */
313 /* $Revision$ */
314 /* $Date$ */
303 /* ref: $Format:%D$ */
304 /* git commit: $Format:%H$ */
305 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /**
110 @file whirltab.c
211 LTC_WHIRLPOOL tables, Tom St Denis
581590
582591 #endif /* __LTC_WHIRLTAB_C__ */
583592
584 /* $Source$ */
585 /* $Revision$ */
586 /* $Date$ */
593 /* ref: $Format:%D$ */
594 /* git commit: $Format:%H$ */
595 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 #ifndef TOMCRYPT_H_
110 #define TOMCRYPT_H_
211 #include <assert.h>
1625 #endif
1726
1827 /* version */
19 #define CRYPT 0x0117
20 #define SCRYPT "1.17"
28 #define CRYPT 0x0118
29 #define SCRYPT "1.18.0"
2130
2231 /* max size of either a cipher/hash block or symmetric key [largest of the two] */
2332 #define MAXBLOCKSIZE 128
5867 CRYPT_OVERFLOW, /* An overflow of a value was detected/prevented */
5968
6069 CRYPT_UNUSED1, /* UNUSED1 */
61 CRYPT_UNUSED2, /* UNUSED2 */
70
71 CRYPT_INPUT_TOO_LONG, /* The input was longer than expected. */
6272
6373 CRYPT_PK_INVALID_SIZE, /* Invalid size input for PK parameters */
6474
8797 #endif /* TOMCRYPT_H_ */
8898
8999
90 /* $Source$ */
91 /* $Revision$ */
92 /* $Date$ */
100 /* ref: $Format:%D$ */
101 /* git commit: $Format:%H$ */
102 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* Defines the LTC_ARGCHK macro used within the library */
110 /* ARGTYPE is defined in tomcrypt_cfg.h */
211 #if ARGTYPE == 0
1019 #define NORETURN
1120 #endif
1221
13 void crypt_argchk(char *v, char *s, int d) NORETURN;
22 void crypt_argchk(const char *v, const char *s, int d) NORETURN;
1423 #define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
1524 #define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
1625
3847 #endif
3948
4049
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
50 /* ref: $Format:%D$ */
51 /* git commit: $Format:%H$ */
52 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* This is the build config file.
110 *
211 * With this you can setup what to inlcude/exclude automatically during any build. Just comment
4049
4150 #endif
4251
43 /* some compilers do not like "inline" */
44 #if defined(__HP_cc)
52 /* some compilers do not like "inline" (or maybe "static inline"), namely: HP cc, IBM xlc */
53 #if defined(__HP_cc) || defined(__xlc__)
4554 #define LTC_INLINE
4655 #elif defined(_MSC_VER)
4756 #define LTC_INLINE __inline
5362 #ifndef ARGTYPE
5463 #define ARGTYPE 0
5564 #endif
65
66 #undef LTC_ENCRYPT
67 #define LTC_ENCRYPT 0
68 #undef LTC_DECRYPT
69 #define LTC_DECRYPT 1
5670
5771 /* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code
5872 *
158172
159173 /* endianness fallback */
160174 #if !defined(ENDIAN_BIG) && !defined(ENDIAN_LITTLE)
161 #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
175 #if defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN || \
176 defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
162177 defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || \
163 defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) || \
178 defined(__BIG_ENDIAN__) || \
164179 defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
165180 defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
166181 #define ENDIAN_BIG
167 #elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \
182 #elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN || \
183 defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \
168184 defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || \
169 defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) || \
185 defined(__LITTLE_ENDIAN__) || \
170186 defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
171187 defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
172188 #define ENDIAN_LITTLE
202218 #endif
203219 #endif
204220
221 #if defined(ENDIAN_64BITWORD) && !defined(_MSC_VER)
222 typedef unsigned long long ltc_mp_digit;
223 #else
224 typedef unsigned long ltc_mp_digit;
225 #endif
226
227 /* No asm is a quick way to disable anything "not portable" */
228 #ifdef LTC_NO_ASM
229 #define ENDIAN_NEUTRAL
230 #undef ENDIAN_32BITWORD
231 #undef ENDIAN_64BITWORD
232 #undef LTC_FAST
233 #define LTC_NO_ROLC
234 #define LTC_NO_BSWAP
235 #endif
236
205237 /* No LTC_FAST if: explicitly disabled OR non-gcc/non-clang compiler OR old gcc OR using -ansi -std=c99 */
206238 #if defined(LTC_NO_FAST) || (__GNUC__ < 4) || defined(__STRICT_ANSI__)
207239 #undef LTC_FAST
216248 #endif
217249 #endif
218250
219 #ifdef ENDIAN_64BITWORD
220 typedef ulong64 ltc_mp_digit;
221 #else
222 typedef ulong32 ltc_mp_digit;
223 #endif
224
225 /* No asm is a quick way to disable anything "not portable" */
226 #ifdef LTC_NO_ASM
227 #define ENDIAN_NEUTRAL
228 #undef ENDIAN_32BITWORD
229 #undef ENDIAN_64BITWORD
230 #undef LTC_FAST
231 #undef LTC_FAST_TYPE
232 #define LTC_NO_ROLC
233 #define LTC_NO_BSWAP
234 #endif
235
236251 #if !defined(ENDIAN_NEUTRAL) && (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD))
237 #error You must specify a word size as well as endianess in tomcrypt_cfg.h
252 #error You must specify a word size as well as endianess in tomcrypt_cfg.h
238253 #endif
239254
240255 #if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE))
242257 #endif
243258
244259 #if (defined(ENDIAN_32BITWORD) && defined(ENDIAN_64BITWORD))
245 #error Cannot be 32 and 64 bit words...
260 #error Cannot be 32 and 64 bit words...
246261 #endif
247262
248263 /* gcc 4.3 and up has a bswap builtin; detect it by gcc version.
262277 #endif
263278
264279
265 /* $Source$ */
266 /* $Revision$ */
267 /* $Date$ */
280 /* ref: $Format:%D$ */
281 /* git commit: $Format:%H$ */
282 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* ---- SYMMETRIC KEY STUFF -----
110 *
211 * We put each of the ciphers scheduled keys in their own structs then we put all of
339348 /** cipher descriptor table, last entry has "name == NULL" to mark the end of table */
340349 extern struct ltc_cipher_descriptor {
341350 /** name of cipher */
342 char *name;
351 const char *name;
343352 /** internal ID */
344353 unsigned char ID;
345354 /** min keysize (octets) */
489498 /** Accelerated GCM packet (one shot)
490499 @param key The secret key
491500 @param keylen The length of the secret key
492 @param IV The initial vector
493 @param IVlen The length of the initial vector
501 @param IV The initialization vector
502 @param IVlen The length of the initialization vector
494503 @param adata The additional authentication data (header)
495504 @param adatalen The length of the adata
496505 @param pt The plaintext
865874
866875 #ifdef LTC_LRW_MODE
867876
868 #define LRW_ENCRYPT 0
869 #define LRW_DECRYPT 1
877 #define LRW_ENCRYPT LTC_ENCRYPT
878 #define LRW_DECRYPT LTC_DECRYPT
870879
871880 int lrw_start( int cipher,
872881 const unsigned char *IV,
932941 int find_cipher_id(unsigned char ID);
933942 int register_cipher(const struct ltc_cipher_descriptor *cipher);
934943 int unregister_cipher(const struct ltc_cipher_descriptor *cipher);
944 int register_all_ciphers(void);
935945 int cipher_is_valid(int idx);
936946
937947 LTC_MUTEX_PROTO(ltc_cipher_mutex)
9921002
9931003 #endif /* LTC_SOBER128_STREAM */
9941004
995 /* $Source$ */
996 /* $Revision$ */
997 /* $Date$ */
1005 /* ref: $Format:%D$ */
1006 /* git commit: $Format:%H$ */
1007 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 #ifndef TOMCRYPT_CUSTOM_H_
110 #define TOMCRYPT_CUSTOM_H_
211
2029 #ifndef XMEMCPY
2130 #define XMEMCPY memcpy
2231 #endif
32 #ifndef XMEMMOVE
33 #define XMEMMOVE memmove
34 #endif
2335 #ifndef XMEMCMP
2436 #define XMEMCMP memcmp
2537 #endif
26 #ifndef XMEMMOVE
27 #define XMEMMOVE memmove
28 #endif
38 /* A memory compare function that has to run in constant time,
39 * c.f. mem_neq() API summary.
40 */
2941 #ifndef XMEM_NEQ
3042 #define XMEM_NEQ mem_neq
3143 #endif
4961
5062 /* shortcut to disable automatic inclusion */
5163 #if defined LTC_NOTHING && !defined LTC_EASY
52 #define LTC_NO_MATH
5364 #define LTC_NO_CIPHERS
5465 #define LTC_NO_MODES
5566 #define LTC_NO_HASHES
5869 #define LTC_NO_PK
5970 #define LTC_NO_PKCS
6071 #define LTC_NO_MISC
61 #define LTC_NO_FILE
6272 #endif /* LTC_NOTHING */
6373
6474 /* Easy button? */
366376 /* Supported Key Sizes */
367377 #define LTC_DH768
368378 #define LTC_DH1024
369 #define LTC_DH1280
370379 #define LTC_DH1536
371 #define LTC_DH1792
372380 #define LTC_DH2048
373381
374382 #ifndef TFM_DESC
375383 /* tfm has a problem in fp_isprime for larger key sizes */
376 #define LTC_DH2560
377384 #define LTC_DH3072
378385 #define LTC_DH4096
386 #define LTC_DH6144
387 #define LTC_DH8192
379388 #endif
380389
381390 /* Include Katja (a Rabin variant like RSA) */
413422 /* Enable ECC timing resistant version by default */
414423 #define LTC_ECC_TIMING_RESISTANT
415424 #endif
416
417 /* define these PK sizes out of LTC_NO_PK
418 * to have them always defined
419 */
420 #if defined(LTC_MRSA)
421 /* Min and Max RSA key sizes (in bits) */
422 #ifndef MIN_RSA_SIZE
423 #define MIN_RSA_SIZE 1024
424 #endif
425 #ifndef MAX_RSA_SIZE
426 #define MAX_RSA_SIZE 4096
427 #endif
428 #endif
429
430 /* in cases where you want ASN.1/DER functionality, but no
431 * RSA, you can define this externally if 1024 is not enough
432 */
433 #if defined(LTC_MRSA)
434 #define LTC_DER_MAX_PUBKEY_SIZE MAX_RSA_SIZE
435 #elif !defined(LTC_DER_MAX_PUBKEY_SIZE)
436 /* this includes DSA */
437 #define LTC_DER_MAX_PUBKEY_SIZE 1024
438 #endif
439
440425
441426 /* PKCS #1 (RSA) and #5 (Password Handling) stuff */
442427 #ifndef LTC_NO_PKCS
517502 #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_MKAT)
518503 /* Include the MPI functionality? (required by the PK algorithms) */
519504 #define LTC_MPI
505
506 #ifndef LTC_PK_MAX_RETRIES
507 /* iterations limit for retry-loops */
508 #define LTC_PK_MAX_RETRIES 20
509 #endif
520510 #endif
521511
522512 #ifdef LTC_MRSA
523513 #define LTC_PKCS_1
524514 #endif
525515
526 #if defined(TFM_DESC) && defined(LTC_RSA_BLINDING)
527 #warning RSA blinding currently not supported in combination with TFM
528 #undef LTC_RSA_BLINDING
529 #endif
530
531516 #if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL)
532517 #error Pelican-MAC requires LTC_RIJNDAEL
533518 #endif
570555
571556 #if defined(LTC_BLAKE2BMAC) && !defined(LTC_BLAKE2B)
572557 #error LTC_BLAKE2BMAC requires LTC_BLAKE2B
558 #endif
559
560 #if defined(LTC_SPRNG) && !defined(LTC_RNG_GET_BYTES)
561 #error LTC_SPRNG requires LTC_RNG_GET_BYTES
562 #endif
563
564 #if defined(LTC_NO_MATH) && (defined(LTM_DESC) || defined(TFM_DESC) || defined(GMP_DESC))
565 #error LTC_NO_MATH defined, but also a math descriptor
573566 #endif
574567
575568 /* THREAD management */
580573 #define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
581574 #define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x;
582575 #define LTC_MUTEX_TYPE(x) pthread_mutex_t x;
583 #define LTC_MUTEX_INIT(x) pthread_mutex_init(x, NULL);
584 #define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x);
585 #define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x);
576 #define LTC_MUTEX_INIT(x) LTC_ARGCHK(pthread_mutex_init(x, NULL) == 0);
577 #define LTC_MUTEX_LOCK(x) LTC_ARGCHK(pthread_mutex_lock(x) == 0);
578 #define LTC_MUTEX_UNLOCK(x) LTC_ARGCHK(pthread_mutex_unlock(x) == 0);
586579
587580 #else
588581
610603 #endif
611604 #endif
612605
613 /* $Source$ */
614 /* $Revision$ */
615 /* $Date$ */
606 /* ref: $Format:%D$ */
607 /* git commit: $Format:%H$ */
608 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* ---- HASH FUNCTIONS ---- */
110 #ifdef LTC_SHA3
211 struct sha3_state {
194203 /** hash descriptor */
195204 extern struct ltc_hash_descriptor {
196205 /** name of hash */
197 char *name;
206 const char *name;
198207 /** internal ID */
199208 unsigned char ID;
200209 /** Size of digest in octets */
460469 int find_hash_any(const char *name, int digestlen);
461470 int register_hash(const struct ltc_hash_descriptor *hash);
462471 int unregister_hash(const struct ltc_hash_descriptor *hash);
472 int register_all_hashes(void);
463473 int hash_is_valid(int idx);
464474
465475 LTC_MUTEX_PROTO(ltc_hash_mutex)
486496 if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \
487497 return CRYPT_INVALID_ARG; \
488498 } \
489 if ((md-> state_var .length + inlen) < md-> state_var .length) { \
499 if ((md-> state_var .length + inlen) < md-> state_var .length) { \
490500 return CRYPT_HASH_OVERFLOW; \
491501 } \
492502 while (inlen > 0) { \
499509 inlen -= block_size; \
500510 } else { \
501511 n = MIN(inlen, (block_size - md-> state_var .curlen)); \
502 XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \
512 XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \
503513 md-> state_var .curlen += n; \
504514 in += n; \
505515 inlen -= n; \
515525 return CRYPT_OK; \
516526 }
517527
518 /* $Source$ */
519 /* $Revision$ */
520 /* $Date$ */
528 /* ref: $Format:%D$ */
529 /* git commit: $Format:%H$ */
530 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 #ifdef LTC_HMAC
110 typedef struct Hmac_state {
211 hash_state md;
256265 symmetric_key key; /* scheduled key for cipher */
257266 unsigned long block_index; /* index # for current data block */
258267 int cipher, /* cipher idx */
268 tag_len, /* length of tag */
259269 block_len; /* length of block */
260270 } ocb3_state;
261271
262272 int ocb3_init(ocb3_state *ocb, int cipher,
263273 const unsigned char *key, unsigned long keylen,
264 const unsigned char *nonce, unsigned long noncelen);
274 const unsigned char *nonce, unsigned long noncelen,
275 unsigned long taglen);
265276
266277 int ocb3_encrypt(ocb3_state *ocb, const unsigned char *pt, unsigned long ptlen, unsigned char *ct);
267278 int ocb3_decrypt(ocb3_state *ocb, const unsigned char *ct, unsigned long ctlen, unsigned char *pt);
289300
290301 int ocb3_test(void);
291302
303 #ifdef LTC_SOURCE
292304 /* internal helper functions */
293 int ocb3_int_aad_add_block(ocb3_state *ocb, const unsigned char *aad_block);
294 void ocb3_int_calc_offset_zero(ocb3_state *ocb, const unsigned char *nonce, unsigned long noncelen);
295305 int ocb3_int_ntz(unsigned long x);
296306 void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const unsigned char *block_b, unsigned long block_len);
307 #endif /* LTC_SOURCE */
297308
298309 #endif /* LTC_OCB3_MODE */
299310
300311 #ifdef LTC_CCM_MODE
301312
302 #define CCM_ENCRYPT 0
303 #define CCM_DECRYPT 1
313 #define CCM_ENCRYPT LTC_ENCRYPT
314 #define CCM_DECRYPT LTC_DECRYPT
304315
305316 typedef struct {
306317 symmetric_key K;
366377
367378 #ifdef LTC_GCM_MODE
368379
369 #define GCM_ENCRYPT 0
370 #define GCM_DECRYPT 1
380 #define GCM_ENCRYPT LTC_ENCRYPT
381 #define GCM_DECRYPT LTC_DECRYPT
371382
372383 #define LTC_GCM_MODE_IV 0
373384 #define LTC_GCM_MODE_AAD 1
530541 int aadflg;
531542 } chacha20poly1305_state;
532543
533 #define CHCHA20POLY1305_ENCRYPT 0
534 #define CHCHA20POLY1305_DECRYPT 1
544 #define CHCHA20POLY1305_ENCRYPT LTC_ENCRYPT
545 #define CHCHA20POLY1305_DECRYPT LTC_DECRYPT
535546
536547 int chacha20poly1305_init(chacha20poly1305_state *st, const unsigned char *key, unsigned long keylen);
537548 int chacha20poly1305_setiv(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen);
551562
552563 #endif /* LTC_CHACHA20POLY1305_MODE */
553564
554 /* $Source$ */
555 /* $Revision$ */
556 /* $Date$ */
565 /* ref: $Format:%D$ */
566 /* git commit: $Format:%H$ */
567 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
08
19 /* ---- HELPER MACROS ---- */
210 #ifdef ENDIAN_NEUTRAL
432440 #define snprintf _snprintf
433441 #endif
434442
435 /* $Source$ */
436 /* $Revision$ */
437 /* $Date$ */
443 /* ref: $Format:%D$ */
444 /* git commit: $Format:%H$ */
445 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /** math functions **/
110
211 #define LTC_MP_LT -1
1423 typedef void rsa_key;
1524 #endif
1625
26 #ifndef LTC_MILLER_RABIN_REPS
27 /* Number of rounds of the Miller-Rabin test
28 * "Reasonable values of reps are between 15 and 50." c.f. gmp doc of mpz_probab_prime_p()
29 * As of https://security.stackexchange.com/a/4546 we should use 40 rounds */
30 #define LTC_MILLER_RABIN_REPS 40
31 #endif
32
33 int radix_to_bin(const void *in, int radix, void *out, unsigned long *len);
34
1735 /** math descriptor */
1836 typedef struct {
1937 /** Name of the math provider */
20 char *name;
38 const char *name;
2139
2240 /** Bits per digit, amount of bits must fit in an unsigned long */
2341 int bits_per_digit;
6482 /** set small constant
6583 @param a Number to write to
6684 @param n Source upto bits_per_digit (actually meant for very small constants)
67 @return CRYPT_OK on succcess
68 */
69 int (*set_int)(void *a, unsigned long n);
85 @return CRYPT_OK on success
86 */
87 int (*set_int)(void *a, ltc_mp_digit n);
7088
7189 /** get small constant
72 @param a Number to read, only fetches upto bits_per_digit from the number
73 @return The lower bits_per_digit of the integer (unsigned)
90 @param a Small number to read,
91 only fetches up to bits_per_digit from the number
92 @return The lower bits_per_digit of the integer (unsigned)
7493 */
7594 unsigned long (*get_int)(void *a);
7695
90109 /** compare two integers
91110 @param a The left side integer
92111 @param b The right side integer
93 @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison)
112 @return LTC_MP_LT if a < b,
113 LTC_MP_GT if a > b and
114 LTC_MP_EQ otherwise. (signed comparison)
94115 */
95116 int (*compare)(void *a, void *b);
96117
97118 /** compare against int
98119 @param a The left side integer
99120 @param b The right side integer (upto bits_per_digit)
100 @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison)
101 */
102 int (*compare_d)(void *a, unsigned long n);
121 @return LTC_MP_LT if a < b,
122 LTC_MP_GT if a > b and
123 LTC_MP_EQ otherwise. (signed comparison)
124 */
125 int (*compare_d)(void *a, ltc_mp_digit n);
103126
104127 /** Count the number of bits used to represent the integer
105128 @param a The integer to count
139162 int (*write_radix)(void *a, char *str, int radix);
140163
141164 /** get size as unsigned char string
142 @param a The integer to get the size (when stored in array of octets)
143 @return The length of the integer
165 @param a The integer to get the size (when stored in array of octets)
166 @return The length of the integer in octets
144167 */
145168 unsigned long (*unsigned_size)(void *a);
146169
157180 @param len The number of octets
158181 @return CRYPT_OK on success
159182 */
160 int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len);
183 int (*unsigned_read)( void *dst,
184 unsigned char *src,
185 unsigned long len);
161186
162187 /* ---- basic math ---- */
163188
169194 */
170195 int (*add)(void *a, void *b, void *c);
171196
172
173197 /** add two integers
174198 @param a The first source integer
175 @param b The second source integer (single digit of upto bits_per_digit in length)
199 @param b The second source integer
200 (single digit of upto bits_per_digit in length)
176201 @param c The destination of "a + b"
177202 @return CRYPT_OK on success
178203 */
179 int (*addi)(void *a, unsigned long b, void *c);
204 int (*addi)(void *a, ltc_mp_digit b, void *c);
180205
181206 /** subtract two integers
182207 @param a The first source integer
188213
189214 /** subtract two integers
190215 @param a The first source integer
191 @param b The second source integer (single digit of upto bits_per_digit in length)
216 @param b The second source integer
217 (single digit of upto bits_per_digit in length)
192218 @param c The destination of "a - b"
193219 @return CRYPT_OK on success
194220 */
195 int (*subi)(void *a, unsigned long b, void *c);
221 int (*subi)(void *a, ltc_mp_digit b, void *c);
196222
197223 /** multiply two integers
198224 @param a The first source integer
199 @param b The second source integer (single digit of upto bits_per_digit in length)
225 @param b The second source integer
226 (single digit of upto bits_per_digit in length)
200227 @param c The destination of "a * b"
201228 @return CRYPT_OK on success
202229 */
204231
205232 /** multiply two integers
206233 @param a The first source integer
207 @param b The second source integer (single digit of upto bits_per_digit in length)
234 @param b The second source integer
235 (single digit of upto bits_per_digit in length)
208236 @param c The destination of "a * b"
209237 @return CRYPT_OK on success
210238 */
211 int (*muli)(void *a, unsigned long b, void *c);
239 int (*muli)(void *a, ltc_mp_digit b, void *c);
212240
213241 /** Square an integer
214242 @param a The integer to square
247275 @param c The destination for the residue
248276 @return CRYPT_OK on success
249277 */
250 int (*modi)(void *a, unsigned long b, unsigned long *c);
278 int (*modi)(void *a, ltc_mp_digit b, ltc_mp_digit *c);
251279
252280 /** gcd
253281 @param a The first integer
292320
293321 /* ---- reduction ---- */
294322
295 /** setup montgomery
323 /** setup Montgomery
296324 @param a The modulus
297325 @param b The destination for the reduction digit
298326 @return CRYPT_OK on success
333361
334362 /** Primality testing
335363 @param a The integer to test
336 @param b The number of tests that shall be executed
364 @param b The number of Miller-Rabin tests that shall be executed
337365 @param c The destination of the result (FP_YES if prime)
338366 @return CRYPT_OK on success
339367 */
347375 @param R The destination for kG
348376 @param a ECC curve parameter a (if NULL we assume a == -3)
349377 @param modulus The modulus for the field
350 @param map Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only)
351 @return CRYPT_OK on success
352 */
353 int (*ecc_ptmul)(void *k, ecc_point *G, ecc_point *R, void *a, void *modulus, int map);
378 @param map Boolean indicated whether to map back to affine or not
379 (can be ignored if you work in affine only)
380 @return CRYPT_OK on success
381 */
382 int (*ecc_ptmul)( void *k,
383 ecc_point *G,
384 ecc_point *R,
385 void *a,
386 void *modulus,
387 int map);
354388
355389 /** ECC GF(p) point addition
356390 @param P The first point
361395 @param mp The "b" value from montgomery_setup()
362396 @return CRYPT_OK on success
363397 */
364 int (*ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *a, void *modulus, void *mp);
398 int (*ecc_ptadd)(ecc_point *P,
399 ecc_point *Q,
400 ecc_point *R,
401 void *a,
402 void *modulus,
403 void *mp);
365404
366405 /** ECC GF(p) point double
367406 @param P The first point
371410 @param mp The "b" value from montgomery_setup()
372411 @return CRYPT_OK on success
373412 */
374 int (*ecc_ptdbl)(ecc_point *P, ecc_point *R, void *a, void *modulus, void *mp);
375
376 /** ECC mapping from projective to affine, currently uses (x,y,z) => (x/z^2, y/z^3, 1)
413 int (*ecc_ptdbl)(ecc_point *P,
414 ecc_point *R,
415 void *a,
416 void *modulus,
417 void *mp);
418
419 /** ECC mapping from projective to affine,
420 currently uses (x,y,z) => (x/z^2, y/z^3, 1)
377421 @param P The point to map
378422 @param modulus The modulus
379423 @param mp The "b" value from montgomery_setup()
380424 @return CRYPT_OK on success
381 @remark The mapping can be different but keep in mind a ecc_point only has three
382 integers (x,y,z) so if you use a different mapping you have to make it fit.
425 @remark The mapping can be different but keep in mind a
426 ecc_point only has three integers (x,y,z) so if
427 you use a different mapping you have to make it fit.
383428 */
384429 int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
385430
388433 @param kA What to multiple A by
389434 @param B Second point to multiply
390435 @param kB What to multiple B by
391 @param C [out] Destination point (can overlap with A or B
436 @param C [out] Destination point (can overlap with A or B)
392437 @param modulus Modulus for curve
393438 @return CRYPT_OK on success
394439 */
403448 /** RSA Key Generation
404449 @param prng An active PRNG state
405450 @param wprng The index of the PRNG desired
406 @param size The size of the modulus (key size) desired (octets)
407 @param e The "e" value (public key). e==65537 is a good choice
451 @param size The size of the key in octets
452 @param e The "e" value (public key).
453 e==65537 is a good choice
408454 @param key [out] Destination of a newly created private key pair
409455 @return CRYPT_OK if successful, upon error all allocated ram is freed
410456 */
411 int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key);
412
457 int (*rsa_keygen)(prng_state *prng,
458 int wprng,
459 int size,
460 long e,
461 rsa_key *key);
413462
414463 /** RSA exponentiation
415464 @param in The octet array representing the base
416465 @param inlen The length of the input
417466 @param out The destination (to be stored in an octet array format)
418 @param outlen The length of the output buffer and the resulting size (zero padded to the size of the modulus)
467 @param outlen The length of the output buffer and the resulting size
468 (zero padded to the size of the modulus)
419469 @param which PK_PUBLIC for public RSA and PK_PRIVATE for private RSA
420470 @param key The RSA key to use
421471 @return CRYPT_OK on success
445495 int (*submod)(void *a, void *b, void *c, void *d);
446496
447497 /* ---- misc stuff ---- */
498
448499 /** Make a pseudo-random mpi
449500 @param a The mpi to make random
450501 @param size The desired length
451502 @return CRYPT_OK on success
452503 */
453504 int (*rand)(void *a, int size);
454
455505 } ltc_math_descriptor;
456506
457507 extern ltc_math_descriptor ltc_mp;
458508
459509 int ltc_init_multi(void **a, ...);
460510 void ltc_deinit_multi(void *a, ...);
511 void ltc_cleanup_multi(void **a, ...);
461512
462513 #ifdef LTM_DESC
463514 extern const ltc_math_descriptor ltm_desc;
480531 #define mp_init_multi ltc_init_multi
481532 #define mp_clear(a) ltc_mp.deinit(a)
482533 #define mp_clear_multi ltc_deinit_multi
534 #define mp_cleanup_multi ltc_cleanup_multi
483535 #define mp_init_copy(a, b) ltc_mp.init_copy(a, b)
484536
485537 #define mp_neg(a, b) ltc_mp.neg(a, b)
541593
542594 #endif
543595
544 /* $Source$ */
545 /* $Revision$ */
546 /* $Date$ */
596 /* ref: $Format:%D$ */
597 /* git commit: $Format:%H$ */
598 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* ---- LTC_BASE64 Routines ---- */
110 #ifdef LTC_BASE64
211 int base64_encode(const unsigned char *in, unsigned long len,
6877 #ifdef TFM_DESC
6978 void init_TFM(void);
7079 #endif
71 /* *** use of GMP is untested ***
7280 #ifdef GMP_DESC
7381 void init_GMP(void);
7482 #endif
75 */
7683
7784 #ifdef LTC_ADLER32
7885 typedef struct adler32_state_s
98105 int crc32_test(void);
99106 #endif
100107
101 /* yeah it's not exactly in misc in the library, but in testprof/x86_prof.c */
102 #if defined(LTC_TEST) && defined(LTC_TEST_DBG)
103 void print_hex(const char* what, const void* v, const unsigned long l);
104108 int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
105 #else
106 #define compare_testvector(is, is_len, should, should_len, what, which) \
107 ((((is_len) != (should_len)) || (XMEMCMP((is), (should), (is_len)) != 0)) ? 1 : 0)
108 #endif
109109
110 /* $Source$ */
111 /* $Revision$ */
112 /* $Date$ */
110 /* ref: $Format:%D$ */
111 /* git commit: $Format:%H$ */
112 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* ---- NUMBER THEORY ---- */
110
211 enum {
312 PK_PUBLIC=0,
4 PK_PRIVATE=1,
5 PK_PUBLIC_COMPRESSED=2, /* used only when exporting public ECC key */
6 PK_CURVEOID=4 /* used only when exporting public ECC key */
13 PK_PRIVATE=1
714 };
815
916 /* Indicates standard output formats that can be read e.g. by OpenSSL or GnuTLS */
1017 #define PK_STD 0x1000
18 /* Indicates compressed public ECC key */
19 #define PK_COMPRESSED 0x2000
20 /* Indicates ECC key with the curve specified by OID */
21 #define PK_CURVEOID 0x4000
1122
1223 int rand_prime(void *N, long len, prng_state *prng, int wprng);
24
25 #ifdef LTC_SOURCE
26 /* internal helper functions */
1327 int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng);
14 int rand_bn_range(void *N, void *limit, prng_state *prng, int wprng);
28 int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng);
1529
1630 enum public_key_algorithms {
1731 PKA_RSA,
1933 PKA_EC,
2034 EC_PRIME_FIELD
2135 };
36 #endif /* LTC_SOURCE */
2237
2338 typedef struct Oid {
2439 unsigned long OID[16];
113128 int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key);
114129 int rsa_import_pkcs8(const unsigned char *in, unsigned long inlen,
115130 const void *passwd, unsigned long passwdlen, rsa_key *key);
116 int rsa_import_radix(int radix, char *N, char *e, char *d, char *p, char *q, char *dP, char *dQ, char *qP, rsa_key *key);
131
132 int rsa_set_key(const unsigned char *N, unsigned long Nlen,
133 const unsigned char *e, unsigned long elen,
134 const unsigned char *d, unsigned long dlen,
135 rsa_key *key);
136 int rsa_set_factors(const unsigned char *p, unsigned long plen,
137 const unsigned char *q, unsigned long qlen,
138 rsa_key *key);
139 int rsa_set_crt_params(const unsigned char *dP, unsigned long dPlen,
140 const unsigned char *dQ, unsigned long dQlen,
141 const unsigned char *qP, unsigned long qPlen,
142 rsa_key *key);
117143 #endif
118144
119145 /* ---- Katja ---- */
174200 /* ---- DH Routines ---- */
175201 #ifdef LTC_MDH
176202
177 typedef struct Dh_key {
178 int idx, type;
203 typedef struct {
204 int type;
179205 void *x;
180206 void *y;
181207 void *base;
182208 void *prime;
183209 } dh_key;
184210
185 int dh_compat_test(void);
186 void dh_sizes(int *low, int *high);
187 int dh_get_size(dh_key *key);
188
189 int dh_make_key_internal(prng_state *prng, int wprng, dh_key *key); /* for internal use only */
190 int dh_make_key_ex(prng_state *prng, int wprng, const char *base_hex, const char *prime_hex, dh_key *key);
191 int dh_make_key(prng_state *prng, int wprng, int keysize, dh_key *key);
192 void dh_free(dh_key *key);
211 int dh_get_groupsize(dh_key *key);
193212
194213 int dh_export(unsigned char *out, unsigned long *outlen, int type, dh_key *key);
195214 int dh_import(const unsigned char *in, unsigned long inlen, dh_key *key);
196 int dh_import_raw(unsigned char *in, unsigned long inlen, int type,
197 const char *base_hex, const char *prime_hex, dh_key *key);
215
216 int dh_set_pg(const unsigned char *p, unsigned long plen,
217 const unsigned char *g, unsigned long glen,
218 dh_key *key);
219 int dh_set_pg_dhparam(const unsigned char *dhparam, unsigned long dhparamlen, dh_key *key);
220 int dh_set_pg_groupsize(int groupsize, dh_key *key);
221
222 int dh_set_key(const unsigned char *in, unsigned long inlen, int type, dh_key *key);
223 int dh_generate_key(prng_state *prng, int wprng, dh_key *key);
198224
199225 int dh_shared_secret(dh_key *private_key, dh_key *public_key,
200226 unsigned char *out, unsigned long *outlen);
201227
202 int dh_encrypt_key(const unsigned char *in, unsigned long keylen,
203 unsigned char *out, unsigned long *outlen,
204 prng_state *prng, int wprng, int hash,
205 dh_key *key);
206
207 int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
208 unsigned char *out, unsigned long *outlen,
209 dh_key *key);
210
211 int dh_sign_hash(const unsigned char *in, unsigned long inlen,
212 unsigned char *out, unsigned long *outlen,
213 prng_state *prng, int wprng, dh_key *key);
214
215 int dh_verify_hash(const unsigned char *sig, unsigned long siglen,
216 const unsigned char *hash, unsigned long hashlen,
217 int *stat, dh_key *key);
218
219
220 #endif
228 void dh_free(dh_key *key);
229
230 int dh_export_key(void *out, unsigned long *outlen, int type, dh_key *key);
231
232 #ifdef LTC_SOURCE
233 typedef struct {
234 int size;
235 const char *name, *base, *prime;
236 } ltc_dh_set_type;
237
238 extern const ltc_dh_set_type ltc_dh_sets[];
239
240 /* internal helper functions */
241 int dh_check_pubkey(dh_key *key);
242 #endif
243
244 #endif /* LTC_MDH */
221245
222246
223247 /* ---- ECC Routines ---- */
335359 unsigned char *out, unsigned long *outlen,
336360 ecc_key *key);
337361
362 int ecc_sign_hash_rfc7518(const unsigned char *in, unsigned long inlen,
363 unsigned char *out, unsigned long *outlen,
364 prng_state *prng, int wprng, ecc_key *key);
365
338366 int ecc_sign_hash(const unsigned char *in, unsigned long inlen,
339367 unsigned char *out, unsigned long *outlen,
340368 prng_state *prng, int wprng, ecc_key *key);
341369
370 int ecc_verify_hash_rfc7518(const unsigned char *sig, unsigned long siglen,
371 const unsigned char *hash, unsigned long hashlen,
372 int *stat, ecc_key *key);
373
342374 int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
343375 const unsigned char *hash, unsigned long hashlen,
344376 int *stat, ecc_key *key);
345
346 int ecc_sign_hash_rfc7518(const unsigned char *in, unsigned long inlen,
347 unsigned char *out, unsigned long *outlen,
348 prng_state *prng, int wprng, ecc_key *key);
349
350 int ecc_verify_hash_rfc7518(const unsigned char *sig, unsigned long siglen,
351 const unsigned char *hash, unsigned long hashlen,
352 int *stat, ecc_key *key);
353377
354378 int ecc_verify_key(ecc_key *key);
355379
447471
448472 int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key);
449473
450 int dsa_make_key_ex(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key, char* p_hex, char* q_hex, char* g_hex);
451
452 int dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g);
474 int dsa_set_pqg(const unsigned char *p, unsigned long plen,
475 const unsigned char *q, unsigned long qlen,
476 const unsigned char *g, unsigned long glen,
477 dsa_key *key);
478 int dsa_set_pqg_dsaparam(const unsigned char *dsaparam, unsigned long dsaparamlen, dsa_key *key);
479 int dsa_generate_pqg(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key);
480
481 int dsa_set_key(const unsigned char *in, unsigned long inlen, int type, dsa_key *key);
482 int dsa_generate_key(prng_state *prng, int wprng, dsa_key *key);
453483
454484 void dsa_free(dsa_key *key);
455485
478508 unsigned char *out, unsigned long *outlen,
479509 dsa_key *key);
480510
481 int dsa_import_radix(int radix, char *p, char *q, char *g, char *x, char *y, dsa_key *key);
482511 int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key);
483512 int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key);
484513 int dsa_verify_key(dsa_key *key, int *stat);
485
514 #ifdef LTC_SOURCE
515 /* internal helper functions */
516 int dsa_int_validate_xy(dsa_key *key, int *stat);
517 int dsa_int_validate_pqg(dsa_key *key, int *stat);
518 int dsa_int_validate_primes(dsa_key *key, int *stat);
519 #endif
486520 int dsa_shared_secret(void *private_key, void *base,
487521 dsa_key *public_key,
488522 unsigned char *out, unsigned long *outlen);
563597
564598 int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
565599 unsigned long *outlen);
600
601
602 #ifdef LTC_SOURCE
603 /* internal helper functions */
566604 int der_length_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
567605 unsigned long *outlen, unsigned long *payloadlen);
568
569606 /* SUBJECT PUBLIC KEY INFO */
570607 int der_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
571608 unsigned int algorithm, void* public_key, unsigned long public_key_len,
579616 unsigned int algorithm, void* public_key, unsigned long* public_key_len,
580617 unsigned long parameters_type, void* parameters, unsigned long parameters_len,
581618 unsigned long *parameters_outsize);
619 #endif /* LTC_SOURCE */
582620
583621 /* SET */
584622 #define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 0)
656694 unsigned char *out, unsigned long *outlen);
657695 int der_length_teletex_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen);
658696
697 #ifdef LTC_SOURCE
698 /* internal helper functions */
659699 int der_teletex_char_encode(int c);
660700 int der_teletex_value_decode(int v);
701 #endif /* LTC_SOURCE */
702
661703
662704 /* PRINTABLE STRING */
663705 int der_encode_printable_string(const unsigned char *in, unsigned long inlen,
689731 int der_decode_utf8_string(const unsigned char *in, unsigned long inlen,
690732 wchar_t *out, unsigned long *outlen);
691733 unsigned long der_utf8_charsize(const wchar_t c);
734 #ifdef LTC_SOURCE
735 /* internal helper functions */
692736 int der_utf8_valid_char(const wchar_t c);
737 #endif /* LTC_SOURCE */
693738 int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen);
694739
695740
743788
744789 #endif
745790
746 /* $Source$ */
747 /* $Revision$ */
748 /* $Date$ */
791 /* ref: $Format:%D$ */
792 /* git commit: $Format:%H$ */
793 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* PKCS Header Info */
110
211 /* ===> PKCS #1 -- RSA Cryptography <=== */
1221 {
1322 LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
1423 LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */
15 LTC_PKCS_1_PSS = 3 /* PKCS #1 v2.1 signature padding */
24 LTC_PKCS_1_PSS = 3, /* PKCS #1 v2.1 signature padding */
25 LTC_PKCS_1_V1_5_NA1 = 4 /* PKCS #1 v1.5 padding - No ASN.1 (\sa ltc_pkcs_1_v1_5_blocks) */
1626 };
1727
1828 int pkcs_1_mgf1( int hash_idx,
6979 /* ===> PKCS #5 -- Password Based Cryptography <=== */
7080 #ifdef LTC_PKCS_5
7181
72 /* Algorithm #1 (old) */
82 /* Algorithm #1 (PBKDF1) */
7383 int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
7484 const unsigned char *salt,
7585 int iteration_count, int hash_idx,
7686 unsigned char *out, unsigned long *outlen);
7787
78 /* Algorithm #1 - OpenSSL-compatible variant for arbitrarily-long keys.
88 /* Algorithm #1 (PBKDF1) - OpenSSL-compatible variant for arbitrarily-long keys.
7989 Compatible with EVP_BytesToKey() */
8090 int pkcs_5_alg1_openssl(const unsigned char *password,
8191 unsigned long password_len,
8393 int iteration_count, int hash_idx,
8494 unsigned char *out, unsigned long *outlen);
8595
86 /* Algorithm #2 (new) */
96 /* Algorithm #2 (PBKDF2) */
8797 int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
8898 const unsigned char *salt, unsigned long salt_len,
8999 int iteration_count, int hash_idx,
92102 int pkcs_5_test (void);
93103 #endif /* LTC_PKCS_5 */
94104
95 /* $Source$ */
96 /* $Revision$ */
97 /* $Date$ */
105 /* ref: $Format:%D$ */
106 /* git commit: $Format:%H$ */
107 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /* ---- PRNG Stuff ---- */
110 #ifdef LTC_YARROW
211 struct yarrow_prng {
7180 /** PRNG descriptor */
7281 extern struct ltc_prng_descriptor {
7382 /** Name of the PRNG */
74 char *name;
83 const char *name;
7584 /** size in bytes of exported state */
7685 int export_size;
7786 /** Start a PRNG state
198207 int find_prng(const char *name);
199208 int register_prng(const struct ltc_prng_descriptor *prng);
200209 int unregister_prng(const struct ltc_prng_descriptor *prng);
210 int register_all_prngs(void);
201211 int prng_is_valid(int idx);
202212 LTC_MUTEX_PROTO(ltc_prng_mutex)
203213
216226 #endif
217227
218228
219 /* $Source$ */
220 /* $Revision$ */
221 /* $Date$ */
229 /* ref: $Format:%D$ */
230 /* git commit: $Format:%H$ */
231 /* commit time: $Format:%ai$ */
1313 /**
1414 Initialize an BLAKE2B MAC context.
1515 @param st The BLAKE2B MAC state
16 @param outlen The size of the MAC output (octets)
1617 @param key The secret key
1718 @param keylen The length of the secret key (octets)
1819 @return CRYPT_OK if successful
5859 }
5960
6061 #endif
62
63 /* ref: $Format:%D$ */
64 /* git commit: $Format:%H$ */
65 /* commit time: $Format:%ai$ */
7676 }
7777
7878 #endif
79
80 /* ref: $Format:%D$ */
81 /* git commit: $Format:%H$ */
82 /* commit time: $Format:%ai$ */
4141 }
4242
4343 #endif
44
45 /* ref: $Format:%D$ */
46 /* git commit: $Format:%H$ */
47 /* commit time: $Format:%ai$ */
1515 BLAKE2B MAC multiple blocks of memory to produce the authentication tag
1616 @param key The secret key
1717 @param keylen The length of the secret key (octets)
18 @param out [out] Destination of the authentication tag
19 @param outlen [in/out] Max size and resulting size of authentication tag
18 @param mac [out] Destination of the authentication tag
19 @param maclen [in/out] Max size and resulting size of authentication tag
2020 @param in The data to BLAKE2B MAC
2121 @param inlen The length of the data to BLAKE2B MAC (octets)
2222 @param ... tuples of (data,len) pairs to BLAKE2B MAC, terminated with a (NULL,x) (x=don't care)
5555 }
5656
5757 #endif
58
59 /* ref: $Format:%D$ */
60 /* git commit: $Format:%H$ */
61 /* commit time: $Format:%ai$ */
1313 /**
1414 Initialize an BLAKE2S MAC context.
1515 @param st The BLAKE2S MAC state
16 @param outlen The size of the MAC output (octets)
1617 @param key The secret key
1718 @param keylen The length of the secret key (octets)
1819 @return CRYPT_OK if successful
5859 }
5960
6061 #endif
62
63 /* ref: $Format:%D$ */
64 /* git commit: $Format:%H$ */
65 /* commit time: $Format:%ai$ */
7676 }
7777
7878 #endif
79
80 /* ref: $Format:%D$ */
81 /* git commit: $Format:%H$ */
82 /* commit time: $Format:%ai$ */
4141 }
4242
4343 #endif
44
45 /* ref: $Format:%D$ */
46 /* git commit: $Format:%H$ */
47 /* commit time: $Format:%ai$ */
1515 BLAKE2S MAC multiple blocks of memory to produce the authentication tag
1616 @param key The secret key
1717 @param keylen The length of the secret key (octets)
18 @param out [out] Destination of the authentication tag
19 @param outlen [in/out] Max size and resulting size of authentication tag
18 @param mac [out] Destination of the authentication tag
19 @param maclen [in/out] Max size and resulting size of authentication tag
2020 @param in The data to BLAKE2S MAC
2121 @param inlen The length of the data to BLAKE2S MAC (octets)
2222 @param ... tuples of (data,len) pairs to BLAKE2S MAC, terminated with a (NULL,x) (x=don't care)
5555 }
5656
5757 #endif
58
59 /* ref: $Format:%D$ */
60 /* git commit: $Format:%H$ */
61 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7068
7169 #endif
7270
73 /* $Source$ */
74 /* $Revision$ */
75 /* $Date$ */
71 /* ref: $Format:%D$ */
72 /* git commit: $Format:%H$ */
73 /* commit time: $Format:%ai$ */
7674
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8785
8886 #endif
8987
90 /* $Source$ */
91 /* $Revision$ */
92 /* $Date$ */
88 /* ref: $Format:%D$ */
89 /* git commit: $Format:%H$ */
90 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6361
6462 #endif
6563
66 /* $Source$ */
67 /* $Revision$ */
68 /* $Date$ */
64 /* ref: $Format:%D$ */
65 /* git commit: $Format:%H$ */
66 /* commit time: $Format:%ai$ */
6967
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6563
6664 #endif
6765
68 /* $Source$ */
69 /* $Revision$ */
70 /* $Date$ */
66 /* ref: $Format:%D$ */
67 /* git commit: $Format:%H$ */
68 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
8482
8583 #endif
8684
87 /* $Source$ */
88 /* $Revision$ */
89 /* $Date$ */
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7169
7270 #endif
7371
74 /* $Source$ */
75 /* $Revision$ */
76 /* $Date$ */
72 /* ref: $Format:%D$ */
73 /* git commit: $Format:%H$ */
74 /* commit time: $Format:%ai$ */
7775
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
103101
104102 #endif
105103
106 /* $Source$ */
107 /* $Revision$ */
108 /* $Date$ */
104 /* ref: $Format:%D$ */
105 /* git commit: $Format:%H$ */
106 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9088
9189 #endif
9290
93 /* $Source$ */
94 /* $Revision$ */
95 /* $Date$ */
91 /* ref: $Format:%D$ */
92 /* git commit: $Format:%H$ */
93 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7674 zeromem((hmac->key) + keylen, (size_t)(LTC_HMAC_BLOCKSIZE - keylen));
7775 }
7876
79 /* Create the initial vector for step (3) */
77 /* Create the initialization vector for step (3) */
8078 for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
8179 buf[i] = hmac->key[i] ^ 0x36;
8280 }
104102
105103 #endif
106104
107 /* $Source$ */
108 /* $Revision$ */
109 /* $Date$ */
105 /* ref: $Format:%D$ */
106 /* git commit: $Format:%H$ */
107 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8280 #endif
8381
8482
85 /* $Source$ */
86 /* $Revision$ */
87 /* $Date$ */
83 /* ref: $Format:%D$ */
84 /* git commit: $Format:%H$ */
85 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
8684 #endif
8785
8886
89 /* $Source$ */
90 /* $Revision$ */
91 /* $Date$ */
87 /* ref: $Format:%D$ */
88 /* git commit: $Format:%H$ */
89 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3735 #endif
3836
3937
40 /* $Source$ */
41 /* $Revision$ */
42 /* $Date$ */
38 /* ref: $Format:%D$ */
39 /* git commit: $Format:%H$ */
40 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8078 #endif
8179
8280
83 /* $Source$ */
84 /* $Revision$ */
85 /* $Date$ */
81 /* ref: $Format:%D$ */
82 /* git commit: $Format:%H$ */
83 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8785
8886 #endif
8987
90 /* $Source$ */
91 /* $Revision$ */
92 /* $Date$ */
88 /* ref: $Format:%D$ */
89 /* git commit: $Format:%H$ */
90 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9593
9694 #endif
9795
98 /* $Source$ */
99 /* $Revision$ */
100 /* $Date$ */
96 /* ref: $Format:%D$ */
97 /* git commit: $Format:%H$ */
98 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7977
8078 #endif
8179
82 /* $Source$ */
83 /* $Revision$ */
84 /* $Date$ */
80 /* ref: $Format:%D$ */
81 /* git commit: $Format:%H$ */
82 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
8482
8583 #endif
8684
87 /* $Source$ */
88 /* $Revision$ */
89 /* $Date$ */
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8684 #endif
8785
8886
89 /* $Source$ */
90 /* $Revision$ */
91 /* $Date$ */
87 /* ref: $Format:%D$ */
88 /* git commit: $Format:%H$ */
89 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5250 return CRYPT_OK;
5351 }
5452
55 static void four_rounds(pelican_state *pelmac)
53 static void _four_rounds(pelican_state *pelmac)
5654 {
5755 ulong32 s0, s1, s2, s3, t0, t1, t2, t3;
5856 int r;
115113 for (x = 0; x < 16; x += sizeof(LTC_FAST_TYPE)) {
116114 *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)pelmac->state + x)) ^= *(LTC_FAST_TYPE_PTR_CAST((unsigned char *)in + x));
117115 }
118 four_rounds(pelmac);
116 _four_rounds(pelmac);
119117 in += 16;
120118 inlen -= 16;
121119 }
125123 while (inlen--) {
126124 pelmac->state[pelmac->buflen++] ^= *in++;
127125 if (pelmac->buflen == 16) {
128 four_rounds(pelmac);
126 _four_rounds(pelmac);
129127 pelmac->buflen = 0;
130128 }
131129 }
149147 }
150148
151149 if (pelmac->buflen == 16) {
152 four_rounds(pelmac);
150 _four_rounds(pelmac);
153151 pelmac->buflen = 0;
154152 }
155153 pelmac->state[pelmac->buflen++] ^= 0x80;
160158
161159 #endif
162160
163 /* $Source$ */
164 /* $Revision$ */
165 /* $Date$ */
161 /* ref: $Format:%D$ */
162 /* git commit: $Format:%H$ */
163 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5351
5452 #endif
5553
56 /* $Source$ */
57 /* $Revision$ */
58 /* $Date$ */
54 /* ref: $Format:%D$ */
55 /* git commit: $Format:%H$ */
56 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6866 #endif
6967
7068
71 /* $Source$ */
72 /* $Revision$ */
73 /* $Date$ */
69 /* ref: $Format:%D$ */
70 /* git commit: $Format:%H$ */
71 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8886
8987 #endif
9088
91 /* $Source$ */
92 /* $Revision$ */
93 /* $Date$ */
89 /* ref: $Format:%D$ */
90 /* git commit: $Format:%H$ */
91 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
144142
145143 #endif
146144
147 /* $Source$ */
148 /* $Revision$ */
149 /* $Date$ */
145 /* ref: $Format:%D$ */
146 /* git commit: $Format:%H$ */
147 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6866
6967 #endif
7068
71 /* $Source$ */
72 /* $Revision$ */
73 /* $Date$ */
69 /* ref: $Format:%D$ */
70 /* git commit: $Format:%H$ */
71 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
8381
8482 #endif
8583
86 /* $Source$ */
87 /* $Revision$ */
88 /* $Date$ */
84 /* ref: $Format:%D$ */
85 /* git commit: $Format:%H$ */
86 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3331
3432 #endif
3533
36 /* $Source$ */
37 /* $Revision$ */
38 /* $Date$ */
34 /* ref: $Format:%D$ */
35 /* git commit: $Format:%H$ */
36 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9492
9593 #endif
9694
97 /* $Source$ */
98 /* $Revision$ */
99 /* $Date$ */
95 /* ref: $Format:%D$ */
96 /* git commit: $Format:%H$ */
97 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3836
3937 #endif
4038
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */
163163 /**
164164 Terminate a POLY1305 session
165165 @param st The POLY1305 state
166 @param out [out] The destination of the POLY1305 authentication tag
167 @param outlen [in/out] The max size and resulting size of the POLY1305 authentication tag
166 @param mac [out] The destination of the POLY1305 authentication tag
167 @param maclen [in/out] The max size and resulting size of the POLY1305 authentication tag
168168 @return CRYPT_OK if successful
169169 */
170170 int poly1305_done(poly1305_state *st, unsigned char *mac, unsigned long *maclen)
261261 }
262262
263263 #endif
264
265 /* ref: $Format:%D$ */
266 /* git commit: $Format:%H$ */
267 /* commit time: $Format:%ai$ */
8181 }
8282
8383 #endif
84
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
4646 }
4747
4848 #endif
49
50 /* ref: $Format:%D$ */
51 /* git commit: $Format:%H$ */
52 /* commit time: $Format:%ai$ */
2020 POLY1305 multiple blocks of memory to produce the authentication tag
2121 @param key The secret key
2222 @param keylen The length of the secret key (octets)
23 @param out [out] Destination of the authentication tag
24 @param outlen [in/out] Max size and resulting size of authentication tag
23 @param mac [out] Destination of the authentication tag
24 @param maclen [in/out] Max size and resulting size of authentication tag
2525 @param in The data to POLY1305
2626 @param inlen The length of the data to POLY1305 (octets)
2727 @param ... tuples of (data,len) pairs to POLY1305, terminated with a (NULL,x) (x=don't care)
6060 }
6161
6262 #endif
63
64 /* ref: $Format:%D$ */
65 /* git commit: $Format:%H$ */
66 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7068
7169 #endif
7270
73 /* $Source$ */
74 /* $Revision$ */
75 /* $Date$ */
71 /* ref: $Format:%D$ */
72 /* git commit: $Format:%H$ */
73 /* commit time: $Format:%ai$ */
7674
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8785
8886 #endif
8987
90 /* $Source$ */
91 /* $Revision$ */
92 /* $Date$ */
88 /* ref: $Format:%D$ */
89 /* git commit: $Format:%H$ */
90 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
10199
102100 #endif
103101
104 /* $Source$ */
105 /* $Revision$ */
106 /* $Date$ */
102 /* ref: $Format:%D$ */
103 /* git commit: $Format:%H$ */
104 /* commit time: $Format:%ai$ */
107105
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6563
6664 #endif
6765
68 /* $Source$ */
69 /* $Revision$ */
70 /* $Date$ */
66 /* ref: $Format:%D$ */
67 /* git commit: $Format:%H$ */
68 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
8482
8583 #endif
8684
87 /* $Source$ */
88 /* $Revision$ */
89 /* $Date$ */
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6866
6967 #endif
7068
71 /* $Source$ */
72 /* $Revision$ */
73 /* $Date$ */
69 /* ref: $Format:%D$ */
70 /* git commit: $Format:%H$ */
71 /* commit time: $Format:%ai$ */
7472
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
573571 };
574572
575573 /* find a hole and free as required, return -1 if no hole found */
576 static int find_hole(void)
574 static int _find_hole(void)
577575 {
578576 unsigned x;
579577 int y, z;
609607 }
610608
611609 /* determine if a base is already in the cache and if so, where */
612 static int find_base(ecc_point *g)
610 static int _find_base(ecc_point *g)
613611 {
614612 int x;
615613 for (x = 0; x < FP_ENTRIES; x++) {
627625 }
628626
629627 /* add a new base to the cache */
630 static int add_entry(int idx, ecc_point *g)
628 static int _add_entry(int idx, ecc_point *g)
631629 {
632630 unsigned x, y;
633631
669667 * The algorithm builds patterns in increasing bit order by first making all
670668 * single bit input patterns, then all two bit input patterns and so on
671669 */
672 static int build_lut(int idx, void *a, void *modulus, void *mp, void *mu)
670 static int _build_lut(int idx, void *a, void *modulus, void *mp, void *mu)
673671 {
674672 unsigned x, y, err, bitlen, lut_gap;
675673 void *tmp;
776774 }
777775
778776 /* perform a fixed point ECC mulmod */
779 static int accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus, void *mp, int map)
777 static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus, void *mp, int map)
780778 {
781779 unsigned char kb[128];
782780 int x;
899897
900898 #ifdef LTC_ECC_SHAMIR
901899 /* perform a fixed point ECC mulmod */
902 static int accel_fp_mul2add(int idx1, int idx2,
900 static int _accel_fp_mul2add(int idx1, int idx2,
903901 void *kA, void *kB,
904902 ecc_point *R, void *a, void *modulus, void *mp)
905903 {
11221120 mu = NULL;
11231121 LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
11241122 /* find point */
1125 idx1 = find_base(A);
1123 idx1 = _find_base(A);
11261124
11271125 /* no entry? */
11281126 if (idx1 == -1) {
11291127 /* find hole and add it */
1130 if ((idx1 = find_hole()) >= 0) {
1131 if ((err = add_entry(idx1, A)) != CRYPT_OK) {
1128 if ((idx1 = _find_hole()) >= 0) {
1129 if ((err = _add_entry(idx1, A)) != CRYPT_OK) {
11321130 goto LBL_ERR;
11331131 }
11341132 }
11391137 }
11401138
11411139 /* find point */
1142 idx2 = find_base(B);
1140 idx2 = _find_base(B);
11431141
11441142 /* no entry? */
11451143 if (idx2 == -1) {
11461144 /* find hole and add it */
1147 if ((idx2 = find_hole()) >= 0) {
1148 if ((err = add_entry(idx2, B)) != CRYPT_OK) {
1145 if ((idx2 = _find_hole()) >= 0) {
1146 if ((err = _add_entry(idx2, B)) != CRYPT_OK) {
11491147 goto LBL_ERR;
11501148 }
11511149 }
11691167 }
11701168
11711169 /* build the LUT */
1172 if ((err = build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) {
1170 if ((err = _build_lut(idx1, a, modulus, mp, mu)) != CRYPT_OK) {
11731171 goto LBL_ERR;;
11741172 }
11751173 }
11901188 }
11911189
11921190 /* build the LUT */
1193 if ((err = build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) {
1191 if ((err = _build_lut(idx2, a, modulus, mp, mu)) != CRYPT_OK) {
11941192 goto LBL_ERR;;
11951193 }
11961194 }
12011199 /* compute mp */
12021200 if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12031201 }
1204 err = accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp);
1202 err = _accel_fp_mul2add(idx1, idx2, kA, kB, C, a, modulus, mp);
12051203 } else {
12061204 err = ltc_ecc_mul2add(A, kA, B, kB, C, a, modulus);
12071205 }
12351233 mu = NULL;
12361234 LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
12371235 /* find point */
1238 idx = find_base(G);
1236 idx = _find_base(G);
12391237
12401238 /* no entry? */
12411239 if (idx == -1) {
12421240 /* find hole and add it */
1243 idx = find_hole();
1241 idx = _find_hole();
12441242
12451243 if (idx >= 0) {
1246 if ((err = add_entry(idx, G)) != CRYPT_OK) {
1244 if ((err = _add_entry(idx, G)) != CRYPT_OK) {
12471245 goto LBL_ERR;
12481246 }
12491247 }
12681266 }
12691267
12701268 /* build the LUT */
1271 if ((err = build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
1269 if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
12721270 goto LBL_ERR;;
12731271 }
12741272 }
12781276 /* compute mp */
12791277 if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { goto LBL_ERR; }
12801278 }
1281 err = accel_fp_mul(idx, k, R, a, modulus, mp, map);
1279 err = _accel_fp_mul(idx, k, R, a, modulus, mp, map);
12821280 } else {
12831281 err = ltc_ecc_mulmod(k, G, R, a, modulus, map);
12841282 }
12941292 }
12951293
12961294 /* helper function for freeing the cache ... must be called with the cache mutex locked */
1297 static void ltc_ecc_fp_free_cache(void)
1295 static void _ltc_ecc_fp_free_cache(void)
12981296 {
12991297 unsigned x, y;
13001298 for (x = 0; x < FP_ENTRIES; x++) {
13191317 void ltc_ecc_fp_free(void)
13201318 {
13211319 LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
1322 ltc_ecc_fp_free_cache();
1320 _ltc_ecc_fp_free_cache();
13231321 LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
13241322 }
13251323
13381336 void *mu = NULL;
13391337
13401338 LTC_MUTEX_LOCK(&ltc_ecc_fp_lock);
1341 if ((idx = find_base(g)) >= 0) {
1339 if ((idx = _find_base(g)) >= 0) {
13421340 /* it is already in the cache ... just check that the LUT is initialized */
13431341 if(fp_cache[idx].lru_count >= 2) {
13441342 LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
13461344 }
13471345 }
13481346
1349 if(idx == -1 && (idx = find_hole()) == -1) {
1347 if(idx == -1 && (idx = _find_hole()) == -1) {
13501348 err = CRYPT_BUFFER_OVERFLOW;
13511349 goto LBL_ERR;
13521350 }
1353 if ((err = add_entry(idx, g)) != CRYPT_OK) {
1351 if ((err = _add_entry(idx, g)) != CRYPT_OK) {
13541352 goto LBL_ERR;
13551353 }
13561354 /* compute mp */
13671365 }
13681366
13691367 /* build the LUT */
1370 if ((err = build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
1368 if ((err = _build_lut(idx, a, modulus, mp, mu)) != CRYPT_OK) {
13711369 goto LBL_ERR;
13721370 }
13731371 fp_cache[idx].lru_count = 2;
15051503 /*
15061504 * start with an empty cache
15071505 */
1508 ltc_ecc_fp_free_cache();
1506 _ltc_ecc_fp_free_cache();
15091507
15101508 /*
15111509 * decode the input packet: It consists of a sequence with a few
15751573 ERR_OUT:
15761574 if(asn1_list)
15771575 XFREE(asn1_list);
1578 ltc_ecc_fp_free_cache();
1576 _ltc_ecc_fp_free_cache();
15791577 LTC_MUTEX_UNLOCK(&ltc_ecc_fp_lock);
15801578 return err;
15811579 }
15831581 #endif
15841582
15851583
1586 /* $Source$ */
1587 /* $Revision$ */
1588 /* $Date$ */
1589
1584 /* ref: $Format:%D$ */
1585 /* git commit: $Format:%H$ */
1586 /* commit time: $Format:%ai$ */
1587
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 #define DESC_DEF_ONLY
8785 }
8886
8987 /* ---- trivial ---- */
90 static int set_int(void *a, unsigned long b)
88 static int set_int(void *a, ltc_mp_digit b)
9189 {
9290 LTC_ARGCHK(a != NULL);
9391 return mpi_to_ltc_error(mp_set_int(a, b));
129127 }
130128 }
131129
132 static int compare_d(void *a, unsigned long b)
130 static int compare_d(void *a, ltc_mp_digit b)
133131 {
134132 int ret;
135133 LTC_ARGCHK(a != NULL);
211209 return mpi_to_ltc_error(mp_add(a, b, c));
212210 }
213211
214 static int addi(void *a, unsigned long b, void *c)
212 static int addi(void *a, ltc_mp_digit b, void *c)
215213 {
216214 LTC_ARGCHK(a != NULL);
217215 LTC_ARGCHK(c != NULL);
227225 return mpi_to_ltc_error(mp_sub(a, b, c));
228226 }
229227
230 static int subi(void *a, unsigned long b, void *c)
228 static int subi(void *a, ltc_mp_digit b, void *c)
231229 {
232230 LTC_ARGCHK(a != NULL);
233231 LTC_ARGCHK(c != NULL);
243241 return mpi_to_ltc_error(mp_mul(a, b, c));
244242 }
245243
246 static int muli(void *a, unsigned long b, void *c)
244 static int muli(void *a, ltc_mp_digit b, void *c)
247245 {
248246 LTC_ARGCHK(a != NULL);
249247 LTC_ARGCHK(c != NULL);
283281 }
284282
285283 /* modi */
286 static int modi(void *a, unsigned long b, unsigned long *c)
284 static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
287285 {
288286 mp_digit tmp;
289287 int err;
414412 LTC_ARGCHK(a != NULL);
415413 LTC_ARGCHK(c != NULL);
416414 if (b == 0) {
417 b = 8;
415 b = LTC_MILLER_RABIN_REPS;
418416 } /* if */
419417 err = mpi_to_ltc_error(mp_prime_is_prime(a, b, c));
420418 *c = (*c == MP_YES) ? LTC_MP_YES : LTC_MP_NO;
519517
520518 #endif
521519
522 /* $Source$ */
523 /* $Revision$ */
524 /* $Date$ */
520 /* ref: $Format:%D$ */
521 /* git commit: $Format:%H$ */
522 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5452 va_end(args);
5553 }
5654
55 void ltc_cleanup_multi(void **a, ...)
56 {
57 void **cur = a;
58 va_list args;
59
60 va_start(args, a);
61 while (cur != NULL) {
62 if (*cur != NULL) {
63 mp_clear(*cur);
64 *cur = NULL;
65 }
66 cur = va_arg(args, void**);
67 }
68 va_end(args);
69 return;
70 }
71
5772 #endif
5873
59 /* $Source$ */
60 /* $Revision$ */
61 /* $Date$ */
74 /* ref: $Format:%D$ */
75 /* git commit: $Format:%H$ */
76 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 /**
11 @file radix_to_bin.c
12 Convert data from a specific radix to binary.
13 Steffen Jaeckel
14 */
15
16 /**
17 Convert data from a specific radix to binary
18
19 The default MPI descriptors #ltm_desc, #tfm_desc and #gmp_desc
20 have the following restrictions on parameters:
21
22 \p in - NUL-terminated char buffer
23
24 \p radix - 2..64
25
26 @param in The input
27 @param radix The radix of the input
28 @param out The output buffer
29 @param len [in/out] The length of the output buffer
30
31 @return CRYPT_OK on success.
32 */
33 int radix_to_bin(const void *in, int radix, void *out, unsigned long *len)
34 {
35 unsigned long l;
36 void* mpi;
37 int err;
38
39 LTC_ARGCHK(in != NULL);
40 LTC_ARGCHK(len != NULL);
41
42 if ((err = mp_init(&mpi)) != CRYPT_OK) return err;
43 if ((err = mp_read_radix(mpi, in, radix)) != CRYPT_OK) goto LBL_ERR;
44
45 if ((l = mp_unsigned_bin_size(mpi)) > *len) {
46 *len = l;
47 err = CRYPT_BUFFER_OVERFLOW;
48 goto LBL_ERR;
49 }
50 *len = l;
51
52 if ((err = mp_to_unsigned_bin(mpi, out)) != CRYPT_OK) goto LBL_ERR;
53
54 LBL_ERR:
55 mp_clear(mpi);
56 return err;
57 }
58
59 /* ref: $Format:%D$ */
60 /* git commit: $Format:%H$ */
61 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
87 */
98 #include "tomcrypt.h"
109
11 #if defined(LTC_MDSA) || defined(LTC_MECC)
10 #ifdef LTC_MDSA
1211 /**
1312 Generate a random number N with given bitlength (note: MSB can be 0)
1413 */
5150 }
5251
5352 /**
54 Generate a random number N in a range: 0 <= N < limit
53 Generate a random number N in a range: 1 <= N < limit
5554 */
56 int rand_bn_range(void *N, void *limit, prng_state *prng, int wprng)
55 int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng)
5756 {
58 int res;
57 int res, bits;
5958
6059 LTC_ARGCHK(N != NULL);
6160 LTC_ARGCHK(limit != NULL);
6261
62 bits = mp_count_bits(limit);
6363 do {
64 res = rand_bn_bits(N, mp_count_bits(limit), prng, wprng);
64 res = rand_bn_bits(N, bits, prng, wprng);
6565 if (res != CRYPT_OK) return res;
66 } while (mp_cmp(N, limit) != LTC_MP_LT);
66 } while (mp_cmp_d(N, 0) != LTC_MP_GT || mp_cmp(N, limit) != LTC_MP_LT);
6767
6868 return CRYPT_OK;
6969 }
7070 #endif
71
72 /* ref: $Format:%D$ */
73 /* git commit: $Format:%H$ */
74 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6765 }
6866
6967 /* test */
70 if ((err = mp_prime_is_prime(N, 8, &res)) != CRYPT_OK) {
68 if ((err = mp_prime_is_prime(N, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) {
7169 XFREE(buf);
7270 return err;
7371 }
8482 #endif /* LTC_NO_MATH */
8583
8684
87 /* $Source$ */
88 /* $Revision$ */
89 /* $Date$ */
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 #define DESC_DEF_ONLY
8381 }
8482
8583 /* ---- trivial ---- */
86 static int set_int(void *a, unsigned long b)
84 static int set_int(void *a, ltc_mp_digit b)
8785 {
8886 LTC_ARGCHK(a != NULL);
8987 fp_set(a, b);
128126 return 0;
129127 }
130128
131 static int compare_d(void *a, unsigned long b)
129 static int compare_d(void *a, ltc_mp_digit b)
132130 {
133131 int ret;
134132 LTC_ARGCHK(a != NULL);
213211 return CRYPT_OK;
214212 }
215213
216 static int addi(void *a, unsigned long b, void *c)
214 static int addi(void *a, ltc_mp_digit b, void *c)
217215 {
218216 LTC_ARGCHK(a != NULL);
219217 LTC_ARGCHK(c != NULL);
231229 return CRYPT_OK;
232230 }
233231
234 static int subi(void *a, unsigned long b, void *c)
232 static int subi(void *a, ltc_mp_digit b, void *c)
235233 {
236234 LTC_ARGCHK(a != NULL);
237235 LTC_ARGCHK(c != NULL);
249247 return CRYPT_OK;
250248 }
251249
252 static int muli(void *a, unsigned long b, void *c)
250 static int muli(void *a, ltc_mp_digit b, void *c)
253251 {
254252 LTC_ARGCHK(a != NULL);
255253 LTC_ARGCHK(c != NULL);
266264 return CRYPT_OK;
267265 }
268266
269 /* sqrtmod_prime */
270 static int sqrtmod_prime(void *a, void *b, void *c)
271 {
272 LTC_ARGCHK(a != NULL);
273 LTC_ARGCHK(b != NULL);
274 LTC_ARGCHK(c != NULL);
275 fprintf(stderr, "TFM does not support sqrtmod_prime\n"); /* XXX-FIXME */
276 return CRYPT_ERROR;
277 }
278
279267 /* div */
280268 static int divide(void *a, void *b, void *c, void *d)
281269 {
293281 }
294282
295283 /* modi */
296 static int modi(void *a, unsigned long b, unsigned long *c)
284 static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
297285 {
298286 fp_digit tmp;
299287 int err;
426414 {
427415 LTC_ARGCHK(a != NULL);
428416 LTC_ARGCHK(c != NULL);
429 (void)b;
430 *c = (fp_isprime(a) == FP_YES) ? LTC_MP_YES : LTC_MP_NO;
417 if (b == 0) {
418 b = LTC_MILLER_RABIN_REPS;
419 } /* if */
420 *c = (fp_isprime_ex(a, b) == FP_YES) ? LTC_MP_YES : LTC_MP_NO;
431421 return CRYPT_OK;
432422 }
433423
547537 @param Q The point to add
548538 @param R [out] The destination of the double
549539 @param modulus The modulus of the field the ECC curve is in
550 @param mp The "b" value from montgomery_setup()
540 @param Mp The "b" value from montgomery_setup()
551541 @return CRYPT_OK on success
552542 */
553543 static int tfm_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *Mp)
708698
709699 #endif
710700
701 static int set_rand(void *a, int size)
702 {
703 LTC_ARGCHK(a != NULL);
704 fp_rand(a, size);
705 return CRYPT_OK;
706 }
707
711708 const ltc_math_descriptor tfm_desc = {
712709
713710 "TomsFastMath",
743740 &mul,
744741 &muli,
745742 &sqr,
746 &sqrtmod_prime,
747743 &divide,
748744 &div_2,
749745 &modi,
798794 &addmod,
799795 &submod,
800796
801 NULL,
797 set_rand,
802798
803799 };
804800
805801
806802 #endif
807803
808 /* $Source$ */
809 /* $Revision$ */
810 /* $Date$ */
804 /* ref: $Format:%D$ */
805 /* git commit: $Format:%H$ */
806 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
119117 adler32_init(&ctx);
120118 adler32_update(&ctx, in, strlen(in));
121119 adler32_finish(&ctx, out, 4);
122 if (XMEMCMP(adler32, out, 4)) {
123 #ifdef LTC_TEST_DBG
124 ulong32 _out, _adler32;
125 LOAD32H(_out, out);
126 LOAD32H(_adler32, adler32);
127 printf("adler32 fail! Is: 0x%x Should: 0x%x\n", _out, _adler32);
128 #endif
120 if (compare_testvector(adler32, 4, out, 4, "adler32", 0)) {
129121 return CRYPT_FAIL_TESTVECTOR;
130122 }
131123 return CRYPT_OK;
133125 }
134126 #endif
135127
136 /* $Source$ */
137 /* $Revision$ */
138 /* $Date$ */
128 /* ref: $Format:%D$ */
129 /* git commit: $Format:%H$ */
130 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
192190 #endif
193191
194192
195 /* $Source$ */
196 /* $Revision$ */
197 /* $Date$ */
193 /* ref: $Format:%D$ */
194 /* git commit: $Format:%H$ */
195 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
120118 #endif
121119
122120
123 /* $Source$ */
124 /* $Revision$ */
125 /* $Date$ */
121 /* ref: $Format:%D$ */
122 /* git commit: $Format:%H$ */
123 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2826
2927
3028
31 /* $Source$ */
32 /* $Revision$ */
33 /* $Date$ */
29 /* ref: $Format:%D$ */
30 /* git commit: $Format:%H$ */
31 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 /**
12 @file compare_testvector.c
13 Function to compare two testvectors and print a (detailed) error-message if required, Steffen Jaeckel
14 */
15
16 #if defined(LTC_TEST) && defined(LTC_TEST_DBG)
17 static void _print_hex(const char* what, const void* v, const unsigned long l)
18 {
19 const unsigned char* p = v;
20 unsigned long x, y = 0, z;
21 fprintf(stderr, "%s contents: \n", what);
22 for (x = 0; x < l; ) {
23 fprintf(stderr, "%02X ", p[x]);
24 if (!(++x % 16) || x == l) {
25 if((x % 16) != 0) {
26 z = 16 - (x % 16);
27 if(z >= 8)
28 fprintf(stderr, " ");
29 for (; z != 0; --z) {
30 fprintf(stderr, " ");
31 }
32 }
33 fprintf(stderr, " | ");
34 for(; y < x; y++) {
35 if((y % 8) == 0)
36 fprintf(stderr, " ");
37 if(isgraph(p[y]))
38 fprintf(stderr, "%c", p[y]);
39 else
40 fprintf(stderr, ".");
41 }
42 fprintf(stderr, "\n");
43 }
44 else if((x % 8) == 0) {
45 fprintf(stderr, " ");
46 }
47 }
48 }
49 #endif
50
51 /**
52 Compare two test-vectors
53
54 @param is The data as it is
55 @param is_len The length of is
56 @param should The data as it should
57 @param should_len The length of should
58 @param what The type of the data
59 @param which The iteration count
60 @return 0 on equality, -1 or 1 on difference
61 */
62 int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
63 {
64 int res = 0;
65 if(is_len != should_len)
66 res = is_len > should_len ? -1 : 1;
67 else
68 res = XMEMCMP(is, should, is_len);
69
70 #if defined(LTC_TEST) && defined(LTC_TEST_DBG)
71 if (res != 0) {
72 fprintf(stderr, "Testvector #%i of %s failed:\n", which, what);
73 _print_hex("SHOULD", should, should_len);
74 _print_hex("IS ", is, is_len);
75 }
76 #else
77 LTC_UNUSED_PARAM(which);
78 LTC_UNUSED_PARAM(what);
79 #endif
80
81 return res;
82 }
83
84 /* ref: $Format:%D$ */
85 /* git commit: $Format:%H$ */
86 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
190188 crc32_init(&ctx);
191189 crc32_update(&ctx, in, strlen(in));
192190 crc32_finish(&ctx, out, 4);
193 if (XMEMCMP(crc32, out, 4)) {
194 #ifdef LTC_TEST_DBG
195 ulong32 _out, _crc32;
196 LOAD32H(_out, out);
197 LOAD32H(_crc32, crc32);
198 printf("crc32 fail! Is: 0x%x Should: 0x%x\n", _out, _crc32);
199 #endif
191 if (compare_testvector(crc32, 4, out, 4, "CRC32", 0)) {
200192 return CRYPT_FAIL_TESTVECTOR;
201193 }
202194 return CRYPT_OK;
204196 }
205197 #endif
206198
207 /* $Source$ */
208 /* $Revision$ */
209 /* $Date$ */
199 /* ref: $Format:%D$ */
200 /* git commit: $Format:%H$ */
201 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #define NAME(s) #s
1816
1917 const char *crypt_build_settings =
20 "LibTomCrypt " SCRYPT " (Tom St Denis, tomstdenis@gmail.com)\n"
18 "LibTomCrypt " SCRYPT " (www.libtom.net)\n"
2119 "LibTomCrypt is public domain software.\n"
2220 #if defined(INCLUDE_BUILD_DATE)
2321 "Built on " __DATE__ " at " __TIME__ "\n"
4442 #else
4543 "disabled\n"
4644 #endif
47 "Ciphers built-in:\n"
45 "\nCiphers built-in:\n"
4846 #if defined(LTC_BLOWFISH)
4947 " Blowfish\n"
5048 #endif
302300 " SOBER128\n"
303301 #endif
304302
305 "\nPK Algs:\n"
303 "\nPK Crypto:\n"
306304 #if defined(LTC_MRSA)
307305 " RSA"
308306 #if defined(LTC_RSA_BLINDING) && defined(LTC_RSA_CRT_HARDENING)
330328 #if defined(LTC_MKAT)
331329 " Katja\n"
332330 #endif
331 #if defined(LTC_PK_MAX_RETRIES)
332 " "NAME_VALUE(LTC_PK_MAX_RETRIES)"\n"
333 #endif
334
335 "\nMPI (Math):\n"
336 #if defined(LTC_MPI)
337 " LTC_MPI\n"
338 #endif
339 #if defined(LTM_DESC)
340 " LTM_DESC\n"
341 #endif
342 #if defined(TFM_DESC)
343 " TFM_DESC\n"
344 #endif
345 #if defined(GMP_DESC)
346 " GMP_DESC\n"
347 #endif
348 #if defined(LTC_MILLER_RABIN_REPS)
349 " "NAME_VALUE(LTC_MILLER_RABIN_REPS)"\n"
350 #endif
333351
334352 "\nCompiler:\n"
335353 #if defined(_WIN64)
362380 #endif
363381
364382 "\nVarious others: "
383 #if defined(ARGTYPE)
384 " " NAME_VALUE(ARGTYPE) " "
385 #endif
365386 #if defined(LTC_ADLER32)
366387 " ADLER32 "
367388 #endif
377398 #if defined(LTC_DER)
378399 " DER "
379400 #endif
380 #if defined(LTC_DER_MAX_PUBKEY_SIZE)
381 " " NAME_VALUE(LTC_DER_MAX_PUBKEY_SIZE) " "
382 #endif
383401 #if defined(LTC_PKCS_1)
384402 " PKCS#1 "
385403 #endif
389407 #if defined(LTC_HKDF)
390408 " HKDF "
391409 #endif
392 #if defined(MPI)
393 " MPI "
394 #endif
395410 #if defined(LTC_DEVRANDOM)
396411 " LTC_DEVRANDOM "
397412 #endif
415430 #endif
416431 #if defined(LTC_TEST)
417432 " LTC_TEST "
433 #endif
434 #if defined(LTC_TEST_DBG)
435 " " NAME_VALUE(LTC_TEST_DBG) " "
418436 #endif
419437 #if defined(LTC_TEST_EXT)
420438 " LTC_TEST_EXT "
455473 #if defined(LTC_PTHREAD)
456474 " LTC_PTHREAD "
457475 #endif
458 #if defined(LTM_DESC)
459 " LTM_DESC "
460 #endif
461 #if defined(TFM_DESC)
462 " TFM_DESC "
463 #endif
464 #if defined(GMP_DESC)
465 " GMP_DESC "
466 #endif
467476 #if defined(LTC_EASY)
468477 " LTC_EASY "
469478 #endif
480489 ;
481490
482491
483 /* $Source$ */
484 /* $Revision$ */
485 /* $Date$ */
492 /* ref: $Format:%D$ */
493 /* git commit: $Format:%H$ */
494 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1513 */
1614
1715 #if (ARGTYPE == 0)
18 void crypt_argchk(char *v, char *s, int d)
16 void crypt_argchk(const char *v, const char *s, int d)
1917 {
2018 fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n",
2119 v, d, s);
2321 }
2422 #endif
2523
26 /* $Source$ */
27 /* $Revision$ */
28 /* $Date$ */
24 /* ref: $Format:%D$ */
25 /* git commit: $Format:%H$ */
26 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2119 LTC_MUTEX_GLOBAL(ltc_cipher_mutex)
2220
2321
24 /* $Source$ */
25 /* $Revision$ */
26 /* $Date$ */
22 /* ref: $Format:%D$ */
23 /* git commit: $Format:%H$ */
24 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3028 return CRYPT_OK;
3129 }
3230
33 /* $Source$ */
34 /* $Revision$ */
35 /* $Date$ */
31 /* ref: $Format:%D$ */
32 /* git commit: $Format:%H$ */
33 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 /**
11 @file crypt_constants.c
12
13 Make various constants available to dynamic languages
14 like Python - Larry Bugbee, February 2013
15
16 LB - Dec 2013 - revised to include compiler define options
17 LB - Mar 2014 - added endianness and word size
18 */
19
20 typedef struct {
21 const char *name;
22 const int value;
23 } crypt_constant;
24
25 #define _C_STRINGIFY(s) { #s, s }
26
27 static const crypt_constant _crypt_constants[] = {
28
29 _C_STRINGIFY(CRYPT_OK),
30 _C_STRINGIFY(CRYPT_ERROR),
31 _C_STRINGIFY(CRYPT_NOP),
32 _C_STRINGIFY(CRYPT_INVALID_KEYSIZE),
33 _C_STRINGIFY(CRYPT_INVALID_ROUNDS),
34 _C_STRINGIFY(CRYPT_FAIL_TESTVECTOR),
35 _C_STRINGIFY(CRYPT_BUFFER_OVERFLOW),
36 _C_STRINGIFY(CRYPT_INVALID_PACKET),
37 _C_STRINGIFY(CRYPT_INVALID_PRNGSIZE),
38 _C_STRINGIFY(CRYPT_ERROR_READPRNG),
39 _C_STRINGIFY(CRYPT_INVALID_CIPHER),
40 _C_STRINGIFY(CRYPT_INVALID_HASH),
41 _C_STRINGIFY(CRYPT_INVALID_PRNG),
42 _C_STRINGIFY(CRYPT_MEM),
43 _C_STRINGIFY(CRYPT_PK_TYPE_MISMATCH),
44 _C_STRINGIFY(CRYPT_PK_NOT_PRIVATE),
45 _C_STRINGIFY(CRYPT_INVALID_ARG),
46 _C_STRINGIFY(CRYPT_FILE_NOTFOUND),
47 _C_STRINGIFY(CRYPT_PK_INVALID_TYPE),
48 _C_STRINGIFY(CRYPT_OVERFLOW),
49 _C_STRINGIFY(CRYPT_UNUSED1),
50 _C_STRINGIFY(CRYPT_INPUT_TOO_LONG),
51 _C_STRINGIFY(CRYPT_PK_INVALID_SIZE),
52 _C_STRINGIFY(CRYPT_INVALID_PRIME_SIZE),
53 _C_STRINGIFY(CRYPT_PK_INVALID_PADDING),
54 _C_STRINGIFY(CRYPT_HASH_OVERFLOW),
55
56 _C_STRINGIFY(PK_PUBLIC),
57 _C_STRINGIFY(PK_PRIVATE),
58
59 _C_STRINGIFY(LTC_ENCRYPT),
60 _C_STRINGIFY(LTC_DECRYPT),
61
62 #ifdef LTC_PKCS_1
63 {"LTC_PKCS_1", 1},
64 /* Block types */
65 _C_STRINGIFY(LTC_PKCS_1_EMSA),
66 _C_STRINGIFY(LTC_PKCS_1_EME),
67
68 /* Padding types */
69 _C_STRINGIFY(LTC_PKCS_1_V1_5),
70 _C_STRINGIFY(LTC_PKCS_1_OAEP),
71 _C_STRINGIFY(LTC_PKCS_1_PSS),
72 _C_STRINGIFY(LTC_PKCS_1_V1_5_NA1),
73 #else
74 {"LTC_PKCS_1", 0},
75 #endif
76
77 #ifdef LTC_MRSA
78 {"LTC_MRSA", 1},
79 #else
80 {"LTC_MRSA", 0},
81 #endif
82
83 #ifdef LTC_MKAT
84 {"LTC_MKAT", 1},
85 _C_STRINGIFY(MIN_KAT_SIZE),
86 _C_STRINGIFY(MAX_KAT_SIZE),
87 #else
88 {"LTC_MKAT", 0},
89 #endif
90
91 #ifdef LTC_MECC
92 {"LTC_MECC", 1},
93 _C_STRINGIFY(ECC_BUF_SIZE),
94 _C_STRINGIFY(ECC_MAXSIZE),
95 #else
96 {"LTC_MECC", 0},
97 #endif
98
99 #ifdef LTC_MDSA
100 {"LTC_MDSA", 1},
101 _C_STRINGIFY(LTC_MDSA_DELTA),
102 _C_STRINGIFY(LTC_MDSA_MAX_GROUP),
103 #else
104 {"LTC_MDSA", 0},
105 #endif
106
107 #ifdef LTC_MILLER_RABIN_REPS
108 _C_STRINGIFY(LTC_MILLER_RABIN_REPS),
109 #endif
110
111 #ifdef LTC_DER
112 /* DER handling */
113 _C_STRINGIFY(LTC_ASN1_EOL),
114 _C_STRINGIFY(LTC_ASN1_BOOLEAN),
115 _C_STRINGIFY(LTC_ASN1_INTEGER),
116 _C_STRINGIFY(LTC_ASN1_SHORT_INTEGER),
117 _C_STRINGIFY(LTC_ASN1_BIT_STRING),
118 _C_STRINGIFY(LTC_ASN1_OCTET_STRING),
119 _C_STRINGIFY(LTC_ASN1_NULL),
120 _C_STRINGIFY(LTC_ASN1_OBJECT_IDENTIFIER),
121 _C_STRINGIFY(LTC_ASN1_IA5_STRING),
122 _C_STRINGIFY(LTC_ASN1_PRINTABLE_STRING),
123 _C_STRINGIFY(LTC_ASN1_UTF8_STRING),
124 _C_STRINGIFY(LTC_ASN1_UTCTIME),
125 _C_STRINGIFY(LTC_ASN1_CHOICE),
126 _C_STRINGIFY(LTC_ASN1_SEQUENCE),
127 _C_STRINGIFY(LTC_ASN1_SET),
128 _C_STRINGIFY(LTC_ASN1_SETOF),
129 _C_STRINGIFY(LTC_ASN1_RAW_BIT_STRING),
130 _C_STRINGIFY(LTC_ASN1_TELETEX_STRING),
131 _C_STRINGIFY(LTC_ASN1_CONSTRUCTED),
132 _C_STRINGIFY(LTC_ASN1_CONTEXT_SPECIFIC),
133 _C_STRINGIFY(LTC_ASN1_GENERALIZEDTIME),
134 #endif
135
136 #ifdef LTC_CTR_MODE
137 {"LTC_CTR_MODE", 1},
138 _C_STRINGIFY(CTR_COUNTER_LITTLE_ENDIAN),
139 _C_STRINGIFY(CTR_COUNTER_BIG_ENDIAN),
140 _C_STRINGIFY(LTC_CTR_RFC3686),
141 #else
142 {"LTC_CTR_MODE", 0},
143 #endif
144 #ifdef LTC_GCM_MODE
145 _C_STRINGIFY(LTC_GCM_MODE_IV),
146 _C_STRINGIFY(LTC_GCM_MODE_AAD),
147 _C_STRINGIFY(LTC_GCM_MODE_TEXT),
148 #endif
149
150 _C_STRINGIFY(LTC_MP_LT),
151 _C_STRINGIFY(LTC_MP_EQ),
152 _C_STRINGIFY(LTC_MP_GT),
153
154 _C_STRINGIFY(LTC_MP_NO),
155 _C_STRINGIFY(LTC_MP_YES),
156
157 _C_STRINGIFY(MAXBLOCKSIZE),
158 _C_STRINGIFY(TAB_SIZE),
159 _C_STRINGIFY(ARGTYPE),
160
161 #ifdef LTM_DESC
162 {"LTM_DESC", 1},
163 #else
164 {"LTM_DESC", 0},
165 #endif
166 #ifdef TFM_DESC
167 {"TFM_DESC", 1},
168 #else
169 {"TFM_DESC", 0},
170 #endif
171 #ifdef GMP_DESC
172 {"GMP_DESC", 1},
173 #else
174 {"GMP_DESC", 0},
175 #endif
176
177 #ifdef LTC_FAST
178 {"LTC_FAST", 1},
179 #else
180 {"LTC_FAST", 0},
181 #endif
182
183 #ifdef LTC_NO_FILE
184 {"LTC_NO_FILE", 1},
185 #else
186 {"LTC_NO_FILE", 0},
187 #endif
188
189 #ifdef ENDIAN_LITTLE
190 {"ENDIAN_LITTLE", 1},
191 #else
192 {"ENDIAN_LITTLE", 0},
193 #endif
194
195 #ifdef ENDIAN_BIG
196 {"ENDIAN_BIG", 1},
197 #else
198 {"ENDIAN_BIG", 0},
199 #endif
200
201 #ifdef ENDIAN_32BITWORD
202 {"ENDIAN_32BITWORD", 1},
203 #else
204 {"ENDIAN_32BITWORD", 0},
205 #endif
206
207 #ifdef ENDIAN_64BITWORD
208 {"ENDIAN_64BITWORD", 1},
209 #else
210 {"ENDIAN_64BITWORD", 0},
211 #endif
212
213 #ifdef ENDIAN_NEUTRAL
214 {"ENDIAN_NEUTRAL", 1},
215 #else
216 {"ENDIAN_NEUTRAL", 0},
217 #endif
218 };
219
220
221 /* crypt_get_constant()
222 * valueout will be the value of the named constant
223 * return -1 if named item not found
224 */
225 int crypt_get_constant(const char* namein, int *valueout) {
226 int i;
227 int _crypt_constants_len = sizeof(_crypt_constants) / sizeof(_crypt_constants[0]);
228 for (i=0; i<_crypt_constants_len; i++) {
229 if (XSTRCMP(_crypt_constants[i].name, namein) == 0) {
230 *valueout = _crypt_constants[i].value;
231 return 0;
232 }
233 }
234 return 1;
235 }
236
237 /* crypt_list_all_constants()
238 * if names_list is NULL, names_list_size will be the minimum
239 * number of bytes needed to receive the complete names_list
240 * if names_list is NOT NULL, names_list must be the addr of
241 * sufficient memory allocated into which the names_list
242 * is to be written. Also, the value in names_list_size
243 * sets the upper bound of the number of characters to be
244 * written.
245 * a -1 return value signifies insufficient space made available
246 */
247 int crypt_list_all_constants(char *names_list, unsigned int *names_list_size) {
248 int i;
249 unsigned int total_len = 0;
250 char number[32], *ptr;
251 int number_len;
252 int count = sizeof(_crypt_constants) / sizeof(_crypt_constants[0]);
253
254 /* calculate amount of memory required for the list */
255 for (i=0; i<count; i++) {
256 total_len += (unsigned int)strlen(_crypt_constants[i].name) + 1;
257 /* the above +1 is for the commas */
258 number_len = snprintf(number, sizeof(number), "%d", _crypt_constants[i].value);
259 if ((number_len < 0) ||
260 ((unsigned int)number_len >= sizeof(number)))
261 return -1;
262 total_len += number_len + 1;
263 /* this last +1 is for newlines (and ending NULL) */
264 }
265
266 if (names_list == NULL) {
267 *names_list_size = total_len;
268 } else {
269 if (total_len > *names_list_size) {
270 return -1;
271 }
272 /* build the names list */
273 ptr = names_list;
274 for (i=0; i<count; i++) {
275 strcpy(ptr, _crypt_constants[i].name);
276 ptr += strlen(_crypt_constants[i].name);
277 strcpy(ptr, ",");
278 ptr += 1;
279
280 number_len = snprintf(number, sizeof(number), "%d", _crypt_constants[i].value);
281 strcpy(ptr, number);
282 ptr += number_len;
283 strcpy(ptr, "\n");
284 ptr += 1;
285 }
286 /* to remove the trailing new-line */
287 ptr -= 1;
288 *ptr = 0;
289 }
290 return 0;
291 }
292
293
294 /* ref: $Format:%D$ */
295 /* git commit: $Format:%H$ */
296 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3533 }
3634
3735
38 /* $Source$ */
39 /* $Revision$ */
40 /* $Date$ */
36 /* ref: $Format:%D$ */
37 /* git commit: $Format:%H$ */
38 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2523 {
2624 int x;
2725
28 LTC_ARGCHK(name != NULL);
29
30 x = find_cipher(name);
31 if (x != -1) return x;
26 if(name != NULL) {
27 x = find_cipher(name);
28 if (x != -1) return x;
29 }
3230
3331 LTC_MUTEX_LOCK(&ltc_cipher_mutex);
3432 for (x = 0; x < TAB_SIZE; x++) {
4442 return -1;
4543 }
4644
47 /* $Source$ */
48 /* $Revision$ */
49 /* $Date$ */
45 /* ref: $Format:%D$ */
46 /* git commit: $Format:%H$ */
47 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3432 return -1;
3533 }
3634
37 /* $Source$ */
38 /* $Revision$ */
39 /* $Date$ */
35 /* ref: $Format:%D$ */
36 /* git commit: $Format:%H$ */
37 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3432 return -1;
3533 }
3634
37 /* $Source$ */
38 /* $Revision$ */
39 /* $Date$ */
35 /* ref: $Format:%D$ */
36 /* git commit: $Format:%H$ */
37 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4341 return z;
4442 }
4543
46 /* $Source$ */
47 /* $Revision$ */
48 /* $Date$ */
44 /* ref: $Format:%D$ */
45 /* git commit: $Format:%H$ */
46 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3432 return -1;
3533 }
3634
37 /* $Source$ */
38 /* $Revision$ */
39 /* $Date$ */
35 /* ref: $Format:%D$ */
36 /* git commit: $Format:%H$ */
37 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2927 return -1;
3028 }
3129
32 /* $Source$ */
33 /* $Revision$ */
34 /* $Date$ */
30 /* ref: $Format:%D$ */
31 /* git commit: $Format:%H$ */
32 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3533 }
3634
3735
38 /* $Source$ */
39 /* $Revision$ */
40 /* $Date$ */
36 /* ref: $Format:%D$ */
37 /* git commit: $Format:%H$ */
38 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
5250 }
5351
5452
55 /* $Source$ */
56 /* $Revision$ */
57 /* $Date$ */
53 /* ref: $Format:%D$ */
54 /* git commit: $Format:%H$ */
55 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2119 LTC_MUTEX_GLOBAL(ltc_hash_mutex)
2220
2321
24 /* $Source$ */
25 /* $Revision$ */
26 /* $Date$ */
22 /* ref: $Format:%D$ */
23 /* git commit: $Format:%H$ */
24 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3028 return CRYPT_OK;
3129 }
3230
33 /* $Source$ */
34 /* $Revision$ */
35 /* $Date$ */
31 /* ref: $Format:%D$ */
32 /* git commit: $Format:%H$ */
33 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1816
1917
2018 #ifdef LTM_DESC
21 void init_LTM(void) {
19 void init_LTM(void)
20 {
2221 ltc_mp = ltm_desc;
2322 }
2423 #endif
2524
2625 #ifdef TFM_DESC
27 void init_TFM(void) {
26 void init_TFM(void)
27 {
2828 ltc_mp = tfm_desc;
2929 }
3030 #endif
3131
32 /* *** use of GMP is untested ***
3332 #ifdef GMP_DESC
34 void init_GMP(void) {
33 void init_GMP(void)
34 {
3535 ltc_mp = gmp_desc;
3636 }
3737 #endif
38 */
3938
4039
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
40 /* ref: $Format:%D$ */
41 /* git commit: $Format:%H$ */
42 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
12 ltc_math_descriptor ltc_mp;
10 /* Initialize ltc_mp to nulls, to force allocation on all platforms, including macOS. */
11 ltc_math_descriptor ltc_mp = { 0 };
12
13 /* ref: $Format:%D$ */
14 /* git commit: $Format:%H$ */
15 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2018 LTC_MUTEX_GLOBAL(ltc_prng_mutex)
2119
2220
23 /* $Source$ */
24 /* $Revision$ */
25 /* $Date$ */
21 /* ref: $Format:%D$ */
22 /* git commit: $Format:%H$ */
23 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3028 return CRYPT_OK;
3129 }
3230
33 /* $Source$ */
34 /* $Revision$ */
35 /* $Date$ */
31 /* ref: $Format:%D$ */
32 /* git commit: $Format:%H$ */
33 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 #ifdef LTC_PRNG_ENABLE_LTC_RNG
11 unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
12 #endif
13
14 /* ref: $Format:%D$ */
15 /* git commit: $Format:%H$ */
16 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 /**
12 @file crypt_register_all_ciphers.c
13
14 Steffen Jaeckel
15 */
16
17 #define REGISTER_CIPHER(h) do {\
18 LTC_ARGCHK((err = register_cipher(h)) != -1); \
19 } while(0)
20
21 int register_all_ciphers(void)
22 {
23 int err = CRYPT_NOP;
24
25 #ifdef LTC_RIJNDAEL
26 #ifdef ENCRYPT_ONLY
27 /* alternative would be
28 * register_cipher(&rijndael_enc_desc);
29 */
30 REGISTER_CIPHER(&aes_enc_desc);
31 #else
32 /* alternative would be
33 * register_cipher(&rijndael_desc);
34 */
35 REGISTER_CIPHER(&aes_desc);
36 #endif
37 #endif
38 #ifdef LTC_BLOWFISH
39 REGISTER_CIPHER(&blowfish_desc);
40 #endif
41 #ifdef LTC_XTEA
42 REGISTER_CIPHER(&xtea_desc);
43 #endif
44 #ifdef LTC_RC5
45 REGISTER_CIPHER(&rc5_desc);
46 #endif
47 #ifdef LTC_RC6
48 REGISTER_CIPHER(&rc6_desc);
49 #endif
50 #ifdef LTC_SAFERP
51 REGISTER_CIPHER(&saferp_desc);
52 #endif
53 #ifdef LTC_TWOFISH
54 REGISTER_CIPHER(&twofish_desc);
55 #endif
56 #ifdef LTC_SAFER
57 REGISTER_CIPHER(&safer_k64_desc);
58 REGISTER_CIPHER(&safer_sk64_desc);
59 REGISTER_CIPHER(&safer_k128_desc);
60 REGISTER_CIPHER(&safer_sk128_desc);
61 #endif
62 #ifdef LTC_RC2
63 REGISTER_CIPHER(&rc2_desc);
64 #endif
65 #ifdef LTC_DES
66 REGISTER_CIPHER(&des_desc);
67 REGISTER_CIPHER(&des3_desc);
68 #endif
69 #ifdef LTC_CAST5
70 REGISTER_CIPHER(&cast5_desc);
71 #endif
72 #ifdef LTC_NOEKEON
73 REGISTER_CIPHER(&noekeon_desc);
74 #endif
75 #ifdef LTC_SKIPJACK
76 REGISTER_CIPHER(&skipjack_desc);
77 #endif
78 #ifdef LTC_ANUBIS
79 REGISTER_CIPHER(&anubis_desc);
80 #endif
81 #ifdef LTC_KHAZAD
82 REGISTER_CIPHER(&khazad_desc);
83 #endif
84 #ifdef LTC_KSEED
85 REGISTER_CIPHER(&kseed_desc);
86 #endif
87 #ifdef LTC_KASUMI
88 REGISTER_CIPHER(&kasumi_desc);
89 #endif
90 #ifdef LTC_MULTI2
91 REGISTER_CIPHER(&multi2_desc);
92 #endif
93 #ifdef LTC_CAMELLIA
94 REGISTER_CIPHER(&camellia_desc);
95 #endif
96 return err;
97 }
98
99 /* ref: $Format:%D$ */
100 /* git commit: $Format:%H$ */
101 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 /**
12 @file crypt_register_all_hashes.c
13
14 Steffen Jaeckel
15 */
16
17 #define REGISTER_HASH(h) do {\
18 LTC_ARGCHK((err = register_hash(h)) != -1); \
19 } while(0)
20
21 int register_all_hashes(void)
22 {
23 int err = CRYPT_NOP;
24 #ifdef LTC_TIGER
25 REGISTER_HASH(&tiger_desc);
26 #endif
27 #ifdef LTC_MD2
28 REGISTER_HASH(&md2_desc);
29 #endif
30 #ifdef LTC_MD4
31 REGISTER_HASH(&md4_desc);
32 #endif
33 #ifdef LTC_MD5
34 REGISTER_HASH(&md5_desc);
35 #endif
36 #ifdef LTC_SHA1
37 REGISTER_HASH(&sha1_desc);
38 #endif
39 #ifdef LTC_SHA224
40 REGISTER_HASH(&sha224_desc);
41 #endif
42 #ifdef LTC_SHA256
43 REGISTER_HASH(&sha256_desc);
44 #endif
45 #ifdef LTC_SHA384
46 REGISTER_HASH(&sha384_desc);
47 #endif
48 #ifdef LTC_SHA512
49 REGISTER_HASH(&sha512_desc);
50 #endif
51 #ifdef LTC_SHA512_224
52 REGISTER_HASH(&sha512_224_desc);
53 #endif
54 #ifdef LTC_SHA512_256
55 REGISTER_HASH(&sha512_256_desc);
56 #endif
57 #ifdef LTC_SHA3
58 REGISTER_HASH(&sha3_224_desc);
59 REGISTER_HASH(&sha3_256_desc);
60 REGISTER_HASH(&sha3_384_desc);
61 REGISTER_HASH(&sha3_512_desc);
62 #endif
63 #ifdef LTC_RIPEMD128
64 REGISTER_HASH(&rmd128_desc);
65 #endif
66 #ifdef LTC_RIPEMD160
67 REGISTER_HASH(&rmd160_desc);
68 #endif
69 #ifdef LTC_RIPEMD256
70 REGISTER_HASH(&rmd256_desc);
71 #endif
72 #ifdef LTC_RIPEMD320
73 REGISTER_HASH(&rmd320_desc);
74 #endif
75 #ifdef LTC_WHIRLPOOL
76 REGISTER_HASH(&whirlpool_desc);
77 #endif
78 #ifdef LTC_BLAKE2S
79 REGISTER_HASH(&blake2s_128_desc);
80 REGISTER_HASH(&blake2s_160_desc);
81 REGISTER_HASH(&blake2s_224_desc);
82 REGISTER_HASH(&blake2s_256_desc);
83 #endif
84 #ifdef LTC_BLAKE2S
85 REGISTER_HASH(&blake2b_160_desc);
86 REGISTER_HASH(&blake2b_256_desc);
87 REGISTER_HASH(&blake2b_384_desc);
88 REGISTER_HASH(&blake2b_512_desc);
89 #endif
90 #ifdef LTC_CHC_HASH
91 REGISTER_HASH(&chc_desc);
92 LTC_ARGCHK((err = chc_register(find_cipher_any("aes", 8, 16))) == CRYPT_OK);
93 #endif
94 return err;
95 }
96
97 /* ref: $Format:%D$ */
98 /* git commit: $Format:%H$ */
99 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 /**
12 @file crypt_register_all_prngs.c
13
14 Steffen Jaeckel
15 */
16
17 #define REGISTER_PRNG(h) do {\
18 LTC_ARGCHK((err = register_prng(h)) != -1); \
19 } while(0)
20
21 int register_all_prngs(void)
22 {
23 int err = CRYPT_NOP;
24 #ifdef LTC_YARROW
25 REGISTER_PRNG(&yarrow_desc);
26 #endif
27 #ifdef LTC_FORTUNA
28 REGISTER_PRNG(&fortuna_desc);
29 #endif
30 #ifdef LTC_RC4
31 REGISTER_PRNG(&rc4_desc);
32 #endif
33 #ifdef LTC_CHACHA20_PRNG
34 REGISTER_PRNG(&chacha20_prng_desc);
35 #endif
36 #ifdef LTC_SOBER128
37 REGISTER_PRNG(&sober128_desc);
38 #endif
39 #ifdef LTC_SPRNG
40 REGISTER_PRNG(&sprng_desc);
41 #endif
42
43 return err;
44 }
45
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4846 return -1;
4947 }
5048
51 /* $Source$ */
52 /* $Revision$ */
53 /* $Date$ */
49 /* ref: $Format:%D$ */
50 /* git commit: $Format:%H$ */
51 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4846 return -1;
4947 }
5048
51 /* $Source$ */
52 /* $Revision$ */
53 /* $Date$ */
49 /* ref: $Format:%D$ */
50 /* git commit: $Format:%H$ */
51 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4846 return -1;
4947 }
5048
51 /* $Source$ */
52 /* $Revision$ */
53 /* $Date$ */
49 /* ref: $Format:%D$ */
50 /* git commit: $Format:%H$ */
51 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 /**
11 @file crypt_sizes.c
12
13 Make various struct sizes available to dynamic languages
14 like Python - Larry Bugbee, February 2013
15
16 LB - Dec 2013 - revised to include compiler define options
17 */
18
19
20 typedef struct {
21 const char *name;
22 const unsigned int size;
23 } crypt_size;
24
25 #define _SZ_STRINGIFY_S(s) { #s, sizeof(struct s) }
26 #define _SZ_STRINGIFY_T(s) { #s, sizeof(s) }
27
28 static const crypt_size _crypt_sizes[] = {
29 /* hash state sizes */
30 _SZ_STRINGIFY_S(ltc_hash_descriptor),
31 _SZ_STRINGIFY_T(hash_state),
32 #ifdef LTC_CHC_HASH
33 _SZ_STRINGIFY_S(chc_state),
34 #endif
35 #ifdef LTC_WHIRLPOOL
36 _SZ_STRINGIFY_S(whirlpool_state),
37 #endif
38 #ifdef LTC_SHA3
39 _SZ_STRINGIFY_S(sha3_state),
40 #endif
41 #ifdef LTC_SHA512
42 _SZ_STRINGIFY_S(sha512_state),
43 #endif
44 #ifdef LTC_SHA256
45 _SZ_STRINGIFY_S(sha256_state),
46 #endif
47 #ifdef LTC_SHA1
48 _SZ_STRINGIFY_S(sha1_state),
49 #endif
50 #ifdef LTC_MD5
51 _SZ_STRINGIFY_S(md5_state),
52 #endif
53 #ifdef LTC_MD4
54 _SZ_STRINGIFY_S(md4_state),
55 #endif
56 #ifdef LTC_MD2
57 _SZ_STRINGIFY_S(md2_state),
58 #endif
59 #ifdef LTC_TIGER
60 _SZ_STRINGIFY_S(tiger_state),
61 #endif
62 #ifdef LTC_RIPEMD128
63 _SZ_STRINGIFY_S(rmd128_state),
64 #endif
65 #ifdef LTC_RIPEMD160
66 _SZ_STRINGIFY_S(rmd160_state),
67 #endif
68 #ifdef LTC_RIPEMD256
69 _SZ_STRINGIFY_S(rmd256_state),
70 #endif
71 #ifdef LTC_RIPEMD320
72 _SZ_STRINGIFY_S(rmd320_state),
73 #endif
74 #ifdef LTC_BLAKE2S
75 _SZ_STRINGIFY_S(blake2s_state),
76 #endif
77 #ifdef LTC_BLAKE2B
78 _SZ_STRINGIFY_S(blake2b_state),
79 #endif
80
81 /* block cipher key sizes */
82 _SZ_STRINGIFY_S(ltc_cipher_descriptor),
83 _SZ_STRINGIFY_T(symmetric_key),
84 #ifdef LTC_ANUBIS
85 _SZ_STRINGIFY_S(anubis_key),
86 #endif
87 #ifdef LTC_CAMELLIA
88 _SZ_STRINGIFY_S(camellia_key),
89 #endif
90 #ifdef LTC_BLOWFISH
91 _SZ_STRINGIFY_S(blowfish_key),
92 #endif
93 #ifdef LTC_CAST5
94 _SZ_STRINGIFY_S(cast5_key),
95 #endif
96 #ifdef LTC_DES
97 _SZ_STRINGIFY_S(des_key),
98 _SZ_STRINGIFY_S(des3_key),
99 #endif
100 #ifdef LTC_KASUMI
101 _SZ_STRINGIFY_S(kasumi_key),
102 #endif
103 #ifdef LTC_KHAZAD
104 _SZ_STRINGIFY_S(khazad_key),
105 #endif
106 #ifdef LTC_KSEED
107 _SZ_STRINGIFY_S(kseed_key),
108 #endif
109 #ifdef LTC_MULTI2
110 _SZ_STRINGIFY_S(multi2_key),
111 #endif
112 #ifdef LTC_NOEKEON
113 _SZ_STRINGIFY_S(noekeon_key),
114 #endif
115 #ifdef LTC_RC2
116 _SZ_STRINGIFY_S(rc2_key),
117 #endif
118 #ifdef LTC_RC5
119 _SZ_STRINGIFY_S(rc5_key),
120 #endif
121 #ifdef LTC_RC6
122 _SZ_STRINGIFY_S(rc6_key),
123 #endif
124 #ifdef LTC_SKIPJACK
125 _SZ_STRINGIFY_S(skipjack_key),
126 #endif
127 #ifdef LTC_XTEA
128 _SZ_STRINGIFY_S(xtea_key),
129 #endif
130 #ifdef LTC_RIJNDAEL
131 _SZ_STRINGIFY_S(rijndael_key),
132 #endif
133 #ifdef LTC_SAFER
134 _SZ_STRINGIFY_S(safer_key),
135 #endif
136 #ifdef LTC_SAFERP
137 _SZ_STRINGIFY_S(saferp_key),
138 #endif
139 #ifdef LTC_TWOFISH
140 _SZ_STRINGIFY_S(twofish_key),
141 #endif
142
143 /* mode sizes */
144 #ifdef LTC_ECB_MODE
145 _SZ_STRINGIFY_T(symmetric_ECB),
146 #endif
147 #ifdef LTC_CFB_MODE
148 _SZ_STRINGIFY_T(symmetric_CFB),
149 #endif
150 #ifdef LTC_OFB_MODE
151 _SZ_STRINGIFY_T(symmetric_OFB),
152 #endif
153 #ifdef LTC_CBC_MODE
154 _SZ_STRINGIFY_T(symmetric_CBC),
155 #endif
156 #ifdef LTC_CTR_MODE
157 _SZ_STRINGIFY_T(symmetric_CTR),
158 #endif
159 #ifdef LTC_LRW_MODE
160 _SZ_STRINGIFY_T(symmetric_LRW),
161 #endif
162 #ifdef LTC_F8_MODE
163 _SZ_STRINGIFY_T(symmetric_F8),
164 #endif
165 #ifdef LTC_XTS_MODE
166 _SZ_STRINGIFY_T(symmetric_xts),
167 #endif
168
169 /* stream cipher sizes */
170 #ifdef LTC_CHACHA
171 _SZ_STRINGIFY_T(chacha_state),
172 #endif
173 #ifdef LTC_RC4_STREAM
174 _SZ_STRINGIFY_T(rc4_state),
175 #endif
176 #ifdef LTC_SOBER128_STREAM
177 _SZ_STRINGIFY_T(sober128_state),
178 #endif
179
180 /* MAC sizes -- no states for ccm, lrw */
181 #ifdef LTC_HMAC
182 _SZ_STRINGIFY_T(hmac_state),
183 #endif
184 #ifdef LTC_OMAC
185 _SZ_STRINGIFY_T(omac_state),
186 #endif
187 #ifdef LTC_PMAC
188 _SZ_STRINGIFY_T(pmac_state),
189 #endif
190 #ifdef LTC_POLY1305
191 _SZ_STRINGIFY_T(poly1305_state),
192 #endif
193 #ifdef LTC_EAX_MODE
194 _SZ_STRINGIFY_T(eax_state),
195 #endif
196 #ifdef LTC_OCB_MODE
197 _SZ_STRINGIFY_T(ocb_state),
198 #endif
199 #ifdef LTC_OCB3_MODE
200 _SZ_STRINGIFY_T(ocb3_state),
201 #endif
202 #ifdef LTC_CCM_MODE
203 _SZ_STRINGIFY_T(ccm_state),
204 #endif
205 #ifdef LTC_GCM_MODE
206 _SZ_STRINGIFY_T(gcm_state),
207 #endif
208 #ifdef LTC_PELICAN
209 _SZ_STRINGIFY_T(pelican_state),
210 #endif
211 #ifdef LTC_XCBC
212 _SZ_STRINGIFY_T(xcbc_state),
213 #endif
214 #ifdef LTC_F9_MODE
215 _SZ_STRINGIFY_T(f9_state),
216 #endif
217 #ifdef LTC_CHACHA20POLY1305_MODE
218 _SZ_STRINGIFY_T(chacha20poly1305_state),
219 #endif
220
221 /* asymmetric keys */
222 #ifdef LTC_MRSA
223 _SZ_STRINGIFY_T(rsa_key),
224 #endif
225 #ifdef LTC_MDSA
226 _SZ_STRINGIFY_T(dsa_key),
227 #endif
228 #ifdef LTC_MDH
229 _SZ_STRINGIFY_T(dh_key),
230 #endif
231 #ifdef LTC_MECC
232 _SZ_STRINGIFY_T(ltc_ecc_set_type),
233 _SZ_STRINGIFY_T(ecc_point),
234 _SZ_STRINGIFY_T(ecc_key),
235 #endif
236 #ifdef LTC_MKAT
237 _SZ_STRINGIFY_T(katja_key),
238 #endif
239
240 /* DER handling */
241 #ifdef LTC_DER
242 _SZ_STRINGIFY_T(ltc_asn1_list), /* a list entry */
243 _SZ_STRINGIFY_T(ltc_utctime),
244 _SZ_STRINGIFY_T(ltc_generalizedtime),
245 #endif
246
247 /* prng state sizes */
248 _SZ_STRINGIFY_S(ltc_prng_descriptor),
249 _SZ_STRINGIFY_T(prng_state),
250 #ifdef LTC_FORTUNA
251 _SZ_STRINGIFY_S(fortuna_prng),
252 #endif
253 #ifdef LTC_CHACHA20_PRNG
254 _SZ_STRINGIFY_S(chacha20_prng),
255 #endif
256 #ifdef LTC_RC4
257 _SZ_STRINGIFY_S(rc4_prng),
258 #endif
259 #ifdef LTC_SOBER128
260 _SZ_STRINGIFY_S(sober128_prng),
261 #endif
262 #ifdef LTC_YARROW
263 _SZ_STRINGIFY_S(yarrow_prng),
264 #endif
265 /* sprng has no state as it uses other potentially available sources */
266 /* like /dev/random. See Developers Guide for more info. */
267
268 #ifdef LTC_ADLER32
269 _SZ_STRINGIFY_T(adler32_state),
270 #endif
271 #ifdef LTC_CRC32
272 _SZ_STRINGIFY_T(crc32_state),
273 #endif
274
275 _SZ_STRINGIFY_T(ltc_mp_digit),
276 _SZ_STRINGIFY_T(ltc_math_descriptor)
277
278 };
279
280 /* crypt_get_size()
281 * sizeout will be the size (bytes) of the named struct or union
282 * return -1 if named item not found
283 */
284 int crypt_get_size(const char* namein, unsigned int *sizeout) {
285 int i;
286 int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
287 for (i=0; i<count; i++) {
288 if (XSTRCMP(_crypt_sizes[i].name, namein) == 0) {
289 *sizeout = _crypt_sizes[i].size;
290 return 0;
291 }
292 }
293 return -1;
294 }
295
296 /* crypt_list_all_sizes()
297 * if names_list is NULL, names_list_size will be the minimum
298 * size needed to receive the complete names_list
299 * if names_list is NOT NULL, names_list must be the addr with
300 * sufficient memory allocated into which the names_list
301 * is to be written. Also, the value in names_list_size
302 * sets the upper bound of the number of characters to be
303 * written.
304 * a -1 return value signifies insufficient space made available
305 */
306 int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size) {
307 int i;
308 unsigned int total_len = 0;
309 char number[32], *ptr;
310 int number_len;
311 int count = sizeof(_crypt_sizes) / sizeof(_crypt_sizes[0]);
312
313 /* calculate amount of memory required for the list */
314 for (i=0; i<count; i++) {
315 total_len += (unsigned int)strlen(_crypt_sizes[i].name) + 1;
316 /* the above +1 is for the commas */
317 number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size);
318 if ((number_len < 0) ||
319 ((unsigned int)number_len >= sizeof(number)))
320 return -1;
321 total_len += (unsigned int)strlen(number) + 1;
322 /* this last +1 is for newlines (and ending NULL) */
323 }
324
325 if (names_list == NULL) {
326 *names_list_size = total_len;
327 } else {
328 if (total_len > *names_list_size) {
329 return -1;
330 }
331 /* build the names list */
332 ptr = names_list;
333 for (i=0; i<count; i++) {
334 strcpy(ptr, _crypt_sizes[i].name);
335 ptr += strlen(_crypt_sizes[i].name);
336 strcpy(ptr, ",");
337 ptr += 1;
338
339 number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size);
340 strcpy(ptr, number);
341 ptr += number_len;
342 strcpy(ptr, "\n");
343 ptr += 1;
344 }
345 /* to remove the trailing new-line */
346 ptr -= 1;
347 *ptr = 0;
348 }
349 return 0;
350 }
351
352
353 /* ref: $Format:%D$ */
354 /* git commit: $Format:%H$ */
355 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3937 return CRYPT_ERROR;
4038 }
4139
42 /* $Source$ */
43 /* $Revision$ */
44 /* $Date$ */
40 /* ref: $Format:%D$ */
41 /* git commit: $Format:%H$ */
42 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3836 return CRYPT_ERROR;
3937 }
4038
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3836 return CRYPT_ERROR;
3937 }
4038
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 #include "tomcrypt.h"
2119 "CRYPT_ERROR",
2220 "Non-fatal 'no-operation' requested.",
2321
24 "Invalid keysize for block cipher.",
22 "Invalid key size.",
2523 "Invalid number of rounds for block cipher.",
2624 "Algorithm failed test vectors.",
2725
4846 "An overflow of a value was detected/prevented.",
4947
5048 "UNUSED1.",
51 "UNUSED2.",
49
50 "The input was longer than expected.",
5251
5352 "Invalid sized parameter.",
5453
7473 }
7574
7675
77 /* $Source$ */
78 /* $Revision$ */
79 /* $Date$ */
76 /* ref: $Format:%D$ */
77 /* git commit: $Format:%H$ */
78 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 #include <assert.h>
110 #include <stdio.h>
211 #include <stdlib.h>
312
4 #include <tomcrypt.h>
13 #include "tomcrypt.h"
514
615 #ifdef LTC_HKDF
716
118127 XFREE(extracted);
119128 return err;
120129 }
121 #if 0
122 {
123 int j;
124 printf("\nPRK: 0x");
125 for(j=0; j < hashsize; j++) {
126 printf("%02x ", extracted[j]);
127 }
128 for(j=0; j < hashsize; j++) {
129 printf("%02x ", extracted[j]);
130 }
131 }
132 #endif
133130 err = hkdf_expand(hash_idx, info, infolen, extracted, hashsize, out, outlen);
134131 zeromem(extracted, hashsize);
135132 XFREE(extracted);
139136
140137
141138 /* vim: set ts=2 sw=2 et ai si: */
139
140 /* ref: $Format:%D$ */
141 /* git commit: $Format:%H$ */
142 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1210 /**
1311 @file mem_neq.c
14 Compare two blocks of memory for inequality.
12 Compare two blocks of memory for inequality in constant time.
1513 Steffen Jaeckel
1614 */
1715
1816 /**
19 Compare two blocks of memory for inequality.
17 Compare two blocks of memory for inequality in constant time.
2018
2119 The usage is similar to that of standard memcmp, but you can only test
2220 if the memory is equal or not - you can not determine by how much the
2321 first different byte differs.
2422
23 This function shall be used to compare results of cryptographic
24 operations where inequality means most likely usage of a wrong key.
25 The execution time has therefore to be constant as otherwise
26 timing attacks could be possible.
27
2528 @param a The first memory region
2629 @param b The second memory region
2730 @param len The length of the area to compare (octets)
2831
29 @return 0 when a and b are equal for len bytes, else they are not equal.
32 @return 0 when a and b are equal for len bytes, 1 they are not equal.
3033 */
3134 int mem_neq(const void *a, const void *b, size_t len)
3235 {
5457 return ret;
5558 }
5659
57 /* $Source$ */
58 /* $Revision$ */
59 /* $Date$ */
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
11 *
22 * LibTomCrypt is a library that provides various cryptographic
33 * algorithms in a highly modular and flexible manner.
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
87 */
98 #include "tomcrypt.h"
109
5453 return CRYPT_OK;
5554 }
5655 #endif
56
57 /* ref: $Format:%D$ */
58 /* git commit: $Format:%H$ */
59 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
10 #include <tomcrypt.h>
8 #include "tomcrypt.h"
119
1210 /**
1311 @file pkcs_5_1.c
183181
184182 #endif
185183
186 /* $Source$ */
187 /* $Revision$ */
188 /* $Date$ */
184 /* ref: $Format:%D$ */
185 /* git commit: $Format:%H$ */
186 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
10 #include <tomcrypt.h>
8 #include "tomcrypt.h"
119
1210 /**
1311 @file pkcs_5_2.c
123121 #endif
124122
125123
126 /* $Source$ */
127 /* $Revision$ */
128 /* $Date$ */
124 /* ref: $Format:%D$ */
125 /* git commit: $Format:%H$ */
126 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2826 }
2927 }
3028
31 /* $Source$ */
32 /* $Revision$ */
33 /* $Date$ */
29 /* ref: $Format:%D$ */
30 /* git commit: $Format:%H$ */
31 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9189
9290 #endif
9391
94 /* $Source$ */
95 /* $Revision$ */
96 /* $Date$ */
92 /* ref: $Format:%D$ */
93 /* git commit: $Format:%H$ */
94 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634
3735 #endif
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9290
9391 #endif
9492
95 /* $Source$ */
96 /* $Revision$ */
97 /* $Date$ */
93 /* ref: $Format:%D$ */
94 /* git commit: $Format:%H$ */
95 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_CBC_MODE
1816
1917 /**
20 Get the current initial vector
21 @param IV [out] The destination of the initial vector
22 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2321 @param cbc The CBC state
2422 @return CRYPT_OK if successful
2523 */
4038
4139 #endif
4240
43 /* $Source$ */
44 /* $Revision$ */
45 /* $Date$ */
41 /* ref: $Format:%D$ */
42 /* git commit: $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1816 #ifdef LTC_CBC_MODE
1917
2018 /**
21 Set an initial vector
22 @param IV The initial vector
19 Set an initialization vector
20 @param IV The initialization vector
2321 @param len The length of the vector (in octets)
2422 @param cbc The CBC state
2523 @return CRYPT_OK if successful
3836 #endif
3937
4038
41 /* $Source$ */
42 /* $Revision$ */
43 /* $Date$ */
39 /* ref: $Format:%D$ */
40 /* git commit: $Format:%H$ */
41 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1917 /**
2018 Initialize a CBC context
2119 @param cipher The index of the cipher desired
22 @param IV The initial vector
20 @param IV The initialization vector
2321 @param key The secret key
2422 @param keylen The length of the secret key (octets)
2523 @param num_rounds Number of rounds in the cipher desired (0 for default)
5654
5755 #endif
5856
59 /* $Source$ */
60 /* $Revision$ */
61 /* $Date$ */
57 /* ref: $Format:%D$ */
58 /* git commit: $Format:%H$ */
59 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6159 #endif
6260
6361
64 /* $Source$ */
65 /* $Revision$ */
66 /* $Date$ */
62 /* ref: $Format:%D$ */
63 /* git commit: $Format:%H$ */
64 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634
3735 #endif
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5957
6058 #endif
6159
62 /* $Source$ */
63 /* $Revision$ */
64 /* $Date$ */
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_CFB_MODE
1816
1917 /**
20 Get the current initial vector
21 @param IV [out] The destination of the initial vector
22 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2321 @param cfb The CFB state
2422 @return CRYPT_OK if successful
2523 */
4038
4139 #endif
4240
43 /* $Source$ */
44 /* $Revision$ */
45 /* $Date$ */
41 /* ref: $Format:%D$ */
42 /* git commit: $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_CFB_MODE
1816
1917 /**
20 Set an initial vector
21 @param IV The initial vector
18 Set an initialization vector
19 @param IV The initialization vector
2220 @param len The length of the vector (in octets)
2321 @param cfb The CFB state
2422 @return CRYPT_OK if successful
4644 #endif
4745
4846
49 /* $Source$ */
50 /* $Revision$ */
51 /* $Date$ */
47 /* ref: $Format:%D$ */
48 /* git commit: $Format:%H$ */
49 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2018 /**
2119 Initialize a CFB context
2220 @param cipher The index of the cipher desired
23 @param IV The initial vector
21 @param IV The initialization vector
2422 @param key The secret key
2523 @param keylen The length of the secret key (octets)
2624 @param num_rounds Number of rounds in the cipher desired (0 for default)
5957
6058 #endif
6159
62 /* $Source$ */
63 /* $Revision$ */
64 /* $Date$ */
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634 #endif
3735
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634
3735 #endif
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
106104
107105 #endif
108106
109 /* $Source$ */
110 /* $Revision$ */
111 /* $Date$ */
107 /* ref: $Format:%D$ */
108 /* git commit: $Format:%H$ */
109 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_CTR_MODE
1816
1917 /**
20 Get the current initial vector
21 @param IV [out] The destination of the initial vector
22 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2321 @param ctr The CTR state
2422 @return CRYPT_OK if successful
2523 */
4038
4139 #endif
4240
43 /* $Source$ */
44 /* $Revision$ */
45 /* $Date$ */
41 /* ref: $Format:%D$ */
42 /* git commit: $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_CTR_MODE
1816
1917 /**
20 Set an initial vector
21 @param IV The initial vector
18 Set an initialization vector
19 @param IV The initialization vector
2220 @param len The length of the vector (in octets)
2321 @param ctr The CTR state
2422 @return CRYPT_OK if successful
5048 #endif
5149
5250
53 /* $Source$ */
54 /* $Revision$ */
55 /* $Date$ */
51 /* ref: $Format:%D$ */
52 /* git commit: $Format:%H$ */
53 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2018 /**
2119 Initialize a CTR context
2220 @param cipher The index of the cipher desired
23 @param IV The initial vector
21 @param IV The initialization vector
2422 @param key The secret key
2523 @param keylen The length of the secret key (octets)
2624 @param num_rounds Number of rounds in the cipher desired (0 for default)
9593
9694 #endif
9795
98 /* $Source$ */
99 /* $Revision$ */
100 /* $Date$ */
96 /* ref: $Format:%D$ */
97 /* git commit: $Format:%H$ */
98 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5553
5654 #endif
5755
58 /* $Source$ */
59 /* $Revision$ */
60 /* $Date$ */
56 /* ref: $Format:%D$ */
57 /* git commit: $Format:%H$ */
58 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634
3735 #endif
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5553
5654 #endif
5755
58 /* $Source$ */
59 /* $Revision$ */
60 /* $Date$ */
56 /* ref: $Format:%D$ */
57 /* git commit: $Format:%H$ */
58 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4240
4341 #endif
4442
45 /* $Source$ */
46 /* $Revision$ */
47 /* $Date$ */
43 /* ref: $Format:%D$ */
44 /* git commit: $Format:%H$ */
45 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3735
3836
3937
40 /* $Source$ */
41 /* $Revision$ */
42 /* $Date$ */
38 /* ref: $Format:%D$ */
39 /* git commit: $Format:%H$ */
40 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634
3735 #endif
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5452
5553 #endif
5654
57 /* $Source$ */
58 /* $Revision$ */
59 /* $Date$ */
55 /* ref: $Format:%D$ */
56 /* git commit: $Format:%H$ */
57 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_OFB_MODE
1816
1917 /**
20 Get the current initial vector
21 @param IV [out] The destination of the initial vector
22 @param len [in/out] The max size and resulting size of the initial vector
18 Get the current initialization vector
19 @param IV [out] The destination of the initialization vector
20 @param len [in/out] The max size and resulting size of the initialization vector
2321 @param ofb The OFB state
2422 @return CRYPT_OK if successful
2523 */
4038
4139 #endif
4240
43 /* $Source$ */
44 /* $Revision$ */
45 /* $Date$ */
41 /* ref: $Format:%D$ */
42 /* git commit: $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_OFB_MODE
1816
1917 /**
20 Set an initial vector
21 @param IV The initial vector
18 Set an initialization vector
19 @param IV The initialization vector
2220 @param len The length of the vector (in octets)
2321 @param ofb The OFB state
2422 @return CRYPT_OK if successful
4644 #endif
4745
4846
49 /* $Source$ */
50 /* $Revision$ */
51 /* $Date$ */
47 /* ref: $Format:%D$ */
48 /* git commit: $Format:%H$ */
49 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2018 /**
2119 Initialize a OFB context
2220 @param cipher The index of the cipher desired
23 @param IV The initial vector
21 @param IV The initialization vector
2422 @param key The secret key
2523 @param keylen The length of the secret key (octets)
2624 @param num_rounds Number of rounds in the cipher desired (0 for default)
5452
5553 #endif
5654
57 /* $Source$ */
58 /* $Revision$ */
59 /* $Date$ */
55 /* ref: $Format:%D$ */
56 /* git commit: $Format:%H$ */
57 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9694
9795 #endif
9896
99 /* $Source$ */
100 /* $Revision$ */
101 /* $Date$ */
97 /* ref: $Format:%D$ */
98 /* git commit: $Format:%H$ */
99 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1816 #ifdef LTC_DER
1917
2018 #define SETBIT(v, n) (v=((unsigned char)(v) | (1U << (unsigned char)(n))))
19 #define CLRBIT(v, n) (v=((unsigned char)(v) & ~(1U << (unsigned char)(n))))
2120
2221 /**
2322 Store a BIT STRING
8584
8685 /* decode/store the bits */
8786 for (y = 0; y < blen; y++) {
88 if (in[x] & (1 << (7 - (y & 7)))) {
89 SETBIT(out[y/8], 7-(y%8));
90 }
91 if ((y & 7) == 7) {
92 ++x;
93 }
87 if (in[x] & (1 << (7 - (y & 7)))) {
88 SETBIT(out[y/8], 7-(y%8));
89 } else {
90 CLRBIT(out[y/8], 7-(y%8));
91 }
92 if ((y & 7) == 7) {
93 ++x;
94 }
9495 }
9596
9697 /* we done */
100101
101102 #endif
102103
103 /* $Source$ */
104 /* $Revision$ */
105 /* $Date$ */
104 /* ref: $Format:%D$ */
105 /* git commit: $Format:%H$ */
106 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8381
8482 #endif
8583
86 /* $Source$ */
87 /* $Revision$ */
88 /* $Date$ */
84 /* ref: $Format:%D$ */
85 /* git commit: $Format:%H$ */
86 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2220 /**
2321 Store a BIT STRING
2422 @param in The array of bits to store (8 per char)
25 @param inlen The number of bits tostore
23 @param inlen The number of bits to store
2624 @param out [out] The destination for the DER encoded BIT STRING
2725 @param outlen [in/out] The max size and resulting size of the DER BIT STRING
2826 @return CRYPT_OK if successful
6967
7068 /* store the bits in big endian format */
7169 for (y = buf = 0; y < inlen; y++) {
72 buf |= (getbit(in[y/8],7-y%8)?1:0) << (7 - (y & 7));
73 if ((y & 7) == 7) {
74 out[x++] = buf;
75 buf = 0;
76 }
70 buf |= (getbit(in[y/8],7-y%8)?1:0) << (7 - (y & 7));
71 if ((y & 7) == 7) {
72 out[x++] = buf;
73 buf = 0;
74 }
7775 }
7876 /* store last byte */
7977 if (inlen & 7) {
8684
8785 #endif
8886
89 /* $Source$ */
90 /* $Revision$ */
91 /* $Date$ */
87 /* ref: $Format:%D$ */
88 /* git commit: $Format:%H$ */
89 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4846 #endif
4947
5048
51 /* $Source$ */
52 /* $Revision$ */
53 /* $Date$ */
49 /* ref: $Format:%D$ */
50 /* git commit: $Format:%H$ */
51 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4139
4240 #endif
4341
44 /* $Source$ */
45 /* $Revision$ */
46 /* $Date$ */
42 /* ref: $Format:%D$ */
43 /* git commit: $Format:%H$ */
44 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4543
4644 #endif
4745
48 /* $Source$ */
49 /* $Revision$ */
50 /* $Date$ */
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2927
3028 #endif
3129
32 /* $Source$ */
33 /* $Revision$ */
34 /* $Date$ */
30 /* ref: $Format:%D$ */
31 /* git commit: $Format:%H$ */
32 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
219217
220218 #endif
221219
222 /* $Source$ */
223 /* $Revision$ */
224 /* $Date$ */
220 /* ref: $Format:%D$ */
221 /* git commit: $Format:%H$ */
222 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715
1816 #ifdef LTC_DER
1917
20 static int char_to_int(unsigned char x)
18 static int _char_to_int(unsigned char x)
2119 {
2220 switch (x) {
2321 case '0': return 0;
3028 case '7': return 7;
3129 case '8': return 8;
3230 case '9': return 9;
31 default: return 100;
3332 }
34 return 100;
3533 }
3634
3735 #define DECODE_V(y, max) do {\
38 y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
36 y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \
3937 if (y >= max) return CRYPT_INVALID_PACKET; \
4038 x += 2; \
4139 } while(0)
4240
4341 #define DECODE_V4(y, max) do {\
44 y = char_to_int(buf[x])*1000 + char_to_int(buf[x+1])*100 + char_to_int(buf[x+2])*10 + char_to_int(buf[x+3]); \
42 y = _char_to_int(buf[x])*1000 + _char_to_int(buf[x+1])*100 + _char_to_int(buf[x+2])*10 + _char_to_int(buf[x+3]); \
4543 if (y >= max) return CRYPT_INVALID_PACKET; \
4644 x += 4; \
4745 } while(0)
119117 unsigned fs = out->fs;
120118 if (x >= sizeof(buf)) return CRYPT_INVALID_PACKET;
121119 out->fs *= 10;
122 out->fs += char_to_int(buf[x]);
120 out->fs += _char_to_int(buf[x]);
123121 if (fs > out->fs) return CRYPT_OVERFLOW;
124122 x++;
125123 }
140138
141139 #endif
142140
143 /* $Source$ */
144 /* $Revision$ */
145 /* $Date$ */
141 /* ref: $Format:%D$ */
142 /* git commit: $Format:%H$ */
143 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3331
3432 /**
3533 Encodes a Generalized time structure in DER format
36 @param utctime The UTC time structure to encode
37 @param out The destination of the DER encoding of the UTC time structure
34 @param gtime The GeneralizedTime structure to encode
35 @param out The destination of the DER encoding of the GeneralizedTime structure
3836 @param outlen [in/out] The length of the DER encoding
3937 @return CRYPT_OK if successful
4038 */
104102
105103 #endif
106104
107 /* $Source$ */
108 /* $Revision$ */
109 /* $Date$ */
105 /* ref: $Format:%D$ */
106 /* git commit: $Format:%H$ */
107 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1917
2018 /**
2119 Gets length of DER encoding of GeneralizedTime
22 @param utctime The UTC time structure to get the size of
20 @param gtime The GeneralizedTime structure to get the size of
2321 @param outlen [out] The length of the DER encoding
2422 @return CRYPT_OK if successful
2523 */
5452
5553 #endif
5654
57 /* $Source$ */
58 /* $Revision$ */
59 /* $Date$ */
55 /* ref: $Format:%D$ */
56 /* git commit: $Format:%H$ */
57 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9088
9189 #endif
9290
93 /* $Source$ */
94 /* $Revision$ */
95 /* $Date$ */
91 /* ref: $Format:%D$ */
92 /* git commit: $Format:%H$ */
93 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7977
8078 #endif
8179
82 /* $Source$ */
83 /* $Revision$ */
84 /* $Date$ */
80 /* ref: $Format:%D$ */
81 /* git commit: $Format:%H$ */
82 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
188186 #endif
189187
190188
191 /* $Source$ */
192 /* $Revision$ */
193 /* $Date$ */
189 /* ref: $Format:%D$ */
190 /* git commit: $Format:%H$ */
191 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
104102
105103 #endif
106104
107 /* $Source$ */
108 /* $Revision$ */
109 /* $Date$ */
105 /* ref: $Format:%D$ */
106 /* git commit: $Format:%H$ */
107 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
124122
125123 #endif
126124
127 /* $Source$ */
128 /* $Revision$ */
129 /* $Date$ */
125 /* ref: $Format:%D$ */
126 /* git commit: $Format:%H$ */
127 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7573
7674 #endif
7775
78 /* $Source$ */
79 /* $Revision$ */
80 /* $Date$ */
76 /* ref: $Format:%D$ */
77 /* git commit: $Format:%H$ */
78 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9391
9492 #endif
9593
96 /* $Source$ */
97 /* $Revision$ */
98 /* $Date$ */
94 /* ref: $Format:%D$ */
95 /* git commit: $Format:%H$ */
96 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
105103
106104 #endif
107105
108 /* $Source$ */
109 /* $Revision$ */
110 /* $Date$ */
106 /* ref: $Format:%D$ */
107 /* git commit: $Format:%H$ */
108 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8381
8482 #endif
8583
86 /* $Source$ */
87 /* $Revision$ */
88 /* $Date$ */
84 /* ref: $Format:%D$ */
85 /* git commit: $Format:%H$ */
86 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8583
8684 #endif
8785
88 /* $Source$ */
89 /* $Revision$ */
90 /* $Date$ */
86 /* ref: $Format:%D$ */
87 /* git commit: $Format:%H$ */
88 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8078
8179 #endif
8280
83 /* $Source$ */
84 /* $Revision$ */
85 /* $Date$ */
81 /* ref: $Format:%D$ */
82 /* git commit: $Format:%H$ */
83 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4745 #endif
4846
4947
50 /* $Source$ */
51 /* $Revision$ */
52 /* $Date$ */
48 /* ref: $Format:%D$ */
49 /* git commit: $Format:%H$ */
50 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9088
9189 #endif
9290
93 /* $Source$ */
94 /* $Revision$ */
95 /* $Date$ */
91 /* ref: $Format:%D$ */
92 /* git commit: $Format:%H$ */
93 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7977
8078 #endif
8179
82 /* $Source$ */
83 /* $Revision$ */
84 /* $Date$ */
80 /* ref: $Format:%D$ */
81 /* git commit: $Format:%H$ */
82 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
160158 #endif
161159
162160
163 /* $Source$ */
164 /* $Revision$ */
165 /* $Date$ */
161 /* ref: $Format:%D$ */
162 /* git commit: $Format:%H$ */
163 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
325323 goto LBL_ERR;
326324 }
327325 }
328 err = CRYPT_OK;
326
327 if (inlen == 0) {
328 err = CRYPT_OK;
329 } else {
330 err = CRYPT_INPUT_TOO_LONG;
331 }
329332
330333 LBL_ERR:
331334 return err;
333336
334337 #endif
335338
336 /* $Source$ */
337 /* $Revision$ */
338 /* $Date$ */
339 /* ref: $Format:%D$ */
340 /* git commit: $Format:%H$ */
341 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1614
1715 #ifdef LTC_DER
1816
19 static unsigned long fetch_length(const unsigned char *in, unsigned long inlen, unsigned long *data_offset)
17 static unsigned long _fetch_length(const unsigned char *in, unsigned long inlen, unsigned long *data_offset)
2018 {
2119 unsigned long x, z;
2220
5250 return z+*data_offset;
5351 }
5452
55 static int new_element(ltc_asn1_list **l)
53 static int _new_element(ltc_asn1_list **l)
5654 {
5755 /* alloc new link */
5856 if (*l == NULL) {
9391
9492 if (*inlen == 0) {
9593 /* alloc new link */
96 if ((err = new_element(&l)) != CRYPT_OK) {
94 if ((err = _new_element(&l)) != CRYPT_OK) {
9795 goto error;
9896 }
9997 }
104102 type = *in;
105103
106104 /* fetch length */
107 len = fetch_length(in, *inlen, &data_offset);
105 len = _fetch_length(in, *inlen, &data_offset);
108106 if (len > *inlen) {
109107 err = CRYPT_INVALID_PACKET;
110108 goto error;
111109 }
112110
113111 /* alloc new link */
114 if ((err = new_element(&l)) != CRYPT_OK) {
112 if ((err = _new_element(&l)) != CRYPT_OK) {
115113 goto error;
116114 }
117115
469467 #endif
470468
471469
472 /* $Source$ */
473 /* $Revision$ */
474 /* $Date$ */
470 /* ref: $Format:%D$ */
471 /* git commit: $Format:%H$ */
472 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
4038 va_start(args, inlen);
4139 x = 0;
4240 for (;;) {
43 type = va_arg(args, ltc_asn1_type);
41 type = (ltc_asn1_type)va_arg(args, int);
4442 size = va_arg(args, unsigned long);
4543 data = va_arg(args, void*);
4644 LTC_UNUSED_PARAM(size);
9593 va_start(args, inlen);
9694 x = 0;
9795 for (;;) {
98 type = va_arg(args, ltc_asn1_type);
96 type = (ltc_asn1_type)va_arg(args, int);
9997 size = va_arg(args, unsigned long);
10098 data = va_arg(args, void*);
10199
141139 #endif
142140
143141
144 /* $Source$ */
145 /* $Revision$ */
146 /* $Date$ */
142 /* ref: $Format:%D$ */
143 /* git commit: $Format:%H$ */
144 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
87 */
98 #include "tomcrypt.h"
109 /**
3130 @param algorithm One out of the enum #public_key_algorithms
3231 @param public_key The buffer for the public key
3332 @param public_key_len [in/out] The length of the public key buffer and the written length
34 @param parameters_type The parameters' type out of the enum #ltc_asn1_type
33 @param parameters_type The parameters' type out of the enum ltc_asn1_type
3534 @param parameters The parameters to include
3635 @param parameters_len The number of parameters to include
3736 @return CRYPT_OK on success
6766 }
6867
6968 /* see if the OpenSSL DER format RSA public key will work */
70 tmpbuf = XCALLOC(1, LTC_DER_MAX_PUBKEY_SIZE*8);
69 tmpbuf = XCALLOC(1, inlen);
7170 if (tmpbuf == NULL) {
7271 err = CRYPT_MEM;
7372 goto LBL_ERR;
8180 * in a **BIT** string ... so we have to extract it then proceed to convert bit to octet
8281 */
8382 LTC_SET_ASN1(subject_pubkey, 0, LTC_ASN1_SEQUENCE, alg_id, 2);
84 LTC_SET_ASN1(subject_pubkey, 1, LTC_ASN1_RAW_BIT_STRING, tmpbuf, LTC_DER_MAX_PUBKEY_SIZE*8);
83 LTC_SET_ASN1(subject_pubkey, 1, LTC_ASN1_RAW_BIT_STRING, tmpbuf, inlen*8U);
8584
8685 err=der_decode_sequence(in, inlen, subject_pubkey, 2UL);
8786 if (err != CRYPT_OK) {
117116 }
118117
119118 #endif
119
120 /* ref: $Format:%D$ */
121 /* git commit: $Format:%H$ */
122 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
241239 }
242240
243241 #endif
242
243 /* ref: $Format:%D$ */
244 /* git commit: $Format:%H$ */
245 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119 #include <stdarg.h>
4139 va_start(args, outlen);
4240 x = 0;
4341 for (;;) {
44 type = va_arg(args, ltc_asn1_type);
42 type = (ltc_asn1_type)va_arg(args, int);
4543 size = va_arg(args, unsigned long);
4644 data = va_arg(args, void*);
4745 LTC_UNUSED_PARAM(size);
9694 va_start(args, outlen);
9795 x = 0;
9896 for (;;) {
99 type = va_arg(args, ltc_asn1_type);
97 type = (ltc_asn1_type)va_arg(args, int);
10098 size = va_arg(args, unsigned long);
10199 data = va_arg(args, void*);
102100
145143 #endif
146144
147145
148 /* $Source$ */
149 /* $Revision$ */
150 /* $Date$ */
146 /* ref: $Format:%D$ */
147 /* git commit: $Format:%H$ */
148 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
87 */
98 #include "tomcrypt.h"
109
3231 @param algorithm One out of the enum #public_key_algorithms
3332 @param public_key The buffer for the public key
3433 @param public_key_len The length of the public key buffer
35 @param parameters_type The parameters' type out of the enum #ltc_asn1_type
34 @param parameters_type The parameters' type out of the enum ltc_asn1_type
3635 @param parameters The parameters to include
3736 @param parameters_len The number of parameters to include
3837 @return CRYPT_OK on success
5857
5958 return der_encode_sequence_multi(out, outlen,
6059 LTC_ASN1_SEQUENCE, (unsigned long)sizeof(alg_id)/sizeof(alg_id[0]), alg_id,
61 LTC_ASN1_RAW_BIT_STRING, (unsigned long)(public_key_len*8), public_key,
60 LTC_ASN1_RAW_BIT_STRING, public_key_len*8U, public_key,
6261 LTC_ASN1_EOL, 0UL, NULL);
6362
6463 }
6564
6665 #endif
6766
67 /* ref: $Format:%D$ */
68 /* git commit: $Format:%H$ */
69 /* commit time: $Format:%ai$ */
6870
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2624 int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
2725 unsigned long *outlen)
2826 {
29 return der_length_sequence_ex(list, inlen, outlen, NULL);
27 return der_length_sequence_ex(list, inlen, outlen, NULL);
3028 }
3129
3230 int der_length_sequence_ex(ltc_asn1_list *list, unsigned long inlen,
208206
209207 #endif
210208
211 /* $Source$ */
212 /* $Revision$ */
213 /* $Date$ */
209 /* ref: $Format:%D$ */
210 /* git commit: $Format:%H$ */
211 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
5957
6058 #endif
6159
62 /* $Source$ */
63 /* $Revision$ */
64 /* $Date$ */
60 /* ref: $Format:%D$ */
61 /* git commit: $Format:%H$ */
62 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 /**
11 @file der_sequence_shrink.c
12 Free memory allocated for CONSTRUCTED, SET or SEQUENCE elements by der_decode_sequence_flexi(), Steffen Jaeckel
13 */
14
15 #ifdef LTC_DER
16
17 /**
18 Free memory allocated for CONSTRUCTED,
19 SET or SEQUENCE elements by der_decode_sequence_flexi()
20 @param in The list to shrink
21 */
22 void der_sequence_shrink(ltc_asn1_list *in)
23 {
24 if (!in) return;
25
26 /* now walk the list and free stuff */
27 while (in != NULL) {
28 /* is there a child? */
29 if (in->child) {
30 der_sequence_shrink(in->child);
31 }
32
33 switch (in->type) {
34 case LTC_ASN1_CONSTRUCTED:
35 case LTC_ASN1_SET:
36 case LTC_ASN1_SEQUENCE : if (in->data != NULL) { XFREE(in->data); in->data = NULL; } break;
37 default: break;
38 }
39
40 /* move to next and free current */
41 in = in->next;
42 }
43 }
44
45 #endif
46
47 /* ref: $Format:%D$ */
48 /* git commit: $Format:%H$ */
49 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_DER
1816
1917 /* LTC define to ASN.1 TAG */
20 static int ltc_to_asn1(ltc_asn1_type v)
18 static int _ltc_to_asn1(ltc_asn1_type v)
2119 {
2220 switch (v) {
2321 case LTC_ASN1_BOOLEAN: return 0x01;
4644 }
4745
4846
49 static int qsort_helper(const void *a, const void *b)
47 static int _qsort_helper(const void *a, const void *b)
5048 {
5149 ltc_asn1_list *A = (ltc_asn1_list *)a, *B = (ltc_asn1_list *)b;
5250 int r;
5351
54 r = ltc_to_asn1(A->type) - ltc_to_asn1(B->type);
52 r = _ltc_to_asn1(A->type) - _ltc_to_asn1(B->type);
5553
5654 /* for QSORT the order is UNDEFINED if they are "equal" which means it is NOT DETERMINISTIC. So we force it to be :-) */
5755 if (r == 0) {
9088 }
9189
9290 /* sort it by the "type" field */
93 XQSORT(copy, inlen, sizeof(*copy), &qsort_helper);
91 XQSORT(copy, inlen, sizeof(*copy), &_qsort_helper);
9492
9593 /* call der_encode_sequence_ex() */
9694 err = der_encode_sequence_ex(copy, inlen, out, outlen, LTC_ASN1_SET);
104102
105103 #endif
106104
107 /* $Source$ */
108 /* $Revision$ */
109 /* $Date$ */
105 /* ref: $Format:%D$ */
106 /* git commit: $Format:%H$ */
107 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2119 unsigned long size;
2220 };
2321
24 static int qsort_helper(const void *a, const void *b)
22 static int _qsort_helper(const void *a, const void *b)
2523 {
2624 struct edge *A = (struct edge *)a, *B = (struct edge *)b;
2725 int r;
133131 }
134132
135133 /* sort based on contents (using edges) */
136 XQSORT(edges, inlen, sizeof(*edges), &qsort_helper);
134 XQSORT(edges, inlen, sizeof(*edges), &_qsort_helper);
137135
138136 /* copy static header */
139137 XMEMCPY(out, buf, hdrlen);
157155
158156 #endif
159157
160 /* $Source$ */
161 /* $Revision$ */
162 /* $Date$ */
158 /* ref: $Format:%D$ */
159 /* git commit: $Format:%H$ */
160 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6260
6361 #endif
6462
65 /* $Source$ */
66 /* $Revision$ */
67 /* $Date$ */
63 /* ref: $Format:%D$ */
64 /* git commit: $Format:%H$ */
65 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9189
9290 #endif
9391
94 /* $Source$ */
95 /* $Revision$ */
96 /* $Date$ */
92 /* ref: $Format:%D$ */
93 /* git commit: $Format:%H$ */
94 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6462
6563 #endif
6664
67 /* $Source$ */
68 /* $Revision$ */
69 /* $Date$ */
65 /* ref: $Format:%D$ */
66 /* git commit: $Format:%H$ */
67 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
8987
9088 #endif
9189
92 /* $Source$ */
93 /* $Revision$ */
94 /* $Date$ */
90 /* ref: $Format:%D$ */
91 /* git commit: $Format:%H$ */
92 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
204202 #endif
205203
206204
207 /* $Source$ */
208 /* $Revision$ */
209 /* $Date$ */
205 /* ref: $Format:%D$ */
206 /* git commit: $Format:%H$ */
207 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1614
1715 #ifdef LTC_DER
1816
19 static int char_to_int(unsigned char x)
17 static int _char_to_int(unsigned char x)
2018 {
2119 switch (x) {
2220 case '0': return 0;
2927 case '7': return 7;
3028 case '8': return 8;
3129 case '9': return 9;
30 default: return 100;
3231 }
33 return 100;
3432 }
3533
3634 #define DECODE_V(y, max) \
37 y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
35 y = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \
3836 if (y >= max) return CRYPT_INVALID_PACKET; \
3937 x += 2;
4038
4846 int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
4947 ltc_utctime *out)
5048 {
51 unsigned char buf[32];
49 unsigned char buf[32] = { 0 }; /* initialize as all zeroes */
5250 unsigned long x;
5351 int y;
5452
121119
122120 #endif
123121
124 /* $Source$ */
125 /* $Revision$ */
126 /* $Date$ */
122 /* ref: $Format:%D$ */
123 /* git commit: $Format:%H$ */
124 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7775
7876 #endif
7977
80 /* $Source$ */
81 /* $Revision$ */
82 /* $Date$ */
78 /* ref: $Format:%D$ */
79 /* git commit: $Format:%H$ */
80 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4038
4139 #endif
4240
43 /* $Source$ */
44 /* $Revision$ */
45 /* $Date$ */
41 /* ref: $Format:%D$ */
42 /* git commit: $Format:%H$ */
43 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
105103
106104 #endif
107105
108 /* $Source$ */
109 /* $Revision$ */
110 /* $Date$ */
106 /* ref: $Format:%D$ */
107 /* git commit: $Format:%H$ */
108 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
10098
10199 #endif
102100
103 /* $Source$ */
104 /* $Revision$ */
105 /* $Date$ */
101 /* ref: $Format:%D$ */
102 /* git commit: $Format:%H$ */
103 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9896 #endif
9997
10098
101 /* $Source$ */
102 /* $Revision$ */
103 /* $Date$ */
99 /* ref: $Format:%D$ */
100 /* git commit: $Format:%H$ */
101 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
97 */
8
109 #include "tomcrypt.h"
1110
11 #ifdef LTC_MDH
12
13 /* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
14 const ltc_dh_set_type ltc_dh_sets[] = {
15 #ifdef LTC_DH768
16 { /* 768-bit MODP Group 1 - https://tools.ietf.org/html/rfc7296#appendix-B.1 */
17 96,
18 "DH-768",
19 "2",
20 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
21 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
22 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
23 "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF"
24 },
25 #endif
26 #ifdef LTC_DH1024
27 { /* 1024-bit MODP Group 2 - https://tools.ietf.org/html/rfc7296#appendix-B.2 */
28 128,
29 "DH-1024",
30 "2",
31 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
32 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
33 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
34 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
35 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381"
36 "FFFFFFFFFFFFFFFF"
37 },
38 #endif
39 #ifdef LTC_DH1536
40 { /* 1536-bit MODP Group 5 - https://tools.ietf.org/html/rfc3526#section-2 */
41 192,
42 "DH-1536",
43 "2",
44 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
45 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
46 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
47 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
48 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
49 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
50 "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
51 "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF"
52 },
53 #endif
54 #ifdef LTC_DH2048
55 { /* 2048-bit MODP Group 14 - https://tools.ietf.org/html/rfc3526#section-3 */
56 256,
57 "DH-2048",
58 "2",
59 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
60 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
61 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
62 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
63 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
64 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
65 "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
66 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
67 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
68 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
69 "15728E5A8AACAA68FFFFFFFFFFFFFFFF"
70 },
71 #endif
72 #ifdef LTC_DH3072
73 { /* 3072-bit MODP Group 15 - https://tools.ietf.org/html/rfc3526#section-4 */
74 384,
75 "DH-3072",
76 "2",
77 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
78 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
79 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
80 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
81 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
82 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
83 "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
84 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
85 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
86 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
87 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
88 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
89 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
90 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
91 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
92 "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
93 },
94 #endif
95 #ifdef LTC_DH4096
96 { /* 4096-bit MODP Group 16 - https://tools.ietf.org/html/rfc3526#section-5 */
97 512,
98 "DH-4096",
99 "2",
100 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
101 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
102 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
103 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
104 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
105 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
106 "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
107 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
108 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
109 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
110 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
111 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
112 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
113 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
114 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
115 "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7"
116 "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA"
117 "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6"
118 "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED"
119 "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9"
120 "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199"
121 "FFFFFFFFFFFFFFFF"
122 },
123 #endif
124 #ifdef LTC_DH6144
125 { /* 6144-bit MODP Group 17 - https://tools.ietf.org/html/rfc3526#section-6 */
126 768,
127 "DH-6144",
128 "2",
129 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
130 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
131 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
132 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
133 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
134 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
135 "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
136 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
137 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
138 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
139 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
140 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
141 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
142 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
143 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
144 "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7"
145 "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA"
146 "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6"
147 "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED"
148 "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9"
149 "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492"
150 "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BD"
151 "F8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831"
152 "179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B"
153 "DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF"
154 "5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6"
155 "D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F3"
156 "23A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA"
157 "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE328"
158 "06A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55C"
159 "DA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE"
160 "12BF2D5B0B7474D6E694F91E6DCC4024FFFFFFFFFFFFFFFF"
161 },
162 #endif
163 #ifdef LTC_DH8192
164 { /* 8192-bit MODP Group 18 - https://tools.ietf.org/html/rfc3526#section-7 */
165 1024,
166 "DH-8192",
167 "2",
168 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
169 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
170 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
171 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
172 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
173 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
174 "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
175 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
176 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
177 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
178 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64"
179 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
180 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B"
181 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C"
182 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31"
183 "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7"
184 "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA"
185 "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6"
186 "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED"
187 "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9"
188 "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492"
189 "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BD"
190 "F8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831"
191 "179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B"
192 "DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF"
193 "5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6"
194 "D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F3"
195 "23A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA"
196 "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE328"
197 "06A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55C"
198 "DA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE"
199 "12BF2D5B0B7474D6E694F91E6DBE115974A3926F12FEE5E4"
200 "38777CB6A932DF8CD8BEC4D073B931BA3BC832B68D9DD300"
201 "741FA7BF8AFC47ED2576F6936BA424663AAB639C5AE4F568"
202 "3423B4742BF1C978238F16CBE39D652DE3FDB8BEFC848AD9"
203 "22222E04A4037C0713EB57A81A23F0C73473FC646CEA306B"
204 "4BCBC8862F8385DDFA9D4B7FA2C087E879683303ED5BDD3A"
205 "062B3CF5B3A278A66D2A13F83F44F82DDF310EE074AB6A36"
206 "4597E899A0255DC164F31CC50846851DF9AB48195DED7EA1"
207 "B1D510BD7EE74D73FAF36BC31ECFA268359046F4EB879F92"
208 "4009438B481C6CD7889A002ED5EE382BC9190DA6FC026E47"
209 "9558E4475677E9AA9E3050E2765694DFC81F56E880B96E71"
210 "60C980DD98EDD3DFFFFFFFFFFFFFFFFF"
211 },
212 #endif
213 {
214 0,
215 NULL,
216 NULL,
217 NULL
218 }
219 };
220
12221 /**
13 @file dh.c
14 DH crypto, Tom St Denis
15 */
16
17 #ifdef LTC_MDH
18
19
20 #include "dh_static.h"
21
22 /**
23 Test the DH sub-system (can take a while)
24 @return CRYPT_OK if successful
25 */
26 int dh_compat_test(void)
222 Returns the DH group size (octets) for given key
223 @param key The DH key to get the size of
224 @return The group size in octets (0 on error)
225 */
226 int dh_get_groupsize(dh_key *key)
27227 {
28 void *p, *g, *tmp;
29 int x, err, primality;
30
31 if ((err = mp_init_multi(&p, &g, &tmp, NULL)) != CRYPT_OK) { goto error; }
32
33 for (x = 0; sets[x].size != 0; x++) {
34 #if 0
35 printf("dh_test():testing size %d-bits\n", sets[x].size * 8);
36 #endif
37 if ((err = mp_read_radix(g,(char *)sets[x].base, 64)) != CRYPT_OK) { goto error; }
38 if ((err = mp_read_radix(p,(char *)sets[x].prime, 64)) != CRYPT_OK) { goto error; }
39
40 /* ensure p is prime */
41 if ((err = mp_prime_is_prime(p, 8, &primality)) != CRYPT_OK) { goto done; }
42 if (primality != LTC_MP_YES ) {
43 err = CRYPT_FAIL_TESTVECTOR;
44 goto done;
45 }
46
47 if ((err = mp_sub_d(p, 1, tmp)) != CRYPT_OK) { goto error; }
48 if ((err = mp_div_2(tmp, tmp)) != CRYPT_OK) { goto error; }
49
50 /* ensure (p-1)/2 is prime */
51 if ((err = mp_prime_is_prime(tmp, 8, &primality)) != CRYPT_OK) { goto done; }
52 if (primality == 0) {
53 err = CRYPT_FAIL_TESTVECTOR;
54 goto done;
55 }
56
57 /* now see if g^((p-1)/2) mod p is in fact 1 */
58 if ((err = mp_exptmod(g, tmp, p, tmp)) != CRYPT_OK) { goto error; }
59 if (mp_cmp_d(tmp, 1)) {
60 err = CRYPT_FAIL_TESTVECTOR;
61 goto done;
62 }
63 }
64 err = CRYPT_OK;
65 error:
66 done:
67 mp_clear_multi(tmp, g, p, NULL);
68 return err;
228 if (key == NULL) return 0;
229 return mp_unsigned_bin_size(key->prime);
69230 }
70231
71 /**
72 Get the min and max DH key sizes (octets)
73 @param low [out] The smallest key size supported
74 @param high [out] The largest key size supported
75 */
76 void dh_sizes(int *low, int *high)
77 {
78 int x;
79 LTC_ARGCHKVD(low != NULL);
80 LTC_ARGCHKVD(high != NULL);
81 *low = INT_MAX;
82 *high = 0;
83 for (x = 0; sets[x].size != 0; x++) {
84 if (*low > sets[x].size) *low = sets[x].size;
85 if (*high < sets[x].size) *high = sets[x].size;
86 }
87 }
88
89 /**
90 Returns the key size of a given DH key (octets)
91 @param key The DH key to get the size of
92 @return The size if valid or INT_MAX if not
93 */
94 int dh_get_size(dh_key *key)
95 {
96 LTC_ARGCHK(key != NULL);
97 if (key->idx == SUPPLIED_PRIME) {
98 return mp_unsigned_bin_size(key->prime);
99 }
100 if (dh_is_valid_idx(key->idx) == 1) {
101 return sets[key->idx].size;
102 } else {
103 return INT_MAX; /* large value that would cause dh_make_key() to fail */
104 }
105 }
106
107 /**
108 Make a DH key [private key pair]
109 @param prng An active PRNG state
110 @param wprng The index for the PRNG you desire to use
111 @param keysize The key size (octets) desired
112 @param key [out] Where the newly created DH key will be stored
113 @return CRYPT_OK if successful, note: on error all allocated memory will be freed automatically.
114 */
115 int dh_make_key(prng_state *prng, int wprng, int keysize, dh_key *key)
116 {
117 unsigned long x;
118 int err;
119
120 /* find key size */
121 for (x = 0; (keysize > sets[x].size) && (sets[x].size != 0); x++);
122 #ifdef FAST_PK
123 keysize = MIN(sets[x].size, 32);
124 #else
125 keysize = sets[x].size;
126 #endif
127 if (sets[x].size == 0) {
128 return CRYPT_INVALID_KEYSIZE;
129 }
130 key->idx = x;
131
132 if ((err = mp_init_multi(&key->base, &key->prime, NULL)) != CRYPT_OK) {
133 goto error;
134 }
135 if ((err = mp_read_radix(key->base, sets[key->idx].base, 64)) != CRYPT_OK) { goto error; }
136 if ((err = mp_read_radix(key->prime, sets[key->idx].prime, 64)) != CRYPT_OK) { goto error; }
137 return dh_make_key_internal(prng, wprng, key);
138 error:
139 mp_clear_multi(key->base, key->prime, NULL);
140 return err;
141 }
142
143 /**
144 Make a DH key [private key pair] from provided base and prime
145 @param prng An active PRNG state
146 @param wprng The index for the PRNG you desire to use
147 @param keysize The key size (octets) desired
148 @param base The base (generator) to create the key from
149 @param prime The prime to create the key from
150 @param key [out] Where the newly created DH key will be stored
151 @return CRYPT_OK if successful, note: on error all allocated memory will be freed automatically.
152 */
153 int dh_make_key_ex(prng_state *prng, int wprng, const char *base_hex, const char *prime_hex, dh_key *key)
154 {
155 int err;
156
157 LTC_ARGCHK(base_hex != NULL);
158 LTC_ARGCHK(prime_hex != NULL);
159 LTC_ARGCHK(key != NULL);
160
161 /* good prng? */
162 if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
163 return err;
164 }
165
166 if ((err = mp_init_multi(&key->base, &key->prime, NULL)) != CRYPT_OK) {
167 goto error;
168 }
169 if ((err = mp_read_radix(key->base, base_hex, 16)) != CRYPT_OK) { goto error; }
170 if ((err = mp_read_radix(key->prime, prime_hex, 16)) != CRYPT_OK) { goto error; }
171 key->idx = SUPPLIED_PRIME;
172 return dh_make_key_internal(prng, wprng, key);
173 error:
174 mp_clear_multi(key->base, key->prime, NULL);
175 return err;
176 }
177
178
179 int dh_make_key_internal(prng_state *prng, int wprng, dh_key *key)
180 {
181 unsigned char *buf = NULL;
182 int err, keysize;
183
184 LTC_ARGCHK(key != NULL);
185 LTC_ARGCHK(key->prime != NULL);
186 LTC_ARGCHK(key->base != NULL);
187
188 /* init parameters */
189 if ((err = mp_init_multi(&key->x, &key->y, NULL)) != CRYPT_OK) {
190 goto error;
191 }
192
193 keysize = dh_get_size(key);
194 if (keysize < 96) {
195 return CRYPT_INVALID_KEYSIZE;
196 }
197
198 /* allocate buffer */
199 buf = XMALLOC(keysize);
200 if (buf == NULL) {
201 return CRYPT_MEM;
202 }
203
204 /* make up random string */
205 if ( (err = rng_make_prng( keysize, wprng, prng, NULL)) != CRYPT_OK) {
206 /*err = CRYPT_ERROR_READPRNG;*/
207 goto error2;
208 }
209
210 if (prng_descriptor[wprng].read(buf, keysize, prng) != (unsigned long)keysize) {
211 err = CRYPT_ERROR_READPRNG;
212 goto error2;
213 }
214
215 /* load the x value */
216 if ((err = mp_read_unsigned_bin(key->x, buf, keysize)) != CRYPT_OK) { goto error; }
217 if ((err = mp_exptmod(key->base, key->x, key->prime, key->y)) != CRYPT_OK) { goto error; }
218 key->type = PK_PRIVATE;
219
220 /* free up ram */
221 err = CRYPT_OK;
222 goto done;
223 error:
224 mp_clear_multi(key->base, key->prime, key->x, key->y, NULL);
225 done:
226 error2:
227 #ifdef LTC_CLEAN_STACK
228 zeromem(buf, keysize);
229 #endif
230 XFREE(buf);
231 return err;
232 }
233
234 /**
235 Free the allocated ram for a DH key
236 @param key The key which you wish to free
237 */
238 void dh_free(dh_key *key)
239 {
240 LTC_ARGCHKVD(key != NULL);
241 if ( key->base ) {
242 mp_clear( key->base );
243 key->base = NULL;
244 }
245 if ( key->prime ) {
246 mp_clear( key->prime );
247 key->prime = NULL;
248 }
249 if ( key->x ) {
250 mp_clear( key->x );
251 key->x = NULL;
252 }
253 if ( key->y ) {
254 mp_clear( key->y );
255 key->y = NULL;
256 }
257 }
258
259 /**
260 Export a DH key to a binary packet
261 @param out [out] The destination for the key
262 @param outlen [in/out] The max size and resulting size of the DH key
263 @param type Which type of key (PK_PRIVATE or PK_PUBLIC)
264 @param key The key you wish to export
265 @return CRYPT_OK if successful
266 */
267 int dh_export(unsigned char *out, unsigned long *outlen, int type, dh_key *key)
268 {
269 unsigned long y, z;
270 int err;
271
272 LTC_ARGCHK(out != NULL);
273 LTC_ARGCHK(outlen != NULL);
274 LTC_ARGCHK(key != NULL);
275
276 /* can we store the static header? */
277 if (*outlen < (PACKET_SIZE + 2)) {
278 return CRYPT_BUFFER_OVERFLOW;
279 }
280
281 if (type == PK_PRIVATE && key->type != PK_PRIVATE) {
282 return CRYPT_PK_NOT_PRIVATE;
283 }
284
285 /* header */
286 y = PACKET_SIZE;
287
288 /* header */
289 out[y++] = type;
290 out[y++] = key->idx == SUPPLIED_PRIME ?
291 SUPPLIED_PRIME :
292 (unsigned char)(sets[key->idx].size / 8);
293
294 /* export y */
295 OUTPUT_BIGNUM(key->y, out, y, z);
296
297 if (type == PK_PRIVATE) {
298 /* export x */
299 OUTPUT_BIGNUM(key->x, out, y, z);
300 }
301 /* export g and p */
302 if (key->idx == SUPPLIED_PRIME) {
303 OUTPUT_BIGNUM(key->base, out, y, z);
304 OUTPUT_BIGNUM(key->prime, out, y, z);
305 }
306
307 /* store header */
308 packet_store_header(out, PACKET_SECT_DH, PACKET_SUB_KEY);
309
310 /* store len */
311 *outlen = y;
312 return CRYPT_OK;
313 }
314
315 /**
316 Import a DH key from a binary string
317 @param in The string to read
318 @param inlen The length of the input packet
319 @param type The type of key. PK_PRIVATE or PK_PUBLIC
320 @param base The base (generator) in hex string
321 @param prime The prime in hex string
322 @param key [out] Where to import the key to
323 @return CRYPT_OK if successful, on error all allocated memory is freed automatically
324 */
325 int dh_import_raw(unsigned char *in, unsigned long inlen, int type,
326 const char *base_hex, const char *prime_hex, dh_key *key)
327 {
328 int err;
329
330 LTC_ARGCHK(in != NULL);
331 LTC_ARGCHK(base_hex != NULL);
332 LTC_ARGCHK(prime_hex != NULL);
333 LTC_ARGCHK(key != NULL);
334
335 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
336 goto error;
337 }
338 if ((err = mp_read_radix(key->base, base_hex, 16)) != CRYPT_OK) { goto error; }
339 if ((err = mp_read_radix(key->prime, prime_hex, 16)) != CRYPT_OK) { goto error; }
340 key->idx = SUPPLIED_PRIME;
341
342 if (type == PK_PRIVATE) {
343 /* load the x value */
344 if ((err = mp_read_unsigned_bin(key->x, in, inlen)) != CRYPT_OK) { goto error; }
345 if ((err = mp_exptmod(key->base, key->x, key->prime, key->y)) != CRYPT_OK) { goto error; }
346 key->type = PK_PRIVATE;
347 } else {
348 /* load the y value */
349 if ((err = mp_read_unsigned_bin(key->y, in, inlen)) != CRYPT_OK) { goto error; }
350 key->type = PK_PUBLIC;
351 mp_clear(key->x);
352 key->x = NULL;
353 }
354 key->idx = SUPPLIED_PRIME;
355 return CRYPT_OK;
356 error:
357 mp_clear_multi(key->y, key->x, key->base, key->prime, NULL);
358 return err;
359 }
360
361 /**
362 Import a DH key from a binary packet
363 @param in The packet to read
364 @param inlen The length of the input packet
365 @param key [out] Where to import the key to
366 @return CRYPT_OK if successful, on error all allocated memory is freed automatically
367 */
368 int dh_import(const unsigned char *in, unsigned long inlen, dh_key *key)
369 {
370 unsigned long x, y;
371 int s, err;
372
373 LTC_ARGCHK(in != NULL);
374 LTC_ARGCHK(key != NULL);
375
376 /* make sure valid length */
377 if ((2+PACKET_SIZE) > inlen) {
378 return CRYPT_INVALID_PACKET;
379 }
380
381 /* check type byte */
382 if ((err = packet_valid_header((unsigned char *)in, PACKET_SECT_DH, PACKET_SUB_KEY)) != CRYPT_OK) {
383 return err;
384 }
385
386 /* init */
387 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
388 return err;
389 }
390
391 /* advance past packet header */
392 y = PACKET_SIZE;
393
394 /* key type, e.g. private, public */
395 key->type = (int)in[y++];
396
397 /* key size in bytes */
398 s = (int)in[y++];
399
400 if (s == SUPPLIED_PRIME) {
401 /* key from provided p,g values */
402 key->idx = SUPPLIED_PRIME;
403 } else {
404 s *= 8;
405 for (x = 0; (s > sets[x].size) && (sets[x].size != 0); x++);
406 if (sets[x].size == 0) {
407 err = CRYPT_INVALID_KEYSIZE;
408 goto error;
409 }
410 key->idx = (int)x;
411 if ((err = mp_read_radix(key->base, (char *)sets[x].base, 64)) != CRYPT_OK) { goto error; }
412 if ((err = mp_read_radix(key->prime, (char *)sets[x].prime, 64)) != CRYPT_OK) { goto error; }
413 }
414
415 /* type check both values */
416 if ((key->type != PK_PUBLIC) && (key->type != PK_PRIVATE)) {
417 err = CRYPT_PK_TYPE_MISMATCH;
418 goto error;
419 }
420
421 /* is the key idx valid? */
422 if (dh_is_valid_idx(key->idx) != 1) {
423 err = CRYPT_PK_TYPE_MISMATCH;
424 goto error;
425 }
426
427 /* load public value g^x mod p*/
428 INPUT_BIGNUM(key->y, in, x, y, inlen);
429
430 if (key->type == PK_PRIVATE) {
431 INPUT_BIGNUM(key->x, in, x, y, inlen);
432 /* if idx = SUPPLIED_PRIME then prime is not from static table */
433 }
434 if (key->idx == SUPPLIED_PRIME) {
435 INPUT_BIGNUM(key->base, in, x, y, inlen);
436 INPUT_BIGNUM(key->prime, in, x, y, inlen);
437 }
438
439 /* eliminate private key if public */
440 if (key->type == PK_PUBLIC) {
441 mp_clear(key->x);
442 key->x = NULL;
443 }
444
445 return CRYPT_OK;
446 error:
447 mp_clear_multi(key->y, key->x, key->base, key->prime, NULL);
448 return err;
449 }
450
451 /**
452 Create a DH shared secret.
453 @param private_key The private DH key in the pair
454 @param public_key The public DH key in the pair
455 @param out [out] The destination of the shared data
456 @param outlen [in/out] The max size and resulting size of the shared data.
457 @return CRYPT_OK if successful
458 */
459 int dh_shared_secret(dh_key *private_key, dh_key *public_key,
460 unsigned char *out, unsigned long *outlen)
461 {
462 void *tmp;
463 unsigned long x;
464 int err;
465
466 LTC_ARGCHK(private_key != NULL);
467 LTC_ARGCHK(public_key != NULL);
468 LTC_ARGCHK(out != NULL);
469 LTC_ARGCHK(outlen != NULL);
470
471 /* types valid? */
472 if (private_key->type != PK_PRIVATE) {
473 return CRYPT_PK_NOT_PRIVATE;
474 }
475
476 /* same idx? */
477 if (private_key->idx != public_key->idx) {
478 return CRYPT_PK_TYPE_MISMATCH;
479 }
480
481 /* compute y^x mod p */
482 if ((err = mp_init(&tmp)) != CRYPT_OK) {
483 return err;
484 }
485
486 if ((err = mp_exptmod(public_key->y, private_key->x, private_key->prime, tmp)) != CRYPT_OK) { goto error; }
487
488 /* enough space for output? */
489 x = (unsigned long)mp_unsigned_bin_size(tmp);
490 if (*outlen < x) {
491 err = CRYPT_BUFFER_OVERFLOW;
492 goto done;
493 }
494 if ((err = mp_to_unsigned_bin(tmp, out)) != CRYPT_OK) { goto error; }
495 *outlen = x;
496 err = CRYPT_OK;
497 goto done;
498 error:
499 done:
500 mp_clear(tmp);
501 return err;
502 }
503
504232 #endif /* LTC_MDH */
233
234 /* ref: $Format:%D$ */
235 /* git commit: $Format:%H$ */
236 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Check DH public key (INTERNAL ONLY, not part of public API)
15 @param key The key you wish to test
16 @return CRYPT_OK if successful
17 */
18 int dh_check_pubkey(dh_key *key)
19 {
20 void *p_minus1;
21 ltc_mp_digit digit;
22 int i, digit_count, bits_set = 0, err;
23
24 LTC_ARGCHK(key != NULL);
25
26 if ((err = mp_init(&p_minus1)) != CRYPT_OK) {
27 return err;
28 }
29
30 /* avoid: y <= 1 OR y >= p-1 */
31 if ((err = mp_sub_d(key->prime, 1, p_minus1)) != CRYPT_OK) {
32 goto error;
33 }
34 if (mp_cmp(key->y, p_minus1) != LTC_MP_LT || mp_cmp_d(key->y, 1) != LTC_MP_GT) {
35 err = CRYPT_INVALID_ARG;
36 goto error;
37 }
38
39 /* public key must have more than one bit set */
40 digit_count = mp_get_digit_count(key->y);
41 for (i = 0; i < digit_count && bits_set < 2; i++) {
42 digit = mp_get_digit(key->y, i);
43 while (digit > 0) {
44 if (digit & 1) bits_set++;
45 digit >>= 1;
46 }
47 }
48 if (bits_set > 1) {
49 err = CRYPT_OK;
50 }
51 else {
52 err = CRYPT_INVALID_ARG;
53 }
54
55 error:
56 mp_clear(p_minus1);
57 return err;
58 }
59
60 #endif /* LTC_MDH */
61
62 /* ref: $Format:%D$ */
63 /* git commit: $Format:%H$ */
64 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Export a DH key to a binary packet
15 @param out [out] The destination for the key
16 @param outlen [in/out] The max size and resulting size of the DH key
17 @param type Which type of key (PK_PRIVATE or PK_PUBLIC)
18 @param key The key you wish to export
19 @return CRYPT_OK if successful
20 */
21 int dh_export(unsigned char *out, unsigned long *outlen, int type, dh_key *key)
22 {
23 unsigned char flags[1];
24 int err;
25 unsigned long version = 0;
26
27 LTC_ARGCHK(out != NULL);
28 LTC_ARGCHK(outlen != NULL);
29 LTC_ARGCHK(key != NULL);
30
31 if (type == PK_PRIVATE) {
32 /* export x - private key */
33 flags[0] = 1;
34 err = der_encode_sequence_multi(out, outlen,
35 LTC_ASN1_SHORT_INTEGER, 1UL, &version,
36 LTC_ASN1_BIT_STRING, 1UL, flags,
37 LTC_ASN1_INTEGER, 1UL, key->prime,
38 LTC_ASN1_INTEGER, 1UL, key->base,
39 LTC_ASN1_INTEGER, 1UL, key->x,
40 LTC_ASN1_EOL, 0UL, NULL);
41 }
42 else {
43 /* export y - public key */
44 flags[0] = 0;
45 err = der_encode_sequence_multi(out, outlen,
46 LTC_ASN1_SHORT_INTEGER, 1UL, &version,
47 LTC_ASN1_BIT_STRING, 1UL, flags,
48 LTC_ASN1_INTEGER, 1UL, key->prime,
49 LTC_ASN1_INTEGER, 1UL, key->base,
50 LTC_ASN1_INTEGER, 1UL, key->y,
51 LTC_ASN1_EOL, 0UL, NULL);
52 }
53
54 return err;
55 }
56
57 #endif /* LTC_MDH */
58
59 /* ref: $Format:%D$ */
60 /* git commit: $Format:%H$ */
61 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Binary export a DH key to a buffer
15 @param out [out] The destination for the key
16 @param outlen [in/out] The max size and resulting size of the DH key
17 @param type Which type of key (PK_PRIVATE or PK_PUBLIC)
18 @param key The key you wish to export
19 @return CRYPT_OK if successful
20 */
21 int dh_export_key(void *out, unsigned long *outlen, int type, dh_key *key)
22 {
23 unsigned long len;
24 void *k;
25
26 LTC_ARGCHK(out != NULL);
27 LTC_ARGCHK(outlen != NULL);
28 LTC_ARGCHK(key != NULL);
29
30 k = (type == PK_PRIVATE) ? key->x : key->y;
31 len = mp_unsigned_bin_size(k);
32
33 if (*outlen < len) {
34 *outlen = len;
35 return CRYPT_BUFFER_OVERFLOW;
36 }
37 *outlen = len;
38
39 return mp_to_unsigned_bin(k, out);
40 }
41
42 #endif /* LTC_MDH */
43
44 /* ref: $Format:%D$ */
45 /* git commit: $Format:%H$ */
46 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Free the allocated ram for a DH key
15 @param key The key which you wish to free
16 */
17 void dh_free(dh_key *key)
18 {
19 LTC_ARGCHKVD(key != NULL);
20 mp_cleanup_multi(&key->prime, &key->base, &key->y, &key->x, NULL);
21 }
22
23 #endif /* LTC_MDH */
24
25 /* ref: $Format:%D$ */
26 /* git commit: $Format:%H$ */
27 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 static int _dh_groupsize_to_keysize(int groupsize)
14 {
15 /* The strength estimates from https://tools.ietf.org/html/rfc3526#section-8
16 * We use "Estimate 2" to get an appropriate private key (exponent) size.
17 */
18 if (groupsize <= 0) {
19 return 0;
20 }
21 else if (groupsize <= 192) {
22 return 30; /* 1536-bit => key size 240-bit */
23 }
24 else if (groupsize <= 256) {
25 return 40; /* 2048-bit => key size 320-bit */
26 }
27 else if (groupsize <= 384) {
28 return 52; /* 3072-bit => key size 416-bit */
29 }
30 else if (groupsize <= 512) {
31 return 60; /* 4096-bit => key size 480-bit */
32 }
33 else if (groupsize <= 768) {
34 return 67; /* 6144-bit => key size 536-bit */
35 }
36 else if (groupsize <= 1024) {
37 return 77; /* 8192-bit => key size 616-bit */
38 }
39 else {
40 return 0;
41 }
42 }
43
44 int dh_generate_key(prng_state *prng, int wprng, dh_key *key)
45 {
46 unsigned char *buf;
47 unsigned long keysize;
48 int err, max_iterations = LTC_PK_MAX_RETRIES;
49
50 LTC_ARGCHK(key != NULL);
51 LTC_ARGCHK(ltc_mp.name != NULL);
52
53 /* good prng? */
54 if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
55 return err;
56 }
57
58 keysize = _dh_groupsize_to_keysize(mp_unsigned_bin_size(key->prime));
59 if (keysize == 0) {
60 err = CRYPT_INVALID_KEYSIZE;
61 goto freemp;
62 }
63
64 /* allocate buffer */
65 buf = XMALLOC(keysize);
66 if (buf == NULL) {
67 err = CRYPT_MEM;
68 goto freemp;
69 }
70
71 key->type = PK_PRIVATE;
72 do {
73 /* make up random buf */
74 if (prng_descriptor[wprng].read(buf, keysize, prng) != keysize) {
75 err = CRYPT_ERROR_READPRNG;
76 goto freebuf;
77 }
78 /* load the x value - private key */
79 if ((err = mp_read_unsigned_bin(key->x, buf, keysize)) != CRYPT_OK) {
80 goto freebuf;
81 }
82 /* compute the y value - public key */
83 if ((err = mp_exptmod(key->base, key->x, key->prime, key->y)) != CRYPT_OK) {
84 goto freebuf;
85 }
86 err = dh_check_pubkey(key);
87 } while (err != CRYPT_OK && max_iterations-- > 0);
88
89 freebuf:
90 zeromem(buf, keysize);
91 XFREE(buf);
92 freemp:
93 if (err != CRYPT_OK) dh_free(key);
94 return err;
95 }
96
97 #endif /* LTC_MDH */
98
99 /* ref: $Format:%D$ */
100 /* git commit: $Format:%H$ */
101 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Import a DH key from a binary packet
15 @param in The packet to read
16 @param inlen The length of the input packet
17 @param key [out] Where to import the key to
18 @return CRYPT_OK if successful, on error all allocated memory is freed automatically
19 */
20 int dh_import(const unsigned char *in, unsigned long inlen, dh_key *key)
21 {
22 unsigned char flags[1];
23 int err;
24 unsigned long version;
25
26 LTC_ARGCHK(in != NULL);
27 LTC_ARGCHK(key != NULL);
28
29 /* init */
30 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
31 return err;
32 }
33
34 /* find out what type of key it is */
35 err = der_decode_sequence_multi(in, inlen,
36 LTC_ASN1_SHORT_INTEGER, 1UL, &version,
37 LTC_ASN1_BIT_STRING, 1UL, &flags,
38 LTC_ASN1_EOL, 0UL, NULL);
39 if (err != CRYPT_OK && err != CRYPT_INPUT_TOO_LONG) {
40 goto error;
41 }
42
43 if (version == 0) {
44 if (flags[0] == 1) {
45 key->type = PK_PRIVATE;
46 if ((err = der_decode_sequence_multi(in, inlen,
47 LTC_ASN1_SHORT_INTEGER, 1UL, &version,
48 LTC_ASN1_BIT_STRING, 1UL, flags,
49 LTC_ASN1_INTEGER, 1UL, key->prime,
50 LTC_ASN1_INTEGER, 1UL, key->base,
51 LTC_ASN1_INTEGER, 1UL, key->x,
52 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
53 goto error;
54 }
55 /* compute public key: y = (base ^ x) mod prime */
56 if ((err = mp_exptmod(key->base, key->x, key->prime, key->y)) != CRYPT_OK) {
57 goto error;
58 }
59 }
60 else if (flags[0] == 0) {
61 key->type = PK_PUBLIC;
62 if ((err = der_decode_sequence_multi(in, inlen,
63 LTC_ASN1_SHORT_INTEGER, 1UL, &version,
64 LTC_ASN1_BIT_STRING, 1UL, flags,
65 LTC_ASN1_INTEGER, 1UL, key->prime,
66 LTC_ASN1_INTEGER, 1UL, key->base,
67 LTC_ASN1_INTEGER, 1UL, key->y,
68 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
69 goto error;
70 }
71 }
72 else {
73 err = CRYPT_INVALID_PACKET;
74 goto error;
75 }
76 }
77 else {
78 err = CRYPT_INVALID_PACKET;
79 goto error;
80 }
81
82 /* check public key */
83 if ((err = dh_check_pubkey(key)) != CRYPT_OK) {
84 goto error;
85 }
86
87 return CRYPT_OK;
88
89 error:
90 dh_free(key);
91 return err;
92 }
93
94 #endif /* LTC_MDH */
95
96 /* ref: $Format:%D$ */
97 /* git commit: $Format:%H$ */
98 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Import DH key parts p and g from raw numbers
15
16 @param p DH's p (prime)
17 @param plen DH's p's length
18 @param g DH's g (group)
19 @param glen DH's g's length
20 @param key [out] the destination for the imported key
21 @return CRYPT_OK if successful
22 */
23 int dh_set_pg(const unsigned char *p, unsigned long plen,
24 const unsigned char *g, unsigned long glen,
25 dh_key *key)
26 {
27 int err;
28
29 LTC_ARGCHK(key != NULL);
30 LTC_ARGCHK(p != NULL);
31 LTC_ARGCHK(g != NULL);
32 LTC_ARGCHK(ltc_mp.name != NULL);
33
34 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
35 return err;
36 }
37
38 if ((err = mp_read_unsigned_bin(key->base, (unsigned char*)g, glen)) != CRYPT_OK) { goto LBL_ERR; }
39 if ((err = mp_read_unsigned_bin(key->prime, (unsigned char*)p, plen)) != CRYPT_OK) { goto LBL_ERR; }
40
41 return CRYPT_OK;
42
43 LBL_ERR:
44 dh_free(key);
45 return err;
46 }
47
48 /**
49 Import DH key parts p and g from built-in DH groups
50
51 @param groupsize The size of the DH group to use
52 @param key [out] Where the newly created DH key will be stored
53 @return CRYPT_OK if successful, note: on error all allocated memory will be freed automatically.
54 */
55 int dh_set_pg_groupsize(int groupsize, dh_key *key)
56 {
57 int err, i;
58
59 LTC_ARGCHK(key != NULL);
60 LTC_ARGCHK(ltc_mp.name != NULL);
61 LTC_ARGCHK(groupsize > 0);
62
63 for (i = 0; (groupsize > ltc_dh_sets[i].size) && (ltc_dh_sets[i].size != 0); i++);
64 if (ltc_dh_sets[i].size == 0) return CRYPT_INVALID_KEYSIZE;
65
66 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
67 return err;
68 }
69 if ((err = mp_read_radix(key->base, ltc_dh_sets[i].base, 16)) != CRYPT_OK) { goto LBL_ERR; }
70 if ((err = mp_read_radix(key->prime, ltc_dh_sets[i].prime, 16)) != CRYPT_OK) { goto LBL_ERR; }
71
72 return CRYPT_OK;
73
74 LBL_ERR:
75 dh_free(key);
76 return err;
77 }
78
79 /**
80 Import DH public or private key part from raw numbers
81
82 NB: The p & g parts must be set beforehand
83
84 @param in The key-part to import, either public or private.
85 @param inlen The key-part's length
86 @param type Which type of key (PK_PRIVATE or PK_PUBLIC)
87 @param key [out] the destination for the imported key
88 @return CRYPT_OK if successful
89 */
90 int dh_set_key(const unsigned char *in, unsigned long inlen, int type, dh_key *key)
91 {
92 int err;
93
94 LTC_ARGCHK(key != NULL);
95 LTC_ARGCHK(ltc_mp.name != NULL);
96
97 if (type == PK_PRIVATE) {
98 key->type = PK_PRIVATE;
99 if ((err = mp_read_unsigned_bin(key->x, (unsigned char*)in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
100 if ((err = mp_exptmod(key->base, key->x, key->prime, key->y)) != CRYPT_OK) { goto LBL_ERR; }
101 }
102 else {
103 key->type = PK_PUBLIC;
104 if ((err = mp_read_unsigned_bin(key->y, (unsigned char*)in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
105 }
106
107 /* check public key */
108 if ((err = dh_check_pubkey(key)) != CRYPT_OK) {
109 goto LBL_ERR;
110 }
111
112 return CRYPT_OK;
113
114 LBL_ERR:
115 dh_free(key);
116 return err;
117 }
118
119 #endif /* LTC_MDH */
120
121 /* ref: $Format:%D$ */
122 /* git commit: $Format:%H$ */
123 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Import DH key parts p and g from dhparam
15
16 dhparam data: openssl dhparam -outform DER -out dhparam.der 2048
17
18 @param dhparam The DH param DER encoded data
19 @param dhparamlen The length of dhparam data
20 @param key [out] Where the newly created DH key will be stored
21 @return CRYPT_OK if successful, note: on error all allocated memory will be freed automatically.
22 */
23 int dh_set_pg_dhparam(const unsigned char *dhparam, unsigned long dhparamlen, dh_key *key)
24 {
25 int err;
26
27 LTC_ARGCHK(key != NULL);
28 LTC_ARGCHK(ltc_mp.name != NULL);
29 LTC_ARGCHK(dhparam != NULL);
30 LTC_ARGCHK(dhparamlen > 0);
31
32 if ((err = mp_init_multi(&key->x, &key->y, &key->base, &key->prime, NULL)) != CRYPT_OK) {
33 return err;
34 }
35 if ((err = der_decode_sequence_multi(dhparam, dhparamlen,
36 LTC_ASN1_INTEGER, 1UL, key->prime,
37 LTC_ASN1_INTEGER, 1UL, key->base,
38 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
39 goto LBL_ERR;
40 }
41
42 return CRYPT_OK;
43
44 LBL_ERR:
45 dh_free(key);
46 return err;
47 }
48
49 #endif /* LTC_MDH */
50
51 /* ref: $Format:%D$ */
52 /* git commit: $Format:%H$ */
53 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 #ifdef LTC_MDH
12
13 /**
14 Create a DH shared secret.
15 @param private_key The private DH key in the pair
16 @param public_key The public DH key in the pair
17 @param out [out] The destination of the shared data
18 @param outlen [in/out] The max size and resulting size of the shared data.
19 @return CRYPT_OK if successful
20 */
21 int dh_shared_secret(dh_key *private_key, dh_key *public_key,
22 unsigned char *out, unsigned long *outlen)
23 {
24 void *tmp;
25 unsigned long x;
26 int err;
27
28 LTC_ARGCHK(private_key != NULL);
29 LTC_ARGCHK(public_key != NULL);
30 LTC_ARGCHK(out != NULL);
31 LTC_ARGCHK(outlen != NULL);
32
33 /* types valid? */
34 if (private_key->type != PK_PRIVATE) {
35 return CRYPT_PK_NOT_PRIVATE;
36 }
37
38 /* same DH group? */
39 if (mp_cmp(private_key->prime, public_key->prime) != LTC_MP_EQ) { return CRYPT_PK_TYPE_MISMATCH; }
40 if (mp_cmp(private_key->base, public_key->base) != LTC_MP_EQ) { return CRYPT_PK_TYPE_MISMATCH; }
41
42 /* init big numbers */
43 if ((err = mp_init(&tmp)) != CRYPT_OK) {
44 return err;
45 }
46
47 /* check public key */
48 if ((err = dh_check_pubkey(public_key)) != CRYPT_OK) {
49 goto error;
50 }
51
52 /* compute tmp = y^x mod p */
53 if ((err = mp_exptmod(public_key->y, private_key->x, private_key->prime, tmp)) != CRYPT_OK) {
54 goto error;
55 }
56
57 /* enough space for output? */
58 x = (unsigned long)mp_unsigned_bin_size(tmp);
59 if (*outlen < x) {
60 *outlen = x;
61 err = CRYPT_BUFFER_OVERFLOW;
62 goto error;
63 }
64 if ((err = mp_to_unsigned_bin(tmp, out)) != CRYPT_OK) {
65 goto error;
66 }
67 *outlen = x;
68 err = CRYPT_OK;
69
70 error:
71 mp_clear(tmp);
72 return err;
73 }
74
75 #endif /* LTC_MDH */
76
77 /* ref: $Format:%D$ */
78 /* git commit: $Format:%H$ */
79 /* commit time: $Format:%ai$ */
+0
-165
src/ltc/pk/dh/dh_static.c less more
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
9 */
10 #include "tomcrypt.h"
11
12 /**
13 @file dh_static.c
14 DH crypto, Tom St Denis
15 */
16
17 #ifdef LTC_MDH
18
19 #define __DECL_DH_STATIC_H__
20 #include "dh_static.h"
21
22 /* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
23 const dh_set sets[] = {
24 #ifdef LTC_DH768
25 {
26 96,
27 "DH-768",
28 "4",
29 "F///////////////////////////////////////////////////////////"
30 "////////////////////////////////////////////////////////////"
31 "//////m3wvV"
32 },
33 #endif
34 #ifdef LTC_DH1024
35 {
36 128,
37 "DH-1024",
38 "4",
39 "F///////////////////////////////////////////////////////////"
40 "////////////////////////////////////////////////////////////"
41 "////////////////////////////////////////////////m3C47"
42 },
43 #endif
44 #ifdef LTC_DH1280
45 {
46 160,
47 "DH-1280",
48 "4",
49 "F///////////////////////////////////////////////////////////"
50 "////////////////////////////////////////////////////////////"
51 "////////////////////////////////////////////////////////////"
52 "//////////////////////////////m4kSN"
53 },
54 #endif
55 #ifdef LTC_DH1536
56 {
57 192,
58 "DH-1536",
59 "4",
60 "F///////////////////////////////////////////////////////////"
61 "////////////////////////////////////////////////////////////"
62 "////////////////////////////////////////////////////////////"
63 "////////////////////////////////////////////////////////////"
64 "////////////m5uqd"
65 },
66 #endif
67 #ifdef LTC_DH1792
68 {
69 224,
70 "DH-1792",
71 "4",
72 "F///////////////////////////////////////////////////////////"
73 "////////////////////////////////////////////////////////////"
74 "////////////////////////////////////////////////////////////"
75 "////////////////////////////////////////////////////////////"
76 "//////////////////////////////////////////////////////mT/sd"
77 },
78 #endif
79 #ifdef LTC_DH2048
80 {
81 256,
82 "DH-2048",
83 "4",
84 "3///////////////////////////////////////////////////////////"
85 "////////////////////////////////////////////////////////////"
86 "////////////////////////////////////////////////////////////"
87 "////////////////////////////////////////////////////////////"
88 "////////////////////////////////////////////////////////////"
89 "/////////////////////////////////////////m8MPh"
90 },
91 #endif
92 #ifdef LTC_DH2560
93 {
94 320,
95 "DH-2560",
96 "4",
97 "3///////////////////////////////////////////////////////////"
98 "////////////////////////////////////////////////////////////"
99 "////////////////////////////////////////////////////////////"
100 "////////////////////////////////////////////////////////////"
101 "////////////////////////////////////////////////////////////"
102 "////////////////////////////////////////////////////////////"
103 "////////////////////////////////////////////////////////////"
104 "/////mKFpF"
105 },
106 #endif
107 #ifdef LTC_DH3072
108 {
109 384,
110 "DH-3072",
111 "4",
112 "3///////////////////////////////////////////////////////////"
113 "////////////////////////////////////////////////////////////"
114 "////////////////////////////////////////////////////////////"
115 "////////////////////////////////////////////////////////////"
116 "////////////////////////////////////////////////////////////"
117 "////////////////////////////////////////////////////////////"
118 "////////////////////////////////////////////////////////////"
119 "////////////////////////////////////////////////////////////"
120 "/////////////////////////////m32nN"
121 },
122 #endif
123 #ifdef LTC_DH4096
124 {
125 512,
126 "DH-4096",
127 "4",
128 "////////////////////////////////////////////////////////////"
129 "////////////////////////////////////////////////////////////"
130 "////////////////////////////////////////////////////////////"
131 "////////////////////////////////////////////////////////////"
132 "////////////////////////////////////////////////////////////"
133 "////////////////////////////////////////////////////////////"
134 "////////////////////////////////////////////////////////////"
135 "////////////////////////////////////////////////////////////"
136 "////////////////////////////////////////////////////////////"
137 "////////////////////////////////////////////////////////////"
138 "////////////////////////////////////////////////////////////"
139 "/////////////////////m8pOF"
140 },
141 #endif
142 {
143 0,
144 NULL,
145 NULL,
146 NULL
147 }
148 };
149
150 int dh_is_valid_idx(int n)
151 {
152 int x;
153
154 if (n == SUPPLIED_PRIME)
155 return 1;
156 for (x = 0; sets[x].size; x++);
157 if ((n < 0) || (n >= x)) {
158 return 0;
159 }
160 return 1;
161 }
162
163
164 #endif /* LTC_MDH */
+0
-129
src/ltc/pk/dh/dh_static.h less more
0 #ifndef __DH_STATIC_H__
1 #define __DH_STATIC_H__
2 #ifndef __DECL_DH_STATIC_H__
3 #define __DECL_DH_STATIC_H__ extern
4 #endif
5
6 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
7 *
8 * LibTomCrypt is a library that provides various cryptographic
9 * algorithms in a highly modular and flexible manner.
10 *
11 * The library is free for all purposes without any express
12 * guarantee it works.
13 *
14 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
15 */
16 #include "tomcrypt.h"
17
18 /**
19 @file dh_static.h
20 DH crypto, Tom St Denis
21 */
22
23 #ifdef LTC_MDH
24
25 /* size of a packet header in bytes */
26 #define PACKET_SIZE 4
27
28 /* Section tags */
29 #define PACKET_SECT_DH 1
30
31 /* Subsection Tags for the first three sections */
32 #define PACKET_SUB_KEY 0
33 #define PACKET_SUB_ENCRYPTED 1
34 #define PACKET_SUB_SIGNED 2
35 #define PACKET_SUB_ENC_KEY 3
36
37 #define OUTPUT_BIGNUM(num, out, y, z) \
38 { \
39 if ((y + 4) > *outlen) { return CRYPT_BUFFER_OVERFLOW; } \
40 z = (unsigned long)mp_unsigned_bin_size(num); \
41 STORE32L(z, out+y); \
42 y += 4; \
43 if ((y + z) > *outlen) { return CRYPT_BUFFER_OVERFLOW; } \
44 if ((err = mp_to_unsigned_bin(num, out+y)) != CRYPT_OK) { return err; } \
45 y += z; \
46 }
47
48 #define INPUT_BIGNUM(num, in, x, y, inlen) \
49 { \
50 /* load value */ \
51 if ((y + 4) > inlen) { \
52 err = CRYPT_INVALID_PACKET; \
53 goto error; \
54 } \
55 LOAD32L(x, in+y); \
56 y += 4; \
57 \
58 /* sanity check... */ \
59 if ((x+y) > inlen) { \
60 err = CRYPT_INVALID_PACKET; \
61 goto error; \
62 } \
63 \
64 /* load it */ \
65 if ((err = mp_read_unsigned_bin(num, (unsigned char *)in+y, (int)x)) != CRYPT_OK) {\
66 goto error; \
67 } \
68 y += x; \
69 }
70
71 #define SUPPLIED_PRIME 255
72
73 /* XXX: HP C compiler + IBM C compiler do not like "static inline" */
74 static void packet_store_header (unsigned char *dst, int section, int subsection)
75 {
76 LTC_ARGCHKVD(dst != NULL);
77
78 /* store version number */
79 dst[0] = (unsigned char)(CRYPT&255);
80 dst[1] = (unsigned char)((CRYPT>>8)&255);
81
82 /* store section and subsection */
83 dst[2] = (unsigned char)(section & 255);
84 dst[3] = (unsigned char)(subsection & 255);
85
86 }
87
88 /* XXX: HP C compiler + IBM C compiler do not like "static inline" */
89 static int packet_valid_header (unsigned char *src, int section, int subsection)
90 {
91 unsigned long ver;
92
93 LTC_ARGCHK(src != NULL);
94
95 /* check version */
96 ver = ((unsigned long)src[0]) | ((unsigned long)src[1] << 8U);
97 if (CRYPT < ver) {
98 return CRYPT_INVALID_PACKET;
99 }
100
101 /* check section and subsection */
102 if (section != (int)src[2] || subsection != (int)src[3]) {
103 return CRYPT_INVALID_PACKET;
104 }
105
106 return CRYPT_OK;
107 }
108
109 #ifndef DH_BUF_SIZE
110 /* max export size we'll encounter (smaller than this but lets round up a bit) */
111 #define DH_BUF_SIZE 1200
112 #endif /* DH_BUF_SIZE */
113
114 typedef struct {
115 int size;
116 char *name, *base, *prime;
117 } dh_set;
118
119 /* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
120 __DECL_DH_STATIC_H__ const dh_set sets[];
121
122
123 int dh_is_valid_idx(int n);
124
125
126 #endif /* __DH_STATIC_H__ */
127
128 #endif /* LTC_MDH */
+0
-487
src/ltc/pk/dh/dh_sys.c less more
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
9 */
10
11 #include "tomcrypt.h"
12
13 #ifdef LTC_MDH
14 /**
15 @file dh_sys.c
16 DH Crypto, Tom St Denis
17 */
18
19 #include "dh_static.h"
20
21
22 /**
23 Encrypt a short symmetric key with a public DH key
24 @param in The symmetric key to encrypt
25 @param inlen The length of the key (octets)
26 @param out [out] The ciphertext
27 @param outlen [in/out] The max size and resulting size of the ciphertext
28 @param prng An active PRNG state
29 @param wprng The index of the PRNG desired
30 @param hash The index of the hash desired (must produce a digest of size >= the size of the plaintext)
31 @param key The public key you wish to encrypt with.
32 @return CRYPT_OK if successful
33 */
34 int dh_encrypt_key(const unsigned char *in, unsigned long inlen,
35 unsigned char *out, unsigned long *outlen,
36 prng_state *prng, int wprng, int hash,
37 dh_key *key)
38 {
39 unsigned char *pub_expt, *dh_shared, *skey;
40 dh_key pubkey;
41 unsigned long x, y, z, pubkeysize;
42 int err;
43
44 LTC_ARGCHK(in != NULL);
45 LTC_ARGCHK(out != NULL);
46 LTC_ARGCHK(outlen != NULL);
47 LTC_ARGCHK(key != NULL);
48
49 /* check that wprng/hash are not invalid */
50 if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
51 return err;
52 }
53
54 if ((err = hash_is_valid(hash)) != CRYPT_OK) {
55 return err;
56 }
57
58 if (inlen > hash_descriptor[hash].hashsize) {
59 return CRYPT_INVALID_HASH;
60 }
61
62 /* allocate memory */
63 pub_expt = XMALLOC(DH_BUF_SIZE);
64 dh_shared = XMALLOC(DH_BUF_SIZE);
65 skey = XMALLOC(MAXBLOCKSIZE);
66 if (pub_expt == NULL || dh_shared == NULL || skey == NULL) {
67 if (pub_expt != NULL) {
68 XFREE(pub_expt);
69 }
70 if (dh_shared != NULL) {
71 XFREE(dh_shared);
72 }
73 if (skey != NULL) {
74 XFREE(skey);
75 }
76 return CRYPT_MEM;
77 }
78
79 /* make a random key and export the public copy */
80 pubkey.idx = key->idx;
81 if ((err = mp_init_multi(&pubkey.base, &pubkey.prime, NULL)) != CRYPT_OK) {
82 goto LBL_ERR;
83 }
84 if ((err = mp_copy(key->base, pubkey.base)) != CRYPT_OK) { goto LBL_ERR; }
85 if ((err = mp_copy(key->prime, pubkey.prime)) != CRYPT_OK) { goto LBL_ERR; }
86 if ((err = dh_make_key_internal(prng, wprng, &pubkey)) != CRYPT_OK) {
87 goto LBL_ERR;
88 }
89
90 pubkeysize = DH_BUF_SIZE;
91 if ((err = dh_export(pub_expt, &pubkeysize, PK_PUBLIC, &pubkey)) != CRYPT_OK) {
92 dh_free(&pubkey);
93 goto LBL_ERR;
94 }
95
96 /* now check if the out buffer is big enough */
97 if (*outlen < (1 + 4 + 4 + PACKET_SIZE + pubkeysize + inlen)) {
98 dh_free(&pubkey);
99 err = CRYPT_BUFFER_OVERFLOW;
100 goto LBL_ERR;
101 }
102
103 x = DH_BUF_SIZE;
104 if ((err = dh_shared_secret(&pubkey, key, dh_shared, &x)) != CRYPT_OK) {
105 dh_free(&pubkey);
106 goto LBL_ERR;
107 }
108 dh_free(&pubkey);
109
110 z = MAXBLOCKSIZE;
111 if ((err = hash_memory(hash, dh_shared, x, skey, &z)) != CRYPT_OK) {
112 goto LBL_ERR;
113 }
114
115 /* store header */
116 packet_store_header(out, PACKET_SECT_DH, PACKET_SUB_ENC_KEY);
117
118 /* output header */
119 y = PACKET_SIZE;
120
121 /* size of hash name and the name itself */
122 out[y++] = hash_descriptor[hash].ID;
123
124 /* length of DH pubkey and the key itself */
125 STORE32L(pubkeysize, out+y);
126 y += 4;
127 for (x = 0; x < pubkeysize; x++, y++) {
128 out[y] = pub_expt[x];
129 }
130
131 /* Store the encrypted key */
132 STORE32L(inlen, out+y);
133 y += 4;
134
135 for (x = 0; x < inlen; x++, y++) {
136 out[y] = skey[x] ^ in[x];
137 }
138 *outlen = y;
139
140 err = CRYPT_OK;
141 LBL_ERR:
142 #ifdef LTC_CLEAN_STACK
143 /* clean up */
144 zeromem(pub_expt, DH_BUF_SIZE);
145 zeromem(dh_shared, DH_BUF_SIZE);
146 zeromem(skey, MAXBLOCKSIZE);
147 #endif
148 XFREE(skey);
149 XFREE(dh_shared);
150 XFREE(pub_expt);
151
152 return err;
153 }
154
155 /**
156 Decrypt a DH encrypted symmetric key
157 @param in The DH encrypted packet
158 @param inlen The length of the DH encrypted packet
159 @param out The plaintext
160 @param outlen [in/out] The max size and resulting size of the plaintext
161 @param key The private DH key corresponding to the public key that encrypted the plaintext
162 @return CRYPT_OK if successful
163 */
164 int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
165 unsigned char *out, unsigned long *outlen,
166 dh_key *key)
167 {
168 unsigned char *shared_secret, *skey;
169 unsigned long x, y, z, keysize;
170 int hash, err;
171 dh_key pubkey;
172
173 LTC_ARGCHK(in != NULL);
174 LTC_ARGCHK(out != NULL);
175 LTC_ARGCHK(outlen != NULL);
176 LTC_ARGCHK(key != NULL);
177
178 /* right key type? */
179 if (key->type != PK_PRIVATE) {
180 return CRYPT_PK_NOT_PRIVATE;
181 }
182
183 /* allocate ram */
184 shared_secret = XMALLOC(DH_BUF_SIZE);
185 skey = XMALLOC(MAXBLOCKSIZE);
186 if (shared_secret == NULL || skey == NULL) {
187 if (shared_secret != NULL) {
188 XFREE(shared_secret);
189 }
190 if (skey != NULL) {
191 XFREE(skey);
192 }
193 return CRYPT_MEM;
194 }
195
196 /* check if initial header should fit */
197 if (inlen < PACKET_SIZE+1+4+4) {
198 err = CRYPT_INVALID_PACKET;
199 goto LBL_ERR;
200 } else {
201 inlen -= PACKET_SIZE+1+4+4;
202 }
203
204 /* is header correct? */
205 if ((err = packet_valid_header((unsigned char *)in, PACKET_SECT_DH, PACKET_SUB_ENC_KEY)) != CRYPT_OK) {
206 goto LBL_ERR;
207 }
208
209 /* now lets get the hash name */
210 y = PACKET_SIZE;
211 hash = find_hash_id(in[y++]);
212 if (hash == -1) {
213 err = CRYPT_INVALID_HASH;
214 goto LBL_ERR;
215 }
216
217 /* get public key */
218 LOAD32L(x, in+y);
219
220 /* now check if the imported key will fit */
221 if (inlen < x) {
222 err = CRYPT_INVALID_PACKET;
223 goto LBL_ERR;
224 } else {
225 inlen -= x;
226 }
227
228 y += 4;
229 if ((err = dh_import(in+y, x, &pubkey)) != CRYPT_OK) {
230 goto LBL_ERR;
231 }
232 y += x;
233
234 /* make shared key */
235 x = DH_BUF_SIZE;
236 if ((err = dh_shared_secret(key, &pubkey, shared_secret, &x)) != CRYPT_OK) {
237 dh_free(&pubkey);
238 goto LBL_ERR;
239 }
240 dh_free(&pubkey);
241
242 z = MAXBLOCKSIZE;
243 if ((err = hash_memory(hash, shared_secret, x, skey, &z)) != CRYPT_OK) {
244 goto LBL_ERR;
245 }
246
247 /* load in the encrypted key */
248 LOAD32L(keysize, in+y);
249
250 /* will the out fit as part of the input */
251 if (inlen < keysize) {
252 err = CRYPT_INVALID_PACKET;
253 goto LBL_ERR;
254 }
255
256 if (keysize > *outlen) {
257 err = CRYPT_BUFFER_OVERFLOW;
258 goto LBL_ERR;
259 }
260 y += 4;
261
262 *outlen = keysize;
263
264 for (x = 0; x < keysize; x++, y++) {
265 out[x] = skey[x] ^ in[y];
266 }
267
268 err = CRYPT_OK;
269 LBL_ERR:
270 #ifdef LTC_CLEAN_STACK
271 zeromem(shared_secret, DH_BUF_SIZE);
272 zeromem(skey, MAXBLOCKSIZE);
273 #endif
274
275 XFREE(skey);
276 XFREE(shared_secret);
277
278 return err;
279 }
280
281 /* perform an ElGamal Signature of a hash
282 *
283 * The math works as follows. x is the private key, M is the message to sign
284
285 1. pick a random k
286 2. compute a = g^k mod p
287 3. compute b = (M - xa)/k mod p
288 4. Send (a,b)
289
290 Now to verify with y=g^x mod p, a and b
291
292 1. compute y^a * a^b = g^(xa) * g^(k*(M-xa)/k)
293 = g^(xa + (M - xa))
294 = g^M [all mod p]
295
296 2. Compare against g^M mod p [based on input hash].
297 3. If result of #2 == result of #1 then signature valid
298 */
299
300 /**
301 Sign a message digest using a DH private key
302 @param in The data to sign
303 @param inlen The length of the input (octets)
304 @param out [out] The destination of the signature
305 @param outlen [in/out] The max size and resulting size of the output
306 @param prng An active PRNG state
307 @param wprng The index of the PRNG desired
308 @param key A private DH key
309 @return CRYPT_OK if successful
310 */
311 int dh_sign_hash(const unsigned char *in, unsigned long inlen,
312 unsigned char *out, unsigned long *outlen,
313 prng_state *prng, int wprng, dh_key *key)
314 {
315 void *a, *b, *k, *m, *p1, *tmp;
316 unsigned char *buf;
317 unsigned long x, y;
318 int err;
319
320 LTC_ARGCHK(in != NULL);
321 LTC_ARGCHK(out != NULL);
322 LTC_ARGCHK(outlen != NULL);
323 LTC_ARGCHK(key != NULL);
324
325 /* check parameters */
326 if (key->type != PK_PRIVATE) {
327 return CRYPT_PK_NOT_PRIVATE;
328 }
329
330 if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
331 return err;
332 }
333
334 /* is the IDX valid ? */
335 if (dh_is_valid_idx(key->idx) != 1) {
336 return CRYPT_PK_INVALID_TYPE;
337 }
338
339 /* allocate ram for buf */
340 buf = XMALLOC(520);
341
342 /* make up a random value k,
343 * since the order of the group is prime
344 * we need not check if gcd(k, r) is 1
345 */
346 if (prng_descriptor[wprng].read(buf, dh_get_size(key), prng) !=
347 (unsigned long)(dh_get_size(key))) {
348 err = CRYPT_ERROR_READPRNG;
349 goto LBL_ERR_1;
350 }
351
352 /* init bignums */
353 if ((err = mp_init_multi(&a, &b, &k, &m, &p1, &tmp, NULL)) != CRYPT_OK) {
354 goto LBL_ERR;
355 }
356
357 /* load k, m and p1 */
358 if ((err = mp_read_unsigned_bin(m, (unsigned char *)in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
359 if ((err = mp_read_unsigned_bin(k, buf, dh_get_size(key))) != CRYPT_OK) { goto LBL_ERR; }
360 if ((err = mp_sub_d(key->prime, 1, p1)) != CRYPT_OK) { goto LBL_ERR; }
361 if ((err = mp_div_2(p1, p1)) != CRYPT_OK) { goto LBL_ERR; } /* p1 = (p-1)/2 */
362 /* now get a = g^k mod p */
363 if ((err = mp_exptmod(key->base, k, key->prime, a)) != CRYPT_OK) { goto LBL_ERR; }
364
365 /* now find M = xa + kb mod p1 or just b = (M - xa)/k mod p1 */
366 if ((err = mp_invmod(k, p1, k)) != CRYPT_OK) { goto LBL_ERR; } /* k = 1/k mod p1 */
367 if ((err = mp_mulmod(a, key->x, p1, tmp)) != CRYPT_OK) { goto LBL_ERR; } /* tmp = xa */
368 if ((err = mp_submod(m, tmp, p1, tmp)) != CRYPT_OK) { goto LBL_ERR; } /* tmp = M - xa */
369 if ((err = mp_mulmod(k, tmp, p1, b)) != CRYPT_OK) { goto LBL_ERR; } /* b = (M - xa)/k */
370
371 /* check for overflow */
372 if ((unsigned long)(PACKET_SIZE + 4 + 4 + mp_unsigned_bin_size(a) + mp_unsigned_bin_size(b)) > *outlen) {
373 err = CRYPT_BUFFER_OVERFLOW;
374 goto LBL_ERR;
375 }
376
377 /* store header */
378 y = PACKET_SIZE;
379
380 /* now store them both (a,b) */
381 x = (unsigned long)mp_unsigned_bin_size(a);
382 STORE32L(x, out+y); y += 4;
383 if ((err = mp_to_unsigned_bin(a, out+y)) != CRYPT_OK) { goto LBL_ERR; }
384 y += x;
385
386 x = (unsigned long)mp_unsigned_bin_size(b);
387 STORE32L(x, out+y); y += 4;
388 if ((err = mp_to_unsigned_bin(b, out+y)) != CRYPT_OK) { goto LBL_ERR; }
389 y += x;
390
391 /* check if size too big */
392 if (*outlen < y) {
393 err = CRYPT_BUFFER_OVERFLOW;
394 goto LBL_ERR;
395 }
396
397 /* store header */
398 packet_store_header(out, PACKET_SECT_DH, PACKET_SUB_SIGNED);
399 *outlen = y;
400
401 err = CRYPT_OK;
402 LBL_ERR:
403 mp_clear_multi(tmp, p1, m, k, b, a, NULL);
404 LBL_ERR_1:
405
406 XFREE(buf);
407
408 return err;
409 }
410
411
412 /**
413 Verify the signature given
414 @param sig The signature
415 @param siglen The length of the signature (octets)
416 @param hash The hash that was signed
417 @param hashlen The length of the hash (octets)
418 @param stat [out] Result of signature comparison, 1==valid, 0==invalid
419 @param key The public DH key that signed the hash
420 @return CRYPT_OK if succsessful (even if signature is invalid)
421 */
422 int dh_verify_hash(const unsigned char *sig, unsigned long siglen,
423 const unsigned char *hash, unsigned long hashlen,
424 int *stat, dh_key *key)
425 {
426 void *a, *b, *m, *tmp;
427 unsigned long x, y;
428 int err;
429
430 LTC_ARGCHK(sig != NULL);
431 LTC_ARGCHK(hash != NULL);
432 LTC_ARGCHK(stat != NULL);
433 LTC_ARGCHK(key != NULL);
434
435 /* default to invalid */
436 *stat = 0;
437
438 /* check initial input length */
439 if (siglen < PACKET_SIZE+4+4) {
440 return CRYPT_INVALID_PACKET;
441 }
442
443 /* header ok? */
444 if ((err = packet_valid_header((unsigned char *)sig, PACKET_SECT_DH, PACKET_SUB_SIGNED)) != CRYPT_OK) {
445 return err;
446 }
447
448 /* get hash out of packet */
449 y = PACKET_SIZE;
450
451 /* init all bignums */
452 if ((err = mp_init_multi(&a, &b, &m, &tmp, NULL)) != CRYPT_OK) {
453 return err;
454 }
455
456 /* load a and b */
457 INPUT_BIGNUM(a, sig, x, y, siglen);
458 INPUT_BIGNUM(b, sig, x, y, siglen);
459
460 /* load m */
461 if ((err = mp_read_unsigned_bin(m, (unsigned char *)hash, hashlen)) != CRYPT_OK) { goto error1; }
462
463 /* find g^m mod p */
464 if ((err = mp_exptmod(key->base, m, key->prime, m)) != CRYPT_OK) { goto error1; } /* m = g^m mod p */
465
466 /* find y^a * a^b */
467 if ((err = mp_exptmod(key->y, a, key->prime, tmp)) != CRYPT_OK) { goto error1; } /* tmp = y^a mod p */
468 if ((err = mp_exptmod(a, b, key->prime, a)) != CRYPT_OK) { goto error1; } /* a = a^b mod p */
469 if ((err = mp_mulmod(a, tmp, key->prime, a)) != CRYPT_OK) { goto error1; } /* a = y^a * a^b mod p */
470
471 /* y^a * a^b == g^m ??? */
472 if (mp_cmp(a, m) == 0) {
473 *stat = 1;
474 }
475
476 /* clean up */
477 err = CRYPT_OK;
478 goto done;
479 error1:
480 error:
481 done:
482 mp_clear_multi(tmp, m, b, a, NULL);
483 return err;
484 }
485
486 #endif /* LTC_MDH */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3129 {
3230 unsigned char *skey, *expt;
3331 void *g_pub;
34 unsigned long x, y, hashOID[32];
32 unsigned long x, y;
33 unsigned long hashOID[32] = { 0 };
3534 int hash, err;
3635 ltc_asn1_list decode[3];
3736
4746
4847 /* decode to find out hash */
4948 LTC_SET_ASN1(decode, 0, LTC_ASN1_OBJECT_IDENTIFIER, hashOID, sizeof(hashOID)/sizeof(hashOID[0]));
50
51 if ((err = der_decode_sequence(in, inlen, decode, 1)) != CRYPT_OK) {
49 err = der_decode_sequence(in, inlen, decode, 1);
50 if (err != CRYPT_OK && err != CRYPT_INPUT_TOO_LONG) {
5251 return err;
5352 }
5453
133132
134133 #endif
135134
136 /* $Source$ */
137 /* $Revision$ */
138 /* $Date$ */
135 /* ref: $Format:%D$ */
136 /* git commit: $Format:%H$ */
137 /* commit time: $Format:%ai$ */
139138
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634 unsigned char *expt, *skey;
3735 void *g_pub, *g_priv;
3836 unsigned long x, y;
39 int err, qbits;
37 int err;
4038
4139 LTC_ARGCHK(in != NULL);
4240 LTC_ARGCHK(out != NULL);
7472 return CRYPT_MEM;
7573 }
7674
77 /* make a random g_priv, g_pub = g^x pair */
78 qbits = mp_count_bits(key->q);
79 do {
80 if ((err = rand_bn_bits(g_priv, qbits, prng, wprng)) != CRYPT_OK) {
81 goto LBL_ERR;
82 }
83 /* private key x should be from range: 1 <= x <= q-1 (see FIPS 186-4 B.1.2) */
84 } while (mp_cmp_d(g_priv, 0) != LTC_MP_GT || mp_cmp(g_priv, key->q) != LTC_MP_LT);
75 /* make a random g_priv, g_pub = g^x pair
76 private key x should be in range: 1 <= x <= q-1 (see FIPS 186-4 B.1.2)
77 */
78 if ((err = rand_bn_upto(g_priv, key->q, prng, wprng)) != CRYPT_OK) {
79 goto LBL_ERR;
80 }
8581
8682 /* compute y */
8783 if ((err = mp_exptmod(key->g, g_priv, key->p, g_pub)) != CRYPT_OK) {
125121 }
126122
127123 #endif
128 /* $Source$ */
129 /* $Revision$ */
130 /* $Date$ */
124 /* ref: $Format:%D$ */
125 /* git commit: $Format:%H$ */
126 /* commit time: $Format:%ai$ */
131127
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
112110 #endif
113111
114112
115 /* $Source$ */
116 /* $Revision$ */
117 /* $Date$ */
113 /* ref: $Format:%D$ */
114 /* git commit: $Format:%H$ */
115 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2321 void dsa_free(dsa_key *key)
2422 {
2523 LTC_ARGCHKVD(key != NULL);
26 mp_clear_multi(key->g, key->q, key->p, key->x, key->y, NULL);
24 mp_cleanup_multi(&key->y, &key->x, &key->q, &key->g, &key->p, NULL);
25 key->type = key->qord = 0;
2726 }
2827
2928 #endif
3029
31 /* $Source$ */
32 /* $Revision$ */
33 /* $Date$ */
30 /* ref: $Format:%D$ */
31 /* git commit: $Format:%H$ */
32 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 /**
11 @file dsa_make_key.c
12 DSA implementation, generate a DSA key
13 */
14
15 #ifdef LTC_MDSA
16
17 /**
18 Create a DSA key
19 @param prng An active PRNG state
20 @param wprng The index of the PRNG desired
21 @param key [in/out] Where to store the created key
22 @return CRYPT_OK if successful.
23 */
24 int dsa_generate_key(prng_state *prng, int wprng, dsa_key *key)
25 {
26 int err;
27
28 LTC_ARGCHK(key != NULL);
29 LTC_ARGCHK(ltc_mp.name != NULL);
30
31 /* so now we have our DH structure, generator g, order q, modulus p
32 Now we need a random exponent [mod q] and it's power g^x mod p
33 */
34 /* private key x should be from range: 1 <= x <= q-1 (see FIPS 186-4 B.1.2) */
35 if ((err = rand_bn_upto(key->x, key->q, prng, wprng)) != CRYPT_OK) { return err; }
36 if ((err = mp_exptmod(key->g, key->x, key->p, key->y)) != CRYPT_OK) { return err; }
37 key->type = PK_PRIVATE;
38
39 return CRYPT_OK;
40 }
41
42 #endif
43
44 /* ref: $Format:%D$ */
45 /* git commit: $Format:%H$ */
46 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10 /**
11 @file dsa_generate_pqg.c
12 DSA implementation - generate DSA parameters p, q & g
13 */
14
15 #ifdef LTC_MDSA
16
17 /**
18 Create DSA parameters (INTERNAL ONLY, not part of public API)
19 @param prng An active PRNG state
20 @param wprng The index of the PRNG desired
21 @param group_size Size of the multiplicative group (octets)
22 @param modulus_size Size of the modulus (octets)
23 @param p [out] bignum where generated 'p' is stored (must be initialized by caller)
24 @param q [out] bignum where generated 'q' is stored (must be initialized by caller)
25 @param g [out] bignum where generated 'g' is stored (must be initialized by caller)
26 @return CRYPT_OK if successful, upon error this function will free all allocated memory
27 */
28 static int _dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g)
29 {
30 unsigned long L, N, n, outbytes, seedbytes, counter, j, i;
31 int err, res, mr_tests_q, mr_tests_p, found_p, found_q, hash;
32 unsigned char *wbuf, *sbuf, digest[MAXBLOCKSIZE];
33 void *t2L1, *t2N1, *t2q, *t2seedlen, *U, *W, *X, *c, *h, *e, *seedinc;
34
35 /* check size */
36 if (group_size >= LTC_MDSA_MAX_GROUP || group_size < 1 || group_size >= modulus_size) {
37 return CRYPT_INVALID_ARG;
38 }
39
40 /* FIPS-186-4 A.1.1.2 Generation of the Probable Primes p and q Using an Approved Hash Function
41 *
42 * L = The desired length of the prime p (in bits e.g. L = 1024)
43 * N = The desired length of the prime q (in bits e.g. N = 160)
44 * seedlen = The desired bit length of the domain parameter seed; seedlen shallbe equal to or greater than N
45 * outlen = The bit length of Hash function
46 *
47 * 1. Check that the (L, N)
48 * 2. If (seedlen <N), then return INVALID.
49 * 3. n = ceil(L / outlen) - 1
50 * 4. b = L- 1 - (n * outlen)
51 * 5. domain_parameter_seed = an arbitrary sequence of seedlen bits
52 * 6. U = Hash (domain_parameter_seed) mod 2^(N-1)
53 * 7. q = 2^(N-1) + U + 1 - (U mod 2)
54 * 8. Test whether or not q is prime as specified in Appendix C.3
55 * 9. If qis not a prime, then go to step 5.
56 * 10. offset = 1
57 * 11. For counter = 0 to (4L- 1) do {
58 * For j=0 to n do {
59 * Vj = Hash ((domain_parameter_seed+ offset + j) mod 2^seedlen
60 * }
61 * W = V0 + (V1 *2^outlen) + ... + (Vn-1 * 2^((n-1) * outlen)) + ((Vn mod 2^b) * 2^(n * outlen))
62 * X = W + 2^(L-1) Comment: 0 <= W < 2^(L-1); hence 2^(L-1) <= X < 2^L
63 * c = X mod 2*q
64 * p = X - (c - 1) Comment: p ~ 1 (mod 2*q)
65 * If (p >= 2^(L-1)) {
66 * Test whether or not p is prime as specified in Appendix C.3.
67 * If p is determined to be prime, then return VALID and the values of p, qand (optionally) the values of domain_parameter_seed and counter
68 * }
69 * offset = offset + n + 1 Comment: Increment offset
70 * }
71 */
72
73 seedbytes = group_size;
74 L = modulus_size * 8;
75 N = group_size * 8;
76
77 /* XXX-TODO no Lucas test */
78 #ifdef LTC_MPI_HAS_LUCAS_TEST
79 /* M-R tests (when followed by one Lucas test) according FIPS-186-4 - Appendix C.3 - table C.1 */
80 mr_tests_p = (L <= 2048) ? 3 : 2;
81 if (N <= 160) { mr_tests_q = 19; }
82 else if (N <= 224) { mr_tests_q = 24; }
83 else { mr_tests_q = 27; }
84 #else
85 /* M-R tests (without Lucas test) according FIPS-186-4 - Appendix C.3 - table C.1 */
86 if (L <= 1024) { mr_tests_p = 40; }
87 else if (L <= 2048) { mr_tests_p = 56; }
88 else { mr_tests_p = 64; }
89
90 if (N <= 160) { mr_tests_q = 40; }
91 else if (N <= 224) { mr_tests_q = 56; }
92 else { mr_tests_q = 64; }
93 #endif
94
95 if (N <= 256) {
96 hash = register_hash(&sha256_desc);
97 }
98 else if (N <= 384) {
99 hash = register_hash(&sha384_desc);
100 }
101 else if (N <= 512) {
102 hash = register_hash(&sha512_desc);
103 }
104 else {
105 return CRYPT_INVALID_ARG; /* group_size too big */
106 }
107
108 if ((err = hash_is_valid(hash)) != CRYPT_OK) { return err; }
109 outbytes = hash_descriptor[hash].hashsize;
110
111 n = ((L + outbytes*8 - 1) / (outbytes*8)) - 1;
112
113 if ((wbuf = XMALLOC((n+1)*outbytes)) == NULL) { err = CRYPT_MEM; goto cleanup3; }
114 if ((sbuf = XMALLOC(seedbytes)) == NULL) { err = CRYPT_MEM; goto cleanup2; }
115
116 err = mp_init_multi(&t2L1, &t2N1, &t2q, &t2seedlen, &U, &W, &X, &c, &h, &e, &seedinc, NULL);
117 if (err != CRYPT_OK) { goto cleanup1; }
118
119 if ((err = mp_2expt(t2L1, L-1)) != CRYPT_OK) { goto cleanup; }
120 /* t2L1 = 2^(L-1) */
121 if ((err = mp_2expt(t2N1, N-1)) != CRYPT_OK) { goto cleanup; }
122 /* t2N1 = 2^(N-1) */
123 if ((err = mp_2expt(t2seedlen, seedbytes*8)) != CRYPT_OK) { goto cleanup; }
124 /* t2seedlen = 2^seedlen */
125
126 for(found_p=0; !found_p;) {
127 /* q */
128 for(found_q=0; !found_q;) {
129 if (prng_descriptor[wprng].read(sbuf, seedbytes, prng) != seedbytes) { err = CRYPT_ERROR_READPRNG; goto cleanup; }
130 i = outbytes;
131 if ((err = hash_memory(hash, sbuf, seedbytes, digest, &i)) != CRYPT_OK) { goto cleanup; }
132 if ((err = mp_read_unsigned_bin(U, digest, outbytes)) != CRYPT_OK) { goto cleanup; }
133 if ((err = mp_mod(U, t2N1, U)) != CRYPT_OK) { goto cleanup; }
134 if ((err = mp_add(t2N1, U, q)) != CRYPT_OK) { goto cleanup; }
135 if (!mp_isodd(q)) mp_add_d(q, 1, q);
136 if ((err = mp_prime_is_prime(q, mr_tests_q, &res)) != CRYPT_OK) { goto cleanup; }
137 if (res == LTC_MP_YES) found_q = 1;
138 }
139
140 /* p */
141 if ((err = mp_read_unsigned_bin(seedinc, sbuf, seedbytes)) != CRYPT_OK) { goto cleanup; }
142 if ((err = mp_add(q, q, t2q)) != CRYPT_OK) { goto cleanup; }
143 for(counter=0; counter < 4*L && !found_p; counter++) {
144 for(j=0; j<=n; j++) {
145 if ((err = mp_add_d(seedinc, 1, seedinc)) != CRYPT_OK) { goto cleanup; }
146 if ((err = mp_mod(seedinc, t2seedlen, seedinc)) != CRYPT_OK) { goto cleanup; }
147 /* seedinc = (seedinc+1) % 2^seed_bitlen */
148 if ((i = mp_unsigned_bin_size(seedinc)) > seedbytes) { err = CRYPT_INVALID_ARG; goto cleanup; }
149 zeromem(sbuf, seedbytes);
150 if ((err = mp_to_unsigned_bin(seedinc, sbuf + seedbytes-i)) != CRYPT_OK) { goto cleanup; }
151 i = outbytes;
152 err = hash_memory(hash, sbuf, seedbytes, wbuf+(n-j)*outbytes, &i);
153 if (err != CRYPT_OK) { goto cleanup; }
154 }
155 if ((err = mp_read_unsigned_bin(W, wbuf, (n+1)*outbytes)) != CRYPT_OK) { goto cleanup; }
156 if ((err = mp_mod(W, t2L1, W)) != CRYPT_OK) { goto cleanup; }
157 if ((err = mp_add(W, t2L1, X)) != CRYPT_OK) { goto cleanup; }
158 if ((err = mp_mod(X, t2q, c)) != CRYPT_OK) { goto cleanup; }
159 if ((err = mp_sub_d(c, 1, p)) != CRYPT_OK) { goto cleanup; }
160 if ((err = mp_sub(X, p, p)) != CRYPT_OK) { goto cleanup; }
161 if (mp_cmp(p, t2L1) != LTC_MP_LT) {
162 /* p >= 2^(L-1) */
163 if ((err = mp_prime_is_prime(p, mr_tests_p, &res)) != CRYPT_OK) { goto cleanup; }
164 if (res == LTC_MP_YES) {
165 found_p = 1;
166 }
167 }
168 }
169 }
170
171 /* FIPS-186-4 A.2.1 Unverifiable Generation of the Generator g
172 * 1. e = (p - 1)/q
173 * 2. h = any integer satisfying: 1 < h < (p - 1)
174 * h could be obtained from a random number generator or from a counter that changes after each use
175 * 3. g = h^e mod p
176 * 4. if (g == 1), then go to step 2.
177 *
178 */
179
180 if ((err = mp_sub_d(p, 1, e)) != CRYPT_OK) { goto cleanup; }
181 if ((err = mp_div(e, q, e, c)) != CRYPT_OK) { goto cleanup; }
182 /* e = (p - 1)/q */
183 i = mp_count_bits(p);
184 do {
185 do {
186 if ((err = rand_bn_bits(h, i, prng, wprng)) != CRYPT_OK) { goto cleanup; }
187 } while (mp_cmp(h, p) != LTC_MP_LT || mp_cmp_d(h, 2) != LTC_MP_GT);
188 if ((err = mp_sub_d(h, 1, h)) != CRYPT_OK) { goto cleanup; }
189 /* h is randon and 1 < h < (p-1) */
190 if ((err = mp_exptmod(h, e, p, g)) != CRYPT_OK) { goto cleanup; }
191 } while (mp_cmp_d(g, 1) == LTC_MP_EQ);
192
193 err = CRYPT_OK;
194 cleanup:
195 mp_clear_multi(t2L1, t2N1, t2q, t2seedlen, U, W, X, c, h, e, seedinc, NULL);
196 cleanup1:
197 XFREE(sbuf);
198 cleanup2:
199 XFREE(wbuf);
200 cleanup3:
201 return err;
202 }
203
204 /**
205 Generate DSA parameters p, q & g
206 @param prng An active PRNG state
207 @param wprng The index of the PRNG desired
208 @param group_size Size of the multiplicative group (octets)
209 @param modulus_size Size of the modulus (octets)
210 @param key [out] Where to store the created key
211 @return CRYPT_OK if successful.
212 */
213 int dsa_generate_pqg(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key)
214 {
215 int err;
216
217 LTC_ARGCHK(key != NULL);
218 LTC_ARGCHK(ltc_mp.name != NULL);
219
220 /* init mp_ints */
221 if ((err = mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL)) != CRYPT_OK) {
222 return err;
223 }
224 /* generate params */
225 err = _dsa_make_params(prng, wprng, group_size, modulus_size, key->p, key->q, key->g);
226 if (err != CRYPT_OK) {
227 goto cleanup;
228 }
229
230 key->qord = group_size;
231
232 return CRYPT_OK;
233
234 cleanup:
235 dsa_free(key);
236 return err;
237 }
238
239 #endif
240
241 /* ref: $Format:%D$ */
242 /* git commit: $Format:%H$ */
243 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2523 */
2624 int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
2725 {
28 int err;
26 int err, stat;
2927 unsigned long zero = 0;
3028 unsigned char* tmpbuf = NULL;
3129 unsigned char flags[1];
4038 }
4139
4240 /* try to match the old libtomcrypt format */
43 if ((err = der_decode_sequence_multi(in, inlen,
44 LTC_ASN1_BIT_STRING, 1UL, flags,
45 LTC_ASN1_EOL, 0UL, NULL)) == CRYPT_OK) {
41 err = der_decode_sequence_multi(in, inlen, LTC_ASN1_BIT_STRING, 1UL, flags,
42 LTC_ASN1_EOL, 0UL, NULL);
43
44 if (err == CRYPT_OK || err == CRYPT_INPUT_TOO_LONG) {
4645 /* private key */
47 if (flags[0]) {
46 if (flags[0] == 1) {
4847 if ((err = der_decode_sequence_multi(in, inlen,
4948 LTC_ASN1_BIT_STRING, 1UL, flags,
5049 LTC_ASN1_INTEGER, 1UL, key->g,
5958 goto LBL_OK;
6059 }
6160 /* public key */
62 else {
61 else if (flags[0] == 0) {
6362 if ((err = der_decode_sequence_multi(in, inlen,
6463 LTC_ASN1_BIT_STRING, 1UL, flags,
6564 LTC_ASN1_INTEGER, 1UL, key->g,
7170 }
7271 key->type = PK_PUBLIC;
7372 goto LBL_OK;
73 }
74 else {
75 err = CRYPT_INVALID_PACKET;
76 goto LBL_ERR;
7477 }
7578 }
7679 /* get key type */
8689 key->type = PK_PRIVATE;
8790 } else { /* public */
8891 ltc_asn1_list params[3];
89 unsigned long tmpbuf_len = MAX_RSA_SIZE*8;
92 unsigned long tmpbuf_len = inlen;
9093
9194 LTC_SET_ASN1(params, 0, LTC_ASN1_INTEGER, key->p, 1UL);
9295 LTC_SET_ASN1(params, 1, LTC_ASN1_INTEGER, key->q, 1UL);
116119 }
117120
118121 LBL_OK:
119 key->qord = mp_unsigned_bin_size(key->q);
122 key->qord = mp_unsigned_bin_size(key->q);
120123
121 if (key->qord >= LTC_MDSA_MAX_GROUP || key->qord <= 15 ||
122 (unsigned long)key->qord >= mp_unsigned_bin_size(key->p) || (mp_unsigned_bin_size(key->p) - key->qord) >= LTC_MDSA_DELTA) {
124 /* quick p, q, g validation, without primality testing */
125 if ((err = dsa_int_validate_pqg(key, &stat)) != CRYPT_OK) {
126 goto LBL_ERR;
127 }
128 if (stat == 0) {
129 err = CRYPT_INVALID_PACKET;
130 goto LBL_ERR;
131 }
132 /* validate x, y */
133 if ((err = dsa_int_validate_xy(key, &stat)) != CRYPT_OK) {
134 goto LBL_ERR;
135 }
136 if (stat == 0) {
123137 err = CRYPT_INVALID_PACKET;
124138 goto LBL_ERR;
125139 }
126140
127141 return CRYPT_OK;
128142 LBL_ERR:
129 mp_clear_multi(key->p, key->g, key->q, key->x, key->y, NULL);
143 dsa_free(key);
130144 return err;
131145 }
132146
133147 #endif
134148
135 /* $Source$ */
136 /* $Revision$ */
137 /* $Date$ */
149 /* ref: $Format:%D$ */
150 /* git commit: $Format:%H$ */
151 /* commit time: $Format:%ai$ */
+0
-67
src/ltc/pk/dsa/dsa_import_radix.c less more
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
9 */
10 #include "tomcrypt.h"
11
12 /**
13 Import DSA public or private key from raw numbers
14 @param radix the radix the numbers are represented in (2-64, 16 = hexadecimal)
15 @param p DSA's p in radix representation
16 @param q DSA's q in radix representation
17 @param g DSA's g in radix representation
18 @param x DSA's x in radix representation (only private key, NULL for public key)
19 @param y DSA's y in radix representation
20 @param key [out] the destination for the imported key
21 @return CRYPT_OK if successful, upon error allocated memory is freed
22 */
23
24 #ifdef LTC_MDSA
25
26 int dsa_import_radix(int radix, char *p, char *q, char *g, char *x, char *y, dsa_key *key)
27 {
28 int err;
29
30 LTC_ARGCHK(p != NULL);
31 LTC_ARGCHK(q != NULL);
32 LTC_ARGCHK(g != NULL);
33 LTC_ARGCHK(y != NULL);
34 LTC_ARGCHK(ltc_mp.name != NULL);
35
36 /* init key */
37 err = mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL);
38 if (err != CRYPT_OK) return err;
39
40 if ((err = mp_read_radix(key->p , p , radix)) != CRYPT_OK) { goto LBL_ERR; }
41 if ((err = mp_read_radix(key->q , q , radix)) != CRYPT_OK) { goto LBL_ERR; }
42 if ((err = mp_read_radix(key->g , g , radix)) != CRYPT_OK) { goto LBL_ERR; }
43 if ((err = mp_read_radix(key->y , y , radix)) != CRYPT_OK) { goto LBL_ERR; }
44 if (x && strlen(x) > 0) {
45 key->type = PK_PRIVATE;
46 if ((err = mp_read_radix(key->x , x , radix)) != CRYPT_OK) { goto LBL_ERR; }
47 }
48 else {
49 key->type = PK_PUBLIC;
50 }
51
52 key->qord = mp_unsigned_bin_size(key->q);
53
54 if (key->qord >= LTC_MDSA_MAX_GROUP || key->qord <= 15 ||
55 (unsigned long)key->qord >= mp_unsigned_bin_size(key->p) || (mp_unsigned_bin_size(key->p) - key->qord) >= LTC_MDSA_DELTA) {
56 err = CRYPT_INVALID_PACKET;
57 goto LBL_ERR;
58 }
59 return CRYPT_OK;
60
61 LBL_ERR:
62 mp_clear_multi(key->p, key->g, key->q, key->x, key->y, NULL);
63 return err;
64 }
65
66 #endif
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1210 /**
1311 @file dsa_make_key.c
14 DSA implementation, generate a DSA key, Tom St Denis
12 DSA implementation, generate a DSA key
1513 */
1614
1715 #ifdef LTC_MDSA
1816
1917 /**
20 Create DSA parameters
21 @param prng An active PRNG state
22 @param wprng The index of the PRNG desired
23 @param group_size Size of the multiplicative group (octets)
24 @param modulus_size Size of the modulus (octets)
25 @param p [out] bignum where generated 'p' is stored (must be initialized by caller)
26 @param q [out] bignum where generated 'q' is stored (must be initialized by caller)
27 @param g [out] bignum where generated 'g' is stored (must be initialized by caller)
28 @return CRYPT_OK if successful, upon error this function will free all allocated memory
29 */
30 int dsa_make_params(prng_state *prng, int wprng, int group_size, int modulus_size, void *p, void *q, void *g)
31 {
32 unsigned long L, N, n, outbytes, seedbytes, counter, j, i;
33 int err, res, mr_tests_q, mr_tests_p, found_p, found_q, hash;
34 unsigned char *wbuf, *sbuf, digest[MAXBLOCKSIZE];
35 void *t2L1, *t2N1, *t2q, *t2seedlen, *U, *W, *X, *c, *h, *e, *seedinc;
36
37 /* check size */
38 if (group_size >= LTC_MDSA_MAX_GROUP || group_size < 1 || group_size >= modulus_size) {
39 return CRYPT_INVALID_ARG;
40 }
41
42 /* FIPS-186-4 A.1.1.2 Generation of the Probable Primes p and q Using an Approved Hash Function
43 *
44 * L = The desired length of the prime p (in bits e.g. L = 1024)
45 * N = The desired length of the prime q (in bits e.g. N = 160)
46 * seedlen = The desired bit length of the domain parameter seed; seedlen shallbe equal to or greater than N
47 * outlen = The bit length of Hash function
48 *
49 * 1. Check that the (L, N)
50 * 2. If (seedlen <N), then return INVALID.
51 * 3. n = ceil(L / outlen) - 1
52 * 4. b = L- 1 - (n * outlen)
53 * 5. domain_parameter_seed = an arbitrary sequence of seedlen bits
54 * 6. U = Hash (domain_parameter_seed) mod 2^(N-1)
55 * 7. q = 2^(N-1) + U + 1 - (U mod 2)
56 * 8. Test whether or not q is prime as specified in Appendix C.3
57 * 9. If qis not a prime, then go to step 5.
58 * 10. offset = 1
59 * 11. For counter = 0 to (4L- 1) do {
60 * For j=0 to n do {
61 * Vj = Hash ((domain_parameter_seed+ offset + j) mod 2^seedlen
62 * }
63 * W = V0 + (V1 *2^outlen) + ... + (Vn-1 * 2^((n-1) * outlen)) + ((Vn mod 2^b) * 2^(n * outlen))
64 * X = W + 2^(L-1) Comment: 0 <= W < 2^(L-1); hence 2^(L-1) <= X < 2^L
65 * c = X mod 2*q
66 * p = X - (c - 1) Comment: p ~ 1 (mod 2*q)
67 * If (p >= 2^(L-1)) {
68 * Test whether or not p is prime as specified in Appendix C.3.
69 * If p is determined to be prime, then return VALID and the values of p, qand (optionally) the values of domain_parameter_seed and counter
70 * }
71 * offset = offset + n + 1 Comment: Increment offset
72 * }
73 */
74
75 seedbytes = group_size;
76 L = modulus_size * 8;
77 N = group_size * 8;
78
79 /* M-R tests (when followed by one Lucas test) according FIPS-186-4 - Appendix C.3 - table C.1 */
80 mr_tests_p = (L <= 2048) ? 3 : 2;
81 if (N <= 160) { mr_tests_q = 19; }
82 else if (N <= 224) { mr_tests_q = 24; }
83 else { mr_tests_q = 27; }
84
85 if (N <= 256) {
86 hash = register_hash(&sha256_desc);
87 }
88 else if (N <= 384) {
89 hash = register_hash(&sha384_desc);
90 }
91 else if (N <= 512) {
92 hash = register_hash(&sha512_desc);
93 }
94 else {
95 return CRYPT_INVALID_ARG; /* group_size too big */
96 }
97
98 if ((err = hash_is_valid(hash)) != CRYPT_OK) { return err; }
99 outbytes = hash_descriptor[hash].hashsize;
100
101 n = ((L + outbytes*8 - 1) / (outbytes*8)) - 1;
102
103 if ((wbuf = XMALLOC((n+1)*outbytes)) == NULL) { err = CRYPT_MEM; goto cleanup3; }
104 if ((sbuf = XMALLOC(seedbytes)) == NULL) { err = CRYPT_MEM; goto cleanup2; }
105
106 err = mp_init_multi(&t2L1, &t2N1, &t2q, &t2seedlen, &U, &W, &X, &c, &h, &e, &seedinc, NULL);
107 if (err != CRYPT_OK) { goto cleanup1; }
108
109 if ((err = mp_2expt(t2L1, L-1)) != CRYPT_OK) { goto cleanup; }
110 /* t2L1 = 2^(L-1) */
111 if ((err = mp_2expt(t2N1, N-1)) != CRYPT_OK) { goto cleanup; }
112 /* t2N1 = 2^(N-1) */
113 if ((err = mp_2expt(t2seedlen, seedbytes*8)) != CRYPT_OK) { goto cleanup; }
114 /* t2seedlen = 2^seedlen */
115
116 for(found_p=0; !found_p;) {
117 /* q */
118 for(found_q=0; !found_q;) {
119 if (prng_descriptor[wprng].read(sbuf, seedbytes, prng) != seedbytes) { err = CRYPT_ERROR_READPRNG; goto cleanup; }
120 i = outbytes;
121 if ((err = hash_memory(hash, sbuf, seedbytes, digest, &i)) != CRYPT_OK) { goto cleanup; }
122 if ((err = mp_read_unsigned_bin(U, digest, outbytes)) != CRYPT_OK) { goto cleanup; }
123 if ((err = mp_mod(U, t2N1, U)) != CRYPT_OK) { goto cleanup; }
124 if ((err = mp_add(t2N1, U, q)) != CRYPT_OK) { goto cleanup; }
125 if (!mp_isodd(q)) mp_add_d(q, 1, q);
126 if ((err = mp_prime_is_prime(q, mr_tests_q, &res)) != CRYPT_OK) { goto cleanup; } /* XXX-TODO rounds are ignored; no Lucas test */
127 if (res == LTC_MP_YES) found_q = 1;
128 }
129
130 /* p */
131 if ((err = mp_read_unsigned_bin(seedinc, sbuf, seedbytes)) != CRYPT_OK) { goto cleanup; }
132 if ((err = mp_add(q, q, t2q)) != CRYPT_OK) { goto cleanup; }
133 for(counter=0; counter < 4*L && !found_p; counter++) {
134 for(j=0; j<=n; j++) {
135 if ((err = mp_add_d(seedinc, 1, seedinc)) != CRYPT_OK) { goto cleanup; }
136 if ((err = mp_mod(seedinc, t2seedlen, seedinc)) != CRYPT_OK) { goto cleanup; }
137 /* seedinc = (seedinc+1) % 2^seed_bitlen */
138 if ((i = mp_unsigned_bin_size(seedinc)) > seedbytes) { err = CRYPT_INVALID_ARG; goto cleanup; }
139 zeromem(sbuf, seedbytes);
140 if ((err = mp_to_unsigned_bin(seedinc, sbuf + seedbytes-i)) != CRYPT_OK) { goto cleanup; }
141 i = outbytes;
142 err = hash_memory(hash, sbuf, seedbytes, wbuf+(n-j)*outbytes, &i);
143 if (err != CRYPT_OK) { goto cleanup; }
144 }
145 if ((err = mp_read_unsigned_bin(W, wbuf, (n+1)*outbytes)) != CRYPT_OK) { goto cleanup; }
146 if ((err = mp_mod(W, t2L1, W)) != CRYPT_OK) { goto cleanup; }
147 if ((err = mp_add(W, t2L1, X)) != CRYPT_OK) { goto cleanup; }
148 if ((err = mp_mod(X, t2q, c)) != CRYPT_OK) { goto cleanup; }
149 if ((err = mp_sub_d(c, 1, p)) != CRYPT_OK) { goto cleanup; }
150 if ((err = mp_sub(X, p, p)) != CRYPT_OK) { goto cleanup; }
151 if (mp_cmp(p, t2L1) != LTC_MP_LT) {
152 /* p >= 2^(L-1) */
153 if ((err = mp_prime_is_prime(p, mr_tests_p, &res)) != CRYPT_OK) { goto cleanup; } /* XXX-TODO rounds are ignored; no Lucas test */
154 if (res == LTC_MP_YES) {
155 found_p = 1;
156 }
157 }
158 }
159 }
160
161 /* FIPS-186-4 A.2.1 Unverifiable Generation of the Generator g
162 * 1. e = (p - 1)/q
163 * 2. h = any integer satisfying: 1 < h < (p - 1)
164 * h could be obtained from a random number generator or from a counter that changes after each use
165 * 3. g = h^e mod p
166 * 4. if (g == 1), then go to step 2.
167 *
168 */
169
170 if ((err = mp_sub_d(p, 1, e)) != CRYPT_OK) { goto cleanup; }
171 if ((err = mp_div(e, q, e, c)) != CRYPT_OK) { goto cleanup; }
172 /* e = (p - 1)/q */
173 i = mp_count_bits(p);
174 do {
175 do {
176 if ((err = rand_bn_bits(h, i, prng, wprng)) != CRYPT_OK) { goto cleanup; }
177 } while (mp_cmp(h, p) != LTC_MP_LT || mp_cmp_d(h, 2) != LTC_MP_GT);
178 if ((err = mp_sub_d(h, 1, h)) != CRYPT_OK) { goto cleanup; }
179 /* h is randon and 1 < h < (p-1) */
180 if ((err = mp_exptmod(h, e, p, g)) != CRYPT_OK) { goto cleanup; }
181 } while (mp_cmp_d(g, 1) == LTC_MP_EQ);
182
183 err = CRYPT_OK;
184 cleanup:
185 mp_clear_multi(t2L1, t2N1, t2q, t2seedlen, U, W, X, c, h, e, seedinc, NULL);
186 cleanup1:
187 XFREE(sbuf);
188 cleanup2:
189 XFREE(wbuf);
190 cleanup3:
191 return err;
192 }
193
194 /**
195 Create a DSA key (with given params)
18 Old-style creation of a DSA key
19619 @param prng An active PRNG state
19720 @param wprng The index of the PRNG desired
19821 @param group_size Size of the multiplicative group (octets)
19922 @param modulus_size Size of the modulus (octets)
20023 @param key [out] Where to store the created key
201 @param p_hex Hexadecimal string 'p'
202 @param q_hex Hexadecimal string 'q'
203 @param g_hex Hexadecimal string 'g'
204 @return CRYPT_OK if successful, upon error this function will free all allocated memory
205 */
206 int dsa_make_key_ex(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key, char* p_hex, char* q_hex, char* g_hex)
207 {
208 int err, qbits;
209
210 LTC_ARGCHK(key != NULL);
211
212 /* init mp_ints */
213 if ((err = mp_init_multi(&key->g, &key->q, &key->p, &key->x, &key->y, NULL)) != CRYPT_OK) {
214 return err;
215 }
216
217 if (p_hex == NULL || q_hex == NULL || g_hex == NULL) {
218 /* generate params */
219 err = dsa_make_params(prng, wprng, group_size, modulus_size, key->p, key->q, key->g);
220 if (err != CRYPT_OK) { goto cleanup; }
221 }
222 else {
223 /* read params */
224 if ((err = mp_read_radix(key->p, p_hex, 16)) != CRYPT_OK) { goto cleanup; }
225 if ((err = mp_read_radix(key->q, q_hex, 16)) != CRYPT_OK) { goto cleanup; }
226 if ((err = mp_read_radix(key->g, g_hex, 16)) != CRYPT_OK) { goto cleanup; }
227 /* XXX-TODO maybe do some validity check for p, q, g */
228 }
229
230 /* so now we have our DH structure, generator g, order q, modulus p
231 Now we need a random exponent [mod q] and it's power g^x mod p
232 */
233 qbits = mp_count_bits(key->q);
234 do {
235 if ((err = rand_bn_bits(key->x, qbits, prng, wprng)) != CRYPT_OK) { goto cleanup; }
236 /* private key x should be from range: 1 <= x <= q-1 (see FIPS 186-4 B.1.2) */
237 } while (mp_cmp_d(key->x, 0) != LTC_MP_GT || mp_cmp(key->x, key->q) != LTC_MP_LT);
238 if ((err = mp_exptmod(key->g, key->x, key->p, key->y)) != CRYPT_OK) { goto cleanup; }
239 key->type = PK_PRIVATE;
240 key->qord = group_size;
241
242 return CRYPT_OK;
243
244 cleanup:
245 mp_clear_multi(key->g, key->q, key->p, key->x, key->y, NULL);
246 return err;
247 }
248
249 /**
250 Create a DSA key
251 @param prng An active PRNG state
252 @param wprng The index of the PRNG desired
253 @param group_size Size of the multiplicative group (octets)
254 @param modulus_size Size of the modulus (octets)
255 @param key [out] Where to store the created key
256 @return CRYPT_OK if successful, upon error this function will free all allocated memory
24 @return CRYPT_OK if successful.
25725 */
25826 int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key)
25927 {
260 return dsa_make_key_ex(prng, wprng, group_size, modulus_size, key, NULL, NULL, NULL);
28 int err;
29
30 if ((err = dsa_generate_pqg(prng, wprng, group_size, modulus_size, key)) != CRYPT_OK) { return err; }
31 if ((err = dsa_generate_key(prng, wprng, key)) != CRYPT_OK) { return err; }
32
33 return CRYPT_OK;
26134 }
26235
26336 #endif
26437
265 /* $Source$ */
266 /* $Revision$ */
267 /* $Date$ */
38 /* ref: $Format:%D$ */
39 /* git commit: $Format:%H$ */
40 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10
11 #ifdef LTC_MDSA
12
13 /**
14 Import DSA's p, q & g from raw numbers
15 @param p DSA's p in binary representation
16 @param plen The length of p
17 @param q DSA's q in binary representation
18 @param qlen The length of q
19 @param g DSA's g in binary representation
20 @param glen The length of g
21 @param key [out] the destination for the imported key
22 @return CRYPT_OK if successful.
23 */
24 int dsa_set_pqg(const unsigned char *p, unsigned long plen,
25 const unsigned char *q, unsigned long qlen,
26 const unsigned char *g, unsigned long glen,
27 dsa_key *key)
28 {
29 int err, stat;
30
31 LTC_ARGCHK(p != NULL);
32 LTC_ARGCHK(q != NULL);
33 LTC_ARGCHK(g != NULL);
34 LTC_ARGCHK(key != NULL);
35 LTC_ARGCHK(ltc_mp.name != NULL);
36
37 /* init key */
38 err = mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL);
39 if (err != CRYPT_OK) return err;
40
41 if ((err = mp_read_unsigned_bin(key->p, (unsigned char *)p , plen)) != CRYPT_OK) { goto LBL_ERR; }
42 if ((err = mp_read_unsigned_bin(key->g, (unsigned char *)g , glen)) != CRYPT_OK) { goto LBL_ERR; }
43 if ((err = mp_read_unsigned_bin(key->q, (unsigned char *)q , qlen)) != CRYPT_OK) { goto LBL_ERR; }
44
45 key->qord = mp_unsigned_bin_size(key->q);
46
47 /* do only a quick validation, without primality testing */
48 if ((err = dsa_int_validate_pqg(key, &stat)) != CRYPT_OK) { goto LBL_ERR; }
49 if (stat == 0) {
50 err = CRYPT_INVALID_PACKET;
51 goto LBL_ERR;
52 }
53
54 return CRYPT_OK;
55
56 LBL_ERR:
57 dsa_free(key);
58 return err;
59 }
60
61 /**
62 Import DSA public or private key-part from raw numbers
63
64 NB: The p, q & g parts must be set beforehand
65
66 @param in The key-part to import, either public or private.
67 @param inlen The key-part's length
68 @param type Which type of key (PK_PRIVATE or PK_PUBLIC)
69 @param key [out] the destination for the imported key
70 @return CRYPT_OK if successful.
71 */
72 int dsa_set_key(const unsigned char *in, unsigned long inlen, int type, dsa_key *key)
73 {
74 int err, stat = 0;
75
76 LTC_ARGCHK(key != NULL);
77 LTC_ARGCHK(key->x != NULL);
78 LTC_ARGCHK(key->y != NULL);
79 LTC_ARGCHK(key->p != NULL);
80 LTC_ARGCHK(key->g != NULL);
81 LTC_ARGCHK(key->q != NULL);
82 LTC_ARGCHK(ltc_mp.name != NULL);
83
84 if (type == PK_PRIVATE) {
85 key->type = PK_PRIVATE;
86 if ((err = mp_read_unsigned_bin(key->x, (unsigned char *)in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
87 if ((err = mp_exptmod(key->g, key->x, key->p, key->y)) != CRYPT_OK) { goto LBL_ERR; }
88 }
89 else {
90 key->type = PK_PUBLIC;
91 if ((err = mp_read_unsigned_bin(key->y, (unsigned char *)in, inlen)) != CRYPT_OK) { goto LBL_ERR; }
92 }
93
94 if ((err = dsa_int_validate_xy(key, &stat)) != CRYPT_OK) { goto LBL_ERR; }
95 if (stat == 0) {
96 err = CRYPT_INVALID_PACKET;
97 goto LBL_ERR;
98 }
99
100 return CRYPT_OK;
101
102 LBL_ERR:
103 dsa_free(key);
104 return err;
105 }
106
107 #endif
108
109 /* ref: $Format:%D$ */
110 /* git commit: $Format:%H$ */
111 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10
11 #ifdef LTC_MDSA
12
13 /**
14 Import DSA's p, q & g from dsaparam
15
16 dsaparam data: openssl dsaparam -outform DER -out dsaparam.der 2048
17
18 @param dsaparam The DSA param DER encoded data
19 @param dsaparamlen The length of dhparam data
20 @param key [out] the destination for the imported key
21 @return CRYPT_OK if successful.
22 */
23 int dsa_set_pqg_dsaparam(const unsigned char *dsaparam, unsigned long dsaparamlen,
24 dsa_key *key)
25 {
26 int err, stat;
27
28 LTC_ARGCHK(dsaparam != NULL);
29 LTC_ARGCHK(key != NULL);
30 LTC_ARGCHK(ltc_mp.name != NULL);
31
32 /* init key */
33 err = mp_init_multi(&key->p, &key->g, &key->q, &key->x, &key->y, NULL);
34 if (err != CRYPT_OK) return err;
35
36 if ((err = der_decode_sequence_multi(dsaparam, dsaparamlen,
37 LTC_ASN1_INTEGER, 1UL, key->p,
38 LTC_ASN1_INTEGER, 1UL, key->q,
39 LTC_ASN1_INTEGER, 1UL, key->g,
40 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
41 goto LBL_ERR;
42 }
43
44 key->qord = mp_unsigned_bin_size(key->q);
45
46 /* quick p, q, g validation, without primality testing */
47 if ((err = dsa_int_validate_pqg(key, &stat)) != CRYPT_OK) {
48 goto LBL_ERR;
49 }
50 if (stat == 0) {
51 err = CRYPT_INVALID_PACKET;
52 goto LBL_ERR;
53 }
54
55 return CRYPT_OK;
56
57 LBL_ERR:
58 dsa_free(key);
59 return err;
60 }
61
62 #endif
63
64 /* ref: $Format:%D$ */
65 /* git commit: $Format:%H$ */
66 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
6563 }
6664
6765 #endif
68 /* $Source$ */
69 /* $Revision$ */
70 /* $Date$ */
66 /* ref: $Format:%D$ */
67 /* git commit: $Format:%H$ */
68 /* commit time: $Format:%ai$ */
7169
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
148146
149147 #endif
150148
151 /* $Source$ */
152 /* $Revision$ */
153 /* $Date$ */
149 /* ref: $Format:%D$ */
150 /* git commit: $Format:%H$ */
151 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2422 @param hash The hash that was signed
2523 @param hashlen The length of the hash that was signed
2624 @param stat [out] The result of the signature verification, 1==valid, 0==invalid
27 @param key The corresponding public DH key
25 @param key The corresponding public DSA key
2826 @return CRYPT_OK if successful (even if the signature is invalid)
2927 */
3028 int dsa_verify_hash_raw( void *r, void *s,
4846 }
4947
5048 /* neither r or s can be null or >q*/
51 if (mp_iszero(r) == LTC_MP_YES || mp_iszero(s) == LTC_MP_YES || mp_cmp(r, key->q) != LTC_MP_LT || mp_cmp(s, key->q) != LTC_MP_LT) {
49 if (mp_cmp_d(r, 0) != LTC_MP_GT || mp_cmp_d(s, 0) != LTC_MP_GT || mp_cmp(r, key->q) != LTC_MP_LT || mp_cmp(s, key->q) != LTC_MP_LT) {
5250 err = CRYPT_INVALID_PACKET;
5351 goto error;
5452 }
9088 @param hash The hash that was signed
9189 @param hashlen The length of the hash that was signed
9290 @param stat [out] The result of the signature verification, 1==valid, 0==invalid
93 @param key The corresponding public DH key
91 @param key The corresponding public DSA key
9492 @return CRYPT_OK if successful (even if the signature is invalid)
9593 */
9694 int dsa_verify_hash(const unsigned char *sig, unsigned long siglen,
9997 {
10098 int err;
10199 void *r, *s;
100 ltc_asn1_list sig_seq[2];
101 unsigned long reallen = 0;
102
103 LTC_ARGCHK(stat != NULL);
104 *stat = 0; /* must be set before the first return */
102105
103106 if ((err = mp_init_multi(&r, &s, NULL)) != CRYPT_OK) {
104107 return err;
105108 }
106109
107 /* decode the sequence */
108 if ((err = der_decode_sequence_multi(sig, siglen,
109 LTC_ASN1_INTEGER, 1UL, r,
110 LTC_ASN1_INTEGER, 1UL, s,
111 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
110 LTC_SET_ASN1(sig_seq, 0, LTC_ASN1_INTEGER, r, 1UL);
111 LTC_SET_ASN1(sig_seq, 1, LTC_ASN1_INTEGER, s, 1UL);
112
113 err = der_decode_sequence(sig, siglen, sig_seq, 2);
114 if (err != CRYPT_OK) {
115 goto LBL_ERR;
116 }
117
118 err = der_length_sequence(sig_seq, 2, &reallen);
119 if (err != CRYPT_OK || reallen != siglen) {
112120 goto LBL_ERR;
113121 }
114122
123131 #endif
124132
125133
126 /* $Source$ */
127 /* $Revision$ */
128 /* $Date$ */
134 /* ref: $Format:%D$ */
135 /* git commit: $Format:%H$ */
136 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1715 #ifdef LTC_MDSA
1816
1917 /**
20 Verify a DSA key for validity
21 @param key The key to verify
18 Validate a DSA key
19
20 Yeah, this function should've been called dsa_validate_key()
21 in the first place and for compat-reasons we keep it
22 as it was (for now).
23
24 @param key The key to validate
2225 @param stat [out] Result of test, 1==valid, 0==invalid
2326 @return CRYPT_OK if successful
2427 */
2528 int dsa_verify_key(dsa_key *key, int *stat)
2629 {
27 void *tmp, *tmp2;
28 int res, err;
30 int err;
31
32 err = dsa_int_validate_primes(key, stat);
33 if (err != CRYPT_OK || *stat == 0) return err;
34
35 err = dsa_int_validate_pqg(key, stat);
36 if (err != CRYPT_OK || *stat == 0) return err;
37
38 return dsa_int_validate_xy(key, stat);
39 }
40
41 /**
42 Non-complex part (no primality testing) of the validation
43 of DSA params (p, q, g)
44
45 @param key The key to validate
46 @param stat [out] Result of test, 1==valid, 0==invalid
47 @return CRYPT_OK if successful
48 */
49 int dsa_int_validate_pqg(dsa_key *key, int *stat)
50 {
51 void *tmp1, *tmp2;
52 int err;
2953
3054 LTC_ARGCHK(key != NULL);
3155 LTC_ARGCHK(stat != NULL);
32
33 /* default to an invalid key */
3456 *stat = 0;
3557
36 /* first make sure key->q and key->p are prime */
37 if ((err = mp_prime_is_prime(key->q, 8, &res)) != CRYPT_OK) {
38 return err;
39 }
40 if (res == 0) {
58 /* check q-order */
59 if ( key->qord >= LTC_MDSA_MAX_GROUP || key->qord <= 15 ||
60 (unsigned long)key->qord >= mp_unsigned_bin_size(key->p) ||
61 (mp_unsigned_bin_size(key->p) - key->qord) >= LTC_MDSA_DELTA ) {
4162 return CRYPT_OK;
4263 }
4364
44 if ((err = mp_prime_is_prime(key->p, 8, &res)) != CRYPT_OK) {
45 return err;
46 }
47 if (res == 0) {
65 /* FIPS 186-4 chapter 4.1: 1 < g < p */
66 if (mp_cmp_d(key->g, 1) != LTC_MP_GT || mp_cmp(key->g, key->p) != LTC_MP_LT) {
4867 return CRYPT_OK;
4968 }
5069
51 /* now make sure that g is not -1, 0 or 1 and <p */
52 if (mp_cmp_d(key->g, 0) == LTC_MP_EQ || mp_cmp_d(key->g, 1) == LTC_MP_EQ) {
53 return CRYPT_OK;
54 }
55 if ((err = mp_init_multi(&tmp, &tmp2, NULL)) != CRYPT_OK) { return err; }
56 if ((err = mp_sub_d(key->p, 1, tmp)) != CRYPT_OK) { goto error; }
57 if (mp_cmp(tmp, key->g) == LTC_MP_EQ || mp_cmp(key->g, key->p) != LTC_MP_LT) {
58 err = CRYPT_OK;
59 goto error;
60 }
70 if ((err = mp_init_multi(&tmp1, &tmp2, NULL)) != CRYPT_OK) { return err; }
6171
62 /* 1 < y < p-1 */
63 if (!(mp_cmp_d(key->y, 1) == LTC_MP_GT && mp_cmp(key->y, tmp) == LTC_MP_LT)) {
64 err = CRYPT_OK;
65 goto error;
66 }
67
68 /* now we have to make sure that g^q = 1, and that p-1/q gives 0 remainder */
69 if ((err = mp_div(tmp, key->q, tmp, tmp2)) != CRYPT_OK) { goto error; }
72 /* FIPS 186-4 chapter 4.1: q is a divisor of (p - 1) */
73 if ((err = mp_sub_d(key->p, 1, tmp1)) != CRYPT_OK) { goto error; }
74 if ((err = mp_div(tmp1, key->q, tmp1, tmp2)) != CRYPT_OK) { goto error; }
7075 if (mp_iszero(tmp2) != LTC_MP_YES) {
7176 err = CRYPT_OK;
7277 goto error;
7378 }
7479
75 if ((err = mp_exptmod(key->g, key->q, key->p, tmp)) != CRYPT_OK) { goto error; }
76 if (mp_cmp_d(tmp, 1) != LTC_MP_EQ) {
80 /* FIPS 186-4 chapter 4.1: g is a generator of a subgroup of order q in
81 * the multiplicative group of GF(p) - so we make sure that g^q mod p = 1
82 */
83 if ((err = mp_exptmod(key->g, key->q, key->p, tmp1)) != CRYPT_OK) { goto error; }
84 if (mp_cmp_d(tmp1, 1) != LTC_MP_EQ) {
7785 err = CRYPT_OK;
7886 goto error;
7987 }
8088
81 /* now we have to make sure that y^q = 1, this makes sure y \in g^x mod p */
82 if ((err = mp_exptmod(key->y, key->q, key->p, tmp)) != CRYPT_OK) { goto error; }
83 if (mp_cmp_d(tmp, 1) != LTC_MP_EQ) {
89 err = CRYPT_OK;
90 *stat = 1;
91 error:
92 mp_clear_multi(tmp2, tmp1, NULL);
93 return err;
94 }
95
96 /**
97 Primality testing of DSA params p and q
98
99 @param key The key to validate
100 @param stat [out] Result of test, 1==valid, 0==invalid
101 @return CRYPT_OK if successful
102 */
103 int dsa_int_validate_primes(dsa_key *key, int *stat)
104 {
105 int err, res;
106
107 *stat = 0;
108 LTC_ARGCHK(key != NULL);
109 LTC_ARGCHK(stat != NULL);
110
111 /* key->q prime? */
112 if ((err = mp_prime_is_prime(key->q, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) {
113 return err;
114 }
115 if (res == LTC_MP_NO) {
116 return CRYPT_OK;
117 }
118
119 /* key->p prime? */
120 if ((err = mp_prime_is_prime(key->p, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) {
121 return err;
122 }
123 if (res == LTC_MP_NO) {
124 return CRYPT_OK;
125 }
126
127 *stat = 1;
128 return CRYPT_OK;
129 }
130
131 /**
132 Validation of a DSA key (x and y values)
133
134 @param key The key to validate
135 @param stat [out] Result of test, 1==valid, 0==invalid
136 @return CRYPT_OK if successful
137 */
138 int dsa_int_validate_xy(dsa_key *key, int *stat)
139 {
140 void *tmp;
141 int err;
142
143 *stat = 0;
144 LTC_ARGCHK(key != NULL);
145 LTC_ARGCHK(stat != NULL);
146
147 /* 1 < y < p-1 */
148 if ((err = mp_init(&tmp)) != CRYPT_OK) {
149 return err;
150 }
151 if ((err = mp_sub_d(key->p, 1, tmp)) != CRYPT_OK) {
152 goto error;
153 }
154 if (mp_cmp_d(key->y, 1) != LTC_MP_GT || mp_cmp(key->y, tmp) != LTC_MP_LT) {
84155 err = CRYPT_OK;
85156 goto error;
86157 }
87158
88 /* at this point we are out of tests ;-( */
159 if (key->type == PK_PRIVATE) {
160 /* FIPS 186-4 chapter 4.1: 0 < x < q */
161 if (mp_cmp_d(key->x, 0) != LTC_MP_GT || mp_cmp(key->x, key->q) != LTC_MP_LT) {
162 err = CRYPT_OK;
163 goto error;
164 }
165 /* FIPS 186-4 chapter 4.1: y = g^x mod p */
166 if ((err = mp_exptmod(key->g, key->x, key->p, tmp)) != CRYPT_OK) {
167 goto error;
168 }
169 if (mp_cmp(tmp, key->y) != LTC_MP_EQ) {
170 err = CRYPT_OK;
171 goto error;
172 }
173 }
174 else {
175 /* with just a public key we cannot test y = g^x mod p therefore we
176 * only test that y^q mod p = 1, which makes sure y is in g^x mod p
177 */
178 if ((err = mp_exptmod(key->y, key->q, key->p, tmp)) != CRYPT_OK) {
179 goto error;
180 }
181 if (mp_cmp_d(tmp, 1) != LTC_MP_EQ) {
182 err = CRYPT_OK;
183 goto error;
184 }
185 }
186
89187 err = CRYPT_OK;
90188 *stat = 1;
91189 error:
92 mp_clear_multi(tmp, tmp2, NULL);
190 mp_clear(tmp);
93191 return err;
94192 }
193
95194 #endif
96195
97 /* $Source$ */
98 /* $Revision$ */
99 /* $Date$ */
196 /* ref: $Format:%D$ */
197 /* git commit: $Format:%H$ */
198 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
419417
420418 #endif
421419
422 /* $Source$ */
423 /* $Revision$ */
424 /* $Date$ */
425
420 /* ref: $Format:%D$ */
421 /* git commit: $Format:%H$ */
422 /* commit time: $Format:%ai$ */
423
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
7068
7169 #endif
7270
73 /* $Source$ */
74 /* $Revision$ */
75 /* $Date$ */
71 /* ref: $Format:%D$ */
72 /* git commit: $Format:%H$ */
73 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
10098
10199 #endif
102100
103 /* $Source$ */
104 /* $Revision$ */
105 /* $Date$ */
101 /* ref: $Format:%D$ */
102 /* git commit: $Format:%H$ */
103 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
5149
5250 /* decode to find out hash */
5351 LTC_SET_ASN1(decode, 0, LTC_ASN1_OBJECT_IDENTIFIER, hashOID, sizeof(hashOID)/sizeof(hashOID[0]));
54
55 if ((err = der_decode_sequence(in, inlen, decode, 1)) != CRYPT_OK) {
52 err = der_decode_sequence(in, inlen, decode, 1);
53 if (err != CRYPT_OK && err != CRYPT_INPUT_TOO_LONG) {
5654 return err;
5755 }
5856
141139
142140 #endif
143141
144 /* $Source$ */
145 /* $Revision$ */
146 /* $Date$ */
142 /* ref: $Format:%D$ */
143 /* git commit: $Format:%H$ */
144 /* commit time: $Format:%ai$ */
147145
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
8381 }
8482
8583 pubkeysize = ECC_BUF_SIZE;
86 if ((err = ecc_export_raw(pub_expt, &pubkeysize, PK_PUBLIC_COMPRESSED, &pubkey)) != CRYPT_OK) {
84 if ((err = ecc_export_raw(pub_expt, &pubkeysize, PK_PUBLIC|PK_COMPRESSED, &pubkey)) != CRYPT_OK) {
8785 ecc_free(&pubkey);
8886 goto LBL_ERR;
8987 }
127125 }
128126
129127 #endif
130 /* $Source$ */
131 /* $Revision$ */
132 /* $Date$ */
128 /* ref: $Format:%D$ */
129 /* git commit: $Format:%H$ */
130 /* commit time: $Format:%ai$ */
133131
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
7371 }
7472
7573 #endif
76 /* $Source$ */
77 /* $Revision$ */
78 /* $Date$ */
74 /* ref: $Format:%D$ */
75 /* git commit: $Format:%H$ */
76 /* commit time: $Format:%ai$ */
7977
1818 /** Export raw public or private key (public keys = ANS X9.63 compressed or uncompressed; private keys = raw bytes)
1919 @param out [out] destination of export
2020 @param outlen [in/out] Length of destination and final output size
21 @param type PK_PRIVATE, PK_PUBLIC or PK_PUBLIC_COMPRESSED
21 @param type PK_PRIVATE, PK_PUBLIC or PK_PUBLIC|PK_COMPRESSED
2222 @param key Key to export
2323 Return CRYPT_OK on success
2424 */
2626 int ecc_export_raw(unsigned char *out, unsigned long *outlen, int type, ecc_key *key)
2727 {
2828 unsigned long size, ksize;
29 int err;
29 int err, compressed;
3030
3131 LTC_ARGCHK(key != NULL);
3232 LTC_ARGCHK(out != NULL);
3737 }
3838 size = key->dp->size;
3939
40 if (type == PK_PUBLIC_COMPRESSED) {
40 compressed = type & PK_COMPRESSED;
41 type &= ~PK_COMPRESSED;
42
43 if (type == PK_PUBLIC && compressed) {
4144 if ((err = ltc_ecc_export_point(out, outlen, key->pubkey.x, key->pubkey.y, size, 1)) != CRYPT_OK) return err;
4245 }
4346 else if (type == PK_PUBLIC) {
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
3129 }
3230
3331 #endif
34 /* $Source$ */
35 /* $Revision$ */
36 /* $Date$ */
32 /* ref: $Format:%D$ */
33 /* git commit: $Format:%H$ */
34 /* commit time: $Format:%ai$ */
3735
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
3533 }
3634
3735 #endif
38 /* $Source$ */
39 /* $Revision$ */
40 /* $Date$ */
36 /* ref: $Format:%D$ */
37 /* git commit: $Format:%H$ */
38 /* commit time: $Format:%ai$ */
4139
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
5654 }
5755
5856 /* find out what type of key it is */
59 if ((err = der_decode_sequence_multi(in, inlen,
60 LTC_ASN1_BIT_STRING, 1UL, &flags,
61 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
57 err = der_decode_sequence_multi(in, inlen, LTC_ASN1_BIT_STRING, 1UL, flags,
58 LTC_ASN1_EOL, 0UL, NULL);
59 if (err != CRYPT_OK && err != CRYPT_INPUT_TOO_LONG) {
6260 goto done;
6361 }
6462
7573 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
7674 goto done;
7775 }
78 } else {
76 } else if (flags[0] == 0) {
7977 /* public key */
8078 key->type = PK_PUBLIC;
8179 if ((err = der_decode_sequence_multi(in, inlen,
8785 goto done;
8886 }
8987 }
88 else {
89 err = CRYPT_INVALID_PACKET;
90 goto done;
91 }
9092
9193 if (dp == NULL) {
92 /* BEWARE: Here we are looking up the curve params by keysize (neither curve name nor curve oid),
93 * which might be ambiguous (there can more than one curve for given keysize).
94 * Thus the chosen curve depends on order of items in ltc_ecc_sets[] - see ecc.c file.
95 */
9694 /* find the idx */
9795 for (key->idx = 0; ltc_ecc_sets[key->idx].size && (unsigned long)ltc_ecc_sets[key->idx].size != key_size; ++key->idx);
9896 if (ltc_ecc_sets[key->idx].size == 0) {
119117 return err;
120118 }
121119 #endif
122 /* $Source$ */
123 /* $Revision$ */
124 /* $Date$ */
120 /* ref: $Format:%D$ */
121 /* git commit: $Format:%H$ */
122 /* commit time: $Format:%ai$ */
125123
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
134132 }
135133
136134 #endif
137 /* $Source$ */
138 /* $Revision$ */
139 /* $Date$ */
135 /* ref: $Format:%D$ */
136 /* git commit: $Format:%H$ */
137 /* commit time: $Format:%ai$ */
140138
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
8886 }
8987
9088 #endif
91 /* $Source$ */
92 /* $Revision$ */
93 /* $Date$ */
89 /* ref: $Format:%D$ */
90 /* git commit: $Format:%H$ */
91 /* commit time: $Format:%ai$ */
9492
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
3937 }
4038
4139 #endif
42 /* $Source$ */
43 /* $Revision$ */
44 /* $Date$ */
40 /* ref: $Format:%D$ */
41 /* git commit: $Format:%H$ */
42 /* commit time: $Format:%ai$ */
4543
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 #include "tomcrypt.h"
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
3735 }
3836
3937 #endif
40 /* $Source$ */
41 /* $Revision$ */
42 /* $Date$ */
38 /* ref: $Format:%D$ */
39 /* git commit: $Format:%H$ */
40 /* commit time: $Format:%ai$ */
4341
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
7472
7573 #endif
7674
77 /* $Source$ */
78 /* $Revision$ */
79 /* $Date$ */
75 /* ref: $Format:%D$ */
76 /* git commit: $Format:%H$ */
77 /* commit time: $Format:%ai$ */
8078
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
205203 #endif
206204 #endif
207205
208 /* $Source$ */
209 /* $Revision$ */
210 /* $Date$ */
206 /* ref: $Format:%D$ */
207 /* git commit: $Format:%H$ */
208 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
228226
229227 #endif
230228
231 /* $Source$ */
232 /* $Revision$ */
233 /* $Date$ */
229 /* ref: $Format:%D$ */
230 /* git commit: $Format:%H$ */
231 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
171169
172170 #endif
173171 #endif
174 /* $Source$ */
175 /* $Revision$ */
176 /* $Date$ */
172 /* ref: $Format:%D$ */
173 /* git commit: $Format:%H$ */
174 /* commit time: $Format:%ai$ */
177175
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
5149 }
5250
5351 #endif
54 /* $Source$ */
55 /* $Revision$ */
56 /* $Date$ */
52 /* ref: $Format:%D$ */
53 /* git commit: $Format:%H$ */
54 /* commit time: $Format:%ai$ */
5755
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
210208
211209 #endif
212210
213 /* $Source$ */
214 /* $Revision$ */
215 /* $Date$ */
216
211 /* ref: $Format:%D$ */
212 /* git commit: $Format:%H$ */
213 /* commit time: $Format:%ai$ */
214
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108
119 /* Implements ECC over Z/pZ for curve y^2 = x^3 + a*x + b
193191 return err;
194192 }
195193 #endif
196 /* $Source$ */
197 /* $Revision$ */
198 /* $Date$ */
194 /* ref: $Format:%D$ */
195 /* git commit: $Format:%H$ */
196 /* commit time: $Format:%ai$ */
199197
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4543 #endif /* LTC_PKCS_1 */
4644
4745
48 /* $Source$ */
49 /* $Revision$ */
50 /* $Date$ */
46 /* ref: $Format:%D$ */
47 /* git commit: $Format:%H$ */
48 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
102100
103101 #endif /* LTC_PKCS_1 */
104102
105 /* $Source$ */
106 /* $Revision$ */
107 /* $Date$ */
103 /* ref: $Format:%D$ */
104 /* git commit: $Format:%H$ */
105 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
181179
182180 #endif /* LTC_PKCS_1 */
183181
184 /* $Source$ */
185 /* $Revision$ */
186 /* $Date$ */
182 /* ref: $Format:%D$ */
183 /* git commit: $Format:%H$ */
184 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
167165 #endif /* LTC_PKCS_1 */
168166
169167
170 /* $Source$ */
171 /* $Revision$ */
172 /* $Date$ */
168 /* ref: $Format:%D$ */
169 /* git commit: $Format:%H$ */
170 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3028 #endif /* LTC_PKCS_1 */
3129
3230
33 /* $Source$ */
34 /* $Revision$ */
35 /* $Date$ */
31 /* ref: $Format:%D$ */
32 /* git commit: $Format:%H$ */
33 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
172170
173171 #endif /* LTC_PKCS_1 */
174172
175 /* $Source$ */
176 /* $Revision$ */
177 /* $Date$ */
173 /* ref: $Format:%D$ */
174 /* git commit: $Format:%H$ */
175 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
170168
171169 #endif /* LTC_PKCS_1 */
172170
173 /* $Source$ */
174 /* $Revision$ */
175 /* $Date$ */
171 /* ref: $Format:%D$ */
172 /* git commit: $Format:%H$ */
173 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
108106
109107 #endif /* #ifdef LTC_PKCS_1 */
110108
111 /* $Source$ */
112 /* $Revision$ */
113 /* $Date$ */
109 /* ref: $Format:%D$ */
110 /* git commit: $Format:%H$ */
111 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
105103
106104 #endif /* #ifdef LTC_PKCS_1 */
107105
108 /* $Source$ */
109 /* $Revision$ */
110 /* $Date$ */
106 /* ref: $Format:%D$ */
107 /* git commit: $Format:%H$ */
108 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9997
10098 #endif /* LTC_MRSA */
10199
102 /* $Source$ */
103 /* $Revision$ */
104 /* $Date$ */
100 /* ref: $Format:%D$ */
101 /* git commit: $Format:%H$ */
102 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9694
9795 #endif /* LTC_MRSA */
9896
99 /* $Source$ */
100 /* $Revision$ */
101 /* $Date$ */
97 /* ref: $Format:%D$ */
98 /* git commit: $Format:%H$ */
99 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
9391
9492 #endif /* LTC_MRSA */
9593
96 /* $Source$ */
97 /* $Revision$ */
98 /* $Date$ */
94 /* ref: $Format:%D$ */
95 /* git commit: $Format:%H$ */
96 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
9 *
10 * Added RSA blinding --nmav
117 */
128 #include "tomcrypt.h"
139
1410 /**
1511 @file rsa_exptmod.c
1612 RSA PKCS exptmod, Tom St Denis
13 Added RSA blinding --nmav
1714 */
1815
1916 #ifdef LTC_MRSA
9996 }
10097 #endif /* LTC_RSA_BLINDING */
10198
102 has_crt_parameters = (key->dP != NULL) && (mp_get_digit_count(key->dP) != 0) &&
103 (key->dQ != NULL) && (mp_get_digit_count(key->dQ) != 0) &&
104 (key->qP != NULL) && (mp_get_digit_count(key->qP) != 0);
99 has_crt_parameters = (key->p != NULL) && (mp_get_digit_count(key->p) != 0) &&
100 (key->q != NULL) && (mp_get_digit_count(key->q) != 0) &&
101 (key->dP != NULL) && (mp_get_digit_count(key->dP) != 0) &&
102 (key->dQ != NULL) && (mp_get_digit_count(key->dQ) != 0) &&
103 (key->qP != NULL) && (mp_get_digit_count(key->qP) != 0);
105104
106105 if (!has_crt_parameters) {
107106 /*
177176
178177 #endif
179178
180 /* $Source$ */
181 /* $Revision$ */
182 /* $Date$ */
179 /* ref: $Format:%D$ */
180 /* git commit: $Format:%H$ */
181 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2321 void rsa_free(rsa_key *key)
2422 {
2523 LTC_ARGCHKVD(key != NULL);
26 mp_clear_multi(key->q, key->p, key->qP, key->dP, key->dQ, key->N, key->d, key->e, NULL);
24 mp_cleanup_multi(&key->q, &key->p, &key->qP, &key->dP, &key->dQ, &key->N, &key->d, &key->e, NULL);
2725 }
2826
2927 #endif
3028
31 /* $Source$ */
32 /* $Revision$ */
33 /* $Date$ */
29 /* ref: $Format:%D$ */
30 /* git commit: $Format:%H$ */
31 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3634
3735 #endif
3836
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
37 /* ref: $Format:%D$ */
38 /* git commit: $Format:%H$ */
39 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4139 }
4240
4341 /* see if the OpenSSL DER format RSA public key will work */
44 tmpbuf_len = MAX_RSA_SIZE * 8;
42 tmpbuf_len = inlen;
4543 tmpbuf = XCALLOC(1, tmpbuf_len);
4644 if (tmpbuf == NULL) {
4745 err = CRYPT_MEM;
6765 }
6866
6967 /* not SSL public key, try to match against PKCS #1 standards */
70 if ((err = der_decode_sequence_multi(in, inlen,
71 LTC_ASN1_INTEGER, 1UL, key->N,
72 LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) {
68 err = der_decode_sequence_multi(in, inlen, LTC_ASN1_INTEGER, 1UL, key->N,
69 LTC_ASN1_EOL, 0UL, NULL);
70
71 if (err != CRYPT_OK && err != CRYPT_INPUT_TOO_LONG) {
7372 goto LBL_ERR;
7473 }
7574
124123 #endif /* LTC_MRSA */
125124
126125
127 /* $Source$ */
128 /* $Revision$ */
129 /* $Date$ */
126 /* ref: $Format:%D$ */
127 /* git commit: $Format:%H$ */
128 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
7472 /* alloc buffers */
7573 buf1len = inlen; /* approx. */
7674 buf1 = XMALLOC(buf1len);
77 if (buf1 == NULL) { err = CRYPT_MEM; goto LBL_NOCLEAR; }
75 if (buf1 == NULL) { err = CRYPT_MEM; goto LBL_NOFREE; }
7876 buf2len = inlen; /* approx. */
7977 buf2 = XMALLOC(buf2len);
80 if (buf2 == NULL) { err = CRYPT_MEM; goto LBL_FREE; }
78 if (buf2 == NULL) { err = CRYPT_MEM; goto LBL_FREE1; }
8179
8280 /* init key */
8381 err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, &zero, &iter, NULL);
84 if (err != CRYPT_OK) { goto LBL_NOCLEAR; }
82 if (err != CRYPT_OK) { goto LBL_FREE2; }
8583
8684 /* try to decode encrypted priv key */
8785 LTC_SET_ASN1(key_seq_e, 0, LTC_ASN1_OCTET_STRING, buf1, buf1len);
132130 LTC_ASN1_INTEGER, 1UL, key->qP,
133131 LTC_ASN1_EOL, 0UL, NULL);
134132 if (err != CRYPT_OK) { goto LBL_ERR; }
135 mp_clear_multi(zero, iter, NULL);
136133 key->type = PK_PRIVATE;
137134 err = CRYPT_OK;
138 goto LBL_FREE;
135 goto LBL_FREE2;
139136
140137 LBL_ERR:
141 mp_clear_multi(key->d, key->e, key->N, key->dQ, key->dP, key->qP, key->p, key->q, zero, iter, NULL);
142 LBL_NOCLEAR:
138 rsa_free(key);
139 LBL_FREE2:
140 mp_clear_multi(iter, zero, NULL);
143141 XFREE(buf2);
144 LBL_FREE:
142 LBL_FREE1:
145143 XFREE(buf1);
146144 LBL_NOFREE:
147145 return err;
148146 }
149147
150148 #endif /* LTC_MRSA */
149
150 /* ref: $Format:%D$ */
151 /* git commit: $Format:%H$ */
152 /* commit time: $Format:%ai$ */
+0
-64
src/ltc/pk/rsa/rsa_import_radix.c less more
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
9 */
10 #include "tomcrypt.h"
11
12 /**
13 Import RSA public or private key from raw numbers
14 @param radix the radix the numbers are represented in (2-64, 16 = hexadecimal)
15 @param N RSA's N in radix representation
16 @param e RSA's e in radix representation
17 @param d RSA's d in radix representation (only private key, NULL for public key)
18 @param p RSA's p in radix representation (only private key, NULL for public key)
19 @param q RSA's q in radix representation (only private key, NULL for public key)
20 @param dP RSA's dP in radix representation (only private key, NULL for public key)
21 @param dQ RSA's dQ in radix representation (only private key, NULL for public key)
22 @param qP RSA's qP in radix representation (only private key, NULL for public key)
23 @param key [out] the destination for the imported key
24 @return CRYPT_OK if successful, upon error allocated memory is freed
25 */
26
27 #ifdef LTC_MRSA
28
29 int rsa_import_radix(int radix, char *N, char *e, char *d, char *p, char *q, char *dP, char *dQ, char *qP, rsa_key *key)
30 {
31 int err;
32
33 LTC_ARGCHK(key != NULL);
34 LTC_ARGCHK(N != NULL);
35 LTC_ARGCHK(e != NULL);
36 LTC_ARGCHK(ltc_mp.name != NULL);
37
38 err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, NULL);
39 if (err != CRYPT_OK) return err;
40
41 if ((err = mp_read_radix(key->N , N , radix)) != CRYPT_OK) { goto LBL_ERR; }
42 if ((err = mp_read_radix(key->e , e , radix)) != CRYPT_OK) { goto LBL_ERR; }
43 if (d && p && q && dP && dQ && qP && strlen(d)>0 && strlen(p)>0 &&
44 strlen(q)>0 && strlen(dP)>0 && strlen(dQ)>0 && strlen(qP)>0) {
45 if ((err = mp_read_radix(key->d , d , radix)) != CRYPT_OK) { goto LBL_ERR; }
46 if ((err = mp_read_radix(key->p , p , radix)) != CRYPT_OK) { goto LBL_ERR; }
47 if ((err = mp_read_radix(key->q , q , radix)) != CRYPT_OK) { goto LBL_ERR; }
48 if ((err = mp_read_radix(key->dP, dP, radix)) != CRYPT_OK) { goto LBL_ERR; }
49 if ((err = mp_read_radix(key->dQ, dQ, radix)) != CRYPT_OK) { goto LBL_ERR; }
50 if ((err = mp_read_radix(key->qP, qP, radix)) != CRYPT_OK) { goto LBL_ERR; }
51 key->type = PK_PRIVATE;
52 }
53 else {
54 key->type = PK_PUBLIC;
55 }
56 return CRYPT_OK;
57
58 LBL_ERR:
59 mp_clear_multi(key->d, key->e, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL);
60 return err;
61 }
62
63 #endif /* LTC_MRSA */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4038 return err;
4139 }
4240
43 tmpbuf_len = MAX_RSA_SIZE * 8;
41 tmpbuf_len = inlen;
4442 tmpbuf = XCALLOC(1, tmpbuf_len);
4543 if (tmpbuf == NULL) {
4644 err = CRYPT_MEM;
114112 #endif /* LTC_MRSA */
115113
116114
117 /* $Source$ */
118 /* $Revision$ */
119 /* $Date$ */
115 /* ref: $Format:%D$ */
116 /* git commit: $Format:%H$ */
117 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
3230
3331 LTC_ARGCHK(ltc_mp.name != NULL);
3432 LTC_ARGCHK(key != NULL);
35
36 if ((size < (MIN_RSA_SIZE/8)) || (size > (MAX_RSA_SIZE/8))) {
37 return CRYPT_INVALID_KEYSIZE;
38 }
33 LTC_ARGCHK(size > 0);
3934
4035 if ((e < 3) || ((e & 1) == 0)) {
4136 return CRYPT_INVALID_ARG;
9893 err = CRYPT_OK;
9994 goto cleanup;
10095 errkey:
101 mp_clear_multi(key->q, key->p, key->qP, key->dP, key->dQ, key->N, key->d, key->e, NULL);
96 rsa_free(key);
10297 cleanup:
10398 mp_clear_multi(tmp3, tmp2, tmp1, q, p, NULL);
10499 return err;
106101
107102 #endif
108103
109 /* $Source$ */
110 /* $Revision$ */
111 /* $Date$ */
104 /* ref: $Format:%D$ */
105 /* git commit: $Format:%H$ */
106 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8 #include "tomcrypt.h"
9
10
11 #ifdef LTC_MRSA
12
13 /**
14 Import RSA key from raw numbers
15
16 @param N RSA's N
17 @param Nlen RSA's N's length
18 @param e RSA's e
19 @param elen RSA's e's length
20 @param d RSA's d (only private key, NULL for public key)
21 @param dlen RSA's d's length
22 @param key [out] the destination for the imported key
23 @return CRYPT_OK if successful
24 */
25 int rsa_set_key(const unsigned char *N, unsigned long Nlen,
26 const unsigned char *e, unsigned long elen,
27 const unsigned char *d, unsigned long dlen,
28 rsa_key *key)
29 {
30 int err;
31
32 LTC_ARGCHK(key != NULL);
33 LTC_ARGCHK(N != NULL);
34 LTC_ARGCHK(e != NULL);
35 LTC_ARGCHK(ltc_mp.name != NULL);
36
37 err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, NULL);
38 if (err != CRYPT_OK) return err;
39
40 if ((err = mp_read_unsigned_bin(key->N , (unsigned char *)N , Nlen)) != CRYPT_OK) { goto LBL_ERR; }
41 if ((err = mp_read_unsigned_bin(key->e , (unsigned char *)e , elen)) != CRYPT_OK) { goto LBL_ERR; }
42 if (d && dlen) {
43 if ((err = mp_read_unsigned_bin(key->d , (unsigned char *)d , dlen)) != CRYPT_OK) { goto LBL_ERR; }
44 key->type = PK_PRIVATE;
45 }
46 else {
47 key->type = PK_PUBLIC;
48 }
49 return CRYPT_OK;
50
51 LBL_ERR:
52 rsa_free(key);
53 return err;
54 }
55
56 /**
57 Import factors of an RSA key from raw numbers
58
59 Only for private keys.
60
61 @param p RSA's p
62 @param plen RSA's p's length
63 @param q RSA's q
64 @param qlen RSA's q's length
65 @param key [out] the destination for the imported key
66 @return CRYPT_OK if successful
67 */
68 int rsa_set_factors(const unsigned char *p, unsigned long plen,
69 const unsigned char *q, unsigned long qlen,
70 rsa_key *key)
71 {
72 int err;
73
74 LTC_ARGCHK(key != NULL);
75 LTC_ARGCHK(p != NULL);
76 LTC_ARGCHK(q != NULL);
77 LTC_ARGCHK(ltc_mp.name != NULL);
78
79 if (key->type != PK_PRIVATE) return CRYPT_PK_TYPE_MISMATCH;
80
81 if ((err = mp_read_unsigned_bin(key->p , (unsigned char *)p , plen)) != CRYPT_OK) { goto LBL_ERR; }
82 if ((err = mp_read_unsigned_bin(key->q , (unsigned char *)q , qlen)) != CRYPT_OK) { goto LBL_ERR; }
83 return CRYPT_OK;
84
85 LBL_ERR:
86 rsa_free(key);
87 return err;
88 }
89
90 /**
91 Import CRT parameters of an RSA key from raw numbers
92
93 Only for private keys.
94
95 @param dP RSA's dP
96 @param dPlen RSA's dP's length
97 @param dQ RSA's dQ
98 @param dQlen RSA's dQ's length
99 @param qP RSA's qP
100 @param qPlen RSA's qP's length
101 @param key [out] the destination for the imported key
102 @return CRYPT_OK if successful
103 */
104 int rsa_set_crt_params(const unsigned char *dP, unsigned long dPlen,
105 const unsigned char *dQ, unsigned long dQlen,
106 const unsigned char *qP, unsigned long qPlen,
107 rsa_key *key)
108 {
109 int err;
110
111 LTC_ARGCHK(key != NULL);
112 LTC_ARGCHK(dP != NULL);
113 LTC_ARGCHK(dQ != NULL);
114 LTC_ARGCHK(qP != NULL);
115 LTC_ARGCHK(ltc_mp.name != NULL);
116
117 if (key->type != PK_PRIVATE) return CRYPT_PK_TYPE_MISMATCH;
118
119 if ((err = mp_read_unsigned_bin(key->dP, (unsigned char *)dP, dPlen)) != CRYPT_OK) { goto LBL_ERR; }
120 if ((err = mp_read_unsigned_bin(key->dQ, (unsigned char *)dQ, dQlen)) != CRYPT_OK) { goto LBL_ERR; }
121 if ((err = mp_read_unsigned_bin(key->qP, (unsigned char *)qP, qPlen)) != CRYPT_OK) { goto LBL_ERR; }
122 return CRYPT_OK;
123
124 LBL_ERR:
125 rsa_free(key);
126 return err;
127 }
128
129 #endif /* LTC_MRSA */
130
131 /* ref: $Format:%D$ */
132 /* git commit: $Format:%H$ */
133 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2220 @param inlen The length of the hash to sign (octets)
2321 @param out [out] The signature
2422 @param outlen [in/out] The max size and resulting size of the signature
25 @param padding Type of padding (LTC_PKCS_1_PSS or LTC_PKCS_1_V1_5)
23 @param padding Type of padding (LTC_PKCS_1_PSS, LTC_PKCS_1_V1_5 or LTC_PKCS_1_V1_5_NA1)
2624 @param prng An active PRNG state
2725 @param prng_idx The index of the PRNG desired
2826 @param hash_idx The index of the hash desired
4644 LTC_ARGCHK(key != NULL);
4745
4846 /* valid padding? */
49 if ((padding != LTC_PKCS_1_V1_5) && (padding != LTC_PKCS_1_PSS)) {
47 if ((padding != LTC_PKCS_1_V1_5) &&
48 (padding != LTC_PKCS_1_PSS) &&
49 (padding != LTC_PKCS_1_V1_5_NA1)) {
5050 return CRYPT_PK_INVALID_PADDING;
5151 }
5252
5353 if (padding == LTC_PKCS_1_PSS) {
54 /* valid prng and hash ? */
54 /* valid prng ? */
5555 if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) {
5656 return err;
5757 }
58 }
59
60 if (padding != LTC_PKCS_1_V1_5_NA1) {
61 /* valid hash ? */
5862 if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
5963 return err;
6064 }
8084 } else {
8185 /* PKCS #1 v1.5 pad the hash */
8286 unsigned char *tmpin;
83 ltc_asn1_list digestinfo[2], siginfo[2];
8487
85 /* not all hashes have OIDs... so sad */
86 if (hash_descriptor[hash_idx].OIDlen == 0) {
87 return CRYPT_INVALID_ARG;
88 }
88 if (padding == LTC_PKCS_1_V1_5) {
89 ltc_asn1_list digestinfo[2], siginfo[2];
90 /* not all hashes have OIDs... so sad */
91 if (hash_descriptor[hash_idx].OIDlen == 0) {
92 return CRYPT_INVALID_ARG;
93 }
8994
9095 /* construct the SEQUENCE
91 SEQUENCE {
92 SEQUENCE {hashoid OID
93 blah NULL
94 }
96 SEQUENCE {
97 SEQUENCE {hashoid OID
98 blah NULL
99 }
95100 hash OCTET STRING
101 }
102 */
103 LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, hash_descriptor[hash_idx].OID, hash_descriptor[hash_idx].OIDlen);
104 LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0);
105 LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2);
106 LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, in, inlen);
107
108 /* allocate memory for the encoding */
109 y = mp_unsigned_bin_size(key->N);
110 tmpin = XMALLOC(y);
111 if (tmpin == NULL) {
112 return CRYPT_MEM;
96113 }
97 */
98 LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, hash_descriptor[hash_idx].OID, hash_descriptor[hash_idx].OIDlen);
99 LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0);
100 LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2);
101 LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, in, inlen);
102114
103 /* allocate memory for the encoding */
104 y = mp_unsigned_bin_size(key->N);
105 tmpin = XMALLOC(y);
106 if (tmpin == NULL) {
107 return CRYPT_MEM;
108 }
109
110 if ((err = der_encode_sequence(siginfo, 2, tmpin, &y)) != CRYPT_OK) {
111 XFREE(tmpin);
112 return err;
115 if ((err = der_encode_sequence(siginfo, 2, tmpin, &y)) != CRYPT_OK) {
116 XFREE(tmpin);
117 return err;
118 }
119 } else {
120 /* set the pointer and data-length to the input values */
121 tmpin = (unsigned char *)in;
122 y = inlen;
113123 }
114124
115125 x = *outlen;
116 if ((err = pkcs_1_v1_5_encode(tmpin, y, LTC_PKCS_1_EMSA,
117 modulus_bitlen, NULL, 0,
118 out, &x)) != CRYPT_OK) {
126 err = pkcs_1_v1_5_encode(tmpin, y, LTC_PKCS_1_EMSA, modulus_bitlen, NULL, 0, out, &x);
127
128 if (padding == LTC_PKCS_1_V1_5) {
119129 XFREE(tmpin);
130 }
131
132 if (err != CRYPT_OK) {
120133 return err;
121134 }
122 XFREE(tmpin);
123135 }
124136
125137 /* RSA encode it */
128140
129141 #endif /* LTC_MRSA */
130142
131 /* $Source$ */
132 /* $Revision$ */
133 /* $Date$ */
143 /* ref: $Format:%D$ */
144 /* git commit: $Format:%H$ */
145 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * http://libtom.org
97 */
108 #include "tomcrypt.h"
119
4341
4442 #endif
4543
46 /* $Source$ */
47 /* $Revision$ */
48 /* $Date$ */
44 /* ref: $Format:%D$ */
45 /* git commit: $Format:%H$ */
46 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
2220 @param siglen The length of the signature data (octets)
2321 @param hash The hash of the message that was signed
2422 @param hashlen The length of the hash of the message that was signed (octets)
25 @param padding Type of padding (LTC_PKCS_1_PSS or LTC_PKCS_1_V1_5)
23 @param padding Type of padding (LTC_PKCS_1_PSS, LTC_PKCS_1_V1_5 or LTC_PKCS_1_V1_5_NA1)
2624 @param hash_idx The index of the desired hash
2725 @param saltlen The length of the salt used during signature
2826 @param stat [out] The result of the signature comparison, 1==valid, 0==invalid
5048 /* valid padding? */
5149
5250 if ((padding != LTC_PKCS_1_V1_5) &&
53 (padding != LTC_PKCS_1_PSS)) {
51 (padding != LTC_PKCS_1_PSS) &&
52 (padding != LTC_PKCS_1_V1_5_NA1)) {
5453 return CRYPT_PK_INVALID_PADDING;
5554 }
5655
57 if (padding == LTC_PKCS_1_PSS) {
56 if (padding != LTC_PKCS_1_V1_5_NA1) {
5857 /* valid hash ? */
5958 if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
6059 return err;
102101 } else {
103102 /* PKCS #1 v1.5 decode it */
104103 unsigned char *out;
105 unsigned long outlen, loid[16], reallen;
104 unsigned long outlen;
106105 int decoded;
107 ltc_asn1_list digestinfo[2], siginfo[2];
108
109 /* not all hashes have OIDs... so sad */
110 if (hash_descriptor[hash_idx].OIDlen == 0) {
111 err = CRYPT_INVALID_ARG;
112 goto bail_2;
113 }
114106
115107 /* allocate temp buffer for decoded hash */
116108 outlen = ((modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0)) - 3;
125117 goto bail_2;
126118 }
127119
128 /* now we must decode out[0...outlen-1] using ASN.1, test the OID and then test the hash */
129 /* construct the SEQUENCE
130 SEQUENCE {
131 SEQUENCE {hashoid OID
132 blah NULL
120 if (padding == LTC_PKCS_1_V1_5) {
121 unsigned long loid[16], reallen;
122 ltc_asn1_list digestinfo[2], siginfo[2];
123
124 /* not all hashes have OIDs... so sad */
125 if (hash_descriptor[hash_idx].OIDlen == 0) {
126 err = CRYPT_INVALID_ARG;
127 goto bail_2;
128 }
129
130 /* now we must decode out[0...outlen-1] using ASN.1, test the OID and then test the hash */
131 /* construct the SEQUENCE
132 SEQUENCE {
133 SEQUENCE {hashoid OID
134 blah NULL
135 }
136 hash OCTET STRING
137 }
138 */
139 LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, loid, sizeof(loid)/sizeof(loid[0]));
140 LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0);
141 LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2);
142 LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, tmpbuf, siglen);
143
144 if ((err = der_decode_sequence(out, outlen, siginfo, 2)) != CRYPT_OK) {
145 /* fallback to Legacy:missing NULL */
146 LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 1);
147 if ((err = der_decode_sequence(out, outlen, siginfo, 2)) != CRYPT_OK) {
148 XFREE(out);
149 goto bail_2;
133150 }
134 hash OCTET STRING
135151 }
136 */
137 LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, loid, sizeof(loid)/sizeof(loid[0]));
138 LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0);
139 LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2);
140 LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, tmpbuf, siglen);
141152
142 if ((err = der_decode_sequence(out, outlen, siginfo, 2)) != CRYPT_OK) {
143 XFREE(out);
144 goto bail_2;
145 }
153 if ((err = der_length_sequence(siginfo, 2, &reallen)) != CRYPT_OK) {
154 XFREE(out);
155 goto bail_2;
156 }
146157
147 if ((err = der_length_sequence(siginfo, 2, &reallen)) != CRYPT_OK) {
148 XFREE(out);
149 goto bail_2;
150 }
151
152 /* test OID */
153 if ((reallen == outlen) &&
154 (digestinfo[0].size == hash_descriptor[hash_idx].OIDlen) &&
155 (XMEM_NEQ(digestinfo[0].data, hash_descriptor[hash_idx].OID, sizeof(unsigned long) * hash_descriptor[hash_idx].OIDlen) == 0) &&
156 (siginfo[1].size == hashlen) &&
157 (XMEM_NEQ(siginfo[1].data, hash, hashlen) == 0)) {
158 *stat = 1;
158 /* test OID */
159 if ((reallen == outlen) &&
160 (digestinfo[0].size == hash_descriptor[hash_idx].OIDlen) &&
161 (XMEMCMP(digestinfo[0].data, hash_descriptor[hash_idx].OID, sizeof(unsigned long) * hash_descriptor[hash_idx].OIDlen) == 0) &&
162 (siginfo[1].size == hashlen) &&
163 (XMEMCMP(siginfo[1].data, hash, hashlen) == 0)) {
164 *stat = 1;
165 }
166 } else {
167 /* only check if the hash is equal */
168 if ((hashlen == outlen) &&
169 (XMEMCMP(out, hash, hashlen) == 0)) {
170 *stat = 1;
171 }
159172 }
160173
161174 #ifdef LTC_CLEAN_STACK
174187
175188 #endif /* LTC_MRSA */
176189
177 /* $Source$ */
178 /* $Revision$ */
179 /* $Date$ */
190 /* ref: $Format:%D$ */
191 /* git commit: $Format:%H$ */
192 /* commit time: $Format:%ai$ */
3030
3131 /**
3232 Start the PRNG
33 @param prng[out] The PRNG state to initialize
33 @param prng The PRNG state to initialize
3434 @return CRYPT_OK if successful
3535 */
3636 int chacha20_prng_start(prng_state *prng)
7070 /* iv 8 bytes */
7171 if ((err = chacha_ivctr64(&prng->chacha.s, buf + 32, 8, 0)) != CRYPT_OK) goto LBL_UNLOCK;
7272 /* clear KEY + IV */
73 XMEMSET(buf, 0, sizeof(buf));
73 zeromem(buf, sizeof(buf));
7474 }
7575 else {
7676 /* chacha20_prng_ready() was not called yet, add entropy to ent buffer */
239239 }
240240
241241 #endif
242
243 /* ref: $Format:%D$ */
244 /* git commit: $Format:%H$ */
245 /* commit time: $Format:%ai$ */
4848 };
4949
5050 /* update the IV */
51 static void fortuna_update_iv(prng_state *prng)
51 static void _fortuna_update_iv(prng_state *prng)
5252 {
5353 int x;
5454 unsigned char *IV;
6161 }
6262
6363 /* reseed the PRNG */
64 static int fortuna_reseed(prng_state *prng)
64 static int _fortuna_reseed(prng_state *prng)
6565 {
6666 unsigned char tmp[MAXBLOCKSIZE];
6767 hash_state md;
105105 if ((err = rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey)) != CRYPT_OK) {
106106 return err;
107107 }
108 fortuna_update_iv(prng);
108 _fortuna_update_iv(prng);
109109
110110 /* reset pool len */
111111 prng->fortuna.pool0_len = 0;
216216 LTC_ARGCHK(prng != NULL);
217217
218218 LTC_MUTEX_LOCK(&prng->lock);
219 err = fortuna_reseed(prng);
219 err = _fortuna_reseed(prng);
220220 prng->ready = (err == CRYPT_OK) ? 1 : 0;
221221
222222 LTC_MUTEX_UNLOCK(&prng->lock);
245245
246246 /* do we have to reseed? */
247247 if (++prng->fortuna.wd == LTC_FORTUNA_WD || prng->fortuna.pool0_len >= 64) {
248 if (fortuna_reseed(prng) != CRYPT_OK) {
248 if (_fortuna_reseed(prng) != CRYPT_OK) {
249249 goto LBL_UNLOCK;
250250 }
251251 }
259259 rijndael_ecb_encrypt(prng->fortuna.IV, out, &prng->fortuna.skey);
260260 out += 16;
261261 outlen -= 16;
262 fortuna_update_iv(prng);
262 _fortuna_update_iv(prng);
263263 }
264264
265265 /* left over bytes? */
266266 if (outlen > 0) {
267267 rijndael_ecb_encrypt(prng->fortuna.IV, tmp, &prng->fortuna.skey);
268268 XMEMCPY(out, tmp, outlen);
269 fortuna_update_iv(prng);
269 _fortuna_update_iv(prng);
270270 }
271271
272272 /* generate new key */
273273 rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K , &prng->fortuna.skey);
274 fortuna_update_iv(prng);
274 _fortuna_update_iv(prng);
275275
276276 rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K+16, &prng->fortuna.skey);
277 fortuna_update_iv(prng);
277 _fortuna_update_iv(prng);
278278
279279 if (rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey) != CRYPT_OK) {
280280 tlen = 0;
443443 #endif
444444
445445
446 /* $Source$ */
447 /* $Revision$ */
448 /* $Date$ */
446 /* ref: $Format:%D$ */
447 /* git commit: $Format:%H$ */
448 /* commit time: $Format:%ai$ */
88 #include "tomcrypt.h"
99
1010 /**
11 @file rc4.c
11 @file prngs/rc4.c
1212 RC4 PRNG, Tom St Denis
1313 */
1414
7171 if ((err = rc4_stream_setup(&prng->rc4.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK;
7272 /* drop first 3072 bytes - https://en.wikipedia.org/wiki/RC4#Fluhrer.2C_Mantin_and_Shamir_attack */
7373 for (i = 0; i < 12; i++) rc4_stream_keystream(&prng->rc4.s, buf, sizeof(buf));
74 zeromem(buf, sizeof(buf));
7475 }
7576 else {
7677 /* rc4_ready() was not called yet, add entropy to the buffer */
241242 }
242243
243244 #endif
245
246 /* ref: $Format:%D$ */
247 /* git commit: $Format:%H$ */
248 /* commit time: $Format:%ai$ */
1313 portable way to get secure random bits to feed a PRNG (Tom St Denis)
1414 */
1515
16 #ifdef LTC_DEVRANDOM
16 #if defined(LTC_DEVRANDOM) && !defined(_WIN32)
1717 /* on *NIX read /dev/random */
1818 static unsigned long rng_nix(unsigned char *buf, unsigned long len,
1919 void (*callback)(void))
153153 }
154154 #endif /* #ifdef LTC_RNG_GET_BYTES */
155155
156 /* $Source$ */
157 /* $Revision$ */
158 /* $Date$ */
156 /* ref: $Format:%D$ */
157 /* git commit: $Format:%H$ */
158 /* commit time: $Format:%ai$ */
6363 #endif /* #ifdef LTC_RNG_MAKE_PRNG */
6464
6565
66 /* $Source$ */
67 /* $Revision$ */
68 /* $Date$ */
66 /* ref: $Format:%D$ */
67 /* git commit: $Format:%H$ */
68 /* commit time: $Format:%ai$ */
99 #include "tomcrypt.h"
1010
1111 /**
12 @file sober128.c
12 @file prngs/sober128.c
1313 Implementation of SOBER-128 by Tom St Denis.
1414 Based on s128fast.c reference code supplied by Greg Rose of QUALCOMM.
1515 */
7272 /* iv 8 bytes */
7373 if ((err = sober128_stream_setiv(&prng->sober128.s, buf + 32, 8)) != CRYPT_OK) goto LBL_UNLOCK;
7474 /* clear KEY + IV */
75 XMEMSET(buf, 0, sizeof(buf));
75 zeromem(buf, sizeof(buf));
7676 }
7777 else {
7878 /* sober128_ready() was not called yet, add entropy to ent buffer */
241241 }
242242
243243 #endif
244
245 /* ref: $Format:%D$ */
246 /* git commit: $Format:%H$ */
247 /* commit time: $Format:%ai$ */
155155
156156
157157
158 /* $Source$ */
159 /* $Revision$ */
160 /* $Date$ */
158 /* ref: $Format:%D$ */
159 /* git commit: $Format:%H$ */
160 /* commit time: $Format:%ai$ */
345345 #endif
346346
347347
348 /* $Source$ */
349 /* $Revision$ */
350 /* $Date$ */
348 /* ref: $Format:%D$ */
349 /* git commit: $Format:%H$ */
350 /* commit time: $Format:%ai$ */
5656 unsigned long i, j;
5757
5858 if (inlen == 0) return CRYPT_OK; /* nothing to do */
59 LTC_ARGCHK(st != NULL);
60 LTC_ARGCHK(in != NULL);
61 LTC_ARGCHK(out != NULL);
59
60 LTC_ARGCHK(st != NULL);
61 LTC_ARGCHK(in != NULL);
62 LTC_ARGCHK(out != NULL);
63 LTC_ARGCHK(st->ivlen != 0);
6264
6365 if (st->ksleft > 0) {
6466 j = MIN(st->ksleft, inlen);
9294 }
9395
9496 #endif
97
98 /* ref: $Format:%D$ */
99 /* git commit: $Format:%H$ */
100 /* commit time: $Format:%ai$ */
2323 }
2424
2525 #endif
26
27 /* ref: $Format:%D$ */
28 /* git commit: $Format:%H$ */
29 /* commit time: $Format:%ai$ */
1919 Set IV + counter data to the ChaCha state
2020 @param st The ChaCha20 state
2121 @param iv The IV data to add
22 @param inlen The length of the IV (must be 12)
22 @param ivlen The length of the IV (must be 12)
2323 @param counter 32bit (unsigned) initial counter value
2424 @return CRYPT_OK on success
2525 */
4040 }
4141
4242 #endif
43
44 /* ref: $Format:%D$ */
45 /* git commit: $Format:%H$ */
46 /* commit time: $Format:%ai$ */
1919 Set IV + counter data to the ChaCha state
2020 @param st The ChaCha20 state
2121 @param iv The IV data to add
22 @param inlen The length of the IV (must be 8)
22 @param ivlen The length of the IV (must be 8)
2323 @param counter 64bit (unsigned) initial counter value
2424 @return CRYPT_OK on success
2525 */
4040 }
4141
4242 #endif
43
44 /* ref: $Format:%D$ */
45 /* git commit: $Format:%H$ */
46 /* commit time: $Format:%ai$ */
3131 }
3232
3333 #endif
34
35 /* ref: $Format:%D$ */
36 /* git commit: $Format:%H$ */
37 /* commit time: $Format:%ai$ */
3434 LTC_ARGCHK(key != NULL);
3535 LTC_ARGCHK(keylen == 32 || keylen == 16);
3636
37 if (rounds == 0) rounds = 20;
38
3739 LOAD32L(st->input[4], key + 0);
3840 LOAD32L(st->input[5], key + 4);
3941 LOAD32L(st->input[6], key + 8);
5860 }
5961
6062 #endif
63
64 /* ref: $Format:%D$ */
65 /* git commit: $Format:%H$ */
66 /* commit time: $Format:%ai$ */
104104 }
105105
106106 #endif
107
108 /* ref: $Format:%D$ */
109 /* git commit: $Format:%H$ */
110 /* commit time: $Format:%ai$ */
44 *
55 * The library is free for all purposes without any express
66 * guarantee it works.
7 *
8 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
97 */
108 #include "tomcrypt.h"
119
1210 /**
13 @file sober128.c
11 @file stream/sober128/sober128.c
1412 Implementation of SOBER-128 by Tom St Denis.
1513 Based on s128fast.c reference code supplied by Greg Rose of QUALCOMM.
1614 */
204202 Set IV to the Sober128 state
205203 @param c The Sober12820 state
206204 @param iv The IV data to add
207 @param inlen The length of the IV (must be 12)
205 @param ivlen The length of the IV (must be 12)
208206 @return CRYPT_OK on success
209207 */
210208 int sober128_stream_setiv(sober128_state *c, const unsigned char *iv, unsigned long ivlen)
262260
263261 /* handle any previously buffered bytes */
264262 while (c->nbuf != 0 && inlen != 0) {
265 *out++ = *in++ ^ (c->sbuf & 0xFF);
263 *out++ = *in++ ^ (unsigned char)(c->sbuf & 0xFF);
266264 c->sbuf >>= 8;
267265 c->nbuf -= 8;
268266 --inlen;
310308 c->sbuf = nltap(c);
311309 c->nbuf = 32;
312310 while (c->nbuf != 0 && inlen != 0) {
313 *out++ = *in++ ^ (c->sbuf & 0xFF);
311 *out++ = *in++ ^ (unsigned char)(c->sbuf & 0xFF);
314312 c->sbuf >>= 8;
315313 c->nbuf -= 8;
316314 --inlen;
341339 }
342340
343341 #endif
342
343 /* ref: $Format:%D$ */
344 /* git commit: $Format:%H$ */
345 /* commit time: $Format:%ai$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
09 /**
110 @file sober128tab.c
211 SOBER-128 Tables
161170
162171 #endif /* __LTC_SOBER128TAB_C__ */
163172
164 /* $Source$ */
165 /* $Revision$ */
166 /* $Date$ */
173 /* ref: $Format:%D$ */
174 /* git commit: $Format:%H$ */
175 /* commit time: $Format:%ai$ */
00 use strict;
11 use warnings;
22
3 use Config;
34 use Test::More tests => 1;
45
5 diag( "Testing CryptX $CryptX::VERSION, Perl $], $^X" );
6 diag( "Testing CryptX $CryptX::VERSION, Perl $] $^O $^X" );
67
78 my $ok;
89 END { die "Could not load all modules" unless $ok }
6768 use Crypt::Checksum::Adler32;
6869 use Crypt::Checksum::CRC32;
6970
71 diag( "osname = $Config{osname}" );
72 diag( "myarchname = $Config{myarchname}" );
73 diag( "myuname = $Config{myuname}" );
74 diag( "intsize = $Config{intsize}" );
75 diag( "longsize = $Config{longsize}" );
76 diag( "longlongsize = $Config{longlongsize}" );
77 diag( "ptrsize = $Config{ptrsize}" );
78 diag( "byteorder = $Config{byteorder}" );
79 diag( "" );
80 diag( CryptX::_ltc_build_settings );
81 diag( "" );
82 diag( "MP_PROVIDER = " . CryptX::_ltc_mp_name );
83 diag( "MP_DIGIT_BIT = " . CryptX::_ltc_mp_bits_per_digit );
84 diag( "" );
85
7086 ok 1, 'All modules loaded successfully';
7187 $ok = 1;
72
1010 my $pt = "plain_half_12345";
1111 my $ct;
1212
13 my $m1 = Crypt::AuthEnc::OCB->new("AES", $key, "123456789012");
13 my $m1 = Crypt::AuthEnc::OCB->new("AES", $key, "123456789012", 16);
1414 $m1->adata_add("adata-123456789012");
1515 $ct = $m1->encrypt_add($pt);
1616 $ct .= $m1->encrypt_last($pt);
1919 is(unpack('H*', $ct), "4c85b38952e71220ecc323253547ae9b446f5a518717759ef8b0f24d5c4809a6", "enc: ciphertext");
2020 is(unpack('H*', $tag), "bd7a6a0aaf24420f97bf239ea5740a40", "enc: tag");
2121
22 my $d1 = Crypt::AuthEnc::OCB->new("AES", $key, "123456789012");
22 my $d1 = Crypt::AuthEnc::OCB->new("AES", $key, "123456789012", 16);
2323 $d1->adata_add("adata-123456789012");
2424 my $pt2 = $d1->decrypt_last($ct);
2525 my $tag2 = $d1->decrypt_done();
2929 }
3030
3131 {
32 my ($ct, $tag) = ocb_encrypt_authenticate('AES', $key, "123456789012", "", "plain_half_12345plain_half_12345");
32 my ($ct, $tag) = ocb_encrypt_authenticate('AES', $key, "123456789012", "", 16, "plain_half_12345plain_half_12345");
3333 is(unpack('H*', $ct), "4c85b38952e71220ecc323253547ae9b446f5a518717759ef8b0f24d5c4809a6", "ocb_encrypt_authenticate: ciphertext (no header)");
3434 is(unpack('H*', $tag), "dfdfab80aca060268c0cc467040af4f9", "ocb_encrypt_authenticate: tag (no header)");
3535 my $pt = ocb_decrypt_verify('AES', $key, "123456789012", "", $ct, $tag);
3737 }
3838
3939 {
40 my ($ct, $tag) = ocb_encrypt_authenticate('AES', $key, "123456789012", "adata-123456789012", "plain_half_12345plain_half_12345");
40 my ($ct, $tag) = ocb_encrypt_authenticate('AES', $key, "123456789012", "adata-123456789012", 16, "plain_half_12345plain_half_12345");
4141 is(unpack('H*', $ct), "4c85b38952e71220ecc323253547ae9b446f5a518717759ef8b0f24d5c4809a6", "ocb_encrypt_authenticate: ciphertext (no header)");
4242 is(unpack('H*', $tag), "bd7a6a0aaf24420f97bf239ea5740a40", "ocb_encrypt_authenticate: tag (no header)");
4343 my $pt = ocb_decrypt_verify('AES', $key, "123456789012", "adata-123456789012", $ct, $tag);
00 use strict;
11 use warnings;
22
3 use Test::More tests => 48;
3 use Test::More tests => 51;
44 use Crypt::AuthEnc::OCB;
55
66 my $count = 1;
1414
1515 if ($l eq '') {
1616 next unless defined $d->{C};
17 my $K = pack('H*', '000102030405060708090A0B0C0D0E0F');
18 my $N = pack('H*', '000102030405060708090A0B');
1917 my $A = pack('H*', $d->{A});
2018 my $P = pack('H*', $d->{P});
2119 my $C = pack('H*', $d->{C});
20 my $K = pack('H*', $d->{K});
21 my $N = pack('H*', $d->{N});
22 my $tag_len = $d->{T} * 1;
2223
2324 { #ENCRYPT
24 my $m = Crypt::AuthEnc::OCB->new('AES', $K, $N);
25 my $m = Crypt::AuthEnc::OCB->new('AES', $K, $N, $tag_len);
2526 $m->adata_add($A);
2627 my $ct = $m->encrypt_last($P);
2728 my $t = $m->encrypt_done();
2930 }
3031
3132 { #DECRYPT
32 my $m = Crypt::AuthEnc::OCB->new('AES', $K, $N);
33 my $m = Crypt::AuthEnc::OCB->new('AES', $K, $N, $tag_len);
3334 $m->adata_add($A);
34 my $pt = $m->decrypt_last(substr($C,0,-16));
35 my $pt = $m->decrypt_last(substr($C,0,-$tag_len));
3536 my $t = $m->decrypt_done();
3637 is(unpack('H*', $pt), lc($d->{P}), "decrypt/$count/a aad_len=" . length($A) . " pt_len=" . length($P));
37 is(unpack('H*', $t), unpack('H*', substr($C,-16)), "decrypt/$count/b aad_len=" . length($A) . " pt_len=" . length($P));
38 is(unpack('H*', $t), unpack('H*', substr($C,-$tag_len)), "decrypt/$count/b aad_len=" . length($A) . " pt_len=" . length($P));
3839 }
39
40 # $text .= "\t{ /* index:" . ($count-1) . " */\n";
41 # $text .= "\t " . length($P) . ", /* PLAINTEXT length */\n";
42 # $text .= "\t " . length($A) . ", /* AAD length */\n";
43 # $text .= "\t { " . join(',', map { sprintf("0x%02x",unpack('C',$_)) } split(//, $P)) . " }, /* PLAINTEXT */\n";
44 # $text .= "\t { " . join(',', map { sprintf("0x%02x",unpack('C',$_)) } split(//, $A)) . " }, /* AAD */\n";
45 # $text .= "\t { " . join(',', map { sprintf("0x%02x",unpack('C',$_)) } split(//, substr($C,0,-16))) . " }, /* CIPHERTEXT */\n";
46 # $text .= "\t { " . join(',', map { sprintf("0x%02x",unpack('C',$_)) } split(//, substr($C,-16))) . " }, /* TAG */\n";
47 # $text .= "\t},\n";
4840
4941 $d = {};
5042 $count++;
5143 }
5244 else {
5345 my ($k, $v) = split /:/, $l;
46 $v = "" if !defined $v;
47 $v =~ s/\s//g;
5448 $d->{$k} = $v;
5549 }
5650
5953 #print $text;
6054
6155 __DATA__
62 #
63 # test vectors from: http://tools.ietf.org/html/draft-krovetz-ocb-03
64 #
65 # This section gives sample output values for various inputs when using
66 # the AEAD_AES_128_OCB_TAGLEN128 parameters defined in Section 3.1. All
67 # strings are represented in hexadecimal (eg, 0F represents the
68 # bitstring 00001111).
69 #
70 # Each of the following (A,P,C) triples show the ciphertext C that
71 # results from OCB-ENCRYPT(K,N,A,P) when K and N are fixed with the
72 # values
73 #
74 #K : 000102030405060708090A0B0C0D0E0F
75 #N : 000102030405060708090A0B
76 #
77 #An empty entry indicates the empty string.
78
56 T: 16
57 K: 000102030405060708090A0B0C0D0E0F
58 N: BBAA99887766554433221100
7959 A:
8060 P:
81 C:197B9C3C441D3C83EAFB2BEF633B9182
61 C: 785407BFFFC8AD9EDCC5520AC9111EE6
8262
83 A:0001020304050607
84 P:0001020304050607
85 C:92B657130A74B85A16DC76A46D47E1EAD537209E8A96D14E
63 T: 16
64 K: 000102030405060708090A0B0C0D0E0F
65 N: BBAA99887766554433221101
66 A: 0001020304050607
67 P: 0001020304050607
68 C: 6820B3657B6F615A5725BDA0D3B4EB3A257C9AF1F8F03009
8669
87 A:0001020304050607
70 T: 16
71 K: 000102030405060708090A0B0C0D0E0F
72 N: BBAA99887766554433221102
73 A: 0001020304050607
8874 P:
89 C:98B91552C8C009185044E30A6EB2FE21
75 C: 81017F8203F081277152FADE694A0A00
9076
77 T: 16
78 K: 000102030405060708090A0B0C0D0E0F
79 N: BBAA99887766554433221103
9180 A:
92 P:0001020304050607
93 C:92B657130A74B85A971EFFCAE19AD4716F88E87B871FBEED
81 P: 0001020304050607
82 C: 45DD69F8F5AAE72414054CD1F35D82760B2CD00D2F99BFA9
9483
95 A:000102030405060708090A0B0C0D0E0F
96 P:000102030405060708090A0B0C0D0E0F
97 C:BEA5E8798DBE7110031C144DA0B26122776C9924D6723A1FC4524532AC3E5BEB
84 T: 16
85 K: 000102030405060708090A0B0C0D0E0F
86 N: BBAA99887766554433221104
87 A: 000102030405060708090A0B0C0D0E0F
88 P: 000102030405060708090A0B0C0D0E0F
89 C: 571D535B60B277188BE5147170A9A22C3AD7A4FF3835B8C5701C1CCEC8FC3358
9890
99 A:000102030405060708090A0B0C0D0E0F
91 T: 16
92 K: 000102030405060708090A0B0C0D0E0F
93 N: BBAA99887766554433221105
94 A: 000102030405060708090A0B0C0D0E0F
10095 P:
101 C:7DDB8E6CEA6814866212509619B19CC6
96 C: 8CF761B6902EF764462AD86498CA6B97
10297
98 T: 16
99 K: 000102030405060708090A0B0C0D0E0F
100 N: BBAA99887766554433221106
103101 A:
104 P:000102030405060708090A0B0C0D0E0F
105 C:BEA5E8798DBE7110031C144DA0B2612213CC8B747807121A4CBB3E4BD6B456AF
102 P: 000102030405060708090A0B0C0D0E0F
103 C: 5CE88EC2E0692706A915C00AEB8B2396F40E1C743F52436BDF06D8FA1ECA343D
106104
107 A:000102030405060708090A0B0C0D0E0F1011121314151617
108 P:000102030405060708090A0B0C0D0E0F1011121314151617
109 C:BEA5E8798DBE7110031C144DA0B26122FCFCEE7A2A8D4D485FA94FC3F38820F1DC3F3D1FD4E55E1C
105 T: 16
106 K: 000102030405060708090A0B0C0D0E0F
107 N: BBAA99887766554433221107
108 A: 000102030405060708090A0B0C0D0E0F1011121314151617
109 P: 000102030405060708090A0B0C0D0E0F1011121314151617
110 C: 1CA2207308C87C010756104D8840CE1952F09673A448A122C92C62241051F57356D7F3C90BB0E07F
110111
111 A:000102030405060708090A0B0C0D0E0F1011121314151617
112 T: 16
113 K: 000102030405060708090A0B0C0D0E0F
114 N: BBAA99887766554433221108
115 A: 000102030405060708090A0B0C0D0E0F1011121314151617
112116 P:
113 C:282026DA3068BC9FA118681D559F10F6
117 C: 6DC225A071FC1B9F7C69F93B0F1E10DE
114118
119 T: 16
120 K: 000102030405060708090A0B0C0D0E0F
121 N: BBAA99887766554433221109
115122 A:
116 P:000102030405060708090A0B0C0D0E0F1011121314151617
117 C:BEA5E8798DBE7110031C144DA0B26122FCFCEE7A2A8D4D486EF2F52587FDA0ED97DC7EEDE241DF68
123 P: 000102030405060708090A0B0C0D0E0F1011121314151617
124 C: 221BD0DE7FA6FE993ECCD769460A0AF2D6CDED0C395B1C3CE725F32494B9F914D85C0B1EB38357FF
118125
119 A:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
120 P:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
121 C:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CBB2A040DD3BD5164372D76D7BB6824240
126 T: 16
127 K: 000102030405060708090A0B0C0D0E0F
128 N: BBAA9988776655443322110A
129 A: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
130 P: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
131 C: BD6F6C496201C69296C11EFD138A467ABD3C707924B964DEAFFC40319AF5A48540FBBA186C5553C68AD9F592A79A4240
122132
123 A:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
133 T: 16
134 K: 000102030405060708090A0B0C0D0E0F
135 N: BBAA9988776655443322110B
136 A: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
124137 P:
125 C:E1E072633BADE51A60E85951D9C42A1B
138 C: FE80690BEE8A485D11F32965BC9D2A32
126139
140 T: 16
141 K: 000102030405060708090A0B0C0D0E0F
142 N: BBAA9988776655443322110C
127143 A:
128 P:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
129 C:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB4A3BAE824465CFDAF8C41FC50C7DF9D9
144 P: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
145 C: 2942BFC773BDA23CABC6ACFD9BFD5835BD300F0973792EF46040C53F1432BCDFB5E1DDE3BC18A5F840B52E653444D5DF
130146
131 A:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
132 P:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
133 C:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB68C65778B058A635659C623211DEEA0DE30D2C381879F4C8
147 T: 16
148 K: 000102030405060708090A0B0C0D0E0F
149 N: BBAA9988776655443322110D
150 A: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
151 P: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
152 C: D5CA91748410C1751FF8A2F618255B68A0A12E093FF454606E59F9C1D0DDC54B65E8628E568BAD7AED07BA06A4A69483A7035490C5769E60
134153
135 A:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
154 T: 16
155 K: 000102030405060708090A0B0C0D0E0F
156 N: BBAA9988776655443322110E
157 A: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
136158 P:
137 C:7AEB7A69A1687DD082CA27B0D9A37096
159 C: C5CD9D1850C141E358649994EE701B68
138160
161 T: 16
162 K: 000102030405060708090A0B0C0D0E0F
163 N: BBAA9988776655443322110F
139164 A:
140 P:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
141 C:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB68C65778B058A635060C8467F4ABAB5E8B3C2067A2E115DC
165 P: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
166 C: 4412923493C57D5DE0D700F753CCE0D1D2D95060122E9F15A5DDBFC5787E50B5CC55EE507BCB084E479AD363AC366B95A98CA5F3000B1479
167
168 T: 12
169 K: 0F0E0D0C0B0A09080706050403020100
170 N: BBAA9988776655443322110D
171 A: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
172 P: 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627
173 C: 1792A4E31E0755FB03E31B22116E6C2DDF9EFD6E33D536F1A0124B0A55BAE884ED93481529C76B6AD0C515F4D1CDD4FDAC4F02AA
142174
143175 LAST_ITEM_PLACEHOLDER_DO_NOT_DELETE!!!
00 use strict;
11 use warnings;
2 use Test::More tests => 41;
2 use Test::More tests => 679;
33
4 use Crypt::Misc qw(encode_b64 decode_b64 encode_b64u decode_b64u pem_to_der der_to_pem read_rawfile write_rawfile slow_eq is_v4uuid random_v4uuid);
4 use Crypt::Misc qw( encode_b64 decode_b64
5 encode_b64u decode_b64u
6 encode_b58b decode_b58b
7 encode_b58f decode_b58f
8 encode_b58r decode_b58r
9 encode_b58t decode_b58t
10 encode_b58s decode_b58s
11 encode_b32r decode_b32r
12 encode_b32b decode_b32b
13 encode_b32z decode_b32z
14 encode_b32c decode_b32c
15 pem_to_der der_to_pem
16 read_rawfile write_rawfile
17 slow_eq is_v4uuid random_v4uuid
18 increment_octets_be increment_octets_le
19 );
520
621 is(encode_b64(pack("H*","702fad4215a04a657f011d3ea5711879c696788c91d2")), "cC+tQhWgSmV/AR0+pXEYecaWeIyR0g==", "encode_b64");
722 is(unpack("H*", decode_b64("cC+tQhWgSmV/AR0+pXEYecaWeIyR0g==")), "702fad4215a04a657f011d3ea5711879c696788c91d2", "decode_b64");
5368 ok($uuid, 'random_v4uuid');
5469 ok(is_v4uuid($uuid), 'is_v4uuid');
5570
71 my @hex = (qw/fb
72 9534
73 93e5de
74 ac143db0
75 bd82426d56
76 d0cd21a99345
77 95df02e1c24160
78 390b1835d5845413
79 e9a141e7ae08ab7684
80 12e8c059cb511d10fabc
81 5bfe0e44cd99e982da61dd
82 990417ce7f929341e01e88c4
83 99cbc040b3e8629c8854615134
84 be294ddb946fdfbce7e70abe7c7c
85 92031ecbb3aa0a7e34479b1bf7b57c
86 a50e6f53a4fd2cf52d443fe815f17b90
87 39d41e163cf2f2be61d0b18d13508a158f
88 792a745c10c0abb3de5f73bdb32a901456ce
89 4897c2083c3952a778c08fe234859cbc06fa6a
90 b3a79f01ecc9a11c703de44dbfb7b9bb7f230de9
91 eba9fa4f4908f74bd0dda6adea37413dcd29a9b623
92 619eb868071f31e2c604de3752a8cc7706d156d7deb3
93 055489debeb244419a587e7f59c42ffa49dbfe537b5c10
94 16c945707cb0421c8adc7d300564b98192a0d15a796f293a
95 c89c8664e43f792bd6348a1ad079ad45dfc02e617597186084
96 2496818ec6f81fcf225c8c73dce933f5322faf41a40c6b4df1c6
97 4d63b1afb4077a1939d46d2b3e5a82637fbef9e87ff72fb1d8d2e7
98 5cba279be0d5cf4bedf92d700fdc6acbe601d454a39e10c666b7017e
99 c2f2c48f4c4ae9bfa7203d2667c54d1af2d6031d2c8c3639afd172d06b
100 303e72e0f19ce9195594ec1c849183a74caf6381c73a41a809f0e1a8c90e
101 36589f8310f0f366327b4565180698e20f41aeee8338e14d98bde4671316c7
102 b3291646007104bb06d9f12f806abde0b4ce137fc5a9f895d4a847161f563b0f
103 01a4afec2458d3403de9631e7c70b418465c6fdaf48bec167ae39045ed518fdf1f
104 9a8205871065078385dec5beeeebff48ff2f85a191438979dc1bf06dfdc09ef4c3d0
105 16bccfed44ddd4b8fae8b84d411744d35becb9ff6e893805cab9e93464c301bdb63128
106 f80358a25a8ba8d071c4734ef0fd8349bde4f0ebb0e7a3f8bfef8ced5027f041dc77cbee
107 6cbdffd01cf7901cca8426406397fac12f5738ac121161a2ae31958ba69706065fb21e9fd2
108 00
109 0000
110 000000
111 00000000
112 0000000000
113 ff
114 ffff
115 ffffff
116 ffffffff
117 ffffffffff
118 00fa
119 00003d
120 000079ec
121 0000a21acb
122 0000538487a3
123 00003e7f8143b5
124 0000161c1c88c3a9
125 0000317cf0558dd0df
126 00007292d21fc70db6e1
127 000057bfcd39753080702a
128 0000e0e553536a659155bf1b
129 /);
130
131 for my $h (@hex) {
132 my $b = pack("H*", $h);
133 is(unpack("H*", decode_b64 (encode_b64 ($b))), $h);
134 is(unpack("H*", decode_b64u(encode_b64u($b))), $h);
135 is(unpack("H*", decode_b58b(encode_b58b($b))), $h);
136 is(unpack("H*", decode_b58f(encode_b58f($b))), $h);
137 is(unpack("H*", decode_b58r(encode_b58r($b))), $h);
138 is(unpack("H*", decode_b58t(encode_b58t($b))), $h);
139 is(unpack("H*", decode_b58s(encode_b58s($b))), $h);
140 is(unpack("H*", decode_b32r(encode_b32r($b))), $h);
141 is(unpack("H*", decode_b32b(encode_b32b($b))), $h);
142 is(unpack("H*", decode_b32z(encode_b32z($b))), $h);
143 is(unpack("H*", decode_b32c(encode_b32c($b))), $h);
144 }
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 -----BEGIN CERTIFICATE-----
1 MIIC8zCCAdugAwIBAgIJAPi+LvMU3uGWMA0GCSqGSIb3DQEBCwUAMBAxDjAMBgNV
2 BAMMBXBva3VzMB4XDTE3MDcxNDE0MTAyMFoXDTIwMDQwOTE0MTAyMFowEDEOMAwG
3 A1UEAwwFcG9rdXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCQima
4 SUIMIdz5uVevzcScbcj06xs1OLaFKUoPJ8v+xP6Ut61BQhAvc8GYuw2uRx223hZC
5 r3HYLfSdWIfmOIAtlL8cPYPVoSivJtpSGE6fBG1tlBjVgXWRmJGR/oxx6Y5QDwcB
6 Q4GZKga8TtHQoY5idZuatYOFZGfMIcIUC0Uoda+YSypnw7A90F/JvlpcTUh3Fnem
7 VinqEA6XOegU9dCZk/29sXqauBjbdGihh8DvpklOhY16eQoiR3909AywQ0KUmI+R
8 Sa9E8oIsmUDetFuXEvana+sD3y42tU+cd2nhBPRETbSXPcum0B3uF4yKgweuJy5D
9 cvtVQIFVkkh4+AWNAgMBAAGjUDBOMB0GA1UdDgQWBBSS6V5PVGyN92NoB0AVLcOb
10 pzR3SzAfBgNVHSMEGDAWgBSS6V5PVGyN92NoB0AVLcObpzR3SzAMBgNVHRMEBTAD
11 AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBIszrBjoJ39axsS6Btbvwvo8vAmgiSWsav
12 7AmjXOAwknHPaCcDmrdOys5POD0DNRwNeRsnxFiZ/UL8Vmj2JGDLgAw+/v32MwfX
13 Ig7m+oIbO8KqDzlYvS5kd3suJ5C21hHy1/JUtfofZLovZH7ZRzhTAoRvCYaodW90
14 2o8ZqmyCdcXPzjFmoJ2xYzs/Sf8/E1cHfb+4HjOpeRnKxDvG0gwWzcsXpUrw2pNO
15 Oztj6Rd0THNrf/anIeYVtAHX4aqZA8Kbv2TyJd+9g78usFw1cn+8vfmilm6Pn0DQ
16 a+I5GyGd7BJI8wYuWqIStzvrJHbQQaNrSk7hgjWYiYlcsPh6w2QP
17 -----END CERTIFICATE-----
00 use strict;
11 use warnings;
2 use Test::More tests => 74;
3
4 use Crypt::PK::DH qw(dh_encrypt dh_decrypt dh_sign_message dh_verify_message dh_sign_hash dh_verify_hash dh_shared_secret);
2 use Test::More tests => 60;
3
4 use Crypt::Misc 'decode_b64';
5 use Crypt::PK::DH qw(dh_shared_secret);
56
67 {
78 my $k;
1011 ok($k, 'load cryptx_priv_dh1.bin');
1112 ok($k->is_private, 'is_private cryptx_priv_dh1.bin');
1213 is($k->size, 256, 'size');
13 is(uc($k->key2hash->{x}), 'FBC1062F73B9A17BB8473A2F5A074911FA7F20D28FBF5D7F4DAF58016CE03A391BA57CB80067EB2D59AD1AA66869F5F37A1B57D440428F67881085F7C1484FADC3A54E39703CE679068417269651DD3438EDBF7827A09419F88A326B76EF04D81145D87D7D2DCF1B24902202B971BBF2EEF956A1EA1A88770097B94C859AE4F06DDDEB9ED31084004815F97D4F6F74C791CF1EC1836013DF835B653E8704981D52FF2323F7AFE22915B82CBA7EBF0558ACA6A182A6F3D631B843B72137D4E5B07603A7517F6768B375FC6C38F7B767C63E5A3DD99CD9EA0992C236EB827EAD4E877430F260020E64CBA26DAA8DEEF5D216C11941C48F76FE2B097BB5D504FBCF', 'key2hash');
14 is(uc($k->key2hash->{x}), '73CA6A11B1595C06AB08E8E0875B9689E265C29E3F52FBC7830F071AEA4AF5A26D23CFBC96101267', 'key2hash');
1415
1516 $k = Crypt::PK::DH->new('t/data/cryptx_priv_dh2.bin');
1617 ok($k, 'load cryptx_priv_dh2.bin');
3233 ok($k, 'load cryptx_priv_dh_pg1.bin');
3334 ok($k->is_private, 'is_private cryptx_priv_dh_pg1.bin');
3435 is($k->size, 256, 'size');
35 is(uc($k->key2hash->{x}), '29BB37065071D1C23AE0D8C555E24E5E546954B985260ECC6A1A21252FCFD2D633B0580F6A00B80ED75123EC37A3E784F888EE026C1034CD930CA58464EB6A59A090D1113855AFA48C9A79631E2534D7F33FAD4DC8FF48E88C865E517B67DAD4B40D64BD67CBFE52F56FBC6764D0629E5EFF63351AF19FF398375BDCE22FBDF3A044DAB2B6EAAA44D1A78F4FF74088175E6B5F184222F116F4C6188547F90B0ADCA3255EA7148CB57E5E852E79F438F995CFC3AC79A01D2C329C0750D55FDADCC6FAF6D6850892EEC073FD77CC7F98D8D317D402E2A89E4161001DAEF43DAC0F386E48870D457FB12CC5B70E6F5719609631CB8B439DB6D2F04CF8A774678F68', 'key2hash');
36 is(uc($k->key2hash->{x}), '3E2F764CDAD2EDFEC737E2198C9C4FAFBA4274C8A73A9E2FDCBC11954D8B48C375399E4BDE930EC9', 'key2hash');
3637
3738 $k = Crypt::PK::DH->new('t/data/cryptx_priv_dh_pg2.bin');
3839 ok($k, 'load cryptx_priv_dh_pg2.bin');
5253 $pr1->import_key('t/data/cryptx_priv_dh1.bin');
5354 my $pu1 = Crypt::PK::DH->new;
5455 $pu1->import_key('t/data/cryptx_pub_dh1.bin');
55
56 my $ct = $pu1->encrypt("secret message");
57 my $pt = $pr1->decrypt($ct);
58 ok(length $ct > 100, 'encrypt ' . length($ct));
59 is($pt, "secret message", 'decrypt');
60
61 my $sig = $pr1->sign_message("message");
62 ok(length $sig > 60, 'sign_message ' . length($sig));
63 ok($pu1->verify_message($sig, "message"), 'verify_message');
64
65 my $hash = pack("H*","04624fae618e9ad0c5e479f62e1420c71fff34dd");
66 $sig = $pr1->sign_hash($hash, 'SHA1');
67 ok(length $sig > 60, 'sign_hash ' . length($sig));
68 ok($pu1->verify_hash($sig, $hash, 'SHA1'), 'verify_hash');
69
56
7057 my $pr2 = Crypt::PK::DH->new;
7158 $pr2->import_key('t/data/cryptx_priv_dh2.bin');
7259 my $pu2 = Crypt::PK::DH->new;
8269 $pr1->import_key('t/data/cryptx_priv_dh_pg1.bin');
8370 my $pu1 = Crypt::PK::DH->new;
8471 $pu1->import_key('t/data/cryptx_pub_dh_pg1.bin');
85
86 my $ct = $pu1->encrypt("secret message");
87 my $pt = $pr1->decrypt($ct);
88 ok(length $ct > 100, 'encrypt ' . length($ct));
89 is($pt, "secret message", 'decrypt');
90
91 my $sig = $pr1->sign_message("message");
92 ok(length $sig > 60, 'sign_message ' . length($sig));
93 ok($pu1->verify_message($sig, "message"), 'verify_message');
94
95 my $hash = pack("H*","04624fae618e9ad0c5e479f62e1420c71fff34dd");
96 $sig = $pr1->sign_hash($hash, 'SHA1');
97 ok(length $sig > 60, 'sign_hash ' . length($sig));
98 ok($pu1->verify_hash($sig, $hash, 'SHA1'), 'verify_hash');
9972
10073 my $pr2 = Crypt::PK::DH->new;
10174 $pr2->import_key('t/data/cryptx_priv_dh_pg2.bin');
12093 is(uc(unpack('H*',$pr1->export_key_raw('public'))),'4B9ECB56202EDBC6578072A4519EBE625DE8972877462240F62393C59A6C04AA159E56505156E7DF645FF6EC588E0778A96B78B26A0793D90A4B5C5EC4C61EA69D21C630843ACC2BFD3864CD9DA9600BA8F1B7D8542B01F7251AA3AC257C7AC65A1D2BCF51A8E3E67D9544599B0956710E2B052CDA9B565CDD121CC123364B480E9E7E2237D3D6B5B1E200C7BF858C54CCD3175736DB28336210A16F8F0ACEC08847EF7905FAB7E97E626CFD13CBDF167441FEEB72CB6E7407DFC59F03249F79312A94DA89B1D61196B41E90C08D2C801FD7BEA02A47A1CDA1581F57BA700C1BCDDE6338718E19079055194CAF176D85464957D405B04CC3DD9756C211E11BF2');
12194 is(uc(unpack('H*',$pu1->export_key_raw('public'))),'4B9ECB56202EDBC6578072A4519EBE625DE8972877462240F62393C59A6C04AA159E56505156E7DF645FF6EC588E0778A96B78B26A0793D90A4B5C5EC4C61EA69D21C630843ACC2BFD3864CD9DA9600BA8F1B7D8542B01F7251AA3AC257C7AC65A1D2BCF51A8E3E67D9544599B0956710E2B052CDA9B565CDD121CC123364B480E9E7E2237D3D6B5B1E200C7BF858C54CCD3175736DB28336210A16F8F0ACEC08847EF7905FAB7E97E626CFD13CBDF167441FEEB72CB6E7407DFC59F03249F79312A94DA89B1D61196B41E90C08D2C801FD7BEA02A47A1CDA1581F57BA700C1BCDDE6338718E19079055194CAF176D85464957D405B04CC3DD9756C211E11BF2');
12295
123 my $ct = $pu1->encrypt("secret message");
124 my $pt = $pr1->decrypt($ct);
125 ok(length $ct > 100, 'encrypt ' . length($ct));
126 is($pt, "secret message", 'decrypt');
127
128 my $sig = $pr1->sign_message("message");
129 ok(length $sig > 60, 'sign_message ' . length($sig));
130 ok($pu1->verify_message($sig, "message"), 'verify_message');
131
132 my $hash = pack("H*","04624fae618e9ad0c5e479f62e1420c71fff34dd");
133 $sig = $pr1->sign_hash($hash, 'SHA1');
134 ok(length $sig > 60, 'sign_hash ' . length($sig));
135 ok($pu1->verify_hash($sig, $hash, 'SHA1'), 'verify_hash');
136
137 my $pr2 = Crypt::PK::DH->new;
96 my $pr2 = Crypt::PK::DH->new;
13897 $pr2->import_key_raw(pack('H*','473156C909EBB0A6F61F707CDDD7E6401BFDE22BC57B8D3CCC30C4CD3FF7678CCD9B022167AA774786F367FE5B5924A3C1E09AA71264F94E7ABA87FFA888913BB9592613F8AD87FBE82E99064B00CE3294CFD410BCFB4C88A46F5F8532633458C317DF40F395C2F08A822D84BF4291A1A63DE1F6D0F460DB81C685ADD0F26262307823227C17B4671BCF74A6337738BB4596337644656A060F1BB109640878D23F56E493719D6EF60FEA7AC85123CFB6E476392789AC1FE4F4CA371DB2863192ADE424F3EFDEE52D4CB445B99B10566A4B6F6DC813C265DC0052D710AEAA0969392BD478A46AB9C7A0E2FA27964A759938904FCEFAC4CE061C9927764AAB57DC'),'private','ike2048');
13998 my $pu2 = Crypt::PK::DH->new;
14099 $pu2->import_key_raw(pack('H*','774A01FF19C1603040DFBB5C8A44F11CE8719F757C2AF6B2921EDDDEF27F77D5F2DAF9539BCBCB30F80D76E054C489C9E6533051767E6220539C871F23D3B6F80D84037A6FBAB3AE6AF8F214A60A816D6F0F6C3F31801DCD6EA771F41A2A5618BC333D650F46F22FEA81A94F4E00CD05B83F8FE257A2607E62519D9BF8B8C96D0587FB2BCEC8D18DDCF66EBBB8A56623953531EE27C68C8C37E6413FD2C98339F491A0472E5D4DFADC7BF30E89A2CE2081EE3CF9F9B0FFCD902A3021CAC14A4AD7E00F6202C8A9AB93BF96E33838FB9178DC8A8F995ABD81F28F5A137A78E813ABD185498A3A50CB3021CF58BE9D0200C19928AA097D306ABAD9874E0F217482'),'public','ike2048');
146105
147106 {
148107 my $k = Crypt::PK::DH->new;
108 my $p = <<"MARKER";
109 -----BEGIN DH PARAMETERS-----
110 MIIBCAKCAQEA7DIdWuBlIVFTnN9t9SP5tjajNgmQtBuhRlBQJIaHxblApAP9XZgS
111 iuAdkZugjvYb83bFzrjdo+TyKCUKZwVp8pv8LHEG90K54BsZwlbyjHHVlWFcQPIh
112 XYMg7YKEVcOPg0ZRty55g2u6IMMlMl16WWubHvtAeI0qVU7VUA6vuy7qAOauaZWo
113 0klH0zGkc8s1NGectcNbk8GmlUop+7JLUh3K0ikHVPYx2OJHjBhTz2vPgTdlcbHb
114 +dQIMdLFBOySNKv141QsDBo1ugu0Cxx02We6FFp1k5k4le+yGhFtLotE4OlZtcZW
115 xyjO1D0DrX8p6PeI4OmMAeGgGmDNBGreywIBAg==
116 -----END DH PARAMETERS-----
117 MARKER
118 $k->generate_key(\$p);
119 ok($k, 'generate_key PEM');
120 ok($k->is_private, 'is_private');
121 ok($k->export_key('private'), 'export_key_pem pri');
122 ok($k->export_key('public'), 'export_key_pem pub');
123 }
124
125 {
126 my $k = Crypt::PK::DH->new;
127 my $p = decode_b64(<<"MARKER");
128 MIIBCAKCAQEA7DIdWuBlIVFTnN9t9SP5tjajNgmQtBuhRlBQJIaHxblApAP9XZgS
129 iuAdkZugjvYb83bFzrjdo+TyKCUKZwVp8pv8LHEG90K54BsZwlbyjHHVlWFcQPIh
130 XYMg7YKEVcOPg0ZRty55g2u6IMMlMl16WWubHvtAeI0qVU7VUA6vuy7qAOauaZWo
131 0klH0zGkc8s1NGectcNbk8GmlUop+7JLUh3K0ikHVPYx2OJHjBhTz2vPgTdlcbHb
132 +dQIMdLFBOySNKv141QsDBo1ugu0Cxx02We6FFp1k5k4le+yGhFtLotE4OlZtcZW
133 xyjO1D0DrX8p6PeI4OmMAeGgGmDNBGreywIBAg==
134 MARKER
135 $k->generate_key(\$p);
136 ok($k, 'generate_key DER');
137 ok($k->is_private, 'is_private');
138 ok($k->export_key('private'), 'export_key_pem pri');
139 ok($k->export_key('public'), 'export_key_pem pub');
140 }
141
142 {
143 my $k = Crypt::PK::DH->new;
144 $k->generate_key({
145 g=>"0x2",
146 p=>"0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1".
147 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD".
148 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245".
149 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED".
150 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D".
151 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F".
152 "83655D23DCA3AD961C62F356208552BB9ED529077096966D".
153 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B".
154 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9".
155 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510".
156 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64".
157 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7".
158 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B".
159 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C".
160 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31".
161 "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
162 });
163 ok($k, 'generate_key HASH');
164 ok($k->is_private, 'is_private');
165 ok($k->export_key('private'), 'export_key_pem pri');
166 ok($k->export_key('public'), 'export_key_pem pub');
167 }
168
169 {
170 my $k = Crypt::PK::DH->new;
171 $k->generate_key('ike2048');
172 ok($k, 'generate_key groupname');
173 ok($k->is_private, 'is_private');
174 ok($k->export_key('private'), 'export_key_pem pri');
175 ok($k->export_key('public'), 'export_key_pem pub');
176 }
177
178 {
179 my $k = Crypt::PK::DH->new;
149180 $k->generate_key(256);
150 ok($k, 'generate_key');
181 ok($k, 'generate_key groupsize');
151182 ok($k->is_private, 'is_private');
152183 ok($k->export_key('private'), 'export_key_pem pri');
153184 ok($k->export_key('public'), 'export_key_pem pub');
172203 }
173204
174205 {
175 my $ct = dh_encrypt('t/data/cryptx_pub_dh1.bin', 'test string');
176 ok($ct, 'dh_encrypt');
177 my $pt = dh_decrypt('t/data/cryptx_priv_dh1.bin', $ct);
178 ok($pt, 'dh_decrypt');
179 my $sig = dh_sign_message('t/data/cryptx_priv_dh1.bin', 'test string');
180 ok($sig, 'dh_sign_message');
181 ok(dh_verify_message('t/data/cryptx_pub_dh1.bin', $sig, 'test string'), 'dh_verify_message');
182 my $hash = pack("H*","04624fae618e9ad0c5e479f62e1420c71fff34dd");
183 $sig = dh_sign_hash('t/data/cryptx_priv_dh1.bin', $hash, 'SHA1');
184 ok($sig, 'dh_sign_hash');
185 ok(dh_verify_hash('t/data/cryptx_pub_dh1.bin', $sig, $hash, 'SHA1'), 'dh_verify_hash');
186
187206 my $ss1 = dh_shared_secret('t/data/cryptx_priv_dh1.bin', 't/data/cryptx_pub_dh2.bin');
188207 my $ss2 = dh_shared_secret('t/data/cryptx_priv_dh2.bin', 't/data/cryptx_pub_dh1.bin');
189208 is(unpack("H*",$ss1), unpack("H*",$ss2), 'shared_secret');
190209 }
191210
192211 {
193 my $ct = dh_encrypt('t/data/cryptx_pub_dh_pg1.bin', 'test string');
194 ok($ct, 'dh_encrypt');
195 my $pt = dh_decrypt('t/data/cryptx_priv_dh_pg1.bin', $ct);
196 ok($pt, 'dh_decrypt');
197 my $sig = dh_sign_message('t/data/cryptx_priv_dh_pg1.bin', 'test string');
198 ok($sig, 'dh_sign_message');
199 ok(dh_verify_message('t/data/cryptx_pub_dh_pg1.bin', $sig, 'test string'), 'dh_verify_message');
200 my $hash = pack("H*","04624fae618e9ad0c5e479f62e1420c71fff34dd");
201 $sig = dh_sign_hash('t/data/cryptx_priv_dh_pg1.bin', $hash, 'SHA1');
202 ok($sig, 'dh_sign_hash');
203 ok(dh_verify_hash('t/data/cryptx_pub_dh_pg1.bin', $sig, $hash, 'SHA1'), 'dh_verify_hash');
204
205212 my $ss1 = dh_shared_secret('t/data/cryptx_priv_dh_pg1.bin', 't/data/cryptx_pub_dh_pg2.bin');
206213 my $ss2 = dh_shared_secret('t/data/cryptx_priv_dh_pg2.bin', 't/data/cryptx_pub_dh_pg1.bin');
207214 is(unpack("H*",$ss1), unpack("H*",$ss2), 'shared_secret');
00 use strict;
11 use warnings;
2 use Test::More tests => 44;
2 use Test::More tests => 62;
33
44 use Crypt::PK::DSA qw(dsa_encrypt dsa_decrypt dsa_sign_message dsa_verify_message dsa_sign_hash dsa_verify_hash);
5 use Crypt::Misc 'decode_b64';
56
67 {
78 my $k;
8990
9091 {
9192 my $k = Crypt::PK::DSA->new;
93 $k->generate_key(\<<"MARKER");
94 -----BEGIN DSA PARAMETERS-----
95 MIICLAKCAQEA3dZSaDnP5LgH44CDYc2wfGLtq4rbBgtOVvLkvh4j29CTiOUDRC1H
96 ivkTdtGrI3DdrAFeKieFYDJ1RJFbru+8/RYE7YfaR5Y3OUI4Vdf26guMViLLVjSL
97 W43Td50ZZziLmmYzn3cliokShe9f5/mtuLJ0uJRq7QxgHj7bgmvJvORvi4QXSCOn
98 nmCOgEfhoU1Vj/PePjtjeZWbLyGFXHC7vpvqePrsFtbUlBzIr2mr7JuHB3rAl7A4
99 1VL6lexqONRa4rQuVxiX0vp3iit9Cx02EwrZODdlifssd9Kceu2UsvifjmCBPyv8
100 6nmmEOtxh/xduuOBtVWXeZHSwIDUQvSJFwIhAK/ZDSl9iNuZ/TRwqQ3JRU3MjXCU
101 /US6/LU1qqjQATk7AoIBACoqauphNZmUZYOilArBfYCMtUwS0FNG6wfUMWDMd46z
102 /hv7equa9b75sT1uHyiUVuPD2hRhR3xNYkKSX9Kx8NGKj/bGDyaEW+Ud852N6BTo
103 9vzZ4GjKVBGe44Wa8eynVgVE5/r0z6OfHkV7uOxlGEdYgIooUbIsY7w0DmaR2FVZ
104 AMjGMg+L6CpulfvdETYi9LQafY4jRkgGWTc9h/2RYGhQUti1PheY1AlDYpubO8am
105 ZBG6vMBaANLx6Pv+lle4ltVvDVhwTK5APyfN1vVdEvVmU1/6zHZEnuiDAT8XI1rH
106 S1+SGX11RIn6uPVL1c0RjgW8/JZ6EeM8NvLdBiYYBuI=
107 -----END DSA PARAMETERS-----
108 MARKER
109 ok($k, 'generate_key PEM');
110 ok($k->is_private, 'is_private');
111 ok($k->export_key_pem('private'), 'export_key_pem pri');
112 ok($k->export_key_pem('public'), 'export_key_pem pub');
113 ok($k->export_key_der('private'), 'export_key_der pri');
114 ok($k->export_key_der('public'), 'export_key_der pub');
115 }
116
117 {
118 my $k = Crypt::PK::DSA->new;
119 $k->generate_key(\decode_b64(<<"MARKER"));
120 MIICLAKCAQEA3dZSaDnP5LgH44CDYc2wfGLtq4rbBgtOVvLkvh4j29CTiOUDRC1H
121 ivkTdtGrI3DdrAFeKieFYDJ1RJFbru+8/RYE7YfaR5Y3OUI4Vdf26guMViLLVjSL
122 W43Td50ZZziLmmYzn3cliokShe9f5/mtuLJ0uJRq7QxgHj7bgmvJvORvi4QXSCOn
123 nmCOgEfhoU1Vj/PePjtjeZWbLyGFXHC7vpvqePrsFtbUlBzIr2mr7JuHB3rAl7A4
124 1VL6lexqONRa4rQuVxiX0vp3iit9Cx02EwrZODdlifssd9Kceu2UsvifjmCBPyv8
125 6nmmEOtxh/xduuOBtVWXeZHSwIDUQvSJFwIhAK/ZDSl9iNuZ/TRwqQ3JRU3MjXCU
126 /US6/LU1qqjQATk7AoIBACoqauphNZmUZYOilArBfYCMtUwS0FNG6wfUMWDMd46z
127 /hv7equa9b75sT1uHyiUVuPD2hRhR3xNYkKSX9Kx8NGKj/bGDyaEW+Ud852N6BTo
128 9vzZ4GjKVBGe44Wa8eynVgVE5/r0z6OfHkV7uOxlGEdYgIooUbIsY7w0DmaR2FVZ
129 AMjGMg+L6CpulfvdETYi9LQafY4jRkgGWTc9h/2RYGhQUti1PheY1AlDYpubO8am
130 ZBG6vMBaANLx6Pv+lle4ltVvDVhwTK5APyfN1vVdEvVmU1/6zHZEnuiDAT8XI1rH
131 S1+SGX11RIn6uPVL1c0RjgW8/JZ6EeM8NvLdBiYYBuI=
132 MARKER
133 ok($k, 'generate_key DER');
134 ok($k->is_private, 'is_private');
135 ok($k->export_key_pem('private'), 'export_key_pem pri');
136 ok($k->export_key_pem('public'), 'export_key_pem pub');
137 ok($k->export_key_der('private'), 'export_key_der pri');
138 ok($k->export_key_der('public'), 'export_key_der pub');
139 }
140
141 {
142 my $k = Crypt::PK::DSA->new;
143 $k->generate_key({
144 p => "A5903F7DF15D5C0769797820".
145 "6CFEED0113CD1C15298198E9".
146 "1F2231135A7BC42568BE8F8D".
147 "357B7EE9AD4E99F9F628EA2C".
148 "9294425FA1C7732253D478CD".
149 "1E242FA81B12C2A9ADB46D14".
150 "AC83875A2D8BF6A1DCF57EC6".
151 "4668DB3751358EB4F5A620A9".
152 "0F28C3D5F62DC1E85E3CC724".
153 "A12018B038FFA4B917AABC66".
154 "543BDD11784134CB",
155 q => "B3CA2D8B0823160915E6B73E".
156 "DD3B0015DFE1E897",
157 g => "5C9F25D69C86E8002BE04F56".
158 "90230BD008A816E7C8E9A96E".
159 "C0DBC630C62A8B42E41C8504".
160 "E682F52C02CDA74740CFA1A4".
161 "A608B8D827C5762EB69FED68".
162 "3D17DBC9050C16DEB9EC5A3E".
163 "02DF7B0E338AFFC01F878352".
164 "A2C82FB458F95DD60A7E23FE".
165 "322173F34F98452B0D16DCE2".
166 "23B15840F82B6AFCDFC6D848".
167 "9C5859DA0E4BE8B9",
168 });
169 ok($k, 'generate_key HASH');
170 ok($k->is_private, 'is_private');
171 ok($k->export_key_pem('private'), 'export_key_pem pri');
172 ok($k->export_key_pem('public'), 'export_key_pem pub');
173 ok($k->export_key_der('private'), 'export_key_der pri');
174 ok($k->export_key_der('public'), 'export_key_der pub');
175 }
176
177 {
178 my $k = Crypt::PK::DSA->new;
92179 $k->generate_key(20, 128);
93 ok($k, 'generate_key');
180 ok($k, 'generate_key size');
94181 ok($k->is_private, 'is_private');
95182 ok($k->export_key_pem('private'), 'export_key_pem pri');
96183 ok($k->export_key_pem('public'), 'export_key_pem pub');
22 use Test::More tests => 121;
33
44 use Crypt::PK::ECC qw(ecc_encrypt ecc_decrypt ecc_sign_message ecc_verify_message ecc_sign_hash ecc_verify_hash ecc_shared_secret);
5
6 sub read_file {
7 my ($file) = @_;
8 return unless $file;
9 if (open(my $fh, "<", $file)) {
10 local $/;
11 binmode($fh);
12 my $content = <$fh>;
13 close($fh);
14 return $content;
15 }
16 }
5 use Crypt::Misc qw(read_rawfile);
176
187 {
198 my ($k, $k2);
6958
7059 for (qw( cryptx_pub_ecc1.der cryptx_pub_ecc1.pem cryptx_pub_ecc2.der cryptx_pub_ecc2.pem )) {
7160 $k = Crypt::PK::ECC->new("t/data/$_");
72 is($k->export_key_der('public'), read_file("t/data/$_"), 'export_key_der public') if (substr($_, -3) eq "der");
73 is($k->export_key_pem('public'), read_file("t/data/$_"), 'export_key_pem public') if (substr($_, -3) eq "pem");
61 is($k->export_key_der('public'), read_rawfile("t/data/$_"), 'export_key_der public') if (substr($_, -3) eq "der");
62 is($k->export_key_pem('public'), read_rawfile("t/data/$_"), 'export_key_pem public') if (substr($_, -3) eq "pem");
7463 }
7564
7665 for (qw( cryptx_priv_ecc1.der cryptx_priv_ecc1.pem cryptx_priv_ecc2.der cryptx_priv_ecc2.pem )) {
7766 $k = Crypt::PK::ECC->new("t/data/$_");
78 is($k->export_key_der('private'), read_file("t/data/$_"), 'export_key_der private') if (substr($_, -3) eq "der");
79 is($k->export_key_pem('private'), read_file("t/data/$_"), 'export_key_pem private') if (substr($_, -3) eq "pem");
67 is($k->export_key_der('private'), read_rawfile("t/data/$_"), 'export_key_der private') if (substr($_, -3) eq "der");
68 is($k->export_key_pem('private'), read_rawfile("t/data/$_"), 'export_key_pem private') if (substr($_, -3) eq "pem");
8069 }
8170
8271 for (qw( openssl_ec1.pub.pem openssl_ec1.pub.der openssl_ec1.pubc.der openssl_ec1.pubc.pem
167156 is(uc($k->key2hash->{pub_x}), 'A01532A3C0900053DE60FBEFEFCCA58793301598D308B41E6F4E364E388C2711', "key2hash $priv");
168157 is(uc($k->curve2hash->{prime}), 'FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF', "curve2hash $priv");
169158 is($k->key2hash->{curve_name}, "secp256r1", "EC curve_name is lowercase");
170 is($k->export_key_der('private_short'), read_file($f), 'export_key_der private_oid') if (substr($priv, -3) eq "der");
171 is($k->export_key_pem('private_short'), read_file($f), 'export_key_pem private_oid') if (substr($priv, -3) eq "pem");
159 is($k->export_key_der('private_short'), read_rawfile($f), 'export_key_der private_oid') if (substr($priv, -3) eq "der");
160 is($k->export_key_pem('private_short'), read_rawfile($f), 'export_key_pem private_oid') if (substr($priv, -3) eq "pem");
172161 }
173162
174163 for my $pub (qw/openssl_ec-short.pub.pem openssl_ec-short.pub.der/) {
179168 is($k->size, 32, "$pub size");
180169 is(uc($k->key2hash->{pub_x}), 'A01532A3C0900053DE60FBEFEFCCA58793301598D308B41E6F4E364E388C2711', "key2hash $pub");
181170 is($k->key2hash->{curve_name}, "secp256r1", "EC curve_name is lowercase");
182 is($k->export_key_der('public_short'), read_file($f), 'export_key_der public_short') if (substr($pub, -3) eq "der");
183 is($k->export_key_pem('public_short'), read_file($f), 'export_key_pem public_short') if (substr($pub, -3) eq "pem");
171 is($k->export_key_der('public_short'), read_rawfile($f), 'export_key_der public_short') if (substr($pub, -3) eq "der");
172 is($k->export_key_pem('public_short'), read_rawfile($f), 'export_key_pem public_short') if (substr($pub, -3) eq "pem");
184173 }
185174
186175 {
00 use strict;
11 use warnings;
2 use Test::More tests => 45;
2 use Test::More tests => 49;
33
44 use Crypt::PK::RSA qw(rsa_encrypt rsa_decrypt rsa_sign_message rsa_verify_message rsa_sign_hash rsa_verify_hash);
55
5555 $k = Crypt::PK::RSA->new('t/data/openssl_rsa2.pem');
5656 ok($k, 'load openssl_rsa2.pem');
5757 ok($k->is_private, 'is_private openssl_rsa2.pem');
58
59 # X509
60 $k = Crypt::PK::RSA->new('t/data/openssl_rsa-x509.pem');
61 ok($k, 'openssl_rsa-x509.pem');
62 ok(!$k->is_private, 'not private openssl_rsa-x509.pem');
63 $k = Crypt::PK::RSA->new('t/data/openssl_rsa-x509.der');
64 ok($k, 'openssl_rsa-x509.der');
65 ok(!$k->is_private, 'not private openssl_rsa-x509.der');
5866 }
5967
6068 {
0 {
1 "algorithm": "AES-GCM",
2 "generatorVersion": "0.0a8",
3 "numberOfTests": 50,
4 "testGroups": [
5 {
6 "ivSize": 96,
7 "keySize": 128,
8 "tagSize": 128,
9 "tests": [
10 {
11 "aad": "",
12 "comment": "",
13 "ct": "26073cc1d851beff176384dc9896d5ff",
14 "iv": "028318abc1824029138141a2",
15 "key": "5b9604fe14eadba931b0ccf34843dab9",
16 "msg": "001d0c231287c1182784554ca3a21908",
17 "result": "valid",
18 "tag": "0a3ea7a5487cb5f7d70fb6c58d038554",
19 "tcId": 1
20 },
21 {
22 "aad": "00112233445566778899aabbccddeeff",
23 "comment": "",
24 "ct": "49d8b9783e911913d87094d1f63cc765",
25 "iv": "921d2507fa8007b7bd067d34",
26 "key": "5b9604fe14eadba931b0ccf34843dab9",
27 "msg": "001d0c231287c1182784554ca3a21908",
28 "result": "valid",
29 "tag": "1e348ba07cca2cf04c618cb4d43a5b92",
30 "tcId": 2
31 },
32 {
33 "aad": "aac39231129872a2",
34 "comment": "",
35 "ct": "eea945f3d0f98cc0fbab472a0cf24e87",
36 "iv": "0432bc49ac34412081288127",
37 "key": "aa023d0478dcb2b2312498293d9a9129",
38 "msg": "2035af313d1346ab00154fea78322105",
39 "result": "valid",
40 "tag": "4bb9b4812519dadf9e1232016d068133",
41 "tcId": 3
42 },
43 {
44 "aad": "",
45 "comment": "",
46 "ct": "ff",
47 "iv": "327182bee515d2b15f949477",
48 "key": "dc25a94c28b9d18a6468f41428fae84d",
49 "msg": "6f",
50 "result": "valid",
51 "tag": "62870f416e1fb63486127df9555ebcdb",
52 "tcId": 4
53 },
54 {
55 "aad": "",
56 "comment": "",
57 "ct": "4bd185849ab0f4d0",
58 "iv": "0cfe85626ce523b3204ca873",
59 "key": "bd6ffed2d59c492aec86368e02f6baeb",
60 "msg": "3c3b3a363f3a504e",
61 "result": "valid",
62 "tag": "742f379ab07b2c8c0c0eff4ce9327218",
63 "tcId": 5
64 },
65 {
66 "aad": "",
67 "comment": "",
68 "ct": "11afae2b91b71126e31d868e3482f907",
69 "iv": "5fe1b8445d7a2bce3ffd01c5",
70 "key": "6b21264d4ffdaa70021f6ea94f3f7729",
71 "msg": "6538395b746031796f5b60303261684e",
72 "result": "valid",
73 "tag": "b5133f5ce864f55641c121fb48c77e8c",
74 "tcId": 6
75 },
76 {
77 "aad": "",
78 "comment": "",
79 "ct": "ca741e2b8f4bfb75f3a897869664982be5e1feb1c3588621",
80 "iv": "1e0055ab643fe8d851f27501",
81 "key": "3f89802f2f430d027d9d27ab10095a1e",
82 "msg": "78446a4e313d634d524834637040456b793c6e4d4166544c",
83 "result": "valid",
84 "tag": "ab9a540db92381a4768ea81f08230100",
85 "tcId": 7
86 },
87 {
88 "aad": "15",
89 "comment": "",
90 "ct": "fa2ac3a4d15e01d64b642c4dc75f95e0",
91 "iv": "2071ec1a1d0ff802349fc01b",
92 "key": "f08afe018379b19417388302c3508983",
93 "msg": "566464646d4639476d5e4673653e3838",
94 "result": "valid",
95 "tag": "d95cea01fafb2c8c21cebfcbc412f87a",
96 "tcId": 8
97 },
98 {
99 "aad": "0b2bc21ab1fbff11e376e1a65ca2a1",
100 "comment": "",
101 "ct": "1e3373677b4615745a57ce43c0874702",
102 "iv": "460b321e66c90ae86f878da7",
103 "key": "7c7337a75c47230f579ff763e544b63b",
104 "msg": "4c565d4051404f4f35633a63455d7676",
105 "result": "valid",
106 "tag": "6c0314734528fe2863f2dc16f313e5ff",
107 "tcId": 9
108 },
109 {
110 "aad": "2eb61446950c83695522fdeb92220645",
111 "comment": "",
112 "ct": "107150b5349540a6b953c033d3ed0eec",
113 "iv": "787c817bf07a25ec613f4fbb",
114 "key": "9bd978c97f84c67e967a6dc71a9dd29a",
115 "msg": "4d36343f6e38716e476476394764635b",
116 "result": "valid",
117 "tag": "87ec1d4fee69de2efe606138b99a1c56",
118 "tcId": 10
119 },
120 {
121 "aad": "62a76634d40bb93ce8bd140e418bf88f002e1b88396511f5ddd9b099abe7b722",
122 "comment": "",
123 "ct": "8e0b9ca71471c5d509167fb138d65834",
124 "iv": "da22d5718083aee0b1ecf18c",
125 "key": "a3b604ee4889e9986b1d760779acb0da",
126 "msg": "453b3b34344076413d3b5b46373f725c",
127 "result": "valid",
128 "tag": "7cc68eb3039691eeea5b211c9f39244a",
129 "tcId": 11
130 },
131 {
132 "aad": "",
133 "comment": "special case",
134 "ct": "f62d84d649e56bc8cfedc5d74a51e2f7",
135 "iv": "000000000000000000000000",
136 "key": "00112233445566778899aabbccddeeff",
137 "msg": "ebd4a3e10cf6d41c50aeae007563b072",
138 "result": "valid",
139 "tag": "ffffffffffffffffffffffffffffffff",
140 "tcId": 12
141 },
142 {
143 "aad": "",
144 "comment": "special case",
145 "ct": "431f31e6840931fd95f94bf88296ff69",
146 "iv": "ffffffffffffffffffffffff",
147 "key": "00112233445566778899aabbccddeeff",
148 "msg": "d593c4d8224f1b100c35e4f6c4006543",
149 "result": "valid",
150 "tag": "00000000000000000000000000000000",
151 "tcId": 13
152 },
153 {
154 "aad": "",
155 "comment": "special case",
156 "ct": "d8eba6a5a03403851abc27f6e15d84c0",
157 "iv": "00112233445566778899aabb",
158 "key": "00112233445566778899aabbccddeeff",
159 "msg": "7fd49ba712d0d28f02ef54ed18db43f8",
160 "result": "valid",
161 "tag": "00000000000000000000000000000000",
162 "tcId": 14
163 }
164 ],
165 "type": "AES-GCM"
166 },
167 {
168 "ivSize": 64,
169 "keySize": 128,
170 "tagSize": 128,
171 "tests": [
172 {
173 "aad": "aac39231129872a2",
174 "comment": "",
175 "ct": "64c36bb3b732034e3a7d04efc5197785",
176 "iv": "0432bc49ac344120",
177 "key": "aa023d0478dcb2b2312498293d9a9129",
178 "msg": "2035af313d1346ab00154fea78322105",
179 "result": "valid",
180 "tag": "b7d0dd70b00d65b97cfd080ff4b819d1",
181 "tcId": 15
182 },
183 {
184 "aad": "",
185 "comment": "unusual IV size",
186 "ct": "553763110458769a08e3c5d9",
187 "iv": "22117438f0762c77",
188 "key": "b215270c3e1055888599f1e5f6188e57",
189 "msg": "7675613a6c356e663d483264",
190 "result": "valid",
191 "tag": "14fed4270ed847fec690988c729672d1",
192 "tcId": 16
193 }
194 ],
195 "type": "AES-GCM"
196 },
197 {
198 "ivSize": 128,
199 "keySize": 128,
200 "tagSize": 128,
201 "tests": [
202 {
203 "aad": "1a0293d8f90219058902139013908190bc490890d3ff12a3",
204 "comment": "",
205 "ct": "64069c2d58690561f27ee199e6b479b6369eec688672bde9",
206 "iv": "3254202d854734812398127a3d134421",
207 "key": "2034a82547276c83dd3212a813572bce",
208 "msg": "02efd2e5782312827ed5d230189a2a342b277ce048462193",
209 "result": "valid",
210 "tag": "9b7abadd6e69c1d9ec925786534f5075",
211 "tcId": 17
212 },
213 {
214 "aad": "",
215 "comment": "J0:000102030405060708090a0b0c0d0e0f",
216 "ct": "00078d109d92143fcd5df56721b884fac64ac7762cc09eea2a3c68e92a17bdb575f87bda18be564e",
217 "iv": "f95fde4a751913202aeeee32a0b55753",
218 "key": "00112233445566778899aabbccddeeff",
219 "msg": "00000000000000000000000000000000000000000000000000000000000000000000000000000000",
220 "result": "valid",
221 "tag": "152a65045fe674f97627427af5be22da",
222 "tcId": 18
223 },
224 {
225 "aad": "",
226 "comment": "J0:00000000000000000000000000000000",
227 "ct": "84d4c9c08b4f482861e3a9c6c35bc4d91df927374513bfd49f436bd73f325285daef4ff7e13d46a6",
228 "iv": "7b95b8c356810a84711d68150a1b7750",
229 "key": "00112233445566778899aabbccddeeff",
230 "msg": "00000000000000000000000000000000000000000000000000000000000000000000000000000000",
231 "result": "valid",
232 "tag": "213a3cb93855d18e69337eee66aeec07",
233 "tcId": 19
234 },
235 {
236 "aad": "",
237 "comment": "J0:ffffffffffffffffffffffffffffffff",
238 "ct": "948ca37a8e6649e88aeffb1c598f3607007702417ea0e0bc3c60ad5a949886de968cf53ea6462aed",
239 "iv": "1a552e67cdc4dc1a33b824874ebf0bed",
240 "key": "00112233445566778899aabbccddeeff",
241 "msg": "00000000000000000000000000000000000000000000000000000000000000000000000000000000",
242 "result": "valid",
243 "tag": "99b381bfa2af9751c39d1b6e86d1be6a",
244 "tcId": 20
245 },
246 {
247 "aad": "",
248 "comment": "J0:000102030405060708090a0bffffffff",
249 "ct": "127af9b39ecdfc57bb11a2847c7c2d3d8f938f40f877e0c4af37d0fe9af033052bd537c4ae978f60",
250 "iv": "99821c2dd5daecded07300f577f7aff1",
251 "key": "00112233445566778899aabbccddeeff",
252 "msg": "00000000000000000000000000000000000000000000000000000000000000000000000000000000",
253 "result": "valid",
254 "tag": "07eb2fe4a958f8434d40684899507c7c",
255 "tcId": 21
256 },
257 {
258 "aad": "",
259 "comment": "J0:000102030405060708090a0bfffffffe",
260 "ct": "0cf6ae47156b14dce03c8a07a2e172b1127af9b39ecdfc57bb11a2847c7c2d3d8f938f40f877e0c4",
261 "iv": "5e4a3900142358d1c774d8d124d8d27d",
262 "key": "00112233445566778899aabbccddeeff",
263 "msg": "00000000000000000000000000000000000000000000000000000000000000000000000000000000",
264 "result": "valid",
265 "tag": "f145c2dcaf339eede427be934357eac0",
266 "tcId": 22
267 },
268 {
269 "aad": "",
270 "comment": "special case",
271 "ct": "1cd5a06214235ceb044d4bad7b047312",
272 "iv": "ffffffffffffffffffffffffffffffff",
273 "key": "00112233445566778899aabbccddeeff",
274 "msg": "4d82639c39d3f3490ee903dd0be7afcf",
275 "result": "valid",
276 "tag": "ffffffffffffffffffffffffffffffff",
277 "tcId": 23
278 },
279 {
280 "aad": "",
281 "comment": "unusual IV size",
282 "ct": "d6db136eb9bd4cdaf0bd1913",
283 "iv": "44b926c2a249611e14475b6cfe4d7dae",
284 "key": "c79117e417d6d45e37a52441cbfaa47b",
285 "msg": "623734365060575b423b303a",
286 "result": "valid",
287 "tag": "54132cb206112184c889e1f15b83fe1f",
288 "tcId": 24
289 }
290 ],
291 "type": "AES-GCM"
292 },
293 {
294 "ivSize": 96,
295 "keySize": 256,
296 "tagSize": 128,
297 "tests": [
298 {
299 "aad": "00000000ffffffff",
300 "comment": "",
301 "ct": "e27abdd2d2a53d2f136b",
302 "iv": "00112233445566778899aabb",
303 "key": "92ace3e348cd821092cd921aa3546374299ab46209691bc28b8752d17f123c20",
304 "msg": "00010203040506070809",
305 "result": "valid",
306 "tag": "9a4a2579529301bcfb71c78d4060f52c",
307 "tcId": 25
308 },
309 {
310 "aad": "aabbccddeeff",
311 "comment": "",
312 "ct": "",
313 "iv": "00112233445566778899aabb",
314 "key": "29d3a44f8723dc640239100c365423a312934ac80239212ac3df3421a2098123",
315 "msg": "",
316 "result": "valid",
317 "tag": "2a7d77fa526b8250cb296078926b5020",
318 "tcId": 26
319 },
320 {
321 "aad": "",
322 "comment": "",
323 "ct": "11",
324 "iv": "61de8c2f27065bb3f1235d55",
325 "key": "a68e06009f0c9630fed700e67d4960378cc1c86ae6cc79a6ac6a9042bf83039a",
326 "msg": "7a",
327 "result": "valid",
328 "tag": "05402b6d9671f281c34848fed708da8b",
329 "tcId": 27
330 },
331 {
332 "aad": "",
333 "comment": "",
334 "ct": "aecefdde647dbfd9",
335 "iv": "27f3c472caf75d6102ef5f0d",
336 "key": "fe65ab5e97e2adff16bb5cf71f31d09754ce2a246aeaedc5647afb54dce7b68d",
337 "msg": "493d425c4b3f6d51",
338 "result": "valid",
339 "tag": "02af89a1eadcb29077a26203314a7dc3",
340 "tcId": 28
341 },
342 {
343 "aad": "",
344 "comment": "",
345 "ct": "3ddf2af410318b26750139bf4ec13460",
346 "iv": "6f5485754cd243aecd2c9e43",
347 "key": "9c6edc8b05d7bceb455a6b915f16f117e244ff788a8c20c25fd6e0a49566d781",
348 "msg": "5031613a625a7348753b323c4f3f7835",
349 "result": "valid",
350 "tag": "4e4bc7648e7fb0976c4cb9c2fb3ca540",
351 "tcId": 29
352 },
353 {
354 "aad": "",
355 "comment": "",
356 "ct": "28bbe0d13c0f43422df882a2dc9e011b4d4fd5bc9e73c515",
357 "iv": "3d3f629413e65f8b6e55ec8e",
358 "key": "c786bc3074dad0f11efecfd24dd9f9df9fec79161d1ffd5acb18fc69fe3f3e0f",
359 "msg": "635569643f32513f655a6e5c423547744259725e454b616d",
360 "result": "valid",
361 "tag": "bbf623568c0bd3b94b5201af8711a8d2",
362 "tcId": 30
363 },
364 {
365 "aad": "45",
366 "comment": "",
367 "ct": "69c3ee7e6d4bae0d747164980d6b9b0c",
368 "iv": "c0dfc8a34a8c946504f882c5",
369 "key": "44a85d703964debdf04efe8748c7953da193ecd7ce4453673d86b96c5a1b3154",
370 "msg": "5a416a725a6d69746269316f6c747566",
371 "result": "valid",
372 "tag": "5221ece0acc54017981f0cdad17839b2",
373 "tcId": 31
374 },
375 {
376 "aad": "e19b62570639e9329109d81795f82f",
377 "comment": "",
378 "ct": "54d25cd9f65a56ee17a4cb88fbc7489d",
379 "iv": "6f6a2fc05f916819550e1ec0",
380 "key": "afc8d84a39c7b984670d42712c1e6b86aa8bf9458e20054da9aa4de627aadb69",
381 "msg": "45353c45306243584277445f317a355a",
382 "result": "valid",
383 "tag": "8e535d739362959710ec3ddb486e8bc2",
384 "tcId": 32
385 },
386 {
387 "aad": "d0468a40ded0439cdf41cfa5662181d8",
388 "comment": "",
389 "ct": "ec23144c64749090e581928d86681f3e",
390 "iv": "b74599e72c0309e162658615",
391 "key": "62f210a5cdfaa9c341c5c25ca1510fbbe611d433091d064eb62dbbcfbc95f15b",
392 "msg": "5a6551343a4b45685c49795b5a557449",
393 "result": "valid",
394 "tag": "ce0594dabb2b4db89460e085bc44e684",
395 "tcId": 33
396 },
397 {
398 "aad": "6387afe729e73233e3860de9c1a6617b37bab1eedaba9fcb53618e7eac3d8009",
399 "comment": "",
400 "ct": "fcfc653448912e1d9f5413dc92c7678b",
401 "iv": "74852c78eb5a479ec8620ae4",
402 "key": "34135b6afae2248312d68c1e28db5a4cbbfd3ccc5b4aab357353bd2541d45c59",
403 "msg": "34356b523f4a6d5c3237325043353e50",
404 "result": "valid",
405 "tag": "1b3acf71c1fdcfa8d61d585d10004f6d",
406 "tcId": 34
407 }
408 ],
409 "type": "AES-GCM"
410 },
411 {
412 "ivSize": 96,
413 "keySize": 192,
414 "tagSize": 128,
415 "tests": [
416 {
417 "aad": "",
418 "comment": "",
419 "ct": "7a",
420 "iv": "e6bfc54c87a8e2a9b539eedb",
421 "key": "6c7a0c4c8515ed6c7d4eca4916bb0c8362d282afeacbe3f9",
422 "msg": "3c",
423 "result": "valid",
424 "tag": "106daeade85585d997e65bc4564fe125",
425 "tcId": 35
426 },
427 {
428 "aad": "",
429 "comment": "",
430 "ct": "16f812c2be4121b6",
431 "iv": "6d7baec9ed558f82aa1128cd",
432 "key": "35a0d16c02ec630e360e9d7243a82c76ac36668c0b59413e",
433 "msg": "5c513c3a74763674",
434 "result": "valid",
435 "tag": "f35ba677c07a76aea8e70a81918d35cf",
436 "tcId": 36
437 },
438 {
439 "aad": "",
440 "comment": "",
441 "ct": "21c250e0f28c494c944bd1345d6daa51",
442 "iv": "cffd1a7e8d52cf3c0c4bbb8e",
443 "key": "ddeb7f10bbd1b82c115165e6c1547d224e3449933ea3bfe9",
444 "msg": "526a3b4e7472324a5b3a5b553b4b443f",
445 "result": "valid",
446 "tag": "bbaea6623cf22328efcd21bf3656987e",
447 "tcId": 37
448 },
449 {
450 "aad": "",
451 "comment": "",
452 "ct": "034c477eee703e11b0f354d5912c16fd512c69cccbc22211",
453 "iv": "56f2119df4070d2e767861e8",
454 "key": "b567dc2ed4684ccfb582d80ff9b15ef520a325f0b8201cdc",
455 "msg": "306c3e337a60677956536e346472534679707a6552624e3f",
456 "result": "valid",
457 "tag": "d8ecc0925d544d9e2906504e4f006bea",
458 "tcId": 38
459 }
460 ],
461 "type": "AES-GCM"
462 },
463 {
464 "ivSize": 120,
465 "keySize": 128,
466 "tagSize": 128,
467 "tests": [
468 {
469 "aad": "",
470 "comment": "unusual IV size",
471 "ct": "fde7899c326af98d67b07890",
472 "iv": "ca2a23ea38e82a4304021e0984800c",
473 "key": "a9ded7b2cbce3621d310006444ce80a3",
474 "msg": "665470423738756779357345",
475 "result": "valid",
476 "tag": "a545ed6b98a8b49c6588232e3d876de7",
477 "tcId": 39
478 }
479 ],
480 "type": "AES-GCM"
481 },
482 {
483 "ivSize": 160,
484 "keySize": 128,
485 "tagSize": 128,
486 "tests": [
487 {
488 "aad": "",
489 "comment": "unusual IV size",
490 "ct": "35a123fa123571aa0d242a66",
491 "iv": "9ce715dd2a59b4a6bf7451c7a144b97f3e62c0a0",
492 "key": "1e7cc3c9116b0a2d25154e1f4ae97796",
493 "msg": "6c74623b3346665333613c3d",
494 "result": "valid",
495 "tag": "831a00839d8c008c9d1cb0f9a8d17255",
496 "tcId": 40
497 }
498 ],
499 "type": "AES-GCM"
500 },
501 {
502 "ivSize": 64,
503 "keySize": 256,
504 "tagSize": 128,
505 "tests": [
506 {
507 "aad": "",
508 "comment": "unusual IV size",
509 "ct": "99add354679e324c3277506c",
510 "iv": "bd3b080f33229c69",
511 "key": "b22f6e946ab41994781b4bfff1e3f44e3daaf4d9ad788bbfa39a8caa2bc112cf",
512 "msg": "3b353b365e37784a5833354c",
513 "result": "valid",
514 "tag": "174fd057b60654548d833f9d6d9626e8",
515 "tcId": 41
516 }
517 ],
518 "type": "AES-GCM"
519 },
520 {
521 "ivSize": 120,
522 "keySize": 256,
523 "tagSize": 128,
524 "tests": [
525 {
526 "aad": "",
527 "comment": "unusual IV size",
528 "ct": "992b01084e37fbe3a6cfd456",
529 "iv": "479e398a4805a347a5c4c16ddfe621",
530 "key": "0d20b8ef8b05c48f691a5dd9b49b6c0637aee0567257b6c3ce35a5823c337294",
531 "msg": "527979696037335d553a4767",
532 "result": "valid",
533 "tag": "1cd717548e768aa0f9932311d443bf0e",
534 "tcId": 42
535 }
536 ],
537 "type": "AES-GCM"
538 },
539 {
540 "ivSize": 128,
541 "keySize": 256,
542 "tagSize": 128,
543 "tests": [
544 {
545 "aad": "",
546 "comment": "unusual IV size",
547 "ct": "fa93631a76a63d8096bb11f3",
548 "iv": "ad581e8f55a8d283f0dfebae9d0c6484",
549 "key": "cc4a246cb3e166c194e59f465db9adf92a8974cd472744c062728ccbae687aac",
550 "msg": "6b4d3e67695a79544b725046",
551 "result": "valid",
552 "tag": "fb1c7f1c3d5c0155ae18eb9bc13f7758",
553 "tcId": 43
554 }
555 ],
556 "type": "AES-GCM"
557 },
558 {
559 "ivSize": 160,
560 "keySize": 256,
561 "tagSize": 128,
562 "tests": [
563 {
564 "aad": "",
565 "comment": "unusual IV size",
566 "ct": "b35920ed04f6a7dcf8d075a9",
567 "iv": "3293e555aa1cb29f839d571e811b8e84807a0031",
568 "key": "3a95937dd23f0997fae31a26821d99e8e338016c05ad30718f41fa04aced12f8",
569 "msg": "5578554a61324e4c3142483a",
570 "result": "valid",
571 "tag": "fa0c75f97432e5ef97445ccf99a90231",
572 "tcId": 44
573 }
574 ],
575 "type": "AES-GCM"
576 },
577 {
578 "ivSize": 0,
579 "keySize": 128,
580 "tagSize": 128,
581 "tests": [
582 {
583 "aad": "",
584 "comment": "0 size IV is not valid",
585 "ct": "",
586 "iv": "",
587 "key": "b1e11d771f1ea274a3386d3879738d64",
588 "msg": "",
589 "result": "invalid",
590 "tag": "ec5c4805da277942d7ad6ea2d212d909",
591 "tcId": 45
592 },
593 {
594 "aad": "",
595 "comment": "0 size IV is not valid",
596 "ct": "8766b19d2e07b51ddfe8c85ea440ee2e",
597 "iv": "",
598 "key": "fb6c0503a1cd5219a2d5daa2e32a1520",
599 "msg": "446e39493339594b7247494d41344739",
600 "result": "invalid",
601 "tag": "5154e473735b026452a57060f3be5f66",
602 "tcId": 46
603 }
604 ],
605 "type": "AES-GCM"
606 },
607 {
608 "ivSize": 0,
609 "keySize": 192,
610 "tagSize": 128,
611 "tests": [
612 {
613 "aad": "",
614 "comment": "0 size IV is not valid",
615 "ct": "",
616 "iv": "",
617 "key": "0955fa25af91994f0407ff1e2f3b09af4074c13fbba6aa0b",
618 "msg": "",
619 "result": "invalid",
620 "tag": "bec27fcd432323a3162cbcfc4a4ae53b",
621 "tcId": 47
622 },
623 {
624 "aad": "",
625 "comment": "0 size IV is not valid",
626 "ct": "a284cb5110f73225954d0a74fc24b024",
627 "iv": "",
628 "key": "0750d0d5d4df4985fcc726177e6b325e90c7e9c5f4922e43",
629 "msg": "793b50665c4c79647534646231496748",
630 "result": "invalid",
631 "tag": "8fe5ddb632fa6d72af5fe114c95bcaa3",
632 "tcId": 48
633 }
634 ],
635 "type": "AES-GCM"
636 },
637 {
638 "ivSize": 0,
639 "keySize": 256,
640 "tagSize": 128,
641 "tests": [
642 {
643 "aad": "",
644 "comment": "0 size IV is not valid",
645 "ct": "",
646 "iv": "",
647 "key": "57163950d52c957068dc2ae7184911402887458e65ae212e54369eac864376a8",
648 "msg": "",
649 "result": "invalid",
650 "tag": "6397e0239baa358c90bc5a8bb69d3330",
651 "tcId": 49
652 },
653 {
654 "aad": "",
655 "comment": "0 size IV is not valid",
656 "ct": "77bbd2bc21a7cb2f1b62510a659db421",
657 "iv": "",
658 "key": "c242c762169e049fa7952d14123f61add08f9cd3cdb0784d7241f073244f0580",
659 "msg": "3669513131313f386240783b573b666f",
660 "result": "invalid",
661 "tag": "b2015bf3387d68cd2e9785d0b8bc46c8",
662 "tcId": 50
663 }
664 ],
665 "type": "AES-GCM"
666 }
667 ]
668 }
0 {
1 "algorithm" : "DSA",
2 "generatorVersion" : "0.0a10",
3 "numberOfTests" : 206,
4 "testGroups" : [
5 {
6 "keyDer" : "3081f03081a806072a8648ce38040130819c024100fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17021500962eddcc369cba8ebb260ee6b6a126d9346e38c50240678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca403430002407cc153f191171bdf13b6541c07dc611debc41efa18e1df5c2e42c2612e0e936abdcc28e66ce73bdedf449b5d39ec8e509a4767907345f38710638abe5c316ce5",
7 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIHwMIGoBgcqhkjOOAQBMIGcAkEA/KaCzo4Syrom78z3EQ5SbbB4sF7ey80etKII\n864WF64B81uRpH5t9jQTxeEu0ImbzRMqzVDZkVG9xD7nN1kuFwIVAJYu3cw2nLqO\nuyYO5rahJtk0bjjFAkBnhHGyepz0TukaScUUfbGpqvJE8FpDTWSGkx0tFCcbnjUD\nC3H9c9oXkGmzLik1Yw4cIGI1TQ2iCmxBblC+eUykA0MAAkB8wVPxkRcb3xO2VBwH\n3GEd68Qe+hjh31wuQsJhLg6Tar3MKOZs5zve30SbXTnsjlCaR2eQc0XzhxBjir5c\nMWzl\n-----END PUBLIC KEY-----",
8 "sha" : "SHA-1",
9 "type" : "DSAVer",
10 "key" : {
11 "g" : "678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4",
12 "keyType" : "DSA public key",
13 "p" : "0fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17",
14 "q" : "0962eddcc369cba8ebb260ee6b6a126d9346e38c5",
15 "y" : "7cc153f191171bdf13b6541c07dc611debc41efa18e1df5c2e42c2612e0e936abdcc28e66ce73bdedf449b5d39ec8e509a4767907345f38710638abe5c316ce5"
16 },
17 "tests" : [
18 {
19 "comment" : "random signature",
20 "message" : "48656c6c6f",
21 "result" : "valid",
22 "sig" : "302c021426184de880bd04090541530d4951dffb2200b2cf02143c2cfef8b2c62eb572547f173fb4973ac7225207",
23 "tcId" : 1
24 },
25 {
26 "comment" : "random signature",
27 "message" : "48656c6c6f",
28 "result" : "valid",
29 "sig" : "302c02141c71bdda8343c3b8c8503772a3dca7f5ebc3e018021421c7aff53838a6ee5fdf4c4b66f7ae67241021f1",
30 "tcId" : 2
31 },
32 {
33 "comment" : "random signature",
34 "message" : "48656c6c6f",
35 "result" : "valid",
36 "sig" : "302c02142b6a1d97f043cf8ac1574af5eae78b3d01e444e80214787affc9a23bf98848ccb99a0339ef9ec7ae767e",
37 "tcId" : 3
38 },
39 {
40 "comment" : "random signature",
41 "message" : "48656c6c6f",
42 "result" : "valid",
43 "sig" : "302d02150087e0e4ae54fe9fa55abe4914380dccd7d546eee902147a075d0115c06d17194665739ab713a0734b3d36",
44 "tcId" : 4
45 },
46 {
47 "comment" : "random signature",
48 "message" : "48656c6c6f",
49 "result" : "valid",
50 "sig" : "302c02144ce8e8d2abb5f230a5fdcf6f2d8f81bb1b80ed5502140d63dbfd1100d3caf0580d93101f21e699633a56",
51 "tcId" : 5
52 }
53 ]
54 },
55 {
56 "keyDer" : "308203423082023506072a8648ce3804013082022802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d0282010016a65c58204850704e7502a39757040d34da3a3478c154d4e4a5c02d242ee04f96e61e4bd0904abdac8f37eeb1e09f3182d23c9043cb642f88004160edf9ca09b32076a79c32a627f2473e91879ba2c4e744bd2081544cb55b802c368d1fa83ed489e94e0fa0688e32428a5c78c478c68d0527b71c9a3abb0b0be12c44689639e7d3ce74db101a65aa2b87f64c6826db3ec72f4b5599834bb4edb02f7c90e9a496d3a55d535bebfc45d4f619f63f3dedbb873925c2f224e07731296da887ec1e4748f87efb5fdeb75484316b2232dee553ddaf02112b0d1f02da30973224fe27aeda8b9d4b2922d9ba8be39ed9e103a63c52810bc688b7e2ed4316e1ef17dbde0382010500028201001e77f842b1ae0fcd9929d394161d41e14614ff7507a9a31f4a1f14d22e2a627a1f4e596624883f1a5b168e9425146f22d5f6ee28757414714bb994ba1129f015d6e04a717edf9b530a5d5cab94f14631e8b4cf79aeb358cc741845553841e8ac461630e804a62f43676ba6794af66899c377b869ea612a7b9fe6611aa96be52eb8b62c979117bbbcca8a7ec1e1ffab1c7dfcfc7048700d3ae3858136e897701d7c2921b5dfef1d1f897f50d96ca1b5c2edc58cada18919e35642f0807eebfa00c99a32f4d095c3188f78ed54711be0325c4b532aeccd6540a567c327225440ea15319bde06510479a1861799e25b57decc73c036d75a0702bd373ca231349931",
57 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIIDQjCCAjUGByqGSM44BAEwggIoAoIBAQCPeTXZuarpv6vtiHrPSVG28y7Fnjuv\nNxjo6sSWHz79NgbnQ1GpxBgzObgJ58KuHFObp0dbhdARrbi0eYd1SYRpXKwOjxSz\nNggooi/6JxEKPWKpk0U0CaD+aWxGWPhL3SCBnDcJoBBXsZWtzQAjPbpUhLYpH51k\njviDRIZ3l5zsBLQ0pqwudemYXeI9sCkvwRGMn/qdgYHnM423krcw17njSVkvaAmY\nchU5Feo9a4tGU8YzRY+AOzKkwuDycpAlbk4/ijsIOKHEUOThjBopo33fXqFD3ktm\n/wSQPtXPFiPhWNSHxgjpfyEc2B3KI8tuOAdl+CLjQr5ITAV2OTlgHNZnAh0AuvaW\npoV499/e5/pnyXfHhe8ysjO65YDAvNVpXQKCAQAWplxYIEhQcE51AqOXVwQNNNo6\nNHjBVNTkpcAtJC7gT5bmHkvQkEq9rI837rHgnzGC0jyQQ8tkL4gAQWDt+coJsyB2\np5wypifyRz6Rh5uixOdEvSCBVEy1W4AsNo0fqD7UielOD6BojjJCilx4xHjGjQUn\ntxyaOrsLC+EsRGiWOefTznTbEBplqiuH9kxoJts+xy9LVZmDS7TtsC98kOmkltOl\nXVNb6/xF1PYZ9j897buHOSXC8iTgdzEpbaiH7B5HSPh++1/et1SEMWsiMt7lU92v\nAhErDR8C2jCXMiT+J67ai51LKSLZuovjntnhA6Y8UoELxoi34u1DFuHvF9veA4IB\nBQACggEAHnf4QrGuD82ZKdOUFh1B4UYU/3UHqaMfSh8U0i4qYnofTllmJIg/GlsW\njpQlFG8i1fbuKHV0FHFLuZS6ESnwFdbgSnF+35tTCl1cq5TxRjHotM95rrNYzHQY\nRVU4QeisRhYw6ASmL0Nna6Z5SvZomcN3uGnqYSp7n+ZhGqlr5S64tiyXkRe7vMqK\nfsHh/6scffz8cEhwDTrjhYE26JdwHXwpIbXf7x0fiX9Q2WyhtcLtxYytoYkZ41ZC\n8IB+6/oAyZoy9NCVwxiPeO1UcRvgMlxLUyrszWVApWfDJyJUQOoVMZveBlEEeaGG\nF5niW1fezHPANtdaBwK9NzyiMTSZMQ==\n-----END PUBLIC KEY-----",
58 "sha" : "SHA-224",
59 "type" : "DSAVer",
60 "key" : {
61 "g" : "16a65c58204850704e7502a39757040d34da3a3478c154d4e4a5c02d242ee04f96e61e4bd0904abdac8f37eeb1e09f3182d23c9043cb642f88004160edf9ca09b32076a79c32a627f2473e91879ba2c4e744bd2081544cb55b802c368d1fa83ed489e94e0fa0688e32428a5c78c478c68d0527b71c9a3abb0b0be12c44689639e7d3ce74db101a65aa2b87f64c6826db3ec72f4b5599834bb4edb02f7c90e9a496d3a55d535bebfc45d4f619f63f3dedbb873925c2f224e07731296da887ec1e4748f87efb5fdeb75484316b2232dee553ddaf02112b0d1f02da30973224fe27aeda8b9d4b2922d9ba8be39ed9e103a63c52810bc688b7e2ed4316e1ef17dbde",
62 "keyType" : "DSA public key",
63 "p" : "08f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
64 "q" : "0baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
65 "y" : "1e77f842b1ae0fcd9929d394161d41e14614ff7507a9a31f4a1f14d22e2a627a1f4e596624883f1a5b168e9425146f22d5f6ee28757414714bb994ba1129f015d6e04a717edf9b530a5d5cab94f14631e8b4cf79aeb358cc741845553841e8ac461630e804a62f43676ba6794af66899c377b869ea612a7b9fe6611aa96be52eb8b62c979117bbbcca8a7ec1e1ffab1c7dfcfc7048700d3ae3858136e897701d7c2921b5dfef1d1f897f50d96ca1b5c2edc58cada18919e35642f0807eebfa00c99a32f4d095c3188f78ed54711be0325c4b532aeccd6540a567c327225440ea15319bde06510479a1861799e25b57decc73c036d75a0702bd373ca231349931"
66 },
67 "tests" : [
68 {
69 "comment" : "valid",
70 "message" : "48656c6c6f",
71 "result" : "valid",
72 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
73 "tcId" : 6
74 },
75 {
76 "comment" : "random signature",
77 "message" : "48656c6c6f",
78 "result" : "valid",
79 "sig" : "303c021c5970bf65c8cd0da10edfe80430ab0b456cefbc3913116a31f024f240021c58ca06a899c7fadedb2d31abf917f9de2e4b97d1b3c323de04fd519d",
80 "tcId" : 7
81 },
82 {
83 "comment" : "random signature",
84 "message" : "48656c6c6f",
85 "result" : "valid",
86 "sig" : "303d021c00ff3f02204b98d07a502c00ff8a59a41497c38f5193e68ccc16d080021d00b51491eae8112ce48ed85896ba2632cd90fd02e83a7a17a420157b0e",
87 "tcId" : 8
88 },
89 {
90 "comment" : "random signature",
91 "message" : "48656c6c6f",
92 "result" : "valid",
93 "sig" : "303d021c39fcb3f986c4fb681f2f5d4a50dd9b3b898ca8df674fbf2760666294021d00b0205076df3997e815fefa0a20e33700460ec66f53415799eb58802a",
94 "tcId" : 9
95 },
96 {
97 "comment" : "random signature",
98 "message" : "48656c6c6f",
99 "result" : "valid",
100 "sig" : "303e021d008588cdf67cff154f19b9007b0b9e8149902c24771435c02c807713e5021d008595d7291eabc7bd81dc7566544e8abba81b764d4edb0dc619cf14c0",
101 "tcId" : 10
102 },
103 {
104 "comment" : "random signature",
105 "message" : "48656c6c6f",
106 "result" : "valid",
107 "sig" : "303c021c521c90b08df83c821e329c7275b88648a9c16031b3acd223806a61bd021c6443cc6666b43702f1a158430ce20529883b03e02ce2d6869c62084e",
108 "tcId" : 11
109 },
110 {
111 "comment" : "Legacy:ASN encoding of s misses leading 0",
112 "message" : "48656c6c6f",
113 "result" : "acceptable",
114 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021cade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
115 "tcId" : 12
116 },
117 {
118 "comment" : "BER:long form encoding of length",
119 "message" : "48656c6c6f",
120 "result" : "acceptable",
121 "sig" : "30813d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
122 "tcId" : 13
123 },
124 {
125 "comment" : "BER:long form encoding of length",
126 "message" : "48656c6c6f",
127 "result" : "acceptable",
128 "sig" : "303e02811c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
129 "tcId" : 14
130 },
131 {
132 "comment" : "BER:long form encoding of length",
133 "message" : "48656c6c6f",
134 "result" : "acceptable",
135 "sig" : "303e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd02811d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
136 "tcId" : 15
137 },
138 {
139 "comment" : "BER:length contains leading 0",
140 "message" : "48656c6c6f",
141 "result" : "acceptable",
142 "sig" : "3082003d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
143 "tcId" : 16
144 },
145 {
146 "comment" : "BER:length contains leading 0",
147 "message" : "48656c6c6f",
148 "result" : "acceptable",
149 "sig" : "303f0282001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
150 "tcId" : 17
151 },
152 {
153 "comment" : "BER:length contains leading 0",
154 "message" : "48656c6c6f",
155 "result" : "acceptable",
156 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0282001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
157 "tcId" : 18
158 },
159 {
160 "comment" : "BER:indefinite length",
161 "message" : "48656c6c6f",
162 "result" : "acceptable",
163 "sig" : "3080021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
164 "tcId" : 19
165 },
166 {
167 "comment" : "BER:prepending 0's to integer",
168 "message" : "48656c6c6f",
169 "result" : "acceptable",
170 "sig" : "303f021e00001e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
171 "tcId" : 20
172 },
173 {
174 "comment" : "BER:prepending 0's to integer",
175 "message" : "48656c6c6f",
176 "result" : "acceptable",
177 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021f000000ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
178 "tcId" : 21
179 },
180 {
181 "comment" : "wrong length",
182 "message" : "48656c6c6f",
183 "result" : "invalid",
184 "sig" : "303e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
185 "tcId" : 22
186 },
187 {
188 "comment" : "wrong length",
189 "message" : "48656c6c6f",
190 "result" : "invalid",
191 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
192 "tcId" : 23
193 },
194 {
195 "comment" : "wrong length",
196 "message" : "48656c6c6f",
197 "result" : "invalid",
198 "sig" : "303d021d1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
199 "tcId" : 24
200 },
201 {
202 "comment" : "wrong length",
203 "message" : "48656c6c6f",
204 "result" : "invalid",
205 "sig" : "303d021b1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
206 "tcId" : 25
207 },
208 {
209 "comment" : "wrong length",
210 "message" : "48656c6c6f",
211 "result" : "invalid",
212 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021e00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
213 "tcId" : 26
214 },
215 {
216 "comment" : "wrong length",
217 "message" : "48656c6c6f",
218 "result" : "invalid",
219 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021c00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
220 "tcId" : 27
221 },
222 {
223 "comment" : "uint32 overflow in length",
224 "message" : "48656c6c6f",
225 "result" : "invalid",
226 "sig" : "3085010000003d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
227 "tcId" : 28
228 },
229 {
230 "comment" : "uint32 overflow in length",
231 "message" : "48656c6c6f",
232 "result" : "invalid",
233 "sig" : "30420285010000001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
234 "tcId" : 29
235 },
236 {
237 "comment" : "uint32 overflow in length",
238 "message" : "48656c6c6f",
239 "result" : "invalid",
240 "sig" : "3042021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0285010000001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
241 "tcId" : 30
242 },
243 {
244 "comment" : "uint64 overflow in length",
245 "message" : "48656c6c6f",
246 "result" : "invalid",
247 "sig" : "308901000000000000003d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
248 "tcId" : 31
249 },
250 {
251 "comment" : "uint64 overflow in length",
252 "message" : "48656c6c6f",
253 "result" : "invalid",
254 "sig" : "3046028901000000000000001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
255 "tcId" : 32
256 },
257 {
258 "comment" : "uint64 overflow in length",
259 "message" : "48656c6c6f",
260 "result" : "invalid",
261 "sig" : "3046021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd028901000000000000001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
262 "tcId" : 33
263 },
264 {
265 "comment" : "length = 2**31 - 1",
266 "message" : "48656c6c6f",
267 "result" : "invalid",
268 "sig" : "30847fffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
269 "tcId" : 34
270 },
271 {
272 "comment" : "length = 2**31 - 1",
273 "message" : "48656c6c6f",
274 "result" : "invalid",
275 "sig" : "304102847fffffff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
276 "tcId" : 35
277 },
278 {
279 "comment" : "length = 2**31 - 1",
280 "message" : "48656c6c6f",
281 "result" : "invalid",
282 "sig" : "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd02847fffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
283 "tcId" : 36
284 },
285 {
286 "comment" : "length = 2**32 - 1",
287 "message" : "48656c6c6f",
288 "result" : "invalid",
289 "sig" : "3084ffffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
290 "tcId" : 37
291 },
292 {
293 "comment" : "length = 2**32 - 1",
294 "message" : "48656c6c6f",
295 "result" : "invalid",
296 "sig" : "30410284ffffffff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
297 "tcId" : 38
298 },
299 {
300 "comment" : "length = 2**32 - 1",
301 "message" : "48656c6c6f",
302 "result" : "invalid",
303 "sig" : "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0284ffffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
304 "tcId" : 39
305 },
306 {
307 "comment" : "length = 2**40 - 1",
308 "message" : "48656c6c6f",
309 "result" : "invalid",
310 "sig" : "3085ffffffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
311 "tcId" : 40
312 },
313 {
314 "comment" : "length = 2**40 - 1",
315 "message" : "48656c6c6f",
316 "result" : "invalid",
317 "sig" : "30420285ffffffffff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
318 "tcId" : 41
319 },
320 {
321 "comment" : "length = 2**40 - 1",
322 "message" : "48656c6c6f",
323 "result" : "invalid",
324 "sig" : "3042021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0285ffffffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
325 "tcId" : 42
326 },
327 {
328 "comment" : "length = 2**64 - 1",
329 "message" : "48656c6c6f",
330 "result" : "invalid",
331 "sig" : "3088ffffffffffffffff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
332 "tcId" : 43
333 },
334 {
335 "comment" : "length = 2**64 - 1",
336 "message" : "48656c6c6f",
337 "result" : "invalid",
338 "sig" : "30450288ffffffffffffffff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
339 "tcId" : 44
340 },
341 {
342 "comment" : "length = 2**64 - 1",
343 "message" : "48656c6c6f",
344 "result" : "invalid",
345 "sig" : "3045021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0288ffffffffffffffff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
346 "tcId" : 45
347 },
348 {
349 "comment" : "incorrect length",
350 "message" : "48656c6c6f",
351 "result" : "invalid",
352 "sig" : "30ff021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
353 "tcId" : 46
354 },
355 {
356 "comment" : "incorrect length",
357 "message" : "48656c6c6f",
358 "result" : "invalid",
359 "sig" : "303d02ff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
360 "tcId" : 47
361 },
362 {
363 "comment" : "incorrect length",
364 "message" : "48656c6c6f",
365 "result" : "invalid",
366 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd02ff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
367 "tcId" : 48
368 },
369 {
370 "comment" : "indefinte length without termination",
371 "message" : "48656c6c6f",
372 "result" : "invalid",
373 "sig" : "3080021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
374 "tcId" : 49
375 },
376 {
377 "comment" : "indefinte length without termination",
378 "message" : "48656c6c6f",
379 "result" : "invalid",
380 "sig" : "303d02801e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
381 "tcId" : 50
382 },
383 {
384 "comment" : "indefinte length without termination",
385 "message" : "48656c6c6f",
386 "result" : "invalid",
387 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd028000ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
388 "tcId" : 51
389 },
390 {
391 "comment" : "removing sequence",
392 "message" : "48656c6c6f",
393 "result" : "invalid",
394 "sig" : "",
395 "tcId" : 52
396 },
397 {
398 "comment" : "appending 0's to sequence",
399 "message" : "48656c6c6f",
400 "result" : "invalid",
401 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
402 "tcId" : 53
403 },
404 {
405 "comment" : "prepending 0's to sequence",
406 "message" : "48656c6c6f",
407 "result" : "invalid",
408 "sig" : "303f0000021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
409 "tcId" : 54
410 },
411 {
412 "comment" : "appending unused 0's",
413 "message" : "48656c6c6f",
414 "result" : "invalid",
415 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
416 "tcId" : 55
417 },
418 {
419 "comment" : "appending unused 0's",
420 "message" : "48656c6c6f",
421 "result" : "invalid",
422 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0000021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
423 "tcId" : 56
424 },
425 {
426 "comment" : "appending null value",
427 "message" : "48656c6c6f",
428 "result" : "invalid",
429 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360500",
430 "tcId" : 57
431 },
432 {
433 "comment" : "appending null value",
434 "message" : "48656c6c6f",
435 "result" : "invalid",
436 "sig" : "303f021e1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0500021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
437 "tcId" : 58
438 },
439 {
440 "comment" : "appending null value",
441 "message" : "48656c6c6f",
442 "result" : "invalid",
443 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021f00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360500",
444 "tcId" : 59
445 },
446 {
447 "comment" : "including garbage",
448 "message" : "48656c6c6f",
449 "result" : "invalid",
450 "sig" : "3042498177303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
451 "tcId" : 60
452 },
453 {
454 "comment" : "including garbage",
455 "message" : "48656c6c6f",
456 "result" : "invalid",
457 "sig" : "30412500303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
458 "tcId" : 61
459 },
460 {
461 "comment" : "including garbage",
462 "message" : "48656c6c6f",
463 "result" : "invalid",
464 "sig" : "303f303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360004deadbeef",
465 "tcId" : 62
466 },
467 {
468 "comment" : "including garbage",
469 "message" : "48656c6c6f",
470 "result" : "invalid",
471 "sig" : "30422221498177021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
472 "tcId" : 63
473 },
474 {
475 "comment" : "including garbage",
476 "message" : "48656c6c6f",
477 "result" : "invalid",
478 "sig" : "304122202500021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
479 "tcId" : 64
480 },
481 {
482 "comment" : "including garbage",
483 "message" : "48656c6c6f",
484 "result" : "invalid",
485 "sig" : "3045221e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0004deadbeef021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
486 "tcId" : 65
487 },
488 {
489 "comment" : "including garbage",
490 "message" : "48656c6c6f",
491 "result" : "invalid",
492 "sig" : "3042021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd2222498177021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
493 "tcId" : 66
494 },
495 {
496 "comment" : "including garbage",
497 "message" : "48656c6c6f",
498 "result" : "invalid",
499 "sig" : "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd22212500021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
500 "tcId" : 67
501 },
502 {
503 "comment" : "including garbage",
504 "message" : "48656c6c6f",
505 "result" : "invalid",
506 "sig" : "3045021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd221f021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360004deadbeef",
507 "tcId" : 68
508 },
509 {
510 "comment" : "including undefined tags",
511 "message" : "48656c6c6f",
512 "result" : "invalid",
513 "sig" : "3045aa00bb00cd00303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
514 "tcId" : 69
515 },
516 {
517 "comment" : "including undefined tags",
518 "message" : "48656c6c6f",
519 "result" : "invalid",
520 "sig" : "3043aa02aabb303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
521 "tcId" : 70
522 },
523 {
524 "comment" : "including undefined tags",
525 "message" : "48656c6c6f",
526 "result" : "invalid",
527 "sig" : "30452224aa00bb00cd00021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
528 "tcId" : 71
529 },
530 {
531 "comment" : "including undefined tags",
532 "message" : "48656c6c6f",
533 "result" : "invalid",
534 "sig" : "30432222aa02aabb021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
535 "tcId" : 72
536 },
537 {
538 "comment" : "including undefined tags",
539 "message" : "48656c6c6f",
540 "result" : "invalid",
541 "sig" : "3045021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd2225aa00bb00cd00021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
542 "tcId" : 73
543 },
544 {
545 "comment" : "including undefined tags",
546 "message" : "48656c6c6f",
547 "result" : "invalid",
548 "sig" : "3043021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd2223aa02aabb021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
549 "tcId" : 74
550 },
551 {
552 "comment" : "using composition with indefinite length",
553 "message" : "48656c6c6f",
554 "result" : "invalid",
555 "sig" : "3080303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
556 "tcId" : 75
557 },
558 {
559 "comment" : "using composition with indefinite length",
560 "message" : "48656c6c6f",
561 "result" : "invalid",
562 "sig" : "30412280021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0000021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
563 "tcId" : 76
564 },
565 {
566 "comment" : "using composition with indefinite length",
567 "message" : "48656c6c6f",
568 "result" : "invalid",
569 "sig" : "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd2280021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
570 "tcId" : 77
571 },
572 {
573 "comment" : "using composition with wrong tag",
574 "message" : "48656c6c6f",
575 "result" : "invalid",
576 "sig" : "3080313d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
577 "tcId" : 78
578 },
579 {
580 "comment" : "using composition with wrong tag",
581 "message" : "48656c6c6f",
582 "result" : "invalid",
583 "sig" : "30412280031c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0000021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
584 "tcId" : 79
585 },
586 {
587 "comment" : "using composition with wrong tag",
588 "message" : "48656c6c6f",
589 "result" : "invalid",
590 "sig" : "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd2280031d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
591 "tcId" : 80
592 },
593 {
594 "comment" : "changing tag value",
595 "message" : "48656c6c6f",
596 "result" : "invalid",
597 "sig" : "2e3d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
598 "tcId" : 81
599 },
600 {
601 "comment" : "changing tag value",
602 "message" : "48656c6c6f",
603 "result" : "invalid",
604 "sig" : "323d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
605 "tcId" : 82
606 },
607 {
608 "comment" : "changing tag value",
609 "message" : "48656c6c6f",
610 "result" : "invalid",
611 "sig" : "ff3d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
612 "tcId" : 83
613 },
614 {
615 "comment" : "changing tag value",
616 "message" : "48656c6c6f",
617 "result" : "invalid",
618 "sig" : "303d001c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
619 "tcId" : 84
620 },
621 {
622 "comment" : "changing tag value",
623 "message" : "48656c6c6f",
624 "result" : "invalid",
625 "sig" : "303d041c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
626 "tcId" : 85
627 },
628 {
629 "comment" : "changing tag value",
630 "message" : "48656c6c6f",
631 "result" : "invalid",
632 "sig" : "303dff1c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
633 "tcId" : 86
634 },
635 {
636 "comment" : "changing tag value",
637 "message" : "48656c6c6f",
638 "result" : "invalid",
639 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd001d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
640 "tcId" : 87
641 },
642 {
643 "comment" : "changing tag value",
644 "message" : "48656c6c6f",
645 "result" : "invalid",
646 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd041d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
647 "tcId" : 88
648 },
649 {
650 "comment" : "changing tag value",
651 "message" : "48656c6c6f",
652 "result" : "invalid",
653 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cdff1d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
654 "tcId" : 89
655 },
656 {
657 "comment" : "dropping value of sequence",
658 "message" : "48656c6c6f",
659 "result" : "invalid",
660 "sig" : "3000",
661 "tcId" : 90
662 },
663 {
664 "comment" : "using composition",
665 "message" : "48656c6c6f",
666 "result" : "invalid",
667 "sig" : "3041300102303c1c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
668 "tcId" : 91
669 },
670 {
671 "comment" : "using composition",
672 "message" : "48656c6c6f",
673 "result" : "invalid",
674 "sig" : "3041222002011e021b41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
675 "tcId" : 92
676 },
677 {
678 "comment" : "using composition",
679 "message" : "48656c6c6f",
680 "result" : "invalid",
681 "sig" : "3041021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd2221020100021cade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
682 "tcId" : 93
683 },
684 {
685 "comment" : "truncate sequence",
686 "message" : "48656c6c6f",
687 "result" : "invalid",
688 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862",
689 "tcId" : 94
690 },
691 {
692 "comment" : "truncate sequence",
693 "message" : "48656c6c6f",
694 "result" : "invalid",
695 "sig" : "303c1c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
696 "tcId" : 95
697 },
698 {
699 "comment" : "prepend empty sequence",
700 "message" : "48656c6c6f",
701 "result" : "invalid",
702 "sig" : "303f3000021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
703 "tcId" : 96
704 },
705 {
706 "comment" : "append empty sequence",
707 "message" : "48656c6c6f",
708 "result" : "invalid",
709 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862363000",
710 "tcId" : 97
711 },
712 {
713 "comment" : "sequence of sequence",
714 "message" : "48656c6c6f",
715 "result" : "invalid",
716 "sig" : "303f303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
717 "tcId" : 98
718 },
719 {
720 "comment" : "truncated sequence",
721 "message" : "48656c6c6f",
722 "result" : "invalid",
723 "sig" : "301e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd",
724 "tcId" : 99
725 },
726 {
727 "comment" : "repeat element in sequence",
728 "message" : "48656c6c6f",
729 "result" : "invalid",
730 "sig" : "305c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
731 "tcId" : 100
732 },
733 {
734 "comment" : "removing integer",
735 "message" : "48656c6c6f",
736 "result" : "invalid",
737 "sig" : "301f021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
738 "tcId" : 101
739 },
740 {
741 "comment" : "appending 0's to integer",
742 "message" : "48656c6c6f",
743 "result" : "invalid",
744 "sig" : "303f021e1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0000021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
745 "tcId" : 102
746 },
747 {
748 "comment" : "appending 0's to integer",
749 "message" : "48656c6c6f",
750 "result" : "invalid",
751 "sig" : "303f021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021f00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862360000",
752 "tcId" : 103
753 },
754 {
755 "comment" : "dropping value of integer",
756 "message" : "48656c6c6f",
757 "result" : "invalid",
758 "sig" : "30210200021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
759 "tcId" : 104
760 },
761 {
762 "comment" : "dropping value of integer",
763 "message" : "48656c6c6f",
764 "result" : "invalid",
765 "sig" : "3020021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd0200",
766 "tcId" : 105
767 },
768 {
769 "comment" : "modify first byte of integer",
770 "message" : "48656c6c6f",
771 "result" : "invalid",
772 "sig" : "303d021c1f41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
773 "tcId" : 106
774 },
775 {
776 "comment" : "modify first byte of integer",
777 "message" : "48656c6c6f",
778 "result" : "invalid",
779 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d01ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
780 "tcId" : 107
781 },
782 {
783 "comment" : "modify last byte of integer",
784 "message" : "48656c6c6f",
785 "result" : "invalid",
786 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cc021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
787 "tcId" : 108
788 },
789 {
790 "comment" : "modify last byte of integer",
791 "message" : "48656c6c6f",
792 "result" : "invalid",
793 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786237",
794 "tcId" : 109
795 },
796 {
797 "comment" : "truncate integer",
798 "message" : "48656c6c6f",
799 "result" : "invalid",
800 "sig" : "303c021b1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
801 "tcId" : 110
802 },
803 {
804 "comment" : "truncate integer",
805 "message" : "48656c6c6f",
806 "result" : "invalid",
807 "sig" : "303c021b41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
808 "tcId" : 111
809 },
810 {
811 "comment" : "truncate integer",
812 "message" : "48656c6c6f",
813 "result" : "invalid",
814 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021c00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe87862",
815 "tcId" : 112
816 },
817 {
818 "comment" : "leading ff in integer",
819 "message" : "48656c6c6f",
820 "result" : "invalid",
821 "sig" : "303e021dff1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
822 "tcId" : 113
823 },
824 {
825 "comment" : "leading ff in integer",
826 "message" : "48656c6c6f",
827 "result" : "invalid",
828 "sig" : "303e021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021eff00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
829 "tcId" : 114
830 },
831 {
832 "comment" : "infinity",
833 "message" : "48656c6c6f",
834 "result" : "invalid",
835 "sig" : "3022090180021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
836 "tcId" : 115
837 },
838 {
839 "comment" : "infinity",
840 "message" : "48656c6c6f",
841 "result" : "invalid",
842 "sig" : "3021021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd090180",
843 "tcId" : 116
844 },
845 {
846 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
847 "message" : "48656c6c6f",
848 "result" : "invalid",
849 "sig" : "303e021d00d9384b2032d060e59848f87cb4535936bc25fa77959e96d7f88e332a021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
850 "tcId" : 117
851 },
852 {
853 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
854 "message" : "48656c6c6f",
855 "result" : "invalid",
856 "sig" : "303e021dff634b1dd327de7125da7903ad2163ca2addc096101fd395567ee36070021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
857 "tcId" : 118
858 },
859 {
860 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
861 "message" : "48656c6c6f",
862 "result" : "invalid",
863 "sig" : "303d021ce1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
864 "tcId" : 119
865 },
866 {
867 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
868 "message" : "48656c6c6f",
869 "result" : "invalid",
870 "sig" : "303e021d009cb4e22cd8218eda2586fc52de9c35d5223f69efe02c6aa9811c9f90021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
871 "tcId" : 120
872 },
873 {
874 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
875 "message" : "48656c6c6f",
876 "result" : "invalid",
877 "sig" : "303e021dff26c7b4dfcd2f9f1a67b707834baca6c943da05886a6169280771ccd6021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
878 "tcId" : 121
879 },
880 {
881 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
882 "message" : "48656c6c6f",
883 "result" : "invalid",
884 "sig" : "303e021d011e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
885 "tcId" : 122
886 },
887 {
888 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
889 "message" : "48656c6c6f",
890 "result" : "invalid",
891 "sig" : "303e021d00e1be4b8652a896fa469f01eb15246e4f330cb7bc2546e9e8c4473633021d00ade65988d237d30f9ef41dd424a4e1c8f16967cf3365813fe8786236",
892 "tcId" : 123
893 },
894 {
895 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
896 "message" : "48656c6c6f",
897 "result" : "invalid",
898 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021d0168dcf02f57b0caef7ddc183bee1ca94ee09c1a02ee4b0200a54dcb93",
899 "tcId" : 124
900 },
901 {
902 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
903 "message" : "48656c6c6f",
904 "result" : "invalid",
905 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021cf2efc2e24cbedb2fc00c236c5b2d1a430236b59b7880007f2ba2f8d9",
906 "tcId" : 125
907 },
908 {
909 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
910 "message" : "48656c6c6f",
911 "result" : "invalid",
912 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021dff5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
913 "tcId" : 126
914 },
915 {
916 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
917 "message" : "48656c6c6f",
918 "result" : "invalid",
919 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021c0d103d1db34124d03ff3dc93a4d2e5bcfdc94a64877fff80d45d0727",
920 "tcId" : 127
921 },
922 {
923 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
924 "message" : "48656c6c6f",
925 "result" : "invalid",
926 "sig" : "303d021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021dfe97230fd0a84f35108223e7c411e356b11f63e5fd11b4fdff5ab2346d",
927 "tcId" : 128
928 },
929 {
930 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
931 "message" : "48656c6c6f",
932 "result" : "invalid",
933 "sig" : "303c021c1e41b479ad576905b960fe14eadb91b0ccf34843dab916173bb8c9cd021c5219a6772dc82cf0610be22bdb5b1e370e969830cc9a7ec017879dca",
934 "tcId" : 129
935 },
936 {
937 "comment" : "Signatures with special case values for r and s.",
938 "message" : "48656c6c6f",
939 "result" : "invalid",
940 "sig" : "3022020100021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
941 "tcId" : 130
942 },
943 {
944 "comment" : "Signatures with special case values for r and s.",
945 "message" : "48656c6c6f",
946 "result" : "invalid",
947 "sig" : "3006020100020100",
948 "tcId" : 131
949 },
950 {
951 "comment" : "Signatures with special case values for r and s.",
952 "message" : "48656c6c6f",
953 "result" : "invalid",
954 "sig" : "3006020100020101",
955 "tcId" : 132
956 },
957 {
958 "comment" : "Signatures with special case values for r and s.",
959 "message" : "48656c6c6f",
960 "result" : "invalid",
961 "sig" : "30060201000201f0",
962 "tcId" : 133
963 },
964 {
965 "comment" : "Signatures with special case values for r and s.",
966 "message" : "48656c6c6f",
967 "result" : "invalid",
968 "sig" : "3022020100021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
969 "tcId" : 134
970 },
971 {
972 "comment" : "Signatures with special case values for r and s.",
973 "message" : "48656c6c6f",
974 "result" : "invalid",
975 "sig" : "3022020100021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
976 "tcId" : 135
977 },
978 {
979 "comment" : "Signatures with special case values for r and s.",
980 "message" : "48656c6c6f",
981 "result" : "invalid",
982 "sig" : "3022020100021d0100000000000000000000000000000000000000000000000000000000",
983 "tcId" : 136
984 },
985 {
986 "comment" : "Signatures with special case values for r and s.",
987 "message" : "48656c6c6f",
988 "result" : "invalid",
989 "sig" : "3082010802010002820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
990 "tcId" : 137
991 },
992 {
993 "comment" : "Signatures with special case values for r and s.",
994 "message" : "48656c6c6f",
995 "result" : "invalid",
996 "sig" : "3008020100090380fe01",
997 "tcId" : 138
998 },
999 {
1000 "comment" : "Signatures with special case values for r and s.",
1001 "message" : "48656c6c6f",
1002 "result" : "invalid",
1003 "sig" : "3022020101021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1004 "tcId" : 139
1005 },
1006 {
1007 "comment" : "Signatures with special case values for r and s.",
1008 "message" : "48656c6c6f",
1009 "result" : "invalid",
1010 "sig" : "3006020101020100",
1011 "tcId" : 140
1012 },
1013 {
1014 "comment" : "Signatures with special case values for r and s.",
1015 "message" : "48656c6c6f",
1016 "result" : "invalid",
1017 "sig" : "3006020101020101",
1018 "tcId" : 141
1019 },
1020 {
1021 "comment" : "Signatures with special case values for r and s.",
1022 "message" : "48656c6c6f",
1023 "result" : "invalid",
1024 "sig" : "30060201010201f0",
1025 "tcId" : 142
1026 },
1027 {
1028 "comment" : "Signatures with special case values for r and s.",
1029 "message" : "48656c6c6f",
1030 "result" : "invalid",
1031 "sig" : "3022020101021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1032 "tcId" : 143
1033 },
1034 {
1035 "comment" : "Signatures with special case values for r and s.",
1036 "message" : "48656c6c6f",
1037 "result" : "invalid",
1038 "sig" : "3022020101021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1039 "tcId" : 144
1040 },
1041 {
1042 "comment" : "Signatures with special case values for r and s.",
1043 "message" : "48656c6c6f",
1044 "result" : "invalid",
1045 "sig" : "3022020101021d0100000000000000000000000000000000000000000000000000000000",
1046 "tcId" : 145
1047 },
1048 {
1049 "comment" : "Signatures with special case values for r and s.",
1050 "message" : "48656c6c6f",
1051 "result" : "invalid",
1052 "sig" : "3082010802010102820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1053 "tcId" : 146
1054 },
1055 {
1056 "comment" : "Signatures with special case values for r and s.",
1057 "message" : "48656c6c6f",
1058 "result" : "invalid",
1059 "sig" : "3008020101090380fe01",
1060 "tcId" : 147
1061 },
1062 {
1063 "comment" : "Signatures with special case values for r and s.",
1064 "message" : "48656c6c6f",
1065 "result" : "invalid",
1066 "sig" : "30220201f0021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1067 "tcId" : 148
1068 },
1069 {
1070 "comment" : "Signatures with special case values for r and s.",
1071 "message" : "48656c6c6f",
1072 "result" : "invalid",
1073 "sig" : "30060201f0020100",
1074 "tcId" : 149
1075 },
1076 {
1077 "comment" : "Signatures with special case values for r and s.",
1078 "message" : "48656c6c6f",
1079 "result" : "invalid",
1080 "sig" : "30060201f0020101",
1081 "tcId" : 150
1082 },
1083 {
1084 "comment" : "Signatures with special case values for r and s.",
1085 "message" : "48656c6c6f",
1086 "result" : "invalid",
1087 "sig" : "30060201f00201f0",
1088 "tcId" : 151
1089 },
1090 {
1091 "comment" : "Signatures with special case values for r and s.",
1092 "message" : "48656c6c6f",
1093 "result" : "invalid",
1094 "sig" : "30220201f0021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1095 "tcId" : 152
1096 },
1097 {
1098 "comment" : "Signatures with special case values for r and s.",
1099 "message" : "48656c6c6f",
1100 "result" : "invalid",
1101 "sig" : "30220201f0021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1102 "tcId" : 153
1103 },
1104 {
1105 "comment" : "Signatures with special case values for r and s.",
1106 "message" : "48656c6c6f",
1107 "result" : "invalid",
1108 "sig" : "30220201f0021d0100000000000000000000000000000000000000000000000000000000",
1109 "tcId" : 154
1110 },
1111 {
1112 "comment" : "Signatures with special case values for r and s.",
1113 "message" : "48656c6c6f",
1114 "result" : "invalid",
1115 "sig" : "308201080201f002820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1116 "tcId" : 155
1117 },
1118 {
1119 "comment" : "Signatures with special case values for r and s.",
1120 "message" : "48656c6c6f",
1121 "result" : "invalid",
1122 "sig" : "30080201f0090380fe01",
1123 "tcId" : 156
1124 },
1125 {
1126 "comment" : "Signatures with special case values for r and s.",
1127 "message" : "48656c6c6f",
1128 "result" : "invalid",
1129 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1130 "tcId" : 157
1131 },
1132 {
1133 "comment" : "Signatures with special case values for r and s.",
1134 "message" : "48656c6c6f",
1135 "result" : "invalid",
1136 "sig" : "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d020100",
1137 "tcId" : 158
1138 },
1139 {
1140 "comment" : "Signatures with special case values for r and s.",
1141 "message" : "48656c6c6f",
1142 "result" : "invalid",
1143 "sig" : "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d020101",
1144 "tcId" : 159
1145 },
1146 {
1147 "comment" : "Signatures with special case values for r and s.",
1148 "message" : "48656c6c6f",
1149 "result" : "invalid",
1150 "sig" : "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d0201f0",
1151 "tcId" : 160
1152 },
1153 {
1154 "comment" : "Signatures with special case values for r and s.",
1155 "message" : "48656c6c6f",
1156 "result" : "invalid",
1157 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1158 "tcId" : 161
1159 },
1160 {
1161 "comment" : "Signatures with special case values for r and s.",
1162 "message" : "48656c6c6f",
1163 "result" : "invalid",
1164 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1165 "tcId" : 162
1166 },
1167 {
1168 "comment" : "Signatures with special case values for r and s.",
1169 "message" : "48656c6c6f",
1170 "result" : "invalid",
1171 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d021d0100000000000000000000000000000000000000000000000000000000",
1172 "tcId" : 163
1173 },
1174 {
1175 "comment" : "Signatures with special case values for r and s.",
1176 "message" : "48656c6c6f",
1177 "result" : "invalid",
1178 "sig" : "30820124021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1179 "tcId" : 164
1180 },
1181 {
1182 "comment" : "Signatures with special case values for r and s.",
1183 "message" : "48656c6c6f",
1184 "result" : "invalid",
1185 "sig" : "3024021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d090380fe01",
1186 "tcId" : 165
1187 },
1188 {
1189 "comment" : "Signatures with special case values for r and s.",
1190 "message" : "48656c6c6f",
1191 "result" : "invalid",
1192 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1193 "tcId" : 166
1194 },
1195 {
1196 "comment" : "Signatures with special case values for r and s.",
1197 "message" : "48656c6c6f",
1198 "result" : "invalid",
1199 "sig" : "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e020100",
1200 "tcId" : 167
1201 },
1202 {
1203 "comment" : "Signatures with special case values for r and s.",
1204 "message" : "48656c6c6f",
1205 "result" : "invalid",
1206 "sig" : "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e020101",
1207 "tcId" : 168
1208 },
1209 {
1210 "comment" : "Signatures with special case values for r and s.",
1211 "message" : "48656c6c6f",
1212 "result" : "invalid",
1213 "sig" : "3022021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e0201f0",
1214 "tcId" : 169
1215 },
1216 {
1217 "comment" : "Signatures with special case values for r and s.",
1218 "message" : "48656c6c6f",
1219 "result" : "invalid",
1220 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1221 "tcId" : 170
1222 },
1223 {
1224 "comment" : "Signatures with special case values for r and s.",
1225 "message" : "48656c6c6f",
1226 "result" : "invalid",
1227 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1228 "tcId" : 171
1229 },
1230 {
1231 "comment" : "Signatures with special case values for r and s.",
1232 "message" : "48656c6c6f",
1233 "result" : "invalid",
1234 "sig" : "303e021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e021d0100000000000000000000000000000000000000000000000000000000",
1235 "tcId" : 172
1236 },
1237 {
1238 "comment" : "Signatures with special case values for r and s.",
1239 "message" : "48656c6c6f",
1240 "result" : "invalid",
1241 "sig" : "30820124021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1242 "tcId" : 173
1243 },
1244 {
1245 "comment" : "Signatures with special case values for r and s.",
1246 "message" : "48656c6c6f",
1247 "result" : "invalid",
1248 "sig" : "3024021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e090380fe01",
1249 "tcId" : 174
1250 },
1251 {
1252 "comment" : "Signatures with special case values for r and s.",
1253 "message" : "48656c6c6f",
1254 "result" : "invalid",
1255 "sig" : "303e021d0100000000000000000000000000000000000000000000000000000000021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1256 "tcId" : 175
1257 },
1258 {
1259 "comment" : "Signatures with special case values for r and s.",
1260 "message" : "48656c6c6f",
1261 "result" : "invalid",
1262 "sig" : "3022021d0100000000000000000000000000000000000000000000000000000000020100",
1263 "tcId" : 176
1264 },
1265 {
1266 "comment" : "Signatures with special case values for r and s.",
1267 "message" : "48656c6c6f",
1268 "result" : "invalid",
1269 "sig" : "3022021d0100000000000000000000000000000000000000000000000000000000020101",
1270 "tcId" : 177
1271 },
1272 {
1273 "comment" : "Signatures with special case values for r and s.",
1274 "message" : "48656c6c6f",
1275 "result" : "invalid",
1276 "sig" : "3022021d01000000000000000000000000000000000000000000000000000000000201f0",
1277 "tcId" : 178
1278 },
1279 {
1280 "comment" : "Signatures with special case values for r and s.",
1281 "message" : "48656c6c6f",
1282 "result" : "invalid",
1283 "sig" : "303e021d0100000000000000000000000000000000000000000000000000000000021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1284 "tcId" : 179
1285 },
1286 {
1287 "comment" : "Signatures with special case values for r and s.",
1288 "message" : "48656c6c6f",
1289 "result" : "invalid",
1290 "sig" : "303e021d0100000000000000000000000000000000000000000000000000000000021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1291 "tcId" : 180
1292 },
1293 {
1294 "comment" : "Signatures with special case values for r and s.",
1295 "message" : "48656c6c6f",
1296 "result" : "invalid",
1297 "sig" : "303e021d0100000000000000000000000000000000000000000000000000000000021d0100000000000000000000000000000000000000000000000000000000",
1298 "tcId" : 181
1299 },
1300 {
1301 "comment" : "Signatures with special case values for r and s.",
1302 "message" : "48656c6c6f",
1303 "result" : "invalid",
1304 "sig" : "30820124021d010000000000000000000000000000000000000000000000000000000002820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1305 "tcId" : 182
1306 },
1307 {
1308 "comment" : "Signatures with special case values for r and s.",
1309 "message" : "48656c6c6f",
1310 "result" : "invalid",
1311 "sig" : "3024021d0100000000000000000000000000000000000000000000000000000000090380fe01",
1312 "tcId" : 183
1313 },
1314 {
1315 "comment" : "Signatures with special case values for r and s.",
1316 "message" : "48656c6c6f",
1317 "result" : "invalid",
1318 "sig" : "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1319 "tcId" : 184
1320 },
1321 {
1322 "comment" : "Signatures with special case values for r and s.",
1323 "message" : "48656c6c6f",
1324 "result" : "invalid",
1325 "sig" : "3082010802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667020100",
1326 "tcId" : 185
1327 },
1328 {
1329 "comment" : "Signatures with special case values for r and s.",
1330 "message" : "48656c6c6f",
1331 "result" : "invalid",
1332 "sig" : "3082010802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667020101",
1333 "tcId" : 186
1334 },
1335 {
1336 "comment" : "Signatures with special case values for r and s.",
1337 "message" : "48656c6c6f",
1338 "result" : "invalid",
1339 "sig" : "3082010802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd6670201f0",
1340 "tcId" : 187
1341 },
1342 {
1343 "comment" : "Signatures with special case values for r and s.",
1344 "message" : "48656c6c6f",
1345 "result" : "invalid",
1346 "sig" : "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1347 "tcId" : 188
1348 },
1349 {
1350 "comment" : "Signatures with special case values for r and s.",
1351 "message" : "48656c6c6f",
1352 "result" : "invalid",
1353 "sig" : "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1354 "tcId" : 189
1355 },
1356 {
1357 "comment" : "Signatures with special case values for r and s.",
1358 "message" : "48656c6c6f",
1359 "result" : "invalid",
1360 "sig" : "3082012402820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667021d0100000000000000000000000000000000000000000000000000000000",
1361 "tcId" : 190
1362 },
1363 {
1364 "comment" : "Signatures with special case values for r and s.",
1365 "message" : "48656c6c6f",
1366 "result" : "invalid",
1367 "sig" : "3082020a02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd66702820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1368 "tcId" : 191
1369 },
1370 {
1371 "comment" : "Signatures with special case values for r and s.",
1372 "message" : "48656c6c6f",
1373 "result" : "invalid",
1374 "sig" : "3082010a02820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667090380fe01",
1375 "tcId" : 192
1376 },
1377 {
1378 "comment" : "Signatures with special case values for r and s.",
1379 "message" : "48656c6c6f",
1380 "result" : "invalid",
1381 "sig" : "3024090380fe01021dff450969597a870820211805983688387a10cd4dcc451a7f3f432a96a3",
1382 "tcId" : 193
1383 },
1384 {
1385 "comment" : "Signatures with special case values for r and s.",
1386 "message" : "48656c6c6f",
1387 "result" : "invalid",
1388 "sig" : "3008090380fe01020100",
1389 "tcId" : 194
1390 },
1391 {
1392 "comment" : "Signatures with special case values for r and s.",
1393 "message" : "48656c6c6f",
1394 "result" : "invalid",
1395 "sig" : "3008090380fe01020101",
1396 "tcId" : 195
1397 },
1398 {
1399 "comment" : "Signatures with special case values for r and s.",
1400 "message" : "48656c6c6f",
1401 "result" : "invalid",
1402 "sig" : "3008090380fe010201f0",
1403 "tcId" : 196
1404 },
1405 {
1406 "comment" : "Signatures with special case values for r and s.",
1407 "message" : "48656c6c6f",
1408 "result" : "invalid",
1409 "sig" : "3024090380fe01021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1410 "tcId" : 197
1411 },
1412 {
1413 "comment" : "Signatures with special case values for r and s.",
1414 "message" : "48656c6c6f",
1415 "result" : "invalid",
1416 "sig" : "3024090380fe01021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695e",
1417 "tcId" : 198
1418 },
1419 {
1420 "comment" : "Signatures with special case values for r and s.",
1421 "message" : "48656c6c6f",
1422 "result" : "invalid",
1423 "sig" : "3024090380fe01021d0100000000000000000000000000000000000000000000000000000000",
1424 "tcId" : 199
1425 },
1426 {
1427 "comment" : "Signatures with special case values for r and s.",
1428 "message" : "48656c6c6f",
1429 "result" : "invalid",
1430 "sig" : "3082010a090380fe0102820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1431 "tcId" : 200
1432 },
1433 {
1434 "comment" : "Signatures with special case values for r and s.",
1435 "message" : "48656c6c6f",
1436 "result" : "invalid",
1437 "sig" : "300a090380fe01090380fe01",
1438 "tcId" : 201
1439 }
1440 ]
1441 },
1442 {
1443 "keyDer" : "308203423082023506072a8648ce3804013082022802820101008f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667021d00baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d0282010016a65c58204850704e7502a39757040d34da3a3478c154d4e4a5c02d242ee04f96e61e4bd0904abdac8f37eeb1e09f3182d23c9043cb642f88004160edf9ca09b32076a79c32a627f2473e91879ba2c4e744bd2081544cb55b802c368d1fa83ed489e94e0fa0688e32428a5c78c478c68d0527b71c9a3abb0b0be12c44689639e7d3ce74db101a65aa2b87f64c6826db3ec72f4b5599834bb4edb02f7c90e9a496d3a55d535bebfc45d4f619f63f3dedbb873925c2f224e07731296da887ec1e4748f87efb5fdeb75484316b2232dee553ddaf02112b0d1f02da30973224fe27aeda8b9d4b2922d9ba8be39ed9e103a63c52810bc688b7e2ed4316e1ef17dbde0382010500028201001e77f842b1ae0fcd9929d394161d41e14614ff7507a9a31f4a1f14d22e2a627a1f4e596624883f1a5b168e9425146f22d5f6ee28757414714bb994ba1129f015d6e04a717edf9b530a5d5cab94f14631e8b4cf79aeb358cc741845553841e8ac461630e804a62f43676ba6794af66899c377b869ea612a7b9fe6611aa96be52eb8b62c979117bbbcca8a7ec1e1ffab1c7dfcfc7048700d3ae3858136e897701d7c2921b5dfef1d1f897f50d96ca1b5c2edc58cada18919e35642f0807eebfa00c99a32f4d095c3188f78ed54711be0325c4b532aeccd6540a567c327225440ea15319bde06510479a1861799e25b57decc73c036d75a0702bd373ca231349931",
1444 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIIDQjCCAjUGByqGSM44BAEwggIoAoIBAQCPeTXZuarpv6vtiHrPSVG28y7Fnjuv\nNxjo6sSWHz79NgbnQ1GpxBgzObgJ58KuHFObp0dbhdARrbi0eYd1SYRpXKwOjxSz\nNggooi/6JxEKPWKpk0U0CaD+aWxGWPhL3SCBnDcJoBBXsZWtzQAjPbpUhLYpH51k\njviDRIZ3l5zsBLQ0pqwudemYXeI9sCkvwRGMn/qdgYHnM423krcw17njSVkvaAmY\nchU5Feo9a4tGU8YzRY+AOzKkwuDycpAlbk4/ijsIOKHEUOThjBopo33fXqFD3ktm\n/wSQPtXPFiPhWNSHxgjpfyEc2B3KI8tuOAdl+CLjQr5ITAV2OTlgHNZnAh0AuvaW\npoV499/e5/pnyXfHhe8ysjO65YDAvNVpXQKCAQAWplxYIEhQcE51AqOXVwQNNNo6\nNHjBVNTkpcAtJC7gT5bmHkvQkEq9rI837rHgnzGC0jyQQ8tkL4gAQWDt+coJsyB2\np5wypifyRz6Rh5uixOdEvSCBVEy1W4AsNo0fqD7UielOD6BojjJCilx4xHjGjQUn\ntxyaOrsLC+EsRGiWOefTznTbEBplqiuH9kxoJts+xy9LVZmDS7TtsC98kOmkltOl\nXVNb6/xF1PYZ9j897buHOSXC8iTgdzEpbaiH7B5HSPh++1/et1SEMWsiMt7lU92v\nAhErDR8C2jCXMiT+J67ai51LKSLZuovjntnhA6Y8UoELxoi34u1DFuHvF9veA4IB\nBQACggEAHnf4QrGuD82ZKdOUFh1B4UYU/3UHqaMfSh8U0i4qYnofTllmJIg/GlsW\njpQlFG8i1fbuKHV0FHFLuZS6ESnwFdbgSnF+35tTCl1cq5TxRjHotM95rrNYzHQY\nRVU4QeisRhYw6ASmL0Nna6Z5SvZomcN3uGnqYSp7n+ZhGqlr5S64tiyXkRe7vMqK\nfsHh/6scffz8cEhwDTrjhYE26JdwHXwpIbXf7x0fiX9Q2WyhtcLtxYytoYkZ41ZC\n8IB+6/oAyZoy9NCVwxiPeO1UcRvgMlxLUyrszWVApWfDJyJUQOoVMZveBlEEeaGG\nF5niW1fezHPANtdaBwK9NzyiMTSZMQ==\n-----END PUBLIC KEY-----",
1445 "sha" : "SHA-256",
1446 "type" : "DSAVer",
1447 "key" : {
1448 "g" : "16a65c58204850704e7502a39757040d34da3a3478c154d4e4a5c02d242ee04f96e61e4bd0904abdac8f37eeb1e09f3182d23c9043cb642f88004160edf9ca09b32076a79c32a627f2473e91879ba2c4e744bd2081544cb55b802c368d1fa83ed489e94e0fa0688e32428a5c78c478c68d0527b71c9a3abb0b0be12c44689639e7d3ce74db101a65aa2b87f64c6826db3ec72f4b5599834bb4edb02f7c90e9a496d3a55d535bebfc45d4f619f63f3dedbb873925c2f224e07731296da887ec1e4748f87efb5fdeb75484316b2232dee553ddaf02112b0d1f02da30973224fe27aeda8b9d4b2922d9ba8be39ed9e103a63c52810bc688b7e2ed4316e1ef17dbde",
1449 "keyType" : "DSA public key",
1450 "p" : "08f7935d9b9aae9bfabed887acf4951b6f32ec59e3baf3718e8eac4961f3efd3606e74351a9c4183339b809e7c2ae1c539ba7475b85d011adb8b47987754984695cac0e8f14b3360828a22ffa27110a3d62a993453409a0fe696c4658f84bdd20819c3709a01057b195adcd00233dba5484b6291f9d648ef883448677979cec04b434a6ac2e75e9985de23db0292fc1118c9ffa9d8181e7338db792b730d7b9e349592f68099872153915ea3d6b8b4653c633458f803b32a4c2e0f27290256e4e3f8a3b0838a1c450e4e18c1a29a37ddf5ea143de4b66ff04903ed5cf1623e158d487c608e97f211cd81dca23cb6e380765f822e342be484c05763939601cd667",
1451 "q" : "0baf696a68578f7dfdee7fa67c977c785ef32b233bae580c0bcd5695d",
1452 "y" : "1e77f842b1ae0fcd9929d394161d41e14614ff7507a9a31f4a1f14d22e2a627a1f4e596624883f1a5b168e9425146f22d5f6ee28757414714bb994ba1129f015d6e04a717edf9b530a5d5cab94f14631e8b4cf79aeb358cc741845553841e8ac461630e804a62f43676ba6794af66899c377b869ea612a7b9fe6611aa96be52eb8b62c979117bbbcca8a7ec1e1ffab1c7dfcfc7048700d3ae3858136e897701d7c2921b5dfef1d1f897f50d96ca1b5c2edc58cada18919e35642f0807eebfa00c99a32f4d095c3188f78ed54711be0325c4b532aeccd6540a567c327225440ea15319bde06510479a1861799e25b57decc73c036d75a0702bd373ca231349931"
1453 },
1454 "tests" : [
1455 {
1456 "comment" : "random signature",
1457 "message" : "54657374",
1458 "result" : "valid",
1459 "sig" : "303c021c50ab097237324f8fc734140e23c11d515939277a182712f7914986a1021c24a4522acf7885deae134d25b679fea410f8c24afdb140c909522d14",
1460 "tcId" : 202
1461 },
1462 {
1463 "comment" : "random signature",
1464 "message" : "54657374",
1465 "result" : "valid",
1466 "sig" : "303d021c79bacf75ffe84e6a2159e0152d568781f7fd41e0a14c1200b21b21b7021d00962f1d0404b0318b0e6eee0b95d22d94eb36b51b6f8884e70b973812",
1467 "tcId" : 203
1468 },
1469 {
1470 "comment" : "random signature",
1471 "message" : "54657374",
1472 "result" : "valid",
1473 "sig" : "303e021d008dea6005d17a3eaad584bed597ff29ca1c91833e1d93a398640a05c9021d00a871f0d68ac9ff53e4714555c8cdc498ccd28ec4924aaf42a65c0db9",
1474 "tcId" : 204
1475 },
1476 {
1477 "comment" : "random signature",
1478 "message" : "54657374",
1479 "result" : "valid",
1480 "sig" : "303d021d00b5e1ee34d2b07ec24262238d3ef3f691827780baaa2107be3131cfb9021c2bdbe0d5cffee75072c5c4c358a7b6dac45e763555430739b593c2fe",
1481 "tcId" : 205
1482 },
1483 {
1484 "comment" : "random signature",
1485 "message" : "54657374",
1486 "result" : "valid",
1487 "sig" : "303d021d00adf128e21e06d3d22c819904f0be159bdedfbf21fc22843255762b07021c646f551ee7e3455f8c3299e9568c581f81d31bc1d1a0373407b18dc6",
1488 "tcId" : 206
1489 }
1490 ]
1491 }
1492 ]
1493 }
0 {
1 "algorithm" : "ECDH",
2 "generatorVersion" : "0.0a11",
3 "numberOfTests" : 57,
4 "testGroups" : [
5 {
6 "type" : "ECDHComp",
7 "tests" : [
8 {
9 "comment" : "normal case",
10 "curve" : "P-256",
11 "name" : "EcdhTestVector",
12 "result" : "valid",
13 "shared" : "5af492c029f055e700150fdf074bbc3b376b3286a0e1a4feb267960bbb0a148e",
14 "tcId" : 1,
15 "private" : {
16 "crv" : "P-256",
17 "d" : "TEKm94QkBRnu2W9CQgBCYrabdRQ436q7mBfeypPoHIc",
18 "ext" : "true",
19 "kty" : "EC",
20 "x" : "WyqqM6oDsZdjGfMIvj6sGGkXhyB-6RPNgCNYBbHz7F4",
21 "y" : "h5IjGBoRRdQKxucb6rv-EVZwIqZv2XRLi3_rvK-dxSI"
22 },
23 "public" : {
24 "crv" : "P-256",
25 "ext" : "true",
26 "kty" : "EC",
27 "x" : "yISNawZIGrhSC2XREZbJe30drwGpT6gWmocmXgm12So",
28 "y" : "0dac4Rq3NgDALW02mtKKwd0hPoqR-H3kK7FohxSMzkc"
29 }
30 },
31 {
32 "comment" : "normal case",
33 "curve" : "P-384",
34 "name" : "EcdhTestVector",
35 "result" : "valid",
36 "shared" : "7ee811a7cc92be6c5d6879d6399c467675c34c1f9c2261e1df4ad7d4dc4de93d192a5020feeb61712e4401cf369700ff",
37 "tcId" : 2,
38 "private" : {
39 "crv" : "P-384",
40 "d" : "XPNFF3sB7GKqQwJJE7JfjRq-9B92mXqz1v1fWh6-uQ3mnecJw5JwbbWAPsI7NhAt",
41 "ext" : "true",
42 "kty" : "EC",
43 "x" : "ymo32uc2KIgSIck9N6h11vy4zGzXuOnw0-jvC3h_IqlOvEJ9gUXeK8XUkn7xBGvh",
44 "y" : "D0e3Bgt0wn4KwyJJDKwHqV6FB7xe3afuTXKBEV7hpj_rqFQqZZsrdz8TJUqjtD5Z"
45 },
46 "public" : {
47 "crv" : "P-384",
48 "ext" : "true",
49 "kty" : "EC",
50 "x" : "y5F1hPIu6IHPMTVd_4jagQ4S6NqKEWrV4bF5Rr04FfqRRqWWoSBNBQVhQuK_OFur",
51 "y" : "0nxF1hhtRBy9qvLFZka-r4cSfZyb86ICsdIIIJqJ6My4vouAeLucCI5TTuJqTEQ-"
52 }
53 },
54 {
55 "comment" : "edge cases for shared secret",
56 "curve" : "P-256",
57 "name" : "EcdhTestVector",
58 "result" : "valid",
59 "shared" : "0000000000000000000000000000000000000000000000000000000000000000",
60 "tcId" : 4,
61 "private" : {
62 "crv" : "P-256",
63 "d" : "V3__4ATEMyhY8ARpZPC-Tl_iZS6vzyYWdDu8Y6sBg3k",
64 "ext" : "true",
65 "kty" : "EC",
66 "x" : "I7gdSwHAhxe3tQ8izFrv0PsGLoIA2Mskr1QoWPE4Bi8",
67 "y" : "CNN26pJpxC4OZYPeFbigQYBnb4r1OrUsf1l2wz5uIuc"
68 },
69 "public" : {
70 "crv" : "P-256",
71 "ext" : "true",
72 "kty" : "EC",
73 "x" : "Z_TxDYzhUV5lUiOTCuRbbYQwp1KNzMBZ7L9_8NSZzpQ",
74 "y" : "PVLyBeRI9xmjw-s9oUkWNH4Vurydaps86bzHPismQWg"
75 }
76 },
77 {
78 "comment" : "edge cases for shared secret",
79 "curve" : "P-256",
80 "name" : "EcdhTestVector",
81 "result" : "valid",
82 "shared" : "00000000ffffffff00000000ffffffff00000000ffffffff0000000100000000",
83 "tcId" : 5,
84 "private" : {
85 "crv" : "P-256",
86 "d" : "FY8M1ObgQ6QJpszBP4-649T22PFI17GyzzxJeMqUGng",
87 "ext" : "true",
88 "kty" : "EC",
89 "x" : "SjM1g2j5_2Np3xDBYW_i7BsxFkFO2cl5OGRVGhfrHBg",
90 "y" : "AvVlj5C266JG6T5Ohhu2idHQcrIjuJsbvRApRAhXQvk"
91 },
92 "public" : {
93 "crv" : "P-256",
94 "ext" : "true",
95 "kty" : "EC",
96 "x" : "3wOehQMUhX2O2yc_8yPZ0mb5l0jvPn_PUsqRbOs2PwM",
97 "y" : "zZycmVJCIQlJaHWyUSEz7taOqXI4v_0UEJQz2sSp-Nk"
98 }
99 },
100 {
101 "comment" : "edge cases for shared secret",
102 "curve" : "P-256",
103 "name" : "EcdhTestVector",
104 "result" : "valid",
105 "shared" : "0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff00010001",
106 "tcId" : 6,
107 "private" : {
108 "crv" : "P-256",
109 "d" : "GQkQmmjEUaDxUMYyhE-cMN5WPQXe4YHR-Sd4b_bkD_0",
110 "ext" : "true",
111 "kty" : "EC",
112 "x" : "cTTJ44nkV_b62xyriRhErvgE0Ul0WY8594uT18wY2eI",
113 "y" : "lCFFPIrYYgK2qZCzIb8Mp6dT0-8UMEmc_HOU_R75coA"
114 },
115 "public" : {
116 "crv" : "P-256",
117 "ext" : "true",
118 "kty" : "EC",
119 "x" : "JdqrnBMBeqmPeE1x15Q8XnaPABJIH7yncU43kF2FTwY",
120 "y" : "WPiNVKFUExBWMeKqfay65gysGzyd4XOfJ6nCv9I0oOw"
121 }
122 },
123 {
124 "comment" : "edge cases for shared secret",
125 "curve" : "P-256",
126 "name" : "EcdhTestVector",
127 "result" : "valid",
128 "shared" : "7fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff",
129 "tcId" : 7,
130 "private" : {
131 "crv" : "P-256",
132 "d" : "00-WuNQUk2E8yO_NxDljiGGOdWRVGL1sGd7JOOkPnOM",
133 "ext" : "true",
134 "kty" : "EC",
135 "x" : "2f8GYyCcsHFQo0hGPSu8FbTOIychG7d-b7d8iEch_-0",
136 "y" : "yCsGEV5BgWq-Y-7zt21qghpZVy9P3cMS09tC2DrO0QA"
137 },
138 "public" : {
139 "crv" : "P-256",
140 "ext" : "true",
141 "kty" : "EC",
142 "x" : "gGBkbTWiSK0C0KjZBpUn0G6pwplS9Y2mCQusShezSx4",
143 "y" : "vmXp2Bh6znrY0dNYS07MxpmpV-4yfzwy6rrC3UlZetM"
144 }
145 },
146 {
147 "comment" : "edge cases for shared secret",
148 "curve" : "P-256",
149 "name" : "EcdhTestVector",
150 "result" : "valid",
151 "shared" : "8000000000000000000000000000000000000000000000000000000000000004",
152 "tcId" : 8,
153 "private" : {
154 "crv" : "P-256",
155 "d" : "Wj2UZ9nw8WmL8VSGJ4L0NhUMjBA9iMqrImBT1zA_pcA",
156 "ext" : "true",
157 "kty" : "EC",
158 "x" : "LXoHReBeihHt83forxIbehHNNH1VLhs1eYvKUGkKrY0",
159 "y" : "uTDrHtcNtyhy-Y_6_Mc-t5e2-iOvqNWgJw7sC7AozgU"
160 },
161 "public" : {
162 "crv" : "P-256",
163 "ext" : "true",
164 "kty" : "EC",
165 "x" : "q8GaAT7v2FB6SxuTPVFVM8y_rSoSnqiwpxZ_Hu8ObQI",
166 "y" : "nHZLhfynaWPPWAFvx1K9UdzX8z_UCU5d55A5SX550CY"
167 }
168 },
169 {
170 "comment" : "edge cases for shared secret",
171 "curve" : "P-256",
172 "name" : "EcdhTestVector",
173 "result" : "valid",
174 "shared" : "ff00000001fffffffc00000007fffffff00000001fffffffc00000007fffffff",
175 "tcId" : 9,
176 "private" : {
177 "crv" : "P-256",
178 "d" : "X3n2bE6P1Vjxqea9LDFYrzhmrpNC6ec_AsYE0efWmbw",
179 "ext" : "true",
180 "kty" : "EC",
181 "x" : "g35sLwD15_TqXQUHszyc5c_N9hsfLqsFp9mtBjSmqSM",
182 "y" : "-UvQSiSIpJkLPEKy33MbvcJc9nENkv4QExgUBQB4HtE"
183 },
184 "public" : {
185 "crv" : "P-256",
186 "ext" : "true",
187 "kty" : "EC",
188 "x" : "nhtwFE914Csb_UApjwESl2tZvPbtRJHPqISi4x2-y5o",
189 "y" : "SQBYhqVRzPNiih8_eNfCqRRQGc-SxYmdMbJwoisd2Fs"
190 }
191 },
192 {
193 "comment" : "edge cases for shared secret",
194 "curve" : "P-256",
195 "name" : "EcdhTestVector",
196 "result" : "valid",
197 "shared" : "ffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff",
198 "tcId" : 10,
199 "private" : {
200 "crv" : "P-256",
201 "d" : "GYByC6k5US0eYVKwWavZdx7F-OpKAbWiO-ZpsDU4Qr0",
202 "ext" : "true",
203 "kty" : "EC",
204 "x" : "lGtMphj7_zUNmVfFHAcS9z9OCSweJ04l6DkWSLBszHE",
205 "y" : "vGESfIjmiAXDa9zDhdHfBwBWWBxHmY86bc9TKCBSlng"
206 },
207 "public" : {
208 "crv" : "P-256",
209 "ext" : "true",
210 "kty" : "EC",
211 "x" : "cnH8JXOPBGBW9uU-OZgIAev9HXPPlGwxcmFUHywlTyc",
212 "y" : "0lOb82YIt-6rvGd7oXZs_1mIcCj7D8oKEUZX5k105qg"
213 }
214 },
215 {
216 "comment" : "edge cases for shared secret",
217 "curve" : "P-384",
218 "name" : "EcdhTestVector",
219 "result" : "valid",
220 "shared" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
221 "tcId" : 11,
222 "private" : {
223 "crv" : "P-384",
224 "d" : "yUtG-GHczuzVFQuXWBtPedDrkt2tG4GeX_yy6V6Hm4005blcOLYd45gjX3N8zYKq",
225 "ext" : "true",
226 "kty" : "EC",
227 "x" : "XvcwMIRsP7gKVAjdPBhULB3ylSxbQyD1fBLFgakWnEFluAosTL2QU95E2xpVN0MV",
228 "y" : "uraiwhV9ED1BvbZPq5UitbdZg33hohJRadF86SCyN7-GmNrlOhEFqnF-o7PB9rDp"
229 },
230 "public" : {
231 "crv" : "P-384",
232 "ext" : "true",
233 "kty" : "EC",
234 "x" : "gfuq69ezpardRLQ9VEmrstzpzpWxSRy4r1I_rOkKHg_kFSQzVn3vDNzEqQeKQHIA",
235 "y" : "1oBddqoXFUrLWBx0zVJ5JUGnt0OkcjJSNEKlM_BBq6XjO5-Ctpy9uS8lpk_49ih2"
236 }
237 },
238 {
239 "comment" : "edge cases for shared secret",
240 "curve" : "P-384",
241 "name" : "EcdhTestVector",
242 "result" : "valid",
243 "shared" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
244 "tcId" : 12,
245 "private" : {
246 "crv" : "P-384",
247 "d" : "0N7muMMenSJu_bYD1y3wN7FIIGFBp60fq9ZNr_DyTEDFaRab1c2PLWnxZwvU1xm8",
248 "ext" : "true",
249 "kty" : "EC",
250 "x" : "M3DOkQjZ_j2pDm-PDGzdW88lBrWNfSolI7LyJJlsAFDO9cog1Lf_MWGm80oJDdgW",
251 "y" : "FfrGsxqv2nffIfMUy1GCEzLTPOeEr2m6_0PuMW9fm2UCAMsVUCxbzBtb1nyZXvFt"
252 },
253 "public" : {
254 "crv" : "P-384",
255 "ext" : "true",
256 "kty" : "EC",
257 "x" : "MFLwgeT22ujEUvcNdw2mxUYaJtF-oCheDNYr6qfIRhroSvz5R3lBSMeZj0rquHhJ",
258 "y" : "iJ6-sff5hF5m2LniNu0JWAGz5htREd0C9036d9S2oFubcjApcHXNohUPya1P1TM0"
259 }
260 },
261 {
262 "comment" : "edge cases for shared secret",
263 "curve" : "P-384",
264 "name" : "EcdhTestVector",
265 "result" : "valid",
266 "shared" : "00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff",
267 "tcId" : 13,
268 "private" : {
269 "crv" : "P-384",
270 "d" : "D7CfwAS8fz2OvdO9t33e1bFAW0fEYFQV4taAGHJVAnDNf8TmZXVFPOCvr7gpClTM",
271 "ext" : "true",
272 "kty" : "EC",
273 "x" : "175rvtMdoJASJSXZ4VsugjNMUIB9wpGSznSKUChjy-jq47szrk23ZpiC0yBXtk-v",
274 "y" : "_ZUyY4erc7k4B89v4n_kB6kTI1NBO2fxTxZabkubimochVwNvk0kbXQq41NLcZS5"
275 },
276 "public" : {
277 "crv" : "P-384",
278 "ext" : "true",
279 "kty" : "EC",
280 "x" : "Gb-ku-UUrJjEFct4kO-FCIkUj67HU4j2VJBeGnrPC-bmXzJUwa39tChOIc4YrTrM",
281 "y" : "wZ6iWL9Z5S9L-9AbHReSxTNeSxqy56tfrGMP7cIOeP3GLip85xCl1HGyLc4gDCv_"
282 }
283 },
284 {
285 "comment" : "edge cases for shared secret",
286 "curve" : "P-384",
287 "name" : "EcdhTestVector",
288 "result" : "valid",
289 "shared" : "0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff",
290 "tcId" : 14,
291 "private" : {
292 "crv" : "P-384",
293 "d" : "xgpoyacaA-DRj0mqSoDPW99cNakj57inqOZIC_aljU_-ja1QnveTu5VT-IErVFaJ",
294 "ext" : "true",
295 "kty" : "EC",
296 "x" : "lj9GrksnYrR5iKn1mIHL1IAuMP5B5Elp0Xvv27YI_PTQccaq-Ou5ntPylMUzHe1y",
297 "y" : "PAwkFHgnQuMabaPPjsIvr4DdBXSR1dJ00Asz6ZyslCorTVKCbxGQDo7qTtHTWKtT"
298 },
299 "public" : {
300 "crv" : "P-384",
301 "ext" : "true",
302 "kty" : "EC",
303 "x" : "OCSThhnjCYVKqk07KFHarvYBy1-n5zHy71-nIFZ19yZn4wnaK3OzCDhHbvH-vfy_",
304 "y" : "oc9rkMnhsPjxuRxG4YIZ4SV67wSf1mMNeF8xefnXBw9_BIO857pbbHifq6k7K3K4"
305 }
306 },
307 {
308 "comment" : "edge cases for shared secret",
309 "curve" : "P-384",
310 "name" : "EcdhTestVector",
311 "result" : "valid",
312 "shared" : "007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0008000",
313 "tcId" : 15,
314 "private" : {
315 "crv" : "P-384",
316 "d" : "I6ItVmh5RIJtO8XLTtOromnKohI1JTbDzNo0hb-Q_Ri1TJ1kkqcznWN4yBmp0zpf",
317 "ext" : "true",
318 "kty" : "EC",
319 "x" : "wg18n8h9e5guY6l2vF7UdlWMeLKlk3X0-EBJctlkbSpOmBUKOUHLlPZ62zJcXH9c",
320 "y" : "38LiWgWKuv0NRjUc8rCFo2d6Q6T98KYC-DxXD9jepg11vtF5tNqn--ofXADnusHx"
321 },
322 "public" : {
323 "crv" : "P-384",
324 "ext" : "true",
325 "kty" : "EC",
326 "x" : "0-m3-Cpll7v4BfekNYHAln410f-wlPXfaG2msh7DNzKZesFccMNsdDiidzq2rVQ1",
327 "y" : "1qsGv2ekstg34nybDH-FzDrf0kRuKKpLVgOU9JQ81FdsH4Bb_Uh3WoK4_jXtzM_Z"
328 }
329 },
330 {
331 "comment" : "edge cases for shared secret",
332 "curve" : "P-384",
333 "name" : "EcdhTestVector",
334 "result" : "valid",
335 "shared" : "800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
336 "tcId" : 16,
337 "private" : {
338 "crv" : "P-384",
339 "d" : "bWHZtZfa2RzHtC0YGCUb-KOwmJUhqZUjgaU9rL2abeOdxqkModI_b35D3_dlS9Nh",
340 "ext" : "true",
341 "kty" : "EC",
342 "x" : "lctf7qgcgdK9ln0siFC1KkaKiDNgE51ulveCH65ZJ1xiy_6HFWvGljuDttMUkdq-",
343 "y" : "tXCGiAA0_9g8AET2oclM88neIGgDpmdHSHxslcAr0ds8Irl2sSAjraJ95NSu2gyn"
344 },
345 "public" : {
346 "crv" : "P-384",
347 "ext" : "true",
348 "kty" : "EC",
349 "x" : "3sfFArTfOdx4alKo4SVuMNhLAPyQM6eJFttq3Ql5rqu_i5M1lvHtYeZqIq2cH6m9",
350 "y" : "QvGllFc0mOVgaAqQF_GvoXQmoVJg0QTIIabHh3Wspy7qy0irVm8dpKxzbit8qJOf"
351 }
352 },
353 {
354 "comment" : "edge cases for shared secret",
355 "curve" : "P-384",
356 "name" : "EcdhTestVector",
357 "result" : "valid",
358 "shared" : "fff00000001fffffffc00000007fffffff00000001fffffffc00000007fffffff00000001fffffffc00000007fffffff",
359 "tcId" : 17,
360 "private" : {
361 "crv" : "P-384",
362 "d" : "mKcUqEZN55w554M6uYXPc1Kfei2DkBygNyAoQV8DtwYqmOUiECDxlyNQYludwUnG",
363 "ext" : "true",
364 "kty" : "EC",
365 "x" : "jOm7u_gNzMp5wd3aUrkybrTPSAGQ7mmuEkYqePSD_LM3TktieWl7dcgeQ73rNLFv",
366 "y" : "zCP24hQmQnEbi3iQC2VBn_1Ah-inR5ppHBgPzEvXWwFoz1lK_uzIKm69qoIgYZw9"
367 },
368 "public" : {
369 "crv" : "P-384",
370 "ext" : "true",
371 "kty" : "EC",
372 "x" : "zbs2N62pGygHN1n2u4O0akBKWnvmWD7qLJu4TTlhRVxXzdmh9_6AtOM4dKy2GyXX",
373 "y" : "RmNU8rZfvXZjWRVtcAKs6hGWqRYXMvA0Vp5dNWqZcUnwgFnFXxk4f-3wtCsRHg6Q"
374 }
375 },
376 {
377 "comment" : "edge cases for shared secret",
378 "curve" : "P-384",
379 "name" : "EcdhTestVector",
380 "result" : "valid",
381 "shared" : "ffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff",
382 "tcId" : 18,
383 "private" : {
384 "crv" : "P-384",
385 "d" : "wSOgjOGyS0THIPlyqZdqYTnSLi0UolDiO9gKInMIkThJi-77xLTiPpQdN124OyiR",
386 "ext" : "true",
387 "kty" : "EC",
388 "x" : "U1vW-LFEqwLorzODSawOWSrZdUiiRSM_vrzMGzz1VqzGM2iIDWSW8pBYeecvvFAe",
389 "y" : "UqmVNd3fqF_zdBhGbfCLoH1A2NBnuXWbnRKLgkrQM4qUJSI4zI3oLJcUBKyTbPhV"
390 },
391 "public" : {
392 "crv" : "P-384",
393 "ext" : "true",
394 "kty" : "EC",
395 "x" : "FX2pFpSuM62j94lwjdrK-8ppETMSLJUZoSAGdhvDkZAlFgT--DrJXnZ18GldlQQC",
396 "y" : "Zajmf3FRa4jAEVbwLP3habKSJjF2jLhqUBNmh1nBnMJRjt07gEACpuwJhAxRdC_L"
397 }
398 },
399 {
400 "comment" : "edge cases for shared secret",
401 "curve" : "P-384",
402 "name" : "EcdhTestVector",
403 "result" : "valid",
404 "shared" : "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffe",
405 "tcId" : 19,
406 "private" : {
407 "crv" : "P-384",
408 "d" : "xh8uHXNp6vfEyQcCNQy50MOnMVFVbRb5_mgEimS9pWMwtdYTTtFvYZfyxI1KCTB1",
409 "ext" : "true",
410 "kty" : "EC",
411 "x" : "aIb04bpycj0d6zAvDMjTpM6T1FwDtnziNt8sQLqlAeuCKdQO619P9uwU4_tilLKq",
412 "y" : "Tq3rWf3EYkB1IxTDSoWhZNpC2h7kfpGtkbfyQqzviz6RWKp4Ue1ICfu9qVZa91eu"
413 },
414 "public" : {
415 "crv" : "P-384",
416 "ext" : "true",
417 "kty" : "EC",
418 "x" : "q39AYquQt0BdQ6VKuiNC30e55iTHfHqs9ogJK_kunUCWu0vDsnn2tWVbYDii57go",
419 "y" : "uqIRUwq6RUG3v49Sy4L-8H9Czx6RO_x0o2ZoZjVjEYcdpEv7I3rwFqO1yLcSbrRS"
420 }
421 },
422 {
423 "comment" : "edge cases for shared secret",
424 "curve" : "P-521",
425 "name" : "EcdhTestVector",
426 "result" : "valid",
427 "shared" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
428 "tcId" : 20,
429 "private" : {
430 "crv" : "P-521",
431 "d" : "AVKh0rHG7Pkd3_PuLDYXWSHmODNUmBjhPcYkoayV1g3HZnZRlu1fROV3rOIloeHvRYdrFx_NB5INebN1qaUMNRqB",
432 "ext" : "true",
433 "kty" : "EC",
434 "x" : "AKlNmCvHHVNVD7yVQZDT0ndwQrHFb-CUb1Q5hpcyIZBfm6ztMv2w23vx6l4-7rWaxEaCGFhFuKs4UFt8JBIs3g6Z",
435 "y" : "AM9y8f1YkPLcaCxYgDGJVlltBFJNpRu6tFaMueJmi_4TQPdHMfUACPTu3ZPiMOJfLAHjdj-40SuS1DE95PcxdVtE"
436 },
437 "public" : {
438 "crv" : "P-521",
439 "ext" : "true",
440 "kty" : "EC",
441 "x" : "AS3urkDLLXtha3NhL90XI0u07sy8om0WO7EbHvsPeJgM0iufl35-RuReyDHZzV10rh-AoHn8y1zITpqxnu8oblJ_",
442 "y" : "AC3Pf4WBRCJec-AxWwruShMAKA3GE5e-XD4HhAxEVsJQ8VDNT4dlBhjpmUs91Vl-Yq-nhAVSbVRceiYm8-ripeex"
443 }
444 },
445 {
446 "comment" : "edge cases for shared secret",
447 "curve" : "P-521",
448 "name" : "EcdhTestVector",
449 "result" : "valid",
450 "shared" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
451 "tcId" : 21,
452 "private" : {
453 "crv" : "P-521",
454 "d" : "ATmak4nm7hXp1MKCw8hx9rnwRfslPzg0E48tyiLkTJq0PiUlXPIop9zJLOp_zTJxol0otFSGDMQHN7UUuOWataAG",
455 "ext" : "true",
456 "kty" : "EC",
457 "x" : "AVjKsZhF9cafY1ZWqEl5rWLBHKUYICfLSotbTrFxs1Gzqsp5rPvXEiGTw3JoUXUanYAiTlDO4D35pYKrehMka8e6",
458 "y" : "AZpeA_ZGbMfb9gefRvzM66QJF4ywd7fX4i7bD6LxWN6X4YvP0TA-9IgEY9P8rmNtEVWNHOQ7lYMXyG3pSJXCiVmo"
459 },
460 "public" : {
461 "crv" : "P-521",
462 "ext" : "true",
463 "kty" : "EC",
464 "x" : "Ab3YIomLurxIHOuHAhK8KzsSUsU-YK4Gr379y2CHaIo9kgP_rh18DiXCoUEvoIIx8gwGTZzzOeRuTPbZRQo5tA8d",
465 "y" : "ADD0l0D-8kB5R3GyXenua2pqLjvxMB7XKkYTVTvikv-dr7kj5-zdWAI0bvdYua9iDydcbvNBIfCqnIMrcCuN-tTv"
466 }
467 },
468 {
469 "comment" : "edge cases for shared secret",
470 "curve" : "P-521",
471 "name" : "EcdhTestVector",
472 "result" : "valid",
473 "shared" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
474 "tcId" : 22,
475 "private" : {
476 "crv" : "P-521",
477 "d" : "Ae0B8AuUv5AvAslCh-nNsc5Rp3aiJaOeDq2r5hDxZOtHXDFWPlYZLG4IVeRITPyvroD8ajdheE5fLTk9xkAwLAlN",
478 "ext" : "true",
479 "kty" : "EC",
480 "x" : "AMJZVTWNZBnvGzroqMvz7iQ_l7EdyH_wfH82VUN-yh5HRB8Zhixc1_ZrRAFIBTRXbG3OhpnkbBynsz93elFLmrS1",
481 "y" : "ADUZa4-xrZuR6TkvperZvyQpU9LA6anRWvtBpfErRRutoNOXNNqZd4iJM9UrOwgMuwD3EcjHi5LcFlU9fnhAX-4F"
482 },
483 "public" : {
484 "crv" : "P-521",
485 "ext" : "true",
486 "kty" : "EC",
487 "x" : "AWImM20DIMkwVqKq5Oj8KGQB7lAiAamgp-MsdmgGpbGoRdHD7BC70po-yvLRKWx0j8wcvDtLBgSlN56X9IiV3_-8",
488 "y" : "ALjyFlEqqyfyfxY2USOCXRU1-NNCJgg95ZaX3AwhJK2osJI_5gl6ZGsR269YSc8lvzz-DMQSkSN6izsJewFYWE35"
489 }
490 },
491 {
492 "comment" : "edge cases for shared secret",
493 "curve" : "P-521",
494 "name" : "EcdhTestVector",
495 "result" : "valid",
496 "shared" : "00003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff00000003fffffff",
497 "tcId" : 23,
498 "private" : {
499 "crv" : "P-521",
500 "d" : "AHCj4dIfcZmOPuhsdHE1_QFbirc5UuwhQSVRGJvnNfMqbvkgwJdDwoh35_rOrvDobZkMCUo2gjywt-jeb1MoTXXL",
501 "ext" : "true",
502 "kty" : "EC",
503 "x" : "AckwlINJRsmZceEqzmdGd6OkBOpgGt7BuIL1_1qKj8KPd0IEVzJOnMIKtllYm6mcb5CjImhB9OTMf2TfbfikDx8z",
504 "y" : "AYop_NDJXvj0A2PHJ4oHLfNybIsJ_yuprFdBxil-CDxyYfOoxxKYwZJqv5dFvahgBq2pcxlUtY_edhyo3t87W5Vn"
505 },
506 "public" : {
507 "crv" : "P-521",
508 "ext" : "true",
509 "kty" : "EC",
510 "x" : "AFRRtylPwcqFK3-rIUMWNocMLgrAOgcbHuBpzjmQe8H-F4PQb22UmMthmg5bV3HUTAUo8CN_fKYHG5Mp-vhlCDw0",
511 "y" : "APnnz_jAwOl6YVA6S-X3i32oAfBRIKgvAGP6-4a1rn3bUxbbX0E6DHxyvXDHBagiswvCTcpmbgf1K2DWl0lYAdvr"
512 }
513 },
514 {
515 "comment" : "edge cases for shared secret",
516 "curve" : "P-521",
517 "name" : "EcdhTestVector",
518 "result" : "valid",
519 "shared" : "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
520 "tcId" : 24,
521 "private" : {
522 "crv" : "P-521",
523 "d" : "AWkrrEpAH1ySoeLzWa29MPCf1d_1AGnmgl5ctM38yHn5HJnANExaKUqMBrOBv5uqqplBUFX7nNL3l4dd7WqaPFIa",
524 "ext" : "true",
525 "kty" : "EC",
526 "x" : "AC3_tgsEuNpiRbo91tSKWj56AQpSbGt1tXpheP-BY-x73ByOHUyH6yiBYeHcdXwi1iLr9utUubAOk0eXUANOYOfe",
527 "y" : "AZPGwdcwZSHbhKuduwfvNyo44kzrWP7Hao6soA6tRAB8bWu-ZqY9VfazCp4UviSfL5npVBVlyWHrbJzm6_rZZ6u5"
528 },
529 "public" : {
530 "crv" : "P-521",
531 "ext" : "true",
532 "kty" : "EC",
533 "x" : "ACpQ9eN9V7C6ykS76ZP0u-UARYdeEbXT1ktF1049JBufZvm7AjNXgEIh5smS5edyPsQ2E3CpKCrRb9zBsZDfeUmm",
534 "y" : "ADRPkod4ORmJNXBkni6W6xjFgQWzJYWyineMsSJcIx5SgFJzFd0wKpJ4r4NoMEQYP7Hro6pwuPb8lzsh3kXq8k3o"
535 }
536 },
537 {
538 "comment" : "edge cases for shared secret",
539 "curve" : "P-521",
540 "name" : "EcdhTestVector",
541 "result" : "valid",
542 "shared" : "01ff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff",
543 "tcId" : 25,
544 "private" : {
545 "crv" : "P-521",
546 "d" : "AVvfMqtnNDa9_sm8S7JMZH6FGX8Rtx3uHHwwqabohiviiTJISFwRwEdc3rrO5XcEbY0R4h2JFj2D_51KB0TsYnt6",
547 "ext" : "true",
548 "kty" : "EC",
549 "x" : "Afrx9MyHjAQXLzWtY8E3Npgc5RHmb_7NJZBnC8IScQExr1Mw6YLdSIApLgebYCItsxn8NI1ePq7Yel40vdYjDmHF",
550 "y" : "AQgpwUfPeLtojxZr3CZ7TRkfOW94MFH6Qd3-RKrNxCfWhDbFn08eizxx9MeDYTTBi7QP7YjgGsNwQHdYynaQCrJl"
551 },
552 "public" : {
553 "crv" : "P-521",
554 "ext" : "true",
555 "kty" : "EC",
556 "x" : "AapJCiTqodo1UEqh71rQPTFdFWAingHpYzYEcQkoNlaN78YHsEh13mq3t4rfAySlSHISiAxhLCUoNE8A0qJH9-uo",
557 "y" : "AbGIwEWcIGbHLtJ8jZdQZlvsq5PPXrp9nv66HuRZIvv4zFjE6EFlmiy05SRbQVdNIxXTPRYzTc3zD2ap0AI6Sp8F"
558 }
559 },
560 {
561 "comment" : "edge cases for shared secret",
562 "curve" : "P-521",
563 "name" : "EcdhTestVector",
564 "result" : "valid",
565 "shared" : "01ff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff00010000",
566 "tcId" : 26,
567 "private" : {
568 "crv" : "P-521",
569 "d" : "AQRGx7aakMJAtvNZjVcMNtuPiKmi0sR4HbQvx2SiPwIE8av5AQ4489sfWCLJEQT1LJmr7z7uCs_RkZnYQfA5nsRY",
570 "ext" : "true",
571 "kty" : "EC",
572 "x" : "AOzcaMvbri-f4B1RYhnAj0-ma1NDDxi4bTiA56rGUB1jToLVVmtUlf19ejkW7IXaEbIxdOvoPFDyEuQ25lEVviI2",
573 "y" : "AAALPmt-i6XKCpayvbbEsXVQgACrzwFm1hH2apTQZ9AuXHMCxqlRtuLWox49b3UWQQxguKUxC-Wp3N6Vc69L0258"
574 },
575 "public" : {
576 "crv" : "P-521",
577 "ext" : "true",
578 "kty" : "EC",
579 "x" : "ARcwdNExeWI1KkBYFq3NrPwHLihiab5Om7EWUye1rUJQ_sqBLSAZ8aH5gunT3LS4govxtGeFJT3591GYZCCx_YR4",
580 "y" : "AL6RaKyYB3FkjvdvupBdCR-TMtMFZoTeiYdiOF17lbowRVEuU0ueOZtC3g-oeUVdR38PAb8qjyBuTUjTfy-PAwFg"
581 }
582 },
583 {
584 "comment" : "edge cases for shared secret",
585 "curve" : "P-521",
586 "name" : "EcdhTestVector",
587 "result" : "valid",
588 "shared" : "01ffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff0001fffc0007fff",
589 "tcId" : 27,
590 "private" : {
591 "crv" : "P-521",
592 "d" : "AEf0gpI9gWUpV2YOJXZbq-_NNs1-0gaz_cqsTCWJryIlZIFpjfAR7E7TYsVWJJOcQ06KThPTq_f465-pNYV6GM0e",
593 "ext" : "true",
594 "kty" : "EC",
595 "x" : "AbbjwscOPKDPxOhuY5Adis_BFWuAtvp6CACwigg7nQsVVMfmmz-2rabNDVM9xfO-IyJluN2iIXfWqfsso9ZfqwNa",
596 "y" : "AN0O-aSlTwMFZMh61_w6Dd6WFF4RSgvTUTKrgBbfwvJ51oEFS2N9wkAO6n9BF5LtGEs05Rk4c7YiHW7cduSTGaP7"
597 },
598 "public" : {
599 "crv" : "P-521",
600 "ext" : "true",
601 "kty" : "EC",
602 "x" : "ALerrg1ExBfKvxgAcbHCrRng59VuQrYtenCecu0zFvM6qCfT-K25W10QlV0CUb2ghufXhEHoYcloPvqAs_9s4fbK",
603 "y" : "ADkJ75dRag1VYGkeFmYAoHo4srO0iLCnA-UkhCPnFnBeMgYymD1w2jgvQAgaklc0Hu-9UaD7p1_Nf-1TjpWJtUow"
604 }
605 },
606 {
607 "comment" : "edge cases for shared secret",
608 "curve" : "P-521",
609 "name" : "EcdhTestVector",
610 "result" : "valid",
611 "shared" : "01ffffff00000001fffffffc00000007fffffff00000001fffffffc00000007fffffff00000001fffffffc00000007fffffff00000001fffffffc000000080000002",
612 "tcId" : 28,
613 "private" : {
614 "crv" : "P-521",
615 "d" : "AVq5Tiol6wETE9p3S4QwJkOnBOLHsjacK2jJwqKNg29fcQYU2F1VfIXn_z_W2gCOA1pfV1nxjFHy71Zbvjt0On74",
616 "ext" : "true",
617 "kty" : "EC",
618 "x" : "AAiC9FSE0AUJRyxhAyzUpiQ9jx6rK--jcvGKfjhV3wOQc8ESnfvM6Ht6a6q4et-ZpudHxtKYEVbg_Sj-DFPf3In-",
619 "y" : "AS4ou5BmSLHuNP15FUxCpaWYcVSAZbEpByTXeaAF4pGrjKAn-QJQTEoeCRzSpaRNOnNuQ4R_RmEYxhWBKGg0GMGV"
620 },
621 "public" : {
622 "crv" : "P-521",
623 "ext" : "true",
624 "kty" : "EC",
625 "x" : "AIADDBIkyBDQ9Mdh5Q55qU38Z5MKqGaZMc6u-lYk_BxYqWpjzkBnNLFnfnEPNB5Pe1VB5rBZ2Bgnklo-E_DErnUV",
626 "y" : "ATMiYwjDaF7zYFgwtWB1j-yPSeB86uTsOl-jZn1xcuIrFJ5rt5SRZCD770ODhWqd0FZ6XimVkkN_C86DfLhRNFtV"
627 }
628 },
629 {
630 "comment" : "edge cases for shared secret",
631 "curve" : "P-521",
632 "name" : "EcdhTestVector",
633 "result" : "valid",
634 "shared" : "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd",
635 "tcId" : 29,
636 "private" : {
637 "crv" : "P-521",
638 "d" : "AV9Wm2yFPuZTEtzoREML-T4ePjFF-qBX1fuKnACO_UXwGLXX63QY8BnW3yTKIRHsLbYZAYl-mcln98Lf031gFvE9",
639 "ext" : "true",
640 "kty" : "EC",
641 "x" : "AFRFfw2juwn-o9pRWj-iWoh6CJnQK-PQuGrRxgCv3-PY4MGCuEWkS9vm4uBoebJqLLrktoCQk9QajjOVO54eXX3Q",
642 "y" : "AWBlktVWdA9WSpA2tAU7qiJrt6wahs1APs0DpDra-co5-_qPVJ4MNRGccMm8NIalEpH-BKTzTa0ulEnkKO_WGkzH"
643 },
644 "public" : {
645 "crv" : "P-521",
646 "ext" : "true",
647 "kty" : "EC",
648 "x" : "AcV8ffR7tx_RPXFPhG66Wy6v_YdvF_DPBRyC2MBdVnqkDA5qRbb13O7MPDOKIbZByBSPo0fYwWWuJJQyHy6ifvhB",
649 "y" : "AVEsOm9DnGCIOdriD6SoT3HpQV6AsJzKG51vehjIngB9QGWjwcMhTZc1vy4FqnOk135hOH18JdBMyp2RvezglWmQ"
650 }
651 },
652 {
653 "comment" : "edge cases for shared secret",
654 "curve" : "P-521",
655 "name" : "EcdhTestVector",
656 "result" : "valid",
657 "shared" : "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe",
658 "tcId" : 30,
659 "private" : {
660 "crv" : "P-521",
661 "d" : "AE4aqLfxx8CRwT3QCLZlGuNRCmYhcpKx1cQKa5yYRCJdoRoFfHBmXKEFpPcn02d56w84wAxo5IqLuiSF6iwBXSP7",
662 "ext" : "true",
663 "kty" : "EC",
664 "x" : "ASeR1fEZFj-lqdUm56zzdw9ye2XQ9rZuNGed20Y89cvpCC3k-qGhjERJWVCJEwvbGWHfG3dikPws3bd4BpNF8imw",
665 "y" : "AUTDJdEeJ3cOzU0w5QHaygcoV7heHoc6mIxLepOattgSh86q9gpuMlEToVuILBB-XLmDXDPcUAfcTugkSgMt0Cb3"
666 },
667 "public" : {
668 "crv" : "P-521",
669 "ext" : "true",
670 "kty" : "EC",
671 "x" : "AGjidY0tiJL7AbgOV75-ZWrkGFHTKhuYfycXv1yUfBUcy97QljiYb9SOHs8g_tdMc-iclHf9jMP33Anyc6mLWIke",
672 "y" : "AEWBC6A7bwhGzO7Km2FkS2gAMDm36KRmlOJ4y_EHSwh3wtC-AwMkUesZLwA7bIlsvLGom3MC4Hi9E7Nczgurhg0H"
673 }
674 },
675 {
676 "comment" : "edge cases for ephemeral key",
677 "curve" : "P-256",
678 "name" : "EcdhTestVector",
679 "result" : "valid",
680 "shared" : "64ebddd0211545e08fff948c3c252bafdb61245146915b8524f27cd6ec766d4f",
681 "tcId" : 31,
682 "private" : {
683 "crv" : "P-256",
684 "d" : "9WHNIE2tXPb9P1qiTZSGfw8xzSIXbrwjDlu4IMNDGK4",
685 "ext" : "true",
686 "kty" : "EC",
687 "x" : "G5TtS3gQhifa-fzyckvupwbKxmfGuveNC2CwLpchqH8",
688 "y" : "FBD5sLTkev2U75DG792XrwCybeK4X-rSkP7OeenV668"
689 },
690 "public" : {
691 "crv" : "P-256",
692 "ext" : "true",
693 "kty" : "EC",
694 "x" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
695 "y" : "ZkhceA4vg9ckM71dhKBrtlQcKvMdrocXKL-FahdPk_Q"
696 }
697 },
698 {
699 "comment" : "edge cases for ephemeral key",
700 "curve" : "P-256",
701 "name" : "EcdhTestVector",
702 "result" : "valid",
703 "shared" : "11c2b3d789d5879ae2b6c5bf25e970d246ae19f27e96d2a53b85b844662bfeba",
704 "tcId" : 32,
705 "private" : {
706 "crv" : "P-256",
707 "d" : "37nCPA2bNyQYlt2dwyPl499ok2n2P9GDC1PC6Kq3_ps",
708 "ext" : "true",
709 "kty" : "EC",
710 "x" : "qPLjpu-qN03vykV-b3Zmsev1gum3iwur3ptEBN1jqO4",
711 "y" : "33Y3hU4lZy8u_ZKc1TJGIhY5TFyqHWH7NGVwikCbE2g"
712 },
713 "public" : {
714 "crv" : "P-256",
715 "ext" : "true",
716 "kty" : "EC",
717 "x" : "AAAAAP____8AAAAA_____wAAAAD_____AAAAAQAAAAA",
718 "y" : "RiwEZuQYAiONbJJey-_HR8_lBeoZavmi0RtihQ_OlG4"
719 }
720 },
721 {
722 "comment" : "edge cases for ephemeral key",
723 "curve" : "P-256",
724 "name" : "EcdhTestVector",
725 "result" : "valid",
726 "shared" : "827b389dd5c08c79f1315302342539be601a7f755bdca98d6702846107a31870",
727 "tcId" : 33,
728 "private" : {
729 "crv" : "P-256",
730 "d" : "fQCkXannaJDeh2kAnq5HI7wLxvzj6x5t-HoWWOhDLMY",
731 "ext" : "true",
732 "kty" : "EC",
733 "x" : "_FJoFGfalGIOTH-b1D-ibY0CN8prxadt3__i8MY5nhw",
734 "y" : "DgvkRsg976wXQkGkRFNW8a8fN1Vr8bD3Ak3V03Q0wgQ"
735 },
736 "public" : {
737 "crv" : "P-256",
738 "ext" : "true",
739 "kty" : "EC",
740 "x" : "AAD__wAA__8AAP__AAD__wAA__8AAP__AAD__wABAAE",
741 "y" : "aEyKlYbtb5y-RHBYp9ohCLqx5eCmDR9z5OLnE_Cj3-A"
742 }
743 },
744 {
745 "comment" : "edge cases for ephemeral key",
746 "curve" : "P-256",
747 "name" : "EcdhTestVector",
748 "result" : "valid",
749 "shared" : "bb25fc9cb64eb69e52f9d1d4c0d9dc7563d2342738b8545bd849c9616f7c35b8",
750 "tcId" : 34,
751 "private" : {
752 "crv" : "P-256",
753 "d" : "7y30Hg3QXiSRil8iTHd33Y9yg3JzVR_PUJ2SaUeNfOQ",
754 "ext" : "true",
755 "kty" : "EC",
756 "x" : "HwhwsMS0T9wPDfjxu0mxkLOfESsQUmIYa4V1KwHrlDc",
757 "y" : "H5yuPQ9-ah6D2MO84W-0MBzRBQzBP4Q11teY74VB7ZA"
758 },
759 "public" : {
760 "crv" : "P-256",
761 "ext" : "true",
762 "kty" : "EC",
763 "x" : "f_8AAf_8AAf_8AAf_8AAf_8AAf_8AAf_8AAf_8AAf_8",
764 "y" : "LiITyvAwM-D9D3lRFU9ubDqSRKcvrKZenOnutcjhzqk"
765 }
766 },
767 {
768 "comment" : "edge cases for ephemeral key",
769 "curve" : "P-256",
770 "name" : "EcdhTestVector",
771 "result" : "valid",
772 "shared" : "01d6936718941de1c689a8d11cf98c0d50cd18b40589e5e4efc2ab7692e9a11d",
773 "tcId" : 35,
774 "private" : {
775 "crv" : "P-256",
776 "d" : "ynQhnwWzXOkr-9Ne4QB_C_gSAjx2gdpSX_aFifK9S0Q",
777 "ext" : "true",
778 "kty" : "EC",
779 "x" : "3v4g84h9rNVn81C14Uxr2QQWp1VZpW33GQ8qfm34ulI",
780 "y" : "SEPuncA58RBm9OslWclcvGWZOoNftu-1vu1Efc4sYiE"
781 },
782 "public" : {
783 "crv" : "P-256",
784 "ext" : "true",
785 "kty" : "EC",
786 "x" : "gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ",
787 "y" : "K-h4nbgbtIcKnmDFwYyAyD3kZCdygfGvHmQIQ6GjFI4"
788 }
789 },
790 {
791 "comment" : "edge cases for ephemeral key",
792 "curve" : "P-256",
793 "name" : "EcdhTestVector",
794 "result" : "valid",
795 "shared" : "b040da667e626da3ecba81774abe5c78b0913269c4a338e96169280cd960cb11",
796 "tcId" : 36,
797 "private" : {
798 "crv" : "P-256",
799 "d" : "dbAXHkNIjNBS9ai8xc1rlIBwtq5u2HFxAHATVr7xORA",
800 "ext" : "true",
801 "kty" : "EC",
802 "x" : "ioFLm07OAbhKONV6TmTlamuJaIwHEzSeeGuNcosgoLk",
803 "y" : "jPuKN9axMkHxUMyjgbTTnE9Tq-QJq5u-gmnJ8Y2iFlQ"
804 },
805 "public" : {
806 "crv" : "P-256",
807 "ext" : "true",
808 "kty" : "EC",
809 "x" : "_wAAAAH____8AAAAB_____AAAAAf____wAAAAH____8",
810 "y" : "XfgPxsria2wZUvvQDtF07hIJ0GkzX1tIWI4p6AuRka0"
811 }
812 },
813 {
814 "comment" : "edge cases for ephemeral key",
815 "curve" : "P-256",
816 "name" : "EcdhTestVector",
817 "result" : "valid",
818 "shared" : "4936cc116991029c526353880d1662c358030966cd55a9a8160fe2d159aeb4e7",
819 "tcId" : 37,
820 "private" : {
821 "crv" : "P-256",
822 "d" : "XOqmj1_5DbRu0cV4_bPB1JTKV2EImMcAmCiQxztru9Y",
823 "ext" : "true",
824 "kty" : "EC",
825 "x" : "oXuqPe7_EUlvhfee5l1fOFn5X5Jb1wNjVcenVgTJyJg",
826 "y" : "29Xvv-xNR8wUyBM_47j4bGb-C3vDFXLKhv0iCc391vo"
827 },
828 "public" : {
829 "crv" : "P-256",
830 "ext" : "true",
831 "kty" : "EC",
832 "x" : "__8AAAAD____8AAAAD____8AAAAD____8AAAAD____8",
833 "y" : "LGNlDmpdMy4ph90Jp5AI6PqrvTfknLAWv7ksjND12nc"
834 }
835 },
836 {
837 "comment" : "edge cases for ephemeral key",
838 "curve" : "P-384",
839 "name" : "EcdhTestVector",
840 "result" : "valid",
841 "shared" : "4e895e34c332213a5df19fabddc6b902d692839babb725d3df788565dab301ce21297ac9bb22634d28f4591bdca4bbbb",
842 "tcId" : 38,
843 "private" : {
844 "crv" : "P-384",
845 "d" : "T1tn2EWp3XrtJUF4-8hqnhI17p1Y3MLSIw4g_yMkj1ZeJVbJxfeCYc-Kh5O34xL5",
846 "ext" : "true",
847 "kty" : "EC",
848 "x" : "SnFhQe1E4hE8LFnQIHsmKuPj1Hvfp7ghcjeQ6l1Abj1bdfwmQexehMePbqPkz7mx",
849 "y" : "FdjHSmVoLnYQaACnx952lcm_Le0dPco8Mf83dOx8nZ6JyWoDe1tk2eInNlmxyJD3"
850 },
851 "public" : {
852 "crv" : "P-384",
853 "ext" : "true",
854 "kty" : "EC",
855 "x" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
856 "y" : "PPme8E9RpepjC6P5-WDdWToUyb45_SvSFdO0sIqq-Gu_kn8sRuUqsG-3QriFDlIe"
857 }
858 },
859 {
860 "comment" : "edge cases for ephemeral key",
861 "curve" : "P-384",
862 "name" : "EcdhTestVector",
863 "result" : "valid",
864 "shared" : "359842f1ba4c9be3d068c74399581ba6a322c6d3ab720d0224f71cf5ca550d1071a2b385adc8fb47fbfe74d25d4736a9",
865 "tcId" : 39,
866 "private" : {
867 "crv" : "P-384",
868 "d" : "50d0UvWbIrGM0eMD2D1wZuZPg6OCsnGbhPgVynGjTaKmbAPI4aj78fDP4HjyZNoe",
869 "ext" : "true",
870 "kty" : "EC",
871 "x" : "bIby6GKIm_c1VxP2_R3JJaD2a7WfrGIbGhKoFbDY6zWN4Lwzb8ujjRJhB0BlG4sK",
872 "y" : "dcKT0WCM0Sf9srQn-YUtmD--lpd9jZkD5AIWKzrDg10igwmh0lgQi_w1NgUguTXB"
873 },
874 "public" : {
875 "crv" : "P-384",
876 "ext" : "true",
877 "kty" : "EC",
878 "x" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC",
879 "y" : "cyFSRC-27lw-bOHZIMBZvGI1Y4FNeQQrkDzmDx1Eh_zNRQqG2gPz5u1SXQIBe_2z"
880 }
881 },
882 {
883 "comment" : "edge cases for ephemeral key",
884 "curve" : "P-384",
885 "name" : "EcdhTestVector",
886 "result" : "valid",
887 "shared" : "71716edde561d5f3160f49150d65d2d7288d828de14ca915b835547687e3b9156bc2575e24687393ad6aae3544367355",
888 "tcId" : 40,
889 "private" : {
890 "crv" : "P-384",
891 "d" : "rzWr72rzurTFbm6_jsnAgXH-H9VodWaGyETRKJC5n7ao06d5zoivfDUYh8iehcLH",
892 "ext" : "true",
893 "kty" : "EC",
894 "x" : "Ir2zHCrFMrmIUiUr4Zy6260S1oKzexrvWSUEu0e9BlXZZQqHf69RUmhxsbwPsf05",
895 "y" : "zRVH8sgQIsx9VOscHN-EAGyLiMQwny0x5faJVqFFE6uqtq05Jq7Peg0Jiwd-sEBk"
896 },
897 "public" : {
898 "crv" : "P-384",
899 "ext" : "true",
900 "kty" : "EC",
901 "x" : "AAAAAP____8AAAAA_____wAAAAD_____AAAAAP____8AAAAA_____wAAAAD_____",
902 "y" : "cDcDhUE9Pv9vo0B7ok9oLCsBtRRF299e97DdCXnxfnE-CQgVcfHpTftmvyggAvOf"
903 }
904 },
905 {
906 "comment" : "edge cases for ephemeral key",
907 "curve" : "P-384",
908 "name" : "EcdhTestVector",
909 "result" : "valid",
910 "shared" : "54a2e9e30ff3dcdf15bb0630dff2af17ae2ddadc9a908a6e844762af8f43b7dc3bb59212e626be44adf94efd3c9bf748",
911 "tcId" : 41,
912 "private" : {
913 "crv" : "P-384",
914 "d" : "lat_maoDiHjgtmOALbi0oV019jqEsoSKVEW8Hadq-sDPpexpBAH7c2TlUhfVKOfb",
915 "ext" : "true",
916 "kty" : "EC",
917 "x" : "k7C1k5ErkiAP3jUFHdgT5sw2WF4oPXNIUuLiWazarSE1mNY6uPCnvPvzc19-ufIR",
918 "y" : "p3OImY5TpcRNr0cht6RZOo14saiFmxNNQKWKXVmGl7s-9dJ9ulpYqf_Sp3vWts5-"
919 },
920 "public" : {
921 "crv" : "P-384",
922 "ext" : "true",
923 "kty" : "EC",
924 "x" : "AAD__wAA__8AAP__AAD__wAA__8AAP__AAD__wAA__8AAP__AAD__wAA__8AAP__",
925 "y" : "ES4ZHx94u8VLbMTwseWa6Mb_Ggf1Eo5B36KCjhtlONT6LKI5TGqrNEncs_xOtEwJ"
926 }
927 },
928 {
929 "comment" : "edge cases for ephemeral key",
930 "curve" : "P-384",
931 "name" : "EcdhTestVector",
932 "result" : "valid",
933 "shared" : "6125603f2419093887c94cdc24030a53774e68436d9db29e58199ff5043f38850c94a843ced979247f2ca1bd48e712f7",
934 "tcId" : 42,
935 "private" : {
936 "crv" : "P-384",
937 "d" : "OriTivAVWkEw0xPlfSEL1XuyfRoo9WXwPFrlaxFY_jHpWXKku0EjnQis9js5i716",
938 "ext" : "true",
939 "kty" : "EC",
940 "x" : "BnGd_rVJP9RPKD1nBm4EJHkAk6UuM3n1WH9-w2tUGC-HHM-ELlLY2imgCV205lLz",
941 "y" : "9DWhsjsMME952LVjIxeC8Gw-KTiK1jmnOTmWHbLj9lw0hiK8t9RPS4iQ4bCwxAB2"
942 },
943 "public" : {
944 "crv" : "P-384",
945 "ext" : "true",
946 "kty" : "EC",
947 "x" : "AH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAIAA",
948 "y" : "AopMjaWgURL-YCXvQZCJad4g0F2WaOXIUu8tSSFy3cKgpiL8SIFk_MGgdrhylCry"
949 }
950 },
951 {
952 "comment" : "edge cases for ephemeral key",
953 "curve" : "P-384",
954 "name" : "EcdhTestVector",
955 "result" : "valid",
956 "shared" : "60d73748120e538409c65508f4fd2c4575ee333d1103be329fd95eda92fdb45665de27db2d3f3ba5c5ce0d448d33442d",
957 "tcId" : 43,
958 "private" : {
959 "crv" : "P-384",
960 "d" : "LgLDmLopfrvWYzRGKWleU8ZSMaPiSMLLBKrJWGwXPvD-USKpohFKBUCxI-x6hDuZ",
961 "ext" : "true",
962 "kty" : "EC",
963 "x" : "P0lK0BgW2hvIautb__wcM9wJxsgN0h_9jP6OEkt2uVQSlzOxnkWGjlQrnQthW8W2",
964 "y" : "h_lSVNmK7k9renQhp30NyVF_PTDhBNH7CDUQi2O9ttMZsu2LgMCzUmQYcdIRDcy8"
965 },
966 "public" : {
967 "crv" : "P-384",
968 "ext" : "true",
969 "kty" : "EC",
970 "x" : "gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC",
971 "y" : "B5faTAdRztFt6A0Wq3xlSl3CfQkmJtCGWhkqHF6nwbiMn8qwV5RnQeQcwoyA7Aua"
972 }
973 },
974 {
975 "comment" : "edge cases for ephemeral key",
976 "curve" : "P-384",
977 "name" : "EcdhTestVector",
978 "result" : "valid",
979 "shared" : "acafe3aa06c90ff391128a2ba4b569d3f76b65ff1ec1e9c98780722c336810768014be29db1c7b523c68f3246b2765c4",
980 "tcId" : 44,
981 "private" : {
982 "crv" : "P-384",
983 "d" : "u5P9WvZZwf3krTQVlA_9dx6HLwp4CwBuEWupeU7xskBvkFQkLEsWgc6ODACeDJ34",
984 "ext" : "true",
985 "kty" : "EC",
986 "x" : "aahIFrSc4nFAKY6U6YSFH8SbW5tLaXzgNUzMwFQB4mV9yshGl_J30i-pYrqgf-KT",
987 "y" : "kKd0wGLab0vwL9vcZXrF4f9Wwl_YpTtBgdTNBVAsfN7gnDO0_KgUjyiuC8V0YADC"
988 },
989 "public" : {
990 "crv" : "P-384",
991 "ext" : "true",
992 "kty" : "EC",
993 "x" : "__AAAAAf____wAAAAH____8AAAAB_____AAAAAf____wAAAAH____8AAAAB_____",
994 "y" : "bHCJiub7MfovCGViry0QSGukxv1eQd_kqmFZi0cHo7wnamL-sbmFV-OxfAJfet9O"
995 }
996 },
997 {
998 "comment" : "edge cases for ephemeral key",
999 "curve" : "P-384",
1000 "name" : "EcdhTestVector",
1001 "result" : "valid",
1002 "shared" : "2f6bdffd0381853dc2c493512138ee843d4f7f0d19fde184f1a438887c741acb066654e45ea79d230c3f3cb376c22665",
1003 "tcId" : 45,
1004 "private" : {
1005 "crv" : "P-384",
1006 "d" : "t7k8StSVU9m_UnPXIr7cpsZHinyGKtb-ihWaapXGXvBb_Q_7DAkhlodltTuOjBNa",
1007 "ext" : "true",
1008 "kty" : "EC",
1009 "x" : "rZ7Tz-zApVpyC7uD66RRSVxnXAtg9qLorxkVbamhRqt52ztcCT6isv5C73FO_J9S",
1010 "y" : "SeQr0j5HOA0cdzcPNj1tHq5RNO7DXT47l07tk41gIEPN2TI6h8CQ1teO7oliUXzl"
1011 },
1012 "public" : {
1013 "crv" : "P-384",
1014 "ext" : "true",
1015 "kty" : "EC",
1016 "x" : "____AAAAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____",
1017 "y" : "SYerrkEoCcL6SP0jsb355iL1pgbEQRchX_phsY70blSn-78R-aa6WcmRtK5QH-3O"
1018 }
1019 },
1020 {
1021 "comment" : "edge cases for ephemeral key",
1022 "curve" : "P-384",
1023 "name" : "EcdhTestVector",
1024 "result" : "valid",
1025 "shared" : "7ac7f7cf745457b1a58ea3cddc0337d47211b44403ab4ea47559be4350e8e87ef1aaf153e88eee72a3bdfa88aff1bad1",
1026 "tcId" : 46,
1027 "private" : {
1028 "crv" : "P-384",
1029 "d" : "G6nOPd7d4YRu2aiuR2rGsJhaHbgu-YD4KWcolBGqjhFF7r4vEut4Z7hJPHCmkYfo",
1030 "ext" : "true",
1031 "kty" : "EC",
1032 "x" : "OdLPzPwjOGKxUaUEWtPkWQcU-lZMiMY7ltEg-sv8cDexBg1YAehFcvNHTNd9Eoco",
1033 "y" : "4cv-rRGl9hZpU7SdqV25z_tQxBHl3H9M8zYJ-rQ1gvjsvszDI9lWfc2Yda6GEauI"
1034 },
1035 "public" : {
1036 "crv" : "P-384",
1037 "ext" : "true",
1038 "kty" : "EC",
1039 "x" : "__________________________________________7_____AAAAAAAAAAD____-",
1040 "y" : "cyFSRC-27lw-bOHZIMBZvGI1Y4FNeQQrkDzmDx1Eh_zNRQqG2gPz5u1SXQIBe_2z"
1041 }
1042 },
1043 {
1044 "comment" : "edge cases for ephemeral key",
1045 "curve" : "P-521",
1046 "name" : "EcdhTestVector",
1047 "result" : "valid",
1048 "shared" : "008a0e65c8611c570562e3eef2172e5fef175d211ca7613d3f301dd8babd9b47d400c31551ac4c06ef3850750a4cc6a012f31bcc556c41ba61054eb6af6829360842",
1049 "tcId" : 47,
1050 "private" : {
1051 "crv" : "P-521",
1052 "d" : "AKpIH05r5B-hJdYsfs2K1lPebZvuR-CKsJizim-_8jVMkK26amEEKxpylsbVT-aP0kR6-Rx_Jxl9IzyBSyPyWHCt",
1053 "ext" : "true",
1054 "kty" : "EC",
1055 "x" : "AP9uLiYau8O5k7k5b5HVp4wr56kfwhAkJk7K5GoGBaQ79oEgzdbbZA4-Xk5kvHcCt6A9JjhR98ADxmEoAR-GtHN6",
1056 "y" : "ACu39ZDjMkyQwIVvi1B4bwOPxZcAuitpWsXGXkh4vWzxvL9hKQ1exhkyu1gLyYipMAM8zZRQgcnGqQncxm8syuWK"
1057 },
1058 "public" : {
1059 "crv" : "P-521",
1060 "ext" : "true",
1061 "kty" : "EC",
1062 "x" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
1063 "y" : "ANIOyf6mtXfBDSbKG7RG9AspnmSLGtUIqtBoiW_uP45hS8YwVNV3K_AaZdQS4LyqjpZdL10zLX85-EbUQK4AH0-H"
1064 }
1065 },
1066 {
1067 "comment" : "edge cases for ephemeral key",
1068 "curve" : "P-521",
1069 "name" : "EcdhTestVector",
1070 "result" : "valid",
1071 "shared" : "012d650d8f3b211999aea626d97a2a359c98cf42ee4a7ce3353ddfea8e303102d60f1b82c207524bfe2c8f280d9d6c1345fe3f61ff889071310cbc5644a6d8683e66",
1072 "tcId" : 48,
1073 "private" : {
1074 "crv" : "P-521",
1075 "d" : "AR4Zxy_JL1yzPdR6rG0nq-06vo32mba1JskRrZPRiBAjcf6dNrGITYhWC_V3gtyeEODQbSDlmdvbI4BLN8vPGfxe",
1076 "ext" : "true",
1077 "kty" : "EC",
1078 "x" : "ACZGXGdGsWYaZ0fOuHCpoJ-8D_caLh8TQQYbcZgB8nXUpBKqn0vKcW1f9_XZVzTVYFKiDjyDIDH34dkf6d3yJwec",
1079 "y" : "AKv_XqoNtUyzdkKqU1ivxekOMmpKa7PKe9PjeCF5pzeVVg-1-6QBZcVOmAlXm2Y-QARvqtvTQbx0FValfOTeNgAj"
1080 },
1081 "public" : {
1082 "crv" : "P-521",
1083 "ext" : "true",
1084 "kty" : "EC",
1085 "x" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB",
1086 "y" : "ABDlm-k8TyacAmnHnir9ZdauqptwHqzBlPs-4D30eEm_VQ7GNuvuDd1KFvHNlAZgWvOPWEVndw4_Jy1ojIMuhDVk"
1087 }
1088 },
1089 {
1090 "comment" : "edge cases for ephemeral key",
1091 "curve" : "P-521",
1092 "name" : "EcdhTestVector",
1093 "result" : "valid",
1094 "shared" : "0090cd100d3a35ce5f9fc6c3dbefd3810d5096ed63e5ee046c26c28984f825a0ce6ff3d643e7ea1648b21dc8daad4286673aa84e28f256bbd978606a1fcca2942f7e",
1095 "tcId" : 49,
1096 "private" : {
1097 "crv" : "P-521",
1098 "d" : "AcfptciIDkTS-s55K0RvlPXZYl3MiXLWQIhQApWyG0rNBlExohWmt4I37TqsKPkuUetp6E5-LNjKfG72RFUZbfi2",
1099 "ext" : "true",
1100 "kty" : "EC",
1101 "x" : "ADmHGMepW0phM-0eOFYStqNF3raQTXAi9FSxb0e8UJiElG4uB4qS_48UaRfqxOrmt-RUoB2lmqmVveoTdSdvtotC",
1102 "y" : "AMxzlDgVrRolQOtp84UBNp9LX_n01wzS7y9RhaAQC_asgVt8IOymIuOAsdGo4JNeYUI7Zg30fS-elK8XVMa8DPzO"
1103 },
1104 "public" : {
1105 "crv" : "P-521",
1106 "ext" : "true",
1107 "kty" : "EC",
1108 "x" : "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC",
1109 "y" : "ANklT9-ABJasszeQsQPF7p-sEoMv5UbGMiJbD3_OPaRXSxqHm2I9ci-o_DTV_CqHMarWkamou4tVTJWgUdaqUFrP"
1110 }
1111 },
1112 {
1113 "comment" : "edge cases for ephemeral key",
1114 "curve" : "P-521",
1115 "name" : "EcdhTestVector",
1116 "result" : "valid",
1117 "shared" : "019c5a8fb31bfec0a892308140c2d4db952066bf0fb5b613c2674634723269da8fd19f1f93cbab0acd80a268f9d108b9a6103505e710b49ed6f3ec10a9a1aab0cb1d",
1118 "tcId" : 50,
1119 "private" : {
1120 "crv" : "P-521",
1121 "d" : "AEYv-AnJxUVNa43Cn7jWp0rMBxXHi-pd25Nfu2wd2vVNiw1OAP_KhduvhluBC6KWTZhpHwCNJhbyy5WiMbbfiKxL",
1122 "ext" : "true",
1123 "kty" : "EC",
1124 "x" : "AYMOoz0H-qWHNgCRhOi5vBMJcnSwGP9TKaNfoNthhA0misgNSJuLwEAUct3lk61FnOLDp-wOXWyWfxtiV14LZKIb",
1125 "y" : "AYLV9C9-sY5659HSeOojg7nt3Y_TZKiZR_XaavQZZZT9HwWOFVCA8s4OAbURON0bCi1DBqInrCxJ7WiiXp3HmzyZ"
1126 },
1127 "public" : {
1128 "crv" : "P-521",
1129 "ext" : "true",
1130 "kty" : "EC",
1131 "x" : "AAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____AAAAA_____",
1132 "y" : "AM0oOdhXtGmfXI6KAZR4biaoYvCGtLqAdGrlIl7Tqmj5a3quxVIlgwu5j1LXUiEUGJe6SdejHrvwttfTE1LlJmGQ"
1133 }
1134 },
1135 {
1136 "comment" : "edge cases for ephemeral key",
1137 "curve" : "P-521",
1138 "name" : "EcdhTestVector",
1139 "result" : "valid",
1140 "shared" : "001e6f34d1c431b605ba5ad341a6d4b21b7c9691d79ae8070fd56705d5ee60c98e3956f12ce58bb831452541b43ffafd102dea31bb4e964da6a3023745554011ebbe",
1141 "tcId" : 51,
1142 "private" : {
1143 "crv" : "P-521",
1144 "d" : "AeONg5fKDfXtk9-RlPUuOZz26gPs_jHUcxlqe5XPrG3PBxAmMQESzT1ZbWy1aZx6Gtqcq-rZOO2WrosQZgs-MV53",
1145 "ext" : "true",
1146 "kty" : "EC",
1147 "x" : "ALwl2eMdd-N5-DAfX84o2w-_iUTtYgq47BBS5uSGUWcYHug7BU3CTUBrKmYafhUQIqnIYxRPsflRVMqnncnxJglb",
1148 "y" : "AOq4DoCisqFOiANEtfs0lwIipGH_vkuPHGWNgaWw4oZlzT424fTyWIC4sj_RZc1sTPWD4kT5ROCnZcemPrVRkzyn"
1149 },
1150 "public" : {
1151 "crv" : "P-521",
1152 "ext" : "true",
1153 "kty" : "EC",
1154 "x" : "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
1155 "y" : "AAgT2YKRGfQv-pX-qLqegeTNamypf7B3jhLl9d_jUgHdTMqOyg0uOVVVmXBBOB5qwfGN30x04LbpBBz9yh0cEDCR"
1156 }
1157 },
1158 {
1159 "comment" : "edge cases for ephemeral key",
1160 "curve" : "P-521",
1161 "name" : "EcdhTestVector",
1162 "result" : "valid",
1163 "shared" : "01367e24697254f96336f32098b6a35dd364c1dfc897c03404ccc8b7b9d207b1fdb9c66bc55d586002c561651842f7a11a7b8f4208ffa14f2b81c867ed6ac5b311d8",
1164 "tcId" : 52,
1165 "private" : {
1166 "crv" : "P-521",
1167 "d" : "AEsWMPirCvc1jgUh5gZJQumH5N4pnOSFfhhCOuXC-URm2HqR6JudLVfMJ_2mSTDEf8ZtYb0Kw4N7s-D_VL_wlzvt",
1168 "ext" : "true",
1169 "kty" : "EC",
1170 "x" : "AWZCsAy5TErC8oCtxpdkWNdeBmsBC_blA3Z9OTcgnfqH6Z6YQvUtj3_XaVS2vShKMd_xkPc9CyEjNPIsUJ_5miOd",
1171 "y" : "Acgw-GCBGqMPwDF4k9giSYYiEXXYJUhe848wvoZfqL3OqY6cBY9bZXMGRMzwNWVjJK8TpITJHqUq_PXSQpRTrDVP"
1172 },
1173 "public" : {
1174 "crv" : "P-521",
1175 "ext" : "true",
1176 "kty" : "EC",
1177 "x" : "Af8AAAAA_____wAAAAD_____AAAAAP____8AAAAA_____wAAAAD_____AAAAAP____8AAAAA_____wAAAAD_____",
1178 "y" : "AB_oAMUOVAErdaM-S-fQfI1g8paAo5XpUaajHFCWsOqSj8LL8yfdeE3Ap8pG6nOZK3WLVkE2S0q6Oek3mKTZJaAI"
1179 }
1180 },
1181 {
1182 "comment" : "edge cases for ephemeral key",
1183 "curve" : "P-521",
1184 "name" : "EcdhTestVector",
1185 "result" : "valid",
1186 "shared" : "0028cde4500ebb4f53aa89d08b162020d53921d43035d585d5645172334c9b0df46e6b0bf66a5240239d51ef1017c14173313317fb544a889efa83effccece7eaea5",
1187 "tcId" : 53,
1188 "private" : {
1189 "crv" : "P-521",
1190 "d" : "AGSRnAUCVCS-_7fN2JLqlXl1gLNlaiyaC9C6UKFmcZN4yeeg79TzMqFPwCHCrhhe89p2BAs4U9Y5gycIOmTa7B96",
1191 "ext" : "true",
1192 "kty" : "EC",
1193 "x" : "AQ8Us1RKPVn2xxhkRI0_7tqkE5acYGGaG9hnqgp7Nbvw1UprVgWUO8tp2rwfyfvlGc56FIcbmahQTFhNnKq4k6T_",
1194 "y" : "AAd77iaKst0JYgHEOnz79w-ZseypWs56oKGXzM1CJ_DUj3zHw45O2GhZ_VfAVEHd1prLKYgqN6n6FQ6EuWhJ9Qih"
1195 },
1196 "public" : {
1197 "crv" : "P-521",
1198 "ext" : "true",
1199 "kty" : "EC",
1200 "x" : "Af8AAP__AAD__wAA__8AAP__AAD__wAA__8AAP__AAD__wAA__8AAP__AAD__wAA__8AAP__AAD__wAA__8AAQAA",
1201 "y" : "AI3Rih9eSCFAvnm7ZaIa1gyJh-UyyENF8BNa_9Ruxx7wKxyjrVbzAdlV-jBsEi1EHW_tz4uFXvJWNQv2nSOnIHrZ"
1202 }
1203 },
1204 {
1205 "comment" : "edge cases for ephemeral key",
1206 "curve" : "P-521",
1207 "name" : "EcdhTestVector",
1208 "result" : "valid",
1209 "shared" : "01f11556b0c2544695555c2c142ebbf72572244e043b755dfca7adcd32d1ff68177a70af88fdbad573f22943522c5e40a99794e3e629518d471f302bdd5cf0be729b",
1210 "tcId" : 54,
1211 "private" : {
1212 "crv" : "P-521",
1213 "d" : "ADl_dtWjNwzJxNPMypvvZQIh4hL8nLY-0GZQoinG9y5L9dh-erUW3nwCgLn1-mZI4F9qIxNxpdPL6WuapnyEJuPE",
1214 "ext" : "true",
1215 "kty" : "EC",
1216 "x" : "AOVtRhkHpYEOdY37Ctitf8tdcazfFeYJpGDIND4IE5Zsurd8gqMeSyp89mOH84HYc1-sBF5JhQ-bF3Pqj2W4-vhi",
1217 "y" : "ASX4TFfru6w_bk3u9k71gKNWFQgDENvSHSLRQhDSCi7w2PHTs9tdJM48O9C7WYw7EImq4oiK3D1jnHbkOyCwLfyd"
1218 },
1219 "public" : {
1220 "crv" : "P-521",
1221 "ext" : "true",
1222 "kty" : "EC",
1223 "x" : "Af_AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__AAH__",
1224 "y" : "ALEcZo-9VJ82iJ97Y0NAUdom8VcFg5E2sbFKCRUtehgup4BsNUeKMtOqPJwWJ6YVGevscbNvp3RJAluIKeJ_MHg0"
1225 }
1226 },
1227 {
1228 "comment" : "edge cases for ephemeral key",
1229 "curve" : "P-521",
1230 "name" : "EcdhTestVector",
1231 "result" : "valid",
1232 "shared" : "00f8f1e1940e2a69e733f8a7a5c9a2d30cad0dd901e702a0687cc83913f0123bbf9ffe5ae4ff6c5630118268e8e67f4327482b9b7e69a93ef4da1d3abe00e3692482",
1233 "tcId" : 55,
1234 "private" : {
1235 "crv" : "P-521",
1236 "d" : "AGiax25EUHBf6o5rTio6wNt2Z1BZdO3Y2ht6Nwj-nUi2sP8oGnmRfx1Qo3k8tGyzTke1Bisrhb_NFo_oByKuRVxt",
1237 "ext" : "true",
1238 "kty" : "EC",
1239 "x" : "ATu4_yZKbhiOikpAwZFrAw5TthD8lUyOjEfH3F8Pwx65KrWdzCTsUxlytYdvO2VGVGGLrfIBRKQeQA6DHxTeRIN1",
1240 "y" : "AY6_5hJv8HywySeUmLI64-Tyjrwof-9xEGkcF13wZC5t780Nsn78-whvVaeMxfl--bKWCF-8cq-ylayu-LRueG_p"
1241 },
1242 "public" : {
1243 "crv" : "P-521",
1244 "ext" : "true",
1245 "kty" : "EC",
1246 "x" : "Af___wAAAAH____8AAAAB_____AAAAAf____wAAAAH____8AAAAB_____AAAAAf____wAAAAH____8AAAACAAAAC",
1247 "y" : "AKp178Co2qwdc_MsnFUkFLzPRK-OdDMbR0OefcxJoTWz7mHp9pcX2JtLujVnoZWu2hP77GNL8phLXsa2-A9ZeO1a"
1248 }
1249 },
1250 {
1251 "comment" : "edge cases for ephemeral key",
1252 "curve" : "P-521",
1253 "name" : "EcdhTestVector",
1254 "result" : "valid",
1255 "shared" : "008567b96fddfb4acc4b0317e5a8144b879e762bd611a8d8d0825c7af7a464d27eee6b721f7bf4aa431b095743299f36c27b0b520432472b040a9807f21abdb78dcb",
1256 "tcId" : 56,
1257 "private" : {
1258 "crv" : "P-521",
1259 "d" : "AMRVHZr067NGsXtKirPSRFaj2KL9oSIC90jdOYlU4CJTLzssF1bZC0BqnOX9AzxAz3C7-ny0LK7Ik3VbgnDy6GQ8",
1260 "ext" : "true",
1261 "kty" : "EC",
1262 "x" : "ABLN5qTrWH6RKn_frzdnVX3XWnW-sQ63iWeknyzshq-U1Fw_tEFN0AN7sV-JzjQaDDkuHyegXmtxfNuJPBI2AzBe",
1263 "y" : "AM6aaQYwMBmQKDRt1cvTDEdK6CMahJOePc7IYRix5VKgsbmBfCv7F9_xE5nexRTjDzGv309LnvVJQ0kk9Fv6f2u7"
1264 },
1265 "public" : {
1266 "crv" : "P-521",
1267 "ext" : "true",
1268 "kty" : "EC",
1269 "x" : "Af_____________________________________________________________________________________9",
1270 "y" : "ABDlm-k8TyacAmnHnir9ZdauqptwHqzBlPs-4D30eEm_VQ7GNuvuDd1KFvHNlAZgWvOPWEVndw4_Jy1ojIMuhDVk"
1271 }
1272 },
1273 {
1274 "comment" : "edge cases for ephemeral key",
1275 "curve" : "P-521",
1276 "name" : "EcdhTestVector",
1277 "result" : "valid",
1278 "shared" : "01c0ed430408acb310910db1933c22d021030c8b9c011b201325484911eec542605283f2a41c02f20ea6d96291293ce16794a759bbe1428bd6f4bc53a1db40e80b0e",
1279 "tcId" : 57,
1280 "private" : {
1281 "crv" : "P-521",
1282 "d" : "AWFrDPqiz_GzwVebeJ-MTnUZsc0Aw-nLZ8PkYl70WQdMhFe9aMQTp5ocQCC0h1_QQBEQxzTYioxfyLTVqA7W7xQ9",
1283 "ext" : "true",
1284 "kty" : "EC",
1285 "x" : "AfAnhZSidHsHhjPfcqc0MsllGBwegXg2tIcHQB3vOeRRvgjL_bLoaYHmp8fZ5ZVrBQcGQ7AMBfB86XiKe-27q_zS",
1286 "y" : "AE16Vy45Ij40KlRqhAFe_SSI7u5tfr5GfAmAPyeHVlM7ryOAOoohrLymiwSLJEmHCukT97D3xbIPdX_1eQyPWrit"
1287 },
1288 "public" : {
1289 "crv" : "P-521",
1290 "ext" : "true",
1291 "kty" : "EC",
1292 "x" : "Af_____________________________________________________________________________________-",
1293 "y" : "ANklT9-ABJasszeQsQPF7p-sEoMv5UbGMiJbD3_OPaRXSxqHm2I9ci-o_DTV_CqHMarWkamou4tVTJWgUdaqUFrP"
1294 }
1295 }
1296 ]
1297 }
1298 ]
1299 }
0 {
1 "algorithm" : "ECDSA",
2 "generatorVersion" : "0.0a10",
3 "numberOfTests" : 273,
4 "testGroups" : [
5 {
6 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044af4f6d1d734798d4c4c6f97c4fff392ee65dc252d617b154ca835ea1535b104fb069171d00e87a92e6c4db1d892bc09b04b5da8bd9b09cfaa41d0a526e55237",
7 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESvT20dc0eY1MTG+XxP/zku5l3CUt\nYXsVTKg16hU1sQT7BpFx0A6HqS5sTbHYkrwJsEtdqL2bCc+qQdClJuVSNw==\n-----END PUBLIC KEY-----",
8 "sha" : "SHA-256",
9 "type" : "ECDSAVer",
10 "key" : {
11 "curve" : "secp256r1",
12 "type" : "ECPublicKey",
13 "wx" : "4af4f6d1d734798d4c4c6f97c4fff392ee65dc252d617b154ca835ea1535b104",
14 "wy" : "0fb069171d00e87a92e6c4db1d892bc09b04b5da8bd9b09cfaa41d0a526e55237"
15 },
16 "tests" : [
17 {
18 "comment" : "signature malleability",
19 "message" : "48656c6c6f",
20 "result" : "valid",
21 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0221008b8d6e21d0c0bb5185319715ccbce2902802e1eca070b7226dec70ceca023883",
22 "tcId" : 1
23 },
24 {
25 "comment" : "random signature",
26 "message" : "48656c6c6f",
27 "result" : "valid",
28 "sig" : "3046022100dc6483cb966474fc22f2e68660e5e52f3bfa403b962de583576177c0dab2a260022100db4526559f5145e2fc5aa10d1d993a811973144f99b86474599a9f1e212c07f1",
29 "tcId" : 2
30 },
31 {
32 "comment" : "random signature",
33 "message" : "48656c6c6f",
34 "result" : "valid",
35 "sig" : "304402201f0819fe1695c49555d6f3c1648a04c24cc59bad4120b3a66e997481d4e973a002206cf5660873b490ee99563c958a02178890191b7da31bd87e43161d83a6ad0efe",
36 "tcId" : 3
37 },
38 {
39 "comment" : "random signature",
40 "message" : "48656c6c6f",
41 "result" : "valid",
42 "sig" : "3046022100b925b7d5a274ec43833fc87d66e50d8bf0be579912d882be3300e7167985448f022100e319bfd2931d9a83b709dd5509d0d907188fa03d3025f842ca9123d052be6c70",
43 "tcId" : 4
44 },
45 {
46 "comment" : "random signature",
47 "message" : "48656c6c6f",
48 "result" : "valid",
49 "sig" : "3046022100d2cb5feded860091556d8710ad7e7aab7a6350d2d97238177604d8d330e0357a022100cab37fcb3ef1fd4485aca7d75dd4685b56f5078383936ad84f8af4c12b874c40",
50 "tcId" : 5
51 },
52 {
53 "comment" : "random signature",
54 "message" : "48656c6c6f",
55 "result" : "valid",
56 "sig" : "3045022100bcf08f55b39ec37c3939d58e9eb6d42f21bccff63f661eecd06c89acb689067b022062e2ba2ec55bb9fe5aaa888d5836deff0abf45cbbaf2f8228b31d2cefa380466",
57 "tcId" : 6
58 },
59 {
60 "comment" : "valid",
61 "message" : "48656c6c6f",
62 "result" : "valid",
63 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
64 "tcId" : 7
65 },
66 {
67 "comment" : "BER:long form encoding of length",
68 "message" : "48656c6c6f",
69 "result" : "acceptable",
70 "sig" : "308145022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
71 "tcId" : 8
72 },
73 {
74 "comment" : "BER:long form encoding of length",
75 "message" : "48656c6c6f",
76 "result" : "acceptable",
77 "sig" : "304602812100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
78 "tcId" : 9
79 },
80 {
81 "comment" : "BER:long form encoding of length",
82 "message" : "48656c6c6f",
83 "result" : "acceptable",
84 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f028120747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
85 "tcId" : 10
86 },
87 {
88 "comment" : "BER:length contains leading 0",
89 "message" : "48656c6c6f",
90 "result" : "acceptable",
91 "sig" : "30820045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
92 "tcId" : 11
93 },
94 {
95 "comment" : "BER:length contains leading 0",
96 "message" : "48656c6c6f",
97 "result" : "acceptable",
98 "sig" : "30470282002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
99 "tcId" : 12
100 },
101 {
102 "comment" : "BER:length contains leading 0",
103 "message" : "48656c6c6f",
104 "result" : "acceptable",
105 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02820020747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
106 "tcId" : 13
107 },
108 {
109 "comment" : "BER:indefinite length",
110 "message" : "48656c6c6f",
111 "result" : "acceptable",
112 "sig" : "3080022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
113 "tcId" : 14
114 },
115 {
116 "comment" : "BER:prepending 0's to integer",
117 "message" : "48656c6c6f",
118 "result" : "acceptable",
119 "sig" : "30470223000000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
120 "tcId" : 15
121 },
122 {
123 "comment" : "BER:prepending 0's to integer",
124 "message" : "48656c6c6f",
125 "result" : "acceptable",
126 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02220000747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
127 "tcId" : 16
128 },
129 {
130 "comment" : "wrong length",
131 "message" : "48656c6c6f",
132 "result" : "invalid",
133 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
134 "tcId" : 17
135 },
136 {
137 "comment" : "wrong length",
138 "message" : "48656c6c6f",
139 "result" : "invalid",
140 "sig" : "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
141 "tcId" : 18
142 },
143 {
144 "comment" : "wrong length",
145 "message" : "48656c6c6f",
146 "result" : "invalid",
147 "sig" : "3045022200b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
148 "tcId" : 19
149 },
150 {
151 "comment" : "wrong length",
152 "message" : "48656c6c6f",
153 "result" : "invalid",
154 "sig" : "3045022000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
155 "tcId" : 20
156 },
157 {
158 "comment" : "wrong length",
159 "message" : "48656c6c6f",
160 "result" : "invalid",
161 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0221747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
162 "tcId" : 21
163 },
164 {
165 "comment" : "wrong length",
166 "message" : "48656c6c6f",
167 "result" : "invalid",
168 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f021f747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
169 "tcId" : 22
170 },
171 {
172 "comment" : "uint32 overflow in length",
173 "message" : "48656c6c6f",
174 "result" : "invalid",
175 "sig" : "30850100000045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
176 "tcId" : 23
177 },
178 {
179 "comment" : "uint32 overflow in length",
180 "message" : "48656c6c6f",
181 "result" : "invalid",
182 "sig" : "304a0285010000002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
183 "tcId" : 24
184 },
185 {
186 "comment" : "uint32 overflow in length",
187 "message" : "48656c6c6f",
188 "result" : "invalid",
189 "sig" : "304a022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02850100000020747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
190 "tcId" : 25
191 },
192 {
193 "comment" : "uint64 overflow in length",
194 "message" : "48656c6c6f",
195 "result" : "invalid",
196 "sig" : "3089010000000000000045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
197 "tcId" : 26
198 },
199 {
200 "comment" : "uint64 overflow in length",
201 "message" : "48656c6c6f",
202 "result" : "invalid",
203 "sig" : "304e028901000000000000002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
204 "tcId" : 27
205 },
206 {
207 "comment" : "uint64 overflow in length",
208 "message" : "48656c6c6f",
209 "result" : "invalid",
210 "sig" : "304e022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0289010000000000000020747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
211 "tcId" : 28
212 },
213 {
214 "comment" : "length = 2**31 - 1",
215 "message" : "48656c6c6f",
216 "result" : "invalid",
217 "sig" : "30847fffffff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
218 "tcId" : 29
219 },
220 {
221 "comment" : "length = 2**31 - 1",
222 "message" : "48656c6c6f",
223 "result" : "invalid",
224 "sig" : "304902847fffffff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
225 "tcId" : 30
226 },
227 {
228 "comment" : "length = 2**31 - 1",
229 "message" : "48656c6c6f",
230 "result" : "invalid",
231 "sig" : "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02847fffffff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
232 "tcId" : 31
233 },
234 {
235 "comment" : "length = 2**32 - 1",
236 "message" : "48656c6c6f",
237 "result" : "invalid",
238 "sig" : "3084ffffffff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
239 "tcId" : 32
240 },
241 {
242 "comment" : "length = 2**32 - 1",
243 "message" : "48656c6c6f",
244 "result" : "invalid",
245 "sig" : "30490284ffffffff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
246 "tcId" : 33
247 },
248 {
249 "comment" : "length = 2**32 - 1",
250 "message" : "48656c6c6f",
251 "result" : "invalid",
252 "sig" : "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0284ffffffff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
253 "tcId" : 34
254 },
255 {
256 "comment" : "length = 2**40 - 1",
257 "message" : "48656c6c6f",
258 "result" : "invalid",
259 "sig" : "3085ffffffffff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
260 "tcId" : 35
261 },
262 {
263 "comment" : "length = 2**40 - 1",
264 "message" : "48656c6c6f",
265 "result" : "invalid",
266 "sig" : "304a0285ffffffffff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
267 "tcId" : 36
268 },
269 {
270 "comment" : "length = 2**40 - 1",
271 "message" : "48656c6c6f",
272 "result" : "invalid",
273 "sig" : "304a022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0285ffffffffff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
274 "tcId" : 37
275 },
276 {
277 "comment" : "length = 2**64 - 1",
278 "message" : "48656c6c6f",
279 "result" : "invalid",
280 "sig" : "3088ffffffffffffffff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
281 "tcId" : 38
282 },
283 {
284 "comment" : "length = 2**64 - 1",
285 "message" : "48656c6c6f",
286 "result" : "invalid",
287 "sig" : "304d0288ffffffffffffffff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
288 "tcId" : 39
289 },
290 {
291 "comment" : "length = 2**64 - 1",
292 "message" : "48656c6c6f",
293 "result" : "invalid",
294 "sig" : "304d022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0288ffffffffffffffff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
295 "tcId" : 40
296 },
297 {
298 "comment" : "incorrect length",
299 "message" : "48656c6c6f",
300 "result" : "invalid",
301 "sig" : "30ff022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
302 "tcId" : 41
303 },
304 {
305 "comment" : "incorrect length",
306 "message" : "48656c6c6f",
307 "result" : "invalid",
308 "sig" : "304502ff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
309 "tcId" : 42
310 },
311 {
312 "comment" : "incorrect length",
313 "message" : "48656c6c6f",
314 "result" : "invalid",
315 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02ff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
316 "tcId" : 43
317 },
318 {
319 "comment" : "indefinte length without termination",
320 "message" : "48656c6c6f",
321 "result" : "invalid",
322 "sig" : "3080022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
323 "tcId" : 44
324 },
325 {
326 "comment" : "indefinte length without termination",
327 "message" : "48656c6c6f",
328 "result" : "invalid",
329 "sig" : "3045028000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
330 "tcId" : 45
331 },
332 {
333 "comment" : "indefinte length without termination",
334 "message" : "48656c6c6f",
335 "result" : "invalid",
336 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0280747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
337 "tcId" : 46
338 },
339 {
340 "comment" : "removing sequence",
341 "message" : "48656c6c6f",
342 "result" : "invalid",
343 "sig" : "",
344 "tcId" : 47
345 },
346 {
347 "comment" : "appending 0's to sequence",
348 "message" : "48656c6c6f",
349 "result" : "invalid",
350 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
351 "tcId" : 48
352 },
353 {
354 "comment" : "prepending 0's to sequence",
355 "message" : "48656c6c6f",
356 "result" : "invalid",
357 "sig" : "30470000022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
358 "tcId" : 49
359 },
360 {
361 "comment" : "appending unused 0's",
362 "message" : "48656c6c6f",
363 "result" : "invalid",
364 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
365 "tcId" : 50
366 },
367 {
368 "comment" : "appending unused 0's",
369 "message" : "48656c6c6f",
370 "result" : "invalid",
371 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f00000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
372 "tcId" : 51
373 },
374 {
375 "comment" : "appending null value",
376 "message" : "48656c6c6f",
377 "result" : "invalid",
378 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0500",
379 "tcId" : 52
380 },
381 {
382 "comment" : "appending null value",
383 "message" : "48656c6c6f",
384 "result" : "invalid",
385 "sig" : "3047022300b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f05000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
386 "tcId" : 53
387 },
388 {
389 "comment" : "appending null value",
390 "message" : "48656c6c6f",
391 "result" : "invalid",
392 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0222747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0500",
393 "tcId" : 54
394 },
395 {
396 "comment" : "including garbage",
397 "message" : "48656c6c6f",
398 "result" : "invalid",
399 "sig" : "304a4981773045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
400 "tcId" : 55
401 },
402 {
403 "comment" : "including garbage",
404 "message" : "48656c6c6f",
405 "result" : "invalid",
406 "sig" : "304925003045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
407 "tcId" : 56
408 },
409 {
410 "comment" : "including garbage",
411 "message" : "48656c6c6f",
412 "result" : "invalid",
413 "sig" : "30473045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0004deadbeef",
414 "tcId" : 57
415 },
416 {
417 "comment" : "including garbage",
418 "message" : "48656c6c6f",
419 "result" : "invalid",
420 "sig" : "304a2226498177022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
421 "tcId" : 58
422 },
423 {
424 "comment" : "including garbage",
425 "message" : "48656c6c6f",
426 "result" : "invalid",
427 "sig" : "304922252500022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
428 "tcId" : 59
429 },
430 {
431 "comment" : "including garbage",
432 "message" : "48656c6c6f",
433 "result" : "invalid",
434 "sig" : "304d2223022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0004deadbeef0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
435 "tcId" : 60
436 },
437 {
438 "comment" : "including garbage",
439 "message" : "48656c6c6f",
440 "result" : "invalid",
441 "sig" : "304a022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f22254981770220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
442 "tcId" : 61
443 },
444 {
445 "comment" : "including garbage",
446 "message" : "48656c6c6f",
447 "result" : "invalid",
448 "sig" : "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f222425000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
449 "tcId" : 62
450 },
451 {
452 "comment" : "including garbage",
453 "message" : "48656c6c6f",
454 "result" : "invalid",
455 "sig" : "304d022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f22220220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0004deadbeef",
456 "tcId" : 63
457 },
458 {
459 "comment" : "including undefined tags",
460 "message" : "48656c6c6f",
461 "result" : "invalid",
462 "sig" : "304daa00bb00cd003045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
463 "tcId" : 64
464 },
465 {
466 "comment" : "including undefined tags",
467 "message" : "48656c6c6f",
468 "result" : "invalid",
469 "sig" : "304baa02aabb3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
470 "tcId" : 65
471 },
472 {
473 "comment" : "including undefined tags",
474 "message" : "48656c6c6f",
475 "result" : "invalid",
476 "sig" : "304d2229aa00bb00cd00022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
477 "tcId" : 66
478 },
479 {
480 "comment" : "including undefined tags",
481 "message" : "48656c6c6f",
482 "result" : "invalid",
483 "sig" : "304b2227aa02aabb022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
484 "tcId" : 67
485 },
486 {
487 "comment" : "including undefined tags",
488 "message" : "48656c6c6f",
489 "result" : "invalid",
490 "sig" : "304d022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f2228aa00bb00cd000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
491 "tcId" : 68
492 },
493 {
494 "comment" : "including undefined tags",
495 "message" : "48656c6c6f",
496 "result" : "invalid",
497 "sig" : "304b022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f2226aa02aabb0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
498 "tcId" : 69
499 },
500 {
501 "comment" : "using composition with indefinite length",
502 "message" : "48656c6c6f",
503 "result" : "invalid",
504 "sig" : "30803045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
505 "tcId" : 70
506 },
507 {
508 "comment" : "using composition with indefinite length",
509 "message" : "48656c6c6f",
510 "result" : "invalid",
511 "sig" : "30492280022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f00000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
512 "tcId" : 71
513 },
514 {
515 "comment" : "using composition with indefinite length",
516 "message" : "48656c6c6f",
517 "result" : "invalid",
518 "sig" : "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f22800220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
519 "tcId" : 72
520 },
521 {
522 "comment" : "using composition with wrong tag",
523 "message" : "48656c6c6f",
524 "result" : "invalid",
525 "sig" : "30803145022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
526 "tcId" : 73
527 },
528 {
529 "comment" : "using composition with wrong tag",
530 "message" : "48656c6c6f",
531 "result" : "invalid",
532 "sig" : "30492280032100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f00000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
533 "tcId" : 74
534 },
535 {
536 "comment" : "using composition with wrong tag",
537 "message" : "48656c6c6f",
538 "result" : "invalid",
539 "sig" : "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f22800320747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
540 "tcId" : 75
541 },
542 {
543 "comment" : "changing tag value",
544 "message" : "48656c6c6f",
545 "result" : "invalid",
546 "sig" : "2e45022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
547 "tcId" : 76
548 },
549 {
550 "comment" : "changing tag value",
551 "message" : "48656c6c6f",
552 "result" : "invalid",
553 "sig" : "3245022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
554 "tcId" : 77
555 },
556 {
557 "comment" : "changing tag value",
558 "message" : "48656c6c6f",
559 "result" : "invalid",
560 "sig" : "ff45022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
561 "tcId" : 78
562 },
563 {
564 "comment" : "changing tag value",
565 "message" : "48656c6c6f",
566 "result" : "invalid",
567 "sig" : "3045002100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
568 "tcId" : 79
569 },
570 {
571 "comment" : "changing tag value",
572 "message" : "48656c6c6f",
573 "result" : "invalid",
574 "sig" : "3045042100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
575 "tcId" : 80
576 },
577 {
578 "comment" : "changing tag value",
579 "message" : "48656c6c6f",
580 "result" : "invalid",
581 "sig" : "3045ff2100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
582 "tcId" : 81
583 },
584 {
585 "comment" : "changing tag value",
586 "message" : "48656c6c6f",
587 "result" : "invalid",
588 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0020747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
589 "tcId" : 82
590 },
591 {
592 "comment" : "changing tag value",
593 "message" : "48656c6c6f",
594 "result" : "invalid",
595 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0420747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
596 "tcId" : 83
597 },
598 {
599 "comment" : "changing tag value",
600 "message" : "48656c6c6f",
601 "result" : "invalid",
602 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3fff20747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
603 "tcId" : 84
604 },
605 {
606 "comment" : "dropping value of sequence",
607 "message" : "48656c6c6f",
608 "result" : "invalid",
609 "sig" : "3000",
610 "tcId" : 85
611 },
612 {
613 "comment" : "using composition",
614 "message" : "48656c6c6f",
615 "result" : "invalid",
616 "sig" : "304930010230442100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
617 "tcId" : 86
618 },
619 {
620 "comment" : "using composition",
621 "message" : "48656c6c6f",
622 "result" : "invalid",
623 "sig" : "304922250201000220b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
624 "tcId" : 87
625 },
626 {
627 "comment" : "using composition",
628 "message" : "48656c6c6f",
629 "result" : "invalid",
630 "sig" : "3049022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f2224020174021f7291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
631 "tcId" : 88
632 },
633 {
634 "comment" : "truncate sequence",
635 "message" : "48656c6c6f",
636 "result" : "invalid",
637 "sig" : "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ec",
638 "tcId" : 89
639 },
640 {
641 "comment" : "truncate sequence",
642 "message" : "48656c6c6f",
643 "result" : "invalid",
644 "sig" : "30442100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
645 "tcId" : 90
646 },
647 {
648 "comment" : "prepend empty sequence",
649 "message" : "48656c6c6f",
650 "result" : "invalid",
651 "sig" : "30473000022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
652 "tcId" : 91
653 },
654 {
655 "comment" : "append empty sequence",
656 "message" : "48656c6c6f",
657 "result" : "invalid",
658 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce3000",
659 "tcId" : 92
660 },
661 {
662 "comment" : "sequence of sequence",
663 "message" : "48656c6c6f",
664 "result" : "invalid",
665 "sig" : "30473045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
666 "tcId" : 93
667 },
668 {
669 "comment" : "truncated sequence",
670 "message" : "48656c6c6f",
671 "result" : "invalid",
672 "sig" : "3023022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f",
673 "tcId" : 94
674 },
675 {
676 "comment" : "repeat element in sequence",
677 "message" : "48656c6c6f",
678 "result" : "invalid",
679 "sig" : "3067022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
680 "tcId" : 95
681 },
682 {
683 "comment" : "removing integer",
684 "message" : "48656c6c6f",
685 "result" : "invalid",
686 "sig" : "30220220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
687 "tcId" : 96
688 },
689 {
690 "comment" : "appending 0's to integer",
691 "message" : "48656c6c6f",
692 "result" : "invalid",
693 "sig" : "3047022300b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f00000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
694 "tcId" : 97
695 },
696 {
697 "comment" : "appending 0's to integer",
698 "message" : "48656c6c6f",
699 "result" : "invalid",
700 "sig" : "3047022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0222747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce0000",
701 "tcId" : 98
702 },
703 {
704 "comment" : "dropping value of integer",
705 "message" : "48656c6c6f",
706 "result" : "invalid",
707 "sig" : "302402000220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
708 "tcId" : 99
709 },
710 {
711 "comment" : "dropping value of integer",
712 "message" : "48656c6c6f",
713 "result" : "invalid",
714 "sig" : "3025022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0200",
715 "tcId" : 100
716 },
717 {
718 "comment" : "modify first byte of integer",
719 "message" : "48656c6c6f",
720 "result" : "invalid",
721 "sig" : "3045022101b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
722 "tcId" : 101
723 },
724 {
725 "comment" : "modify first byte of integer",
726 "message" : "48656c6c6f",
727 "result" : "invalid",
728 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220757291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
729 "tcId" : 102
730 },
731 {
732 "comment" : "modify last byte of integer",
733 "message" : "48656c6c6f",
734 "result" : "invalid",
735 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3e0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
736 "tcId" : 103
737 },
738 {
739 "comment" : "modify last byte of integer",
740 "message" : "48656c6c6f",
741 "result" : "invalid",
742 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260eccf",
743 "tcId" : 104
744 },
745 {
746 "comment" : "truncate integer",
747 "message" : "48656c6c6f",
748 "result" : "invalid",
749 "sig" : "3044022000b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
750 "tcId" : 105
751 },
752 {
753 "comment" : "truncate integer",
754 "message" : "48656c6c6f",
755 "result" : "invalid",
756 "sig" : "30440220b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
757 "tcId" : 106
758 },
759 {
760 "comment" : "truncate integer",
761 "message" : "48656c6c6f",
762 "result" : "invalid",
763 "sig" : "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f021f747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ec",
764 "tcId" : 107
765 },
766 {
767 "comment" : "truncate integer",
768 "message" : "48656c6c6f",
769 "result" : "invalid",
770 "sig" : "3044022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f021f7291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
771 "tcId" : 108
772 },
773 {
774 "comment" : "leading ff in integer",
775 "message" : "48656c6c6f",
776 "result" : "invalid",
777 "sig" : "30460222ff00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
778 "tcId" : 109
779 },
780 {
781 "comment" : "leading ff in integer",
782 "message" : "48656c6c6f",
783 "result" : "invalid",
784 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0221ff747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
785 "tcId" : 110
786 },
787 {
788 "comment" : "infinity",
789 "message" : "48656c6c6f",
790 "result" : "invalid",
791 "sig" : "30250901800220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
792 "tcId" : 111
793 },
794 {
795 "comment" : "infinity",
796 "message" : "48656c6c6f",
797 "result" : "invalid",
798 "sig" : "3026022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f090180",
799 "tcId" : 112
800 },
801 {
802 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
803 "message" : "48656c6c6f",
804 "result" : "invalid",
805 "sig" : "3045022101b7babae8332b54b9a3a05b7004579821656e9c5fbb7d96607df713de366051900220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
806 "tcId" : 113
807 },
808 {
809 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
810 "message" : "48656c6c6f",
811 "result" : "invalid",
812 "sig" : "30440220b7babaea332b54b7a3a05b7004579821eba0a7046d4e595696837e583d9a06ee0220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
813 "tcId" : 114
814 },
815 {
816 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
817 "message" : "48656c6c6f",
818 "result" : "invalid",
819 "sig" : "30450221ff48454516ccd4ab475c5fa48ffba867de57785e4deb9a082475c2b6e4c602d3c10220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
820 "tcId" : 115
821 },
822 {
823 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
824 "message" : "48656c6c6f",
825 "result" : "invalid",
826 "sig" : "3044022048454515ccd4ab485c5fa48ffba867de145f58fb92b1a6a9697c81a7c265f9120220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
827 "tcId" : 116
828 },
829 {
830 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
831 "message" : "48656c6c6f",
832 "result" : "invalid",
833 "sig" : "30450221fe48454517ccd4ab465c5fa48ffba867de9a9163a04482699f8208ec21c99fae700220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
834 "tcId" : 117
835 },
836 {
837 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
838 "message" : "48656c6c6f",
839 "result" : "invalid",
840 "sig" : "3044022048454516ccd4ab475c5fa48ffba867de57785e4deb9a082475c2b6e4c602d3c10220747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
841 "tcId" : 118
842 },
843 {
844 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
845 "message" : "48656c6c6f",
846 "result" : "invalid",
847 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f022101747291dc2f3f44b07ace68ea33431d6f51cb136eadbe85e7798724b72ec4121f",
848 "tcId" : 119
849 },
850 {
851 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
852 "message" : "48656c6c6f",
853 "result" : "invalid",
854 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0221ff747291de2f3f44ae7ace68ea33431d6fd7fd1e135f8f48dd92138f3135fdc77d",
855 "tcId" : 120
856 },
857 {
858 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
859 "message" : "48656c6c6f",
860 "result" : "invalid",
861 "sig" : "3045022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f02208b8d6e22d0c0bb5085319715ccbce2906b1be73ef959189d7a32a60bcd9f1332",
862 "tcId" : 121
863 },
864 {
865 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
866 "message" : "48656c6c6f",
867 "result" : "invalid",
868 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0221fe8b8d6e23d0c0bb4f85319715ccbce290ae34ec9152417a188678db48d13bede1",
869 "tcId" : 122
870 },
871 {
872 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
873 "message" : "48656c6c6f",
874 "result" : "invalid",
875 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f022101747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
876 "tcId" : 123
877 },
878 {
879 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
880 "message" : "48656c6c6f",
881 "result" : "invalid",
882 "sig" : "3046022100b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f0221008b8d6e22d0c0bb5085319715ccbce2906b1be73ef959189d7a32a60bcd9f1332",
883 "tcId" : 124
884 },
885 {
886 "comment" : "Signatures with special case values for r and s.",
887 "message" : "48656c6c6f",
888 "result" : "invalid",
889 "sig" : "3006020100020100",
890 "tcId" : 125
891 },
892 {
893 "comment" : "Signatures with special case values for r and s.",
894 "message" : "48656c6c6f",
895 "result" : "invalid",
896 "sig" : "3006020100020101",
897 "tcId" : 126
898 },
899 {
900 "comment" : "Signatures with special case values for r and s.",
901 "message" : "48656c6c6f",
902 "result" : "invalid",
903 "sig" : "30060201000201f0",
904 "tcId" : 127
905 },
906 {
907 "comment" : "Signatures with special case values for r and s.",
908 "message" : "48656c6c6f",
909 "result" : "invalid",
910 "sig" : "3026020100022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
911 "tcId" : 128
912 },
913 {
914 "comment" : "Signatures with special case values for r and s.",
915 "message" : "48656c6c6f",
916 "result" : "invalid",
917 "sig" : "3026020100022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
918 "tcId" : 129
919 },
920 {
921 "comment" : "Signatures with special case values for r and s.",
922 "message" : "48656c6c6f",
923 "result" : "invalid",
924 "sig" : "3026020100022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
925 "tcId" : 130
926 },
927 {
928 "comment" : "Signatures with special case values for r and s.",
929 "message" : "48656c6c6f",
930 "result" : "invalid",
931 "sig" : "3026020100022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
932 "tcId" : 131
933 },
934 {
935 "comment" : "Signatures with special case values for r and s.",
936 "message" : "48656c6c6f",
937 "result" : "invalid",
938 "sig" : "3026020100022100ffffffff00000001000000000000000000000001000000000000000000000000",
939 "tcId" : 132
940 },
941 {
942 "comment" : "Signatures with special case values for r and s.",
943 "message" : "48656c6c6f",
944 "result" : "invalid",
945 "sig" : "3008020100090380fe01",
946 "tcId" : 133
947 },
948 {
949 "comment" : "Signatures with special case values for r and s.",
950 "message" : "48656c6c6f",
951 "result" : "invalid",
952 "sig" : "3006020101020100",
953 "tcId" : 134
954 },
955 {
956 "comment" : "Signatures with special case values for r and s.",
957 "message" : "48656c6c6f",
958 "result" : "invalid",
959 "sig" : "3006020101020101",
960 "tcId" : 135
961 },
962 {
963 "comment" : "Signatures with special case values for r and s.",
964 "message" : "48656c6c6f",
965 "result" : "invalid",
966 "sig" : "30060201010201f0",
967 "tcId" : 136
968 },
969 {
970 "comment" : "Signatures with special case values for r and s.",
971 "message" : "48656c6c6f",
972 "result" : "invalid",
973 "sig" : "3026020101022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
974 "tcId" : 137
975 },
976 {
977 "comment" : "Signatures with special case values for r and s.",
978 "message" : "48656c6c6f",
979 "result" : "invalid",
980 "sig" : "3026020101022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
981 "tcId" : 138
982 },
983 {
984 "comment" : "Signatures with special case values for r and s.",
985 "message" : "48656c6c6f",
986 "result" : "invalid",
987 "sig" : "3026020101022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
988 "tcId" : 139
989 },
990 {
991 "comment" : "Signatures with special case values for r and s.",
992 "message" : "48656c6c6f",
993 "result" : "invalid",
994 "sig" : "3026020101022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
995 "tcId" : 140
996 },
997 {
998 "comment" : "Signatures with special case values for r and s.",
999 "message" : "48656c6c6f",
1000 "result" : "invalid",
1001 "sig" : "3026020101022100ffffffff00000001000000000000000000000001000000000000000000000000",
1002 "tcId" : 141
1003 },
1004 {
1005 "comment" : "Signatures with special case values for r and s.",
1006 "message" : "48656c6c6f",
1007 "result" : "invalid",
1008 "sig" : "3008020101090380fe01",
1009 "tcId" : 142
1010 },
1011 {
1012 "comment" : "Signatures with special case values for r and s.",
1013 "message" : "48656c6c6f",
1014 "result" : "invalid",
1015 "sig" : "30060201f0020100",
1016 "tcId" : 143
1017 },
1018 {
1019 "comment" : "Signatures with special case values for r and s.",
1020 "message" : "48656c6c6f",
1021 "result" : "invalid",
1022 "sig" : "30060201f0020101",
1023 "tcId" : 144
1024 },
1025 {
1026 "comment" : "Signatures with special case values for r and s.",
1027 "message" : "48656c6c6f",
1028 "result" : "invalid",
1029 "sig" : "30060201f00201f0",
1030 "tcId" : 145
1031 },
1032 {
1033 "comment" : "Signatures with special case values for r and s.",
1034 "message" : "48656c6c6f",
1035 "result" : "invalid",
1036 "sig" : "30260201f0022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1037 "tcId" : 146
1038 },
1039 {
1040 "comment" : "Signatures with special case values for r and s.",
1041 "message" : "48656c6c6f",
1042 "result" : "invalid",
1043 "sig" : "30260201f0022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
1044 "tcId" : 147
1045 },
1046 {
1047 "comment" : "Signatures with special case values for r and s.",
1048 "message" : "48656c6c6f",
1049 "result" : "invalid",
1050 "sig" : "30260201f0022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1051 "tcId" : 148
1052 },
1053 {
1054 "comment" : "Signatures with special case values for r and s.",
1055 "message" : "48656c6c6f",
1056 "result" : "invalid",
1057 "sig" : "30260201f0022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
1058 "tcId" : 149
1059 },
1060 {
1061 "comment" : "Signatures with special case values for r and s.",
1062 "message" : "48656c6c6f",
1063 "result" : "invalid",
1064 "sig" : "30260201f0022100ffffffff00000001000000000000000000000001000000000000000000000000",
1065 "tcId" : 150
1066 },
1067 {
1068 "comment" : "Signatures with special case values for r and s.",
1069 "message" : "48656c6c6f",
1070 "result" : "invalid",
1071 "sig" : "30080201f0090380fe01",
1072 "tcId" : 151
1073 },
1074 {
1075 "comment" : "Signatures with special case values for r and s.",
1076 "message" : "48656c6c6f",
1077 "result" : "invalid",
1078 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551020100",
1079 "tcId" : 152
1080 },
1081 {
1082 "comment" : "Signatures with special case values for r and s.",
1083 "message" : "48656c6c6f",
1084 "result" : "invalid",
1085 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551020101",
1086 "tcId" : 153
1087 },
1088 {
1089 "comment" : "Signatures with special case values for r and s.",
1090 "message" : "48656c6c6f",
1091 "result" : "invalid",
1092 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325510201f0",
1093 "tcId" : 154
1094 },
1095 {
1096 "comment" : "Signatures with special case values for r and s.",
1097 "message" : "48656c6c6f",
1098 "result" : "invalid",
1099 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1100 "tcId" : 155
1101 },
1102 {
1103 "comment" : "Signatures with special case values for r and s.",
1104 "message" : "48656c6c6f",
1105 "result" : "invalid",
1106 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
1107 "tcId" : 156
1108 },
1109 {
1110 "comment" : "Signatures with special case values for r and s.",
1111 "message" : "48656c6c6f",
1112 "result" : "invalid",
1113 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1114 "tcId" : 157
1115 },
1116 {
1117 "comment" : "Signatures with special case values for r and s.",
1118 "message" : "48656c6c6f",
1119 "result" : "invalid",
1120 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
1121 "tcId" : 158
1122 },
1123 {
1124 "comment" : "Signatures with special case values for r and s.",
1125 "message" : "48656c6c6f",
1126 "result" : "invalid",
1127 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551022100ffffffff00000001000000000000000000000001000000000000000000000000",
1128 "tcId" : 159
1129 },
1130 {
1131 "comment" : "Signatures with special case values for r and s.",
1132 "message" : "48656c6c6f",
1133 "result" : "invalid",
1134 "sig" : "3028022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551090380fe01",
1135 "tcId" : 160
1136 },
1137 {
1138 "comment" : "Signatures with special case values for r and s.",
1139 "message" : "48656c6c6f",
1140 "result" : "invalid",
1141 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550020100",
1142 "tcId" : 161
1143 },
1144 {
1145 "comment" : "Signatures with special case values for r and s.",
1146 "message" : "48656c6c6f",
1147 "result" : "invalid",
1148 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550020101",
1149 "tcId" : 162
1150 },
1151 {
1152 "comment" : "Signatures with special case values for r and s.",
1153 "message" : "48656c6c6f",
1154 "result" : "invalid",
1155 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325500201f0",
1156 "tcId" : 163
1157 },
1158 {
1159 "comment" : "Signatures with special case values for r and s.",
1160 "message" : "48656c6c6f",
1161 "result" : "invalid",
1162 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1163 "tcId" : 164
1164 },
1165 {
1166 "comment" : "Signatures with special case values for r and s.",
1167 "message" : "48656c6c6f",
1168 "result" : "invalid",
1169 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
1170 "tcId" : 165
1171 },
1172 {
1173 "comment" : "Signatures with special case values for r and s.",
1174 "message" : "48656c6c6f",
1175 "result" : "invalid",
1176 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1177 "tcId" : 166
1178 },
1179 {
1180 "comment" : "Signatures with special case values for r and s.",
1181 "message" : "48656c6c6f",
1182 "result" : "invalid",
1183 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
1184 "tcId" : 167
1185 },
1186 {
1187 "comment" : "Signatures with special case values for r and s.",
1188 "message" : "48656c6c6f",
1189 "result" : "invalid",
1190 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550022100ffffffff00000001000000000000000000000001000000000000000000000000",
1191 "tcId" : 168
1192 },
1193 {
1194 "comment" : "Signatures with special case values for r and s.",
1195 "message" : "48656c6c6f",
1196 "result" : "invalid",
1197 "sig" : "3028022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550090380fe01",
1198 "tcId" : 169
1199 },
1200 {
1201 "comment" : "Signatures with special case values for r and s.",
1202 "message" : "48656c6c6f",
1203 "result" : "invalid",
1204 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552020100",
1205 "tcId" : 170
1206 },
1207 {
1208 "comment" : "Signatures with special case values for r and s.",
1209 "message" : "48656c6c6f",
1210 "result" : "invalid",
1211 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552020101",
1212 "tcId" : 171
1213 },
1214 {
1215 "comment" : "Signatures with special case values for r and s.",
1216 "message" : "48656c6c6f",
1217 "result" : "invalid",
1218 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325520201f0",
1219 "tcId" : 172
1220 },
1221 {
1222 "comment" : "Signatures with special case values for r and s.",
1223 "message" : "48656c6c6f",
1224 "result" : "invalid",
1225 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1226 "tcId" : 173
1227 },
1228 {
1229 "comment" : "Signatures with special case values for r and s.",
1230 "message" : "48656c6c6f",
1231 "result" : "invalid",
1232 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
1233 "tcId" : 174
1234 },
1235 {
1236 "comment" : "Signatures with special case values for r and s.",
1237 "message" : "48656c6c6f",
1238 "result" : "invalid",
1239 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1240 "tcId" : 175
1241 },
1242 {
1243 "comment" : "Signatures with special case values for r and s.",
1244 "message" : "48656c6c6f",
1245 "result" : "invalid",
1246 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
1247 "tcId" : 176
1248 },
1249 {
1250 "comment" : "Signatures with special case values for r and s.",
1251 "message" : "48656c6c6f",
1252 "result" : "invalid",
1253 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552022100ffffffff00000001000000000000000000000001000000000000000000000000",
1254 "tcId" : 177
1255 },
1256 {
1257 "comment" : "Signatures with special case values for r and s.",
1258 "message" : "48656c6c6f",
1259 "result" : "invalid",
1260 "sig" : "3028022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552090380fe01",
1261 "tcId" : 178
1262 },
1263 {
1264 "comment" : "Signatures with special case values for r and s.",
1265 "message" : "48656c6c6f",
1266 "result" : "invalid",
1267 "sig" : "3026022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff020100",
1268 "tcId" : 179
1269 },
1270 {
1271 "comment" : "Signatures with special case values for r and s.",
1272 "message" : "48656c6c6f",
1273 "result" : "invalid",
1274 "sig" : "3026022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff020101",
1275 "tcId" : 180
1276 },
1277 {
1278 "comment" : "Signatures with special case values for r and s.",
1279 "message" : "48656c6c6f",
1280 "result" : "invalid",
1281 "sig" : "3026022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff0201f0",
1282 "tcId" : 181
1283 },
1284 {
1285 "comment" : "Signatures with special case values for r and s.",
1286 "message" : "48656c6c6f",
1287 "result" : "invalid",
1288 "sig" : "3046022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1289 "tcId" : 182
1290 },
1291 {
1292 "comment" : "Signatures with special case values for r and s.",
1293 "message" : "48656c6c6f",
1294 "result" : "invalid",
1295 "sig" : "3046022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
1296 "tcId" : 183
1297 },
1298 {
1299 "comment" : "Signatures with special case values for r and s.",
1300 "message" : "48656c6c6f",
1301 "result" : "invalid",
1302 "sig" : "3046022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1303 "tcId" : 184
1304 },
1305 {
1306 "comment" : "Signatures with special case values for r and s.",
1307 "message" : "48656c6c6f",
1308 "result" : "invalid",
1309 "sig" : "3046022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
1310 "tcId" : 185
1311 },
1312 {
1313 "comment" : "Signatures with special case values for r and s.",
1314 "message" : "48656c6c6f",
1315 "result" : "invalid",
1316 "sig" : "3046022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff022100ffffffff00000001000000000000000000000001000000000000000000000000",
1317 "tcId" : 186
1318 },
1319 {
1320 "comment" : "Signatures with special case values for r and s.",
1321 "message" : "48656c6c6f",
1322 "result" : "invalid",
1323 "sig" : "3028022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff090380fe01",
1324 "tcId" : 187
1325 },
1326 {
1327 "comment" : "Signatures with special case values for r and s.",
1328 "message" : "48656c6c6f",
1329 "result" : "invalid",
1330 "sig" : "3026022100ffffffff00000001000000000000000000000001000000000000000000000000020100",
1331 "tcId" : 188
1332 },
1333 {
1334 "comment" : "Signatures with special case values for r and s.",
1335 "message" : "48656c6c6f",
1336 "result" : "invalid",
1337 "sig" : "3026022100ffffffff00000001000000000000000000000001000000000000000000000000020101",
1338 "tcId" : 189
1339 },
1340 {
1341 "comment" : "Signatures with special case values for r and s.",
1342 "message" : "48656c6c6f",
1343 "result" : "invalid",
1344 "sig" : "3026022100ffffffff000000010000000000000000000000010000000000000000000000000201f0",
1345 "tcId" : 190
1346 },
1347 {
1348 "comment" : "Signatures with special case values for r and s.",
1349 "message" : "48656c6c6f",
1350 "result" : "invalid",
1351 "sig" : "3046022100ffffffff00000001000000000000000000000001000000000000000000000000022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1352 "tcId" : 191
1353 },
1354 {
1355 "comment" : "Signatures with special case values for r and s.",
1356 "message" : "48656c6c6f",
1357 "result" : "invalid",
1358 "sig" : "3046022100ffffffff00000001000000000000000000000001000000000000000000000000022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
1359 "tcId" : 192
1360 },
1361 {
1362 "comment" : "Signatures with special case values for r and s.",
1363 "message" : "48656c6c6f",
1364 "result" : "invalid",
1365 "sig" : "3046022100ffffffff00000001000000000000000000000001000000000000000000000000022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1366 "tcId" : 193
1367 },
1368 {
1369 "comment" : "Signatures with special case values for r and s.",
1370 "message" : "48656c6c6f",
1371 "result" : "invalid",
1372 "sig" : "3046022100ffffffff00000001000000000000000000000001000000000000000000000000022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
1373 "tcId" : 194
1374 },
1375 {
1376 "comment" : "Signatures with special case values for r and s.",
1377 "message" : "48656c6c6f",
1378 "result" : "invalid",
1379 "sig" : "3046022100ffffffff00000001000000000000000000000001000000000000000000000000022100ffffffff00000001000000000000000000000001000000000000000000000000",
1380 "tcId" : 195
1381 },
1382 {
1383 "comment" : "Signatures with special case values for r and s.",
1384 "message" : "48656c6c6f",
1385 "result" : "invalid",
1386 "sig" : "3028022100ffffffff00000001000000000000000000000001000000000000000000000000090380fe01",
1387 "tcId" : 196
1388 }
1389 ]
1390 },
1391 {
1392 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926",
1393 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1wXRb4CYfi2bGmlX0pziL+v30Q+l\nFRUxgkFcg2G6rKSx/BBe5c6A1RTsEji+riA3pvg2JVk2INRggZ6GghYJJg==\n-----END PUBLIC KEY-----",
1394 "sha" : "SHA-256",
1395 "type" : "ECDSAVer",
1396 "key" : {
1397 "curve" : "secp256r1",
1398 "type" : "ECPublicKey",
1399 "wx" : "0d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4",
1400 "wy" : "0b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926"
1401 },
1402 "tests" : [
1403 {
1404 "comment" : "k*G has a large x-coordinate",
1405 "message" : "54657374",
1406 "result" : "valid",
1407 "sig" : "303502104319055358e8617b0c46353d039cdaab022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e",
1408 "tcId" : 197
1409 }
1410 ]
1411 },
1412 {
1413 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926",
1414 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1wXRb4CYfi2bGmlX0pziL+v30Q+l\nFRUxgkFcg2G6rKSx/BBe5c6A1RTsEji+riA3pvg2JVk2INRggZ6GghYJJg==\n-----END PUBLIC KEY-----",
1415 "sha" : "SHA-256",
1416 "type" : "ECDSAVer",
1417 "key" : {
1418 "curve" : "secp256r1",
1419 "type" : "ECPublicKey",
1420 "wx" : "0d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4",
1421 "wy" : "0b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926"
1422 },
1423 "tests" : [
1424 {
1425 "comment" : "r too large",
1426 "message" : "54657374",
1427 "result" : "invalid",
1428 "sig" : "3046022100ffffffff00000001000000000000000000000000fffffffffffffffffffffffc022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e",
1429 "tcId" : 198
1430 }
1431 ]
1432 },
1433 {
1434 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200043cd8d2f81d6953b0844c09d7b560d527cd2ef67056893eadafa52c8501387d59ee41fdb4d10402ce7a0c5e3b747adfa3a490b62a6b7719068903485c0bb6dc2d",
1435 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPNjS+B1pU7CETAnXtWDVJ80u9nBW\niT6tr6UshQE4fVnuQf200QQCznoMXjt0et+jpJC2Kmt3GQaJA0hcC7bcLQ==\n-----END PUBLIC KEY-----",
1436 "sha" : "SHA-256",
1437 "type" : "ECDSAVer",
1438 "key" : {
1439 "curve" : "secp256r1",
1440 "type" : "ECPublicKey",
1441 "wx" : "3cd8d2f81d6953b0844c09d7b560d527cd2ef67056893eadafa52c8501387d59",
1442 "wy" : "0ee41fdb4d10402ce7a0c5e3b747adfa3a490b62a6b7719068903485c0bb6dc2d"
1443 },
1444 "tests" : [
1445 {
1446 "comment" : "r,s are large",
1447 "message" : "54657374",
1448 "result" : "valid",
1449 "sig" : "3046022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e",
1450 "tcId" : 199
1451 }
1452 ]
1453 },
1454 {
1455 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e53e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0",
1456 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESgPvn5LrJoyvpgEHJImlY4D6DcQx\ncddxKBOzoZoeteU+IT4opgjOmi9KF/2DDGZUAYp5s+AmPZGoupBiLfby8A==\n-----END PUBLIC KEY-----",
1457 "sha" : "SHA-256",
1458 "type" : "ECDSAVer",
1459 "key" : {
1460 "curve" : "secp256r1",
1461 "type" : "ECPublicKey",
1462 "wx" : "4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e5",
1463 "wy" : "3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0"
1464 },
1465 "tests" : [
1466 {
1467 "comment" : "small r and s",
1468 "message" : "54657374",
1469 "result" : "valid",
1470 "sig" : "3006020105020101",
1471 "tcId" : 200
1472 }
1473 ]
1474 },
1475 {
1476 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e53e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0",
1477 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESgPvn5LrJoyvpgEHJImlY4D6DcQx\ncddxKBOzoZoeteU+IT4opgjOmi9KF/2DDGZUAYp5s+AmPZGoupBiLfby8A==\n-----END PUBLIC KEY-----",
1478 "sha" : "SHA-256",
1479 "type" : "ECDSAVer",
1480 "key" : {
1481 "curve" : "secp256r1",
1482 "type" : "ECPublicKey",
1483 "wx" : "4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e5",
1484 "wy" : "3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0"
1485 },
1486 "tests" : [
1487 {
1488 "comment" : "r is larger than n",
1489 "message" : "54657374",
1490 "result" : "invalid",
1491 "sig" : "3026022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632556020101",
1492 "tcId" : 201
1493 }
1494 ]
1495 },
1496 {
1497 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e53e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0",
1498 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESgPvn5LrJoyvpgEHJImlY4D6DcQx\ncddxKBOzoZoeteU+IT4opgjOmi9KF/2DDGZUAYp5s+AmPZGoupBiLfby8A==\n-----END PUBLIC KEY-----",
1499 "sha" : "SHA-256",
1500 "type" : "ECDSAVer",
1501 "key" : {
1502 "curve" : "secp256r1",
1503 "type" : "ECPublicKey",
1504 "wx" : "4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e5",
1505 "wy" : "3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0"
1506 },
1507 "tests" : [
1508 {
1509 "comment" : "s is larger than n",
1510 "message" : "54657374",
1511 "result" : "invalid",
1512 "sig" : "3026020105022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
1513 "tcId" : 202
1514 }
1515 ]
1516 },
1517 {
1518 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200040203736fcb198b15d8d7a0c80f66dddd15259240aa78d08aae67c467de04503434383438d5041ea9a387ee8e4d4e84b4471b160c6bcf2568b072f8f20e87a996",
1519 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAgNzb8sZixXY16DID2bd3RUlkkCq\neNCKrmfEZ94EUDQ0ODQ41QQeqaOH7o5NToS0RxsWDGvPJWiwcvjyDoeplg==\n-----END PUBLIC KEY-----",
1520 "sha" : "SHA-256",
1521 "type" : "ECDSAVer",
1522 "key" : {
1523 "curve" : "secp256r1",
1524 "type" : "ECPublicKey",
1525 "wx" : "203736fcb198b15d8d7a0c80f66dddd15259240aa78d08aae67c467de045034",
1526 "wy" : "34383438d5041ea9a387ee8e4d4e84b4471b160c6bcf2568b072f8f20e87a996"
1527 },
1528 "tests" : [
1529 {
1530 "comment" : "point at infinity during verify",
1531 "message" : "54657374",
1532 "result" : "invalid",
1533 "sig" : "304402207fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3192a80220555555550000000055555555555555553ef7a8e48d07df81a693439654210c70",
1534 "tcId" : 203
1535 }
1536 ]
1537 },
1538 {
1539 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004a17f5b75a35ed64623ca5cbf1f91951292db0c23f0c2ea24c3d0cad0988cabc083a7a618625c228940730b4fa3ee64faecbb2fc20fdde7c58b3a3f6300424dc6",
1540 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoX9bdaNe1kYjyly/H5GVEpLbDCPw\nwuokw9DK0JiMq8CDp6YYYlwiiUBzC0+j7mT67Lsvwg/d58WLOj9jAEJNxg==\n-----END PUBLIC KEY-----",
1541 "sha" : "SHA-256",
1542 "type" : "ECDSAVer",
1543 "key" : {
1544 "curve" : "secp256r1",
1545 "type" : "ECPublicKey",
1546 "wx" : "0a17f5b75a35ed64623ca5cbf1f91951292db0c23f0c2ea24c3d0cad0988cabc0",
1547 "wy" : "083a7a618625c228940730b4fa3ee64faecbb2fc20fdde7c58b3a3f6300424dc6"
1548 },
1549 "tests" : [
1550 {
1551 "comment" : "u1 == 1",
1552 "message" : "54657374",
1553 "result" : "valid",
1554 "sig" : "30440220555555550000000055555555555555553ef7a8e48d07df81a693439654210c700220532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1555 "tcId" : 204
1556 }
1557 ]
1558 },
1559 {
1560 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d0301070342000404ba0cba291a37db13f33bf90dab628c04ec8393a0200419e9eaa1ebcc9fb5c31f3a0a0e6823a49b625ad57b12a32d4047970fc3428f0f0049ecf4265dc12f62",
1561 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBLoMuikaN9sT8zv5DatijATsg5Og\nIAQZ6eqh68yftcMfOgoOaCOkm2Ja1XsSoy1AR5cPw0KPDwBJ7PQmXcEvYg==\n-----END PUBLIC KEY-----",
1562 "sha" : "SHA-256",
1563 "type" : "ECDSAVer",
1564 "key" : {
1565 "curve" : "secp256r1",
1566 "type" : "ECPublicKey",
1567 "wx" : "4ba0cba291a37db13f33bf90dab628c04ec8393a0200419e9eaa1ebcc9fb5c3",
1568 "wy" : "1f3a0a0e6823a49b625ad57b12a32d4047970fc3428f0f0049ecf4265dc12f62"
1569 },
1570 "tests" : [
1571 {
1572 "comment" : "u1 == n - 1",
1573 "message" : "54657374",
1574 "result" : "valid",
1575 "sig" : "30450220555555550000000055555555555555553ef7a8e48d07df81a693439654210c70022100acd155416a8b77f34089464733ff7cd39c400e9c69af7beb9eac5054ed2ec72c",
1576 "tcId" : 205
1577 }
1578 ]
1579 },
1580 {
1581 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004692b6c828e0feed63d8aeaa2b7322f9ccbe8723a1ed39f229f204a434b8900efa1f6f6abcb38ea3b8fde38b98c7c271f274af56a8c5628dc3329069ae4dd5716",
1582 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaStsgo4P7tY9iuqitzIvnMvocjoe\n058inyBKQ0uJAO+h9varyzjqO4/eOLmMfCcfJ0r1aoxWKNwzKQaa5N1XFg==\n-----END PUBLIC KEY-----",
1583 "sha" : "SHA-256",
1584 "type" : "ECDSAVer",
1585 "key" : {
1586 "curve" : "secp256r1",
1587 "type" : "ECPublicKey",
1588 "wx" : "692b6c828e0feed63d8aeaa2b7322f9ccbe8723a1ed39f229f204a434b8900ef",
1589 "wy" : "0a1f6f6abcb38ea3b8fde38b98c7c271f274af56a8c5628dc3329069ae4dd5716"
1590 },
1591 "tests" : [
1592 {
1593 "comment" : "u2 == 1",
1594 "message" : "54657374",
1595 "result" : "valid",
1596 "sig" : "30440220555555550000000055555555555555553ef7a8e48d07df81a693439654210c700220555555550000000055555555555555553ef7a8e48d07df81a693439654210c70",
1597 "tcId" : 206
1598 }
1599 ]
1600 },
1601 {
1602 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d0301070342000400cefd9162d13e64cb93687a9cd8f9755ebb5a3ef7632f800f84871874ccef09543ecbeaf7e8044ef721be2fb5f549e4b8480d2587404ebf7dbbef2c54bc0cb1",
1603 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAM79kWLRPmTLk2h6nNj5dV67Wj73\nYy+AD4SHGHTM7wlUPsvq9+gETvchvi+19UnkuEgNJYdATr99u+8sVLwMsQ==\n-----END PUBLIC KEY-----",
1604 "sha" : "SHA-256",
1605 "type" : "ECDSAVer",
1606 "key" : {
1607 "curve" : "secp256r1",
1608 "type" : "ECPublicKey",
1609 "wx" : "0cefd9162d13e64cb93687a9cd8f9755ebb5a3ef7632f800f84871874ccef09",
1610 "wy" : "543ecbeaf7e8044ef721be2fb5f549e4b8480d2587404ebf7dbbef2c54bc0cb1"
1611 },
1612 "tests" : [
1613 {
1614 "comment" : "u2 == n - 1",
1615 "message" : "54657374",
1616 "result" : "valid",
1617 "sig" : "30450220555555550000000055555555555555553ef7a8e48d07df81a693439654210c70022100aaaaaaaa00000000aaaaaaaaaaaaaaaa7def51c91a0fbf034d26872ca84218e1",
1618 "tcId" : 207
1619 }
1620 ]
1621 },
1622 {
1623 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200040158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237e2a964fc00d377a8592b8b61aafa7a4aaa7c7b9fd2b41d6e0e17bd1ba5677edcd",
1624 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAVgTd1W5AfeXqQ1MqIh+Ajyy72Oy\nuiwNRV7a70LPI34qlk/ADTd6hZK4thqvp6Sqp8e5/StB1uDhe9G6VnftzQ==\n-----END PUBLIC KEY-----",
1625 "sha" : "SHA-256",
1626 "type" : "ECDSAVer",
1627 "key" : {
1628 "curve" : "secp256r1",
1629 "type" : "ECPublicKey",
1630 "wx" : "158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237e",
1631 "wy" : "2a964fc00d377a8592b8b61aafa7a4aaa7c7b9fd2b41d6e0e17bd1ba5677edcd"
1632 },
1633 "tests" : [
1634 {
1635 "comment" : "weak key",
1636 "message" : "54657374",
1637 "result" : "valid",
1638 "sig" : "304502206f2347cab7dd76858fe0555ac3bc99048c4aacafdfb6bcbe05ea6c42c4934569022100f21d907e3890916dc4fa1f4703c1e50d3f54ddf7383e44023a41de562aa18ed8",
1639 "tcId" : 208
1640 }
1641 ]
1642 },
1643 {
1644 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200040158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237ed569b03ef2c8857b6d4749e550585b5558384603d4be291f1e842e45a9881232",
1645 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAVgTd1W5AfeXqQ1MqIh+Ajyy72Oy\nuiwNRV7a70LPI37VabA+8siFe21HSeVQWFtVWDhGA9S+KR8ehC5FqYgSMg==\n-----END PUBLIC KEY-----",
1646 "sha" : "SHA-256",
1647 "type" : "ECDSAVer",
1648 "key" : {
1649 "curve" : "secp256r1",
1650 "type" : "ECPublicKey",
1651 "wx" : "158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237e",
1652 "wy" : "0d569b03ef2c8857b6d4749e550585b5558384603d4be291f1e842e45a9881232"
1653 },
1654 "tests" : [
1655 {
1656 "comment" : "duplication bug",
1657 "message" : "54657374",
1658 "result" : "invalid",
1659 "sig" : "304502206f2347cab7dd76858fe0555ac3bc99048c4aacafdfb6bcbe05ea6c42c4934569022100f21d907e3890916dc4fa1f4703c1e50d3f54ddf7383e44023a41de562aa18ed8",
1660 "tcId" : 209
1661 }
1662 ]
1663 },
1664 {
1665 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200043f7137e42b6c5d98c6bb61bce91426f8e2c2f33fdc893a0d32be1ba0042c21c59c0df75782993e9a31ef773dc73eeb038cd6594f43ecca77fe586105efa19833",
1666 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEP3E35CtsXZjGu2G86RQm+OLC8z/c\niToNMr4boAQsIcWcDfdXgpk+mjHvdz3HPusDjNZZT0Psynf+WGEF76GYMw==\n-----END PUBLIC KEY-----",
1667 "sha" : "SHA-256",
1668 "type" : "ECDSAVer",
1669 "key" : {
1670 "curve" : "secp256r1",
1671 "type" : "ECPublicKey",
1672 "wx" : "3f7137e42b6c5d98c6bb61bce91426f8e2c2f33fdc893a0d32be1ba0042c21c5",
1673 "wy" : "09c0df75782993e9a31ef773dc73eeb038cd6594f43ecca77fe586105efa19833"
1674 },
1675 "tests" : [
1676 {
1677 "comment" : "random signature",
1678 "message" : "00000000000000000000000000000000",
1679 "result" : "valid",
1680 "sig" : "304502203c3fe1264b2995df966337a6ede98fc5c71893e352696703cf863c7e63ac0627022100bcb0a9a02e57ce80f72d91eee92a99ba5b16a3411f9dd541bfdf44a7f2ad54cc",
1681 "tcId" : 210
1682 },
1683 {
1684 "comment" : "random signature",
1685 "message" : "00000000000000000000000000000000",
1686 "result" : "valid",
1687 "sig" : "3045022100a3f9d3ea2c35bb1899508129e0edaf40292ec3b895dc0c6396d9b162b8d88134022073a92358fc9921bf80b3f0f6244d73b141f007a632e8c3cd1f988752e6492c79",
1688 "tcId" : 211
1689 },
1690 {
1691 "comment" : "random signature",
1692 "message" : "00000000000000000000000000000000",
1693 "result" : "valid",
1694 "sig" : "304402203c137c3cf8feb9eb4f7f5984e954918dd408b4df79534150919694d07877067f02202ca4c9d4440262934ca5c8b2cc4bfab3348462b5ab3a308d097dee9b8077a0c0",
1695 "tcId" : 212
1696 },
1697 {
1698 "comment" : "random signature",
1699 "message" : "00000000000000000000000000000000",
1700 "result" : "valid",
1701 "sig" : "3045022005916c5b5d012f85a11fb8adccee8403674dd259e9b158594a3979346d38620c022100945e551009e002951ad9551ed507feca41103c3bf23a156eaefd0c844f3567be",
1702 "tcId" : 213
1703 },
1704 {
1705 "comment" : "random signature",
1706 "message" : "00000000000000000000000000000000",
1707 "result" : "valid",
1708 "sig" : "3044022007c1801de1ec0c089fcbc6301deaa0c161ae59c7e367c6f0376d3fcfcbc6a3e5022006d8ff0b593ed08b35e781551e8ca8222a8f4524e07dc055ec9b78567fe7cd81",
1709 "tcId" : 214
1710 },
1711 {
1712 "comment" : "random signature",
1713 "message" : "00000000000000000000000000000000",
1714 "result" : "valid",
1715 "sig" : "30450220204ff2e911d442d3e46979b2177894bd07cf25485b990f6f162335f916e9d2d00221009825c6539cc3a4d1be8ef523fe28f99f5445377f70471bffbd88362909ee4fde",
1716 "tcId" : 215
1717 },
1718 {
1719 "comment" : "random signature",
1720 "message" : "00000000000000000000000000000000",
1721 "result" : "valid",
1722 "sig" : "304502206a2e4b1eda9b5e5426e0fe6f2fe3180793ec1ae414b4c1164c1cb85a85af49b00221008a40315be22f196eb6d4dca64adab267778eaef5884a074573cb4f2bed185519",
1723 "tcId" : 216
1724 },
1725 {
1726 "comment" : "random signature",
1727 "message" : "00000000000000000000000000000000",
1728 "result" : "valid",
1729 "sig" : "3045022100aaedd77d46a678ca6200a38fcb35550d6c523b6e929efe621673307c295c7de602201dbf3d1edcebd7f7caa604ec3d967a213c57ca2f016ed1c281a2bbce2978c59a",
1730 "tcId" : 217
1731 },
1732 {
1733 "comment" : "random signature",
1734 "message" : "00000000000000000000000000000000",
1735 "result" : "valid",
1736 "sig" : "304402204491da1b704c0410cf6d3ed7c40e770f35d54dd79eb7646537b5e48654b9a28e02204118b53ab6da09a9fcc23af86d8fb8db903a596883167c29042bc13618a3a1b1",
1737 "tcId" : 218
1738 },
1739 {
1740 "comment" : "random signature",
1741 "message" : "00000000000000000000000000000000",
1742 "result" : "valid",
1743 "sig" : "304502205f9da7e8a353a0b324b512a6d7bc9daa655041c09e1aebd281f85b6445ba7ca3022100fb1386685b75f05d836a9a7c2aa698b543fac3cb3a54a256efa9f6f1efaaaedb",
1744 "tcId" : 219
1745 }
1746 ]
1747 },
1748 {
1749 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004013d6e38dfa75ddb2e7822a68192ba40b947bdbbb666d40c63d03b757eb512ed826bfe58bb2706af6ed7b771c98d86133a8d6f5ac6ec22c589cef90e43480f2b2bee0061d76af46853de2a9e2b444cba5adbeb38ad82541a483350c313ff259b93e0d64085566c6c2bb6ff0fbdbd46e69c48b37ec3905d06234bbbd8ca4198d564c8e465",
1750 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBPW4436dd2y54IqaBkrpAuUe9u7Zm\n1Axj0Dt1frUS7YJr/li7Jwavbte3ccmNhhM6jW9axuwixYnO+Q5DSA8rK+4AYddq\n9GhT3iqeK0RMulrb6zitglQaSDNQwxP/JZuT4NZAhVZsbCu2/w+9vUbmnEizfsOQ\nXQYjS7vYykGY1WTI5GU=\n-----END PUBLIC KEY-----",
1751 "sha" : "SHA-512",
1752 "type" : "ECDSAVer",
1753 "key" : {
1754 "curve" : "secp521r1",
1755 "type" : "ECPublicKey",
1756 "wx" : "13d6e38dfa75ddb2e7822a68192ba40b947bdbbb666d40c63d03b757eb512ed826bfe58bb2706af6ed7b771c98d86133a8d6f5ac6ec22c589cef90e43480f2b2bee",
1757 "wy" : "61d76af46853de2a9e2b444cba5adbeb38ad82541a483350c313ff259b93e0d64085566c6c2bb6ff0fbdbd46e69c48b37ec3905d06234bbbd8ca4198d564c8e465"
1758 },
1759 "tests" : [
1760 {
1761 "comment" : "random signature",
1762 "message" : "0000000000000000000000000000000000000000",
1763 "result" : "valid",
1764 "sig" : "30818702411b01186e46e19d71dc2062453be3b4b94c27556069ac5211f6cdb99d4b4d89405c2da8663a32dcec5515cb7357564b32a6ce33f379f3df35b4e2a5db855ad1d7be024200efea92828d6cf125504a247141adc9ecf35fde30c7e0487eff4fbe2f3949b7788d034968a198dcfb4ad1bb6b873ef9f5c8683757aa716f8c00dbc1ccc534c2fece",
1765 "tcId" : 220
1766 },
1767 {
1768 "comment" : "random signature",
1769 "message" : "0000000000000000000000000000000000000000",
1770 "result" : "valid",
1771 "sig" : "3081880242016f39b566c7e037f0c5dfe9f453fb1dc488fa610c341408333326cb632d16dda66af7286e4237de3310cffd6863398257fe2c9e1deb30d61d098c7d5c255b4b45d9024201a49858926129db492d53130bedd4c9be18ac9f7bfd7d62eaf99fe12f58e81d2786b12da9c13b3f025f94f5398e784e909ff363125b98dc35ba850400ef8e4efa2d",
1772 "tcId" : 221
1773 },
1774 {
1775 "comment" : "random signature",
1776 "message" : "0000000000000000000000000000000000000000",
1777 "result" : "valid",
1778 "sig" : "308187024200fcec8495af424d3d6468cf79a0b2d6a2ff7d3c249e78ea1f157e1558066e5118558a830ba105dc8a29b8375642593f0e5c2d23b62a39954ad7a4be3e82a69d817b02410960873c13cd81af95e3980db5fdc537bebfc9ebae4d94d05a276d3bdd86b65ec60175471ae661e16c225c6e17635664a20e8160f7365e4034ca625642de17d479",
1779 "tcId" : 222
1780 },
1781 {
1782 "comment" : "random signature",
1783 "message" : "0000000000000000000000000000000000000000",
1784 "result" : "valid",
1785 "sig" : "308187024171ad3beb8abd01e53fed56ea34f1bd9ae252d290e5c5ae364ae60ce67b0f42186254db2783333a97eeabf2a84b6bcb4683107e03d97bb3e67d400cc8c314a20939024200dc4afe3dca6572fd4a56ba150d3a5266d7828f2c764c416fa2b2e64b1c694040d1fe8061e742c9212ec4330a0d1e312ad65ec4623821d3327da583b78e6a2539ed",
1786 "tcId" : 223
1787 },
1788 {
1789 "comment" : "random signature",
1790 "message" : "0000000000000000000000000000000000000000",
1791 "result" : "valid",
1792 "sig" : "308188024200e53d62a974603f05997fce2df0cb2df83a34cc34b56d71db12cf980db9834e1a322a17fad9ba8d7ea58e2d31de4688527fc5f18424470a51383dbcb177c97c2f6f024201668d2e11b296637f7886291eb339ecfbd630be841b622f81df118cdd16ecebfd0999dca4f82b7fc4f17be81c64d6903ca2a9d854702b6783b1bb47455fc9665032",
1793 "tcId" : 224
1794 },
1795 {
1796 "comment" : "random signature",
1797 "message" : "0000000000000000000000000000000000000000",
1798 "result" : "valid",
1799 "sig" : "308186024107250d6a30bc7c47a63f2aebb3eb0b7b9be3bf833f761bf6a56cd1300224e5753c85987f9e61401c0434ab1566b6a3e5519575415c24417c69c39fc43dab11d3cb024157f319ebf47bbfe2b7d38a3da246b135f31baa455c72c5869016d7fcabdaec581efc5b756d0f451ad079f697961225e55495fbac374bb246fd499c1ba7b9bbae57",
1800 "tcId" : 225
1801 },
1802 {
1803 "comment" : "random signature",
1804 "message" : "0000000000000000000000000000000000000000",
1805 "result" : "valid",
1806 "sig" : "308188024200d2b0e8938f97fad395fa00d91888f9ba29d4df80626cc278ad233c9a9fdc5fd1762cb6a53bc34d1f6f0b1b42dd0ac5bde7c3f95becf6fe39f356a47ffa7cc2343a024201cb90ceb1c46d9d0f584d0e8b58b21a5e9d7b101dc253a1109fe99715f32223b4e02ac3a880e8eeb7d4a92a7d10d33543fad8c78cfb0700bf794f0497f4c8276c3c",
1807 "tcId" : 226
1808 },
1809 {
1810 "comment" : "random signature",
1811 "message" : "0000000000000000000000000000000000000000",
1812 "result" : "valid",
1813 "sig" : "3081880242018a4cffe3fbacdaffe208bbd0c682ffdfc7d77a41d05e71f8e5bfe3685279bc62dd35e3ac1c6bec556bfe3ba0b12c6ef6124dcf05bc61d66856c00740bd271856c8024200a6105606f6bdf923a8dd1a70802a98d42b83293dbd8e78799d9093e22819edc20754e0da61f05c0650069a2f766c0e2caea947d436c9a4cf1d7c4881315fa840b6",
1814 "tcId" : 227
1815 },
1816 {
1817 "comment" : "random signature",
1818 "message" : "0000000000000000000000000000000000000000",
1819 "result" : "valid",
1820 "sig" : "3081880242010bc1d5bcda1e17bb6abffe483005885455d6042eb89dc346765017a270524ad03d8bce116860c79f9a33085b6d9a9ec0bd03944bd117cc24a46e4cfd58a75afa18024201db04999a96b4caa3725d1fd178e0471e05ea8800fce35e1cf52d1c8006083898a28cf8b106eb58588a0aa642bb91581aa940f3e02b9fdcb064cf29cf012b449cb4",
1821 "tcId" : 228
1822 },
1823 {
1824 "comment" : "random signature",
1825 "message" : "0000000000000000000000000000000000000000",
1826 "result" : "valid",
1827 "sig" : "3081880242017381d2a07c84ebe2fb4356f07c27a2d110d6d1ef7c0a23dfb3a038dbbc53d457d3207039bdfb46bacae9d9ed821d46ce328d3d2acdf9641331b28713998d0398dd024200b6b943a7300d396d07a76c29e80a88c1ff1a6def766fb72022db7bb006e311e6cfbc4452390962461e767a97383d2f908122645e82710dd7fbbeff947d2e488bad",
1828 "tcId" : 229
1829 }
1830 ]
1831 },
1832 {
1833 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004e10ba0fabf162af055b859b7d939435cce257ffa274349456403292bb8cb60e9fa1a0a6408df5e4e3675f47621c8f29cda59832a7acedcd3315f6a8ea848afc8",
1834 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4Qug+r8WKvBVuFm32TlDXM4lf/on\nQ0lFZAMpK7jLYOn6GgpkCN9eTjZ19HYhyPKc2lmDKnrO3NMxX2qOqEivyA==\n-----END PUBLIC KEY-----",
1835 "sha" : "SHA-512",
1836 "type" : "ECDSAVer",
1837 "key" : {
1838 "curve" : "secp256r1",
1839 "type" : "ECPublicKey",
1840 "wx" : "0e10ba0fabf162af055b859b7d939435cce257ffa274349456403292bb8cb60e9",
1841 "wy" : "0fa1a0a6408df5e4e3675f47621c8f29cda59832a7acedcd3315f6a8ea848afc8"
1842 },
1843 "tests" : [
1844 {
1845 "comment" : "random signature",
1846 "message" : "48656c6c6f",
1847 "result" : "valid",
1848 "sig" : "3045022100f5a4fa630913d5ad82d46e31c305e6b0933b4d9aaaf52997cf86527e36fb784c02206534b74e9d19ae8756afdde2876ad90195863f7c04ee61997eab183d175cf770",
1849 "tcId" : 230
1850 },
1851 {
1852 "comment" : "random signature",
1853 "message" : "48656c6c6f",
1854 "result" : "valid",
1855 "sig" : "304502204ccf6585c28ed8ec75d4023f2f8827c3e87c30fa884d992f53b3515ea6060d6b022100b80de22c729068f2191aa7bb638cb26b0018914981b4ab20a09d48333147b9a4",
1856 "tcId" : 231
1857 },
1858 {
1859 "comment" : "random signature",
1860 "message" : "48656c6c6f",
1861 "result" : "valid",
1862 "sig" : "30460221009f14dfcd5b7963d2f6d3ea0925bfcbdbf3b6a9500d080efbb787f6b792886312022100eae1881b232e64f10dd41b0b94c8c4e662ff3be7d25f1137ede60737664a2c7b",
1863 "tcId" : 232
1864 },
1865 {
1866 "comment" : "random signature",
1867 "message" : "48656c6c6f",
1868 "result" : "valid",
1869 "sig" : "3046022100e43b319bd4d94cd6beeb23caf950dbb448d713de4830ac4f749a30149932cdfb0221008118d54087fae841c61eca28622f95a315f8d9f505ba30fea43c17a7b48e6f9a",
1870 "tcId" : 233
1871 },
1872 {
1873 "comment" : "random signature",
1874 "message" : "48656c6c6f",
1875 "result" : "valid",
1876 "sig" : "3045022100d66f8bfe727d5697feda9fd2a7be014454329f6a72414b69a181a7a7bc6614d402203e7aa1f19cb90fa30cebd30ce5c3022748f050a418d1d42550a76f4eb497b0e7",
1877 "tcId" : 234
1878 },
1879 {
1880 "comment" : "random signature",
1881 "message" : "48656c6c6f",
1882 "result" : "valid",
1883 "sig" : "3046022100db555ffefc339c394d1a8059390a78aa9eba72dc008421f581f78ed1b29c3e910221009082dba3909cfc596ade6108a199d66fc1f726016eae2871c8e343bc14639bb3",
1884 "tcId" : 235
1885 },
1886 {
1887 "comment" : "random signature",
1888 "message" : "48656c6c6f",
1889 "result" : "valid",
1890 "sig" : "30440220190dd08a839b27641f1145fc8e04e8d71a55f2be835d360bd1c5f5d357c749490220474915b4bc6d81437eaff2f438e05bedcfd10f4222984782f3202ee32b55253d",
1891 "tcId" : 236
1892 },
1893 {
1894 "comment" : "random signature",
1895 "message" : "48656c6c6f",
1896 "result" : "valid",
1897 "sig" : "304502200159de0f5c777d001cf22e46cccd10dc01a124f12bc707aaaf305d3e05f0fc1a022100c2314c660d0107473edaf36e718248971522c20adea9e7b1f01fe174510ab00d",
1898 "tcId" : 237
1899 },
1900 {
1901 "comment" : "random signature",
1902 "message" : "48656c6c6f",
1903 "result" : "valid",
1904 "sig" : "3045022100ed5137b13ce59346a00a2380e3ff1a874f52172ecd601652dd12e38ce638bb410220776161b448299c2cbcd9856dcd2aeea99423d817895ce9c5d3071c81bf7b0218",
1905 "tcId" : 238
1906 },
1907 {
1908 "comment" : "random signature",
1909 "message" : "48656c6c6f",
1910 "result" : "valid",
1911 "sig" : "304402206c5fa55a3cc7d21fcdbbd353acaff2c33bcce0a7768277dfea9999c49b80e78e022029316ba855bcfdfed36032e648413beaea51675286ed5fc7c67a623ec6ab550b",
1912 "tcId" : 239
1913 }
1914 ]
1915 },
1916 {
1917 "keyDer" : "304e301006072a8648ce3d020106052b81040021033a0004043d002e8a7578988a8013868221598c76b22591f95b6328a07f60ff1bb55957b1a83fce6aeeb38f2c1489d170e51fd3ba396e4dd4997314",
1918 "keyPem" : "-----BEGIN PUBLIC KEY-----\nME4wEAYHKoZIzj0CAQYFK4EEACEDOgAEBD0ALop1eJiKgBOGgiFZjHayJZH5W2Mo\noH9g/xu1WVexqD/Oau6zjywUidFw5R/TujluTdSZcxQ=\n-----END PUBLIC KEY-----",
1919 "sha" : "SHA-256",
1920 "type" : "ECDSAVer",
1921 "key" : {
1922 "curve" : "secp224r1",
1923 "type" : "ECPublicKey",
1924 "wx" : "43d002e8a7578988a8013868221598c76b22591f95b6328a07f60ff",
1925 "wy" : "1bb55957b1a83fce6aeeb38f2c1489d170e51fd3ba396e4dd4997314"
1926 },
1927 "tests" : [
1928 {
1929 "comment" : "random signature",
1930 "message" : "48656c6c6f",
1931 "result" : "valid",
1932 "sig" : "303c021c31788aeb1f7e5a8ef02691c94b6ef09c178177e1efd0b66024e2bbf0021c61b855d33928aa6a06ce4744459246912bb546299dc1361afe8b54f6",
1933 "tcId" : 240
1934 },
1935 {
1936 "comment" : "random signature",
1937 "message" : "48656c6c6f",
1938 "result" : "valid",
1939 "sig" : "303d021c535fd315dc20cffdb12d9760e78f265b372cbab47d16d452b7323e29021d00b647908b7afbc054bd8da42a2c919542e3f46ee500c701c73077bcdb",
1940 "tcId" : 241
1941 },
1942 {
1943 "comment" : "random signature",
1944 "message" : "48656c6c6f",
1945 "result" : "valid",
1946 "sig" : "303e021d00c4732d71dfa662e7954ff9bebfd649d0979fb3b1cff0f003d2bb2491021d00a646d691a1298e7c35a97a3b466a24fb6920b4fadbe879c7753b6cc0",
1947 "tcId" : 242
1948 },
1949 {
1950 "comment" : "random signature",
1951 "message" : "48656c6c6f",
1952 "result" : "valid",
1953 "sig" : "303c021c5234ab61f3968397d91b43782dd4c1d6fb9d3efe408179350776fbc9021c2eb655fb47d872f419455708db8eeb887798c8b4f2c7a97676dba7b8",
1954 "tcId" : 243
1955 },
1956 {
1957 "comment" : "random signature",
1958 "message" : "48656c6c6f",
1959 "result" : "valid",
1960 "sig" : "303d021c0130551eb38f5031878979407512b41539e433dc286d1fede4b80be3021d009bd60de297786209c5432b806a54b7631621d46de47d48842ff681c5",
1961 "tcId" : 244
1962 },
1963 {
1964 "comment" : "random signature",
1965 "message" : "48656c6c6f",
1966 "result" : "valid",
1967 "sig" : "303c021c27d821f9c9cf6318f2a037de60fa4782c351ba4ff80d932d213c4d07021c62ee9b287ba2a0b3e30ddd3fc64e7929bdad9113a1282c10643ad592",
1968 "tcId" : 245
1969 },
1970 {
1971 "comment" : "random signature",
1972 "message" : "48656c6c6f",
1973 "result" : "valid",
1974 "sig" : "303c021c1016ed7dbcb22340942aa8f0e7a84101d96dc42eb55ca2d681632e90021c5c16afccd82d04f8c444de978fe63d5450d07e12b203c32b2196b495",
1975 "tcId" : 246
1976 },
1977 {
1978 "comment" : "random signature",
1979 "message" : "48656c6c6f",
1980 "result" : "valid",
1981 "sig" : "303d021d00ed965e2d4693550bb57f5e02ddb4decd39a6e04877acff12a73a8235021c355bcf5024e4c59fbd085b93309d9c5bbe1a46753ffb4f721a893886",
1982 "tcId" : 247
1983 },
1984 {
1985 "comment" : "random signature",
1986 "message" : "48656c6c6f",
1987 "result" : "valid",
1988 "sig" : "303e021d00bafa121f3eaa86be5126d205415bbac620a5629055ca27d3df9b8678021d00b85d2b3b11517a994317139d28b75772dec6aeb21b1e9fa07886ad8c",
1989 "tcId" : 248
1990 },
1991 {
1992 "comment" : "random signature",
1993 "message" : "48656c6c6f",
1994 "result" : "valid",
1995 "sig" : "303d021d00dc63d34b62603b5f6f5e3a55b65d0571b5d1c5aebe0b2ebb5ffac3a9021c6a88c49cb0d3dd86bae375f93c299dcd32c372ce201e4ab50b31d233",
1996 "tcId" : 249
1997 }
1998 ]
1999 },
2000 {
2001 "keyDer" : "3076301006072a8648ce3d020106052b810400220362000437c5fdb948494b3fd8bb5ec5930025276fa55d43f660e1f06b74a4462063f4735ed0a6d9dfdee6797b70655755e8e2e373d53d1f06fe73b766f5c4e06b788dea92b7a17d7cc1abb95d2c90cb2c09b5a2de2e672126debc46516e910952a91dfa",
2002 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEN8X9uUhJSz/Yu17FkwAlJ2+lXUP2YOHw\na3SkRiBj9HNe0KbZ397meXtwZVdV6OLjc9U9Hwb+c7dm9cTga3iN6pK3oX18wau5\nXSyQyywJtaLeLmchJt68RlFukQlSqR36\n-----END PUBLIC KEY-----",
2003 "sha" : "SHA-512",
2004 "type" : "ECDSAVer",
2005 "key" : {
2006 "curve" : "secp384r1",
2007 "type" : "ECPublicKey",
2008 "wx" : "37c5fdb948494b3fd8bb5ec5930025276fa55d43f660e1f06b74a4462063f4735ed0a6d9dfdee6797b70655755e8e2e3",
2009 "wy" : "73d53d1f06fe73b766f5c4e06b788dea92b7a17d7cc1abb95d2c90cb2c09b5a2de2e672126debc46516e910952a91dfa"
2010 },
2011 "tests" : [
2012 {
2013 "comment" : "random signature",
2014 "message" : "48656c6c6f",
2015 "result" : "valid",
2016 "sig" : "3064023063a13e9cff9933f28be9d5512a41e7d360267d969787bb547de033ec25f4ce8d4241739136ef85c87d4fc26b508e6b0a02300d58575ba57ac5677cf1c0c482310f2ac49bd8e7777cbae1c4255a203b43fc4c57cf80d29054305a4816fa585d1d796f",
2017 "tcId" : 250
2018 },
2019 {
2020 "comment" : "random signature",
2021 "message" : "48656c6c6f",
2022 "result" : "valid",
2023 "sig" : "3064022f2d4f256b6cb1a53506a80dcc9168819143d406429c5d6a250382de196d5d85f15d55a03c2f75438c50ee88e500bfcc023100fb09a8ac3864ae3392d4ff8c6735525daccc3c406abf2b55127c1073e637a2d6ffebed7d7e76c33080323732f932b061",
2024 "tcId" : 251
2025 },
2026 {
2027 "comment" : "random signature",
2028 "message" : "48656c6c6f",
2029 "result" : "valid",
2030 "sig" : "3066023100ab7f86f08c50b3d270130751f841d7872d9cd9da32a20d45af87829ad1b3114ed37c40971abf1b9b901bb90e86ec66ed023100f7a2d3aed355f4fa173e5011da4759bf842c607f45e9716f95a55d9c164901113ed50df4883c52b83db7905d34edb7cf",
2031 "tcId" : 252
2032 },
2033 {
2034 "comment" : "random signature",
2035 "message" : "48656c6c6f",
2036 "result" : "valid",
2037 "sig" : "3066023100d6b7b5fb43b88233c0c08039489b0ff9c356488887aead4a4c67761d9dae82ae53346cc4d962453c95d8c6cc8138b15a0231009f9651cff09767563d5821940d16ef418d80b682af5137bfef8ff12ad0c5b0df90cd936b4ac75b750f52b8609b49cb00",
2038 "tcId" : 253
2039 },
2040 {
2041 "comment" : "random signature",
2042 "message" : "48656c6c6f",
2043 "result" : "valid",
2044 "sig" : "30650231009f04654cfa89783482e23f24a63e0161108b963353856216e8f668b61ce33cb552d9eaf110c1ebf0c7d674410e9efbf20230411c2050c857b0f312ccc3e69afff849bf89e0ff3868ff5693d69c16d901d4d976306b8f5e7cc0a908faa88a06aa4839",
2045 "tcId" : 254
2046 },
2047 {
2048 "comment" : "random signature",
2049 "message" : "48656c6c6f",
2050 "result" : "valid",
2051 "sig" : "30650230221ce3308b394973315c1ae936d41cbe103b3c480d0249063b491c6f282b6a003910cd1b53f78333d1d6bd0fc45cb775023100f7ae3e8c0849282145e8d411e69bb9abf8df77da4c794b639d0fa16e828ca74034e0d190636fb902cce42d29df3ae674",
2052 "tcId" : 255
2053 },
2054 {
2055 "comment" : "random signature",
2056 "message" : "48656c6c6f",
2057 "result" : "valid",
2058 "sig" : "3066023100fe157fe0d7830b2df78a6f41581b3982e2fe2b37d0c50a90804b9fa51fafb64f88b8a4a2a8899eb85709805626bb2374023100b5e8e146185dd26e1a7178f64377456e2bb56e6e3322d27bc8899a14bed7d8652e09d03dfc1730e3ac8ba1f6f0d7fe8d",
2059 "tcId" : 256
2060 },
2061 {
2062 "comment" : "random signature",
2063 "message" : "48656c6c6f",
2064 "result" : "valid",
2065 "sig" : "3065023100d9533df0741a9d3435366d9347259457bf1ace27f436b809a36a04f73a6499aaf1778bfdae763b16f6ab8329beef4cba0230282693221bf9ee2883c2793bccf45bcc50eceafeae3d6f0b0e7e55edda06bc36deebaabb3aee25339b37e7b2fc420f1d",
2066 "tcId" : 257
2067 },
2068 {
2069 "comment" : "random signature",
2070 "message" : "48656c6c6f",
2071 "result" : "valid",
2072 "sig" : "306402304b36a23584076fc30ab2ef9e6b026ce1e60a7d380dc6be69fe2c1e1ec6edb737a8cc85c1486e810d00190cbcb6272bc6023030c794a0cca240578eda7d89b5f0a34b05330e926f7576327550fc444c3aee66c4d913c8d90be9b405486c8c879d1080",
2073 "tcId" : 258
2074 },
2075 {
2076 "comment" : "random signature",
2077 "message" : "48656c6c6f",
2078 "result" : "valid",
2079 "sig" : "3065023100d1993840050f853b6b046e3761a6007dca17f24bd96cc38cf08cee3b25ce1142cbe1b23bd97f49f1f73667f9956a0b8502305d1b757f67de261d5b7729a0cb582a0d4133ba6ffb329315328e43a2d3345b670a6c44ddaef6ff4b400616cdc0ecaf83",
2080 "tcId" : 259
2081 }
2082 ]
2083 },
2084 {
2085 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000400252ba02b52511e0d27c926f51933deb9da574b65790d0586514afe02478a384c7709702304fa45d891f74ea5b7774658ec7f6bd665b7b857a19946ed97a13e12370122a5e01c6cc84e4ccf55a27b836a31e3faa91a27b8967b85abd815595f76bf7a0ed524ac8730bcb3b0c536907c8d492718bbbcc581d27b8d347fbe7844f65675fb",
2086 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAJSugK1JRHg0nySb1GTPeudpXS2V5\nDQWGUUr+AkeKOEx3CXAjBPpF2JH3TqW3d0ZY7H9r1mW3uFehmUbtl6E+EjcBIqXg\nHGzITkzPVaJ7g2ox4/qpGie4lnuFq9gVWV92v3oO1SSshzC8s7DFNpB8jUknGLu8\nxYHSe400f754RPZWdfs=\n-----END PUBLIC KEY-----",
2087 "sha" : "SHA-512",
2088 "type" : "ECDSAVer",
2089 "key" : {
2090 "curve" : "secp521r1",
2091 "type" : "ECPublicKey",
2092 "wx" : "252ba02b52511e0d27c926f51933deb9da574b65790d0586514afe02478a384c7709702304fa45d891f74ea5b7774658ec7f6bd665b7b857a19946ed97a13e1237",
2093 "wy" : "122a5e01c6cc84e4ccf55a27b836a31e3faa91a27b8967b85abd815595f76bf7a0ed524ac8730bcb3b0c536907c8d492718bbbcc581d27b8d347fbe7844f65675fb"
2094 },
2095 "tests" : [
2096 {
2097 "comment" : "random signature",
2098 "message" : "48656c6c6f",
2099 "result" : "valid",
2100 "sig" : "30818702412a996b82715ac9f1fe285a850a617e51ebabf92b521aa0c8548b6ab3fd218ae9bfd63f04416943a4c6ea6a9d679b770a40fb2298511c9e1541f08f63680dcb920d0242011e06a29b2b4b4342d23a5e1986fd5ec5970719a9afa019b17be2b29655187b0ed1d81359dd48d3dcb8c8ca201b33038dfb5980165de4797ae9108d3544dce9e9f2",
2101 "tcId" : 260
2102 },
2103 {
2104 "comment" : "random signature",
2105 "message" : "48656c6c6f",
2106 "result" : "valid",
2107 "sig" : "30818802420143eefbaa995087d553835fe93afcf43364d834e37302317c0587b7c86604dde272474e7f2501463280e0e979eb59e79e9f7a3236d967230fc5677fad4b29b424a1024201578a2dbb28cb4e7ca50bd237253b7912f3c8a7cb455d7da98c599855838b0dde6ed83276ab8eaefb312756cd3e16e53377358a98b8c612168e84261b510ea42253",
2108 "tcId" : 261
2109 },
2110 {
2111 "comment" : "random signature",
2112 "message" : "48656c6c6f",
2113 "result" : "valid",
2114 "sig" : "30818702420131247501344d5aac53cdc31d65e22ab02bf552c246f0fa92ea7d24999bf6df4474c64af6c892ad05b1c3d83634c3420f55993d10589352674ffbec71552ff66bb102412655b482f9231e3ba0283b96d0a934c6f0c6282f7907e8d0aa1e6707d0410a78d036461b5e5d3cf7f0e7ceb23c24f334d6cbc2f1d1684039a14c22d8538debb62b",
2115 "tcId" : 262
2116 },
2117 {
2118 "comment" : "random signature",
2119 "message" : "48656c6c6f",
2120 "result" : "valid",
2121 "sig" : "308188024201538632e5ba4b1119240dbe68e026a9ffe934ad46f129fae49dd30caf2dec9e45504be132685474c6ba473f39f9439717939b3dc725a82488c77b17358511a3eae90242015d36c05195a17382a229a61a011639f8c309696d68e1f3b95d0053ee23bf6cb6249bf7a4fc9f1517147a33438c66edef6c587f00d3de8635be84a785d5e7baf319",
2122 "tcId" : 263
2123 },
2124 {
2125 "comment" : "random signature",
2126 "message" : "48656c6c6f",
2127 "result" : "valid",
2128 "sig" : "308188024200fafebd657159b7a0f5d9e3b58ceffcb30056407fdbbf345f416d9cfadfc22edd4f31d9ba39a8e3a0ab1a4154f2417ed99cf80600cf95ecb5ce8b0e7ee79cf84c7a024201c47968f0a10144d6f399a270bf8c663eb083c2c6629f13704e855a84d78fe4fd9e4ffd81191882b6ba51b220cb6bc94c55f89a8182460a321325a0c978f57bc17b",
2129 "tcId" : 264
2130 },
2131 {
2132 "comment" : "random signature",
2133 "message" : "48656c6c6f",
2134 "result" : "valid",
2135 "sig" : "3081870241138ffe382f05a34b2aea9bc90c2c5cac363d2cbd3af5c4fd1b39e75a92b34d6a1e6f0304a29a1b53651bda15840e1a93971bf20121c2d72d61481b95c3777116cc024201076665a62dd5dc147b30eb6521deaab06125d77b020c756940b21e1ff66f0d9b18b0013427b72a5ace91ccb790f94d0fea8f058f75324d4803283d2d3ea725a09c",
2136 "tcId" : 265
2137 },
2138 {
2139 "comment" : "random signature",
2140 "message" : "48656c6c6f",
2141 "result" : "valid",
2142 "sig" : "308188024201a1f9f065bab50e83ab6c8c9008df1bfcb74f344f02efadab68c41d6f89c082157b978562bd4afea4769fbab392224682ef2683b449888f83205917e0918bbec217024201f7c1b72a0c0be8dddda08219060254bfc1e3e3c65427e89eff7868a7d9cfee31ee6653d455041ffa273b1ea383518b33231da95ea353a4d9ff3e5fa8c94c99e8f7",
2143 "tcId" : 266
2144 },
2145 {
2146 "comment" : "random signature",
2147 "message" : "48656c6c6f",
2148 "result" : "valid",
2149 "sig" : "3081880242018270e7745dad6d8488720f4c93b69700d9717503887288c671d916cd649595f9783591833116b2ef912fa72d259ab7114ae3a182a9864a7edd4e6fcb3990649ce702420146242a4a3483946bc090a40ac39339fc124368e7535c84530a98aa3bbcece21909605d4c045b22f611ee5bc33179f11dd0d528c7b64ca241a47a273430b5a4e844",
2150 "tcId" : 267
2151 },
2152 {
2153 "comment" : "random signature",
2154 "message" : "48656c6c6f",
2155 "result" : "valid",
2156 "sig" : "308188024201a04b162ee70667cd609d86eb5410b9d7c0c72a95ff3b3cab5c2d51023806a221d18db37a130be74b32356b29f6e6420bc022f83f60999b4176d5c9e31d900f226b0242011eb2c375e10607769fee41fa0ab61bd7c4b2761776851590e75bc2c91a0d1f5db1e8031df3ae6ae753e7ee9465c7fb547f97ebf080f756d33e323b0ba0afeeef23",
2157 "tcId" : 268
2158 },
2159 {
2160 "comment" : "random signature",
2161 "message" : "48656c6c6f",
2162 "result" : "valid",
2163 "sig" : "3081880242009dc34469da72d84ac5addcb57e8b47186733860fc0ed44ea83ed28987cec9549102e537db86589e27204015cd2b2bf197dba0c21f28f01bcb16e0c0ee623e395fb024200db1653be45deca922f80d620f5524d9ce88cbcc9e5ee6c6be6227836f8badf6d99138bdde1ba7b9ee3395382e827f2adbea608ca51175a64c483f1342193f52bbd",
2164 "tcId" : 269
2165 }
2166 ]
2167 },
2168 {
2169 "keyDer" : "304e301006072a8648ce3d020106052b81040021033a0004d90c6ccc60a40e92013f34fbeaa6d9e765e4a25f937f53faf6dc8595e603a9c4b1a60a5a51531b2fb1b57e38151a859c204f0f6c27b6feb6",
2170 "keyPem" : "-----BEGIN PUBLIC KEY-----\nME4wEAYHKoZIzj0CAQYFK4EEACEDOgAE2QxszGCkDpIBPzT76qbZ52Xkol+Tf1P6\n9tyFleYDqcSxpgpaUVMbL7G1fjgVGoWcIE8PbCe2/rY=\n-----END PUBLIC KEY-----",
2171 "sha" : "SHA-1",
2172 "type" : "ECDSAVer",
2173 "key" : {
2174 "curve" : "secp224r1",
2175 "type" : "ECPublicKey",
2176 "wx" : "0d90c6ccc60a40e92013f34fbeaa6d9e765e4a25f937f53faf6dc8595",
2177 "wy" : "0e603a9c4b1a60a5a51531b2fb1b57e38151a859c204f0f6c27b6feb6"
2178 },
2179 "tests" : [
2180 {
2181 "comment" : "Hash weaker than DL-group",
2182 "message" : "48656c6c6f",
2183 "result" : "acceptable",
2184 "sig" : "303d021d00a2dfa28cce02d4006d07d3251a8ad54328571941869f48f3fcbcc316021c6d5cbf4e497d80bb1ad7955b441917872580c8977b4c026420ff449d",
2185 "tcId" : 270
2186 }
2187 ]
2188 },
2189 {
2190 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004e49b6e5e078e9aa4364583f037efd94fb1058b9de125cb2a471981c343e662b2beaa75937c479c738574093053a2d54218753a967da74c0064d52e6a4db2cd73",
2191 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5JtuXgeOmqQ2RYPwN+/ZT7EFi53h\nJcsqRxmBw0PmYrK+qnWTfEecc4V0CTBTotVCGHU6ln2nTABk1S5qTbLNcw==\n-----END PUBLIC KEY-----",
2192 "sha" : "SHA-224",
2193 "type" : "ECDSAVer",
2194 "key" : {
2195 "curve" : "secp256r1",
2196 "type" : "ECPublicKey",
2197 "wx" : "0e49b6e5e078e9aa4364583f037efd94fb1058b9de125cb2a471981c343e662b2",
2198 "wy" : "0beaa75937c479c738574093053a2d54218753a967da74c0064d52e6a4db2cd73"
2199 },
2200 "tests" : [
2201 {
2202 "comment" : "Hash weaker than DL-group",
2203 "message" : "48656c6c6f",
2204 "result" : "acceptable",
2205 "sig" : "30460221008febf29c959ccc9c138a3190b9e22d1721a14351ddb2be669aa4370b944fc318022100d41f7637c75f4f4631aa2dbd42e1282f8a9ac13fb869339d10c3a00a5953397b",
2206 "tcId" : 271
2207 }
2208 ]
2209 },
2210 {
2211 "keyDer" : "3076301006072a8648ce3d020106052b8104002203620004a884162c27b9b66355f98c71d58a568d1306a3cbb530f527355deabc9a91ee1e7c9a0f0667435ec7ccb2507eb93c5ea8b2326d0e69c1e053e49b55de8d6257a07f1421dcfd49290c962d71ea5e5585917d406bd78a345f721e183e2d53a394b2",
2212 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEqIQWLCe5tmNV+Yxx1YpWjRMGo8u1MPUn\nNV3qvJqR7h58mg8GZ0Nex8yyUH65PF6osjJtDmnB4FPkm1XejWJXoH8UIdz9SSkM\nli1x6l5VhZF9QGvXijRfch4YPi1To5Sy\n-----END PUBLIC KEY-----",
2213 "sha" : "SHA-256",
2214 "type" : "ECDSAVer",
2215 "key" : {
2216 "curve" : "secp384r1",
2217 "type" : "ECPublicKey",
2218 "wx" : "0a884162c27b9b66355f98c71d58a568d1306a3cbb530f527355deabc9a91ee1e7c9a0f0667435ec7ccb2507eb93c5ea8",
2219 "wy" : "0b2326d0e69c1e053e49b55de8d6257a07f1421dcfd49290c962d71ea5e5585917d406bd78a345f721e183e2d53a394b2"
2220 },
2221 "tests" : [
2222 {
2223 "comment" : "Hash weaker than DL-group",
2224 "message" : "48656c6c6f",
2225 "result" : "acceptable",
2226 "sig" : "306502305158cdcc24d284b3427c1364844c04129b5d2d802bfa10401f81fc9c6fc0a4e66dd9c3d9a9964707494c497a5f702949023100c48ae0e2e4610bf39902f14e9abd0e3e785218711320dd353b0c5c4699f575570e0d6855dfcc8cbf28e88cadc3802cea",
2227 "tcId" : 272
2228 }
2229 ]
2230 },
2231 {
2232 "keyDer" : "30819b301006072a8648ce3d020106052b8104002303818600040024654b7e0621518502ecf70d7dce95c1000dacc7ea72be66462b2ae13befdc7fcbcb188f811c41ab67b0cb6490a8fd51a6561103b7b8b61413ce7324574ef9aa37009a61befa9b2b32c250b96e7868cb9de26e480b7ff608fdd64e02a392e216098a0d3383975375df15671fbe8d32165bf954e8b4b3efcef764ecca11dfda98e2073c",
2233 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAJGVLfgYhUYUC7PcNfc6VwQANrMfq\ncr5mRisq4Tvv3H/LyxiPgRxBq2ewy2SQqP1RplYRA7e4thQTznMkV075qjcAmmG+\n+psrMsJQuW54aMud4m5IC3/2CP3WTgKjkuIWCYoNM4OXU3XfFWcfvo0yFlv5VOi0\ns+/O92TsyhHf2pjiBzw=\n-----END PUBLIC KEY-----",
2234 "sha" : "SHA-256",
2235 "type" : "ECDSAVer",
2236 "key" : {
2237 "curve" : "secp521r1",
2238 "type" : "ECPublicKey",
2239 "wx" : "24654b7e0621518502ecf70d7dce95c1000dacc7ea72be66462b2ae13befdc7fcbcb188f811c41ab67b0cb6490a8fd51a6561103b7b8b61413ce7324574ef9aa37",
2240 "wy" : "09a61befa9b2b32c250b96e7868cb9de26e480b7ff608fdd64e02a392e216098a0d3383975375df15671fbe8d32165bf954e8b4b3efcef764ecca11dfda98e2073c"
2241 },
2242 "tests" : [
2243 {
2244 "comment" : "Hash weaker than DL-group",
2245 "message" : "48656c6c6f",
2246 "result" : "acceptable",
2247 "sig" : "308188024201d9422e516e19f29b1d44450c9a7f63c6621a111f6ac69bbd58a0bcb19dc76d4ffe32dd3ebe796f3b5bf908f882545ba40025bbfd7a67d02507789fe6696384f921024201878e7aa8b9c5dda694c3e9f4bc702ad74ce1e30d959097dfffd173fe57a55fbacfeabe6f514654ea21961f9f2d1f07782f7db156c2807df333de15ec57f58d8099",
2248 "tcId" : 273
2249 }
2250 ]
2251 }
2252 ]
2253 }
0 {
1 "algorithm" : "ECDSA",
2 "generatorVersion" : "0.0a11",
3 "numberOfTests" : 123,
4 "testGroups" : [
5 {
6 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044af4f6d1d734798d4c4c6f97c4fff392ee65dc252d617b154ca835ea1535b104fb069171d00e87a92e6c4db1d892bc09b04b5da8bd9b09cfaa41d0a526e55237",
7 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESvT20dc0eY1MTG+XxP/zku5l3CUt\nYXsVTKg16hU1sQT7BpFx0A6HqS5sTbHYkrwJsEtdqL2bCc+qQdClJuVSNw==\n-----END PUBLIC KEY-----",
8 "sha" : "SHA-256",
9 "type" : "ECDSAVer",
10 "jwk" : {
11 "crv" : "P-256",
12 "kid" : "none",
13 "kty" : "EC",
14 "x" : "SvT20dc0eY1MTG-XxP_zku5l3CUtYXsVTKg16hU1sQQ",
15 "y" : "-waRcdAOh6kubE2x2JK8CbBLXai9mwnPqkHQpSblUjc"
16 },
17 "key" : {
18 "curve" : "secp256r1",
19 "keySize" : 256,
20 "type" : "ECPublicKey",
21 "wx" : "4af4f6d1d734798d4c4c6f97c4fff392ee65dc252d617b154ca835ea1535b104",
22 "wy" : "0fb069171d00e87a92e6c4db1d892bc09b04b5da8bd9b09cfaa41d0a526e55237"
23 },
24 "tests" : [
25 {
26 "comment" : "signature malleability",
27 "message" : "48656c6c6f",
28 "result" : "valid",
29 "sig" : "b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f8b8d6e21d0c0bb5185319715ccbce2902802e1eca070b7226dec70ceca023883",
30 "tcId" : 1
31 },
32 {
33 "comment" : "random signature",
34 "message" : "48656c6c6f",
35 "result" : "valid",
36 "sig" : "f67dd15cef0128e9a4fb3c3e9958dd08039eba90453e8993a54251e667a317ab7e59ce34928cc502a3b3c3758cfb6f4907a2d463b0aba52291793b5854245944",
37 "tcId" : 2
38 },
39 {
40 "comment" : "random signature",
41 "message" : "48656c6c6f",
42 "result" : "valid",
43 "sig" : "56179fa191744e602ae7f6ae46e42312c6e336fc83a628ee455c6229b46c33413f0bd962a1a81406a29bc03a4b61c08e9503e75eba0bc29e8bc65494a25d3744",
44 "tcId" : 3
45 },
46 {
47 "comment" : "random signature",
48 "message" : "48656c6c6f",
49 "result" : "valid",
50 "sig" : "ca3503dfdf49e158b08046eb3ff169ae4b7f299cfd432ad9d7598ec952dac1c11cfc4c46c9eea69e577310202df187d32c058d9fef2d32bc5283642b79d1373b",
51 "tcId" : 4
52 },
53 {
54 "comment" : "random signature",
55 "message" : "48656c6c6f",
56 "result" : "valid",
57 "sig" : "9483c852f5b725da505e8cf57b9148b2772a1f2acc6f479fe8f176e69e1377f5b3cce9b6a9d46d9af3b992f8e947b72b165ac9e216966d34c533a6626796164b",
58 "tcId" : 5
59 },
60 {
61 "comment" : "random signature",
62 "message" : "48656c6c6f",
63 "result" : "valid",
64 "sig" : "1656802176c0e98da5512de8f9080f4dd91163c8a7422d1e930d58075309edef88be892159f048816a046d05d426f5d38d38e3f41d52617239fe8f5ae93b1abc",
65 "tcId" : 6
66 },
67 {
68 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
69 "message" : "48656c6c6f",
70 "result" : "invalid",
71 "sig" : "01b7babae8332b54b9a3a05b7004579821656e9c5fbb7d96607df713de3660519000747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
72 "tcId" : 7
73 },
74 {
75 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
76 "message" : "48656c6c6f",
77 "result" : "invalid",
78 "sig" : "48454515ccd4ab485c5fa48ffba867de145f58fb92b1a6a9697c81a7c265f912747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
79 "tcId" : 8
80 },
81 {
82 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
83 "message" : "48656c6c6f",
84 "result" : "invalid",
85 "sig" : "01b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f00747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
86 "tcId" : 9
87 },
88 {
89 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
90 "message" : "48656c6c6f",
91 "result" : "invalid",
92 "sig" : "48454516ccd4ab475c5fa48ffba867de57785e4deb9a082475c2b6e4c602d3c1747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
93 "tcId" : 10
94 },
95 {
96 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
97 "message" : "48656c6c6f",
98 "result" : "invalid",
99 "sig" : "00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f01747291dc2f3f44b07ace68ea33431d6f51cb136eadbe85e7798724b72ec4121f",
100 "tcId" : 11
101 },
102 {
103 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
104 "message" : "48656c6c6f",
105 "result" : "invalid",
106 "sig" : "00b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f01747291dd2f3f44af7ace68ea33431d6f94e418c106a6e76285cd59f43260ecce",
107 "tcId" : 12
108 },
109 {
110 "comment" : "Modified r or s, e.g. by adding or subtracting the order of the group",
111 "message" : "48656c6c6f",
112 "result" : "invalid",
113 "sig" : "b7babae9332b54b8a3a05b7004579821a887a1b21465f7db8a3d491b39fd2c3f8b8d6e22d0c0bb5085319715ccbce2906b1be73ef959189d7a32a60bcd9f1332",
114 "tcId" : 13
115 },
116 {
117 "comment" : "Signatures with special case values for r and s.",
118 "message" : "48656c6c6f",
119 "result" : "invalid",
120 "sig" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
121 "tcId" : 14
122 },
123 {
124 "comment" : "Signatures with special case values for r and s.",
125 "message" : "48656c6c6f",
126 "result" : "invalid",
127 "sig" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
128 "tcId" : 15
129 },
130 {
131 "comment" : "Signatures with special case values for r and s.",
132 "message" : "48656c6c6f",
133 "result" : "invalid",
134 "sig" : "0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
135 "tcId" : 16
136 },
137 {
138 "comment" : "Signatures with special case values for r and s.",
139 "message" : "48656c6c6f",
140 "result" : "invalid",
141 "sig" : "0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
142 "tcId" : 17
143 },
144 {
145 "comment" : "Signatures with special case values for r and s.",
146 "message" : "48656c6c6f",
147 "result" : "invalid",
148 "sig" : "0000000000000000000000000000000000000000000000000000000000000000ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
149 "tcId" : 18
150 },
151 {
152 "comment" : "Signatures with special case values for r and s.",
153 "message" : "48656c6c6f",
154 "result" : "invalid",
155 "sig" : "0000000000000000000000000000000000000000000000000000000000000000ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
156 "tcId" : 19
157 },
158 {
159 "comment" : "Signatures with special case values for r and s.",
160 "message" : "48656c6c6f",
161 "result" : "invalid",
162 "sig" : "0000000000000000000000000000000000000000000000000000000000000000ffffffff00000001000000000000000000000001000000000000000000000000",
163 "tcId" : 20
164 },
165 {
166 "comment" : "Signatures with special case values for r and s.",
167 "message" : "48656c6c6f",
168 "result" : "invalid",
169 "sig" : "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
170 "tcId" : 21
171 },
172 {
173 "comment" : "Signatures with special case values for r and s.",
174 "message" : "48656c6c6f",
175 "result" : "invalid",
176 "sig" : "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
177 "tcId" : 22
178 },
179 {
180 "comment" : "Signatures with special case values for r and s.",
181 "message" : "48656c6c6f",
182 "result" : "invalid",
183 "sig" : "0000000000000000000000000000000000000000000000000000000000000001ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
184 "tcId" : 23
185 },
186 {
187 "comment" : "Signatures with special case values for r and s.",
188 "message" : "48656c6c6f",
189 "result" : "invalid",
190 "sig" : "0000000000000000000000000000000000000000000000000000000000000001ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
191 "tcId" : 24
192 },
193 {
194 "comment" : "Signatures with special case values for r and s.",
195 "message" : "48656c6c6f",
196 "result" : "invalid",
197 "sig" : "0000000000000000000000000000000000000000000000000000000000000001ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
198 "tcId" : 25
199 },
200 {
201 "comment" : "Signatures with special case values for r and s.",
202 "message" : "48656c6c6f",
203 "result" : "invalid",
204 "sig" : "0000000000000000000000000000000000000000000000000000000000000001ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
205 "tcId" : 26
206 },
207 {
208 "comment" : "Signatures with special case values for r and s.",
209 "message" : "48656c6c6f",
210 "result" : "invalid",
211 "sig" : "0000000000000000000000000000000000000000000000000000000000000001ffffffff00000001000000000000000000000001000000000000000000000000",
212 "tcId" : 27
213 },
214 {
215 "comment" : "Signatures with special case values for r and s.",
216 "message" : "48656c6c6f",
217 "result" : "invalid",
218 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325510000000000000000000000000000000000000000000000000000000000000000",
219 "tcId" : 28
220 },
221 {
222 "comment" : "Signatures with special case values for r and s.",
223 "message" : "48656c6c6f",
224 "result" : "invalid",
225 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325510000000000000000000000000000000000000000000000000000000000000001",
226 "tcId" : 29
227 },
228 {
229 "comment" : "Signatures with special case values for r and s.",
230 "message" : "48656c6c6f",
231 "result" : "invalid",
232 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
233 "tcId" : 30
234 },
235 {
236 "comment" : "Signatures with special case values for r and s.",
237 "message" : "48656c6c6f",
238 "result" : "invalid",
239 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
240 "tcId" : 31
241 },
242 {
243 "comment" : "Signatures with special case values for r and s.",
244 "message" : "48656c6c6f",
245 "result" : "invalid",
246 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
247 "tcId" : 32
248 },
249 {
250 "comment" : "Signatures with special case values for r and s.",
251 "message" : "48656c6c6f",
252 "result" : "invalid",
253 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
254 "tcId" : 33
255 },
256 {
257 "comment" : "Signatures with special case values for r and s.",
258 "message" : "48656c6c6f",
259 "result" : "invalid",
260 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551ffffffff00000001000000000000000000000001000000000000000000000000",
261 "tcId" : 34
262 },
263 {
264 "comment" : "Signatures with special case values for r and s.",
265 "message" : "48656c6c6f",
266 "result" : "invalid",
267 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325500000000000000000000000000000000000000000000000000000000000000000",
268 "tcId" : 35
269 },
270 {
271 "comment" : "Signatures with special case values for r and s.",
272 "message" : "48656c6c6f",
273 "result" : "invalid",
274 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325500000000000000000000000000000000000000000000000000000000000000001",
275 "tcId" : 36
276 },
277 {
278 "comment" : "Signatures with special case values for r and s.",
279 "message" : "48656c6c6f",
280 "result" : "invalid",
281 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
282 "tcId" : 37
283 },
284 {
285 "comment" : "Signatures with special case values for r and s.",
286 "message" : "48656c6c6f",
287 "result" : "invalid",
288 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
289 "tcId" : 38
290 },
291 {
292 "comment" : "Signatures with special case values for r and s.",
293 "message" : "48656c6c6f",
294 "result" : "invalid",
295 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
296 "tcId" : 39
297 },
298 {
299 "comment" : "Signatures with special case values for r and s.",
300 "message" : "48656c6c6f",
301 "result" : "invalid",
302 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
303 "tcId" : 40
304 },
305 {
306 "comment" : "Signatures with special case values for r and s.",
307 "message" : "48656c6c6f",
308 "result" : "invalid",
309 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550ffffffff00000001000000000000000000000001000000000000000000000000",
310 "tcId" : 41
311 },
312 {
313 "comment" : "Signatures with special case values for r and s.",
314 "message" : "48656c6c6f",
315 "result" : "invalid",
316 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325520000000000000000000000000000000000000000000000000000000000000000",
317 "tcId" : 42
318 },
319 {
320 "comment" : "Signatures with special case values for r and s.",
321 "message" : "48656c6c6f",
322 "result" : "invalid",
323 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325520000000000000000000000000000000000000000000000000000000000000001",
324 "tcId" : 43
325 },
326 {
327 "comment" : "Signatures with special case values for r and s.",
328 "message" : "48656c6c6f",
329 "result" : "invalid",
330 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
331 "tcId" : 44
332 },
333 {
334 "comment" : "Signatures with special case values for r and s.",
335 "message" : "48656c6c6f",
336 "result" : "invalid",
337 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
338 "tcId" : 45
339 },
340 {
341 "comment" : "Signatures with special case values for r and s.",
342 "message" : "48656c6c6f",
343 "result" : "invalid",
344 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
345 "tcId" : 46
346 },
347 {
348 "comment" : "Signatures with special case values for r and s.",
349 "message" : "48656c6c6f",
350 "result" : "invalid",
351 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
352 "tcId" : 47
353 },
354 {
355 "comment" : "Signatures with special case values for r and s.",
356 "message" : "48656c6c6f",
357 "result" : "invalid",
358 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552ffffffff00000001000000000000000000000001000000000000000000000000",
359 "tcId" : 48
360 },
361 {
362 "comment" : "Signatures with special case values for r and s.",
363 "message" : "48656c6c6f",
364 "result" : "invalid",
365 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000",
366 "tcId" : 49
367 },
368 {
369 "comment" : "Signatures with special case values for r and s.",
370 "message" : "48656c6c6f",
371 "result" : "invalid",
372 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000001",
373 "tcId" : 50
374 },
375 {
376 "comment" : "Signatures with special case values for r and s.",
377 "message" : "48656c6c6f",
378 "result" : "invalid",
379 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffffffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
380 "tcId" : 51
381 },
382 {
383 "comment" : "Signatures with special case values for r and s.",
384 "message" : "48656c6c6f",
385 "result" : "invalid",
386 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffffffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
387 "tcId" : 52
388 },
389 {
390 "comment" : "Signatures with special case values for r and s.",
391 "message" : "48656c6c6f",
392 "result" : "invalid",
393 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffffffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
394 "tcId" : 53
395 },
396 {
397 "comment" : "Signatures with special case values for r and s.",
398 "message" : "48656c6c6f",
399 "result" : "invalid",
400 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffffffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
401 "tcId" : 54
402 },
403 {
404 "comment" : "Signatures with special case values for r and s.",
405 "message" : "48656c6c6f",
406 "result" : "invalid",
407 "sig" : "ffffffff00000001000000000000000000000000ffffffffffffffffffffffffffffffff00000001000000000000000000000001000000000000000000000000",
408 "tcId" : 55
409 },
410 {
411 "comment" : "Signatures with special case values for r and s.",
412 "message" : "48656c6c6f",
413 "result" : "invalid",
414 "sig" : "ffffffff000000010000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
415 "tcId" : 56
416 },
417 {
418 "comment" : "Signatures with special case values for r and s.",
419 "message" : "48656c6c6f",
420 "result" : "invalid",
421 "sig" : "ffffffff000000010000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
422 "tcId" : 57
423 },
424 {
425 "comment" : "Signatures with special case values for r and s.",
426 "message" : "48656c6c6f",
427 "result" : "invalid",
428 "sig" : "ffffffff00000001000000000000000000000001000000000000000000000000ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
429 "tcId" : 58
430 },
431 {
432 "comment" : "Signatures with special case values for r and s.",
433 "message" : "48656c6c6f",
434 "result" : "invalid",
435 "sig" : "ffffffff00000001000000000000000000000001000000000000000000000000ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632550",
436 "tcId" : 59
437 },
438 {
439 "comment" : "Signatures with special case values for r and s.",
440 "message" : "48656c6c6f",
441 "result" : "invalid",
442 "sig" : "ffffffff00000001000000000000000000000001000000000000000000000000ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
443 "tcId" : 60
444 },
445 {
446 "comment" : "Signatures with special case values for r and s.",
447 "message" : "48656c6c6f",
448 "result" : "invalid",
449 "sig" : "ffffffff00000001000000000000000000000001000000000000000000000000ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
450 "tcId" : 61
451 },
452 {
453 "comment" : "Signatures with special case values for r and s.",
454 "message" : "48656c6c6f",
455 "result" : "invalid",
456 "sig" : "ffffffff00000001000000000000000000000001000000000000000000000000ffffffff00000001000000000000000000000001000000000000000000000000",
457 "tcId" : 62
458 }
459 ]
460 },
461 {
462 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926",
463 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1wXRb4CYfi2bGmlX0pziL+v30Q+l\nFRUxgkFcg2G6rKSx/BBe5c6A1RTsEji+riA3pvg2JVk2INRggZ6GghYJJg==\n-----END PUBLIC KEY-----",
464 "sha" : "SHA-256",
465 "type" : "ECDSAVer",
466 "jwk" : {
467 "crv" : "P-256",
468 "kid" : "none",
469 "kty" : "EC",
470 "x" : "1wXRb4CYfi2bGmlX0pziL-v30Q-lFRUxgkFcg2G6rKQ",
471 "y" : "sfwQXuXOgNUU7BI4vq4gN6b4NiVZNiDUYIGehoIWCSY"
472 },
473 "key" : {
474 "curve" : "secp256r1",
475 "keySize" : 256,
476 "type" : "ECPublicKey",
477 "wx" : "0d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4",
478 "wy" : "0b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926"
479 },
480 "tests" : [
481 {
482 "comment" : "k*G has a large x-coordinate",
483 "message" : "54657374",
484 "result" : "valid",
485 "sig" : "000000000000000000000000000000004319055358e8617b0c46353d039cdaabffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e",
486 "tcId" : 63
487 }
488 ]
489 },
490 {
491 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926",
492 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1wXRb4CYfi2bGmlX0pziL+v30Q+l\nFRUxgkFcg2G6rKSx/BBe5c6A1RTsEji+riA3pvg2JVk2INRggZ6GghYJJg==\n-----END PUBLIC KEY-----",
493 "sha" : "SHA-256",
494 "type" : "ECDSAVer",
495 "jwk" : {
496 "crv" : "P-256",
497 "kid" : "none",
498 "kty" : "EC",
499 "x" : "1wXRb4CYfi2bGmlX0pziL-v30Q-lFRUxgkFcg2G6rKQ",
500 "y" : "sfwQXuXOgNUU7BI4vq4gN6b4NiVZNiDUYIGehoIWCSY"
501 },
502 "key" : {
503 "curve" : "secp256r1",
504 "keySize" : 256,
505 "type" : "ECPublicKey",
506 "wx" : "0d705d16f80987e2d9b1a6957d29ce22febf7d10fa515153182415c8361baaca4",
507 "wy" : "0b1fc105ee5ce80d514ec1238beae2037a6f83625593620d460819e8682160926"
508 },
509 "tests" : [
510 {
511 "comment" : "r too large",
512 "message" : "54657374",
513 "result" : "invalid",
514 "sig" : "ffffffff00000001000000000000000000000000fffffffffffffffffffffffcffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e",
515 "tcId" : 64
516 }
517 ]
518 },
519 {
520 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200043cd8d2f81d6953b0844c09d7b560d527cd2ef67056893eadafa52c8501387d59ee41fdb4d10402ce7a0c5e3b747adfa3a490b62a6b7719068903485c0bb6dc2d",
521 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPNjS+B1pU7CETAnXtWDVJ80u9nBW\niT6tr6UshQE4fVnuQf200QQCznoMXjt0et+jpJC2Kmt3GQaJA0hcC7bcLQ==\n-----END PUBLIC KEY-----",
522 "sha" : "SHA-256",
523 "type" : "ECDSAVer",
524 "jwk" : {
525 "crv" : "P-256",
526 "kid" : "none",
527 "kty" : "EC",
528 "x" : "PNjS-B1pU7CETAnXtWDVJ80u9nBWiT6tr6UshQE4fVk",
529 "y" : "7kH9tNEEAs56DF47dHrfo6SQtiprdxkGiQNIXAu23C0"
530 },
531 "key" : {
532 "curve" : "secp256r1",
533 "keySize" : 256,
534 "type" : "ECPublicKey",
535 "wx" : "3cd8d2f81d6953b0844c09d7b560d527cd2ef67056893eadafa52c8501387d59",
536 "wy" : "0ee41fdb4d10402ce7a0c5e3b747adfa3a490b62a6b7719068903485c0bb6dc2d"
537 },
538 "tests" : [
539 {
540 "comment" : "r,s are large",
541 "message" : "54657374",
542 "result" : "valid",
543 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e",
544 "tcId" : 65
545 }
546 ]
547 },
548 {
549 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e53e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0",
550 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESgPvn5LrJoyvpgEHJImlY4D6DcQx\ncddxKBOzoZoeteU+IT4opgjOmi9KF/2DDGZUAYp5s+AmPZGoupBiLfby8A==\n-----END PUBLIC KEY-----",
551 "sha" : "SHA-256",
552 "type" : "ECDSAVer",
553 "jwk" : {
554 "crv" : "P-256",
555 "kid" : "none",
556 "kty" : "EC",
557 "x" : "SgPvn5LrJoyvpgEHJImlY4D6DcQxcddxKBOzoZoeteU",
558 "y" : "PiE-KKYIzpovShf9gwxmVAGKebPgJj2RqLqQYi328vA"
559 },
560 "key" : {
561 "curve" : "secp256r1",
562 "keySize" : 256,
563 "type" : "ECPublicKey",
564 "wx" : "4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e5",
565 "wy" : "3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0"
566 },
567 "tests" : [
568 {
569 "comment" : "small r and s",
570 "message" : "54657374",
571 "result" : "valid",
572 "sig" : "00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000001",
573 "tcId" : 66
574 },
575 {
576 "comment" : "incorrect size of signature",
577 "message" : "54657374",
578 "result" : "acceptable",
579 "sig" : "0501",
580 "tcId" : 67
581 }
582 ]
583 },
584 {
585 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e53e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0",
586 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESgPvn5LrJoyvpgEHJImlY4D6DcQx\ncddxKBOzoZoeteU+IT4opgjOmi9KF/2DDGZUAYp5s+AmPZGoupBiLfby8A==\n-----END PUBLIC KEY-----",
587 "sha" : "SHA-256",
588 "type" : "ECDSAVer",
589 "jwk" : {
590 "crv" : "P-256",
591 "kid" : "none",
592 "kty" : "EC",
593 "x" : "SgPvn5LrJoyvpgEHJImlY4D6DcQxcddxKBOzoZoeteU",
594 "y" : "PiE-KKYIzpovShf9gwxmVAGKebPgJj2RqLqQYi328vA"
595 },
596 "key" : {
597 "curve" : "secp256r1",
598 "keySize" : 256,
599 "type" : "ECPublicKey",
600 "wx" : "4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e5",
601 "wy" : "3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0"
602 },
603 "tests" : [
604 {
605 "comment" : "r is larger than n",
606 "message" : "54657374",
607 "result" : "invalid",
608 "sig" : "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc6325560000000000000000000000000000000000000000000000000000000000000001",
609 "tcId" : 68
610 }
611 ]
612 },
613 {
614 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200044a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e53e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0",
615 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAESgPvn5LrJoyvpgEHJImlY4D6DcQx\ncddxKBOzoZoeteU+IT4opgjOmi9KF/2DDGZUAYp5s+AmPZGoupBiLfby8A==\n-----END PUBLIC KEY-----",
616 "sha" : "SHA-256",
617 "type" : "ECDSAVer",
618 "jwk" : {
619 "crv" : "P-256",
620 "kid" : "none",
621 "kty" : "EC",
622 "x" : "SgPvn5LrJoyvpgEHJImlY4D6DcQxcddxKBOzoZoeteU",
623 "y" : "PiE-KKYIzpovShf9gwxmVAGKebPgJj2RqLqQYi328vA"
624 },
625 "key" : {
626 "curve" : "secp256r1",
627 "keySize" : 256,
628 "type" : "ECPublicKey",
629 "wx" : "4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e5",
630 "wy" : "3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0"
631 },
632 "tests" : [
633 {
634 "comment" : "s is larger than n",
635 "message" : "54657374",
636 "result" : "invalid",
637 "sig" : "0000000000000000000000000000000000000000000000000000000000000005ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552",
638 "tcId" : 69
639 }
640 ]
641 },
642 {
643 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200040203736fcb198b15d8d7a0c80f66dddd15259240aa78d08aae67c467de04503434383438d5041ea9a387ee8e4d4e84b4471b160c6bcf2568b072f8f20e87a996",
644 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAgNzb8sZixXY16DID2bd3RUlkkCq\neNCKrmfEZ94EUDQ0ODQ41QQeqaOH7o5NToS0RxsWDGvPJWiwcvjyDoeplg==\n-----END PUBLIC KEY-----",
645 "sha" : "SHA-256",
646 "type" : "ECDSAVer",
647 "jwk" : {
648 "crv" : "P-256",
649 "kid" : "none",
650 "kty" : "EC",
651 "x" : "AgNzb8sZixXY16DID2bd3RUlkkCqeNCKrmfEZ94EUDQ",
652 "y" : "NDg0ONUEHqmjh-6OTU6EtEcbFgxrzyVosHL48g6HqZY"
653 },
654 "key" : {
655 "curve" : "secp256r1",
656 "keySize" : 256,
657 "type" : "ECPublicKey",
658 "wx" : "203736fcb198b15d8d7a0c80f66dddd15259240aa78d08aae67c467de045034",
659 "wy" : "34383438d5041ea9a387ee8e4d4e84b4471b160c6bcf2568b072f8f20e87a996"
660 },
661 "tests" : [
662 {
663 "comment" : "point at infinity during verify",
664 "message" : "54657374",
665 "result" : "invalid",
666 "sig" : "7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3192a8555555550000000055555555555555553ef7a8e48d07df81a693439654210c70",
667 "tcId" : 70
668 }
669 ]
670 },
671 {
672 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004a17f5b75a35ed64623ca5cbf1f91951292db0c23f0c2ea24c3d0cad0988cabc083a7a618625c228940730b4fa3ee64faecbb2fc20fdde7c58b3a3f6300424dc6",
673 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoX9bdaNe1kYjyly/H5GVEpLbDCPw\nwuokw9DK0JiMq8CDp6YYYlwiiUBzC0+j7mT67Lsvwg/d58WLOj9jAEJNxg==\n-----END PUBLIC KEY-----",
674 "sha" : "SHA-256",
675 "type" : "ECDSAVer",
676 "jwk" : {
677 "crv" : "P-256",
678 "kid" : "none",
679 "kty" : "EC",
680 "x" : "oX9bdaNe1kYjyly_H5GVEpLbDCPwwuokw9DK0JiMq8A",
681 "y" : "g6emGGJcIolAcwtPo-5k-uy7L8IP3efFizo_YwBCTcY"
682 },
683 "key" : {
684 "curve" : "secp256r1",
685 "keySize" : 256,
686 "type" : "ECPublicKey",
687 "wx" : "0a17f5b75a35ed64623ca5cbf1f91951292db0c23f0c2ea24c3d0cad0988cabc0",
688 "wy" : "083a7a618625c228940730b4fa3ee64faecbb2fc20fdde7c58b3a3f6300424dc6"
689 },
690 "tests" : [
691 {
692 "comment" : "u1 == 1",
693 "message" : "54657374",
694 "result" : "valid",
695 "sig" : "555555550000000055555555555555553ef7a8e48d07df81a693439654210c70532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
696 "tcId" : 71
697 }
698 ]
699 },
700 {
701 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d0301070342000404ba0cba291a37db13f33bf90dab628c04ec8393a0200419e9eaa1ebcc9fb5c31f3a0a0e6823a49b625ad57b12a32d4047970fc3428f0f0049ecf4265dc12f62",
702 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBLoMuikaN9sT8zv5DatijATsg5Og\nIAQZ6eqh68yftcMfOgoOaCOkm2Ja1XsSoy1AR5cPw0KPDwBJ7PQmXcEvYg==\n-----END PUBLIC KEY-----",
703 "sha" : "SHA-256",
704 "type" : "ECDSAVer",
705 "jwk" : {
706 "crv" : "P-256",
707 "kid" : "none",
708 "kty" : "EC",
709 "x" : "BLoMuikaN9sT8zv5DatijATsg5OgIAQZ6eqh68yftcM",
710 "y" : "HzoKDmgjpJtiWtV7EqMtQEeXD8NCjw8ASez0Jl3BL2I"
711 },
712 "key" : {
713 "curve" : "secp256r1",
714 "keySize" : 256,
715 "type" : "ECPublicKey",
716 "wx" : "4ba0cba291a37db13f33bf90dab628c04ec8393a0200419e9eaa1ebcc9fb5c3",
717 "wy" : "1f3a0a0e6823a49b625ad57b12a32d4047970fc3428f0f0049ecf4265dc12f62"
718 },
719 "tests" : [
720 {
721 "comment" : "u1 == n - 1",
722 "message" : "54657374",
723 "result" : "valid",
724 "sig" : "555555550000000055555555555555553ef7a8e48d07df81a693439654210c70acd155416a8b77f34089464733ff7cd39c400e9c69af7beb9eac5054ed2ec72c",
725 "tcId" : 72
726 }
727 ]
728 },
729 {
730 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d03010703420004692b6c828e0feed63d8aeaa2b7322f9ccbe8723a1ed39f229f204a434b8900efa1f6f6abcb38ea3b8fde38b98c7c271f274af56a8c5628dc3329069ae4dd5716",
731 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaStsgo4P7tY9iuqitzIvnMvocjoe\n058inyBKQ0uJAO+h9varyzjqO4/eOLmMfCcfJ0r1aoxWKNwzKQaa5N1XFg==\n-----END PUBLIC KEY-----",
732 "sha" : "SHA-256",
733 "type" : "ECDSAVer",
734 "jwk" : {
735 "crv" : "P-256",
736 "kid" : "none",
737 "kty" : "EC",
738 "x" : "aStsgo4P7tY9iuqitzIvnMvocjoe058inyBKQ0uJAO8",
739 "y" : "ofb2q8s46juP3ji5jHwnHydK9WqMVijcMykGmuTdVxY"
740 },
741 "key" : {
742 "curve" : "secp256r1",
743 "keySize" : 256,
744 "type" : "ECPublicKey",
745 "wx" : "692b6c828e0feed63d8aeaa2b7322f9ccbe8723a1ed39f229f204a434b8900ef",
746 "wy" : "0a1f6f6abcb38ea3b8fde38b98c7c271f274af56a8c5628dc3329069ae4dd5716"
747 },
748 "tests" : [
749 {
750 "comment" : "u2 == 1",
751 "message" : "54657374",
752 "result" : "valid",
753 "sig" : "555555550000000055555555555555553ef7a8e48d07df81a693439654210c70555555550000000055555555555555553ef7a8e48d07df81a693439654210c70",
754 "tcId" : 73
755 }
756 ]
757 },
758 {
759 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d0301070342000400cefd9162d13e64cb93687a9cd8f9755ebb5a3ef7632f800f84871874ccef09543ecbeaf7e8044ef721be2fb5f549e4b8480d2587404ebf7dbbef2c54bc0cb1",
760 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAM79kWLRPmTLk2h6nNj5dV67Wj73\nYy+AD4SHGHTM7wlUPsvq9+gETvchvi+19UnkuEgNJYdATr99u+8sVLwMsQ==\n-----END PUBLIC KEY-----",
761 "sha" : "SHA-256",
762 "type" : "ECDSAVer",
763 "jwk" : {
764 "crv" : "P-256",
765 "kid" : "none",
766 "kty" : "EC",
767 "x" : "AM79kWLRPmTLk2h6nNj5dV67Wj73Yy-AD4SHGHTM7wk",
768 "y" : "VD7L6vfoBE73Ib4vtfVJ5LhIDSWHQE6_fbvvLFS8DLE"
769 },
770 "key" : {
771 "curve" : "secp256r1",
772 "keySize" : 256,
773 "type" : "ECPublicKey",
774 "wx" : "0cefd9162d13e64cb93687a9cd8f9755ebb5a3ef7632f800f84871874ccef09",
775 "wy" : "543ecbeaf7e8044ef721be2fb5f549e4b8480d2587404ebf7dbbef2c54bc0cb1"
776 },
777 "tests" : [
778 {
779 "comment" : "u2 == n - 1",
780 "message" : "54657374",
781 "result" : "valid",
782 "sig" : "555555550000000055555555555555553ef7a8e48d07df81a693439654210c70aaaaaaaa00000000aaaaaaaaaaaaaaaa7def51c91a0fbf034d26872ca84218e1",
783 "tcId" : 74
784 }
785 ]
786 },
787 {
788 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200040158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237e2a964fc00d377a8592b8b61aafa7a4aaa7c7b9fd2b41d6e0e17bd1ba5677edcd",
789 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAVgTd1W5AfeXqQ1MqIh+Ajyy72Oy\nuiwNRV7a70LPI34qlk/ADTd6hZK4thqvp6Sqp8e5/StB1uDhe9G6VnftzQ==\n-----END PUBLIC KEY-----",
790 "sha" : "SHA-256",
791 "type" : "ECDSAVer",
792 "jwk" : {
793 "crv" : "P-256",
794 "kid" : "none",
795 "kty" : "EC",
796 "x" : "AVgTd1W5AfeXqQ1MqIh-Ajyy72OyuiwNRV7a70LPI34",
797 "y" : "KpZPwA03eoWSuLYar6ekqqfHuf0rQdbg4XvRulZ37c0"
798 },
799 "key" : {
800 "curve" : "secp256r1",
801 "keySize" : 256,
802 "type" : "ECPublicKey",
803 "wx" : "158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237e",
804 "wy" : "2a964fc00d377a8592b8b61aafa7a4aaa7c7b9fd2b41d6e0e17bd1ba5677edcd"
805 },
806 "tests" : [
807 {
808 "comment" : "weak key",
809 "message" : "54657374",
810 "result" : "valid",
811 "sig" : "6f2347cab7dd76858fe0555ac3bc99048c4aacafdfb6bcbe05ea6c42c4934569f21d907e3890916dc4fa1f4703c1e50d3f54ddf7383e44023a41de562aa18ed8",
812 "tcId" : 75
813 }
814 ]
815 },
816 {
817 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d030107034200040158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237ed569b03ef2c8857b6d4749e550585b5558384603d4be291f1e842e45a9881232",
818 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAVgTd1W5AfeXqQ1MqIh+Ajyy72Oy\nuiwNRV7a70LPI37VabA+8siFe21HSeVQWFtVWDhGA9S+KR8ehC5FqYgSMg==\n-----END PUBLIC KEY-----",
819 "sha" : "SHA-256",
820 "type" : "ECDSAVer",
821 "jwk" : {
822 "crv" : "P-256",
823 "kid" : "none",
824 "kty" : "EC",
825 "x" : "AVgTd1W5AfeXqQ1MqIh-Ajyy72OyuiwNRV7a70LPI34",
826 "y" : "1WmwPvLIhXttR0nlUFhbVVg4RgPUvikfHoQuRamIEjI"
827 },
828 "key" : {
829 "curve" : "secp256r1",
830 "keySize" : 256,
831 "type" : "ECPublicKey",
832 "wx" : "158137755b901f797a90d4ca8887e023cb2ef63b2ba2c0d455edaef42cf237e",
833 "wy" : "0d569b03ef2c8857b6d4749e550585b5558384603d4be291f1e842e45a9881232"
834 },
835 "tests" : [
836 {
837 "comment" : "duplication bug",
838 "message" : "54657374",
839 "result" : "invalid",
840 "sig" : "6f2347cab7dd76858fe0555ac3bc99048c4aacafdfb6bcbe05ea6c42c4934569f21d907e3890916dc4fa1f4703c1e50d3f54ddf7383e44023a41de562aa18ed8",
841 "tcId" : 76
842 }
843 ]
844 },
845 {
846 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004011d2fc994df204b63f05ae8420ca390559b80c4988ef639b95c469e5cb24cf216540cbebc470bcaa0466612dbde6d03098c6996e0a05f02902183ceba4b530f4f3500a99e4cdc8a50c0d98d870944e56548dc4cf6bbbf3d6978efbc8fc8778b33e132d2c185c20844cf3df394d522259317e3931f0130f23f6500c880f3a8319ab44a0e",
847 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBHS/JlN8gS2PwWuhCDKOQVZuAxJiO\n9jm5XEaeXLJM8hZUDL68RwvKoEZmEtvebQMJjGmW4KBfApAhg866S1MPTzUAqZ5M\n3IpQwNmNhwlE5WVI3Ez2u789aXjvvI/Id4sz4TLSwYXCCETPPfOU1SIlkxfjkx8B\nMPI/ZQDIgPOoMZq0Sg4=\n-----END PUBLIC KEY-----",
848 "sha" : "SHA-512",
849 "type" : "ECDSAVer",
850 "jwk" : {
851 "crv" : "P-521",
852 "kid" : "none",
853 "kty" : "EC",
854 "x" : "AR0vyZTfIEtj8FroQgyjkFWbgMSYjvY5uVxGnlyyTPIWVAy-vEcLyqBGZhLb3m0DCYxpluCgXwKQIYPOuktTD081",
855 "y" : "AKmeTNyKUMDZjYcJROVlSNxM9ru_PWl477yPyHeLM-Ey0sGFwghEzz3zlNUiJZMX45MfATDyP2UAyIDzqDGatEoO"
856 },
857 "key" : {
858 "curve" : "secp521r1",
859 "keySize" : 521,
860 "type" : "ECPublicKey",
861 "wx" : "11d2fc994df204b63f05ae8420ca390559b80c4988ef639b95c469e5cb24cf216540cbebc470bcaa0466612dbde6d03098c6996e0a05f02902183ceba4b530f4f35",
862 "wy" : "0a99e4cdc8a50c0d98d870944e56548dc4cf6bbbf3d6978efbc8fc8778b33e132d2c185c20844cf3df394d522259317e3931f0130f23f6500c880f3a8319ab44a0e"
863 },
864 "tests" : [
865 {
866 "comment" : "k*G has a large x-coordinate",
867 "message" : "54657374",
868 "result" : "valid",
869 "sig" : "00000000000000000000000000000000000000000000000000000000000000000005ae79787c40d069948033feb708f65a2fc44a36477663b851449048e16ec79bf501fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386406",
870 "tcId" : 77
871 }
872 ]
873 },
874 {
875 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004011d2fc994df204b63f05ae8420ca390559b80c4988ef639b95c469e5cb24cf216540cbebc470bcaa0466612dbde6d03098c6996e0a05f02902183ceba4b530f4f3500a99e4cdc8a50c0d98d870944e56548dc4cf6bbbf3d6978efbc8fc8778b33e132d2c185c20844cf3df394d522259317e3931f0130f23f6500c880f3a8319ab44a0e",
876 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBHS/JlN8gS2PwWuhCDKOQVZuAxJiO\n9jm5XEaeXLJM8hZUDL68RwvKoEZmEtvebQMJjGmW4KBfApAhg866S1MPTzUAqZ5M\n3IpQwNmNhwlE5WVI3Ez2u789aXjvvI/Id4sz4TLSwYXCCETPPfOU1SIlkxfjkx8B\nMPI/ZQDIgPOoMZq0Sg4=\n-----END PUBLIC KEY-----",
877 "sha" : "SHA-512",
878 "type" : "ECDSAVer",
879 "jwk" : {
880 "crv" : "P-521",
881 "kid" : "none",
882 "kty" : "EC",
883 "x" : "AR0vyZTfIEtj8FroQgyjkFWbgMSYjvY5uVxGnlyyTPIWVAy-vEcLyqBGZhLb3m0DCYxpluCgXwKQIYPOuktTD081",
884 "y" : "AKmeTNyKUMDZjYcJROVlSNxM9ru_PWl477yPyHeLM-Ey0sGFwghEzz3zlNUiJZMX45MfATDyP2UAyIDzqDGatEoO"
885 },
886 "key" : {
887 "curve" : "secp521r1",
888 "keySize" : 521,
889 "type" : "ECPublicKey",
890 "wx" : "11d2fc994df204b63f05ae8420ca390559b80c4988ef639b95c469e5cb24cf216540cbebc470bcaa0466612dbde6d03098c6996e0a05f02902183ceba4b530f4f35",
891 "wy" : "0a99e4cdc8a50c0d98d870944e56548dc4cf6bbbf3d6978efbc8fc8778b33e132d2c185c20844cf3df394d522259317e3931f0130f23f6500c880f3a8319ab44a0e"
892 },
893 "tests" : [
894 {
895 "comment" : "r too large",
896 "message" : "54657374",
897 "result" : "invalid",
898 "sig" : "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386406",
899 "tcId" : 78
900 }
901 ]
902 },
903 {
904 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004019a029c77fed04cab1ab8937fda8128fc19bf8c41a8f242f6a9ca6f0ae813c1709b8b03e26a9298fe59f99e3706ffc28c43d26a11690d2ffd815a33ea329076697800125b2a4b635f514fd5d63215672f311ae5935c1774ed5d8a44897b68191e6369ab26df915e2066a943e59a3577319dac5a86640bc8c718d2b159479fdd22d11441",
905 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBmgKcd/7QTKsauJN/2oEo/Bm/jEGo\n8kL2qcpvCugTwXCbiwPiapKY/ln5njcG/8KMQ9JqEWkNL/2BWjPqMpB2aXgAElsq\nS2NfUU/V1jIVZy8xGuWTXBd07V2KRIl7aBkeY2mrJt+RXiBmqUPlmjV3MZ2sWoZk\nC8jHGNKxWUef3SLRFEE=\n-----END PUBLIC KEY-----",
906 "sha" : "SHA-512",
907 "type" : "ECDSAVer",
908 "jwk" : {
909 "crv" : "P-521",
910 "kid" : "none",
911 "kty" : "EC",
912 "x" : "AZoCnHf-0EyrGriTf9qBKPwZv4xBqPJC9qnKbwroE8Fwm4sD4mqSmP5Z-Z43Bv_CjEPSahFpDS_9gVoz6jKQdml4",
913 "y" : "ABJbKktjX1FP1dYyFWcvMRrlk1wXdO1dikSJe2gZHmNpqybfkV4gZqlD5Zo1dzGdrFqGZAvIxxjSsVlHn90i0RRB"
914 },
915 "key" : {
916 "curve" : "secp521r1",
917 "keySize" : 521,
918 "type" : "ECPublicKey",
919 "wx" : "19a029c77fed04cab1ab8937fda8128fc19bf8c41a8f242f6a9ca6f0ae813c1709b8b03e26a9298fe59f99e3706ffc28c43d26a11690d2ffd815a33ea3290766978",
920 "wy" : "125b2a4b635f514fd5d63215672f311ae5935c1774ed5d8a44897b68191e6369ab26df915e2066a943e59a3577319dac5a86640bc8c718d2b159479fdd22d11441"
921 },
922 "tests" : [
923 {
924 "comment" : "r,s are large",
925 "message" : "54657374",
926 "result" : "valid",
927 "sig" : "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e9138640701fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386406",
928 "tcId" : 79
929 }
930 ]
931 },
932 {
933 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004005f5059308349f9ebbb4d1c55c0afccf62162ec1dd12ef3ed906656924ffd99cab9f06b0eb218cff078a4677a5ce1cc07652bc976aefc732c28f67ef078a434e99900a5d14df310630d76ec03cb6f9b95bf1a22438105c88cd9fd3dac80f857add38271d8ba901684b26d436d4a859ad4cda5e9677b73cab3f3e5e41a3d7996607279ab",
934 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAX1BZMINJ+eu7TRxVwK/M9iFi7B3R\nLvPtkGZWkk/9mcq58GsOshjP8HikZ3pc4cwHZSvJdq78cywo9n7weKQ06ZkApdFN\n8xBjDXbsA8tvm5W/GiJDgQXIjNn9PayA+Fet04Jx2LqQFoSybUNtSoWa1M2l6Wd7\nc8qz8+XkGj15lmByeas=\n-----END PUBLIC KEY-----",
935 "sha" : "SHA-512",
936 "type" : "ECDSAVer",
937 "jwk" : {
938 "crv" : "P-521",
939 "kid" : "none",
940 "kty" : "EC",
941 "x" : "AF9QWTCDSfnru00cVcCvzPYhYuwd0S7z7ZBmVpJP_ZnKufBrDrIYz_B4pGd6XOHMB2UryXau_HMsKPZ-8HikNOmZ",
942 "y" : "AKXRTfMQYw127APLb5uVvxoiQ4EFyIzZ_T2sgPhXrdOCcdi6kBaEsm1DbUqFmtTNpelne3PKs_Pl5Bo9eZZgcnmr"
943 },
944 "key" : {
945 "curve" : "secp521r1",
946 "keySize" : 521,
947 "type" : "ECPublicKey",
948 "wx" : "5f5059308349f9ebbb4d1c55c0afccf62162ec1dd12ef3ed906656924ffd99cab9f06b0eb218cff078a4677a5ce1cc07652bc976aefc732c28f67ef078a434e999",
949 "wy" : "0a5d14df310630d76ec03cb6f9b95bf1a22438105c88cd9fd3dac80f857add38271d8ba901684b26d436d4a859ad4cda5e9677b73cab3f3e5e41a3d7996607279ab"
950 },
951 "tests" : [
952 {
953 "comment" : "small r and s",
954 "message" : "54657374",
955 "result" : "valid",
956 "sig" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
957 "tcId" : 80
958 },
959 {
960 "comment" : "incorrect size of signature",
961 "message" : "54657374",
962 "result" : "acceptable",
963 "sig" : "0101",
964 "tcId" : 81
965 }
966 ]
967 },
968 {
969 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004005f5059308349f9ebbb4d1c55c0afccf62162ec1dd12ef3ed906656924ffd99cab9f06b0eb218cff078a4677a5ce1cc07652bc976aefc732c28f67ef078a434e99900a5d14df310630d76ec03cb6f9b95bf1a22438105c88cd9fd3dac80f857add38271d8ba901684b26d436d4a859ad4cda5e9677b73cab3f3e5e41a3d7996607279ab",
970 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAX1BZMINJ+eu7TRxVwK/M9iFi7B3R\nLvPtkGZWkk/9mcq58GsOshjP8HikZ3pc4cwHZSvJdq78cywo9n7weKQ06ZkApdFN\n8xBjDXbsA8tvm5W/GiJDgQXIjNn9PayA+Fet04Jx2LqQFoSybUNtSoWa1M2l6Wd7\nc8qz8+XkGj15lmByeas=\n-----END PUBLIC KEY-----",
971 "sha" : "SHA-512",
972 "type" : "ECDSAVer",
973 "jwk" : {
974 "crv" : "P-521",
975 "kid" : "none",
976 "kty" : "EC",
977 "x" : "AF9QWTCDSfnru00cVcCvzPYhYuwd0S7z7ZBmVpJP_ZnKufBrDrIYz_B4pGd6XOHMB2UryXau_HMsKPZ-8HikNOmZ",
978 "y" : "AKXRTfMQYw127APLb5uVvxoiQ4EFyIzZ_T2sgPhXrdOCcdi6kBaEsm1DbUqFmtTNpelne3PKs_Pl5Bo9eZZgcnmr"
979 },
980 "key" : {
981 "curve" : "secp521r1",
982 "keySize" : 521,
983 "type" : "ECPublicKey",
984 "wx" : "5f5059308349f9ebbb4d1c55c0afccf62162ec1dd12ef3ed906656924ffd99cab9f06b0eb218cff078a4677a5ce1cc07652bc976aefc732c28f67ef078a434e999",
985 "wy" : "0a5d14df310630d76ec03cb6f9b95bf1a22438105c88cd9fd3dac80f857add38271d8ba901684b26d436d4a859ad4cda5e9677b73cab3f3e5e41a3d7996607279ab"
986 },
987 "tests" : [
988 {
989 "comment" : "r is larger than n",
990 "message" : "54657374",
991 "result" : "invalid",
992 "sig" : "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e9138640a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
993 "tcId" : 82
994 }
995 ]
996 },
997 {
998 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004005f5059308349f9ebbb4d1c55c0afccf62162ec1dd12ef3ed906656924ffd99cab9f06b0eb218cff078a4677a5ce1cc07652bc976aefc732c28f67ef078a434e99900a5d14df310630d76ec03cb6f9b95bf1a22438105c88cd9fd3dac80f857add38271d8ba901684b26d436d4a859ad4cda5e9677b73cab3f3e5e41a3d7996607279ab",
999 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAX1BZMINJ+eu7TRxVwK/M9iFi7B3R\nLvPtkGZWkk/9mcq58GsOshjP8HikZ3pc4cwHZSvJdq78cywo9n7weKQ06ZkApdFN\n8xBjDXbsA8tvm5W/GiJDgQXIjNn9PayA+Fet04Jx2LqQFoSybUNtSoWa1M2l6Wd7\nc8qz8+XkGj15lmByeas=\n-----END PUBLIC KEY-----",
1000 "sha" : "SHA-512",
1001 "type" : "ECDSAVer",
1002 "jwk" : {
1003 "crv" : "P-521",
1004 "kid" : "none",
1005 "kty" : "EC",
1006 "x" : "AF9QWTCDSfnru00cVcCvzPYhYuwd0S7z7ZBmVpJP_ZnKufBrDrIYz_B4pGd6XOHMB2UryXau_HMsKPZ-8HikNOmZ",
1007 "y" : "AKXRTfMQYw127APLb5uVvxoiQ4EFyIzZ_T2sgPhXrdOCcdi6kBaEsm1DbUqFmtTNpelne3PKs_Pl5Bo9eZZgcnmr"
1008 },
1009 "key" : {
1010 "curve" : "secp521r1",
1011 "keySize" : 521,
1012 "type" : "ECPublicKey",
1013 "wx" : "5f5059308349f9ebbb4d1c55c0afccf62162ec1dd12ef3ed906656924ffd99cab9f06b0eb218cff078a4677a5ce1cc07652bc976aefc732c28f67ef078a434e999",
1014 "wy" : "0a5d14df310630d76ec03cb6f9b95bf1a22438105c88cd9fd3dac80f857add38271d8ba901684b26d436d4a859ad4cda5e9677b73cab3f3e5e41a3d7996607279ab"
1015 },
1016 "tests" : [
1017 {
1018 "comment" : "s is larger than n",
1019 "message" : "54657374",
1020 "result" : "invalid",
1021 "sig" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e9138640a",
1022 "tcId" : 83
1023 }
1024 ]
1025 },
1026 {
1027 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004013b73be0ec4f18b36fdc20aac9675580a20cc725ed0de6fea63ab6111b4aaecc69b1fdf05bb1c7a71c4b7a5a1eaaff23be15604f405b5ecd3b3ed6afea8e49cd64900912180c981f480d2b8b7438988b03a0c5efdbd2da094f082f7fa57ecc41fde8c65d3c9d80f34f9124e151da55d96d2a9b991672de79449bcc1c0192b7650ae90b7",
1028 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBO3O+DsTxizb9wgqslnVYCiDMcl7Q\n3m/qY6thEbSq7MabH98Fuxx6ccS3paHqr/I74VYE9AW17NOz7Wr+qOSc1kkAkSGA\nyYH0gNK4t0OJiLA6DF79vS2glPCC9/pX7MQf3oxl08nYDzT5Ek4VHaVdltKpuZFn\nLeeUSbzBwBkrdlCukLc=\n-----END PUBLIC KEY-----",
1029 "sha" : "SHA-512",
1030 "type" : "ECDSAVer",
1031 "jwk" : {
1032 "crv" : "P-521",
1033 "kid" : "none",
1034 "kty" : "EC",
1035 "x" : "ATtzvg7E8Ys2_cIKrJZ1WAogzHJe0N5v6mOrYRG0quzGmx_fBbscenHEt6Wh6q_yO-FWBPQFtezTs-1q_qjknNZJ",
1036 "y" : "AJEhgMmB9IDSuLdDiYiwOgxe_b0toJTwgvf6V-zEH96MZdPJ2A80-RJOFR2lXZbSqbmRZy3nlEm8wcAZK3ZQrpC3"
1037 },
1038 "key" : {
1039 "curve" : "secp521r1",
1040 "keySize" : 521,
1041 "type" : "ECPublicKey",
1042 "wx" : "13b73be0ec4f18b36fdc20aac9675580a20cc725ed0de6fea63ab6111b4aaecc69b1fdf05bb1c7a71c4b7a5a1eaaff23be15604f405b5ecd3b3ed6afea8e49cd649",
1043 "wy" : "0912180c981f480d2b8b7438988b03a0c5efdbd2da094f082f7fa57ecc41fde8c65d3c9d80f34f9124e151da55d96d2a9b991672de79449bcc1c0192b7650ae90b7"
1044 },
1045 "tests" : [
1046 {
1047 "comment" : "point at infinity during verify",
1048 "message" : "54657374",
1049 "result" : "invalid",
1050 "sig" : "00fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd28c343c1df97cb35bfe600a47b84d2e81ddae4dc44ce23d75db7db8f489c320400aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8c5d782813fba87792a9955c2fd033745693c9892d8896d3a3e7a925f85bd76ad",
1051 "tcId" : 84
1052 }
1053 ]
1054 },
1055 {
1056 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000401c01eab9ba6ddd21e33421034acd6ac923a409fab349e0380bfaa54b404890086a5e12fb09e1352712cfde15abc2563079a73d333c9c79c670fb06b5d802aa9b77600a76a28d03f657c61bf87ff78e7733a069556d2bd638b79316ab70b5a2809bc8a98a2a843238d4abe2698b2aa6aede1b2541bf3dcd007cf9cd5c4d4969c4f7ffccb",
1057 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBwB6rm6bd0h4zQhA0rNaskjpAn6s0\nngOAv6pUtASJAIal4S+wnhNScSz94Vq8JWMHmnPTM8nHnGcPsGtdgCqpt3YAp2oo\n0D9lfGG/h/9453M6BpVW0r1ji3kxarcLWigJvIqYoqhDI41KviaYsqpq7eGyVBvz\n3NAHz5zVxNSWnE9//Ms=\n-----END PUBLIC KEY-----",
1058 "sha" : "SHA-512",
1059 "type" : "ECDSAVer",
1060 "jwk" : {
1061 "crv" : "P-521",
1062 "kid" : "none",
1063 "kty" : "EC",
1064 "x" : "AcAeq5um3dIeM0IQNKzWrJI6QJ-rNJ4DgL-qVLQEiQCGpeEvsJ4TUnEs_eFavCVjB5pz0zPJx5xnD7BrXYAqqbd2",
1065 "y" : "AKdqKNA_ZXxhv4f_eOdzOgaVVtK9Y4t5MWq3C1ooCbyKmKKoQyONSr4mmLKqau3hslQb89zQB8-c1cTUlpxPf_zL"
1066 },
1067 "key" : {
1068 "curve" : "secp521r1",
1069 "keySize" : 521,
1070 "type" : "ECPublicKey",
1071 "wx" : "1c01eab9ba6ddd21e33421034acd6ac923a409fab349e0380bfaa54b404890086a5e12fb09e1352712cfde15abc2563079a73d333c9c79c670fb06b5d802aa9b776",
1072 "wy" : "0a76a28d03f657c61bf87ff78e7733a069556d2bd638b79316ab70b5a2809bc8a98a2a843238d4abe2698b2aa6aede1b2541bf3dcd007cf9cd5c4d4969c4f7ffccb"
1073 },
1074 "tests" : [
1075 {
1076 "comment" : "u1 == 1",
1077 "message" : "54657374",
1078 "result" : "valid",
1079 "sig" : "00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8c5d782813fba87792a9955c2fd033745693c9892d8896d3a3e7a925f85bd76ad0000c6ee9e33cf5c6715a1d148fd73f7318884b41adcb916021e2bc0e800a5c5dd97f5142178f6ae88c8fdd98e1afb0ce4c8d2c54b5f37b30b7da1997bb33b0b8a31",
1080 "tcId" : 85
1081 }
1082 ]
1083 },
1084 {
1085 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000400186365c73588807a51005412db004b45f5f7be3a6074e6119042978dbfbc5a431e16cc930747e6cd7511505b4c9349cedf908a5a9dbd33cdb0aeccbf69454457fb0014620a29a2691d8038d39e1e4de7c4243c8c42601e719945c1297c1a4b10d7415af37bf1ed0ddc9030bce530185dfdfc4658ff635f6bd9660becc8ff9eca4fddfa",
1086 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAGGNlxzWIgHpRAFQS2wBLRfX3vjpg\ndOYRkEKXjb+8WkMeFsyTB0fmzXURUFtMk0nO35CKWp29M82wrsy/aUVEV/sAFGIK\nKaJpHYA4054eTefEJDyMQmAecZlFwSl8GksQ10Fa83vx7Q3ckDC85TAYXf38Rlj/\nY19r2WYL7Mj/nspP3fo=\n-----END PUBLIC KEY-----",
1087 "sha" : "SHA-512",
1088 "type" : "ECDSAVer",
1089 "jwk" : {
1090 "crv" : "P-521",
1091 "kid" : "none",
1092 "kty" : "EC",
1093 "x" : "ABhjZcc1iIB6UQBUEtsAS0X19746YHTmEZBCl42_vFpDHhbMkwdH5s11EVBbTJNJzt-QilqdvTPNsK7Mv2lFRFf7",
1094 "y" : "ABRiCimiaR2AONOeHk3nxCQ8jEJgHnGZRcEpfBpLENdBWvN78e0N3JAwvOUwGF39_EZY_2Nfa9lmC-zI_57KT936"
1095 },
1096 "key" : {
1097 "curve" : "secp521r1",
1098 "keySize" : 521,
1099 "type" : "ECPublicKey",
1100 "wx" : "186365c73588807a51005412db004b45f5f7be3a6074e6119042978dbfbc5a431e16cc930747e6cd7511505b4c9349cedf908a5a9dbd33cdb0aeccbf69454457fb",
1101 "wy" : "14620a29a2691d8038d39e1e4de7c4243c8c42601e719945c1297c1a4b10d7415af37bf1ed0ddc9030bce530185dfdfc4658ff635f6bd9660becc8ff9eca4fddfa"
1102 },
1103 "tests" : [
1104 {
1105 "comment" : "u1 == n - 1",
1106 "message" : "54657374",
1107 "result" : "valid",
1108 "sig" : "00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8c5d782813fba87792a9955c2fd033745693c9892d8896d3a3e7a925f85bd76ad01ff391161cc30a398ea5e2eb7028c08ce777b4be52346e9fde1d43f17ff5a3a22625c72660ac8810da281f2732dfbfcc10768f07e5951e93c3119d63b6b562cd9d8",
1109 "tcId" : 86
1110 }
1111 ]
1112 },
1113 {
1114 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004002e2a746b55e05bc130d374c8abb8bf651a2e2b025404f08545befcb95c9f7f681f6f5b9bf2ebc45d4c8572921d3ab5dce144ea5d50ebec89b8c8f010ea31494863008c816f122d5d63b5fea00d1a00ed23577f7ef7d48f3973568353d468368ec77cbc9e3c5012839b74833087d51ba3e680ab5375be680ea8c18f7b619f32b141f281",
1115 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQALip0a1XgW8Ew03TIq7i/ZRouKwJU\nBPCFRb78uVyff2gfb1ub8uvEXUyFcpIdOrXc4UTqXVDr7Im4yPAQ6jFJSGMAjIFv\nEi1dY7X+oA0aAO0jV39+99SPOXNWg1PUaDaOx3y8njxQEoObdIMwh9Ubo+aAq1N1\nvmgOqMGPe2GfMrFB8oE=\n-----END PUBLIC KEY-----",
1116 "sha" : "SHA-512",
1117 "type" : "ECDSAVer",
1118 "jwk" : {
1119 "crv" : "P-521",
1120 "kid" : "none",
1121 "kty" : "EC",
1122 "x" : "AC4qdGtV4FvBMNN0yKu4v2UaLisCVATwhUW-_Llcn39oH29bm_LrxF1MhXKSHTq13OFE6l1Q6-yJuMjwEOoxSUhj",
1123 "y" : "AIyBbxItXWO1_qANGgDtI1d_fvfUjzlzVoNT1Gg2jsd8vJ48UBKDm3SDMIfVG6PmgKtTdb5oDqjBj3thnzKxQfKB"
1124 },
1125 "key" : {
1126 "curve" : "secp521r1",
1127 "keySize" : 521,
1128 "type" : "ECPublicKey",
1129 "wx" : "2e2a746b55e05bc130d374c8abb8bf651a2e2b025404f08545befcb95c9f7f681f6f5b9bf2ebc45d4c8572921d3ab5dce144ea5d50ebec89b8c8f010ea31494863",
1130 "wy" : "08c816f122d5d63b5fea00d1a00ed23577f7ef7d48f3973568353d468368ec77cbc9e3c5012839b74833087d51ba3e680ab5375be680ea8c18f7b619f32b141f281"
1131 },
1132 "tests" : [
1133 {
1134 "comment" : "u2 == 1",
1135 "message" : "54657374",
1136 "result" : "valid",
1137 "sig" : "00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8c5d782813fba87792a9955c2fd033745693c9892d8896d3a3e7a925f85bd76ad00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8c5d782813fba87792a9955c2fd033745693c9892d8896d3a3e7a925f85bd76ad",
1138 "tcId" : 87
1139 }
1140 ]
1141 },
1142 {
1143 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000400d379f79826b04198df371ab0519d1a7f0a4f199d6149ca8b7f13a5da09cba024fbe7d4ff7fd7a8a93b5cbcaf3c68243f630d47d8f2b652b6a7d6b1c522a75fa9f201c660722d95c83c6b9457944acc671e881e8d17b07362f2f82799456f2f15d662d36aa09d5a5236288d3c1382e3e2308f46867d53c588a370857fae4d32f0a3ddaf",
1144 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA03n3mCawQZjfNxqwUZ0afwpPGZ1h\nScqLfxOl2gnLoCT759T/f9eoqTtcvK88aCQ/Yw1H2PK2Uran1rHFIqdfqfIBxmBy\nLZXIPGuUV5RKzGceiB6NF7BzYvL4J5lFby8V1mLTaqCdWlI2KI08E4Lj4jCPRoZ9\nU8WIo3CFf65NMvCj3a8=\n-----END PUBLIC KEY-----",
1145 "sha" : "SHA-512",
1146 "type" : "ECDSAVer",
1147 "jwk" : {
1148 "crv" : "P-521",
1149 "kid" : "none",
1150 "kty" : "EC",
1151 "x" : "ANN595gmsEGY3zcasFGdGn8KTxmdYUnKi38TpdoJy6Ak--fU_3_XqKk7XLyvPGgkP2MNR9jytlK2p9axxSKnX6ny",
1152 "y" : "AcZgci2VyDxrlFeUSsxnHogejRewc2Ly-CeZRW8vFdZi02qgnVpSNiiNPBOC4-Iwj0aGfVPFiKNwhX-uTTLwo92v"
1153 },
1154 "key" : {
1155 "curve" : "secp521r1",
1156 "keySize" : 521,
1157 "type" : "ECPublicKey",
1158 "wx" : "0d379f79826b04198df371ab0519d1a7f0a4f199d6149ca8b7f13a5da09cba024fbe7d4ff7fd7a8a93b5cbcaf3c68243f630d47d8f2b652b6a7d6b1c522a75fa9f2",
1159 "wy" : "1c660722d95c83c6b9457944acc671e881e8d17b07362f2f82799456f2f15d662d36aa09d5a5236288d3c1382e3e2308f46867d53c588a370857fae4d32f0a3ddaf"
1160 },
1161 "tests" : [
1162 {
1163 "comment" : "u2 == n - 1",
1164 "message" : "54657374",
1165 "result" : "valid",
1166 "sig" : "00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa8c5d782813fba87792a9955c2fd033745693c9892d8896d3a3e7a925f85bd76ad015555555555555555555555555555555555555555555555555555555555555555518baf05027f750ef25532ab85fa066e8ad2793125b112da747cf524bf0b7aed5c",
1167 "tcId" : 88
1168 }
1169 ]
1170 },
1171 {
1172 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000401400fa3bc87482ec1ba75346a129ec8f79456e7d6343b2a6be22490884b8f8b89114c0e5f9558d7627adeae53ff8ce37baf94b99d04f75098ca8e3e77c6be02bc3e01690d770806bde9f4d2760293aba6076066f1762e8448f0d08724ef311ff7596f35e8b6a9346de65bea924b9d30bb972e3b38878172f9040378a0db47299e979856",
1173 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBQA+jvIdILsG6dTRqEp7I95RW59Y0\nOypr4iSQiEuPi4kRTA5flVjXYnrerlP/jON7r5S5nQT3UJjKjj53xr4CvD4BaQ13\nCAa96fTSdgKTq6YHYGbxdi6ESPDQhyTvMR/3WW816LapNG3mW+qSS50wu5cuOziH\ngXL5BAN4oNtHKZ6XmFY=\n-----END PUBLIC KEY-----",
1174 "sha" : "SHA-512",
1175 "type" : "ECDSAVer",
1176 "jwk" : {
1177 "crv" : "P-521",
1178 "kid" : "none",
1179 "kty" : "EC",
1180 "x" : "AUAPo7yHSC7BunU0ahKeyPeUVufWNDsqa-IkkIhLj4uJEUwOX5VY12J63q5T_4zje6-UuZ0E91CYyo4-d8a-Arw-",
1181 "y" : "AWkNdwgGven00nYCk6umB2Bm8XYuhEjw0Ick7zEf91lvNei2qTRt5lvqkkudMLuXLjs4h4Fy-QQDeKDbRymel5hW"
1182 },
1183 "key" : {
1184 "curve" : "secp521r1",
1185 "keySize" : 521,
1186 "type" : "ECPublicKey",
1187 "wx" : "1400fa3bc87482ec1ba75346a129ec8f79456e7d6343b2a6be22490884b8f8b89114c0e5f9558d7627adeae53ff8ce37baf94b99d04f75098ca8e3e77c6be02bc3e",
1188 "wy" : "1690d770806bde9f4d2760293aba6076066f1762e8448f0d08724ef311ff7596f35e8b6a9346de65bea924b9d30bb972e3b38878172f9040378a0db47299e979856"
1189 },
1190 "tests" : [
1191 {
1192 "comment" : "weak key",
1193 "message" : "54657374",
1194 "result" : "valid",
1195 "sig" : "0090c8d0d718cb9d8d81094e6d068fb13c16b4df8c77bac676dddfe3e68855bed06b9ba8d0f8a80edce03a9fac7da561e24b1cd22d459239a146695a671f81f73aaf00a24fbd602ff7012b6b00e9aa1683b45bfa2d62dc768737e8da92cad52f069efbea526acc68096fc0ef9960c6b989bf8922aea38fd463d02c0e7c25e336f32b0874",
1196 "tcId" : 89
1197 }
1198 ]
1199 },
1200 {
1201 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000401400fa3bc87482ec1ba75346a129ec8f79456e7d6343b2a6be22490884b8f8b89114c0e5f9558d7627adeae53ff8ce37baf94b99d04f75098ca8e3e77c6be02bc3e0096f288f7f942160b2d89fd6c5459f89f990e89d17bb70f2f78db10cee008a690ca174956cb9219a4156db462cf4468d1c4c7787e8d06fbfc875f24b8d6616867a9",
1202 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBQA+jvIdILsG6dTRqEp7I95RW59Y0\nOypr4iSQiEuPi4kRTA5flVjXYnrerlP/jON7r5S5nQT3UJjKjj53xr4CvD4AlvKI\n9/lCFgstif1sVFn4n5kOidF7tw8veNsQzuAIppDKF0lWy5IZpBVttGLPRGjRxMd4\nfo0G+/yHXyS41mFoZ6k=\n-----END PUBLIC KEY-----",
1203 "sha" : "SHA-512",
1204 "type" : "ECDSAVer",
1205 "jwk" : {
1206 "crv" : "P-521",
1207 "kid" : "none",
1208 "kty" : "EC",
1209 "x" : "AUAPo7yHSC7BunU0ahKeyPeUVufWNDsqa-IkkIhLj4uJEUwOX5VY12J63q5T_4zje6-UuZ0E91CYyo4-d8a-Arw-",
1210 "y" : "AJbyiPf5QhYLLYn9bFRZ-J-ZDonRe7cPL3jbEM7gCKaQyhdJVsuSGaQVbbRiz0Ro0cTHeH6NBvv8h18kuNZhaGep"
1211 },
1212 "key" : {
1213 "curve" : "secp521r1",
1214 "keySize" : 521,
1215 "type" : "ECPublicKey",
1216 "wx" : "1400fa3bc87482ec1ba75346a129ec8f79456e7d6343b2a6be22490884b8f8b89114c0e5f9558d7627adeae53ff8ce37baf94b99d04f75098ca8e3e77c6be02bc3e",
1217 "wy" : "096f288f7f942160b2d89fd6c5459f89f990e89d17bb70f2f78db10cee008a690ca174956cb9219a4156db462cf4468d1c4c7787e8d06fbfc875f24b8d6616867a9"
1218 },
1219 "tests" : [
1220 {
1221 "comment" : "duplication bug",
1222 "message" : "54657374",
1223 "result" : "invalid",
1224 "sig" : "0090c8d0d718cb9d8d81094e6d068fb13c16b4df8c77bac676dddfe3e68855bed06b9ba8d0f8a80edce03a9fac7da561e24b1cd22d459239a146695a671f81f73aaf00a24fbd602ff7012b6b00e9aa1683b45bfa2d62dc768737e8da92cad52f069efbea526acc68096fc0ef9960c6b989bf8922aea38fd463d02c0e7c25e336f32b0874",
1225 "tcId" : 90
1226 }
1227 ]
1228 },
1229 {
1230 "keyDer" : "3059301306072a8648ce3d020106082a8648ce3d0301070342000482efed52b9053723f669085c5aae160e7b995362aadfb715224c3b75c78c39ede4f52fd89da37fae31b852ce0f5ef5897dfc79de579435a938e1e723a2f4df06",
1231 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgu/tUrkFNyP2aQhcWq4WDnuZU2Kq\n37cVIkw7dceMOe3k9S/YnaN/rjG4Us4PXvWJffx53leUNak44ecjovTfBg==\n-----END PUBLIC KEY-----",
1232 "sha" : "SHA-256",
1233 "type" : "ECDSAVer",
1234 "jwk" : {
1235 "crv" : "P-256",
1236 "kid" : "none",
1237 "kty" : "EC",
1238 "x" : "gu_tUrkFNyP2aQhcWq4WDnuZU2Kq37cVIkw7dceMOe0",
1239 "y" : "5PUv2J2jf64xuFLOD171iX38ed5XlDWpOOHnI6L03wY"
1240 },
1241 "key" : {
1242 "curve" : "secp256r1",
1243 "keySize" : 256,
1244 "type" : "ECPublicKey",
1245 "wx" : "082efed52b9053723f669085c5aae160e7b995362aadfb715224c3b75c78c39ed",
1246 "wy" : "0e4f52fd89da37fae31b852ce0f5ef5897dfc79de579435a938e1e723a2f4df06"
1247 },
1248 "tests" : [
1249 {
1250 "comment" : "random signature",
1251 "message" : "00000000000000000000000000000000",
1252 "result" : "valid",
1253 "sig" : "1e63913374b3ead80d4b27bfdf7a50eb063c39bc585ea43cbd12f9dce3071a44a7bbd74b1eac2c54fccec9a3523ca29c95b7ace517ab2b0f4995d220481ce326",
1254 "tcId" : 91
1255 },
1256 {
1257 "comment" : "random signature",
1258 "message" : "00000000000000000000000000000000",
1259 "result" : "valid",
1260 "sig" : "e3f4fced8145c2ad8da913d8e15ba196f10a85d44a320c94a09cb194aea8ef1883afe416680a2c0cc915753ec869d9f2117256abecf234164613722bd7a8cb7c",
1261 "tcId" : 92
1262 },
1263 {
1264 "comment" : "random signature",
1265 "message" : "00000000000000000000000000000000",
1266 "result" : "valid",
1267 "sig" : "9f30cc8eafbeacc166a1af87664bef8b2add9c1988841f5de200feaaee1393fdd986454e46e388e11d6d3fb10d7eea364b814751975327401ad124951dbdda45",
1268 "tcId" : 93
1269 },
1270 {
1271 "comment" : "random signature",
1272 "message" : "00000000000000000000000000000000",
1273 "result" : "valid",
1274 "sig" : "67e8a0b9ba82d0c4e1ad9fad1592a179c6dac964215c8a519863141e053f55dd6c41d1be827bb6b5658ccf8c0ff16d87f3ce16d62a7641b64a107191d6531ad7",
1275 "tcId" : 94
1276 },
1277 {
1278 "comment" : "random signature",
1279 "message" : "00000000000000000000000000000000",
1280 "result" : "valid",
1281 "sig" : "9963a72f589bcf7d4a561f8b0bed9af6e5a1309a1f5ab1791ce179d68478fe905c6870382a1ea973a84f85d8365b8d6e67527a5bdc9b80526a28968e7884758c",
1282 "tcId" : 95
1283 },
1284 {
1285 "comment" : "random signature",
1286 "message" : "00000000000000000000000000000000",
1287 "result" : "valid",
1288 "sig" : "74a6f79b92039e101a3a45ad6287d16a05107d07899ec858eade5d51b7b5f61d79f33dc00dbed4edb967eda02768731b4dc5bffe6764e7258b2d7bbf223947c6",
1289 "tcId" : 96
1290 },
1291 {
1292 "comment" : "random signature",
1293 "message" : "00000000000000000000000000000000",
1294 "result" : "valid",
1295 "sig" : "5a5599a21beec4979655e89a77ab145566296f71095c457a40ef52efd98c4bd5cb7b8beff27c7bb66c5ed2aad94b7e204c4c0a4748d1f35aff4b6eeb25236e4b",
1296 "tcId" : 97
1297 },
1298 {
1299 "comment" : "random signature",
1300 "message" : "00000000000000000000000000000000",
1301 "result" : "valid",
1302 "sig" : "d1a536b7938286c12f3d7cc12d779cfd7662dd1b1a80a0e50d6f15d8ec34d1748eedd5e3bf94ce409210e4c58fae664657dc160d41525fd7f62a17d614ccae50",
1303 "tcId" : 98
1304 },
1305 {
1306 "comment" : "random signature",
1307 "message" : "00000000000000000000000000000000",
1308 "result" : "valid",
1309 "sig" : "3e594afa1518a97360941a8930785150ec14cbd9d390da407155557e47540fd7590aeb35acb45eebf80e590585329e0543d3ebd6536321429cd6905541667d8f",
1310 "tcId" : 99
1311 },
1312 {
1313 "comment" : "random signature",
1314 "message" : "00000000000000000000000000000000",
1315 "result" : "valid",
1316 "sig" : "ff84c44ad23cb2bb9a92309c92c41487e618442f54decd53532f84e14326c49787fccaa0107558605d49ddf10bf83c561dbd75035e3acfd17bb5d49f2de1e15f",
1317 "tcId" : 100
1318 }
1319 ]
1320 },
1321 {
1322 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004008299c4e2bbbc1a061eb5d09c5ca6655e923fd85f08376cc8de849cf0e3cfa45d242976899c27551cccc30f9d9a82d2baa396e020def5454652239858d1eb44a33b00202ef1fbd2b2717fd75e40975aec6ed7f5c060fb04291711402d503840976b9f6ad826a05957f8691b4cfd8e2b4a774908d7c7ea94e47c33e5763309404cdd5e4a",
1323 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAgpnE4ru8GgYetdCcXKZlXpI/2F8I\nN2zI3oSc8OPPpF0kKXaJnCdVHMzDD52agtK6o5bgIN71RUZSI5hY0etEozsAIC7x\n+9KycX/XXkCXWuxu1/XAYPsEKRcRQC1QOECXa59q2CagWVf4aRtM/Y4rSndJCNfH\n6pTkfDPldjMJQEzdXko=\n-----END PUBLIC KEY-----",
1324 "sha" : "SHA-512",
1325 "type" : "ECDSAVer",
1326 "jwk" : {
1327 "crv" : "P-521",
1328 "kid" : "none",
1329 "kty" : "EC",
1330 "x" : "AIKZxOK7vBoGHrXQnFymZV6SP9hfCDdsyN6EnPDjz6RdJCl2iZwnVRzMww-dmoLSuqOW4CDe9UVGUiOYWNHrRKM7",
1331 "y" : "ACAu8fvSsnF_115Al1rsbtf1wGD7BCkXEUAtUDhAl2ufatgmoFlX-GkbTP2OK0p3SQjXx-qU5Hwz5XYzCUBM3V5K"
1332 },
1333 "key" : {
1334 "curve" : "secp521r1",
1335 "keySize" : 521,
1336 "type" : "ECPublicKey",
1337 "wx" : "08299c4e2bbbc1a061eb5d09c5ca6655e923fd85f08376cc8de849cf0e3cfa45d242976899c27551cccc30f9d9a82d2baa396e020def5454652239858d1eb44a33b",
1338 "wy" : "202ef1fbd2b2717fd75e40975aec6ed7f5c060fb04291711402d503840976b9f6ad826a05957f8691b4cfd8e2b4a774908d7c7ea94e47c33e5763309404cdd5e4a"
1339 },
1340 "tests" : [
1341 {
1342 "comment" : "random signature",
1343 "message" : "0000000000000000000000000000000000000000",
1344 "result" : "valid",
1345 "sig" : "01901935f873695f6d978537d1932a74b594e98ee672348f9a25abe2cf8b8aae31208c90f80fe508c356302f11f4b7d8180aa1c70207483c560133ada3060dce63c9004acb84ee9ca82af573e5ab9ec86820e60d12f20168862cf34429219dd6d8610298af6d01a57c4b5d867acbb9faab0628501a489a6ec63273022e72aa1aaec8dfc5",
1346 "tcId" : 101
1347 },
1348 {
1349 "comment" : "random signature",
1350 "message" : "0000000000000000000000000000000000000000",
1351 "result" : "valid",
1352 "sig" : "008b2d6f870aa5a329e2cfd2d7b557879ed300154058e2c55569312d929d43e44b761fba188745e047cabd77ad54b5ec3f301ad5725e41dc07e28cabdd0f948d10e201496e8da0f64dda20666dd78dfb529695f32df3d4c33e402dfe85db1ebce89396553aef4d62cb3bac401241ab9938040a6d22b36bb866d3878a7001c646e2ade4fd",
1353 "tcId" : 102
1354 },
1355 {
1356 "comment" : "random signature",
1357 "message" : "0000000000000000000000000000000000000000",
1358 "result" : "valid",
1359 "sig" : "0102dc32e8f53daeb00ac0b9ea88a3496b19be2831261660e2ef599c08623c3bb4cb7f9d4e5d24e9b50256b3243292b6a5d7de11e371aae3e88abdb01112b5fc31e400ed4642d1a5d4456a8bd94037d180cfe2faadb1fccf434fcbb12eb0a353064a9764bb8b8d689320e8a83af8045109c2007f1486627cc7ac0c5c713a419075862434",
1360 "tcId" : 103
1361 },
1362 {
1363 "comment" : "random signature",
1364 "message" : "0000000000000000000000000000000000000000",
1365 "result" : "valid",
1366 "sig" : "002be69063cb7c574e1f15b2f762b9499411ee01f786e1bd6876c753b640cf0c4861ec5e85f0a7ec4f430ac7f4cd6c8afda97df7f7914549770b46f429931c8a02ad00898a7ded6b2a1ae812bf52fa1afb219b9b28b6b5e8e09f2eb3a3a364eed565664ae25dde99fd3421821e241e28cc9b3168943fb5ef56c7c9fb3a7bbba4c4e20f75",
1367 "tcId" : 104
1368 },
1369 {
1370 "comment" : "random signature",
1371 "message" : "0000000000000000000000000000000000000000",
1372 "result" : "valid",
1373 "sig" : "0019c52156a6044e89a69d35d5ea3855108c39f038652be3a3819fd38c4f087510918c5a013b1e06c5c463db7aae0c584316dae3062d90da918ff474e687d7bd9c5101caf79795bca185e27c985083ee936455d1c60c1c7e3d95e032cef0d80bf1426df5cdf1b9a5edbec533bc737c24b77b4694f233ec2f5e88d9effdd2a9b8d3b800d4",
1374 "tcId" : 105
1375 },
1376 {
1377 "comment" : "random signature",
1378 "message" : "0000000000000000000000000000000000000000",
1379 "result" : "valid",
1380 "sig" : "00e903e8ad55d36cfdf951f631d4226b5bf79c17e7c2f53c4dabecfbf8675d38ed29e150fbf1d86f44c730df7777410e9df72a5a88cbe5f52e083585d1765ca3055300b85d63f3c4e2f36691e165026696a9eeb8adc4c0e32bf56c03de418eed3fd48057e9d402dc124d710e2536986472cf75b87ec283574223cb193af34966ea93183f",
1381 "tcId" : 106
1382 },
1383 {
1384 "comment" : "random signature",
1385 "message" : "0000000000000000000000000000000000000000",
1386 "result" : "valid",
1387 "sig" : "006c5437ca8b2f853c2a4216d9e7379c4400bd5fb2b74d6c4af5658589d4894eff0c754465569c45804c0b3b105a917ea53006cfbc7f0e967b14014dda4f1a6a3f0101620b46f91afbde439d2f479555ed03b5210df454926d2473513b6342016bbb24b1eb10f16d5666732b977ca4938dfed9bbf36aab261f924f153a4eded721da124b",
1388 "tcId" : 107
1389 },
1390 {
1391 "comment" : "random signature",
1392 "message" : "0000000000000000000000000000000000000000",
1393 "result" : "valid",
1394 "sig" : "005f49f8e46ee467fba634e7b2c7a089eabadfd82727a4dd4e8e20c2eef15d795cf287c62f86cc64cd988b83a4271084b32c2176ef15815026220c17a5d1255e953e01bae15b61f0ad85db8c4aaa70aab509e6ebf32ffab91c90e63da1670f94d1ea54d50e98dfb3f67626a27c047b457a20fdae6110acd4ffc96f17d38e90af8bd7b819",
1395 "tcId" : 108
1396 },
1397 {
1398 "comment" : "random signature",
1399 "message" : "0000000000000000000000000000000000000000",
1400 "result" : "valid",
1401 "sig" : "0044a5b08f9d5031efe823a3f7b2226ea7c88e7d770acd5943a5804fe6f48a1421aee3c530145c20680ae35b198e5a0565a71748b37f3944708d40e1acaf928bdd7f008d5fbe874e1b709f4b20e78e08755ce1792a724bdc2e48816193d77e95e021f1baf99c8d26a981b5c882c56a70f8a06dec227a3f29204f9f582c72eaccd1f96165",
1402 "tcId" : 109
1403 },
1404 {
1405 "comment" : "random signature",
1406 "message" : "0000000000000000000000000000000000000000",
1407 "result" : "valid",
1408 "sig" : "0077751cca360c5abf093605729cfc68e1c80b255b01e3d12b632d00b6dfdc8e37c74cf4d862d66c7989d2f999af58d33720cae0aa83251a968be4db122d3470c9f901af02304c5bdc546c2d06785ef906367d7117e6efec63151ad02d5346f7253206a70125dde96824f17005aaaebaa50f7c4d2bc1f7b653075fbc9c1a8afa225630c2",
1409 "tcId" : 110
1410 }
1411 ]
1412 },
1413 {
1414 "keyDer" : "3076301006072a8648ce3d020106052b8104002203620004820ee7b7457b52790f012e3f0a0e315d6a4270ff8ffeae9404a4c43d1e47a8fcfcae1a6ff4751635f42aaf94b0e3654de80847146fb7360f4aee71cdbf54eb16387d07d6e6894be68a5dfb62aed5b1f839596ea7bac188a4b766eb94e33f22d5",
1415 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEgg7nt0V7UnkPAS4/Cg4xXWpCcP+P/q6U\nBKTEPR5HqPz8rhpv9HUWNfQqr5Sw42VN6AhHFG+3Ng9K7nHNv1TrFjh9B9bmiUvm\nil37Yq7Vsfg5WW6nusGIpLdm65TjPyLV\n-----END PUBLIC KEY-----",
1416 "sha" : "SHA-384",
1417 "type" : "ECDSAVer",
1418 "jwk" : {
1419 "crv" : "P-384",
1420 "kid" : "none",
1421 "kty" : "EC",
1422 "x" : "gg7nt0V7UnkPAS4_Cg4xXWpCcP-P_q6UBKTEPR5HqPz8rhpv9HUWNfQqr5Sw42VN",
1423 "y" : "6AhHFG-3Ng9K7nHNv1TrFjh9B9bmiUvmil37Yq7Vsfg5WW6nusGIpLdm65TjPyLV"
1424 },
1425 "key" : {
1426 "curve" : "secp384r1",
1427 "keySize" : 384,
1428 "type" : "ECPublicKey",
1429 "wx" : "0820ee7b7457b52790f012e3f0a0e315d6a4270ff8ffeae9404a4c43d1e47a8fcfcae1a6ff4751635f42aaf94b0e3654d",
1430 "wy" : "0e80847146fb7360f4aee71cdbf54eb16387d07d6e6894be68a5dfb62aed5b1f839596ea7bac188a4b766eb94e33f22d5"
1431 },
1432 "tests" : [
1433 {
1434 "comment" : "random signature",
1435 "message" : "48656c6c6f",
1436 "result" : "valid",
1437 "sig" : "6d61307eb3042c72fa2e5051e5d7fd969357bbf7a77ef28db8e5c35431a253e47fd271c5b14a377f41e9db9353c33e848bf9412381b9fe33fdb00757af2e08440d36d4fc7ee0c085850daae1f8df972ab8299f381be2951e8e0b1e1eb9b5f803",
1438 "tcId" : 111
1439 },
1440 {
1441 "comment" : "random signature",
1442 "message" : "48656c6c6f",
1443 "result" : "valid",
1444 "sig" : "87c43936c6b260236bc47417f0fdc6c5dabfd38576f74135dff1fad9daade052098c82e46e1dd4577168dab9a2af95f1a7f1fd50ee1a7b34b4ddeea66ce3b0455377c47cc75cbdcd7f7848b3dd6c567dcfcb77a29951ea6bf5e6d30bfbd7b064",
1445 "tcId" : 112
1446 },
1447 {
1448 "comment" : "random signature",
1449 "message" : "48656c6c6f",
1450 "result" : "valid",
1451 "sig" : "cacd409cefcf1fc0d10b7f4cdfd751c4e207a71f7e602bfb855a592f5b33e6d666443ee9c9abd1258aa65ca06318447e50fbc450a2d2d6669a790cecac7748bc11111429fa0631a1c2f8ce0d8abb60d2b699db316f1b88e748f3f8af2b4623b2",
1452 "tcId" : 113
1453 },
1454 {
1455 "comment" : "random signature",
1456 "message" : "48656c6c6f",
1457 "result" : "valid",
1458 "sig" : "8bfd7fe7562e19381fe51cdf5784fc8248e71a19ec73db9ab59a49eb28bd05763b0789072a6449dbcf32dc227eebaca8c7f49385fd9e3c8c4199030e238bf1c38b0000a03bd230d303cd0cb06e9a1cf70248c35da5258db2bb2047ff4b13bd9e",
1459 "tcId" : 114
1460 },
1461 {
1462 "comment" : "random signature",
1463 "message" : "48656c6c6f",
1464 "result" : "valid",
1465 "sig" : "4936aacd98530d41afb1adcb0429d6e18d55b8956f7996f47dc5fe712bb5484ea9c992cc8fd7c5e50a5312c9a1fca21e68a97212b13a2d1d95fe45a434051cdebdb4886e9f23392384a32f61b50990e123241b06813095ffd557d181af38cdb3",
1466 "tcId" : 115
1467 },
1468 {
1469 "comment" : "random signature",
1470 "message" : "48656c6c6f",
1471 "result" : "valid",
1472 "sig" : "323afee80faf41d30344b29d7c5dc63960c9f229f2cffe66a5d58fc0918ff15996e9e65879aad3c9ebddb3f67568db09f70abf2c40cd360dec66fd59df3dc3b845f90657e82f4b9f1da8aab9df5f45003224cb4b6519274d2925b245edbc3543",
1473 "tcId" : 116
1474 },
1475 {
1476 "comment" : "random signature",
1477 "message" : "48656c6c6f",
1478 "result" : "valid",
1479 "sig" : "e52d47dc305382258dcfc364bcfbec863e844c75768dee340c9a5c6f0f98904726f500a2997f8f835a4db5968e6f727b7e9e3a2c64e66064f15a527a8a44396c29db47397058d0498cca36ed93ae76d92918087fd367e2db74ca807db6d33d1f",
1480 "tcId" : 117
1481 },
1482 {
1483 "comment" : "random signature",
1484 "message" : "48656c6c6f",
1485 "result" : "valid",
1486 "sig" : "bffd543c002ab7740588aef8212205cef78baa907ab537634f5c3cfad76013d5085ec4f734fd085e0e153c6d86cf798bd237c58554f0c00888676c7b0147ffd7e336824775a4f675956be1daf617e2834abdc465c2e72b42032b6364ed926dc9",
1487 "tcId" : 118
1488 },
1489 {
1490 "comment" : "random signature",
1491 "message" : "48656c6c6f",
1492 "result" : "valid",
1493 "sig" : "176847a307aebae41f08db05411eedac6f47f20ffde5a5e10c9bf45d1b244eef2c724497f4857f2f06aee4cac11ac37c9c80f7283350fde434d6b0fbccc8f26434ad2ad9a5bc9e3665dfd11009f68cb959aab1e1c5b2481cd987836854650f7d",
1494 "tcId" : 119
1495 },
1496 {
1497 "comment" : "random signature",
1498 "message" : "48656c6c6f",
1499 "result" : "valid",
1500 "sig" : "be2eec483e0c2d9fad3e03163bdfaadc6baef5ffe3373aa1a48cfc0c00fd67da56dff871a98be8fab8645bf5ca645d65aae76f1d6acd4bfdbe683b5315a956ed96f57e82ff04932e837e759b40d8dcc73521a289508a7a71e430f680d6c0fb3d",
1501 "tcId" : 120
1502 }
1503 ]
1504 },
1505 {
1506 "keyDer" : "3076301006072a8648ce3d020106052b8104002203620004031fbb3c18dfaff249ed5b7ddcfb0282197fda8708cc4d2c49000939c413dcb907e275efccaec2a13ef98638ebb90c07015df32d9c8cef5c0a3cbccff96d36d5738201b8430c231acde7c831bb5a270cec6d35f5427443a0b0242ff2289ba07c",
1507 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEAx+7PBjfr/JJ7Vt93PsCghl/2ocIzE0s\nSQAJOcQT3LkH4nXvzK7CoT75hjjruQwHAV3zLZyM71wKPLzP+W021XOCAbhDDCMa\nzefIMbtaJwzsbTX1QnRDoLAkL/Iom6B8\n-----END PUBLIC KEY-----",
1508 "sha" : "SHA-256",
1509 "type" : "ECDSAVer",
1510 "jwk" : {
1511 "crv" : "P-384",
1512 "kid" : "none",
1513 "kty" : "EC",
1514 "x" : "Ax-7PBjfr_JJ7Vt93PsCghl_2ocIzE0sSQAJOcQT3LkH4nXvzK7CoT75hjjruQwH",
1515 "y" : "AV3zLZyM71wKPLzP-W021XOCAbhDDCMazefIMbtaJwzsbTX1QnRDoLAkL_Iom6B8"
1516 },
1517 "key" : {
1518 "curve" : "secp384r1",
1519 "keySize" : 384,
1520 "type" : "ECPublicKey",
1521 "wx" : "31fbb3c18dfaff249ed5b7ddcfb0282197fda8708cc4d2c49000939c413dcb907e275efccaec2a13ef98638ebb90c07",
1522 "wy" : "15df32d9c8cef5c0a3cbccff96d36d5738201b8430c231acde7c831bb5a270cec6d35f5427443a0b0242ff2289ba07c"
1523 },
1524 "tests" : [
1525 {
1526 "comment" : "Hash weaker than DL-group",
1527 "message" : "48656c6c6f",
1528 "result" : "acceptable",
1529 "sig" : "f131a61e2bb3c8260b0f1b8fbbd57dfea3194fb9e4ea5eb1f343f67f013358e94f5b1a550bcccd6d6e40d065be590706bba3db852eef1c12d71f5e351c8d1790e8a11af575f13b0c992c4984e1e17d259e4e02917f480847e5c2b9430335ba94",
1530 "tcId" : 121
1531 }
1532 ]
1533 },
1534 {
1535 "keyDer" : "30819b301006072a8648ce3d020106052b81040023038186000400f3762f3ceb3a7dbbad769c6733b665aec3a802f8069345173dfbabe93fa6624e2a65ade6b849e05c59b01c7b709d36933c50c6ffd89e85e959571f8f9a25c1603701fb8f0d50bdfb4dca4e25d746dde110524b00cd6c272b2f5e6db3c99382bcf0b8eec5034645dc139baac5dc23f43c1f91ff8ed086d33192ee2f534fd0ca7a840e85",
1536 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA83YvPOs6fbutdpxnM7ZlrsOoAvgG\nk0UXPfur6T+mYk4qZa3muEngXFmwHHtwnTaTPFDG/9iehelZVx+PmiXBYDcB+48N\nUL37TcpOJddG3eEQUksAzWwnKy9ebbPJk4K88LjuxQNGRdwTm6rF3CP0PB+R/47Q\nhtMxku4vU0/QynqEDoU=\n-----END PUBLIC KEY-----",
1537 "sha" : "SHA-384",
1538 "type" : "ECDSAVer",
1539 "jwk" : {
1540 "crv" : "P-521",
1541 "kid" : "none",
1542 "kty" : "EC",
1543 "x" : "APN2LzzrOn27rXacZzO2Za7DqAL4BpNFFz37q-k_pmJOKmWt5rhJ4FxZsBx7cJ02kzxQxv_YnoXpWVcfj5olwWA3",
1544 "y" : "AfuPDVC9-03KTiXXRt3hEFJLAM1sJysvXm2zyZOCvPC47sUDRkXcE5uqxdwj9Dwfkf-O0IbTMZLuL1NP0Mp6hA6F"
1545 },
1546 "key" : {
1547 "curve" : "secp521r1",
1548 "keySize" : 521,
1549 "type" : "ECPublicKey",
1550 "wx" : "0f3762f3ceb3a7dbbad769c6733b665aec3a802f8069345173dfbabe93fa6624e2a65ade6b849e05c59b01c7b709d36933c50c6ffd89e85e959571f8f9a25c16037",
1551 "wy" : "1fb8f0d50bdfb4dca4e25d746dde110524b00cd6c272b2f5e6db3c99382bcf0b8eec5034645dc139baac5dc23f43c1f91ff8ed086d33192ee2f534fd0ca7a840e85"
1552 },
1553 "tests" : [
1554 {
1555 "comment" : "Hash weaker than DL-group",
1556 "message" : "48656c6c6f",
1557 "result" : "acceptable",
1558 "sig" : "016e9c9ec1320d9403f5b86df59158da27830857f77f58d5c4d34bad9af3f5a422be7f406c994ed865ed6555c326a8f1c7749212cd8dded24f943ff9655072d233bb0127b8318f719866ece8b0092e9c4cbdd212c99e644c1bde2b9c97ff82af6e2e40bbac92e0acd01a2d7a1fa10a7ee725c140b7418c1d5f56688ca0096726987e3aa2",
1559 "tcId" : 122
1560 }
1561 ]
1562 },
1563 {
1564 "keyDer" : "30819b301006072a8648ce3d020106052b810400230381860004016894136702a1ff2de14be80fa8ee832777d885caa90182281195187a8c24dfeb92bd33685a78dd348ae4042a02fa25524b7c111f04111df9fe3df830dabd8a8dcf00abe007cdd100461bec9a3dc0c51a6da36f9637aec3fee4c781cf016b190c67f87392a59e6afbba6ca89603dcb1ae07a6c695e6e1694ec440fae62214e016db01f5",
1565 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBaJQTZwKh/y3hS+gPqO6DJ3fYhcqp\nAYIoEZUYeowk3+uSvTNoWnjdNIrkBCoC+iVSS3wRHwQRHfn+Pfgw2r2Kjc8Aq+AH\nzdEARhvsmj3AxRpto2+WN67D/uTHgc8BaxkMZ/hzkqWeavu6bKiWA9yxrgemxpXm\n4WlOxED65iIU4BbbAfU=\n-----END PUBLIC KEY-----",
1566 "sha" : "SHA-256",
1567 "type" : "ECDSAVer",
1568 "jwk" : {
1569 "crv" : "P-521",
1570 "kid" : "none",
1571 "kty" : "EC",
1572 "x" : "AWiUE2cCof8t4UvoD6jugyd32IXKqQGCKBGVGHqMJN_rkr0zaFp43TSK5AQqAvolUkt8ER8EER35_j34MNq9io3P",
1573 "y" : "AKvgB83RAEYb7Jo9wMUabaNvljeuw_7kx4HPAWsZDGf4c5Klnmr7umyolgPcsa4HpsaV5uFpTsRA-uYiFOAW2wH1"
1574 },
1575 "key" : {
1576 "curve" : "secp521r1",
1577 "keySize" : 521,
1578 "type" : "ECPublicKey",
1579 "wx" : "16894136702a1ff2de14be80fa8ee832777d885caa90182281195187a8c24dfeb92bd33685a78dd348ae4042a02fa25524b7c111f04111df9fe3df830dabd8a8dcf",
1580 "wy" : "0abe007cdd100461bec9a3dc0c51a6da36f9637aec3fee4c781cf016b190c67f87392a59e6afbba6ca89603dcb1ae07a6c695e6e1694ec440fae62214e016db01f5"
1581 },
1582 "tests" : [
1583 {
1584 "comment" : "Hash weaker than DL-group",
1585 "message" : "48656c6c6f",
1586 "result" : "acceptable",
1587 "sig" : "0062ecd31c77761bc89143b044efcb514e9c6ef4b5a0999203e14aba19d3f7b484e20b3833ade5f5f49d30e1282a2b22a14ee8816709595edf8f42f5630f92d303450147d4a41d4ada8896a4462d925fcb7cfd95e57048b73de44f2e292ab3009e3877723b8d0641046b622c65d5c0bde0ff46789ca2c205c6117736c5f971fd208eae8f",
1588 "tcId" : 123
1589 }
1590 ]
1591 }
1592 ]
1593 }
0 {
1 "algorithm" : "RSASig",
2 "generatorVersion" : "0.0a10",
3 "numberOfTests" : 362,
4 "testGroups" : [
5 {
6 "e" : "10001",
7 "keyAsn" : "30818902818100ab9014dc47d44b6d260fc1fef9ab022042fd9566e9d7b60c54100cb6e1d4edc98590467d0502c17fce69d00ac5efb40b2cb167d8a44ab93d73c4d0f109fb5a26c2f8823236ff517cf84412e173679cfae42e043b6fec81f9d984b562517e6febe1f72295dbc3fdfc19d3240aa75515563f31dad83563f3a315acf9a0b351a23f0203010001",
8 "keyDer" : "30819f300d06092a864886f70d010101050003818d0030818902818100ab9014dc47d44b6d260fc1fef9ab022042fd9566e9d7b60c54100cb6e1d4edc98590467d0502c17fce69d00ac5efb40b2cb167d8a44ab93d73c4d0f109fb5a26c2f8823236ff517cf84412e173679cfae42e043b6fec81f9d984b562517e6febe1f72295dbc3fdfc19d3240aa75515563f31dad83563f3a315acf9a0b351a23f0203010001",
9 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrkBTcR9RLbSYPwf75qwIgQv2V\nZunXtgxUEAy24dTtyYWQRn0FAsF/zmnQCsXvtAsssWfYpEq5PXPE0PEJ+1omwviC\nMjb/UXz4RBLhc2ec+uQuBDtv7IH52YS1YlF+b+vh9yKV28P9/BnTJAqnVRVWPzHa\n2DVj86MVrPmgs1GiPwIDAQAB\n-----END PUBLIC KEY-----",
10 "keysize" : 1024,
11 "n" : "0ab9014dc47d44b6d260fc1fef9ab022042fd9566e9d7b60c54100cb6e1d4edc98590467d0502c17fce69d00ac5efb40b2cb167d8a44ab93d73c4d0f109fb5a26c2f8823236ff517cf84412e173679cfae42e043b6fec81f9d984b562517e6febe1f72295dbc3fdfc19d3240aa75515563f31dad83563f3a315acf9a0b351a23f",
12 "sha" : "SHA-256",
13 "type" : "RSASigVer",
14 "tests" : [
15 {
16 "comment" : "valid",
17 "message" : "54657374",
18 "name" : "RsaSignatureTestVector",
19 "padding" : "3031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
20 "result" : "valid",
21 "sig" : "68ea71ee1911687eb54b3d19cedcfd44719d0b24accccc59bdafd84e4eba48ef0be7f115e7073f9f273286a7dcee3b94cdbe208e30ae496987479d3aa12ab0e12685ab592d7693a494e6ad27d526ed3ab5912c7f81e09983931794c2165c22fd859e0f9af1a93a4dfe144098c562731e6059d236b52cb865996c87a9baf7f103",
22 "tcId" : 1
23 },
24 {
25 "comment" : "Legacy:missing NULL",
26 "message" : "54657374",
27 "name" : "RsaSignatureTestVector",
28 "padding" : "302f300b06096086480165030402010420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
29 "result" : "acceptable",
30 "sig" : "253e1d19bbe91064f2364c1e7db3ba8eb6dc5b19202e440eab6fbdf28c8c6ec05b812983713c338c72b6e99b8edf506a89ff9fc8e5c2c52362097a56dc228060eca01e1ff318c6c81617691438703411c1f953b21cd74331f87c9b8b189fdffdfe8550bd2bd1d47be915f8604a0f472199dd705e19b1b815f99b68d60bc257c7",
31 "tcId" : 2
32 },
33 {
34 "comment" : "long form encoding of length",
35 "message" : "54657374",
36 "name" : "RsaSignatureTestVector",
37 "padding" : "308131300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
38 "result" : "invalid",
39 "sig" : "52f46d508e31f030b17c537888585f919037562e15f1924543601a41f9b701ee416ad73d6576b4eaaa64e685289dc478751dfe2d7e588252bfe2d43f4b3a31c6c6c39a9df884a2fc2e45f09c2150a830974b1c9d26090830b37bf06f1d57be1da34ebb016e9db7ce2c34e94872c89567ff6f2ab35a1a9fb6632e100c7d7af834",
40 "tcId" : 3
41 },
42 {
43 "comment" : "long form encoding of length",
44 "message" : "54657374",
45 "name" : "RsaSignatureTestVector",
46 "padding" : "303230810d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
47 "result" : "invalid",
48 "sig" : "3f34017b3172aaeec72d208308e9b83150699f86634b948847eab56f0169fef51b5636a96866f4f0f4c649400489e047803a91f2b2f32ab715065e20770c4e2788946b85aca5c90efdd6a9458dd9b6f797f96a3de88d2e4896afe147d8c0389943828100061903a30eaff1dadd98d3e49dba56cdcfa5f215d9c615f974f4a0bc",
49 "tcId" : 4
50 },
51 {
52 "comment" : "long form encoding of length",
53 "message" : "54657374",
54 "name" : "RsaSignatureTestVector",
55 "padding" : "3032300e06810960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
56 "result" : "invalid",
57 "sig" : "1478337676aa47ca72ea7557facff06f6c777f56063f4487d345e43dc56a6bc5f8a891085d53a32c9d1c3cf7f469e7f56847b0b1b9b5b784526078271f21d0550afc40f81e2b8e8dec851d87511cace965edceb83cb96c8d6616e1ee75bb22c54412fc942a6f71c9fc609a31a69d34b774a97c1ba4f85cca28d9993db8543f75",
58 "tcId" : 5
59 },
60 {
61 "comment" : "long form encoding of length",
62 "message" : "54657374",
63 "name" : "RsaSignatureTestVector",
64 "padding" : "3032300e06096086480165030402010581000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
65 "result" : "invalid",
66 "sig" : "77ba423e600bdd761ed10e7c00698a87fe1322f5f42b2902a0be7a24b1cf44f613fa55edeb2ded0475f8e1a13e5368f9a2bfc4f2f926ef289a2207bf3689fc1c8ec3e5463064a7f51bbc993966cc4016319b7c95f282372f1ff848d7fca753a81d905b3341b0fbf60ba186e750f3171cfc84288eff8742bda432bd6c8dc04f9f",
67 "tcId" : 6
68 },
69 {
70 "comment" : "long form encoding of length",
71 "message" : "54657374",
72 "name" : "RsaSignatureTestVector",
73 "padding" : "3032300d06096086480165030402010500048120532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
74 "result" : "invalid",
75 "sig" : "9460ee79bb990bc3fe28cfca92363e6ff6900e3b61b3a402f06024a72b7a65d62094b4419e93900995eb121327f72b26b139bab3e5e2bd0c82e0cf6357f3b16f1c1dd4407a9a820f20e3baaa2259614d9ee3e015e1c1778befa13aff1e545ea1758cba4713631d63180a91b52df394294441642964a024f45b2251c90e002ec0",
76 "tcId" : 7
77 },
78 {
79 "comment" : "length contains leading 0",
80 "message" : "54657374",
81 "name" : "RsaSignatureTestVector",
82 "padding" : "30820031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
83 "result" : "invalid",
84 "sig" : "96ac043d3cada45aed0dbdc4662dcf7855553a5effa1077048b51c7e9bfff7c2bb3486ea42894d4b4afb26a3b3bd32cb68d5c4d8ca2622f50d8c56fdc25baf83b9909ecb096419ddc13578dcc8121007f7204ee82c517ae03de70fa23ef2390602029a0cbc8a96c5b781d857dbf12802aa561f5f41ea35aa0babb91b9f891762",
85 "tcId" : 8
86 },
87 {
88 "comment" : "length contains leading 0",
89 "message" : "54657374",
90 "name" : "RsaSignatureTestVector",
91 "padding" : "30333082000d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
92 "result" : "invalid",
93 "sig" : "2a70643572a7cda975d9e2c0827837e60eaa78c297b1ff75b84f654a91fe33294ccbeda52676ece50fcc03018151e66c24940bd0574ab85a6599231d587f4a6e0ae841cb6696e7dcfd182cb75001304e36887bc4fe3b373828f8b0e62ac2300a626c9e6a2cd05bb7910e74da2978dae1948f855b3b455cd30367160e21581cab",
94 "tcId" : 9
95 },
96 {
97 "comment" : "length contains leading 0",
98 "message" : "54657374",
99 "name" : "RsaSignatureTestVector",
100 "padding" : "3033300f0682000960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
101 "result" : "invalid",
102 "sig" : "27778e39b45dee1e7003f1d315d3466fc111791187ddc056784c158df92097e123021e11918b6df8d905304db732e83d904bc914271b03def4ee129c3fc8adcc4f81b690e09e70e46c8b920093f304e64ecb7358740e976d28538a9eecf09ec1e1cd47df9107968207b21538cabe076bcc07c3862c46a793fcf638c70a972885",
103 "tcId" : 10
104 },
105 {
106 "comment" : "length contains leading 0",
107 "message" : "54657374",
108 "name" : "RsaSignatureTestVector",
109 "padding" : "3033300f0609608648016503040201058200000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
110 "result" : "invalid",
111 "sig" : "3a879e9f883b158908014f3617cae3315d47afdadd30840494f68d91c04dfe81bd16a40c7d21238cd1816928d989a232a3492325ab0f95d4426e3fb7d58c9908191dc557d8779dabb282287b7860c30e0796283428e0276447235809882ee990deb0f4312c01e7ddf0690406eeacb660acc6957bb670904cfd8d04df5e3ebda2",
112 "tcId" : 11
113 },
114 {
115 "comment" : "length contains leading 0",
116 "message" : "54657374",
117 "name" : "RsaSignatureTestVector",
118 "padding" : "3033300d0609608648016503040201050004820020532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
119 "result" : "invalid",
120 "sig" : "2b82155f363a3b283ae455f59e41c29dec2fbd8c7438b0e347aec5b38c7c895cb7d326870e4fbdb935fcbb561f223bd926dbe8b95ef5eaab27920dbe30c641e99f526a9bc356af54198b459b59383135a82cd5b6edab7da0b1a51d939b2f9951e1432d637c4f04a3546ed9c890143ae364602b94eabdaa2a45e4bdf0b5bdfa71",
121 "tcId" : 12
122 },
123 {
124 "comment" : "wrong length",
125 "message" : "54657374",
126 "name" : "RsaSignatureTestVector",
127 "padding" : "3032300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
128 "result" : "invalid",
129 "sig" : "1dda56dc953aeee7fd76ae7166d92ab9e3d1d9759e76f8f1d7634a73cbf69e39d8249153d7c2d83c9664db13552f0c78df34b8a67e7b6c10bcc61b5ead7ba62ce0ec7ba8ac78d146f7e4cadee6f6250e0bc3100660e7afbe3afa17fa288d97549b4c8cacc00ac5c942673485739f89c9e5e63ad2be97a8f2313f5c5b095e7542",
130 "tcId" : 13
131 },
132 {
133 "comment" : "wrong length",
134 "message" : "54657374",
135 "name" : "RsaSignatureTestVector",
136 "padding" : "3030300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
137 "result" : "invalid",
138 "sig" : "692c143b82196a391a3546607336e6f3bc047412645cf0def0d62d1b42234c14da138bb7f451b45073bbda2aba23412e83bc40d4e7de3e0684f2cad7d059f2d6831aa3d2ece4964ca75cd41dce23c5ba495c15345b36947b4b5a051fe1b84e148b5ae21f112d2245b1acbaeef9dc4a0c408829b9d2b1b5ab1d3a40af0a27b99e",
139 "tcId" : 14
140 },
141 {
142 "comment" : "wrong length",
143 "message" : "54657374",
144 "name" : "RsaSignatureTestVector",
145 "padding" : "3031300e060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
146 "result" : "invalid",
147 "sig" : "66c31a45b2287425a20f65c3eba9cc58c370882f5fc62921935491fbd516df9baf9b28304a21d9008b61a92779ecfb3b0c03f6d74354f5159956e3fc1d35bd7376289378f05d7a71e05ab32794f2566a54635e8dc64740acbe10a293ceddbebe8499b520f406023a134eb9927ebb788b92488f036d109ec0a40ac52372e847b3",
148 "tcId" : 15
149 },
150 {
151 "comment" : "wrong length",
152 "message" : "54657374",
153 "name" : "RsaSignatureTestVector",
154 "padding" : "3031300c060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
155 "result" : "invalid",
156 "sig" : "7b85536bdcda4ad3fc40129f2ff9dc85d9ec049913784064e7358686640446278a2006d93fb33429407597e5d8c783e3f7aee8a7791d69139f3c802a6547f01bf987415eec2447b0e8c4f3aee7ae2085d141fa34ca6634bc109dede93285d5c40cfcd98bd47ceb9cc1890dfff53b7ebb8038533580c7a67fe14c0c422e20cd64",
157 "tcId" : 16
158 },
159 {
160 "comment" : "wrong length",
161 "message" : "54657374",
162 "name" : "RsaSignatureTestVector",
163 "padding" : "3031300d060a60864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
164 "result" : "invalid",
165 "sig" : "5d77fba3cbb1905d83aa532fcc3227a95d7931bf0c2ab51f8118824de9dc029bd2470adf48b41c694ec7359d00a1336990c30ee368dd40bd681ba74794415d3997e7a756659397bf6abd44ca91c12a8580a3f5d1cdbc7f3be0c23c72334ce9b1419e6540dab73f5ff8ab57d0bbbe92b688bd3495f9344822b622042c2491bc41",
166 "tcId" : 17
167 },
168 {
169 "comment" : "wrong length",
170 "message" : "54657374",
171 "name" : "RsaSignatureTestVector",
172 "padding" : "3031300d060860864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
173 "result" : "invalid",
174 "sig" : "7b5476fb78f389d1131764e7a13322f86008924c8c098f6d74f2df4dcc5a504cd786b3eaae33295cd1e87a2bbd1a06cb385674d465110a9a990d52de9a67f1c13ecaaa86383d489423c084fae9ecd2e9b109f4f04b8c013e3409128f3a079c068c1ad27bc2a20e76ad149325b7b0f0bd804a4e33949a98aac49076260702b0b0",
175 "tcId" : 18
176 },
177 {
178 "comment" : "wrong length",
179 "message" : "54657374",
180 "name" : "RsaSignatureTestVector",
181 "padding" : "3031300d060960864801650304020105010420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
182 "result" : "invalid",
183 "sig" : "6034e1253e4860a29096e392076794cfcea166a30b340cc09f77baa5952c06d148bd89b750c3112930ef210a50a7d3f6569da89912b5e50e824116e73a15536958f75779506d07e67ec9c0cd8de4b51dfbb0fe56926feed18ffbd83b0cdd50d56326c54adf97e629378ae5f0f02fcda3da1aa98cb1d1990946edec711a85a0d8",
184 "tcId" : 19
185 },
186 {
187 "comment" : "wrong length",
188 "message" : "54657374",
189 "name" : "RsaSignatureTestVector",
190 "padding" : "3031300d060960864801650304020105000421532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
191 "result" : "invalid",
192 "sig" : "a44cd265e1ecea83fc74e9eef746ef173277cc96f69a1798590ddee7ce5b5c34a82ad58a5c042db19005e04eec4159900ea764c0d008c52b94577d1c438661fb767902d9d1bbd6a90bdc4df685ec5951eac81d8b4dd36bceef7b6f919e85b6c994c7cf22a804f15cebe63b77f47b3bc2c2aaa68c6362c27a574b849efafe72e9",
193 "tcId" : 20
194 },
195 {
196 "comment" : "wrong length",
197 "message" : "54657374",
198 "name" : "RsaSignatureTestVector",
199 "padding" : "3031300d06096086480165030402010500041f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
200 "result" : "invalid",
201 "sig" : "a160aa43f4873cada34bea5ccd2be9dce07940ee1c08eaad524a5019993bc753ce92cccada706b483f106ff20b327b35e7c83955ad3bbff3f26ced3489877d1b5bf285d61afcb30219c02a440da61030e301aadb901a525345d1a651a21c31a62ac9fb71738c3e215a8941ca9a3c4910679c5e774530c28788f6eddd7a31c024",
202 "tcId" : 21
203 },
204 {
205 "comment" : "uint32 overflow in length",
206 "message" : "54657374",
207 "name" : "RsaSignatureTestVector",
208 "padding" : "30850100000031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
209 "result" : "invalid",
210 "sig" : "1369c78f816a9baf027e255de0c258125be90f35b8daafee87f2ffef2d465e0694af4401cc5cdc7ca78b08d5688ceefbddc02abc5495d47c6829d696f8370ea427e7e0225eaf22cda720bbb5881edd16b19bbf2ca86654c65b4ad481c13fb38af00d77922f46b311f936c51f4610f6bdb514b366aa05f029c1e63e3cfcf9763d",
211 "tcId" : 22
212 },
213 {
214 "comment" : "uint32 overflow in length",
215 "message" : "54657374",
216 "name" : "RsaSignatureTestVector",
217 "padding" : "30363085010000000d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
218 "result" : "invalid",
219 "sig" : "41d4c1ea43cb207af8bfc1552e31da7ca5744b68c4e00c3bf55f4edd4c81e91c01f44fa05290dbaa1fdcdcc775f6032a049b4965345c16aac6994b06cda9e0387dbff96cdb115e014f69bb057faca2f618c70a31edd0beaef7acdcc0fb7c83b2f07a8b9de48aa04b7c973920af5b8dc20aac343251ddf4c2277985c3db1dac2f",
220 "tcId" : 23
221 },
222 {
223 "comment" : "uint32 overflow in length",
224 "message" : "54657374",
225 "name" : "RsaSignatureTestVector",
226 "padding" : "303630120685010000000960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
227 "result" : "invalid",
228 "sig" : "76bae6c330b9ab33aa9f2abe8559c51fb95f953a75e48053ab99078069214b509dd1b5080ac6819e32912619372d71a9ff1a67449dd699e5bc6ec0e18d1893dfb5bd571d933926d05b0d9fd7036ba4556e209369d1c57ec49cd9075e583c257c6fd4899c2a8bbb157547812cc692f264bf54712c71ee090b974d99b4d1629696",
229 "tcId" : 24
230 },
231 {
232 "comment" : "uint32 overflow in length",
233 "message" : "54657374",
234 "name" : "RsaSignatureTestVector",
235 "padding" : "303630120609608648016503040201058501000000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
236 "result" : "invalid",
237 "sig" : "3480a5c22f092f259b5bc4fdb9a33c044c24a645b57d61920effde1dc0bbfe53738023f16025841f9323b40f72c11091941bbdfaf7c2fbf77ad6626dbd6a3b7abb3ee916d96a922b11c86ce80ee67dec619bb98e9246d35a33b11b3a4e2a3a130e8b57ed4bcdd4b4e73aec3f9e3d50d3db5e29cffeb186846c72d09468d018ed",
238 "tcId" : 25
239 },
240 {
241 "comment" : "uint32 overflow in length",
242 "message" : "54657374",
243 "name" : "RsaSignatureTestVector",
244 "padding" : "3036300d0609608648016503040201050004850100000020532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
245 "result" : "invalid",
246 "sig" : "5b3d3a198d4b36c6d9641db181fff59407a25bf1571f85e47bad1eaf138079872b93b9eb51aae09b48d6f4ef56badd96a6584277d8f3c6e4a4e11275f72021b50a1665ddaaa56a2a7caa7da6b4d502c5214e17042811154d411dd2197c250264bb69ba43adf668d4f7b81d932afa55e378214bb19ddeb431f702a91dd11e23bb",
247 "tcId" : 26
248 },
249 {
250 "comment" : "uint64 overflow in length",
251 "message" : "54657374",
252 "name" : "RsaSignatureTestVector",
253 "padding" : "3089010000000000000031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
254 "result" : "invalid",
255 "sig" : "1cc5577d04e34550e7f3d136064547efa30b9413e2c423b5a320eaaaf11cbebb91e13bbe3874e4650e057a8e38c8a366c473f35e0de82b22f846721a09e3f279ebdf54c8df395a9041333f09cb7bed5291bc1842857c4ce6ad5a1c2c476c1efddd5fe42824c25e0581aa7bb8f621d3b53566637c6266bb1bd0a5b7fb79c72616",
256 "tcId" : 27
257 },
258 {
259 "comment" : "uint64 overflow in length",
260 "message" : "54657374",
261 "name" : "RsaSignatureTestVector",
262 "padding" : "303a308901000000000000000d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
263 "result" : "invalid",
264 "sig" : "6e56d1746105344b34fb8299d173f4a5032cbce3556ca9d1eee35f8b31818efc121a1a9599c24fef8531243016dd6288d67b4bf9fdbf2c90fba5b1661be03531b5e15385ea465d1376010f0af761e8fb1afff7823dcef8dc100d97c192e9a7d03c82321d83fd8ecf67207c65cf182e1104ec5669536070cf1e3fe73c5e27edeb",
265 "tcId" : 28
266 },
267 {
268 "comment" : "uint64 overflow in length",
269 "message" : "54657374",
270 "name" : "RsaSignatureTestVector",
271 "padding" : "303a3016068901000000000000000960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
272 "result" : "invalid",
273 "sig" : "37a413f9202591b8860cd9d68515ab522ae800e9a71793b479f1fb74ab8c9b07e72fe82dabe1189d028b813610e5e57c055af2d32837551fdb0cd93d7669a3c02a14c460f4c92136a4d11cfb7dcc76401bb5b699fbc64d302736d68c3591ecd59220107cd63f55c83edd38c4568e6f7749c0d9baebfb7c8ae1bf2179101745a9",
274 "tcId" : 29
275 },
276 {
277 "comment" : "uint64 overflow in length",
278 "message" : "54657374",
279 "name" : "RsaSignatureTestVector",
280 "padding" : "303a3016060960864801650304020105890100000000000000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
281 "result" : "invalid",
282 "sig" : "9fa8aac224bb50697103d457e7fc870853b23670ee5b8c7395d68ed82b30db18ae34a569abdcdf19238ffca8f5e435327dbe605bdc1a6dd3eaa3c2beb33f00642984a2034bf3b3e8de3ec7009e35069d5b27253c4aadcb4f163148e157252e3b9334abb6cf0299161c12908529f52de9416ec6218af7a6963fcc987c5024ea71",
283 "tcId" : 30
284 },
285 {
286 "comment" : "uint64 overflow in length",
287 "message" : "54657374",
288 "name" : "RsaSignatureTestVector",
289 "padding" : "303a300d060960864801650304020105000489010000000000000020532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
290 "result" : "invalid",
291 "sig" : "0f50bc6b1b94aeb6805dee51c92860693de47c4925ab90b57a46e0485a9afeed45083eade73bee684cd07048e632d1dd24aa2efc42c1f85e4fd7b7058dbeafb53a3d5b1cb1e7dded3352c3c92ded891839263a501afaa78fedfd04546c43d16f7a52b800abc9ab1ef827ae0eb19d9b52def2435f1477a48dff61800b4db830e4",
292 "tcId" : 31
293 },
294 {
295 "comment" : "length = 2**31 - 1",
296 "message" : "54657374",
297 "name" : "RsaSignatureTestVector",
298 "padding" : "30847fffffff300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
299 "result" : "invalid",
300 "sig" : "9dcc651cc0a1b4d406112c0d1ebd7a9fb5a2c9d9f9cffbeab2d2821e5ed01efa9d191665794649bd1f588b729e8fba1eaa37a5a736a5863973c338a92b2665d6ead13b72a19d2da778febb94b150e8d750340a3b856fca8b3b6e3cbfecb9c397c23f46912ba546ab0f64ed88404ce317f8fb2278b68950e9712d6b11f5cdfcaa",
301 "tcId" : 32
302 },
303 {
304 "comment" : "length = 2**31 - 1",
305 "message" : "54657374",
306 "name" : "RsaSignatureTestVector",
307 "padding" : "303530847fffffff060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
308 "result" : "invalid",
309 "sig" : "0397d14205c2f52423ef69c874294dc2b37d5be5d5647f7e83f1dd6783cb41cce52e6de1dc8c9e93ca1ef887d4c0ea79cd8b26391d638bbd8080bce830bf1bd7fb1de31346f28d609874fafd4a34fb7bee900441f55589ec3c5e190106d8816cadfcfb445834739cafaaa3903ed93cedc41a76aa0ce18fb49a3a73b7b5928735",
310 "tcId" : 33
311 },
312 {
313 "comment" : "length = 2**31 - 1",
314 "message" : "54657374",
315 "name" : "RsaSignatureTestVector",
316 "padding" : "3035301106847fffffff60864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
317 "result" : "invalid",
318 "sig" : "2c3ffd881c1c0ce2e4c98282d6011179a89b1e84b17072bcbbb64164e5e05410d0414a1fdbbc04564f3d80f3891f28c3f02e92bf97b4339b5bd4699614e236d4223cef0688c44b297eb9c0e22246b4cb28983b102a446dc76671206c3b77af6897f2f445512abda37bc9c37257dd4f1c6f0e6ec40929eb6b0058682b9d2f6c66",
319 "tcId" : 34
320 },
321 {
322 "comment" : "length = 2**31 - 1",
323 "message" : "54657374",
324 "name" : "RsaSignatureTestVector",
325 "padding" : "30353011060960864801650304020105847fffffff0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
326 "result" : "invalid",
327 "sig" : "668bd06eafe953fca6a17b0da0f9006ceadb09ad904786b7530148df7eedc146d20a5472c39677d65e59934c00227fb662b3474596e6072f56d2c00c3d31e66f0da85f4670e75c3f2c910c0fec8c98bc31fb2eceff80350b78aec0d316e9bbb331544d8a3d0b1649291396c717e350bebba3d3c3a0b1d55f010879b8c7b7d4f9",
328 "tcId" : 35
329 },
330 {
331 "comment" : "length = 2**31 - 1",
332 "message" : "54657374",
333 "name" : "RsaSignatureTestVector",
334 "padding" : "3035300d0609608648016503040201050004847fffffff532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
335 "result" : "invalid",
336 "sig" : "87482257ae1d18d0357428b756ae35a48549536a3439ca3c148eee64f4c096d896219097d55c14a25eb1490779f6b1471aed238cc0d6aaf265c12ac086d04de9b79a37518056dfacc12cb4916c17505fc7e2e6c1e0db720a286ea65bde4d3da1d2dcb8d0276e8ce73f3f923209149955285c602572cfd24c82e8d96d45f569e6",
337 "tcId" : 36
338 },
339 {
340 "comment" : "length = 2**32 - 1",
341 "message" : "54657374",
342 "name" : "RsaSignatureTestVector",
343 "padding" : "3084ffffffff300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
344 "result" : "invalid",
345 "sig" : "03aadd447f36952dfe73ae89e5c656b7d37ec92535e547cca62a7747f3831f2f613c7dc094f3d5c4c6b9e02b21ed4626930ef3948b42ed41f4cf468d2474acadf1c75599c5619e4872e6d3dfd93abe92234165135ed265e0c0f64fddf23e50c1f9fdcede8778a8ca008ab00f8afa887da3f4699df9f1140953232f36d035b03f",
346 "tcId" : 37
347 },
348 {
349 "comment" : "length = 2**32 - 1",
350 "message" : "54657374",
351 "name" : "RsaSignatureTestVector",
352 "padding" : "30353084ffffffff060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
353 "result" : "invalid",
354 "sig" : "31afd9a0d827755352b16de04de42e98a8c72f08919ed475530a00c762b8a03bde22634dd856a7eede4b4947d780cb3efe55775e16d7f46f209dbcb5569b2d9469cc271aa850f74960f7c741928055925349821e32e1e0fe5a040010a39a4b6a343f7f35c204106b3617e528a99dcaea8a93766adcfe7be31cdb98f7f7f14669",
355 "tcId" : 38
356 },
357 {
358 "comment" : "length = 2**32 - 1",
359 "message" : "54657374",
360 "name" : "RsaSignatureTestVector",
361 "padding" : "303530110684ffffffff60864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
362 "result" : "invalid",
363 "sig" : "16ac0aa2d727ef5fbf0305259ee6fa40827c92419f819673fd64cc2dc2dbfe7ce1cfcf06e26d45f59cb3d9afd30d7a6265863fe856e0a0b1b9508b1e7a2dfb0f87f5ebfc444bbdae504abde7daa33bffb991551940df682c8e2c45edef0563b34d4f11e1955e83c2145ee321165517d1532abd64dc613a280fc30670bba1f898",
364 "tcId" : 39
365 },
366 {
367 "comment" : "length = 2**32 - 1",
368 "message" : "54657374",
369 "name" : "RsaSignatureTestVector",
370 "padding" : "3035301106096086480165030402010584ffffffff0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
371 "result" : "invalid",
372 "sig" : "0fe0c75dae62462e66e7277b03c9113727419f7d4db7b2a567c0c189fb6328e1f73d5d44e2196b436f4c2f0f12950d419774c8a51c55f9b2217f904c4f03d5f5754174719dfb85f62795ef75e6d54e703bf231fd8472250f529f85294f29f6c5653ef585079c3b3d8f931da80a46c8afeef37696fb0e7986d413bb1996b8ad57",
373 "tcId" : 40
374 },
375 {
376 "comment" : "length = 2**32 - 1",
377 "message" : "54657374",
378 "name" : "RsaSignatureTestVector",
379 "padding" : "3035300d060960864801650304020105000484ffffffff532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
380 "result" : "invalid",
381 "sig" : "9ef993e6ccf015b0b0de75b51213a1c3efcaf66bf83655287484ef28d984806226a7af1704fa6a7fc02984b44449f83ae24761021e49ba6117505c1e609406b002215de27d696643c3354fb48e6c64e7300944edaeb96e4872275f75532f5aab94358d4954522fc7903439e99223d8124e79a3f519050b6b576b77d5abe7c3e3",
382 "tcId" : 41
383 },
384 {
385 "comment" : "length = 2**40 - 1",
386 "message" : "54657374",
387 "name" : "RsaSignatureTestVector",
388 "padding" : "3085ffffffffff300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
389 "result" : "invalid",
390 "sig" : "0fbc20d18ef2dce383ef9640232e44fc287cd97bdb1a18614a77a6d72da5db05df264fff4964b3395445a5b75f4098be8c923ec613efa49e87877c08ce52e9e8b491eaab77ed2336179f1e447bc53e0d9fb9cbd2f2c5e180acdc946df4cdb0a878f27dc010adb1d080330e0bed852181bf97dc4372049ac6ab5802c0d650ffa9",
391 "tcId" : 42
392 },
393 {
394 "comment" : "length = 2**40 - 1",
395 "message" : "54657374",
396 "name" : "RsaSignatureTestVector",
397 "padding" : "30363085ffffffffff060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
398 "result" : "invalid",
399 "sig" : "3df42c382b86647a466ffc743dc4713259bd7dfdc909939738e59e3d1eb11d104537762c50eb55d4677a005f7f925ffc7ef0751ffe0c4320a6cf0733e738a404b2672f3dd11fa97bf9d84b786a47c63bbc962d52873765a6de3a57590c2cec68118af81d7dac4f7ce6c101811f2fa364a34fe704d674be5a28531d6e8c4fe120",
400 "tcId" : 43
401 },
402 {
403 "comment" : "length = 2**40 - 1",
404 "message" : "54657374",
405 "name" : "RsaSignatureTestVector",
406 "padding" : "303630120685ffffffffff60864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
407 "result" : "invalid",
408 "sig" : "a66d9848a3db7e49d8053c4a3869415c0bb58fd265276c99a66ed1df84e162cfe8f0820229d2ac2f99d9753eed39af46649409cf559ca6edc8c47e550b7a4cf24fac756389e365ad73ddfa67e72d042ec494644c5f277f60864dc90d6cbfdf556396c795192077f51f173477b934871e2a960f7ac3e6e8c8039956a5061bccf2",
409 "tcId" : 44
410 },
411 {
412 "comment" : "length = 2**40 - 1",
413 "message" : "54657374",
414 "name" : "RsaSignatureTestVector",
415 "padding" : "3036301206096086480165030402010585ffffffffff0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
416 "result" : "invalid",
417 "sig" : "7561668d5b2f8fd3190be8244d4d0550043dc0a7e80dfac83eb6f6ddbf448d424082fafc332e473d434b37ce7605352594ce632f4d5de30951581af907fff6c01814022c31a31b3d130673a56b4ef7763bad595053af0174df395b802722f5046e408c978e2b5a9a63f8ea80e932f76513928253f432c8bdc7ee51872d315b7a",
418 "tcId" : 45
419 },
420 {
421 "comment" : "length = 2**40 - 1",
422 "message" : "54657374",
423 "name" : "RsaSignatureTestVector",
424 "padding" : "3036300d060960864801650304020105000485ffffffffff532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
425 "result" : "invalid",
426 "sig" : "5a836168587968425c4e103bae20603e0ae6f714ccdc603a865bb3541b65eee9dd0d9ee21cc66c7a83403fce2413b97f1c1239947e94614f6f2eb731387c8b9d956242bd9fb0545eb2c874ca1a167222034649894b41fd0fa935cf52e583a5e9a4b503cf9f2b238c025bf2e22ed78e7a64bcac1d38302cc2361c71b854e79123",
427 "tcId" : 46
428 },
429 {
430 "comment" : "length = 2**64 - 1",
431 "message" : "54657374",
432 "name" : "RsaSignatureTestVector",
433 "padding" : "3088ffffffffffffffff300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
434 "result" : "invalid",
435 "sig" : "97c602416f2131d34f2a57acecf26365a30c12f77e5beac095533848ce227302092c6f44b47f011d6eb0a91f8024d1935d8bb274c42b57875115a94281fd3cb198f9334758d3200c1c721f6babef332c02a89968a7089f7783993bdd54f809f8372437798d2364040c1faabfb00faabf28cd6ae4ffea29ae2c08a6a7e6074700",
436 "tcId" : 47
437 },
438 {
439 "comment" : "length = 2**64 - 1",
440 "message" : "54657374",
441 "name" : "RsaSignatureTestVector",
442 "padding" : "30393088ffffffffffffffff060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
443 "result" : "invalid",
444 "sig" : "2a970dc291a1dc935cca6985dda703bcc1ece2e40817ce8fa79b6e8fe84e113686e6e65570d46bf22147bcbc389cb5f86f92dc185f556d15e7614cef119fcd7305a31fd2f8710812f35f9f0bd8a1a6e5be3163de644370c67181b7575635dfb9f717f78631d62db714b2a19cea7079ff13c8926ae0c601e4befb6541b02a7e20",
445 "tcId" : 48
446 },
447 {
448 "comment" : "length = 2**64 - 1",
449 "message" : "54657374",
450 "name" : "RsaSignatureTestVector",
451 "padding" : "303930150688ffffffffffffffff60864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
452 "result" : "invalid",
453 "sig" : "6e16d110235cd11e32b114ca9dac0cd6a1b041a6d2c61941d49bb458241281f62a4e2b1bf3cebc3e67e8c062ec67a51a599a553b09732e23e1d09fb2b20be7fd311a7122414d535651718a1421d4239276c227b96506729a09e3ff2779dd1c79de4d402623039b826e2bb4d26d1b56775fce14ed0203a9ebd8f042d981705a77",
454 "tcId" : 49
455 },
456 {
457 "comment" : "length = 2**64 - 1",
458 "message" : "54657374",
459 "name" : "RsaSignatureTestVector",
460 "padding" : "3039301506096086480165030402010588ffffffffffffffff0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
461 "result" : "invalid",
462 "sig" : "0716d252488e08f10a25cec94714e6105bd4e13ff019431190864cb0f4378d315f4bd0fdf186e1f2d45a6e97eb04fb2013273e178ce4f82a0b67bf9d021b1d8ab73d753adf2073ee1ad6190b2163139db63778a3670b7cce23f45efb601bd59644a431cbe534ecdf4c4c58ed02ed03863ee32d296b5736c010305fec655b1a44",
463 "tcId" : 50
464 },
465 {
466 "comment" : "length = 2**64 - 1",
467 "message" : "54657374",
468 "name" : "RsaSignatureTestVector",
469 "padding" : "3039300d060960864801650304020105000488ffffffffffffffff532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
470 "result" : "invalid",
471 "sig" : "03e52a2ed638bfb9184a0ee3698502af3a19bb959a984957de5101e6f7a62cccc2ec2a6293fa9d76fabf3ce7e4bf35c65a5f864bc003686a1e05b57c5af6ad588e05a5225479422d7b78c5bedddaec7f4b8c1e9ab7478c1ee253847324e025434b76a01b82a40123ab31ec9862c6016885dc6cbfe97801503369fd3688bdaaf8",
472 "tcId" : 51
473 },
474 {
475 "comment" : "incorrect length",
476 "message" : "54657374",
477 "name" : "RsaSignatureTestVector",
478 "padding" : "30ff300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
479 "result" : "invalid",
480 "sig" : "9c4217830da16424a6c80a62e1e1cc0c589e3324267b4498e89af96998f83524b67c703e46860ca55631f1e659096366b60557dbbc8aa8a3a7ff6a887f1afcc55d336458ae25b015061adc391b8a449a7546e48d7e1d783e5684730333b0e2a32c13d36e342e31a9c1c447c0585545e08ce4f6340529413aaba6872280bbd7a7",
481 "tcId" : 52
482 },
483 {
484 "comment" : "incorrect length",
485 "message" : "54657374",
486 "name" : "RsaSignatureTestVector",
487 "padding" : "303130ff060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
488 "result" : "invalid",
489 "sig" : "5aa35d19b312de94d0123619500c15ec79fd838f6f18e75e79a11e50d0eca9406ecb38de68e11cf107f80ce2d62573bd1e4062fe78f30cf4bdfe9bb571488887d9dfaa2d6031f3b7efdd0dd78f04d980abfe641f490faee10e86dcc9b729bda0b127b448d33b1e1b76373794c284d1aecb5b813a2defdae3723eafaaf3606eac",
490 "tcId" : 53
491 },
492 {
493 "comment" : "incorrect length",
494 "message" : "54657374",
495 "name" : "RsaSignatureTestVector",
496 "padding" : "3031300d06ff60864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
497 "result" : "invalid",
498 "sig" : "971daa114a33b412a3aa1c3a93d5e1cb9810210019fe4e6dd0c70361a99f1a0676563bca2a05915df2ef2e38cab387ea16405d371d1a382ac286f1f97d4fdcf84464413986d54d6e2c7aeb8d5afffdc6de31684ecc7df721957d331bfa588a5f2a65c52f29ba5e4585bc69539e1945f1c4306f8d664d9cedde6684254ac704e0",
499 "tcId" : 54
500 },
501 {
502 "comment" : "incorrect length",
503 "message" : "54657374",
504 "name" : "RsaSignatureTestVector",
505 "padding" : "3031300d060960864801650304020105ff0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
506 "result" : "invalid",
507 "sig" : "1f5bf49483eb6f33a5575ec2a8d49388523ee41223210f05e1f9f73bcb5a8973dfaa0093247460885f034e4ed7cd888c63f9f0f74dba7065f00cbfe5d9cc0dc7aebd7893acc3f32d5cc03763b59a0a846554ef58569f153301dd6080d428c8330718e733b92e76367f4eb75213de1495bdb1a5743deb55a77919adb45bb6bc4a",
508 "tcId" : 55
509 },
510 {
511 "comment" : "incorrect length",
512 "message" : "54657374",
513 "name" : "RsaSignatureTestVector",
514 "padding" : "3031300d0609608648016503040201050004ff532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
515 "result" : "invalid",
516 "sig" : "7bffc77cda9ff6bfbbd5a92fa6d4cf5a9f48a083c37a9437e5d82c0ad9f625aac8917c8df8bb4db5ef879431bacf360399c6607711082d6bfc5264f40631f2a742a3494c039146c3f41c7b53aa754afd35410a0a26c6957dfec86797268861036bacb5dc8fa6ca2893b26a3e4b186d4ae774a3822aa1e99ba4bf6bc3d53b2c99",
517 "tcId" : 56
518 },
519 {
520 "comment" : "indefinte length without termination",
521 "message" : "54657374",
522 "name" : "RsaSignatureTestVector",
523 "padding" : "3080300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
524 "result" : "invalid",
525 "sig" : "3e461f3131735907cec3208f19a7ecfaa8f3bedf587d1c586773899f3fed55cf669ba736c9478b93ff058fc063e62433bb0da4d6da8254a00a6b1e1527dba86d89ca412cb952a988009d8874163683e729c7544b9c83e07b77467b4329e04bdee552ab0513f92dcc7376ed59718b645b50bd50661c783d559eaceb12f7bf5d10",
526 "tcId" : 57
527 },
528 {
529 "comment" : "indefinte length without termination",
530 "message" : "54657374",
531 "name" : "RsaSignatureTestVector",
532 "padding" : "30313080060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
533 "result" : "invalid",
534 "sig" : "81312384fb68fc608aa019df2a251d5a77dbff379c99d2804bc5ea766f051a80dcab2f63ec0b60d2b26391b35a83a5b75c7449fb0b32bd28d78f1138dde33b223d141e293bf007c5d028b34cd6055a4ed7aa31881c8514a2a091690405f8a708da65b34730233168dc08cd81733d2717db133f5d54ada593184bd008e5a7f016",
535 "tcId" : 58
536 },
537 {
538 "comment" : "indefinte length without termination",
539 "message" : "54657374",
540 "name" : "RsaSignatureTestVector",
541 "padding" : "3031300d068060864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
542 "result" : "invalid",
543 "sig" : "1d1150ce975992c50b3cbe98f2373621929c7a90f8dc5a9434a06159fb614acdfbd09851b297505db51aea8132a8f082fe72ea23099aea18494d2a73aaa6b9b6b04ca6d20a88c5dcea917f92c5df7943254fa9c3b1e7eca05a2ae2f796726d9296c880cf0872b8c32082a3a42b9cd099d286b586b0efce95908c8ffd27835572",
544 "tcId" : 59
545 },
546 {
547 "comment" : "indefinte length without termination",
548 "message" : "54657374",
549 "name" : "RsaSignatureTestVector",
550 "padding" : "3031300d060960864801650304020105800420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
551 "result" : "invalid",
552 "sig" : "7c64ae50883b449f68f941c9892dc1e1f446bc3a779ce9906bf5f6751dd110162ee03a99d1b556ff380f176263846e76aea5e7078927ec6c076a79c64450f6ce8e7a9faab4040a31c145564107120cb524451e4fec4b1ae3702d0b063c660031b61fb6c2d0cb46d17c5f4605124057d5ce3a0ded2019a14718de1374e0e87124",
553 "tcId" : 60
554 },
555 {
556 "comment" : "indefinte length without termination",
557 "message" : "54657374",
558 "name" : "RsaSignatureTestVector",
559 "padding" : "3031300d060960864801650304020105000480532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
560 "result" : "invalid",
561 "sig" : "65e61f63db5ef3a5de4a11aa39e3f4a6d3d952336c19f0fd60255b376d459d318fe4234a3a6c883090617306f98659577f7670054fc4f2d4c82bf7fde24bd1a231c71644d487d65beead86828e48a3e081fa6d4666b86b899ea57c99a67c0ae75947f2a4e5dbce3025421b3213224e29a55faf0cab8d9411b629baabf7c9ba6a",
562 "tcId" : 61
563 },
564 {
565 "comment" : "removing sequence",
566 "message" : "54657374",
567 "name" : "RsaSignatureTestVector",
568 "padding" : "",
569 "result" : "invalid",
570 "sig" : "5df1c4a701c6fc1f2daf6f4538f29c3452667424c05edcbdaba4a1678c8b5bc0e89656a0e48aef46642e0bb597813688904e9d74cbd377a3d9d2c965bd3ed06f136f10367ea3eecf89a97508389448a31ae0e79ed3725d0c4e99a516daa4116479bc53da5d7c2f26c7ec6310d4cb4174bb781405630a9b1c147b0e1da3a7faf9",
571 "tcId" : 62
572 },
573 {
574 "comment" : "removing sequence",
575 "message" : "54657374",
576 "name" : "RsaSignatureTestVector",
577 "padding" : "30220420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
578 "result" : "invalid",
579 "sig" : "3e43837b92ebe4df08586fced3dce46aeb2fdb6ec2bd0c58e823f6e6363b9b676786929d13ede60a8d8d0daaf71f0de8880ed0fdac8706eb2f324394145818b641d1049cc7552bc6273d86e901099c78297381faec5c518fb6de429700f3bbfef76cdecbb60088b9f2a77d75b8ff86f06cf23850e3183a267c0ea34f4f839015",
580 "tcId" : 63
581 },
582 {
583 "comment" : "appending 0's to sequence",
584 "message" : "54657374",
585 "name" : "RsaSignatureTestVector",
586 "padding" : "3033300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
587 "result" : "invalid",
588 "sig" : "26d20fecdcf0b7d6a0472754aecbe115c39d580ce9d78b67d1a6395aa6ce6689bf6d0d96545341fbf04956a48c47f7d30bda017acb1d8e24ce596aacd3e05b1afa571d19f5316142557f765e4c5d080bc5336b79e2c02d8833d076ac9d7794ffbe85c66d0db97e1f5bd2ecb46afb15c19a8fe083fa593420e996a483c2a3a766",
589 "tcId" : 64
590 },
591 {
592 "comment" : "appending 0's to sequence",
593 "message" : "54657374",
594 "name" : "RsaSignatureTestVector",
595 "padding" : "3033300f0609608648016503040201050000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
596 "result" : "invalid",
597 "sig" : "1163082ba8d48352df7eab96a0067539faff24374a630aa4393461a0aac716606625d706699dfc22cf3aff89fcc278f83a0adac87aa0bf192dd86a97031515de1933a23849478ebed20e4203abfb47345bc18f38da5d45e829997b10107c536999b2ce10b2781e1db03e10cc2bdbc2e0ff4c3db5d271ce83c1e7e267e7c1e107",
598 "tcId" : 65
599 },
600 {
601 "comment" : "prepending 0's to sequence",
602 "message" : "54657374",
603 "name" : "RsaSignatureTestVector",
604 "padding" : "30330000300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
605 "result" : "invalid",
606 "sig" : "0ded592bef1fa809841e0d7365e66af12f4239be0928656e7c49a043b9f2b18b9bd2dfe93a810c6e6c8ae6cb8a5c9d6e9d39a96a10b3bbdb92a7b8f575c2db4841c1b628160f956f54e0c58d3b6fd4d640b0a06d39476daba7be04b63a75f38bbf7517d9751d2b12d2dc00e44de7263275dce6b0c0af65d3c04878d6fc1be2ac",
607 "tcId" : 66
608 },
609 {
610 "comment" : "prepending 0's to sequence",
611 "message" : "54657374",
612 "name" : "RsaSignatureTestVector",
613 "padding" : "3033300f0000060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
614 "result" : "invalid",
615 "sig" : "95a42e5d9bd9ad5a8579444e8167bdecec16116a7900117b298c82d5560f1d16e9fbe963764727fef9111f2465e66177b576bdb8c70a58e3df6ff69edd2d6827c97d626b09c24cc49f223cd5d2db2916c54fd8f2ac7301723449b1823f2ff48c56849f7d608312d4bb7a97f90ba218f99cb773fba0a34909618f5d25854d7687",
616 "tcId" : 67
617 },
618 {
619 "comment" : "appending unused 0's",
620 "message" : "54657374",
621 "name" : "RsaSignatureTestVector",
622 "padding" : "3031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
623 "result" : "invalid",
624 "sig" : "2344c598a8905b350f20de5cf0cee60253729a54be45b0b19acc109ac15862efab2e7c96e92bc990ed6959a40d725c24c25c8d223a46f490905c1448d8dbf7c9c427bc2e896bdce6d2c1daabdc93ce177f9525ac69d899bded12443338834a16d885456057461740c5140cb9a89a017851f9e99e38c1727fe5ccad9a7a8709d6",
625 "tcId" : 68
626 },
627 {
628 "comment" : "appending unused 0's",
629 "message" : "54657374",
630 "name" : "RsaSignatureTestVector",
631 "padding" : "3033300d0609608648016503040201050000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
632 "result" : "invalid",
633 "sig" : "a08cbe4009080f73cef03116ea949d1dbacce7025f7f61040fb4e052754d5b2d74c2dd06c0dfe1d09b97aa5739c809bec6d8cb27e852e9fef353bfa32964b99495a6dc63d6ce77460ac280c74c0cabdef794f74930f7f8827af1c6690d22ec2df3af497837bbe900a890e3feeaca2c0d16b0017155390ff0396a35ecb62b5992",
634 "tcId" : 69
635 },
636 {
637 "comment" : "appending unused 0's",
638 "message" : "54657374",
639 "name" : "RsaSignatureTestVector",
640 "padding" : "3033300f0609608648016503040201000005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
641 "result" : "invalid",
642 "sig" : "500df36bd7d0b56642e2d5dab6e4ec0b148e7b8673cfab40e45c5dad5efc469b3321ce027a3a7ff5689366a18a32267d161a1266491b055f11557c35bd0d4f43df11b8a26f7b13c54be423b87b30b1dca956151c3ec3df03b30918a413179b0e064bf434736b323408e3f1330743c8bdbbb9d466dc1e21710c12e2e3b638b172",
643 "tcId" : 70
644 },
645 {
646 "comment" : "appending null value",
647 "message" : "54657374",
648 "name" : "RsaSignatureTestVector",
649 "padding" : "3033300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250500",
650 "result" : "invalid",
651 "sig" : "11a382fe570e0cfeb515955b70ec89a9353cda0c5a5d3cfa3e16e41340eccaa18ba21ad87c4a54a7131c4a7cf9afed68b1c1645568bab9b0fe7dfe0437abbe1fb6cf06bb690f46aa2eca034093ded661c38954341f3f35abe484015150307ecafd06d4309836771dfe29bfe56350d68725e0cd02b1479c6f99eeba2d59f40626",
652 "tcId" : 71
653 },
654 {
655 "comment" : "appending null value",
656 "message" : "54657374",
657 "name" : "RsaSignatureTestVector",
658 "padding" : "3033300f0609608648016503040201050005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
659 "result" : "invalid",
660 "sig" : "110f3f188df46da58cdd46b5d460ba3d2f8d00d907289634d52a3ce693eb232cd6db738c48c8aa22d923d4f81d55925b3d4ff29ad9869f97a244d37b860cbd4646c6318c041729a7aaf473b61a93cccd62fe223d1be00364f03d722f43c7beff98c3fde573e7e6a0ce7d4a2a4bcf279765e29769bd4f884ce41fb808ac3d541a",
661 "tcId" : 72
662 },
663 {
664 "comment" : "appending null value",
665 "message" : "54657374",
666 "name" : "RsaSignatureTestVector",
667 "padding" : "3033300f060b608648016503040201050005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
668 "result" : "invalid",
669 "sig" : "470416ee76f0bbdbd2812b533813e4463b799f4036e6955f3e174f6287e3c73d57c32875607e2eaf06d612cc85170ba5df31286edb645ae9ceb9e62064050f3e7f6b36fe8fdae7a3bd89b6acc523c923b9d3f3e5f57d80c9100b39dde75caf46adcae56668149ce0b80762bc459ac598241dd79c6b4fe0220ad53e3c591243fe",
670 "tcId" : 73
671 },
672 {
673 "comment" : "appending null value",
674 "message" : "54657374",
675 "name" : "RsaSignatureTestVector",
676 "padding" : "3033300f0609608648016503040201050205000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
677 "result" : "invalid",
678 "sig" : "100714ee0d38c541c2632e96885a7ce0afcb22f0cbd84c556f19d1b44bce75a8fdf141e975dda1812b4465050d4615a51c3b9816606c7ac88d6b684df938e7a8852835dcf5bf0ee45f2e413290691832095af77eef0e7a86f72167dbb03758e68561f7f06afc6e902ba19fad57e00cb43c0fb2a5ead689a146c79c9e6188bd85",
679 "tcId" : 74
680 },
681 {
682 "comment" : "appending null value",
683 "message" : "54657374",
684 "name" : "RsaSignatureTestVector",
685 "padding" : "3033300d060960864801650304020105000422532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250500",
686 "result" : "invalid",
687 "sig" : "44eaf5ded57ac5c25c17eb31c2e071400b46b9022641347b2edb0b14efbd4eac5f71e4bfbe791e164c003667387e57ae22c6b00e69971d7245e381f6459e5f88d9dc0fdb385b777fe99e5e4d79aec057e41a1e457fe2b91a5f4a8878d2eaa1c3ad8393d281eca07ebd287364a19045029fa7ed0e62a21e5e42a88a52ea4abc8b",
688 "tcId" : 75
689 },
690 {
691 "comment" : "including garbage",
692 "message" : "54657374",
693 "name" : "RsaSignatureTestVector",
694 "padding" : "30364981773031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
695 "result" : "invalid",
696 "sig" : "3b8b17b4c7b66b2fa3be8eb404e32b6fc0b9e56bbe678bddc8f7ef7c042c12ae5290b9c4201b35d10e409f3b7eb7760f5dee7fef09c30ea858b78bc9637dab245b8f83ee83c75a7aa3d5234b0b6dcdec385f8cd305dfef92aa83cc0ecde8f20f08af78b600c1f802695c243502397dd161b6151a72ac20596a7d7efd8e321298",
697 "tcId" : 76
698 },
699 {
700 "comment" : "including garbage",
701 "message" : "54657374",
702 "name" : "RsaSignatureTestVector",
703 "padding" : "303525003031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
704 "result" : "invalid",
705 "sig" : "762d30b302cd76b021e237f28017e48488ff3bb30ff9e92db5b1e76eec2ee91c9af03e1c5038afc22591b1cd8cfae648a33ab77901f9f3736e50eea83f7c7a4546dc55c0265fb17dfdd30250fa3881e34e51b4f2e54554ad098eee952ec888e911a0ea5df42c0560bcb4bdd718c88d834b534917e555c38fd1ec3593b2f25b39",
706 "tcId" : 77
707 },
708 {
709 "comment" : "including garbage",
710 "message" : "54657374",
711 "name" : "RsaSignatureTestVector",
712 "padding" : "30333031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250004deadbeef",
713 "result" : "invalid",
714 "sig" : "8cbf9d425abef67ff0a7fb648e70b82b1556ac80e46dcff37145b9041bee2bbbfa56817e04994c9cf1123c6df2aeeb1637595eb1e20adef51d657943fd67826ac5d5dfba106ae9cd243f12746917a446ce955034b46ceb0f4d542b7bcd06ad3e6e10899d5338e6d8caf3d4de3cbf45d45a58d946a64d0bc13e97a4ab4e6b6016",
715 "tcId" : 78
716 },
717 {
718 "comment" : "including garbage",
719 "message" : "54657374",
720 "name" : "RsaSignatureTestVector",
721 "padding" : "30363012498177300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
722 "result" : "invalid",
723 "sig" : "2f4944e5191dde165950a381eee6cce3fd40214e6a9851919f5441b4efb7ae5724db46e92a747937c3c8f9329facb7a71ad5f380e44dad0436cd05fc312bf3cbf05c4873ab2125d605848cf97ef976f7ba8ab6949bdac5152bf1a66945caeddbd89346965a33a8fe0a0ba63b59beb05a44b6d84e1fd93506edcc48da12d488a6",
724 "tcId" : 79
725 },
726 {
727 "comment" : "including garbage",
728 "message" : "54657374",
729 "name" : "RsaSignatureTestVector",
730 "padding" : "303530112500300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
731 "result" : "invalid",
732 "sig" : "975d07b7295268a8662aedbd2b65b5eb10bb496077f41b90d12d34ebc7e492f0c7f3a41d4164a279f06ea616f91968628be4ceecd4a554477bc76cc6b2e6bda4042dc253327c4b8fc40e9242cbc8b835114a7379a3081bae4b2803a99deb4a540f8c149ca5db3a61c7bc9f61cd7e55521660a06603849896c791a18d1c7360e1",
733 "tcId" : 80
734 },
735 {
736 "comment" : "including garbage",
737 "message" : "54657374",
738 "name" : "RsaSignatureTestVector",
739 "padding" : "3039300f300d060960864801650304020105000004deadbeef0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
740 "result" : "invalid",
741 "sig" : "37352cd11eb5ff7380bfb7c0d3e8d9979ae7cb489a71c31a077d59496547b0c95a760387ed50eefde0b762222f05a6033740f6e010693edf3ef8ab5f9c57f4eb1f6ccd83287dcc2e90857defe5ba4109bf79ad84ab069c85a25758d22536c6882919245fa2d7e7921b3635d984deeb6555cabdfc46a42c75875d55924c8bac62",
742 "tcId" : 81
743 },
744 {
745 "comment" : "including garbage",
746 "message" : "54657374",
747 "name" : "RsaSignatureTestVector",
748 "padding" : "30363012260e498177060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
749 "result" : "invalid",
750 "sig" : "05df1fa9290a68415b86468a57394c052f00abdd6c65eb4fbbd834cc117cee4bba99764906fdc46e78bd9d554d15cf0284a64dd0c19877115c425a1ba70c1a4339a54ba7fd60ec809b9b789dc06997c2f25e890d8bdb1bc945c0daa8c61feab5bca471bd520126b6db3d6077f55428e0e7374da961dc5cba5397604303eec6d5",
751 "tcId" : 82
752 },
753 {
754 "comment" : "including garbage",
755 "message" : "54657374",
756 "name" : "RsaSignatureTestVector",
757 "padding" : "30353011260d2500060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
758 "result" : "invalid",
759 "sig" : "1fb1960934683292a4c92cf3d582cd5fe68888a5b0f6c2e64538289da7f96a9efcc36bdbf1fdc0cc0b3b36c6af608309de58c6151112f3a78599ade4a718b359547a4cac9a020e5e7e7117d1bfeb3ec21bfe9732825e624b27ddf8a946eb858b30461706f769a54b0478e0753388951d98129383590186b80836608f7e06c72f",
760 "tcId" : 83
761 },
762 {
763 "comment" : "including garbage",
764 "message" : "54657374",
765 "name" : "RsaSignatureTestVector",
766 "padding" : "30393015260b06096086480165030402010004deadbeef05000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
767 "result" : "invalid",
768 "sig" : "7e4f953b288c20fd5bec56a00745db9be03590efcb637e2ce2119a0a1846e9f38c0ebc5f2498ebde6217d81c9939b6d6a6f35ba54ee50d6313d3f2579751e7ae8d31ef4b0e99ca2e96c80459a7e5ff51f6f31e9c965be19097de13017c90037aa482d197c986f50bf2d5e1acb3f3024605e46d963410a4a623c898d0d773a78e",
769 "tcId" : 84
770 },
771 {
772 "comment" : "including garbage",
773 "message" : "54657374",
774 "name" : "RsaSignatureTestVector",
775 "padding" : "303630120609608648016503040201250549817705000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
776 "result" : "invalid",
777 "sig" : "53b8fdeb2d8aee9796a56afe4934221610ad028ae6f9478c90d4e865f3f78b3d27b383f87086d50fc4d96c5004d8a22a0c5d32afad45fd68fcc3e9115bdfddab605c81f31d0a8ccffcfd5fdbfa0f0a4386649198b11c10f33ec5bd73c713a6af706e617a3a1e967f6ac025e7f283e49bb9ea1fe3a4f27d9f6caaf1bf4981ba06",
778 "tcId" : 85
779 },
780 {
781 "comment" : "including garbage",
782 "message" : "54657374",
783 "name" : "RsaSignatureTestVector",
784 "padding" : "3035301106096086480165030402012504250005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
785 "result" : "invalid",
786 "sig" : "90a5d10e2e19f7e016d5126a3d3eb91432611ebfd411b07a4be15aa48c39df33f3a2855f1e150ad34c7f83973bd73eca6575dcbac4086aa0a38db3d6e6ee2e9f419768493fb4829f1f6d67f80359f82d95483d6057de17fd388ae46687c429dea4d9f7a286c95fb1b9df0f1ba40a4263307789952b1bd07cdcb3b5cef10d9d2e",
787 "tcId" : 86
788 },
789 {
790 "comment" : "including garbage",
791 "message" : "54657374",
792 "name" : "RsaSignatureTestVector",
793 "padding" : "303930150609608648016503040201250205000004deadbeef0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
794 "result" : "invalid",
795 "sig" : "a88d38e8c765b7e439f42294e71c1689a318ed5414efdf474196989829d4989fce8910798f4d7873fb43d3a501fa15c8019813104e4699597246db66f96c838e45aa3596a1d26cbe9f6ee91c077422953b402f7e11f8768a2f132295bff79a0d10ab843cbcf2c921113992336638f4052446f52815328ba4946510a6b701d448",
796 "tcId" : 87
797 },
798 {
799 "comment" : "including garbage",
800 "message" : "54657374",
801 "name" : "RsaSignatureTestVector",
802 "padding" : "3036300d0609608648016503040201050024254981770420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
803 "result" : "invalid",
804 "sig" : "a34e59121976568352ea031232f6da386623a1c6866e36d6c6c07168de977faf6e008f14fe22a27d42664925f756f4b57f5258ceaa8197c3c172068dabf3c6cd46b3cf0262931bea731249781f28361c25cba9b64f678c0b2692056469624d0204bf2bf9c4e87407372838926e6b34e68cfb31e2870bfb5b0fdfa2ec1e177149",
805 "tcId" : 88
806 },
807 {
808 "comment" : "including garbage",
809 "message" : "54657374",
810 "name" : "RsaSignatureTestVector",
811 "padding" : "3035300d06096086480165030402010500242425000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
812 "result" : "invalid",
813 "sig" : "7f642b5702c331dd76b7ff66578a2c0547d91c556b7b9751443d911729fb5ce8426515ba068e2839cfdc956eb813c25d65a2d5213b59302c0ed5e6fb95c49002edb1605f8f622912fdc309d92e6e3f188ba19e991fab0a7018ae4f6e70927d91cffec51b2dcc8113908faa1173ec9ed72350aa93a8cadef8bfa7305bae22bdf9",
814 "tcId" : 89
815 },
816 {
817 "comment" : "including garbage",
818 "message" : "54657374",
819 "name" : "RsaSignatureTestVector",
820 "padding" : "3039300d0609608648016503040201050024220420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250004deadbeef",
821 "result" : "invalid",
822 "sig" : "0abb75f2fac084da0b99bc823c021c4872e23302a6a25e400b6f25d60f7c903899a69dc548676106b44f37c1e6d2604eb995a16880a2a8e2cc9e0ccb2b984ae482036f69a6ad31a2b5836e73e0d30c3e10f8b93c7587d7c0f2371183edc3b8cd0fd7bc325b1cf75e1079f8d6df53fe495722cc1ce707cca49bc6f4ed2ca6c4f9",
823 "tcId" : 90
824 },
825 {
826 "comment" : "including undefined tags",
827 "message" : "54657374",
828 "name" : "RsaSignatureTestVector",
829 "padding" : "3039aa00bb00cd003031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
830 "result" : "invalid",
831 "sig" : "9f2234b108a45abaed850e19d2f9576f59bb83dbc6165da61c4798638f9c98587c7eb92a8c901dc4430e4a47dc05681ae811ffcad6f7a604c43551cd0f5d123549435d622f7efec578301efd49dc6b139abbc3c7d6a26858f6d18f09b863a145d6483c9efc6c322fec1341b6362dc1d752c714efcdfb09097a0ce6df7dbe88a9",
832 "tcId" : 91
833 },
834 {
835 "comment" : "including undefined tags",
836 "message" : "54657374",
837 "name" : "RsaSignatureTestVector",
838 "padding" : "3037aa02aabb3031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
839 "result" : "invalid",
840 "sig" : "24ba137a293599ab7e50a0a4f8c7a5cd02dda6a4568c93f84d00ff47296564563c9051b334db2fd2c081b23d322d4870a61b2435d651d7efb4e1b0920e759f7fd81a937bbc85ff43dbe2b702dec3acf4db68d5fd7b8a2f6d32cc49a7300dd659623b391927a2442d69c6c3c29e59eb80b1d0a95bec6d18a6223cf4357eb7cc96",
841 "tcId" : 92
842 },
843 {
844 "comment" : "including undefined tags",
845 "message" : "54657374",
846 "name" : "RsaSignatureTestVector",
847 "padding" : "30393015aa00bb00cd00300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
848 "result" : "invalid",
849 "sig" : "04023dd35fa479f8156794d02935f8669c023c774b95c5a0e02837e32ccaf7a4ba5195835a15de6a21796eb96bdaed868f9e8b7f0a5a21c1a3058f53aadb62d6ee74cd70b2c38f17e42a1f7ffd88955731b4e15368211ad53f617aacbb54a7e7078740ba6daaca81c1b321b748ea1d13f7aece490226636ecac41bdc275175d6",
850 "tcId" : 93
851 },
852 {
853 "comment" : "including undefined tags",
854 "message" : "54657374",
855 "name" : "RsaSignatureTestVector",
856 "padding" : "30373013aa02aabb300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
857 "result" : "invalid",
858 "sig" : "253bed76e4b8465ebfffd1b7214ce586294d3bea290517ca2bfc417ba9d8e72d286570c348dc6084fd379c2bf4dae424189964639533e17c409ae18e445210ed4dc98de4ad7336554740d1532d5010a1bd7ebbc33ba48a3365d50669e4f4522d0e5ff7a3bdb1c42c42dee647a8a3ce16633eb33bbc0a869e12cf99f9481dcf85",
859 "tcId" : 94
860 },
861 {
862 "comment" : "including undefined tags",
863 "message" : "54657374",
864 "name" : "RsaSignatureTestVector",
865 "padding" : "303930152611aa00bb00cd00060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
866 "result" : "invalid",
867 "sig" : "0775598491297eb9004eed66234ded82e047ea2f06837425e6bd27f33b1373667f3ff4961d60f85edede88ec2bba2680151da3763f0df9785b31771da7e643862ff9ba944ab54bb1356ee113e420002a873f1eb381660f3eb84b1d6b25ccb8b82ad12ad0a449c4de205144873329e80ae8a84d1d3c1660b3303cbef28b48a553",
868 "tcId" : 95
869 },
870 {
871 "comment" : "including undefined tags",
872 "message" : "54657374",
873 "name" : "RsaSignatureTestVector",
874 "padding" : "30373013260faa02aabb060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
875 "result" : "invalid",
876 "sig" : "a73df043d06ae53a37773016a4e21d3f1093c50e079b189c4bd7db3e2e9875b14e5374cb8e7394a9f1b45c7e4e9dd516198bf5055b30ea4d205f39fddaab3da0cec63524bdae2ae166a3874c59057d93855d6e6314fc5da8111ff58666a73c00a105311859f27d2fb92f507531b9d681e219861e4f0b2b979c185af2690eb4f7",
877 "tcId" : 96
878 },
879 {
880 "comment" : "including undefined tags",
881 "message" : "54657374",
882 "name" : "RsaSignatureTestVector",
883 "padding" : "3039301506096086480165030402012508aa00bb00cd0005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
884 "result" : "invalid",
885 "sig" : "17e5a889b8139593e192f7af684c918f2751f157214863f88984ff3d8c9e381d1bee5ee788fc82869f4c3d8483e3c17c873a850a7a5c85e4518cbd8531b331a308a0368a868bb7995ce0f8a7ac5ba53b88c31c958dfabb36ed461472505b598418185b864f381342c29dc80e55ca7c2095e7788e7e8d385d61de605f74e431b9",
886 "tcId" : 97
887 },
888 {
889 "comment" : "including undefined tags",
890 "message" : "54657374",
891 "name" : "RsaSignatureTestVector",
892 "padding" : "3037301306096086480165030402012506aa02aabb05000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
893 "result" : "invalid",
894 "sig" : "a659f7c44e4589e9f6658b0b57e82e65d5ee9fbe2376894f558a7ca4b6e3c5032f953d1dccfb9b76bbc53dd5d1a52cfc092c6ca279b37c0a43c99ec0553d7ef4d9bf9361a1c4a3fb7496aa58c0af518312e18819fffdafd1a230a38440a6fbb0e69babaa977b8b5fe08ed7c6d59c0391ccd80b42a0c0102264b0ed6af8524e9e",
895 "tcId" : 98
896 },
897 {
898 "comment" : "including undefined tags",
899 "message" : "54657374",
900 "name" : "RsaSignatureTestVector",
901 "padding" : "3039300d060960864801650304020105002428aa00bb00cd000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
902 "result" : "invalid",
903 "sig" : "83fd4599a47bc0852ee1a12b2d97fceae6d8442fd089df1d21ecc252a410982410bbd2cc6bbca219502c2934ac593a09beefdeb54b0692b3e5724b79b0f5c53541b62b0c4bf80a658af71d5964fc6a1fd7823370d00e24dcead4bdc86bcd883fe3f48dc7f8468ce99b7580306007021b68b48ace274e3c09a1b5e21fc7542ef0",
904 "tcId" : 99
905 },
906 {
907 "comment" : "including undefined tags",
908 "message" : "54657374",
909 "name" : "RsaSignatureTestVector",
910 "padding" : "3037300d060960864801650304020105002426aa02aabb0420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
911 "result" : "invalid",
912 "sig" : "4bab6fc6948143f8ec7c8ad86a0c5cda5bd8151c24ca7916857778729c882581603363fde0ae2a28b6f8f2c8ce8d5f6b6e731bf8ef735bd31318069544295b54b04ff2abd1e11900373931164586d7c830bae704f7314eebf1d32b3a171274ed456e335d2a0b998ac441053ef096a037bfa6e5cdf3835c45ede383f0ee8feeec",
913 "tcId" : 100
914 },
915 {
916 "comment" : "using composition with indefinite length",
917 "message" : "54657374",
918 "name" : "RsaSignatureTestVector",
919 "padding" : "30803031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
920 "result" : "invalid",
921 "sig" : "2d9940c172e83a1ce38ce52741e694c7b62c77a63c0523ef68ffde402b0cdf7102afa7005a731d399757b69d313c2970a61f785c12fe79aad5398a956a2c004faec802691b00246cb759b0db432739febfef9abece7bd95e6ad980eb9d8b53886f739035b71fecd5e5ef0f0c0990a9f8fc0aa5d18089471dbd53488c23630415",
922 "tcId" : 101
923 },
924 {
925 "comment" : "using composition with indefinite length",
926 "message" : "54657374",
927 "name" : "RsaSignatureTestVector",
928 "padding" : "30353080300d0609608648016503040201050000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
929 "result" : "invalid",
930 "sig" : "69fd1dfca1b436593840f946e6113a79018c6cbc4e2b4562b12d06c03c7cfc1e724841ec59aeb0371c67a76a089a3f83f837255719bd648bc0888339c54223c25a238e717d1a90691fcf9690a3fef132f034cc03926ba8ae21dbb68467669cd19837907ca58237b6619be08a92ccf8e5756e3caec34a3c2a4622d7154a72256f",
931 "tcId" : 102
932 },
933 {
934 "comment" : "using composition with indefinite length",
935 "message" : "54657374",
936 "name" : "RsaSignatureTestVector",
937 "padding" : "3035301126800609608648016503040201000005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
938 "result" : "invalid",
939 "sig" : "58c64866f9c1b6cd94c33fd708375ee8462f89efb1c72322174a1c5ed9117885bfa4a02ef0acc16d6a078800b84e9fbdb7f8f4f232091326811e71639fc1321b31c15c9fccb68f77c79b2e39b817478539636966c0adb23407401a4c68e6cf5589104a5557650ac389e4fb2a64191014c4e8f9af48f8a28f555d5cc32d7a87aa",
940 "tcId" : 103
941 },
942 {
943 "comment" : "using composition with indefinite length",
944 "message" : "54657374",
945 "name" : "RsaSignatureTestVector",
946 "padding" : "3035301106096086480165030402012580050000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
947 "result" : "invalid",
948 "sig" : "0ba4e7900332ef20ad600bd4b8c0bab55c1030138c6131c1cf14a45fa98e10ea297ff6c2b8de3d92bcab6f1d303f4f8168848b2fee58ca40fb1f1c7eeb808c212b413f6f302d2e3904c2be2fa77fac21d04352a0abb07aae028e54d9e08ce37a6c210ae47095890d668cc1c296c9db1b5ddec30b722790260dc26c85e35f6692",
949 "tcId" : 104
950 },
951 {
952 "comment" : "using composition with indefinite length",
953 "message" : "54657374",
954 "name" : "RsaSignatureTestVector",
955 "padding" : "3035300d0609608648016503040201050024800420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
956 "result" : "invalid",
957 "sig" : "6f7b739d7e604a1123a232be4d0909a890eb3ad115f822b91592563a55fa59711f7ad17d1370abd4a6af6dac7ba08b6ae111291b0c8fd0626bc068022a8eff5ea5b797cc7fd35a81130a9394f051d2bb6bdf6190c11b964dbe2e4021a71ee8b405d0baf91ad5897d9ce22c8c1dd0e7dfee0e6abd979f5a1cd9443116c212b806",
958 "tcId" : 105
959 },
960 {
961 "comment" : "using composition with wrong tag",
962 "message" : "54657374",
963 "name" : "RsaSignatureTestVector",
964 "padding" : "30803131300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
965 "result" : "invalid",
966 "sig" : "53e00d738939553ca6f742ccc3671c88fd2319dc438d046f06011e088b57df8703813a53fa9c68a8b2de333445fb739726ac2b6ce3b2800e3082f48b823a06d0b2a83fc4c0b2e6a40fc2d86b73030e974f101dc6fd6a24abcc6cb347eeed08a4c8086d1fc5fd68b0b36fce0c79e5187c38c8a4cd35973b1755643aa28496fbd4",
967 "tcId" : 106
968 },
969 {
970 "comment" : "using composition with wrong tag",
971 "message" : "54657374",
972 "name" : "RsaSignatureTestVector",
973 "padding" : "30353080310d0609608648016503040201050000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
974 "result" : "invalid",
975 "sig" : "9382e341df276efda17aaa4410801a3ba0e4ccd5f0b61cde2416c7a8345cab1bb1fcc4a4a1d7c4a03a9d9ef68c83f2b3e08fc5893324159cd3dbae159bab67b109e55db550b540aa6142531528281732f63235785e145ea0defac4e67e825b30fbe9ff19687436d600ca412053e2430a1d1b637d4db255f1616713f3a2ad135b",
976 "tcId" : 107
977 },
978 {
979 "comment" : "using composition with wrong tag",
980 "message" : "54657374",
981 "name" : "RsaSignatureTestVector",
982 "padding" : "3035301126800709608648016503040201000005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
983 "result" : "invalid",
984 "sig" : "01ed4d8d4a342729f18182bc4f7645ca0a5216b57d4d26b874832983d19741673aa7c0e01705ada27ab779b9b84f431e83c621a2dd7ae5f501ec369273d297144b76477f4408bca5ef6a59053c1ffde80bc228f99dcaaffb4c520c507b3a941399042f0c535015d86b2b5a95696b71ed61ff2bb585442b85fa2477268b71f77e",
985 "tcId" : 108
986 },
987 {
988 "comment" : "using composition with wrong tag",
989 "message" : "54657374",
990 "name" : "RsaSignatureTestVector",
991 "padding" : "3035301106096086480165030402012580040000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
992 "result" : "invalid",
993 "sig" : "21782ca777e07848b600c37bb0a881707e580fe822d5dbb78f4809251a5cd74cb6f3636194cec8bab9040339da6531c730060ff5ac39ac9ad56a2371fe21e02ce08da18778d2256276c47ef0261d9c453360fbc4a2cc1dc7a8965ac2ccc17b460b0fe359ae4fa53f75efc68e96762cff5d98be46fbeacce2edf1d1bf5e158653",
994 "tcId" : 109
995 },
996 {
997 "comment" : "using composition with wrong tag",
998 "message" : "54657374",
999 "name" : "RsaSignatureTestVector",
1000 "padding" : "3035300d0609608648016503040201050024800520532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
1001 "result" : "invalid",
1002 "sig" : "1eb6de862a77d435e62635b620be37fc8be499500c19b4d87b3f993b9710f55476d3f3ac27d5ab2c1ec36dded088bc50ba5c0540934fdbb5ed3309babd766726ae833aec211a526caa82bf08f1704b66128f24c912c8c3719170090fe1a2738b0da32f91d35546a9a499618428d368b326203aeafce635668d3d5fde15762d84",
1003 "tcId" : 110
1004 },
1005 {
1006 "comment" : "changing tag value",
1007 "message" : "54657374",
1008 "name" : "RsaSignatureTestVector",
1009 "padding" : "2e31300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1010 "result" : "invalid",
1011 "sig" : "5770bbbb883f93f7c29bdab32e496f2e9063110fe648705fd0b1dc927052fc9ace9b36d898d19cd4f862b777b7c790d767b8313f735ff567c34cfb31f29644540645beea182cabdf789ff9ac3f68cc20444af0b9d4ec0bc8992945063fdb733cccef7590a10bdf491bc21c38f25ff65a581b40343e30529c3dbb71f62189ba3f",
1012 "tcId" : 111
1013 },
1014 {
1015 "comment" : "changing tag value",
1016 "message" : "54657374",
1017 "name" : "RsaSignatureTestVector",
1018 "padding" : "3231300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1019 "result" : "invalid",
1020 "sig" : "359dfbf40d3c2383f58bef1d518abe9852ca80d797393e4e1a9380ef08aa851d585213e8897c6f701ab680b0f63ccf5ea4216331918ca9a984fb6ba549f4bd066ec1fc4f1ed053fa5658b01df674a21322ba7e21fba6cbb3a8eb5565fb7bc269f99c65981efa650dde613ccd6d3927cdae45922d94dcf7ca5188bf5acf84035f",
1021 "tcId" : 112
1022 },
1023 {
1024 "comment" : "changing tag value",
1025 "message" : "54657374",
1026 "name" : "RsaSignatureTestVector",
1027 "padding" : "ff31300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1028 "result" : "invalid",
1029 "sig" : "24a61067121e9b4363b816b7c5750584c23f3c3200ca929fdedbe95d7504c56ea7dffd762074e44e96e22147943f2b704003967270b2be1bd1baadc3861c4cae91bd41530c67220349db4481d324d9927d52fe85618ddab2598996c5813f3299e1afb020b24003fa94f94a0c6c02b3183295e0de79eda021dccc5539cd7874ce",
1030 "tcId" : 113
1031 },
1032 {
1033 "comment" : "changing tag value",
1034 "message" : "54657374",
1035 "name" : "RsaSignatureTestVector",
1036 "padding" : "30312e0d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1037 "result" : "invalid",
1038 "sig" : "11b8d1dc2fa2afbc32f048d7454ba032b432a2ecd438506aa72c697a5c118e9e231a0c6b6340b5564402b7e837c59dd36f726fd626621b8f543964198484087eded70e7bb1dd63df2cea33198b9d02dd28e3b8bd006ba991a8b3bf06ac928bef45cba2362f2e11a5fbfb0310e84e8b7ba1e17c315adc1f34519134c36689619d",
1039 "tcId" : 114
1040 },
1041 {
1042 "comment" : "changing tag value",
1043 "message" : "54657374",
1044 "name" : "RsaSignatureTestVector",
1045 "padding" : "3031320d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1046 "result" : "invalid",
1047 "sig" : "8748f029d5294dc917cf4fb347e0046f903c088fd976ca97b1322738549df7c56cd67349d66596338fe418b29de9e8af8872fcdbb55e1a6f74e9965fe7a365b846b667d0ae50df23083be73cceb59db545a3e1a560f6ce0e9eaee57b5f95b8487a3987c00f364d0f148ead6d7e6a37b05456b913b7a79c0547b80da2a2893881",
1048 "tcId" : 115
1049 },
1050 {
1051 "comment" : "changing tag value",
1052 "message" : "54657374",
1053 "name" : "RsaSignatureTestVector",
1054 "padding" : "3031ff0d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1055 "result" : "invalid",
1056 "sig" : "2bfc087003f3b98f0c8c5273de34f5e4d5047e909cd80e222072f6a7926ced5ae169131342640f2be11bde2f7565c3c63d0335614dd278915514de8421f4521f0138109a5c9778f86647b8a42815b6b861f173f5a6df893873f99c5e62bc3c086150e3b7d7abb943ecbe5806068abc433e9052d9bdfa19a58d19da463dbf3b23",
1057 "tcId" : 116
1058 },
1059 {
1060 "comment" : "changing tag value",
1061 "message" : "54657374",
1062 "name" : "RsaSignatureTestVector",
1063 "padding" : "3031300d040960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1064 "result" : "invalid",
1065 "sig" : "0fe03eea6c50ab664bebc7d64346762aa29b08b61f2877973cd543c9533c9d0451db8d836eb46e8d64283306efd7ef6387cdc3c794f7474f2e7d51b9df078095adc85fb810cae52434c9cee5048fbff72610778397fd83204f44bb87f7637373d111dd16e18287bd9ffe816683bc3663f586082fe0811ff6a06c0264b67f7716",
1066 "tcId" : 117
1067 },
1068 {
1069 "comment" : "changing tag value",
1070 "message" : "54657374",
1071 "name" : "RsaSignatureTestVector",
1072 "padding" : "3031300d080960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1073 "result" : "invalid",
1074 "sig" : "748b9e64195314003ca31f726bb3d3294abd8eb376365acc5b1cd36934bbe1a9bae99ceb7c1a40c910bca6007ced7961ecc9ac74c7a6424cc87b6b9610320ab9c5b527d986c6e8ed21e677bbe2ee7752e2dbcfceecc2dd6da3f6c6b9c81435e9e060dcd67ba834729761dfc9570b79bb1b8ead7bc1325c2233e445eeed12dcad",
1075 "tcId" : 118
1076 },
1077 {
1078 "comment" : "changing tag value",
1079 "message" : "54657374",
1080 "name" : "RsaSignatureTestVector",
1081 "padding" : "3031300dff0960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1082 "result" : "invalid",
1083 "sig" : "7379bc96dd40d37a7f8e58f87c10fb94f250a964a55b2abead479b368e60e442e6eb864952308eb45eef1d318b6a5ffce634fcb886dbfa062060b9809cf89a09a26fd334ca22a1917fd219900ec0c68164c308cb9cbca3fb2b89ed8637c5540f7a5886ab1e52c503e20edd6316e41c746e53917e107ef5308590800ad378ac97",
1084 "tcId" : 119
1085 },
1086 {
1087 "comment" : "changing tag value",
1088 "message" : "54657374",
1089 "name" : "RsaSignatureTestVector",
1090 "padding" : "3031300d060960864801650304020103000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1091 "result" : "invalid",
1092 "sig" : "4a2478918565be6b46fe61e5f66cd1befb7a3026b5a1502e9a42636b0b924a02e85d7ffdfd8671b1d6d3e604e3ac6a5302db4e0ae0975d0661efa018d6ba0c632a6381368dcb75926542c74823a8c6d8732619764d5a61062fb3b17ae243bd691c97c8f9821af9526abcb522ec8e9dca32de1989e576e336af9dddc3e766541b",
1093 "tcId" : 120
1094 },
1095 {
1096 "comment" : "changing tag value",
1097 "message" : "54657374",
1098 "name" : "RsaSignatureTestVector",
1099 "padding" : "3031300d060960864801650304020107000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1100 "result" : "invalid",
1101 "sig" : "5ec392c91cc165ae59013337e7f7d5f2f9b3a6d45b6f6beee6dbf93e7b9607900f4672555a57de6e9e1aee1fc9b7adfc0dc00e122e84b0233c0d615dd0d79764fdc9d1b0e541f2de0083ab479f313a07f55f51390d1c2274858b219b1ec0601b82a2f7648ae95ec17099067a173e3e83959b6c06f149af0e4610761aab5be1a5",
1102 "tcId" : 121
1103 },
1104 {
1105 "comment" : "changing tag value",
1106 "message" : "54657374",
1107 "name" : "RsaSignatureTestVector",
1108 "padding" : "3031300d0609608648016503040201ff000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1109 "result" : "invalid",
1110 "sig" : "6173aef07a7057c3e97f6b7d4d7266918876f9fad86000b4c8ec7f83ee491563115b0cb5d580df8c97feb0d95866eabb79147926f5395c5189554749f4a2c75c0d96325971635be029062e1f27536c5041bb42f42e1fa10e21bb8e9a2e2502f2a7299dfe3bd8720ecb8a57238056ab0eb546de8dc0e56b317c73ab1e19772596",
1111 "tcId" : 122
1112 },
1113 {
1114 "comment" : "changing tag value",
1115 "message" : "54657374",
1116 "name" : "RsaSignatureTestVector",
1117 "padding" : "3031300d060960864801650304020105000220532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1118 "result" : "invalid",
1119 "sig" : "3b80c72f3b7ada8b38b30527bca41180b4a89b066f44a17b9df5963dca46517d9160326afee7a34b650b9e7746e764958ce6a0a6268481a8df40e0a95a81ab0f0bd20c050becfc0c4b03ebda19749a4a1dd3ce925fafd9a4006a835eedf221a6ceab6aac6bc74f743fe171ef8c01935f8901e1ec9ff6e33ae8311851fa14a65e",
1120 "tcId" : 123
1121 },
1122 {
1123 "comment" : "changing tag value",
1124 "message" : "54657374",
1125 "name" : "RsaSignatureTestVector",
1126 "padding" : "3031300d060960864801650304020105000620532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1127 "result" : "invalid",
1128 "sig" : "4b0eaf3ae1c7a3322dcfabee0569aaafba51e0f34fa6afc325bacc853ccd2daa3dca56c918325bf553af02ddd19fb597c368dd18892d52d9e935dc51d38347ebae2a7f90c78504355f6899ab4452d5f51d2025381d81042a08582dc50bc1078246ee69652043bb747969a7450659e333193990f34a8ce3f036221193e700489c",
1129 "tcId" : 124
1130 },
1131 {
1132 "comment" : "changing tag value",
1133 "message" : "54657374",
1134 "name" : "RsaSignatureTestVector",
1135 "padding" : "3031300d06096086480165030402010500ff20532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1136 "result" : "invalid",
1137 "sig" : "1fe7b390bcbd5bc1904e676111653e14e581e7817b45294bb790e4e62f3010aaaa77e246b29729f2b7da65a2f437b8d9c4fe3b26baad367a19fd7b1758d04c2f788c45e5309a833522b46d7255dd5ef70ed006ef966aa7c648bd0b893b8e1566961c16e9554fb729ec81819f1b3da890d413a153f487c030c7581da9531bf134",
1138 "tcId" : 125
1139 },
1140 {
1141 "comment" : "dropping value of sequence",
1142 "message" : "54657374",
1143 "name" : "RsaSignatureTestVector",
1144 "padding" : "3000",
1145 "result" : "invalid",
1146 "sig" : "317379f37cb7f21fd03259a27db3575d491a248df82e67b39d4956a1c619094fcde001544f0fa70c64dc0d0440fb21d2860a20a911cbb397792bf3eafa5cc050e78b1e7bb29d041cfa0287bdf54a90a7a8bff5c870e898fe34bb522477daf8e003bc22891b789ff215869cceb92610c4b03210d19506058d941e6fce7a3cd786",
1147 "tcId" : 126
1148 },
1149 {
1150 "comment" : "dropping value of sequence",
1151 "message" : "54657374",
1152 "name" : "RsaSignatureTestVector",
1153 "padding" : "302430000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1154 "result" : "invalid",
1155 "sig" : "2de802ddacb7e47e27875943d5098419bca3b170bf74f1c4b4a8ac420d4469d9aea97592fbeaaa1dcb5fd20bb97afc5f7abae17a9bb85c5490db97010c5217c88f9f52b5e209cf5fba5f0594f4e4450114dd0348ece336870a1333f7660caf959056ba13b77d35239eea164ddbc8808f8e7e1beb070f551b6e95f90d5bdbd925",
1156 "tcId" : 127
1157 },
1158 {
1159 "comment" : "using composition",
1160 "message" : "54657374",
1161 "name" : "RsaSignatureTestVector",
1162 "padding" : "303530013030300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1163 "result" : "invalid",
1164 "sig" : "09342a8fb8402b5e50fbf8c5d1cae415ce02c0a803adfed88188982129e8480918dc21616bb5f8381e8dfe13f63234090c32e542a005df70df5e8e00dd2a478d10fff1b61efbdcf0e410236f7c031c9a5f7cd0db9098f8a32a6a49f408e72c4a29b7d27e8041ba605bf089bbdb9777e19b31ecca0d49b90d54701721af79cf3a",
1165 "tcId" : 128
1166 },
1167 {
1168 "comment" : "using composition",
1169 "message" : "54657374",
1170 "name" : "RsaSignatureTestVector",
1171 "padding" : "30353011300106300c0960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1172 "result" : "invalid",
1173 "sig" : "3ef90c414a64601c538c286f2c35f32445039799b8c266eed605027578edda796a409d905a751bf5c1cdea97840437fa82733d8f27efbbc05da732887078a8f547bbfb54607a54f893df7dde0c35c45f9c2402bed0405c72e98175e5b9d6f90224e07d12e8c1bbad2fc8b1a14c42dd5fb7e554db5edae89d335705c672cd7b55",
1174 "tcId" : 129
1175 },
1176 {
1177 "comment" : "using composition",
1178 "message" : "54657374",
1179 "name" : "RsaSignatureTestVector",
1180 "padding" : "30353011260d0601600608864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1181 "result" : "invalid",
1182 "sig" : "3ad3e4ec3636b5eb8aac2161c04d228491ca0d9da2abd69d8904054373940b39b5c025c011c9b9508a25ec25b24a0837cdd6a27cb5c8ba3683d90ba5912ede9a21f2f7e851dc49dfebea8807576be703a6a87ca44c370db76812b9929a54fb8e2259453ccaf47da1b8ddc5b7322c20197604b9e028ec00bd7eb48012274d5b81",
1183 "tcId" : 130
1184 },
1185 {
1186 "comment" : "using composition",
1187 "message" : "54657374",
1188 "name" : "RsaSignatureTestVector",
1189 "padding" : "3035300d060960864801650304020105002424040153041f2eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1190 "result" : "invalid",
1191 "sig" : "778d93be708d56defbb6dedcfec2a917a3772b2810e26143db1f9d0f26c4fbb8de8db5818aa32ebb2cdcd7960e593ace2c3c3eb682c930cbffcfa6b34438ee2a786a9707d5d10902f7f4d8fc677106275fcb6cb08f56f341e0f52af590e0bdfa2f2bf95693265e87f5046bcf3e6de34810e8eaa479f3afa2b0a98b175007c209",
1192 "tcId" : 131
1193 },
1194 {
1195 "comment" : "truncate sequence",
1196 "message" : "54657374",
1197 "name" : "RsaSignatureTestVector",
1198 "padding" : "3030300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e",
1199 "result" : "invalid",
1200 "sig" : "a3e0e0cb9f7cdf8a2b95139f7c475f274bb63252385f62e66f82158f429e74d83df9ab1040717d34b6a5e009b6ac95960826ee83bb298ecf900425ff03a8f156053b57eac6086d61dd3a8085b84c83bebbe3270164e3147ddee8966a026796401fa48da70f5d949386eccad26b0016543f3f90c8ac2874100dce13f03845509c",
1201 "tcId" : 132
1202 },
1203 {
1204 "comment" : "truncate sequence",
1205 "message" : "54657374",
1206 "name" : "RsaSignatureTestVector",
1207 "padding" : "30300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1208 "result" : "invalid",
1209 "sig" : "84345c9d3de7b5da2156d3669a731c4baf6726c4c231bc8bcaef950d7ac37ca8d86e9c9558404f313de3fdf09024d25491b0a933cc3958033210b1c4f90070ddd083005873762566ff2cd7f6915b4cb430f5e7e1bca8c2ec32b4ddee48aba667f9d614a27c3bb40c6cb7f0cd77d3d17257f197974d1871cc09c9583cc6af8e15",
1210 "tcId" : 133
1211 },
1212 {
1213 "comment" : "truncate sequence",
1214 "message" : "54657374",
1215 "name" : "RsaSignatureTestVector",
1216 "padding" : "3030300c0609608648016503040201050420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1217 "result" : "invalid",
1218 "sig" : "227aaebca262d2189c479ab46d8715a34100bc1975c2d3991a4ade27376f068756cc9d89e903713bc28394d202d81b32126d7eb09154261841227cba6ea0a60d0ed9302f816fb4dd241dcd2d746d5c1b068c42c0b2bd567ef799cbfd0a83e8a30c4fa2f7296dceca38c36ab597ba992f658ef7955d32d38847870afbca35d836",
1219 "tcId" : 134
1220 },
1221 {
1222 "comment" : "truncate sequence",
1223 "message" : "54657374",
1224 "name" : "RsaSignatureTestVector",
1225 "padding" : "3030300c0960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1226 "result" : "invalid",
1227 "sig" : "a4316d438c7091b3bd5ec09aeea9095cb5046d8f08642b087c34985c34377bdafe74285d00862fba20572ce7a06dfe62b4fc08704d1cfb161cd88478e7e1c5451e0bdcce0fdd83c0e37fba5168ae03fcf4ccf60fa12c9b0acb39fe99b06933b9e0774f41151e0564ef805144c0cb76101672c287912197155d91bf036e84d1ce",
1228 "tcId" : 135
1229 },
1230 {
1231 "comment" : "indefinite length",
1232 "message" : "54657374",
1233 "name" : "RsaSignatureTestVector",
1234 "padding" : "3080300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
1235 "result" : "invalid",
1236 "sig" : "447904593d2796cb9851fc38f6494697af3eff1997568a320a0e6a50d62b484d7254c99cad3897f7383da73ee48ee824f7f6819c7dfce18021e7cb43b48cd77532c6af28e9adbe8005c576415c379bb7bd164a49010f0b243f60064f1986d1923146be8e8a4eceb9263445f32e49e5cef3e500467f3cfa9102b51b2772df803a",
1237 "tcId" : 136
1238 },
1239 {
1240 "comment" : "indefinite length",
1241 "message" : "54657374",
1242 "name" : "RsaSignatureTestVector",
1243 "padding" : "303330800609608648016503040201050000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1244 "result" : "invalid",
1245 "sig" : "01ce4a92bfbefd1de73607085c875704ff40751537bbce8ae2df9b10db01443154f415a936b38f937f7514763e20de0c55a1b441c5b10a09c7e09a7070cbc88becfaa8d39ab1cb93f4e2d1dfbc973715b04bf5d21f2cbab061ce36c81642fea43d0b11317961886d8783c628947b8f14be0864674e84c4af5f9dbb1f95b327a1",
1246 "tcId" : 137
1247 },
1248 {
1249 "comment" : "prepend empty sequence",
1250 "message" : "54657374",
1251 "name" : "RsaSignatureTestVector",
1252 "padding" : "30333000300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1253 "result" : "invalid",
1254 "sig" : "361f80a57ddb48796e50b3e6467cb00a9e1e193330ecd2cd6a31f649b49eac27e295450efe03e09e59f1829cc661d36b0fe904602c644aad7ec8cb2ca3099078b6d4f7b9233dc159fd1a6189451fedbd176e436f6605f2b889fc7197ebb520accd7f90e543da44453c7ba1948e83e31f5907d1989d982acbb348ca2216fe050d",
1255 "tcId" : 138
1256 },
1257 {
1258 "comment" : "prepend empty sequence",
1259 "message" : "54657374",
1260 "name" : "RsaSignatureTestVector",
1261 "padding" : "3033300f3000060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1262 "result" : "invalid",
1263 "sig" : "674c01596bf71fccd36aa81b000be007f6cff713e5f6ffe58b25e790f9a1f6542ba3f68e1eeaf1bb1ac6c3d55aeaf08140f6cc3d0474f6bd87ee442568346553ceb34efb5301a4d3a5b3f28a5fb038ccfe8444524d18adfa042aa1685fc3a5f9005da5688853b8660ba74f0e32c5be38c743b0048ca9b9fc19a35a5ff4e2c48f",
1264 "tcId" : 139
1265 },
1266 {
1267 "comment" : "append empty sequence",
1268 "message" : "54657374",
1269 "name" : "RsaSignatureTestVector",
1270 "padding" : "3033300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e253000",
1271 "result" : "invalid",
1272 "sig" : "07ba2b5d519b1f60dc455d6ad90b4135cb45c5da5a2a2c9b8cb954165394a0f40145ebf2b1a3ff1d47f5031d542d25041fe9b6d78aab623c40eedcd8467618168ad02af8a696573c5c63cae0b2c26583b0240848d663fdd0195322bc2c8dbf9b5db2ff9cc3e75e70480e51da0d6dd402fa87772ddef5256467205cf41a42d18a",
1273 "tcId" : 140
1274 },
1275 {
1276 "comment" : "append empty sequence",
1277 "message" : "54657374",
1278 "name" : "RsaSignatureTestVector",
1279 "padding" : "3033300f0609608648016503040201050030000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1280 "result" : "invalid",
1281 "sig" : "9fd302307455d4e946c1ccee65b0941c3550c823279cc52c4f29ecff72a12ac40ef6b7e37b7dd774b7735bbae89b0792908bafc47f0b0a11637042fc8541b346151bdadc3990e64b6d1807dd0e7f9266ceb3f686a9813341f835562d3c8c84868a1f98db97d3e695ce4a25fce80b828d010d6323120362ac48700abff8a7116e",
1282 "tcId" : 141
1283 },
1284 {
1285 "comment" : "sequence of sequence",
1286 "message" : "54657374",
1287 "name" : "RsaSignatureTestVector",
1288 "padding" : "30333031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1289 "result" : "invalid",
1290 "sig" : "247aa1cb69ccb72795c93809d7c3a5e52de98ec5285196058a6ab18ec2f5d9fef5545ab5df923f63bd58f5f247b3d824bf161bcb56d325d4e2fc7eb3765dd81b5580422abf2a3bca8d8af94cf6a9a3133b1494f66d5cbe938d30b9308b5ce2cc6d3df37d3299b6a7616d40afcc7935d80225e1a89a7a63ebff13a66e21280a6a",
1291 "tcId" : 142
1292 },
1293 {
1294 "comment" : "sequence of sequence",
1295 "message" : "54657374",
1296 "name" : "RsaSignatureTestVector",
1297 "padding" : "3033300f300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1298 "result" : "invalid",
1299 "sig" : "6d6248f823020a9604bbafe5acc103d9bd020624585c95805533de22afa3b6b1b511f8805296ee4d3e96d707c91e55df8959464ddb6d6a3d62b1cb248754302b2833406300f4975d913f1b90f95e3673e2c57d6181d73a360e8c818b8a9dd1e7a4fdcd68683f11dd47c2d395f20b0ce9c59eede6ae6aa58a707c4ea8d1a73a9a",
1300 "tcId" : 143
1301 },
1302 {
1303 "comment" : "truncated sequence",
1304 "message" : "54657374",
1305 "name" : "RsaSignatureTestVector",
1306 "padding" : "300f300d06096086480165030402010500",
1307 "result" : "invalid",
1308 "sig" : "941d41c39aa8bf3879d16cb78c5486589e7b97e56a0249c4f613060d26b786598fd2d34bc4e99cc8888137975937307d6a328059a09f3b994bf955c7de4a2841a0d10bbbebb2db3b332656f258c66c8d50cf9155ba94e1cb21a78e6147af76958ddd997665b6d8f67ea8f5e1fdbebd7df635f20494489c895d33ae4c7f248bad",
1309 "tcId" : 144
1310 },
1311 {
1312 "comment" : "repeat element in sequence",
1313 "message" : "54657374",
1314 "name" : "RsaSignatureTestVector",
1315 "padding" : "3053300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1316 "result" : "invalid",
1317 "sig" : "a32afeafa2c3b58bef55776ef6daaac6647485dde100d968e0449d1a2d5a121807ca2fdd70e2e9cf524cae4f263e11837000df85f0886b718ff45cd316c8d031b746dabfb956dd6118a37e0dabcda1ce9c728afd9a5f2448f5b15d27982218888d457752485119f53219315bf63141c9c0802327226a096403ece022cb27c0df",
1318 "tcId" : 145
1319 },
1320 {
1321 "comment" : "removing oid",
1322 "message" : "54657374",
1323 "name" : "RsaSignatureTestVector",
1324 "padding" : "3026300205000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1325 "result" : "invalid",
1326 "sig" : "6098a732419cd71887548ccf4fbf3edeaf9fe7b220bd747ae1b995b746de1f4d7b48c73ddb71903f50ccf7c93be9c8219de5a75ecc302ab50356069dfaf642f32ec580a283519fbcf04784860b0660174dfb7e1e527bb320960bde8f6c605bc3c1055b878d2adbb44e1b6c41add15cb603345c4fe2d1c0158fa03f21b4c015e0",
1327 "tcId" : 146
1328 },
1329 {
1330 "comment" : "appending 0's to oid",
1331 "message" : "54657374",
1332 "name" : "RsaSignatureTestVector",
1333 "padding" : "3033300f060b608648016503040201000005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1334 "result" : "invalid",
1335 "sig" : "2f08cdca4d621007acd15b1f4e3c39882a8aef706878e8f101e7fb250798a3528dcbf4d3327ceb0754a2ca0850794094dde8a875cb947d624d386ddb9593259c53ef2311260ac3c9cd1277050ec98d105188f590f198ba908ddcf3f9ed18f5a96cc6b353fadde007658f87ff4c201db7621d69c8278305f3e9f2041a2dddfad0",
1336 "tcId" : 147
1337 },
1338 {
1339 "comment" : "prepending 0's to oid",
1340 "message" : "54657374",
1341 "name" : "RsaSignatureTestVector",
1342 "padding" : "3033300f060b000060864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1343 "result" : "invalid",
1344 "sig" : "10078ea73abb9bbb879c9d8139b1758170fb73b34f39cdc83e6a725439e315a5cba4421fe15e8c80d8fda0a9aba9a12c23aab41f7328d4191e6c7c3a53a505ab518dce078439347945671ab06a2cd5375457b3bf181c40a1a4be1ea8305c9a401488532c7cdc1150fb9c46a2e846ce4a2fd9ee863d0b0b8af7f10360acc47f10",
1345 "tcId" : 148
1346 },
1347 {
1348 "comment" : "dropping value of oid",
1349 "message" : "54657374",
1350 "name" : "RsaSignatureTestVector",
1351 "padding" : "30283004060005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1352 "result" : "invalid",
1353 "sig" : "69a74665f61787b54b522937c534e95e91917f5dd4fa9e3472add6e21dc033a275408f35c71ff6cc029e25986fe6dced8ed053a9040aac32fc444e9252d2bd4081fe3e51ace15a0f694c0b8953dd6afa7f8cac67f4d8e17513b415c14b439a634274893885907e2ea428a6e242154a58a031fedae31c73df7cd4e2f5591496cb",
1354 "tcId" : 149
1355 },
1356 {
1357 "comment" : "modify first byte of oid",
1358 "message" : "54657374",
1359 "name" : "RsaSignatureTestVector",
1360 "padding" : "3031300d060961864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1361 "result" : "invalid",
1362 "sig" : "8f3b544724810d462cc9b19f356e61efe7c192dd63511a9f1f63286ca81f89477c2b464f8e51a97ee138dcf8c6709d79a78591081384af7cb5e182c9867b826013e6191efddddcc39909d3ffbb18944503b69d774c959831a8092f4790a4933521100c3e9741c3b58e1d24b75425ee28fde4e40c249b4dccd726cb06cb9ad2e3",
1363 "tcId" : 150
1364 },
1365 {
1366 "comment" : "modify last byte of oid",
1367 "message" : "54657374",
1368 "name" : "RsaSignatureTestVector",
1369 "padding" : "3031300d060960864801650304020005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1370 "result" : "invalid",
1371 "sig" : "3933d6937e977caac37a07a5c4ae503565af57e6c4e830004147f8bbf6784f79666d89cb4cac60e3f0aff2d5ed6a182921e490c958bfa49c86fcf0270914c102275b0878f01795c7a2f44a8a6f5306aa67a81f9294089876801503989e749d152c3e34906291f1f54bb6232fdd3d51e807f70927bf38ef70bd2ba45f0323acf2",
1372 "tcId" : 151
1373 },
1374 {
1375 "comment" : "truncate oid",
1376 "message" : "54657374",
1377 "name" : "RsaSignatureTestVector",
1378 "padding" : "3030300c0608608648016503040205000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1379 "result" : "invalid",
1380 "sig" : "7b2f6581fb0b4f913ed38c0ea20dff2bd60723f2bc3f1022ceb946e48adb75b1e0be031dd8b706d82967f93c6b6ba496d8c4b49aea9970e139b18fefdce30a4ec04f77625eaca4c7d1265cebbbcf53b63a113cf06bc50e4a416a771cd28785a0075631a3ef60c9212e224aaa063e7d8109c27e248e6422b26acd02ec012b7bf3",
1381 "tcId" : 152
1382 },
1383 {
1384 "comment" : "truncate oid",
1385 "message" : "54657374",
1386 "name" : "RsaSignatureTestVector",
1387 "padding" : "3030300c0608864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1388 "result" : "invalid",
1389 "sig" : "4dc9e86e076a395b530868d9fec9f858bd6e8c10cc1e32cae7653abb3f23991c677e970ee468c7f35022f3241f5d35673a8cf4ce9134b1e63a994dc7abc8cf4b9dbbb126b314312539931a0163c911f0234f5c3f683c9376f2ecaa3294d71a1274f6c63b84ea8faf826eacb05e4fa5459b787ff384b2cfe0f1f4c755f32b5c50",
1390 "tcId" : 153
1391 },
1392 {
1393 "comment" : "wrong oid",
1394 "message" : "54657374",
1395 "name" : "RsaSignatureTestVector",
1396 "padding" : "302d300906052b0e03021a05000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1397 "result" : "invalid",
1398 "sig" : "8bbc9167821885a728260bf9831120ecc42c14b2b07854169c86421146367d1bec66d8c3daadd115f16a29754e7fa8fb70a63966f7838484615d4364311b6c3f6e73ecd8ced0adb52db2c374297119f5fe571bd5396529d13b7225e87db5b5b0df38e4c56f2349071b09ff5c1ded919b398d4aff38c6ae29af6f6ff99d3e8836",
1399 "tcId" : 154
1400 },
1401 {
1402 "comment" : "longer oid",
1403 "message" : "54657374",
1404 "name" : "RsaSignatureTestVector",
1405 "padding" : "3032300e060a6086480165030402010105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1406 "result" : "invalid",
1407 "sig" : "2054d402bf6a148b52972b830c8c8a16a6aeddbcd5c2ae3fd83de67c666e712fa98650308658837a67ab87b2c444bedc7cf995c19af433da9343f260049b1bcb436ebe27d8a502728dfb0daac5d2710e2c39fa000b909aede07ad7a0d27629e0ac27ed9fcd41a39e09f7acdec4c2df77f38c535f46e3b96f2772a81e65e74bb8",
1408 "tcId" : 155
1409 },
1410 {
1411 "comment" : "oid with modified node",
1412 "message" : "54657374",
1413 "name" : "RsaSignatureTestVector",
1414 "padding" : "3031300d060960864801650304021105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1415 "result" : "invalid",
1416 "sig" : "3a94d241563a2ad97574ec82baefccd9dd114e21fa9169d0f54c4d0f57826224804ddc9b29c1905c59f39bd6aa3366705a85f5e6e18c0eb0f67986b5265e7371865b618e90e5c5313f0b6fce2343aa12d4ed44d6770fa08d4f1342608a4fb627a273f3a1f1340d1f5c55957ce51048e3690a845851009cbfe38d3c96e96d4172",
1417 "tcId" : 156
1418 },
1419 {
1420 "comment" : "oid with modified node",
1421 "message" : "54657374",
1422 "name" : "RsaSignatureTestVector",
1423 "padding" : "30353011060d6086480165030402888080800105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1424 "result" : "invalid",
1425 "sig" : "079cb62831dbeb40a638402865cc92cb49913dae214babc3f4f8d69d64cf14362c23c8dd6ebcee9c44633dd54a62bb2f0042c20033728fc2f8ff482cf0be3ee103bacf757b50319495d9a838844ea1064f4bd1f1ebdc1b71a318c3c8f7d76ebd79ef2f3991d4d87e110d60e5fc655adfa4a8e792e46c1c7aa96156b884e2f7a9",
1426 "tcId" : 157
1427 },
1428 {
1429 "comment" : "large integer in oid",
1430 "message" : "54657374",
1431 "name" : "RsaSignatureTestVector",
1432 "padding" : "303a3016061260864801650304028280808080808080800105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1433 "result" : "invalid",
1434 "sig" : "2c9083459ba6504dc10e0e63edf8ede8bdb4a9728673306908ad4e8f25656d4865f0748b9fd2cf7b51db0a2c659e0ce021fef3d2d3d0cf7c45343729c2001a19d37e29398a9a7e92d7f62693252261f1f7406b54af5447db6e846f981722059b7bb09ba95268c321c156ff659e0ce8e709d2819d5ce15f5dcfa54c55114a611a",
1435 "tcId" : 158
1436 },
1437 {
1438 "comment" : "oid with invalid node",
1439 "message" : "54657374",
1440 "name" : "RsaSignatureTestVector",
1441 "padding" : "3032300e060a608648016503040201e005000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1442 "result" : "invalid",
1443 "sig" : "9a76669c75f0f11399699f76e7bfbefc0d29feb5a8d86de1f751eedbb5c9e7b81ecbc224534db67cfe1b611951a6ff499d86e11cac4a1725e2ff707085a81a76c73d5b53d1b0b2c4fab2d2eebe57eca83242a261cfca768abcd8e1f42e3841d698bef3d4f16ac2dfab0fd42ef0abb0463474367dff7ec99d665a9838f2cfc24c",
1444 "tcId" : 159
1445 },
1446 {
1447 "comment" : "oid with invalid node",
1448 "message" : "54657374",
1449 "name" : "RsaSignatureTestVector",
1450 "padding" : "3032300e060a6080864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1451 "result" : "invalid",
1452 "sig" : "6674ec2352f0d3e90f4b72086f39815db11b056babc57644c8a703014f439baa46e8ed961714d5c7b5f0ec97ba3fe5ab867c16b7e1de089868dcb195fc20cc42fa1b3d3060f50cca77281bb6be18d65a1ee8e5a381e21e7f02e819752b71327a28719c7284f6425bc9241abb08d000faf58d48848d7f4b8d68b28266e663f36b",
1453 "tcId" : 160
1454 },
1455 {
1456 "comment" : "appending 0's to null",
1457 "message" : "54657374",
1458 "name" : "RsaSignatureTestVector",
1459 "padding" : "3033300f0609608648016503040201050200000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1460 "result" : "invalid",
1461 "sig" : "8d18a5e0a81522b56eb9e4f43bee15475cdfc7881006150cc230e76028283375a13425fe5a106f2626346a65817010a5510b157b234a16fcb9426909a524a288161537be91ab13033ed296f5f8c1e5c3bdb963f12d7b5eded46106f7c2dc1ae9c451415303cb7e6a3f59809b922183b9638197909d5730e5b1e89705fbbe8464",
1462 "tcId" : 161
1463 },
1464 {
1465 "comment" : "composed null",
1466 "message" : "54657374",
1467 "name" : "RsaSignatureTestVector",
1468 "padding" : "3037301306096086480165030402012580aa00bb0000000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1469 "result" : "invalid",
1470 "sig" : "80c9add3930a98b726fe543b4350c593d28e77f9f53f1ea04c2bfca30f157309eeb41e5a675bc0045823df8e99f2e55d2567f4b78e36eb8af1b45c50e33e6634dcfdc4094407b760d8b60f76995edd05920a6a89e22168a788557bfc7cf01d47d21448a65f9766bb217bcac1124020b6b062fd0e7bbe3e142ec88652eb617513",
1471 "tcId" : 162
1472 },
1473 {
1474 "comment" : "appending 0's to digest",
1475 "message" : "54657374",
1476 "name" : "RsaSignatureTestVector",
1477 "padding" : "3033300d060960864801650304020105000422532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e250000",
1478 "result" : "invalid",
1479 "sig" : "51640e26e8764936a7d9d709b3e0f52a5f1843453f2c6107a8e7fd6dad8b1c02ecc71659cd4134be952c03ee83c190bea4ea7260e5472c3cdf87b6ad45b5c974957ee9b4bf6f30152c2d939f722cff32e5482db96f3e283532b96716d3624daf16767e0ecdad16c97e56e4e076d64b92af329d2d6a2f8d14b59d1b84853659ab",
1480 "tcId" : 163
1481 },
1482 {
1483 "comment" : "prepending 0's to digest",
1484 "message" : "54657374",
1485 "name" : "RsaSignatureTestVector",
1486 "padding" : "3033300d0609608648016503040201050004220000532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1487 "result" : "invalid",
1488 "sig" : "9080bd4ac03b7ecedd45f8165360d4848bdfe1c9212ee1a4debc1aa92886cd7947a2df5435789bbb0b3e8f78815aac80e2cff14e1939e9ec32f42e7c29ed4029c88cafb64e8523dc85217c40d1bba900468a69c5bd4d12ac67401698fbffaa5159907ad459d3843e12487b3b2315c585881bc42e45543f7cf25110ab7e0a19f4",
1489 "tcId" : 164
1490 },
1491 {
1492 "comment" : "dropping value of digest",
1493 "message" : "54657374",
1494 "name" : "RsaSignatureTestVector",
1495 "padding" : "3011300d060960864801650304020105000400",
1496 "result" : "invalid",
1497 "sig" : "5f66f645307346216d3ba9c3d8b29e96270cb3b2e686a676fe975c10b8c26fda8d8eb172628bb3dcd726160c13ab8c5afb1d6ae943ea4c18d00465d97c0d2bcc27a63c18457ff8d6e3f5ba373b4be7b6f4c610f83578613f4fe41a40d86230afce0bb8d4496425a5bf0a80c6b1b1e2a981cd44c31a9aa603748c3d2fd2b85478",
1498 "tcId" : 165
1499 },
1500 {
1501 "comment" : "modify first byte of digest",
1502 "message" : "54657374",
1503 "name" : "RsaSignatureTestVector",
1504 "padding" : "3031300d060960864801650304020105000420522eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1505 "result" : "invalid",
1506 "sig" : "8ccff4ab4fd8534b6b50593f775bf6684391225adc37745e7ff25a4c4baff78a252aa1177ea3f3f09d2791da50ba19cef40ab8915379f128bba3271069cc2c02725e09f0b2cdfa0d313eba3f5a7e231588fd617b7d90b285e88a944d7d0a7fe9cc558dfe8103391ab2e6fbf762d829a55ed4486b5d888957078ffcf49e8ec352",
1507 "tcId" : 166
1508 },
1509 {
1510 "comment" : "modify last byte of digest",
1511 "message" : "54657374",
1512 "name" : "RsaSignatureTestVector",
1513 "padding" : "3031300d060960864801650304020105000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e24",
1514 "result" : "invalid",
1515 "sig" : "694b90d259b8dbe290f5851ede2ebf3bb718c1674ab1d3b7b6418e8ef7ea0760bf3ce69d98a7a3baae5aee488cddfb877972fa88ad05996879d0ce15aca53591423bf1b1b3ff02f823cdbb26bb80e3f7b83c3b7ac01ad7806335f871cd7b7e9e64708c200a9cd092589131aeb7db15655174000cf7db782bd54325ea956a1a15",
1516 "tcId" : 167
1517 },
1518 {
1519 "comment" : "truncate digest",
1520 "message" : "54657374",
1521 "name" : "RsaSignatureTestVector",
1522 "padding" : "3030300d06096086480165030402010500041f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e",
1523 "result" : "invalid",
1524 "sig" : "888cd9bdece5ceeef0fea92727ef1a1d996960f3f551bf108682f8103590323669ba1ab48becd14a49b87a900434d0ca7670d094b08b2f851834757bef580d2d3278d85b88036ea90d4c2a673dfafeb0c3701332c2b77493110d9b28dade7e985ec27240c90498372fc00ac8e0e5547e4d59cdd19022b8d961f3b63630b5448d",
1525 "tcId" : 168
1526 },
1527 {
1528 "comment" : "truncate digest",
1529 "message" : "54657374",
1530 "name" : "RsaSignatureTestVector",
1531 "padding" : "3030300d06096086480165030402010500041f2eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1532 "result" : "invalid",
1533 "sig" : "762c745262627d0df634d6cce41fb8af3cb855fc2d974b8093b035e9d11e510b9b7e7d61581b8f262fc1c4b8a6da3f6d609512e32f16416c7449c623c1773417032ddf2a559d7eb3af129fd02f83b5e35f5b5c065b1e0bc6481f38b6361f0b018b5e7166e8e67dddcf1550222f125efde241a27b0e7f670d15346dde082a8c4e",
1534 "tcId" : 169
1535 },
1536 {
1537 "comment" : "wrong hash in padding",
1538 "message" : "54657374",
1539 "name" : "RsaSignatureTestVector",
1540 "padding" : "3030300c06082a864886f70d020505000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1541 "result" : "invalid",
1542 "sig" : "27830ed405bc9d34009ec6258b766100273b4dcf2a9b3cf6ae31029837c6e24cf6e819734c1fd10c2c23db34d227d98d3498850f083ecd78b648baccfd4647a572607dedbc2b8ab7a595c0594ece904380e7f395ba4840a81367e99275cde1064fc6f7fbd564c5f26ddd0103991ae8262eaf16623685b43f77ea7a05d080166a",
1543 "tcId" : 170
1544 },
1545 {
1546 "comment" : "wrong hash in padding",
1547 "message" : "54657374",
1548 "name" : "RsaSignatureTestVector",
1549 "padding" : "3031300d060960864801650304020205000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1550 "result" : "invalid",
1551 "sig" : "4cdfa8cd615bcdefa253d75212e4ed0a1fd60841656c6a749690cb0c6c3cd723b518560c3b11a734010acf6e38f0526338351d9b58351826b360c851d3c86429f38eb689e8555aa2a23157e197faebdd29bc49f84c10dacca655cd5fa50fdec86a72f0ff1c7f8feeec31fee188fbfa72776a7b5cdae1c1506830bd3a00181b13",
1552 "tcId" : 171
1553 },
1554 {
1555 "comment" : "wrong hash in padding",
1556 "message" : "54657374",
1557 "name" : "RsaSignatureTestVector",
1558 "padding" : "3031300d060960864801650304020305000420532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
1559 "result" : "invalid",
1560 "sig" : "024746d8dd71ecfe33cf0ad7ab8ddab9dfeb5740ec47b8ddd668f07b8f7610f726692404ac14c3a1947ff4246fe0a9e216131489125e71df68d60930fac06a20e948a3e4948aff5e3f9772155f8bd6772b1cefd8180ae719afc061e2f0d68a69769930b8d90ca4ecd6c7b20d04f0cc939502e698ad1c500403763c0205f6870d",
1561 "tcId" : 172
1562 },
1563 {
1564 "comment" : "wrong hash in signature",
1565 "message" : "54657374",
1566 "name" : "RsaSignatureTestVector",
1567 "padding" : "3020300c06082a864886f70d0205050004100cbc6611f5540bd0809a388dc95a615b",
1568 "result" : "invalid",
1569 "sig" : "3a152ced8b5e0efa33cd57d4afe67f31ed3b9fb22e7b0ff32795cd9510374fa09fc63a3366465f83ba4d44e36418a5c1d171b6ca05d8c74a242983d5e5912cd05bdbd75fcfd5b4eda7cadab21e6dcefca8e2ab7303871ef360beff45564a01bdc887d9e849e407c6aa5b12055647f6c9df49758d1272f7cb476f51088e21f246",
1570 "tcId" : 173
1571 },
1572 {
1573 "comment" : "wrong hash in signature",
1574 "message" : "54657374",
1575 "name" : "RsaSignatureTestVector",
1576 "padding" : "3021300906052b0e03021a05000414640ab2bae07bedc4c163f679a746f7ab7fb5d1fa",
1577 "result" : "invalid",
1578 "sig" : "3765b8800e6ccf29544d834034e39f8fe7a2e6dfd7e6b4a8f81df091bbfd7aa17edfa6005024fe04d35c340a2215fd3f1cf4b4dfdd3c8ad09e6df2c2256c7541e19c2e80051d1ef5df5c384bfb6be88c4415eb2740db2d9fb3214890a8a0f19146dfb7897bacc02700a89139dc8fb21b2a7bbfbd43604d7f384cc00aecefb4ef",
1579 "tcId" : 174
1580 },
1581 {
1582 "comment" : "wrong hash in signature",
1583 "message" : "54657374",
1584 "name" : "RsaSignatureTestVector",
1585 "padding" : "3041300d0609608648016503040202050004307b8f4654076b80eb963911f19cfad1aaf4285ed48e826f6cde1b01a79aa73fadb5446e667fc4f90417782c91270540f3",
1586 "result" : "invalid",
1587 "sig" : "5c5b097c21ac2eb156de39d1eaebe3b96082f54b0171469a94edf7d2027ebfdebc0837f766cfefec577e7b797c7a082df2ecc826e55d39927b01c2da26f8f6814ec993e3b93ee87a3418322b65ac652b3bba6d34373a13fd40b66be489938fadf67bbda762f6ee09a1ddc41382051d4a9a946e0df832bc65b7d5dd58cc5a402b",
1588 "tcId" : 175
1589 },
1590 {
1591 "comment" : "wrong hash in signature",
1592 "message" : "54657374",
1593 "name" : "RsaSignatureTestVector",
1594 "padding" : "3051300d060960864801650304020305000440c6ee9e33cf5c6715a1d148fd73f7318884b41adcb916021e2bc0e800a5c5dd97f5142178f6ae88c8fdd98e1afb0ce4c8d2c54b5f37b30b7da1997bb33b0b8a31",
1595 "result" : "invalid",
1596 "sig" : "0ede4ac9ffcb6d3d42c75cf73303a28ba6089941f68dcf392a75b071f6c149a109cab95b80a679ca3b29ae44e51c18a2db4c72211ae6b959c7f22e854c45f20f5560446f33be4819f08d981d2fb176d48039ac4acd28127d593f9e219ad40e2a5ee911b334b3b8bb290f2327524e3faae2c028745e03d58882bfe503c4ff04b2",
1597 "tcId" : 176
1598 },
1599 {
1600 "comment" : "using PKCS#1 encryption padding",
1601 "message" : "54657374",
1602 "name" : "RsaSignatureTestVector",
1603 "padding" : "0002ff...00<asn wrapped hash>",
1604 "result" : "invalid",
1605 "sig" : "6c0b3edf5f6e5d3f07057d0b752e89cfdd1c289ad18a0ba94670cd36547734e2c7bb32dd49709f0f7149944c450c23b7f2d360e3602cad5ddff7fd9d711eef6dd4c32e66c4433f041fffefe112024a655bc5bacbd0914bbb2b2a41a91b1293fe9478ddca926a13e6131cc5e9b70625eac1e533ce8171a2dc7b2c4a490e966445",
1606 "tcId" : 177
1607 },
1608 {
1609 "comment" : "using PKCS#1 encryption padding",
1610 "message" : "54657374",
1611 "name" : "RsaSignatureTestVector",
1612 "padding" : "0002ff...00<hash>",
1613 "result" : "invalid",
1614 "sig" : "1acce04e348a5c8377c54d8ddd8ec2d8c5cb9b195863c32eb716745f3462b5f249b612aefb31ba484949d0a0cb5cb8e1f06c1cec58fe5ffff6ba796218c46c3e527c7ab0c4276ccbafd133812faec33721a08542e7e3a34449bebbb28bd0f28994c6801ba5c971991004e31de8f728f6bc37a4ec7b049c1f2dc64d4be9415462",
1615 "tcId" : 178
1616 },
1617 {
1618 "comment" : "invalid PKCS#1 signature padding",
1619 "message" : "54657374",
1620 "name" : "RsaSignatureTestVector",
1621 "padding" : "0001ff...ee00",
1622 "result" : "invalid",
1623 "sig" : "61a4066d0b64964100ecf583325cad10b53912aba1bf3606720d2bdd8e21120bb0b5e4323987d96039819ccce0e5e90854bc0e5c239ab198f75b00355a04e4eb1f855f76697cd65732820575306eb9323954bc5913568a7278fcdeff8e8acad4481e3559f8c44a0be3bc02bae437c3146e4516632b3fe788c3a0e44171155728",
1624 "tcId" : 179
1625 },
1626 {
1627 "comment" : "PKCS#1 padding too short",
1628 "message" : "54657374",
1629 "name" : "RsaSignatureTestVector",
1630 "padding" : "000001ff...",
1631 "result" : "invalid",
1632 "sig" : "979a313677883b0980997f1cb525f43401739945860149dcad80f602df8abed4fd85bcd6e174d9183a5a44008fd77b5a5abcffbcfd4f47ccd2dabef963d9b228310d99000ed0cebbf61438cbe586985bcffb3923a8467a97ae791d0b04925c0894b5a41583d6de72d4369f481f66abce41a577fb128fc0b0aeec746ec089d834",
1633 "tcId" : 180
1634 },
1635 {
1636 "comment" : "invalid length",
1637 "message" : "54657374",
1638 "name" : "RsaSignatureTestVector",
1639 "padding" : "2 bytes too long",
1640 "result" : "invalid",
1641 "sig" : "ab9014dc47d44b6d260fc1fef9ab022042fd9566e9d7b60c54100cb6e1d4edc98590467d0502c17fce69d00ac5efb40b2cb167d8a44ab93d73c4d0f109fb5a26c2f8823236ff517cf84412e173679cfae42e043b6fec81f9d984b562517e6febe1f72295dbc3fdfc19d3240aa75515563f31dad83563f3a315acf9a0b351a23f0000",
1642 "tcId" : 181
1643 }
1644 ]
1645 },
1646 {
1647 "e" : "10001",
1648 "keyAsn" : "308189028181009e62337ef7d4fabec2561bb45a18a362022b23666571bbc762c1c717a14a46d8f58119072aa26245e71fc6945540335163798fcbdea04b3104ee23f2c3874bbfb3e7e0c1ba5f1fca909265274414db6957a5eb668e0e36a388784355d528e51a6a4a9a9c6b6ab912812a268dac9dcacf1c13507768e63b1f82f8af29c3786a170203010001",
1649 "keyDer" : "30819f300d06092a864886f70d010101050003818d00308189028181009e62337ef7d4fabec2561bb45a18a362022b23666571bbc762c1c717a14a46d8f58119072aa26245e71fc6945540335163798fcbdea04b3104ee23f2c3874bbfb3e7e0c1ba5f1fca909265274414db6957a5eb668e0e36a388784355d528e51a6a4a9a9c6b6ab912812a268dac9dcacf1c13507768e63b1f82f8af29c3786a170203010001",
1650 "keyPem" : "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeYjN+99T6vsJWG7RaGKNiAisj\nZmVxu8diwccXoUpG2PWBGQcqomJF5x/GlFVAM1FjeY/L3qBLMQTuI/LDh0u/s+fg\nwbpfH8qQkmUnRBTbaVel62aODjajiHhDVdUo5RpqSpqca2q5EoEqJo2sncrPHBNQ\nd2jmOx+C+K8pw3hqFwIDAQAB\n-----END PUBLIC KEY-----",
1651 "keysize" : 1024,
1652 "n" : "09e62337ef7d4fabec2561bb45a18a362022b23666571bbc762c1c717a14a46d8f58119072aa26245e71fc6945540335163798fcbdea04b3104ee23f2c3874bbfb3e7e0c1ba5f1fca909265274414db6957a5eb668e0e36a388784355d528e51a6a4a9a9c6b6ab912812a268dac9dcacf1c13507768e63b1f82f8af29c3786a17",
1653 "sha" : "SHA-1",
1654 "type" : "RSASigVer",
1655 "tests" : [
1656 {
1657 "comment" : "valid",
1658 "message" : "48656c6c6f",
1659 "name" : "RsaSignatureTestVector",
1660 "padding" : "3021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1661 "result" : "valid",
1662 "sig" : "8aa2c8a167fa230a1d1ea6bf5286d3ba6e675ca57cc5ca8cb26fdf465810c19af36cbdf843319f7af9b2954f372ef16891918aaa2ab64dbd1cd0ea54351ff2b3437fae5ec947971662c1f75ef6892b6899b77343fe87665c5b74df322b59f017e5488a67ec836ccc3f873788d60992d43f64b736507c455b649119373ba1aea4",
1663 "tcId" : 182
1664 },
1665 {
1666 "comment" : "Legacy:missing NULL",
1667 "message" : "48656c6c6f",
1668 "name" : "RsaSignatureTestVector",
1669 "padding" : "301f300706052b0e03021a0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1670 "result" : "acceptable",
1671 "sig" : "707e19417b5b3cb975795e5d53cb2db69bf80699e69114955aea5ff45755eb365fd34a18290db1975c32388eaed0d446b44138bf18b012f7da3ed067de6e444a5a66a35633c875254ed3d1b120ce657873e888af703e649076b368e90d761cb3e14cf79099026cb4a4c1f20c771c1d7544fccebd6d642506146e3d28acb6cf6b",
1672 "tcId" : 183
1673 },
1674 {
1675 "comment" : "long form encoding of length",
1676 "message" : "48656c6c6f",
1677 "name" : "RsaSignatureTestVector",
1678 "padding" : "308121300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1679 "result" : "invalid",
1680 "sig" : "5b4cb0b22300dc4913e7c1cb82e86663462e4b30d03053f697d59252e01339cd230b72afc8623e185db939108f3a47814f418b5411dbd3365d45b609f93b1f4fa10b7b908430a9f7d97037161cbeb2a1af0223b6657179a9bd2efa8c40a2f57b20755042b401e81d3fa3d4faf69d05cfdf3b7c3d5d3cce8fe036e9899db34de5",
1681 "tcId" : 184
1682 },
1683 {
1684 "comment" : "long form encoding of length",
1685 "message" : "48656c6c6f",
1686 "name" : "RsaSignatureTestVector",
1687 "padding" : "302230810906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1688 "result" : "invalid",
1689 "sig" : "264bb84974efc808ded6a363c50bba6c1ad8acea4d26f86afb81839d8ecfe7041db3ace271f308399bf3bd2effd70c3b17e968f084867a0d95299a8dd0bc27e516925d3b8c0e748d5f91dfc87eebc383ecfdf6bf46cd28912bd4cfb9949f7660f1dbdba527db82cfca5aad1f99cebb1d7b554d4038238a4755b25c2348397e2f",
1690 "tcId" : 185
1691 },
1692 {
1693 "comment" : "long form encoding of length",
1694 "message" : "48656c6c6f",
1695 "name" : "RsaSignatureTestVector",
1696 "padding" : "3022300a0681052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1697 "result" : "invalid",
1698 "sig" : "23fad8546f338cec2aa7fd93387b8f1e735e3fc3337350276efad8950161e6cbc7dfd28c7272be65c9dd469cbfc8ddeb6945880234a60c0778d5e8f185b95b0caeda346ce5b8231f94c076d056e2aa7245072ee055f37e7392ad4c158dab92263e4803d82939c7ede603c3467c14c61a5743df002358cc63eab3648d8ca8ec2a",
1699 "tcId" : 186
1700 },
1701 {
1702 "comment" : "long form encoding of length",
1703 "message" : "48656c6c6f",
1704 "name" : "RsaSignatureTestVector",
1705 "padding" : "3022300a06052b0e03021a0581000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1706 "result" : "invalid",
1707 "sig" : "64513a079e0bd31939110d49d36101fd2a49c6d940637b9900fd317a64d174ef64acea808329b700954471c8282d1f246ca3172481fddfda77bbe24deb8d3d20200e78ee9cfbd97b063c1da700a50f635cc32ed74efc59407b8af422e01f728997c9a2dd6f8fd0fc89c9c5a9b0a2038cb006f3e8a8bd86ec129db6ae95b18ffd",
1708 "tcId" : 187
1709 },
1710 {
1711 "comment" : "long form encoding of length",
1712 "message" : "48656c6c6f",
1713 "name" : "RsaSignatureTestVector",
1714 "padding" : "3022300906052b0e03021a0500048114f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1715 "result" : "invalid",
1716 "sig" : "79547cc01aba5ccca5e0337304e02c48455df528e61037516262e151d4378f3447a730b894d63974c3df0cecd708bffd53742c908b718ea1e09786f00b58f434a10e5014fc5ee96c8c87aa0cd73348a470c369b71bee3d78e3b7a640d605736f3b3691253d853473e34e0eee9533abf655e0e490744a354309c3639ca5e0e084",
1717 "tcId" : 188
1718 },
1719 {
1720 "comment" : "length contains leading 0",
1721 "message" : "48656c6c6f",
1722 "name" : "RsaSignatureTestVector",
1723 "padding" : "30820021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1724 "result" : "invalid",
1725 "sig" : "6dde5d8a638e4cda4551a295aa037c0db901578d70b6943d58f842e2b334822e986506768fbd73bd46e62f11acc308eb9b0f9fc8831729fdf630bb0b9ac8a9ce484e1fdf5d1099659ff452c132096d085b624e521ec0cd76449f50e57fa39adfb91d1c4cad4b9651cfda905689c24b3118970f78ca6240b48cba83d19da8ae91",
1726 "tcId" : 189
1727 },
1728 {
1729 "comment" : "length contains leading 0",
1730 "message" : "48656c6c6f",
1731 "name" : "RsaSignatureTestVector",
1732 "padding" : "30233082000906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1733 "result" : "invalid",
1734 "sig" : "28a4c4957ee24b104aa7f68d8d7fe5275abfe1c449f6e2d41d2741081e4e0248ff40acbfe0bf7652af44f4f369de583c355af6a5af87500330710b976f1bd3a705c216255d71589c341b237024337d38161946dd0ee3fc822b06c96775c6be57a906eb7c6178751537bb181e47acae959862253c34e979c3def80038488d0482",
1735 "tcId" : 190
1736 },
1737 {
1738 "comment" : "length contains leading 0",
1739 "message" : "48656c6c6f",
1740 "name" : "RsaSignatureTestVector",
1741 "padding" : "3023300b068200052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1742 "result" : "invalid",
1743 "sig" : "08cc5258ab3d68d796e5dd868d676ce9c2774d1eb6a16b4bbf0acaa0baf9d812ed0138a17ab8a64dbb913e33a88a388883889bfde6922cca5ca98d5fd1ac13fa87eb1b5701cb4ef5271057b39cceafa0f8509f9151383058a1349460db1895b3d7fbc043771ebd48538e9c208c34719f21b2d60dfb7a06a3ef42d1f2a90826b8",
1744 "tcId" : 191
1745 },
1746 {
1747 "comment" : "length contains leading 0",
1748 "message" : "48656c6c6f",
1749 "name" : "RsaSignatureTestVector",
1750 "padding" : "3023300b06052b0e03021a058200000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1751 "result" : "invalid",
1752 "sig" : "118bdd711ce909f3e6894be2c5f7fbd21b6e542205e63447848bd6be079874f2858e9640ca8723cd4f73d1d272780aef52200d991cf620f7345f20ed4b5c978f93dfa495a24680c762ff1f1c4c3d0513b818b2cdedc63cacaa76af3b4672e0c3eae523b410d7c03ce4b9d2f65f92e580e4e7f04d3f62047db3968e33f0f1f40c",
1753 "tcId" : 192
1754 },
1755 {
1756 "comment" : "length contains leading 0",
1757 "message" : "48656c6c6f",
1758 "name" : "RsaSignatureTestVector",
1759 "padding" : "3023300906052b0e03021a050004820014f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1760 "result" : "invalid",
1761 "sig" : "7c2ddfeb9611939302c4791b44d2eaec63ba700853c84c928e11f50a5fb15c47a2f0ad91962aa88e944c0a655db19ea4bda87e386ae820fea49725c75e13b26a7c7d9dc63e353259d318246a3ec3c4b7d2ff8e6af164fe73ef35eeb76e921a523f48db83d541b3abca995d807968cb960fe192ffc0501a0840a1f5bf1b332123",
1762 "tcId" : 193
1763 },
1764 {
1765 "comment" : "wrong length",
1766 "message" : "48656c6c6f",
1767 "name" : "RsaSignatureTestVector",
1768 "padding" : "3022300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1769 "result" : "invalid",
1770 "sig" : "5065698891c73f55ade9d829053b14086b977af8f8ddcb9d2b5d236bced0821b00cca31a26b43a838ed36f96d823205fe79644ab4d431d2072f823bf9dd60bde8c2af3e2f4af0fcd734f285c0f8e0b9e5cfb5b7cf5d4131ad2122862c7bb6d9a9d6a7ec674703c79e4712ea84bc178da4bbf08355b2c248a5887a9b87702f70d",
1771 "tcId" : 194
1772 },
1773 {
1774 "comment" : "wrong length",
1775 "message" : "48656c6c6f",
1776 "name" : "RsaSignatureTestVector",
1777 "padding" : "3020300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1778 "result" : "invalid",
1779 "sig" : "33ab162433e5c9677c2ef33d2949c64167afc165223a79ea96bc1096e0654db370f84b30f3ae03da910e6343fdc9f7413e9422f76dfe4287dfaf7250567076a4b2cba812b784410ff19f412df89f1af8b9a5ea4809b7f60b8b5b4063d07dd17311b5b0b75599ea8988c605b06cee2b6bcf79f20ad7c4bd67cf179511ceb9fb21",
1780 "tcId" : 195
1781 },
1782 {
1783 "comment" : "wrong length",
1784 "message" : "48656c6c6f",
1785 "name" : "RsaSignatureTestVector",
1786 "padding" : "3021300a06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1787 "result" : "invalid",
1788 "sig" : "7cb2655e9bc1e633b46656d28db5bf457cfd6a6557ebe511a694ecd36987fcf94a6de7a3f73d47777990697b5663fe59b838fc0a7fcc0604a08e951fb1ef4dcdae0bc09c6733815a65ed465e86e98bd08ccce8df0a7822f1dd74fd8ff7add8314387ed2bb5474c7c282333bcc962af3f0506a15971f30967f49bbb22cf3e99d4",
1789 "tcId" : 196
1790 },
1791 {
1792 "comment" : "wrong length",
1793 "message" : "48656c6c6f",
1794 "name" : "RsaSignatureTestVector",
1795 "padding" : "3021300806052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1796 "result" : "invalid",
1797 "sig" : "5e147003f7061b46a6046dc91374cbb2f1113ddb56dee64f203a513b421330655c123fc2c51a79ce70fef2884b6b444ff8639d5448a0781f8f0503009cac89a58fa0bf73b698011d80986379dfa0b8923591f2c310cdea8982f8b87dffc4ce27e5a1a75f44c40e95898d0ae12cabb94fff41116f1d96dfc8fb5834965b750cbc",
1798 "tcId" : 197
1799 },
1800 {
1801 "comment" : "wrong length",
1802 "message" : "48656c6c6f",
1803 "name" : "RsaSignatureTestVector",
1804 "padding" : "3021300906062b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1805 "result" : "invalid",
1806 "sig" : "8cf10e501268713c12ae5c26c5982c082a912ba2d22501a12438118067ac19957b0191498fb2113d1ca2db5fad32761f282b4c7684827b35a1709297c9bded1fe61a4e1963d32aaf4cd0ba5c51ad9c1aa3494c47afca86a264293d9a940310d6c1d8bc3e51ea3e12488e87f624e738f3568b21ab5f7a8b299b5eb0d7147ca794",
1807 "tcId" : 198
1808 },
1809 {
1810 "comment" : "wrong length",
1811 "message" : "48656c6c6f",
1812 "name" : "RsaSignatureTestVector",
1813 "padding" : "3021300906042b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1814 "result" : "invalid",
1815 "sig" : "8ee3b703c37759112397fbc6410d9c95a93084f544a26756071b298ba563b2c22962befb038d995912ef5b48f5ffb9d187be72f835d0afa764eaaaffa2cf42b0918e8b364bdef42a482e571cb949342654c91e3012776620cdb590323326e2861d1abdae6ea2fae95d7304b25255aae9d7309324bfb6b47cc2555e5191e95a79",
1816 "tcId" : 199
1817 },
1818 {
1819 "comment" : "wrong length",
1820 "message" : "48656c6c6f",
1821 "name" : "RsaSignatureTestVector",
1822 "padding" : "3021300906052b0e03021a05010414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1823 "result" : "invalid",
1824 "sig" : "7ab24ebda94da9c07a8742a96884e7006e36c15fadc0d41721d8192581ace97b040af10f79bdf1041ce48bfbdfe0e2807042ef91efb0136acd592346bc8c572bd0da5f6400406971b8d84b021c0550e32b9ae8cc4481b8979979170d7690158dc95f2fea00e05566a2369a3eb34794cfa6792128d72774eb0fb504490a5e9484",
1825 "tcId" : 200
1826 },
1827 {
1828 "comment" : "wrong length",
1829 "message" : "48656c6c6f",
1830 "name" : "RsaSignatureTestVector",
1831 "padding" : "3021300906052b0e03021a05000415f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1832 "result" : "invalid",
1833 "sig" : "49877ff5a25db5d9736e7c0198f7908dd0eaf2f2ac754d6456073df7a1b8d87f49fe9ed7caac03e92cf8bf253626c2ec049c4dd4615bacc5a617ffd874934ad868db7c5d7db8e37bddaa22b557b49bf8ee769bcd0d0faee45adaeca042fdfabe0864256a64389208ea8a825d373c439e220a60fb30ddf96427741e5771b89200",
1834 "tcId" : 201
1835 },
1836 {
1837 "comment" : "wrong length",
1838 "message" : "48656c6c6f",
1839 "name" : "RsaSignatureTestVector",
1840 "padding" : "3021300906052b0e03021a05000413f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1841 "result" : "invalid",
1842 "sig" : "6acf67de89d21ac6c0e0360dc872eabd3d9f315a46921fbc835391f4e5df2d5a73826cccc3ae099c76c5e0b5dcf13f76316cad72f2715be8927fe83273cb5b10dce6b4a58236e90028146519ee975599e2cfce518be7e20701b82d24e1448654a89a52cdad64c33ef916e1d3a40eaeb07a7b1509a151ca7a8c3f37b734dbcdd3",
1843 "tcId" : 202
1844 },
1845 {
1846 "comment" : "uint32 overflow in length",
1847 "message" : "48656c6c6f",
1848 "name" : "RsaSignatureTestVector",
1849 "padding" : "30850100000021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1850 "result" : "invalid",
1851 "sig" : "8291239e82027853aad5ec6526dc14eb2e4d6f62459cec895e311302e531a472dc720a55f01089ad3ff96608cd0804dcc4816441f92e77b9dc59d85a7b750cef32013fc888ce4bab028152ed07d31e1232cfbdcdbf096cfbbed22be93a8cca41ffd69575c3e47aa6f3c4bb895690622ad253c60db7fad789b3508252120f2905",
1852 "tcId" : 203
1853 },
1854 {
1855 "comment" : "uint32 overflow in length",
1856 "message" : "48656c6c6f",
1857 "name" : "RsaSignatureTestVector",
1858 "padding" : "30263085010000000906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1859 "result" : "invalid",
1860 "sig" : "0c0a60f4426a0922599d12bf623821ef3a69e88b8f3df39c998b91951bf8fd9f12f379db75bd051943076b73f145f6de4e82c050bdff9989bfb7430c6b4483502d291e666fc1b93e61a2e7dfc4f3b3d0f695ac605772a8f54a85148b76285aa0ae2a993d5061dccac1afeb9605771de9b51d6891e875c384d8827faef2388555",
1861 "tcId" : 204
1862 },
1863 {
1864 "comment" : "uint32 overflow in length",
1865 "message" : "48656c6c6f",
1866 "name" : "RsaSignatureTestVector",
1867 "padding" : "3026300e068501000000052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1868 "result" : "invalid",
1869 "sig" : "52d65dbd6d48dce0dbc538883d3508588966c4932afcb22457221c34414a59d8effbcb805c6320b5edb024c745afec75bb7c698d9e903fffeaf7a4ee8c36d7f44482f5116d8d7758f08c889ad777405f204e1c5b75e1dd2721f46679fa13a98f8bfc07885ad67a43fe4c05ded4c36f8d7e1bf5695bd348192986f1b40c60527e",
1870 "tcId" : 205
1871 },
1872 {
1873 "comment" : "uint32 overflow in length",
1874 "message" : "48656c6c6f",
1875 "name" : "RsaSignatureTestVector",
1876 "padding" : "3026300e06052b0e03021a058501000000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1877 "result" : "invalid",
1878 "sig" : "485b9c137230f1bd439b4b5753be8267f386e1725d63d6c29bef2759c8fc81d4bfe2b5759e9dfd1772fe2cb661d320ec8fc831cf6e4abe8e18d622893a7ee92c64907c15427e7748faa3d1445e7721260e70be4f32167d60462fae53bfc2d943501b8634e443a940d9f41a1391119305a0367799909a7b83fdf7374721d4efcc",
1879 "tcId" : 206
1880 },
1881 {
1882 "comment" : "uint32 overflow in length",
1883 "message" : "48656c6c6f",
1884 "name" : "RsaSignatureTestVector",
1885 "padding" : "3026300906052b0e03021a050004850100000014f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1886 "result" : "invalid",
1887 "sig" : "73c06cbffd5b65aa863f4d61321d840689ab69885ecc340748b8c4ad290945074fb58c73a419ea9f56e9ad70d1b133567a6c3e8e42a9b009241179eb154d7fd1603b6e25db969bb62eac8477addf62f1437d225c57725f3a017073c7418e70adf1e5caf81740e9503ff395b956bc90aced537e846968d879e1a17f4823aa3ffc",
1888 "tcId" : 207
1889 },
1890 {
1891 "comment" : "uint64 overflow in length",
1892 "message" : "48656c6c6f",
1893 "name" : "RsaSignatureTestVector",
1894 "padding" : "3089010000000000000021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1895 "result" : "invalid",
1896 "sig" : "5d718291abc4c814b265b5eb7c41d96648ada9e6baeca90e4dc851a1655a64aadc072ed9402f583f6f56b1d885c9423f4b708afa978c3c941969188b44b04d4d787bb6079e3527d6c1e36cd5fffbd33178cb6f23c4e1302b3a59cebe6353b6b10a005e6f24a5ef8350900b3717646917d1efdaf8aab1a3e994d5627a8d11e577",
1897 "tcId" : 208
1898 },
1899 {
1900 "comment" : "uint64 overflow in length",
1901 "message" : "48656c6c6f",
1902 "name" : "RsaSignatureTestVector",
1903 "padding" : "302a308901000000000000000906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1904 "result" : "invalid",
1905 "sig" : "1849ce77edf490fe5825f6bd1d6b4c312227fa9296ebb4f5e9a48dcb9b9a8918362a92d8a620dd3cec378f67beda0216b4c39fe07903bdeaed853f8884ba017fafce472c751284cfcd4db8fd5b93dd821eb43a202747927f1bcb947ad76ebd9d6085b616e8f8485b31889b95f28c4bf06dd4852142ac2f5ae707d1ed4f23cb5e",
1906 "tcId" : 209
1907 },
1908 {
1909 "comment" : "uint64 overflow in length",
1910 "message" : "48656c6c6f",
1911 "name" : "RsaSignatureTestVector",
1912 "padding" : "302a301206890100000000000000052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1913 "result" : "invalid",
1914 "sig" : "0d3eb2ba13141b7d5fb65b0ebca47b979bb51778e762bde3c4cf33b02f84b0567214eaf31dfdc8197c2e84d9a85af76e8bf832a5ca2797af79b0293d85f513e421714e364ac5a5551a066063f008d6eb7c3bfdda6c6fed53e0161cb607ff7e78916f301cd81dd63f351eab77395c718b56d8d0b73b4806229999fb98aaa7751a",
1915 "tcId" : 210
1916 },
1917 {
1918 "comment" : "uint64 overflow in length",
1919 "message" : "48656c6c6f",
1920 "name" : "RsaSignatureTestVector",
1921 "padding" : "302a301206052b0e03021a05890100000000000000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1922 "result" : "invalid",
1923 "sig" : "88b8e16d5527fc54feac2b63c905964e71c47701dad5944aba4847460b235c09e9ffa8bc6e59390dfa8d739893cbb32f5b06ec7f1fc918ffa0c364e0b5985dc05aafe98a8b86b18168d7705231dede7f0ffef76e6805a35a0ed9a78bebedcc274169f242aab6c33541c840a1e50cf09720b2aecfc356ed88ce1090bc54499f6c",
1924 "tcId" : 211
1925 },
1926 {
1927 "comment" : "uint64 overflow in length",
1928 "message" : "48656c6c6f",
1929 "name" : "RsaSignatureTestVector",
1930 "padding" : "302a300906052b0e03021a05000489010000000000000014f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1931 "result" : "invalid",
1932 "sig" : "54bbb6fa9891afe6101547c34599fd1fb4bfb3dbe0c57fcaba3bd3700f0ee7d658ccd24bde5394aadc7480f181b90576a74de3c705b85bf214d9d8284be4b00b12678891989c3e3e16f53185fa590c016c29fd6ea02f97f1a872100969fdc57654b691122f2eddbeb6dc558ade5854fc8f26c11c5c32638bd4f7253099c7d1bf",
1933 "tcId" : 212
1934 },
1935 {
1936 "comment" : "length = 2**31 - 1",
1937 "message" : "48656c6c6f",
1938 "name" : "RsaSignatureTestVector",
1939 "padding" : "30847fffffff300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1940 "result" : "invalid",
1941 "sig" : "0dd112d02c49ae5057f4b89c14b871e5a446e96dca84c6d0d012c95615cf43ebd42e79d034fdcdc93de62e3b11dc11dba63dacf300190d443e3796e0c95a5db3955f799ec1bcdd4ecf69b708fec727b76401e989f5cdd612773f65e1a357e0b2942b78aac09dea9eb0d86463aca289a0af876eb4ee031bdf10e0df27516ebafa",
1942 "tcId" : 213
1943 },
1944 {
1945 "comment" : "length = 2**31 - 1",
1946 "message" : "48656c6c6f",
1947 "name" : "RsaSignatureTestVector",
1948 "padding" : "302530847fffffff06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1949 "result" : "invalid",
1950 "sig" : "603d34e2f71dabf90d862e828a0579fef915972f070c495da35fb279808ccf4bdbb0a43f666d203aa494f0a3012f5a4518c2a83fd8a8d3f1537be15174f22a355124657fef6e1b673c4010e8514cb133f63a15a7245ba9fd8acd03c080e4e89531c0ee3b41612e34b136c07c469c042b2b2718dc600cc1f4069063d0989fa188",
1951 "tcId" : 214
1952 },
1953 {
1954 "comment" : "length = 2**31 - 1",
1955 "message" : "48656c6c6f",
1956 "name" : "RsaSignatureTestVector",
1957 "padding" : "3025300d06847fffffff2b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1958 "result" : "invalid",
1959 "sig" : "11238413d11b4c1e0e311fee14bc4b3370c9943fc22c8b9429487bcb920e091d9edd0341bfc79070337854884267cbbc0f41dc34746c3e56096bc03cfa9d58e812d2bb9cf7dd90f3f16c048036255c0338c3777073a925f565ca9c9f78c7edb856f20a541275f84eef9a022e94dfeeeae4f07416cfefd742c21da502a1fe80c1",
1960 "tcId" : 215
1961 },
1962 {
1963 "comment" : "length = 2**31 - 1",
1964 "message" : "48656c6c6f",
1965 "name" : "RsaSignatureTestVector",
1966 "padding" : "3025300d06052b0e03021a05847fffffff0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1967 "result" : "invalid",
1968 "sig" : "8364095ecbfbd1f50f2964bce941395095071e45e9ab55edfef6ec767dc3790ac237a11132e6e087e96c226fd338783d4de817abfb9e134c2dd61dd4e400188f50be2a7cf3f96804011b5240da29bb1e8f7d4337c8e1f2af0acc1536057b0114a23172c6d37f9128ba4c2b719158ad70c5c44033e532c58d0d79c4508470465e",
1969 "tcId" : 216
1970 },
1971 {
1972 "comment" : "length = 2**31 - 1",
1973 "message" : "48656c6c6f",
1974 "name" : "RsaSignatureTestVector",
1975 "padding" : "3025300906052b0e03021a050004847ffffffff7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1976 "result" : "invalid",
1977 "sig" : "8a3d7f621509191a435d03f94a338c1aeb99a824eac10a7c8575d1848f16af74dd87db6137a590d3e0cffa18cb5c52e1ab42688c2d50afa5a29730a98d6cd60e24f13c7dfd8500a9442954a23e773560a11b1a2a3fc087a28ff2520aeeff2a058928c9af14e90125b0d534bfec11eb1a02227e7d513569f3f8dc6e35f6fe6136",
1978 "tcId" : 217
1979 },
1980 {
1981 "comment" : "length = 2**32 - 1",
1982 "message" : "48656c6c6f",
1983 "name" : "RsaSignatureTestVector",
1984 "padding" : "3084ffffffff300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1985 "result" : "invalid",
1986 "sig" : "149a74b89d1eb542f383ce0f24f8665b1387529770f561cee91f39e3af3e82c1cb0f589f4d6d5e9fbe92a8105993d55c205cbf9b4ec4c3085739ae1ae2ef4615d43040926813981d4b626f3c71e08981b8c900952eb23d8b9da218fc3f1f113a27682ead4466157e9043188d331a9632c8972ac7bca5729132bcf4b76309fcf4",
1987 "tcId" : 218
1988 },
1989 {
1990 "comment" : "length = 2**32 - 1",
1991 "message" : "48656c6c6f",
1992 "name" : "RsaSignatureTestVector",
1993 "padding" : "30253084ffffffff06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
1994 "result" : "invalid",
1995 "sig" : "3b55f4f1b497c53dc4fe59e8e2c8bd48f9199bae420e43e5a22fcefe047a5fd6422de99742ab6b3f946a908d382852359f5f80037976287f4806ee3edbfb94a01d81fcc9c28afbbe8d824089bca34f939d5298152bfa11e69e047a6379723d5d187c1cee5f437517ea237d0a024d2d21316666f867411b0b84f6010dbf3fc2f7",
1996 "tcId" : 219
1997 },
1998 {
1999 "comment" : "length = 2**32 - 1",
2000 "message" : "48656c6c6f",
2001 "name" : "RsaSignatureTestVector",
2002 "padding" : "3025300d0684ffffffff2b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2003 "result" : "invalid",
2004 "sig" : "99a4a625ecb0c1c339c42b058d05f8cc6cd47bb29deb1df909fc16083e08ea18f482dc3932f0f81a0881c8a4e450d52da647fe501baa9363ce0261729beb173e3c6b3ecfb392ce93d89ea4c0e911ee2b95574a966c23276b9495b2ef6dee3a054c728c4ebb1cb294c703e1320a7d3cace4acdb57c605ab1c197448d5b890e71c",
2005 "tcId" : 220
2006 },
2007 {
2008 "comment" : "length = 2**32 - 1",
2009 "message" : "48656c6c6f",
2010 "name" : "RsaSignatureTestVector",
2011 "padding" : "3025300d06052b0e03021a0584ffffffff0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2012 "result" : "invalid",
2013 "sig" : "4473370a0f1cbe032dd66017379c5605c69fb77c74af9f119f93b4df107cda358dd074a7c8a2a4b3afb3bdd4d6074be90e6e8018fe482121cea28e7d42b4a64e0fad25c86d4792099812b74dfd225efefe1a4c9b664a3786c9e2070bd7ec4bbf666a4fdacf5966d121fd17169db07d47f04beae689080c76592527346d3741ec",
2014 "tcId" : 221
2015 },
2016 {
2017 "comment" : "length = 2**32 - 1",
2018 "message" : "48656c6c6f",
2019 "name" : "RsaSignatureTestVector",
2020 "padding" : "3025300906052b0e03021a05000484fffffffff7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2021 "result" : "invalid",
2022 "sig" : "1157bd4955170a4d8dbb6c3e20faf50fdc20140cd2f0ba30f2b3b059742b747f501e8fd4df0c614d247d7c7ffb91365e6bfb5ce36d21364cde0ddf7d9b10c1b1fa0ef1aa37deecfcb0002094a6b2971854f70912e62e91275091ecdbf0c218c0a3a4d7c5ddc7eed97c317f46ea2b554d391d08a5d015ffdf1c51de55f8048d1f",
2023 "tcId" : 222
2024 },
2025 {
2026 "comment" : "length = 2**40 - 1",
2027 "message" : "48656c6c6f",
2028 "name" : "RsaSignatureTestVector",
2029 "padding" : "3085ffffffffff300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2030 "result" : "invalid",
2031 "sig" : "50af5b10a7fb4f26fe6abe148cbf8169fc5f7260e732f4ae4ccb79877a3b1c8d6fbc476a43db9f5e94c8c13fb256ce767aacd02445b47bcc54f535ce67251ee94a63b33dac77cff65d3de5aff42f12939f10320d40ac448cde70bcd8a40fa20dc91354f97521d847e45aaeb9fe38a8c9c0a3ebaaa34046a620654e305cbc3289",
2032 "tcId" : 223
2033 },
2034 {
2035 "comment" : "length = 2**40 - 1",
2036 "message" : "48656c6c6f",
2037 "name" : "RsaSignatureTestVector",
2038 "padding" : "30263085ffffffffff06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2039 "result" : "invalid",
2040 "sig" : "4635e85ef3201bd0c0f1e57a2fda4c1a7b68f36db6ca9f1f034c75bad695a67964086d3d7f7a7505ff10cd77f1017908634f309fd5e0d4a406c1c579b08b397305e0e6a57390738c2e663449a72c0894bb3beb0933cd12c469181b139ee21ca9954dfd88b0ebc6f0e8d29c7b45b2bf5714e17ea9950e0d5b476b55aa0b717bfc",
2041 "tcId" : 224
2042 },
2043 {
2044 "comment" : "length = 2**40 - 1",
2045 "message" : "48656c6c6f",
2046 "name" : "RsaSignatureTestVector",
2047 "padding" : "3026300e0685ffffffffff2b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2048 "result" : "invalid",
2049 "sig" : "6cec5f74cea80f137a424880ca5254507315b6e50376a969a444aa0c33d5a9079fbdd417662c16048a249a94d251685742ebe4fba882e797bc77f6d28105136b2ba9bd5ec3080343d00d7bb9f579a334c945c1239680c11170e0470e801bdf6f9789a5428cf97b0af0f2fa77db2f8fc00182b1bf9601acde6fd5158b4f57bcaf",
2050 "tcId" : 225
2051 },
2052 {
2053 "comment" : "length = 2**40 - 1",
2054 "message" : "48656c6c6f",
2055 "name" : "RsaSignatureTestVector",
2056 "padding" : "3026300e06052b0e03021a0585ffffffffff0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2057 "result" : "invalid",
2058 "sig" : "0513eb217a06590004cbfcb0bc94c0c6f79b488fffbba9d85e289e42b91824c8c4e1dc04f3ad6f6ce6e8480c96889bef3c62105bdff8af972264cf0110b4e522fd26ff6af8147990143828fa3aa2ba25066369357e19fce0b8f90d048ac1ef19380fe493fb70ac9660d5258dc0657a6270166d3400c2421bbf57bcfe10e2ad64",
2059 "tcId" : 226
2060 },
2061 {
2062 "comment" : "length = 2**40 - 1",
2063 "message" : "48656c6c6f",
2064 "name" : "RsaSignatureTestVector",
2065 "padding" : "3026300906052b0e03021a05000485fffffffffff7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2066 "result" : "invalid",
2067 "sig" : "5b0df944013467b97409704eb2130b06e537f746c5387dbb858651f4446887f874977dfbe9d5fd26d0be6ed9ed9381b9a8511710d0756434ce897cb00863c652ddf3a6b2df37f9308a46dcf2027ea523f124c9f32c2d9a09b5d1928e2677dfaf5e0d8a00c3d0edc5c1441f017011a16f2e0788fb2d8d22e395b4d79a8375ba49",
2068 "tcId" : 227
2069 },
2070 {
2071 "comment" : "length = 2**64 - 1",
2072 "message" : "48656c6c6f",
2073 "name" : "RsaSignatureTestVector",
2074 "padding" : "3088ffffffffffffffff300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2075 "result" : "invalid",
2076 "sig" : "52be2fd82c24a1fcbcc3d832732eb97b1032933fa6af3b7fd8d63fca652d4b3a40c8488695414049f416f4eb01095767d75325662accd8c47bb75500ea4a99ac1fbd01815d0b8ddf450e097380c53715298c22fd3150b8417a66f499495372f07e98578e407ca2d226c69533c80b08f58e1fc0ca1cacb8652fc9374e12f6278e",
2077 "tcId" : 228
2078 },
2079 {
2080 "comment" : "length = 2**64 - 1",
2081 "message" : "48656c6c6f",
2082 "name" : "RsaSignatureTestVector",
2083 "padding" : "30293088ffffffffffffffff06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2084 "result" : "invalid",
2085 "sig" : "2703db8b7d2f7a879c235f95a9a39870074efea76b73663c50c4581eb2debb494472402d271b115a14fdc14eaea36cdb4c199260abd321d8cfbd1f56b1954761c5c61ad3ec1e440b53f1cceb156d8638b597eee1eb717b110f30fcea92f47e7c1ba438b1b161967f555bd14f0bcbcd21833aeb2c6b8b3f5c4727d07ddf009b11",
2086 "tcId" : 229
2087 },
2088 {
2089 "comment" : "length = 2**64 - 1",
2090 "message" : "48656c6c6f",
2091 "name" : "RsaSignatureTestVector",
2092 "padding" : "302930110688ffffffffffffffff2b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2093 "result" : "invalid",
2094 "sig" : "927d2fcf22048a79d64b34aaa94de24a10770a95e32f0a6e2b9bd5a9c1e502e9fca540e54aca240091923bf4a64fd703b30fb5cec96c8da5431373bfec653da1ab25cff5024e1a029cca12469db0ca362ecefadf60991fc1c1615154450d9e1b54abad613f5ddccb5545e615c6168d0247f8e7c061659c9946c3af1e373a618a",
2095 "tcId" : 230
2096 },
2097 {
2098 "comment" : "length = 2**64 - 1",
2099 "message" : "48656c6c6f",
2100 "name" : "RsaSignatureTestVector",
2101 "padding" : "3029301106052b0e03021a0588ffffffffffffffff0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2102 "result" : "invalid",
2103 "sig" : "1da7bb65b41d9e5fb8b895882b9b6c2aa5ba32e7297c8eb3d64e5ae4311ad229692296cc27eb84e8673c29b65c35b1d52038d8b4136b334f4bd385621d7ddd6e0b5718c65834dcee0e7841a154f1953b130573995ad5cb29849490366936ee8a383f33f6cab3221d21d86c42ad8fff91efc5257ab8e9279df968d477167e75cb",
2104 "tcId" : 231
2105 },
2106 {
2107 "comment" : "length = 2**64 - 1",
2108 "message" : "48656c6c6f",
2109 "name" : "RsaSignatureTestVector",
2110 "padding" : "3029300906052b0e03021a05000488fffffffffffffffff7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2111 "result" : "invalid",
2112 "sig" : "4c3a7204c4807d5b44fc36eff6b0513730fde67c74eb7a7d0484b7a5b89e444e89b07170ec0ff4ec4f58b9f13c3bb82cba0081b737f62277dbbc678933dc3faad4dcdd61c8b4d62c7a1c9a6dc40c564b36bcfb9aff90e9c642afd81a8c9911351e3f0b78e0ad6850c937a69ee2a639be88473682d7c4a6edc77365cfcfe91075",
2113 "tcId" : 232
2114 },
2115 {
2116 "comment" : "incorrect length",
2117 "message" : "48656c6c6f",
2118 "name" : "RsaSignatureTestVector",
2119 "padding" : "30ff300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2120 "result" : "invalid",
2121 "sig" : "32107f36c8b86cee3154d197a6e281869070fa9947177aff8cfea5942b3fbc323452b002f957f19083b57d59e6279d80821fa33c1f450ef5f805eabf1782f729dad2f9d0e63462e901dcd449c7fb14a8c42ec9599d30cf1b16b45550061f5b6f7f91c4c2bcb1613daaec5984e634fdd65a19cf24cd29d093406d7f5f4c443a23",
2122 "tcId" : 233
2123 },
2124 {
2125 "comment" : "incorrect length",
2126 "message" : "48656c6c6f",
2127 "name" : "RsaSignatureTestVector",
2128 "padding" : "302130ff06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2129 "result" : "invalid",
2130 "sig" : "5ebb4faf49a82b1fda92b2ccc8de0d158bf62f819359d06c6a4a2a508bf728635296d188d5a221b40cde9d51e107b8e8f73ed2a0c3cbd92325ddea1cad1f72ff6491133ab7a2847f3d339cb2317e8b9e336516a7a9d84fa8fb2b481df9e1ec397fe97d18227ab98c2fa55f080569aedc7025af770674a5b33c61b811922058dd",
2131 "tcId" : 234
2132 },
2133 {
2134 "comment" : "incorrect length",
2135 "message" : "48656c6c6f",
2136 "name" : "RsaSignatureTestVector",
2137 "padding" : "3021300906ff2b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2138 "result" : "invalid",
2139 "sig" : "531ddbfca4d3202639ecda32eed51b2fcffaa0cc6a0e97bdc1df71ab3b800f3e80f661b118d9cd82dfa1ae35cc3a364dd2a1c688e90cb6b6a215485e5e30679838bea37edcbe982ae858ebb461a45ff687332be102eb65746d9539a693b489c3cd5901adecc2d4afeca278fcf3b21774f2d11090f436d949d4ef96480839b678",
2140 "tcId" : 235
2141 },
2142 {
2143 "comment" : "incorrect length",
2144 "message" : "48656c6c6f",
2145 "name" : "RsaSignatureTestVector",
2146 "padding" : "3021300906052b0e03021a05ff0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2147 "result" : "invalid",
2148 "sig" : "4ec4e1b4bb0ce0b002b8cc0b47fbc2baa9be415e35d77fb95906620322a63fed39595837d1a547cffc5f50c34a4daebf3a15d7d7ede9e583ffefb77ca4e4cd953b91a8608ede58a5500dbb71ad24bfa2b07bbec03b702c53baf4a1053d4834376b205854cee7e0dbaa1ec60f72ef238fbce20d76f9549b485b41173da58356aa",
2149 "tcId" : 236
2150 },
2151 {
2152 "comment" : "incorrect length",
2153 "message" : "48656c6c6f",
2154 "name" : "RsaSignatureTestVector",
2155 "padding" : "3021300906052b0e03021a050004fff7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2156 "result" : "invalid",
2157 "sig" : "7d54aa05c2043d5f6330ab97726ae0407d0f6be65cc1146b374d3e7f75583beb5ad0ba0361b2cd6bcfcfa01987cfdd4423047fa6f909b3fe3840262c55b3f2c0385cd8474cb92eedf9eb9113e9e83d0ae220124493c3df2380df4cea3e88b81d9e3947feebd788c2417c644974f6b909c1e44b75b74240b370f8663e9a1f63b3",
2158 "tcId" : 237
2159 },
2160 {
2161 "comment" : "indefinte length without termination",
2162 "message" : "48656c6c6f",
2163 "name" : "RsaSignatureTestVector",
2164 "padding" : "3080300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2165 "result" : "invalid",
2166 "sig" : "1573e93ebc5caf4eba58c9d80b89c0b62de2073a85f5872a22ea283f37366fbb8c6c7f4b0a4f459505d95da2921d8aefa640d81f5dffb9e0e679c69ccb310eda59f36d49b33219b30ee3b0f680e2794654c99e63effef73b09891f67c403283999943d4ded2c823797ac2773aed7a0af88cade66f4a203fe91c8d86d720fbd36",
2167 "tcId" : 238
2168 },
2169 {
2170 "comment" : "indefinte length without termination",
2171 "message" : "48656c6c6f",
2172 "name" : "RsaSignatureTestVector",
2173 "padding" : "3021308006052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2174 "result" : "invalid",
2175 "sig" : "9dc2d9a253cf809bf178002806d1c9883f5c74a0734f70dea7e322f2ea00a00a3bc864dc4f0fa90bdf0af0a8e46f893f6405a63998ed27f18cdffd1b46a183763e3bcfc4c491a023468f1b355d12be2118e4381d960fa2548afa12a6ea46da03268d1d050bd942ec8c2bf584f8d2ff00ff975860686311b1dd17d1ad6f262d66",
2176 "tcId" : 239
2177 },
2178 {
2179 "comment" : "indefinte length without termination",
2180 "message" : "48656c6c6f",
2181 "name" : "RsaSignatureTestVector",
2182 "padding" : "3021300906802b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2183 "result" : "invalid",
2184 "sig" : "3b1240c785cab25d0ebd26078da7323bd28352a878cd405419cef18938d27dede67112d32f6a60d22b14c78e0f5c392bc9f53f2a71769e21a9dd4b5d8495a203ff0e715a1173ce69f3c966d83e8ac9a45ad534c36b77d1cd120a6a3236ce023099b19acb39a25ec420f8765829b77cb048a5136b597645caafbc34d3c09723c1",
2185 "tcId" : 240
2186 },
2187 {
2188 "comment" : "indefinte length without termination",
2189 "message" : "48656c6c6f",
2190 "name" : "RsaSignatureTestVector",
2191 "padding" : "3021300906052b0e03021a05800414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2192 "result" : "invalid",
2193 "sig" : "84bbedc08a146e7f8923dbc116c9793d1bac3608d71f962664d2a155bc06b8a02d3a346e067f347cdf50ba537c14c1c8bfabcae5ff982e5543b626f89627d1a4bace0928115d22d2b0daa5285afab45c9d54e5fe1832494f432b32bafb8a922360f5f545b15dc189b7e64dfbe96372b401ad519162488f0123934a9c0512b4d3",
2194 "tcId" : 241
2195 },
2196 {
2197 "comment" : "indefinte length without termination",
2198 "message" : "48656c6c6f",
2199 "name" : "RsaSignatureTestVector",
2200 "padding" : "3021300906052b0e03021a05000480f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2201 "result" : "invalid",
2202 "sig" : "15a6c89db01ecf6d5f4d3a1535bdadcab861655619500b010851340b88cf8ec2547bf402137751006ac9d675b42308f939eed23d010fa36006eee53b94d63c3ef3800665038ffb4f017c1f3f5f8e9b909fd555e67cb002fbe261a42bd7b617525c5027d5af82aae2b6fd29abe4f503dc5f2620aff14d7b7798fdb8d4a7629db2",
2203 "tcId" : 242
2204 },
2205 {
2206 "comment" : "removing sequence",
2207 "message" : "48656c6c6f",
2208 "name" : "RsaSignatureTestVector",
2209 "padding" : "",
2210 "result" : "invalid",
2211 "sig" : "14951bfe3fa22176d5ff4ad5f7dec0d0954e25a2381c91bc17707034ba19087c9f5b167d250129b95b41c883c69a5628196f9733cdff2daacb49ab61ee430582aab7c785e4f70f2320ea1d18da9ed0bd4f96e597977c2aaf0c2b8a3dfd8015d08195e3446efe12788fb7cbfd612d309a13952682b65f03a8c9440fd735fb2078",
2212 "tcId" : 243
2213 },
2214 {
2215 "comment" : "removing sequence",
2216 "message" : "48656c6c6f",
2217 "name" : "RsaSignatureTestVector",
2218 "padding" : "30160414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2219 "result" : "invalid",
2220 "sig" : "40868e6b6d88f66b2478d680ea58466d642e141951f69c1f25bc3f23211100441857b33253b4cf1668b6568b858d1c604e6062022c71c0d764f260c1924972ce44a89b508a3a220cc5b545c4166974e6b619d3d6cfd0b72be7f31070e743eb7611230b4da746f64dec399f71bbe8aa998a99f746bd422be6d02f0e80f5e9a337",
2221 "tcId" : 244
2222 },
2223 {
2224 "comment" : "appending 0's to sequence",
2225 "message" : "48656c6c6f",
2226 "name" : "RsaSignatureTestVector",
2227 "padding" : "3023300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2228 "result" : "invalid",
2229 "sig" : "34bff75efb6f79769cdf1dae7cbf4be4644b03b7e44ba74a277281e229a6bdd96f922884fdf97705a456ad07e13f90578ce2b3aad819879be2c4097ebe5329e8eb72598005d02c6e73d8ecdbb45fab138cd88259320397f6b90a5108adab63ea07e1b86f5e20455368cfec220782a63aa7aea41761ead5952f9c7da59135f0e9",
2230 "tcId" : 245
2231 },
2232 {
2233 "comment" : "appending 0's to sequence",
2234 "message" : "48656c6c6f",
2235 "name" : "RsaSignatureTestVector",
2236 "padding" : "3023300b06052b0e03021a050000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2237 "result" : "invalid",
2238 "sig" : "96d9ab79a2c8db9e9a483d5c36c0c3ee430eed6bd8385e4b7b655b7428a28d609ef4a9d413269572cc4be679497329042a1e1b0b090cfbc9a9236b94942e33e2e54a593efc3821ced8110042f4e56a521f4f46a3305dfcd1b899c0f092aeba78ecb8731a91c2a64bfbe7e00d46d85275a04c2269a74cbdf3ee6d6aa4867c8728",
2239 "tcId" : 246
2240 },
2241 {
2242 "comment" : "prepending 0's to sequence",
2243 "message" : "48656c6c6f",
2244 "name" : "RsaSignatureTestVector",
2245 "padding" : "30230000300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2246 "result" : "invalid",
2247 "sig" : "26ec2f6585eb6e732d8430faad988f8223db0f11b8e56c14370697f083f16daf1ce571f73ed43162b40abe8736a43b99cb3c6c6e4a2fd5e2cc75bf779f10abd718eb0f252fa867b4d08cd8ab3f80745c2d368ceaac264427b96dac8b4b7aeeb3303cf4bdb7a45cac40f991c1fe53e8dc530c6dd76302dd8f6bfcd86d6ab290b2",
2248 "tcId" : 247
2249 },
2250 {
2251 "comment" : "prepending 0's to sequence",
2252 "message" : "48656c6c6f",
2253 "name" : "RsaSignatureTestVector",
2254 "padding" : "3023300b000006052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2255 "result" : "invalid",
2256 "sig" : "9e4c79c5fe53b5514cd9a3f3d6d898b53f92859d7f862f66b08585ebd6efcead5b69df6d12b1dfed30abf729558f340def7ffd341bc599102ee3cad5459b11457a2a463cdc40594fea9b7d8d0a99b952aa442a25f77991d34a2dbb0b5d73946d5780c176f0cd977a4e2c26b3b25406b7092c2d8ca14205007fcd0b776d01278b",
2257 "tcId" : 248
2258 },
2259 {
2260 "comment" : "appending unused 0's",
2261 "message" : "48656c6c6f",
2262 "name" : "RsaSignatureTestVector",
2263 "padding" : "3021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2264 "result" : "invalid",
2265 "sig" : "94c2d05aa194c25bbf274f9b1a312f87128d3c177cda66961cc8388a3ed5c658cdf320bc6af14e57b1569ee6f96280e5fa98ca6eb67017cf3077fa63d9f7a916c445dceacf73d06fe53060a11a4c9ebf0e6203890c0da57324d86fa92e8f9b854c262b57046b1422c9aabd40edbef96f97c015690a4dd1f84bcc02867067d35c",
2266 "tcId" : 249
2267 },
2268 {
2269 "comment" : "appending unused 0's",
2270 "message" : "48656c6c6f",
2271 "name" : "RsaSignatureTestVector",
2272 "padding" : "3023300906052b0e03021a050000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2273 "result" : "invalid",
2274 "sig" : "789468845b4388391ff3baafc966a3957f2db65a01fb34132be2445c22b303fcdaa4379c14a9291f3a7e1f23948c5c6b3d1d61934d3e5689267a14b122017df19da59a762114b4db56b17fd61043caede4ad0c8f89ddf180456d5695b337525f6dee1d1806c69a14868ccbe6edfa523795a9422057a3dd9ca8636e5026ca74ea",
2275 "tcId" : 250
2276 },
2277 {
2278 "comment" : "appending unused 0's",
2279 "message" : "48656c6c6f",
2280 "name" : "RsaSignatureTestVector",
2281 "padding" : "3023300b06052b0e03021a000005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2282 "result" : "invalid",
2283 "sig" : "65929dfb1cfa05e3a405e1fd566e86a0627ad471101f5b2ace5d2a225641a521ecf2638b5de2c9f691dc0d4260ec49ce2b05bac8064e5a16881bba6dcf7fbb890896c27ca5fad9bfe6259aaaca16d94f01c24f13e30285caa9d610ad26457376c332bba7ab26d6bf832c7aeb2746faa914936c9ee51f9475861db055a89a1cf0",
2284 "tcId" : 251
2285 },
2286 {
2287 "comment" : "appending null value",
2288 "message" : "48656c6c6f",
2289 "name" : "RsaSignatureTestVector",
2290 "padding" : "3023300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00500",
2291 "result" : "invalid",
2292 "sig" : "81bacc6576415739b7cdf7ec09bbe148be54e8e9b1941992d6c3108cfd3bf095e9f2b4d0c9101136def16587e2121e6ce9d705be253c1597b4963ec43e99ff48d2cfc1ca6141a7c6c309d7a09312dcc5d2b985c38c89bc532578e19f544a0d22262306482973163a93a0e7845479214300f00cb9a01bc5253650d79446c4aa7d",
2293 "tcId" : 252
2294 },
2295 {
2296 "comment" : "appending null value",
2297 "message" : "48656c6c6f",
2298 "name" : "RsaSignatureTestVector",
2299 "padding" : "3023300b06052b0e03021a050005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2300 "result" : "invalid",
2301 "sig" : "42b488de85d7a4dfd153e07d965116dc20c05b971faf7c7c899dda96b3325947a36652cf1c6861011307c47b45fccdf1520c39a56e5ecc1292f336ae19256a2e68ca1d3e8930456e53b3778ccaf50a79f8bbce54489281f7dfd376473951f1a893460503cdec4ed81c722906fbde5b9553ace4f794e600b00e79b11822d13ff0",
2302 "tcId" : 253
2303 },
2304 {
2305 "comment" : "appending null value",
2306 "message" : "48656c6c6f",
2307 "name" : "RsaSignatureTestVector",
2308 "padding" : "3023300b06072b0e03021a050005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2309 "result" : "invalid",
2310 "sig" : "497311a6c38b7b78634e563139cd5255d5db5f49950b9a45928f0e0b84c9db2bda1072389bdd5c44b229a4038d5dd111e4681fd94fa09775e7670fa7de90f1362621f1ca85fb9c79d941fc34b121f60e38b211b3bbed00edbada6f53aaec2555ed59145af32235232a322519fd408ace24b819e0e3c9bd0a6597d84f9530d208",
2311 "tcId" : 254
2312 },
2313 {
2314 "comment" : "appending null value",
2315 "message" : "48656c6c6f",
2316 "name" : "RsaSignatureTestVector",
2317 "padding" : "3023300b06052b0e03021a050205000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2318 "result" : "invalid",
2319 "sig" : "637bfa1961468a3ceae4f91bb9fdf7815d171cdc947a8cedb8beb9077f2096b65500a15c99f512c34acde371be79690acb660bcfe55c0d1a812d12d079f516a6d48b3d35c5c10f21987ac6ba830839a83b1d140c15c57a9df09dd0b1cceb323b1c9a0d854510116d0fa5d16443ea5fec8fc1ec782c76936beef5bd420d789494",
2320 "tcId" : 255
2321 },
2322 {
2323 "comment" : "appending null value",
2324 "message" : "48656c6c6f",
2325 "name" : "RsaSignatureTestVector",
2326 "padding" : "3023300906052b0e03021a05000416f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00500",
2327 "result" : "invalid",
2328 "sig" : "7fbadbb2cb7b323b8f1dfe78abd8e6b78df62aee4cd2d261ba32c05fa321caabf2ec7486bc9811999e48b3b1b06fa1c590fb7b014fe6137165357b4977821e74323eb64a338e98cb0133cc2a9a46e1691fe45dec76781e60022eecbaa6773e911589e831ac2a485c9654fdf3cfc73b66029295eef4c8065f831abafd960ac0b7",
2329 "tcId" : 256
2330 },
2331 {
2332 "comment" : "including garbage",
2333 "message" : "48656c6c6f",
2334 "name" : "RsaSignatureTestVector",
2335 "padding" : "30264981773021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2336 "result" : "invalid",
2337 "sig" : "7d63040570a002364293787b3c0340b7c460eea2cc307d4a6542662a04c0f07ebbc27457f1745129eeddf08156c977e8e346b112024b50c2e3d3686b8e87dd0e35d4f5499cb14049e61e81a5b43fe306ef02b644f20f8db8ed738de9dc630dca8de629a9bc268bee600b7c13c35eaebbbd4e018df9659354efd9bcd5452f578d",
2338 "tcId" : 257
2339 },
2340 {
2341 "comment" : "including garbage",
2342 "message" : "48656c6c6f",
2343 "name" : "RsaSignatureTestVector",
2344 "padding" : "302525003021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2345 "result" : "invalid",
2346 "sig" : "0cc6704e2d24718199b007a9a590a3a63aad1d5f769bb29d2c233f38cd994ad8359522e9c1af260bd8c526de9528de4bf67ea0a34286eaf9e015e4276be490214a52e4f66d44d6f71b7e5c07850a18072ef3e15ce31ad0a085ac59501abc4552a5a2762d484ab494a281801eeebe59d20187f3b6a168cf23f0893b3ea100bba8",
2347 "tcId" : 258
2348 },
2349 {
2350 "comment" : "including garbage",
2351 "message" : "48656c6c6f",
2352 "name" : "RsaSignatureTestVector",
2353 "padding" : "30233021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00004deadbeef",
2354 "result" : "invalid",
2355 "sig" : "2916f598221ebb2894a79ae4580d3e7cf6af6a5d345d4be8b254b9efa08d267e3c25570a515ae47a22fe24a914218bd7bb8322e96d49cf16076cd5cefab88db6609438d939f392c2c985272c7561726e51c85ade312ea1b77cc96b0d681f6f2695106d6e8dd5fd5556ed88151cc0a4302f61f5f3db1e714ce11356fd6c6d46e2",
2356 "tcId" : 259
2357 },
2358 {
2359 "comment" : "including garbage",
2360 "message" : "48656c6c6f",
2361 "name" : "RsaSignatureTestVector",
2362 "padding" : "3026300e498177300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2363 "result" : "invalid",
2364 "sig" : "934016d53fdc1e94095ad0c3b39fd01983a037a5344c486edf74efe2daa9da8e1b8e597176faba7ecc9562d432ff98dc205d00cb3937221a6efd35c42674058db4edeec5b6bc86f49e31201e8c6d5b0fe3d0463e2b36bfcd9bbfd055e89034446da971bc3dfe793350f2f85862baf328c542199ad55fd56bd1f75094eb5e09e2",
2365 "tcId" : 260
2366 },
2367 {
2368 "comment" : "including garbage",
2369 "message" : "48656c6c6f",
2370 "name" : "RsaSignatureTestVector",
2371 "padding" : "3025300d2500300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2372 "result" : "invalid",
2373 "sig" : "5ef2282d6b3b03eeb68b8f1fa17bb20d7f3bd2a66f2450ad97048183c3647de4cf533442f92e2ea850b09c552be9e99419a48891e4952a0d4d886cc1a7115563a49c3490fb8e146b368d3a9f9d98567d6ad03799e6d6415cd325a413d43be0ddd2d5b3706c0bb0432989bda8a5d4543b832638ff3ee4ceaaf239acf0c1ac2f53",
2374 "tcId" : 261
2375 },
2376 {
2377 "comment" : "including garbage",
2378 "message" : "48656c6c6f",
2379 "name" : "RsaSignatureTestVector",
2380 "padding" : "3029300b300906052b0e03021a05000004deadbeef0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2381 "result" : "invalid",
2382 "sig" : "88f59da879a63cb4fa4523cda167443e78b2878e8143a54cb0e237ff51e45d34d17d59ce704b72c185346c7093b79fcc0700516dec9c5cb8c3bd7bc21a1f46f593b38b4dc52f80e06a1eb7631bf2590dc7001c122bd2fbe260547c9d13010094ad1e5e75255cbbda3539b1454e3914e6c1e8c93f58b36381b844c39d08770c64",
2383 "tcId" : 262
2384 },
2385 {
2386 "comment" : "including garbage",
2387 "message" : "48656c6c6f",
2388 "name" : "RsaSignatureTestVector",
2389 "padding" : "3026300e260a49817706052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2390 "result" : "invalid",
2391 "sig" : "1458cdaa71d53e60633583b0ca0edd905eaae3dc86350c4803a5fb5d1620b31713930cbe5d21d9530cd791c1cd10007078799a9359b09f39c61394f0d2ffe366efd4485830aceff2296da12a1f9b6677a1b8349cf6b832e7b9821e1be8d5e39a7e892062926066312b231306ba32cff73b03e9be39f12eb1a559e7e18d912f85",
2392 "tcId" : 263
2393 },
2394 {
2395 "comment" : "including garbage",
2396 "message" : "48656c6c6f",
2397 "name" : "RsaSignatureTestVector",
2398 "padding" : "3025300d2609250006052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2399 "result" : "invalid",
2400 "sig" : "7f2c73434ec35a0db8a6e89d81171d7df1e1479d4b5e00da0d5e1223c95ebf9eaecb9f5d7b2705ea3e06f42828fc6c6c3cd3af52e3dc20c164789785aa88cbdb63c4b973b4f871c085670039612d4a9f50f0ff84e38c576b09bcc9d55d6c66418f0e8737b1c0e8abc3c2dcee84d7861e58d4cbe887d022a3250f28059c5d4288",
2401 "tcId" : 264
2402 },
2403 {
2404 "comment" : "including garbage",
2405 "message" : "48656c6c6f",
2406 "name" : "RsaSignatureTestVector",
2407 "padding" : "30293011260706052b0e03021a0004deadbeef05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2408 "result" : "invalid",
2409 "sig" : "51d48f38227999d2d1af07719ec317d34e2ee5e42650a6b59b2d0057b7df31a2b551a736c621f5a8e4345fa755f57e55ff80a61c041c7c28e9148b020913b72d6a0ea7cf2f956b567eaed32ea647687505e11d756581fa1d0b593207c6f2db3a75a0923a375731b925779fc3ade0a00997ce4cda3ec6e981e91e1af78b12dc26",
2410 "tcId" : 265
2411 },
2412 {
2413 "comment" : "including garbage",
2414 "message" : "48656c6c6f",
2415 "name" : "RsaSignatureTestVector",
2416 "padding" : "3026300e06052b0e03021a250549817705000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2417 "result" : "invalid",
2418 "sig" : "55dc53df20ba602ce3b36914347d0a2c22ece2b11ca27b9f8807ffd36545ae33f4a665b6a125253a5cd7c358c52d75b65cac14f9553252ec770c25ad03693a1b6f44470a7418bb55ef5d6a0528ff0174119b1b43c1fd1d07a2506603def7f66d45afb99ba70178b3774cc1f3b4421addb8fee0c22e86416b0b1f3c19356ee38f",
2419 "tcId" : 266
2420 },
2421 {
2422 "comment" : "including garbage",
2423 "message" : "48656c6c6f",
2424 "name" : "RsaSignatureTestVector",
2425 "padding" : "3025300d06052b0e03021a2504250005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2426 "result" : "invalid",
2427 "sig" : "1ff67456aa711438c0bf7e46aedf2cd4ebca7d0e9f8b3f98af54c949a1e27026281f77ecc61ae1a981afda0bf7aae38619c5447508b0fea79a588d0d2806ae0f67b32d6dac4b2ad58dfd413d235543666ddfe31d8545015edf25b5b90cf0f8c592f048d009a293dfd1e7bb50a37d52c1540bccf99d8fe2c1299cdbc563d96b45",
2428 "tcId" : 267
2429 },
2430 {
2431 "comment" : "including garbage",
2432 "message" : "48656c6c6f",
2433 "name" : "RsaSignatureTestVector",
2434 "padding" : "3029301106052b0e03021a250205000004deadbeef0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2435 "result" : "invalid",
2436 "sig" : "6af2cd04b32de5d3cf8ce985bca6f581e96dfb4ec483b1d2c06cf4439bde888524b2e6675c4fd4e10277752d269c87fe1c4eb70a72a2596cf53f1f4f0ba3e82212e72e09774781c888a96e8870658bd9c248bb1f0f7e3c44f4cd284dd6c611cda266f2f841ec1215295edb5291ff1e5111701258441f06b1ed85e16452a02cf5",
2437 "tcId" : 268
2438 },
2439 {
2440 "comment" : "including garbage",
2441 "message" : "48656c6c6f",
2442 "name" : "RsaSignatureTestVector",
2443 "padding" : "3026300906052b0e03021a050024194981770414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2444 "result" : "invalid",
2445 "sig" : "0541e9a8f0735076b58133e205803982f403cd1203407ebff3534a48eb35f06842fd496d505739fb07dd85f48b3b24685e1d6c7be539edc862cd9b6869097c7344847201842aeea3ebe3595557cb93269898e2109226a2f4eca5bfef0851a5fceb2d6bac753faf6dec4911610e6b40d827a00502537a6fe743d616558813df8a",
2446 "tcId" : 269
2447 },
2448 {
2449 "comment" : "including garbage",
2450 "message" : "48656c6c6f",
2451 "name" : "RsaSignatureTestVector",
2452 "padding" : "3025300906052b0e03021a0500241825000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2453 "result" : "invalid",
2454 "sig" : "5e21d6a684e3daf0be25155cf79874a6bfaee2b771d38ab8895f031cf25a9a05fc8e1d421ce78944bf57a3f0214ee090c42cec51decdc0dc3ab376deaa4603d59eb3ec8b4470e6d8b00b53651873d48f6f2cbd035bacd0f7b24633a025b8ea9dc7c55dfc6578601849e9aaaccdf5fd4d1611b45ed3abe2010079e64de8ab74e0",
2455 "tcId" : 270
2456 },
2457 {
2458 "comment" : "including garbage",
2459 "message" : "48656c6c6f",
2460 "name" : "RsaSignatureTestVector",
2461 "padding" : "3029300906052b0e03021a050024160414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00004deadbeef",
2462 "result" : "invalid",
2463 "sig" : "1f96486457eb037dc9e2464e507d720adcf90f48a0dd1d42bf4239df64e5ef25556ec27290a8d87fc9fb89ad0a8547980f6b2bd7efd0dbe425559bdf08005fb762b92d0aea2f33c17002ab9a911e457532f0134d2e35db6b3393436de160faca0a2c82509ec929d2893bf82a83bfe1a59fc9189e7ca846998b39919d3ec4d6ed",
2464 "tcId" : 271
2465 },
2466 {
2467 "comment" : "including undefined tags",
2468 "message" : "48656c6c6f",
2469 "name" : "RsaSignatureTestVector",
2470 "padding" : "3029aa00bb00cd003021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2471 "result" : "invalid",
2472 "sig" : "48eedcec184b7ade4fb34efac030a4ce140fcd91a1a1e986bf5232e8db9160f076d9ae36ca23246efd53ece2014ea56d5e596b42ce66e3c585d5e6a4cadcd779c6df0d8c43e7945cf02a07dd3851258ed021ade9cfe6fc3df222ebbd6b9e3f39b4331a11c4ea401592883b4f8da7372526f4f3e7acfdad447846ac8160e5ce38",
2473 "tcId" : 272
2474 },
2475 {
2476 "comment" : "including undefined tags",
2477 "message" : "48656c6c6f",
2478 "name" : "RsaSignatureTestVector",
2479 "padding" : "3027aa02aabb3021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2480 "result" : "invalid",
2481 "sig" : "107ae9af715ac312dcae1f831a818dd55caa33e659ac6f1a15ef41ebed6207cb54a7faa7e45b519a3ca9c304a645f24ee9ad3eb83d6856ce4809e5d7137ed30e919c9615382e9e8767495495cb7dc4cc27e2ee8932c47cdc6c9154391993108cf952fbada535823368843adbfb06d874c14634659f7dd89b02a14377a5c1e8c0",
2482 "tcId" : 273
2483 },
2484 {
2485 "comment" : "including undefined tags",
2486 "message" : "48656c6c6f",
2487 "name" : "RsaSignatureTestVector",
2488 "padding" : "30293011aa00bb00cd00300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2489 "result" : "invalid",
2490 "sig" : "34b98ee9fe1600e2806f67ea122dfc989aa727f16c8e2cf704b1f05026105b595528692c16a052725a2ea47c4ea2ef13c2f5f9a9304d11607a25b8cb261e64658c6047627e9a7651730b81376d9fd978547c270d15f5c57126e3b41b39ca687d6c8be52bf2552104ca06ef64dfe317095b835cdac2840d4f0d3febcc3863684c",
2491 "tcId" : 274
2492 },
2493 {
2494 "comment" : "including undefined tags",
2495 "message" : "48656c6c6f",
2496 "name" : "RsaSignatureTestVector",
2497 "padding" : "3027300faa02aabb300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2498 "result" : "invalid",
2499 "sig" : "358ce2879366fcebb1212839560958d6a3cfc4cffe2a05e9c7ccbdf18b6427f419a2c1e85fd82e27bc63315a9742d141ca157a435c4f20758e4011b8b0b33b9fb5f0006170c3bbdf4d2fe16888404dbf8b9c00ef30bf45ea68371b76a692f98e79c6c5a574e410a8505d5166112f43cffc506a9d46276cbedfec64f1b2697584",
2500 "tcId" : 275
2501 },
2502 {
2503 "comment" : "including undefined tags",
2504 "message" : "48656c6c6f",
2505 "name" : "RsaSignatureTestVector",
2506 "padding" : "30293011260daa00bb00cd0006052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2507 "result" : "invalid",
2508 "sig" : "5affee843b343a6d142406d3d89366a9149d642ca12a661c5d0eb0c1b5e15d3c90dc134eb76aff110b1964ed6566469c47e54aba7145c5601412cd38c630e05236c169f2ac6491795408d410a763f0090e299ad9022ebacfcf2f8f0f248674402479db2387e9eefe47c86c2430e529cd13e213753332fc4a3541de49dd1f3920",
2509 "tcId" : 276
2510 },
2511 {
2512 "comment" : "including undefined tags",
2513 "message" : "48656c6c6f",
2514 "name" : "RsaSignatureTestVector",
2515 "padding" : "3027300f260baa02aabb06052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2516 "result" : "invalid",
2517 "sig" : "5cf35c6711fb8b297ec405496e8db527ad1cbcc55ce6122b24ed917fb989c28e369354900abb96f41457f15754fd1060710c6e984db30eb73300cfd890454e97957a589de151225827b5a12384717a7ad92aeb941e1e148e8d008e11598bc7b8a3eac35f2af5584f61335a608c5206e5e24cf934ef2009367f3403e8da2dd0cb",
2518 "tcId" : 277
2519 },
2520 {
2521 "comment" : "including undefined tags",
2522 "message" : "48656c6c6f",
2523 "name" : "RsaSignatureTestVector",
2524 "padding" : "3029301106052b0e03021a2508aa00bb00cd0005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2525 "result" : "invalid",
2526 "sig" : "6e037fa40b3ce48ea72b28bc1ce8cc01188e6f84addcbefa2c729179043b3804d6ff1f25d85c2b9d72acce9c9c64e3f63ecffac670f76b2be75d63b3cee45b72f8758345021177ed13b66ecf0082e3c4418cc92713bb9867c8d28b78f30ff599e82f17734d0772e1e733c0b74fbf31c4f1ee99dbb89b5b113a7f628742d3b2a2",
2527 "tcId" : 278
2528 },
2529 {
2530 "comment" : "including undefined tags",
2531 "message" : "48656c6c6f",
2532 "name" : "RsaSignatureTestVector",
2533 "padding" : "3027300f06052b0e03021a2506aa02aabb05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2534 "result" : "invalid",
2535 "sig" : "5e7bf33ad4d9393d6b368764fac6395ed8ba3da7bf04a0f95d8426684bf0e9f2f78c9e49189bbeec883955af428e6e4527b871aeac21feb8231162f5380077c1fdf63a7cd4be65f813663dd82e732cfb3e1cd09298abbc42fbddc3551772f492627e657febca487db5c03c54850327eacc44dbf4a7c230f1c8166138cbd95587",
2536 "tcId" : 279
2537 },
2538 {
2539 "comment" : "including undefined tags",
2540 "message" : "48656c6c6f",
2541 "name" : "RsaSignatureTestVector",
2542 "padding" : "3029300906052b0e03021a0500241caa00bb00cd000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2543 "result" : "invalid",
2544 "sig" : "0c57e98c13628c8188a0095b98d312cf0fa1a1d2039700ab4c607fe75ea0fab11c2c84e5d22d26b014ae1c2aa948efbb1197e39eafc49cf9f010a7b2be4ab9dfa94ad48ce5dcd5c7fd405f55922146cbc541b9ebc1c89f30a2a3f7cf4a8b14797ff4a60922ac710e7496931ff69e4c0d4e06375c05a7ef1910cbd6c3cae5bbb8",
2545 "tcId" : 280
2546 },
2547 {
2548 "comment" : "including undefined tags",
2549 "message" : "48656c6c6f",
2550 "name" : "RsaSignatureTestVector",
2551 "padding" : "3027300906052b0e03021a0500241aaa02aabb0414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2552 "result" : "invalid",
2553 "sig" : "874f05aca449fe8b39b29dff1eb20b145ca4bccd25981176d33b6b41a1dcb48b7a668782549013deeceae3599309f541bfd4a15eb984a401bec4f0facce679c0608d962964b85df739ad19a926de875f6404ca5b209891d380f6e53140b1bfc05a2cf1db336d3a01e8777614299b6e2f683f2406b295f3366d77505cb2e56875",
2554 "tcId" : 281
2555 },
2556 {
2557 "comment" : "using composition with indefinite length",
2558 "message" : "48656c6c6f",
2559 "name" : "RsaSignatureTestVector",
2560 "padding" : "30803021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2561 "result" : "invalid",
2562 "sig" : "123c3ba6d4a5de10837fe12e9b2c61ecb00c93c7d25aa440b7c739df817ccb37be122c5f5570e44a943ee345590c5ca0597605c1487986dfb75245f8e89e4f29aaf3c8eb5c5e8944a63baee4d0143ea2765b0f297a1da8a51981c26a807cf4f9a1aee00bb75cedfbf6466098f7aa27f1e3e63f4f0b7b8c40fc837c23248e914c",
2563 "tcId" : 282
2564 },
2565 {
2566 "comment" : "using composition with indefinite length",
2567 "message" : "48656c6c6f",
2568 "name" : "RsaSignatureTestVector",
2569 "padding" : "30253080300906052b0e03021a050000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2570 "result" : "invalid",
2571 "sig" : "2220dc736ee3c63b5d5915050c6687b3861b52e664ce1ab501681d6e40990f02dfaf96f240adf2dfec05edcb268f6dda4129f901f7416660d56ab3a4145bc354fd11a1dc4e1535a4b8a61498508019ac38b61636356a641b8fb4d4739eb84b4fc49647fad35668ead0743aea841214a6e628ab2b5488de6e60d012c0566fe78d",
2572 "tcId" : 283
2573 },
2574 {
2575 "comment" : "using composition with indefinite length",
2576 "message" : "48656c6c6f",
2577 "name" : "RsaSignatureTestVector",
2578 "padding" : "3025300d268006052b0e03021a000005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2579 "result" : "invalid",
2580 "sig" : "51fc2dc54c9a46a30ea1c7ea262e86c85110f8bbe42d5abaa3eafb13fa7f3e2424090476c2e50e5eb74d3b6f5e5fe379f3935afe5ed940d443fbcb8686f999c6fdc9e508a5fc7c27bc17169eb5d8e0421ebe7d04260c60435f56d4f614ab9dc0b9298c45fd660c352d35d2985831622eea08010bc27c887f95cb33699759e630",
2581 "tcId" : 284
2582 },
2583 {
2584 "comment" : "using composition with indefinite length",
2585 "message" : "48656c6c6f",
2586 "name" : "RsaSignatureTestVector",
2587 "padding" : "3025300d06052b0e03021a2580050000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2588 "result" : "invalid",
2589 "sig" : "87fb9a61395878aafc1fb4a872d8e2db7db123ce4b2d67cd36a7f6e7e190d0bef9487f54340c28fe55d1bd9c38afe166924c787169890493d5cd2a5c79317064313b77a481ddb8bff9a917da32899448d9104ab67dcc856aee617a0a65631609f0632d58bb6585b4dd0c4a8bb41fa0dab99a08489feda41f1e7e5e1fde382952",
2590 "tcId" : 285
2591 },
2592 {
2593 "comment" : "using composition with indefinite length",
2594 "message" : "48656c6c6f",
2595 "name" : "RsaSignatureTestVector",
2596 "padding" : "3025300906052b0e03021a050024800414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2597 "result" : "invalid",
2598 "sig" : "442ac72092d6956bc846d7be909704dc4633e3e59e6ff4bcc97bc9d412645dc17ec3db8bd885150bacfbb085dc90bdf26129637876a4d5713beee0385cb5ea7fa6ae57208df368b4ba95720a716d58ca6ee5a03ede1cc7f2ef31d8c459576ef72f6ba1b5d9409efc74932543ed601f957913a12304c2e29dac219d78ed12203a",
2599 "tcId" : 286
2600 },
2601 {
2602 "comment" : "using composition with wrong tag",
2603 "message" : "48656c6c6f",
2604 "name" : "RsaSignatureTestVector",
2605 "padding" : "30803121300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2606 "result" : "invalid",
2607 "sig" : "2ebe12f793a821425e9513256ce1517b03b6bc19e2c2347e94651054caffb1f5d6101d4f3402d5945b4aecd04dacc3ba89d1123916d44941715951e9fd59bf0614a0534762e86275a8f1b0b16fd9a9d146946cff740c206ba6b27b26e8d1fc43b2b4d117e144973091674607844f86fce6f07a2a63acf8df67d3827141ad432b",
2608 "tcId" : 287
2609 },
2610 {
2611 "comment" : "using composition with wrong tag",
2612 "message" : "48656c6c6f",
2613 "name" : "RsaSignatureTestVector",
2614 "padding" : "30253080310906052b0e03021a050000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2615 "result" : "invalid",
2616 "sig" : "6e4d642285fa7a46daf985135181712e84efd52cebe8885b52c61a5cec753c1f8c8ba42886b584faf1551da81232214c2088060e6843d0d319a5e877bd4c500f6832f537306285011e5d8b98e2fe00bd38885211478f27b0d037c34d79d7f4d5828403d20b5463a7e1e2de2398c79fed33bc9eee2fdab52bb40acf9fb68a16a8",
2617 "tcId" : 288
2618 },
2619 {
2620 "comment" : "using composition with wrong tag",
2621 "message" : "48656c6c6f",
2622 "name" : "RsaSignatureTestVector",
2623 "padding" : "3025300d268007052b0e03021a000005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2624 "result" : "invalid",
2625 "sig" : "0de20757fb64e3633c36e8965fcc20631e9e890152e3a1d2d6a91fbe9ebd56bb99126050c79b41ef0c107086106738a91d0e815d3218404c1db9d4e8526e085ae10195b9cee788fdf7ba9d28c614bce268af0cc58b8a959fb4c24bfceeb5bcfcc4e326d9de825bcbd8eed0df37de2add59f8879326a7e6bfa2a36eb48eba2f36",
2626 "tcId" : 289
2627 },
2628 {
2629 "comment" : "using composition with wrong tag",
2630 "message" : "48656c6c6f",
2631 "name" : "RsaSignatureTestVector",
2632 "padding" : "3025300d06052b0e03021a2580040000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2633 "result" : "invalid",
2634 "sig" : "2e48a4122de8e1779d169f5a6ab72eba7ca3b0c31ea73d41fd82047e18559ff9706acb85f92872124b4020ae001dadc76b61c0e166df0af677f886cde8e13dc8c2b5c93d62cee44cf3bbdc74756d249d3c59834e079154f6646a8c69a2320cf7bc3925523bc2ca3f8fa7d63650321d2a4de3ef3726f74a2020ff5db397454242",
2635 "tcId" : 290
2636 },
2637 {
2638 "comment" : "using composition with wrong tag",
2639 "message" : "48656c6c6f",
2640 "name" : "RsaSignatureTestVector",
2641 "padding" : "3025300906052b0e03021a050024800514f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2642 "result" : "invalid",
2643 "sig" : "6726053471ecf6651529165c96db60559a525efb27d31de913a44d885d33e404fa9dd7d28de94a7d8dfaed297ae500a55bb3535d77dad3031f7edf7bcd636534621d870c28fe64f7b4752f59cb1490208405bf38dc054311473286c52a59a8c6060827ce9a2ccaae9739030927aaa5225d45655be1fd826eaa6b27a8e20a4f31",
2644 "tcId" : 291
2645 },
2646 {
2647 "comment" : "changing tag value",
2648 "message" : "48656c6c6f",
2649 "name" : "RsaSignatureTestVector",
2650 "padding" : "2e21300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2651 "result" : "invalid",
2652 "sig" : "4aba9d2c7a58610d7d3f1050cf5c1558369823c1a344c1573b64d3e8483e04995176f05c255ba67e8bfdcc6c7ca640a4ae423bb3c027f8b14318467e6ce1086db7307c0c9c56acd0372c9f53ad17e117df0557e5548d8d7bb6b9545ace3354f5400b832accea7c60c2585b34881461ee6595f0fd564de7f49a7f0228a042c39d",
2653 "tcId" : 292
2654 },
2655 {
2656 "comment" : "changing tag value",
2657 "message" : "48656c6c6f",
2658 "name" : "RsaSignatureTestVector",
2659 "padding" : "3221300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2660 "result" : "invalid",
2661 "sig" : "8c7108f3eab93fdfe930ff1a149a071019936122a4ba0524e309c9af89664f4a202a4f49a4288d80f759521de7e0e04409b5d9f4cb93a722724e34bce76607f9a4c46081abc5a606cda70a859ac1fc931afd10d22a7a4c224cffea888979cb314e9a8dd75a85059bc282c923ca5fd6b508cf4e0c21a93f5d179d05228316eed2",
2662 "tcId" : 293
2663 },
2664 {
2665 "comment" : "changing tag value",
2666 "message" : "48656c6c6f",
2667 "name" : "RsaSignatureTestVector",
2668 "padding" : "ff21300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2669 "result" : "invalid",
2670 "sig" : "5200334dfd766b1052dbe9d422f94b979b60afe3d9a2d60aa5eccf0e449357296eccc321561534450ddec51de1b6dc6b94e1e8b1ca52714230f9f7081a36eab655827defce738670c769953dce9696110689c1db5d475c4b1b030db86cab46745b4f23d68dbe3951e089786101d19548816f78343c942f31373519aabee6e520",
2671 "tcId" : 294
2672 },
2673 {
2674 "comment" : "changing tag value",
2675 "message" : "48656c6c6f",
2676 "name" : "RsaSignatureTestVector",
2677 "padding" : "30212e0906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2678 "result" : "invalid",
2679 "sig" : "3fc2126ef4b90f42dc8817fb368e4fc5ca34105ae98b3298425af76d2a304ffdabf8d246a53385e0b1c2a2c46205d64eae7be9edb22d5d9bbfa50bca0ca7a8b279ca8eb0ef3aa94d48ec1120010148a58bb576258ec2fd57d10c3d60ed4d94160c5256a24973e5a8333a4f54c288a18494eeff5579e52ee8a45af1ef9943d6a8",
2680 "tcId" : 295
2681 },
2682 {
2683 "comment" : "changing tag value",
2684 "message" : "48656c6c6f",
2685 "name" : "RsaSignatureTestVector",
2686 "padding" : "3021320906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2687 "result" : "invalid",
2688 "sig" : "8cda31b963c774894aeea363abc4af9a8b83cd4aec6cc9197423e7bf9f6935bce978a148d9179f47c092f3de5bf9229f37f86e7586d8fe197cabf27b99a902e561d722b0359a738523aef87286d19cb36d7b430aef83d9828df1aa334ec3835648b3b2af8c2c65f9ac8990d2f4df370d49da6f81dc93cb7035ee931093d843dc",
2689 "tcId" : 296
2690 },
2691 {
2692 "comment" : "changing tag value",
2693 "message" : "48656c6c6f",
2694 "name" : "RsaSignatureTestVector",
2695 "padding" : "3021ff0906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2696 "result" : "invalid",
2697 "sig" : "426aa261ad32507dbd08dc315b39368e8909824128abb746c65743fee574b42840489d54c8c5d6c5553e8ae1a3f14bdf4ae3677fec308864ad9d5ac5439976e9379904c6ae5a24e73daa34822e846a0eced7314b4cddc0111c21387d56f89f03a470b79514dfa97c405c8ca9dfbb6f2e3610a8eb5d6c52b37b200a1519026e7e",
2698 "tcId" : 297
2699 },
2700 {
2701 "comment" : "changing tag value",
2702 "message" : "48656c6c6f",
2703 "name" : "RsaSignatureTestVector",
2704 "padding" : "3021300904052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2705 "result" : "invalid",
2706 "sig" : "126d30c8acb2fdaee4e622a2b4f2a16c56b50d03c3fa4ef5a417e9aac346512483e1f4fb7217ff640197d31b0d6f4c41403945dcef37da312f33eb845fb862ec9994060b085c005c6feb382547a4fa1a7d6e7383c81c8ff7a51b539cb55c94d41fa804d9d6968b57a2e8c946f5260d835167b3b5a8302bb054638b9842ac963b",
2707 "tcId" : 298
2708 },
2709 {
2710 "comment" : "changing tag value",
2711 "message" : "48656c6c6f",
2712 "name" : "RsaSignatureTestVector",
2713 "padding" : "3021300908052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2714 "result" : "invalid",
2715 "sig" : "44715b61effca0e94098d7dba43839ab8999dca771968c09b9263a9d732d000db443e4253394eb357cb05bc0d2a715d4d9a0a64b64e3ae7938e040bc9ce6f2b2a5172a564bf970a56a12dbe54d96bc9a6d5d1ee78b112e7c5447015dd461ce824062161f513f17cce02f259a80fa78e655b9c09d5f129fcab8df0a045d19142f",
2716 "tcId" : 299
2717 },
2718 {
2719 "comment" : "changing tag value",
2720 "message" : "48656c6c6f",
2721 "name" : "RsaSignatureTestVector",
2722 "padding" : "30213009ff052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2723 "result" : "invalid",
2724 "sig" : "5ec2194d5f835d6dba9c4ab2bdebbed946f106fcd2a3c6a623e67e6f8ed7ffd8eb4d41f0bbfdcaad34a34d84f9a735f78de159748efe2fe3629f7f185e681dbc5c48025469fc890222e5be9884c550e5cc483f6854184df13162f20d1daeab78eccbc52988815997887e4e52ab7b756885442c7ddb557e726642bccabdfe78fb",
2725 "tcId" : 300
2726 },
2727 {
2728 "comment" : "changing tag value",
2729 "message" : "48656c6c6f",
2730 "name" : "RsaSignatureTestVector",
2731 "padding" : "3021300906052b0e03021a03000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2732 "result" : "invalid",
2733 "sig" : "2fb77b5a5766d1e898af896192abf3f347100053b920dbaa931a8f210f1b84d522b283e59f6f6f5b7b13d4a3ffd21d2e0b64d1b275501b0bfadd23e89361f327e8fc7f29992dde2e5ecd85ae81cc1740228f983b02bb9875eb30597fd247a8351ba87a5ad5ae32cc4596b4105904a19e5805b92c266f66a9516fc2ca519ceb14",
2734 "tcId" : 301
2735 },
2736 {
2737 "comment" : "changing tag value",
2738 "message" : "48656c6c6f",
2739 "name" : "RsaSignatureTestVector",
2740 "padding" : "3021300906052b0e03021a07000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2741 "result" : "invalid",
2742 "sig" : "6a853a5244bf6d3795dd7047da88403f24831169f0fe2f7b789109f279d01e092d5e35d837644c4b83614bd40ae164290cb4fe6fb6eea7dd271195d0b81715a32184342c8c83a82ab6fc62ad58e299b619489d5670c65a6f9faae11909a825da0c4486ea2ba1002f5f8d1dfaccfee2312c9098ee684675f920e61a3f6ff11480",
2743 "tcId" : 302
2744 },
2745 {
2746 "comment" : "changing tag value",
2747 "message" : "48656c6c6f",
2748 "name" : "RsaSignatureTestVector",
2749 "padding" : "3021300906052b0e03021aff000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2750 "result" : "invalid",
2751 "sig" : "16f7787a9f5760f025b2e03886ae1a6c83a99a7495eb57e01b687434a1aa27e5f73e0440a0e6d45d7dae80b7f3d9dda8e2bd37540eac08bfd75f13371daa98a334af10762a55b684bef3c67ee6072717ee9fe67397fd612837e0c449d0404382a1b59adb19bebe32f29b1374b36f9649c0c5fe838252c15e2c8b92ba02bf607d",
2752 "tcId" : 303
2753 },
2754 {
2755 "comment" : "changing tag value",
2756 "message" : "48656c6c6f",
2757 "name" : "RsaSignatureTestVector",
2758 "padding" : "3021300906052b0e03021a05000214f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2759 "result" : "invalid",
2760 "sig" : "71629cae46ffacf0f7af338c56deb86464d037b1c38baf338eea05164a1bc15db208b8e3054d828dfa10aa5595d20e9010d071baff42f5d39264ba7a10ab263a30cf169021bafc2647bccb1f624abd87ea18750fb3380e7b0bcc0e12f96ffb6b98caebf9f2faee4644c8d6f0d8d33511725ac390f99fae9b40968de60a50dbb2",
2761 "tcId" : 304
2762 },
2763 {
2764 "comment" : "changing tag value",
2765 "message" : "48656c6c6f",
2766 "name" : "RsaSignatureTestVector",
2767 "padding" : "3021300906052b0e03021a05000614f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2768 "result" : "invalid",
2769 "sig" : "656312f836bcfdfb4e38f88994a2295bb55ecff0e745974753b22a15c67c64c92c329693917050fae66f565310f8ef8cf4b37dd47eae088adafc34cb0a2eb1d34223ff51bd230d3946fd8d4abb8ed8d4c923bdff7011052e07b358bc5d59deca4a3d82999e54fb5d521564e9ce1fc69c3968adf31a5837fdecc0c9552297ecda",
2770 "tcId" : 305
2771 },
2772 {
2773 "comment" : "changing tag value",
2774 "message" : "48656c6c6f",
2775 "name" : "RsaSignatureTestVector",
2776 "padding" : "3021300906052b0e03021a0500ff14f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2777 "result" : "invalid",
2778 "sig" : "8fe1efcfcfb09cb4bcea76590fb8fac5ad9428898848d3c20efb256ba2532dcd77603bbc2cb7c5902e099081f6a54ecfa4b0669d5391c10f391aebfc636fef14bb7bda71f12e0d9f164a2ad47abba6103986eba5cbb0b1a4bc3887a51ebe614e0dfa60afe1c5c0bd76911d01450952408384fb88e795897c0ed64e28c5f00b71",
2779 "tcId" : 306
2780 },
2781 {
2782 "comment" : "dropping value of sequence",
2783 "message" : "48656c6c6f",
2784 "name" : "RsaSignatureTestVector",
2785 "padding" : "3000",
2786 "result" : "invalid",
2787 "sig" : "2b58ee609310e66e3d812f20eb3a9e2995bbd5947b5569c0c23aad8638590a43c8610e25fe6c248b74392ebe9f4edabb1e5b918e227f49bb9df288f5755d06f7a22e8e7e3d63b21ac023d35067142f301bde6f6ce017ffdd256647861801e3dcf38b18888b9986eb2c944937fe1706e28988f0781b7acc83c4a0ef4b40b25b44",
2788 "tcId" : 307
2789 },
2790 {
2791 "comment" : "dropping value of sequence",
2792 "message" : "48656c6c6f",
2793 "name" : "RsaSignatureTestVector",
2794 "padding" : "301830000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2795 "result" : "invalid",
2796 "sig" : "1bf19d3dbdc4d1ce61350bb52d11ef6ecde6816b875ce7fa7361bb2edf84115313cb95d21f3472b7d178e27c0701c6ab528a735fc0ced0a8af81c78d96227ffecc545c8cb7a49fe269e97d647b5b01e0996f29689504b1ff4e4d8e08fab6756ce9603c0bd622b4e74eb8c18373ac1efd5074d08ddaf8fd7c3204e25fc0c99328",
2797 "tcId" : 308
2798 },
2799 {
2800 "comment" : "using composition",
2801 "message" : "48656c6c6f",
2802 "name" : "RsaSignatureTestVector",
2803 "padding" : "302530013030200906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2804 "result" : "invalid",
2805 "sig" : "5e1f0d448504349b31c8a5ed03e066c7dd7878622fe42d645bae8592aee87e1056504d92a88a3626c54fe3da07649ae6bb30315f3c3b358beed1afd38d414785906dbbc6d0e188f9006756a545a1d1979a496449689ee3cc067072624ef5f2de8a1f6f0c798e8bbbb9b6e14db12512feaff11063dc3ca3a5b3bd5926bcabbd78",
2806 "tcId" : 309
2807 },
2808 {
2809 "comment" : "using composition",
2810 "message" : "48656c6c6f",
2811 "name" : "RsaSignatureTestVector",
2812 "padding" : "3025300d3001063008052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2813 "result" : "invalid",
2814 "sig" : "18d30faf84664f79faa0dd0285c408fe54793df5858ed7cc367d62847470e32f433edb77c30f0d0dd549220cb18eba18d1076820ec27ac37bbd8b989b847ed8c84ed1930e7ea8566a9d043807b0f03fae51aa0046483343ae06831743fa79f4438190164e9d5e75610bb5fb9201365dd9dd4aa6b5dcafcfd73161dde7da40e99",
2815 "tcId" : 310
2816 },
2817 {
2818 "comment" : "using composition",
2819 "message" : "48656c6c6f",
2820 "name" : "RsaSignatureTestVector",
2821 "padding" : "3025300d260906012b06040e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2822 "result" : "invalid",
2823 "sig" : "981a4523b61116d28d4bdb8d80969f7fe1cfbb06f4dd218d05fa332680b1342d20f0e4d4a1a6401ad777615fc56e3ca2fccaf07139f43ebe1d92d20605f8c894d88e8c062487fa86f51b2026dd12ba68077c3551d928990848bf0de07cd880194f2ac276af86c1e55e25044be3c7204ddafdcd61795a9e3b7885a88f43aa6b8f",
2824 "tcId" : 311
2825 },
2826 {
2827 "comment" : "using composition",
2828 "message" : "48656c6c6f",
2829 "name" : "RsaSignatureTestVector",
2830 "padding" : "3025300906052b0e03021a050024180401f70413ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2831 "result" : "invalid",
2832 "sig" : "98d603185c1e2927622056c9053a62e17ea4aab5808418725cf8887720f5f3500cfe6ffa00513e45b72c9fe44d288d06555bf715282f6feb685df2f44bfcb3ed541653139eeeaeabeae9d52514495b604512a9ad6223f68a860612b668f5a0993ebd5c9ce9cc00baa80484d60b01c23a6abf40be03cd1cce3317563b1f9326f5",
2833 "tcId" : 312
2834 },
2835 {
2836 "comment" : "truncate sequence",
2837 "message" : "48656c6c6f",
2838 "name" : "RsaSignatureTestVector",
2839 "padding" : "3020300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0ab",
2840 "result" : "invalid",
2841 "sig" : "3b5c1e0d3dc103755b67feb766d58968f94e8d8af6a209f6d28e7c0541a4fdf7a6976f664414f5ee0beb9369a59681291fb2c902853fcaa01bd065fb7a1da967849cf45bf558e375058591b3af1b5c8a18da21d5dd7598e7e3aebe0478180200294b86d88b1c39e224bc1dc22f1a8e537e05db467b5a04dc70ab9346c79fddd0",
2842 "tcId" : 313
2843 },
2844 {
2845 "comment" : "truncate sequence",
2846 "message" : "48656c6c6f",
2847 "name" : "RsaSignatureTestVector",
2848 "padding" : "30200906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2849 "result" : "invalid",
2850 "sig" : "61b6f98e16e4809448e56d9845850b748bdb64064ed4851c141c57e93c37744bd91f54f5ffd9264f151294e6f73bc8d5a51daa06b9121bfea1f28847229875ab87a7297dc383987db1f6bc1133e344a95af6d34fd18105d154ca951e4e6f64f9fde7994207ddd5eb6bb2a07037f13c8d853a8b8684431d5ecf1cc9bde41cda49",
2851 "tcId" : 314
2852 },
2853 {
2854 "comment" : "truncate sequence",
2855 "message" : "48656c6c6f",
2856 "name" : "RsaSignatureTestVector",
2857 "padding" : "3020300806052b0e03021a050414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2858 "result" : "invalid",
2859 "sig" : "8c05912e8ebe5f2cc9fcbc2410bcb63b217756cd961db8caba316634c6ce191f365a21137602373f357461e9020b702025c61e3571cac6967a8f68375a9cd4792222b59c54e21649776f6e7d5995448779f7f9d32bb4e0e4e2b612b5c2b8574d98d01b9cdd26965541c0a67d484e13d4f49095ff7030b180569058376c7926a5",
2860 "tcId" : 315
2861 },
2862 {
2863 "comment" : "truncate sequence",
2864 "message" : "48656c6c6f",
2865 "name" : "RsaSignatureTestVector",
2866 "padding" : "30203008052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2867 "result" : "invalid",
2868 "sig" : "8bf895e0a26741d142767e67e73f102180a5e2083ee27d869585cd02c0211673641ab3e4f84cfdb2748b0a3a39db047fca2261c7ab3a7bac575990741d15c543f83f9da27fb5da3362ad1ce1a0eccf853b9e0a36f851b6cb5734cd22bc3b621193db37e13dd06d8854ff111dac2c939618aa041abce70123cb14d62d527223c1",
2869 "tcId" : 316
2870 },
2871 {
2872 "comment" : "indefinite length",
2873 "message" : "48656c6c6f",
2874 "name" : "RsaSignatureTestVector",
2875 "padding" : "3080300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
2876 "result" : "invalid",
2877 "sig" : "5280f9fd14542d5b61a951893b081540d922ba15a7a650aced363106d97b69aff5b1ad624528b7560dce27c3a3e8f8657c8b0e9b83ab63342550fea7469ec14ef1cf48ed33515d56c7872d5eae8cf2480ae7549a8ce4c56748d08c4f3a61bd13b9c9ead6bcaa113bf3f85a112057658689ea075fc8ac7d74216918d588865ec7",
2878 "tcId" : 317
2879 },
2880 {
2881 "comment" : "indefinite length",
2882 "message" : "48656c6c6f",
2883 "name" : "RsaSignatureTestVector",
2884 "padding" : "3023308006052b0e03021a050000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2885 "result" : "invalid",
2886 "sig" : "88cd60c74205ced62ae7bf35eae4c86826ca946a9b3bf190ab8069734489058191b6a501b6766fce0f5a3e5f7a39c0deae40aa66ab36b5a2a39d955650118ded3a8dba0df5b50056058cd643630133c4f2cbaaf8055cbe96e63e8fef8074fa23e1f1d5a1b5cb5ecde5fde92c78441f2907aa53ae9e3e09f0a7a7628e4e2be5df",
2887 "tcId" : 318
2888 },
2889 {
2890 "comment" : "prepend empty sequence",
2891 "message" : "48656c6c6f",
2892 "name" : "RsaSignatureTestVector",
2893 "padding" : "30233000300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2894 "result" : "invalid",
2895 "sig" : "91c68a2673606cff82abf69c9e2d591315595a3a0b612d6d2708528be0184c9116195f58cb4109a69f8d2f7cbf4036affcebe7a1615a914833b921b915ea12b16324e6e74f95d6eb5b03201d67b945f03296ffb37ef7cda908e83f44dbed24a54e81b71f840668fa4fd82b29c0e1c5b1c021d481c73a662668603d3fbf5182dd",
2896 "tcId" : 319
2897 },
2898 {
2899 "comment" : "prepend empty sequence",
2900 "message" : "48656c6c6f",
2901 "name" : "RsaSignatureTestVector",
2902 "padding" : "3023300b300006052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2903 "result" : "invalid",
2904 "sig" : "17c921fb3a8535f2e472df2c447a60f2fe49a4afeefa065f1c84e50dc97f989268ae6bf1e8d77f5b2edd59c2c7f3653b7565902c5b889ec7007fb9006f244257649888a4a1883146c88828717d381018b1f00d656d5e092172f49fadb42f913a92ae1eb4e01e3c2490e1dc52a109e37094188bcaa181898d97ea2c0203a885a8",
2905 "tcId" : 320
2906 },
2907 {
2908 "comment" : "append empty sequence",
2909 "message" : "48656c6c6f",
2910 "name" : "RsaSignatureTestVector",
2911 "padding" : "3023300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf03000",
2912 "result" : "invalid",
2913 "sig" : "077b2d2e79ff380612aa3f9c79e8b7a580ffafdab8ca3ec86501c40248b3459c0c7b2590fc18ccfba2b0e7a34c67b8d3a7ed92fa686170475666570d38464720b4983e5c374f1b6c604226284a62e20a8a37341abd72f238aec8a2cdfeff00c512c28e608ce98e4bf3640c61509ec56f7e2143216214eb5b06bfd0fa448ba633",
2914 "tcId" : 321
2915 },
2916 {
2917 "comment" : "append empty sequence",
2918 "message" : "48656c6c6f",
2919 "name" : "RsaSignatureTestVector",
2920 "padding" : "3023300b06052b0e03021a050030000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2921 "result" : "invalid",
2922 "sig" : "2121389e8b2282bf6022c45e7a3ac9f42bd7f13ea37060f6989bacc72fb6e887db8128024698a5c76adea034c69604b1f56e062627c840cd2f80802e6f2764606b96b78506614198844319bf7726b95afdfd19d5ffda1ccb159646bee5c3d81adf56f2b54edf749ca99a86bc9452f6a307eae06f028f86b4af17137f6a2352cb",
2923 "tcId" : 322
2924 },
2925 {
2926 "comment" : "sequence of sequence",
2927 "message" : "48656c6c6f",
2928 "name" : "RsaSignatureTestVector",
2929 "padding" : "30233021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2930 "result" : "invalid",
2931 "sig" : "059efdc649108b988ee6a63697701a3c98bf7c770dd525844dd6e936d0f468b3c786f82a03c4b1d23caca0dd2a62a6ac43f58b6cb311a819f7b9f48cb9b59b17306deebf1d69a7d93a2d9381e48ddd0ef1d0a07dc5a5568eeefb3832dbbad503e21141f6dd58a5bf503a469d49dd3edc5f3a712b7e63d8ae734ee1808a9654f9",
2932 "tcId" : 323
2933 },
2934 {
2935 "comment" : "sequence of sequence",
2936 "message" : "48656c6c6f",
2937 "name" : "RsaSignatureTestVector",
2938 "padding" : "3023300b300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2939 "result" : "invalid",
2940 "sig" : "21d94c3d46c49bc86f376e2d4fba1495f98558e9f76136ba001f1f90befb6311771b700c1252894a5348491c262329e99cc52ee68e577615ebe73d59210f8ddd8b91ddced5fe98cd832b57a4c583318377892bb15bb7d545cc7a182fb47c3149b99e4db5f12df9105a055d0925d8f3d747a2f25ba1dd00a5184afa46695197e3",
2941 "tcId" : 324
2942 },
2943 {
2944 "comment" : "truncated sequence",
2945 "message" : "48656c6c6f",
2946 "name" : "RsaSignatureTestVector",
2947 "padding" : "300b300906052b0e03021a0500",
2948 "result" : "invalid",
2949 "sig" : "690c052df7c7079aa3bbcc9d4699ac50bf0dd90b1d6822046c7ad1429900ce2c4882af9decd580fab0698e5ce3185bcc234561e051533283d022831fd8b19434e4bdbc84223ddcd99d1a8f28a9ba222394312d11d81ee95831b4264d5434c3122c30afaf6b990ccb4f6991f60e78195d3aed5f670c4c2fdc034a514b92c67519",
2950 "tcId" : 325
2951 },
2952 {
2953 "comment" : "repeat element in sequence",
2954 "message" : "48656c6c6f",
2955 "name" : "RsaSignatureTestVector",
2956 "padding" : "3037300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2957 "result" : "invalid",
2958 "sig" : "4f4f38364932377af52adb8c51c5bd705088ddbfda713458377c3997915766ae05da5c797cbf24a9c73d36fa61b1b0bfb9c14e429c0b66fd6fe1ec041b9d14946588dc384a7a69bf2ab69fd8da67d0e1fab2dbf1838959cadd0d3ca03c9c0bc929d207be60ff8e08bfbb03f4423cd81fc5f587bbff3985d2beef69dce295b903",
2959 "tcId" : 326
2960 },
2961 {
2962 "comment" : "removing oid",
2963 "message" : "48656c6c6f",
2964 "name" : "RsaSignatureTestVector",
2965 "padding" : "301a300205000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2966 "result" : "invalid",
2967 "sig" : "6ea8317813355faec271a659d62cc94f7408fe73178a2de00407136a53b69d77136b9ef4533e3cda580761f42a683d4a02a2abb7aeb941a44854832d18950d8efc43ae8de29c0c97873761d126e15e7816d173dcaf9315dfa045681d9a4b37b2ce1578ffcbfb4c30cba6e1746ec3f95d310839d75ea873ffcc0ee82513342a71",
2968 "tcId" : 327
2969 },
2970 {
2971 "comment" : "appending 0's to oid",
2972 "message" : "48656c6c6f",
2973 "name" : "RsaSignatureTestVector",
2974 "padding" : "3023300b06072b0e03021a000005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2975 "result" : "invalid",
2976 "sig" : "990ac0a5dbe9f30114427c45925353e49c235ec8fc5b19724bffa75eb7e93987ed97dc3107e2ec26b9bb2c51d53f92158fca0baea0d881cb829e0bfcbc88f0021bf967e44a245eadf78fa8eed67aee696fde1a2a79e05a7c6a049f3af282a394f743bb4eedc9798b2d3290e8255a2339fb7a694e789a6fa38e2a236b948f48e1",
2977 "tcId" : 328
2978 },
2979 {
2980 "comment" : "prepending 0's to oid",
2981 "message" : "48656c6c6f",
2982 "name" : "RsaSignatureTestVector",
2983 "padding" : "3023300b060700002b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2984 "result" : "invalid",
2985 "sig" : "3c8995341ca2811f9e976e8157e708aa59b38f8e1a24ed16d8b30a19fa23c5df8b1ac2b3c82fbf91800918a2ad6b9320b10e39fb391254a3d954a278faffa97a2052513ccc8b17783faed189b8a4d997d7baba3053d6ab6493e2e36b3ee5046ea62d37a835a51390252dff088cc3a0a33cd1a82e557a0be0d5871b4fa18c05e2",
2986 "tcId" : 329
2987 },
2988 {
2989 "comment" : "dropping value of oid",
2990 "message" : "48656c6c6f",
2991 "name" : "RsaSignatureTestVector",
2992 "padding" : "301c3004060005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
2993 "result" : "invalid",
2994 "sig" : "87b5cb8841fa252f38c375b39ccce2d0361397a8436d2f37ca3e2293e554ca27fea1095683e42f274ccead1876d89dbb4e5dcca8e28972aeabe3d818144e96c020bef1de944724d1c2a813c633f8e7f8b6f8c8950d2c89dd26534430ff9cb6f5f08b332638b1385770a69bbbf6f76342b8270e2bd440df058c2ad55f9a0dd679",
2995 "tcId" : 330
2996 },
2997 {
2998 "comment" : "modify first byte of oid",
2999 "message" : "48656c6c6f",
3000 "name" : "RsaSignatureTestVector",
3001 "padding" : "3021300906052a0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3002 "result" : "invalid",
3003 "sig" : "288ea84a615e75c398407dc72e2482ffc013e09b1ba302790d17d0949e286c156584e6098858501b0c5c763615e59d840ec53269bf0ff5bab1f79c8e717497e705724fe933343106bab5b9e619b0a111a59b72be36372efb6fb981be725e3408a1185a5f42d486d8c052af448f0abedbeafaa1d5d8caf5fc03d85329fe675f9a",
3004 "tcId" : 331
3005 },
3006 {
3007 "comment" : "modify last byte of oid",
3008 "message" : "48656c6c6f",
3009 "name" : "RsaSignatureTestVector",
3010 "padding" : "3021300906052b0e03021b05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3011 "result" : "invalid",
3012 "sig" : "222c07c03d0c5bb3cbe70a8835447ff9af92ce32245f0e1de0481d87bd174731093f9b84aa5381b107c00fde8ed78030026d87951f8e5b6180827ff2a0a277db3a8f5031a82b83259bf6baab154cda64b372ba3cac5c629459284d986f3c2367e8b14f6dec7d38628e4ecb884158cc78ac39f4c9ee537d45370b089418d7227e",
3013 "tcId" : 332
3014 },
3015 {
3016 "comment" : "truncate oid",
3017 "message" : "48656c6c6f",
3018 "name" : "RsaSignatureTestVector",
3019 "padding" : "3020300806042b0e030205000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3020 "result" : "invalid",
3021 "sig" : "3fcd54aa3d66afce987282cbfe09f0a6eb30d0c94227bef8a2c9fccba44f1c8aa080b361b13eed4c9d0d37caf26fe61ddac8347102d9080cb17f2cfdba7e217df3f8c19039d466241264ae8caf15652c8f72a6ae292dc71c80049d679034ad19bc745d6155cb2efde963f738cfea08f7bba8894f472beff5deebe33173033317",
3022 "tcId" : 333
3023 },
3024 {
3025 "comment" : "truncate oid",
3026 "message" : "48656c6c6f",
3027 "name" : "RsaSignatureTestVector",
3028 "padding" : "3020300806040e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3029 "result" : "invalid",
3030 "sig" : "4ad8a7e4a92ee9aeb1bf3ee9392abe141d435a6ebd1799d90f5417e6daef65d37bf33c8c5255d52ce5d8b2cc223cd0c68a6061450df5c6694e2b911c8c25e6384a70fb19a50e10bfbc494fe5a62d9db915b7c77a27d17788f0567110bb046b8aa42d3ee1ea444c20b983226cf094f4cbfab24855c68f1e2e9fefd41b2dc7903b",
3031 "tcId" : 334
3032 },
3033 {
3034 "comment" : "wrong oid",
3035 "message" : "48656c6c6f",
3036 "name" : "RsaSignatureTestVector",
3037 "padding" : "3025300d060960864801650304020105000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3038 "result" : "invalid",
3039 "sig" : "949fecb83ddc236d3c622c9b6118fe0bf524080594c731636eb735e7d1285b5b6c527a2346b51c42fcf706184c4edd79ac98750dcf35973920aa19dee689cb7654b4785d2755b0dde4113c293e301f4e0331cf166bd8c7ae07031165fa4c02a3d6d70422fe42c7c6077a1f1dcbdc0de257363d51951ed1e2b8cb66684d42a8b4",
3040 "tcId" : 335
3041 },
3042 {
3043 "comment" : "longer oid",
3044 "message" : "48656c6c6f",
3045 "name" : "RsaSignatureTestVector",
3046 "padding" : "3022300a06062b0e03021a0105000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3047 "result" : "invalid",
3048 "sig" : "8a52f6b0275fe745b429d0a4a42122269277de6a5eacd0daf79166cf8ab8ad061e74d91ee1877bb6ca50b9bcc5f0677702184e6d8ffc841fe3b6c24c9cd6dc017824bad65d89a47a21e54f87005afb3f13cf11d10383458548394211074f19da555205026f4fcdfafb73041bb84f1dd9e8012bb1473314c85bb3460d51ab5f13",
3049 "tcId" : 336
3050 },
3051 {
3052 "comment" : "oid with modified node",
3053 "message" : "48656c6c6f",
3054 "name" : "RsaSignatureTestVector",
3055 "padding" : "3021300906052b0e03022a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3056 "result" : "invalid",
3057 "sig" : "216fc9e3ee6438bf1934f30ea7a86aba6ecbfc04fbbced4576a6c59f7a9f5a761d6a97d262142489807e4ca1b9bc02c86a80e093b55fc97bc943be0403bcf390f6140de964199f753b7afe430308b871fc0c596c1b08ca74006a10bdbd6a53064796747bbc203383ac7916ca1ef1a2def714e9f5f9ce9584cb09bd677ef374be",
3058 "tcId" : 337
3059 },
3060 {
3061 "comment" : "oid with modified node",
3062 "message" : "48656c6c6f",
3063 "name" : "RsaSignatureTestVector",
3064 "padding" : "3025300d06092b0e0302888080801a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3065 "result" : "invalid",
3066 "sig" : "135f14404b953bbcf4580133f0432cd746a5601ae01c5542924a1b28fc422c501c732dc330bb81d8df7a2a3829e6c5a151e81333832cb124d513f5b6fe799e207999c3010bf30689cc4b8b3bdb081d7351b47196de41e9f988c2eed49c22c7b0a6ca3eed511080fdc17d263b82ba668d3225da4fe66bffae68c536c4e38b2dcc",
3067 "tcId" : 338
3068 },
3069 {
3070 "comment" : "large integer in oid",
3071 "message" : "48656c6c6f",
3072 "name" : "RsaSignatureTestVector",
3073 "padding" : "302a3012060e2b0e03028280808080808080801a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3074 "result" : "invalid",
3075 "sig" : "21fb0d97e5e1a178b08e2bd646f59ab8ad1a7a955afa71d4c0e4631069ec8436abff03327b696c90b91f7769fe0b085a83ed2bed876a9da05f273b58ed057429ddf25a8b1bc0c87ccfbc8394864405c0b7c27d4a4b589d7a5711f36d8922729169520d7bffd52aefc41205a6ee8a54609d0533c64bc8e88b3d58ed9a04d2f9fa",
3076 "tcId" : 339
3077 },
3078 {
3079 "comment" : "oid with invalid node",
3080 "message" : "48656c6c6f",
3081 "name" : "RsaSignatureTestVector",
3082 "padding" : "3022300a06062b0e03021ae005000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3083 "result" : "invalid",
3084 "sig" : "9be13e0d25b9cd6a1b8544fb488254319505a1fb27fda933f8b91f6f325b5beffdb71dbf377093da2e0ca3098c891cf7d8a8762e1e27ba1d4e6491ac3fa4c8ad3d4e4937621904a347d197fb373c62766ad14525e2c32913e7fe6f045eaca77c9a5025a6746f9c7b94cab054c476548dd1eb3e01c5923ed681fa04d47ba126d2",
3085 "tcId" : 340
3086 },
3087 {
3088 "comment" : "oid with invalid node",
3089 "message" : "48656c6c6f",
3090 "name" : "RsaSignatureTestVector",
3091 "padding" : "3022300a06062b800e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3092 "result" : "invalid",
3093 "sig" : "4738deff4b32a30dd68b0abc1971dd2af9a500b5f6922558b96ac9b1ab4a50328b2ba9a48e7c207a02ddf642728930f4004d337483eaa0a01fb038a7a6c289672bdaf1016120f2faea563f179d3d623d3ec9bb5d936ea2a7f74d2bd70a06c83e904df55f5142c5c6b6f75221397dabcb19e069436b94ca764a5016141496503d",
3094 "tcId" : 341
3095 },
3096 {
3097 "comment" : "appending 0's to null",
3098 "message" : "48656c6c6f",
3099 "name" : "RsaSignatureTestVector",
3100 "padding" : "3023300b06052b0e03021a050200000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3101 "result" : "invalid",
3102 "sig" : "977a5c762a4dcbe9551a4a0bcfe96114aa59187e6dd0164cbbec2d28ff9d11e413a1de7f274704c24229c99ce9b5a3d98872db56310be7259a2fa44e652c4d02f8802360d3a29ded2a7de0a183001e74b3aa3fe594867294461d6a23160481ecdee9c05c28ce066021847a23366cb147013f57ce53a24791dd1873527f1323f0",
3103 "tcId" : 342
3104 },
3105 {
3106 "comment" : "composed null",
3107 "message" : "48656c6c6f",
3108 "name" : "RsaSignatureTestVector",
3109 "padding" : "3027300f06052b0e03021a2580aa00bb0000000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3110 "result" : "invalid",
3111 "sig" : "79a42d1f294f82bd6ad48818f1f634733fbefea7def5ea32a1ed56de994ac047011695a0c8a11813d042ee6784cb172da76aa0ed892e53d4bf99fc21301a91181e7c93a56646190aeeb4a1c212d34d17484521580d84adb41b2a5cc285963509d0c832e5a2252e5cb028839d9db7bdabb7689219b97d699277ed004ca6389b61",
3112 "tcId" : 343
3113 },
3114 {
3115 "comment" : "appending 0's to digest",
3116 "message" : "48656c6c6f",
3117 "name" : "RsaSignatureTestVector",
3118 "padding" : "3023300906052b0e03021a05000416f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf00000",
3119 "result" : "invalid",
3120 "sig" : "37ddb1b141539dfc350974039429b948cfd8acc40ecab7270b3e560f0876cec68fa22c8dbf09c8c25955819a5cfc6d251ab99cd06c013792207caa2ada95d4fc01a6d89329e211869c02c648a64b721e92ef3aa767569ba2f0c7c376772926a95ededa5d3f0ce10ab3b2b25f70fee1702dfedb0605ef6401f3f44c464ee98110",
3121 "tcId" : 344
3122 },
3123 {
3124 "comment" : "prepending 0's to digest",
3125 "message" : "48656c6c6f",
3126 "name" : "RsaSignatureTestVector",
3127 "padding" : "3023300906052b0e03021a050004160000f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3128 "result" : "invalid",
3129 "sig" : "85c2c430e7cc2e989e729186cb1256a5f7e78bbb6e135b36a43059389f57cc7fd67ccf20becc0d9e63731ae4ee77e926754ee5226991f9bd46203f7fb88562b00974dad035b1a0f39cba567dc0ed3cb3f7bf51326e62b0f82d8aaf8cc8dfb96c08c64235dc2a4f612bc29a8d4fb4b1edff1cd517d1c981a809ce9708a547a765",
3130 "tcId" : 345
3131 },
3132 {
3133 "comment" : "dropping value of digest",
3134 "message" : "48656c6c6f",
3135 "name" : "RsaSignatureTestVector",
3136 "padding" : "300d300906052b0e03021a05000400",
3137 "result" : "invalid",
3138 "sig" : "708e3d4577c0ced7b4d729b5124169f67836738bc18f82537dbe1c9a48054769ed0888751a823eedd05408ed934a555655d473dcec0fb5c6f19aee82f1dedf3f4fa14171c3ccbd3f1f9920f233a21be4341134f25636cbdd55918e9da76568c3ba55c630ee3e9eaa4dba7bd989fe0534925d1c47592214eb4869bcd42b60c92d",
3139 "tcId" : 346
3140 },
3141 {
3142 "comment" : "modify first byte of digest",
3143 "message" : "48656c6c6f",
3144 "name" : "RsaSignatureTestVector",
3145 "padding" : "3021300906052b0e03021a05000414f6ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3146 "result" : "invalid",
3147 "sig" : "0a581f33a2e1e1665032331dcd1baefb9048af3efa9d6e24ae8e73fb0611422db4426bf804c08ea5ee7089574d4b657cb526437bf677fe3f9e140ee76f4ee2a9514bf0772670de18141840d93f12975013b84dfb74fb450f3bf2cf1cb0cd0267fe521f01d85efd8726be12e9c574907e97a2834cf00910b164732e5daeff4acc",
3148 "tcId" : 347
3149 },
3150 {
3151 "comment" : "modify last byte of digest",
3152 "message" : "48656c6c6f",
3153 "name" : "RsaSignatureTestVector",
3154 "padding" : "3021300906052b0e03021a05000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf1",
3155 "result" : "invalid",
3156 "sig" : "0c64af0070eb86bb4abe059fce3fe3ced43fb4c19d1c3560877ef54c575530d0473ff2691781c2f7d7aa971b07e517888dc50cd63b0b07e2eb5aa18c6c5ea7f5c9e8e4c7d283808e40920c83cdba64a7e9d01b1e15710b1caa6da8686cc2e4e3b8cc276204c3e21f3e352e81e081660b18a8e6057f2227b117c2c9c5021be26d",
3157 "tcId" : 348
3158 },
3159 {
3160 "comment" : "truncate digest",
3161 "message" : "48656c6c6f",
3162 "name" : "RsaSignatureTestVector",
3163 "padding" : "3020300906052b0e03021a05000413f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0ab",
3164 "result" : "invalid",
3165 "sig" : "313624a0449c7f2f19878797dab59c91ed45ca0910aed355737635283d56edc7f470628e119a70f7d40b238e0ead042ec1c1c377272fa3ca975cc21eeec934f758ce70f19e00f592a0e5a4aad8e9956d9fd7dbbc126b6a001f20c42b517ba54511630382612f2bacb9711c87d9a19897c8c44f7905f548b558fada6a2c9912c7",
3166 "tcId" : 349
3167 },
3168 {
3169 "comment" : "truncate digest",
3170 "message" : "48656c6c6f",
3171 "name" : "RsaSignatureTestVector",
3172 "padding" : "3020300906052b0e03021a05000413ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3173 "result" : "invalid",
3174 "sig" : "4a3539eaceb4691d856020b9acc11854892df705ad7994759dea2efe0c5384e8f86ebeb3f4360ab0bc7d35c8ca520c8d0a1c869f3979ddedbb60437e798332a0ef7a52ca86b430ebc6aa57114f6057c8f18066ca1483cbe8a8ad3a1e96476a21d53ac6f6a4e18ee965371ebe58184fdcec67f0d42cd16d6ce6800ec87978b759",
3175 "tcId" : 350
3176 },
3177 {
3178 "comment" : "wrong hash in padding",
3179 "message" : "48656c6c6f",
3180 "name" : "RsaSignatureTestVector",
3181 "padding" : "3024300c06082a864886f70d020505000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3182 "result" : "invalid",
3183 "sig" : "1d8eb339d60f873bf3dd07816dbd8a5b5e61805e26654e5a5869fcbef176a61a3b2c173778ce5fb7323dee2f4e42a272474576e8942ce04c66a17d2ccc093e529df580d047159f7c1266af51b7a7f07f43a28e309111540a80fa76b25b6d86f9d2fc99a28d1715567545509f80beb700fe9cfb82be7bc801794b7d32eb9b584d",
3184 "tcId" : 351
3185 },
3186 {
3187 "comment" : "wrong hash in padding",
3188 "message" : "48656c6c6f",
3189 "name" : "RsaSignatureTestVector",
3190 "padding" : "3025300d060960864801650304020205000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3191 "result" : "invalid",
3192 "sig" : "3b2ead8d64cf96e26db3ba9d1ff63a187a715d04e3a7dfcf6c85790896793bc19c0ea6c5266cd4ebc25b859a07ad6459942eb46f3efcb9adbc29f3fa5acf0013d5baf3089e3ec5cd3401ae282670d27493b0ee33e391a9d32283b224036405c9d61bbb470dc8a69762bc35483d3d26c1c8e16c311e5d3e284f1d51383ce7bdcb",
3193 "tcId" : 352
3194 },
3195 {
3196 "comment" : "wrong hash in padding",
3197 "message" : "48656c6c6f",
3198 "name" : "RsaSignatureTestVector",
3199 "padding" : "3025300d060960864801650304020305000414f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0",
3200 "result" : "invalid",
3201 "sig" : "6b23ad94314f022d64a7b525aa933b7aef8184b66473572bf41c00f899dbeeb95755da7c749a0ce5cb09d3567ebd4ceb0033a1b16cfa13e85fd1745640a5306229a14a9c67c07f75058ad1dfebee25c44ba3bbf75fa053ef74717ea7f972dcf7d7d23901a3aed841e0ca419aa570a605e0d189d2b51ce3f00497c0bf16998ade",
3202 "tcId" : 353
3203 },
3204 {
3205 "comment" : "wrong hash in signature",
3206 "message" : "48656c6c6f",
3207 "name" : "RsaSignatureTestVector",
3208 "padding" : "3020300c06082a864886f70d0205050004108b1a9953c4611296a827abf8c47804d7",
3209 "result" : "invalid",
3210 "sig" : "53ee28bf3582045ff9a6f7d813b9453fc5813245b198d98cb141f6f36202240746b9d3778006aa4cd3905bffed0fde38157d8e8809228871fb48037706ddaaebd31ecebe3dae0516539509bfaea18dc1fc3c7f29620f3214db5d70005e1323094aa8f94ac9d64d9d02ff2010178425027145740b40640a43ff24db043a7a2d2b",
3211 "tcId" : 354
3212 },
3213 {
3214 "comment" : "wrong hash in signature",
3215 "message" : "48656c6c6f",
3216 "name" : "RsaSignatureTestVector",
3217 "padding" : "3031300d060960864801650304020105000420185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969",
3218 "result" : "invalid",
3219 "sig" : "171b1a7fa8cf97283809515866708d449f184d675613cbd33e91586f8e238946f860915f0fb6a390bc7cedfcf7d1621f49f3c6f39b7412d75660fbe3c2326c48399b7d41dfceeadabf0cbfc4b7dd756d8bdc38d28e80fb60e743fdf6d81973959d2c6b111fa0d8f3c9c8677c0c8030001b12f3e2c5990822154b1b762162dd7d",
3220 "tcId" : 355
3221 },
3222 {
3223 "comment" : "wrong hash in signature",
3224 "message" : "48656c6c6f",
3225 "name" : "RsaSignatureTestVector",
3226 "padding" : "3041300d0609608648016503040202050004303519fe5ad2c596efe3e276a6f351b8fc0b03db861782490d45f7598ebd0ab5fd5520ed102f38c4a5ec834e98668035fc",
3227 "result" : "invalid",
3228 "sig" : "9810d39416595ad79cf376b41e6e5f94fb89f61ae78bc5a0c710fab15d369dd7f050b035e5c2b8cdfe10d06be739bae08b47afd0b7dd2b226905f3ee718ccd5b5fb5b951558a62d83a2f3ba5dd1990d2d3e05c461e33ccaa1bbc22350c3ca157351a5b88ad3b1f524fc5cec5c1714a8ab3ef709e462434a6048133846fd1d85b",
3229 "tcId" : 356
3230 },
3231 {
3232 "comment" : "wrong hash in signature",
3233 "message" : "48656c6c6f",
3234 "name" : "RsaSignatureTestVector",
3235 "padding" : "3051300d0609608648016503040203050004403615f80c9d293ed7402687f94b22d58e529b8cc7916f8fac7fddf7fbd5af4cf777d3d795a7a00a16bf7e7f3fb9561ee9baae480da9fe7a18769e71886b03f315",
3236 "result" : "invalid",
3237 "sig" : "57532194f33bfddba2e848b9342342114e2c6dcffe228cb97b72ac9e26b77cd336a6fa5c8152db0d536c6fb3cc48487a89cfcf42990593fd0dad420b46fa87ea2b9c9962025dcc2b8a6d5a0476408a62d9c276fb5eb8e97e5f1726918fef41c0d12ad420525a803d804002061c3bf355a3c4fee4ce42016cb0e0531d2657726d",
3238 "tcId" : 357
3239 },
3240 {
3241 "comment" : "using PKCS#1 encryption padding",
3242 "message" : "48656c6c6f",
3243 "name" : "RsaSignatureTestVector",
3244 "padding" : "0002ff...00<asn wrapped hash>",
3245 "result" : "invalid",
3246 "sig" : "572ecc55660cc4f8888559092f54e4ee0dc6a57d0722bcba6b608869bc0e86ed53f8d88180b40c006ff10dbf32ba2c6bf3558e22a688f7d68a6d38740b99dd2a2eaa6fc94fe9fa76a0bf775c0eca5751ce7837a3da3db7dc648fb94ed0def4996eb40e168d49417dfd82c86f2c586fc49dfa37a6335b8a76aee84c755610948b",
3247 "tcId" : 358
3248 },
3249 {
3250 "comment" : "using PKCS#1 encryption padding",
3251 "message" : "48656c6c6f",
3252 "name" : "RsaSignatureTestVector",
3253 "padding" : "0002ff...00<hash>",
3254 "result" : "invalid",
3255 "sig" : "849f48195c7ae50b762ff93e350bacdf52e3eef5f86dbec5115d74ccfb2c9a49cc91115f6935b71deb424865666ba070299e17e64c3ce5019e1481ee195cffb4fc1f92f026cea579bbe9f78d7c665dd7f65af7c3221bae50d5c0b50ede25a3993979d167a86db511b9ace4f11c331f892f06e72d17e934da9a83a3c703b3409b",
3256 "tcId" : 359
3257 },
3258 {
3259 "comment" : "invalid PKCS#1 signature padding",
3260 "message" : "48656c6c6f",
3261 "name" : "RsaSignatureTestVector",
3262 "padding" : "0001ff...ee00",
3263 "result" : "invalid",
3264 "sig" : "29b9b831e6694768910397fbe53e0a6868f75e3910d600e3421349bc4321d93067c78f6294b00e52e9c2fafdef67e0a460c3d76e6196fec6aab5c4964a4782c5da021466908d106193ec1b6b0bae4c9a5e3fcc4a355565c1dcfb76c489b4c3ad11b6f2182188470edf748eaf81646fcc164c60c1a55e9334076d8b5ce3d09808",
3265 "tcId" : 360
3266 },
3267 {
3268 "comment" : "PKCS#1 padding too short",
3269 "message" : "48656c6c6f",
3270 "name" : "RsaSignatureTestVector",
3271 "padding" : "000001ff...",
3272 "result" : "invalid",
3273 "sig" : "583dc8ac657ac9d55c74b6505f1a7a4b2225c038f36cc66d76a7eb8c818195b138e8bb2b26ac5a01ce32aa3f590815f0ecdf693877bdb12c5dd55b947b91f83d66639874ca263d1227dd0b6531e3eedf0b1e87a92b8db4be7c3c40d70865f56c8e0b6cf6607d47ed44acff9c4360d65f847f4ae947a13e4a56dff1d11503bc9b",
3274 "tcId" : 361
3275 },
3276 {
3277 "comment" : "invalid length",
3278 "message" : "48656c6c6f",
3279 "name" : "RsaSignatureTestVector",
3280 "padding" : "2 bytes too long",
3281 "result" : "invalid",
3282 "sig" : "9e62337ef7d4fabec2561bb45a18a362022b23666571bbc762c1c717a14a46d8f58119072aa26245e71fc6945540335163798fcbdea04b3104ee23f2c3874bbfb3e7e0c1ba5f1fca909265274414db6957a5eb668e0e36a388784355d528e51a6a4a9a9c6b6ab912812a268dac9dcacf1c13507768e63b1f82f8af29c3786a170000",
3283 "tcId" : 362
3284 }
3285 ]
3286 }
3287 ]
3288 }
0 # rebuild:
1 # rm -f src/liballinone.a && touch CryptX.xs && make && perl -Mblib t/wycheproof.t
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 plan skip_all => "No JSON::* module installed" unless eval { require JSON::PP } || eval { require JSON::XS } || eval { require Cpanel::JSON::XS };
9 plan tests => 762;
10
11 use CryptX;
12 use Crypt::Misc 'read_rawfile';
13 use Crypt::Digest 'digest_data';
14
15 if (1) {
16 use Crypt::AuthEnc::GCM qw(gcm_encrypt_authenticate gcm_decrypt_verify);
17
18 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/aes_gcm_test.json';
19 for my $g (@{$tests->{testGroups}}) {
20 my $type = $g->{type};
21 for my $t (@{$g->{tests}}) {
22 my $tcId = $t->{tcId}; # 1
23 my $comment = $t->{comment}; # ""
24 my $result = $t->{result}; # "valid"
25 my $aad = pack "H*", $t->{aad}; # "6578616d706c65"
26 my $ct = pack "H*", $t->{ct}; # "5d349ead175ef6b1def6fd"
27 my $iv = pack "H*", $t->{iv}; # "752abad3e0afb5f434dc4310"
28 my $key = pack "H*", $t->{key}; # "ee8e1ed9ff2540ae8f2ba9f50bc2f27c"
29 my $msg = pack "H*", $t->{msg}; # "48656c6c6f20776f726c64"
30 my $tag = pack "H*", $t->{tag}; # "4fbcdeb7e4793f4a1d7e4faa70100af1"
31 # do the test
32 my ($ct2, $tag2) = eval { gcm_encrypt_authenticate('AES', $key, $iv, $aad, $msg) };
33 my $pt2 = eval { gcm_decrypt_verify('AES', $key, $iv, $aad, $ct, $tag) };
34 my $testname = "type=$type tcId=$tcId comment='$comment' expected-result=$result";
35 if ($result eq 'valid') {
36 is(unpack("H*", $ct2), $t->{ct}, "$testname CT-v");
37 is(unpack("H*", $tag2), $t->{tag}, "$testname TAG-v");
38 is(unpack("H*", $pt2), $t->{msg}, "$testname PT-v");
39 }
40 elsif ($result eq 'invalid') {
41 #isnt(unpack("H*", $ct2), $t->{ct}, "$testname CT-i");
42 #isnt(unpack("H*", $tag2), $t->{tag}, "$testname TAG-i");
43 is($pt2, undef, "$testname PT-i");
44 }
45 else {
46 ok(0, "UNEXPECTED result=$result");
47 }
48 }
49 }
50 }
51
52 if (1) {
53 use Crypt::PK::RSA;
54
55 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/rsa_signature_test.json';
56 for my $g (@{$tests->{testGroups}}) {
57 my $type = $g->{type};
58 my $keyDer = pack "H*", $g->{keyDer};
59 my $keyPem = $g->{keyPem};
60 my $sha = $g->{sha};
61 $sha =~ s/-//g; # SHA-1 >> SHA1
62 ok(Crypt::PK::RSA->new( \$keyDer ), "Crypt::PK::RSA->new + DER type: $type/$sha");
63 ok(Crypt::PK::RSA->new( \$keyPem ), "Crypt::PK::RSA->new + PEM type: $type/$sha");
64 for my $t (@{$g->{tests}}) {
65 my $tcId = $t->{tcId};
66 my $comment = $t->{comment};
67 my $result = $t->{result};
68 my $message = pack "H*", $t->{message};
69 my $sig = pack "H*", $t->{sig};
70 # do the test
71 my $testname = "type=$type/$sha tcId=$tcId comment='$comment' expected-result=$result";
72 my $pk = Crypt::PK::RSA->new( \$keyPem );
73 my $valid = $pk->verify_message($sig, $message, $sha,"v1.5");
74 if ($result eq 'valid' || $result eq 'acceptable') {
75 ok($valid, $testname);
76 }
77 elsif ($result eq 'invalid') {
78 ok(!$valid, $testname);
79 }
80 else {
81 ok(0, "UNEXPECTED result=$result");
82 }
83 }
84 }
85 }
86
87 if (1) {
88 use Crypt::PK::DSA;
89
90 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/dsa_test.json';
91 for my $g (@{$tests->{testGroups}}) {
92 my $type = $g->{type}; # "DSAVer"
93 my $keyDer = pack "H*", $g->{keyDer};
94 my $keyPem = $g->{keyPem};
95 my $sha = $g->{sha}; # "SHA-1"
96 $sha =~ s/-//g; # SHA-1 >> SHA1
97 ok(Crypt::PK::DSA->new( \$keyDer ), "Crypt::PK::DSA->new + DER type=$type/$sha");
98 ok(Crypt::PK::DSA->new( \$keyPem ), "Crypt::PK::DSA->new + PEM type=$type/$sha");
99 for my $t (@{$g->{tests}}) {
100 my $tcId = $t->{tcId};
101 my $comment = $t->{comment};
102 my $result = $t->{result};
103 my $message = pack "H*", $t->{message};
104 my $sig = pack "H*", $t->{sig};
105 # skip unsupported tests:
106 next if $tcId==12 && $result eq 'acceptable' && $comment eq "Legacy:ASN encoding of s misses leading 0";
107 next if $tcId==13 && $result eq 'acceptable' && $comment eq "BER:long form encoding of length";
108 next if $tcId==14 && $result eq 'acceptable' && $comment eq "BER:long form encoding of length";
109 next if $tcId==15 && $result eq 'acceptable' && $comment eq "BER:long form encoding of length";
110 next if $tcId==16 && $result eq 'acceptable' && $comment eq "BER:length contains leading 0";
111 next if $tcId==17 && $result eq 'acceptable' && $comment eq "BER:length contains leading 0";
112 next if $tcId==18 && $result eq 'acceptable' && $comment eq "BER:length contains leading 0";
113 next if $tcId==19 && $result eq 'acceptable' && $comment eq "BER:indefinite length";
114 next if $tcId==20 && $result eq 'acceptable' && $comment eq "BER:prepending 0's to integer";
115 next if $tcId==21 && $result eq 'acceptable' && $comment eq "BER:prepending 0's to integer";
116 # do the test
117 my $testname = "type=$type/$sha tcId=$tcId comment='$comment' expected-result=$result";
118 my $pk = Crypt::PK::DSA->new( \$keyPem );
119 my $valid = $pk->verify_message($sig, $message, $sha);
120 my $hash = digest_data($sha, $message);
121 my $valid_h = $pk->verify_hash($sig, $hash);
122 if ($result eq 'valid' || $result eq 'acceptable') {
123 ok($valid, $testname);
124 }
125 elsif ($result eq 'invalid') {
126 ok(!$valid, $testname);
127 }
128 else {
129 ok(0, "UNEXPECTED result=$result");
130 }
131 }
132 }
133 }
134
135 if (0) {
136 #XXX-TODO:
137 # not ok 749 - type=ECDSAVer/SHA256 tcId=50 comment='appending unused 0's' expected-result=invalid verify_message=1
138 # not ok 819 - type=ECDSAVer/SHA256 tcId=120 comment='Modified r or s, e.g. by adding or subtracting the order of the group' expected-result=invalid verify_message=1
139 # not ok 820 - type=ECDSAVer/SHA256 tcId=121 comment='Modified r or s, e.g. by adding or subtracting the order of the group' expected-result=invalid verify_message=1
140 # not ok 821 - type=ECDSAVer/SHA256 tcId=122 comment='Modified r or s, e.g. by adding or subtracting the order of the group' expected-result=invalid verify_message=1
141
142 use Crypt::PK::ECC;
143
144 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/ecdsa_test.json';
145 for my $g (@{$tests->{testGroups}}) {
146 my $type = $g->{type};
147 my $keyDer = pack "H*", $g->{keyDer};
148 my $keyPem = $g->{keyPem};
149 my $sha = $g->{sha};
150 $sha =~ s/-//g; # SHA-1 >> SHA1
151 ok(Crypt::PK::ECC->new( \$keyDer ), "Crypt::PK::ECC->new + DER type=$type/$sha");
152 ok(Crypt::PK::ECC->new( \$keyPem ), "Crypt::PK::ECC->new + PEM type=$type/$sha");
153 for my $t (@{$g->{tests}}) {
154 my $tcId = $t->{tcId};
155 my $comment = $t->{comment};
156 my $result = $t->{result};
157 my $message = pack "H*", $t->{message};
158 my $sig = pack "H*", $t->{sig};
159 # do the test
160 my $testname = "type=$type/$sha tcId=$tcId comment='$comment' expected-result=$result";
161 my $pk = Crypt::PK::ECC->new( \$keyPem );
162 my $valid = $pk->verify_message($sig, $message, $sha);
163 if ($result eq 'valid') {
164 ok($valid, "$testname verify_message=$valid");
165 }
166 elsif ($result eq 'acceptable') {
167 #XXX-TODO
168 #ok($valid, "$testname verify_message=$valid");
169 }
170 elsif ($result eq 'invalid') {
171 ok(!$valid, "$testname verify_message=$valid");
172 }
173 else {
174 ok(0, "UNEXPECTED result=$result");
175 }
176 }
177 }
178 }
179
180 if (0) {
181 use Crypt::PK::ECC;
182
183 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/ecdsa_webcrypto_test.json';
184 for my $g (@{$tests->{testGroups}}) {
185 my $type = $g->{type};
186 my $keyDer = pack "H*", $g->{keyDer};
187 my $keyPem = $g->{keyPem};
188 my $sha = $g->{sha};
189 my $jwk = $g->{jwk};
190 $sha =~ s/-//g; # SHA-1 >> SHA1
191 ok(Crypt::PK::ECC->new( \$keyDer ), "Crypt::PK::ECC->new + DER type=$type/$sha");
192 ok(Crypt::PK::ECC->new( \$keyPem ), "Crypt::PK::ECC->new + PEM type=$type/$sha");
193 ok(Crypt::PK::ECC->new( $jwk ), "Crypt::PK::ECC->new + JWK type=$type/$sha");
194 for my $t (@{$g->{tests}}) {
195 my $tcId = $t->{tcId};
196 my $comment = $t->{comment};
197 my $result = $t->{result};
198 my $message = pack "H*", $t->{message};
199 my $sig = pack "H*", $t->{sig};
200 # do the test
201 my $testname = "type=$type/$sha tcId=$tcId comment='$comment' expected-result=$result";
202 my $pk = Crypt::PK::ECC->new( \$keyPem );
203 my $valid = $pk->verify_message($sig, $message, $sha);
204 if ($result eq 'valid') {
205 ok($valid, "$testname verify_message=$valid");
206 }
207 elsif ($result eq 'acceptable') {
208 #XXX-TODO
209 #ok($valid, "$testname verify_message=$valid");
210 }
211 elsif ($result eq 'invalid') {
212 ok(!$valid, "$testname verify_message=$valid");
213 }
214 else {
215 ok(0, "UNEXPECTED result=$result");
216 }
217 }
218 }
219 }
220
221 if (1) {
222 use Crypt::PK::ECC;
223
224 my $tests = CryptX::_decode_json read_rawfile 't/wycheproof/ecdh_webcrypto_test.json';
225 for my $g (@{$tests->{testGroups}}) {
226 my $type = $g->{type};
227 for my $t (@{$g->{tests}}) {
228 my $tcId = $t->{tcId};
229 my $comment = $t->{comment};
230 my $name = $t->{name};
231 my $result = $t->{result};
232 my $shared = pack "H*", $t->{shared};
233 # do the test
234 my $testname = "type=$type/$name tcId=$tcId comment='$comment' expected-result=$result";
235 my $pub = Crypt::PK::ECC->new( $t->{public} );
236 my $pri = Crypt::PK::ECC->new( $t->{private} );
237 my $shared_hex = unpack "H*", $pri->shared_secret($pub);
238 if ($result eq 'valid' || $result eq 'acceptable') {
239 is($shared_hex, $t->{shared}, $testname);
240 }
241 elsif ($result eq 'invalid') {
242 isnt($shared_hex, $t->{shared}, $testname);
243 }
244 else {
245 ok(0, "UNEXPECTED result=$result");
246 }
247 }
248 }
249 }