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