Skip to content

Commit

Permalink
Update sizes to support 4K RSA keygen
Browse files Browse the repository at this point in the history
  • Loading branch information
billphipps committed Jul 30, 2024
1 parent 86d2d31 commit d2323e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/wh_client_cryptocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
info->pk.rsakg.key->devCtx = WH_KEYID_TO_DEVCTX(keyId);

if (info->pk.rsakg.key != NULL) {
byte keyDer[2048] = {0};
/* DER cannot be larger than MTU */
byte keyDer[WOLFHSM_CFG_COMM_DATA_LEN] = {0};
uint32_t derSize = sizeof(keyDer);
word32 idx = 0;
uint8_t keyLabel[WH_NVM_LABEL_LEN] = {0};
Expand All @@ -328,6 +329,9 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
ret = wh_Client_KeyExport(ctx,keyId,
keyLabel, sizeof(keyLabel),
keyDer, &derSize);
#ifdef DEBUG_CRYPTOCB_VERBOSE
printf("-RSA Keygen Der size:%u\n", derSize);
#endif
if (ret == 0) {
/* Update the RSA key structure */
ret = wc_RsaPrivateKeyDecode(
Expand All @@ -344,7 +348,7 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
case WC_PK_TYPE_RSA:
{
whKeyId cacheKeyId = WH_KEYID_ERASED;
byte keyDer[2048] = {0};
byte keyDer[5000] = {0}; /* Estimated size of a 4096 keyfile */
int derSize = 0;
char keyLabel[] = "ClientCbTemp";

Expand Down
4 changes: 2 additions & 2 deletions test/wolfhsm_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
/* #define WOLFHSM_CFG_NO_CRYPTO */
/* #define WOLFHSM_CFG_SHE_EXTENSION */

#define WOLFHSM_CFG_COMM_DATA_LEN 1152
#define WOLFHSM_CFG_COMM_DATA_LEN 1280


#define WOLFHSM_CFG_NVM_OBJECT_COUNT 30
#define WOLFHSM_CFG_SERVER_KEYCACHE_COUNT 10
#define WOLFHSM_CFG_SERVER_KEYCACHE_SIZE 1024
#define WOLFHSM_CFG_SERVER_KEYCACHE_SIZE 1280
#define WOLFHSM_CFG_SERVER_DMAADDR_COUNT 8
#define WOLFHSM_CFG_SERVER_CUSTOMCB_COUNT 6

Expand Down

0 comments on commit d2323e9

Please sign in to comment.