diff options
author | Doug Hogan <[email protected]> | 2018-12-21 07:58:02 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2018-12-21 08:40:50 -0800 |
commit | c1eb6e52b503fdcb7f69052e69b392ea6df3bdab (patch) | |
tree | 9004d38a476deb9884b26cf1fb8243b8a26b5417 /lib/crypto/c_src/cipher.c | |
parent | bd3c0fac624c6b31ccbb8d72ae4ced958a40ddee (diff) | |
download | otp-c1eb6e52b503fdcb7f69052e69b392ea6df3bdab.tar.gz otp-c1eb6e52b503fdcb7f69052e69b392ea6df3bdab.tar.bz2 otp-c1eb6e52b503fdcb7f69052e69b392ea6df3bdab.zip |
Make cipher ctx init internal to cipher.c per PR feedback
Diffstat (limited to 'lib/crypto/c_src/cipher.c')
-rw-r--r-- | lib/crypto/c_src/cipher.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/crypto/c_src/cipher.c b/lib/crypto/c_src/cipher.c index 6eba6aa49b..6580cb183f 100644 --- a/lib/crypto/c_src/cipher.c +++ b/lib/crypto/c_src/cipher.c @@ -73,11 +73,26 @@ static struct cipher_type_t cipher_types[] = #ifdef HAVE_EVP_AES_CTR ErlNifResourceType* evp_cipher_ctx_rtype; -void evp_cipher_ctx_dtor(ErlNifEnv* env, struct evp_cipher_ctx* ctx) { +static void evp_cipher_ctx_dtor(ErlNifEnv* env, struct evp_cipher_ctx* ctx) { EVP_CIPHER_CTX_free(ctx->ctx); } #endif +int init_cipher_ctx(ErlNifEnv *env) { +#ifdef HAVE_EVP_AES_CTR + evp_cipher_ctx_rtype = enif_open_resource_type(env, NULL, "EVP_CIPHER_CTX", + (ErlNifResourceDtor*) evp_cipher_ctx_dtor, + ERL_NIF_RT_CREATE|ERL_NIF_RT_TAKEOVER, + NULL); + if (evp_cipher_ctx_rtype == NULL) { + PRINTF_ERR0("CRYPTO: Could not open resource type 'EVP_CIPHER_CTX'"); + return 0; + } +#endif + + return 1; +} + void init_cipher_types(ErlNifEnv* env) { struct cipher_type_t* p = cipher_types; |