aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto.c
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-03-07 16:31:30 +0100
committerHans Nilsson <[email protected]>2017-03-09 15:27:18 +0100
commitf7610977cb2370e2bf54531ad7d6bcd051e6b27c (patch)
tree6e6a9c99a907928d9ca6a5a65fa9b5a0a1cec395 /lib/crypto/c_src/crypto.c
parentfcbcc330e733e62ae75c7748ae254e368ce97033 (diff)
downloadotp-f7610977cb2370e2bf54531ad7d6bcd051e6b27c.tar.gz
otp-f7610977cb2370e2bf54531ad7d6bcd051e6b27c.tar.bz2
otp-f7610977cb2370e2bf54531ad7d6bcd051e6b27c.zip
crypto: removed error function from PR and added error handling in crypto.erl
Diffstat (limited to 'lib/crypto/c_src/crypto.c')
-rw-r--r--lib/crypto/c_src/crypto.c35
1 files changed, 1 insertions, 34 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index ba011c3317..42cf7ac37b 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -42,7 +42,6 @@
#endif /* #ifndef OPENSSL_NO_DES */
/* #include <openssl/idea.h> This is not supported on the openssl OTP requires */
#include <openssl/dsa.h>
-#include <openssl/err.h>
#include <openssl/rsa.h>
#include <openssl/aes.h>
#include <openssl/md5.h>
@@ -500,7 +499,6 @@ static ERL_NIF_TERM atom_true;
static ERL_NIF_TERM atom_false;
static ERL_NIF_TERM atom_sha;
static ERL_NIF_TERM atom_error;
-static ERL_NIF_TERM atom_openssl;
static ERL_NIF_TERM atom_rsa_pkcs1_padding;
static ERL_NIF_TERM atom_rsa_pkcs1_oaep_padding;
static ERL_NIF_TERM atom_rsa_no_padding;
@@ -830,7 +828,6 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info)
atom_sha = enif_make_atom(env,"sha");
atom_error = enif_make_atom(env,"error");
- atom_openssl = enif_make_atom(env, "openssl"),
atom_rsa_pkcs1_padding = enif_make_atom(env,"rsa_pkcs1_padding");
atom_rsa_pkcs1_oaep_padding = enif_make_atom(env,"rsa_pkcs1_oaep_padding");
atom_rsa_no_padding = enif_make_atom(env,"rsa_no_padding");
@@ -918,8 +915,6 @@ static int initialize(ErlNifEnv* env, ERL_NIF_TERM load_info)
}
#endif /* OPENSSL_THREADS */
- ERR_load_crypto_strings();
-
return 0;
}
@@ -1673,34 +1668,6 @@ static ERL_NIF_TERM cmac_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]
#endif
}
-static ERL_NIF_TERM raise_openssl_error(ErlNifEnv* env)
-{
- ERL_NIF_TERM error_stack, error_triplet, error_tuple;
-
- error_stack = enif_make_list(env, 0);
- for(;;) {
- unsigned long next_error;
- const char *libname, *funcname, *reason;
-
- next_error = ERR_get_error();
- if (!next_error)
- break;
-
- libname = ERR_lib_error_string(next_error);
- funcname = ERR_func_error_string(next_error);
- reason = ERR_reason_error_string(next_error);
-
-#define TO_STRING(s) ((s)? enif_make_string(env, s, ERL_NIF_LATIN1) : atom_unknown)
- error_triplet = enif_make_tuple3(env, TO_STRING(libname), TO_STRING(funcname), TO_STRING(reason));
-#undef TO_STRING
-
- error_stack = enif_make_list_cell(env, error_triplet, error_stack);
- }
-
- error_tuple = enif_make_tuple2(env, atom_openssl, error_stack);
- return enif_raise_exception(env, enif_make_tuple2(env, atom_error, error_tuple));
-}
-
static ERL_NIF_TERM block_crypt_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{/* (Type, Key, Ivec, Text, IsEncrypt) or (Type, Key, Text, IsEncrypt) */
struct cipher_type_t *cipherp = NULL;
@@ -2982,7 +2949,7 @@ static ERL_NIF_TERM rsa_generate_key(ErlNifEnv* env, int argc, const ERL_NIF_TER
if (!success) {
RSA_free(rsa);
- return raise_openssl_error(env);
+ return atom_error;
}
result = put_rsa_private_key(env, rsa);