dst_parse.h

Go to the documentation of this file.
00001 /*
00002  * Portions Copyright (C) 2004-2010, 2012, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  * Portions Copyright (C) 2000-2002  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
00010  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
00011  * WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE
00012  * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00013  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00014  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
00015  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00016  *
00017  * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
00018  *
00019  * Permission to use, copy, modify, and/or distribute this software for any
00020  * purpose with or without fee is hereby granted, provided that the above
00021  * copyright notice and this permission notice appear in all copies.
00022  *
00023  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
00024  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
00025  * WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE
00026  * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00027  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00028  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
00029  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00030  */
00031 
00032 /* $Id: dst_parse.h,v 1.17 2010/12/23 23:47:08 tbox Exp $ */
00033 
00034 /*! \file */
00035 #ifndef DST_DST_PARSE_H
00036 #define DST_DST_PARSE_H 1
00037 
00038 #include <isc/lang.h>
00039 
00040 #include <dst/dst.h>
00041 
00042 #define MAXFIELDSIZE            512
00043 
00044 /*
00045  * Maximum number of fields in a private file is 18 (12 algorithm-
00046  * specific fields for RSA, plus 6 generic fields).
00047  */
00048 #define MAXFIELDS               12+6
00049 
00050 #define TAG_SHIFT               4
00051 #define TAG_ALG(tag)            ((unsigned int)(tag) >> TAG_SHIFT)
00052 #define TAG(alg, off)           (((alg) << TAG_SHIFT) + (off))
00053 
00054 /* These are used by both RSA-MD5 and RSA-SHA1 */
00055 #define RSA_NTAGS               11
00056 #define TAG_RSA_MODULUS         ((DST_ALG_RSAMD5 << TAG_SHIFT) + 0)
00057 #define TAG_RSA_PUBLICEXPONENT  ((DST_ALG_RSAMD5 << TAG_SHIFT) + 1)
00058 #define TAG_RSA_PRIVATEEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 2)
00059 #define TAG_RSA_PRIME1          ((DST_ALG_RSAMD5 << TAG_SHIFT) + 3)
00060 #define TAG_RSA_PRIME2          ((DST_ALG_RSAMD5 << TAG_SHIFT) + 4)
00061 #define TAG_RSA_EXPONENT1       ((DST_ALG_RSAMD5 << TAG_SHIFT) + 5)
00062 #define TAG_RSA_EXPONENT2       ((DST_ALG_RSAMD5 << TAG_SHIFT) + 6)
00063 #define TAG_RSA_COEFFICIENT     ((DST_ALG_RSAMD5 << TAG_SHIFT) + 7)
00064 #define TAG_RSA_ENGINE          ((DST_ALG_RSAMD5 << TAG_SHIFT) + 8)
00065 #define TAG_RSA_LABEL           ((DST_ALG_RSAMD5 << TAG_SHIFT) + 9)
00066 
00067 #define DH_NTAGS                4
00068 #define TAG_DH_PRIME            ((DST_ALG_DH << TAG_SHIFT) + 0)
00069 #define TAG_DH_GENERATOR        ((DST_ALG_DH << TAG_SHIFT) + 1)
00070 #define TAG_DH_PRIVATE          ((DST_ALG_DH << TAG_SHIFT) + 2)
00071 #define TAG_DH_PUBLIC           ((DST_ALG_DH << TAG_SHIFT) + 3)
00072 
00073 #define DSA_NTAGS               5
00074 #define TAG_DSA_PRIME           ((DST_ALG_DSA << TAG_SHIFT) + 0)
00075 #define TAG_DSA_SUBPRIME        ((DST_ALG_DSA << TAG_SHIFT) + 1)
00076 #define TAG_DSA_BASE            ((DST_ALG_DSA << TAG_SHIFT) + 2)
00077 #define TAG_DSA_PRIVATE         ((DST_ALG_DSA << TAG_SHIFT) + 3)
00078 #define TAG_DSA_PUBLIC          ((DST_ALG_DSA << TAG_SHIFT) + 4)
00079 
00080 #define GOST_NTAGS              1
00081 #define TAG_GOST_PRIVASN1       ((DST_ALG_ECCGOST << TAG_SHIFT) + 0)
00082 #define TAG_GOST_PRIVRAW        ((DST_ALG_ECCGOST << TAG_SHIFT) + 1)
00083 
00084 #define ECDSA_NTAGS             4
00085 #define TAG_ECDSA_PRIVATEKEY    ((DST_ALG_ECDSA256 << TAG_SHIFT) + 0)
00086 #define TAG_ECDSA_ENGINE        ((DST_ALG_ECDSA256 << TAG_SHIFT) + 1)
00087 #define TAG_ECDSA_LABEL         ((DST_ALG_ECDSA256 << TAG_SHIFT) + 2)
00088 
00089 #define OLD_HMACMD5_NTAGS       1
00090 #define HMACMD5_NTAGS           2
00091 #define TAG_HMACMD5_KEY         ((DST_ALG_HMACMD5 << TAG_SHIFT) + 0)
00092 #define TAG_HMACMD5_BITS        ((DST_ALG_HMACMD5 << TAG_SHIFT) + 1)
00093 
00094 #define HMACSHA1_NTAGS          2
00095 #define TAG_HMACSHA1_KEY        ((DST_ALG_HMACSHA1 << TAG_SHIFT) + 0)
00096 #define TAG_HMACSHA1_BITS       ((DST_ALG_HMACSHA1 << TAG_SHIFT) + 1)
00097 
00098 #define HMACSHA224_NTAGS        2
00099 #define TAG_HMACSHA224_KEY      ((DST_ALG_HMACSHA224 << TAG_SHIFT) + 0)
00100 #define TAG_HMACSHA224_BITS     ((DST_ALG_HMACSHA224 << TAG_SHIFT) + 1)
00101 
00102 #define HMACSHA256_NTAGS        2
00103 #define TAG_HMACSHA256_KEY      ((DST_ALG_HMACSHA256 << TAG_SHIFT) + 0)
00104 #define TAG_HMACSHA256_BITS     ((DST_ALG_HMACSHA256 << TAG_SHIFT) + 1)
00105 
00106 #define HMACSHA384_NTAGS        2
00107 #define TAG_HMACSHA384_KEY      ((DST_ALG_HMACSHA384 << TAG_SHIFT) + 0)
00108 #define TAG_HMACSHA384_BITS     ((DST_ALG_HMACSHA384 << TAG_SHIFT) + 1)
00109 
00110 #define HMACSHA512_NTAGS        2
00111 #define TAG_HMACSHA512_KEY      ((DST_ALG_HMACSHA512 << TAG_SHIFT) + 0)
00112 #define TAG_HMACSHA512_BITS     ((DST_ALG_HMACSHA512 << TAG_SHIFT) + 1)
00113 
00114 struct dst_private_element {
00115         unsigned short tag;
00116         unsigned short length;
00117         unsigned char *data;
00118 };
00119 
00120 typedef struct dst_private_element dst_private_element_t;
00121 
00122 struct dst_private {
00123         unsigned short nelements;
00124         dst_private_element_t elements[MAXFIELDS];
00125 };
00126 
00127 typedef struct dst_private dst_private_t;
00128 
00129 ISC_LANG_BEGINDECLS
00130 
00131 void
00132 dst__privstruct_free(dst_private_t *priv, isc_mem_t *mctx);
00133 
00134 isc_result_t
00135 dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
00136                       isc_mem_t *mctx, dst_private_t *priv);
00137 
00138 isc_result_t
00139 dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
00140                           const char *directory);
00141 
00142 ISC_LANG_ENDDECLS
00143 
00144 #endif /* DST_DST_PARSE_H */

Generated on Tue Apr 28 17:40:56 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha