From 05336437fade6f9bff26ad3b106348c08326b543 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 23 Apr 2002 22:20:48 +0000 Subject: initial hack at a CIOCSYMFEAT ioctl --- sys/crypto/crypto.c | 31 ++++++++++++++++++++++++++++++- sys/crypto/cryptodev.c | 5 ++++- sys/crypto/cryptodev.h | 3 ++- 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); -- cgit v1.2.3