summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
Diffstat (limited to 'cipher.c')
-rw-r--r--cipher.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/cipher.c b/cipher.c
index c3cd5dcf4..578763616 100644
--- a/cipher.c
+++ b/cipher.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher.c,v 1.107 2017/05/07 23:12:57 djm Exp $ */ 1/* $OpenBSD: cipher.c,v 1.111 2018/02/23 15:58:37 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -310,8 +310,7 @@ cipher_init(struct sshcipher_ctx **ccp, const struct sshcipher *cipher,
310 } else { 310 } else {
311 if (cc != NULL) { 311 if (cc != NULL) {
312#ifdef WITH_OPENSSL 312#ifdef WITH_OPENSSL
313 if (cc->evp != NULL) 313 EVP_CIPHER_CTX_free(cc->evp);
314 EVP_CIPHER_CTX_free(cc->evp);
315#endif /* WITH_OPENSSL */ 314#endif /* WITH_OPENSSL */
316 explicit_bzero(cc, sizeof(*cc)); 315 explicit_bzero(cc, sizeof(*cc));
317 free(cc); 316 free(cc);
@@ -402,7 +401,7 @@ cipher_get_length(struct sshcipher_ctx *cc, u_int *plenp, u_int seqnr,
402 cp, len); 401 cp, len);
403 if (len < 4) 402 if (len < 4)
404 return SSH_ERR_MESSAGE_INCOMPLETE; 403 return SSH_ERR_MESSAGE_INCOMPLETE;
405 *plenp = get_u32(cp); 404 *plenp = PEEK_U32(cp);
406 return 0; 405 return 0;
407} 406}
408 407
@@ -416,10 +415,8 @@ cipher_free(struct sshcipher_ctx *cc)
416 else if ((cc->cipher->flags & CFLAG_AESCTR) != 0) 415 else if ((cc->cipher->flags & CFLAG_AESCTR) != 0)
417 explicit_bzero(&cc->ac_ctx, sizeof(cc->ac_ctx)); 416 explicit_bzero(&cc->ac_ctx, sizeof(cc->ac_ctx));
418#ifdef WITH_OPENSSL 417#ifdef WITH_OPENSSL
419 if (cc->evp != NULL) { 418 EVP_CIPHER_CTX_free(cc->evp);
420 EVP_CIPHER_CTX_free(cc->evp); 419 cc->evp = NULL;
421 cc->evp = NULL;
422 }
423#endif 420#endif
424 explicit_bzero(cc, sizeof(*cc)); 421 explicit_bzero(cc, sizeof(*cc));
425 free(cc); 422 free(cc);
@@ -449,9 +446,9 @@ cipher_get_keyiv_len(const struct sshcipher_ctx *cc)
449int 446int
450cipher_get_keyiv(struct sshcipher_ctx *cc, u_char *iv, u_int len) 447cipher_get_keyiv(struct sshcipher_ctx *cc, u_char *iv, u_int len)
451{ 448{
452 const struct sshcipher *c = cc->cipher;
453#ifdef WITH_OPENSSL 449#ifdef WITH_OPENSSL
454 int evplen; 450 const struct sshcipher *c = cc->cipher;
451 int evplen;
455#endif 452#endif
456 453
457 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) { 454 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) {
@@ -494,9 +491,9 @@ cipher_get_keyiv(struct sshcipher_ctx *cc, u_char *iv, u_int len)
494int 491int
495cipher_set_keyiv(struct sshcipher_ctx *cc, const u_char *iv) 492cipher_set_keyiv(struct sshcipher_ctx *cc, const u_char *iv)
496{ 493{
497 const struct sshcipher *c = cc->cipher;
498#ifdef WITH_OPENSSL 494#ifdef WITH_OPENSSL
499 int evplen = 0; 495 const struct sshcipher *c = cc->cipher;
496 int evplen = 0;
500#endif 497#endif
501 498
502 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0) 499 if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)