Currently iked does not provide an option to configure extended sequence numbers (ESN) for child SAs, but always proposes/accepts both options. This diff adds a new optional "esn on/off" config option to explicitly enable or disable esn.
ok? Index: iked.conf.5 =================================================================== RCS file: /mount/openbsd/cvs/src/sbin/iked/iked.conf.5,v retrieving revision 1.57 diff -u -p -r1.57 iked.conf.5 --- iked.conf.5 24 Aug 2019 13:24:49 -0000 1.57 +++ iked.conf.5 11 Nov 2019 14:16:45 -0000 @@ -409,6 +409,7 @@ multiple crypto transforms. .Ic auth Ar algorithm .Ic enc Ar algorithm .Ic group Ar group +.Ic esn Ar esn .Xc These parameters define the cryptographic transforms to be used for the Child SA negotiation, also known as phase 2. @@ -421,6 +422,7 @@ Possible values for .Ic auth , .Ic enc , .Ic group , +.Ic esn , and the default proposals are described below in .Sx CRYPTO TRANSFORMS . If omitted, @@ -849,6 +851,15 @@ not encryption: .It Li aes-192-gmac Ta "224 bits" Ta "[ESP only]" .It Li aes-256-gmac Ta "288 bits" Ta "[ESP only]" .It Li null Ta "" Ta "[ESP only]" +.El +.Pp +The Extended Sequence Numbers option can be enabled or disabled with the +.Ic esn +keyword: +.Bl -column "ESN" "[ESP only]" -offset indent +.It Em ESN +.It Li on Ta "[ESP only]" +.It Li off Ta "[ESP only]" .El .Pp Transforms followed by Index: parse.y =================================================================== RCS file: /mount/openbsd/cvs/src/sbin/iked/parse.y,v retrieving revision 1.84 diff -u -p -r1.84 parse.y --- parse.y 26 Sep 2019 07:33:36 -0000 1.84 +++ parse.y 11 Nov 2019 14:21:48 -0000 @@ -127,6 +127,8 @@ struct ipsec_transforms { unsigned int nencxf; const struct ipsec_xf **groupxf; unsigned int ngroupxf; + const struct ipsec_xf **esnxf; + unsigned int nesnxf; }; struct ipsec_mode { @@ -259,6 +261,12 @@ const struct ipsec_xf groupxfs[] = { { NULL } }; +const struct ipsec_xf esnxfs[] = { + { "on", IKEV2_XFORMESN_ESN }, + { "off", IKEV2_XFORMESN_NONE }, + { NULL } +}; + const struct ipsec_xf methodxfs[] = { { "none", IKEV2_AUTH_NONE }, { "rsa", IKEV2_AUTH_RSA_SIG }, @@ -395,7 +403,7 @@ typedef struct { %} %token FROM ESP AH IN PEER ON OUT TO SRCID DSTID PSK PORT -%token FILENAME AUTHXF PRFXF ENCXF ERROR IKEV2 IKESA CHILDSA +%token FILENAME AUTHXF PRFXF ENCXF ERROR IKEV2 IKESA CHILDSA ESN %token PASSIVE ACTIVE ANY TAG TAP PROTO LOCAL GROUP NAME CONFIG EAP USER %token IKEV1 FLOW SA TCPMD5 TUNNEL TRANSPORT COUPLE DECOUPLE SET %token INCLUDE LIFETIME BYTES INET INET6 QUICK SKIP DEFAULT @@ -802,6 +810,19 @@ transform : AUTHXF STRING { ipsec_transforms->groupxf = xfs; ipsec_transforms->ngroupxf++; } + | ESN STRING { + const struct ipsec_xf **xfs = ipsec_transforms->esnxf; + size_t nxfs = ipsec_transforms->nesnxf; + xfs = recallocarray(xfs, nxfs, nxfs + 1, + sizeof(struct ipsec_xf *)); + if ((xfs[nxfs] = parse_xf($2, 0, esnxfs)) == NULL) { + yyerror("%s not a valid transform", $2); + YYERROR; + } + free($2); + ipsec_transforms->esnxf = xfs; + ipsec_transforms->nesnxf++; + } ; ike_sas : { @@ -1180,6 +1201,7 @@ lookup(char *s) { "dstid", DSTID }, { "eap", EAP }, { "enc", ENCXF }, + { "esn", ESN }, { "esp", ESP }, { "file", FILENAME }, { "flow", FLOW }, @@ -2578,6 +2600,10 @@ print_policy(struct iked_policy *pol) print_verbose(" group "); xfs = groupxfs; break; + case IKEV2_XFORMTYPE_ESN: + print_verbose(" esn "); + xfs = esnxfs; + break; default: continue; } @@ -2833,6 +2859,11 @@ create_ike(char *name, int af, uint8_t i if ((p = calloc(1, sizeof(*p))) == NULL) err(1, "%s", __func__); + if (ike_sa->xfs[i]->nesnxf) { + yyerror("cannot use ESN with ikesa."); + goto done; + } + xf = NULL; xfi = 0; copy_transforms(IKEV2_XFORMTYPE_INTEGR, @@ -2914,7 +2945,8 @@ create_ike(char *name, int af, uint8_t i ikev2_default_esp_transforms, ikev2_default_nesp_transforms); copy_transforms(IKEV2_XFORMTYPE_ESN, - NULL, 0, &xf, &xfi, + ipsec_sa->xfs[i]->esnxf, + ipsec_sa->xfs[i]->nesnxf, &xf, &xfi, ikev2_default_esp_transforms, ikev2_default_nesp_transforms);