diff options
Diffstat (limited to 'contrib/bind/lib/dst')
-rw-r--r-- | contrib/bind/lib/dst/Makefile | 4 | ||||
-rw-r--r-- | contrib/bind/lib/dst/bsafe_link.c | 39 | ||||
-rw-r--r-- | contrib/bind/lib/dst/cylink_link.c | 8 | ||||
-rw-r--r-- | contrib/bind/lib/dst/dst_api.c | 25 | ||||
-rw-r--r-- | contrib/bind/lib/dst/dst_internal.h | 23 | ||||
-rw-r--r-- | contrib/bind/lib/dst/eay_dss_link.c | 20 | ||||
-rw-r--r-- | contrib/bind/lib/dst/hmac_link.c | 10 | ||||
-rw-r--r-- | contrib/bind/lib/dst/md5.h | 2 | ||||
-rw-r--r-- | contrib/bind/lib/dst/md5_dgst.c | 8 | ||||
-rw-r--r-- | contrib/bind/lib/dst/prandom.c | 41 | ||||
-rw-r--r-- | contrib/bind/lib/dst/rsaref_link.c | 15 | ||||
-rw-r--r-- | contrib/bind/lib/dst/support.c | 10 |
12 files changed, 127 insertions, 78 deletions
diff --git a/contrib/bind/lib/dst/Makefile b/contrib/bind/lib/dst/Makefile index a5518bd..5503afa 100644 --- a/contrib/bind/lib/dst/Makefile +++ b/contrib/bind/lib/dst/Makefile @@ -13,7 +13,7 @@ # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE. -# $Id: Makefile,v 1.18 2000/12/23 08:02:58 vixie Exp $ +# $Id: Makefile,v 1.19 2001/08/14 05:58:03 marka Exp $ # these are only appropriate for BSD 4.4 or derivatives, and are used in # development. normal builds will be done in the top level directory and @@ -64,7 +64,7 @@ ${LIBBIND}: ${OBJS} ${RANLIB} ${LIBBIND} .c.${O}: - if test ! -d ${THREADED} ; then mkdir ${THREADED} ; else true ; fi + mkdir ${THREADED} 2> /dev/null || test -d ${THREADED} -a -w ${THREADED} ${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} ${REENTRANT} ${CRYPTINCL} ${CRYPTFLAGS} -c $*.c -o ${THREADED}/$*.${O} -${LDS} ${LD} ${LD_LIBFLAGS} ${THREADED}/$*.${O} \ -o ${THREADED}/$*.out && \ diff --git a/contrib/bind/lib/dst/bsafe_link.c b/contrib/bind/lib/dst/bsafe_link.c index ec072b3..7c9e481 100644 --- a/contrib/bind/lib/dst/bsafe_link.c +++ b/contrib/bind/lib/dst/bsafe_link.c @@ -1,5 +1,5 @@ #if defined(BSAFE) || defined(DNSSAFE) -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/bsafe_link.c,v 1.12 2001/04/05 21:59:59 bwelling Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/bsafe_link.c,v 1.15 2001/09/25 04:50:28 marka Exp $"; /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -118,7 +118,7 @@ static void *dst_bsafe_free_key_structure(void *key); * BSAFE/DNSSAFE related functions */ int -dst_bsafe_init() +dst_bsafe_init(void) { if (dst_t_func[KEY_RSA] != NULL) return (1); @@ -327,7 +327,8 @@ dst_bsafe_verify(const int mode, DST_KEY *dkey, void **context, if (ret == 0 && (status = B_DecryptUpdate(rsaEncryptor, work_area, &u_bytes, 0, - (u_char *) signature, sig_len, + (const u_char *) signature, + sig_len, NULL_PTR, NULL_SURRENDER))) ret = VERIFY_FINAL_FAILURE; @@ -385,24 +386,28 @@ dst_bsafe_to_dns_key(const DST_KEY *in_key, u_char *out_str, public = (B_KEY_OBJ)((RSA_Key *) in_key->dk_KEY_struct)->rk_Public_Key; n = B_GetKeyInfo((POINTER *) &pub, public, KI_RSAPublic); - - if (out_len < pub->exponent.len) /* not enough space */ + if (n != 0) return (-1); - if (pub->exponent.len < 256) /* key exponent is <= 2040 bits */ + + if (pub->exponent.len < 256) { /* key exponent is <= 2040 bits */ + if ((unsigned int)out_len < pub->exponent.len + 1) + return (-1); *op++ = (u_int8_t) pub->exponent.len; - else { /* key exponent is > 2040 bits */ + } else { /* key exponent is > 2040 bits */ u_int16_t e = (u_int16_t) pub->exponent.len; - *op++ = 0; /* 3 byte lenght field */ + if ((unsigned int)out_len < pub->exponent.len + 3) + return (-1); + *op++ = 0; /* 3 byte length field */ dst_s_put_int16(op, e); op += sizeof(e); n = 2; } - n += pub->exponent.len; - memcpy(op, pub->exponent.data, n); - op += n; n++; + memcpy(op, pub->exponent.data, pub->exponent.len); + op += pub->exponent.len; + n += pub->exponent.len; - if ((out_len - n) > pub->modulus.len) { + if ((unsigned int)(out_len - n) >= pub->modulus.len) { /*copy exponent */ memcpy(op, pub->modulus.data, pub->modulus.len); n += pub->modulus.len; @@ -612,7 +617,6 @@ dst_bsafe_key_from_file_format(DST_KEY *d_key, const char *buff, int status; char s[RAW_KEY_SIZE]; int len, s_len = sizeof(s); - int tag = -1; const char *p = buff; RSA_Key *b_key; A_RSA_KEY *public; @@ -1041,7 +1045,7 @@ dst_bsafe_md5digest(const int mode, B_ALGORITHM_OBJ *digest_obj, if (digest_obj == NULL || *digest_obj == NULL) { printf("NO digest obj\n"); - exit(-33); + exit(33); } if ((mode & SIG_MODE_INIT) && @@ -1050,8 +1054,7 @@ dst_bsafe_md5digest(const int mode, B_ALGORITHM_OBJ *digest_obj, return (SIGN_INIT_FAILURE); if ((mode & SIG_MODE_UPDATE) && data && (len > 0) && - (status = B_DigestUpdate(*digest_obj, (u_char *) data, len, - NULL_SURRENDER))) + (status = B_DigestUpdate(*digest_obj, data, len, NULL_SURRENDER))) return (SIGN_UPDATE_FAILURE); if (mode & SIG_MODE_FINAL) { @@ -1080,13 +1083,13 @@ T_malloc(unsigned int len) } int -T_memcmp(POINTER firstBlock, POINTER secondBlock, unsigned int len) +T_memcmp(CPOINTER firstBlock, CPOINTER secondBlock, unsigned int len) { return (memcmp(firstBlock, secondBlock, len)); } void -T_memcpy(POINTER output, POINTER input, unsigned int len) +T_memcpy(POINTER output, CPOINTER input, unsigned int len) { memcpy(output, input, len); } diff --git a/contrib/bind/lib/dst/cylink_link.c b/contrib/bind/lib/dst/cylink_link.c index 60097f5..6c2bdae 100644 --- a/contrib/bind/lib/dst/cylink_link.c +++ b/contrib/bind/lib/dst/cylink_link.c @@ -1,5 +1,5 @@ #ifdef CYLINK_DSS -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/cylink_link.c,v 1.8 2001/04/05 22:00:00 bwelling Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/cylink_link.c,v 1.9 2001/05/29 05:48:05 marka Exp $"; /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -147,7 +147,7 @@ dst_cylink_sign(const int mode, DST_KEY *dkey, void **context, SHAInit(ctx); if ((mode & SIG_MODE_UPDATE) && (data && len > 0)) { - status = SHAUpdate(ctx, (u_char *) data, len); + status = SHAUpdate(ctx, data, len); if (status != SUCCESS) return (SIGN_UPDATE_FAILURE); } @@ -228,7 +228,7 @@ dst_cylink_verify(const int mode, DST_KEY *dkey, void **context, SHAInit(ctx); if ((mode & SIG_MODE_UPDATE) && (data && len > 0)) { - status = SHAUpdate(ctx, (u_char *) data, len); + status = SHAUpdate(ctx, data, len); if (status != SUCCESS) return (VERIFY_UPDATE_FAILURE); } @@ -576,6 +576,8 @@ dst_cylink_generate_keypair(DST_KEY *key, int nothing) DSA_Key *dsa; u_char rand[SHA_LENGTH]; + UNUSED(nothing); + if (key == NULL || key->dk_alg != KEY_DSA) return (0); diff --git a/contrib/bind/lib/dst/dst_api.c b/contrib/bind/lib/dst/dst_api.c index a79dcf1..cc2a7e4 100644 --- a/contrib/bind/lib/dst/dst_api.c +++ b/contrib/bind/lib/dst/dst_api.c @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c,v 1.17.2.2 2001/07/26 01:58:06 marka Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c,v 1.20 2001/07/26 01:20:08 marka Exp $"; #endif /* @@ -62,8 +62,8 @@ static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c, /* static variables */ static int done_init = 0; dst_func *dst_t_func[DST_MAX_ALGS]; -char *key_file_fmt_str = "Private-key-format: v%s\nAlgorithm: %d (%s)\n"; -char *dst_path = ""; +const char *key_file_fmt_str = "Private-key-format: v%s\nAlgorithm: %d (%s)\n"; +const char *dst_path = ""; /* internal I/O functions */ static DST_KEY *dst_s_read_public_key(const char *in_name, @@ -109,12 +109,14 @@ dst_init() } else if (stat(s, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) { EREPORT(("%s is not a valid directory\n", s)); } else { - dst_path = (char *) malloc(len + 2); - memcpy(dst_path, s, len + 1); - if (dst_path[strlen(dst_path) - 1] != '/') { - dst_path[strlen(dst_path) + 1] = 0; - dst_path[strlen(dst_path)] = '/'; + char *tmp; + tmp = (char *) malloc(len + 2); + memcpy(tmp, s, len + 1); + if (tmp[strlen(tmp) - 1] != '/') { + tmp[strlen(tmp) + 1] = 0; + tmp[strlen(tmp)] = '/'; } + dst_path = tmp; } } memset(dst_t_func, 0, sizeof(dst_t_func)); @@ -555,7 +557,7 @@ dst_s_read_public_key(const char *in_name, const u_int16_t in_id, int in_alg) enckey[--len] = '\0'; /* remove leading spaces */ - for (notspace = (char *) enckey; isspace(*notspace); len--) + for (notspace = (char *) enckey; isspace((*notspace)&0xff); len--) notspace++; dlen = b64_pton(notspace, deckey, sizeof(deckey)); @@ -589,6 +591,7 @@ dst_s_write_public_key(const DST_KEY *key) u_char out_key[RAW_KEY_SIZE]; char enc_key[RAW_KEY_SIZE]; int len = 0; + int mode; memset(out_key, 0, sizeof(out_key)); if (key == NULL) { @@ -604,8 +607,10 @@ dst_s_write_public_key(const DST_KEY *key) key->dk_key_name, key->dk_id, PUBLIC_KEY)); return (0); } + /* XXX in general this should be a check for symmetric keys */ + mode = (key->dk_alg == KEY_HMAC_MD5) ? 0600 : 0644; /* create public key file */ - if ((fp = dst_s_fopen(filename, "w+", 0644)) == NULL) { + if ((fp = dst_s_fopen(filename, "w+", mode)) == NULL) { EREPORT(("DST_write_public_key: open of file:%s failed (errno=%d)\n", filename, errno)); return (0); diff --git a/contrib/bind/lib/dst/dst_internal.h b/contrib/bind/lib/dst/dst_internal.h index 66bfed4..0825109 100644 --- a/contrib/bind/lib/dst/dst_internal.h +++ b/contrib/bind/lib/dst/dst_internal.h @@ -65,13 +65,14 @@ typedef struct dst_key { #ifdef REPORT_ERRORS #define EREPORT(str) printf str #else -#define EREPORT(str) +#define EREPORT(str) (void)0 #endif /* use our own special macro to FRRE memory */ #ifndef SAFE_FREE -#define SAFE_FREE(a) if(a != NULL){memset(a,0, sizeof(*a)); free(a); a=NULL;} +#define SAFE_FREE(a) \ +do{if(a != NULL){memset(a,0, sizeof(*a)); free(a); a=NULL;}} while (0) #define SAFE_FREE2(a,s) if (a != NULL && s > 0){memset(a,0, s);free(a); a=NULL;} #endif @@ -98,22 +99,22 @@ typedef struct dst_func { } dst_func; extern dst_func *dst_t_func[DST_MAX_ALGS]; -extern char *key_file_fmt_str; -extern char *dst_path; +extern const char *key_file_fmt_str; +extern const char *dst_path; #ifndef DST_HASH_SIZE #define DST_HASH_SIZE 20 /* RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */ #endif -int dst_bsafe_init(); +int dst_bsafe_init(void); -int dst_rsaref_init(); +int dst_rsaref_init(void); -int dst_hmac_md5_init(); +int dst_hmac_md5_init(void); -int dst_cylink_init(); +int dst_cylink_init(void); -int dst_eay_dss_init(); +int dst_eay_dss_init(void); /* support functions */ /* base64 to bignum conversion routines */ @@ -158,6 +159,10 @@ void dst_s_put_int32( u_int8_t *buf, const u_int32_t val); #else # define DUMP(a,b,c,d) #endif +void +dst_s_dump(const int mode, const u_char *data, const int size, + const char *msg); + #endif /* DST_INTERNAL_H */ diff --git a/contrib/bind/lib/dst/eay_dss_link.c b/contrib/bind/lib/dst/eay_dss_link.c index 0cc01a8..b5c7caa 100644 --- a/contrib/bind/lib/dst/eay_dss_link.c +++ b/contrib/bind/lib/dst/eay_dss_link.c @@ -1,5 +1,5 @@ #ifdef EAY_DSS -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/eay_dss_link.c,v 1.5 2001/04/05 22:00:03 bwelling Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/eay_dss_link.c,v 1.6 2001/05/29 05:48:09 marka Exp $"; /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -44,6 +44,7 @@ static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/eay_dss_li #include "port_after.h" + static int dst_eay_dss_sign(const int mode, DST_KEY *dkey, void **context, const u_char *data, const int len, u_char *signature, const int sig_len); @@ -71,7 +72,7 @@ static int dst_eay_dss_compare_keys(const DST_KEY *key1, const DST_KEY *key2); * EAY DSS related functions */ int -dst_eay_dss_init() +dst_eay_dss_init(void) { if (dst_t_func[KEY_DSA] != NULL) return (1); @@ -608,8 +609,21 @@ dst_eay_dss_compare_keys(const DST_KEY *key1, const DST_KEY *key2) return (0); } #else +#include "port_before.h" + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <memory.h> +#include <sys/param.h> +#include <sys/time.h> +#include <netinet/in.h> + +#include "dst_internal.h" +#include "port_after.h" int -dst_eay_dss_init() +dst_eay_dss_init(void) { return (0); } diff --git a/contrib/bind/lib/dst/hmac_link.c b/contrib/bind/lib/dst/hmac_link.c index 1b93088..12e22a8 100644 --- a/contrib/bind/lib/dst/hmac_link.c +++ b/contrib/bind/lib/dst/hmac_link.c @@ -1,6 +1,6 @@ #ifdef HMAC_MD5 #ifndef LINT -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/hmac_link.c,v 1.8 1999/10/15 21:30:07 vixie Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/hmac_link.c,v 1.9 2001/05/29 05:48:10 marka Exp $"; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -103,7 +103,7 @@ dst_hmac_md5_sign(const int mode, DST_KEY *d_key, void **context, } if ((mode & SIG_MODE_UPDATE) && (data && len > 0)) - MD5Update(ctx, (u_char *)data, len); + MD5Update(ctx, data, len); if (mode & SIG_MODE_FINAL) { if (signature == NULL || sig_len < MD5_LEN) @@ -169,7 +169,7 @@ dst_hmac_md5_verify(const int mode, DST_KEY *d_key, void **context, MD5Update(ctx, key->hk_ipad, HMAC_LEN); } if ((mode & SIG_MODE_UPDATE) && (data && len > 0)) - MD5Update(ctx, (u_char *)data, len); + MD5Update(ctx, data, len); if (mode & SIG_MODE_FINAL) { u_char digest[MD5_LEN]; @@ -229,7 +229,7 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen) if (keylen > HMAC_LEN) { u_char tk[MD5_LEN]; MD5Init(&ctx); - MD5Update(&ctx, (u_char *)key, keylen); + MD5Update(&ctx, key, keylen); MD5Final(tk, &ctx); memset((void *) &ctx, 0, sizeof(ctx)); key = tk; @@ -431,6 +431,8 @@ dst_hmac_md5_generate_key(DST_KEY *key, const int nothing) u_char *buff; int i, n, size; + i = nothing; + if (key == NULL || key->dk_alg != KEY_HMAC_MD5) return (0); size = (key->dk_key_size + 7) / 8; /* convert to bytes */ diff --git a/contrib/bind/lib/dst/md5.h b/contrib/bind/lib/dst/md5.h index c8b1580..c886d17 100644 --- a/contrib/bind/lib/dst/md5.h +++ b/contrib/bind/lib/dst/md5.h @@ -80,7 +80,7 @@ typedef struct MD5state_st #ifndef NOPROTO void MD5_Init(MD5_CTX *c); -void MD5_Update(MD5_CTX *c, unsigned char *data, unsigned long len); +void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len); void MD5_Final(unsigned char *md, MD5_CTX *c); unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md); #else diff --git a/contrib/bind/lib/dst/md5_dgst.c b/contrib/bind/lib/dst/md5_dgst.c index 82e5a38..78882d1 100644 --- a/contrib/bind/lib/dst/md5_dgst.c +++ b/contrib/bind/lib/dst/md5_dgst.c @@ -56,11 +56,13 @@ * [including the GNU Public Licence.] */ -#include <stdio.h> #ifdef USE_MD5 /* Added by ogud@tis.com 1998/1/26 */ +#include <port_before.h> +#include <stdio.h> #include "md5_locl.h" +#include <port_after.h> -char *MD5_version="MD5 part of SSLeay 0.8.1 19-Jul-1997"; +const char *MD5_version="MD5 part of SSLeay 0.8.1 19-Jul-1997"; /* Implemented from RFC1321 The MD5 Message-Digest Algorithm */ @@ -90,7 +92,7 @@ MD5_CTX *c; void MD5_Update(c, data, len) MD5_CTX *c; -register unsigned char *data; +register const unsigned char *data; unsigned long len; { register ULONG *p; diff --git a/contrib/bind/lib/dst/prandom.c b/contrib/bind/lib/dst/prandom.c index 031da2e..2236fe8 100644 --- a/contrib/bind/lib/dst/prandom.c +++ b/contrib/bind/lib/dst/prandom.c @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/prandom.c,v 1.10 2001/02/12 23:13:46 marka Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/prandom.c,v 1.12 2001/07/26 01:20:09 marka Exp $"; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -119,9 +119,9 @@ static int unix_cmd(dst_work *work); static int digest_file(dst_work *work); static void force_hash(dst_work *work, prand_hash *hash); -static int do_hash(dst_work *work, prand_hash *hash, u_char *input, +static int do_hash(dst_work *work, prand_hash *hash, const u_char *input, int size); -static int my_digest(dst_work *tmp, u_char *input, int size); +static int my_digest(dst_work *tmp, const u_char *input, int size); static prand_hash *get_hmac_key(int step, int block); static int own_random(dst_work *work); @@ -257,11 +257,10 @@ do_ls(dst_work *work) else if (i==1) /* if starting a new round cut what we accept */ d_round += (tv.tv_sec - d_round)/2; - if (buf.st_atime < d_round) + if (buf.st_atime < (time_t)d_round) return (0); - EREPORT(("do_ls i %d filled %4d in_temp %4d\n", - i-1, work->filled, work->in_temp)); + EREPORT(("do_ls i %d filled %4d\n", i-1, work->filled)); memcpy(tmp_buff, &buf, sizeof(buf)); tb_i += sizeof(buf); @@ -322,8 +321,7 @@ unix_cmd(dst_work *work) if (cmds[cmd_index] == NULL) cmd_index = 0; - EREPORT(("unix_cmd() i %d filled %4d in_temp %4d\n", - cmd_index, work->filled, work->in_temp)); + EREPORT(("unix_cmd() i %d filled %4d\n", cmd_index, work->filled)); pipe = popen(cmds[cmd_index++], "r"); /* execute the command */ while ((n = fread(buffer, sizeof(char), sizeof(buffer), pipe)) > 0) { @@ -334,7 +332,7 @@ unix_cmd(dst_work *work) cnt += do_time(work); } while ((n = fread(buffer, sizeof(char), sizeof(buffer), pipe)) > 0) - NULL; /* drain the pipe */ + (void)NULL; /* drain the pipe */ pclose(pipe); return (cnt); /* read how many bytes where read in */ } @@ -377,7 +375,7 @@ digest_file(dst_work *work) } if (access(name, R_OK) || stat(name, &st)) return (0); /* no such file or not allowed to read it */ - if (strncmp(name, "/proc/", 6) && st.st_mtime < f_round) + if (strncmp(name, "/proc/", 6) && st.st_mtime < (time_t)f_round) return(0); /* file has not changed recently enough */ if (dst_sign_data(SIG_MODE_INIT, work->file_digest, &ctx, NULL, 0, NULL, 0)) { @@ -401,7 +399,7 @@ digest_file(dst_work *work) } else if (i > 0) my_digest(work, buf, i); - my_digest(work, (u_char *)name, strlen(name)); + my_digest(work, (const u_char *)name, strlen(name)); return (no + strlen(name)); } @@ -439,9 +437,10 @@ force_hash(dst_work *work, prand_hash *hash) * */ static int -do_hash(dst_work *work, prand_hash *hash, u_char *input, int size) +do_hash(dst_work *work, prand_hash *hash, const u_char *input, int size) { - u_char *tmp = input, *tp; + const u_char *tmp = input; + u_char *save = NULL, *tp; int i, cnt = size, n, needed, avail, dig, tmp_size = 0; if (cnt <= 0 || input == NULL) @@ -449,7 +448,7 @@ do_hash(dst_work *work, prand_hash *hash, u_char *input, int size) if (hash->step > 1) { /* if using subset of input data */ tmp_size = size / hash->step + 2; - tp = tmp = malloc(tmp_size); + tmp = tp = save = malloc(tmp_size); for (cnt = 0, i = hash->curr; i < size; i += hash->step, cnt++) *(tp++) = input[i]; /* calcutate the starting point in the next input set */ @@ -466,13 +465,13 @@ do_hash(dst_work *work, prand_hash *hash, u_char *input, int size) if (hash->digested >= hash->block) force_hash(work, hash); if (work->needed < work->filled) { - if (tmp != input) - SAFE_FREE2(tmp, tmp_size); + if (tmp_size > 0) + SAFE_FREE2(save, tmp_size); return (1); } } if (tmp_size > 0) - SAFE_FREE2(tmp, tmp_size); + SAFE_FREE2(save, tmp_size); return (0); } @@ -482,7 +481,7 @@ do_hash(dst_work *work, prand_hash *hash, u_char *input, int size) * if work-block needs more data, keep filling with the rest of the input. */ static int -my_digest(dst_work *work, u_char *input, int size) +my_digest(dst_work *work, const u_char *input, int size) { int i, full = 0; @@ -603,8 +602,8 @@ own_random(dst_work *work) * proceed while needed */ while (work->filled < work->needed) { - EREPORT(("own_random r %08x b %6d t %6d f %6d\n", - ran_val, bytes, work->in_temp, work->filled)); + EREPORT(("own_random r %08x b %6d f %6d\n", + ran_val, bytes, work->filled)); /* pick a random number in the range of 0..7 based on that random number * perform some operations that yield random data */ @@ -840,8 +839,10 @@ dst_s_semi_random(u_char *output, int size) i = dst_sign_data(SIG_MODE_ALL, my_key, NULL, (u_char *) counter, hb_size, semi_old, sizeof(semi_old)); +#ifdef REPORT_ERRORS if (i != hb_size) EREPORT(("HMAC SIGNATURE FAILURE %d\n", i)); +#endif cnt++; if (size - out < i) /* Not all data is needed */ semi_loc = i = size - out; diff --git a/contrib/bind/lib/dst/rsaref_link.c b/contrib/bind/lib/dst/rsaref_link.c index a45b6f7..8e09b86 100644 --- a/contrib/bind/lib/dst/rsaref_link.c +++ b/contrib/bind/lib/dst/rsaref_link.c @@ -1,5 +1,5 @@ #ifdef RSAREF -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/rsaref_link.c,v 1.9 2001/04/05 22:00:04 bwelling Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/rsaref_link.c,v 1.10 2001/05/29 05:48:15 marka Exp $"; /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -740,6 +740,19 @@ dst_rsaref_init_random_struct(R_RANDOM_STRUCT * randomstruct) #else +#include "port_before.h" + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <memory.h> +#include <sys/param.h> +#include <sys/time.h> +#include <netinet/in.h> + +#include "dst_internal.h" +#include "port_after.h" int /* rsaref is not available */ dst_rsaref_init() { diff --git a/contrib/bind/lib/dst/support.c b/contrib/bind/lib/dst/support.c index 2dd2a8c..6cc0bd1 100644 --- a/contrib/bind/lib/dst/support.c +++ b/contrib/bind/lib/dst/support.c @@ -1,4 +1,4 @@ -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/support.c,v 1.9.2.1 2001/06/06 21:45:17 marka Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/support.c,v 1.11 2001/05/29 05:48:16 marka Exp $"; /* @@ -241,7 +241,7 @@ dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len) /* compute id */ if (dns_key_rdata[3] == KEY_RSA) /* Algorithm RSA */ - return dst_s_get_int16((u_char *) + return dst_s_get_int16((const u_char *) &dns_key_rdata[rdata_len - 3]); else if (dns_key_rdata[3] == KEY_HMAC_MD5) /* compatibility */ @@ -393,7 +393,7 @@ dst_s_build_filename(char *filename, const char *name, u_int16_t id, return (-1); my_id = id; sprintf(filename, "K%s+%03d+%05d.%s", name, alg, my_id, - (char *) suffix); + (const char *) suffix); if (strrchr(filename, '/')) return (-1); if (strrchr(filename, '\\')) @@ -420,7 +420,7 @@ dst_s_fopen(const char *filename, const char *mode, int perm) { FILE *fp; char pathname[PATH_MAX]; - int plen = sizeof(pathname); + size_t plen = sizeof(pathname); if (*dst_path != '\0') { strcpy(pathname, dst_path); @@ -444,6 +444,8 @@ void dst_s_dump(const int mode, const u_char *data, const int size, const char *msg) { + UNUSED(data); + if (size > 0) { #ifdef LONG_TEST static u_char scratch[1000]; |