Skip to content

Commit e262be8

Browse files
committed
Fix error handling, NULL checks, and TLS padding
1 parent f3fc934 commit e262be8

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/wp_aes_aead.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ static int wp_aead_set_param_tag(wp_AeadCtx* ctx,
488488
if (ok && ((sz == 0) || ((p->data != NULL) && ctx->enc))) {
489489
ok = 0;
490490
}
491-
ctx->tagLen = sz;
491+
if (ok) {
492+
ctx->tagLen = sz;
493+
}
492494

493495
WOLFPROV_LEAVE(WP_LOG_COMP_AES, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
494496
return ok;
@@ -1122,7 +1124,7 @@ static int wp_aesgcm_dinit(wp_AeadCtx *ctx, const unsigned char *key,
11221124
ok = 0;
11231125
}
11241126
}
1125-
if (ok) {
1127+
if (ok && (iv != NULL)) {
11261128
XMEMCPY(ctx->iv, iv, ivLen);
11271129
ctx->ivState = IV_STATE_BUFFERED;
11281130
ctx->ivSet = 0;

src/wp_kbkdf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,9 @@ static int wp_kdf_kbkdf_derive(wp_KbkdfCtx* ctx, unsigned char* key,
623623
ok = 0;
624624
}
625625
else {
626-
XMEMCPY(k_i, ctx->iv, ctx->ivLen);
626+
if (ctx->ivLen > 0) {
627+
XMEMCPY(k_i, ctx->iv, ctx->ivLen);
628+
}
627629
k_i_len = ctx->ivLen;
628630
/* Prep [L]2 */
629631
wp_c32toa((word32)(keyLen * 8), (byte *)&beL);

0 commit comments

Comments
 (0)