summaryrefslogtreecommitdiffstats
path: root/src/crypto/cipher
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-05-27 23:44:07 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-05-27 23:44:07 +0200
commitd859894f7a88e07e7beae8dc355278cfd6c185e2 (patch)
treea0de7e31e8e10dfab1f2b981348d6a11e95597d7 /src/crypto/cipher
parentb9f329256d5911d9694b44ce1e4545d78fdd5340 (diff)
downloadfastd-d859894f7a88e07e7beae8dc355278cfd6c185e2.tar
fastd-d859894f7a88e07e7beae8dc355278cfd6c185e2.zip
Remove fastd_true()
Diffstat (limited to 'src/crypto/cipher')
-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
5 files changed, 7 insertions, 11 deletions
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,