summaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 22:15:58 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 22:15:58 +0100
commitd0707b161d10cf79242d40b24853988c89c7604a (patch)
tree2d7ebb6082708f49c17ec6385f6019b83be0dda6 /src/crypto
parent27c14deaedc8f914e82388e41e61e8adbfd13f35 (diff)
downloadfastd-d0707b161d10cf79242d40b24853988c89c7604a.tar
fastd-d0707b161d10cf79242d40b24853988c89c7604a.zip
crypto: separate cipher/MAC availability check from information request
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/cipher/ciphers.c.in14
-rw-r--r--src/crypto/mac/macs.c.in14
2 files changed, 24 insertions, 4 deletions
diff --git a/src/crypto/cipher/ciphers.c.in b/src/crypto/cipher/ciphers.c.in
index b3c6b1b..84607a0 100644
--- a/src/crypto/cipher/ciphers.c.in
+++ b/src/crypto/cipher/ciphers.c.in
@@ -107,7 +107,7 @@ void fastd_cipher_free(fastd_context_t *ctx) {
free(ctx->cipher_contexts);
}
-const fastd_cipher_info_t* fastd_cipher_info_get_by_name(const char *name) {
+bool fastd_cipher_is_available(const char *name) {
size_t i, j;
for (i = 0; i < array_size(ciphers); i++) {
if (strcmp(ciphers[i].name, name))
@@ -115,12 +115,22 @@ const fastd_cipher_info_t* fastd_cipher_info_get_by_name(const char *name) {
for (j = 0; ciphers[i].impls[j].impl; j++) {
if (ciphers[i].impls[j].impl->available())
- return ciphers[i].info;
+ return true;
}
break;
}
+ return false;
+}
+
+const fastd_cipher_info_t* fastd_cipher_info_get_by_name(const char *name) {
+ size_t i, j;
+ for (i = 0; i < array_size(ciphers); i++) {
+ if (!strcmp(ciphers[i].name, name))
+ return ciphers[i].info;
+ }
+
return NULL;
}
diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in
index 3587322..c38e190 100644
--- a/src/crypto/mac/macs.c.in
+++ b/src/crypto/mac/macs.c.in
@@ -107,7 +107,7 @@ void fastd_mac_free(fastd_context_t *ctx) {
free(ctx->mac_contexts);
}
-const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) {
+bool fastd_mac_is_available(const char *name) {
size_t i, j;
for (i = 0; i < array_size(macs); i++) {
if (strcmp(macs[i].name, name))
@@ -115,12 +115,22 @@ const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) {
for (j = 0; macs[i].impls[j].impl; j++) {
if (macs[i].impls[j].impl->available())
- return macs[i].info;
+ return true;
}
break;
}
+ return false;
+}
+
+const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) {
+ size_t i, j;
+ for (i = 0; i < array_size(macs); i++) {
+ if (!strcmp(macs[i].name, name))
+ return macs[i].info;
+ }
+
return NULL;
}