add sanity checks and change index increment

This commit is contained in:
Jacob Barthelmeh
2018-02-26 13:55:56 -07:00
parent 512a0be75e
commit e4f40fb6c0

View File

@ -11039,6 +11039,10 @@ static int ASNToHexString(const byte* input, word32* inOutIdx, char** out,
int i; int i;
char* str; char* str;
if (*inOutIdx >= inSz) {
return BUFFER_E;
}
if (input[*inOutIdx] == ASN_INTEGER) { if (input[*inOutIdx] == ASN_INTEGER) {
if (GetASNInt(input, inOutIdx, &len, inSz) < 0) if (GetASNInt(input, inOutIdx, &len, inSz) < 0)
return ASN_PARSE_E; return ASN_PARSE_E;
@ -11081,6 +11085,10 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
if (ret != 0) if (ret != 0)
return ret; return ret;
if (*inOutIdx >= inSz) {
return BUFFER_E;
}
if (input[*inOutIdx] == (ASN_SEQUENCE | ASN_CONSTRUCTED)) { if (input[*inOutIdx] == (ASN_SEQUENCE | ASN_CONSTRUCTED)) {
#ifdef WOLFSSL_CUSTOM_CURVES #ifdef WOLFSSL_CUSTOM_CURVES
ecc_set_type* curve; ecc_set_type* curve;
@ -11131,7 +11139,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
if (input[*inOutIdx] == ASN_BIT_STRING) { if (input[*inOutIdx] == ASN_BIT_STRING) {
len = 0; len = 0;
ret = GetASNHeader(input, ASN_BIT_STRING, inOutIdx, &len, inSz); ret = GetASNHeader(input, ASN_BIT_STRING, inOutIdx, &len, inSz);
inOutIdx += len; *inOutIdx += len;
} }
} }
if (ret == 0) { if (ret == 0) {