summaryrefslogtreecommitdiffstats
path: root/sys/opencrypto
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2014-03-11 01:45:46 +0000
committerjmg <jmg@FreeBSD.org>2014-03-11 01:45:46 +0000
commit588b3c0ed0bfc96b7bec31ceddf938f7a71b64f8 (patch)
treeb113f2476c823c4c27a1f431058cfc86e8f40b0b /sys/opencrypto
parent3a0a47e77ad61c056388421e3df37d383d4bcc49 (diff)
downloadFreeBSD-src-588b3c0ed0bfc96b7bec31ceddf938f7a71b64f8.zip
FreeBSD-src-588b3c0ed0bfc96b7bec31ceddf938f7a71b64f8.tar.gz
allow the kern.cryptodevallowsoft sysctl to enable symetric/hashes too...
This will allow us to more easily test the software versions of these routines... Considering that we've never had an software asymetric implmentation, it's doubtful anyone has this enabled...
Diffstat (limited to 'sys/opencrypto')
-rw-r--r--sys/opencrypto/crypto.c4
-rw-r--r--sys/opencrypto/cryptodev.c13
2 files changed, 10 insertions, 7 deletions
diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 889e855..d1df283 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -161,10 +161,10 @@ int crypto_userasymcrypto = 1; /* userland may do asym crypto reqs */
SYSCTL_INT(_kern, OID_AUTO, userasymcrypto, CTLFLAG_RW,
&crypto_userasymcrypto, 0,
"Enable/disable user-mode access to asymmetric crypto support");
-int crypto_devallowsoft = 0; /* only use hardware crypto for asym */
+int crypto_devallowsoft = 0; /* only use hardware crypto */
SYSCTL_INT(_kern, OID_AUTO, cryptodevallowsoft, CTLFLAG_RW,
&crypto_devallowsoft, 0,
- "Enable/disable use of software asym crypto support");
+ "Enable/disable use of software crypto by /dev/crypto");
MALLOC_DEFINE(M_CRYPTO_DATA, "crypto", "crypto session records");
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c
index 5e949ca..4d16833 100644
--- a/sys/opencrypto/cryptodev.c
+++ b/sys/opencrypto/cryptodev.c
@@ -351,11 +351,14 @@ cryptof_truncate(
static int
checkforsoftware(int crid)
{
- if (crid & CRYPTOCAP_F_SOFTWARE)
- return EINVAL; /* XXX */
- if ((crid & CRYPTOCAP_F_HARDWARE) == 0 &&
- (crypto_getcaps(crid) & CRYPTOCAP_F_HARDWARE) == 0)
- return EINVAL; /* XXX */
+
+ if (!crypto_devallowsoft) {
+ if (crid & CRYPTOCAP_F_SOFTWARE)
+ return EINVAL; /* XXX */
+ if ((crid & CRYPTOCAP_F_HARDWARE) == 0 &&
+ (crypto_getcaps(crid) & CRYPTOCAP_F_HARDWARE) == 0)
+ return EINVAL; /* XXX */
+ }
return 0;
}
OpenPOWER on IntegriCloud