summaryrefslogtreecommitdiffstats
path: root/src/methods
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-05 14:08:56 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-05 14:08:56 +0100
commitcd1ed6a4c53606419dc1474d01bc1d4d08ccb241 (patch)
treed29e742742202e241e221bc00b3b8099a1ac8d3c /src/methods
parent3d6e771dd203cb6fc693632c4de98e46703f6810 (diff)
downloadfastd-cd1ed6a4c53606419dc1474d01bc1d4d08ccb241.tar
fastd-cd1ed6a4c53606419dc1474d01bc1d4d08ccb241.zip
Add support for <cipher>+<cipher>+gmac methods
Diffstat (limited to 'src/methods')
-rw-r--r--src/methods/composed_gmac/composed_gmac.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/methods/composed_gmac/composed_gmac.c b/src/methods/composed_gmac/composed_gmac.c
index b3b22d6..55ee3de 100644
--- a/src/methods/composed_gmac/composed_gmac.c
+++ b/src/methods/composed_gmac/composed_gmac.c
@@ -62,15 +62,22 @@ static bool method_create_by_name(const char *name, fastd_method_t **method) {
return false;
size_t len = strlen(name);
- if (len < 5)
- return false;
+ char cipher_name[len];
- if (strcmp(name+len-5, "-gmac"))
- return false;
+ if (len >= 5 && !strcmp(name+len-5, "-gmac")) {
+ memcpy(cipher_name, name, len-4);
+ strncpy(cipher_name+len-4, "ctr", 4);
+ }
+ else if (len >= 5 && !strcmp(name+len-5, "+gmac")) {
+ if (len >= 9 && !strcmp(name+len-9, "-ctr+gmac"))
+ return false;
- char cipher_name[len];
- memcpy(cipher_name, name, len-4);
- strncpy(cipher_name+len-4, "ctr", 4);
+ memcpy(cipher_name, name, len-5);
+ cipher_name[len-5] = 0;
+ }
+ else {
+ return false;
+ }
char *gmac_cipher_name = strchr(cipher_name, '+');