params.h revision 1.11 1 /* $NetBSD: params.h,v 1.11 2014/12/14 12:31:39 mlelstv 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 string_t *kg_cmd;
43 struct keygen *next;
44 };
45
46 struct params {
47 string_t *algorithm;
48 string_t *ivmeth;
49 bits_t *key;
50 size_t keylen;
51 size_t bsize;
52 int verify_method;
53 struct keygen *dep_keygen;
54 struct keygen *keygen;
55 };
56
57 /* key generation methods */
58
59 #define KEYGEN_UNKNOWN 0x0
60 #define KEYGEN_RANDOMKEY 0x1
61 #define KEYGEN_PKCS5_PBKDF2_OLD 0x2
62 #define KEYGEN_STOREDKEY 0x3
63 #define KEYGEN_URANDOMKEY 0x4
64 #define KEYGEN_PKCS5_PBKDF2_SHA1 0x5
65 #define KEYGEN_SHELL_CMD 0x6
66
67 /* verification methods */
68
69 #define VERIFY_UNKNOWN 0x0
70 #define VERIFY_NONE 0x1
71 #define VERIFY_DISKLABEL 0x2
72 #define VERIFY_FFS 0x3
73 #define VERIFY_REENTER 0x4
74 #define VERIFY_MBR 0x5
75 #define VERIFY_GPT 0x6
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(size_t);
88 struct params *params_bsize(size_t);
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 *, size_t);
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(size_t);
111 struct keygen *keygen_key(bits_t *);
112 struct keygen *keygen_cmd(string_t *);
113
114 int keygen_fput(struct keygen *, int, FILE *);
115 __END_DECLS
116
117 #endif
118