Adding support for AES GMAC (RFC4543).
This commit is contained in:
@@ -139,6 +139,7 @@ static bool is_authenticated_encryption(int ealg_id)
|
||||
case ESP_AES_GCM_8:
|
||||
case ESP_AES_GCM_12:
|
||||
case ESP_AES_GCM_16:
|
||||
case ESP_AES_GMAC:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -474,7 +475,7 @@ struct alg_info_ike *alg_info_ike_create_from_str(char *alg_str)
|
||||
|
||||
if (alg_info_parse_str((struct alg_info *)alg_info_ike, alg_str) == SUCCESS)
|
||||
{
|
||||
alg_info_ike->ref_cnt = 1;
|
||||
alg_info_ike->ref_cnt = 1;
|
||||
return alg_info_ike;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -392,7 +392,8 @@ static const char *const esp_transform_name[] = {
|
||||
"AES_GCM_12",
|
||||
"AES_GCM_16",
|
||||
"SEED_CBC",
|
||||
"CAMELLIA_CBC"
|
||||
"CAMELLIA_CBC",
|
||||
"AES_GMAC"
|
||||
};
|
||||
|
||||
static const char *const esp_transform_name_high[] = {
|
||||
|
||||
@@ -125,10 +125,10 @@ extern const char sparse_end[];
|
||||
#define MAX_DIGEST_LEN HASH_SIZE_SHA512
|
||||
|
||||
/* RFC 2404 "HMAC-SHA-1-96" section 3 */
|
||||
#define HMAC_SHA1_KEY_LEN HASH_SIZE_SHA1
|
||||
#define HMAC_SHA1_KEY_LEN HASH_SIZE_SHA1
|
||||
|
||||
/* RFC 2403 "HMAC-MD5-96" section 3 */
|
||||
#define HMAC_MD5_KEY_LEN HASH_SIZE_MD5
|
||||
#define HMAC_MD5_KEY_LEN HASH_SIZE_MD5
|
||||
|
||||
#define IKE_UDP_PORT 500
|
||||
|
||||
@@ -150,7 +150,7 @@ enum ipsec_authentication_algo {
|
||||
AH_AES_128_GMAC = 11,
|
||||
AH_AES_192_GMAC = 12,
|
||||
AH_AES_256_GMAC = 13,
|
||||
AH_SHA2_256_96 = 252
|
||||
AH_SHA2_256_96 = 252
|
||||
};
|
||||
|
||||
extern enum_names ah_transform_names;
|
||||
@@ -184,6 +184,7 @@ enum ipsec_cipher_algo {
|
||||
ESP_AES_GCM_16 = 20,
|
||||
ESP_SEED_CBC = 21,
|
||||
ESP_CAMELLIA = 22,
|
||||
ESP_AES_GMAC = 23,
|
||||
ESP_SERPENT = 252,
|
||||
ESP_TWOFISH = 253
|
||||
};
|
||||
|
||||
+3
-1
@@ -580,9 +580,11 @@ int esp_from_encryption_algorithm(encryption_algorithm_t alg)
|
||||
return ESP_AES_GCM_16;
|
||||
case ENCR_CAMELLIA_CBC:
|
||||
return ESP_CAMELLIA;
|
||||
case ENCR_NULL_AUTH_AES_GMAC:
|
||||
return ESP_AES_GMAC;
|
||||
case ENCR_SERPENT_CBC:
|
||||
return ESP_SERPENT;
|
||||
case ENCR_TWOFISH_CBC:
|
||||
case ENCR_TWOFISH_CBC:
|
||||
return ESP_TWOFISH;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -2753,6 +2753,7 @@ static void compute_proto_keymat(struct state *st, u_int8_t protoid,
|
||||
case ESP_AES_GCM_12:
|
||||
case ESP_AES_GCM_16:
|
||||
case ESP_AES_CTR:
|
||||
case ESP_AES_GMAC:
|
||||
needed_len += 4;
|
||||
break;
|
||||
default:
|
||||
@@ -3620,7 +3621,7 @@ stf_status main_inR2_outI3(struct msg_digest *md)
|
||||
if (send_cert)
|
||||
{
|
||||
bool success;
|
||||
chunk_t cert_encoding;
|
||||
chunk_t cert_encoding;
|
||||
pb_stream cert_pbs;
|
||||
|
||||
struct isakmp_cert cert_hd;
|
||||
@@ -3634,7 +3635,7 @@ stf_status main_inR2_outI3(struct msg_digest *md)
|
||||
cert_encoding = mycert->cert->get_encoding(mycert->cert);
|
||||
success = out_chunk(cert_encoding, &cert_pbs, "CERT");
|
||||
free(cert_encoding.ptr);
|
||||
if (!success)
|
||||
if (!success)
|
||||
{
|
||||
return STF_INTERNAL_ERROR;
|
||||
}
|
||||
@@ -4076,7 +4077,7 @@ main_inI3_outR3_tail(struct msg_digest *md
|
||||
success = out_chunk(cert_encoding, &cert_pbs, "CERT");
|
||||
free(cert_encoding.ptr);
|
||||
if (!success)
|
||||
{
|
||||
{
|
||||
return STF_INTERNAL_ERROR;
|
||||
}
|
||||
close_output_pbs(&cert_pbs);
|
||||
|
||||
@@ -1993,6 +1993,7 @@ static bool setup_half_ipsec_sa(struct state *st, bool inbound)
|
||||
case ESP_AES_GCM_12:
|
||||
case ESP_AES_GCM_16:
|
||||
case ESP_AES_CTR:
|
||||
case ESP_AES_GMAC:
|
||||
key_len += 4;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -395,6 +395,10 @@ void kernel_alg_register_pfkey(const struct sadb_msg *msg_buf, int buflen)
|
||||
kernel_alg_add(satype, supp_exttype, &alg);
|
||||
}
|
||||
}
|
||||
|
||||
/* also register AES_GMAC */
|
||||
alg.sadb_alg_id = SADB_X_EALG_NULL_AES_GMAC;
|
||||
kernel_alg_add(satype, supp_exttype, &alg);
|
||||
}
|
||||
/* if SHA2_256 is registered then also register SHA2_256_96 */
|
||||
if (satype == SADB_SATYPE_ESP &&
|
||||
|
||||
@@ -112,6 +112,7 @@ static sparse_names ealg_list = {
|
||||
{ SADB_X_EALG_AES_GCM_ICV8, "rfc4106(gcm(aes))" },
|
||||
{ SADB_X_EALG_AES_GCM_ICV12, "rfc4106(gcm(aes))" },
|
||||
{ SADB_X_EALG_AES_GCM_ICV16, "rfc4106(gcm(aes))" },
|
||||
{ SADB_X_EALG_NULL_AES_GMAC, "rfc4543(gcm(aes))" },
|
||||
{ SADB_X_EALG_CAMELLIACBC, "cbc(camellia)" },
|
||||
{ SADB_X_EALG_SERPENTCBC, "serpent" },
|
||||
{ SADB_X_EALG_TWOFISHCBC, "twofish" },
|
||||
@@ -687,6 +688,7 @@ static bool netlink_add_sa(const struct kernel_sa *sa, bool replace)
|
||||
break;
|
||||
case SADB_X_EALG_AES_CCM_ICV16:
|
||||
case SADB_X_EALG_AES_GCM_ICV16:
|
||||
case SADB_X_EALG_NULL_AES_GMAC:
|
||||
icv_size += 32;
|
||||
/* FALL */
|
||||
case SADB_X_EALG_AES_CCM_ICV12:
|
||||
|
||||
Reference in New Issue
Block a user