1/*	$OpenBSD: cryptosoft.h,v 1.16 2021/07/09 15:29:55 bluhm Exp $	*/
2
3/*
4 * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
5 *
6 * This code was written by Angelos D. Keromytis in Athens, Greece, in
7 * February 2000. Network Security Technologies Inc. (NSTI) kindly
8 * supported the development of this code.
9 *
10 * Copyright (c) 2000 Angelos D. Keromytis
11 *
12 * Permission to use, copy, and modify this software with or without fee
13 * is hereby granted, provided that this entire notice is included in
14 * all source code copies of any software which is or includes a copy or
15 * modification of this software.
16 *
17 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
18 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
19 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
20 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
21 * PURPOSE.
22 */
23
24#ifndef _CRYPTO_CRYPTOSOFT_H_
25#define _CRYPTO_CRYPTOSOFT_H_
26
27#include <sys/queue.h>
28
29/* Software session entry */
30struct swcr_data {
31	int		sw_alg;		/* Algorithm */
32	union {
33		struct {
34			u_int8_t	 *SW_ictx;
35			u_int8_t	 *SW_octx;
36			u_int32_t	 SW_klen;
37			const struct auth_hash *SW_axf;
38		} SWCR_AUTH;
39		struct {
40			u_int8_t	 *SW_kschedule;
41			const struct enc_xform *SW_exf;
42		} SWCR_ENC;
43		struct {
44			u_int32_t	 SW_size;
45			const struct comp_algo *SW_cxf;
46		} SWCR_COMP;
47	} SWCR_UN;
48
49#define sw_ictx		SWCR_UN.SWCR_AUTH.SW_ictx
50#define sw_octx		SWCR_UN.SWCR_AUTH.SW_octx
51#define sw_klen		SWCR_UN.SWCR_AUTH.SW_klen
52#define sw_axf		SWCR_UN.SWCR_AUTH.SW_axf
53#define sw_kschedule	SWCR_UN.SWCR_ENC.SW_kschedule
54#define sw_exf		SWCR_UN.SWCR_ENC.SW_exf
55#define sw_size		SWCR_UN.SWCR_COMP.SW_size
56#define sw_cxf		SWCR_UN.SWCR_COMP.SW_cxf
57
58	SLIST_ENTRY(swcr_data)	sw_next;
59};
60SLIST_HEAD(swcr_list, swcr_data);
61
62#ifdef _KERNEL
63extern const u_int8_t hmac_ipad_buffer[HMAC_MAX_BLOCK_LEN];
64extern const u_int8_t hmac_opad_buffer[HMAC_MAX_BLOCK_LEN];
65
66int	swcr_encdec(struct cryptodesc *, struct swcr_data *, caddr_t, int);
67int	swcr_authcompute(struct cryptop *, struct cryptodesc *, struct swcr_data *,
68	caddr_t, int);
69int	swcr_authenc(struct cryptop *);
70int	swcr_compdec(struct cryptodesc *, struct swcr_data *, caddr_t, int);
71int	swcr_process(struct cryptop *);
72int	swcr_newsession(u_int32_t *, struct cryptoini *);
73int	swcr_freesession(u_int64_t);
74void	swcr_init(void);
75#endif /* _KERNEL */
76
77#endif /* _CRYPTO_CRYPTO_H_ */
78