diff options
author | Hans Nilsson <[email protected]> | 2019-03-13 16:16:36 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2019-03-19 12:45:56 +0100 |
commit | 7281dd92eb48280c25a8342547d70c867f6d731a (patch) | |
tree | 54e3180261c790372b912701dc2886c72dc33317 | |
parent | 27882b21c33396135ff7789cc14cc782c0c0e318 (diff) | |
download | otp-7281dd92eb48280c25a8342547d70c867f6d731a.tar.gz otp-7281dd92eb48280c25a8342547d70c867f6d731a.tar.bz2 otp-7281dd92eb48280c25a8342547d70c867f6d731a.zip |
crypto: Better error descriptions
-rw-r--r-- | lib/crypto/c_src/api_ng.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c index 393fee31ef..2823b2714b 100644 --- a/lib/crypto/c_src/api_ng.c +++ b/lib/crypto/c_src/api_ng.c @@ -98,7 +98,10 @@ static int get_init_args(ErlNifEnv* env, if (!(*cipherp = get_cipher_type(cipher_arg, key_bin.size))) { - *return_term = EXCP_BADARG(env, "Unknown cipher or bad key size for the cipher"); + if (!get_cipher_type_no_key(cipher_arg)) + *return_term = EXCP_BADARG(env, "Unknown cipher"); + else + *return_term = EXCP_BADARG(env, "Bad key size"); goto err; } @@ -122,14 +125,14 @@ static int get_init_args(ErlNifEnv* env, ivec_len = 16; else { /* Unsupported crypto */ - *return_term = EXCP_NOTSUP(env, "Unsupported cipher"); + *return_term = EXCP_NOTSUP(env, "Cipher not supported in this libcrypto version"); goto err; } } #else /* Normal code */ if (!((*cipherp)->cipher.p)) { - *return_term = EXCP_NOTSUP(env, "Unsupported cipher"); + *return_term = EXCP_NOTSUP(env, "Cipher not supported in this libcrypto version"); goto err; } ivec_len = GET_IV_LEN(*cipherp); |