diff --git a/agent/ChangeLog b/agent/ChangeLog index 78b4871bb..4c7df8b6d 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,5 +1,8 @@ 2007-08-22 Werner Koch + * 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. diff --git a/agent/findkey.c b/agent/findkey.c index 35254c433..d8dc52696 100644 --- a/agent/findkey.c +++ b/agent/findkey.c @@ -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 @@ agent_write_private_key (const unsigned char *grip, 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 diff --git a/jnlib/logging.h b/jnlib/logging.h index a54e2d50d..9da46e29e 100644 --- a/jnlib/logging.h +++ b/jnlib/logging.h @@ -71,6 +71,11 @@ void log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); 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); diff --git a/sm/ChangeLog b/sm/ChangeLog index 8d88b7e85..8bcc22a0d 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,5 +1,7 @@ 2007-08-22 Werner Koch + * certreqgen.c (create_request): Replace open coding by bin2hex. + * certreqgen-ui.c (gpgsm_gencertreq_tty): Use es_fopenmem. 2007-08-21 Werner Koch diff --git a/sm/certreqgen.c b/sm/certreqgen.c index 4acd033b4..30b8179fd 100644 --- a/sm/certreqgen.c +++ b/sm/certreqgen.c @@ -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 @@ create_request (ctrl_t ctrl, 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,