summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/d1_enc.c')
-rw-r--r--src/lib/libssl/d1_enc.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/lib/libssl/d1_enc.c b/src/lib/libssl/d1_enc.c
index cf3332e4e4..8fa57347a9 100644
--- a/src/lib/libssl/d1_enc.c
+++ b/src/lib/libssl/d1_enc.c
@@ -136,8 +136,12 @@ int dtls1_enc(SSL *s, int send)
136 136
137 if (send) 137 if (send)
138 { 138 {
139 if (s->write_hash != NULL) 139 if (EVP_MD_CTX_md(s->write_hash))
140 n=EVP_MD_size(s->write_hash); 140 {
141 n=EVP_MD_CTX_size(s->write_hash);
142 if (n < 0)
143 return -1;
144 }
141 ds=s->enc_write_ctx; 145 ds=s->enc_write_ctx;
142 rec= &(s->s3->wrec); 146 rec= &(s->s3->wrec);
143 if (s->enc_write_ctx == NULL) 147 if (s->enc_write_ctx == NULL)
@@ -151,15 +155,19 @@ int dtls1_enc(SSL *s, int send)
151 __FILE__, __LINE__); 155 __FILE__, __LINE__);
152 else if ( EVP_CIPHER_block_size(ds->cipher) > 1) 156 else if ( EVP_CIPHER_block_size(ds->cipher) > 1)
153 { 157 {
154 if (!RAND_bytes(rec->input, EVP_CIPHER_block_size(ds->cipher))) 158 if (RAND_bytes(rec->input, EVP_CIPHER_block_size(ds->cipher)) <= 0)
155 return -1; 159 return -1;
156 } 160 }
157 } 161 }
158 } 162 }
159 else 163 else
160 { 164 {
161 if (s->read_hash != NULL) 165 if (EVP_MD_CTX_md(s->read_hash))
162 n=EVP_MD_size(s->read_hash); 166 {
167 n=EVP_MD_CTX_size(s->read_hash);
168 if (n < 0)
169 return -1;
170 }
163 ds=s->enc_read_ctx; 171 ds=s->enc_read_ctx;
164 rec= &(s->s3->rrec); 172 rec= &(s->s3->rrec);
165 if (s->enc_read_ctx == NULL) 173 if (s->enc_read_ctx == NULL)
@@ -206,11 +214,10 @@ int dtls1_enc(SSL *s, int send)
206 { 214 {
207 unsigned long ui; 215 unsigned long ui;
208 printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n", 216 printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n",
209 (void *)ds,rec->data,rec->input,l); 217 ds,rec->data,rec->input,l);
210 printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%ld %ld], %d iv_len\n", 218 printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%d %d], %d iv_len\n",
211 ds->buf_len, ds->cipher->key_len, 219 ds->buf_len, ds->cipher->key_len,
212 (unsigned long)DES_KEY_SZ, 220 DES_KEY_SZ, DES_SCHEDULE_SZ,
213 (unsigned long)DES_SCHEDULE_SZ,
214 ds->cipher->iv_len); 221 ds->cipher->iv_len);
215 printf("\t\tIV: "); 222 printf("\t\tIV: ");
216 for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]); 223 for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]);
@@ -235,10 +242,10 @@ int dtls1_enc(SSL *s, int send)
235 242
236#ifdef KSSL_DEBUG 243#ifdef KSSL_DEBUG
237 { 244 {
238 unsigned long ki; 245 unsigned long i;
239 printf("\trec->data="); 246 printf("\trec->data=");
240 for (ki=0; ki<l; ki++) 247 for (i=0; i<l; i++)
241 printf(" %02x", rec->data[ki]); printf("\n"); 248 printf(" %02x", rec->data[i]); printf("\n");
242 } 249 }
243#endif /* KSSL_DEBUG */ 250#endif /* KSSL_DEBUG */
244 251