Home | History | Annotate | Line # | Download | only in isc
dst.h revision 1.1.1.3.22.1
      1  1.1.1.3.22.1       jym /*	$NetBSD: dst.h,v 1.1.1.3.22.1 2009/05/13 19:18:24 jym Exp $	*/
      2           1.1  christos 
      3           1.1  christos #ifndef DST_H
      4           1.1  christos #define DST_H
      5           1.1  christos 
      6           1.1  christos #ifndef HAS_DST_KEY
      7           1.1  christos typedef struct dst_key {
      8       1.1.1.2  christos 	char	*dk_key_name;   /*%< name of the key */
      9       1.1.1.2  christos 	int	dk_key_size;    /*%< this is the size of the key in bits */
     10       1.1.1.2  christos 	int	dk_proto;       /*%< what protocols this key can be used for */
     11       1.1.1.2  christos 	int	dk_alg;         /*%< algorithm number from key record */
     12       1.1.1.2  christos 	u_int32_t dk_flags;     /*%< and the flags of the public key */
     13       1.1.1.2  christos 	u_int16_t dk_id;        /*%< identifier of the key */
     14           1.1  christos } DST_KEY;
     15           1.1  christos #endif /* HAS_DST_KEY */
     16           1.1  christos /*
     17           1.1  christos  * do not taint namespace
     18           1.1  christos  */
     19           1.1  christos #define	dst_bsafe_init		__dst_bsafe_init
     20           1.1  christos #define	dst_buffer_to_key	__dst_buffer_to_key
     21           1.1  christos #define	dst_check_algorithm	__dst_check_algorithm
     22           1.1  christos #define	dst_compare_keys	__dst_compare_keys
     23           1.1  christos #define	dst_cylink_init		__dst_cylink_init
     24           1.1  christos #define	dst_dnskey_to_key	__dst_dnskey_to_key
     25           1.1  christos #define	dst_eay_dss_init	__dst_eay_dss_init
     26           1.1  christos #define	dst_free_key		__dst_free_key
     27           1.1  christos #define	dst_generate_key	__dst_generate_key
     28           1.1  christos #define	dst_hmac_md5_init	__dst_hmac_md5_init
     29           1.1  christos #define	dst_init		__dst_init
     30           1.1  christos #define	dst_key_to_buffer	__dst_key_to_buffer
     31           1.1  christos #define	dst_key_to_dnskey	__dst_key_to_dnskey
     32           1.1  christos #define	dst_read_key		__dst_read_key
     33           1.1  christos #define	dst_rsaref_init		__dst_rsaref_init
     34           1.1  christos #define	dst_s_build_filename	__dst_s_build_filename
     35           1.1  christos #define	dst_s_calculate_bits	__dst_s_calculate_bits
     36           1.1  christos #define	dst_s_conv_bignum_b64_to_u8	__dst_s_conv_bignum_b64_to_u8
     37           1.1  christos #define	dst_s_conv_bignum_u8_to_b64	__dst_s_conv_bignum_u8_to_b64
     38           1.1  christos #define	dst_s_dns_key_id	__dst_s_dns_key_id
     39           1.1  christos #define	dst_s_dump		__dst_s_dump
     40           1.1  christos #define	dst_s_filename_length	__dst_s_filename_length
     41           1.1  christos #define	dst_s_fopen		__dst_s_fopen
     42           1.1  christos #define	dst_s_get_int16		__dst_s_get_int16
     43           1.1  christos #define	dst_s_get_int32		__dst_s_get_int32
     44           1.1  christos #define	dst_s_id_calc		__dst_s_id_calc
     45           1.1  christos #define	dst_s_put_int16		__dst_s_put_int16
     46           1.1  christos #define	dst_s_put_int32		__dst_s_put_int32
     47           1.1  christos #define	dst_s_quick_random	__dst_s_quick_random
     48           1.1  christos #define	dst_s_quick_random_set	__dst_s_quick_random_set
     49           1.1  christos #define	dst_s_random		__dst_s_random
     50           1.1  christos #define	dst_s_semi_random	__dst_s_semi_random
     51           1.1  christos #define	dst_s_verify_str	__dst_s_verify_str
     52           1.1  christos #define	dst_sig_size		__dst_sig_size
     53           1.1  christos #define	dst_sign_data		__dst_sign_data
     54           1.1  christos #define	dst_verify_data		__dst_verify_data
     55           1.1  christos #define	dst_write_key		__dst_write_key
     56           1.1  christos 
     57           1.1  christos /*
     58           1.1  christos  * DST Crypto API defintions
     59           1.1  christos  */
     60           1.1  christos void     dst_init(void);
     61           1.1  christos int      dst_check_algorithm(const int);
     62           1.1  christos 
     63           1.1  christos 
     64       1.1.1.2  christos int dst_sign_data(const int,	 	/*!<   specifies INIT/UPDATE/FINAL/ALL  */
     65       1.1.1.2  christos 		  DST_KEY *,	 	/*!<   the key to use  */
     66       1.1.1.2  christos 		  void **,	 	/*!<   pointer to state structure  */
     67       1.1.1.2  christos 		  const u_char *,	/*!<   data to be signed  */
     68       1.1.1.2  christos 		  const int,	 	/*!<   length of input data  */
     69       1.1.1.2  christos 		  u_char *,	 	/*!<   buffer to write signature to  */
     70       1.1.1.2  christos 		  const int);	 	/*!<   size of output buffer  */
     71       1.1.1.2  christos int dst_verify_data(const int,	 	/*!<   specifies INIT/UPDATE/FINAL/ALL  */
     72       1.1.1.2  christos 		    DST_KEY *,	 	/*!<   the key to use  */
     73       1.1.1.2  christos 		    void **,	 	/*!<   pointer to state structure  */
     74       1.1.1.2  christos 		    const u_char *,	/*!<   data to be verified  */
     75       1.1.1.2  christos 		    const int,	 	/*!<   length of input data  */
     76       1.1.1.2  christos 		    const u_char *,	/*!<   buffer containing signature  */
     77       1.1.1.2  christos 		    const int);	 	/*!<   length of signature  */
     78       1.1.1.2  christos DST_KEY *dst_read_key(const char *,	/*!<   name of key  */
     79       1.1.1.2  christos 		      const u_int16_t,	/*!<   key tag identifier  */
     80       1.1.1.2  christos 		      const int,	/*!<   key algorithm  */
     81       1.1.1.2  christos 		      const int);	/*!<   Private/PublicKey wanted */
     82       1.1.1.2  christos int      dst_write_key(const DST_KEY *,	/*!<   key to write out  */
     83       1.1.1.2  christos 		       const int); 	/*!<   Public/Private  */
     84       1.1.1.2  christos DST_KEY *dst_dnskey_to_key(const char *,	/*!<   KEY record name  */
     85       1.1.1.2  christos 			   const u_char *,	/*!<   KEY RDATA  */
     86       1.1.1.2  christos 			   const int);		/*!<   size of input buffer */
     87       1.1.1.2  christos int      dst_key_to_dnskey(const DST_KEY *,	/*!<   key to translate  */
     88       1.1.1.2  christos 			   u_char *,		/*!<   output buffer  */
     89       1.1.1.2  christos 			   const int);		/*!<   size of out_storage */
     90       1.1.1.2  christos DST_KEY *dst_buffer_to_key(const char *,  	/*!<   name of the key  */
     91       1.1.1.2  christos 			   const int,	  	/*!<   algorithm  */
     92       1.1.1.2  christos 			   const int,	  	/*!<   dns flags  */
     93       1.1.1.2  christos 			   const int,	  	/*!<   dns protocol  */
     94       1.1.1.2  christos 			   const u_char *, 	/*!<   key in dns wire fmt  */
     95       1.1.1.2  christos 			   const int);	  	/*!<   size of key  */
     96           1.1  christos int     dst_key_to_buffer(DST_KEY *, u_char *, int);
     97           1.1  christos 
     98       1.1.1.2  christos DST_KEY *dst_generate_key(const char *,    	/*!<   name of new key  */
     99       1.1.1.2  christos 			  const int,       	/*!<   key algorithm to generate  */
    100       1.1.1.2  christos 			  const int,      	/*!<   size of new key  */
    101       1.1.1.2  christos 			  const int,       	/*!<   alg dependent parameter */
    102       1.1.1.2  christos 			  const int,     	/*!<   key DNS flags  */
    103       1.1.1.2  christos 			  const int);		/*!<   key DNS protocol  */
    104           1.1  christos DST_KEY *dst_free_key(DST_KEY *);
    105           1.1  christos int      dst_compare_keys(const DST_KEY *, const DST_KEY *);
    106           1.1  christos 
    107           1.1  christos int	dst_sig_size(DST_KEY *);
    108           1.1  christos 
    109           1.1  christos 
    110           1.1  christos /* support for dns key tags/ids */
    111           1.1  christos u_int16_t dst_s_dns_key_id(const u_char *, const int);
    112           1.1  christos u_int16_t dst_s_id_calc(const u_char *, const int);
    113           1.1  christos 
    114           1.1  christos /* Used by callers as well as by the library.  */
    115       1.1.1.2  christos #define RAW_KEY_SIZE    8192        /*%< large enough to store any key */
    116           1.1  christos /* DST_API control flags */
    117           1.1  christos /* These are used used in functions dst_sign_data and dst_verify_data */
    118       1.1.1.2  christos #define SIG_MODE_INIT		1  /*%< initialize digest */
    119       1.1.1.2  christos #define SIG_MODE_UPDATE		2  /*%< add data to digest */
    120       1.1.1.2  christos #define SIG_MODE_FINAL		4  /*%< generate/verify signature */
    121           1.1  christos #define SIG_MODE_ALL		(SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
    122           1.1  christos 
    123           1.1  christos /* Flags for dst_read_private_key()  */
    124           1.1  christos #define DST_FORCE_READ		0x1000000
    125           1.1  christos #define DST_CAN_SIGN		0x010F
    126           1.1  christos #define DST_NO_AUTHEN		0x8000
    127           1.1  christos #define DST_EXTEND_FLAG         0x1000
    128           1.1  christos #define DST_STANDARD		0
    129           1.1  christos #define DST_PRIVATE             0x2000000
    130           1.1  christos #define DST_PUBLIC              0x4000000
    131           1.1  christos #define DST_RAND_SEMI           1
    132           1.1  christos #define DST_RAND_STD            2
    133           1.1  christos #define DST_RAND_KEY            3
    134           1.1  christos #define DST_RAND_DSS            4
    135           1.1  christos 
    136           1.1  christos 
    137           1.1  christos /* DST algorithm codes */
    138           1.1  christos #define KEY_RSA			1
    139           1.1  christos #define KEY_DH			2
    140           1.1  christos #define KEY_DSA			3
    141           1.1  christos #define KEY_PRIVATE		254
    142           1.1  christos #define KEY_EXPAND		255
    143           1.1  christos #define KEY_HMAC_MD5		157
    144           1.1  christos #define KEY_HMAC_SHA1		158
    145           1.1  christos #define UNKNOWN_KEYALG		0
    146           1.1  christos #define DST_MAX_ALGS            KEY_HMAC_SHA1
    147           1.1  christos 
    148           1.1  christos /* DST constants to locations in KEY record  changes in new KEY record */
    149           1.1  christos #define DST_FLAGS_SIZE		2
    150           1.1  christos #define DST_KEY_PROT		2
    151           1.1  christos #define DST_KEY_ALG		3
    152           1.1  christos #define DST_EXT_FLAG            4
    153           1.1  christos #define DST_KEY_START		4
    154           1.1  christos 
    155           1.1  christos #ifndef SIGN_F_NOKEY
    156           1.1  christos #define SIGN_F_NOKEY		0xC000
    157           1.1  christos #endif
    158           1.1  christos 
    159           1.1  christos /* error codes from dst routines */
    160           1.1  christos #define SIGN_INIT_FAILURE	(-23)
    161           1.1  christos #define SIGN_UPDATE_FAILURE	(-24)
    162           1.1  christos #define SIGN_FINAL_FAILURE	(-25)
    163           1.1  christos #define VERIFY_INIT_FAILURE	(-26)
    164           1.1  christos #define VERIFY_UPDATE_FAILURE	(-27)
    165           1.1  christos #define VERIFY_FINAL_FAILURE	(-28)
    166           1.1  christos #define MISSING_KEY_OR_SIGNATURE (-30)
    167           1.1  christos #define UNSUPPORTED_KEYALG	(-31)
    168           1.1  christos 
    169           1.1  christos #endif /* DST_H */
    170       1.1.1.2  christos /*! \file */
    171