From 0f0a8472d7b42b34e7aef276f765fd3ef76e8ae4 Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Tue, 10 May 2005 17:02:05 +0000
Subject: [PATCH] * add a "label" argument to printhex() * make some vars
 static in random.c

--HG--
extra : convert_revision : ef941a918e42e8af23b132946f44e6836a327e71
---
 dbutil.c | 3 ++-
 dbutil.h | 2 +-
 random.c | 6 +++---
 rsa.c    | 7 ++++---
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/dbutil.c b/dbutil.c
index 5f3a45df..45c720e3 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -430,10 +430,11 @@ char* getaddrhostname(struct sockaddr_storage * addr) {
 }
 
 #ifdef DEBUG_TRACE
-void printhex(unsigned char* buf, int len) {
+void printhex(const char * label, const unsigned char * buf, int len) {
 
 	int i;
 
+	fprintf(stderr, "%s\n", label);
 	for (i = 0; i < len; i++) {
 		fprintf(stderr, "%02x", buf[i]);
 		if (i % 16 == 15) {
diff --git a/dbutil.h b/dbutil.h
index 6363f70d..d9049494 100644
--- a/dbutil.h
+++ b/dbutil.h
@@ -41,7 +41,7 @@ void dropbear_close(const char* format, ...);
 void dropbear_log(int priority, const char* format, ...);
 #ifdef DEBUG_TRACE
 void dropbear_trace(const char* format, ...);
-void printhex(unsigned char* buf, int len);
+void printhex(const char * label, const unsigned char * buf, int len);
 extern int debug_trace;
 #endif
 char * stripcontrol(const char * text);
diff --git a/random.c b/random.c
index 8012148b..d58c8a83 100644
--- a/random.c
+++ b/random.c
@@ -27,13 +27,13 @@
 #include "dbutil.h"
 #include "bignum.h"
 
-int donerandinit = 0;
+static int donerandinit = 0;
 
 /* this is used to generate unique output from the same hashpool */
-unsigned int counter = 0;
+static unsigned int counter = 0;
 #define MAX_COUNTER 1000000/* the max value for the counter, so it won't loop */
 
-unsigned char hashpool[SHA1_HASH_SIZE];
+static unsigned char hashpool[SHA1_HASH_SIZE];
 
 #define INIT_SEED_SIZE 32 /* 256 bits */
 
diff --git a/rsa.c b/rsa.c
index 8b243602..f86fdd97 100644
--- a/rsa.c
+++ b/rsa.c
@@ -333,7 +333,7 @@ void buf_put_rsa_sign(buffer* buf, rsa_key *key, const unsigned char* data,
 	mp_clear(&rsa_s);
 
 #if defined(DEBUG_RSA) && defined(DEBUG_TRACE)
-	printhex(buf->data, buf->len);
+	printhex("RSA sig", buf->data, buf->len);
 #endif
 	
 
@@ -357,10 +357,11 @@ static void rsa_pad_em(rsa_key * key,
 		mp_int * rsa_em) {
 
 	/* ASN1 designator (including the 0x00 preceding) */
-	const char rsa_asn1_magic[] = 
+	const unsigned char rsa_asn1_magic[] = 
 		{0x00, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 
 		 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14};
-#define RSA_ASN1_MAGIC_LEN 16
+	const unsigned int RSA_ASN1_MAGIC_LEN = 16;
+
 	buffer * rsa_EM = NULL;
 	hash_state hs;
 	unsigned int nsize;
-- 
GitLab