From 7fc1874a3bfdae5e898ae00769afb4ff11c16f17 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 23 Apr 2002 19:13:05 +0000 Subject: driver queueing & callback code for keying operations --- sys/crypto/cryptodev.h | 69 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'sys/crypto/cryptodev.h') diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h index ac79041dcc8..3e982c159b2 100644 --- a/sys/crypto/cryptodev.h +++ b/sys/crypto/cryptodev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.h,v 1.24 2002/04/08 17:49:42 jason Exp $ */ +/* $OpenBSD: cryptodev.h,v 1.25 2002/04/23 19:13:04 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -173,6 +173,44 @@ struct cryptop { #define CRYPTO_OP_DECRYPT 0x0 #define CRYPTO_OP_ENCRYPT 0x1 +/* bignum parameter, in packed bytes, ... */ +struct crparam { + caddr_t crp_p; + u_int crp_nbits; +}; + +#define CRK_MAXPARAM 8 + +struct crypt_kop { + u_int crk_op; /* ie. CRK_MOD_EXP or other */ + u_int crk_status; /* return status */ + u_short crk_iparams; /* # of input parameters */ + u_short crk_oparams; /* # of output parameters */ + u_int crk_pad1; + struct crparam crk_param[CRK_MAXPARAM]; + +}; +#define CRK_MOD_EXP 0 +#define CRK_MOD_EXP_CRT 1 +#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 */ + +struct cryptkop { + u_int krp_op; /* ie. CRK_MOD_EXP or other */ + u_int krp_status; /* return status */ + u_short krp_iparams; /* # of input parameters */ + u_short krp_oparams; /* # of output parameters */ + u_int krp_pad1; + struct crparam krp_param[CRK_MAXPARAM]; + struct crparam krp_kvp[CRK_MAXPARAM]; + + u_int32_t krp_hid; + int (*krp_callback)(struct cryptkop *); + struct cryptkop *krp_next; +}; + /* Crypto capabilities structure */ struct cryptocap { u_int32_t cc_sessions; @@ -185,6 +223,8 @@ struct cryptocap { u_int8_t cc_alg[CRYPTO_ALGORITHM_MAX + 1]; + u_int8_t cc_kalg[CRK_ALGORITHM_MAX + 1]; + u_int8_t cc_flags; #define CRYPTOCAP_F_CLEANUP 0x1 #define CRYPTOCAP_F_SOFTWARE 0x02 @@ -192,6 +232,7 @@ struct cryptocap { int (*cc_newsession) (u_int32_t *, struct cryptoini *); int (*cc_process) (struct cryptop *); int (*cc_freesession) (u_int64_t); + int (*cc_kprocess) (struct cryptkop *); }; /* @@ -227,27 +268,6 @@ struct crypt_op { #define CRYPTO_MAX_MAC_LEN 20 -/* bignum parameter, in packed bytes, ... */ -struct crparam { - caddr_t crp_p; - u_int crp_nbits; -}; - -#define CRK_MAXPARAM 8 -struct crypt_kop { - u_int crk_op; /* ie. CRK_MOD_EXP or other */ - u_int crk_status; /* return status */ - u_short crk_iparams; /* # of input parameters */ - u_short crk_oparams; /* # of output parameters */ - u_int crk_pad1; - struct crparam crk_param[CRK_MAXPARAM]; -}; -#define CRK_MOD_EXP 0 -#define CRK_MOD_EXP_CRT 1 -#define CRK_DSA_SIGN 2 -#define CRK_DSA_VERIFY 3 -#define CRK_DH_COMPUTE_KEY 4 - /* * done against open of /dev/crypto, to get a cloned descriptor. * Please use F_SETFD against the cloned descriptor. @@ -269,14 +289,19 @@ struct crypt_kop { int crypto_newsession(u_int64_t *, struct cryptoini *, int); int crypto_freesession(u_int64_t); int crypto_dispatch(struct cryptop *); +int crypto_kdispatch(struct cryptkop *); int crypto_register(u_int32_t, int, u_int16_t, u_int32_t, int (*)(u_int32_t *, struct cryptoini *), int (*)(u_int64_t), int (*)(struct cryptop *)); +int crypto_kregister(u_int32_t, int, u_int32_t, + int (*)(struct cryptkop *)); int crypto_unregister(u_int32_t, int); int32_t crypto_get_driverid(u_int8_t); void crypto_thread(void); int crypto_invoke(struct cryptop *); +int crypto_kinvoke(struct cryptkop *); void crypto_done(struct cryptop *); +void crypto_kdone(struct cryptkop *); void cuio_copydata(struct uio *, int, int, caddr_t); void cuio_copyback(struct uio *, int, int, caddr_t); -- cgit v1.2.3