diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2010-06-27 14:22:11 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2010-06-27 14:22:11 +0000 |
commit | b4b15f68c01c4bf4557db5ff6180623411540b52 (patch) | |
tree | dc8969be13937ea8b79125e68494497474c2b1ab /ssl/t1_enc.c | |
parent | 1eb1cf452b1263373ff3f7c91b9419adca8c3ba8 (diff) |
Backport TLS v1.1 support from HEAD, ssl/ changes
Diffstat (limited to 'ssl/t1_enc.c')
-rw-r--r-- | ssl/t1_enc.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index 793ea43e90..b5c3179c48 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -143,6 +143,7 @@ #include <openssl/evp.h> #include <openssl/hmac.h> #include <openssl/md5.h> +#include <openssl/rand.h> #ifdef KSSL_DEBUG #include <openssl/des.h> #endif @@ -655,7 +656,27 @@ int tls1_enc(SSL *s, int send) if (s->enc_write_ctx == NULL) enc=NULL; else + { + int ivlen; enc=EVP_CIPHER_CTX_cipher(s->enc_write_ctx); + /* For TLSv1.1 and later explicit IV */ + if (s->version >= TLS1_1_VERSION) + ivlen = EVP_CIPHER_iv_length(enc); + else + ivlen = 0; + if (ivlen > 1) + { + if ( rec->data != rec->input) + /* we can't write into the input stream: + * Can this ever happen?? (steve) + */ + fprintf(stderr, + "%s:%d: rec->data != rec->input\n", + __FILE__, __LINE__); + else if (RAND_bytes(rec->input, ivlen) <= 0) + return -1; + } + } } else { @@ -784,7 +805,13 @@ int tls1_enc(SSL *s, int send) return -1; } } - rec->length-=i; + rec->length -=i; + if (s->version >= TLS1_1_VERSION) + { + rec->data += bs; /* skip the explicit IV */ + rec->input += bs; + rec->length -= bs; + } } } return(1); |