1 /* $NetBSD: params.h,v 1.10 2008/05/11 03:15:21 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 * 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 75 __BEGIN_DECLS 76 struct params *params_new(void); 77 void params_free(struct params *); 78 79 int params_filldefaults(struct params *); 80 int params_verify(const struct params *); 81 82 struct params *params_combine(struct params *, struct params *); 83 struct params *params_algorithm(string_t *); 84 struct params *params_ivmeth(string_t *); 85 struct params *params_keylen(size_t); 86 struct params *params_bsize(size_t); 87 struct params *params_verify_method(string_t *); 88 struct params *params_keygen(struct keygen *); 89 struct params *params_dep_keygen(struct keygen *); 90 91 struct params *params_fget(FILE *); 92 struct params *params_cget(const char *); 93 int params_fput(struct params *, FILE *); 94 int params_cput(struct params *, const char *); 95 96 struct keygen *keygen_new(void); 97 void keygen_free(struct keygen *); 98 99 int keygen_filldefaults(struct keygen *, size_t); 100 int keygen_verify(const struct keygen *); 101 void keygen_addlist(struct keygen **, struct keygen *); 102 103 struct keygen *keygen_combine(struct keygen *, struct keygen *); 104 struct keygen *keygen_generate(int); 105 struct keygen *keygen_method(string_t *); 106 struct keygen *keygen_set_method(struct keygen *, string_t *); 107 struct keygen *keygen_salt(bits_t *); 108 struct keygen *keygen_iterations(size_t); 109 struct keygen *keygen_key(bits_t *); 110 struct keygen *keygen_cmd(string_t *); 111 112 int keygen_fput(struct keygen *, int, FILE *); 113 __END_DECLS 114 115 #endif 116