xref: /netbsd-src/sbin/cgdconfig/params.h (revision f81322cf185a4db50f71fcf7701f20198272620e)
1 /* $NetBSD: params.h,v 1.7 2004/08/13 15:03:57 tv Exp $ */
2 
3 /*-
4  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Roland C. Dowdeswell.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef PARAMS_H
40 #define PARAMS_H
41 
42 #include "utils.h"
43 
44 struct keygen {
45 	int		 kg_method;
46 	int		 kg_iterations;
47 	bits_t		*kg_salt;
48 	bits_t		*kg_key;
49 	struct keygen	*next;
50 };
51 
52 struct params {
53 	string_t	*algorithm;
54 	string_t	*ivmeth;
55 	bits_t		*key;
56 	int		 keylen;
57 	int		 bsize;
58 	int		 verify_method;
59 	struct keygen	*dep_keygen;
60 	struct keygen	*keygen;
61 };
62 
63 /* key generation methods */
64 
65 #define KEYGEN_UNKNOWN			0x0
66 #define KEYGEN_RANDOMKEY		0x1
67 #define KEYGEN_PKCS5_PBKDF2_OLD		0x2
68 #define KEYGEN_STOREDKEY		0x3
69 #define KEYGEN_URANDOMKEY		0x4
70 #define KEYGEN_PKCS5_PBKDF2_SHA1	0x5
71 
72 /* verification methods */
73 
74 #define VERIFY_UNKNOWN		0x0
75 #define VERIFY_NONE		0x1
76 #define VERIFY_DISKLABEL	0x2
77 #define VERIFY_FFS		0x3
78 #define VERIFY_REENTER		0x4
79 
80 __BEGIN_DECLS
81 struct params	*params_new(void);
82 void		 params_free(struct params *);
83 
84 int		 params_filldefaults(struct params *);
85 int		 params_verify(const struct params *);
86 
87 struct params	*params_combine(struct params *, struct params *);
88 struct params	*params_algorithm(string_t *);
89 struct params	*params_ivmeth(string_t *);
90 struct params	*params_keylen(int);
91 struct params	*params_bsize(int);
92 struct params	*params_verify_method(string_t *);
93 struct params	*params_keygen(struct keygen *);
94 struct params	*params_dep_keygen(struct keygen *);
95 
96 struct params	*params_fget(FILE *);
97 struct params	*params_cget(const char *);
98 int		 params_fput(struct params *, FILE *);
99 int		 params_cput(struct params *, const char *);
100 
101 struct keygen	*keygen_new(void);
102 void		 keygen_free(struct keygen *);
103 
104 int		 keygen_filldefaults(struct keygen *, int);
105 int		 keygen_verify(const struct keygen *);
106 void		 keygen_addlist(struct keygen **, struct keygen *);
107 
108 struct keygen	*keygen_combine(struct keygen *, struct keygen *);
109 struct keygen	*keygen_generate(int);
110 struct keygen	*keygen_method(string_t *);
111 struct keygen	*keygen_set_method(struct keygen *, string_t *);
112 struct keygen	*keygen_salt(bits_t *);
113 struct keygen	*keygen_iterations(int);
114 struct keygen	*keygen_key(bits_t *);
115 
116 int		 keygen_fput(struct keygen *, int, FILE *);
117 __END_DECLS
118 
119 #endif
120