summaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-25 17:52:38 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-25 17:52:38 +0000
commit229a5d71ccbaa626117a5bb0cba713db1fde6ef6 (patch)
treea24ba39c3770336ecb4b070fb554c8a2da70292b /sys/crypto
parent31ff067ccc03f1e976a938b03963dc5c8a86bfa6 (diff)
Add crypto_check_alg(), from jgarfiel@seas.upenn.edu
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/crypto.c33
-rw-r--r--sys/crypto/cryptodev.h3
2 files changed, 34 insertions, 2 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c
index fc36e3c0c5d..7dfc7dd9ec9 100644
--- a/sys/crypto/crypto.c
+++ b/sys/crypto/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.22 2001/06/25 05:02:22 angelos Exp $ */
+/* $OpenBSD: crypto.c,v 1.23 2001/06/25 17:52:36 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
@@ -279,6 +279,7 @@ crypto_unregister(u_int32_t driverid, int alg)
}
crypto_drivers[driverid].cc_alg[alg] = 0;
+ crypto_drivers[driverid].cc_max_op_len[alg] = 0;
/* Was this the last algorithm ? */
for (i = 1; i <= CRYPTO_ALGORITHM_MAX; i++)
@@ -470,3 +471,33 @@ crypto_done(struct cryptop *crp)
{
crp->crp_callback(crp);
}
+
+/*
+ * Return SYMMETRIC or PUBLIC_KEY, depending on the algorithm type.
+ */
+int
+crypto_check_alg(struct cryptoini *cri)
+{
+ switch (cri->cri_alg)
+ {
+ case CRYPTO_DES_CBC:
+ case CRYPTO_3DES_CBC:
+ case CRYPTO_BLF_CBC:
+ case CRYPTO_CAST_CBC:
+ case CRYPTO_SKIPJACK_CBC:
+ case CRYPTO_RIJNDAEL128_CBC:
+ return SYMMETRIC;
+ case CRYPTO_DH_SEND:
+ case CRYPTO_DH_RECEIVE:
+ case CRYPTO_RSA_ENCRYPT:
+ case CRYPTO_RSA_DECRYPT:
+ case CRYPTO_DSA_SIGN:
+ case CRYPTO_DSA_VERIFY:
+ return PUBLIC_KEY;
+ }
+
+#ifdef DIAGNOSTIC
+ panic("crypto_check_alg: unknown algorithm %d", cri->cri_alg);
+#endif
+ return -1;
+}
diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h
index cbae99c577e..e648155e456 100644
--- a/sys/crypto/cryptodev.h
+++ b/sys/crypto/cryptodev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptodev.h,v 1.8 2001/06/25 17:35:47 angelos Exp $ */
+/* $OpenBSD: cryptodev.h,v 1.9 2001/06/25 17:52:37 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
@@ -359,6 +359,7 @@ int32_t crypto_get_driverid(void);
void crypto_thread(void);
int crypto_invoke(struct cryptop *);
void crypto_done(struct cryptop *);
+int crypto_check_alg(struct cryptoini *);
struct mbuf;
int mbuf2pages __P((struct mbuf *, int *, long *, int *, int, int *));