Merge branch 'vendor/GCC44'
[dragonfly.git] / contrib / bind-9.3 / lib / dns / dst_parse.h
1 /*
2  * Portions Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Portions Copyright (C) 2000-2002  Internet Software Consortium.
4  * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
11  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE
13  * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
16  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18
19 /* $Id: dst_parse.h,v 1.1.4.1 2004/12/09 04:07:17 marka Exp $ */
20
21 #ifndef DST_DST_PARSE_H
22 #define DST_DST_PARSE_H 1
23
24 #include <isc/lang.h>
25
26 #include <dst/dst.h>
27
28 #define MAJOR_VERSION           1
29 #define MINOR_VERSION           2
30
31 #define MAXFIELDSIZE            512
32 #define MAXFIELDS               12
33
34 #define TAG_SHIFT               4
35 #define TAG_ALG(tag)            ((unsigned int)(tag) >> TAG_SHIFT)
36 #define TAG(alg, off)           (((alg) << TAG_SHIFT) + (off))
37
38 /* These are used by both RSA-MD5 and RSA-SHA1 */
39 #define RSA_NTAGS               8
40 #define TAG_RSA_MODULUS         ((DST_ALG_RSAMD5 << TAG_SHIFT) + 0)
41 #define TAG_RSA_PUBLICEXPONENT  ((DST_ALG_RSAMD5 << TAG_SHIFT) + 1)
42 #define TAG_RSA_PRIVATEEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 2)
43 #define TAG_RSA_PRIME1          ((DST_ALG_RSAMD5 << TAG_SHIFT) + 3)
44 #define TAG_RSA_PRIME2          ((DST_ALG_RSAMD5 << TAG_SHIFT) + 4)
45 #define TAG_RSA_EXPONENT1       ((DST_ALG_RSAMD5 << TAG_SHIFT) + 5)
46 #define TAG_RSA_EXPONENT2       ((DST_ALG_RSAMD5 << TAG_SHIFT) + 6)
47 #define TAG_RSA_COEFFICIENT     ((DST_ALG_RSAMD5 << TAG_SHIFT) + 7)
48
49 #define DH_NTAGS                4
50 #define TAG_DH_PRIME            ((DST_ALG_DH << TAG_SHIFT) + 0)
51 #define TAG_DH_GENERATOR        ((DST_ALG_DH << TAG_SHIFT) + 1)
52 #define TAG_DH_PRIVATE          ((DST_ALG_DH << TAG_SHIFT) + 2)
53 #define TAG_DH_PUBLIC           ((DST_ALG_DH << TAG_SHIFT) + 3)
54
55 #define DSA_NTAGS               5
56 #define TAG_DSA_PRIME           ((DST_ALG_DSA << TAG_SHIFT) + 0)
57 #define TAG_DSA_SUBPRIME        ((DST_ALG_DSA << TAG_SHIFT) + 1)
58 #define TAG_DSA_BASE            ((DST_ALG_DSA << TAG_SHIFT) + 2)
59 #define TAG_DSA_PRIVATE         ((DST_ALG_DSA << TAG_SHIFT) + 3)
60 #define TAG_DSA_PUBLIC          ((DST_ALG_DSA << TAG_SHIFT) + 4)
61
62 #define HMACMD5_NTAGS           1
63 #define TAG_HMACMD5_KEY         ((DST_ALG_HMACMD5 << TAG_SHIFT) + 0)
64
65 struct dst_private_element {
66         unsigned short tag;
67         unsigned short length;
68         unsigned char *data;
69 };
70
71 typedef struct dst_private_element dst_private_element_t;
72
73 struct dst_private {
74         unsigned short nelements;
75         dst_private_element_t elements[MAXFIELDS];
76 };
77
78 typedef struct dst_private dst_private_t;
79
80 ISC_LANG_BEGINDECLS
81
82 void
83 dst__privstruct_free(dst_private_t *priv, isc_mem_t *mctx);
84
85 int
86 dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
87                       isc_mem_t *mctx, dst_private_t *priv);
88
89 int
90 dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
91                           const char *directory);
92
93 ISC_LANG_ENDDECLS
94
95 #endif /* DST_DST_PARSE_H */