]> git.saurik.com Git - apple/libresolv.git/blob - dst.h
libresolv-19.tar.gz
[apple/libresolv.git] / dst.h
1 #ifndef DST_H
2 #define DST_H
3
4 #ifndef HAS_DST_KEY
5 #define DST_KEY RES_9_DST_KEY
6 typedef struct dst_key {
7 char *dk_key_name; /* name of the key */
8 int dk_key_size; /* this is the size of the key in bits */
9 int dk_proto; /* what protocols this key can be used for */
10 int dk_alg; /* algorithm number from key record */
11 u_int32_t dk_flags; /* and the flags of the public key */
12 u_int16_t dk_id; /* identifier of the key */
13 } DST_KEY;
14 #endif /* HAS_DST_KEY */
15
16 /*
17 * DST Crypto API defintions
18 */
19 #define dst_init res_9_dst_init
20 void dst_init(void);
21 #ifndef __APPLE__
22 int dst_check_algorithm(const int);
23 #endif
24
25 #define dst_sign_data res_9_dst_sign_data
26 int dst_sign_data(const int mode, /* specifies INIT/UPDATE/FINAL/ALL */
27 DST_KEY *in_key, /* the key to use */
28 void **context, /* pointer to state structure */
29 const u_char *data, /* data to be signed */
30 const int len, /* length of input data */
31 u_char *signature, /* buffer to write signature to */
32 const int sig_len); /* size of output buffer */
33
34 #define dst_verify_data res_9_dst_verify_data
35 int dst_verify_data(const int mode, /* specifies INIT/UPDATE/FINAL/ALL */
36 DST_KEY *in_key, /* the key to use */
37 void **context, /* pointer to state structure */
38 const u_char *data, /* data to be verified */
39 const int len, /* length of input data */
40 const u_char *signature,/* buffer containing signature */
41 const int sig_len); /* length of signature */
42
43 #define dst_read_key res_9_dst_read_key
44 DST_KEY *dst_read_key(const char *in_name, /* name of key */
45 const u_int16_t in_id, /* key tag identifier */
46 const int in_alg, /* key algorithm */
47 const int key_type); /* Private/PublicKey wanted*/
48
49 #define dst_write_key res_9_dst_write_key
50 int dst_write_key(const DST_KEY *key, /* key to write out */
51 const int key_type); /* Public/Private */
52
53 #define dst_dnskey_to_key res_9_dst_dnskey_to_key
54 DST_KEY *dst_dnskey_to_key(const char *in_name, /* KEY record name */
55 const u_char *key, /* KEY RDATA */
56 const int len); /* size of input buffer*/
57
58 #ifndef __APPLE__
59 int dst_key_to_dnskey(const DST_KEY *key, /* key to translate */
60 u_char *out_storage, /* output buffer */
61 const int out_len); /* size of out_storage*/
62 #endif
63
64 #define dst_buffer_to_key res_9_dst_buffer_to_key
65 DST_KEY *dst_buffer_to_key(const char *key_name, /* name of the key */
66 const int alg, /* algorithm */
67 const int flags, /* dns flags */
68 const int protocol, /* dns protocol */
69 const u_char *key_buf, /* key in dns wire fmt */
70 const int key_len); /* size of key */
71
72
73 #define dst_key_to_buffer res_9_dst_key_to_buffer
74 int dst_key_to_buffer(DST_KEY *key, u_char *out_buff, int buf_len);
75
76 #define dst_generate_key res_9_dst_generate_key
77 DST_KEY *dst_generate_key(const char *name, /* name of new key */
78 const int alg, /* key algorithm to generate */
79 const int bits, /* size of new key */
80 const int exp, /* alg dependent parameter*/
81 const int flags, /* key DNS flags */
82 const int protocol); /* key DNS protocol */
83
84 #define dst_free_key res_9_dst_free_key
85 DST_KEY *dst_free_key(DST_KEY *f_key);
86
87 #define dst_compare_keys res_9_dst_compare_keys
88 int dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2);
89
90 #define dst_sig_size res_9_dst_sig_size
91 int dst_sig_size(DST_KEY *key);
92
93 /* support for dns key tags/ids */
94 #define dst_s_dns_key_id res_9_dst_s_dns_key_id
95 u_int16_t dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len);
96 #ifndef __APPLE__
97 u_int16_t dst_s_id_calc(const u_char *key_data, const int key_len);
98 #endif
99
100 /* Used by callers as well as by the library. */
101 #define RAW_KEY_SIZE 8192 /* large enough to store any key */
102
103 /* DST_API control flags */
104 /* These are used used in functions dst_sign_data and dst_verify_data */
105 #define SIG_MODE_INIT 1 /* initialize digest */
106 #define SIG_MODE_UPDATE 2 /* add data to digest */
107 #define SIG_MODE_FINAL 4 /* generate/verify signature */
108 #define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
109
110 /* Flags for dst_read_private_key() */
111 #define DST_FORCE_READ 0x1000000
112 #define DST_CAN_SIGN 0x010F
113 #define DST_NO_AUTHEN 0x8000
114 #define DST_EXTEND_FLAG 0x1000
115 #define DST_STANDARD 0
116 #define DST_PRIVATE 0x2000000
117 #define DST_PUBLIC 0x4000000
118 #define DST_RAND_SEMI 1
119 #define DST_RAND_STD 2
120 #define DST_RAND_KEY 3
121 #define DST_RAND_DSS 4
122
123
124 /* DST algorithm codes */
125 #define KEY_RSA 1
126 #define KEY_DH 2
127 #define KEY_DSA 3
128 #define KEY_PRIVATE 254
129 #define KEY_EXPAND 255
130 #define KEY_HMAC_MD5 157
131 #define KEY_HMAC_SHA1 158
132 #define UNKNOWN_KEYALG 0
133 #define DST_MAX_ALGS KEY_HMAC_SHA1
134
135 /* DST constants to locations in KEY record changes in new KEY record */
136 #define DST_FLAGS_SIZE 2
137 #define DST_KEY_PROT 2
138 #define DST_KEY_ALG 3
139 #define DST_EXT_FLAG 4
140 #define DST_KEY_START 4
141
142 #ifndef SIGN_F_NOKEY
143 #define SIGN_F_NOKEY 0xC000
144 #endif
145
146 /* error codes from dst routines */
147 #define SIGN_INIT_FAILURE (-23)
148 #define SIGN_UPDATE_FAILURE (-24)
149 #define SIGN_FINAL_FAILURE (-25)
150 #define VERIFY_INIT_FAILURE (-26)
151 #define VERIFY_UPDATE_FAILURE (-27)
152 #define VERIFY_FINAL_FAILURE (-28)
153 #define MISSING_KEY_OR_SIGNATURE (-30)
154 #define UNSUPPORTED_KEYALG (-31)
155
156 #endif /* DST_H */