mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
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:
1300
wolfcrypt/src/asn.c
1300
wolfcrypt/src/asn.c
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
|
Reference in New Issue
Block a user