Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions src/wh_client_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ static int _certVerifyResponse(whClientContext* c, whKeyId* out_keyId,
uint16_t size;
whMessageCert_VerifyResponse resp;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -447,7 +448,9 @@ static int _certVerify(whClientContext* c, const uint8_t* cert,
int rc = 0;
whKeyId keyId = WH_KEYID_ERASED;

if ((c == NULL) || (cert == NULL) || (cert_len == 0)) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (cert == NULL) || (cert_len == 0) ||
(out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -568,7 +571,8 @@ static int _certVerifyMultiRootResponse(whClientContext* c, whKeyId* out_keyId,
uint16_t size;
whMessageCert_VerifyResponse resp;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -603,8 +607,9 @@ static int _certVerifyMultiRoot(whClientContext* c, const uint8_t* cert,
int rc = 0;
whKeyId keyId = WH_KEYID_ERASED;

/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (cert == NULL) || (cert_len == 0) ||
(trustedRootNvmIds == NULL) || (numRoots == 0)) {
(trustedRootNvmIds == NULL) || (numRoots == 0) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -992,7 +997,8 @@ static int _certVerifyDmaResponse(whClientContext* c, whKeyId* out_keyId,
uint16_t size;
whMessageCert_VerifyDmaResponse resp;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -1025,7 +1031,8 @@ static int _certVerifyDma(whClientContext* c, const void* cert,
int rc = 0;
whKeyId keyId = WH_KEYID_ERASED;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -1137,7 +1144,8 @@ static int _certVerifyMultiRootDmaResponse(whClientContext* c,
uint16_t size;
whMessageCert_VerifyDmaResponse resp;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -1172,7 +1180,8 @@ static int _certVerifyMultiRootDma(whClientContext* c, const void* cert,
int rc = 0;
whKeyId keyId = WH_KEYID_ERASED;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -1287,6 +1296,11 @@ int wh_Client_CertVerifyAcertResponse(whClientContext* c, int32_t* out_rc)
uint16_t size;
whMessageCert_SimpleResponse resp;

/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

rc = wh_Client_RecvResponse(c, &group, &action, &size, &resp);
if (rc == 0) {
if ((group != WH_MESSAGE_GROUP_CERT) ||
Expand All @@ -1310,7 +1324,8 @@ int wh_Client_CertVerifyAcert(whClientContext* c, const void* cert,
{
int rc = 0;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down Expand Up @@ -1356,7 +1371,8 @@ int wh_Client_CertVerifyAcertDmaResponse(whClientContext* c, int32_t* out_rc)
uint16_t size;
whMessageCert_SimpleResponse resp;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand All @@ -1383,7 +1399,8 @@ int wh_Client_CertVerifyAcertDma(whClientContext* c, const void* cert,
{
int rc = 0;

if (c == NULL) {
/* out_rc is mandatory; it carries the verification verdict */
if ((c == NULL) || (out_rc == NULL)) {
return WH_ERROR_BADARGS;
}

Expand Down
7 changes: 7 additions & 0 deletions test/wh_test_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,13 @@ int whTest_CertClient(whClientContext* client)
rootCertA_id, &out_rc));
WH_TEST_ASSERT_RETURN(out_rc == WH_ERROR_OK);

/* out_rc is mandatory; a NULL verdict pointer must be rejected so the
* verification result can never be silently discarded */
WH_TEST_ASSERT_RETURN(wh_Client_CertVerify(client, INTERMEDIATE_A_CERT,
INTERMEDIATE_A_CERT_len,
rootCertA_id,
NULL) == WH_ERROR_BADARGS);

/* attempt to verify invalid cert (leaf w/o intermediate), should fail */
WH_TEST_PRINT(
"Attempting to verify invalid single certificate...using leaf cert "
Expand Down
Loading
Loading