Skip to content

Commit 0ed7fe7

Browse files
authored
Merge pull request #10 from JacobBarthelmeh/master
changes for tls 1.3 with FIPS ready
2 parents 4246a2f + e349eef commit 0ed7fe7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/wp_hkdf.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ static int wp_tls13_hkdf_expand(wp_HkdfCtx* ctx, unsigned char* inKey,
519519
}
520520
ctx->infoSz = idx;
521521

522+
PRIVATE_KEY_UNLOCK();
522523
rc = wc_HKDF_Expand(ctx->mdType, inKey, (word32)inKeyLen, ctx->info,
523524
(word32)ctx->infoSz, key, (word32)keyLen);
525+
PRIVATE_KEY_LOCK();
524526
if (rc != 0) {
525527
ok = 0;
526528
}
@@ -578,8 +580,16 @@ static int wp_tls13_hkdf_extract(wp_HkdfCtx* ctx, unsigned char* key,
578580

579581
if (ok) {
580582
(void)keyLen;
581-
rc = wc_HKDF_Extract(ctx->mdType, salt, (word32)saltLen, inKey,
582-
(word32)inKeyLen, key);
583+
PRIVATE_KEY_UNLOCK();
584+
if (saltLen == 0) {
585+
rc = wc_HKDF_Extract(ctx->mdType, NULL, 0, inKey,
586+
(word32)inKeyLen, key);
587+
}
588+
else {
589+
rc = wc_HKDF_Extract(ctx->mdType, salt, (word32)saltLen, inKey,
590+
(word32)inKeyLen, key);
591+
}
592+
PRIVATE_KEY_LOCK();
583593
if (rc != 0) {
584594
ok = 0;
585595
}

0 commit comments

Comments
 (0)