diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-05-27 23:44:07 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-05-27 23:44:07 +0200 |
commit | d859894f7a88e07e7beae8dc355278cfd6c185e2 (patch) | |
tree | a0de7e31e8e10dfab1f2b981348d6a11e95597d7 /src/crypto | |
parent | b9f329256d5911d9694b44ce1e4545d78fdd5340 (diff) | |
download | fastd-d859894f7a88e07e7beae8dc355278cfd6c185e2.tar fastd-d859894f7a88e07e7beae8dc355278cfd6c185e2.zip |
Remove fastd_true()
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c | 2 | ||||
-rw-r--r-- | src/crypto/cipher/ciphers.c.in | 10 | ||||
-rw-r--r-- | src/crypto/cipher/null/memcpy/null_memcpy.c | 2 | ||||
-rw-r--r-- | src/crypto/cipher/salsa20/nacl/salsa20_nacl.c | 2 | ||||
-rw-r--r-- | src/crypto/cipher/salsa2012/nacl/salsa2012_nacl.c | 2 | ||||
-rw-r--r-- | src/crypto/mac/ghash/builtin/ghash_builtin.c | 2 | ||||
-rw-r--r-- | src/crypto/mac/macs.c.in | 10 |
7 files changed, 14 insertions, 16 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, 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; } |