ASN functions added to simplify code

Functions to get and set different ASN.1 tags have been added.
The functions are used in the asn.c file to simplify the code and ensure
all checks are done.
This commit is contained in:
Sean Parkinson
2017-04-03 16:56:21 +10:00
parent ccad9f5575
commit fd9e41dd99
2 changed files with 594 additions and 721 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5842,8 +5842,6 @@ static int rsa_decode_test(void)
const byte good[] = { 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 };
const byte goodAlgId[] = { 0x30, 0x0f, 0x30, 0x0d, 0x06, 0x00,
0x03, 0x09, 0x00, 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 };
const byte goodBitStrNoZero[] = { 0x30, 0x0e, 0x30, 0x0c, 0x06, 0x00,
0x03, 0x08, 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 };
const byte goodAlgIdNull[] = { 0x30, 0x11, 0x30, 0x0f, 0x06, 0x00,
0x05, 0x00, 0x03, 0x09, 0x00, 0x30, 0x06, 0x02, 0x01, 0x23,
0x02, 0x1, 0x03 };
@ -5862,6 +5860,8 @@ static int rsa_decode_test(void)
const byte badIntN[] = { 0x30, 0x06, 0x02, 0x05, 0x23, 0x02, 0x1, 0x03 };
const byte badNotIntE[] = { 0x30, 0x06, 0x02, 0x01, 0x23, 0x04, 0x1, 0x03 };
const byte badLength[] = { 0x30, 0x04, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 };
const byte badBitStrNoZero[] = { 0x30, 0x0e, 0x30, 0x0c, 0x06, 0x00,
0x03, 0x08, 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 };
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
@ -6060,17 +6060,14 @@ static int rsa_decode_test(void)
if (ret != 0)
return -520;
inSz = sizeof(goodBitStrNoZero);
inSz = sizeof(badBitStrNoZero);
inOutIdx = 0;
ret = wc_RsaPublicKeyDecode(goodBitStrNoZero, &inOutIdx, &keyPub, inSz);
if (ret != 0) {
ret = wc_RsaPublicKeyDecode(badBitStrNoZero, &inOutIdx, &keyPub, inSz);
if (ret != ASN_EXPECT_0_E) {
ret = -556;
goto done;
}
if (inOutIdx != inSz) {
ret = -557;
goto done;
}
ret = 0;
done:
wc_FreeRsaKey(&keyPub);