Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/cryptodev.h
Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | |||||
* op to affect the device/driver assigned. If neither | * op to affect the device/driver assigned. If neither | ||||
* of these are specified then the crid is assumed to hold | * of these are specified then the crid is assumed to hold | ||||
* the driver id of an existing (and suitable) device that | * the driver id of an existing (and suitable) device that | ||||
* must be used to satisfy the request. | * must be used to satisfy the request. | ||||
*/ | */ | ||||
#define CRYPTO_FLAG_HARDWARE 0x01000000 /* hardware accelerated */ | #define CRYPTO_FLAG_HARDWARE 0x01000000 /* hardware accelerated */ | ||||
#define CRYPTO_FLAG_SOFTWARE 0x02000000 /* software implementation */ | #define CRYPTO_FLAG_SOFTWARE 0x02000000 /* software implementation */ | ||||
/* Does crypto support unmapped buffers on this platform? */ | |||||
#define CRYPTO_HAS_UNMAPPED ( PMAP_HAS_DMAP ) | |||||
/* NB: deprecated */ | /* NB: deprecated */ | ||||
struct session_op { | struct session_op { | ||||
u_int32_t cipher; /* ie. CRYPTO_AES_CBC */ | u_int32_t cipher; /* ie. CRYPTO_AES_CBC */ | ||||
u_int32_t mac; /* ie. CRYPTO_SHA2_256_HMAC */ | u_int32_t mac; /* ie. CRYPTO_SHA2_256_HMAC */ | ||||
u_int32_t keylen; /* cipher key */ | u_int32_t keylen; /* cipher key */ | ||||
c_caddr_t key; | c_caddr_t key; | ||||
int mackeylen; /* mac key */ | int mackeylen; /* mac key */ | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | int csp_auth_mlen; /* Number of digest bytes to use. | ||||
0 means all. */ | 0 means all. */ | ||||
}; | }; | ||||
enum crypto_buffer_type { | enum crypto_buffer_type { | ||||
CRYPTO_BUF_NONE = 0, | CRYPTO_BUF_NONE = 0, | ||||
CRYPTO_BUF_CONTIG, | CRYPTO_BUF_CONTIG, | ||||
CRYPTO_BUF_UIO, | CRYPTO_BUF_UIO, | ||||
CRYPTO_BUF_MBUF, | CRYPTO_BUF_MBUF, | ||||
CRYPTO_BUF_LAST = CRYPTO_BUF_MBUF | CRYPTO_BUF_UNMAPPED, | ||||
CRYPTO_BUF_LAST = CRYPTO_BUF_UNMAPPED | |||||
}; | }; | ||||
/* | /* | ||||
* Description of a data buffer for a request. Requests can either | * Description of a data buffer for a request. Requests can either | ||||
* have a single buffer that is modified in place or separate input | * have a single buffer that is modified in place or separate input | ||||
* and output buffers. | * and output buffers. | ||||
*/ | */ | ||||
struct crypto_buffer { | struct crypto_buffer { | ||||
union { | union { | ||||
struct { | struct { | ||||
char *cb_buf; | char *cb_buf; | ||||
int cb_buf_len; | int cb_buf_len; | ||||
}; | }; | ||||
struct mbuf *cb_mbuf; | struct mbuf *cb_mbuf; | ||||
struct { | |||||
vm_page_t *cb_unmapped; | |||||
int cb_unmapped_len; | |||||
int cb_unmapped_offset; | |||||
}; | |||||
struct uio *cb_uio; | struct uio *cb_uio; | ||||
}; | }; | ||||
enum crypto_buffer_type cb_type; | enum crypto_buffer_type cb_type; | ||||
}; | }; | ||||
/* | /* | ||||
* A cursor is used to iterate through a crypto request data buffer. | * A cursor is used to iterate through a crypto request data buffer. | ||||
*/ | */ | ||||
struct crypto_buffer_cursor { | struct crypto_buffer_cursor { | ||||
union { | union { | ||||
char *cc_buf; | char *cc_buf; | ||||
struct mbuf *cc_mbuf; | struct mbuf *cc_mbuf; | ||||
struct iovec *cc_iov; | struct iovec *cc_iov; | ||||
vm_page_t *cc_unmapped; | |||||
}; | }; | ||||
union { | /* Optional bytes of valid data remaining */ | ||||
jhb: In general style(9) wants a blank line before comments (here and many other places throughout) | |||||
int cc_buf_len; | int cc_buf_len; | ||||
/* | |||||
* Optional offset within the current buffer segment where | |||||
* valid data begins | |||||
*/ | |||||
size_t cc_offset; | size_t cc_offset; | ||||
}; | |||||
enum crypto_buffer_type cc_type; | enum crypto_buffer_type cc_type; | ||||
}; | }; | ||||
/* Structure describing complete operation */ | /* Structure describing complete operation */ | ||||
struct cryptop { | struct cryptop { | ||||
TAILQ_ENTRY(cryptop) crp_next; | TAILQ_ENTRY(cryptop) crp_next; | ||||
struct task crp_task; | struct task crp_task; | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
static __inline void | static __inline void | ||||
_crypto_use_mbuf(struct crypto_buffer *cb, struct mbuf *m) | _crypto_use_mbuf(struct crypto_buffer *cb, struct mbuf *m) | ||||
{ | { | ||||
cb->cb_mbuf = m; | cb->cb_mbuf = m; | ||||
cb->cb_type = CRYPTO_BUF_MBUF; | cb->cb_type = CRYPTO_BUF_MBUF; | ||||
} | } | ||||
static __inline void | static __inline void | ||||
_crypto_use_unmapped(struct crypto_buffer *cb, vm_page_t *pages, int len, | |||||
int offset) | |||||
{ | |||||
cb->cb_unmapped = pages; | |||||
cb->cb_unmapped_len = len; | |||||
cb->cb_unmapped_offset = offset; | |||||
cb->cb_type = CRYPTO_BUF_UNMAPPED; | |||||
} | |||||
static __inline void | |||||
_crypto_use_uio(struct crypto_buffer *cb, struct uio *uio) | _crypto_use_uio(struct crypto_buffer *cb, struct uio *uio) | ||||
{ | { | ||||
cb->cb_uio = uio; | cb->cb_uio = uio; | ||||
cb->cb_type = CRYPTO_BUF_UIO; | cb->cb_type = CRYPTO_BUF_UIO; | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_buf(struct cryptop *crp, void *buf, int len) | crypto_use_buf(struct cryptop *crp, void *buf, int len) | ||||
{ | { | ||||
_crypto_use_buf(&crp->crp_buf, buf, len); | _crypto_use_buf(&crp->crp_buf, buf, len); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_mbuf(struct cryptop *crp, struct mbuf *m) | crypto_use_mbuf(struct cryptop *crp, struct mbuf *m) | ||||
{ | { | ||||
_crypto_use_mbuf(&crp->crp_buf, m); | _crypto_use_mbuf(&crp->crp_buf, m); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_unmapped(struct cryptop *crp, vm_page_t *pages, int len, | |||||
int offset) | |||||
{ | |||||
_crypto_use_unmapped(&crp->crp_buf, pages, len, offset); | |||||
} | |||||
static __inline void | |||||
crypto_use_uio(struct cryptop *crp, struct uio *uio) | crypto_use_uio(struct cryptop *crp, struct uio *uio) | ||||
{ | { | ||||
_crypto_use_uio(&crp->crp_buf, uio); | _crypto_use_uio(&crp->crp_buf, uio); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_output_buf(struct cryptop *crp, void *buf, int len) | crypto_use_output_buf(struct cryptop *crp, void *buf, int len) | ||||
{ | { | ||||
_crypto_use_buf(&crp->crp_obuf, buf, len); | _crypto_use_buf(&crp->crp_obuf, buf, len); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_output_mbuf(struct cryptop *crp, struct mbuf *m) | crypto_use_output_mbuf(struct cryptop *crp, struct mbuf *m) | ||||
{ | { | ||||
_crypto_use_mbuf(&crp->crp_obuf, m); | _crypto_use_mbuf(&crp->crp_obuf, m); | ||||
} | |||||
static __inline void | |||||
crypto_use_output_unmapped(struct cryptop *crp, vm_page_t *pages, int len, | |||||
int offset) | |||||
{ | |||||
_crypto_use_unmapped(&crp->crp_obuf, pages, len, offset); | |||||
} | } | ||||
static __inline void | static __inline void | ||||
crypto_use_output_uio(struct cryptop *crp, struct uio *uio) | crypto_use_output_uio(struct cryptop *crp, struct uio *uio) | ||||
{ | { | ||||
_crypto_use_uio(&crp->crp_obuf, uio); | _crypto_use_uio(&crp->crp_obuf, uio); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |
In general style(9) wants a blank line before comments (here and many other places throughout)