3838
3939/* Helper function to send a certificate verification request */
4040static int _certVerifyRequest (whClientContext * c , const uint8_t * cert ,
41- uint32_t cert_len , whNvmId trustedRootNvmId ,
41+ uint32_t cert_len , whKeyId trustedRootId ,
4242 uint16_t verifyFlags , whNvmFlags cachedKeyFlags ,
4343 whKeyId keyId );
4444
@@ -48,7 +48,7 @@ static int _certVerifyResponse(whClientContext* c, whKeyId* out_keyId,
4848
4949/* Helper function to perform certificate verification */
5050static int _certVerify (whClientContext * c , const uint8_t * cert ,
51- uint32_t cert_len , whNvmId trustedRootNvmId ,
51+ uint32_t cert_len , whKeyId trustedRootId ,
5252 uint16_t verifyFlags , whNvmFlags cachedKeyFlags ,
5353 whKeyId * inout_keyId , int32_t * out_rc );
5454
@@ -363,7 +363,7 @@ int wh_Client_CertReadTrusted(whClientContext* c, whNvmId id, uint8_t* cert,
363363
364364/* Helper function to send a verify request */
365365static int _certVerifyRequest (whClientContext * c , const uint8_t * cert ,
366- uint32_t cert_len , whNvmId trustedRootNvmId ,
366+ uint32_t cert_len , whKeyId trustedRootId ,
367367 uint16_t verifyFlags , whNvmFlags cachedKeyFlags ,
368368 whKeyId keyId )
369369{
@@ -379,7 +379,7 @@ static int _certVerifyRequest(whClientContext* c, const uint8_t* cert,
379379
380380 /* Prepare request */
381381 req .cert_len = cert_len ;
382- req .trustedRootNvmId = trustedRootNvmId ;
382+ req .trustedRootId = trustedRootId ;
383383 req .flags = verifyFlags ;
384384 req .cachedKeyFlags = cachedKeyFlags ;
385385 req .keyId = keyId ;
@@ -430,7 +430,7 @@ static int _certVerifyResponse(whClientContext* c, whKeyId* out_keyId,
430430}
431431
432432static int _certVerify (whClientContext * c , const uint8_t * cert ,
433- uint32_t cert_len , whNvmId trustedRootNvmId ,
433+ uint32_t cert_len , whKeyId trustedRootId ,
434434 uint16_t verifyFlags , whNvmFlags cachedKeyFlags ,
435435 whKeyId * inout_keyId , int32_t * out_rc )
436436{
@@ -446,8 +446,8 @@ static int _certVerify(whClientContext* c, const uint8_t* cert,
446446 }
447447
448448 do {
449- rc = _certVerifyRequest (c , cert , cert_len , trustedRootNvmId ,
450- verifyFlags , cachedKeyFlags , keyId );
449+ rc = _certVerifyRequest (c , cert , cert_len , trustedRootId , verifyFlags ,
450+ cachedKeyFlags , keyId );
451451 } while (rc == WH_ERROR_NOTREADY );
452452
453453 if (rc == 0 ) {
@@ -460,9 +460,9 @@ static int _certVerify(whClientContext* c, const uint8_t* cert,
460460}
461461
462462int wh_Client_CertVerifyRequest (whClientContext * c , const uint8_t * cert ,
463- uint32_t cert_len , whNvmId trustedRootNvmId )
463+ uint32_t cert_len , whKeyId trustedRootId )
464464{
465- return _certVerifyRequest (c , cert , cert_len , trustedRootNvmId ,
465+ return _certVerifyRequest (c , cert , cert_len , trustedRootId ,
466466 WH_CERT_FLAGS_NONE , WH_NVM_FLAGS_USAGE_ANY ,
467467 WH_KEYID_ERASED );
468468}
@@ -473,18 +473,18 @@ int wh_Client_CertVerifyResponse(whClientContext* c, int32_t* out_rc)
473473}
474474
475475int wh_Client_CertVerify (whClientContext * c , const uint8_t * cert ,
476- uint32_t cert_len , whNvmId trustedRootNvmId ,
476+ uint32_t cert_len , whKeyId trustedRootId ,
477477 int32_t * out_rc )
478478{
479- return _certVerify (c , cert , cert_len , trustedRootNvmId , WH_CERT_FLAGS_NONE ,
479+ return _certVerify (c , cert , cert_len , trustedRootId , WH_CERT_FLAGS_NONE ,
480480 WH_NVM_FLAGS_USAGE_ANY , NULL , out_rc );
481481}
482482
483483int wh_Client_CertVerifyAndCacheLeafPubKeyRequest (
484484 whClientContext * c , const uint8_t * cert , uint32_t cert_len ,
485- whNvmId trustedRootNvmId , whNvmFlags cachedKeyFlags , whKeyId keyId )
485+ whKeyId trustedRootId , whNvmFlags cachedKeyFlags , whKeyId keyId )
486486{
487- return _certVerifyRequest (c , cert , cert_len , trustedRootNvmId ,
487+ return _certVerifyRequest (c , cert , cert_len , trustedRootId ,
488488 WH_CERT_FLAGS_CACHE_LEAF_PUBKEY , cachedKeyFlags ,
489489 keyId );
490490}
@@ -499,10 +499,10 @@ int wh_Client_CertVerifyAndCacheLeafPubKeyResponse(whClientContext* c,
499499
500500int wh_Client_CertVerifyAndCacheLeafPubKey (
501501 whClientContext * c , const uint8_t * cert , uint32_t cert_len ,
502- whNvmId trustedRootNvmId , whNvmFlags cachedKeyFlags , whKeyId * inout_keyId ,
502+ whKeyId trustedRootId , whNvmFlags cachedKeyFlags , whKeyId * inout_keyId ,
503503 int32_t * out_rc )
504504{
505- return _certVerify (c , cert , cert_len , trustedRootNvmId ,
505+ return _certVerify (c , cert , cert_len , trustedRootId ,
506506 WH_CERT_FLAGS_CACHE_LEAF_PUBKEY , cachedKeyFlags ,
507507 inout_keyId , out_rc );
508508}
@@ -664,7 +664,7 @@ int wh_Client_CertReadTrustedDma(whClientContext* c, whNvmId id, void* cert,
664664}
665665
666666static int _certVerifyDmaRequest (whClientContext * c , const void * cert ,
667- uint32_t cert_len , whNvmId trustedRootNvmId ,
667+ uint32_t cert_len , whKeyId trustedRootId ,
668668 uint16_t flags , whNvmFlags cachedKeyFlags ,
669669 whKeyId keyId )
670670{
@@ -677,7 +677,7 @@ static int _certVerifyDmaRequest(whClientContext* c, const void* cert,
677677 /* Prepare and send request */
678678 req .cert_addr = (uint64_t )(uintptr_t )cert ;
679679 req .cert_len = cert_len ;
680- req .trustedRootNvmId = trustedRootNvmId ;
680+ req .trustedRootId = trustedRootId ;
681681 req .flags = flags ;
682682 req .cachedKeyFlags = cachedKeyFlags ;
683683 req .keyId = keyId ;
@@ -721,7 +721,7 @@ static int _certVerifyDmaResponse(whClientContext* c, whKeyId* out_keyId,
721721}
722722
723723static int _certVerifyDma (whClientContext * c , const void * cert ,
724- uint32_t cert_len , whNvmId trustedRootNvmId ,
724+ uint32_t cert_len , whKeyId trustedRootId ,
725725 uint16_t flags , whNvmFlags cachedKeyFlags ,
726726 whKeyId * inout_keyId , int32_t * out_rc )
727727{
@@ -740,7 +740,7 @@ static int _certVerifyDma(whClientContext* c, const void* cert,
740740 }
741741
742742 do {
743- rc = _certVerifyDmaRequest (c , cert , cert_len , trustedRootNvmId , flags ,
743+ rc = _certVerifyDmaRequest (c , cert , cert_len , trustedRootId , flags ,
744744 cachedKeyFlags , keyId );
745745 } while (rc == WH_ERROR_NOTREADY );
746746
@@ -754,9 +754,9 @@ static int _certVerifyDma(whClientContext* c, const void* cert,
754754}
755755
756756int wh_Client_CertVerifyDmaRequest (whClientContext * c , const void * cert ,
757- uint32_t cert_len , whNvmId trustedRootNvmId )
757+ uint32_t cert_len , whKeyId trustedRootId )
758758{
759- return _certVerifyDmaRequest (c , cert , cert_len , trustedRootNvmId ,
759+ return _certVerifyDmaRequest (c , cert , cert_len , trustedRootId ,
760760 WH_CERT_FLAGS_NONE , WH_NVM_FLAGS_USAGE_ANY ,
761761 WH_KEYID_ERASED );
762762}
@@ -767,19 +767,18 @@ int wh_Client_CertVerifyDmaResponse(whClientContext* c, int32_t* out_rc)
767767}
768768
769769int wh_Client_CertVerifyDma (whClientContext * c , const void * cert ,
770- uint32_t cert_len , whNvmId trustedRootNvmId ,
770+ uint32_t cert_len , whKeyId trustedRootId ,
771771 int32_t * out_rc )
772772{
773- return _certVerifyDma (c , cert , cert_len , trustedRootNvmId ,
774- WH_CERT_FLAGS_NONE , WH_NVM_FLAGS_USAGE_ANY , NULL ,
775- out_rc );
773+ return _certVerifyDma (c , cert , cert_len , trustedRootId , WH_CERT_FLAGS_NONE ,
774+ WH_NVM_FLAGS_USAGE_ANY , NULL , out_rc );
776775}
777776
778777int wh_Client_CertVerifyDmaAndCacheLeafPubKeyRequest (
779778 whClientContext * c , const void * cert , uint32_t cert_len ,
780- whNvmId trustedRootNvmId , whNvmFlags cachedKeyFlags , whKeyId keyId )
779+ whKeyId trustedRootId , whNvmFlags cachedKeyFlags , whKeyId keyId )
781780{
782- return _certVerifyDmaRequest (c , cert , cert_len , trustedRootNvmId ,
781+ return _certVerifyDmaRequest (c , cert , cert_len , trustedRootId ,
783782 WH_CERT_FLAGS_CACHE_LEAF_PUBKEY ,
784783 cachedKeyFlags , keyId );
785784}
@@ -793,10 +792,10 @@ int wh_Client_CertVerifyDmaAndCacheLeafPubKeyResponse(whClientContext* c,
793792
794793int wh_Client_CertVerifyDmaAndCacheLeafPubKey (
795794 whClientContext * c , const void * cert , uint32_t cert_len ,
796- whNvmId trustedRootNvmId , whNvmFlags cachedKeyFlags , whKeyId * inout_keyId ,
795+ whKeyId trustedRootId , whNvmFlags cachedKeyFlags , whKeyId * inout_keyId ,
797796 int32_t * out_rc )
798797{
799- return _certVerifyDma (c , cert , cert_len , trustedRootNvmId ,
798+ return _certVerifyDma (c , cert , cert_len , trustedRootId ,
800799 WH_CERT_FLAGS_CACHE_LEAF_PUBKEY , cachedKeyFlags ,
801800 inout_keyId , out_rc );
802801}
@@ -807,23 +806,21 @@ int wh_Client_CertVerifyDmaAndCacheLeafPubKey(
807806
808807
809808int wh_Client_CertVerifyAcertRequest (whClientContext * c , const void * cert ,
810- uint32_t cert_len ,
811- whNvmId trustedRootNvmId )
809+ uint32_t cert_len , whKeyId trustedRootId )
812810{
813811 whMessageCert_VerifyAcertRequest req = {0 };
814812 uint8_t buffer [WOLFHSM_CFG_COMM_DATA_LEN ];
815813 size_t hdr_len = sizeof (req );
816814 uint8_t * payload = buffer + hdr_len ;
817815
818816
819- if ((c == NULL ) || (trustedRootNvmId == WH_NVM_ID_INVALID ) ||
820- (cert == NULL ) || (cert_len == 0 ) ||
821- (cert_len > (sizeof (buffer ) - hdr_len ))) {
817+ if ((c == NULL ) || (trustedRootId == WH_NVM_ID_INVALID ) || (cert == NULL ) ||
818+ (cert_len == 0 ) || (cert_len > (sizeof (buffer ) - hdr_len ))) {
822819 return WH_ERROR_BADARGS ;
823820 }
824821
825822 req .cert_len = cert_len ;
826- req .trustedRootNvmId = trustedRootNvmId ;
823+ req .trustedRootId = trustedRootId ;
827824
828825 memcpy (buffer , & req , sizeof (req ));
829826 memcpy (payload , cert , cert_len );
@@ -859,7 +856,7 @@ int wh_Client_CertVerifyAcertResponse(whClientContext* c, int32_t* out_rc)
859856}
860857
861858int wh_Client_CertVerifyAcert (whClientContext * c , const void * cert ,
862- uint32_t cert_len , whNvmId trustedRootNvmId ,
859+ uint32_t cert_len , whKeyId trustedRootId ,
863860 int32_t * out_rc )
864861{
865862 int rc = 0 ;
@@ -869,8 +866,7 @@ int wh_Client_CertVerifyAcert(whClientContext* c, const void* cert,
869866 }
870867
871868 do {
872- rc = wh_Client_CertVerifyAcertRequest (c , cert , cert_len ,
873- trustedRootNvmId );
869+ rc = wh_Client_CertVerifyAcertRequest (c , cert , cert_len , trustedRootId );
874870 } while (rc == WH_ERROR_NOTREADY );
875871
876872 if (rc == 0 ) {
@@ -886,7 +882,7 @@ int wh_Client_CertVerifyAcert(whClientContext* c, const void* cert,
886882
887883int wh_Client_CertVerifyAcertDmaRequest (whClientContext * c , const void * cert ,
888884 uint32_t cert_len ,
889- whNvmId trustedRootNvmId )
885+ whKeyId trustedRootId )
890886{
891887 whMessageCert_VerifyDmaRequest req = {0 };
892888
@@ -896,7 +892,7 @@ int wh_Client_CertVerifyAcertDmaRequest(whClientContext* c, const void* cert,
896892
897893 req .cert_addr = (uint64_t )(intptr_t )cert ;
898894 req .cert_len = cert_len ;
899- req .trustedRootNvmId = trustedRootNvmId ;
895+ req .trustedRootId = trustedRootId ;
900896 return wh_Client_SendRequest (c , WH_MESSAGE_GROUP_CERT ,
901897 WH_MESSAGE_CERT_ACTION_VERIFY_ACERT_DMA ,
902898 sizeof (req ), & req );
@@ -932,7 +928,7 @@ int wh_Client_CertVerifyAcertDmaResponse(whClientContext* c, int32_t* out_rc)
932928}
933929
934930int wh_Client_CertVerifyAcertDma (whClientContext * c , const void * cert ,
935- uint32_t cert_len , whNvmId trustedRootNvmId ,
931+ uint32_t cert_len , whKeyId trustedRootId ,
936932 int32_t * out_rc )
937933{
938934 int rc = 0 ;
@@ -943,7 +939,7 @@ int wh_Client_CertVerifyAcertDma(whClientContext* c, const void* cert,
943939
944940 do {
945941 rc = wh_Client_CertVerifyAcertDmaRequest (c , cert , cert_len ,
946- trustedRootNvmId );
942+ trustedRootId );
947943 } while (rc == WH_ERROR_NOTREADY );
948944
949945 if (rc == 0 ) {
0 commit comments