Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / sec / dst / dst_internal.h
blob5366c807532483dcde58decc39886ddbaafca897
1 /*
2 * Portions Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Portions Copyright (C) 2000, 2001 Internet Software Consortium.
4 * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
13 * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
16 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 /* $Id: dst_internal.h,v 1.38.2.1 2004/03/09 06:11:40 marka Exp $ */
21 #ifndef DST_DST_INTERNAL_H
22 #define DST_DST_INTERNAL_H 1
24 #include <isc/lang.h>
25 #include <isc/buffer.h>
26 #include <isc/int.h>
27 #include <isc/magic.h>
28 #include <isc/region.h>
30 #include <dst/dst.h>
32 ISC_LANG_BEGINDECLS
34 #define KEY_MAGIC ISC_MAGIC('D','S','T','K')
35 #define CTX_MAGIC ISC_MAGIC('D','S','T','C')
37 #define VALID_KEY(x) ISC_MAGIC_VALID(x, KEY_MAGIC)
38 #define VALID_CTX(x) ISC_MAGIC_VALID(x, CTX_MAGIC)
40 /***
41 *** Types
42 ***/
44 typedef struct dst_func dst_func_t;
46 struct dst_key {
47 unsigned int magic;
48 dns_name_t * key_name; /* name of the key */
49 unsigned int key_size; /* size of the key in bits */
50 unsigned int key_proto; /* protocols this key is used for */
51 unsigned int key_alg; /* algorithm of the key */
52 isc_uint32_t key_flags; /* flags of the public key */
53 isc_uint16_t key_id; /* identifier of the key */
54 dns_rdataclass_t key_class; /* class of the key record */
55 isc_mem_t *mctx; /* memory context */
56 void * opaque; /* pointer to key in crypto pkg fmt */
57 dst_func_t * func; /* crypto package specific functions */
60 struct dst_context {
61 unsigned int magic;
62 dst_key_t *key;
63 isc_mem_t *mctx;
64 void *opaque;
67 struct dst_func {
69 * Context functions
71 isc_result_t (*createctx)(dst_key_t *key, dst_context_t *dctx);
72 void (*destroyctx)(dst_context_t *dctx);
73 isc_result_t (*adddata)(dst_context_t *dctx, const isc_region_t *data);
76 * Key operations
78 isc_result_t (*sign)(dst_context_t *dctx, isc_buffer_t *sig);
79 isc_result_t (*verify)(dst_context_t *dctx, const isc_region_t *sig);
80 isc_result_t (*computesecret)(const dst_key_t *pub,
81 const dst_key_t *priv,
82 isc_buffer_t *secret);
83 isc_boolean_t (*compare)(const dst_key_t *key1, const dst_key_t *key2);
84 isc_boolean_t (*paramcompare)(const dst_key_t *key1,
85 const dst_key_t *key2);
86 isc_result_t (*generate)(dst_key_t *key, int parms);
87 isc_boolean_t (*isprivate)(const dst_key_t *key);
88 isc_boolean_t (*issymmetric)(void);
89 void (*destroy)(dst_key_t *key);
91 /* conversion functions */
92 isc_result_t (*todns)(const dst_key_t *key, isc_buffer_t *data);
93 isc_result_t (*fromdns)(dst_key_t *key, isc_buffer_t *data);
94 isc_result_t (*tofile)(const dst_key_t *key, const char *directory);
95 isc_result_t (*fromfile)(dst_key_t *key, const char *filename);
99 * Initializers
101 isc_result_t dst__openssl_init(void);
103 isc_result_t dst__hmacmd5_init(struct dst_func **funcp);
104 isc_result_t dst__opensslrsa_init(struct dst_func **funcp);
105 isc_result_t dst__openssldsa_init(struct dst_func **funcp);
106 isc_result_t dst__openssldh_init(struct dst_func **funcp);
107 isc_result_t dst__gssapi_init(struct dst_func **funcp);
110 * Destructors
112 void dst__openssl_destroy(void);
114 void dst__hmacmd5_destroy(void);
115 void dst__opensslrsa_destroy(void);
116 void dst__openssldsa_destroy(void);
117 void dst__openssldh_destroy(void);
118 void dst__gssapi_destroy(void);
121 * Memory allocators using the DST memory pool.
123 void * dst__mem_alloc(size_t size);
124 void dst__mem_free(void *ptr);
125 void * dst__mem_realloc(void *ptr, size_t size);
128 * Entropy retriever using the DST entropy pool.
130 isc_result_t dst__entropy_getdata(void *buf, unsigned int len,
131 isc_boolean_t pseudo);
134 * Generic helper functions.
136 isc_result_t
137 dst__file_addsuffix(char *filename, unsigned int len,
138 const char *ofilename, const char *suffix);
140 ISC_LANG_ENDDECLS
142 #endif /* DST_DST_INTERNAL_H */