From b979f5e3a6d99d5e9a37a9a086004feaa8fd15e5 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Mon, 2 Mar 2020 21:49:48 +0000 Subject: ikev2: make integ algo optional Type: improvement This patch makes configuring integration algorithm optional. This is useful when using AEAD cipher (in fact when using such cipher, integ algo is ignored anyway). Change-Id: I5891db5c0433afb85ae2d9084d45b89ec1133178 Signed-off-by: Filip Tehlar --- src/plugins/ikev2/ikev2.c | 35 +++++++++++++++++++---------------- src/plugins/ikev2/ikev2_cli.c | 26 +++++++++++++++++++++----- 2 files changed, 40 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/plugins/ikev2/ikev2.c b/src/plugins/ikev2/ikev2.c index db68135db42..a9d7e5696a8 100644 --- a/src/plugins/ikev2/ikev2.c +++ b/src/plugins/ikev2/ikev2.c @@ -2754,24 +2754,27 @@ ikev2_set_initiator_proposals (vlib_main_t * vm, ikev2_sa_t * sa, return r; } - /* Integrity */ - error = 1; - vec_foreach (td, km->supported_transforms) - { - if (td->type == IKEV2_TRANSFORM_TYPE_INTEG - && td->integ_type == ts->integ_alg) + if (IKEV2_TRANSFORM_ENCR_TYPE_AES_GCM_16 != ts->crypto_alg) + { + /* Integrity */ + error = 1; + vec_foreach (td, km->supported_transforms) { - vec_add1 (proposal->transforms, *td); - error = 0; - break; + if (td->type == IKEV2_TRANSFORM_TYPE_INTEG + && td->integ_type == ts->integ_alg) + { + vec_add1 (proposal->transforms, *td); + error = 0; + break; + } } - } - if (error) - { - ikev2_elog_error - ("Didn't find any supported algorithm for IKEV2_TRANSFORM_TYPE_INTEG"); - r = clib_error_return (0, "Unsupported algorithm"); - return r; + if (error) + { + ikev2_elog_error + ("Didn't find any supported algorithm for IKEV2_TRANSFORM_TYPE_INTEG"); + r = clib_error_return (0, "Unsupported algorithm"); + return r; + } } /* PRF */ diff --git a/src/plugins/ikev2/ikev2_cli.c b/src/plugins/ikev2/ikev2_cli.c index 6b9876b4ead..1acae91c777 100644 --- a/src/plugins/ikev2/ikev2_cli.c +++ b/src/plugins/ikev2/ikev2_cli.c @@ -125,10 +125,13 @@ show_ikev2_sa_command_fn (vlib_main_t * vm, vlib_cli_output(vm, " SK_e i:%U\n r:%U", format_hex_bytes, child->sk_ei, vec_len(child->sk_ei), format_hex_bytes, child->sk_er, vec_len(child->sk_er)); - vlib_cli_output(vm, " SK_a i:%U\n r:%U", - format_hex_bytes, child->sk_ai, vec_len(child->sk_ai), - format_hex_bytes, child->sk_ar, vec_len(child->sk_ar)); - vlib_cli_output(vm, " traffic selectors (i):"); + if (child->sk_ai) + { + vlib_cli_output(vm, " SK_a i:%U\n r:%U", + format_hex_bytes, child->sk_ai, vec_len(child->sk_ai), + format_hex_bytes, child->sk_ar, vec_len(child->sk_ar)); + vlib_cli_output(vm, " traffic selectors (i):"); + } vec_foreach(ts, child->tsi) { vlib_cli_output(vm, " %u type %u protocol_id %u addr " @@ -362,6 +365,18 @@ ikev2_profile_add_del_command_fn (vlib_main_t * vm, dh_type, tmp1); goto done; } + else if (unformat + (line_input, + "set %U esp-crypto-alg %U %u esp-dh %U", + unformat_token, valid_chars, &name, + unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1, + unformat_ikev2_transform_dh_type, &dh_type)) + { + r = + ikev2_set_profile_esp_transforms (vm, name, crypto_alg, 0, + dh_type, tmp1); + goto done; + } else if (unformat (line_input, "set %U sa-lifetime %lu %u %u %lu", unformat_token, valid_chars, &name, &tmp4, &tmp1, &tmp2, &tmp5)) @@ -405,7 +420,8 @@ VLIB_CLI_COMMAND (ikev2_profile_add_del_command, static) = { "protocol \n" "ikev2 profile set responder \n" "ikev2 profile set ike-crypto-alg ike-integ-alg ike-dh \n" - "ikev2 profile set esp-crypto-alg esp-integ-alg esp-dh \n" + "ikev2 profile set esp-crypto-alg " + "[esp-integ-alg ] esp-dh \n" "ikev2 profile set sa-lifetime ", .function = ikev2_profile_add_del_command_fn, }; -- cgit 1.2.3-korg