1104476Ssam/* $FreeBSD$ */ 2104476Ssam/* $OpenBSD: cryptodev.h,v 1.31 2002/06/11 11:14:29 beck Exp $ */ 3104476Ssam 4139825Simp/*- 5104476Ssam * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) 6167755Ssam * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting 7104476Ssam * 8104476Ssam * This code was written by Angelos D. Keromytis in Athens, Greece, in 9104476Ssam * February 2000. Network Security Technologies Inc. (NSTI) kindly 10104476Ssam * supported the development of this code. 11104476Ssam * 12104476Ssam * Copyright (c) 2000 Angelos D. Keromytis 13104476Ssam * 14104476Ssam * Permission to use, copy, and modify this software with or without fee 15104476Ssam * is hereby granted, provided that this entire notice is included in 16104476Ssam * all source code copies of any software which is or includes a copy or 17104476Ssam * modification of this software. 18104476Ssam * 19104476Ssam * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 20104476Ssam * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY 21104476Ssam * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 22104476Ssam * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 23104476Ssam * PURPOSE. 24104476Ssam * 25104476Ssam * Copyright (c) 2001 Theo de Raadt 26104476Ssam * 27104476Ssam * Redistribution and use in source and binary forms, with or without 28104476Ssam * modification, are permitted provided that the following conditions 29104476Ssam * are met: 30104476Ssam * 31104476Ssam * 1. Redistributions of source code must retain the above copyright 32104476Ssam * notice, this list of conditions and the following disclaimer. 33104476Ssam * 2. Redistributions in binary form must reproduce the above copyright 34104476Ssam * notice, this list of conditions and the following disclaimer in the 35104476Ssam * documentation and/or other materials provided with the distribution. 36104476Ssam * 3. The name of the author may not be used to endorse or promote products 37104476Ssam * derived from this software without specific prior written permission. 38104476Ssam * 39104476Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 40104476Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 41104476Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 42104476Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 43104476Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44104476Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 45104476Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 46104476Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 47104476Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 48104476Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49104476Ssam * 50104476Ssam * Effort sponsored in part by the Defense Advanced Research Projects 51104476Ssam * Agency (DARPA) and Air Force Research Laboratory, Air Force 52104476Ssam * Materiel Command, USAF, under agreement number F30602-01-2-0537. 53104476Ssam * 54104476Ssam */ 55104476Ssam 56104476Ssam#ifndef _CRYPTO_CRYPTO_H_ 57104476Ssam#define _CRYPTO_CRYPTO_H_ 58104476Ssam 59104476Ssam#include <sys/ioccom.h> 60104476Ssam 61104476Ssam/* Some initial values */ 62104476Ssam#define CRYPTO_DRIVERS_INITIAL 4 63104476Ssam#define CRYPTO_SW_SESSIONS 32 64104476Ssam 65159227Spjd/* Hash values */ 66159227Spjd#define NULL_HASH_LEN 16 67159227Spjd#define MD5_HASH_LEN 16 68159227Spjd#define SHA1_HASH_LEN 20 69159227Spjd#define RIPEMD160_HASH_LEN 20 70159227Spjd#define SHA2_256_HASH_LEN 32 71159227Spjd#define SHA2_384_HASH_LEN 48 72159227Spjd#define SHA2_512_HASH_LEN 64 73159227Spjd#define MD5_KPDK_HASH_LEN 16 74159227Spjd#define SHA1_KPDK_HASH_LEN 20 75159228Spjd/* Maximum hash algorithm result length */ 76159228Spjd#define HASH_MAX_LEN SHA2_512_HASH_LEN /* Keep this updated */ 77159228Spjd 78104476Ssam/* HMAC values */ 79159227Spjd#define NULL_HMAC_BLOCK_LEN 64 80159227Spjd#define MD5_HMAC_BLOCK_LEN 64 81159227Spjd#define SHA1_HMAC_BLOCK_LEN 64 82159227Spjd#define RIPEMD160_HMAC_BLOCK_LEN 64 83159227Spjd#define SHA2_256_HMAC_BLOCK_LEN 64 84159227Spjd#define SHA2_384_HMAC_BLOCK_LEN 128 85159227Spjd#define SHA2_512_HMAC_BLOCK_LEN 128 86159229Spjd/* Maximum HMAC block length */ 87159229Spjd#define HMAC_MAX_BLOCK_LEN SHA2_512_HMAC_BLOCK_LEN /* Keep this updated */ 88159227Spjd#define HMAC_IPAD_VAL 0x36 89159227Spjd#define HMAC_OPAD_VAL 0x5C 90104476Ssam 91104476Ssam/* Encryption algorithm block sizes */ 92159227Spjd#define NULL_BLOCK_LEN 4 93104476Ssam#define DES_BLOCK_LEN 8 94104476Ssam#define DES3_BLOCK_LEN 8 95104476Ssam#define BLOWFISH_BLOCK_LEN 8 96104476Ssam#define SKIPJACK_BLOCK_LEN 8 97104476Ssam#define CAST128_BLOCK_LEN 8 98104476Ssam#define RIJNDAEL128_BLOCK_LEN 16 99159227Spjd#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN 100169425Sgnn#define CAMELLIA_BLOCK_LEN 16 101159230Spjd#define EALG_MAX_BLOCK_LEN AES_BLOCK_LEN /* Keep this updated */ 102104476Ssam 103104476Ssam#define CRYPTO_ALGORITHM_MIN 1 104104476Ssam#define CRYPTO_DES_CBC 1 105104476Ssam#define CRYPTO_3DES_CBC 2 106104476Ssam#define CRYPTO_BLF_CBC 3 107104476Ssam#define CRYPTO_CAST_CBC 4 108104476Ssam#define CRYPTO_SKIPJACK_CBC 5 109104476Ssam#define CRYPTO_MD5_HMAC 6 110104476Ssam#define CRYPTO_SHA1_HMAC 7 111104476Ssam#define CRYPTO_RIPEMD160_HMAC 8 112104476Ssam#define CRYPTO_MD5_KPDK 9 113104476Ssam#define CRYPTO_SHA1_KPDK 10 114104476Ssam#define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */ 115104476Ssam#define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */ 116104476Ssam#define CRYPTO_ARC4 12 117104476Ssam#define CRYPTO_MD5 13 118104476Ssam#define CRYPTO_SHA1 14 119158703Spjd#define CRYPTO_NULL_HMAC 15 120158703Spjd#define CRYPTO_NULL_CBC 16 121158703Spjd#define CRYPTO_DEFLATE_COMP 17 /* Deflate compression algorithm */ 122158703Spjd#define CRYPTO_SHA2_256_HMAC 18 123158703Spjd#define CRYPTO_SHA2_384_HMAC 19 124158703Spjd#define CRYPTO_SHA2_512_HMAC 20 125169425Sgnn#define CRYPTO_CAMELLIA_CBC 21 126213068Spjd#define CRYPTO_AES_XTS 22 127213068Spjd#define CRYPTO_ALGORITHM_MAX 22 /* Keep updated - see below */ 128104476Ssam 129104476Ssam/* Algorithm flags */ 130104476Ssam#define CRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */ 131104476Ssam#define CRYPTO_ALG_FLAG_RNG_ENABLE 0x02 /* Has HW RNG for DH/DSA */ 132104476Ssam#define CRYPTO_ALG_FLAG_DSA_SHA 0x04 /* Can do SHA on msg */ 133104476Ssam 134167755Ssam/* 135167755Ssam * Crypto driver/device flags. They can set in the crid 136167755Ssam * parameter when creating a session or submitting a key 137167755Ssam * op to affect the device/driver assigned. If neither 138167755Ssam * of these are specified then the crid is assumed to hold 139167755Ssam * the driver id of an existing (and suitable) device that 140167755Ssam * must be used to satisfy the request. 141167755Ssam */ 142167755Ssam#define CRYPTO_FLAG_HARDWARE 0x01000000 /* hardware accelerated */ 143167755Ssam#define CRYPTO_FLAG_SOFTWARE 0x02000000 /* software implementation */ 144167755Ssam 145167755Ssam/* NB: deprecated */ 146104476Ssamstruct session_op { 147104476Ssam u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ 148104476Ssam u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ 149104476Ssam 150104476Ssam u_int32_t keylen; /* cipher key */ 151104476Ssam caddr_t key; 152104476Ssam int mackeylen; /* mac key */ 153104476Ssam caddr_t mackey; 154104476Ssam 155104476Ssam u_int32_t ses; /* returns: session # */ 156104476Ssam}; 157104476Ssam 158167755Ssamstruct session2_op { 159167755Ssam u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ 160167755Ssam u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */ 161167755Ssam 162167755Ssam u_int32_t keylen; /* cipher key */ 163167755Ssam caddr_t key; 164167755Ssam int mackeylen; /* mac key */ 165167755Ssam caddr_t mackey; 166167755Ssam 167167755Ssam u_int32_t ses; /* returns: session # */ 168167755Ssam int crid; /* driver id + flags (rw) */ 169167755Ssam int pad[4]; /* for future expansion */ 170167755Ssam}; 171167755Ssam 172104476Ssamstruct crypt_op { 173104476Ssam u_int32_t ses; 174104476Ssam u_int16_t op; /* i.e. COP_ENCRYPT */ 175104476Ssam#define COP_ENCRYPT 1 176104476Ssam#define COP_DECRYPT 2 177111297Ssam u_int16_t flags; 178111297Ssam#define COP_F_BATCH 0x0008 /* Batch op if possible */ 179104476Ssam u_int len; 180104476Ssam caddr_t src, dst; /* become iov[] inside kernel */ 181104476Ssam caddr_t mac; /* must be big enough for chosen MAC */ 182104476Ssam caddr_t iv; 183104476Ssam}; 184104476Ssam 185167755Ssam/* 186167755Ssam * Parameters for looking up a crypto driver/device by 187167755Ssam * device name or by id. The latter are returned for 188167755Ssam * created sessions (crid) and completed key operations. 189167755Ssam */ 190167755Ssamstruct crypt_find_op { 191167755Ssam int crid; /* driver id + flags */ 192167755Ssam char name[32]; /* device/driver name */ 193167755Ssam}; 194167755Ssam 195104476Ssam/* bignum parameter, in packed bytes, ... */ 196104476Ssamstruct crparam { 197104476Ssam caddr_t crp_p; 198104476Ssam u_int crp_nbits; 199104476Ssam}; 200104476Ssam 201104476Ssam#define CRK_MAXPARAM 8 202104476Ssam 203104476Ssamstruct crypt_kop { 204104476Ssam u_int crk_op; /* ie. CRK_MOD_EXP or other */ 205104476Ssam u_int crk_status; /* return status */ 206104476Ssam u_short crk_iparams; /* # of input parameters */ 207104476Ssam u_short crk_oparams; /* # of output parameters */ 208167755Ssam u_int crk_crid; /* NB: only used by CIOCKEY2 (rw) */ 209104476Ssam struct crparam crk_param[CRK_MAXPARAM]; 210104476Ssam}; 211104476Ssam#define CRK_ALGORITM_MIN 0 212104476Ssam#define CRK_MOD_EXP 0 213104476Ssam#define CRK_MOD_EXP_CRT 1 214104476Ssam#define CRK_DSA_SIGN 2 215104476Ssam#define CRK_DSA_VERIFY 3 216104476Ssam#define CRK_DH_COMPUTE_KEY 4 217104476Ssam#define CRK_ALGORITHM_MAX 4 /* Keep updated - see below */ 218104476Ssam 219104476Ssam#define CRF_MOD_EXP (1 << CRK_MOD_EXP) 220104476Ssam#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) 221104476Ssam#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) 222104476Ssam#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) 223104476Ssam#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) 224104476Ssam 225104476Ssam/* 226104476Ssam * done against open of /dev/crypto, to get a cloned descriptor. 227104476Ssam * Please use F_SETFD against the cloned descriptor. 228104476Ssam */ 229104476Ssam#define CRIOGET _IOWR('c', 100, u_int32_t) 230167755Ssam#define CRIOASYMFEAT CIOCASYMFEAT 231167755Ssam#define CRIOFINDDEV CIOCFINDDEV 232104476Ssam 233104476Ssam/* the following are done against the cloned descriptor */ 234104476Ssam#define CIOCGSESSION _IOWR('c', 101, struct session_op) 235104476Ssam#define CIOCFSESSION _IOW('c', 102, u_int32_t) 236104476Ssam#define CIOCCRYPT _IOWR('c', 103, struct crypt_op) 237104476Ssam#define CIOCKEY _IOWR('c', 104, struct crypt_kop) 238104476Ssam#define CIOCASYMFEAT _IOR('c', 105, u_int32_t) 239167755Ssam#define CIOCGSESSION2 _IOWR('c', 106, struct session2_op) 240167755Ssam#define CIOCKEY2 _IOWR('c', 107, struct crypt_kop) 241167755Ssam#define CIOCFINDDEV _IOWR('c', 108, struct crypt_find_op) 242104476Ssam 243108587Ssamstruct cryptotstat { 244108587Ssam struct timespec acc; /* total accumulated time */ 245108587Ssam struct timespec min; /* min time */ 246108587Ssam struct timespec max; /* max time */ 247108587Ssam u_int32_t count; /* number of observations */ 248108587Ssam}; 249108587Ssam 250108587Ssamstruct cryptostats { 251108587Ssam u_int32_t cs_ops; /* symmetric crypto ops submitted */ 252108587Ssam u_int32_t cs_errs; /* symmetric crypto ops that failed */ 253108587Ssam u_int32_t cs_kops; /* asymetric/key ops submitted */ 254108587Ssam u_int32_t cs_kerrs; /* asymetric/key ops that failed */ 255108587Ssam u_int32_t cs_intrs; /* crypto swi thread activations */ 256108587Ssam u_int32_t cs_rets; /* crypto return thread activations */ 257108587Ssam u_int32_t cs_blocks; /* symmetric op driver block */ 258108587Ssam u_int32_t cs_kblocks; /* symmetric op driver block */ 259108587Ssam /* 260108587Ssam * When CRYPTO_TIMING is defined at compile time and the 261108587Ssam * sysctl debug.crypto is set to 1, the crypto system will 262108587Ssam * accumulate statistics about how long it takes to process 263108587Ssam * crypto requests at various points during processing. 264108587Ssam */ 265108587Ssam struct cryptotstat cs_invoke; /* crypto_dipsatch -> crypto_invoke */ 266108587Ssam struct cryptotstat cs_done; /* crypto_invoke -> crypto_done */ 267108587Ssam struct cryptotstat cs_cb; /* crypto_done -> callback */ 268108587Ssam struct cryptotstat cs_finis; /* callback -> callback return */ 269108587Ssam}; 270108587Ssam 271104476Ssam#ifdef _KERNEL 272104476Ssam/* Standard initialization structure beginning */ 273104476Ssamstruct cryptoini { 274104476Ssam int cri_alg; /* Algorithm to use */ 275104476Ssam int cri_klen; /* Key length, in bits */ 276158703Spjd int cri_mlen; /* Number of bytes we want from the 277158703Spjd entire hash. 0 means all. */ 278104476Ssam caddr_t cri_key; /* key to use */ 279104476Ssam u_int8_t cri_iv[EALG_MAX_BLOCK_LEN]; /* IV to use */ 280104476Ssam struct cryptoini *cri_next; 281104476Ssam}; 282104476Ssam 283104476Ssam/* Describe boundaries of a single crypto operation */ 284104476Ssamstruct cryptodesc { 285104476Ssam int crd_skip; /* How many bytes to ignore from start */ 286104476Ssam int crd_len; /* How many bytes to process */ 287104476Ssam int crd_inject; /* Where to inject results, if applicable */ 288104476Ssam int crd_flags; 289104476Ssam 290104476Ssam#define CRD_F_ENCRYPT 0x01 /* Set when doing encryption */ 291104476Ssam#define CRD_F_IV_PRESENT 0x02 /* When encrypting, IV is already in 292104476Ssam place, so don't copy. */ 293104476Ssam#define CRD_F_IV_EXPLICIT 0x04 /* IV explicitly provided */ 294104476Ssam#define CRD_F_DSA_SHA_NEEDED 0x08 /* Compute SHA-1 of buffer for DSA */ 295125330Sphk#define CRD_F_KEY_EXPLICIT 0x10 /* Key explicitly provided */ 296104476Ssam#define CRD_F_COMP 0x0f /* Set when doing compression */ 297104476Ssam 298104476Ssam struct cryptoini CRD_INI; /* Initialization/context data */ 299104476Ssam#define crd_iv CRD_INI.cri_iv 300104476Ssam#define crd_key CRD_INI.cri_key 301104476Ssam#define crd_alg CRD_INI.cri_alg 302104476Ssam#define crd_klen CRD_INI.cri_klen 303104476Ssam 304104476Ssam struct cryptodesc *crd_next; 305104476Ssam}; 306104476Ssam 307104476Ssam/* Structure describing complete operation */ 308104476Ssamstruct cryptop { 309104476Ssam TAILQ_ENTRY(cryptop) crp_next; 310104476Ssam 311104476Ssam u_int64_t crp_sid; /* Session ID */ 312104476Ssam int crp_ilen; /* Input data total length */ 313104476Ssam int crp_olen; /* Result total length */ 314104476Ssam 315104476Ssam int crp_etype; /* 316104476Ssam * Error type (zero means no error). 317104476Ssam * All error codes except EAGAIN 318104476Ssam * indicate possible data corruption (as in, 319104476Ssam * the data have been touched). On all 320104476Ssam * errors, the crp_sid may have changed 321104476Ssam * (reset to a new one), so the caller 322104476Ssam * should always check and use the new 323104476Ssam * value on future requests. 324104476Ssam */ 325104476Ssam int crp_flags; 326104476Ssam 327117058Ssam#define CRYPTO_F_IMBUF 0x0001 /* Input/output are mbuf chains */ 328117058Ssam#define CRYPTO_F_IOV 0x0002 /* Input/output are uio */ 329117058Ssam#define CRYPTO_F_REL 0x0004 /* Must return data in same place */ 330117058Ssam#define CRYPTO_F_BATCH 0x0008 /* Batch op if possible */ 331117058Ssam#define CRYPTO_F_CBIMM 0x0010 /* Do callback immediately */ 332117058Ssam#define CRYPTO_F_DONE 0x0020 /* Operation completed */ 333117058Ssam#define CRYPTO_F_CBIFSYNC 0x0040 /* Do CBIMM if op is synchronous */ 334104476Ssam 335104476Ssam caddr_t crp_buf; /* Data to be processed */ 336104476Ssam caddr_t crp_opaque; /* Opaque pointer, passed along */ 337104476Ssam struct cryptodesc *crp_desc; /* Linked list of processing descriptors */ 338104476Ssam 339104476Ssam int (*crp_callback)(struct cryptop *); /* Callback function */ 340104476Ssam 341108587Ssam struct bintime crp_tstamp; /* performance time stamp */ 342104476Ssam}; 343104476Ssam 344104476Ssam#define CRYPTO_BUF_CONTIG 0x0 345104476Ssam#define CRYPTO_BUF_IOV 0x1 346104476Ssam#define CRYPTO_BUF_MBUF 0x2 347104476Ssam 348104476Ssam#define CRYPTO_OP_DECRYPT 0x0 349104476Ssam#define CRYPTO_OP_ENCRYPT 0x1 350104476Ssam 351104476Ssam/* 352104476Ssam * Hints passed to process methods. 353104476Ssam */ 354104476Ssam#define CRYPTO_HINT_MORE 0x1 /* more ops coming shortly */ 355104476Ssam 356104476Ssamstruct cryptkop { 357104476Ssam TAILQ_ENTRY(cryptkop) krp_next; 358104476Ssam 359104476Ssam u_int krp_op; /* ie. CRK_MOD_EXP or other */ 360104476Ssam u_int krp_status; /* return status */ 361104476Ssam u_short krp_iparams; /* # of input parameters */ 362104476Ssam u_short krp_oparams; /* # of output parameters */ 363167755Ssam u_int krp_crid; /* desired device, etc. */ 364104476Ssam u_int32_t krp_hid; 365104476Ssam struct crparam krp_param[CRK_MAXPARAM]; /* kvm */ 366104476Ssam int (*krp_callback)(struct cryptkop *); 367104476Ssam}; 368104476Ssam 369158824Spjd/* 370116924Ssam * Session ids are 64 bits. The lower 32 bits contain a "local id" which 371116924Ssam * is a driver-private session identifier. The upper 32 bits contain a 372116924Ssam * "hardware id" used by the core crypto code to identify the driver and 373116924Ssam * a copy of the driver's capabilities that can be used by client code to 374116924Ssam * optimize operation. 375116924Ssam */ 376167755Ssam#define CRYPTO_SESID2HID(_sid) (((_sid) >> 32) & 0x00ffffff) 377167755Ssam#define CRYPTO_SESID2CAPS(_sid) (((_sid) >> 32) & 0xff000000) 378116924Ssam#define CRYPTO_SESID2LID(_sid) (((u_int32_t) (_sid)) & 0xffffffff) 379116924Ssam 380104476SsamMALLOC_DECLARE(M_CRYPTO_DATA); 381104476Ssam 382104476Ssamextern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard); 383104476Ssamextern int crypto_freesession(u_int64_t sid); 384167755Ssam#define CRYPTOCAP_F_HARDWARE CRYPTO_FLAG_HARDWARE 385167755Ssam#define CRYPTOCAP_F_SOFTWARE CRYPTO_FLAG_SOFTWARE 386167755Ssam#define CRYPTOCAP_F_SYNC 0x04000000 /* operates synchronously */ 387167755Ssamextern int32_t crypto_get_driverid(device_t dev, int flags); 388167755Ssamextern int crypto_find_driver(const char *); 389167755Ssamextern device_t crypto_find_device_byhid(int hid); 390167755Ssamextern int crypto_getcaps(int hid); 391104476Ssamextern int crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen, 392167755Ssam u_int32_t flags); 393167755Ssamextern int crypto_kregister(u_int32_t, int, u_int32_t); 394104476Ssamextern int crypto_unregister(u_int32_t driverid, int alg); 395104476Ssamextern int crypto_unregister_all(u_int32_t driverid); 396104476Ssamextern int crypto_dispatch(struct cryptop *crp); 397104476Ssamextern int crypto_kdispatch(struct cryptkop *); 398104476Ssam#define CRYPTO_SYMQ 0x1 399104476Ssam#define CRYPTO_ASYMQ 0x2 400104476Ssamextern int crypto_unblock(u_int32_t, int); 401104476Ssamextern void crypto_done(struct cryptop *crp); 402104476Ssamextern void crypto_kdone(struct cryptkop *); 403104476Ssamextern int crypto_getfeat(int *); 404104476Ssam 405104476Ssamextern void crypto_freereq(struct cryptop *crp); 406104476Ssamextern struct cryptop *crypto_getreq(int num); 407104476Ssam 408104476Ssamextern int crypto_usercrypto; /* userland may do crypto requests */ 409104476Ssamextern int crypto_userasymcrypto; /* userland may do asym crypto reqs */ 410104476Ssamextern int crypto_devallowsoft; /* only use hardware crypto */ 411104476Ssam 412104476Ssam/* 413104476Ssam * Crypto-related utility routines used mainly by drivers. 414104476Ssam * 415104476Ssam * XXX these don't really belong here; but for now they're 416104476Ssam * kept apart from the rest of the system. 417104476Ssam */ 418104476Ssamstruct uio; 419104476Ssamextern void cuio_copydata(struct uio* uio, int off, int len, caddr_t cp); 420104476Ssamextern void cuio_copyback(struct uio* uio, int off, int len, caddr_t cp); 421104476Ssamextern struct iovec *cuio_getptr(struct uio *uio, int loc, int *off); 422158699Spjdextern int cuio_apply(struct uio *uio, int off, int len, 423158703Spjd int (*f)(void *, void *, u_int), void *arg); 424159241Spjd 425159241Spjdextern void crypto_copyback(int flags, caddr_t buf, int off, int size, 426159241Spjd caddr_t in); 427159241Spjdextern void crypto_copydata(int flags, caddr_t buf, int off, int size, 428159241Spjd caddr_t out); 429159241Spjdextern int crypto_apply(int flags, caddr_t buf, int off, int len, 430159241Spjd int (*f)(void *, void *, u_int), void *arg); 431104476Ssam#endif /* _KERNEL */ 432104476Ssam#endif /* _CRYPTO_CRYPTO_H_ */ 433