mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Finished the bulk of changes to use estream in most places instead of
stdio.
This commit is contained in:
parent
37870234a1
commit
fb2ba98963
@ -1,3 +1,7 @@
|
||||
2010-03-12 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac (AC_INIT): Prepare for using git.
|
||||
|
||||
2010-03-10 Werner Koch <wk@g10code.com>
|
||||
|
||||
* jnlib/: Move all code to common/.
|
||||
|
@ -1,10 +1,26 @@
|
||||
2010-03-12 Werner Koch <wk@g10code.com>
|
||||
|
||||
* status.h (STATUS_ENTER): New.
|
||||
|
||||
* ttyio.c (tty_fprintf): Change to use estream.
|
||||
|
||||
* miscellaneous.c (print_utf8_string): Rename to print_utf8_buffer
|
||||
and change FP arg to an estream. Change all callers.
|
||||
(print_utf8_string2): Ditto; new name is to print_utf8_buffer2.
|
||||
|
||||
2010-03-11 Werner Koch <wk@g10code.com>
|
||||
|
||||
* miscellaneous.c (print_string): Remove.
|
||||
|
||||
* estream.c (es_setvbuf): Fix parameter check.
|
||||
(es_set_buffering): Allow a SIZE of 0.
|
||||
* asshelp.c (setup_libassuan_logging, my_libassuan_log_handler): New.
|
||||
* logging.c (do_logv): Add arg IGNORE_ARG_PTR. Change all callers.
|
||||
(log_string): New.
|
||||
(log_flush): New.
|
||||
(set_file_fd): Simplify by using estreams es_stderr.
|
||||
|
||||
* estream.h (es_stdout, es_stderr, es_stdin): New.
|
||||
|
||||
2010-03-10 Werner Koch <wk@g10code.com>
|
||||
|
||||
|
@ -42,6 +42,8 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
|
||||
{
|
||||
unsigned int dbgval;
|
||||
|
||||
(void)ctx;
|
||||
|
||||
if (cat != ASSUAN_LOG_CONTROL)
|
||||
return 0; /* We only want the control channel messages. */
|
||||
dbgval = hook? *(unsigned int*)hook : 0;
|
||||
|
138
common/estream.c
138
common/estream.c
@ -213,6 +213,8 @@ struct estream_internal
|
||||
unsigned int eof: 1;
|
||||
} indicators;
|
||||
unsigned int deallocate_buffer: 1;
|
||||
unsigned int is_stdstream:1; /* This is a standard stream. */
|
||||
unsigned int stdstream_fd:2; /* 0, 1 or 2 for a standard stream. */
|
||||
unsigned int print_err: 1; /* Error in print_fun_writer. */
|
||||
int print_errno; /* Errno from print_fun_writer. */
|
||||
size_t print_ntotal; /* Bytes written from in print_fun_writer. */
|
||||
@ -302,9 +304,11 @@ mem_free (void *p)
|
||||
* List manipulation.
|
||||
*/
|
||||
|
||||
/* Add STREAM to the list of registered stream objects. */
|
||||
/* Add STREAM to the list of registered stream objects. If
|
||||
WITH_LOCKED_LIST is true we assumed that the list of streams is
|
||||
already locked. */
|
||||
static int
|
||||
es_list_add (estream_t stream)
|
||||
es_list_add (estream_t stream, int with_locked_list)
|
||||
{
|
||||
estream_list_t list_obj;
|
||||
int ret;
|
||||
@ -314,14 +318,16 @@ es_list_add (estream_t stream)
|
||||
ret = -1;
|
||||
else
|
||||
{
|
||||
ESTREAM_LIST_LOCK;
|
||||
if (!with_locked_list)
|
||||
ESTREAM_LIST_LOCK;
|
||||
list_obj->car = stream;
|
||||
list_obj->cdr = estream_list;
|
||||
list_obj->prev_cdr = &estream_list;
|
||||
if (estream_list)
|
||||
estream_list->prev_cdr = &list_obj->cdr;
|
||||
estream_list = list_obj;
|
||||
ESTREAM_LIST_UNLOCK;
|
||||
if (!with_locked_list)
|
||||
ESTREAM_LIST_UNLOCK;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
@ -330,11 +336,12 @@ es_list_add (estream_t stream)
|
||||
|
||||
/* Remove STREAM from the list of registered stream objects. */
|
||||
static void
|
||||
es_list_remove (estream_t stream)
|
||||
es_list_remove (estream_t stream, int with_locked_list)
|
||||
{
|
||||
estream_list_t list_obj;
|
||||
|
||||
ESTREAM_LIST_LOCK;
|
||||
if (!with_locked_list)
|
||||
ESTREAM_LIST_LOCK;
|
||||
for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr)
|
||||
if (list_obj->car == stream)
|
||||
{
|
||||
@ -344,7 +351,8 @@ es_list_remove (estream_t stream)
|
||||
mem_free (list_obj);
|
||||
break;
|
||||
}
|
||||
ESTREAM_LIST_UNLOCK;
|
||||
if (!with_locked_list)
|
||||
ESTREAM_LIST_UNLOCK;
|
||||
}
|
||||
|
||||
/* Type of an stream-iterator-function. */
|
||||
@ -1211,6 +1219,8 @@ es_initialize (estream_t stream,
|
||||
stream->intern->print_fp = NULL;
|
||||
stream->intern->indicators.err = 0;
|
||||
stream->intern->indicators.eof = 0;
|
||||
stream->intern->is_stdstream = 0;
|
||||
stream->intern->stdstream_fd = 0;
|
||||
stream->intern->deallocate_buffer = 0;
|
||||
|
||||
stream->data_len = 0;
|
||||
@ -1219,7 +1229,7 @@ es_initialize (estream_t stream,
|
||||
stream->unread_data_len = 0;
|
||||
/* Depending on the modeflags we set whether we start in writing or
|
||||
reading mode. This is required in case we are working on a
|
||||
wronly stream which is not seeekable (like stdout). Without this
|
||||
stream which is not seeekable (like stdout). Without this
|
||||
pre-initialization we would do a seek at the first write call and
|
||||
as this will fail no utput will be delivered. */
|
||||
if ((modeflags & O_WRONLY) || (modeflags & O_RDWR) )
|
||||
@ -1258,7 +1268,8 @@ es_deinitialize (estream_t stream)
|
||||
/* Create a new stream object, initialize it. */
|
||||
static int
|
||||
es_create (estream_t *stream, void *cookie, int fd,
|
||||
es_cookie_io_functions_t functions, unsigned int modeflags)
|
||||
es_cookie_io_functions_t functions, unsigned int modeflags,
|
||||
int with_locked_list)
|
||||
{
|
||||
estream_internal_t stream_internal_new;
|
||||
estream_t stream_new;
|
||||
@ -1290,7 +1301,7 @@ es_create (estream_t *stream, void *cookie, int fd,
|
||||
ESTREAM_MUTEX_INITIALIZE (stream_new->intern->lock);
|
||||
es_initialize (stream_new, cookie, fd, functions, modeflags);
|
||||
|
||||
err = es_list_add (stream_new);
|
||||
err = es_list_add (stream_new, with_locked_list);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
@ -1312,13 +1323,13 @@ es_create (estream_t *stream, void *cookie, int fd,
|
||||
|
||||
/* Deinitialize a stream object and destroy it. */
|
||||
static int
|
||||
es_destroy (estream_t stream)
|
||||
es_destroy (estream_t stream, int with_locked_list)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (stream)
|
||||
{
|
||||
es_list_remove (stream);
|
||||
es_list_remove (stream, with_locked_list);
|
||||
err = es_deinitialize (stream);
|
||||
mem_free (stream->intern);
|
||||
mem_free (stream);
|
||||
@ -1838,7 +1849,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
|
||||
goto out;
|
||||
|
||||
err = es_create (&line_stream, line_stream_cookie, -1,
|
||||
estream_functions_mem, O_RDWR);
|
||||
estream_functions_mem, O_RDWR, 0);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
@ -1923,7 +1934,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
|
||||
out:
|
||||
|
||||
if (line_stream)
|
||||
es_destroy (line_stream);
|
||||
es_destroy (line_stream, 0);
|
||||
else if (line_stream_cookie)
|
||||
es_func_mem_destroy (line_stream_cookie);
|
||||
|
||||
@ -2122,7 +2133,7 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
|
||||
goto out;
|
||||
|
||||
create_called = 1;
|
||||
err = es_create (&stream, cookie, fd, estream_functions_file, modeflags);
|
||||
err = es_create (&stream, cookie, fd, estream_functions_file, modeflags, 0);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
@ -2162,7 +2173,7 @@ es_mopen (unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len,
|
||||
goto out;
|
||||
|
||||
create_called = 1;
|
||||
err = es_create (&stream, cookie, -1, estream_functions_mem, modeflags);
|
||||
err = es_create (&stream, cookie, -1, estream_functions_mem, modeflags, 0);
|
||||
|
||||
out:
|
||||
|
||||
@ -2193,7 +2204,7 @@ es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode)
|
||||
memlimit))
|
||||
return NULL;
|
||||
|
||||
if (es_create (&stream, cookie, -1, estream_functions_mem, modeflags))
|
||||
if (es_create (&stream, cookie, -1, estream_functions_mem, modeflags, 0))
|
||||
(*estream_functions_mem.func_close) (cookie);
|
||||
|
||||
return stream;
|
||||
@ -2217,7 +2228,7 @@ es_fopencookie (void *ES__RESTRICT cookie,
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = es_create (&stream, cookie, -1, functions, modeflags);
|
||||
err = es_create (&stream, cookie, -1, functions, modeflags, 0);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
@ -2249,7 +2260,8 @@ do_fdopen (int filedes, const char *mode, int no_close)
|
||||
goto out;
|
||||
|
||||
create_called = 1;
|
||||
err = es_create (&stream, cookie, filedes, estream_functions_fd, modeflags);
|
||||
err = es_create (&stream, cookie, filedes, estream_functions_fd,
|
||||
modeflags, 0);
|
||||
|
||||
out:
|
||||
|
||||
@ -2274,7 +2286,7 @@ es_fdopen_nc (int filedes, const char *mode)
|
||||
|
||||
|
||||
estream_t
|
||||
do_fpopen (FILE *fp, const char *mode, int no_close)
|
||||
do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list)
|
||||
{
|
||||
unsigned int modeflags;
|
||||
int create_called;
|
||||
@ -2298,7 +2310,7 @@ do_fpopen (FILE *fp, const char *mode, int no_close)
|
||||
|
||||
create_called = 1;
|
||||
err = es_create (&stream, cookie, fp? fileno (fp):-1, estream_functions_fp,
|
||||
modeflags);
|
||||
modeflags, with_locked_list);
|
||||
|
||||
out:
|
||||
|
||||
@ -2320,7 +2332,7 @@ do_fpopen (FILE *fp, const char *mode, int no_close)
|
||||
estream_t
|
||||
es_fpopen (FILE *fp, const char *mode)
|
||||
{
|
||||
return do_fpopen (fp, mode, 0);
|
||||
return do_fpopen (fp, mode, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -2328,7 +2340,52 @@ es_fpopen (FILE *fp, const char *mode)
|
||||
estream_t
|
||||
es_fpopen_nc (FILE *fp, const char *mode)
|
||||
{
|
||||
return do_fpopen (fp, mode, 1);
|
||||
return do_fpopen (fp, mode, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
estream_t
|
||||
_es_get_std_stream (int fd)
|
||||
{
|
||||
estream_list_t list_obj;
|
||||
estream_t stream = NULL;
|
||||
|
||||
fd %= 3; /* We only allow 0, 1 or 2 but we don't want to return an error. */
|
||||
ESTREAM_LIST_LOCK;
|
||||
for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr)
|
||||
if (list_obj->car->intern->is_stdstream
|
||||
&& list_obj->car->intern->stdstream_fd == fd)
|
||||
{
|
||||
stream = list_obj->car;
|
||||
break;
|
||||
}
|
||||
if (!stream)
|
||||
{
|
||||
/* Standard stream not yet created - do it now. */
|
||||
if (!fd)
|
||||
stream = do_fpopen (stdin, "r", 1, 1);
|
||||
else if (fd == 1)
|
||||
stream = do_fpopen (stdout, "a", 1, 1);
|
||||
else
|
||||
stream = do_fpopen (stderr, "a", 1, 1);
|
||||
|
||||
if (!stream) /* Fallback: Create a bit bucket. */
|
||||
{
|
||||
stream = do_fpopen (NULL, fd? "a":"r", 0, 1);
|
||||
if (!stream)
|
||||
{
|
||||
fprintf (stderr, "fatal: error creating a dummy estream"
|
||||
" for %d: %s\n", fd, strerror (errno));
|
||||
abort();
|
||||
}
|
||||
}
|
||||
stream->intern->is_stdstream = 1;
|
||||
stream->intern->stdstream_fd = fd;
|
||||
if (fd == 2)
|
||||
es_set_buffering (stream, NULL, _IOLBF, 0);
|
||||
}
|
||||
ESTREAM_LIST_UNLOCK;
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
@ -2370,7 +2427,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
|
||||
if (create_called)
|
||||
es_func_fd_destroy (cookie);
|
||||
|
||||
es_destroy (stream);
|
||||
es_destroy (stream, 0);
|
||||
stream = NULL;
|
||||
}
|
||||
else
|
||||
@ -2381,7 +2438,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
|
||||
/* FIXME? We don't support re-opening at the moment. */
|
||||
_set_errno (EINVAL);
|
||||
es_deinitialize (stream);
|
||||
es_destroy (stream);
|
||||
es_destroy (stream, 0);
|
||||
stream = NULL;
|
||||
}
|
||||
|
||||
@ -2394,7 +2451,7 @@ es_fclose (estream_t stream)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = es_destroy (stream);
|
||||
err = es_destroy (stream, 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -2496,6 +2553,23 @@ es_clearerr (estream_t stream)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
do_fflush (estream_t stream)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (stream->flags.writing)
|
||||
err = es_flush (stream);
|
||||
else
|
||||
{
|
||||
es_empty (stream);
|
||||
err = 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
es_fflush (estream_t stream)
|
||||
{
|
||||
@ -2504,17 +2578,11 @@ es_fflush (estream_t stream)
|
||||
if (stream)
|
||||
{
|
||||
ESTREAM_LOCK (stream);
|
||||
if (stream->flags.writing)
|
||||
err = es_flush (stream);
|
||||
else
|
||||
{
|
||||
es_empty (stream);
|
||||
err = 0;
|
||||
}
|
||||
err = do_fflush (stream);
|
||||
ESTREAM_UNLOCK (stream);
|
||||
}
|
||||
else
|
||||
err = es_list_iterate (es_fflush);
|
||||
err = es_list_iterate (do_fflush);
|
||||
|
||||
return err ? EOF : 0;
|
||||
}
|
||||
@ -3186,7 +3254,7 @@ es_tmpfile (void)
|
||||
goto out;
|
||||
|
||||
create_called = 1;
|
||||
err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags);
|
||||
err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags, 0);
|
||||
|
||||
out:
|
||||
|
||||
|
@ -80,6 +80,7 @@
|
||||
#define es_fdopen_nc _ESTREAM_PREFIX(es_fdopen_nc)
|
||||
#define es_fpopen _ESTREAM_PREFIX(es_fpopen)
|
||||
#define es_fpopen_nc _ESTREAM_PREFIX(es_fpopen_nc)
|
||||
#define _es_get_std_stream _ESTREAM_PREFIX(_es_get_std_stream)
|
||||
#define es_freopen _ESTREAM_PREFIX(es_freopen)
|
||||
#define es_fopencookie _ESTREAM_PREFIX(es_fopencookie)
|
||||
#define es_fclose _ESTREAM_PREFIX(es_fclose)
|
||||
@ -250,6 +251,13 @@ int es_fclose (estream_t stream);
|
||||
int es_fileno (estream_t stream);
|
||||
int es_fileno_unlocked (estream_t stream);
|
||||
|
||||
estream_t _es_get_std_stream (int fd);
|
||||
|
||||
#define es_stdin _es_get_std_stream (0)
|
||||
#define es_stdout _es_get_std_stream (1)
|
||||
#define es_stderr _es_get_std_stream (2)
|
||||
|
||||
|
||||
void es_flockfile (estream_t stream);
|
||||
int es_ftrylockfile (estream_t stream);
|
||||
void es_funlockfile (estream_t stream);
|
||||
|
@ -283,32 +283,7 @@ set_file_fd (const char *name, int fd)
|
||||
|
||||
/* On error default to a stderr based estream. */
|
||||
if (!fp)
|
||||
{
|
||||
fp = es_fpopen (stderr, "a");
|
||||
if (fp)
|
||||
{
|
||||
if (name)
|
||||
es_fprintf (fp, "failed to open log file `%s': %s\n",
|
||||
name, strerror (errno));
|
||||
else
|
||||
es_fprintf (fp, "failed to fdopen file descriptor %d: %s\n",
|
||||
fd, strerror (errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "failed to use stderr as log stream: %s\n",
|
||||
strerror (errno));
|
||||
/* No way to log something. Create a dummy estream so that
|
||||
there is something we can use. */
|
||||
fp = es_fpopen (NULL, "a");
|
||||
if (!fp)
|
||||
{
|
||||
fprintf (stderr, "fatal: failed to open dummy stream: %s\n",
|
||||
strerror (errno));
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
fp = es_stderr;
|
||||
|
||||
es_setvbuf (fp, NULL, _IOLBF, 0);
|
||||
|
||||
@ -605,6 +580,16 @@ log_printf (const char *fmt, ...)
|
||||
}
|
||||
|
||||
|
||||
/* Flush the log - this is useful to make sure that the trailing
|
||||
linefeed has been printed. */
|
||||
void
|
||||
log_flush (void)
|
||||
{
|
||||
volatile va_list dummy_arg_ptr;
|
||||
do_logv (JNLIB_LOG_CONT, 1, NULL, dummy_arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
/* Print a hexdump of BUFFER. With TEXT of NULL print just the raw
|
||||
dump, with TEXT just an empty string, print a trailing linefeed,
|
||||
otherwise print an entire debug line. */
|
||||
|
@ -75,6 +75,7 @@ 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);
|
||||
void log_flush (void);
|
||||
|
||||
/* Print a hexdump of BUFFER. With TEXT passes as NULL print just the
|
||||
raw dump, with TEXT being an empty string, print a trailing
|
||||
|
@ -117,23 +117,22 @@ print_fname_stdin (const char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
/* fixme: Globally replace it by print_sanitized_buffer. */
|
||||
void
|
||||
print_string( FILE *fp, const byte *p, size_t n, int delim )
|
||||
{
|
||||
print_sanitized_buffer (fp, p, n, delim);
|
||||
}
|
||||
|
||||
void
|
||||
print_utf8_string2 ( FILE *fp, const byte *p, size_t n, int delim )
|
||||
print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim)
|
||||
{
|
||||
print_sanitized_utf8_buffer (fp, p, n, delim);
|
||||
char tmp[2];
|
||||
|
||||
tmp[0] = delim;
|
||||
tmp[1] = 0;
|
||||
es_write_sanitized_utf8_buffer (stream, p, n, tmp, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_utf8_string( FILE *fp, const byte *p, size_t n )
|
||||
print_utf8_buffer (estream_t stream, const void *p, size_t n)
|
||||
{
|
||||
print_utf8_string2 (fp, p, n, 0);
|
||||
es_write_sanitized_utf8_buffer (stream, p, n, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Write LENGTH bytes of BUFFER to FP as a hex encoded string.
|
||||
|
@ -126,7 +126,8 @@ enum
|
||||
STATUS_TRUNCATED,
|
||||
STATUS_MOUNTPOINT,
|
||||
|
||||
STATUS_ERROR
|
||||
STATUS_ERROR,
|
||||
STATUS_SUCCESS
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ttyio.c - tty i/O functions
|
||||
* Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2006,2007,
|
||||
* 2009 Free Software Foundation, Inc.
|
||||
* 2009, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
@ -244,14 +244,14 @@ tty_printf( const char *fmt, ... )
|
||||
/* Same as tty_printf but if FP is not NULL, behave like a regular
|
||||
fprintf. */
|
||||
void
|
||||
tty_fprintf (FILE *fp, const char *fmt, ... )
|
||||
tty_fprintf (estream_t fp, const char *fmt, ... )
|
||||
{
|
||||
va_list arg_ptr;
|
||||
|
||||
if (fp)
|
||||
{
|
||||
va_start (arg_ptr, fmt) ;
|
||||
vfprintf (fp, fmt, arg_ptr );
|
||||
es_vfprintf (fp, fmt, arg_ptr );
|
||||
va_end (arg_ptr);
|
||||
return;
|
||||
}
|
||||
@ -259,32 +259,32 @@ tty_fprintf (FILE *fp, const char *fmt, ... )
|
||||
if (no_terminal)
|
||||
return;
|
||||
|
||||
if( !initialized )
|
||||
init_ttyfp();
|
||||
if (!initialized)
|
||||
init_ttyfp ();
|
||||
|
||||
va_start( arg_ptr, fmt ) ;
|
||||
va_start (arg_ptr, fmt);
|
||||
#ifdef _WIN32
|
||||
{
|
||||
char *buf = NULL;
|
||||
int n;
|
||||
DWORD nwritten;
|
||||
|
||||
n = vasprintf(&buf, fmt, arg_ptr);
|
||||
if( !buf )
|
||||
log_bug("vasprintf() failed\n");
|
||||
|
||||
if( !WriteConsoleA( con.out, buf, n, &nwritten, NULL ) )
|
||||
log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() );
|
||||
if( n != nwritten )
|
||||
log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten );
|
||||
last_prompt_len += n;
|
||||
xfree (buf);
|
||||
}
|
||||
{
|
||||
char *buf = NULL;
|
||||
int n;
|
||||
DWORD nwritten;
|
||||
|
||||
n = vasprintf(&buf, fmt, arg_ptr);
|
||||
if (!buf)
|
||||
log_bug("vasprintf() failed\n");
|
||||
|
||||
if (!WriteConsoleA( con.out, buf, n, &nwritten, NULL ))
|
||||
log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() );
|
||||
if (n != nwritten)
|
||||
log_fatal("WriteConsole failed: %d != %d\n", n, (int)nwritten );
|
||||
last_prompt_len += n;
|
||||
xfree (buf);
|
||||
}
|
||||
#else
|
||||
last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ;
|
||||
fflush(ttyfp);
|
||||
last_prompt_len += vfprintf(ttyfp,fmt,arg_ptr) ;
|
||||
fflush(ttyfp);
|
||||
#endif
|
||||
va_end(arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,13 +28,13 @@ int tty_batchmode (int onoff);
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
|
||||
void tty_printf (const char *fmt, ... )
|
||||
__attribute__ ((format (printf,1,2)));
|
||||
void tty_fprintf (FILE *fp, const char *fmt, ... )
|
||||
void tty_fprintf (estream_t fp, const char *fmt, ... )
|
||||
__attribute__ ((format (printf,2,3)));
|
||||
char *tty_getf (const char *promptfmt, ... )
|
||||
__attribute__ ((format (printf,1,2)));
|
||||
#else
|
||||
void tty_printf (const char *fmt, ... );
|
||||
void tty_fprintf (FILE *fp, const char *fmt, ... );
|
||||
void tty_fprintf (estream_t fp, const char *fmt, ... );
|
||||
char *tty_getf (const char *promptfmt, ... );
|
||||
#endif
|
||||
void tty_print_string (const unsigned char *p, size_t n);
|
||||
|
@ -278,9 +278,8 @@ char *xtryasprintf (const char *fmt, ...) JNLIB_GCC_A_PRINTF(1,2);
|
||||
|
||||
const char *print_fname_stdout (const char *s);
|
||||
const char *print_fname_stdin (const char *s);
|
||||
void print_string (FILE *fp, const byte *p, size_t n, int delim);
|
||||
void print_utf8_string2 ( FILE *fp, const byte *p, size_t n, int delim);
|
||||
void print_utf8_string (FILE *fp, const byte *p, size_t n);
|
||||
void print_utf8_buffer2 (estream_t fp, const void *p, size_t n, int delim);
|
||||
void print_utf8_buffer (estream_t fp, const void *p, size_t n);
|
||||
void print_hexstring (FILE *fp, const void *buffer, size_t length,
|
||||
int reserved);
|
||||
char *make_printable_string (const void *p, size_t n, int delim);
|
||||
|
@ -29,8 +29,11 @@ m4_define([my_issvn], [yes])
|
||||
|
||||
m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \
|
||||
| sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)]))
|
||||
m4_define([git_revision], m4_esyscmd([git branch -v 2>/dev/null \
|
||||
| awk '/^\* / {printf "%s",$3}']))
|
||||
AC_INIT([gnupg],
|
||||
[my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])],
|
||||
[my_version[]m4_if(my_issvn,[yes],
|
||||
[m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])],
|
||||
[http://bugs.gnupg.org])
|
||||
# Set development_version to yes if the minor number is odd or you
|
||||
# feel that the default check for a development version is not
|
||||
|
@ -617,6 +617,12 @@ more arguments in future versions.
|
||||
prefixed with a numerical error code and an underscore; e.g.:
|
||||
"151011327_EOF".
|
||||
|
||||
SUCCESS [<location>]
|
||||
Postive confirimation that an operation succeeded. <location>
|
||||
is optional but if given should not contain spaces.
|
||||
Used only with a few commands.
|
||||
|
||||
|
||||
ATTRIBUTE <fpr> <octets> <type> <index> <count>
|
||||
<timestamp> <expiredate> <flags>
|
||||
This is one long line issued for each attribute subpacket when
|
||||
|
@ -1,5 +1,39 @@
|
||||
2010-03-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* card-util.c: Replace stdio by estream.
|
||||
* keylist.c: Ditto.
|
||||
|
||||
2010-03-12 Werner Koch <wk@g10code.com>
|
||||
|
||||
* plaintext.c (setup_plaintext_name): Do not encode pipe like
|
||||
filenames. This helps with bug#1201.
|
||||
|
||||
* seckey-cert.c (do_check): Return GPG_ERR_CANCELED.
|
||||
* keyedit.c (change_passphrase): Add arg R_ERR.
|
||||
(keyedit_passwd): Return the correct error or emit a success
|
||||
status message.
|
||||
|
||||
2010-03-11 Werner Koch <wk@g10code.com>
|
||||
|
||||
* misc.c (mpi_print): Change to take a estream_t arg.
|
||||
|
||||
* parse-packet.c (listfp): Change to an estream_t. Change all
|
||||
users to use estream functions.
|
||||
|
||||
* kbnode.c (dump_kbnode): Change to use log functions.
|
||||
* pkclist.c (do_show_revocation_reason): Ditto
|
||||
|
||||
* armor.c (parse_header_line): Replace print_string by
|
||||
es_print_sanitized.
|
||||
(fake_packet): Ditto.
|
||||
* keyedit.c (print_and_check_one_sig_colon): Ditto.
|
||||
(show_key_with_all_names_colon): Ditto.
|
||||
(ask_revoke_sig): Ditto.
|
||||
* keylist.c (list_keyblock_colon): Ditto.
|
||||
* mainproc.c (print_userid, list_node): Ditto.
|
||||
* trustdb.c (dump_key_array): Ditto.
|
||||
* gpg.c (list_config): ditto.
|
||||
|
||||
* gpg.c: Include "asshelp.h".
|
||||
(main): Remove assuan_set_assuan_log_prefix. Add
|
||||
assuan_set_log_cb.
|
||||
|
25
g10/armor.c
25
g10/armor.c
@ -415,9 +415,9 @@ parse_header_line( armor_filter_context_t *afx, byte *line, unsigned int len )
|
||||
if( !p || (RFC2440 && p[1]!=' ')
|
||||
|| (!RFC2440 && p[1]!=' ' && p[1]!='\n' && p[1]!='\r'))
|
||||
{
|
||||
log_error(_("invalid armor header: "));
|
||||
print_string( stderr, line, len, 0 );
|
||||
putc('\n', stderr);
|
||||
log_error (_("invalid armor header: "));
|
||||
es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
|
||||
log_printf ("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -427,8 +427,8 @@ parse_header_line( armor_filter_context_t *afx, byte *line, unsigned int len )
|
||||
|
||||
if( opt.verbose ) {
|
||||
log_info(_("armor header: "));
|
||||
print_string( stderr, line, len, 0 );
|
||||
putc('\n', stderr);
|
||||
es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
|
||||
log_printf ("\n");
|
||||
}
|
||||
|
||||
if( afx->in_cleartext )
|
||||
@ -453,8 +453,8 @@ parse_header_line( armor_filter_context_t *afx, byte *line, unsigned int len )
|
||||
signed data section is "Hash". */
|
||||
|
||||
log_info(_("unknown armor header: "));
|
||||
print_string( stderr, line, len, 0 );
|
||||
putc('\n', stderr);
|
||||
es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
|
||||
log_printf ("\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -641,8 +641,9 @@ fake_packet( armor_filter_context_t *afx, IOBUF a,
|
||||
if( type != BEGIN_SIGNATURE )
|
||||
{
|
||||
log_info(_("unexpected armor: "));
|
||||
print_string( stderr, p, n, 0 );
|
||||
putc('\n', stderr);
|
||||
es_write_sanitized (log_get_stream (), p, n,
|
||||
NULL, NULL);
|
||||
log_printf ("\n");
|
||||
}
|
||||
|
||||
lastline = 1;
|
||||
@ -652,9 +653,9 @@ fake_packet( armor_filter_context_t *afx, IOBUF a,
|
||||
else if(!afx->not_dash_escaped)
|
||||
{
|
||||
/* Bad dash-escaping. */
|
||||
log_info(_("invalid dash escaped line: "));
|
||||
print_string( stderr, p, n, 0 );
|
||||
putc('\n', stderr);
|
||||
log_info (_("invalid dash escaped line: "));
|
||||
es_write_sanitized (log_get_stream (), p, n, NULL, NULL);
|
||||
log_printf ("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
137
g10/card-util.c
137
g10/card-util.c
@ -218,7 +218,7 @@ get_manufacturer (unsigned int no)
|
||||
|
||||
|
||||
static void
|
||||
print_sha1_fpr (FILE *fp, const unsigned char *fpr)
|
||||
print_sha1_fpr (estream_t fp, const unsigned char *fpr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -238,21 +238,21 @@ print_sha1_fpr (FILE *fp, const unsigned char *fpr)
|
||||
|
||||
|
||||
static void
|
||||
print_sha1_fpr_colon (FILE *fp, const unsigned char *fpr)
|
||||
print_sha1_fpr_colon (estream_t fp, const unsigned char *fpr)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (fpr)
|
||||
{
|
||||
for (i=0; i < 20 ; i++, fpr++)
|
||||
fprintf (fp, "%02X", *fpr);
|
||||
es_fprintf (fp, "%02X", *fpr);
|
||||
}
|
||||
putc (':', fp);
|
||||
es_putc (':', fp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_name (FILE *fp, const char *text, const char *name)
|
||||
print_name (estream_t fp, const char *text, const char *name)
|
||||
{
|
||||
tty_fprintf (fp, "%s", text);
|
||||
|
||||
@ -261,7 +261,7 @@ print_name (FILE *fp, const char *text, const char *name)
|
||||
if (name && *name)
|
||||
{
|
||||
if (fp)
|
||||
print_utf8_string2 (fp, name, strlen (name), '\n');
|
||||
print_utf8_buffer2 (fp, name, strlen (name), '\n');
|
||||
else
|
||||
tty_print_utf8_string2 (name, strlen (name), 0);
|
||||
}
|
||||
@ -271,10 +271,11 @@ print_name (FILE *fp, const char *text, const char *name)
|
||||
}
|
||||
|
||||
static void
|
||||
print_isoname (FILE *fp, const char *text, const char *tag, const char *name)
|
||||
print_isoname (estream_t fp, const char *text,
|
||||
const char *tag, const char *name)
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fprintf (fp, "%s:", tag);
|
||||
es_fprintf (fp, "%s:", tag);
|
||||
else
|
||||
tty_fprintf (fp, "%s", text);
|
||||
|
||||
@ -291,22 +292,22 @@ print_isoname (FILE *fp, const char *text, const char *tag, const char *name)
|
||||
*given = 0;
|
||||
given += 2;
|
||||
if (opt.with_colons)
|
||||
print_string (fp, given, strlen (given), ':');
|
||||
es_write_sanitized (fp, given, strlen (given), ":", NULL);
|
||||
else if (fp)
|
||||
print_utf8_string2 (fp, given, strlen (given), '\n');
|
||||
print_utf8_buffer2 (fp, given, strlen (given), '\n');
|
||||
else
|
||||
tty_print_utf8_string2 (given, strlen (given), 0);
|
||||
|
||||
if (opt.with_colons)
|
||||
putc (':', fp);
|
||||
es_putc (':', fp);
|
||||
else if (*buf)
|
||||
tty_fprintf (fp, " ");
|
||||
}
|
||||
|
||||
if (opt.with_colons)
|
||||
print_string (fp, buf, strlen (buf), ':');
|
||||
es_write_sanitized (fp, buf, strlen (buf), ":", NULL);
|
||||
else if (fp)
|
||||
print_utf8_string2 (fp, buf, strlen (buf), '\n');
|
||||
print_utf8_buffer2 (fp, buf, strlen (buf), '\n');
|
||||
else
|
||||
tty_print_utf8_string2 (buf, strlen (buf), 0);
|
||||
xfree (buf);
|
||||
@ -314,13 +315,13 @@ print_isoname (FILE *fp, const char *text, const char *tag, const char *name)
|
||||
else
|
||||
{
|
||||
if (opt.with_colons)
|
||||
putc (':', fp);
|
||||
es_putc (':', fp);
|
||||
else
|
||||
tty_fprintf (fp, _("[not set]"));
|
||||
}
|
||||
|
||||
if (opt.with_colons)
|
||||
fputs (":\n", fp);
|
||||
es_fputs (":\n", fp);
|
||||
else
|
||||
tty_fprintf (fp, "\n");
|
||||
}
|
||||
@ -351,7 +352,7 @@ fpr_is_ff (const char *fpr)
|
||||
|
||||
/* Print all available information about the current card. */
|
||||
void
|
||||
card_status (FILE *fp, char *serialno, size_t serialnobuflen)
|
||||
card_status (estream_t fp, char *serialno, size_t serialnobuflen)
|
||||
{
|
||||
struct agent_card_info_s info;
|
||||
PKT_public_key *pk = xcalloc (1, sizeof *pk);
|
||||
@ -367,15 +368,14 @@ card_status (FILE *fp, char *serialno, size_t serialnobuflen)
|
||||
if (rc)
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fputs ("AID:::\n", fp);
|
||||
log_error (_("OpenPGP card not available: %s\n"),
|
||||
gpg_strerror (rc));
|
||||
es_fputs ("AID:::\n", fp);
|
||||
log_error (_("OpenPGP card not available: %s\n"), gpg_strerror (rc));
|
||||
xfree (pk);
|
||||
return;
|
||||
}
|
||||
|
||||
if (opt.with_colons)
|
||||
fprintf (fp, "AID:%s:", info.serialno? info.serialno : "");
|
||||
es_fprintf (fp, "AID:%s:", info.serialno? info.serialno : "");
|
||||
else
|
||||
tty_fprintf (fp, "Application ID ...: %s\n",
|
||||
info.serialno? info.serialno : "[none]");
|
||||
@ -385,31 +385,31 @@ card_status (FILE *fp, char *serialno, size_t serialnobuflen)
|
||||
if (info.apptype && !strcmp (info.apptype, "NKS"))
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fputs ("netkey-card:\n", fp);
|
||||
es_fputs ("netkey-card:\n", fp);
|
||||
log_info ("this is a NetKey card\n");
|
||||
}
|
||||
else if (info.apptype && !strcmp (info.apptype, "DINSIG"))
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fputs ("dinsig-card:\n", fp);
|
||||
es_fputs ("dinsig-card:\n", fp);
|
||||
log_info ("this is a DINSIG compliant card\n");
|
||||
}
|
||||
else if (info.apptype && !strcmp (info.apptype, "P15"))
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fputs ("pkcs15-card:\n", fp);
|
||||
es_fputs ("pkcs15-card:\n", fp);
|
||||
log_info ("this is a PKCS#15 compliant card\n");
|
||||
}
|
||||
else if (info.apptype && !strcmp (info.apptype, "GELDKARTE"))
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fputs ("geldkarte-card:\n", fp);
|
||||
es_fputs ("geldkarte-card:\n", fp);
|
||||
log_info ("this is a Geldkarte compliant card\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (opt.with_colons)
|
||||
fputs ("unknown:\n", fp);
|
||||
es_fputs ("unknown:\n", fp);
|
||||
}
|
||||
log_info ("not an OpenPGP card\n");
|
||||
agent_release_card_info (&info);
|
||||
@ -425,69 +425,72 @@ card_status (FILE *fp, char *serialno, size_t serialnobuflen)
|
||||
strcpy (serialno, info.serialno);
|
||||
|
||||
if (opt.with_colons)
|
||||
fputs ("openpgp-card:\n", fp);
|
||||
es_fputs ("openpgp-card:\n", fp);
|
||||
|
||||
|
||||
if (opt.with_colons)
|
||||
{
|
||||
fprintf (fp, "version:%.4s:\n", info.serialno+12);
|
||||
es_fprintf (fp, "version:%.4s:\n", info.serialno+12);
|
||||
uval = xtoi_2(info.serialno+16)*256 + xtoi_2 (info.serialno+18);
|
||||
fprintf (fp, "vendor:%04x:%s:\n", uval, get_manufacturer (uval));
|
||||
fprintf (fp, "serial:%.8s:\n", info.serialno+20);
|
||||
es_fprintf (fp, "vendor:%04x:%s:\n", uval, get_manufacturer (uval));
|
||||
es_fprintf (fp, "serial:%.8s:\n", info.serialno+20);
|
||||
|
||||
print_isoname (fp, "Name of cardholder: ", "name", info.disp_name);
|
||||
|
||||
fputs ("lang:", fp);
|
||||
es_fputs ("lang:", fp);
|
||||
if (info.disp_lang)
|
||||
print_string (fp, info.disp_lang, strlen (info.disp_lang), ':');
|
||||
fputs (":\n", fp);
|
||||
es_write_sanitized (fp, info.disp_lang, strlen (info.disp_lang),
|
||||
":", NULL);
|
||||
es_fputs (":\n", fp);
|
||||
|
||||
fprintf (fp, "sex:%c:\n", (info.disp_sex == 1? 'm':
|
||||
es_fprintf (fp, "sex:%c:\n", (info.disp_sex == 1? 'm':
|
||||
info.disp_sex == 2? 'f' : 'u'));
|
||||
|
||||
fputs ("url:", fp);
|
||||
es_fputs ("url:", fp);
|
||||
if (info.pubkey_url)
|
||||
print_string (fp, info.pubkey_url, strlen (info.pubkey_url), ':');
|
||||
fputs (":\n", fp);
|
||||
es_write_sanitized (fp, info.pubkey_url, strlen (info.pubkey_url),
|
||||
":", NULL);
|
||||
es_fputs (":\n", fp);
|
||||
|
||||
fputs ("login:", fp);
|
||||
es_fputs ("login:", fp);
|
||||
if (info.login_data)
|
||||
print_string (fp, info.login_data, strlen (info.login_data), ':');
|
||||
fputs (":\n", fp);
|
||||
es_write_sanitized (fp, info.login_data, strlen (info.login_data),
|
||||
":", NULL);
|
||||
es_fputs (":\n", fp);
|
||||
|
||||
fprintf (fp, "forcepin:%d:::\n", !info.chv1_cached);
|
||||
es_fprintf (fp, "forcepin:%d:::\n", !info.chv1_cached);
|
||||
for (i=0; i < DIM (info.key_attr); i++)
|
||||
if (info.key_attr[0].algo)
|
||||
fprintf (fp, "keyattr:%d:%d:%u:\n", i+1,
|
||||
info.key_attr[i].algo, info.key_attr[i].nbits);
|
||||
fprintf (fp, "maxpinlen:%d:%d:%d:\n",
|
||||
info.chvmaxlen[0], info.chvmaxlen[1], info.chvmaxlen[2]);
|
||||
fprintf (fp, "pinretry:%d:%d:%d:\n",
|
||||
info.chvretry[0], info.chvretry[1], info.chvretry[2]);
|
||||
fprintf (fp, "sigcount:%lu:::\n", info.sig_counter);
|
||||
es_fprintf (fp, "keyattr:%d:%d:%u:\n", i+1,
|
||||
info.key_attr[i].algo, info.key_attr[i].nbits);
|
||||
es_fprintf (fp, "maxpinlen:%d:%d:%d:\n",
|
||||
info.chvmaxlen[0], info.chvmaxlen[1], info.chvmaxlen[2]);
|
||||
es_fprintf (fp, "pinretry:%d:%d:%d:\n",
|
||||
info.chvretry[0], info.chvretry[1], info.chvretry[2]);
|
||||
es_fprintf (fp, "sigcount:%lu:::\n", info.sig_counter);
|
||||
|
||||
for (i=0; i < 4; i++)
|
||||
{
|
||||
if (info.private_do[i])
|
||||
{
|
||||
fprintf (fp, "private_do:%d:", i+1);
|
||||
print_string (fp, info.private_do[i],
|
||||
strlen (info.private_do[i]), ':');
|
||||
fputs (":\n", fp);
|
||||
es_fprintf (fp, "private_do:%d:", i+1);
|
||||
es_write_sanitized (fp, info.private_do[i],
|
||||
strlen (info.private_do[i]), ":", NULL);
|
||||
es_fputs (":\n", fp);
|
||||
}
|
||||
}
|
||||
|
||||
fputs ("cafpr:", fp);
|
||||
es_fputs ("cafpr:", fp);
|
||||
print_sha1_fpr_colon (fp, info.cafpr1valid? info.cafpr1:NULL);
|
||||
print_sha1_fpr_colon (fp, info.cafpr2valid? info.cafpr2:NULL);
|
||||
print_sha1_fpr_colon (fp, info.cafpr3valid? info.cafpr3:NULL);
|
||||
putc ('\n', fp);
|
||||
fputs ("fpr:", fp);
|
||||
es_putc ('\n', fp);
|
||||
es_fputs ("fpr:", fp);
|
||||
print_sha1_fpr_colon (fp, info.fpr1valid? info.fpr1:NULL);
|
||||
print_sha1_fpr_colon (fp, info.fpr2valid? info.fpr2:NULL);
|
||||
print_sha1_fpr_colon (fp, info.fpr3valid? info.fpr3:NULL);
|
||||
putc ('\n', fp);
|
||||
fprintf (fp, "fprtime:%lu:%lu:%lu:\n",
|
||||
es_putc ('\n', fp);
|
||||
es_fprintf (fp, "fprtime:%lu:%lu:%lu:\n",
|
||||
(unsigned long)info.fpr1time, (unsigned long)info.fpr2time,
|
||||
(unsigned long)info.fpr3time);
|
||||
}
|
||||
@ -764,13 +767,13 @@ fetch_url(void)
|
||||
static int
|
||||
get_data_from_file (const char *fname, size_t maxlen, char **r_buffer)
|
||||
{
|
||||
FILE *fp;
|
||||
estream_t fp;
|
||||
char *data;
|
||||
int n;
|
||||
|
||||
*r_buffer = NULL;
|
||||
|
||||
fp = fopen (fname, "rb");
|
||||
fp = es_fopen (fname, "rb");
|
||||
#if GNUPG_MAJOR_VERSION == 1
|
||||
if (fp && is_secured_file (fileno (fp)))
|
||||
{
|
||||
@ -789,15 +792,15 @@ get_data_from_file (const char *fname, size_t maxlen, char **r_buffer)
|
||||
if (!data)
|
||||
{
|
||||
tty_printf (_("error allocating enough memory: %s\n"), strerror (errno));
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (maxlen)
|
||||
n = fread (data, 1, maxlen, fp);
|
||||
n = es_fread (data, 1, maxlen, fp);
|
||||
else
|
||||
n = 0;
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
if (n < 0)
|
||||
{
|
||||
tty_printf (_("error reading `%s': %s\n"), fname, strerror (errno));
|
||||
@ -814,9 +817,9 @@ get_data_from_file (const char *fname, size_t maxlen, char **r_buffer)
|
||||
static int
|
||||
put_data_to_file (const char *fname, const void *buffer, size_t length)
|
||||
{
|
||||
FILE *fp;
|
||||
estream_t fp;
|
||||
|
||||
fp = fopen (fname, "wb");
|
||||
fp = es_fopen (fname, "wb");
|
||||
#if GNUPG_MAJOR_VERSION == 1
|
||||
if (fp && is_secured_file (fileno (fp)))
|
||||
{
|
||||
@ -831,13 +834,13 @@ put_data_to_file (const char *fname, const void *buffer, size_t length)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (length && fwrite (buffer, length, 1, fp) != 1)
|
||||
if (length && es_fwrite (buffer, length, 1, fp) != 1)
|
||||
{
|
||||
tty_printf (_("error writing `%s': %s\n"), fname, strerror (errno));
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
return -1;
|
||||
}
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1785,7 +1788,7 @@ card_edit (strlist_t commands)
|
||||
{
|
||||
if (opt.with_colons)
|
||||
{
|
||||
card_status (stdout, serialnobuf, DIM (serialnobuf));
|
||||
card_status (es_stdout, serialnobuf, DIM (serialnobuf));
|
||||
fflush (stdout);
|
||||
}
|
||||
else
|
||||
|
26
g10/gpg.c
26
g10/gpg.c
@ -1497,9 +1497,10 @@ list_config(char *items)
|
||||
{
|
||||
strlist_t sl;
|
||||
|
||||
printf("cfg:group:");
|
||||
print_string(stdout,iter->name,strlen(iter->name),':');
|
||||
printf(":");
|
||||
es_fprintf (es_stdout, "cfg:group:");
|
||||
es_write_sanitized (es_stdout, iter->name, strlen(iter->name),
|
||||
":", NULL);
|
||||
es_putc (':', es_stdout);
|
||||
|
||||
for(sl=iter->values;sl;sl=sl->next)
|
||||
{
|
||||
@ -1517,7 +1518,7 @@ list_config(char *items)
|
||||
if(show_all || ascii_strcasecmp(name,"version")==0)
|
||||
{
|
||||
printf("cfg:version:");
|
||||
print_string(stdout,VERSION,strlen(VERSION),':');
|
||||
es_write_sanitized (es_stdout, VERSION, strlen(VERSION), ":", NULL);
|
||||
printf("\n");
|
||||
any=1;
|
||||
}
|
||||
@ -3828,29 +3829,30 @@ main (int argc, char **argv)
|
||||
{ int mode = argc < 2 ? 0 : atoi(*argv);
|
||||
|
||||
if( mode == 1 && argc == 2 ) {
|
||||
mpi_print( stdout, generate_public_prime( atoi(argv[1]) ), 1);
|
||||
mpi_print (es_stdout,
|
||||
generate_public_prime( atoi(argv[1]) ), 1);
|
||||
}
|
||||
else if( mode == 2 && argc == 3 ) {
|
||||
mpi_print( stdout, generate_elg_prime(
|
||||
mpi_print (es_stdout, generate_elg_prime(
|
||||
0, atoi(argv[1]),
|
||||
atoi(argv[2]), NULL,NULL ), 1);
|
||||
}
|
||||
else if( mode == 3 && argc == 3 ) {
|
||||
MPI *factors;
|
||||
mpi_print( stdout, generate_elg_prime(
|
||||
mpi_print (es_stdout, generate_elg_prime(
|
||||
1, atoi(argv[1]),
|
||||
atoi(argv[2]), NULL,&factors ), 1);
|
||||
putchar('\n');
|
||||
mpi_print( stdout, factors[0], 1 ); /* print q */
|
||||
mpi_print (es_stdout, factors[0], 1 ); /* print q */
|
||||
}
|
||||
else if( mode == 4 && argc == 3 ) {
|
||||
MPI g = mpi_alloc(1);
|
||||
mpi_print( stdout, generate_elg_prime(
|
||||
mpi_print (es_stdout, generate_elg_prime(
|
||||
0, atoi(argv[1]),
|
||||
atoi(argv[2]), g, NULL ), 1);
|
||||
putchar('\n');
|
||||
mpi_print( stdout, g, 1 );
|
||||
mpi_free(g);
|
||||
mpi_print (es_stdout, g, 1 );
|
||||
mpi_free (g);
|
||||
}
|
||||
else
|
||||
wrong_args("--gen-prime mode bits [qbits] ");
|
||||
@ -3987,7 +3989,7 @@ main (int argc, char **argv)
|
||||
case aCardStatus:
|
||||
if (argc)
|
||||
wrong_args ("--card-status");
|
||||
card_status (stdout, NULL, 0);
|
||||
card_status (es_stdout, NULL, 0);
|
||||
break;
|
||||
|
||||
case aCardEdit:
|
||||
|
@ -718,7 +718,7 @@ import_one( const char *fname, KBNODE keyblock, struct stats_s *stats,
|
||||
pubkey_letter( pk->pubkey_algo ),
|
||||
keystr_from_pk(pk), datestr_from_pk(pk) );
|
||||
if (uidnode)
|
||||
print_utf8_string (log_get_stream (),
|
||||
print_utf8_buffer (log_get_stream (),
|
||||
uidnode->pkt->pkt.user_id->name,
|
||||
uidnode->pkt->pkt.user_id->len );
|
||||
log_printf ("\n");
|
||||
@ -1127,7 +1127,7 @@ import_secret_one( const char *fname, KBNODE keyblock,
|
||||
pubkey_letter( sk->pubkey_algo ),
|
||||
keystr_from_sk(sk), datestr_from_sk(sk) );
|
||||
if( uidnode )
|
||||
print_utf8_string( stderr, uidnode->pkt->pkt.user_id->name,
|
||||
print_utf8_buffer (es_stderr, uidnode->pkt->pkt.user_id->name,
|
||||
uidnode->pkt->pkt.user_id->len );
|
||||
log_printf ("\n");
|
||||
}
|
||||
|
122
g10/kbnode.c
122
g10/kbnode.c
@ -1,6 +1,6 @@
|
||||
/* kbnode.c - keyblock node utility functions
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
|
||||
* 2005 Free Software Foundation, Inc.
|
||||
* 2005, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
@ -336,63 +336,71 @@ move_kbnode( KBNODE *root, KBNODE node, KBNODE where )
|
||||
|
||||
|
||||
void
|
||||
dump_kbnode( KBNODE node )
|
||||
dump_kbnode (KBNODE node)
|
||||
{
|
||||
for(; node; node = node->next ) {
|
||||
const char *s;
|
||||
switch( node->pkt->pkttype ) {
|
||||
case 0: s="empty"; break;
|
||||
case PKT_PUBLIC_KEY: s="public-key"; break;
|
||||
case PKT_SECRET_KEY: s="secret-key"; break;
|
||||
case PKT_SECRET_SUBKEY: s= "secret-subkey"; break;
|
||||
case PKT_PUBKEY_ENC: s="public-enc"; break;
|
||||
case PKT_SIGNATURE: s="signature"; break;
|
||||
case PKT_ONEPASS_SIG: s="onepass-sig"; break;
|
||||
case PKT_USER_ID: s="user-id"; break;
|
||||
case PKT_PUBLIC_SUBKEY: s="public-subkey"; break;
|
||||
case PKT_COMMENT: s="comment"; break;
|
||||
case PKT_RING_TRUST: s="trust"; break;
|
||||
case PKT_PLAINTEXT: s="plaintext"; break;
|
||||
case PKT_COMPRESSED: s="compressed"; break;
|
||||
case PKT_ENCRYPTED: s="encrypted"; break;
|
||||
case PKT_GPG_CONTROL: s="gpg-control"; break;
|
||||
default: s="unknown"; break;
|
||||
for (; node; node = node->next )
|
||||
{
|
||||
const char *s;
|
||||
switch (node->pkt->pkttype)
|
||||
{
|
||||
case 0: s="empty"; break;
|
||||
case PKT_PUBLIC_KEY: s="public-key"; break;
|
||||
case PKT_SECRET_KEY: s="secret-key"; break;
|
||||
case PKT_SECRET_SUBKEY: s= "secret-subkey"; break;
|
||||
case PKT_PUBKEY_ENC: s="public-enc"; break;
|
||||
case PKT_SIGNATURE: s="signature"; break;
|
||||
case PKT_ONEPASS_SIG: s="onepass-sig"; break;
|
||||
case PKT_USER_ID: s="user-id"; break;
|
||||
case PKT_PUBLIC_SUBKEY: s="public-subkey"; break;
|
||||
case PKT_COMMENT: s="comment"; break;
|
||||
case PKT_RING_TRUST: s="trust"; break;
|
||||
case PKT_PLAINTEXT: s="plaintext"; break;
|
||||
case PKT_COMPRESSED: s="compressed"; break;
|
||||
case PKT_ENCRYPTED: s="encrypted"; break;
|
||||
case PKT_GPG_CONTROL: s="gpg-control"; break;
|
||||
default: s="unknown"; break;
|
||||
}
|
||||
fprintf(stderr, "node %p %02x/%02x type=%s",
|
||||
node, node->flag, node->private_flag, s);
|
||||
if( node->pkt->pkttype == PKT_USER_ID ) {
|
||||
PKT_user_id *uid = node->pkt->pkt.user_id;
|
||||
fputs(" \"", stderr);
|
||||
print_string( stderr, uid->name, uid->len, 0 );
|
||||
fprintf (stderr, "\" %c%c%c%c\n",
|
||||
uid->is_expired? 'e':'.',
|
||||
uid->is_revoked? 'r':'.',
|
||||
uid->created? 'v':'.',
|
||||
uid->is_primary? 'p':'.' );
|
||||
}
|
||||
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||
fprintf(stderr, " class=%02x keyid=%08lX ts=%lu\n",
|
||||
node->pkt->pkt.signature->sig_class,
|
||||
(ulong)node->pkt->pkt.signature->keyid[1],
|
||||
(ulong)node->pkt->pkt.signature->timestamp);
|
||||
}
|
||||
else if( node->pkt->pkttype == PKT_GPG_CONTROL ) {
|
||||
fprintf(stderr, " ctrl=%d len=%u\n",
|
||||
node->pkt->pkt.gpg_control->control,
|
||||
(unsigned int)node->pkt->pkt.gpg_control->datalen);
|
||||
}
|
||||
else if( node->pkt->pkttype == PKT_PUBLIC_KEY
|
||||
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
|
||||
PKT_public_key *pk = node->pkt->pkt.public_key;
|
||||
fprintf(stderr, " keyid=%08lX a=%d u=%d %c%c%c%c\n",
|
||||
(ulong)keyid_from_pk( pk, NULL ),
|
||||
pk->pubkey_algo, pk->pubkey_usage,
|
||||
pk->has_expired? 'e':'.',
|
||||
pk->is_revoked? 'r':'.',
|
||||
pk->is_valid? 'v':'.',
|
||||
pk->mdc_feature? 'm':'.');
|
||||
}
|
||||
else
|
||||
fputs("\n", stderr);
|
||||
log_debug ("node %p %02x/%02x type=%s",
|
||||
node, node->flag, node->private_flag, s);
|
||||
if (node->pkt->pkttype == PKT_USER_ID)
|
||||
{
|
||||
PKT_user_id *uid = node->pkt->pkt.user_id;
|
||||
log_printf (" \"");
|
||||
es_write_sanitized (log_get_stream (), uid->name, uid->len,
|
||||
NULL, NULL);
|
||||
log_printf ("\" %c%c%c%c\n",
|
||||
uid->is_expired? 'e':'.',
|
||||
uid->is_revoked? 'r':'.',
|
||||
uid->created? 'v':'.',
|
||||
uid->is_primary? 'p':'.' );
|
||||
}
|
||||
else if (node->pkt->pkttype == PKT_SIGNATURE)
|
||||
{
|
||||
log_printf (" class=%02x keyid=%08lX ts=%lu\n",
|
||||
node->pkt->pkt.signature->sig_class,
|
||||
(ulong)node->pkt->pkt.signature->keyid[1],
|
||||
(ulong)node->pkt->pkt.signature->timestamp);
|
||||
}
|
||||
else if (node->pkt->pkttype == PKT_GPG_CONTROL)
|
||||
{
|
||||
log_printf (" ctrl=%d len=%u\n",
|
||||
node->pkt->pkt.gpg_control->control,
|
||||
(unsigned int)node->pkt->pkt.gpg_control->datalen);
|
||||
}
|
||||
else if (node->pkt->pkttype == PKT_PUBLIC_KEY
|
||||
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
|
||||
{
|
||||
PKT_public_key *pk = node->pkt->pkt.public_key;
|
||||
|
||||
log_printf (" keyid=%08lX a=%d u=%d %c%c%c%c\n",
|
||||
(ulong)keyid_from_pk( pk, NULL ),
|
||||
pk->pubkey_algo, pk->pubkey_usage,
|
||||
pk->has_expired? 'e':'.',
|
||||
pk->is_revoked? 'r':'.',
|
||||
pk->is_valid? 'v':'.',
|
||||
pk->mdc_feature? 'm':'.');
|
||||
}
|
||||
|
||||
log_flush ();
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,9 @@ print_and_check_one_sig_colon( KBNODE keyblock, KBNODE node,
|
||||
printf(":");
|
||||
|
||||
if(sig->trust_regexp)
|
||||
print_string(stdout,sig->trust_regexp,strlen(sig->trust_regexp),':');
|
||||
es_write_sanitized (es_stdout,
|
||||
sig->trust_regexp, strlen (sig->trust_regexp),
|
||||
":", NULL);
|
||||
|
||||
printf("::%02x%c\n",sig->sig_class,sig->flags.exportable?'x':'l');
|
||||
|
||||
@ -1100,7 +1102,7 @@ sign_uids( KBNODE keyblock, strlist_t locusr, int *ret_modified,
|
||||
* We use only one passphrase for all keys.
|
||||
*/
|
||||
static int
|
||||
change_passphrase( KBNODE keyblock )
|
||||
change_passphrase (KBNODE keyblock, int *r_err)
|
||||
{
|
||||
int rc = 0;
|
||||
int changed=0;
|
||||
@ -1264,6 +1266,8 @@ change_passphrase( KBNODE keyblock )
|
||||
leave:
|
||||
xfree( passphrase );
|
||||
set_next_passphrase( NULL );
|
||||
if (r_err)
|
||||
*r_err = rc;
|
||||
return changed && !rc;
|
||||
}
|
||||
|
||||
@ -2150,7 +2154,7 @@ keyedit_menu( const char *username, strlist_t locusr,
|
||||
break;
|
||||
|
||||
case cmdPASSWD:
|
||||
if( change_passphrase( sec_keyblock ) )
|
||||
if (change_passphrase (sec_keyblock, NULL))
|
||||
sec_modified = 1;
|
||||
break;
|
||||
|
||||
@ -2372,11 +2376,8 @@ keyedit_passwd (const char *username)
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
if (!change_passphrase (keyblock))
|
||||
{
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
goto leave;
|
||||
}
|
||||
if (!change_passphrase (keyblock, &err))
|
||||
goto leave;
|
||||
|
||||
err = keydb_update_keyblock (kdh, keyblock);
|
||||
if (err)
|
||||
@ -2393,6 +2394,8 @@ keyedit_passwd (const char *username)
|
||||
username, gpg_strerror (err));
|
||||
write_status_error ("keyedit.passwd", err);
|
||||
}
|
||||
else
|
||||
write_status_text (STATUS_SUCCESS, "keyedit.passwd");
|
||||
}
|
||||
|
||||
|
||||
@ -2685,7 +2688,7 @@ show_key_with_all_names_colon (KBNODE keyblock)
|
||||
if(uid->attrib_data)
|
||||
printf ("%u %lu",uid->numattribs,uid->attrib_len);
|
||||
else
|
||||
print_string (stdout, uid->name, uid->len, ':');
|
||||
es_write_sanitized (es_stdout, uid->name, uid->len, ":", NULL);
|
||||
|
||||
putchar (':');
|
||||
/* signature class */
|
||||
@ -4791,7 +4794,7 @@ ask_revoke_sig( KBNODE keyblock, KBNODE node )
|
||||
else
|
||||
{
|
||||
printf("uid:::::::::");
|
||||
print_string (stdout, uid->name, uid->len, ':');
|
||||
es_write_sanitized (es_stdout, uid->name, uid->len, ":", NULL);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
395
g10/keylist.c
395
g10/keylist.c
@ -54,7 +54,7 @@ struct sig_stats
|
||||
};
|
||||
|
||||
/* The stream used to write attribute packets to. */
|
||||
static FILE *attrib_fp = NULL;
|
||||
static estream_t attrib_fp;
|
||||
|
||||
|
||||
/* List the keys. If list is NULL, all available keys are listed.
|
||||
@ -71,32 +71,32 @@ public_key_list (strlist_t list, int locate_mode)
|
||||
read_trust_options (&trust_model, &created, &nextcheck,
|
||||
&marginals, &completes, &cert_depth);
|
||||
|
||||
printf ("tru:");
|
||||
es_fprintf (es_stdout, "tru:");
|
||||
|
||||
if (nextcheck && nextcheck <= make_timestamp ())
|
||||
printf ("o");
|
||||
es_fprintf (es_stdout, "o");
|
||||
if (trust_model != opt.trust_model)
|
||||
printf ("t");
|
||||
es_fprintf (es_stdout, "t");
|
||||
if (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC)
|
||||
{
|
||||
if (marginals != opt.marginals_needed)
|
||||
printf ("m");
|
||||
es_fprintf (es_stdout, "m");
|
||||
if (completes != opt.completes_needed)
|
||||
printf ("c");
|
||||
es_fprintf (es_stdout, "c");
|
||||
if (cert_depth != opt.max_cert_depth)
|
||||
printf ("d");
|
||||
es_fprintf (es_stdout, "d");
|
||||
}
|
||||
|
||||
printf (":%d:%lu:%lu", trust_model, created, nextcheck);
|
||||
es_fprintf (es_stdout, ":%d:%lu:%lu", trust_model, created, nextcheck);
|
||||
|
||||
/* Only show marginals, completes, and cert_depth in the classic
|
||||
or PGP trust models since they are not meaningful
|
||||
otherwise. */
|
||||
|
||||
if (trust_model == TM_PGP || trust_model == TM_CLASSIC)
|
||||
printf (":%d:%d:%d", marginals, completes, cert_depth);
|
||||
es_fprintf (es_stdout, ":%d:%d:%d", marginals, completes, cert_depth);
|
||||
|
||||
printf ("\n");
|
||||
es_fprintf (es_stdout, "\n");
|
||||
}
|
||||
|
||||
/* We need to do the stale check right here because it might need to
|
||||
@ -147,7 +147,7 @@ print_seckey_info (PKT_public_key *pk)
|
||||
the tty output interface is used, otherwise output is directted to
|
||||
the given stream. */
|
||||
void
|
||||
print_pubkey_info (FILE * fp, PKT_public_key * pk)
|
||||
print_pubkey_info (estream_t fp, PKT_public_key * pk)
|
||||
{
|
||||
u32 keyid[2];
|
||||
char *p;
|
||||
@ -162,15 +162,11 @@ print_pubkey_info (FILE * fp, PKT_public_key * pk)
|
||||
p = get_user_id_native (keyid);
|
||||
|
||||
if (fp)
|
||||
fprintf (fp, "pub %4u%c/%s %s %s\n",
|
||||
nbits_from_pk (pk),
|
||||
pubkey_letter (pk->pubkey_algo),
|
||||
keystr (keyid), datestr_from_pk (pk), p);
|
||||
else
|
||||
tty_printf ("\npub %4u%c/%s %s %s\n",
|
||||
nbits_from_pk (pk), pubkey_letter (pk->pubkey_algo),
|
||||
keystr (keyid), datestr_from_pk (pk), p);
|
||||
|
||||
tty_printf ("\n");
|
||||
tty_fprintf (fp, "pub %4u%c/%s %s %s\n",
|
||||
nbits_from_pk (pk),
|
||||
pubkey_letter (pk->pubkey_algo),
|
||||
keystr (keyid), datestr_from_pk (pk), p);
|
||||
xfree (p);
|
||||
}
|
||||
|
||||
@ -178,7 +174,7 @@ print_pubkey_info (FILE * fp, PKT_public_key * pk)
|
||||
/* Print basic information of a secret key including the card serial
|
||||
number information. */
|
||||
void
|
||||
print_card_key_info (FILE * fp, KBNODE keyblock)
|
||||
print_card_key_info (estream_t fp, KBNODE keyblock)
|
||||
{
|
||||
KBNODE node;
|
||||
int i;
|
||||
@ -239,7 +235,8 @@ status_one_subpacket (sigsubpkttype_t type, size_t len, int flags,
|
||||
if (len > 256)
|
||||
return;
|
||||
|
||||
sprintf (status, "%d %u %u ", type, flags, (unsigned int) len);
|
||||
snprintf (status, sizeof status,
|
||||
"%d %u %u ", type, flags, (unsigned int) len);
|
||||
|
||||
write_status_text_and_buffer (STATUS_SIG_SUBPACKET, status, buf, len, 0);
|
||||
}
|
||||
@ -256,7 +253,7 @@ show_policy_url (PKT_signature * sig, int indent, int mode)
|
||||
const byte *p;
|
||||
size_t len;
|
||||
int seq = 0, crit;
|
||||
FILE *fp = mode ? log_get_stream () : stdout;
|
||||
estream_t fp = mode ? log_get_stream () : es_stdout;
|
||||
|
||||
while ((p =
|
||||
enum_sig_subpkt (sig->hashed, SIGSUBPKT_POLICY, &len, &seq, &crit)))
|
||||
@ -267,7 +264,7 @@ show_policy_url (PKT_signature * sig, int indent, int mode)
|
||||
const char *str;
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
putchar (' ');
|
||||
es_putc (' ', fp);
|
||||
|
||||
if (crit)
|
||||
str = _("Critical signature policy: ");
|
||||
@ -276,9 +273,9 @@ show_policy_url (PKT_signature * sig, int indent, int mode)
|
||||
if (mode)
|
||||
log_info ("%s", str);
|
||||
else
|
||||
printf ("%s", str);
|
||||
print_utf8_string (fp, p, len);
|
||||
fprintf (fp, "\n");
|
||||
es_fprintf (fp, "%s", str);
|
||||
print_utf8_buffer (fp, p, len);
|
||||
es_fprintf (fp, "\n");
|
||||
}
|
||||
|
||||
if (mode)
|
||||
@ -299,7 +296,7 @@ show_keyserver_url (PKT_signature * sig, int indent, int mode)
|
||||
const byte *p;
|
||||
size_t len;
|
||||
int seq = 0, crit;
|
||||
FILE *fp = mode ? log_get_stream () : stdout;
|
||||
estream_t fp = mode ? log_get_stream () : es_stdout;
|
||||
|
||||
while ((p =
|
||||
enum_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_KS, &len, &seq,
|
||||
@ -311,7 +308,7 @@ show_keyserver_url (PKT_signature * sig, int indent, int mode)
|
||||
const char *str;
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
putchar (' ');
|
||||
es_putc (' ', es_stdout);
|
||||
|
||||
if (crit)
|
||||
str = _("Critical preferred keyserver: ");
|
||||
@ -320,9 +317,9 @@ show_keyserver_url (PKT_signature * sig, int indent, int mode)
|
||||
if (mode)
|
||||
log_info ("%s", str);
|
||||
else
|
||||
printf ("%s", str);
|
||||
print_utf8_string (fp, p, len);
|
||||
fprintf (fp, "\n");
|
||||
es_fprintf (es_stdout, "%s", str);
|
||||
print_utf8_buffer (fp, p, len);
|
||||
es_fprintf (fp, "\n");
|
||||
}
|
||||
|
||||
if (mode)
|
||||
@ -343,7 +340,7 @@ show_keyserver_url (PKT_signature * sig, int indent, int mode)
|
||||
void
|
||||
show_notation (PKT_signature * sig, int indent, int mode, int which)
|
||||
{
|
||||
FILE *fp = mode ? log_get_stream () : stdout;
|
||||
estream_t fp = mode ? log_get_stream () : es_stdout;
|
||||
struct notation *nd, *notations;
|
||||
|
||||
if (which == 0)
|
||||
@ -364,7 +361,7 @@ show_notation (PKT_signature * sig, int indent, int mode, int which)
|
||||
const char *str;
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
putchar (' ');
|
||||
es_putc (' ', es_stdout);
|
||||
|
||||
if (nd->flags.critical)
|
||||
str = _("Critical signature notation: ");
|
||||
@ -373,12 +370,12 @@ show_notation (PKT_signature * sig, int indent, int mode, int which)
|
||||
if (mode)
|
||||
log_info ("%s", str);
|
||||
else
|
||||
printf ("%s", str);
|
||||
es_fprintf (es_stdout, "%s", str);
|
||||
/* This is all UTF8 */
|
||||
print_utf8_string (fp, nd->name, strlen (nd->name));
|
||||
fprintf (fp, "=");
|
||||
print_utf8_string (fp, nd->value, strlen (nd->value));
|
||||
fprintf (fp, "\n");
|
||||
print_utf8_buffer (fp, nd->name, strlen (nd->name));
|
||||
es_fprintf (fp, "=");
|
||||
print_utf8_buffer (fp, nd->value, strlen (nd->value));
|
||||
es_fprintf (fp, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -455,10 +452,10 @@ list_all (int secret)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("%s\n", resname);
|
||||
es_fprintf (es_stdout, "%s\n", resname);
|
||||
for (i = strlen (resname); i; i--)
|
||||
putchar ('-');
|
||||
putchar ('\n');
|
||||
es_putc ('-', es_stdout);
|
||||
es_putc ('\n', es_stdout);
|
||||
lastresname = resname;
|
||||
}
|
||||
}
|
||||
@ -517,10 +514,10 @@ list_one (strlist_t names, int secret)
|
||||
if ((opt.list_options & LIST_SHOW_KEYRING) && !opt.with_colons)
|
||||
{
|
||||
resname = keydb_get_resource_name (get_ctx_handle (ctx));
|
||||
printf ("%s: %s\n", keyring_str, resname);
|
||||
es_fprintf (es_stdout, "%s: %s\n", keyring_str, resname);
|
||||
for (i = strlen (resname) + strlen (keyring_str) + 2; i; i--)
|
||||
putchar ('-');
|
||||
putchar ('\n');
|
||||
es_putc ('-', es_stdout);
|
||||
es_putc ('\n', es_stdout);
|
||||
}
|
||||
list_keyblock (keyblock, secret, opt.fingerprint,
|
||||
(!secret && opt.check_sigs)? &stats : NULL);
|
||||
@ -580,10 +577,10 @@ print_key_data (PKT_public_key * pk)
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
printf ("pkd:%d:%u:", i, mpi_get_nbits (pk->pkey[i]));
|
||||
mpi_print (stdout, pk->pkey[i], 1);
|
||||
putchar (':');
|
||||
putchar ('\n');
|
||||
es_fprintf (es_stdout, "pkd:%d:%u:", i, mpi_get_nbits (pk->pkey[i]));
|
||||
mpi_print (es_stdout, pk->pkey[i], 1);
|
||||
es_putc (':', es_stdout);
|
||||
es_putc ('\n', es_stdout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,14 +591,14 @@ print_capabilities (PKT_public_key *pk, KBNODE keyblock)
|
||||
int c_printed = 0;
|
||||
|
||||
if (use & PUBKEY_USAGE_ENC)
|
||||
putchar ('e');
|
||||
es_putc ('e', es_stdout);
|
||||
|
||||
if (use & PUBKEY_USAGE_SIG)
|
||||
{
|
||||
putchar ('s');
|
||||
es_putc ('s', es_stdout);
|
||||
if (pk->is_primary)
|
||||
{
|
||||
putchar ('c');
|
||||
es_putc ('c', es_stdout);
|
||||
/* The PUBKEY_USAGE_CERT flag was introduced later and we
|
||||
used to always print 'c' for a primary key. To avoid any
|
||||
regression here we better track whether we printed 'c'
|
||||
@ -611,10 +608,10 @@ print_capabilities (PKT_public_key *pk, KBNODE keyblock)
|
||||
}
|
||||
|
||||
if ((use & PUBKEY_USAGE_CERT) && !c_printed)
|
||||
putchar ('c');
|
||||
es_putc ('c', es_stdout);
|
||||
|
||||
if ((use & PUBKEY_USAGE_AUTH))
|
||||
putchar ('a');
|
||||
es_putc ('a', es_stdout);
|
||||
|
||||
if (keyblock)
|
||||
{
|
||||
@ -650,18 +647,18 @@ print_capabilities (PKT_public_key *pk, KBNODE keyblock)
|
||||
}
|
||||
}
|
||||
if (enc)
|
||||
putchar ('E');
|
||||
es_putc ('E', es_stdout);
|
||||
if (sign)
|
||||
putchar ('S');
|
||||
es_putc ('S', es_stdout);
|
||||
if (cert)
|
||||
putchar ('C');
|
||||
es_putc ('C', es_stdout);
|
||||
if (auth)
|
||||
putchar ('A');
|
||||
es_putc ('A', es_stdout);
|
||||
if (disabled)
|
||||
putchar ('D');
|
||||
es_putc ('D', es_stdout);
|
||||
}
|
||||
|
||||
putchar (':');
|
||||
es_putc (':', es_stdout);
|
||||
}
|
||||
|
||||
|
||||
@ -673,18 +670,18 @@ print_one_subpacket (sigsubpkttype_t type, size_t len, int flags,
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf ("spk:%d:%u:%u:", type, flags, (unsigned int) len);
|
||||
es_fprintf (es_stdout, "spk:%d:%u:%u:", type, flags, (unsigned int) len);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
/* printable ascii other than : and % */
|
||||
if (buf[i] >= 32 && buf[i] <= 126 && buf[i] != ':' && buf[i] != '%')
|
||||
printf ("%c", buf[i]);
|
||||
es_fprintf (es_stdout, "%c", buf[i]);
|
||||
else
|
||||
printf ("%%%02X", buf[i]);
|
||||
es_fprintf (es_stdout, "%%%02X", buf[i]);
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
es_fprintf (es_stdout, "\n");
|
||||
}
|
||||
|
||||
|
||||
@ -748,8 +745,8 @@ dump_attribs (const PKT_user_id *uid, PKT_public_key *pk)
|
||||
write_status_text (STATUS_ATTRIBUTE, buf);
|
||||
}
|
||||
|
||||
fwrite (uid->attribs[i].data, uid->attribs[i].len, 1, attrib_fp);
|
||||
fflush (attrib_fp);
|
||||
es_fwrite (uid->attribs[i].data, uid->attribs[i].len, 1, attrib_fp);
|
||||
es_fflush (attrib_fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,7 +779,7 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
|
||||
check_trustdb_stale ();
|
||||
|
||||
printf ("%s%c %4u%c/%s %s",
|
||||
es_fprintf (es_stdout, "%s%c %4u%c/%s %s",
|
||||
secret? "sec":"pub",
|
||||
s2k_char,
|
||||
nbits_from_pk (pk), pubkey_letter (pk->pubkey_algo),
|
||||
@ -790,21 +787,21 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
|
||||
if (pk->is_revoked)
|
||||
{
|
||||
printf (" [");
|
||||
printf (_("revoked: %s"), revokestr_from_pk (pk));
|
||||
printf ("]");
|
||||
es_fprintf (es_stdout, " [");
|
||||
es_fprintf (es_stdout, _("revoked: %s"), revokestr_from_pk (pk));
|
||||
es_fprintf (es_stdout, "]");
|
||||
}
|
||||
else if (pk->has_expired)
|
||||
{
|
||||
printf (" [");
|
||||
printf (_("expired: %s"), expirestr_from_pk (pk));
|
||||
printf ("]");
|
||||
es_fprintf (es_stdout, " [");
|
||||
es_fprintf (es_stdout, _("expired: %s"), expirestr_from_pk (pk));
|
||||
es_fprintf (es_stdout, "]");
|
||||
}
|
||||
else if (pk->expiredate)
|
||||
{
|
||||
printf (" [");
|
||||
printf (_("expires: %s"), expirestr_from_pk (pk));
|
||||
printf ("]");
|
||||
es_fprintf (es_stdout, " [");
|
||||
es_fprintf (es_stdout, _("expires: %s"), expirestr_from_pk (pk));
|
||||
es_fprintf (es_stdout, "]");
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -813,11 +810,11 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
if (opt.list_options & LIST_SHOW_VALIDITY)
|
||||
{
|
||||
int validity = get_validity (pk, NULL);
|
||||
printf (" [%s]", trust_value_to_string (validity));
|
||||
es_fprintf (es_stdout, " [%s]", trust_value_to_string (validity));
|
||||
}
|
||||
#endif
|
||||
|
||||
printf ("\n");
|
||||
es_fprintf (es_stdout, "\n");
|
||||
|
||||
if (fpr)
|
||||
print_fingerprint (pk, NULL, 0);
|
||||
@ -860,13 +857,13 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
if (indent < 0 || indent > 40)
|
||||
indent = 0;
|
||||
|
||||
printf ("uid%*s%s ", indent, "", validity);
|
||||
es_fprintf (es_stdout, "uid%*s%s ", indent, "", validity);
|
||||
}
|
||||
else
|
||||
printf ("uid%*s", (int) keystrlen () + 10, "");
|
||||
es_fprintf (es_stdout, "uid%*s", (int) keystrlen () + 10, "");
|
||||
|
||||
print_utf8_string (stdout, uid->name, uid->len);
|
||||
putchar ('\n');
|
||||
print_utf8_buffer (es_stdout, uid->name, uid->len);
|
||||
es_putc ('\n', es_stdout);
|
||||
|
||||
if ((opt.list_options & LIST_SHOW_PHOTOS) && uid->attribs != NULL)
|
||||
show_photos (uid->attribs, uid->numattribs, pk, NULL, uid);
|
||||
@ -888,30 +885,30 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
s2k_char = (/*(sk->protect.s2k.mode == 1001)? '#' :
|
||||
(sk->protect.s2k.mode == 1002)? '>' : */' ');
|
||||
|
||||
printf ("%s%c %4u%c/%s %s",
|
||||
es_fprintf (es_stdout, "%s%c %4u%c/%s %s",
|
||||
secret? "ssb":"sub",
|
||||
s2k_char,
|
||||
nbits_from_pk (pk2), pubkey_letter (pk2->pubkey_algo),
|
||||
keystr_from_pk (pk2), datestr_from_pk (pk2));
|
||||
if (pk2->is_revoked)
|
||||
{
|
||||
printf (" [");
|
||||
printf (_("revoked: %s"), revokestr_from_pk (pk2));
|
||||
printf ("]");
|
||||
es_fprintf (es_stdout, " [");
|
||||
es_fprintf (es_stdout, _("revoked: %s"), revokestr_from_pk (pk2));
|
||||
es_fprintf (es_stdout, "]");
|
||||
}
|
||||
else if (pk2->has_expired)
|
||||
{
|
||||
printf (" [");
|
||||
printf (_("expired: %s"), expirestr_from_pk (pk2));
|
||||
printf ("]");
|
||||
es_fprintf (es_stdout, " [");
|
||||
es_fprintf (es_stdout, _("expired: %s"), expirestr_from_pk (pk2));
|
||||
es_fprintf (es_stdout, "]");
|
||||
}
|
||||
else if (pk2->expiredate)
|
||||
{
|
||||
printf (" [");
|
||||
printf (_("expires: %s"), expirestr_from_pk (pk2));
|
||||
printf ("]");
|
||||
es_fprintf (es_stdout, " [");
|
||||
es_fprintf (es_stdout, _("expires: %s"), expirestr_from_pk (pk2));
|
||||
es_fprintf (es_stdout, "]");
|
||||
}
|
||||
putchar ('\n');
|
||||
es_putc ('\n', es_stdout);
|
||||
if (fpr > 1)
|
||||
{
|
||||
print_fingerprint (pk2, NULL, 0);
|
||||
@ -972,14 +969,14 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
sigstr = "sig";
|
||||
else
|
||||
{
|
||||
printf ("sig "
|
||||
es_fprintf (es_stdout, "sig "
|
||||
"[unexpected signature class 0x%02x]\n",
|
||||
sig->sig_class);
|
||||
continue;
|
||||
}
|
||||
|
||||
fputs (sigstr, stdout);
|
||||
printf ("%c%c %c%c%c%c%c%c %s %s",
|
||||
es_fputs (sigstr, es_stdout);
|
||||
es_fprintf (es_stdout, "%c%c %c%c%c%c%c%c %s %s",
|
||||
sigrc, (sig->sig_class - 0x10 > 0 &&
|
||||
sig->sig_class - 0x10 <
|
||||
4) ? '0' + sig->sig_class - 0x10 : ' ',
|
||||
@ -993,20 +990,20 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
sig->trust_depth : ' ', keystr (sig->keyid),
|
||||
datestr_from_sig (sig));
|
||||
if (opt.list_options & LIST_SHOW_SIG_EXPIRE)
|
||||
printf (" %s", expirestr_from_sig (sig));
|
||||
printf (" ");
|
||||
es_fprintf (es_stdout, " %s", expirestr_from_sig (sig));
|
||||
es_fprintf (es_stdout, " ");
|
||||
if (sigrc == '%')
|
||||
printf ("[%s] ", g10_errstr (rc));
|
||||
es_fprintf (es_stdout, "[%s] ", g10_errstr (rc));
|
||||
else if (sigrc == '?')
|
||||
;
|
||||
else if (!opt.fast_list_mode)
|
||||
{
|
||||
size_t n;
|
||||
char *p = get_user_id (sig->keyid, &n);
|
||||
print_utf8_string (stdout, p, n);
|
||||
print_utf8_buffer (es_stdout, p, n);
|
||||
xfree (p);
|
||||
}
|
||||
putchar ('\n');
|
||||
es_putc ('\n', es_stdout);
|
||||
|
||||
if (sig->flags.policy_url
|
||||
&& (opt.list_options & LIST_SHOW_POLICY_URLS))
|
||||
@ -1028,7 +1025,7 @@ list_keyblock_print (KBNODE keyblock, int secret, int fpr, void *opaque)
|
||||
/* fixme: check or list other sigs here */
|
||||
}
|
||||
}
|
||||
putchar ('\n');
|
||||
es_putc ('\n', es_stdout);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1045,11 +1042,11 @@ print_revokers (PKT_public_key * pk)
|
||||
{
|
||||
byte *p;
|
||||
|
||||
printf ("rvk:::%d::::::", pk->revkey[i].algid);
|
||||
es_fprintf (es_stdout, "rvk:::%d::::::", pk->revkey[i].algid);
|
||||
p = pk->revkey[i].fpr;
|
||||
for (j = 0; j < 20; j++, p++)
|
||||
printf ("%02X", *p);
|
||||
printf (":%02x%s:\n", pk->revkey[i].class,
|
||||
es_fprintf (es_stdout, "%02X", *p);
|
||||
es_fprintf (es_stdout, ":%02x%s:\n", pk->revkey[i].class,
|
||||
(pk->revkey[i].class & 0x40) ? "s" : "");
|
||||
}
|
||||
}
|
||||
@ -1079,13 +1076,13 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
pk = node->pkt->pkt.public_key;
|
||||
|
||||
keyid_from_pk (pk, keyid);
|
||||
fputs (secret? "sec:":"pub:", stdout);
|
||||
es_fputs (secret? "sec:":"pub:", es_stdout);
|
||||
if (!pk->is_valid)
|
||||
putchar ('i');
|
||||
es_putc ('i', es_stdout);
|
||||
else if (pk->is_revoked)
|
||||
putchar ('r');
|
||||
es_putc ('r', es_stdout);
|
||||
else if (pk->has_expired)
|
||||
putchar ('e');
|
||||
es_putc ('e', es_stdout);
|
||||
else if (opt.fast_list_mode || opt.no_expensive_trust_checks)
|
||||
;
|
||||
else
|
||||
@ -1093,39 +1090,39 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
trustletter = get_validity_info (pk, NULL);
|
||||
if (trustletter == 'u')
|
||||
ulti_hack = 1;
|
||||
putchar (trustletter);
|
||||
es_putc (trustletter, es_stdout);
|
||||
}
|
||||
|
||||
printf (":%u:%d:%08lX%08lX:%s:%s::",
|
||||
es_fprintf (es_stdout, ":%u:%d:%08lX%08lX:%s:%s::",
|
||||
nbits_from_pk (pk),
|
||||
pk->pubkey_algo,
|
||||
(ulong) keyid[0], (ulong) keyid[1],
|
||||
colon_datestr_from_pk (pk), colon_strtime (pk->expiredate));
|
||||
|
||||
if (!opt.fast_list_mode && !opt.no_expensive_trust_checks)
|
||||
putchar (get_ownertrust_info (pk));
|
||||
putchar (':');
|
||||
es_putc (get_ownertrust (pk), es_stdout);
|
||||
es_putc (':', es_stdout);
|
||||
|
||||
putchar (':');
|
||||
putchar (':');
|
||||
es_putc (':', es_stdout);
|
||||
es_putc (':', es_stdout);
|
||||
print_capabilities (pk, keyblock);
|
||||
if (secret)
|
||||
{
|
||||
putchar (':'); /* End of field 13. */
|
||||
putchar (':'); /* End of field 14. */
|
||||
es_putc (':', es_stdout); /* End of field 13. */
|
||||
es_putc (':', es_stdout); /* End of field 14. */
|
||||
if (/*FIXME sk->protect.s2k.mode*/1 == 1001)
|
||||
putchar ('#'); /* Key is just a stub. */
|
||||
es_putc ('#', es_stdout); /* Key is just a stub. */
|
||||
else if (/*FIXME sk->protect.s2k.mode*/1 == 1002)
|
||||
{
|
||||
/* Key is stored on an external token (card) or handled by
|
||||
the gpg-agent. Print the serial number of that token
|
||||
here. */
|
||||
/* FIXME: for (i = 0; i < sk->protect.ivlen; i++) */
|
||||
/* printf ("%02X", sk->protect.iv[i]); */
|
||||
/* es_fprintf (es_stdout, "%02X", sk->protect.iv[i]); */
|
||||
}
|
||||
putchar (':'); /* End of field 15. */
|
||||
es_putc (':', es_stdout); /* End of field 15. */
|
||||
}
|
||||
putchar ('\n');
|
||||
es_putc ('\n', es_stdout);
|
||||
|
||||
print_revokers (pk);
|
||||
if (fpr)
|
||||
@ -1147,11 +1144,11 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
*/
|
||||
str = uid->attrib_data ? "uat" : "uid";
|
||||
if (uid->is_revoked)
|
||||
printf ("%s:r::::", str);
|
||||
es_fprintf (es_stdout, "%s:r::::", str);
|
||||
else if (uid->is_expired)
|
||||
printf ("%s:e::::", str);
|
||||
es_fprintf (es_stdout, "%s:e::::", str);
|
||||
else if (opt.no_expensive_trust_checks)
|
||||
printf ("%s:::::", str);
|
||||
es_fprintf (es_stdout, "%s:::::", str);
|
||||
else
|
||||
{
|
||||
int uid_validity;
|
||||
@ -1160,25 +1157,25 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
uid_validity = get_validity_info (pk, uid);
|
||||
else
|
||||
uid_validity = 'u';
|
||||
printf ("%s:%c::::", str, uid_validity);
|
||||
es_fprintf (es_stdout, "%s:%c::::", str, uid_validity);
|
||||
}
|
||||
|
||||
printf ("%s:", colon_strtime (uid->created));
|
||||
printf ("%s:", colon_strtime (uid->expiredate));
|
||||
es_fprintf (es_stdout, "%s:", colon_strtime (uid->created));
|
||||
es_fprintf (es_stdout, "%s:", colon_strtime (uid->expiredate));
|
||||
|
||||
namehash_from_uid (uid);
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
printf ("%02X", uid->namehash[i]);
|
||||
es_fprintf (es_stdout, "%02X", uid->namehash[i]);
|
||||
|
||||
printf ("::");
|
||||
es_fprintf (es_stdout, "::");
|
||||
|
||||
if (uid->attrib_data)
|
||||
printf ("%u %lu", uid->numattribs, uid->attrib_len);
|
||||
es_fprintf (es_stdout, "%u %lu", uid->numattribs, uid->attrib_len);
|
||||
else
|
||||
print_string (stdout, uid->name, uid->len, ':');
|
||||
putchar (':');
|
||||
putchar ('\n');
|
||||
es_write_sanitized (es_stdout, uid->name, uid->len, ":", NULL);
|
||||
es_putc (':', es_stdout);
|
||||
es_putc ('\n', es_stdout);
|
||||
}
|
||||
else if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
|
||||
{
|
||||
@ -1186,22 +1183,22 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
PKT_public_key *pk2 = node->pkt->pkt.public_key;
|
||||
|
||||
keyid_from_pk (pk2, keyid2);
|
||||
fputs (secret? "ssb:":"sub:", stdout);
|
||||
es_fputs (secret? "ssb:":"sub:", es_stdout);
|
||||
if (!pk2->is_valid)
|
||||
putchar ('i');
|
||||
es_putc ('i', es_stdout);
|
||||
else if (pk2->is_revoked)
|
||||
putchar ('r');
|
||||
es_putc ('r', es_stdout);
|
||||
else if (pk2->has_expired)
|
||||
putchar ('e');
|
||||
es_putc ('e', es_stdout);
|
||||
else if (opt.fast_list_mode || opt.no_expensive_trust_checks)
|
||||
;
|
||||
else
|
||||
{
|
||||
/* TRUSTLETTER should always be defined here. */
|
||||
if (trustletter)
|
||||
printf ("%c", trustletter);
|
||||
es_fprintf (es_stdout, "%c", trustletter);
|
||||
}
|
||||
printf (":%u:%d:%08lX%08lX:%s:%s:::::",
|
||||
es_fprintf (es_stdout, ":%u:%d:%08lX%08lX:%s:%s:::::",
|
||||
nbits_from_pk (pk2),
|
||||
pk2->pubkey_algo,
|
||||
(ulong) keyid2[0], (ulong) keyid2[1],
|
||||
@ -1211,21 +1208,21 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
print_capabilities (pk2, NULL);
|
||||
if (secret)
|
||||
{
|
||||
putchar (':'); /* End of field 13. */
|
||||
putchar (':'); /* End of field 14. */
|
||||
es_putc (':', es_stdout); /* End of field 13. */
|
||||
es_putc (':', es_stdout); /* End of field 14. */
|
||||
if (/*FIXME:sk2->protect.s2k.mode*/1 == 1001)
|
||||
putchar ('#'); /* Key is just a stub. */
|
||||
es_putc ('#', es_stdout); /* Key is just a stub. */
|
||||
else if (/*FIXME: sk2->protect.s2k.mode*/1 == 1002)
|
||||
{
|
||||
/* Key is stored on an external token (card) or
|
||||
handled by the gpg-agent. Print the serial
|
||||
number of that token here. */
|
||||
/* FIXME: for (i = 0; i < sk2->protect.ivlen; i++)
|
||||
printf ("%02X", sk2->protect.iv[i]); */
|
||||
es_fprintf (es_stdout, "%02X", sk2->protect.iv[i]); */
|
||||
}
|
||||
putchar (':'); /* End of field 15. */
|
||||
es_putc (':', es_stdout); /* End of field 15. */
|
||||
}
|
||||
putchar ('\n');
|
||||
es_putc ('\n', es_stdout);
|
||||
if (fpr > 1)
|
||||
print_fingerprint (pk2, NULL, 0);
|
||||
if (opt.with_key_data)
|
||||
@ -1250,7 +1247,7 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
sigstr = "sig";
|
||||
else
|
||||
{
|
||||
printf ("sig::::::::::%02x%c:\n",
|
||||
es_fprintf (es_stdout, "sig::::::::::%02x%c:\n",
|
||||
sig->sig_class, sig->flags.exportable ? 'x' : 'l');
|
||||
continue;
|
||||
}
|
||||
@ -1297,49 +1294,49 @@ list_keyblock_colon (KBNODE keyblock, int secret, int fpr)
|
||||
rc = 0;
|
||||
sigrc = ' ';
|
||||
}
|
||||
fputs (sigstr, stdout);
|
||||
putchar (':');
|
||||
es_fputs (sigstr, es_stdout);
|
||||
es_putc (':', es_stdout);
|
||||
if (sigrc != ' ')
|
||||
putchar (sigrc);
|
||||
printf ("::%d:%08lX%08lX:%s:%s:", sig->pubkey_algo,
|
||||
es_putc (sigrc, es_stdout);
|
||||
es_fprintf (es_stdout, "::%d:%08lX%08lX:%s:%s:", sig->pubkey_algo,
|
||||
(ulong) sig->keyid[0], (ulong) sig->keyid[1],
|
||||
colon_datestr_from_sig (sig),
|
||||
colon_expirestr_from_sig (sig));
|
||||
|
||||
if (sig->trust_depth || sig->trust_value)
|
||||
printf ("%d %d", sig->trust_depth, sig->trust_value);
|
||||
printf (":");
|
||||
es_fprintf (es_stdout, "%d %d", sig->trust_depth, sig->trust_value);
|
||||
es_fprintf (es_stdout, ":");
|
||||
|
||||
if (sig->trust_regexp)
|
||||
print_string (stdout, sig->trust_regexp,
|
||||
strlen (sig->trust_regexp), ':');
|
||||
printf (":");
|
||||
es_write_sanitized (es_stdout, sig->trust_regexp,
|
||||
strlen (sig->trust_regexp), ":", NULL);
|
||||
es_fprintf (es_stdout, ":");
|
||||
|
||||
if (sigrc == '%')
|
||||
printf ("[%s] ", g10_errstr (rc));
|
||||
es_fprintf (es_stdout, "[%s] ", g10_errstr (rc));
|
||||
else if (sigrc == '?')
|
||||
;
|
||||
else if (!opt.fast_list_mode)
|
||||
{
|
||||
size_t n;
|
||||
char *p = get_user_id (sig->keyid, &n);
|
||||
print_string (stdout, p, n, ':');
|
||||
es_write_sanitized (es_stdout, p, n, ":", NULL);
|
||||
xfree (p);
|
||||
}
|
||||
printf (":%02x%c:", sig->sig_class,
|
||||
es_fprintf (es_stdout, ":%02x%c:", sig->sig_class,
|
||||
sig->flags.exportable ? 'x' : 'l');
|
||||
|
||||
if (opt.no_sig_cache && opt.check_sigs && fprokay)
|
||||
{
|
||||
putchar (':');
|
||||
es_putc (':', es_stdout);
|
||||
|
||||
for (i = 0; i < fplen; i++)
|
||||
printf ("%02X", fparray[i]);
|
||||
es_fprintf (es_stdout, "%02X", fparray[i]);
|
||||
|
||||
putchar (':');
|
||||
es_putc (':', es_stdout);
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
es_fprintf (es_stdout, "\n");
|
||||
|
||||
if (opt.show_subpackets)
|
||||
print_subpackets_colon (sig);
|
||||
@ -1428,7 +1425,7 @@ print_fingerprint (PKT_public_key * pk, PKT_secret_key * sk, int mode)
|
||||
{
|
||||
byte array[MAX_FINGERPRINT_LEN], *p;
|
||||
size_t i, n;
|
||||
FILE *fp;
|
||||
estream_t fp;
|
||||
const char *text;
|
||||
int primary = 0;
|
||||
|
||||
@ -1497,7 +1494,7 @@ print_fingerprint (PKT_public_key * pk, PKT_secret_key * sk, int mode)
|
||||
}
|
||||
else
|
||||
{
|
||||
fp = stdout;
|
||||
fp = es_stdout;
|
||||
text = _(" Key fingerprint =");
|
||||
}
|
||||
|
||||
@ -1508,58 +1505,26 @@ print_fingerprint (PKT_public_key * pk, PKT_secret_key * sk, int mode)
|
||||
p = array;
|
||||
if (opt.with_colons && !mode)
|
||||
{
|
||||
fprintf (fp, "fpr:::::::::");
|
||||
es_fprintf (fp, "fpr:::::::::");
|
||||
for (i = 0; i < n; i++, p++)
|
||||
fprintf (fp, "%02X", *p);
|
||||
putc (':', fp);
|
||||
es_fprintf (fp, "%02X", *p);
|
||||
es_putc (':', fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fp)
|
||||
fputs (text, fp);
|
||||
else
|
||||
tty_printf ("%s", text);
|
||||
tty_fprintf (fp, "%s", text);
|
||||
if (n == 20)
|
||||
{
|
||||
for (i = 0; i < n; i++, i++, p += 2)
|
||||
{
|
||||
if (fp)
|
||||
{
|
||||
if (i == 10)
|
||||
putc (' ', fp);
|
||||
fprintf (fp, " %02X%02X", *p, p[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == 10)
|
||||
tty_printf (" ");
|
||||
tty_printf (" %02X%02X", *p, p[1]);
|
||||
}
|
||||
}
|
||||
tty_fprintf (fp, "%s %02X%02X", i==10? " ":"", *p, p[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < n; i++, p++)
|
||||
{
|
||||
if (fp)
|
||||
{
|
||||
if (i && !(i % 8))
|
||||
putc (' ', fp);
|
||||
fprintf (fp, " %02X", *p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i && !(i % 8))
|
||||
tty_printf (" ");
|
||||
tty_printf (" %02X", *p);
|
||||
}
|
||||
}
|
||||
tty_fprintf (fp, "%s %02X", (i && !(i % 8))? " ":"", *p);
|
||||
}
|
||||
}
|
||||
if (fp)
|
||||
putc ('\n', fp);
|
||||
else
|
||||
tty_printf ("\n");
|
||||
tty_fprintf (fp, "\n");
|
||||
}
|
||||
|
||||
/* Print the serial number of an OpenPGP card if available. */
|
||||
@ -1575,8 +1540,8 @@ print_card_serialno (PKT_secret_key * sk)
|
||||
if (opt.with_colons)
|
||||
return; /* Handled elsewhere. */
|
||||
|
||||
fputs (_(" Card serial no. ="), stdout);
|
||||
putchar (' ');
|
||||
es_fputs (_(" Card serial no. ="), es_stdout);
|
||||
es_putc (' ', es_stdout);
|
||||
if (sk->protect.ivlen == 16
|
||||
&& !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6))
|
||||
{
|
||||
@ -1584,17 +1549,17 @@ print_card_serialno (PKT_secret_key * sk)
|
||||
for (i = 8; i < 14; i++)
|
||||
{
|
||||
if (i == 10)
|
||||
putchar (' ');
|
||||
printf ("%02X", sk->protect.iv[i]);
|
||||
es_putc (' ', es_stdout);
|
||||
es_fprintf (es_stdout, "%02X", sk->protect.iv[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Something is wrong: Print all. */
|
||||
for (i = 0; i < sk->protect.ivlen; i++)
|
||||
printf ("%02X", sk->protect.iv[i]);
|
||||
es_fprintf (es_stdout, "%02X", sk->protect.iv[i]);
|
||||
}
|
||||
putchar ('\n');
|
||||
es_putc ('\n', es_stdout);
|
||||
}
|
||||
|
||||
|
||||
@ -1607,9 +1572,9 @@ set_attrib_fd (int fd)
|
||||
if (fd != -1 && last_fd == fd)
|
||||
return;
|
||||
|
||||
if (attrib_fp && attrib_fp != stdout && attrib_fp != stderr
|
||||
&& attrib_fp != log_get_stream ())
|
||||
fclose (attrib_fp);
|
||||
/* Fixme: Do we need to check for the log stream here? */
|
||||
if (attrib_fp && attrib_fp != log_get_stream ())
|
||||
es_fclose (attrib_fp);
|
||||
attrib_fp = NULL;
|
||||
if (fd == -1)
|
||||
return;
|
||||
@ -1618,11 +1583,11 @@ set_attrib_fd (int fd)
|
||||
setmode (fd, O_BINARY);
|
||||
#endif
|
||||
if (fd == 1)
|
||||
attrib_fp = stdout;
|
||||
attrib_fp = es_stdout;
|
||||
else if (fd == 2)
|
||||
attrib_fp = stderr;
|
||||
attrib_fp = es_stderr;
|
||||
else
|
||||
attrib_fp = fdopen (fd, "wb");
|
||||
attrib_fp = es_fdopen (fd, "wb");
|
||||
if (!attrib_fp)
|
||||
{
|
||||
log_fatal ("can't open fd %d for attribute output: %s\n",
|
||||
|
@ -149,7 +149,7 @@ int pubkey_get_nskey( int algo );
|
||||
int pubkey_get_nsig( int algo );
|
||||
int pubkey_get_nenc( int algo );
|
||||
unsigned int pubkey_nbits( int algo, gcry_mpi_t *pkey );
|
||||
int mpi_print( FILE *fp, gcry_mpi_t a, int mode );
|
||||
int mpi_print (estream_t stream, gcry_mpi_t a, int mode);
|
||||
|
||||
/*-- status.c --*/
|
||||
void set_status_fd ( int fd );
|
||||
@ -308,8 +308,8 @@ void show_notation(PKT_signature *sig,int indent,int mode,int which);
|
||||
void dump_attribs (const PKT_user_id *uid, PKT_public_key *pk);
|
||||
void set_attrib_fd(int fd);
|
||||
void print_seckey_info (PKT_public_key *pk);
|
||||
void print_pubkey_info (FILE *fp, PKT_public_key *pk);
|
||||
void print_card_key_info (FILE *fp, KBNODE keyblock);
|
||||
void print_pubkey_info (estream_t fp, PKT_public_key *pk);
|
||||
void print_card_key_info (estream_t fp, KBNODE keyblock);
|
||||
|
||||
/*-- verify.c --*/
|
||||
void print_file_status( int status, const char *name, int what );
|
||||
@ -341,7 +341,7 @@ int gpg_server (ctrl_t);
|
||||
#ifdef ENABLE_CARD_SUPPORT
|
||||
/*-- card-util.c --*/
|
||||
void change_pin (int no, int allow_admin);
|
||||
void card_status (FILE *fp, char *serialno, size_t serialnobuflen);
|
||||
void card_status (estream_t fp, char *serialno, size_t serialnobuflen);
|
||||
void card_edit (strlist_t commands);
|
||||
int card_generate_subkey (KBNODE pub_keyblock, KBNODE sec_keyblock);
|
||||
int card_store_subkey (KBNODE node, int use);
|
||||
|
@ -892,12 +892,12 @@ print_userid( PACKET *pkt )
|
||||
pkt->pkt.user_id->numattribs,
|
||||
pkt->pkt.user_id->attrib_len);
|
||||
else
|
||||
print_string( stdout, pkt->pkt.user_id->name,
|
||||
pkt->pkt.user_id->len, ':');
|
||||
es_write_sanitized (es_stdout, pkt->pkt.user_id->name,
|
||||
pkt->pkt.user_id->len, ":", NULL);
|
||||
}
|
||||
else
|
||||
print_utf8_string( stdout, pkt->pkt.user_id->name,
|
||||
pkt->pkt.user_id->len );
|
||||
print_utf8_buffer (es_stdout, pkt->pkt.user_id->name,
|
||||
pkt->pkt.user_id->len );
|
||||
}
|
||||
|
||||
|
||||
@ -1135,8 +1135,8 @@ list_node( CTX c, KBNODE node )
|
||||
printf(":");
|
||||
|
||||
if(sig->trust_regexp)
|
||||
print_string(stdout,sig->trust_regexp,
|
||||
strlen(sig->trust_regexp),':');
|
||||
es_write_sanitized (es_stdout,sig->trust_regexp,
|
||||
strlen(sig->trust_regexp), ":", NULL);
|
||||
printf(":");
|
||||
}
|
||||
else
|
||||
@ -1155,7 +1155,8 @@ list_node( CTX c, KBNODE node )
|
||||
}
|
||||
else if( !opt.fast_list_mode ) {
|
||||
p = get_user_id( sig->keyid, &n );
|
||||
print_string( stdout, p, n, opt.with_colons );
|
||||
es_write_sanitized (es_stdout, p, n,
|
||||
opt.with_colons?":":NULL, NULL );
|
||||
xfree(p);
|
||||
}
|
||||
if( opt.with_colons )
|
||||
@ -1633,7 +1634,7 @@ check_sig_and_print( CTX c, KBNODE node )
|
||||
page, but "from" if it is located on a keyserver. I'm
|
||||
not going to even try to make two strings here :) */
|
||||
log_info(_("Key available at: ") );
|
||||
print_utf8_string( log_get_stream(), p, n );
|
||||
print_utf8_buffer (log_get_stream(), p, n);
|
||||
log_printf ("\n");
|
||||
|
||||
if(opt.keyserver_options.options&KEYSERVER_AUTO_KEY_RETRIEVE
|
||||
|
38
g10/misc.c
38
g10/misc.c
@ -1394,26 +1394,28 @@ pubkey_nbits( int algo, gcry_mpi_t *key )
|
||||
|
||||
/* FIXME: Use gcry_mpi_print directly. */
|
||||
int
|
||||
mpi_print( FILE *fp, gcry_mpi_t a, int mode )
|
||||
mpi_print (estream_t fp, gcry_mpi_t a, int mode)
|
||||
{
|
||||
int n=0;
|
||||
|
||||
if( !a )
|
||||
return fprintf(fp, "[MPI_NULL]");
|
||||
if( !mode ) {
|
||||
unsigned int n1;
|
||||
n1 = gcry_mpi_get_nbits(a);
|
||||
n += fprintf(fp, "[%u bits]", n1);
|
||||
int n=0;
|
||||
|
||||
if (!a)
|
||||
return es_fprintf (fp, "[MPI_NULL]");
|
||||
if (!mode)
|
||||
{
|
||||
unsigned int n1;
|
||||
n1 = gcry_mpi_get_nbits(a);
|
||||
n += es_fprintf (fp, "[%u bits]", n1);
|
||||
}
|
||||
else {
|
||||
unsigned char *buffer;
|
||||
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buffer, NULL, a))
|
||||
BUG ();
|
||||
fputs( buffer, fp );
|
||||
n += strlen(buffer);
|
||||
gcry_free( buffer );
|
||||
else
|
||||
{
|
||||
unsigned char *buffer;
|
||||
|
||||
if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buffer, NULL, a))
|
||||
BUG ();
|
||||
es_fputs (buffer, fp);
|
||||
n += strlen (buffer);
|
||||
gcry_free (buffer);
|
||||
}
|
||||
return n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* parse-packet.c - read packets
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
* 2007, 2009 Free Software Foundation, Inc.
|
||||
* 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
static int mpi_print_mode;
|
||||
static int list_mode;
|
||||
static FILE *listfp;
|
||||
static estream_t listfp;
|
||||
|
||||
static int parse (IOBUF inp, PACKET * pkt, int onlykeypkts,
|
||||
off_t * retpos, int *skip, IOBUF out, int do_skip
|
||||
@ -169,7 +169,7 @@ set_packet_list_mode (int mode)
|
||||
list_mode = mode;
|
||||
/* FIXME(gcrypt) mpi_print_mode = DBG_MPI; */
|
||||
/* We use stdout print only if invoked by the --list-packets command
|
||||
but switch to stderr in all otehr cases. This breaks the
|
||||
but switch to stderr in all other cases. This breaks the
|
||||
previous behaviour but that seems to be more of a bug than
|
||||
intentional. I don't believe that any application makes use of
|
||||
this long standing annoying way of printing to stdout except when
|
||||
@ -180,11 +180,11 @@ set_packet_list_mode (int mode)
|
||||
stream.
|
||||
|
||||
Using stderr is not actually very clean because it bypasses the
|
||||
logging code but it is a special thing anyay. I am not sure
|
||||
logging code but it is a special thing anyway. I am not sure
|
||||
whether using log_stream() would be better. Perhaps we should
|
||||
enable the list mdoe only with a special option. */
|
||||
if (!listfp)
|
||||
listfp = opt.list_packets == 2 ? stdout : stderr;
|
||||
listfp = opt.list_packets == 2 ? es_stdout : es_stderr;
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -639,14 +639,14 @@ dump_hex_line (int c, int *i)
|
||||
if (*i && !(*i % 8))
|
||||
{
|
||||
if (*i && !(*i % 24))
|
||||
fprintf (listfp, "\n%4d:", *i);
|
||||
es_fprintf (listfp, "\n%4d:", *i);
|
||||
else
|
||||
putc (' ', listfp);
|
||||
es_putc (' ', listfp);
|
||||
}
|
||||
if (c == -1)
|
||||
fprintf (listfp, " EOF");
|
||||
es_fprintf (listfp, " EOF");
|
||||
else
|
||||
fprintf (listfp, " %02x", c);
|
||||
es_fprintf (listfp, " %02x", c);
|
||||
++*i;
|
||||
}
|
||||
|
||||
@ -694,12 +694,12 @@ skip_packet (IOBUF inp, int pkttype, unsigned long pktlen, int partial)
|
||||
{
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, ":unknown packet: type %2d, length %lu\n",
|
||||
pkttype, pktlen);
|
||||
es_fprintf (listfp, ":unknown packet: type %2d, length %lu\n",
|
||||
pkttype, pktlen);
|
||||
if (pkttype)
|
||||
{
|
||||
int c, i = 0;
|
||||
fputs ("dump:", listfp);
|
||||
es_fputs ("dump:", listfp);
|
||||
if (partial)
|
||||
{
|
||||
while ((c = iobuf_get (inp)) != -1)
|
||||
@ -714,7 +714,7 @@ skip_packet (IOBUF inp, int pkttype, unsigned long pktlen, int partial)
|
||||
break;
|
||||
}
|
||||
}
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -770,7 +770,7 @@ parse_marker (IOBUF inp, int pkttype, unsigned long pktlen)
|
||||
}
|
||||
|
||||
if (list_mode)
|
||||
fputs (":marker packet: PGP\n", listfp);
|
||||
es_fputs (":marker packet: PGP\n", listfp);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -870,22 +870,21 @@ parse_symkeyenc (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp,
|
||||
":symkey enc packet: version %d, cipher %d, s2k %d, hash %d",
|
||||
version, cipher_algo, s2kmode, hash_algo);
|
||||
es_fprintf (listfp,
|
||||
":symkey enc packet: version %d, cipher %d, s2k %d, hash %d",
|
||||
version, cipher_algo, s2kmode, hash_algo);
|
||||
if (seskeylen)
|
||||
fprintf (listfp, ", seskey %d bits", (seskeylen - 1) * 8);
|
||||
fprintf (listfp, "\n");
|
||||
es_fprintf (listfp, ", seskey %d bits", (seskeylen - 1) * 8);
|
||||
es_fprintf (listfp, "\n");
|
||||
if (s2kmode == 1 || s2kmode == 3)
|
||||
{
|
||||
fprintf (listfp, "\tsalt ");
|
||||
for (i = 0; i < 8; i++)
|
||||
fprintf (listfp, "%02x", k->s2k.salt[i]);
|
||||
es_fprintf (listfp, "\tsalt ");
|
||||
es_write_hexstring (listfp, k->s2k.salt, 8, 0, NULL);
|
||||
if (s2kmode == 3)
|
||||
fprintf (listfp, ", count %lu (%lu)",
|
||||
S2K_DECODE_COUNT ((ulong) k->s2k.count),
|
||||
(ulong) k->s2k.count);
|
||||
fprintf (listfp, "\n");
|
||||
es_fprintf (listfp, ", count %lu (%lu)",
|
||||
S2K_DECODE_COUNT ((ulong) k->s2k.count),
|
||||
(ulong) k->s2k.count);
|
||||
es_fprintf (listfp, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -927,16 +926,16 @@ parse_pubkeyenc (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen--;
|
||||
k->throw_keyid = 0; /* Only used as flag for build_packet. */
|
||||
if (list_mode)
|
||||
fprintf (listfp,
|
||||
":pubkey enc packet: version %d, algo %d, keyid %08lX%08lX\n",
|
||||
k->version, k->pubkey_algo, (ulong) k->keyid[0],
|
||||
(ulong) k->keyid[1]);
|
||||
es_fprintf (listfp,
|
||||
":pubkey enc packet: version %d, algo %d, keyid %08lX%08lX\n",
|
||||
k->version, k->pubkey_algo, (ulong) k->keyid[0],
|
||||
(ulong) k->keyid[1]);
|
||||
|
||||
ndata = pubkey_get_nenc (k->pubkey_algo);
|
||||
if (!ndata)
|
||||
{
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tunsupported algorithm %d\n", k->pubkey_algo);
|
||||
es_fprintf (listfp, "\tunsupported algorithm %d\n", k->pubkey_algo);
|
||||
unknown_pubkey_warning (k->pubkey_algo);
|
||||
k->data[0] = NULL; /* No need to store the encrypted data. */
|
||||
}
|
||||
@ -949,9 +948,9 @@ parse_pubkeyenc (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen -= n;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tdata: ");
|
||||
es_fprintf (listfp, "\tdata: ");
|
||||
mpi_print (listfp, k->data[i], mpi_print_mode);
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
if (!k->data[i])
|
||||
rc = gpg_error (GPG_ERR_INV_PACKET);
|
||||
@ -976,98 +975,98 @@ dump_sig_subpkt (int hashed, int type, int critical,
|
||||
* and add an additional notice. */
|
||||
if (type == SIGSUBPKT_ARR && !hashed)
|
||||
{
|
||||
fprintf (listfp,
|
||||
"\tsubpkt %d len %u (additional recipient request)\n"
|
||||
"WARNING: PGP versions > 5.0 and < 6.5.8 will automagically "
|
||||
"encrypt to this key and thereby reveal the plaintext to "
|
||||
"the owner of this ARR key. Detailed info follows:\n",
|
||||
type, (unsigned) length);
|
||||
es_fprintf (listfp,
|
||||
"\tsubpkt %d len %u (additional recipient request)\n"
|
||||
"WARNING: PGP versions > 5.0 and < 6.5.8 will automagically "
|
||||
"encrypt to this key and thereby reveal the plaintext to "
|
||||
"the owner of this ARR key. Detailed info follows:\n",
|
||||
type, (unsigned) length);
|
||||
}
|
||||
|
||||
buffer++;
|
||||
length--;
|
||||
|
||||
fprintf (listfp, "\t%s%ssubpkt %d len %u (", /*) */
|
||||
critical ? "critical " : "",
|
||||
hashed ? "hashed " : "", type, (unsigned) length);
|
||||
es_fprintf (listfp, "\t%s%ssubpkt %d len %u (", /*) */
|
||||
critical ? "critical " : "",
|
||||
hashed ? "hashed " : "", type, (unsigned) length);
|
||||
if (length > buflen)
|
||||
{
|
||||
fprintf (listfp, "too short: buffer is only %u)\n", (unsigned) buflen);
|
||||
es_fprintf (listfp, "too short: buffer is only %u)\n", (unsigned) buflen);
|
||||
return;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case SIGSUBPKT_SIG_CREATED:
|
||||
if (length >= 4)
|
||||
fprintf (listfp, "sig created %s",
|
||||
strtimestamp (buffer_to_u32 (buffer)));
|
||||
es_fprintf (listfp, "sig created %s",
|
||||
strtimestamp (buffer_to_u32 (buffer)));
|
||||
break;
|
||||
case SIGSUBPKT_SIG_EXPIRE:
|
||||
if (length >= 4)
|
||||
{
|
||||
if (buffer_to_u32 (buffer))
|
||||
fprintf (listfp, "sig expires after %s",
|
||||
strtimevalue (buffer_to_u32 (buffer)));
|
||||
es_fprintf (listfp, "sig expires after %s",
|
||||
strtimevalue (buffer_to_u32 (buffer)));
|
||||
else
|
||||
fprintf (listfp, "sig does not expire");
|
||||
es_fprintf (listfp, "sig does not expire");
|
||||
}
|
||||
break;
|
||||
case SIGSUBPKT_EXPORTABLE:
|
||||
if (length)
|
||||
fprintf (listfp, "%sexportable", *buffer ? "" : "not ");
|
||||
es_fprintf (listfp, "%sexportable", *buffer ? "" : "not ");
|
||||
break;
|
||||
case SIGSUBPKT_TRUST:
|
||||
if (length != 2)
|
||||
p = "[invalid trust subpacket]";
|
||||
else
|
||||
fprintf (listfp, "trust signature of depth %d, value %d", buffer[0],
|
||||
buffer[1]);
|
||||
es_fprintf (listfp, "trust signature of depth %d, value %d", buffer[0],
|
||||
buffer[1]);
|
||||
break;
|
||||
case SIGSUBPKT_REGEXP:
|
||||
if (!length)
|
||||
p = "[invalid regexp subpacket]";
|
||||
else
|
||||
fprintf (listfp, "regular expression: \"%s\"", buffer);
|
||||
es_fprintf (listfp, "regular expression: \"%s\"", buffer);
|
||||
break;
|
||||
case SIGSUBPKT_REVOCABLE:
|
||||
if (length)
|
||||
fprintf (listfp, "%srevocable", *buffer ? "" : "not ");
|
||||
es_fprintf (listfp, "%srevocable", *buffer ? "" : "not ");
|
||||
break;
|
||||
case SIGSUBPKT_KEY_EXPIRE:
|
||||
if (length >= 4)
|
||||
{
|
||||
if (buffer_to_u32 (buffer))
|
||||
fprintf (listfp, "key expires after %s",
|
||||
strtimevalue (buffer_to_u32 (buffer)));
|
||||
es_fprintf (listfp, "key expires after %s",
|
||||
strtimevalue (buffer_to_u32 (buffer)));
|
||||
else
|
||||
fprintf (listfp, "key does not expire");
|
||||
es_fprintf (listfp, "key does not expire");
|
||||
}
|
||||
break;
|
||||
case SIGSUBPKT_PREF_SYM:
|
||||
fputs ("pref-sym-algos:", listfp);
|
||||
es_fputs ("pref-sym-algos:", listfp);
|
||||
for (i = 0; i < length; i++)
|
||||
fprintf (listfp, " %d", buffer[i]);
|
||||
es_fprintf (listfp, " %d", buffer[i]);
|
||||
break;
|
||||
case SIGSUBPKT_REV_KEY:
|
||||
fputs ("revocation key: ", listfp);
|
||||
es_fputs ("revocation key: ", listfp);
|
||||
if (length < 22)
|
||||
p = "[too short]";
|
||||
else
|
||||
{
|
||||
fprintf (listfp, "c=%02x a=%d f=", buffer[0], buffer[1]);
|
||||
es_fprintf (listfp, "c=%02x a=%d f=", buffer[0], buffer[1]);
|
||||
for (i = 2; i < length; i++)
|
||||
fprintf (listfp, "%02X", buffer[i]);
|
||||
es_fprintf (listfp, "%02X", buffer[i]);
|
||||
}
|
||||
break;
|
||||
case SIGSUBPKT_ISSUER:
|
||||
if (length >= 8)
|
||||
fprintf (listfp, "issuer key ID %08lX%08lX",
|
||||
(ulong) buffer_to_u32 (buffer),
|
||||
(ulong) buffer_to_u32 (buffer + 4));
|
||||
es_fprintf (listfp, "issuer key ID %08lX%08lX",
|
||||
(ulong) buffer_to_u32 (buffer),
|
||||
(ulong) buffer_to_u32 (buffer + 4));
|
||||
break;
|
||||
case SIGSUBPKT_NOTATION:
|
||||
{
|
||||
fputs ("notation: ", listfp);
|
||||
es_fputs ("notation: ", listfp);
|
||||
if (length < 8)
|
||||
p = "[too short]";
|
||||
else
|
||||
@ -1082,11 +1081,11 @@ dump_sig_subpkt (int hashed, int type, int critical,
|
||||
p = "[error]";
|
||||
else
|
||||
{
|
||||
print_string (listfp, s, n1, ')');
|
||||
putc ('=', listfp);
|
||||
es_write_sanitized (listfp, s, n1, ")", NULL);
|
||||
es_putc ('=', listfp);
|
||||
|
||||
if (*buffer & 0x80)
|
||||
print_string (listfp, s + n1, n2, ')');
|
||||
es_write_sanitized (listfp, s + n1, n2, ")", NULL);
|
||||
else
|
||||
p = "[not human readable]";
|
||||
}
|
||||
@ -1094,35 +1093,35 @@ dump_sig_subpkt (int hashed, int type, int critical,
|
||||
}
|
||||
break;
|
||||
case SIGSUBPKT_PREF_HASH:
|
||||
fputs ("pref-hash-algos:", listfp);
|
||||
es_fputs ("pref-hash-algos:", listfp);
|
||||
for (i = 0; i < length; i++)
|
||||
fprintf (listfp, " %d", buffer[i]);
|
||||
es_fprintf (listfp, " %d", buffer[i]);
|
||||
break;
|
||||
case SIGSUBPKT_PREF_COMPR:
|
||||
fputs ("pref-zip-algos:", listfp);
|
||||
es_fputs ("pref-zip-algos:", listfp);
|
||||
for (i = 0; i < length; i++)
|
||||
fprintf (listfp, " %d", buffer[i]);
|
||||
es_fprintf (listfp, " %d", buffer[i]);
|
||||
break;
|
||||
case SIGSUBPKT_KS_FLAGS:
|
||||
fputs ("key server preferences:", listfp);
|
||||
es_fputs ("key server preferences:", listfp);
|
||||
for (i = 0; i < length; i++)
|
||||
fprintf (listfp, " %02X", buffer[i]);
|
||||
es_fprintf (listfp, " %02X", buffer[i]);
|
||||
break;
|
||||
case SIGSUBPKT_PREF_KS:
|
||||
fputs ("preferred key server: ", listfp);
|
||||
print_string (listfp, buffer, length, ')');
|
||||
es_fputs ("preferred key server: ", listfp);
|
||||
es_write_sanitized (listfp, buffer, length, ")", NULL);
|
||||
break;
|
||||
case SIGSUBPKT_PRIMARY_UID:
|
||||
p = "primary user ID";
|
||||
break;
|
||||
case SIGSUBPKT_POLICY:
|
||||
fputs ("policy: ", listfp);
|
||||
print_string (listfp, buffer, length, ')');
|
||||
es_fputs ("policy: ", listfp);
|
||||
es_write_sanitized (listfp, buffer, length, ")", NULL);
|
||||
break;
|
||||
case SIGSUBPKT_KEY_FLAGS:
|
||||
fputs ("key flags:", listfp);
|
||||
es_fputs ("key flags:", listfp);
|
||||
for (i = 0; i < length; i++)
|
||||
fprintf (listfp, " %02X", buffer[i]);
|
||||
es_fprintf (listfp, " %02X", buffer[i]);
|
||||
break;
|
||||
case SIGSUBPKT_SIGNERS_UID:
|
||||
p = "signer's user ID";
|
||||
@ -1130,37 +1129,37 @@ dump_sig_subpkt (int hashed, int type, int critical,
|
||||
case SIGSUBPKT_REVOC_REASON:
|
||||
if (length)
|
||||
{
|
||||
fprintf (listfp, "revocation reason 0x%02x (", *buffer);
|
||||
print_string (listfp, buffer + 1, length - 1, ')');
|
||||
es_fprintf (listfp, "revocation reason 0x%02x (", *buffer);
|
||||
es_write_sanitized (listfp, buffer + 1, length - 1, ")", NULL);
|
||||
p = ")";
|
||||
}
|
||||
break;
|
||||
case SIGSUBPKT_ARR:
|
||||
fputs ("Big Brother's key (ignored): ", listfp);
|
||||
es_fputs ("Big Brother's key (ignored): ", listfp);
|
||||
if (length < 22)
|
||||
p = "[too short]";
|
||||
else
|
||||
{
|
||||
fprintf (listfp, "c=%02x a=%d f=", buffer[0], buffer[1]);
|
||||
for (i = 2; i < length; i++)
|
||||
fprintf (listfp, "%02X", buffer[i]);
|
||||
es_fprintf (listfp, "c=%02x a=%d f=", buffer[0], buffer[1]);
|
||||
if (length > 2)
|
||||
es_write_hexstring (listfp, buffer+2, length-2, 0, NULL);
|
||||
}
|
||||
break;
|
||||
case SIGSUBPKT_FEATURES:
|
||||
fputs ("features:", listfp);
|
||||
es_fputs ("features:", listfp);
|
||||
for (i = 0; i < length; i++)
|
||||
fprintf (listfp, " %02x", buffer[i]);
|
||||
es_fprintf (listfp, " %02x", buffer[i]);
|
||||
break;
|
||||
case SIGSUBPKT_SIGNATURE:
|
||||
fputs ("signature: ", listfp);
|
||||
es_fputs ("signature: ", listfp);
|
||||
if (length < 17)
|
||||
p = "[too short]";
|
||||
else
|
||||
fprintf (listfp, "v%d, class 0x%02X, algo %d, digest algo %d",
|
||||
buffer[0],
|
||||
buffer[0] == 3 ? buffer[2] : buffer[1],
|
||||
buffer[0] == 3 ? buffer[15] : buffer[2],
|
||||
buffer[0] == 3 ? buffer[16] : buffer[3]);
|
||||
es_fprintf (listfp, "v%d, class 0x%02X, algo %d, digest algo %d",
|
||||
buffer[0],
|
||||
buffer[0] == 3 ? buffer[2] : buffer[1],
|
||||
buffer[0] == 3 ? buffer[15] : buffer[2],
|
||||
buffer[0] == 3 ? buffer[16] : buffer[3]);
|
||||
break;
|
||||
default:
|
||||
if (type >= 100 && type <= 110)
|
||||
@ -1170,7 +1169,7 @@ dump_sig_subpkt (int hashed, int type, int critical,
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf (listfp, "%s)\n", p ? p : "");
|
||||
es_fprintf (listfp, "%s)\n", p ? p : "");
|
||||
}
|
||||
|
||||
|
||||
@ -1654,13 +1653,13 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, ":signature packet: algo %d, keyid %08lX%08lX\n"
|
||||
"\tversion %d, created %lu, md5len %d, sigclass 0x%02x\n"
|
||||
"\tdigest algo %d, begin of digest %02x %02x\n",
|
||||
sig->pubkey_algo,
|
||||
(ulong) sig->keyid[0], (ulong) sig->keyid[1],
|
||||
sig->version, (ulong) sig->timestamp, md5_len, sig->sig_class,
|
||||
sig->digest_algo, sig->digest_start[0], sig->digest_start[1]);
|
||||
es_fprintf (listfp, ":signature packet: algo %d, keyid %08lX%08lX\n"
|
||||
"\tversion %d, created %lu, md5len %d, sigclass 0x%02x\n"
|
||||
"\tdigest algo %d, begin of digest %02x %02x\n",
|
||||
sig->pubkey_algo,
|
||||
(ulong) sig->keyid[0], (ulong) sig->keyid[1],
|
||||
sig->version, (ulong) sig->timestamp, md5_len, sig->sig_class,
|
||||
sig->digest_algo, sig->digest_start[0], sig->digest_start[1]);
|
||||
if (is_v4)
|
||||
{
|
||||
parse_sig_subpkt (sig->hashed, SIGSUBPKT_LIST_HASHED, NULL);
|
||||
@ -1672,7 +1671,7 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
if (!ndata)
|
||||
{
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tunknown algorithm %d\n", sig->pubkey_algo);
|
||||
es_fprintf (listfp, "\tunknown algorithm %d\n", sig->pubkey_algo);
|
||||
unknown_pubkey_warning (sig->pubkey_algo);
|
||||
|
||||
/* We store the plain material in data[0], so that we are able
|
||||
@ -1701,9 +1700,9 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen -= n;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tdata: ");
|
||||
es_fprintf (listfp, "\tdata: ");
|
||||
mpi_print (listfp, sig->data[i], mpi_print_mode);
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
if (!sig->data[i])
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
@ -1750,13 +1749,13 @@ parse_onepass_sig (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
ops->last = iobuf_get_noeof (inp);
|
||||
pktlen--;
|
||||
if (list_mode)
|
||||
fprintf (listfp,
|
||||
":onepass_sig packet: keyid %08lX%08lX\n"
|
||||
"\tversion %d, sigclass 0x%02x, digest %d, pubkey %d, "
|
||||
"last=%d\n",
|
||||
(ulong) ops->keyid[0], (ulong) ops->keyid[1],
|
||||
version, ops->sig_class,
|
||||
ops->digest_algo, ops->pubkey_algo, ops->last);
|
||||
es_fprintf (listfp,
|
||||
":onepass_sig packet: keyid %08lX%08lX\n"
|
||||
"\tversion %d, sigclass 0x%02x, digest %d, pubkey %d, "
|
||||
"last=%d\n",
|
||||
(ulong) ops->keyid[0], (ulong) ops->keyid[1],
|
||||
version, ops->sig_class,
|
||||
ops->digest_algo, ops->pubkey_algo, ops->last);
|
||||
|
||||
|
||||
leave:
|
||||
@ -1834,17 +1833,17 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
* luckily all those comments are started by a hash. */
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, ":rfc1991 comment packet: \"");
|
||||
es_fprintf (listfp, ":rfc1991 comment packet: \"");
|
||||
for (; pktlen; pktlen--)
|
||||
{
|
||||
int c;
|
||||
c = iobuf_get_noeof (inp);
|
||||
if (c >= ' ' && c <= 'z')
|
||||
putc (c, listfp);
|
||||
es_putc (c, listfp);
|
||||
else
|
||||
fprintf (listfp, "\\x%02x", c);
|
||||
es_fprintf (listfp, "\\x%02x", c);
|
||||
}
|
||||
fprintf (listfp, "\"\n");
|
||||
es_fprintf (listfp, "\"\n");
|
||||
}
|
||||
iobuf_skip_rest (inp, pktlen, 0);
|
||||
return 0;
|
||||
@ -1887,13 +1886,13 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
algorithm = iobuf_get_noeof (inp);
|
||||
pktlen--;
|
||||
if (list_mode)
|
||||
fprintf (listfp, ":%s key packet:\n"
|
||||
"\tversion %d, algo %d, created %lu, expires %lu\n",
|
||||
pkttype == PKT_PUBLIC_KEY ? "public" :
|
||||
pkttype == PKT_SECRET_KEY ? "secret" :
|
||||
pkttype == PKT_PUBLIC_SUBKEY ? "public sub" :
|
||||
pkttype == PKT_SECRET_SUBKEY ? "secret sub" : "??",
|
||||
version, algorithm, timestamp, expiredate);
|
||||
es_fprintf (listfp, ":%s key packet:\n"
|
||||
"\tversion %d, algo %d, created %lu, expires %lu\n",
|
||||
pkttype == PKT_PUBLIC_KEY ? "public" :
|
||||
pkttype == PKT_SECRET_KEY ? "secret" :
|
||||
pkttype == PKT_PUBLIC_SUBKEY ? "public sub" :
|
||||
pkttype == PKT_SECRET_SUBKEY ? "secret sub" : "??",
|
||||
version, algorithm, timestamp, expiredate);
|
||||
|
||||
if (pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY)
|
||||
{
|
||||
@ -1932,7 +1931,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
if (!npkey)
|
||||
{
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tunknown algorithm %d\n", algorithm);
|
||||
es_fprintf (listfp, "\tunknown algorithm %d\n", algorithm);
|
||||
unknown_pubkey_warning (algorithm);
|
||||
}
|
||||
|
||||
@ -1958,9 +1957,9 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen -= n;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tskey[%d]: ", i);
|
||||
es_fprintf (listfp, "\tskey[%d]: ", i);
|
||||
mpi_print (listfp, sk->skey[i], mpi_print_mode);
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
if (!sk->skey[i])
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
@ -1999,8 +1998,8 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
if (i < 4 || memcmp (temp, "GNU", 3))
|
||||
{
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tunknown S2K %d\n",
|
||||
sk->protect.s2k.mode);
|
||||
es_fprintf (listfp, "\tunknown S2K %d\n",
|
||||
sk->protect.s2k.mode);
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
goto leave;
|
||||
}
|
||||
@ -2023,46 +2022,46 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
{
|
||||
case 0:
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tsimple S2K");
|
||||
es_fprintf (listfp, "\tsimple S2K");
|
||||
break;
|
||||
case 1:
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tsalted S2K");
|
||||
es_fprintf (listfp, "\tsalted S2K");
|
||||
break;
|
||||
case 3:
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\titer+salt S2K");
|
||||
es_fprintf (listfp, "\titer+salt S2K");
|
||||
break;
|
||||
case 1001:
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tgnu-dummy S2K");
|
||||
es_fprintf (listfp, "\tgnu-dummy S2K");
|
||||
break;
|
||||
case 1002:
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tgnu-divert-to-card S2K");
|
||||
es_fprintf (listfp, "\tgnu-divert-to-card S2K");
|
||||
break;
|
||||
default:
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tunknown %sS2K %d\n",
|
||||
sk->protect.s2k.mode < 1000 ? "" : "GNU ",
|
||||
sk->protect.s2k.mode);
|
||||
es_fprintf (listfp, "\tunknown %sS2K %d\n",
|
||||
sk->protect.s2k.mode < 1000 ? "" : "GNU ",
|
||||
sk->protect.s2k.mode);
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, ", algo: %d,%s hash: %d",
|
||||
sk->protect.algo,
|
||||
sk->protect.sha1chk ? " SHA1 protection,"
|
||||
: " simple checksum,", sk->protect.s2k.hash_algo);
|
||||
es_fprintf (listfp, ", algo: %d,%s hash: %d",
|
||||
sk->protect.algo,
|
||||
sk->protect.sha1chk ? " SHA1 protection,"
|
||||
: " simple checksum,", sk->protect.s2k.hash_algo);
|
||||
if (sk->protect.s2k.mode == 1 || sk->protect.s2k.mode == 3)
|
||||
{
|
||||
fprintf (listfp, ", salt: ");
|
||||
for (i = 0; i < 8; i++)
|
||||
fprintf (listfp, "%02x", sk->protect.s2k.salt[i]);
|
||||
es_fprintf (listfp, ", salt: ");
|
||||
es_write_hexstring (listfp, sk->protect.s2k.salt, 8,
|
||||
0, NULL);
|
||||
}
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
|
||||
if (sk->protect.s2k.mode == 3)
|
||||
@ -2075,8 +2074,8 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
sk->protect.s2k.count = iobuf_get (inp);
|
||||
pktlen--;
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tprotect count: %lu\n",
|
||||
(ulong) sk->protect.s2k.count);
|
||||
es_fprintf (listfp, "\tprotect count: %lu\n",
|
||||
(ulong) sk->protect.s2k.count);
|
||||
}
|
||||
else if (sk->protect.s2k.mode == 1002)
|
||||
{
|
||||
@ -2103,8 +2102,8 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
sk->protect.s2k.mode = 0;
|
||||
sk->protect.s2k.hash_algo = DIGEST_ALGO_MD5;
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tprotect algo: %d (hash algo: %d)\n",
|
||||
sk->protect.algo, sk->protect.s2k.hash_algo);
|
||||
es_fprintf (listfp, "\tprotect algo: %d (hash algo: %d)\n",
|
||||
sk->protect.algo, sk->protect.s2k.hash_algo);
|
||||
}
|
||||
|
||||
/* It is really ugly that we don't know the size
|
||||
@ -2131,12 +2130,12 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
temp[i] = iobuf_get_noeof (inp);
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp,
|
||||
es_fprintf (listfp,
|
||||
sk->protect.s2k.mode == 1002 ? "\tserial-number: "
|
||||
: "\tprotect IV: ");
|
||||
for (i = 0; i < sk->protect.ivlen; i++)
|
||||
fprintf (listfp, " %02x", temp[i]);
|
||||
putc ('\n', listfp);
|
||||
es_fprintf (listfp, " %02x", temp[i]);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
memcpy (sk->protect.iv, temp, sk->protect.ivlen);
|
||||
}
|
||||
@ -2166,7 +2165,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen = 0;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tencrypted stuff follows\n");
|
||||
es_fprintf (listfp, "\tencrypted stuff follows\n");
|
||||
}
|
||||
}
|
||||
else /* The v3 method: The mpi length is not encrypted. */
|
||||
@ -2177,7 +2176,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
{
|
||||
sk->skey[i] = read_protected_v3_mpi (inp, &pktlen);
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tskey[%d]: [encrypted]\n", i);
|
||||
es_fprintf (listfp, "\tskey[%d]: [encrypted]\n", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2186,9 +2185,9 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen -= n;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tskey[%d]: ", i);
|
||||
es_fprintf (listfp, "\tskey[%d]: ", i);
|
||||
mpi_print (listfp, sk->skey[i], mpi_print_mode);
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2202,7 +2201,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen -= 2;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tchecksum: %04hx\n", sk->csum);
|
||||
es_fprintf (listfp, "\tchecksum: %04hx\n", sk->csum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2229,9 +2228,9 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
pktlen -= n;
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, "\tpkey[%d]: ", i);
|
||||
es_fprintf (listfp, "\tpkey[%d]: ", i);
|
||||
mpi_print (listfp, pk->pkey[i], mpi_print_mode);
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
if (!pk->pkey[i])
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
@ -2243,8 +2242,8 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
}
|
||||
|
||||
if (list_mode)
|
||||
fprintf (listfp, "\tkeyid: %08lX%08lX\n",
|
||||
(ulong) keyid[0], (ulong) keyid[1]);
|
||||
es_fprintf (listfp, "\tkeyid: %08lX%08lX\n",
|
||||
(ulong) keyid[0], (ulong) keyid[1]);
|
||||
|
||||
leave:
|
||||
iobuf_skip_rest (inp, pktlen, 0);
|
||||
@ -2352,16 +2351,16 @@ parse_user_id (IOBUF inp, int pkttype, unsigned long pktlen, PACKET * packet)
|
||||
if (list_mode)
|
||||
{
|
||||
int n = packet->pkt.user_id->len;
|
||||
fprintf (listfp, ":user ID packet: \"");
|
||||
/* fixme: Hey why don't we replace this with print_string?? */
|
||||
es_fprintf (listfp, ":user ID packet: \"");
|
||||
/* fixme: Hey why don't we replace this with es_write_sanitized?? */
|
||||
for (p = packet->pkt.user_id->name; n; p++, n--)
|
||||
{
|
||||
if (*p >= ' ' && *p <= 'z')
|
||||
putc (*p, listfp);
|
||||
es_putc (*p, listfp);
|
||||
else
|
||||
fprintf (listfp, "\\x%02x", *p);
|
||||
es_fprintf (listfp, "\\x%02x", *p);
|
||||
}
|
||||
fprintf (listfp, "\"\n");
|
||||
es_fprintf (listfp, "\"\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2429,7 +2428,7 @@ parse_attribute (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, ":attribute packet: %s\n", packet->pkt.user_id->name);
|
||||
es_fprintf (listfp, ":attribute packet: %s\n", packet->pkt.user_id->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2459,16 +2458,16 @@ parse_comment (IOBUF inp, int pkttype, unsigned long pktlen, PACKET * packet)
|
||||
if (list_mode)
|
||||
{
|
||||
int n = packet->pkt.comment->len;
|
||||
fprintf (listfp, ":%scomment packet: \"", pkttype == PKT_OLD_COMMENT ?
|
||||
"OpenPGP draft " : "");
|
||||
es_fprintf (listfp, ":%scomment packet: \"", pkttype == PKT_OLD_COMMENT ?
|
||||
"OpenPGP draft " : "");
|
||||
for (p = packet->pkt.comment->data; n; p++, n--)
|
||||
{
|
||||
if (*p >= ' ' && *p <= 'z')
|
||||
putc (*p, listfp);
|
||||
es_putc (*p, listfp);
|
||||
else
|
||||
fprintf (listfp, "\\x%02x", *p);
|
||||
es_fprintf (listfp, "\\x%02x", *p);
|
||||
}
|
||||
fprintf (listfp, "\"\n");
|
||||
es_fprintf (listfp, "\"\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2498,14 +2497,14 @@ parse_trust (IOBUF inp, int pkttype, unsigned long pktlen, PACKET * pkt)
|
||||
pkt->pkt.ring_trust->sigcache = c;
|
||||
}
|
||||
if (list_mode)
|
||||
fprintf (listfp, ":trust packet: flag=%02x sigcache=%02x\n",
|
||||
pkt->pkt.ring_trust->trustval,
|
||||
pkt->pkt.ring_trust->sigcache);
|
||||
es_fprintf (listfp, ":trust packet: flag=%02x sigcache=%02x\n",
|
||||
pkt->pkt.ring_trust->trustval,
|
||||
pkt->pkt.ring_trust->sigcache);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list_mode)
|
||||
fprintf (listfp, ":trust packet: empty\n");
|
||||
es_fprintf (listfp, ":trust packet: empty\n");
|
||||
}
|
||||
iobuf_skip_rest (inp, pktlen, 0);
|
||||
}
|
||||
@ -2562,22 +2561,22 @@ parse_plaintext (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
|
||||
if (list_mode)
|
||||
{
|
||||
fprintf (listfp, ":literal data packet:\n"
|
||||
"\tmode %c (%X), created %lu, name=\"",
|
||||
mode >= ' ' && mode < 'z' ? mode : '?', mode,
|
||||
(ulong) pt->timestamp);
|
||||
es_fprintf (listfp, ":literal data packet:\n"
|
||||
"\tmode %c (%X), created %lu, name=\"",
|
||||
mode >= ' ' && mode < 'z' ? mode : '?', mode,
|
||||
(ulong) pt->timestamp);
|
||||
for (p = pt->name, i = 0; i < namelen; p++, i++)
|
||||
{
|
||||
if (*p >= ' ' && *p <= 'z')
|
||||
putc (*p, listfp);
|
||||
es_putc (*p, listfp);
|
||||
else
|
||||
fprintf (listfp, "\\x%02x", *p);
|
||||
es_fprintf (listfp, "\\x%02x", *p);
|
||||
}
|
||||
fprintf (listfp, "\",\n\traw data: ");
|
||||
es_fprintf (listfp, "\",\n\traw data: ");
|
||||
if (partial)
|
||||
fprintf (listfp, "unknown length\n");
|
||||
es_fprintf (listfp, "unknown length\n");
|
||||
else
|
||||
fprintf (listfp, "%lu bytes\n", (ulong) pt->len);
|
||||
es_fprintf (listfp, "%lu bytes\n", (ulong) pt->len);
|
||||
}
|
||||
|
||||
leave:
|
||||
@ -2603,7 +2602,7 @@ parse_compressed (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
zd->new_ctb = new_ctb;
|
||||
zd->buf = inp;
|
||||
if (list_mode)
|
||||
fprintf (listfp, ":compressed packet: algo=%d\n", zd->algorithm);
|
||||
es_fprintf (listfp, ":compressed packet: algo=%d\n", zd->algorithm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2663,12 +2662,12 @@ parse_encrypted (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
if (list_mode)
|
||||
{
|
||||
if (orig_pktlen)
|
||||
fprintf (listfp, ":encrypted data packet:\n\tlength: %lu\n",
|
||||
orig_pktlen);
|
||||
es_fprintf (listfp, ":encrypted data packet:\n\tlength: %lu\n",
|
||||
orig_pktlen);
|
||||
else
|
||||
fprintf (listfp, ":encrypted data packet:\n\tlength: unknown\n");
|
||||
es_fprintf (listfp, ":encrypted data packet:\n\tlength: unknown\n");
|
||||
if (ed->mdc_method)
|
||||
fprintf (listfp, "\tmdc_method: %d\n", ed->mdc_method);
|
||||
es_fprintf (listfp, "\tmdc_method: %d\n", ed->mdc_method);
|
||||
}
|
||||
|
||||
ed->buf = inp;
|
||||
@ -2693,7 +2692,7 @@ parse_mdc (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
|
||||
mdc = pkt->pkt.mdc = xmalloc (sizeof *pkt->pkt.mdc);
|
||||
if (list_mode)
|
||||
fprintf (listfp, ":mdc packet: length=%lu\n", pktlen);
|
||||
es_fprintf (listfp, ":mdc packet: length=%lu\n", pktlen);
|
||||
if (!new_ctb || pktlen != 20)
|
||||
{
|
||||
log_error ("mdc_packet with invalid encoding\n");
|
||||
@ -2732,7 +2731,7 @@ parse_gpg_control (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
(void) pkttype;
|
||||
|
||||
if (list_mode)
|
||||
fprintf (listfp, ":packet 63: length %lu ", pktlen);
|
||||
es_fprintf (listfp, ":packet 63: length %lu ", pktlen);
|
||||
|
||||
sesmark = get_session_marker (&sesmarklen);
|
||||
if (pktlen < sesmarklen + 1) /* 1 is for the control bytes */
|
||||
@ -2765,7 +2764,7 @@ parse_gpg_control (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
int c;
|
||||
|
||||
i = 0;
|
||||
fprintf (listfp, "- private (rest length %lu)\n", pktlen);
|
||||
es_fprintf (listfp, "- private (rest length %lu)\n", pktlen);
|
||||
if (partial)
|
||||
{
|
||||
while ((c = iobuf_get (inp)) != -1)
|
||||
@ -2780,7 +2779,7 @@ parse_gpg_control (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
break;
|
||||
}
|
||||
}
|
||||
putc ('\n', listfp);
|
||||
es_putc ('\n', listfp);
|
||||
}
|
||||
iobuf_skip_rest (inp, pktlen, 0);
|
||||
return gpg_error (GPG_ERR_INV_PACKET);
|
||||
|
@ -81,12 +81,11 @@ do_show_revocation_reason( PKT_signature *sig )
|
||||
else
|
||||
text = NULL;
|
||||
|
||||
log_info( _("reason for revocation: ") );
|
||||
if( text )
|
||||
fputs( text, log_get_stream() );
|
||||
log_info ( _("reason for revocation: "));
|
||||
if (text)
|
||||
log_printf ("%s\n", text);
|
||||
else
|
||||
fprintf( log_get_stream(), "code=%02x", *p );
|
||||
log_printf ("\n");
|
||||
log_printf ("code=%02x\n", *p );
|
||||
n--; p++;
|
||||
pp = NULL;
|
||||
do {
|
||||
@ -99,7 +98,7 @@ do_show_revocation_reason( PKT_signature *sig )
|
||||
pp = memchr( p, '\n', n );
|
||||
nn = pp? pp - p : n;
|
||||
log_info ( _("revocation comment: ") );
|
||||
print_string ( log_get_stream(), p, nn, 0 );
|
||||
es_write_sanitized (log_get_stream(), p, nn, NULL, NULL);
|
||||
log_printf ("\n");
|
||||
p += nn; n -= nn;
|
||||
}
|
||||
|
@ -689,7 +689,8 @@ setup_plaintext_name (const char *filename, IOBUF iobuf)
|
||||
{
|
||||
PKT_plaintext *pt;
|
||||
|
||||
if (filename || opt.set_filename)
|
||||
if ((filename && !iobuf_is_pipe_filename (filename))
|
||||
|| (opt.set_filename && !iobuf_is_pipe_filename (opt.set_filename)))
|
||||
{
|
||||
char *s;
|
||||
|
||||
|
@ -83,7 +83,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
|
||||
&sk->protect.s2k, mode,
|
||||
tryagain_text, canceled );
|
||||
if (!dek && canceled && *canceled)
|
||||
return G10ERR_GENERAL;
|
||||
return GPG_ERR_CANCELED;
|
||||
|
||||
|
||||
err = openpgp_cipher_open (&cipher_hd, sk->protect.algo,
|
||||
|
@ -1376,7 +1376,8 @@ dump_key_array (int depth, struct key_array *keys)
|
||||
(node->flag & 4)? 'f':
|
||||
(node->flag & 2)? 'm':
|
||||
(node->flag & 1)? 'q':'-');
|
||||
print_string (stdout, node->pkt->pkt.user_id->name, len, ':');
|
||||
es_write_sanitized (es_stdout, node->pkt->pkt.user_id->name,
|
||||
len, ":", NULL);
|
||||
putchar (':');
|
||||
putchar ('\n');
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
2010-03-11 Werner Koch <wk@g10code.com>
|
||||
|
||||
* verify.c (gpgsm_verify): Use gpgsm_es_print_name.
|
||||
|
||||
* gpgsm.c: Include "asshelp.h".
|
||||
(main): Remove assuan_set_assuan_log_prefix. Add
|
||||
assuan_set_log_cb.
|
||||
|
@ -595,7 +595,7 @@ gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, estream_t out_fp)
|
||||
log_info (!i? _("Good signature from")
|
||||
: _(" aka"));
|
||||
log_printf (" \"");
|
||||
gpgsm_print_name (log_get_stream (), p);
|
||||
gpgsm_es_print_name (log_get_stream (), p);
|
||||
log_printf ("\"\n");
|
||||
ksba_free (p);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user