diff options
author | Tobias Brunner <tobias@strongswan.org> | 2016-06-27 11:17:56 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2016-06-29 11:09:37 +0200 |
commit | 1b36fbedf5707ea4318ae9216d3c65aebe1917da (patch) | |
tree | 8d3d94e36c0745dbd25b34b35769db5eaf69abcf /src/libstrongswan/plugins/openssl | |
parent | faa904fb0baa1bd805432634f921fda6ce96b284 (diff) | |
download | strongswan-1b36fbedf5707ea4318ae9216d3c65aebe1917da.tar.bz2 strongswan-1b36fbedf5707ea4318ae9216d3c65aebe1917da.tar.xz |
openssl: Update crypter API to OpenSSL 1.1.0
EVP_CIPHER and EVP_CIPHER_CTX are now opaque types, the getters already
existed before.
Diffstat (limited to 'src/libstrongswan/plugins/openssl')
-rw-r--r-- | src/libstrongswan/plugins/openssl/openssl_crypter.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_crypter.c b/src/libstrongswan/plugins/openssl/openssl_crypter.c index 72a9ad92a..b9085f9aa 100644 --- a/src/libstrongswan/plugins/openssl/openssl_crypter.c +++ b/src/libstrongswan/plugins/openssl/openssl_crypter.c @@ -93,8 +93,10 @@ static char* lookup_algorithm(uint16_t ikev2_algo, size_t *key_size) static bool crypt(private_openssl_crypter_t *this, chunk_t data, chunk_t iv, chunk_t *dst, int enc) { + EVP_CIPHER_CTX *ctx; int len; u_char *out; + bool success = FALSE; out = data.ptr; if (dst) @@ -102,16 +104,19 @@ static bool crypt(private_openssl_crypter_t *this, chunk_t data, chunk_t iv, *dst = chunk_alloc(data.len); out = dst->ptr; } - EVP_CIPHER_CTX ctx; - EVP_CIPHER_CTX_init(&ctx); - return EVP_CipherInit_ex(&ctx, this->cipher, NULL, NULL, NULL, enc) && - EVP_CIPHER_CTX_set_padding(&ctx, 0) /* disable padding */ && - EVP_CIPHER_CTX_set_key_length(&ctx, this->key.len) && - EVP_CipherInit_ex(&ctx, NULL, NULL, this->key.ptr, iv.ptr, enc) && - EVP_CipherUpdate(&ctx, out, &len, data.ptr, data.len) && - /* since padding is disabled this does nothing */ - EVP_CipherFinal_ex(&ctx, out + len, &len) && - EVP_CIPHER_CTX_cleanup(&ctx); + ctx = EVP_CIPHER_CTX_new(); + if (EVP_CipherInit_ex(ctx, this->cipher, NULL, NULL, NULL, enc) && + EVP_CIPHER_CTX_set_padding(ctx, 0) /* disable padding */ && + EVP_CIPHER_CTX_set_key_length(ctx, this->key.len) && + EVP_CipherInit_ex(ctx, NULL, NULL, this->key.ptr, iv.ptr, enc) && + EVP_CipherUpdate(ctx, out, &len, data.ptr, data.len) && + /* since padding is disabled this does nothing */ + EVP_CipherFinal_ex(ctx, out + len, &len)) + { + success = TRUE; + } + EVP_CIPHER_CTX_free(ctx); + return success; } METHOD(crypter_t, decrypt, bool, @@ -129,13 +134,13 @@ METHOD(crypter_t, encrypt, bool, METHOD(crypter_t, get_block_size, size_t, private_openssl_crypter_t *this) { - return this->cipher->block_size; + return EVP_CIPHER_block_size(this->cipher); } METHOD(crypter_t, get_iv_size, size_t, private_openssl_crypter_t *this) { - return this->cipher->iv_len; + return EVP_CIPHER_iv_length(this->cipher); } METHOD(crypter_t, get_key_size, size_t, |