Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/lib use hexdump() where ...
details: https://anonhg.NetBSD.org/src/rev/540122a4e93c
branches: trunk
changeset: 754661:540122a4e93c
user: agc <agc%NetBSD.org@localhost>
date: Sat May 08 00:33:28 2010 +0000
description:
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
diffstat:
crypto/external/bsd/netpgp/dist/src/lib/create.c | 20 ++------
crypto/external/bsd/netpgp/dist/src/lib/crypto.h | 1 -
crypto/external/bsd/netpgp/dist/src/lib/keyring.c | 24 ++-------
crypto/external/bsd/netpgp/dist/src/lib/keyring.h | 2 -
crypto/external/bsd/netpgp/dist/src/lib/misc.c | 39 ++-------------
crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c | 37 ++------------
crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c | 14 +----
crypto/external/bsd/netpgp/dist/src/lib/packet.h | 1 -
crypto/external/bsd/netpgp/dist/src/lib/reader.c | 25 ++--------
9 files changed, 31 insertions(+), 132 deletions(-)
diffs (truncated from 379 to 300 lines):
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/create.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/create.c Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/create.c Sat May 08 00:33:28 2010 +0000
@@ -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);
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/crypto.h
--- a/crypto/external/bsd/netpgp/dist/src/lib/crypto.h Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/crypto.h Sat May 08 00:33:28 2010 +0000
@@ -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 *);
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/keyring.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Sat May 08 00:33:28 2010 +0000
@@ -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) {
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/keyring.h
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.h Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.h Sat May 08 00:33:28 2010 +0000
@@ -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);
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/misc.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/misc.c Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/misc.c Sat May 08 00:33:28 2010 +0000
@@ -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
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/openssl_crypto.c Sat May 08 00:33:28 2010 +0000
@@ -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
}
/**
diff -r a8a50d9aa8d1 -r 540122a4e93c crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c Sat May 08 00:31:07 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/packet-parse.c Sat May 08 00:33:28 2010 +0000
@@ -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), " ");
Home |
Main Index |
Thread Index |
Old Index