Skip to content

Commit 6d2a8b3

Browse files
committed
ready-for-use flag fix
1 parent 7898823 commit 6d2a8b3

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/keys.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3554,6 +3554,10 @@ int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side)
35543554
ret = PROTOCOLCB_UNAVAILABLE;
35553555
if (ssl->ctx->EncryptKeysCb) {
35563556
void* ctx = wolfSSL_GetEncryptKeysCtx(ssl);
3557+
#if defined(WOLFSSL_RENESAS_FSPSM_TLS)
3558+
FSPSM_ST* cbInfo = (FSPSM_ST*)ctx;
3559+
cbInfo->side = side;
3560+
#endif
35573561
ret = ssl->ctx->EncryptKeysCb(ssl, ctx);
35583562
}
35593563
if (!ssl->ctx->EncryptKeysCb ||

wolfcrypt/src/port/Renesas/renesas_common.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
171171
if (info == NULL || ctx == NULL)
172172
return BAD_FUNC_ARG;
173173

174-
#if defined(DEBUG_WOLFSSL)
175-
printf("CryptoDevCb: Algo Type %d session key set: %d\n",
176-
info->algo_type, cbInfo->session_key_set);
177-
#endif
178174
#if defined(DEBUG_CRYPTOCB)
179175
wc_CryptoCb_InfoString(info);
180176
#endif
@@ -830,12 +826,23 @@ static int Renesas_cmn_EncryptKeys(WOLFSSL* ssl, void* ctx)
830826
if (cbInfo->session_key_set == 1) {
831827
#elif defined(WOLFSSL_RENESAS_FSPSM_TLS)
832828
FSPSM_ST* cbInfo = (FSPSM_ST*)ctx;
833-
834-
829+
835830
if (cbInfo->keyflgs_tls.bits.session_key_set == 1) {
831+
switch(cbInfo->side) {
832+
case 1:/* ENCRYPT_SIDE_ONLY */
833+
ssl->encrypt.setup = 1;
834+
break;
835+
case 2:/* DECRYPT_SIDE_ONLY */
836+
ssl->decrypt.setup = 1;
837+
break;
838+
case 3:/* ENCRYPT AND DECRYPT */
839+
ssl->decrypt.setup = 1;
840+
ssl->encrypt.setup = 1;
841+
break;
842+
default:break;
843+
}
836844
#endif
837845
ret = 0;
838-
839846
wolfSSL_CTX_SetTlsFinishedCb(ssl->ctx, Renesas_cmn_TlsFinished);
840847
wolfSSL_SetTlsFinishedCtx(ssl, cbInfo);
841848
}

wolfcrypt/src/port/Renesas/renesas_fspsm_util.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,15 +834,13 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
834834
if (enc) {
835835
enc->aes->ctx.keySize = ssl->specs.key_size;
836836
enc->aes->ctx.setup = 1;
837-
/* ready for use */
838-
enc->setup = 1;
837+
/* ready-for-use flag will be set when SetKeySide() is called */
839838
}
840839
/* set up key size and marked ready */
841840
if (dec) {
842841
dec->aes->ctx.keySize = ssl->specs.key_size;
843842
dec->aes->ctx.setup = 1;
844-
/* ready for use */
845-
dec->setup = 1;
843+
/* ready-for-use flag will be set when SetKeySide() is called */
846844
}
847845

848846
if (cbInfo->cipher == SCE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ||

wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef struct FSPSM_tag_ST {
6666
uint8_t clientRandom[FSPSM_TLS_CLIENTRANDOM_SZ];
6767
uint8_t serverRandom[FSPSM_TLS_SERVERRANDOM_SZ];
6868
uint8_t cipher;
69-
69+
uint8_t side; /* for key set side */
7070
#endif
7171

7272
/* installed key handling */

0 commit comments

Comments
 (0)