summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>1997-06-20 06:14:37 +0000
committerprovos <provos@openbsd.org>1997-06-20 06:14:37 +0000
commitc2d9297bc9dd43be937e9e4167612c980e3db1cf (patch)
tree24d7570dfe296c10d8258ca4465b9b512944691b
parentip_ahsha1.c + ip_esp3des.c (diff)
downloadwireguard-openbsd-c2d9297bc9dd43be937e9e4167612c980e3db1cf.tar.xz
wireguard-openbsd-c2d9297bc9dd43be937e9e4167612c980e3db1cf.zip
ah-sha1 + esp-3des
-rw-r--r--sbin/ipsec/ipsecadm/Makefile4
-rw-r--r--sbin/ipsec/ipsecadm/ipsecadm.c6
-rw-r--r--sbin/ipsec/ipsecadm/xf_ahsha1.c98
-rw-r--r--sbin/ipsec/ipsecadm/xf_esp3des.c102
4 files changed, 207 insertions, 3 deletions
diff --git a/sbin/ipsec/ipsecadm/Makefile b/sbin/ipsec/ipsecadm/Makefile
index a0100685414..db286d46af2 100644
--- a/sbin/ipsec/ipsecadm/Makefile
+++ b/sbin/ipsec/ipsecadm/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.1 1997/03/01 15:08:24 provos Exp $
+# $OpenBSD: Makefile,v 1.2 1997/06/20 06:14:37 provos Exp $
PROG= ipsecadm
SRCS= ipsecadm.c xf_espdes.c xf_esp3desmd5.c xf_ahmd5.c xf_ahhmacmd5.c \
xf_ahhmacsha1.c xf_ip4.c xf_espdesmd5.c kernel.c xf_grp.c \
- xf_delspi.c xf_pfr.c
+ xf_delspi.c xf_pfr.c xf_ahsha1.c xf_esp3des.c
.include <bsd.prog.mk>
diff --git a/sbin/ipsec/ipsecadm/ipsecadm.c b/sbin/ipsec/ipsecadm/ipsecadm.c
index 48573b7e459..70dcfc11255 100644
--- a/sbin/ipsec/ipsecadm/ipsecadm.c
+++ b/sbin/ipsec/ipsecadm/ipsecadm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsecadm.c,v 1.3 1997/05/15 19:32:22 deraadt Exp $ */
+/* $OpenBSD: ipsecadm.c,v 1.4 1997/06/20 06:14:38 provos Exp $ */
/*
* The author of this code is John Ioannidis, ji@tla.org,
* (except when noted otherwise).
@@ -57,9 +57,11 @@ typedef struct {
} transform;
int xf_espdes __P((int, char **));
+int xf_esp3des __P((int, char **));
int xf_esp3desmd5 __P((int, char **));
int xf_espdesmd5 __P((int, char **));
int xf_ahmd5 __P((int, char **));
+int xf_ahsha1 __P((int, char **));
int xf_ahhmacmd5 __P((int, char **));
int xf_ahhmacsha1 __P((int, char **));
int xf_ip4 __P((int, char **));
@@ -69,9 +71,11 @@ int xf_pfr __P((int, char **));
transform xf[] = {
{"des", xf_espdes},
+ {"3des", xf_esp3des},
{"3desmd5", xf_esp3desmd5},
{"desmd5", xf_espdesmd5},
{"md5", xf_ahmd5},
+ {"sha1", xf_ahsha1},
{"hmacmd5", xf_ahhmacmd5},
{"hmacsha1", xf_ahhmacsha1},
{"ip4", xf_ip4},
diff --git a/sbin/ipsec/ipsecadm/xf_ahsha1.c b/sbin/ipsec/ipsecadm/xf_ahsha1.c
new file mode 100644
index 00000000000..2578a963c79
--- /dev/null
+++ b/sbin/ipsec/ipsecadm/xf_ahsha1.c
@@ -0,0 +1,98 @@
+/* $OpenBSD: xf_ahsha1.c,v 1.1 1997/06/20 06:14:38 provos Exp $ */
+/*
+ * The author of this code is John Ioannidis, ji@tla.org,
+ * (except when noted otherwise).
+ *
+ * This code was written for BSD/OS in Athens, Greece, in November 1995.
+ *
+ * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
+ * by Angelos D. Keromytis, kermit@forthnet.gr.
+ *
+ * Copyright (C) 1995, 1996, 1997 by John Ioannidis and Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software 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.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NEITHER AUTHOR MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mbuf.h>
+#include <sys/sysctl.h>
+
+#include <net/if.h>
+#include <net/route.h>
+#include <net/if_dl.h>
+#include <netinet/in.h>
+#include <netns/ns.h>
+#include <netiso/iso.h>
+#include <netccitt/x25.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <paths.h>
+#include "net/encap.h"
+#include "netinet/ip_ipsp.h"
+#include "netinet/ip_ah.h"
+
+extern char buf[];
+
+int xf_set __P(( struct encap_msghdr *));
+int x2i __P((char *));
+
+int
+xf_ahsha1(argc, argv)
+int argc;
+char **argv;
+{
+ int klen, i;
+
+ struct encap_msghdr *em;
+ struct ahsha1_xdata *xd;
+
+ if (argc != 4) {
+ fprintf(stderr, "usage: %s dst spi key\n", argv[0]);
+ return 0;
+ }
+
+ klen = strlen(argv[3])/2;
+ if (klen > AHSHA1_KMAX)
+ klen = AHSHA1_KMAX;
+
+ em = (struct encap_msghdr *)&buf[0];
+
+ em->em_msglen = EMT_SETSPI_FLEN + 4 + klen;
+ em->em_version = 0;
+ em->em_type = EMT_SETSPI;
+ em->em_spi = htonl(strtoul(argv[2], NULL, 16));
+ em->em_if = 1;
+ em->em_dst.s_addr = inet_addr(argv[1]);
+ em->em_alg = XF_AHSHA1;
+ xd = (struct ahsha1_xdata *)(em->em_dat);
+
+ xd->amx_klen = klen;
+ xd->amx_alen = AHSHA1_ALEN;
+
+
+ for (i = 0; i < klen; i++ )
+ xd->amx_key[i] = x2i(&(argv[3][2*i]));
+
+ return xf_set(em);
+}
+
+
diff --git a/sbin/ipsec/ipsecadm/xf_esp3des.c b/sbin/ipsec/ipsecadm/xf_esp3des.c
new file mode 100644
index 00000000000..404da71edf7
--- /dev/null
+++ b/sbin/ipsec/ipsecadm/xf_esp3des.c
@@ -0,0 +1,102 @@
+/* $OpenBSD: xf_esp3des.c,v 1.1 1997/06/20 06:14:39 provos Exp $ */
+/*
+ * The author of this code is John Ioannidis, ji@tla.org,
+ * (except when noted otherwise).
+ *
+ * This code was written for BSD/OS in Athens, Greece, in November 1995.
+ *
+ * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
+ * by Angelos D. Keromytis, kermit@forthnet.gr.
+ *
+ * Copyright (C) 1995, 1996, 1997 by John Ioannidis and Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software 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.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NEITHER AUTHOR MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mbuf.h>
+#include <sys/sysctl.h>
+
+#include <net/if.h>
+#include <net/route.h>
+#include <net/if_dl.h>
+#include <netinet/in.h>
+#include <netns/ns.h>
+#include <netiso/iso.h>
+#include <netccitt/x25.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <paths.h>
+#include "net/encap.h"
+#include "netinet/ip_ipsp.h"
+#include "netinet/ip_esp.h"
+
+extern char buf[];
+
+int xf_set __P(( struct encap_msghdr *));
+int x2i __P((char *));
+
+int
+xf_esp3des(argc, argv)
+int argc;
+char **argv;
+{
+ int i;
+
+ struct encap_msghdr *em;
+ struct esp3des_xdata *xd;
+
+ if (argc != 5) {
+ fprintf(stderr, "usage: %s dst spi iv key\n", argv[0]);
+ return 0;
+ }
+
+ em = (struct encap_msghdr *)&buf[0];
+
+ em->em_msglen = EMT_SETSPI_FLEN + ESP_ULENGTH;
+ em->em_version = 0;
+ em->em_type = EMT_SETSPI;
+ em->em_spi = htonl(strtoul(argv[2], NULL, 16));
+ em->em_if = 1;
+ em->em_dst.s_addr = inet_addr(argv[1]);
+ em->em_alg = XF_ESP3DES;
+ xd = (struct esp3des_xdata *)(em->em_dat);
+
+ xd->edx_ivlen = 4;
+
+#if 0
+#define max(_a,_b) (((_a)>(_b))?(_a):(_b))
+
+ memcpy(&(xd->edx_iv[0]), argv[3], max(strlen(argv[3]), 8));
+ memcpy(&(xd->edx_iv[8]), argv[4], max(strlen(argv[4]), 8));
+#endif
+
+ for (i = 0; i < 4; i++)
+ xd->edx_iv[i] = x2i(&(argv[3][2*i]));
+
+ for (i = 0; i < 3*8; i++)
+ xd->edx_iv[i+8] = x2i(&(argv[4][2*i]));
+
+ return xf_set(em);
+}
+
+