params.h revision 1.4 1 /* $NetBSD: params.h,v 1.4 2003/03/24 02:02:51 elric 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 0x2
68 #define KEYGEN_STOREDKEY 0x3
69
70 /* verification methods */
71
72 #define VERIFY_UNKNOWN 0x0
73 #define VERIFY_NONE 0x1
74 #define VERIFY_DISKLABEL 0x2
75 #define VERIFY_FFS 0x3
76
77 __BEGIN_DECLS
78 struct params *params_new(void);
79 void params_free(struct params *);
80
81 int params_filldefaults(struct params *);
82 int params_verify(const struct params *);
83
84 struct params *params_combine(struct params *, struct params *);
85 struct params *params_algorithm(string_t *);
86 struct params *params_ivmeth(string_t *);
87 struct params *params_keylen(int);
88 struct params *params_bsize(int);
89 struct params *params_verify_method(string_t *);
90 struct params *params_keygen(struct keygen *);
91 struct params *params_dep_keygen(struct keygen *);
92
93 struct params *params_fget(FILE *);
94 struct params *params_cget(const char *);
95 int params_fput(struct params *, FILE *);
96 int params_cput(struct params *, const char *);
97
98 struct keygen *keygen_new(void);
99 void keygen_free(struct keygen *);
100
101 int keygen_filldefaults(struct keygen *, int);
102 int keygen_verify(const struct keygen *);
103 void keygen_addlist(struct keygen **, struct keygen *);
104
105 struct keygen *keygen_combine(struct keygen *, struct keygen *);
106 struct keygen *keygen_generate(int);
107 struct keygen *keygen_method(string_t *);
108 struct keygen *keygen_set_method(struct keygen *, string_t *);
109 struct keygen *keygen_salt(bits_t *);
110 struct keygen *keygen_iterations(int);
111 struct keygen *keygen_key(bits_t *);
112
113 int keygen_fput(struct keygen *, int, FILE *);
114 __END_DECLS
115
116 #endif
117