Skip to content

Commit bd3cf10

Browse files
committed
DTLS export: cap IV size at buffer size
ExportKeyState was writing ssl->specs.iv_size bytes from keys->aead_enc_imp_IV (always sized AEAD_MAX_IMP_SZ). ssl->specs.iv_size carries a different meaning depending on the cipher suite: in AEAD suites it's the implicit IV / nonce size, but in CBC it's the block cipher's IV size (16). In CBC this overran the size of aead_enc_imp_IV (12).
1 parent 95c177b commit bd3cf10

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/internal.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,9 @@ static int ExportKeyState(WOLFSSL* ssl, byte* exp, word32 len, byte ver,
10001000
XMEMCPY(exp + idx, keys->aead_exp_IV, AEAD_MAX_EXP_SZ);
10011001
idx += AEAD_MAX_EXP_SZ;
10021002

1003-
sz = (small)? 0: ssl->specs.iv_size;
1003+
sz = (small) ? 0 :
1004+
(ssl->specs.iv_size > AEAD_MAX_IMP_SZ ? AEAD_MAX_IMP_SZ
1005+
: ssl->specs.iv_size);
10041006
if (idx + (sz * 2) + OPAQUE8_LEN > len) {
10051007
WOLFSSL_MSG("Buffer not large enough for imp IVs");
10061008
return BUFFER_E;

0 commit comments

Comments
 (0)