dst_parse.h revision d3735e0e2588a8d07215e0b76d029c1ac3d40a17
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister/*
b8e2e5dd861bdc72a5496a745a85f8761bef7dc4Tinderbox User * Portions Copyright (C) 2000 Internet Software Consortium.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and distribute this software for any
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister * purpose with or without fee is hereby granted, provided that the above
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM AND
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NETWORK ASSOCIATES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE CONSORTIUM OR NETWORK
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ASSOCIATES BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister * PERFORMANCE OF THIS SOFTWARE.
d7201de09b85929a86b157f4b2d91667c68c6b52Automatic Updater */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* $Id: dst_parse.h,v 1.16 2000/09/02 01:15:23 bwelling Exp $ */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#ifndef DST_DST_PARSE_H
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define DST_DST_PARSE_H 1
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <isc/lang.h>
364a82f7c25b62967678027043425201a5e5171aBob Halley
600cbd1fcea3c9cc9706dc1ff8fc0d0034ebdeacTatuya JINMEI 神明達哉#include <dst/dst.h>
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
b3e77535185043f089b346166440402d092030c3David Lawrence#define MAJOR_VERSION 1
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellington#define MINOR_VERSION 2
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define MAXFIELDSIZE 512
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define MAXFIELDS 12
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_SHIFT 4
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_ALG(tag) ((unsigned int)(tag) >> TAG_SHIFT)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG(alg, off) (((alg) << TAG_SHIFT) + (off))
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister/* These are used by both RSA-MD5 and RSA-SHA1 */
72166c5cf59db011cce11e98abe377f5aa6f7052Andreas Gustafsson#define RSA_NTAGS 8
5475a2d296215b7a93bd89804dc33c36a6de7cb5James Brister#define TAG_RSA_MODULUS ((DST_ALG_RSAMD5 << TAG_SHIFT) + 0)
d25dd5b0567f67ecf40b7ed1cb20e0dce7b41c49Brian Wellington#define TAG_RSA_PUBLICEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 1)
1c153afce556ff3c687986fb7c4a0b0a7f5e7cd8Mark Andrews#define TAG_RSA_PRIVATEEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 2)
08c90261660649ca7d92065f6f13a61ec5a9a86dMark Andrews#define TAG_RSA_PRIME1 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 3)
db30f4bdcb66afb7eb1ab0c6882cc70be9a53d79Mark Andrews#define TAG_RSA_PRIME2 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 4)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_RSA_EXPONENT1 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 5)
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson#define TAG_RSA_EXPONENT2 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 6)
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson#define TAG_RSA_COEFFICIENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 7)
b3e77535185043f089b346166440402d092030c3David Lawrence
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson#define DH_NTAGS 4
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson#define TAG_DH_PRIME ((DST_ALG_DH << TAG_SHIFT) + 0)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_DH_GENERATOR ((DST_ALG_DH << TAG_SHIFT) + 1)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_DH_PRIVATE ((DST_ALG_DH << TAG_SHIFT) + 2)
b3e77535185043f089b346166440402d092030c3David Lawrence#define TAG_DH_PUBLIC ((DST_ALG_DH << TAG_SHIFT) + 3)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence#define DSA_NTAGS 5
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_DSA_PRIME ((DST_ALG_DSA << TAG_SHIFT) + 0)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence#define TAG_DSA_SUBPRIME ((DST_ALG_DSA << TAG_SHIFT) + 1)
f3ca27e9fe307b55e35ea8d7b37351650630e5a3Andreas Gustafsson#define TAG_DSA_BASE ((DST_ALG_DSA << TAG_SHIFT) + 2)
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson#define TAG_DSA_PRIVATE ((DST_ALG_DSA << TAG_SHIFT) + 3)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_DSA_PUBLIC ((DST_ALG_DSA << TAG_SHIFT) + 4)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define HMACMD5_NTAGS 1
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#define TAG_HMACMD5_KEY ((DST_ALG_HMACMD5 << TAG_SHIFT) + 0)
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerstruct dst_private_element {
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence unsigned short tag;
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister unsigned short length;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence unsigned char *data;
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister};
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristertypedef struct dst_private_element dst_private_element_t;
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
b3e77535185043f089b346166440402d092030c3David Lawrencestruct dst_private {
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister unsigned short nelements;
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister dst_private_element_t elements[MAXFIELDS];
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister};
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristertypedef struct dst_private dst_private_t;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
2cde028c51055c9fd4837337116cd4fdfe8ff623James BristerISC_LANG_BEGINDECLS
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristervoid
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerdst__privstruct_free(dst_private_t *priv, isc_mem_t *mctx);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerint
b3e77535185043f089b346166440402d092030c3David Lawrencedst__privstruct_parsefile(dst_key_t *key, const isc_uint16_t id,
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister const char *filename, isc_mem_t *mctx,
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence dst_private_t *priv);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerint
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerdst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister const char *directory);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James BristerISC_LANG_ENDDECLS
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister#endif /* DST_DST_PARSE_H */
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister