From cd1ed6a4c53606419dc1474d01bc1d4d08ccb241 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 5 Dec 2013 14:08:56 +0100 Subject: Add support for ++gmac methods --- src/methods/composed_gmac/composed_gmac.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') 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, '+'); -- cgit v1.2.3