@@ -171,7 +171,7 @@ static int _GetKeyCacheSlot(whKeyCacheContext* ctx, uint16_t keySz,
171171
172172 /* Zero slot and return pointers */
173173 if (foundIndex >= 0 ) {
174- memset (& ctx -> cache [foundIndex ], 0 , sizeof (whServerCacheSlot ));
174+ memset (& ctx -> cache [foundIndex ], 0 , sizeof (whCacheSlot ));
175175 * outBuf = ctx -> cache [foundIndex ].buffer ;
176176 * outMeta = ctx -> cache [foundIndex ].meta ;
177177 }
@@ -197,7 +197,7 @@ static int _GetKeyCacheSlot(whKeyCacheContext* ctx, uint16_t keySz,
197197
198198 /* Zero slot and return pointers */
199199 if (foundIndex >= 0 ) {
200- memset (& ctx -> bigCache [foundIndex ], 0 , sizeof (whServerBigCacheSlot ));
200+ memset (& ctx -> bigCache [foundIndex ], 0 , sizeof (whBigCacheSlot ));
201201 * outBuf = ctx -> bigCache [foundIndex ].buffer ;
202202 * outMeta = ctx -> bigCache [foundIndex ].meta ;
203203 }
@@ -485,26 +485,6 @@ static int _ExistsInCache(whServerContext* server, whKeyId keyId)
485485}
486486#endif /* WOLFHSM_CFG_KEYWRAP */
487487
488- #ifdef WOLFHSM_CFG_KEYWRAP
489- int wh_Server_KeystoreIsWrappedKey (whServerContext * server , whKeyId keyId ,
490- int * outIsWrapped )
491- {
492- int isWrapped ;
493-
494- if (server == NULL || WH_KEYID_ISERASED (keyId )) {
495- return WH_ERROR_BADARGS ;
496- }
497-
498- (void )server ;
499- isWrapped = (WH_KEYID_TYPE (keyId ) == WH_KEYTYPE_WRAPPED );
500- if (outIsWrapped != NULL ) {
501- * outIsWrapped = isWrapped ;
502- }
503-
504- return WH_ERROR_OK ;
505- }
506- #endif /* WOLFHSM_CFG_KEYWRAP */
507-
508488/* try to put the specified key into cache if it isn't already, return pointers
509489 * to meta and the cached data*/
510490int wh_Server_KeystoreFreshenKey (whServerContext * server , whKeyId keyId ,
@@ -742,8 +722,8 @@ static int _AesGcmWrapKey(whServerContext* server, whKeyId serverKeyId,
742722 /* Get the server side key */
743723 ret = wh_Server_KeystoreReadKey (
744724 server ,
745- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO , server -> comm -> client_id ,
746- serverKeyId ),
725+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO , server -> comm -> client_id ,
726+ serverKeyId ),
747727 NULL , serverKey , & serverKeySz );
748728 if (ret != WH_ERROR_OK ) {
749729 return ret ;
@@ -815,8 +795,8 @@ static int _AesGcmUnwrapKey(whServerContext* server, uint16_t serverKeyId,
815795 /* Get the server side key */
816796 ret = wh_Server_KeystoreReadKey (
817797 server ,
818- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO , server -> comm -> client_id ,
819- serverKeyId ),
798+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO , server -> comm -> client_id ,
799+ serverKeyId ),
820800 NULL , serverKey , & serverKeySz );
821801 if (ret != WH_ERROR_OK ) {
822802 return ret ;
@@ -1115,7 +1095,7 @@ _HandleUnwrapAndCacheKeyRequest(whServerContext* server,
11151095 }
11161096
11171097 /* Store the assigned key ID in the response, preserving client flags */
1118- resp -> keyId = wh_KeyId_ToClient (metadata .id );
1098+ resp -> keyId = wh_KeyId_TranslateToClient (metadata .id );
11191099
11201100 /* Cache the key */
11211101 return wh_Server_KeystoreCacheKey (server , & metadata , key );
@@ -1153,7 +1133,7 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
11531133 in = (uint8_t * )req_packet + sizeof (req );
11541134
11551135 /* set the metadata fields */
1156- meta -> id = wh_KeyId_TranslateClient (
1136+ meta -> id = wh_KeyId_TranslateFromClient (
11571137 WH_KEYTYPE_CRYPTO , server -> comm -> client_id , req .id );
11581138 meta -> access = WH_NVM_ACCESS_ANY ;
11591139 meta -> flags = req .flags ;
@@ -1181,7 +1161,7 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
11811161 }
11821162 if (ret == WH_ERROR_OK ) {
11831163 /* Translate server keyId back to client format with flags */
1184- resp .id = wh_KeyId_ToClient (meta -> id );
1164+ resp .id = wh_KeyId_TranslateToClient (meta -> id );
11851165
11861166 (void )wh_MessageKeystore_TranslateCacheResponse (
11871167 magic , & resp ,
@@ -1202,7 +1182,7 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
12021182 magic , (whMessageKeystore_CacheDmaRequest * )req_packet , & req );
12031183
12041184 /* set the metadata fields */
1205- meta -> id = wh_KeyId_TranslateClient (
1185+ meta -> id = wh_KeyId_TranslateFromClient (
12061186 WH_KEYTYPE_CRYPTO , server -> comm -> client_id , req .id );
12071187 meta -> access = WH_NVM_ACCESS_ANY ;
12081188 meta -> flags = req .flags ;
@@ -1236,7 +1216,7 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
12361216 }
12371217
12381218 /* Translate server keyId back to client format with flags */
1239- resp .id = wh_KeyId_ToClient (meta -> id );
1219+ resp .id = wh_KeyId_TranslateToClient (meta -> id );
12401220
12411221 (void )wh_MessageKeystore_TranslateCacheDmaResponse (
12421222 magic , & resp , (whMessageKeystore_CacheDmaResponse * )resp_packet );
@@ -1254,8 +1234,8 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
12541234
12551235 ret = wh_Server_KeystoreExportKeyDma (
12561236 server ,
1257- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO ,
1258- server -> comm -> client_id , req .id ),
1237+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO ,
1238+ server -> comm -> client_id , req .id ),
12591239 req .key .addr , req .key .sz , meta );
12601240 resp .rc = ret ;
12611241 /* propagate bad address to client if DMA operation failed */
@@ -1288,8 +1268,8 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
12881268
12891269 ret = wh_Server_KeystoreEvictKey (
12901270 server ,
1291- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO ,
1292- server -> comm -> client_id , req .id ));
1271+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO ,
1272+ server -> comm -> client_id , req .id ));
12931273 resp .rc = ret ;
12941274 /* TODO: Are there any fatal server errors? */
12951275 ret = WH_ERROR_OK ;
@@ -1320,8 +1300,8 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
13201300 /* read the key */
13211301 ret = wh_Server_KeystoreReadKey (
13221302 server ,
1323- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO ,
1324- server -> comm -> client_id , req .id ),
1303+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO ,
1304+ server -> comm -> client_id , req .id ),
13251305 meta , out , & keySz );
13261306
13271307 /* Check if key is non-exportable */
@@ -1364,8 +1344,8 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
13641344
13651345 ret = wh_Server_KeystoreCommitKey (
13661346 server ,
1367- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO ,
1368- server -> comm -> client_id , req .id ));
1347+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO ,
1348+ server -> comm -> client_id , req .id ));
13691349 resp .rc = ret ;
13701350 /* TODO: Are there any fatal server errors? */
13711351 ret = WH_ERROR_OK ;
@@ -1391,8 +1371,8 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
13911371
13921372 ret = wh_Server_KeystoreEraseKey (
13931373 server ,
1394- wh_KeyId_TranslateClient (WH_KEYTYPE_CRYPTO ,
1395- server -> comm -> client_id , req .id ));
1374+ wh_KeyId_TranslateFromClient (WH_KEYTYPE_CRYPTO ,
1375+ server -> comm -> client_id , req .id ));
13961376 resp .rc = ret ;
13971377 /* TODO: Are there any fatal server errors? */
13981378 ret = WH_ERROR_OK ;
0 commit comments