params.h revision 1.9 1 /* $NetBSD: params.h,v 1.9 2008/04/28 20:23:08 martin 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 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef PARAMS_H
33 #define PARAMS_H
34
35 #include "utils.h"
36
37 struct keygen {
38 int kg_method;
39 size_t kg_iterations;
40 bits_t *kg_salt;
41 bits_t *kg_key;
42 struct keygen *next;
43 };
44
45 struct params {
46 string_t *algorithm;
47 string_t *ivmeth;
48 bits_t *key;
49 size_t keylen;
50 size_t bsize;
51 int verify_method;
52 struct keygen *dep_keygen;
53 struct keygen *keygen;
54 };
55
56 /* key generation methods */
57
58 #define KEYGEN_UNKNOWN 0x0
59 #define KEYGEN_RANDOMKEY 0x1
60 #define KEYGEN_PKCS5_PBKDF2_OLD 0x2
61 #define KEYGEN_STOREDKEY 0x3
62 #define KEYGEN_URANDOMKEY 0x4
63 #define KEYGEN_PKCS5_PBKDF2_SHA1 0x5
64
65 /* verification methods */
66
67 #define VERIFY_UNKNOWN 0x0
68 #define VERIFY_NONE 0x1
69 #define VERIFY_DISKLABEL 0x2
70 #define VERIFY_FFS 0x3
71 #define VERIFY_REENTER 0x4
72
73 __BEGIN_DECLS
74 struct params *params_new(void);
75 void params_free(struct params *);
76
77 int params_filldefaults(struct params *);
78 int params_verify(const struct params *);
79
80 struct params *params_combine(struct params *, struct params *);
81 struct params *params_algorithm(string_t *);
82 struct params *params_ivmeth(string_t *);
83 struct params *params_keylen(size_t);
84 struct params *params_bsize(size_t);
85 struct params *params_verify_method(string_t *);
86 struct params *params_keygen(struct keygen *);
87 struct params *params_dep_keygen(struct keygen *);
88
89 struct params *params_fget(FILE *);
90 struct params *params_cget(const char *);
91 int params_fput(struct params *, FILE *);
92 int params_cput(struct params *, const char *);
93
94 struct keygen *keygen_new(void);
95 void keygen_free(struct keygen *);
96
97 int keygen_filldefaults(struct keygen *, size_t);
98 int keygen_verify(const struct keygen *);
99 void keygen_addlist(struct keygen **, struct keygen *);
100
101 struct keygen *keygen_combine(struct keygen *, struct keygen *);
102 struct keygen *keygen_generate(int);
103 struct keygen *keygen_method(string_t *);
104 struct keygen *keygen_set_method(struct keygen *, string_t *);
105 struct keygen *keygen_salt(bits_t *);
106 struct keygen *keygen_iterations(size_t);
107 struct keygen *keygen_key(bits_t *);
108
109 int keygen_fput(struct keygen *, int, FILE *);
110 __END_DECLS
111
112 #endif
113