ocryptodev.h revision 1.4 1 1.4 pgoyette /* $NetBSD: ocryptodev.h,v 1.4 2019/01/27 02:08:48 pgoyette Exp $ */
2 1.1 darran /* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.6 2003/07/02 17:04:50 sam Exp $ */
3 1.1 darran /* $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $ */
4 1.1 darran
5 1.1 darran /*-
6 1.1 darran * Copyright (c) 2008 The NetBSD Foundation, Inc.
7 1.1 darran * All rights reserved.
8 1.1 darran *
9 1.1 darran * This code is derived from software contributed to The NetBSD Foundation
10 1.1 darran * by Coyote Point Systems, Inc.
11 1.1 darran *
12 1.1 darran * Redistribution and use in source and binary forms, with or without
13 1.1 darran * modification, are permitted provided that the following conditions
14 1.1 darran * are met:
15 1.1 darran * 1. Redistributions of source code must retain the above copyright
16 1.1 darran * notice, this list of conditions and the following disclaimer.
17 1.1 darran * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 darran * notice, this list of conditions and the following disclaimer in the
19 1.1 darran * documentation and/or other materials provided with the distribution.
20 1.1 darran *
21 1.1 darran * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 1.1 darran * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 1.1 darran * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 1.1 darran * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 1.1 darran * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 1.1 darran * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 1.1 darran * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.1 darran * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.1 darran * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.1 darran * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 1.1 darran * POSSIBILITY OF SUCH DAMAGE.
32 1.1 darran */
33 1.1 darran
34 1.1 darran /*
35 1.1 darran * The author of this code is Angelos D. Keromytis (angelos (at) cis.upenn.edu)
36 1.1 darran *
37 1.1 darran * This code was written by Angelos D. Keromytis in Athens, Greece, in
38 1.1 darran * February 2000. Network Security Technologies Inc. (NSTI) kindly
39 1.1 darran * supported the development of this code.
40 1.1 darran *
41 1.1 darran * Copyright (c) 2000 Angelos D. Keromytis
42 1.1 darran *
43 1.1 darran * Permission to use, copy, and modify this software with or without fee
44 1.1 darran * is hereby granted, provided that this entire notice is included in
45 1.1 darran * all source code copies of any software which is or includes a copy or
46 1.1 darran * modification of this software.
47 1.1 darran *
48 1.1 darran * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
49 1.1 darran * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
50 1.1 darran * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
51 1.1 darran * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
52 1.1 darran * PURPOSE.
53 1.1 darran *
54 1.1 darran * Copyright (c) 2001 Theo de Raadt
55 1.1 darran *
56 1.1 darran * Redistribution and use in source and binary forms, with or without
57 1.1 darran * modification, are permitted provided that the following conditions
58 1.1 darran * are met:
59 1.1 darran *
60 1.1 darran * 1. Redistributions of source code must retain the above copyright
61 1.1 darran * notice, this list of conditions and the following disclaimer.
62 1.1 darran * 2. Redistributions in binary form must reproduce the above copyright
63 1.1 darran * notice, this list of conditions and the following disclaimer in the
64 1.1 darran * documentation and/or other materials provided with the distribution.
65 1.1 darran * 3. The name of the author may not be used to endorse or promote products
66 1.1 darran * derived from this software without specific prior written permission.
67 1.1 darran *
68 1.1 darran * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
69 1.1 darran * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
70 1.1 darran * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
71 1.1 darran * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
72 1.1 darran * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
73 1.1 darran * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
74 1.1 darran * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
75 1.1 darran * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76 1.1 darran * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
77 1.1 darran * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78 1.1 darran *
79 1.1 darran * Effort sponsored in part by the Defense Advanced Research Projects
80 1.1 darran * Agency (DARPA) and Air Force Research Laboratory, Air Force
81 1.1 darran * Materiel Command, USAF, under agreement number F30602-01-2-0537.
82 1.1 darran *
83 1.1 darran */
84 1.1 darran
85 1.1 darran #ifndef _CRYPTO_OCRYPTODEV_H_
86 1.1 darran #define _CRYPTO_OCRYPTODEV_H_
87 1.1 darran
88 1.3 dholland #include <sys/ioccom.h>
89 1.3 dholland
90 1.1 darran struct osession_op { /* backwards compatible */
91 1.1 darran u_int32_t cipher; /* ie. CRYPTO_DES_CBC */
92 1.1 darran u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
93 1.1 darran u_int32_t keylen; /* cipher key */
94 1.1 darran void * key;
95 1.1 darran int mackeylen; /* mac key */
96 1.1 darran void * mackey;
97 1.1 darran
98 1.1 darran u_int32_t ses; /* returns: session # */
99 1.1 darran };
100 1.1 darran
101 1.1 darran struct osession_n_op {
102 1.1 darran u_int32_t cipher; /* ie. CRYPTO_DES_CBC */
103 1.1 darran u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
104 1.1 darran
105 1.1 darran u_int32_t keylen; /* cipher key */
106 1.1 darran void * key;
107 1.1 darran int mackeylen; /* mac key */
108 1.1 darran void * mackey;
109 1.1 darran
110 1.1 darran u_int32_t ses; /* returns: session # */
111 1.1 darran int status;
112 1.1 darran };
113 1.1 darran
114 1.1 darran struct ocrypt_op {
115 1.1 darran u_int32_t ses;
116 1.1 darran u_int16_t op; /* i.e. COP_ENCRYPT */
117 1.1 darran u_int16_t flags;
118 1.1 darran u_int len;
119 1.1 darran void * src, *dst; /* become iov[] inside kernel */
120 1.1 darran void * mac; /* must be big enough for chosen MAC */
121 1.1 darran void * iv;
122 1.1 darran };
123 1.1 darran
124 1.1 darran /* to support multiple session creation */
125 1.1 darran /*
126 1.1 darran *
127 1.1 darran * The reqid field is filled when the operation has
128 1.1 darran * been accepted and started, and can be used to later retrieve
129 1.1 darran * the operation results via CIOCNCRYPTRET or identify the
130 1.1 darran * request in the completion list returned by CIOCNCRYPTRETM.
131 1.1 darran *
132 1.1 darran * The opaque pointer can be set arbitrarily by the user
133 1.1 darran * and it is passed back in the crypt_result structure
134 1.1 darran * when the request completes. This field can be used for example
135 1.1 darran * to track context for the request and avoid lookups in the
136 1.1 darran * user application.
137 1.1 darran */
138 1.1 darran
139 1.1 darran struct ocrypt_n_op {
140 1.1 darran u_int32_t ses;
141 1.1 darran u_int16_t op; /* i.e. COP_ENCRYPT */
142 1.1 darran u_int16_t flags;
143 1.1 darran u_int len; /* src & dst len */
144 1.1 darran
145 1.1 darran u_int32_t reqid; /* request id */
146 1.1 darran int status; /* status of request -accepted or not */
147 1.1 darran void *opaque; /* opaque pointer returned to user */
148 1.1 darran u_int32_t keylen; /* cipher key - optional */
149 1.1 darran void * key;
150 1.1 darran u_int32_t mackeylen; /* also optional */
151 1.1 darran void * mackey;
152 1.1 darran
153 1.1 darran void * src, *dst; /* become iov[] inside kernel */
154 1.1 darran void * mac; /* must be big enough for chosen MAC */
155 1.1 darran void * iv;
156 1.1 darran };
157 1.1 darran
158 1.1 darran struct ocrypt_sgop {
159 1.1 darran size_t count;
160 1.1 darran struct osession_n_op * sessions;
161 1.1 darran };
162 1.1 darran
163 1.1 darran struct ocrypt_mop {
164 1.1 darran size_t count; /* how many */
165 1.1 darran struct ocrypt_n_op * reqs; /* where to get them */
166 1.1 darran };
167 1.1 darran
168 1.1 darran #define OCIOCGSESSION _IOWR('c', 101, struct osession_op)
169 1.1 darran #define OCIOCNGSESSION _IOWR('c', 106, struct ocrypt_sgop)
170 1.1 darran #define OCIOCCRYPT _IOWR('c', 103, struct ocrypt_op)
171 1.1 darran #define OCIOCNCRYPTM _IOWR('c', 107, struct ocrypt_mop)
172 1.1 darran
173 1.4 pgoyette struct fcrypt;
174 1.4 pgoyette struct session_op;
175 1.4 pgoyette struct csession;
176 1.4 pgoyette struct crypt_op;
177 1.4 pgoyette struct crypt_n_op;
178 1.4 pgoyette
179 1.1 darran int ocryptof_ioctl(struct file *, u_long, void *);
180 1.1 darran
181 1.1 darran #endif /* _CRYPTO_OCRYPTODEV_H_ */
182