xref: /freebsd/sys/crypto/intake.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1*ec5c0e5bSAllan Jude /*-
2*ec5c0e5bSAllan Jude  * Copyright (c) 2016 Eric McCorkle
3*ec5c0e5bSAllan Jude  * All rights reserved.
4*ec5c0e5bSAllan Jude  *
5*ec5c0e5bSAllan Jude  * Redistribution and use in source and binary forms, with or without
6*ec5c0e5bSAllan Jude  * modification, are permitted provided that the following conditions
7*ec5c0e5bSAllan Jude  * are met:
8*ec5c0e5bSAllan Jude  * 1. Redistributions of source code must retain the above copyright
9*ec5c0e5bSAllan Jude  *    notice, this list of conditions and the following disclaimer.
10*ec5c0e5bSAllan Jude  * 2. Redistributions in binary form must reproduce the above copyright
11*ec5c0e5bSAllan Jude  *    notice, this list of conditions and the following disclaimer in the
12*ec5c0e5bSAllan Jude  *    documentation and/or other materials provided with the distribution.
13*ec5c0e5bSAllan Jude  *
14*ec5c0e5bSAllan Jude  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*ec5c0e5bSAllan Jude  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*ec5c0e5bSAllan Jude  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*ec5c0e5bSAllan Jude  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*ec5c0e5bSAllan Jude  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*ec5c0e5bSAllan Jude  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*ec5c0e5bSAllan Jude  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*ec5c0e5bSAllan Jude  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*ec5c0e5bSAllan Jude  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*ec5c0e5bSAllan Jude  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*ec5c0e5bSAllan Jude  * SUCH DAMAGE.
25*ec5c0e5bSAllan Jude  */
26*ec5c0e5bSAllan Jude 
27*ec5c0e5bSAllan Jude #ifndef _INTAKE_H_
28*ec5c0e5bSAllan Jude #define _INTAKE_H_
29*ec5c0e5bSAllan Jude 
30*ec5c0e5bSAllan Jude #include  <sys/param.h>
31*ec5c0e5bSAllan Jude 
32*ec5c0e5bSAllan Jude /*
33*ec5c0e5bSAllan Jude  * This file provides an interface for providing keys to the kernel
34*ec5c0e5bSAllan Jude  * during boot time.
35*ec5c0e5bSAllan Jude  */
36*ec5c0e5bSAllan Jude 
37*ec5c0e5bSAllan Jude #define MAX_KEY_BITS	4096
38*ec5c0e5bSAllan Jude #define	MAX_KEY_BYTES	(MAX_KEY_BITS / NBBY)
39*ec5c0e5bSAllan Jude 
40*ec5c0e5bSAllan Jude #define KEYBUF_SENTINEL	0xcee54b5d	/* KEYS4BSD */
41*ec5c0e5bSAllan Jude 
42*ec5c0e5bSAllan Jude enum {
43*ec5c0e5bSAllan Jude         KEYBUF_TYPE_NONE,
44*ec5c0e5bSAllan Jude         KEYBUF_TYPE_GELI
45*ec5c0e5bSAllan Jude };
46*ec5c0e5bSAllan Jude 
47*ec5c0e5bSAllan Jude struct keybuf_ent {
48*ec5c0e5bSAllan Jude         unsigned int ke_type;
49*ec5c0e5bSAllan Jude         char ke_data[MAX_KEY_BYTES];
50*ec5c0e5bSAllan Jude };
51*ec5c0e5bSAllan Jude 
52*ec5c0e5bSAllan Jude struct keybuf {
53*ec5c0e5bSAllan Jude         unsigned int kb_nents;
54*ec5c0e5bSAllan Jude         struct keybuf_ent kb_ents[];
55*ec5c0e5bSAllan Jude };
56*ec5c0e5bSAllan Jude 
57*ec5c0e5bSAllan Jude #ifdef _KERNEL
58*ec5c0e5bSAllan Jude /* Get the key intake buffer */
59*ec5c0e5bSAllan Jude extern struct keybuf* get_keybuf(void);
60*ec5c0e5bSAllan Jude #endif
61*ec5c0e5bSAllan Jude 
62*ec5c0e5bSAllan Jude #endif
63