2N/A#ifndef DST_INTERNAL_H
2N/A#define DST_INTERNAL_H
2N/A
2N/A/*
2N/A * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
2N/A *
2N/A * Permission to use, copy modify, and distribute this software for any
2N/A * purpose with or without fee is hereby granted, provided that the above
2N/A * copyright notice and this permission notice appear in all copies.
2N/A *
2N/A * THE SOFTWARE IS PROVIDED "AS IS" AND TRUSTED INFORMATION SYSTEMS
2N/A * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
2N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
2N/A * TRUSTED INFORMATION SYSTEMS BE LIABLE FOR ANY SPECIAL, DIRECT,
2N/A * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
2N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2N/A * WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
2N/A */
2N/A#include <limits.h>
2N/A#include <sys/param.h>
2N/A#if (!defined(BSD)) || (BSD < 199306)
2N/A# include <sys/bitypes.h>
2N/A#else
2N/A# include <sys/types.h>
2N/A#endif
2N/A
2N/A#ifndef PATH_MAX
2N/A# ifdef POSIX_PATH_MAX
2N/A# define PATH_MAX POSIX_PATH_MAX
2N/A# else
2N/A# define PATH_MAX 255 /*%< this is the value of POSIX_PATH_MAX */
2N/A# endif
2N/A#endif
2N/A
2N/Atypedef struct dst_key {
2N/A char *dk_key_name; /*%< name of the key */
2N/A int dk_key_size; /*%< this is the size of the key in bits */
2N/A int dk_proto; /*%< what protocols this key can be used for */
2N/A int dk_alg; /*%< algorithm number from key record */
2N/A u_int32_t dk_flags; /*%< and the flags of the public key */
2N/A u_int16_t dk_id; /*%< identifier of the key */
2N/A void *dk_KEY_struct; /*%< pointer to key in crypto pkg fmt */
2N/A struct dst_func *dk_func; /*%< point to cryptto pgk specific function table */
2N/A} DST_KEY;
2N/A#define HAS_DST_KEY
2N/A
2N/A#include <isc/dst.h>
2N/A/*
2N/A * define what crypto systems are supported for RSA,
2N/A * BSAFE is prefered over RSAREF; only one can be set at any time
2N/A */
2N/A#if defined(BSAFE) && defined(RSAREF)
2N/A# error "Cannot have both BSAFE and RSAREF defined"
2N/A#endif
2N/A
2N/A/* Declare dst_lib specific constants */
2N/A#define KEY_FILE_FORMAT "1.2"
2N/A
2N/A/* suffixes for key file names */
2N/A#define PRIVATE_KEY "private"
2N/A#define PUBLIC_KEY "key"
2N/A
2N/A/* error handling */
2N/A#ifdef REPORT_ERRORS
2N/A#define EREPORT(str) printf str
2N/A#else
2N/A#define EREPORT(str) (void)0
2N/A#endif
2N/A
2N/A/* use our own special macro to FRRE memory */
2N/A
2N/A#ifndef SAFE_FREE
2N/A#define SAFE_FREE(a) \
2N/Ado{if(a != NULL){memset(a,0, sizeof(*a)); free(a); a=NULL;}} while (0)
2N/A#define SAFE_FREE2(a,s) if (a != NULL && (long)s > 0){memset(a,0, s);free(a); a=NULL;}
2N/A#endif
2N/A
2N/Atypedef struct dst_func {
2N/A int (*sign)(const int mode, DST_KEY *key, void **context,
2N/A const u_int8_t *data, const int len,
2N/A u_int8_t *signature, const int sig_len);
2N/A int (*verify)(const int mode, DST_KEY *key, void **context,
2N/A const u_int8_t *data, const int len,
2N/A const u_int8_t *signature, const int sig_len);
2N/A int (*compare)(const DST_KEY *key1, const DST_KEY *key2);
2N/A int (*generate)(DST_KEY *key, int parms);
2N/A void *(*destroy)(void *key);
2N/A /* conversion functions */
2N/A int (*to_dns_key)(const DST_KEY *key, u_int8_t *out,
2N/A const int out_len);
2N/A int (*from_dns_key)(DST_KEY *key, const u_int8_t *str,
2N/A const int str_len);
2N/A int (*to_file_fmt)(const DST_KEY *key, char *out,
2N/A const int out_len);
2N/A int (*from_file_fmt)(DST_KEY *key, const char *out,
2N/A const int out_len);
2N/A
2N/A} dst_func;
2N/A
2N/Aextern dst_func *dst_t_func[DST_MAX_ALGS];
2N/Aextern const char *key_file_fmt_str;
2N/Aextern const char *dst_path;
2N/A
2N/A#ifndef DST_HASH_SIZE
2N/A#define DST_HASH_SIZE 20 /*%< RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */
2N/A#endif
2N/A
2N/Aint dst_bsafe_init(void);
2N/A
2N/Aint dst_rsaref_init(void);
2N/A
2N/Aint dst_hmac_md5_init(void);
2N/A
2N/Aint dst_cylink_init(void);
2N/A
2N/Aint dst_eay_dss_init(void);
2N/A
2N/A/* from higher level support routines */
2N/Aint dst_s_calculate_bits( const u_int8_t *str, const int max_bits);
2N/Aint dst_s_verify_str( const char **buf, const char *str);
2N/A
2N/A
2N/A/* conversion between dns names and key file names */
2N/Asize_t dst_s_filename_length( const char *name, const char *suffix);
2N/Aint dst_s_build_filename( char *filename, const char *name,
2N/A u_int16_t id, int alg, const char *suffix,
2N/A size_t filename_length);
2N/A
2N/AFILE *dst_s_fopen (const char *filename, const char *mode, int perm);
2N/A
2N/A/*%
2N/A * read and write network byte order into u_int?_t
2N/A * all of these should be retired
2N/A */
2N/Au_int16_t dst_s_get_int16( const u_int8_t *buf);
2N/Avoid dst_s_put_int16( u_int8_t *buf, const u_int16_t val);
2N/A
2N/Au_int32_t dst_s_get_int32( const u_int8_t *buf);
2N/Avoid dst_s_put_int32( u_int8_t *buf, const u_int32_t val);
2N/A
2N/A#ifdef DUMP
2N/A# undef DUMP
2N/A# define DUMP(a,b,c,d) dst_s_dump(a,b,c,d)
2N/A#else
2N/A# define DUMP(a,b,c,d)
2N/A#endif
2N/Avoid
2N/Adst_s_dump(const int mode, const u_char *data, const int size,
2N/A const char *msg);
2N/A
2N/A
2N/A
2N/A#endif /* DST_INTERNAL_H */
2N/A/*! \file */