summaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-04-23 22:20:48 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-04-23 22:20:48 +0000
commit05336437fade6f9bff26ad3b106348c08326b543 (patch)
tree897c858c7e54ebcbb77b7b72883e4bed3ab9549b /sys/crypto
parentb865d956cd2c0375d965fa7c792c8a1261333dfc (diff)
initial hack at a CIOCSYMFEAT ioctl
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/crypto.c31
-rw-r--r--sys/crypto/cryptodev.c5
-rw-r--r--sys/crypto/cryptodev.h3
3 files changed, 36 insertions, 3 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c
index 12261990d81..a599b08e364 100644
--- a/sys/crypto/crypto.c
+++ b/sys/crypto/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.34 2002/04/23 19:13:04 deraadt Exp $ */
+/* $OpenBSD: crypto.c,v 1.35 2002/04/23 22:20:47 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -589,3 +589,32 @@ crypto_kdone(struct cryptkop *krp)
{
krp->krp_callback(krp);
}
+
+int
+crypto_getfeat(int *featp)
+{
+ int kalgs[CRK_ALGORITHM_MAX];
+ extern int cryptodevallowsoft;
+ int hid, kalg, feat = 0;
+
+ for (hid = 0; hid < crypto_drivers_num; hid++) {
+ if ((crypto_drivers[hid].cc_flags & CRYPTOCAP_F_SOFTWARE) &&
+ cryptodevallowsoft == 0)
+ continue;
+ if (crypto_drivers[hid].cc_kprocess == NULL)
+ continue;
+ for (kalg = 0; kalg < CRK_ALGORITHM_MAX; kalg++)
+ if ((crypto_drivers[hid].cc_kalg[kalg] &
+ CRYPTO_ALG_FLAG_SUPPORTED) == 0)
+ kalgs[kalg] = 1;
+ }
+
+ if (kalgs[CRK_MOD_EXP] && kalgs[CRK_MOD_EXP_CRT])
+ feat |= CRSFEAT_RSA;
+ if (kalgs[CRK_DSA_VERIFY] && kalgs[CRK_DSA_SIGN])
+ feat |= CRSFEAT_DSA;
+ if (kalgs[CRK_DH_COMPUTE_KEY] && kalgs[CRK_MOD_EXP])
+ feat |= CRSFEAT_DH;
+ *featp = feat;
+ return (0);
+}
diff --git a/sys/crypto/cryptodev.c b/sys/crypto/cryptodev.c
index 3031f6a63a5..fc39f6f83a1 100644
--- a/sys/crypto/cryptodev.c
+++ b/sys/crypto/cryptodev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptodev.c,v 1.37 2002/04/23 19:13:04 deraadt Exp $ */
+/* $OpenBSD: cryptodev.c,v 1.38 2002/04/23 22:20:47 deraadt Exp $ */
/*
* Copyright (c) 2001 Theo de Raadt
@@ -292,6 +292,9 @@ bail:
case CIOCKEY:
error = cryptodev_key((struct crypt_kop *)data);
break;
+ case CIOCSYMFEAT:
+ error = crypto_getfeat((int *)data);
+ break;
default:
error = EINVAL;
}
diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h
index 3e982c159b2..5d4088ad513 100644
--- a/sys/crypto/cryptodev.h
+++ b/sys/crypto/cryptodev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptodev.h,v 1.25 2002/04/23 19:13:04 deraadt Exp $ */
+/* $OpenBSD: cryptodev.h,v 1.26 2002/04/23 22:20:47 deraadt Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
@@ -302,6 +302,7 @@ int crypto_invoke(struct cryptop *);
int crypto_kinvoke(struct cryptkop *);
void crypto_done(struct cryptop *);
void crypto_kdone(struct cryptkop *);
+int crypto_getfeat(int *);
void cuio_copydata(struct uio *, int, int, caddr_t);
void cuio_copyback(struct uio *, int, int, caddr_t);