Skip to content

Commit

Permalink
Add unit_test for openssl verify cert
Browse files Browse the repository at this point in the history
Signed-off-by: Wenxing Hou <[email protected]>
  • Loading branch information
Wenxing-hou authored and jyao1 committed Mar 7, 2024
1 parent 49b5c6d commit 204d173
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions unit_test/test_crypt/x509_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,55 @@ bool libspdm_validate_crypt_x509(char *Path, size_t len)
libspdm_my_print("[Pass]\n");
}

LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
"- X509 Certificate CA cert verify itself Verification ... "));
status = libspdm_x509_verify_cert_chain((const uint8_t *)test_ca_cert, test_ca_cert_len,
(const uint8_t *)test_ca_cert,
test_ca_cert_len);
if (!status) {
libspdm_my_print("[Fail]\n");
goto cleanup;
} else {
libspdm_my_print("[Pass]\n");
}

LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
"- X509 Certificate CA cert verify itself Verification with large cert len"));
status = libspdm_x509_verify_cert_chain((const uint8_t *)test_ca_cert, test_ca_cert_len,
(const uint8_t *)test_ca_cert,
test_ca_cert_len + 1);
if (!status) {
libspdm_my_print("[Fail]\n");
goto cleanup;
} else {
libspdm_my_print("[Pass]\n");
}

LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
"- X509 Certificate end cert verify itself Verification ... "));
status = libspdm_x509_verify_cert_chain((const uint8_t *)test_end_cert, test_end_cert_len,
(const uint8_t *)test_end_cert,
test_end_cert_len);
if (status) {
libspdm_my_print("[Fail]\n");
goto cleanup;
} else {
libspdm_my_print("[Pass]\n");
}

LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
"- X509 Certificate end cert verify itself Verification with large cert len"));
status = libspdm_x509_verify_cert_chain((const uint8_t *)test_end_cert, test_end_cert_len,
(const uint8_t *)test_end_cert,
test_end_cert_len + 1);
if (status) {
libspdm_my_print("[Fail]\n");
goto cleanup;
} else {
libspdm_my_print("[Pass]\n");
}


/* X509 Get leaf certificate from cert_chain Verificate*/
LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
"- X509 Certificate Chain get leaf certificate Verification ... "));
Expand Down

0 comments on commit 204d173

Please sign in to comment.