00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DNS_TSIG_H
00021 #define DNS_TSIG_H 1
00022
00023
00024
00025 #include <isc/lang.h>
00026 #include <isc/refcount.h>
00027 #include <isc/rwlock.h>
00028 #include <isc/stdio.h>
00029 #include <isc/stdtime.h>
00030
00031 #include <dns/types.h>
00032 #include <dns/name.h>
00033
00034 #include <dst/dst.h>
00035
00036
00037
00038
00039 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_hmacmd5_name;
00040 #define DNS_TSIG_HMACMD5_NAME dns_tsig_hmacmd5_name
00041 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_gssapi_name;
00042 #define DNS_TSIG_GSSAPI_NAME dns_tsig_gssapi_name
00043 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_gssapims_name;
00044 #define DNS_TSIG_GSSAPIMS_NAME dns_tsig_gssapims_name
00045 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_hmacsha1_name;
00046 #define DNS_TSIG_HMACSHA1_NAME dns_tsig_hmacsha1_name
00047 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_hmacsha224_name;
00048 #define DNS_TSIG_HMACSHA224_NAME dns_tsig_hmacsha224_name
00049 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_hmacsha256_name;
00050 #define DNS_TSIG_HMACSHA256_NAME dns_tsig_hmacsha256_name
00051 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_hmacsha384_name;
00052 #define DNS_TSIG_HMACSHA384_NAME dns_tsig_hmacsha384_name
00053 LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_tsig_hmacsha512_name;
00054 #define DNS_TSIG_HMACSHA512_NAME dns_tsig_hmacsha512_name
00055
00056
00057
00058
00059 #define DNS_TSIG_FUDGE 300
00060
00061 struct dns_tsig_keyring {
00062 dns_rbt_t *keys;
00063 unsigned int writecount;
00064 isc_rwlock_t lock;
00065 isc_mem_t *mctx;
00066
00067
00068
00069
00070 unsigned int generated;
00071 unsigned int maxgenerated;
00072 ISC_LIST(dns_tsigkey_t) lru;
00073 unsigned int references;
00074 };
00075
00076 struct dns_tsigkey {
00077
00078 unsigned int magic;
00079 isc_mem_t *mctx;
00080 dst_key_t *key;
00081 dns_name_t name;
00082 dns_name_t *algorithm;
00083 dns_name_t *creator;
00084 isc_boolean_t generated;
00085 isc_stdtime_t inception;
00086 isc_stdtime_t expire;
00087 dns_tsig_keyring_t *ring;
00088 isc_refcount_t refs;
00089 ISC_LINK(dns_tsigkey_t) link;
00090 };
00091
00092 #define dns_tsigkey_identity(tsigkey) \
00093 ((tsigkey) == NULL ? NULL : \
00094 (tsigkey)->generated ? ((tsigkey)->creator) : \
00095 (&((tsigkey)->name)))
00096
00097 ISC_LANG_BEGINDECLS
00098
00099 isc_result_t
00100 dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm,
00101 unsigned char *secret, int length, isc_boolean_t generated,
00102 dns_name_t *creator, isc_stdtime_t inception,
00103 isc_stdtime_t expire, isc_mem_t *mctx,
00104 dns_tsig_keyring_t *ring, dns_tsigkey_t **key);
00105
00106 isc_result_t
00107 dns_tsigkey_createfromkey(dns_name_t *name, dns_name_t *algorithm,
00108 dst_key_t *dstkey, isc_boolean_t generated,
00109 dns_name_t *creator, isc_stdtime_t inception,
00110 isc_stdtime_t expire, isc_mem_t *mctx,
00111 dns_tsig_keyring_t *ring, dns_tsigkey_t **key);
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 void
00144 dns_tsigkey_attach(dns_tsigkey_t *source, dns_tsigkey_t **targetp);
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 void
00156 dns_tsigkey_detach(dns_tsigkey_t **keyp);
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 void
00168 dns_tsigkey_setdeleted(dns_tsigkey_t *key);
00169
00170
00171
00172
00173
00174
00175
00176
00177 isc_result_t
00178 dns_tsig_sign(dns_message_t *msg);
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 isc_result_t
00196 dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
00197 dns_tsig_keyring_t *ring1, dns_tsig_keyring_t *ring2);
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 isc_result_t
00225 dns_tsigkey_find(dns_tsigkey_t **tsigkey, dns_name_t *name,
00226 dns_name_t *algorithm, dns_tsig_keyring_t *ring);
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 isc_result_t
00245 dns_tsigkeyring_create(isc_mem_t *mctx, dns_tsig_keyring_t **ringp);
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 isc_result_t
00259 dns_tsigkeyring_add(dns_tsig_keyring_t *ring, dns_name_t *name,
00260 dns_tsigkey_t *tkey);
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 void
00274 dns_tsigkeyring_attach(dns_tsig_keyring_t *source, dns_tsig_keyring_t **target);
00275
00276 void
00277 dns_tsigkeyring_detach(dns_tsig_keyring_t **ringp);
00278
00279 isc_result_t
00280 dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp);
00281
00282
00283
00284
00285
00286
00287
00288
00289 void
00290 dns_keyring_restore(dns_tsig_keyring_t *ring, FILE *fp);
00291
00292 ISC_LANG_ENDDECLS
00293
00294 #endif