1 /**	$MirOS: src/sys/dev/vndioctl.h,v 1.8 2008/07/09 23:20:50 tg Exp $	*/
2 /*	$OpenBSD: vndioctl.h,v 1.6 2004/06/20 18:03:03 pedro Exp $	*/
3 /*	$NetBSD: vndioctl.h,v 1.5 1995/01/25 04:46:30 cgd Exp $	*/
4 
5 /*
6  * Copyright (c) 1988 University of Utah.
7  * Copyright (c) 1990, 1993
8  *	The Regents of the University of California.  All rights reserved.
9  *
10  * This code is derived from software contributed to Berkeley by
11  * the Systems Programming Group of the University of Utah Computer
12  * Science Department.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 3. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$
39  *
40  *	@(#)vnioctl.h	8.1 (Berkeley) 6/10/93
41  */
42 
43 #ifndef _SYS_VNDIOCTL_H_
44 #define _SYS_VNDIOCTL_H_
45 
46 #define VNDNLEN	90
47 
48 /*
49  * Ioctl definitions for file (vnode) disk pseudo-device.
50  */
51 struct vnd_ioctl {
52 	char	*vnd_file;	/* pathname of file to mount */
53 	off_t	vnd_size;	/* (returned) size of disk */
54 	u_char	*vnd_key;
55 	int	vnd_keylen;
56 	u_int32_t vnd_options;	/* mount options (for configure) */
57 #define VNDIOC_OPT_RDONLY  1	/* don't write to the underlying file */
58 #define VNDIOC_ALGSHIFT	24	/* shift of algorithm in vnd_options */
59 #define VNDIOC_ALG_BLF		0x00	/* old Blowfish */
60 #ifdef notyet
61 /* do not use these yet:
62  * 1) kernel implementation has not yet been tested
63  * 2) user space is not ready yet
64  * 3) the API will change for XTR support:
65  *    http://marc.info/?m=121341266715025
66  *    we will do it like them, one key per 2³⁰ blocks (sectors), for all algos
67  */
68 #define VNDIOC_ALG_BF_CBC	0x01	/* new Blowfish-CBC */
69 #define VNDIOC_ALG_AES128_CBC	0x02	/* AES with 128-bit keys */
70 #define VNDIOC_ALG_AES192_CBC	0x03	/* AES with 192-bit keys */
71 #define VNDIOC_ALG_AES256_CBC	0x04	/* AES with 256-bit keys */
72 #endif
73 };
74 
75 /*
76  * Key sizes for the encrypton algorithms
77  */
78 #define VNDIOC_KSZ_BLF		72	/* 576 bit (448 bit used) */
79 #ifdef notyet
80 #define VNDIOC_KSZ_BF_CBC	88	/* 16 bytes salt, 72 bytes key */
81 #define VNDIOC_KSZ_AES128_CBC	32	/* 16 bytes salt, 16 bytes key */
82 #define VNDIOC_KSZ_AES192_CBC	40	/* 16 bytes salt, 24 bytes key */
83 #define VNDIOC_KSZ_AES256_CBC	48	/* 16 bytes salt, 32 bytes key */
84 #define VNDIOC_MAXKSZ		88	/* largest of the above */
85 #else
86 #define VNDIOC_MAXKSZ		72
87 #endif
88 
89 #define VNDIOC_BSZ_BLF		8	/* blowfish has 64 bit blocks */
90 #ifdef notyet
91 #define VNDIOC_BSZ_AES		16	/* rijndael has 128 bit blocks */
92 #define VNDIOC_MAXBSZ		16	/* largest of the above */
93 
94 #define VNDIOC_IVSZ		16	/* size of the salt/IV */
95 #else
96 #define VNDIOC_MAXBSZ		8
97 #endif
98 
99 /*
100  * A simple structure used by userland to query about a specific vnd.
101  */
102 struct vnd_user {
103 	char	vnu_file[VNDNLEN];	/* vnd file */
104 	int	vnu_unit;		/* vnd unit */
105 	dev_t	vnu_dev;		/* vnd device */
106 	ino_t	vnu_ino;		/* vnd inode */
107 };
108 
109 /*
110  * Before you can use a unit, it must be configured with VNDIOCSET.
111  * The configuration persists across opens and closes of the device;
112  * an VNDIOCCLR must be used to reset a configuration.  An attempt to
113  * VNDIOCSET an already active unit will return EBUSY.
114  */
115 #define VNDIOCSET	_IOWR('F', 0, struct vnd_ioctl)	/* enable disk */
116 #define VNDIOCCLR	_IOW('F', 1, struct vnd_ioctl)	/* disable disk */
117 #define VNDIOCGET	_IOWR('F', 2, struct vnd_user)	/* get disk info */
118 
119 #endif /* !_SYS_VNDIOCTL_H_ */
120