Annotation of src/lib/libresolv/dst_internal.h, Revision 1.2
1.2 ! joerg 1: /* $NetBSD: dst_internal.h,v 1.1 2012/11/15 18:48:48 christos Exp $ */
1.1 christos 2:
3: #ifndef DST_INTERNAL_H
4: #define DST_INTERNAL_H
5:
6: /*
7: * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
8: *
9: * Permission to use, copy modify, and distribute this software for any
10: * purpose with or without fee is hereby granted, provided that the above
11: * copyright notice and this permission notice appear in all copies.
12: *
13: * THE SOFTWARE IS PROVIDED "AS IS" AND TRUSTED INFORMATION SYSTEMS
14: * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
16: * TRUSTED INFORMATION SYSTEMS BE LIABLE FOR ANY SPECIAL, DIRECT,
17: * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
18: * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
19: * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
20: * WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
21: */
22: #include <limits.h>
23: #include <sys/param.h>
24: #if (!defined(BSD)) || (BSD < 199306)
25: # include <sys/bitypes.h>
26: #else
27: # include <sys/types.h>
28: #endif
29:
30: #ifndef PATH_MAX
31: # ifdef POSIX_PATH_MAX
32: # define PATH_MAX POSIX_PATH_MAX
33: # else
34: # define PATH_MAX 255 /*%< this is the value of POSIX_PATH_MAX */
35: # endif
36: #endif
37:
38: typedef struct dst_key {
39: char *dk_key_name; /*%< name of the key */
40: int dk_key_size; /*%< this is the size of the key in bits */
41: int dk_proto; /*%< what protocols this key can be used for */
42: int dk_alg; /*%< algorithm number from key record */
43: u_int32_t dk_flags; /*%< and the flags of the public key */
44: u_int16_t dk_id; /*%< identifier of the key */
45: void *dk_KEY_struct; /*%< pointer to key in crypto pkg fmt */
46: struct dst_func *dk_func; /*%< point to cryptto pgk specific function table */
47: } DST_KEY;
48: #define HAS_DST_KEY
49:
50: #include <isc/dst.h>
51: /*
52: * define what crypto systems are supported for RSA,
53: * BSAFE is prefered over RSAREF; only one can be set at any time
54: */
55: #if defined(BSAFE) && defined(RSAREF)
56: # error "Cannot have both BSAFE and RSAREF defined"
57: #endif
58:
59: /* Declare dst_lib specific constants */
60: #define KEY_FILE_FORMAT "1.2"
61:
62: /* suffixes for key file names */
63: #define PRIVATE_KEY "private"
64: #define PUBLIC_KEY "key"
65:
66: /* error handling */
67: #ifdef DEBUG
68: #define EREPORT(str) printf str
69: #else
70: #define EREPORT(str) do {} while (/*CONSTCOND*/0)
71: #endif
72:
73: /* use our own special macro to FRRE memory */
74:
75: #ifndef SAFE_FREE2
76: #define SAFE_FREE2(a, s) do { \
77: if ((a) != NULL) { \
78: memset((a), 0, (s)); \
79: free((a)); \
80: (a) = NULL; \
81: } \
82: } while (/*CONSTCOND*/0)
83: #endif
84:
85: #ifndef SAFE_FREE
1.2 ! joerg 86: #define SAFE_FREE(a) SAFE_FREE2((a), sizeof(*(a)))
1.1 christos 87: #endif
88:
89: typedef struct dst_func {
90: int (*sign)(const int mode, DST_KEY *key, void **context,
91: const u_int8_t *data, const int len,
92: u_int8_t *signature, const int sig_len);
93: int (*verify)(const int mode, DST_KEY *key, void **context,
94: const u_int8_t *data, const int len,
95: const u_int8_t *signature, const int sig_len);
96: int (*compare)(const DST_KEY *key1, const DST_KEY *key2);
97: int (*generate)(DST_KEY *key, int parms);
98: void *(*destroy)(void *key);
99: /* conversion functions */
100: int (*to_dns_key)(const DST_KEY *key, u_int8_t *out,
101: const int out_len);
102: int (*from_dns_key)(DST_KEY *key, const u_int8_t *str,
103: const int str_len);
104: int (*to_file_fmt)(const DST_KEY *key, char *out,
105: const int out_len);
106: int (*from_file_fmt)(DST_KEY *key, const char *out,
107: const int out_len);
108:
109: } dst_func;
110:
111: extern dst_func *dst_t_func[DST_MAX_ALGS];
112: extern const char *key_file_fmt_str;
113: extern const char *dst_path;
114:
115: #ifndef DST_HASH_SIZE
116: #define DST_HASH_SIZE 20 /*%< RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */
117: #endif
118:
119: int dst_bsafe_init(void);
120:
121: int dst_rsaref_init(void);
122:
123: int dst_hmac_md5_init(void);
124:
125: int dst_cylink_init(void);
126:
127: int dst_eay_dss_init(void);
128:
129: /* from higher level support routines */
130: int dst_s_calculate_bits( const u_int8_t *str, const int max_bits);
131: int dst_s_verify_str( const char **buf, const char *str);
132:
133:
134: /* conversion between dns names and key file names */
135: size_t dst_s_filename_length( const char *name, const char *suffix);
136: int dst_s_build_filename( char *filename, const char *name,
137: u_int16_t id, int alg, const char *suffix,
138: size_t filename_length);
139:
140: FILE *dst_s_fopen (const char *filename, const char *mode, int perm);
141:
142: /*%
143: * read and write network byte order into u_int?_t
144: * all of these should be retired
145: */
146: u_int16_t dst_s_get_int16( const u_int8_t *buf);
147: void dst_s_put_int16( u_int8_t *buf, const u_int16_t val);
148:
149: u_int32_t dst_s_get_int32( const u_int8_t *buf);
150: void dst_s_put_int32( u_int8_t *buf, const u_int32_t val);
151:
152: #ifdef DUMP
153: # undef DUMP
154: # define DUMP(a,b,c,d) dst_s_dump(a,b,c,d)
155: #else
156: # define DUMP(a,b,c,d)
157: #endif
158: void
159: dst_s_dump(const int mode, const u_char *data, const int size,
160: const char *msg);
161:
162: #define KEY_FILE_FMT_STR "Private-key-format: v%s\nAlgorithm: %d (%s)\n"
163:
164:
165: #endif /* DST_INTERNAL_H */
166: /*! \file */
CVSweb <webmaster@jp.NetBSD.org>