-/* $OpenBSD: ikev2.c,v 1.303 2021/02/04 20:38:26 tobhe Exp $ */
+/* $OpenBSD: ikev2.c,v 1.304 2021/02/09 21:35:48 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
uint64_t spi64;
uint32_t spi32, spi = 0;
unsigned int i, xfi, nxforms;
+ int prop_skipdh;
TAILQ_FOREACH(prop, proposals, prop_entry) {
if ((protoid && prop->prop_protoid != protoid) ||
(!protoid && prop->prop_protoid == IKEV2_SAPROTO_IKE))
continue;
+ prop_skipdh = skipdh;
+
if (protoid != IKEV2_SAPROTO_IKE && initiator) {
if (spi == 0) {
bzero(&csa, sizeof(csa));
prop->prop_localspi.spi_protoid = IKEV2_SAPROTO_IKE;
}
+ /*
+ * A single DH transform of type NONE is equivalent with
+ * not sending a DH transform at all.
+ * Prefer the latter for downwards compatibility.
+ */
+ if (protoid != IKEV2_SAPROTO_IKE) {
+ for (i = 0; i < prop->prop_nxforms; i++) {
+ xform = prop->prop_xforms + i;
+ if (xform->xform_type == IKEV2_XFORMTYPE_DH &&
+ xform->xform_id != IKEV2_XFORMDH_NONE)
+ break;
+ }
+ if (i == prop->prop_nxforms)
+ prop_skipdh = 1;
+ }
+
/*
* RFC 7296: 1.2. The Initial Exchanges
* IKE_AUTH messages do not contain KE/N payloads, thus
* SA payloads cannot contain groups.
*/
- if (skipdh) {
+ if (prop_skipdh) {
nxforms = 0;
for (i = 0; i < prop->prop_nxforms; i++) {
xform = prop->prop_xforms + i;
for (i = 0, xfi = 0; i < prop->prop_nxforms; i++) {
xform = prop->prop_xforms + i;
- if (skipdh && xform->xform_type == IKEV2_XFORMTYPE_DH)
+ if (prop_skipdh && xform->xform_type == IKEV2_XFORMTYPE_DH)
continue;
if ((xflen = ikev2_add_transform(buf,
{
struct iked_policy *pol = sa->sa_policy;
struct iked_childsa *csa = NULL, *csb = NULL;
+ struct iked_transform *xform;
struct ikev2_notify *n;
struct ikev2_payload *pld = NULL;
struct ikev2_keyexchange *ke;
goto done;
len = ibuf_size(nonce);
- if (config_findtransform(&pol->pol_proposals, IKEV2_XFORMTYPE_DH,
- protoid)) {
+ if ((xform = config_findtransform(&pol->pol_proposals, IKEV2_XFORMTYPE_DH,
+ protoid)) && group_get(xform->xform_id) != IKEV2_XFORMDH_NONE) {
log_debug("%s: enable PFS", __func__);
ikev2_sa_cleanup_dh(sa);
if (proposed_group) {
-/* $OpenBSD: parse.y,v 1.126 2021/02/07 00:51:53 tobhe Exp $ */
+/* $OpenBSD: parse.y,v 1.127 2021/02/09 21:35:48 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
{ IKEV2_XFORMTYPE_INTEGR, IKEV2_XFORMAUTH_HMAC_SHA2_384_192 },
{ IKEV2_XFORMTYPE_INTEGR, IKEV2_XFORMAUTH_HMAC_SHA2_512_256 },
{ IKEV2_XFORMTYPE_INTEGR, IKEV2_XFORMAUTH_HMAC_SHA1_96 },
+ { IKEV2_XFORMTYPE_DH, IKEV2_XFORMDH_NONE },
{ IKEV2_XFORMTYPE_ESN, IKEV2_XFORMESN_ESN },
{ IKEV2_XFORMTYPE_ESN, IKEV2_XFORMESN_NONE },
{ 0 }
struct iked_transform ikev2_default_esp_transforms_noauth[] = {
{ IKEV2_XFORMTYPE_ENCR, IKEV2_XFORMENCR_AES_GCM_16, 128 },
{ IKEV2_XFORMTYPE_ENCR, IKEV2_XFORMENCR_AES_GCM_16, 256 },
+ { IKEV2_XFORMTYPE_DH, IKEV2_XFORMDH_NONE },
{ IKEV2_XFORMTYPE_ESN, IKEV2_XFORMESN_ESN },
{ IKEV2_XFORMTYPE_ESN, IKEV2_XFORMESN_NONE },
{ 0 }
};
const struct ipsec_xf groupxfs[] = {
+ { "none", IKEV2_XFORMDH_NONE },
{ "modp768", IKEV2_XFORMDH_MODP_768 },
{ "grp1", IKEV2_XFORMDH_MODP_768 },
{ "modp1024", IKEV2_XFORMDH_MODP_1024 },
else
auth++;
}
+ for (j = 0; j < ike_sa->xfs[i]->ngroupxf; j++) {
+ if (ike_sa->xfs[i]->groupxf[j]->id
+ == IKEV2_XFORMDH_NONE) {
+ yyerror("IKE group can not be \"none\".");
+ goto done;
+ }
+ }
if (ike_sa->xfs[i]->nauthxf)
auth++;
-/* $OpenBSD: policy.c,v 1.75 2021/02/01 16:37:48 tobhe Exp $ */
+/* $OpenBSD: policy.c,v 1.76 2021/02/09 21:35:48 tobhe Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
*/
if (rekey && requiredh == 0 &&
protoid == IKEV2_SAPROTO_ESP &&
- tlocal->xform_type == IKEV2_XFORMTYPE_DH)
+ tlocal->xform_type == IKEV2_XFORMTYPE_DH &&
+ tlocal->xform_id != IKEV2_XFORMDH_NONE)
requiredh = 1;
/* Compare peer and local proposals */