xref: /freebsd/stand/libsa/geli/geliboot_internal.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
162bd02ceSWarner Losh /*-
262bd02ceSWarner Losh  * Copyright (c) 2015 Allan Jude <allanjude@FreeBSD.org>
362bd02ceSWarner Losh  * Copyright (c) 2005-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
462bd02ceSWarner Losh  * All rights reserved.
562bd02ceSWarner Losh  *
662bd02ceSWarner Losh  * Redistribution and use in source and binary forms, with or without
762bd02ceSWarner Losh  * modification, are permitted provided that the following conditions
862bd02ceSWarner Losh  * are met:
962bd02ceSWarner Losh  * 1. Redistributions of source code must retain the above copyright
1062bd02ceSWarner Losh  *    notice, this list of conditions and the following disclaimer.
1162bd02ceSWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
1262bd02ceSWarner Losh  *    notice, this list of conditions and the following disclaimer in the
1362bd02ceSWarner Losh  *    documentation and/or other materials provided with the distribution.
1462bd02ceSWarner Losh  *
1562bd02ceSWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
1662bd02ceSWarner Losh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1762bd02ceSWarner Losh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1862bd02ceSWarner Losh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
1962bd02ceSWarner Losh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2062bd02ceSWarner Losh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2162bd02ceSWarner Losh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2262bd02ceSWarner Losh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2362bd02ceSWarner Losh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2462bd02ceSWarner Losh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2562bd02ceSWarner Losh  * SUCH DAMAGE.
2662bd02ceSWarner Losh  */
2762bd02ceSWarner Losh 
2862bd02ceSWarner Losh #ifndef _GELIBOOT_INTERNAL_H_
2962bd02ceSWarner Losh #define _GELIBOOT_INTERNAL_H_
3062bd02ceSWarner Losh 
3162bd02ceSWarner Losh #define _STRING_H_
3262bd02ceSWarner Losh #define _STRINGS_H_
3362bd02ceSWarner Losh #define _STDIO_H_
3462bd02ceSWarner Losh 
3562bd02ceSWarner Losh #include <sys/endian.h>
3662bd02ceSWarner Losh #include <sys/queue.h>
3762bd02ceSWarner Losh 
3862bd02ceSWarner Losh #include <geom/eli/g_eli.h>
3962bd02ceSWarner Losh #include <geom/eli/pkcs5v2.h>
4062bd02ceSWarner Losh 
4162bd02ceSWarner Losh /* Pull in the md5, sha256, and sha512 implementations */
4262bd02ceSWarner Losh #include <sys/md5.h>
4362bd02ceSWarner Losh #include <crypto/sha2/sha256.h>
4462bd02ceSWarner Losh #include <crypto/sha2/sha512.h>
4562bd02ceSWarner Losh 
4662bd02ceSWarner Losh /* Pull in AES implementation */
4762bd02ceSWarner Losh #include <crypto/rijndael/rijndael-api-fst.h>
4862bd02ceSWarner Losh 
4962bd02ceSWarner Losh /* AES-XTS implementation */
5062bd02ceSWarner Losh #define _STAND 1
5162bd02ceSWarner Losh #define STAND_H /* We don't want stand.h in {gpt,zfs,gptzfs}boot */
5262bd02ceSWarner Losh #include <opencrypto/xform_enc.h>
5362bd02ceSWarner Losh 
54de776da3SToomas Soome #include "geliboot.h"
55de776da3SToomas Soome 
56c1418270SIan Lepore #define GELIDEV_NAMELEN	32
57c1418270SIan Lepore 
58c1418270SIan Lepore struct geli_dev {
5962bd02ceSWarner Losh 	off_t			part_end;
6062bd02ceSWarner Losh 	struct g_eli_softc	sc;
6162bd02ceSWarner Losh 	struct g_eli_metadata	md;
6262bd02ceSWarner Losh 	int			keybuf_slot;
63c1418270SIan Lepore 	char                    *name; /* for prompting; it ends in ':' */
64c1418270SIan Lepore };
6562bd02ceSWarner Losh 
66de776da3SToomas Soome int geliboot_crypt(u_int algo, geli_op_t  enc, u_char *data, size_t datasize,
67*c7721958SJohn Baldwin     const u_char *key, size_t keysize, u_char *iv);
6862bd02ceSWarner Losh 
6962bd02ceSWarner Losh #endif /* _GELIBOOT_INTERNAL_H_ */
70