2 * Portions Copyright (C) 2004 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.4.1 2004/12/09 04:07:16 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;
51 dns_name_t * key_name; /* name of the key */
52 unsigned int key_size; /* size of the key in bits */
53 unsigned int key_proto; /* protocols this key is used for */
54 unsigned int key_alg; /* algorithm of the key */
55 isc_uint32_t key_flags; /* flags of the public key */
56 isc_uint16_t key_id; /* identifier of the key */
57 dns_rdataclass_t key_class; /* class of the key record */
58 isc_mem_t *mctx; /* memory context */
59 void * opaque; /* pointer to key in crypto pkg fmt */
60 dst_func_t * func; /* crypto package specific functions */
74 isc_result_t (*createctx)(dst_key_t *key, dst_context_t *dctx);
75 void (*destroyctx)(dst_context_t *dctx);
76 isc_result_t (*adddata)(dst_context_t *dctx, const isc_region_t *data);
81 isc_result_t (*sign)(dst_context_t *dctx, isc_buffer_t *sig);
82 isc_result_t (*verify)(dst_context_t *dctx, const isc_region_t *sig);
83 isc_result_t (*computesecret)(const dst_key_t *pub,
84 const dst_key_t *priv,
85 isc_buffer_t *secret);
86 isc_boolean_t (*compare)(const dst_key_t *key1, const dst_key_t *key2);
87 isc_boolean_t (*paramcompare)(const dst_key_t *key1,
88 const dst_key_t *key2);
89 isc_result_t (*generate)(dst_key_t *key, int parms);
90 isc_boolean_t (*isprivate)(const dst_key_t *key);
91 void (*destroy)(dst_key_t *key);
93 /* conversion functions */
94 isc_result_t (*todns)(const dst_key_t *key, isc_buffer_t *data);
95 isc_result_t (*fromdns)(dst_key_t *key, isc_buffer_t *data);
96 isc_result_t (*tofile)(const dst_key_t *key, const char *directory);
97 isc_result_t (*parse)(dst_key_t *key, isc_lex_t *lexer);
100 void (*cleanup)(void);
106 isc_result_t dst__openssl_init(void);
108 isc_result_t dst__hmacmd5_init(struct dst_func **funcp);
109 isc_result_t dst__opensslrsa_init(struct dst_func **funcp);
110 isc_result_t dst__openssldsa_init(struct dst_func **funcp);
111 isc_result_t dst__openssldh_init(struct dst_func **funcp);
112 isc_result_t dst__gssapi_init(struct dst_func **funcp);
117 void dst__openssl_destroy(void);
120 * Memory allocators using the DST memory pool.
122 void * dst__mem_alloc(size_t size);
123 void dst__mem_free(void *ptr);
124 void * dst__mem_realloc(void *ptr, size_t size);
127 * Entropy retriever using the DST entropy pool.
129 isc_result_t dst__entropy_getdata(void *buf, unsigned int len,
130 isc_boolean_t pseudo);
134 #endif /* DST_DST_INTERNAL_H */