Mercurial > dropbear
comparison libtomcrypt/tests/der_test.c @ 1733:d529a52b2f7c coverity coverity
merge coverity from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 26 Jun 2020 21:07:34 +0800 |
parents | e9dba7abd939 |
children |
comparison
equal
deleted
inserted
replaced
1643:b59623a64678 | 1733:d529a52b2f7c |
---|---|
1092 mp_clear(mpinteger); | 1092 mp_clear(mpinteger); |
1093 return 0; | 1093 return 0; |
1094 } | 1094 } |
1095 | 1095 |
1096 | 1096 |
1097 static void _der_recursion_limit(void) | |
1098 { | |
1099 int failed = 0; | |
1100 unsigned int n; | |
1101 unsigned long integer = 123, s; | |
1102 ltc_asn1_list seqs[LTC_DER_MAX_RECURSION + 2], dummy[1], *flexi; | |
1103 unsigned char buf[2048]; | |
1104 LTC_SET_ASN1(dummy, 0, LTC_ASN1_SHORT_INTEGER, &integer, 1); | |
1105 LTC_SET_ASN1(seqs, LTC_DER_MAX_RECURSION + 1, LTC_ASN1_SEQUENCE, dummy, 1); | |
1106 for (n = 0; n < LTC_DER_MAX_RECURSION + 1; ++n) { | |
1107 LTC_SET_ASN1(seqs, LTC_DER_MAX_RECURSION - n, LTC_ASN1_SEQUENCE, &seqs[LTC_DER_MAX_RECURSION - n + 1], 1); | |
1108 } | |
1109 s = sizeof(buf); | |
1110 DO(der_encode_sequence(seqs, 1, buf, &s)); | |
1111 DO(der_decode_sequence(buf, s, seqs, 1)); | |
1112 SHOULD_FAIL(der_decode_sequence_flexi(buf, &s, &flexi)); | |
1113 if (failed) exit(EXIT_FAILURE); | |
1114 } | |
1115 | |
1097 int der_test(void) | 1116 int der_test(void) |
1098 { | 1117 { |
1099 unsigned long x, y, z, zz, oid[2][32]; | 1118 unsigned long x, y, z, zz, oid[2][32]; |
1100 unsigned char buf[3][2048]; | 1119 unsigned char buf[3][2048]; |
1101 void *a, *b, *c, *d, *e, *f, *g; | 1120 void *a, *b, *c, *d, *e, *f, *g; |
1124 static const unsigned char utf8_2_der[] = { 0x0C, 0x09, 0xED, 0x95, 0x9C, 0xEA, 0xB5, 0xAD, 0xEC, 0x96, 0xB4 }; | 1143 static const unsigned char utf8_2_der[] = { 0x0C, 0x09, 0xED, 0x95, 0x9C, 0xEA, 0xB5, 0xAD, 0xEC, 0x96, 0xB4 }; |
1125 | 1144 |
1126 unsigned char utf8_buf[32]; | 1145 unsigned char utf8_buf[32]; |
1127 wchar_t utf8_out[32]; | 1146 wchar_t utf8_out[32]; |
1128 | 1147 |
1148 | |
1149 _der_recursion_limit(); | |
1129 der_cacert_test(); | 1150 der_cacert_test(); |
1130 | 1151 |
1131 DO(mp_init_multi(&a, &b, &c, &d, &e, &f, &g, NULL)); | 1152 DO(mp_init_multi(&a, &b, &c, &d, &e, &f, &g, NULL)); |
1132 for (zz = 0; zz < 16; zz++) { | 1153 for (zz = 0; zz < 16; zz++) { |
1133 #ifdef USE_TFM | 1154 #ifdef USE_TFM |