2017-08-02 04:28:02 +03:00
|
|
|
/* $NetBSD: xform_esp.c,v 1.68 2017/08/02 01:28:03 ozaki-r Exp $ */
|
2003-08-14 00:06:49 +04:00
|
|
|
/* $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $ */
|
|
|
|
/* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The authors of this code are John Ioannidis (ji@tla.org),
|
|
|
|
* Angelos D. Keromytis (kermit@csd.uch.gr) and
|
|
|
|
* Niels Provos (provos@physnet.uni-hamburg.de).
|
|
|
|
*
|
|
|
|
* The original version of this code was written by John Ioannidis
|
|
|
|
* for BSD/OS in Athens, Greece, in November 1995.
|
|
|
|
*
|
|
|
|
* Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
|
|
|
|
* by Angelos D. Keromytis.
|
|
|
|
*
|
|
|
|
* Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
|
|
|
|
* and Niels Provos.
|
|
|
|
*
|
|
|
|
* Additional features in 1999 by Angelos D. Keromytis.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
|
|
|
|
* Angelos D. Keromytis and Niels Provos.
|
|
|
|
* Copyright (c) 2001 Angelos D. Keromytis.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, and modify this software with or without fee
|
|
|
|
* is hereby granted, provided that this entire notice is included in
|
|
|
|
* all copies of any software which is or includes a copy or
|
|
|
|
* modification of this software.
|
|
|
|
* You may use this code under the GNU public license if you so wish. Please
|
|
|
|
* contribute changes back to the authors under this freer than GPL license
|
|
|
|
* so that we may further the use of strong encryption without limitations to
|
|
|
|
* all.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
|
|
|
|
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
|
|
|
|
* MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
|
|
|
|
* PURPOSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2017-08-02 04:28:02 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.68 2017/08/02 01:28:03 ozaki-r Exp $");
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-04-06 12:20:07 +03:00
|
|
|
#if defined(_KERNEL_OPT)
|
2003-08-14 00:06:49 +04:00
|
|
|
#include "opt_inet.h"
|
2015-03-30 06:51:50 +03:00
|
|
|
#include "opt_ipsec.h"
|
2017-04-06 12:20:07 +03:00
|
|
|
#endif
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/sysctl.h>
|
2017-04-19 06:39:14 +03:00
|
|
|
#include <sys/cprng.h>
|
2017-07-20 11:07:14 +03:00
|
|
|
#include <sys/pool.h>
|
2017-08-02 04:28:02 +03:00
|
|
|
#include <sys/pserialize.h>
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/ip_ecn.h>
|
|
|
|
#include <netinet/ip6.h>
|
|
|
|
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <netipsec/ipsec.h>
|
2008-04-23 10:09:04 +04:00
|
|
|
#include <netipsec/ipsec_private.h>
|
2003-08-14 00:06:49 +04:00
|
|
|
#include <netipsec/ah.h>
|
|
|
|
#include <netipsec/ah_var.h>
|
|
|
|
#include <netipsec/esp.h>
|
|
|
|
#include <netipsec/esp_var.h>
|
|
|
|
#include <netipsec/xform.h>
|
|
|
|
|
|
|
|
#ifdef INET6
|
|
|
|
#include <netinet6/ip6_var.h>
|
|
|
|
#include <netipsec/ipsec6.h>
|
|
|
|
#endif
|
|
|
|
|
2003-10-07 02:05:15 +04:00
|
|
|
#include <netipsec/key.h>
|
|
|
|
#include <netipsec/key_debug.h>
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
#include <opencrypto/cryptodev.h>
|
|
|
|
#include <opencrypto/xform.h>
|
|
|
|
|
2008-04-23 10:09:04 +04:00
|
|
|
percpu_t *espstat_percpu;
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
int esp_enable = 1;
|
|
|
|
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
SYSCTL_DECL(_net_inet_esp);
|
|
|
|
SYSCTL_INT(_net_inet_esp, OID_AUTO,
|
|
|
|
esp_enable, CTLFLAG_RW, &esp_enable, 0, "");
|
|
|
|
SYSCTL_STRUCT(_net_inet_esp, IPSECCTL_STATS,
|
|
|
|
stats, CTLFLAG_RD, &espstat, espstat, "");
|
2003-10-07 02:05:15 +04:00
|
|
|
#endif /* __FreeBSD__ */
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
static int esp_max_ivlen; /* max iv length over all algorithms */
|
|
|
|
|
|
|
|
static int esp_input_cb(struct cryptop *op);
|
|
|
|
static int esp_output_cb(struct cryptop *crp);
|
|
|
|
|
2017-04-13 19:38:31 +03:00
|
|
|
const uint8_t esp_stats[256] = { SADB_EALG_STATS_INIT };
|
|
|
|
|
2017-07-20 11:07:14 +03:00
|
|
|
static struct pool esp_tdb_crypto_pool;
|
|
|
|
static size_t esp_pool_item_size;
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
/*
|
|
|
|
* NB: this is public for use by the PF_KEY support.
|
|
|
|
* NB: if you add support here; be sure to add code to esp_attach below!
|
|
|
|
*/
|
2011-02-18 22:56:01 +03:00
|
|
|
const struct enc_xform *
|
2003-08-14 00:06:49 +04:00
|
|
|
esp_algorithm_lookup(int alg)
|
|
|
|
{
|
2017-04-13 04:32:57 +03:00
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
switch (alg) {
|
|
|
|
case SADB_EALG_DESCBC:
|
|
|
|
return &enc_xform_des;
|
|
|
|
case SADB_EALG_3DESCBC:
|
|
|
|
return &enc_xform_3des;
|
|
|
|
case SADB_X_EALG_AES:
|
|
|
|
return &enc_xform_rijndael128;
|
|
|
|
case SADB_X_EALG_BLOWFISHCBC:
|
|
|
|
return &enc_xform_blf;
|
|
|
|
case SADB_X_EALG_CAST128CBC:
|
|
|
|
return &enc_xform_cast5;
|
|
|
|
case SADB_X_EALG_SKIPJACK:
|
|
|
|
return &enc_xform_skipjack;
|
2011-05-05 21:48:29 +04:00
|
|
|
case SADB_X_EALG_CAMELLIACBC:
|
|
|
|
return &enc_xform_camellia;
|
2011-05-23 17:57:52 +04:00
|
|
|
case SADB_X_EALG_AESCTR:
|
|
|
|
return &enc_xform_aes_ctr;
|
2011-05-27 01:50:02 +04:00
|
|
|
case SADB_X_EALG_AESGCM16:
|
|
|
|
return &enc_xform_aes_gcm;
|
|
|
|
case SADB_X_EALG_AESGMAC:
|
|
|
|
return &enc_xform_aes_gmac;
|
2003-08-14 00:06:49 +04:00
|
|
|
case SADB_EALG_NULL:
|
|
|
|
return &enc_xform_null;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
2011-02-18 22:56:01 +03:00
|
|
|
esp_hdrsiz(const struct secasvar *sav)
|
2003-08-14 00:06:49 +04:00
|
|
|
{
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
if (sav != NULL) {
|
|
|
|
/*XXX not right for null algorithm--does it matter??*/
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERT(sav->tdb_encalgxform != NULL);
|
2003-08-14 00:06:49 +04:00
|
|
|
if (sav->flags & SADB_X_EXT_OLD)
|
2017-04-16 01:01:57 +03:00
|
|
|
size = sizeof(struct esp);
|
2003-08-14 00:06:49 +04:00
|
|
|
else
|
2017-04-16 01:01:57 +03:00
|
|
|
size = sizeof(struct newesp);
|
2011-05-23 17:46:54 +04:00
|
|
|
size += sav->tdb_encalgxform->ivsize + 9;
|
2003-08-14 00:06:49 +04:00
|
|
|
/*XXX need alg check???*/
|
|
|
|
if (sav->tdb_authalgxform != NULL && sav->replay)
|
|
|
|
size += ah_hdrsiz(sav);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* base header size
|
|
|
|
* + max iv length for CBC mode
|
|
|
|
* + max pad length
|
2017-04-16 01:01:57 +03:00
|
|
|
* + sizeof(pad length field)
|
|
|
|
* + sizeof(next header field)
|
2003-08-14 00:06:49 +04:00
|
|
|
* + max icv supported.
|
|
|
|
*/
|
2017-07-13 06:00:46 +03:00
|
|
|
size = sizeof(struct newesp) + esp_max_ivlen + 9 +
|
|
|
|
ah_hdrsiz(NULL);
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* esp_init() is called when an SPI is being set up.
|
|
|
|
*/
|
|
|
|
static int
|
2011-02-18 22:56:01 +03:00
|
|
|
esp_init(struct secasvar *sav, const struct xformsw *xsp)
|
2003-08-14 00:06:49 +04:00
|
|
|
{
|
2011-02-18 22:56:01 +03:00
|
|
|
const struct enc_xform *txform;
|
2017-04-10 17:19:22 +03:00
|
|
|
struct cryptoini cria, crie, *cr;
|
2003-08-14 00:06:49 +04:00
|
|
|
int keylen;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
txform = esp_algorithm_lookup(sav->alg_enc);
|
|
|
|
if (txform == NULL) {
|
2017-04-10 17:19:22 +03:00
|
|
|
DPRINTF(("%s: unsupported encryption algorithm %d\n", __func__,
|
|
|
|
sav->alg_enc));
|
2003-08-14 00:06:49 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if (sav->key_enc == NULL) {
|
2017-04-10 17:19:22 +03:00
|
|
|
DPRINTF(("%s: no encoding key for %s algorithm\n", __func__,
|
|
|
|
txform->name));
|
2003-08-14 00:06:49 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if ((sav->flags&(SADB_X_EXT_OLD|SADB_X_EXT_IV4B)) == SADB_X_EXT_IV4B) {
|
2017-04-10 17:19:22 +03:00
|
|
|
DPRINTF(("%s: 4-byte IV not supported with protocol\n",
|
|
|
|
__func__));
|
2003-08-14 00:06:49 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
keylen = _KEYLEN(sav->key_enc);
|
|
|
|
if (txform->minkey > keylen || keylen > txform->maxkey) {
|
2017-04-10 17:19:22 +03:00
|
|
|
DPRINTF(("%s: invalid key length %u, must be in "
|
|
|
|
"the range [%u..%u] for algorithm %s\n", __func__,
|
|
|
|
keylen, txform->minkey, txform->maxkey, txform->name));
|
2003-08-14 00:06:49 +04:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-05-23 17:46:54 +04:00
|
|
|
sav->ivlen = txform->ivsize;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup AH-related state.
|
|
|
|
*/
|
|
|
|
if (sav->alg_auth != 0) {
|
|
|
|
error = ah_init0(sav, xsp, &cria);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NB: override anything set in ah_init0 */
|
|
|
|
sav->tdb_xform = xsp;
|
|
|
|
sav->tdb_encalgxform = txform;
|
|
|
|
|
2017-04-10 17:19:22 +03:00
|
|
|
switch (sav->alg_enc) {
|
|
|
|
case SADB_X_EALG_AESGCM16:
|
|
|
|
case SADB_X_EALG_AESGMAC:
|
2011-05-27 01:50:02 +04:00
|
|
|
switch (keylen) {
|
|
|
|
case 20:
|
|
|
|
sav->alg_auth = SADB_X_AALG_AES128GMAC;
|
|
|
|
sav->tdb_authalgxform = &auth_hash_gmac_aes_128;
|
|
|
|
break;
|
|
|
|
case 28:
|
|
|
|
sav->alg_auth = SADB_X_AALG_AES192GMAC;
|
|
|
|
sav->tdb_authalgxform = &auth_hash_gmac_aes_192;
|
|
|
|
break;
|
|
|
|
case 36:
|
|
|
|
sav->alg_auth = SADB_X_AALG_AES256GMAC;
|
|
|
|
sav->tdb_authalgxform = &auth_hash_gmac_aes_256;
|
|
|
|
break;
|
2017-04-10 17:19:22 +03:00
|
|
|
default:
|
|
|
|
DPRINTF(("%s: invalid key length %u, must be either of "
|
|
|
|
"20, 28 or 36\n", __func__, keylen));
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-05-27 01:50:02 +04:00
|
|
|
memset(&cria, 0, sizeof(cria));
|
|
|
|
cria.cri_alg = sav->tdb_authalgxform->type;
|
|
|
|
cria.cri_klen = _KEYBITS(sav->key_enc);
|
|
|
|
cria.cri_key = _KEYBUF(sav->key_enc);
|
2017-04-10 17:19:22 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2011-05-27 01:50:02 +04:00
|
|
|
}
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
/* Initialize crypto session. */
|
2017-04-16 01:01:57 +03:00
|
|
|
memset(&crie, 0, sizeof(crie));
|
2003-08-14 00:06:49 +04:00
|
|
|
crie.cri_alg = sav->tdb_encalgxform->type;
|
|
|
|
crie.cri_klen = _KEYBITS(sav->key_enc);
|
|
|
|
crie.cri_key = _KEYBUF(sav->key_enc);
|
|
|
|
/* XXX Rounds ? */
|
|
|
|
|
|
|
|
if (sav->tdb_authalgxform && sav->tdb_encalgxform) {
|
|
|
|
/* init both auth & enc */
|
|
|
|
crie.cri_next = &cria;
|
2017-04-10 17:19:22 +03:00
|
|
|
cr = &crie;
|
2003-08-14 00:06:49 +04:00
|
|
|
} else if (sav->tdb_encalgxform) {
|
2017-04-10 17:19:22 +03:00
|
|
|
cr = &crie;
|
2003-08-14 00:06:49 +04:00
|
|
|
} else if (sav->tdb_authalgxform) {
|
2017-04-10 17:19:22 +03:00
|
|
|
cr = &cria;
|
2003-08-14 00:06:49 +04:00
|
|
|
} else {
|
|
|
|
/* XXX cannot happen? */
|
2017-04-10 17:19:22 +03:00
|
|
|
DPRINTF(("%s: no encoding OR authentication xform!\n",
|
|
|
|
__func__));
|
|
|
|
return EINVAL;
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
2017-04-10 17:19:22 +03:00
|
|
|
|
|
|
|
return crypto_newsession(&sav->tdb_cryptoid, cr, crypto_support);
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Paranoia.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
esp_zeroize(struct secasvar *sav)
|
|
|
|
{
|
|
|
|
/* NB: ah_zerorize free's the crypto session state */
|
|
|
|
int error = ah_zeroize(sav);
|
|
|
|
|
2017-07-10 10:17:12 +03:00
|
|
|
if (sav->key_enc) {
|
|
|
|
explicit_memset(_KEYBUF(sav->key_enc), 0,
|
|
|
|
_KEYLEN(sav->key_enc));
|
|
|
|
}
|
2003-08-14 00:06:49 +04:00
|
|
|
sav->tdb_encalgxform = NULL;
|
|
|
|
sav->tdb_xform = NULL;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESP input processing, called (eventually) through the protocol switch.
|
|
|
|
*/
|
|
|
|
static int
|
2017-07-14 04:24:23 +03:00
|
|
|
esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
|
2003-08-14 00:06:49 +04:00
|
|
|
{
|
2011-02-18 22:56:01 +03:00
|
|
|
const struct auth_hash *esph;
|
|
|
|
const struct enc_xform *espx;
|
2003-08-14 00:06:49 +04:00
|
|
|
struct tdb_crypto *tc;
|
2012-01-26 00:31:23 +04:00
|
|
|
int plen, alen, hlen, error;
|
2003-08-14 00:06:49 +04:00
|
|
|
struct newesp *esp;
|
|
|
|
|
|
|
|
struct cryptodesc *crde;
|
|
|
|
struct cryptop *crp;
|
|
|
|
|
2017-04-16 01:01:57 +03:00
|
|
|
IPSEC_SPLASSERT_SOFTNET(__func__);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERT(sav != NULL);
|
|
|
|
KASSERT(sav->tdb_encalgxform != NULL);
|
|
|
|
KASSERTMSG((skip&3) == 0 && (m->m_pkthdr.len&3) == 0,
|
|
|
|
"misaligned packet, skip %u pkt len %u",
|
|
|
|
skip, m->m_pkthdr.len);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* XXX don't pullup, just copy header */
|
2017-04-16 01:01:57 +03:00
|
|
|
IP6_EXTHDR_GET(esp, struct newesp *, m, skip, sizeof(struct newesp));
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
esph = sav->tdb_authalgxform;
|
|
|
|
espx = sav->tdb_encalgxform;
|
|
|
|
|
|
|
|
/* Determine the ESP header length */
|
|
|
|
if (sav->flags & SADB_X_EXT_OLD)
|
2017-04-16 01:01:57 +03:00
|
|
|
hlen = sizeof(struct esp) + sav->ivlen;
|
2003-08-14 00:06:49 +04:00
|
|
|
else
|
2017-04-16 01:01:57 +03:00
|
|
|
hlen = sizeof(struct newesp) + sav->ivlen;
|
2003-08-14 00:06:49 +04:00
|
|
|
/* Authenticator hash size */
|
2011-02-25 23:13:10 +03:00
|
|
|
alen = esph ? esph->authsize : 0;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify payload length is multiple of encryption algorithm
|
|
|
|
* block size.
|
|
|
|
*
|
|
|
|
* NB: This works for the null algorithm because the blocksize
|
|
|
|
* is 4 and all packets must be 4-byte aligned regardless
|
|
|
|
* of the algorithm.
|
|
|
|
*/
|
|
|
|
plen = m->m_pkthdr.len - (skip + hlen + alen);
|
|
|
|
if ((plen & (espx->blocksize - 1)) || (plen <= 0)) {
|
2017-05-11 08:55:14 +03:00
|
|
|
char buf[IPSEC_ADDRSTRLEN];
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: payload of %d octets not a multiple of %d octets,"
|
|
|
|
" SA %s/%08lx\n", __func__, plen, espx->blocksize,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)),
|
2003-08-14 00:06:49 +04:00
|
|
|
(u_long) ntohl(sav->spi)));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_BADILEN);
|
2003-08-14 00:06:49 +04:00
|
|
|
m_freem(m);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check sequence number.
|
|
|
|
*/
|
|
|
|
if (esph && sav->replay && !ipsec_chkreplay(ntohl(esp->esp_seq), sav)) {
|
2017-05-11 08:55:14 +03:00
|
|
|
char logbuf[IPSEC_LOGSASTRLEN];
|
|
|
|
DPRINTF(("%s: packet replay check for %s\n", __func__,
|
|
|
|
ipsec_logsastr(sav, logbuf, sizeof(logbuf)))); /*XXX*/
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_REPLAY);
|
2003-08-14 00:06:49 +04:00
|
|
|
m_freem(m);
|
|
|
|
return ENOBUFS; /*XXX*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the counters */
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATADD(ESP_STAT_IBYTES, m->m_pkthdr.len - skip - hlen - alen);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Get crypto descriptors */
|
|
|
|
crp = crypto_getreq(esph && espx ? 2 : 1);
|
|
|
|
if (crp == NULL) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: failed to acquire crypto descriptors\n",
|
|
|
|
__func__));
|
|
|
|
error = ENOBUFS;
|
|
|
|
goto out;
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get IPsec-specific opaque pointer */
|
2017-07-20 11:07:14 +03:00
|
|
|
size_t extra __diagused = esph == NULL ? 0 : alen;
|
|
|
|
KASSERTMSG(sizeof(*tc) + extra <= esp_pool_item_size,
|
|
|
|
"sizeof(*tc) + extra=%zu > esp_pool_item_size=%zu\n",
|
|
|
|
sizeof(*tc) + extra, esp_pool_item_size);
|
|
|
|
tc = pool_get(&esp_tdb_crypto_pool, PR_NOWAIT);
|
2003-08-14 00:06:49 +04:00
|
|
|
if (tc == NULL) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
|
|
|
|
error = ENOBUFS;
|
|
|
|
goto out1;
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
2012-01-26 00:31:23 +04:00
|
|
|
error = m_makewritable(&m, 0, m->m_pkthdr.len, M_NOWAIT);
|
|
|
|
if (error) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: m_makewritable failed\n", __func__));
|
|
|
|
goto out2;
|
2012-01-26 00:31:23 +04:00
|
|
|
}
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
if (esph) {
|
2017-04-18 08:26:41 +03:00
|
|
|
struct cryptodesc *crda;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERT(crp->crp_desc != NULL);
|
|
|
|
crda = crp->crp_desc;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Authentication descriptor */
|
|
|
|
crda->crd_skip = skip;
|
2011-05-27 01:50:02 +04:00
|
|
|
if (espx && espx->type == CRYPTO_AES_GCM_16)
|
|
|
|
crda->crd_len = hlen - sav->ivlen;
|
|
|
|
else
|
|
|
|
crda->crd_len = m->m_pkthdr.len - (skip + alen);
|
2003-08-14 00:06:49 +04:00
|
|
|
crda->crd_inject = m->m_pkthdr.len - alen;
|
|
|
|
|
|
|
|
crda->crd_alg = esph->type;
|
2011-05-27 01:50:02 +04:00
|
|
|
if (espx && (espx->type == CRYPTO_AES_GCM_16 ||
|
|
|
|
espx->type == CRYPTO_AES_GMAC)) {
|
|
|
|
crda->crd_key = _KEYBUF(sav->key_enc);
|
|
|
|
crda->crd_klen = _KEYBITS(sav->key_enc);
|
|
|
|
} else {
|
|
|
|
crda->crd_key = _KEYBUF(sav->key_auth);
|
|
|
|
crda->crd_klen = _KEYBITS(sav->key_auth);
|
|
|
|
}
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Copy the authenticator */
|
2017-07-05 06:44:59 +03:00
|
|
|
m_copydata(m, m->m_pkthdr.len - alen, alen, (tc + 1));
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Chain authentication request */
|
|
|
|
crde = crda->crd_next;
|
|
|
|
} else {
|
|
|
|
crde = crp->crp_desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Crypto operation descriptor */
|
|
|
|
crp->crp_ilen = m->m_pkthdr.len; /* Total input length */
|
|
|
|
crp->crp_flags = CRYPTO_F_IMBUF;
|
2007-03-05 00:17:54 +03:00
|
|
|
crp->crp_buf = m;
|
2003-08-14 00:06:49 +04:00
|
|
|
crp->crp_callback = esp_input_cb;
|
|
|
|
crp->crp_sid = sav->tdb_cryptoid;
|
2007-03-05 00:17:54 +03:00
|
|
|
crp->crp_opaque = tc;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* These are passed as-is to the callback */
|
|
|
|
tc->tc_spi = sav->spi;
|
|
|
|
tc->tc_dst = sav->sah->saidx.dst;
|
|
|
|
tc->tc_proto = sav->sah->saidx.proto;
|
|
|
|
tc->tc_protoff = protoff;
|
|
|
|
tc->tc_skip = skip;
|
2017-07-14 04:24:23 +03:00
|
|
|
tc->tc_sav = sav;
|
|
|
|
KEY_SA_REF(sav);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Decryption descriptor */
|
|
|
|
if (espx) {
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERTMSG(crde != NULL, "null esp crypto descriptor");
|
2003-08-14 00:06:49 +04:00
|
|
|
crde->crd_skip = skip + hlen;
|
2011-05-27 01:50:02 +04:00
|
|
|
if (espx->type == CRYPTO_AES_GMAC)
|
|
|
|
crde->crd_len = 0;
|
|
|
|
else
|
|
|
|
crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen);
|
2003-08-14 00:06:49 +04:00
|
|
|
crde->crd_inject = skip + hlen - sav->ivlen;
|
|
|
|
|
|
|
|
crde->crd_alg = espx->type;
|
|
|
|
crde->crd_key = _KEYBUF(sav->key_enc);
|
|
|
|
crde->crd_klen = _KEYBITS(sav->key_enc);
|
|
|
|
/* XXX Rounds ? */
|
|
|
|
}
|
|
|
|
|
2017-07-05 06:44:59 +03:00
|
|
|
return crypto_dispatch(crp);
|
2017-04-16 01:01:57 +03:00
|
|
|
|
|
|
|
out2:
|
2017-07-20 11:07:14 +03:00
|
|
|
pool_put(&esp_tdb_crypto_pool, tc);
|
2017-04-16 01:01:57 +03:00
|
|
|
out1:
|
|
|
|
crypto_freereq(crp);
|
|
|
|
out:
|
|
|
|
ESP_STATINC(ESP_STAT_CRYPTO);
|
|
|
|
m_freem(m);
|
|
|
|
return error;
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef INET6
|
2017-07-05 06:44:59 +03:00
|
|
|
#define IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) do { \
|
2003-08-14 00:06:49 +04:00
|
|
|
if (saidx->dst.sa.sa_family == AF_INET6) { \
|
2017-07-05 06:44:59 +03:00
|
|
|
error = ipsec6_common_input_cb(m, sav, skip, protoff); \
|
2003-08-14 00:06:49 +04:00
|
|
|
} else { \
|
2017-07-05 06:44:59 +03:00
|
|
|
error = ipsec4_common_input_cb(m, sav, skip, protoff); \
|
2003-08-14 00:06:49 +04:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#else
|
2017-07-05 06:44:59 +03:00
|
|
|
#define IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff) \
|
|
|
|
(error = ipsec4_common_input_cb(m, sav, skip, protoff))
|
2003-08-14 00:06:49 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESP input callback from the crypto driver.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
esp_input_cb(struct cryptop *crp)
|
|
|
|
{
|
2017-05-11 08:55:14 +03:00
|
|
|
char buf[IPSEC_ADDRSTRLEN];
|
2017-04-16 01:01:57 +03:00
|
|
|
uint8_t lastthree[3], aalg[AH_ALEN_MAX];
|
2017-07-27 09:59:28 +03:00
|
|
|
int hlen, skip, protoff, error;
|
2003-08-14 00:06:49 +04:00
|
|
|
struct mbuf *m;
|
2011-02-18 22:56:01 +03:00
|
|
|
const struct auth_hash *esph;
|
2003-08-14 00:06:49 +04:00
|
|
|
struct tdb_crypto *tc;
|
|
|
|
struct secasvar *sav;
|
|
|
|
struct secasindex *saidx;
|
2007-03-04 08:59:00 +03:00
|
|
|
void *ptr;
|
2017-04-16 01:01:57 +03:00
|
|
|
uint16_t dport;
|
|
|
|
uint16_t sport;
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_DECLARE_LOCK_VARIABLE;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERT(crp->crp_desc != NULL);
|
|
|
|
KASSERT(crp->crp_opaque != NULL);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-04-16 01:01:57 +03:00
|
|
|
tc = crp->crp_opaque;
|
2003-08-14 00:06:49 +04:00
|
|
|
skip = tc->tc_skip;
|
|
|
|
protoff = tc->tc_protoff;
|
2017-04-16 01:01:57 +03:00
|
|
|
m = crp->crp_buf;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2007-06-28 00:38:32 +04:00
|
|
|
/* find the source port for NAT-T */
|
2013-06-05 02:47:37 +04:00
|
|
|
nat_t_ports_get(m, &dport, &sport);
|
2007-06-28 00:38:32 +04:00
|
|
|
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_ACQUIRE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-07-14 04:24:23 +03:00
|
|
|
sav = tc->tc_sav;
|
|
|
|
if (__predict_false(!SADB_SASTATE_USABLE_P(sav))) {
|
|
|
|
KEY_FREESAV(&sav);
|
|
|
|
sav = KEY_LOOKUP_SA(&tc->tc_dst, tc->tc_proto, tc->tc_spi,
|
|
|
|
sport, dport);
|
|
|
|
if (sav == NULL) {
|
|
|
|
ESP_STATINC(ESP_STAT_NOTDB);
|
|
|
|
DPRINTF(("%s: SA expired while in crypto "
|
|
|
|
"(SA %s/%08lx proto %u)\n", __func__,
|
|
|
|
ipsec_address(&tc->tc_dst, buf, sizeof(buf)),
|
|
|
|
(u_long) ntohl(tc->tc_spi), tc->tc_proto));
|
|
|
|
error = ENOBUFS; /*XXX*/
|
|
|
|
goto bad;
|
|
|
|
}
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
saidx = &sav->sah->saidx;
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERTMSG(saidx->dst.sa.sa_family == AF_INET ||
|
2017-04-16 01:01:57 +03:00
|
|
|
saidx->dst.sa.sa_family == AF_INET6,
|
2017-04-18 08:26:41 +03:00
|
|
|
"unexpected protocol family %u", saidx->dst.sa.sa_family);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
esph = sav->tdb_authalgxform;
|
|
|
|
|
|
|
|
/* Check for crypto errors */
|
|
|
|
if (crp->crp_etype) {
|
|
|
|
/* Reset the session ID */
|
|
|
|
if (sav->tdb_cryptoid != 0)
|
|
|
|
sav->tdb_cryptoid = crp->crp_sid;
|
|
|
|
|
|
|
|
if (crp->crp_etype == EAGAIN) {
|
|
|
|
KEY_FREESAV(&sav);
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_RELEASE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
return crypto_dispatch(crp);
|
|
|
|
}
|
|
|
|
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_NOXFORM);
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
|
2003-08-14 00:06:49 +04:00
|
|
|
error = crp->crp_etype;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2017-04-13 19:38:31 +03:00
|
|
|
ESP_STATINC(ESP_STAT_HIST + esp_stats[sav->alg_enc]);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* If authentication was performed, check now. */
|
|
|
|
if (esph != NULL) {
|
|
|
|
/*
|
|
|
|
* If we have a tag, it means an IPsec-aware NIC did
|
|
|
|
* the verification for us. Otherwise we need to
|
|
|
|
* check the authentication calculation.
|
|
|
|
*/
|
2017-04-13 19:38:31 +03:00
|
|
|
AH_STATINC(AH_STAT_HIST + ah_stats[sav->alg_auth]);
|
2017-07-05 06:44:59 +03:00
|
|
|
/* Copy the authenticator from the packet */
|
|
|
|
m_copydata(m, m->m_pkthdr.len - esph->authsize,
|
|
|
|
esph->authsize, aalg);
|
|
|
|
|
|
|
|
ptr = (tc + 1);
|
|
|
|
|
|
|
|
/* Verify authenticator */
|
|
|
|
if (!consttime_memequal(ptr, aalg, esph->authsize)) {
|
|
|
|
DPRINTF(("%s: authentication hash mismatch "
|
|
|
|
"for packet in SA %s/%08lx\n", __func__,
|
|
|
|
ipsec_address(&saidx->dst, buf,
|
|
|
|
sizeof(buf)), (u_long) ntohl(sav->spi)));
|
|
|
|
ESP_STATINC(ESP_STAT_BADAUTH);
|
|
|
|
error = EACCES;
|
|
|
|
goto bad;
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove trailing authenticator */
|
|
|
|
m_adj(m, -(esph->authsize));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release the crypto descriptors */
|
2017-07-20 11:07:14 +03:00
|
|
|
pool_put(&esp_tdb_crypto_pool, tc);
|
|
|
|
tc = NULL;
|
2003-08-14 00:06:49 +04:00
|
|
|
crypto_freereq(crp), crp = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Packet is now decrypted.
|
|
|
|
*/
|
|
|
|
m->m_flags |= M_DECRYPTED;
|
|
|
|
|
2006-03-23 18:25:46 +03:00
|
|
|
/*
|
|
|
|
* Update replay sequence number, if appropriate.
|
|
|
|
*/
|
|
|
|
if (sav->replay) {
|
2017-04-16 01:01:57 +03:00
|
|
|
uint32_t seq;
|
2006-03-23 18:25:46 +03:00
|
|
|
|
|
|
|
m_copydata(m, skip + offsetof(struct newesp, esp_seq),
|
2017-04-16 01:01:57 +03:00
|
|
|
sizeof(seq), &seq);
|
2006-03-23 18:25:46 +03:00
|
|
|
if (ipsec_updatereplay(ntohl(seq), sav)) {
|
2017-05-11 08:55:14 +03:00
|
|
|
char logbuf[IPSEC_LOGSASTRLEN];
|
2006-03-23 18:25:46 +03:00
|
|
|
DPRINTF(("%s: packet replay check for %s\n", __func__,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_logsastr(sav, logbuf, sizeof(logbuf))));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_REPLAY);
|
2006-03-23 18:25:46 +03:00
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
/* Determine the ESP header length */
|
|
|
|
if (sav->flags & SADB_X_EXT_OLD)
|
2017-04-16 01:01:57 +03:00
|
|
|
hlen = sizeof(struct esp) + sav->ivlen;
|
2003-08-14 00:06:49 +04:00
|
|
|
else
|
2017-04-16 01:01:57 +03:00
|
|
|
hlen = sizeof(struct newesp) + sav->ivlen;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Remove the ESP header and IV from the mbuf. */
|
|
|
|
error = m_striphdr(m, skip, hlen);
|
|
|
|
if (error) {
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_HDROPS);
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: bad mbuf chain, SA %s/%08lx\n", __func__,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)),
|
2003-08-14 00:06:49 +04:00
|
|
|
(u_long) ntohl(sav->spi)));
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the last three bytes of decrypted data */
|
|
|
|
m_copydata(m, m->m_pkthdr.len - 3, 3, lastthree);
|
|
|
|
|
|
|
|
/* Verify pad length */
|
|
|
|
if (lastthree[1] + 2 > m->m_pkthdr.len - skip) {
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_BADILEN);
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: invalid padding length %d "
|
|
|
|
"for %u byte packet in SA %s/%08lx\n", __func__,
|
|
|
|
lastthree[1], m->m_pkthdr.len - skip,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)),
|
2017-04-16 01:01:57 +03:00
|
|
|
(u_long) ntohl(sav->spi)));
|
2003-08-14 00:06:49 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify correct decryption by checking the last padding bytes */
|
|
|
|
if ((sav->flags & SADB_X_EXT_PMASK) != SADB_X_EXT_PRAND) {
|
|
|
|
if (lastthree[1] != lastthree[0] && lastthree[1] != 0) {
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_BADENC);
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: decryption failed for packet in SA "
|
|
|
|
"%s/%08lx\n", __func__,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&sav->sah->saidx.dst, buf,
|
|
|
|
sizeof(buf)), (u_long) ntohl(sav->spi)));
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: %x %x\n", __func__, lastthree[0],
|
|
|
|
lastthree[1]));
|
2003-08-14 00:06:49 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Trim the mbuf chain to remove trailing authenticator and padding */
|
|
|
|
m_adj(m, -(lastthree[1] + 2));
|
|
|
|
|
|
|
|
/* Restore the Next Protocol field */
|
2017-04-16 01:01:57 +03:00
|
|
|
m_copyback(m, protoff, sizeof(uint8_t), lastthree + 2);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-07-05 06:44:59 +03:00
|
|
|
IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
KEY_FREESAV(&sav);
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_RELEASE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
return error;
|
|
|
|
bad:
|
|
|
|
if (sav)
|
|
|
|
KEY_FREESAV(&sav);
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_RELEASE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
if (m != NULL)
|
|
|
|
m_freem(m);
|
|
|
|
if (tc != NULL)
|
2017-07-20 11:07:14 +03:00
|
|
|
pool_put(&esp_tdb_crypto_pool, tc);
|
2003-08-14 00:06:49 +04:00
|
|
|
if (crp != NULL)
|
|
|
|
crypto_freereq(crp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESP output routine, called by ipsec[46]_process_packet().
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
esp_output(
|
2006-10-14 00:53:59 +04:00
|
|
|
struct mbuf *m,
|
|
|
|
struct ipsecrequest *isr,
|
2017-07-14 15:26:26 +03:00
|
|
|
struct secasvar *sav,
|
2006-11-16 04:32:37 +03:00
|
|
|
struct mbuf **mp,
|
2006-10-14 00:53:59 +04:00
|
|
|
int skip,
|
|
|
|
int protoff
|
2003-08-14 00:06:49 +04:00
|
|
|
)
|
|
|
|
{
|
2017-05-11 08:55:14 +03:00
|
|
|
char buf[IPSEC_ADDRSTRLEN];
|
2011-02-18 22:56:01 +03:00
|
|
|
const struct enc_xform *espx;
|
|
|
|
const struct auth_hash *esph;
|
2013-11-03 22:37:10 +04:00
|
|
|
int hlen, rlen, padding, blks, alen, i, roff;
|
2011-08-31 22:31:02 +04:00
|
|
|
struct mbuf *mo = NULL;
|
2003-08-14 00:06:49 +04:00
|
|
|
struct tdb_crypto *tc;
|
|
|
|
struct secasindex *saidx;
|
|
|
|
unsigned char *pad;
|
2017-04-16 01:01:57 +03:00
|
|
|
uint8_t prot;
|
2003-08-14 00:06:49 +04:00
|
|
|
int error, maxpacketsize;
|
|
|
|
|
|
|
|
struct cryptodesc *crde = NULL, *crda = NULL;
|
|
|
|
struct cryptop *crp;
|
|
|
|
|
2017-04-16 01:01:57 +03:00
|
|
|
IPSEC_SPLASSERT_SOFTNET(__func__);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
esph = sav->tdb_authalgxform;
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERT(sav->tdb_encalgxform != NULL);
|
2003-08-14 00:06:49 +04:00
|
|
|
espx = sav->tdb_encalgxform;
|
|
|
|
|
|
|
|
if (sav->flags & SADB_X_EXT_OLD)
|
2017-04-16 01:01:57 +03:00
|
|
|
hlen = sizeof(struct esp) + sav->ivlen;
|
2003-08-14 00:06:49 +04:00
|
|
|
else
|
2017-04-16 01:01:57 +03:00
|
|
|
hlen = sizeof(struct newesp) + sav->ivlen;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
rlen = m->m_pkthdr.len - skip; /* Raw payload length. */
|
|
|
|
/*
|
|
|
|
* NB: The null encoding transform has a blocksize of 4
|
|
|
|
* so that headers are properly aligned.
|
|
|
|
*/
|
|
|
|
blks = espx->blocksize; /* IV blocksize */
|
|
|
|
|
|
|
|
/* XXX clamp padding length a la KAME??? */
|
|
|
|
padding = ((blks - ((rlen + 2) % blks)) % blks) + 2;
|
|
|
|
|
|
|
|
if (esph)
|
2011-02-25 23:13:10 +03:00
|
|
|
alen = esph->authsize;
|
2003-08-14 00:06:49 +04:00
|
|
|
else
|
|
|
|
alen = 0;
|
|
|
|
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_OUTPUT);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
saidx = &sav->sah->saidx;
|
|
|
|
/* Check for maximum packet size violations. */
|
|
|
|
switch (saidx->dst.sa.sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
maxpacketsize = IP_MAXPACKET;
|
|
|
|
break;
|
|
|
|
#endif /* INET */
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
maxpacketsize = IPV6_MAXPACKET;
|
|
|
|
break;
|
|
|
|
#endif /* INET6 */
|
|
|
|
default:
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: unknown/unsupported protocol family %d, "
|
|
|
|
"SA %s/%08lx\n", __func__, saidx->dst.sa.sa_family,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&saidx->dst, buf, sizeof(buf)),
|
|
|
|
(u_long)ntohl(sav->spi)));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_NOPF);
|
2003-08-14 00:06:49 +04:00
|
|
|
error = EPFNOSUPPORT;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
if (skip + hlen + rlen + padding + alen > maxpacketsize) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: packet in SA %s/%08lx got too big (len %u, "
|
2017-05-11 08:55:14 +03:00
|
|
|
"max len %u)\n", __func__,
|
|
|
|
ipsec_address(&saidx->dst, buf, sizeof(buf)),
|
2017-04-16 01:01:57 +03:00
|
|
|
(u_long) ntohl(sav->spi),
|
2003-08-14 00:06:49 +04:00
|
|
|
skip + hlen + rlen + padding + alen, maxpacketsize));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_TOOBIG);
|
2003-08-14 00:06:49 +04:00
|
|
|
error = EMSGSIZE;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the counters. */
|
2011-02-14 19:34:43 +03:00
|
|
|
ESP_STATADD(ESP_STAT_OBYTES, m->m_pkthdr.len - skip);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
m = m_clone(m);
|
|
|
|
if (m == NULL) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: cannot clone mbuf chain, SA %s/%08lx\n", __func__,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&saidx->dst, buf, sizeof(buf)),
|
|
|
|
(u_long) ntohl(sav->spi)));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_HDROPS);
|
2003-08-14 00:06:49 +04:00
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Inject ESP header. */
|
|
|
|
mo = m_makespace(m, skip, hlen, &roff);
|
|
|
|
if (mo == NULL) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: failed to inject %u byte ESP hdr for SA "
|
2017-05-11 08:55:14 +03:00
|
|
|
"%s/%08lx\n", __func__, hlen,
|
|
|
|
ipsec_address(&saidx->dst, buf, sizeof(buf)),
|
2003-08-14 00:06:49 +04:00
|
|
|
(u_long) ntohl(sav->spi)));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_HDROPS); /* XXX diffs from openbsd */
|
2003-08-14 00:06:49 +04:00
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize ESP header. */
|
2017-04-16 01:01:57 +03:00
|
|
|
memcpy(mtod(mo, char *) + roff, &sav->spi, sizeof(uint32_t));
|
2003-08-14 00:06:49 +04:00
|
|
|
if (sav->replay) {
|
2017-04-16 01:01:57 +03:00
|
|
|
uint32_t replay;
|
2006-04-12 00:21:28 +04:00
|
|
|
|
|
|
|
#ifdef IPSEC_DEBUG
|
|
|
|
/* Emulate replay attack when ipsec_replay is TRUE. */
|
|
|
|
if (!ipsec_replay)
|
|
|
|
#endif
|
|
|
|
sav->replay->count++;
|
|
|
|
|
|
|
|
replay = htonl(sav->replay->count);
|
2017-04-16 01:01:57 +03:00
|
|
|
memcpy(mtod(mo,char *) + roff + sizeof(uint32_t), &replay,
|
|
|
|
sizeof(uint32_t));
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add padding -- better to do it ourselves than use the crypto engine,
|
|
|
|
* although if/when we support compression, we'd have to do that.
|
|
|
|
*/
|
2017-04-16 01:01:57 +03:00
|
|
|
pad = m_pad(m, padding + alen);
|
2003-08-14 00:06:49 +04:00
|
|
|
if (pad == NULL) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: m_pad failed for SA %s/%08lx\n", __func__,
|
2017-05-11 08:55:14 +03:00
|
|
|
ipsec_address(&saidx->dst, buf, sizeof(buf)),
|
|
|
|
(u_long) ntohl(sav->spi)));
|
2003-08-14 00:06:49 +04:00
|
|
|
m = NULL; /* NB: free'd by m_pad */
|
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add padding: random, zero, or self-describing.
|
|
|
|
* XXX catch unexpected setting
|
|
|
|
*/
|
|
|
|
switch (sav->flags & SADB_X_EXT_PMASK) {
|
|
|
|
case SADB_X_EXT_PRAND:
|
2017-04-19 06:39:14 +03:00
|
|
|
(void) cprng_fast(pad, padding - 2);
|
2003-08-14 00:06:49 +04:00
|
|
|
break;
|
|
|
|
case SADB_X_EXT_PZERO:
|
2009-03-18 19:00:08 +03:00
|
|
|
memset(pad, 0, padding - 2);
|
2003-08-14 00:06:49 +04:00
|
|
|
break;
|
|
|
|
case SADB_X_EXT_PSEQ:
|
|
|
|
for (i = 0; i < padding - 2; i++)
|
|
|
|
pad[i] = i+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fix padding length and Next Protocol in padding itself. */
|
|
|
|
pad[padding - 2] = padding - 2;
|
2017-04-16 01:01:57 +03:00
|
|
|
m_copydata(m, protoff, sizeof(uint8_t), pad + padding - 1);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Fix Next Protocol in IPv4/IPv6 header. */
|
|
|
|
prot = IPPROTO_ESP;
|
2017-04-16 01:01:57 +03:00
|
|
|
m_copyback(m, protoff, sizeof(uint8_t), &prot);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Get crypto descriptors. */
|
|
|
|
crp = crypto_getreq(esph && espx ? 2 : 1);
|
|
|
|
if (crp == NULL) {
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: failed to acquire crypto descriptors\n",
|
|
|
|
__func__));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_CRYPTO);
|
2003-08-14 00:06:49 +04:00
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (espx) {
|
|
|
|
crde = crp->crp_desc;
|
|
|
|
crda = crde->crd_next;
|
|
|
|
|
|
|
|
/* Encryption descriptor. */
|
|
|
|
crde->crd_skip = skip + hlen;
|
2011-05-27 01:50:02 +04:00
|
|
|
if (espx->type == CRYPTO_AES_GMAC)
|
|
|
|
crde->crd_len = 0;
|
|
|
|
else
|
|
|
|
crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen);
|
2003-08-14 00:06:49 +04:00
|
|
|
crde->crd_flags = CRD_F_ENCRYPT;
|
|
|
|
crde->crd_inject = skip + hlen - sav->ivlen;
|
|
|
|
|
|
|
|
/* Encryption operation. */
|
|
|
|
crde->crd_alg = espx->type;
|
|
|
|
crde->crd_key = _KEYBUF(sav->key_enc);
|
|
|
|
crde->crd_klen = _KEYBITS(sav->key_enc);
|
|
|
|
/* XXX Rounds ? */
|
|
|
|
} else
|
|
|
|
crda = crp->crp_desc;
|
|
|
|
|
|
|
|
/* IPsec-specific opaque crypto info. */
|
2017-07-20 11:07:14 +03:00
|
|
|
tc = pool_get(&esp_tdb_crypto_pool, PR_NOWAIT);
|
2003-08-14 00:06:49 +04:00
|
|
|
if (tc == NULL) {
|
|
|
|
crypto_freereq(crp);
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_CRYPTO);
|
2003-08-14 00:06:49 +04:00
|
|
|
error = ENOBUFS;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2017-08-02 04:28:02 +03:00
|
|
|
{
|
|
|
|
int s = pserialize_read_enter();
|
|
|
|
|
|
|
|
if (__predict_false(isr->sp->state == IPSEC_SPSTATE_DEAD)) {
|
|
|
|
pserialize_read_exit(s);
|
|
|
|
pool_put(&esp_tdb_crypto_pool, tc);
|
|
|
|
crypto_freereq(crp);
|
|
|
|
ESP_STATINC(ESP_STAT_NOTDB);
|
|
|
|
error = ENOENT;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
KEY_SP_REF(isr->sp);
|
|
|
|
pserialize_read_exit(s);
|
|
|
|
}
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
/* Callback parameters */
|
|
|
|
tc->tc_isr = isr;
|
|
|
|
tc->tc_spi = sav->spi;
|
|
|
|
tc->tc_dst = saidx->dst;
|
|
|
|
tc->tc_proto = saidx->proto;
|
2017-07-14 04:24:23 +03:00
|
|
|
tc->tc_sav = sav;
|
|
|
|
KEY_SA_REF(sav);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Crypto operation descriptor. */
|
|
|
|
crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */
|
|
|
|
crp->crp_flags = CRYPTO_F_IMBUF;
|
2007-03-05 00:17:54 +03:00
|
|
|
crp->crp_buf = m;
|
2003-08-14 00:06:49 +04:00
|
|
|
crp->crp_callback = esp_output_cb;
|
2007-03-05 00:17:54 +03:00
|
|
|
crp->crp_opaque = tc;
|
2003-08-14 00:06:49 +04:00
|
|
|
crp->crp_sid = sav->tdb_cryptoid;
|
|
|
|
|
|
|
|
if (esph) {
|
|
|
|
/* Authentication descriptor. */
|
|
|
|
crda->crd_skip = skip;
|
2011-05-27 01:50:02 +04:00
|
|
|
if (espx && espx->type == CRYPTO_AES_GCM_16)
|
|
|
|
crda->crd_len = hlen - sav->ivlen;
|
|
|
|
else
|
|
|
|
crda->crd_len = m->m_pkthdr.len - (skip + alen);
|
2003-08-14 00:06:49 +04:00
|
|
|
crda->crd_inject = m->m_pkthdr.len - alen;
|
|
|
|
|
|
|
|
/* Authentication operation. */
|
|
|
|
crda->crd_alg = esph->type;
|
2011-05-27 01:50:02 +04:00
|
|
|
if (espx && (espx->type == CRYPTO_AES_GCM_16 ||
|
|
|
|
espx->type == CRYPTO_AES_GMAC)) {
|
|
|
|
crda->crd_key = _KEYBUF(sav->key_enc);
|
|
|
|
crda->crd_klen = _KEYBITS(sav->key_enc);
|
|
|
|
} else {
|
|
|
|
crda->crd_key = _KEYBUF(sav->key_auth);
|
|
|
|
crda->crd_klen = _KEYBITS(sav->key_auth);
|
|
|
|
}
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return crypto_dispatch(crp);
|
|
|
|
bad:
|
|
|
|
if (m)
|
|
|
|
m_freem(m);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESP output callback from the crypto driver.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
esp_output_cb(struct cryptop *crp)
|
|
|
|
{
|
|
|
|
struct tdb_crypto *tc;
|
|
|
|
struct ipsecrequest *isr;
|
|
|
|
struct secasvar *sav;
|
|
|
|
struct mbuf *m;
|
2017-07-27 09:59:28 +03:00
|
|
|
int err, error;
|
|
|
|
IPSEC_DECLARE_LOCK_VARIABLE;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-04-18 08:26:41 +03:00
|
|
|
KASSERT(crp->crp_opaque != NULL);
|
2017-04-16 01:01:57 +03:00
|
|
|
tc = crp->crp_opaque;
|
|
|
|
m = crp->crp_buf;
|
2003-08-14 00:06:49 +04:00
|
|
|
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_ACQUIRE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
isr = tc->tc_isr;
|
2017-07-14 04:24:23 +03:00
|
|
|
sav = tc->tc_sav;
|
2017-07-19 13:26:09 +03:00
|
|
|
if (__predict_false(isr->sp->state == IPSEC_SPSTATE_DEAD)) {
|
|
|
|
ESP_STATINC(ESP_STAT_NOTDB);
|
|
|
|
IPSECLOG(LOG_DEBUG,
|
|
|
|
"SP is being destroyed while in crypto (id=%u)\n",
|
|
|
|
isr->sp->id);
|
|
|
|
error = ENOENT;
|
|
|
|
goto bad;
|
|
|
|
}
|
2017-07-14 04:24:23 +03:00
|
|
|
if (__predict_false(!SADB_SASTATE_USABLE_P(sav))) {
|
|
|
|
KEY_FREESAV(&sav);
|
|
|
|
sav = KEY_LOOKUP_SA(&tc->tc_dst, tc->tc_proto, tc->tc_spi, 0, 0);
|
|
|
|
if (sav == NULL) {
|
|
|
|
char buf[IPSEC_ADDRSTRLEN];
|
|
|
|
ESP_STATINC(ESP_STAT_NOTDB);
|
|
|
|
DPRINTF(("%s: SA expired while in crypto (SA %s/%08lx "
|
|
|
|
"proto %u)\n", __func__,
|
|
|
|
ipsec_address(&tc->tc_dst, buf, sizeof(buf)),
|
|
|
|
(u_long) ntohl(tc->tc_spi), tc->tc_proto));
|
|
|
|
error = ENOBUFS; /*XXX*/
|
|
|
|
goto bad;
|
|
|
|
}
|
2003-08-14 00:06:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for crypto errors. */
|
|
|
|
if (crp->crp_etype) {
|
|
|
|
/* Reset session ID. */
|
|
|
|
if (sav->tdb_cryptoid != 0)
|
|
|
|
sav->tdb_cryptoid = crp->crp_sid;
|
|
|
|
|
|
|
|
if (crp->crp_etype == EAGAIN) {
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_RELEASE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
return crypto_dispatch(crp);
|
|
|
|
}
|
|
|
|
|
2008-04-23 10:09:04 +04:00
|
|
|
ESP_STATINC(ESP_STAT_NOXFORM);
|
2017-04-16 01:01:57 +03:00
|
|
|
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
|
2003-08-14 00:06:49 +04:00
|
|
|
error = crp->crp_etype;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2017-04-13 19:38:31 +03:00
|
|
|
ESP_STATINC(ESP_STAT_HIST + esp_stats[sav->alg_enc]);
|
2003-08-14 00:06:49 +04:00
|
|
|
if (sav->tdb_authalgxform != NULL)
|
2017-04-13 19:38:31 +03:00
|
|
|
AH_STATINC(AH_STAT_HIST + ah_stats[sav->alg_auth]);
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
/* Release crypto descriptors. */
|
2017-07-20 11:07:14 +03:00
|
|
|
pool_put(&esp_tdb_crypto_pool, tc);
|
2003-08-14 00:06:49 +04:00
|
|
|
crypto_freereq(crp);
|
|
|
|
|
2006-04-12 00:21:28 +04:00
|
|
|
#ifdef IPSEC_DEBUG
|
|
|
|
/* Emulate man-in-the-middle attack when ipsec_integrity is TRUE. */
|
|
|
|
if (ipsec_integrity) {
|
2011-02-25 23:13:10 +03:00
|
|
|
static unsigned char ipseczeroes[AH_ALEN_MAX];
|
2011-02-19 21:26:50 +03:00
|
|
|
const struct auth_hash *esph;
|
2006-04-12 00:21:28 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Corrupt HMAC if we want to test integrity verification of
|
|
|
|
* the other side.
|
|
|
|
*/
|
|
|
|
esph = sav->tdb_authalgxform;
|
|
|
|
if (esph != NULL) {
|
2011-03-28 01:56:57 +04:00
|
|
|
m_copyback(m, m->m_pkthdr.len - esph->authsize,
|
|
|
|
esph->authsize, ipseczeroes);
|
2006-04-12 00:21:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
/* NB: m is reclaimed by ipsec_process_done. */
|
2017-07-14 15:26:26 +03:00
|
|
|
err = ipsec_process_done(m, isr, sav);
|
2003-08-14 00:06:49 +04:00
|
|
|
KEY_FREESAV(&sav);
|
2017-08-02 04:28:02 +03:00
|
|
|
KEY_SP_UNREF(&isr->sp);
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_RELEASE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
return err;
|
|
|
|
bad:
|
|
|
|
if (sav)
|
|
|
|
KEY_FREESAV(&sav);
|
2017-08-02 04:28:02 +03:00
|
|
|
KEY_SP_UNREF(&isr->sp);
|
2017-07-27 09:59:28 +03:00
|
|
|
IPSEC_RELEASE_GLOBAL_LOCKS();
|
2003-08-14 00:06:49 +04:00
|
|
|
if (m)
|
|
|
|
m_freem(m);
|
2017-07-20 11:07:14 +03:00
|
|
|
pool_put(&esp_tdb_crypto_pool, tc);
|
2003-08-14 00:06:49 +04:00
|
|
|
crypto_freereq(crp);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct xformsw esp_xformsw = {
|
2017-06-29 10:13:41 +03:00
|
|
|
.xf_type = XF_ESP,
|
|
|
|
.xf_flags = XFT_CONF|XFT_AUTH,
|
|
|
|
.xf_name = "IPsec ESP",
|
|
|
|
.xf_init = esp_init,
|
|
|
|
.xf_zeroize = esp_zeroize,
|
|
|
|
.xf_input = esp_input,
|
|
|
|
.xf_output = esp_output,
|
|
|
|
.xf_next = NULL,
|
2003-08-14 00:06:49 +04:00
|
|
|
};
|
|
|
|
|
2017-04-19 06:39:14 +03:00
|
|
|
void
|
2003-08-14 00:06:49 +04:00
|
|
|
esp_attach(void)
|
|
|
|
{
|
2008-04-23 10:09:04 +04:00
|
|
|
|
|
|
|
espstat_percpu = percpu_alloc(sizeof(uint64_t) * ESP_NSTATS);
|
|
|
|
|
2017-07-20 11:07:14 +03:00
|
|
|
extern int ah_max_authsize;
|
|
|
|
KASSERT(ah_max_authsize != 0);
|
|
|
|
esp_pool_item_size = sizeof(struct tdb_crypto) + ah_max_authsize;
|
|
|
|
pool_init(&esp_tdb_crypto_pool, esp_pool_item_size,
|
|
|
|
0, 0, 0, "esp_tdb_crypto", NULL, IPL_SOFTNET);
|
|
|
|
|
2003-08-14 00:06:49 +04:00
|
|
|
#define MAXIV(xform) \
|
2011-05-23 17:46:54 +04:00
|
|
|
if (xform.ivsize > esp_max_ivlen) \
|
|
|
|
esp_max_ivlen = xform.ivsize \
|
2003-08-14 00:06:49 +04:00
|
|
|
|
|
|
|
esp_max_ivlen = 0;
|
|
|
|
MAXIV(enc_xform_des); /* SADB_EALG_DESCBC */
|
|
|
|
MAXIV(enc_xform_3des); /* SADB_EALG_3DESCBC */
|
|
|
|
MAXIV(enc_xform_rijndael128); /* SADB_X_EALG_AES */
|
|
|
|
MAXIV(enc_xform_blf); /* SADB_X_EALG_BLOWFISHCBC */
|
|
|
|
MAXIV(enc_xform_cast5); /* SADB_X_EALG_CAST128CBC */
|
|
|
|
MAXIV(enc_xform_skipjack); /* SADB_X_EALG_SKIPJACK */
|
2011-05-05 21:48:29 +04:00
|
|
|
MAXIV(enc_xform_camellia); /* SADB_X_EALG_CAMELLIACBC */
|
2011-05-23 17:57:52 +04:00
|
|
|
MAXIV(enc_xform_aes_ctr); /* SADB_X_EALG_AESCTR */
|
2003-08-14 00:06:49 +04:00
|
|
|
MAXIV(enc_xform_null); /* SADB_EALG_NULL */
|
|
|
|
|
|
|
|
xform_register(&esp_xformsw);
|
|
|
|
#undef MAXIV
|
|
|
|
}
|