summaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2010-06-09 19:38:20 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2010-06-09 19:38:20 +0000
commit5889424235680f1650a55007c032525b1187d698 (patch)
treef65ff2a4951f4de694c9ac5d763821a3536e4c5c /sys/crypto
parent230ad00030d6be174f1b4c6a6b4395f6f77f053c (diff)
Remove the CRYPTO_ALGORITHM_ALL define, fixup accordingly
and make the loop invartiants <= CRYPTO_ALGORITHM_MAX Do this also for the CRK_ALGORITHM_MAX this also fixes the a bug that caused us to skip CRK_DH_COMPUTE_KEY. ok deraadt@
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/crypto.c18
-rw-r--r--sys/crypto/cryptodev.h8
2 files changed, 12 insertions, 14 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c
index a6445b3e30a..35813c437f6 100644
--- a/sys/crypto/crypto.c
+++ b/sys/crypto/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.53 2009/09/03 07:47:27 dlg Exp $ */
+/* $OpenBSD: crypto.c,v 1.54 2010/06/09 19:38:19 thib Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -295,7 +295,7 @@ crypto_kregister(u_int32_t driverid, int *kalg,
s = splvm();
- for (i = 0; i < CRK_ALGORITHM_MAX; i++) {
+ for (i = 0; i <= CRK_ALGORITHM_MAX; i++) {
/*
* XXX Do some performance testing to determine
* placing. We probably need an auxiliary data
@@ -326,7 +326,7 @@ crypto_register(u_int32_t driverid, int *alg,
s = splvm();
- for (i = 0; i < CRYPTO_ALGORITHM_ALL; i++) {
+ for (i = 0; i <= CRYPTO_ALGORITHM_MAX; i++) {
/*
* XXX Do some performance testing to determine
* placing. We probably need an auxiliary data
@@ -364,13 +364,13 @@ crypto_unregister(u_int32_t driverid, int alg)
/* Sanity checks. */
if (driverid >= crypto_drivers_num || crypto_drivers == NULL ||
((alg <= 0 || alg > CRYPTO_ALGORITHM_MAX) &&
- alg != CRYPTO_ALGORITHM_ALL) ||
+ alg != CRYPTO_ALGORITHM_MAX + 1) ||
crypto_drivers[driverid].cc_alg[alg] == 0) {
splx(s);
return EINVAL;
}
- if (alg != CRYPTO_ALGORITHM_ALL) {
+ if (alg != CRYPTO_ALGORITHM_MAX + 1) {
crypto_drivers[driverid].cc_alg[alg] = 0;
/* Was this the last algorithm ? */
@@ -381,9 +381,9 @@ crypto_unregister(u_int32_t driverid, int alg)
/*
* If a driver unregistered its last algorithm or all of them
- * (alg == CRYPTO_ALGORITHM_ALL), cleanup its entry.
+ * (alg == CRYPTO_ALGORITHM_MAX + 1), cleanup its entry.
*/
- if (i == CRYPTO_ALGORITHM_MAX + 1 || alg == CRYPTO_ALGORITHM_ALL) {
+ if (i == CRYPTO_ALGORITHM_MAX + 1 || alg == CRYPTO_ALGORITHM_MAX + 1) {
ses = crypto_drivers[driverid].cc_sessions;
bzero(&crypto_drivers[driverid], sizeof(struct cryptocap));
if (ses != 0) {
@@ -534,7 +534,7 @@ crypto_invoke(struct cryptop *crp)
if (error) {
if (error == ERESTART) {
/* Unregister driver and migrate session. */
- crypto_unregister(hid, CRYPTO_ALGORITHM_ALL);
+ crypto_unregister(hid, CRYPTO_ALGORITHM_MAX + 1);
goto migrate;
} else {
crp->crp_etype = error;
@@ -672,7 +672,7 @@ crypto_getfeat(int *featp)
}
if (crypto_drivers[hid].cc_kprocess == NULL)
continue;
- for (kalg = 0; kalg < CRK_ALGORITHM_MAX; kalg++)
+ for (kalg = 0; kalg <= CRK_ALGORITHM_MAX; kalg++)
if ((crypto_drivers[hid].cc_kalg[kalg] &
CRYPTO_ALG_FLAG_SUPPORTED) != 0)
feat |= 1 << kalg;
diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h
index c2418a04f03..042421932da 100644
--- a/sys/crypto/cryptodev.h
+++ b/sys/crypto/cryptodev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptodev.h,v 1.49 2010/01/10 12:43:07 markus Exp $ */
+/* $OpenBSD: cryptodev.h,v 1.50 2010/06/09 19:38:19 thib Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
@@ -105,9 +105,7 @@
#define CRYPTO_SHA2_512_HMAC 20
#define CRYPTO_AES_CTR 21
#define CRYPTO_AES_XTS 22
-#define CRYPTO_ALGORITHM_MAX 22 /* Keep updated - see below */
-
-#define CRYPTO_ALGORITHM_ALL (CRYPTO_ALGORITHM_MAX + 1)
+#define CRYPTO_ALGORITHM_MAX 22 /* Keep updated */
/* Algorithm flags */
#define CRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */
@@ -211,7 +209,7 @@ struct crypt_kop {
#define CRK_DSA_SIGN 2
#define CRK_DSA_VERIFY 3
#define CRK_DH_COMPUTE_KEY 4
-#define CRK_ALGORITHM_MAX 4 /* Keep updated - see below */
+#define CRK_ALGORITHM_MAX 4 /* Keep updated */
#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)