mirror of https://github.com/wolfSSL/wolfTPM.git
F-6839 - Cover truncated-buffer error path in DecodeX509Cert test
parent
14d02a32b2
commit
5c682e167b
|
|
@ -4441,6 +4441,7 @@ static void test_TPM2_ASN_DecodeX509Cert_Errors(void)
|
|||
int rc;
|
||||
DecodedX509 x509;
|
||||
byte garbage[16];
|
||||
byte trunc[4];
|
||||
|
||||
XMEMSET(&x509, 0, sizeof(x509));
|
||||
XMEMSET(garbage, 0xFF, sizeof(garbage));
|
||||
|
|
@ -4455,6 +4456,11 @@ static void test_TPM2_ASN_DecodeX509Cert_Errors(void)
|
|||
rc = TPM2_ASN_DecodeX509Cert(garbage, (int)sizeof(garbage), &x509);
|
||||
AssertIntNE(rc, 0);
|
||||
|
||||
/* outer SEQUENCE whose length runs past the buffer (TPM_RC_INSUFFICIENT) */
|
||||
trunc[0] = 0x30; trunc[1] = 0x20; trunc[2] = 0x00; trunc[3] = 0x00;
|
||||
rc = TPM2_ASN_DecodeX509Cert(trunc, (int)sizeof(trunc), &x509);
|
||||
AssertIntNE(rc, 0);
|
||||
|
||||
printf("Test TPM Wrapper: %-40s Passed\n", "ASN DecodeX509Cert errors:");
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue