aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/algorithms.c
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-06-14 13:33:55 +0200
committerHans Nilsson <[email protected]>2019-06-14 13:33:55 +0200
commitbfc7e7aab9d08d0fc34a7ba85b3928af5f6578c6 (patch)
treefe17531cde30a1b8303e5585b67e51e29c154005 /lib/crypto/c_src/algorithms.c
parentd5a0aaf4ee45f9c046ca6e8a7f16e51079037990 (diff)
parent511480bd35d03a52062ac340f49b5149d3dce507 (diff)
downloadotp-bfc7e7aab9d08d0fc34a7ba85b3928af5f6578c6.tar.gz
otp-bfc7e7aab9d08d0fc34a7ba85b3928af5f6578c6.tar.bz2
otp-bfc7e7aab9d08d0fc34a7ba85b3928af5f6578c6.zip
Merge branch 'hans/crypto/unified_xMAC/OTP-13872' into maint
* hans/crypto/unified_xMAC/OTP-13872: crypto: Documentation crypto: Enable MAC key length checking in mac-table crypto: Renaming, typing and some polishing crypto: Begin test of the new mac interface directly. crypto: Move mac compatibility functions to hmac.c and cmac.c crypto: Move functions around for better readability crypto: White space removed at line ends crypto: Use dirty schedulers for mac_update crypto: Implement NIFs for the new mac_init, mac_update and mac_final crypto: Use new mac_nif for hmac, cmac and poly1305 crypto: Refactor for readability crypto: Use dirty schedulers for the new mac_nif if large data crypto: MAC nif unifying HMAC, CMAC and POLY1305 crypto: Re-structure cmac and hmac test vector handling crypto: Enable CMAC tests for aes-128-cbc and aes-256-cbc crypto: Remove warnings when linking with LibreSSL
Diffstat (limited to 'lib/crypto/c_src/algorithms.c')
-rw-r--r--lib/crypto/c_src/algorithms.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/lib/crypto/c_src/algorithms.c b/lib/crypto/c_src/algorithms.c
index 75cddeb1e9..53b8b7eaa9 100644
--- a/lib/crypto/c_src/algorithms.c
+++ b/lib/crypto/c_src/algorithms.c
@@ -20,13 +20,12 @@
#include "algorithms.h"
#include "cipher.h"
+#include "mac.h"
static unsigned int algo_hash_cnt, algo_hash_fips_cnt;
static ERL_NIF_TERM algo_hash[14]; /* increase when extending the list */
static unsigned int algo_pubkey_cnt, algo_pubkey_fips_cnt;
static ERL_NIF_TERM algo_pubkey[12]; /* increase when extending the list */
-static unsigned int algo_mac_cnt, algo_mac_fips_cnt;
-static ERL_NIF_TERM algo_mac[3]; /* increase when extending the list */
static unsigned int algo_curve_cnt, algo_curve_fips_cnt;
static ERL_NIF_TERM algo_curve[89]; /* increase when extending the list */
static unsigned int algo_rsa_opts_cnt, algo_rsa_opts_fips_cnt;
@@ -101,19 +100,6 @@ void init_algorithms_types(ErlNifEnv* env)
#endif
algo_pubkey[algo_pubkey_cnt++] = enif_make_atom(env, "srp");
-
- // Validated algorithms first
- algo_mac_cnt = 0;
- algo_mac[algo_mac_cnt++] = enif_make_atom(env,"hmac");
-#ifdef HAVE_CMAC
- algo_mac[algo_mac_cnt++] = enif_make_atom(env,"cmac");
-#endif
-#ifdef HAVE_POLY1305
- algo_mac[algo_mac_cnt++] = enif_make_atom(env,"poly1305");
-#endif
- // Non-validated algorithms follow
- algo_mac_fips_cnt = algo_mac_cnt;
-
// Validated algorithms first
algo_curve_cnt = 0;
#if defined(HAVE_EC)
@@ -250,7 +236,6 @@ void init_algorithms_types(ErlNifEnv* env)
// Check that the max number of algos is updated
ASSERT(algo_hash_cnt <= sizeof(algo_hash)/sizeof(ERL_NIF_TERM));
ASSERT(algo_pubkey_cnt <= sizeof(algo_pubkey)/sizeof(ERL_NIF_TERM));
- ASSERT(algo_mac_cnt <= sizeof(algo_mac)/sizeof(ERL_NIF_TERM));
ASSERT(algo_curve_cnt <= sizeof(algo_curve)/sizeof(ERL_NIF_TERM));
ASSERT(algo_rsa_opts_cnt <= sizeof(algo_rsa_opts)/sizeof(ERL_NIF_TERM));
}
@@ -284,18 +269,12 @@ ERL_NIF_TERM cipher_algorithms(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv
return cipher_types_as_list(env); /* Exclude old api ciphers */
}
+
ERL_NIF_TERM mac_algorithms(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
- unsigned int cnt =
-#ifdef FIPS_SUPPORT
- FIPS_mode() ? algo_mac_fips_cnt :
-#endif
- algo_mac_cnt;
-
- return enif_make_list_from_array(env, algo_mac, cnt);
+ return mac_types_as_list(env);
}
-
ERL_NIF_TERM curve_algorithms(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
unsigned int cnt =