xref: /openbsd-src/sys/crypto/cryptosoft.h (revision a986bd3b88c678c8f70a69c57528cec429f57892)
1*a986bd3bSbluhm /*	$OpenBSD: cryptosoft.h,v 1.16 2021/07/09 15:29:55 bluhm Exp $	*/
24ec50cecSjason 
36e99f306Sderaadt /*
46e99f306Sderaadt  * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
56e99f306Sderaadt  *
66e99f306Sderaadt  * This code was written by Angelos D. Keromytis in Athens, Greece, in
76e99f306Sderaadt  * February 2000. Network Security Technologies Inc. (NSTI) kindly
86e99f306Sderaadt  * supported the development of this code.
96e99f306Sderaadt  *
106e99f306Sderaadt  * Copyright (c) 2000 Angelos D. Keromytis
116e99f306Sderaadt  *
126e5f36c8Sderaadt  * Permission to use, copy, and modify this software with or without fee
136e99f306Sderaadt  * is hereby granted, provided that this entire notice is included in
146e99f306Sderaadt  * all source code copies of any software which is or includes a copy or
156e99f306Sderaadt  * modification of this software.
166e99f306Sderaadt  *
176e99f306Sderaadt  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
186e99f306Sderaadt  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
196e99f306Sderaadt  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
206e99f306Sderaadt  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
216e99f306Sderaadt  * PURPOSE.
226e99f306Sderaadt  */
236e99f306Sderaadt 
246e99f306Sderaadt #ifndef _CRYPTO_CRYPTOSOFT_H_
256e99f306Sderaadt #define _CRYPTO_CRYPTOSOFT_H_
266e99f306Sderaadt 
27*a986bd3bSbluhm #include <sys/queue.h>
28*a986bd3bSbluhm 
296e99f306Sderaadt /* Software session entry */
308a4e6689Sderaadt struct swcr_data {
316e99f306Sderaadt 	int		sw_alg;		/* Algorithm */
328a4e6689Sderaadt 	union {
338a4e6689Sderaadt 		struct {
346e99f306Sderaadt 			u_int8_t	 *SW_ictx;
356e99f306Sderaadt 			u_int8_t	 *SW_octx;
36e26e8293Sangelos 			u_int32_t	 SW_klen;
374d13edafSbluhm 			const struct auth_hash *SW_axf;
386e99f306Sderaadt 		} SWCR_AUTH;
398a4e6689Sderaadt 		struct {
406e99f306Sderaadt 			u_int8_t	 *SW_kschedule;
414d13edafSbluhm 			const struct enc_xform *SW_exf;
426e99f306Sderaadt 		} SWCR_ENC;
4371960029Sjjbg 		struct {
4471960029Sjjbg 			u_int32_t	 SW_size;
454d13edafSbluhm 			const struct comp_algo *SW_cxf;
4671960029Sjjbg 		} SWCR_COMP;
476e99f306Sderaadt 	} SWCR_UN;
486e99f306Sderaadt 
496e99f306Sderaadt #define sw_ictx		SWCR_UN.SWCR_AUTH.SW_ictx
506e99f306Sderaadt #define sw_octx		SWCR_UN.SWCR_AUTH.SW_octx
51e26e8293Sangelos #define sw_klen		SWCR_UN.SWCR_AUTH.SW_klen
526e99f306Sderaadt #define sw_axf		SWCR_UN.SWCR_AUTH.SW_axf
536e99f306Sderaadt #define sw_kschedule	SWCR_UN.SWCR_ENC.SW_kschedule
546e99f306Sderaadt #define sw_exf		SWCR_UN.SWCR_ENC.SW_exf
5571960029Sjjbg #define sw_size		SWCR_UN.SWCR_COMP.SW_size
5671960029Sjjbg #define sw_cxf		SWCR_UN.SWCR_COMP.SW_cxf
576e99f306Sderaadt 
58*a986bd3bSbluhm 	SLIST_ENTRY(swcr_data)	sw_next;
596e99f306Sderaadt };
60*a986bd3bSbluhm SLIST_HEAD(swcr_list, swcr_data);
616e99f306Sderaadt 
626e99f306Sderaadt #ifdef _KERNEL
638688c78cSmarkus extern const u_int8_t hmac_ipad_buffer[HMAC_MAX_BLOCK_LEN];
648688c78cSmarkus extern const u_int8_t hmac_opad_buffer[HMAC_MAX_BLOCK_LEN];
656e99f306Sderaadt 
668a4e6689Sderaadt int	swcr_encdec(struct cryptodesc *, struct swcr_data *, caddr_t, int);
67649dc2d9Smarkus int	swcr_authcompute(struct cryptop *, struct cryptodesc *, struct swcr_data *,
686e99f306Sderaadt 	caddr_t, int);
69e3c3ea0bSmikeb int	swcr_authenc(struct cryptop *);
7071960029Sjjbg int	swcr_compdec(struct cryptodesc *, struct swcr_data *, caddr_t, int);
718a4e6689Sderaadt int	swcr_process(struct cryptop *);
728a4e6689Sderaadt int	swcr_newsession(u_int32_t *, struct cryptoini *);
738a4e6689Sderaadt int	swcr_freesession(u_int64_t);
748a4e6689Sderaadt void	swcr_init(void);
756e99f306Sderaadt #endif /* _KERNEL */
766e99f306Sderaadt 
776e99f306Sderaadt #endif /* _CRYPTO_CRYPTO_H_ */
78