Module Name:    src
Committed By:   agc
Date:           Sat May  8 00:33:28 UTC 2010

Modified Files:
        src/crypto/external/bsd/netpgp/dist/src/lib: create.c crypto.h
            keyring.c keyring.h misc.c openssl_crypto.c packet-parse.c packet.h
            reader.c

Log Message:
use hexdump() where possible.

get rid of all traces of dmalloc - it's not used anymore. we can now g/c
initialisation functions which do not do anything.

also get rid of the pkeyid() functions, which just prints a
hexadecimal string


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 \
    src/crypto/external/bsd/netpgp/dist/src/lib/create.c
cvs rdiff -u -r1.18 -r1.19 \
    src/crypto/external/bsd/netpgp/dist/src/lib/crypto.h
cvs rdiff -u -r1.34 -r1.35 \
    src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c
cvs rdiff -u -r1.24 -r1.25 \
    src/crypto/external/bsd/netpgp/dist/src/lib/keyring.h
cvs rdiff -u -r1.28 -r1.29 src/crypto/external/bsd/netpgp/dist/src/lib/misc.c
cvs rdiff -u -r1.21 -r1.22 \
    src/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c
cvs rdiff -u -r1.31 -r1.32 \
    src/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c
cvs rdiff -u -r1.20 -r1.21 \
    src/crypto/external/bsd/netpgp/dist/src/lib/packet.h
cvs rdiff -u -r1.33 -r1.34 \
    src/crypto/external/bsd/netpgp/dist/src/lib/reader.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/netpgp/dist/src/lib/create.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/create.c:1.25 src/crypto/external/bsd/netpgp/dist/src/lib/create.c:1.26
--- src/crypto/external/bsd/netpgp/dist/src/lib/create.c:1.25	Wed Apr 14 00:25:10 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/create.c	Sat May  8 00:33:28 2010
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: create.c,v 1.25 2010/04/14 00:25:10 agc Exp $");
+__RCSID("$NetBSD: create.c,v 1.26 2010/05/08 00:33:28 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -425,21 +425,11 @@
 	__ops_encrypt_init(&crypted);
 
 	if (__ops_get_debug_level(__FILE__)) {
-		unsigned	i2;
-
 		(void) fprintf(stderr, "\nWRITING:\niv=");
-		for (i2 = 0; i2 < __ops_block_size(key->alg); i2++) {
-			(void) fprintf(stderr, "%02x ", key->iv[i2]);
-		}
-		(void) fprintf(stderr, "\n");
-
-		(void) fprintf(stderr, "key=");
-		for (i2 = 0; i2 < CAST_KEY_LENGTH; i2++) {
-			(void) fprintf(stderr, "%02x ", sesskey[i2]);
-		}
-		(void) fprintf(stderr, "\n");
-
-		(void) fprintf(stderr, "turning encryption on...\n");
+		hexdump(stderr, key->iv, __ops_block_size(key->alg), " ");
+		(void) fprintf(stderr, "\nkey=");
+		hexdump(stderr, sesskey, CAST_KEY_LENGTH, " ");
+		(void) fprintf(stderr, "\nturning encryption on...\n");
 	}
 	__ops_push_enc_crypt(output, &crypted);
 

Index: src/crypto/external/bsd/netpgp/dist/src/lib/crypto.h
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/crypto.h:1.18 src/crypto/external/bsd/netpgp/dist/src/lib/crypto.h:1.19
--- src/crypto/external/bsd/netpgp/dist/src/lib/crypto.h:1.18	Wed Apr 14 00:24:00 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/crypto.h	Sat May  8 00:33:28 2010
@@ -116,7 +116,6 @@
 	void				*decrypt_key;
 };
 
-void __ops_crypto_init(void);
 void __ops_crypto_finish(void);
 void __ops_hash_md5(__ops_hash_t *);
 void __ops_hash_sha1(__ops_hash_t *);

Index: src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.34 src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.35
--- src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.34	Wed Apr 14 00:23:09 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c	Sat May  8 00:33:28 2010
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: keyring.c,v 1.34 2010/04/14 00:23:09 agc Exp $");
+__RCSID("$NetBSD: keyring.c,v 1.35 2010/05/08 00:33:28 agc Exp $");
 #endif
 
 #ifdef HAVE_FCNTL_H
@@ -86,6 +86,7 @@
 #include "packet.h"
 #include "crypto.h"
 #include "validate.h"
+#include "netpgpdefs.h"
 #include "netpgpdigest.h"
 
 
@@ -801,17 +802,6 @@
 	keyring->keyc = keyring->keyvsize = 0;
 }
 
-/* simple function to print out a binary keyid */
-void
-__ops_pkeyid(FILE *fp, const uint8_t *keyid, size_t size)
-{
-	size_t	i;
-
-	for (i = 0 ; i < size ; i++) {
-		(void) fprintf(fp, "%02x", keyid[i]);
-	}
-}
-
 /**
    \ingroup HighLevel_KeyringFind
 
@@ -834,10 +824,9 @@
 		if (__ops_get_debug_level(__FILE__)) {
 			(void) fprintf(io->errs,
 				"__ops_getkeybyid: keyring keyid ");
-			__ops_pkeyid(io->errs, keyring->keys[*from].key_id,
-				OPS_KEY_ID_SIZE);
+			hexdump(io->errs, keyring->keys[*from].key_id, OPS_KEY_ID_SIZE, "");
 			(void) fprintf(io->errs, ", keyid ");
-			__ops_pkeyid(io->errs, keyid, OPS_KEY_ID_SIZE);
+			hexdump(io->errs, keyid, OPS_KEY_ID_SIZE, "");
 			(void) fprintf(io->errs, "\n");
 		}
 		if (memcmp(keyring->keys[*from].key_id, keyid,
@@ -915,10 +904,7 @@
 	(void) memset(keyid, 0x0, sizeof(keyid));
 	str2keyid(name, keyid, sizeof(keyid));
 	if (__ops_get_debug_level(__FILE__)) {
-		(void) fprintf(io->outs,
-			"name \"%s\", keyid %02x%02x%02x%02x\n",
-			name,
-			keyid[0], keyid[1], keyid[2], keyid[3]);
+		hexdump(io->outs, keyid, 4, "");
 	}
 	savedstart = *from;
 	if ((kp = __ops_getkeybyid(io, keyring, keyid, from)) != NULL) {

Index: src/crypto/external/bsd/netpgp/dist/src/lib/keyring.h
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/keyring.h:1.24 src/crypto/external/bsd/netpgp/dist/src/lib/keyring.h:1.25
--- src/crypto/external/bsd/netpgp/dist/src/lib/keyring.h:1.24	Tue Mar 16 04:14:29 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/keyring.h	Sat May  8 00:33:28 2010
@@ -114,8 +114,6 @@
 
 int __ops_parse_and_accumulate(__ops_keyring_t *, __ops_stream_t *);
 
-void __ops_pkeyid(FILE *, const uint8_t *, size_t);
-
 int __ops_sprint_keydata(__ops_io_t *, const __ops_keyring_t *,
 			const __ops_key_t *, char **, const char *,
 			const __ops_pubkey_t *, const int);

Index: src/crypto/external/bsd/netpgp/dist/src/lib/misc.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/misc.c:1.28 src/crypto/external/bsd/netpgp/dist/src/lib/misc.c:1.29
--- src/crypto/external/bsd/netpgp/dist/src/lib/misc.c:1.28	Fri Apr  2 15:28:16 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/misc.c	Sat May  8 00:33:28 2010
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: misc.c,v 1.28 2010/04/02 15:28:16 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.29 2010/05/08 00:33:28 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -698,16 +698,10 @@
 	uint8_t		c;
 
 	if (__ops_get_debug_level(__FILE__)) {
-		unsigned	i;
-
-		(void) fprintf(stderr, "__ops_calc_mdc_hash():\n");
-		(void) fprintf(stderr, "\npreamble: ");
-		for (i = 0; i < sz_preamble; i++)
-			(void) fprintf(stderr, " 0x%02x", preamble[i]);
-		(void) fprintf(stderr, "\n");
+		(void) fprintf(stderr, "__ops_calc_mdc_hash():\npreamble: ");
+		hexdump(stderr, preamble, sz_preamble, " ");
 		(void) fprintf(stderr, "\nplaintext (len=%u): ", sz_plaintext);
-		for (i = 0; i < sz_plaintext; i++)
-			(void) fprintf(stderr, " 0x%02x", plaintext[i]);
+		hexdump(stderr, plaintext, sz_plaintext, " ");
 		(void) fprintf(stderr, "\n");
 	}
 	/* init */
@@ -733,13 +727,8 @@
 	hash.finish(&hash, hashed);
 
 	if (__ops_get_debug_level(__FILE__)) {
-		unsigned	i;
-
-		(void) fprintf(stderr, "\nhashed (len=%d): ",
-				OPS_SHA1_HASH_SIZE);
-		for (i = 0; i < OPS_SHA1_HASH_SIZE; i++) {
-			(void) fprintf(stderr, " 0x%02x", hashed[i]);
-		}
+		(void) fprintf(stderr, "\nhashed (len=%d): ", OPS_SHA1_HASH_SIZE);
+		hexdump(stderr, hashed, OPS_SHA1_HASH_SIZE, " ");
 		(void) fprintf(stderr, "\n");
 	}
 }
@@ -1065,24 +1054,10 @@
 
 /**
  * \ingroup HighLevel_Functions
- * \brief Initialises OpenPGP::SDK. To be called before any other OPS function.
- *
- * Initialises OpenPGP::SDK and the underlying openssl library.
- */
-
-void 
-__ops_init(void)
-{
-	__ops_crypto_init();
-}
-
-/**
- * \ingroup HighLevel_Functions
  * \brief Closes down OpenPGP::SDK.
  *
  * Close down OpenPGP:SDK, release any resources under the control of
- * the library. No OpenPGP:SDK function other than __ops_init() should
- * be called after this function.
+ * the library. 
  */
 
 void 

Index: src/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c:1.21 src/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c:1.22
--- src/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c:1.21	Wed Apr 14 00:21:40 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c	Sat May  8 00:33:28 2010
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: openssl_crypto.c,v 1.21 2010/04/14 00:21:40 agc Exp $");
+__RCSID("$NetBSD: openssl_crypto.c,v 1.22 2010/05/08 00:33:28 agc Exp $");
 #endif
 
 #ifdef HAVE_OPENSSL_DSA_H
@@ -538,18 +538,12 @@
 	odsa->pub_key = dsa->y;
 
 	if (__ops_get_debug_level(__FILE__)) {
-		unsigned        i;
-
 		(void) fprintf(stderr, "hash passed in:\n");
-		for (i = 0; i < hash_length; i++) {
-			(void) fprintf(stderr, "%02x ", hash[i]);
-		}
-		(void) fprintf(stderr, "\n");
-		printf("hash_length=%" PRIsize "d\n", hash_length);
-		printf("Q=%d\n", BN_num_bytes(odsa->q));
+		hexdump(stderr, hash, hash_length, " ");
+		(void) fprintf(stderr, "\nhash_length=%" PRIsize "d\n", hash_length);
+		(void) fprintf(stderr, "Q=%d\n", BN_num_bytes(odsa->q));
 	}
-	/* XXX - Flexelint -  Info 732: Loss of sign (assignment) (int to unsigned) */
-	if ((qlen = BN_num_bytes(odsa->q)) < hash_length) {
+	if ((qlen = (unsigned)BN_num_bytes(odsa->q)) < hash_length) {
 		hash_length = qlen;
 	}
 	ret = DSA_do_verify(hash, (int)hash_length, osig, odsa);
@@ -621,7 +615,7 @@
 	int             n;
 
 	orsa = RSA_new();
-	orsa->n = BN_dup(pubkey->n);	/* XXX: do we need n? */
+	orsa->n = BN_dup(pubkey->n);
 	orsa->d = seckey->d;
 	orsa->p = seckey->q;
 	orsa->q = seckey->p;
@@ -745,22 +739,6 @@
 
 /**
    \ingroup Core_Crypto
-   \brief initialises openssl
-   \note Would usually call __ops_init() instead
-   \sa __ops_init()
-*/
-void 
-__ops_crypto_init(void)
-{
-#ifdef DMALLOC
-	CRYPTO_malloc_debug_init();
-	CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
-	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-#endif
-}
-
-/**
-   \ingroup Core_Crypto
    \brief Finalise openssl
    \note Would usually call __ops_finish() instead
    \sa __ops_finish()
@@ -770,9 +748,6 @@
 {
 	CRYPTO_cleanup_all_ex_data();
 	ERR_remove_state((unsigned long)0);
-#ifdef DMALLOC
-	CRYPTO_mem_leaks_fp(stderr);
-#endif
 }
 
 /**

Index: src/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c:1.31 src/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c:1.32
--- src/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c:1.31	Mon Mar  8 07:37:24 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c	Sat May  8 00:33:28 2010
@@ -58,7 +58,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: packet-parse.c,v 1.31 2010/03/08 07:37:24 agc Exp $");
+__RCSID("$NetBSD: packet-parse.c,v 1.32 2010/05/08 00:33:28 agc Exp $");
 #endif
 
 #ifdef HAVE_OPENSSL_CAST_H
@@ -2669,18 +2669,10 @@
 
 		__ops_crypt_any(&decrypt, pkt.u.seckey.alg);
 		if (__ops_get_debug_level(__FILE__)) {
-			unsigned	i;
-
 			fprintf(stderr, "\nREADING:\niv=");
-			for (i = 0;
-			     i < __ops_block_size(pkt.u.seckey.alg);
-			     i++) {
-				fprintf(stderr, "%02x ", pkt.u.seckey.iv[i]);
-			}
+			hexdump(stderr, pkt.u.seckey.iv, __ops_block_size(pkt.u.seckey.alg), " ");
 			fprintf(stderr, "\nkey=");
-			for (i = 0; i < CAST_KEY_LENGTH; i++) {
-				fprintf(stderr, "%02x ", key[i]);
-			}
+			hexdump(stderr, key, CAST_KEY_LENGTH, " ");
 			fprintf(stderr, "\n");
 		}
 		decrypt.set_iv(&decrypt, pkt.u.seckey.iv);

Index: src/crypto/external/bsd/netpgp/dist/src/lib/packet.h
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/packet.h:1.20 src/crypto/external/bsd/netpgp/dist/src/lib/packet.h:1.21
--- src/crypto/external/bsd/netpgp/dist/src/lib/packet.h:1.20	Sat Mar 13 23:30:41 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/packet.h	Sat May  8 00:33:28 2010
@@ -1046,7 +1046,6 @@
 	unsigned        length;
 } __ops_fingerprint_t;
 
-void __ops_init(void);
 void __ops_finish(void);
 void __ops_keyid(uint8_t *, const size_t, const __ops_pubkey_t *);
 void __ops_fingerprint(__ops_fingerprint_t *, const __ops_pubkey_t *);

Index: src/crypto/external/bsd/netpgp/dist/src/lib/reader.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/reader.c:1.33 src/crypto/external/bsd/netpgp/dist/src/lib/reader.c:1.34
--- src/crypto/external/bsd/netpgp/dist/src/lib/reader.c:1.33	Wed Apr 14 00:19:52 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/reader.c	Sat May  8 00:33:28 2010
@@ -54,7 +54,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: reader.c,v 1.33 2010/04/14 00:19:52 agc Exp $");
+__RCSID("$NetBSD: reader.c,v 1.34 2010/05/08 00:33:28 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1611,25 +1611,16 @@
 			return -1;
 		}
 		if (__ops_get_debug_level(__FILE__)) {
-			unsigned	i;
-
 			fprintf(stderr, "\n\nentire SE IP packet (len=%d):\n",
 					decrypted_region.length);
-			for (i = 0; i < decrypted_region.length; i++) {
-				fprintf(stderr, "0x%02x ", buf[i]);
-				if (!((i + 1) % 8))
-					fprintf(stderr, "\n");
-			}
+			hexdump(stderr, buf, decrypted_region.length, " "); 
 			fprintf(stderr, "\n\n");
 		}
 		/* verify leading preamble */
 
 		if (__ops_get_debug_level(__FILE__)) {
-			unsigned	i;
-
 			fprintf(stderr, "\npreamble: ");
-			for (i = 0; i < se_ip->decrypt->blocksize + 2; i++)
-				fprintf(stderr, " 0x%02x", buf[i]);
+			hexdump(stderr, buf, se_ip->decrypt->blocksize , " ");
 			fprintf(stderr, "\n");
 		}
 		b = se_ip->decrypt->blocksize;
@@ -1655,17 +1646,11 @@
 		mdc_hash = mdc + 2;
 
 		if (__ops_get_debug_level(__FILE__)) {
-			unsigned	i;
-
 			fprintf(stderr, "\nplaintext (len=%" PRIsize "u): ",
 				sz_plaintext);
-			for (i = 0; i < sz_plaintext; i++)
-				fprintf(stderr, " 0x%02x", plaintext[i]);
-			fprintf(stderr, "\n");
-
+			hexdump(stderr, plaintext, sz_plaintext, " ");
 			fprintf(stderr, "\nmdc (len=%" PRIsize "u): ", sz_mdc);
-			for (i = 0; i < sz_mdc; i++)
-				fprintf(stderr, " 0x%02x", mdc[i]);
+			hexdump(stderr, mdc, sz_mdc, " ");
 			fprintf(stderr, "\n");
 		}
 		__ops_calc_mdc_hash(preamble, sz_preamble, plaintext,

Reply via email to