Skip to content

Commit

Permalink
Additional print protections. Remove in the future.
Browse files Browse the repository at this point in the history
  • Loading branch information
billphipps committed Jul 30, 2024
1 parent d2323e9 commit 9aad059
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wh_client_cryptocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,20 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
WC_ALGO_TYPE_PK,
WH_PACKET_STUB_SIZE + sizeof(packet->pkRsakgReq),
(uint8_t*)packet);
#ifdef DEBUG_CRYPTOCB_VERBOSE
printf("RSA KeyGen Req sent:size:%u, e:%u, ret:%d\n",
packet->pkRsakgReq.size, packet->pkRsakgReq.e, ret);
#endif
if (ret == 0) {
do {
ret = wh_Client_RecvResponse(ctx, &group, &action, &dataSz,
(uint8_t*)packet);
} while (ret == WH_ERROR_NOTREADY);
}
#ifdef DEBUG_CRYPTOCB_VERBOSE
printf("RSA KeyGen Res recv:keyid:%u, rc:%d, ret:%d\n",
packet->pkRsakgRes.keyId, packet->rc, ret);
#endif
if (ret == 0) {
if (packet->rc != 0)
ret = packet->rc;
Expand Down Expand Up @@ -372,6 +376,8 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
ret = derSize = wc_RsaKeyToDer(info->pk.rsa.key, keyDer, sizeof(keyDer));
if(derSize >= 0) {
/* Cache the key and get the keyID */
/* WWW This is likely recursive so assume the packet will be
* trashed by the time this returns */
ret = wh_Client_KeyCache(ctx, 0, (uint8_t*)keyLabel,
sizeof(keyLabel), keyDer, derSize, &cacheKeyId);
packet->pkRsaReq.keyId = cacheKeyId;
Expand All @@ -385,7 +391,9 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
#endif
/* set type */
packet->pkRsaReq.opType = info->pk.rsa.type;
#ifdef DEBUG_CRYPTOCB_VERBOSE
printf("RSA optype:%u\n",packet->pkRsaReq.opType);
#endif
/* set inLen */
packet->pkRsaReq.inLen = info->pk.rsa.inLen;
/* set outLen */
Expand Down
2 changes: 2 additions & 0 deletions src/wh_server_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ static int hsmCryptoRsaFunction(whServerContext* server, whPacket* packet,
if (ret == 0) {
ret = hsmLoadKeyRsa(server, server->crypto->algoCtx.rsa,
packet->pkRsaReq.keyId);
#ifdef DEBUG_CRYPTOCB_VERBOSE
printf("-LoadKeyRsa keyid %u:%d\n", packet->pkRsaReq.keyId,ret);
#endif
}
/* do the rsa operation */
if (ret == 0) {
Expand Down

0 comments on commit 9aad059

Please sign in to comment.