summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2020-08-09 15:46:28 +0000
committerjsing <>2020-08-09 15:46:28 +0000
commite770512d626b103f809dfdecb1ba758a92b5f57b (patch)
tree3134c41f81a5946eb2147d3c878d32f247735220 /src
parent6fea4ce7c01be8942e2bcb4f672dede119751ed6 (diff)
downloadopenbsd-e770512d626b103f809dfdecb1ba758a92b5f57b.tar.gz
openbsd-e770512d626b103f809dfdecb1ba758a92b5f57b.tar.bz2
openbsd-e770512d626b103f809dfdecb1ba758a92b5f57b.zip
Make the explicit IV length handling in DTLS the same as SSL3/TLS.
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/d1_pkt.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c
index 0caf2a5965..5bbdf5f738 100644
--- a/src/lib/libssl/d1_pkt.c
+++ b/src/lib/libssl/d1_pkt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_pkt.c,v 1.76 2020/08/02 07:33:15 jsing Exp $ */ 1/* $OpenBSD: d1_pkt.c,v 1.77 2020/08/09 15:46:28 jsing Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -1229,13 +1229,18 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len)
1229 1229
1230 p += DTLS1_RT_HEADER_LENGTH; 1230 p += DTLS1_RT_HEADER_LENGTH;
1231 1231
1232 /* 1232 /* Explicit IV length. */
1233 * Make space for the explicit IV in case of CBC. 1233 if (s->internal->enc_write_ctx && SSL_USE_EXPLICIT_IV(s)) {
1234 * (this is a bit of a boundary violation, but what the heck). 1234 int mode = EVP_CIPHER_CTX_mode(s->internal->enc_write_ctx);
1235 */ 1235 if (mode == EVP_CIPH_CBC_MODE) {
1236 if (s->internal->enc_write_ctx && 1236 eivlen = EVP_CIPHER_CTX_iv_length(s->internal->enc_write_ctx);
1237 (EVP_CIPHER_mode(s->internal->enc_write_ctx->cipher) & EVP_CIPH_CBC_MODE)) 1237 if (eivlen <= 1)
1238 eivlen = EVP_CIPHER_block_size(s->internal->enc_write_ctx->cipher); 1238 eivlen = 0;
1239 }
1240 } else if (s->internal->aead_write_ctx != NULL &&
1241 s->internal->aead_write_ctx->variable_nonce_in_record) {
1242 eivlen = s->internal->aead_write_ctx->variable_nonce_len;
1243 }
1239 1244
1240 wr->type = type; 1245 wr->type = type;
1241 wr->data = p + eivlen; 1246 wr->data = p + eivlen;