summaryrefslogtreecommitdiffstats
path: root/src/methods/generic_poly1305
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 22:24:02 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 22:24:02 +0100
commita09d04a02231964fa5a8f0113e9909cfb140fe4e (patch)
tree2d3da68cf388d88ebff299f7c3866c608c847f40 /src/methods/generic_poly1305
parentd0707b161d10cf79242d40b24853988c89c7604a (diff)
downloadfastd-a09d04a02231964fa5a8f0113e9909cfb140fe4e.tar
fastd-a09d04a02231964fa5a8f0113e9909cfb140fe4e.zip
Revert "crypto: separate cipher/MAC availability check from information request"
This reverts commit d0707b161d10cf79242d40b24853988c89c7604a.
Diffstat (limited to 'src/methods/generic_poly1305')
-rw-r--r--src/methods/generic_poly1305/generic_poly1305.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c
index 80ced8c..3820907 100644
--- a/src/methods/generic_poly1305/generic_poly1305.c
+++ b/src/methods/generic_poly1305/generic_poly1305.c
@@ -43,7 +43,7 @@ struct fastd_method_session_state {
};
-static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx, bool check) {
+static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_cipher_info_t **cipher_info, const fastd_cipher_t **cipher, const fastd_cipher_context_t **cctx) {
size_t len = strlen(name);
if (len < 9)
@@ -56,28 +56,31 @@ static bool cipher_get(fastd_context_t *ctx, const char *name, const fastd_ciphe
memcpy(cipher_name, name, len-9);
cipher_name[len-9] = 0;
- if (check && !fastd_cipher_is_available(cipher_name))
+ const fastd_cipher_info_t *info = NULL;
+
+ if (ctx) {
+ *cipher = fastd_cipher_get_by_name(ctx, cipher_name, &info, cctx);
+ if (!*cipher)
+ return false;
+ }
+ else {
+ info = fastd_cipher_info_get_by_name(cipher_name);
+ if (!info)
+ return false;
+ }
+
+ if (info->iv_length <= COMMON_NONCEBYTES)
return false;
- if (ctx)
- *cipher = fastd_cipher_get_by_name(ctx, cipher_name, cipher_info, cctx);
- else if (cipher_info)
- *cipher_info = fastd_cipher_info_get_by_name(cipher_name);
+ if (cipher_info)
+ *cipher_info = info;
return true;
}
static bool method_provides(const char *name) {
- const fastd_cipher_info_t *cipher_info;
-
- if (!cipher_get(NULL, name, &cipher_info, NULL, NULL, true))
- return false;
-
- if (cipher_info->iv_length <= COMMON_NONCEBYTES)
- return false;
-
- return true;
+ return cipher_get(NULL, name, NULL, NULL, NULL);
}
static size_t method_key_length(fastd_context_t *ctx, const char *name) {