diff options
author | Dirkjan Bussink <d.bussink@gmail.com> | 2020-12-22 19:32:45 +0100 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2021-01-11 10:45:22 +0100 |
commit | a1e8c985d1f1da0561a155d46a580b0b732e727c (patch) | |
tree | 1add208296d4eb1bc4e504b524ed14a41317c44e /src | |
parent | da36ecd6f25027c8767cd1132229450d699bd49f (diff) | |
download | libssh-a1e8c985d1f1da0561a155d46a580b0b732e727c.tar.gz libssh-a1e8c985d1f1da0561a155d46a580b0b732e727c.tar.xz libssh-a1e8c985d1f1da0561a155d46a580b0b732e727c.zip |
Remove compat reset function
This can be implemented with the init directly when the context is
reused. When a new cipher context is allocated, no initialization call
is needed either so this moves the logic to one place as well.
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcrypto-compat.c | 6 | ||||
-rw-r--r-- | src/libcrypto-compat.h | 2 | ||||
-rw-r--r-- | src/libcrypto.c | 4 |
3 files changed, 2 insertions, 10 deletions
diff --git a/src/libcrypto-compat.c b/src/libcrypto-compat.c index 12051c85..8700a9b5 100644 --- a/src/libcrypto-compat.c +++ b/src/libcrypto-compat.c @@ -236,12 +236,6 @@ void EVP_MD_CTX_free(EVP_MD_CTX *ctx) OPENSSL_free(ctx); } -int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx) -{ - EVP_CIPHER_CTX_init(ctx); - return 1; -} - #ifndef HAVE_OPENSSL_EVP_CIPHER_CTX_NEW EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void) { diff --git a/src/libcrypto-compat.h b/src/libcrypto-compat.h index c584ed25..437b0534 100644 --- a/src/libcrypto-compat.h +++ b/src/libcrypto-compat.h @@ -33,8 +33,6 @@ int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); EVP_MD_CTX *EVP_MD_CTX_new(void); void EVP_MD_CTX_free(EVP_MD_CTX *ctx); -int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx); - void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); diff --git a/src/libcrypto.c b/src/libcrypto.c index a9fecbe4..b2d5fc93 100644 --- a/src/libcrypto.c +++ b/src/libcrypto.c @@ -482,6 +482,8 @@ static void evp_cipher_init(struct ssh_cipher_struct *cipher) { if (cipher->ctx == NULL) { cipher->ctx = EVP_CIPHER_CTX_new(); + } else { + EVP_CIPHER_CTX_init(cipher->ctx); } switch(cipher->ciphertype){ @@ -548,7 +550,6 @@ static int evp_cipher_set_encrypt_key(struct ssh_cipher_struct *cipher, int rc; evp_cipher_init(cipher); - EVP_CIPHER_CTX_reset(cipher->ctx); rc = EVP_EncryptInit_ex(cipher->ctx, cipher->cipher, NULL, key, IV); if (rc != 1){ @@ -581,7 +582,6 @@ static int evp_cipher_set_decrypt_key(struct ssh_cipher_struct *cipher, int rc; evp_cipher_init(cipher); - EVP_CIPHER_CTX_reset(cipher->ctx); rc = EVP_DecryptInit_ex(cipher->ctx, cipher->cipher, NULL, key, IV); if (rc != 1){ |