Thu May 5 17:48:29 2011 UTC ()
support camellia-cbc as ESP cipher


(drochner)
diff -r1.31 -r1.32 src/sys/netipsec/xform_esp.c

cvs diff -r1.31 -r1.32 src/sys/netipsec/xform_esp.c (expand / switch to unified diff)

--- src/sys/netipsec/xform_esp.c 2011/03/27 21:56:57 1.31
+++ src/sys/netipsec/xform_esp.c 2011/05/05 17:48:29 1.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: xform_esp.c,v 1.31 2011/03/27 21:56:57 spz Exp $ */ 1/* $NetBSD: xform_esp.c,v 1.32 2011/05/05 17:48:29 drochner Exp $ */
2/* $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $ */ 2/* $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $ */
3/* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */ 3/* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
4 4
5/* 5/*
6 * The authors of this code are John Ioannidis (ji@tla.org), 6 * The authors of this code are John Ioannidis (ji@tla.org),
7 * Angelos D. Keromytis (kermit@csd.uch.gr) and 7 * Angelos D. Keromytis (kermit@csd.uch.gr) and
8 * Niels Provos (provos@physnet.uni-hamburg.de). 8 * Niels Provos (provos@physnet.uni-hamburg.de).
9 * 9 *
10 * The original version of this code was written by John Ioannidis 10 * The original version of this code was written by John Ioannidis
11 * for BSD/OS in Athens, Greece, in November 1995. 11 * for BSD/OS in Athens, Greece, in November 1995.
12 * 12 *
13 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, 13 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
14 * by Angelos D. Keromytis. 14 * by Angelos D. Keromytis.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * You may use this code under the GNU public license if you so wish. Please 29 * You may use this code under the GNU public license if you so wish. Please
30 * contribute changes back to the authors under this freer than GPL license 30 * contribute changes back to the authors under this freer than GPL license
31 * so that we may further the use of strong encryption without limitations to 31 * so that we may further the use of strong encryption without limitations to
32 * all. 32 * all.
33 * 33 *
34 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 34 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
35 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY 35 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
36 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 36 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
37 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 37 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
38 * PURPOSE. 38 * PURPOSE.
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.31 2011/03/27 21:56:57 spz Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.32 2011/05/05 17:48:29 drochner Exp $");
43 43
44#include "opt_inet.h" 44#include "opt_inet.h"
45#ifdef __FreeBSD__ 45#ifdef __FreeBSD__
46#include "opt_inet6.h" 46#include "opt_inet6.h"
47#endif 47#endif
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/mbuf.h> 51#include <sys/mbuf.h>
52#include <sys/socket.h> 52#include <sys/socket.h>
53#include <sys/syslog.h> 53#include <sys/syslog.h>
54#include <sys/kernel.h> 54#include <sys/kernel.h>
55/*#include <sys/random.h>*/ 55/*#include <sys/random.h>*/
@@ -118,26 +118,28 @@ esp_algorithm_lookup(int alg) @@ -118,26 +118,28 @@ esp_algorithm_lookup(int alg)
118 switch (alg) { 118 switch (alg) {
119 case SADB_EALG_DESCBC: 119 case SADB_EALG_DESCBC:
120 return &enc_xform_des; 120 return &enc_xform_des;
121 case SADB_EALG_3DESCBC: 121 case SADB_EALG_3DESCBC:
122 return &enc_xform_3des; 122 return &enc_xform_3des;
123 case SADB_X_EALG_AES: 123 case SADB_X_EALG_AES:
124 return &enc_xform_rijndael128; 124 return &enc_xform_rijndael128;
125 case SADB_X_EALG_BLOWFISHCBC: 125 case SADB_X_EALG_BLOWFISHCBC:
126 return &enc_xform_blf; 126 return &enc_xform_blf;
127 case SADB_X_EALG_CAST128CBC: 127 case SADB_X_EALG_CAST128CBC:
128 return &enc_xform_cast5; 128 return &enc_xform_cast5;
129 case SADB_X_EALG_SKIPJACK: 129 case SADB_X_EALG_SKIPJACK:
130 return &enc_xform_skipjack; 130 return &enc_xform_skipjack;
 131 case SADB_X_EALG_CAMELLIACBC:
 132 return &enc_xform_camellia;
131 case SADB_EALG_NULL: 133 case SADB_EALG_NULL:
132 return &enc_xform_null; 134 return &enc_xform_null;
133 } 135 }
134 return NULL; 136 return NULL;
135} 137}
136 138
137size_t 139size_t
138esp_hdrsiz(const struct secasvar *sav) 140esp_hdrsiz(const struct secasvar *sav)
139{ 141{
140 size_t size; 142 size_t size;
141 143
142 if (sav != NULL) { 144 if (sav != NULL) {
143 /*XXX not right for null algorithm--does it matter??*/ 145 /*XXX not right for null algorithm--does it matter??*/
@@ -1039,22 +1041,23 @@ esp_attach(void) @@ -1039,22 +1041,23 @@ esp_attach(void)
1039 espstat_percpu = percpu_alloc(sizeof(uint64_t) * ESP_NSTATS); 1041 espstat_percpu = percpu_alloc(sizeof(uint64_t) * ESP_NSTATS);
1040 1042
1041#define MAXIV(xform) \ 1043#define MAXIV(xform) \
1042 if (xform.blocksize > esp_max_ivlen) \ 1044 if (xform.blocksize > esp_max_ivlen) \
1043 esp_max_ivlen = xform.blocksize \ 1045 esp_max_ivlen = xform.blocksize \
1044 1046
1045 esp_max_ivlen = 0; 1047 esp_max_ivlen = 0;
1046 MAXIV(enc_xform_des); /* SADB_EALG_DESCBC */ 1048 MAXIV(enc_xform_des); /* SADB_EALG_DESCBC */
1047 MAXIV(enc_xform_3des); /* SADB_EALG_3DESCBC */ 1049 MAXIV(enc_xform_3des); /* SADB_EALG_3DESCBC */
1048 MAXIV(enc_xform_rijndael128); /* SADB_X_EALG_AES */ 1050 MAXIV(enc_xform_rijndael128); /* SADB_X_EALG_AES */
1049 MAXIV(enc_xform_blf); /* SADB_X_EALG_BLOWFISHCBC */ 1051 MAXIV(enc_xform_blf); /* SADB_X_EALG_BLOWFISHCBC */
1050 MAXIV(enc_xform_cast5); /* SADB_X_EALG_CAST128CBC */ 1052 MAXIV(enc_xform_cast5); /* SADB_X_EALG_CAST128CBC */
1051 MAXIV(enc_xform_skipjack); /* SADB_X_EALG_SKIPJACK */ 1053 MAXIV(enc_xform_skipjack); /* SADB_X_EALG_SKIPJACK */
 1054 MAXIV(enc_xform_camellia); /* SADB_X_EALG_CAMELLIACBC */
1052 MAXIV(enc_xform_null); /* SADB_EALG_NULL */ 1055 MAXIV(enc_xform_null); /* SADB_EALG_NULL */
1053 1056
1054 xform_register(&esp_xformsw); 1057 xform_register(&esp_xformsw);
1055#undef MAXIV 1058#undef MAXIV
1056} 1059}
1057#ifdef __FreeBSD__ 1060#ifdef __FreeBSD__
1058SYSINIT(esp_xform_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, esp_attach, NULL) 1061SYSINIT(esp_xform_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, esp_attach, NULL)
1059#else 1062#else
1060#endif 1063#endif