summaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2021-10-24 14:50:43 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2021-10-24 14:50:43 +0000
commitd8cae6db62622ae63fa1306e093cc0334455b661 (patch)
tree5a33b95535cd47f93c9413fe8352875b2f694ad1 /sys/crypto
parent3242bacd701cad59ec26965de90d27d6435c91e5 (diff)
Remove crp_etype and return errors directly from crypto_invoke()
ok patrick@
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/crypto.c12
-rw-r--r--sys/crypto/cryptodev.h14
2 files changed, 8 insertions, 18 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c
index a51edbbbada..ea9f36060b8 100644
--- a/sys/crypto/crypto.c
+++ b/sys/crypto/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.91 2021/10/24 10:26:22 patrick Exp $ */
+/* $OpenBSD: crypto.c,v 1.92 2021/10/24 14:50:42 tobhe Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -379,7 +379,7 @@ crypto_unregister(u_int32_t driverid, int alg)
/*
* Dispatch a crypto request to the appropriate crypto devices.
*/
-void
+int
crypto_invoke(struct cryptop *crp)
{
u_int64_t nid;
@@ -394,7 +394,7 @@ crypto_invoke(struct cryptop *crp)
s = splvm();
if (crp->crp_ndesc < 1 || crypto_drivers == NULL) {
- crp->crp_etype = EINVAL;
+ error = EINVAL;
goto done;
}
@@ -414,7 +414,6 @@ crypto_invoke(struct cryptop *crp)
crypto_drivers[hid].cc_bytes += crp->crp_ilen;
error = crypto_drivers[hid].cc_process(crp);
- crp->crp_etype = error;
if (error == ERESTART) {
/* Unregister driver and migrate session. */
crypto_unregister(hid, CRYPTO_ALGORITHM_MAX + 1);
@@ -422,7 +421,7 @@ crypto_invoke(struct cryptop *crp)
}
splx(s);
- return;
+ return error;
migrate:
/* Migrate session. */
@@ -433,9 +432,10 @@ crypto_invoke(struct cryptop *crp)
if (crypto_newsession(&nid, &(crp->crp_desc->CRD_INI), 0) == 0)
crp->crp_sid = nid;
- crp->crp_etype = EAGAIN;
+ error = EAGAIN;
done:
splx(s);
+ return error;
}
/*
diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h
index 4af72c7a9a5..9f353aa86b6 100644
--- a/sys/crypto/cryptodev.h
+++ b/sys/crypto/cryptodev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptodev.h,v 1.80 2021/10/23 15:42:35 tobhe Exp $ */
+/* $OpenBSD: cryptodev.h,v 1.81 2021/10/24 14:50:42 tobhe Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
@@ -154,16 +154,6 @@ struct cryptop {
int crp_olen; /* Result total length */
int crp_alloctype; /* Type of buf to allocate if needed */
- int crp_etype; /*
- * Error type (zero means no error).
- * All error codes except EAGAIN
- * indicate possible data corruption (as in,
- * the data have been touched). On all
- * errors, the crp_sid may have changed
- * (reset to a new one), so the caller
- * should always check and use the new
- * value on future requests.
- */
int crp_flags;
#define CRYPTO_F_IMBUF 0x0001 /* Input/output are mbuf chains, otherwise contig */
@@ -215,7 +205,7 @@ int crypto_register(u_int32_t, int *,
int (*)(struct cryptop *));
int crypto_unregister(u_int32_t, int);
int32_t crypto_get_driverid(u_int8_t);
-void crypto_invoke(struct cryptop *);
+int crypto_invoke(struct cryptop *);
void cuio_copydata(struct uio *, int, int, caddr_t);
void cuio_copyback(struct uio *, int, int, const void *);