summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/crypto.h4
-rw-r--r--src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c2
-rw-r--r--src/crypto/cipher/ciphers.c.in10
-rw-r--r--src/crypto/cipher/null/memcpy/null_memcpy.c2
-rw-r--r--src/crypto/cipher/salsa20/nacl/salsa20_nacl.c2
-rw-r--r--src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c2
-rw-r--r--src/crypto/mac/ghash/builtin/ghash_builtin.c2
-rw-r--r--src/crypto/mac/macs.c.in10
8 files changed, 14 insertions, 20 deletions
diff --git a/src/crypto.h b/src/crypto.h
index a228f5a..fbb77ec 100644
--- a/src/crypto.h
+++ b/src/crypto.h
@@ -93,7 +93,3 @@ static inline void xor(fastd_block128_t *x, const fastd_block128_t *a, const fas
static inline void xor_a(fastd_block128_t *x, const fastd_block128_t *a) {
xor(x, x, a);
}
-
-static inline bool fastd_true(void) {
- return true;
-}
diff --git a/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c b/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c
index c5d6200..793b724 100644
--- a/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c
+++ b/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c
@@ -60,8 +60,6 @@ static void aes128_ctr_free(fastd_cipher_state_t *state) {
}
const fastd_cipher_t fastd_cipher_aes128_ctr_nacl = {
- .available = fastd_true,
-
.init = aes128_ctr_init,
.crypt = aes128_ctr_crypt,
.free = aes128_ctr_free,
diff --git a/src/crypto/cipher/ciphers.c.in b/src/crypto/cipher/ciphers.c.in
index 2140731..1796cc5 100644
--- a/src/crypto/cipher/ciphers.c.in
+++ b/src/crypto/cipher/ciphers.c.in
@@ -47,13 +47,17 @@ static const cipher_entry_t ciphers[] = { @CIPHER_LIST@
};
+static inline bool cipher_available(const fastd_cipher_t *cipher) {
+ return (!cipher->available) || cipher->available();
+}
+
const fastd_cipher_t** fastd_cipher_config_alloc(void) {
const fastd_cipher_t **cipher_conf = calloc(array_size(ciphers), sizeof(const fastd_cipher_t*));
size_t i, j;
for (i = 0; i < array_size(ciphers); i++) {
for (j = 0; ciphers[i].impls[j].impl; j++) {
- if (ciphers[i].impls[j].impl->available())
+ if (cipher_available(ciphers[i].impls[j].impl))
break;
}
@@ -74,7 +78,7 @@ bool fastd_cipher_config(const fastd_cipher_t **cipher_conf, const char *name, c
size_t j;
for (j = 0; ciphers[i].impls[j].impl; j++) {
if (!strcmp(ciphers[i].impls[j].name, impl)) {
- if (!ciphers[i].impls[j].impl->available())
+ if (!cipher_available(ciphers[i].impls[j].impl))
return false;
cipher_conf[i] = ciphers[i].impls[j].impl;
@@ -96,7 +100,7 @@ const fastd_cipher_info_t* fastd_cipher_info_get_by_name(const char *name) {
continue;
for (j = 0; ciphers[i].impls[j].impl; j++) {
- if (ciphers[i].impls[j].impl->available())
+ if (cipher_available(ciphers[i].impls[j].impl))
return ciphers[i].info;
}
diff --git a/src/crypto/cipher/null/memcpy/null_memcpy.c b/src/crypto/cipher/null/memcpy/null_memcpy.c
index 767e06c..a2c0df9 100644
--- a/src/crypto/cipher/null/memcpy/null_memcpy.c
+++ b/src/crypto/cipher/null/memcpy/null_memcpy.c
@@ -40,8 +40,6 @@ static void null_free(fastd_cipher_state_t *state UNUSED) {
}
const fastd_cipher_t fastd_cipher_null_memcpy = {
- .available = fastd_true,
-
.init = null_init,
.crypt = null_memcpy,
.free = null_free,
diff --git a/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c b/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c
index 10f2fe8..03ab1d9 100644
--- a/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c
+++ b/src/crypto/cipher/salsa20/nacl/salsa20_nacl.c
@@ -54,8 +54,6 @@ static void salsa20_free(fastd_cipher_state_t *state) {
}
const fastd_cipher_t fastd_cipher_salsa20_nacl = {
- .available = fastd_true,
-
.init = salsa20_init,
.crypt = salsa20_crypt,
.free = salsa20_free,
diff --git a/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c b/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
index 8f456ec..efe7089 100644
--- a/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
+++ b/src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c
@@ -54,8 +54,6 @@ static void salsa2012_free(fastd_cipher_state_t *state) {
}
const fastd_cipher_t fastd_cipher_salsa2012_nacl = {
- .available = fastd_true,
-
.init = salsa2012_init,
.crypt = salsa2012_crypt,
.free = salsa2012_free,
diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c
index 2819109..28e9292 100644
--- a/src/crypto/mac/ghash/builtin/ghash_builtin.c
+++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c
@@ -127,8 +127,6 @@ static void ghash_free(fastd_mac_state_t *state) {
}
const fastd_mac_t fastd_mac_ghash_builtin = {
- .available = fastd_true,
-
.init = ghash_init,
.hash = ghash_hash,
.free = ghash_free,
diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in
index ccf560e..3a8c943 100644
--- a/src/crypto/mac/macs.c.in
+++ b/src/crypto/mac/macs.c.in
@@ -47,13 +47,17 @@ static const mac_entry_t macs[] = { @MAC_LIST@
};
+static inline bool mac_available(const fastd_mac_t *mac) {
+ return (!mac->available) || mac->available();
+}
+
const fastd_mac_t** fastd_mac_config_alloc(void) {
const fastd_mac_t **mac_conf = calloc(array_size(macs), sizeof(const fastd_mac_t*));
size_t i, j;
for (i = 0; i < array_size(macs); i++) {
for (j = 0; macs[i].impls[j].impl; j++) {
- if (macs[i].impls[j].impl->available())
+ if (mac_available(macs[i].impls[j].impl))
break;
}
@@ -74,7 +78,7 @@ bool fastd_mac_config(const fastd_mac_t **mac_conf, const char *name, const char
size_t j;
for (j = 0; macs[i].impls[j].impl; j++) {
if (!strcmp(macs[i].impls[j].name, impl)) {
- if (!macs[i].impls[j].impl->available())
+ if (!mac_available(macs[i].impls[j].impl))
return false;
mac_conf[i] = macs[i].impls[j].impl;
@@ -96,7 +100,7 @@ const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) {
continue;
for (j = 0; macs[i].impls[j].impl; j++) {
- if (macs[i].impls[j].impl->available())
+ if (mac_available(macs[i].impls[j].impl))
return macs[i].info;
}