Skip to content

Commit afce879

Browse files
committed
Correct fix for file chnages
1 parent 81f2bb2 commit afce879

3 files changed

Lines changed: 2 additions & 877 deletions

File tree

test/wh_test_clientserver.c

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -651,79 +651,6 @@ static int _testNonExportableNvmAccess(whClientContext* client)
651651
}
652652
#endif /* WOLFHSM_CFG_ENABLE_CLIENT */
653653

654-
#if defined(WOLFHSM_CFG_KEYWRAP) && !defined(WOLFHSM_CFG_NO_CRYPTO) && \
655-
defined(WOLFHSM_CFG_ENABLE_CLIENT) && defined(WOLFHSM_CFG_ENABLE_SERVER)
656-
/* Test key wrapping functionality using Request/Response pattern for sequential
657-
* mode */
658-
static int _testKeyWrapSequential(whServerContext* server,
659-
whClientContext* client)
660-
{
661-
uint8_t key[16]; /* Wrap key */
662-
uint8_t plainKey[16]; /* Key to be wrapped */
663-
uint8_t tmpPlainKey[16];
664-
uint8_t wrappedKey[16 + 12 + 16 +
665-
sizeof(whNvmMetadata)]; /* key + IV + tag + metadata */
666-
uint8_t label[] = "Server AES Key Label";
667-
whKeyId serverKeyId = 0;
668-
whKeyId wrappedKeyId = 0;
669-
whNvmMetadata metadata = {
670-
.id = 8, .label = "AES Key Label", .len = sizeof(plainKey)};
671-
whNvmMetadata tmpMetadata;
672-
WC_RNG rng[1];
673-
674-
/* Initialize RNG with INVALID_DEVID to use local wolfCrypt (not HSM) */
675-
WH_TEST_RETURN_ON_FAIL(wc_InitRng_ex(rng, NULL, INVALID_DEVID));
676-
677-
/* Generate random keys */
678-
WH_TEST_RETURN_ON_FAIL(wc_RNG_GenerateBlock(rng, key, sizeof(key)));
679-
WH_TEST_RETURN_ON_FAIL(
680-
wc_RNG_GenerateBlock(rng, plainKey, sizeof(plainKey)));
681-
682-
/* Cache the wrap key using Request/Response pattern */
683-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyCacheRequest(
684-
client, 0, label, sizeof(label), key, sizeof(key)));
685-
WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server));
686-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyCacheResponse(client, &serverKeyId));
687-
printf(" Wrap key cached with ID: %d\n", serverKeyId);
688-
689-
/* Wrap the key using Request/Response pattern */
690-
WH_TEST_RETURN_ON_FAIL(
691-
wh_Client_KeyWrapRequest(client, WC_CIPHER_AES_GCM, serverKeyId,
692-
plainKey, sizeof(plainKey), &metadata));
693-
WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server));
694-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyWrapResponse(
695-
client, WC_CIPHER_AES_GCM, wrappedKey, sizeof(wrappedKey)));
696-
697-
/* Unwrap and cache using Request/Response pattern */
698-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyUnwrapAndCacheRequest(
699-
client, WC_CIPHER_AES_GCM, serverKeyId, wrappedKey,
700-
sizeof(wrappedKey)));
701-
WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server));
702-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyUnwrapAndCacheResponse(
703-
client, WC_CIPHER_AES_GCM, &wrappedKeyId));
704-
printf(" Unwrapped and cached with ID: %d\n", wrappedKeyId);
705-
706-
/* Unwrap and export using Request/Response pattern */
707-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyUnwrapAndExportRequest(
708-
client, WC_CIPHER_AES_GCM, serverKeyId, wrappedKey,
709-
sizeof(wrappedKey)));
710-
WH_TEST_RETURN_ON_FAIL(wh_Server_HandleRequestMessage(server));
711-
WH_TEST_RETURN_ON_FAIL(wh_Client_KeyUnwrapAndExportResponse(
712-
client, WC_CIPHER_AES_GCM, &tmpMetadata, tmpPlainKey,
713-
sizeof(tmpPlainKey)));
714-
715-
/* Verify the keys match */
716-
WH_TEST_ASSERT_RETURN(memcmp(plainKey, tmpPlainKey, sizeof(plainKey)) == 0);
717-
WH_TEST_ASSERT_RETURN(memcmp(&metadata, &tmpMetadata, sizeof(metadata)) ==
718-
0);
719-
720-
wc_FreeRng(rng);
721-
printf("KeyWrap sequential test passed\n");
722-
return WH_ERROR_OK;
723-
}
724-
#endif /* WOLFHSM_CFG_KEYWRAP && !WOLFHSM_CFG_NO_CRYPTO && \
725-
WOLFHSM_CFG_ENABLE_CLIENT && WOLFHSM_CFG_ENABLE_SERVER */
726-
727654
#if defined(WOLFHSM_CFG_ENABLE_CLIENT) && defined(WOLFHSM_CFG_ENABLE_SERVER)
728655
static int _clientServerSequentialTestConnectCb(void* context,
729656
whCommConnected connected)
@@ -1313,12 +1240,6 @@ int whTest_ClientServerSequential(void)
13131240
WH_TEST_RETURN_ON_FAIL(_testDma(server, client));
13141241
#endif /* WOLFHSM_CFG_DMA */
13151242

1316-
#if defined(WOLFHSM_CFG_KEYWRAP) && !defined(WOLFHSM_CFG_NO_CRYPTO)
1317-
/* Test key wrapping functionality */
1318-
printf("Testing KeyWrap...\n");
1319-
WH_TEST_RETURN_ON_FAIL(_testKeyWrapSequential(server, client));
1320-
#endif
1321-
13221243
/* Check that we are still connected */
13231244
WH_TEST_RETURN_ON_FAIL(wh_Server_GetConnected(server, &server_connected));
13241245
WH_TEST_ASSERT_RETURN(server_connected == WH_COMM_CONNECTED);

0 commit comments

Comments
 (0)