diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-25 23:18:11 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-25 23:18:11 +0100 |
commit | c62a0f592c49b41d393fae580ce9f1293ee7a16d (patch) | |
tree | 6d8ef6b7c93fdcaa0fd1bcd590dba531ef8b5140 /src/crypto/mac/macs.c.in | |
parent | 60c2c11de820687887a643344fc1b0a91fd45226 (diff) | |
download | fastd-c62a0f592c49b41d393fae580ce9f1293ee7a16d.tar fastd-c62a0f592c49b41d393fae580ce9f1293ee7a16d.zip |
Move crypto algorithm information out of implementation
Diffstat (limited to 'src/crypto/mac/macs.c.in')
-rw-r--r-- | src/crypto/mac/macs.c.in | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in index 43031ee..9952396 100644 --- a/src/crypto/mac/macs.c.in +++ b/src/crypto/mac/macs.c.in @@ -30,14 +30,20 @@ @MAC_DEFINITIONS@ -typedef struct mac_impl_list { +typedef struct fastd_mac_impl { const char *name; - const fastd_mac_t *const *impls; -} mac_impl_list_t; + const fastd_mac_t *impl; +} fastd_mac_impl_t; + +typedef struct mac_entry { + const char *name; + const fastd_mac_info_t *info; + const fastd_mac_impl_t *impls; +} mac_entry_t; @MAC_IMPLS@ -static const mac_impl_list_t macs[] = { @MAC_LIST@ +static const mac_entry_t macs[] = { @MAC_LIST@ }; @@ -46,7 +52,7 @@ const fastd_mac_t** fastd_mac_config_alloc(void) { size_t i; for (i = 0; i < array_size(macs); i++) - mac_conf[i] = macs[i].impls[0]; + mac_conf[i] = macs[i].impls[0].impl; return mac_conf; } @@ -60,9 +66,9 @@ bool fastd_mac_config(const fastd_mac_t **mac_conf, const char *name, const char for (i = 0; i < array_size(macs); i++) { if (!strcmp(macs[i].name, name)) { size_t j; - for (j = 0; macs[i].impls[j]; j++) { - if (!strcmp(macs[i].impls[j]->name, impl)) { - mac_conf[i] = macs[i].impls[j]; + for (j = 0; macs[i].impls[j].impl; j++) { + if (!strcmp(macs[i].impls[j].name, impl)) { + mac_conf[i] = macs[i].impls[j].impl; return true; } } @@ -92,20 +98,28 @@ void fastd_mac_free(fastd_context_t *ctx) { free(ctx->mac_contexts); } -bool fastd_mac_available(const char *name) { +const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) { size_t i; for (i = 0; i < array_size(macs); i++) { - if (!strcmp(macs[i].name, name)) - return macs[i].impls[0]; + if (strcmp(macs[i].name, name)) + continue; + + if (!macs[i].impls[0].impl) + continue; + + return macs[i].info; } - return false; + return NULL; } -const fastd_mac_t* fastd_mac_get_by_name(fastd_context_t *ctx, const char *name, const fastd_mac_context_t **cctx) { +const fastd_mac_t* fastd_mac_get_by_name(fastd_context_t *ctx, const char *name, const fastd_mac_info_t **info, const fastd_mac_context_t **cctx) { size_t i; for (i = 0; i < array_size(macs); i++) { if (!strcmp(macs[i].name, name)) { + if (info) + *info = macs[i].info; + if (cctx) *cctx = ctx->mac_contexts[i]; |