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