other-licenses/android/dst.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/android/dst.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,192 @@
     1.4 +/*	$NetBSD: dst.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $	*/
     1.5 +
     1.6 +/*
     1.7 + * This version of this file is derived from Android 2.3 "Gingerbread",
     1.8 + * which contains uncredited changes by Android/Google developers.  It has
     1.9 + * been modified in 2011 for use in the Android build of Mozilla Firefox by
    1.10 + * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
    1.11 + * and Steve Workman <sjhworkman@gmail.com>).
    1.12 + * These changes are offered under the same license as the original NetBSD
    1.13 + * file, whose copyright and license are unchanged above.
    1.14 + */
    1.15 +
    1.16 +#ifndef DST_H
    1.17 +#define DST_H
    1.18 +
    1.19 +#ifndef HAS_DST_KEY
    1.20 +typedef struct dst_key {
    1.21 +	char	*dk_key_name;   /* name of the key */
    1.22 +	int	dk_key_size;    /* this is the size of the key in bits */
    1.23 +	int	dk_proto;       /* what protocols this key can be used for */
    1.24 +	int	dk_alg;         /* algorithm number from key record */
    1.25 +	u_int32_t dk_flags;     /* and the flags of the public key */
    1.26 +	u_int16_t dk_id;        /* identifier of the key */
    1.27 +} DST_KEY;
    1.28 +#endif /* HAS_DST_KEY */
    1.29 +
    1.30 +/*
    1.31 + * do not taint namespace
    1.32 + */
    1.33 +#define	dst_bsafe_init		__dst_bsafe_init
    1.34 +#define	dst_buffer_to_key	__dst_buffer_to_key
    1.35 +#define	dst_check_algorithm	__dst_check_algorithm
    1.36 +#define	dst_compare_keys	__dst_compare_keys
    1.37 +#define	dst_cylink_init		__dst_cylink_init
    1.38 +#define	dst_dnskey_to_key	__dst_dnskey_to_key
    1.39 +#define	dst_eay_dss_init	__dst_eay_dss_init
    1.40 +#define	dst_free_key		__dst_free_key
    1.41 +#define	dst_generate_key	__dst_generate_key
    1.42 +#define	dst_hmac_md5_init	__dst_hmac_md5_init
    1.43 +#define	dst_init		__dst_init
    1.44 +#define	dst_key_to_buffer	__dst_key_to_buffer
    1.45 +#define	dst_key_to_dnskey	__dst_key_to_dnskey
    1.46 +#define	dst_read_key		__dst_read_key
    1.47 +#define	dst_rsaref_init		__dst_rsaref_init
    1.48 +#define	dst_s_build_filename	__dst_s_build_filename
    1.49 +#define	dst_s_calculate_bits	__dst_s_calculate_bits
    1.50 +#define	dst_s_conv_bignum_b64_to_u8	__dst_s_conv_bignum_b64_to_u8
    1.51 +#define	dst_s_conv_bignum_u8_to_b64	__dst_s_conv_bignum_u8_to_b64
    1.52 +#define	dst_s_dns_key_id	__dst_s_dns_key_id
    1.53 +#define	dst_s_dump		__dst_s_dump
    1.54 +#define	dst_s_filename_length	__dst_s_filename_length
    1.55 +#define	dst_s_fopen		__dst_s_fopen
    1.56 +#define	dst_s_get_int16		__dst_s_get_int16
    1.57 +#define	dst_s_get_int32		__dst_s_get_int32
    1.58 +#define	dst_s_id_calc		__dst_s_id_calc
    1.59 +#define	dst_s_put_int16		__dst_s_put_int16
    1.60 +#define	dst_s_put_int32		__dst_s_put_int32
    1.61 +#define	dst_s_quick_random	__dst_s_quick_random
    1.62 +#define	dst_s_quick_random_set	__dst_s_quick_random_set
    1.63 +#define	dst_s_random		__dst_s_random
    1.64 +#define	dst_s_semi_random	__dst_s_semi_random
    1.65 +#define	dst_s_verify_str	__dst_s_verify_str
    1.66 +#define	dst_sig_size		__dst_sig_size
    1.67 +#define	dst_sign_data		__dst_sign_data
    1.68 +#define	dst_verify_data		__dst_verify_data
    1.69 +#define	dst_write_key		__dst_write_key
    1.70 +
    1.71 +/* 
    1.72 + * DST Crypto API defintions 
    1.73 + */
    1.74 +void     dst_init(void);
    1.75 +int      dst_check_algorithm(const int);
    1.76 +
    1.77 +int dst_sign_data(const int,	 	/* specifies INIT/UPDATE/FINAL/ALL */
    1.78 +		  DST_KEY *,	 	/* the key to use */
    1.79 +		  void **,	 	/* pointer to state structure */
    1.80 +		  const u_char *,	/* data to be signed */
    1.81 +		  const int,	 	/* length of input data */
    1.82 +		  u_char *,	 	/* buffer to write signature to */
    1.83 +		  const int);	 	/* size of output buffer */
    1.84 +
    1.85 +int dst_verify_data(const int,	 	/* specifies INIT/UPDATE/FINAL/ALL */
    1.86 +		    DST_KEY *,	 	/* the key to use */
    1.87 +		    void **,	 	/* pointer to state structure */
    1.88 +		    const u_char *,	/* data to be verified */
    1.89 +		    const int,	 	/* length of input data */
    1.90 +		    const u_char *,	/* buffer containing signature */
    1.91 +		    const int);	 	/* length of signature */
    1.92 +
    1.93 +
    1.94 +DST_KEY *dst_read_key(const char *,	/* name of key */
    1.95 +		      const u_int16_t,	/* key tag identifier */
    1.96 +		      const int,	/* key algorithm */
    1.97 +		      const int);	/* Private/PublicKey wanted*/
    1.98 +
    1.99 +int      dst_write_key(const DST_KEY *,	/* key to write out */
   1.100 +		       const int); 	/* Public/Private */
   1.101 +
   1.102 +DST_KEY *dst_dnskey_to_key(const char *,	/* KEY record name */
   1.103 +			   const u_char *,	/* KEY RDATA */
   1.104 +			   const int);		/* size of input buffer*/
   1.105 +
   1.106 +
   1.107 +int      dst_key_to_dnskey(const DST_KEY *,	/* key to translate */
   1.108 +			   u_char *,		/* output buffer */
   1.109 +			   const int);		/* size of out_storage*/
   1.110 +
   1.111 +
   1.112 +DST_KEY *dst_buffer_to_key(const char *,  	/* name of the key */
   1.113 +			   const int,	  	/* algorithm */
   1.114 +			   const int,	  	/* dns flags */
   1.115 +			   const int,	  	/* dns protocol */
   1.116 +			   const u_char *, 	/* key in dns wire fmt */
   1.117 +			   const int);	  	/* size of key */
   1.118 +
   1.119 +
   1.120 +int     dst_key_to_buffer(DST_KEY *, u_char *, int);
   1.121 +
   1.122 +DST_KEY *dst_generate_key(const char *,    	/* name of new key */
   1.123 +			  const int,       	/* key algorithm to generate */
   1.124 +			  const int,      	/* size of new key */
   1.125 +			  const int,       	/* alg dependent parameter*/
   1.126 +			  const int,     	/* key DNS flags */
   1.127 +			  const int);		/* key DNS protocol */
   1.128 +
   1.129 +DST_KEY *dst_free_key(DST_KEY *);
   1.130 +int      dst_compare_keys(const DST_KEY *, const DST_KEY *);
   1.131 +
   1.132 +int	dst_sig_size(DST_KEY *);
   1.133 +
   1.134 +
   1.135 +/* support for dns key tags/ids */
   1.136 +u_int16_t dst_s_dns_key_id(const u_char *, const int);
   1.137 +u_int16_t dst_s_id_calc(const u_char *, const int);
   1.138 +
   1.139 +/* Used by callers as well as by the library.  */
   1.140 +#define RAW_KEY_SIZE    8192        /* large enough to store any key */
   1.141 +
   1.142 +/* DST_API control flags */
   1.143 +/* These are used used in functions dst_sign_data and dst_verify_data */
   1.144 +#define SIG_MODE_INIT		1  /* initialize digest */
   1.145 +#define SIG_MODE_UPDATE		2  /* add data to digest */
   1.146 +#define SIG_MODE_FINAL		4  /* generate/verify signature */
   1.147 +#define SIG_MODE_ALL		(SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
   1.148 +
   1.149 +/* Flags for dst_read_private_key()  */
   1.150 +#define DST_FORCE_READ		0x1000000
   1.151 +#define DST_CAN_SIGN		0x010F
   1.152 +#define DST_NO_AUTHEN		0x8000
   1.153 +#define DST_EXTEND_FLAG         0x1000
   1.154 +#define DST_STANDARD		0
   1.155 +#define DST_PRIVATE             0x2000000
   1.156 +#define DST_PUBLIC              0x4000000
   1.157 +#define DST_RAND_SEMI           1
   1.158 +#define DST_RAND_STD            2
   1.159 +#define DST_RAND_KEY            3
   1.160 +#define DST_RAND_DSS            4
   1.161 +
   1.162 +
   1.163 +/* DST algorithm codes */
   1.164 +#define KEY_RSA			1
   1.165 +#define KEY_DH			2
   1.166 +#define KEY_DSA			3
   1.167 +#define KEY_PRIVATE		254
   1.168 +#define KEY_EXPAND		255
   1.169 +#define KEY_HMAC_MD5		157
   1.170 +#define KEY_HMAC_SHA1		158
   1.171 +#define UNKNOWN_KEYALG		0
   1.172 +#define DST_MAX_ALGS            KEY_HMAC_SHA1
   1.173 +
   1.174 +/* DST constants to locations in KEY record  changes in new KEY record */
   1.175 +#define DST_FLAGS_SIZE		2
   1.176 +#define DST_KEY_PROT		2
   1.177 +#define DST_KEY_ALG		3
   1.178 +#define DST_EXT_FLAG            4
   1.179 +#define DST_KEY_START		4
   1.180 +
   1.181 +#ifndef SIGN_F_NOKEY 
   1.182 +#define SIGN_F_NOKEY		0xC000
   1.183 +#endif
   1.184 +
   1.185 +/* error codes from dst routines */
   1.186 +#define SIGN_INIT_FAILURE	(-23)
   1.187 +#define SIGN_UPDATE_FAILURE	(-24)
   1.188 +#define SIGN_FINAL_FAILURE	(-25)
   1.189 +#define VERIFY_INIT_FAILURE	(-26)
   1.190 +#define VERIFY_UPDATE_FAILURE	(-27)
   1.191 +#define VERIFY_FINAL_FAILURE	(-28)
   1.192 +#define MISSING_KEY_OR_SIGNATURE (-30)
   1.193 +#define UNSUPPORTED_KEYALG	(-31)
   1.194 +
   1.195 +#endif /* DST_H */

mercurial