From owner-svn-src-head@freebsd.org Thu Jul 30 05:07:27 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDC7E9AD3EB; Thu, 30 Jul 2015 05:07:27 +0000 (UTC) (envelope-from root@sierra.onthenet.com.au) Received: from sierra.onthenet.com.au (sierra.onthenet.com.au [121.50.214.253]) by mx1.freebsd.org (Postfix) with ESMTP id 8B28E7CE; Thu, 30 Jul 2015 05:07:27 +0000 (UTC) (envelope-from root@sierra.onthenet.com.au) Received: by sierra.onthenet.com.au (Postfix, from userid 0) id 62D41E88C6; Thu, 30 Jul 2015 14:56:59 +1000 (AEST) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mx2.freebsd.org (mx2.freebsd.org [8.8.178.116]) by sierra.onthenet.com.au (Postfix) with ESMTP id 3161736DC69 for ; Wed, 29 Jul 2015 22:53:33 +1000 (AEST) Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.freebsd.org (Postfix) with ESMTPS id 1548637F1 for ; Wed, 29 Jul 2015 12:53:31 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 0D4A2192A for ; Wed, 29 Jul 2015 12:53:28 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix) id E699E186A; Wed, 29 Jul 2015 12:53:27 +0000 (UTC) Delivered-To: grehan@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by freefall.freebsd.org (Postfix) with ESMTP id 4602E181B; Wed, 29 Jul 2015 12:53:27 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 125B218D2; Wed, 29 Jul 2015 12:53:27 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 0CA8A1819; Wed, 29 Jul 2015 12:53:27 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by freefall.freebsd.org (Postfix) with ESMTP id 2B6711803; Wed, 29 Jul 2015 12:53:22 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: from mail-yk0-x22c.google.com (mail-yk0-x22c.google.com [IPv6:2607:f8b0:4002:c07::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DCD6C18B1; Wed, 29 Jul 2015 12:53:21 +0000 (UTC) (envelope-from ermal.luci@gmail.com) Received: by ykba194 with SMTP id a194so6527213ykb.0; Wed, 29 Jul 2015 05:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=JaOsZ2VR88m8NyRBZqLy8UF+Jxjzu6TXnCLQuO9AQZ8=; b=PUskAo4B7S37DqRNGEhmeKdlh0FQjgRTkxnYZbu72XqNgcLbj5qR82ai/R7V1txpeA QWA7jiY9mubktGeIzD4yJal751VmdKyElX5PplLqcaK8FC7ejmQVXYRohdtRszpRNRSz awMiALcfOAGNmAWLLDaSwCjb1eJJpCqgFeGWAzecclhKPyIuNzpc6KvfldugobKBcXrr SgmLTKDYC9Y+Tp4os5TPQu/T3/dYiaLNSdBH9NN16AkSFvnBQfSDtLMGOZVZugi6arJ2 kcGl1/iVtH1HBe2s1xEuPptPblhBcSlhIaDXq5WGa1F373byePTrDNi2JNpy3IS8CBgv HCyg== MIME-Version: 1.0 X-Received: by 10.170.198.144 with SMTP id p138mr43361632yke.70.1438174400734; Wed, 29 Jul 2015 05:53:20 -0700 (PDT) Received: by 10.129.83.139 with HTTP; Wed, 29 Jul 2015 05:53:20 -0700 (PDT) In-Reply-To: <201507290715.t6T7FHGb094456@repo.freebsd.org> References: <201507290715.t6T7FHGb094456@repo.freebsd.org> Date: Wed, 29 Jul 2015 14:53:20 +0200 X-Google-Sender-Auth: YTg-pUgGUq5agmzlItWf-43Lhpk Message-ID: Subject: Re: svn commit: r286000 - head/sys/netipsec From: =?UTF-8?Q?Ermal_Lu=C3=A7i?= To: John-Mark Gurney , George Neville-Neil Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Not scanned: please contact your Internet E-Mail Service Provider for details X-Spam-Flag: not spam (whitelisted), SpamAssassin (not cached, score=-6.808, required 5, autolearn=not spam, BAYES_00 -1.90, DKIM_SIGNED 0.10, HEADER_FROM_DIFFERENT_DOMAINS 0.00, HTML_MESSAGE 0.00, RCVD_IN_DNSWL_HI -5.00, RCVD_IN_MSPIKE_H4 -0.01, RCVD_IN_MSPIKE_WL -0.01, T_DKIM_INVALID 0.01) X-MailScanner-From: root@sierra.onthenet.com.au X-Spam-Status: No Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2015 05:07:28 -0000 Hello John-Mark, this was forgotten part on my patches merge from gnn@. Can it be fixed by correcting the patches rather than re-introducing this? Most probably the constant definition is wrong on the transforms and also some part of code removal was missed. On Wed, Jul 29, 2015 at 9:15 AM, John-Mark Gurney wrote: > Author: jmg > Date: Wed Jul 29 07:15:16 2015 > New Revision: 286000 > URL: https://svnweb.freebsd.org/changeset/base/286000 > > Log: > RFC4868 section 2.3 requires that the output be half... This fixes > problems that was introduced in r285336... I have verified that > HMAC-SHA2-256 both ah only and w/ AES-CBC interoperate w/ a NetBSD > 6.1.5 vm... > > Reviewed by: gnn > > Modified: > head/sys/netipsec/xform.h > head/sys/netipsec/xform_ah.c > head/sys/netipsec/xform_esp.c > > Modified: head/sys/netipsec/xform.h > > ============================================================================== > --- head/sys/netipsec/xform.h Wed Jul 29 06:35:36 2015 (r285999) > +++ head/sys/netipsec/xform.h Wed Jul 29 07:15:16 2015 (r286000) > @@ -105,6 +105,7 @@ struct xformsw { > #ifdef _KERNEL > extern void xform_register(struct xformsw*); > extern int xform_init(struct secasvar *sav, int xftype); > +extern int xform_ah_authsize(struct auth_hash *esph); > > struct cryptoini; > > > Modified: head/sys/netipsec/xform_ah.c > > ============================================================================== > --- head/sys/netipsec/xform_ah.c Wed Jul 29 06:35:36 2015 > (r285999) > +++ head/sys/netipsec/xform_ah.c Wed Jul 29 07:15:16 2015 > (r286000) > @@ -85,8 +85,8 @@ > * Return authenticator size in bytes, based on a field in the > * algorithm descriptor. > */ > -#define AUTHSIZE(sav) \ > - ((sav->flags & SADB_X_EXT_OLD) ? 16 : > (sav)->tdb_authalgxform->hashsize) > +#define AUTHSIZE(sav) ((sav->flags & SADB_X_EXT_OLD) ? 16 : \ > + xform_ah_authsize((sav)->tdb_authalgxform)) > > VNET_DEFINE(int, ah_enable) = 1; /* control flow of packets with AH > */ > VNET_DEFINE(int, ah_cleartos) = 1; /* clear ip_tos when doing AH calc > */ > @@ -112,6 +112,35 @@ static unsigned char ipseczeroes[256]; / > static int ah_input_cb(struct cryptop*); > static int ah_output_cb(struct cryptop*); > > +int > +xform_ah_authsize(struct auth_hash *esph) > +{ > + int alen; > + > + if (esph == NULL) > + return 0; > + > + switch (esph->type) { > + case CRYPTO_SHA2_256_HMAC: > + case CRYPTO_SHA2_384_HMAC: > + case CRYPTO_SHA2_512_HMAC: > + alen = esph->hashsize / 2; /* RFC4868 2.3 */ > + break; > + > + case CRYPTO_AES_128_NIST_GMAC: > + case CRYPTO_AES_192_NIST_GMAC: > + case CRYPTO_AES_256_NIST_GMAC: > + alen = esph->hashsize; > + break; > + > + default: > + alen = AH_HMAC_HASHLEN; > + break; > + } > + > + return alen; > +} > + > /* > * NB: this is public for use by the PF_KEY support. > */ > > Modified: head/sys/netipsec/xform_esp.c > > ============================================================================== > --- head/sys/netipsec/xform_esp.c Wed Jul 29 06:35:36 2015 > (r285999) > +++ head/sys/netipsec/xform_esp.c Wed Jul 29 07:15:16 2015 > (r286000) > @@ -320,7 +320,6 @@ esp_input(struct mbuf *m, struct secasva > IPSEC_ASSERT(sav != NULL, ("null SA")); > IPSEC_ASSERT(sav->tdb_encalgxform != NULL, ("null encoding > xform")); > > - alen = 0; > /* Valid IP Packet length ? */ > if ( (skip&3) || (m->m_pkthdr.len&3) ){ > DPRINTF(("%s: misaligned packet, skip %u pkt len %u", > @@ -335,13 +334,13 @@ esp_input(struct mbuf *m, struct secasva > esph = sav->tdb_authalgxform; > espx = sav->tdb_encalgxform; > > - /* Determine the ESP header length */ > + /* Determine the ESP header and auth length */ > if (sav->flags & SADB_X_EXT_OLD) > hlen = sizeof (struct esp) + sav->ivlen; > else > hlen = sizeof (struct newesp) + sav->ivlen; > - /* Authenticator hash size */ > - alen = esph ? esph->hashsize : 0; > + > + alen = xform_ah_authsize(esph); > > /* > * Verify payload length is multiple of encryption algorithm > @@ -530,7 +529,7 @@ esp_input_cb(struct cryptop *crp) > > /* If authentication was performed, check now. */ > if (esph != NULL) { > - alen = esph->hashsize; > + alen = xform_ah_authsize(esph); > AHSTAT_INC(ahs_hist[sav->alg_auth]); > /* Copy the authenticator from the packet */ > m_copydata(m, m->m_pkthdr.len - alen, alen, aalg); > @@ -700,10 +699,7 @@ esp_output(struct mbuf *m, struct ipsecr > /* XXX clamp padding length a la KAME??? */ > padding = ((blks - ((rlen + 2) % blks)) % blks) + 2; > > - if (esph) > - alen = esph->hashsize; > - else > - alen = 0; > + alen = xform_ah_authsize(esph); > > ESPSTAT_INC(esps_output); > > @@ -983,21 +979,7 @@ esp_output_cb(struct cryptop *crp) > if (esph != NULL) { > int alen; > > - switch (esph->type) { > - case CRYPTO_SHA2_256_HMAC: > - case CRYPTO_SHA2_384_HMAC: > - case CRYPTO_SHA2_512_HMAC: > - alen = esph->hashsize/2; > - break; > - case CRYPTO_AES_128_NIST_GMAC: > - case CRYPTO_AES_192_NIST_GMAC: > - case CRYPTO_AES_256_NIST_GMAC: > - alen = esph->hashsize; > - break; > - default: > - alen = AH_HMAC_HASHLEN; > - break; > - } > + alen = xform_ah_authsize(esph); > m_copyback(m, m->m_pkthdr.len - alen, > alen, ipseczeroes); > } > > -- > Ermal >