From ee3abe04089cc0e253ab6cdffbf450e191b2bf41 Mon Sep 17 00:00:00 2001 From: Tseng Jun <6501202@qq.com> Date: Wed, 4 Mar 2020 03:57:21 +0800 Subject: [PATCH] openssl.c: minor changes of coding style (#454) File: openssl.c Notes: minor changes of coding style and align preprocessor conditional for #439 Credit: Tseng Jun --- src/openssl.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/openssl.c b/src/openssl.c index 2802217..9d3b8c7 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -433,12 +433,6 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx, return ret == 1 ? 0 : 1; } -#ifndef HAVE_EVP_AES_128_CTR -static EVP_CIPHER * aes_128_ctr_cipher = NULL; -static EVP_CIPHER * aes_192_ctr_cipher = NULL; -static EVP_CIPHER * aes_256_ctr_cipher = NULL; -#endif - #if LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR) #include @@ -451,6 +445,10 @@ typedef struct unsigned char ctr[AES_BLOCK_SIZE]; } aes_ctr_ctx; +static EVP_CIPHER * aes_128_ctr_cipher = NULL; +static EVP_CIPHER * aes_192_ctr_cipher = NULL; +static EVP_CIPHER * aes_256_ctr_cipher = NULL; + static int aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) /* init key */ @@ -642,7 +640,7 @@ _libssh2_EVP_aes_256_ctr(void) #endif } -#endif /* LIBSSH2_AES_CTR */ +#endif /* LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR) */ void _libssh2_openssl_crypto_init(void) { @@ -661,16 +659,16 @@ void _libssh2_openssl_crypto_init(void) ENGINE_register_all_complete(); #endif #endif -#ifndef HAVE_EVP_AES_128_CTR - aes_128_ctr_cipher = (EVP_CIPHER *) _libssh2_EVP_aes_128_ctr(); - aes_192_ctr_cipher = (EVP_CIPHER *) _libssh2_EVP_aes_192_ctr(); - aes_256_ctr_cipher = (EVP_CIPHER *) _libssh2_EVP_aes_256_ctr(); +#if LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR) + aes_128_ctr_cipher = (EVP_CIPHER *) _libssh2_EVP_aes_128_ctr(); + aes_192_ctr_cipher = (EVP_CIPHER *) _libssh2_EVP_aes_192_ctr(); + aes_256_ctr_cipher = (EVP_CIPHER *) _libssh2_EVP_aes_256_ctr(); #endif } void _libssh2_openssl_crypto_exit(void) { -#ifndef HAVE_EVP_AES_128_CTR +#if LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR) #ifdef HAVE_OPAQUE_STRUCTS if(aes_128_ctr_cipher) { EVP_CIPHER_meth_free(aes_128_ctr_cipher);