Skip to content

Commit

Permalink
Merge pull request #10 from JacobBarthelmeh/master
Browse files Browse the repository at this point in the history
changes for tls 1.3 with FIPS ready
  • Loading branch information
SparkiDev authored Sep 22, 2023
2 parents 4246a2f + e349eef commit 0ed7fe7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/wp_hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,10 @@ static int wp_tls13_hkdf_expand(wp_HkdfCtx* ctx, unsigned char* inKey,
}
ctx->infoSz = idx;

PRIVATE_KEY_UNLOCK();
rc = wc_HKDF_Expand(ctx->mdType, inKey, (word32)inKeyLen, ctx->info,
(word32)ctx->infoSz, key, (word32)keyLen);
PRIVATE_KEY_LOCK();
if (rc != 0) {
ok = 0;
}
Expand Down Expand Up @@ -578,8 +580,16 @@ static int wp_tls13_hkdf_extract(wp_HkdfCtx* ctx, unsigned char* key,

if (ok) {
(void)keyLen;
rc = wc_HKDF_Extract(ctx->mdType, salt, (word32)saltLen, inKey,
(word32)inKeyLen, key);
PRIVATE_KEY_UNLOCK();
if (saltLen == 0) {
rc = wc_HKDF_Extract(ctx->mdType, NULL, 0, inKey,
(word32)inKeyLen, key);
}
else {
rc = wc_HKDF_Extract(ctx->mdType, salt, (word32)saltLen, inKey,
(word32)inKeyLen, key);
}
PRIVATE_KEY_LOCK();
if (rc != 0) {
ok = 0;
}
Expand Down

0 comments on commit 0ed7fe7

Please sign in to comment.