[svn] GnuPG - r4566 - in trunk: agent jnlib sm

svn author wk cvs at cvs.gnupg.org
Wed Aug 22 22:37:03 CEST 2007


Author: wk
Date: 2007-08-22 22:36:33 +0200 (Wed, 22 Aug 2007)
New Revision: 4566

Modified:
   trunk/agent/ChangeLog
   trunk/agent/findkey.c
   trunk/jnlib/logging.h
   trunk/sm/ChangeLog
   trunk/sm/certreqgen.c
Log:
Fixed creation of private keys under W32.
Minor code cleanups.


Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2007-08-22 10:55:07 UTC (rev 4565)
+++ trunk/agent/ChangeLog	2007-08-22 20:36:33 UTC (rev 4566)
@@ -1,5 +1,8 @@
 2007-08-22  Werner Koch  <wk at g10code.com>
 
+	* findkey.c (O_BINARY): Make sure it is defined.
+	(agent_write_private_key): Use O_BINARY
+
 	* protect-tool.c (import_p12_file): Add hack to allow importing of
 	gnupg 2.0.4 generated files.
 

Modified: trunk/agent/findkey.c
===================================================================
--- trunk/agent/findkey.c	2007-08-22 10:55:07 UTC (rev 4565)
+++ trunk/agent/findkey.c	2007-08-22 20:36:33 UTC (rev 4566)
@@ -32,6 +32,10 @@
 
 #include "agent.h"
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 /* Helper to pass data to the check callback of the unprotect function. */
 struct try_unprotect_arg_s {
   const unsigned char *protected_key;
@@ -70,8 +74,8 @@
      POSIX (GNU provides the "x" opentype for fopen, however, this is
      not portable).  Thus, we use the more flexible open function and
      then use fdopen to obtain a stream. */
-  fd = open (fname, force? (O_CREAT | O_TRUNC | O_WRONLY)
-                         : (O_CREAT | O_EXCL | O_WRONLY),
+  fd = open (fname, force? (O_CREAT | O_TRUNC | O_WRONLY | O_BINARY)
+                         : (O_CREAT | O_EXCL | O_WRONLY | O_BINARY),
              S_IRUSR | S_IWUSR 
 #ifndef HAVE_W32_SYSTEM
                  | S_IRGRP 

Modified: trunk/jnlib/logging.h
===================================================================
--- trunk/jnlib/logging.h	2007-08-22 10:55:07 UTC (rev 4565)
+++ trunk/jnlib/logging.h	2007-08-22 20:36:33 UTC (rev 4566)
@@ -71,6 +71,11 @@
 void log_info( const char *fmt, ... )	JNLIB_GCC_A_PRINTF(1,2);
 void log_debug( const char *fmt, ... )	JNLIB_GCC_A_PRINTF(1,2);
 void log_printf( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
+
+/* Print a hexdump of BUFFER.  With TEXT passes as NULL print just the
+   raw dump, with TEXT being an empty string, print a trailing
+   linefeed, otherwise print an entire debug line with TEXT followed
+   by the hexdump and a final LF.  */
 void log_printhex (const char *text, const void *buffer, size_t length);
 
 

Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2007-08-22 10:55:07 UTC (rev 4565)
+++ trunk/sm/ChangeLog	2007-08-22 20:36:33 UTC (rev 4566)
@@ -1,5 +1,7 @@
 2007-08-22  Werner Koch  <wk at g10code.com>
 
+	* certreqgen.c (create_request): Replace open coding by bin2hex.
+
 	* certreqgen-ui.c (gpgsm_gencertreq_tty): Use es_fopenmem.
 
 2007-08-21  Werner Koch  <wk at g10code.com>

Modified: trunk/sm/certreqgen.c
===================================================================
--- trunk/sm/certreqgen.c	2007-08-22 10:55:07 UTC (rev 4565)
+++ trunk/sm/certreqgen.c	2007-08-22 20:36:33 UTC (rev 4566)
@@ -1,5 +1,5 @@
 /* certreqgen.c - Generate a key and a certification request
- *	Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -786,8 +786,7 @@
               goto leave;
             }
           gcry_sexp_release (s_pkey);
-          for (n=0; n < 20; n++)
-            sprintf (hexgrip+n*2, "%02X", grip[n]);
+          bin2hex (grip, 20, hexgrip);
 
           if (carddirect)
             rc = gpgsm_scd_pksign (ctrl, carddirect, NULL,




More information about the Gnupg-commits mailing list