2 * Portions Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
3 * Portions Copyright (C) 2000-2002 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.1.6.5 2006/01/27 23:57:44 marka Exp $ */
21 #ifndef DST_DST_INTERNAL_H
22 #define DST_DST_INTERNAL_H 1
25 #include <isc/buffer.h>
27 #include <isc/magic.h>
28 #include <isc/region.h>
29 #include <isc/types.h>
35 #define KEY_MAGIC ISC_MAGIC('D','S','T','K')
36 #define CTX_MAGIC ISC_MAGIC('D','S','T','C')
38 #define VALID_KEY(x) ISC_MAGIC_VALID(x, KEY_MAGIC)
39 #define VALID_CTX(x) ISC_MAGIC_VALID(x, CTX_MAGIC)
41 extern isc_mem_t *dst__memory_pool;
47 typedef struct dst_func dst_func_t;
49 /*% DST Key Structure */
52 dns_name_t * key_name; /*%< name of the key */
53 unsigned int key_size; /*%< size of the key in bits */
54 unsigned int key_proto; /*%< protocols this key is used for */
55 unsigned int key_alg; /*%< algorithm of the key */
56 isc_uint32_t key_flags; /*%< flags of the public key */
57 isc_uint16_t key_id; /*%< identifier of the key */
58 isc_uint16_t key_bits; /*%< hmac digest bits */
59 dns_rdataclass_t key_class; /*%< class of the key record */
60 isc_mem_t *mctx; /*%< memory context */
61 void * opaque; /*%< pointer to key in crypto pkg fmt */
62 dst_func_t * func; /*%< crypto package specific functions */
76 isc_result_t (*createctx)(dst_key_t *key, dst_context_t *dctx);
77 void (*destroyctx)(dst_context_t *dctx);
78 isc_result_t (*adddata)(dst_context_t *dctx, const isc_region_t *data);
83 isc_result_t (*sign)(dst_context_t *dctx, isc_buffer_t *sig);
84 isc_result_t (*verify)(dst_context_t *dctx, const isc_region_t *sig);
85 isc_result_t (*computesecret)(const dst_key_t *pub,
86 const dst_key_t *priv,
87 isc_buffer_t *secret);
88 isc_boolean_t (*compare)(const dst_key_t *key1, const dst_key_t *key2);
89 isc_boolean_t (*paramcompare)(const dst_key_t *key1,
90 const dst_key_t *key2);
91 isc_result_t (*generate)(dst_key_t *key, int parms);
92 isc_boolean_t (*isprivate)(const dst_key_t *key);
93 void (*destroy)(dst_key_t *key);
95 /* conversion functions */
96 isc_result_t (*todns)(const dst_key_t *key, isc_buffer_t *data);
97 isc_result_t (*fromdns)(dst_key_t *key, isc_buffer_t *data);
98 isc_result_t (*tofile)(const dst_key_t *key, const char *directory);
99 isc_result_t (*parse)(dst_key_t *key, isc_lex_t *lexer);
102 void (*cleanup)(void);
108 isc_result_t dst__openssl_init(void);
110 isc_result_t dst__hmacmd5_init(struct dst_func **funcp);
111 isc_result_t dst__hmacsha1_init(struct dst_func **funcp);
112 isc_result_t dst__hmacsha224_init(struct dst_func **funcp);
113 isc_result_t dst__hmacsha256_init(struct dst_func **funcp);
114 isc_result_t dst__hmacsha384_init(struct dst_func **funcp);
115 isc_result_t dst__hmacsha512_init(struct dst_func **funcp);
116 isc_result_t dst__opensslrsa_init(struct dst_func **funcp);
117 isc_result_t dst__openssldsa_init(struct dst_func **funcp);
118 isc_result_t dst__openssldh_init(struct dst_func **funcp);
119 isc_result_t dst__gssapi_init(struct dst_func **funcp);
124 void dst__openssl_destroy(void);
127 * Memory allocators using the DST memory pool.
129 void * dst__mem_alloc(size_t size);
130 void dst__mem_free(void *ptr);
131 void * dst__mem_realloc(void *ptr, size_t size);
134 * Entropy retriever using the DST entropy pool.
136 isc_result_t dst__entropy_getdata(void *buf, unsigned int len,
137 isc_boolean_t pseudo);
141 #endif /* DST_DST_INTERNAL_H */