some more ASN.1 fixes

these should have been in #49
This commit is contained in:
Steffen Jaeckel 2014-08-31 18:26:14 +02:00
parent c342cb5a21
commit ee4c00b753
2 changed files with 20 additions and 9 deletions

View File

@ -519,7 +519,7 @@ int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...)
/* FLEXI DECODER handle unknown list decoder */ /* FLEXI DECODER handle unknown list decoder */
int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out); int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out);
void der_free_sequence_flexi(ltc_asn1_list *list); #define der_free_sequence_flexi der_sequence_free
void der_sequence_free(ltc_asn1_list *in); void der_sequence_free(ltc_asn1_list *in);
/* BOOLEAN */ /* BOOLEAN */

View File

@ -27,7 +27,8 @@
int der_length_sequence(ltc_asn1_list *list, unsigned long inlen, int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
unsigned long *outlen) unsigned long *outlen)
{ {
int err, type; int err;
ltc_asn1_type type;
unsigned long size, x, y, i; unsigned long size, x, y, i;
void *data; void *data;
@ -68,6 +69,7 @@ int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
break; break;
case LTC_ASN1_BIT_STRING: case LTC_ASN1_BIT_STRING:
case LTC_ASN1_RAW_BIT_STRING:
if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) { if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
} }
@ -99,6 +101,13 @@ int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
y += x; y += x;
break; break;
case LTC_ASN1_TELETEX_STRING:
if ((err = der_length_teletex_string(data, size, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
y += x;
break;
case LTC_ASN1_PRINTABLE_STRING: case LTC_ASN1_PRINTABLE_STRING:
if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) { if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) {
goto LBL_ERR; goto LBL_ERR;
@ -130,7 +139,9 @@ int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
break; break;
default: case LTC_ASN1_CHOICE:
case LTC_ASN1_CONSTRUCTED:
case LTC_ASN1_EOL:
err = CRYPT_INVALID_ARG; err = CRYPT_INVALID_ARG;
goto LBL_ERR; goto LBL_ERR;
} }