summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-07-20 12:17:40 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-07-21 14:26:31 +0200
commita0875593eb9308ae9ae9fde1b886422bb03540f5 (patch)
treea635d8d7f39005d3bbeb05e760150339d5742408 /lib
parent80ce2b45b35bd72aa7e422aad833d21f48bb44e9 (diff)
downloadgnutls-a0875593eb9308ae9ae9fde1b886422bb03540f5.tar.gz
mac: re-organized the hash algorithms table
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/algorithms/mac.c137
1 files changed, 109 insertions, 28 deletions
diff --git a/lib/algorithms/mac.c b/lib/algorithms/mac.c
index ce2d18c154..07c5112164 100644
--- a/lib/algorithms/mac.c
+++ b/lib/algorithms/mac.c
@@ -38,32 +38,113 @@
#endif
static const mac_entry_st hash_algorithms[] = {
- {"SHA1", HASH_OID_SHA1, MAC_OID_SHA1, GNUTLS_MAC_SHA1, 20, 20, 0, 0, SHA1_SECURE_VAL, 64},
- {"MD5", HASH_OID_MD5, NULL, GNUTLS_MAC_MD5, 16, 16, 0, 0, 0, 64},
- {"MD5+SHA1", NULL, NULL, GNUTLS_MAC_MD5_SHA1, 36, 36, 0, 0, 0, 64},
- {"SHA256", HASH_OID_SHA256, MAC_OID_SHA256, GNUTLS_MAC_SHA256, 32, 32, 0, 0, 1,
- 64},
- {"SHA384", HASH_OID_SHA384, MAC_OID_SHA384, GNUTLS_MAC_SHA384, 48, 48, 0, 0, 1,
- 64},
- {"SHA512", HASH_OID_SHA512, MAC_OID_SHA512, GNUTLS_MAC_SHA512, 64, 64, 0, 0, 1,
- 64},
- {"SHA224", HASH_OID_SHA224, MAC_OID_SHA224, GNUTLS_MAC_SHA224, 28, 28, 0, 0, 1,
- 64},
- {"SHA3-256", HASH_OID_SHA3_256, NULL, GNUTLS_MAC_SHA3_256, 32, 32, 0, 0, 1,
- 136},
- {"SHA3-384", HASH_OID_SHA3_384, NULL, GNUTLS_MAC_SHA3_384, 48, 48, 0, 0, 1,
- 104},
- {"SHA3-512", HASH_OID_SHA3_512, NULL, GNUTLS_MAC_SHA3_512, 64, 64, 0, 0, 1,
- 72},
- {"SHA3-224", HASH_OID_SHA3_224, NULL, GNUTLS_MAC_SHA3_224, 28, 28, 0, 0, 1,
- 144},
- {"UMAC-96", NULL, NULL, GNUTLS_MAC_UMAC_96, 12, 16, 8, 0, 1, 0},
- {"UMAC-128", NULL, NULL, GNUTLS_MAC_UMAC_128, 16, 16, 8, 0, 1, 0},
- {"AEAD", NULL, NULL, GNUTLS_MAC_AEAD, 0, 0, 0, 1, 1, 0},
- {"MD2", HASH_OID_MD2, NULL, GNUTLS_MAC_MD2, 0, 0, 0, 0, 0, 0}, /* not used as MAC */
- {"RIPEMD160", HASH_OID_RMD160, NULL, GNUTLS_MAC_RMD160, 20, 20, 0, 0, 1,
- 64},
- {"MAC-NULL", NULL, NULL, GNUTLS_MAC_NULL, 0, 0, 0, 0, 0, 0},
+ {.name = "SHA1",
+ .oid = HASH_OID_SHA1,
+ .mac_oid = MAC_OID_SHA1,
+ .id = GNUTLS_MAC_SHA1,
+ .output_size = 20,
+ .key_size = 20,
+ .secure = SHA1_SECURE_VAL,
+ .block_size = 64},
+ {.name = "MD5",
+ .oid = HASH_OID_MD5,
+ .id = GNUTLS_MAC_MD5,
+ .output_size = 16,
+ .key_size = 16,
+ .block_size = 64},
+ {.name = "MD5+SHA1",
+ .id = GNUTLS_MAC_MD5_SHA1,
+ .output_size = 36,
+ .key_size = 36,
+ .block_size = 64},
+ {.name = "SHA256",
+ .oid = HASH_OID_SHA256,
+ .mac_oid = MAC_OID_SHA256,
+ .id = GNUTLS_MAC_SHA256,
+ .output_size = 32,
+ .key_size = 32,
+ .secure = 1,
+ .block_size = 64},
+ {.name = "SHA384",
+ .oid = HASH_OID_SHA384,
+ .mac_oid = MAC_OID_SHA384,
+ .id = GNUTLS_MAC_SHA384,
+ .output_size = 48,
+ .key_size = 48,
+ .secure = 1,
+ .block_size = 64},
+ {.name = "SHA512",
+ .oid = HASH_OID_SHA512,
+ .mac_oid = MAC_OID_SHA512,
+ .id = GNUTLS_MAC_SHA512,
+ .output_size = 64,
+ .key_size = 64,
+ .secure = 1,
+ .block_size = 64},
+ {.name = "SHA224",
+ .oid = HASH_OID_SHA224,
+ .mac_oid = MAC_OID_SHA224,
+ .id = GNUTLS_MAC_SHA224,
+ .output_size = 28,
+ .key_size = 28,
+ .secure = 1,
+ .block_size = 64},
+ {.name = "SHA3-256",
+ .oid = HASH_OID_SHA3_256,
+ .id = GNUTLS_MAC_SHA3_256,
+ .output_size = 32,
+ .key_size = 32,
+ .secure = 1,
+ .block_size = 136},
+ {.name = "SHA3-384",
+ .oid = HASH_OID_SHA3_384,
+ .id = GNUTLS_MAC_SHA3_384,
+ .output_size = 48,
+ .key_size = 48,
+ .secure = 1,
+ .block_size = 104},
+ {.name = "SHA3-512",
+ .oid = HASH_OID_SHA3_512,
+ .id = GNUTLS_MAC_SHA3_512,
+ .output_size = 64,
+ .key_size = 64,
+ .secure = 1,
+ .block_size = 72},
+ {.name = "SHA3-224",
+ .oid = HASH_OID_SHA3_224,
+ .id = GNUTLS_MAC_SHA3_224,
+ .output_size = 28,
+ .key_size = 28,
+ .secure = 1,
+ .block_size = 144},
+ {.name = "UMAC-96",
+ .id = GNUTLS_MAC_UMAC_96,
+ .output_size = 12,
+ .key_size = 16,
+ .nonce_size = 8,
+ .secure = 1},
+ {.name = "UMAC-128",
+ .id = GNUTLS_MAC_UMAC_128,
+ .output_size = 16,
+ .key_size = 16,
+ .nonce_size = 8,
+ .secure = 1},
+ {.name = "AEAD",
+ .id = GNUTLS_MAC_AEAD,
+ .placeholder = 1,
+ .secure = 1},
+ {.name = "MD2",
+ .oid = HASH_OID_MD2,
+ .id = GNUTLS_MAC_MD2},
+ {.name = "RIPEMD160",
+ .oid = HASH_OID_RMD160,
+ .id = GNUTLS_MAC_RMD160,
+ .output_size = 20,
+ .key_size = 20,
+ .secure = 1,
+ .block_size = 64},
+ {.name = "MAC-NULL",
+ .id = GNUTLS_MAC_NULL},
{0, 0, 0, 0, 0, 0, 0, 0, 0}
};
@@ -178,7 +259,7 @@ gnutls_mac_algorithm_t gnutls_mac_get_id(const char *name)
* gnutls_mac_get_key_size:
* @algorithm: is an encryption algorithm
*
- * Returns the size of the MAC key used in TLS.
+ * Returns the size of the MAC key used in TLS.
*
* Returns: length (in bytes) of the given MAC key size, or 0 if the
* given MAC algorithm is invalid.
@@ -217,7 +298,7 @@ size_t gnutls_mac_get_nonce_size(gnutls_mac_algorithm_t algorithm)
* gnutls_mac_list:
*
* Get a list of hash algorithms for use as MACs. Note that not
- * necessarily all MACs are supported in TLS cipher suites.
+ * necessarily all MACs are supported in TLS cipher suites.
* This function is not thread safe.
*
* Returns: Return a (0)-terminated list of #gnutls_mac_algorithm_t