summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2016-09-30 14:34:36 +0000
committerotto <otto@openbsd.org>2016-09-30 14:34:36 +0000
commit787e90abb77985b9b796285c1755d39e8bbfe4fa (patch)
treec622af9e083314b68d800e2bac6946e54df9f6a5
parentThe opencvs sources are not linked to the build. To make the cvs (diff)
downloadwireguard-openbsd-787e90abb77985b9b796285c1755d39e8bbfe4fa.tar.xz
wireguard-openbsd-787e90abb77985b9b796285c1755d39e8bbfe4fa.zip
crypto(4) is no more
-rw-r--r--regress/sys/crypto/auth/Makefile5
-rw-r--r--regress/sys/crypto/auth/md5.c174
2 files changed, 0 insertions, 179 deletions
diff --git a/regress/sys/crypto/auth/Makefile b/regress/sys/crypto/auth/Makefile
deleted file mode 100644
index 7cd22beb9fa..00000000000
--- a/regress/sys/crypto/auth/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $OpenBSD: Makefile,v 1.1 2002/03/25 14:06:17 markus Exp $
-
-PROG= md5
-
-.include <bsd.regress.mk>
diff --git a/regress/sys/crypto/auth/md5.c b/regress/sys/crypto/auth/md5.c
deleted file mode 100644
index 2a959fd1e31..00000000000
--- a/regress/sys/crypto/auth/md5.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* $OpenBSD: md5.c,v 1.6 2004/07/22 15:11:35 miod Exp $ */
-
-/*
- * Copyright (c) 2002 Markus Friedl. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-#include <crypto/cryptodev.h>
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define MD5LEN 16
-
-static char *
-sysmd5(const char *s, size_t len)
-{
- static char md[MD5LEN*2 + 1];
- unsigned char digest[MD5LEN];
- struct session_op session;
- struct crypt_op cryp;
- int cryptodev_fd = -1, fd = -1, i;
-
- if ((cryptodev_fd = open("/dev/crypto", O_RDWR, 0)) < 0) {
- warn("/dev/crypto");
- goto err;
- }
- if (ioctl(cryptodev_fd, CRIOGET, &fd) == -1) {
- warn("CRIOGET failed");
- goto err;
- }
- memset(&session, 0, sizeof(session));
- session.cipher = 0;
- session.mac = CRYPTO_MD5;
- session.mackeylen = 0;
- if (ioctl(fd, CIOCGSESSION, &session) == -1) {
- warn("CIOCGSESSION");
- goto err;
- }
- memset(&cryp, 0, sizeof(cryp));
- cryp.ses = session.ses;
- cryp.op = COP_ENCRYPT; /*???*/
- cryp.flags = 0;
- cryp.src = (caddr_t) s;
- cryp.len = len;
- cryp.dst = 0;
- cryp.mac = (caddr_t) digest;
- cryp.iv = 0;
- if (ioctl(fd, CIOCCRYPT, &cryp) == -1) {
- warn("CIOCCRYPT");
- goto err;
- }
- if (ioctl(fd, CIOCFSESSION, &session.ses) == -1) {
- warn("CIOCFSESSION");
- goto err;
- }
- close(fd);
- close(cryptodev_fd);
-
- md[0] = '\0';
- for (i = 0; i < MD5LEN; i++)
- snprintf(md + 2*i, sizeof(md) - 2*i, "%2.2x", digest[i]);
- return (md);
-err:
- if (fd != -1)
- close(fd);
- if (cryptodev_fd != -1)
- close(cryptodev_fd);
- return (NULL);
-}
-
-static int
-getallowsoft(void)
-{
- int mib[2], old;
- size_t olen;
-
- olen = sizeof(old);
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_CRYPTODEVALLOWSOFT;
- if (sysctl(mib, 2, &old, &olen, NULL, 0) < 0)
- err(1, "sysctl failed");
-
- return old;
-}
-
-static void
-setallowsoft(int new)
-{
- int mib[2], old;
- size_t olen, nlen;
-
- olen = nlen = sizeof(new);
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_CRYPTODEVALLOWSOFT;
-
- if (sysctl(mib, 2, &old, &olen, &new, nlen) < 0)
- err(1, "sysctl failed");
-}
-
-/* test vectors from RFC 1321 */
-static struct {
- char *dat;
- char *md;
-} test[] = {
- { "", "d41d8cd98f00b204e9800998ecf8427e" },
- { "a", "0cc175b9c0f1b6a831c399e269772661" },
- { "abc", "900150983cd24fb0d6963f7d28e17f72" },
- { "message digest", "f96b697d7cb7938d525a2f31aaf161d0" },
- { "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b" },
- { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "d174ab98d277d9f5a5611c2c9f419d9f" },
- { "123456789012345678901234567890123456789012345678901234567890"
- "12345678901234567890", "57edf4a22be3c955ac49da2e2107b67a" },
- { NULL, NULL },
-};
-
-int
-main(int argc, char **argv)
-{
- int allowed = 0, i, count, fail;
- char *md;
-
- if (geteuid() == 0) {
- allowed = getallowsoft();
- if (allowed == 0)
- setallowsoft(1);
- }
- for (count = 0, fail = 0, i = 0; test[i].dat; i++) {
- if ((md = sysmd5(test[i].dat, strlen(test[i].dat))) == NULL) {
- warn("md5 with /dev/crypto failed");
- continue;
- }
- if (strcmp(md, test[i].md) == 0) {
- printf("md5 ok for '%s'\n", test[i].dat);
- count++;
- } else {
- warnx("md5 failed for '%s': got '%s' expected '%s'",
- test[i].dat, md, test[i].md);
- fail++;
- }
- }
- if (geteuid() == 0 && allowed == 0)
- setallowsoft(0);
- exit((fail > 0 || count == 0) ? 1 : 0);
-}