summaryrefslogtreecommitdiffstats
path: root/src/crypto/cipher/ciphers.c.in
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-02 13:23:12 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-02 13:23:12 +0100
commitf2c2f2926bce65c5c09d274c514d382ffd98f78c (patch)
tree582fa48dd067aebf851df20e765d114affc93528 /src/crypto/cipher/ciphers.c.in
parent20ee3b5a4f110f53a73746e18fc0eb0cbbb7845c (diff)
downloadfastd-f2c2f2926bce65c5c09d274c514d382ffd98f78c.tar
fastd-f2c2f2926bce65c5c09d274c514d382ffd98f78c.zip
Correctly handle ciphers without implementation
Diffstat (limited to 'src/crypto/cipher/ciphers.c.in')
-rw-r--r--src/crypto/cipher/ciphers.c.in17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/crypto/cipher/ciphers.c.in b/src/crypto/cipher/ciphers.c.in
index ee710f8..7ae2dea 100644
--- a/src/crypto/cipher/ciphers.c.in
+++ b/src/crypto/cipher/ciphers.c.in
@@ -77,8 +77,10 @@ void fastd_cipher_init(fastd_context_t *ctx) {
ctx->cipher_contexts = calloc(array_size(ciphers), sizeof(fastd_cipher_context_t*));
size_t i;
- for (i = 0; i < array_size(ciphers); i++)
- ctx->cipher_contexts[i] = ctx->conf->ciphers[i]->initialize(ctx);
+ for (i = 0; i < array_size(ciphers); i++) {
+ if (ctx->conf->ciphers[i])
+ ctx->cipher_contexts[i] = ctx->conf->ciphers[i]->initialize(ctx);
+ }
}
void fastd_cipher_free(fastd_context_t *ctx) {
@@ -89,15 +91,16 @@ void fastd_cipher_free(fastd_context_t *ctx) {
free(ctx->cipher_contexts);
}
-bool fastd_cipher_get_by_name(fastd_context_t *ctx, const char *name, const fastd_cipher_t **cipher, fastd_cipher_context_t **cctx) {
+const fastd_cipher_t* fastd_cipher_get_by_name(fastd_context_t *ctx, const char *name, fastd_cipher_context_t **cctx) {
size_t i;
for (i = 0; i < array_size(ciphers); i++) {
if (!strcmp(ciphers[i].name, name)) {
- *cipher = ctx->conf->ciphers[i];
- *cctx = ctx->cipher_contexts[i];
- return true;
+ if (cctx)
+ *cctx = ctx->cipher_contexts[i];
+
+ return ctx->conf->ciphers[i];
}
}
- return false;
+ return NULL;
}