00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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
00046
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
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