]>
git.saurik.com Git - apple/libresolv.git/blob - dst_internal.h
5 * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
7 * Permission to use, copy modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND TRUSTED INFORMATION SYSTEMS
12 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
13 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
14 * TRUSTED INFORMATION SYSTEMS BE LIABLE FOR ANY SPECIAL, DIRECT,
15 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
16 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
18 * WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
22 #include <sys/param.h>
23 #if (!defined(BSD)) || (BSD < 199306)
24 # include <sys/bitypes.h>
26 # include <sys/types.h>
30 # ifdef POSIX_PATH_MAX
31 # define PATH_MAX POSIX_PATH_MAX
33 # define PATH_MAX 255 /* this is the value of POSIX_PATH_MAX */
38 #define dst_func res_9_dst_func
40 #define DST_KEY res_9_DST_KEY
41 typedef struct dst_key
{
42 char *dk_key_name
; /* name of the key */
43 int dk_key_size
; /* this is the size of the key in bits */
44 int dk_proto
; /* what protocols this key can be used for */
45 int dk_alg
; /* algorithm number from key record */
46 u_int32_t dk_flags
; /* and the flags of the public key */
47 u_int16_t dk_id
; /* identifier of the key */
48 void *dk_KEY_struct
; /* pointer to key in crypto pkg fmt */
49 struct dst_func
*dk_func
; /* point to cryptto pgk specific function table */
59 #pragma GCC visibility push(hidden)
62 * define what crypto systems are supported for RSA,
63 * BSAFE is prefered over RSAREF; only one can be set at any time
65 #if defined(BSAFE) && defined(RSAREF)
66 # error "Cannot have both BSAFE and RSAREF defined"
69 /* Declare dst_lib specific constants */
70 #define KEY_FILE_FORMAT "1.2"
72 /* suffixes for key file names */
73 #define PRIVATE_KEY "private"
74 #define PUBLIC_KEY "key"
78 #define EREPORT(str) printf str
80 #define EREPORT(str) (void)0
83 /* use our own special macro to FRRE memory */
86 #define SAFE_FREE(a) \
87 do{if(a != NULL){memset(a,0, sizeof(*a)); free(a); a=NULL;}} while (0)
88 #define SAFE_FREE2(a,s) if (a != NULL && s > 0){memset(a,0, s);free(a); a=NULL;}
91 #define dst_func res_9_dst_func
92 typedef struct dst_func
{
93 int (*sign
)(const int mode
, DST_KEY
*key
, void **context
,
94 const u_int8_t
*data
, const int len
,
95 u_int8_t
*signature
, const int sig_len
);
96 int (*verify
)(const int mode
, DST_KEY
*key
, void **context
,
97 const u_int8_t
*data
, const int len
,
98 const u_int8_t
*signature
, const int sig_len
);
99 int (*compare
)(const DST_KEY
*key1
, const DST_KEY
*key2
);
100 int (*generate
)(DST_KEY
*key
, int parms
);
101 void *(*destroy
)(void *key
);
102 /* conversion functions */
103 int (*to_dns_key
)(const DST_KEY
*key
, u_int8_t
*out
,
105 int (*from_dns_key
)(DST_KEY
*key
, const u_int8_t
*str
,
107 int (*to_file_fmt
)(const DST_KEY
*key
, char *out
,
109 int (*from_file_fmt
)(DST_KEY
*key
, const char *out
,
114 #define dst_t_func res_9_dst_t_func
115 extern dst_func
*dst_t_func
[DST_MAX_ALGS
];
117 #define key_file_fmt_str res_9_key_file_fmt_str
118 extern const char *key_file_fmt_str
;
120 #define dst_path res_9_dst_path
121 extern const char *dst_path
;
123 #ifndef DST_HASH_SIZE
124 #define DST_HASH_SIZE 20 /* RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */
127 #define dst_bsafe_init res_9_dst_bsafe_init
128 int dst_bsafe_init(void);
130 #define dst_rsaref_init res_9_dst_rsaref_init
131 int dst_rsaref_init(void);
133 #define dst_hmac_md5_init res_9_dst_hmac_md5_init
134 int dst_hmac_md5_init(void);
136 #define dst_cylink_init res_9_dst_cylink_init
137 int dst_cylink_init(void);
139 #define dst_eay_dss_init res_9_dst_eay_dss_init
140 int dst_eay_dss_init(void);
142 /* from higher level support routines */
143 #define dst_s_calculate_bits res_9_dst_s_calculate_bits
144 int dst_s_calculate_bits( const u_int8_t
*str
, const int max_bits
);
146 #define dst_s_verify_str res_9_dst_s_verify_str
147 int dst_s_verify_str( const char **buf
, const char *str
);
150 /* conversion between dns names and key file names */
151 #define dst_s_filename_length res_9_dst_s_filename_length
152 size_t dst_s_filename_length( const char *name
, const char *suffix
);
154 #define dst_s_build_filename res_9_dst_s_build_filename
155 int dst_s_build_filename( char *filename
, const char *name
,
156 u_int16_t id
, int alg
, const char *suffix
,
157 size_t filename_length
);
159 #define dst_s_fopen res_9_dst_s_fopen
160 FILE *dst_s_fopen (const char *filename
, const char *mode
, int perm
);
163 * read and write network byte order into u_int?_t
164 * all of these should be retired
166 #define dst_s_get_int16 res_9_dst_s_get_int16
167 u_int16_t
dst_s_get_int16( const u_int8_t
*buf
);
169 #define dst_s_put_int16 res_9_dst_s_put_int16
170 void dst_s_put_int16( u_int8_t
*buf
, const u_int16_t val
);
172 #define dst_s_get_int32 res_9_dst_s_get_int32
173 u_int32_t
dst_s_get_int32( const u_int8_t
*buf
);
175 #define dst_s_put_int32 res_9_dst_s_put_int32
176 void dst_s_put_int32( u_int8_t
*buf
, const u_int32_t val
);
180 # define DUMP(a,b,c,d) dst_s_dump(a,b,c,d)
182 # define DUMP(a,b,c,d)
184 #define dst_s_dump res_9_dst_s_dump
186 dst_s_dump(const int mode
, const u_char
*data
, const int size
,
189 #pragma GCC visibility pop
191 #endif /* DST_INTERNAL_H */