hasher: Redefine hash algorithms to match values defined by RFC 7427
authorTobias Brunner <tobias@strongswan.org>
Wed, 25 Feb 2015 15:05:35 +0000 (16:05 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 4 Mar 2015 12:54:08 +0000 (13:54 +0100)
Other algorithms are defined in private use range.

src/libstrongswan/crypto/hashers/hasher.c
src/libstrongswan/crypto/hashers/hasher.h

index a569303..50357d1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2015 Tobias Brunner
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
 
 #include <asn1/oid.h>
 
-ENUM(hash_algorithm_names, HASH_UNKNOWN, HASH_SHA512,
+ENUM_BEGIN(hash_algorithm_names, HASH_SHA1, HASH_SHA512,
+       "HASH_SHA1",
+       "HASH_SHA256",
+       "HASH_SHA384",
+       "HASH_SHA512");
+ENUM_NEXT(hash_algorithm_names, HASH_UNKNOWN, HASH_SHA224, HASH_SHA512,
        "HASH_UNKNOWN",
        "HASH_MD2",
        "HASH_MD4",
        "HASH_MD5",
-       "HASH_SHA1",
-       "HASH_SHA224",
-       "HASH_SHA256",
-       "HASH_SHA384",
-       "HASH_SHA512"
-);
+       "HASH_SHA224");
+ENUM_END(hash_algorithm_names, HASH_SHA224);
 
-ENUM(hash_algorithm_short_names, HASH_UNKNOWN, HASH_SHA512,
+ENUM_BEGIN(hash_algorithm_short_names, HASH_SHA1, HASH_SHA512,
+       "sha1",
+       "sha256",
+       "sha384",
+       "sha512");
+ENUM_NEXT(hash_algorithm_short_names, HASH_UNKNOWN, HASH_SHA224, HASH_SHA512,
        "unknown",
        "md2",
        "md4",
        "md5",
-       "sha1",
-       "sha224",
-       "sha256",
-       "sha384",
-       "sha512"
-);
+       "sha224");
+ENUM_END(hash_algorithm_short_names, HASH_SHA224);
 
 /*
  * Described in header.
index 37ef0b6..bae95fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2015 Tobias Brunner
  * Copyright (C) 2005-2006 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Hochschule fuer Technik Rapperswil
@@ -32,19 +32,19 @@ typedef struct hasher_t hasher_t;
 #include <credentials/keys/public_key.h>
 
 /**
- * Algorithms to use for hashing.
+ * Hash algorithms as defined for IKEv2 by RFC 7427
  */
 enum hash_algorithm_t {
-       /** not specified hash function */
-       HASH_UNKNOWN            = 0,
-       HASH_MD2                        = 1,
-       HASH_MD4                        = 2,
-       HASH_MD5                        = 3,
-       HASH_SHA1                       = 4,
-       HASH_SHA224                     = 5,
-       HASH_SHA256             = 6,
-       HASH_SHA384             = 7,
-       HASH_SHA512             = 8
+       HASH_SHA1                       = 1,
+       HASH_SHA256                     = 2,
+       HASH_SHA384                     = 3,
+       HASH_SHA512                     = 4,
+       /* use private use range for algorithms not defined/permitted by RFC 7427 */
+       HASH_UNKNOWN            = 1024,
+       HASH_MD2                        = 1025,
+       HASH_MD4                        = 1026,
+       HASH_MD5                        = 1027,
+       HASH_SHA224                     = 1028,
 };
 
 #define HASH_SIZE_MD2          16