From 8088a82a2a91d29967cef920ba780eecdf72518e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 30 Nov 2013 03:19:38 +0100 Subject: Perform string-based lookup of method-related information only once --- src/crypto/cipher/ciphers.c.in | 8 ++------ src/crypto/mac/macs.c.in | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src/crypto') diff --git a/src/crypto/cipher/ciphers.c.in b/src/crypto/cipher/ciphers.c.in index 72ea3d2..cdc9911 100644 --- a/src/crypto/cipher/ciphers.c.in +++ b/src/crypto/cipher/ciphers.c.in @@ -106,15 +106,11 @@ const fastd_cipher_info_t* fastd_cipher_info_get_by_name(const char *name) { return NULL; } -const fastd_cipher_t* fastd_cipher_get_by_name(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **info) { +const fastd_cipher_t* fastd_cipher_get(fastd_context_t *ctx, const fastd_cipher_info_t *info) { size_t i; for (i = 0; i < array_size(ciphers); i++) { - if (!strcmp(ciphers[i].name, name)) { - if (info) - *info = ciphers[i].info; - + if (ciphers[i].info == info) return ctx->conf->ciphers[i]; - } } return NULL; diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in index c70473b..ee64362 100644 --- a/src/crypto/mac/macs.c.in +++ b/src/crypto/mac/macs.c.in @@ -106,15 +106,11 @@ const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) { return NULL; } -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_t* fastd_mac_get(fastd_context_t *ctx, const fastd_mac_info_t *info) { size_t i; for (i = 0; i < array_size(macs); i++) { - if (!strcmp(macs[i].name, name)) { - if (info) - *info = macs[i].info; - + if (macs[i].info == info) return ctx->conf->macs[i]; - } } return NULL; -- cgit v1.2.3