Merge pull request #833 from SparkiDev/asn_func

ASN Code Rework
This commit is contained in:
dgarske
2017-04-06 12:47:40 -07:00
committed by GitHub
2 changed files with 728 additions and 750 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5866,8 +5866,6 @@ static int rsa_decode_test(void)
const byte good[] = { 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 }; const byte good[] = { 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 };
const byte goodAlgId[] = { 0x30, 0x0f, 0x30, 0x0d, 0x06, 0x00, const byte goodAlgId[] = { 0x30, 0x0f, 0x30, 0x0d, 0x06, 0x00,
0x03, 0x09, 0x00, 0x30, 0x06, 0x02, 0x01, 0x23, 0x02, 0x1, 0x03 }; 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, const byte goodAlgIdNull[] = { 0x30, 0x11, 0x30, 0x0f, 0x06, 0x00,
0x05, 0x00, 0x03, 0x09, 0x00, 0x30, 0x06, 0x02, 0x01, 0x23, 0x05, 0x00, 0x03, 0x09, 0x00, 0x30, 0x06, 0x02, 0x01, 0x23,
0x02, 0x1, 0x03 }; 0x02, 0x1, 0x03 };
@@ -5886,6 +5884,8 @@ static int rsa_decode_test(void)
const byte badIntN[] = { 0x30, 0x06, 0x02, 0x05, 0x23, 0x02, 0x1, 0x03 }; const byte badIntN[] = { 0x30, 0x06, 0x02, 0x05, 0x23, 0x02, 0x1, 0x03 };
const byte badNotIntE[] = { 0x30, 0x06, 0x02, 0x01, 0x23, 0x04, 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 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); ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0) if (ret != 0)
@@ -6084,17 +6084,14 @@ static int rsa_decode_test(void)
if (ret != 0) if (ret != 0)
return -520; return -520;
inSz = sizeof(goodBitStrNoZero); inSz = sizeof(badBitStrNoZero);
inOutIdx = 0; inOutIdx = 0;
ret = wc_RsaPublicKeyDecode(goodBitStrNoZero, &inOutIdx, &keyPub, inSz); ret = wc_RsaPublicKeyDecode(badBitStrNoZero, &inOutIdx, &keyPub, inSz);
if (ret != 0) { if (ret != ASN_EXPECT_0_E) {
ret = -556; ret = -556;
goto done; goto done;
} }
if (inOutIdx != inSz) { ret = 0;
ret = -557;
goto done;
}
done: done:
wc_FreeRsaKey(&keyPub); wc_FreeRsaKey(&keyPub);