PageRenderTime 42ms CodeModel.GetById 37ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/bind9/lib/dns/dst_parse.h

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