Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / bind / dist / lib / dns / dst_parse.h
blobe5bd548496efb78e1752381276613dcd45b51fcd
1 /* $NetBSD$ */
3 /*
4 * Portions Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
5 * Portions Copyright (C) 2000-2002 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
12 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
14 * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
17 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
21 * Permission to use, copy, modify, and/or distribute this software for any
22 * purpose with or without fee is hereby granted, provided that the above
23 * copyright notice and this permission notice appear in all copies.
25 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
26 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
28 * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
29 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
30 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
31 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34 /* Id: dst_parse.h,v 1.15 2009/10/26 21:18:24 each Exp */
36 /*! \file */
37 #ifndef DST_DST_PARSE_H
38 #define DST_DST_PARSE_H 1
40 #include <isc/lang.h>
42 #include <dst/dst.h>
44 #define MAXFIELDSIZE 512
47 * Maximum number of fields in a private file is 18 (12 algorithm-
48 * specific fields for RSA, plus 6 generic fields).
50 #define MAXFIELDS 12+6
52 #define TAG_SHIFT 4
53 #define TAG_ALG(tag) ((unsigned int)(tag) >> TAG_SHIFT)
54 #define TAG(alg, off) (((alg) << TAG_SHIFT) + (off))
56 /* These are used by both RSA-MD5 and RSA-SHA1 */
57 #define RSA_NTAGS 11
58 #define TAG_RSA_MODULUS ((DST_ALG_RSAMD5 << TAG_SHIFT) + 0)
59 #define TAG_RSA_PUBLICEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 1)
60 #define TAG_RSA_PRIVATEEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 2)
61 #define TAG_RSA_PRIME1 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 3)
62 #define TAG_RSA_PRIME2 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 4)
63 #define TAG_RSA_EXPONENT1 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 5)
64 #define TAG_RSA_EXPONENT2 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 6)
65 #define TAG_RSA_COEFFICIENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 7)
66 #define TAG_RSA_ENGINE ((DST_ALG_RSAMD5 << TAG_SHIFT) + 8)
67 #define TAG_RSA_LABEL ((DST_ALG_RSAMD5 << TAG_SHIFT) + 9)
68 #define TAG_RSA_PIN ((DST_ALG_RSAMD5 << TAG_SHIFT) + 10)
70 #define DH_NTAGS 4
71 #define TAG_DH_PRIME ((DST_ALG_DH << TAG_SHIFT) + 0)
72 #define TAG_DH_GENERATOR ((DST_ALG_DH << TAG_SHIFT) + 1)
73 #define TAG_DH_PRIVATE ((DST_ALG_DH << TAG_SHIFT) + 2)
74 #define TAG_DH_PUBLIC ((DST_ALG_DH << TAG_SHIFT) + 3)
76 #define DSA_NTAGS 5
77 #define TAG_DSA_PRIME ((DST_ALG_DSA << TAG_SHIFT) + 0)
78 #define TAG_DSA_SUBPRIME ((DST_ALG_DSA << TAG_SHIFT) + 1)
79 #define TAG_DSA_BASE ((DST_ALG_DSA << TAG_SHIFT) + 2)
80 #define TAG_DSA_PRIVATE ((DST_ALG_DSA << TAG_SHIFT) + 3)
81 #define TAG_DSA_PUBLIC ((DST_ALG_DSA << TAG_SHIFT) + 4)
83 #define OLD_HMACMD5_NTAGS 1
84 #define HMACMD5_NTAGS 2
85 #define TAG_HMACMD5_KEY ((DST_ALG_HMACMD5 << TAG_SHIFT) + 0)
86 #define TAG_HMACMD5_BITS ((DST_ALG_HMACMD5 << TAG_SHIFT) + 1)
88 #define HMACSHA1_NTAGS 2
89 #define TAG_HMACSHA1_KEY ((DST_ALG_HMACSHA1 << TAG_SHIFT) + 0)
90 #define TAG_HMACSHA1_BITS ((DST_ALG_HMACSHA1 << TAG_SHIFT) + 1)
92 #define HMACSHA224_NTAGS 2
93 #define TAG_HMACSHA224_KEY ((DST_ALG_HMACSHA224 << TAG_SHIFT) + 0)
94 #define TAG_HMACSHA224_BITS ((DST_ALG_HMACSHA224 << TAG_SHIFT) + 1)
96 #define HMACSHA256_NTAGS 2
97 #define TAG_HMACSHA256_KEY ((DST_ALG_HMACSHA256 << TAG_SHIFT) + 0)
98 #define TAG_HMACSHA256_BITS ((DST_ALG_HMACSHA256 << TAG_SHIFT) + 1)
100 #define HMACSHA384_NTAGS 2
101 #define TAG_HMACSHA384_KEY ((DST_ALG_HMACSHA384 << TAG_SHIFT) + 0)
102 #define TAG_HMACSHA384_BITS ((DST_ALG_HMACSHA384 << TAG_SHIFT) + 1)
104 #define HMACSHA512_NTAGS 2
105 #define TAG_HMACSHA512_KEY ((DST_ALG_HMACSHA512 << TAG_SHIFT) + 0)
106 #define TAG_HMACSHA512_BITS ((DST_ALG_HMACSHA512 << TAG_SHIFT) + 1)
108 struct dst_private_element {
109 unsigned short tag;
110 unsigned short length;
111 unsigned char *data;
114 typedef struct dst_private_element dst_private_element_t;
116 struct dst_private {
117 unsigned short nelements;
118 dst_private_element_t elements[MAXFIELDS];
121 typedef struct dst_private dst_private_t;
123 ISC_LANG_BEGINDECLS
125 void
126 dst__privstruct_free(dst_private_t *priv, isc_mem_t *mctx);
128 isc_result_t
129 dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
130 isc_mem_t *mctx, dst_private_t *priv);
132 isc_result_t
133 dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
134 const char *directory);
136 ISC_LANG_ENDDECLS
138 #endif /* DST_DST_PARSE_H */