1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-30 16:17:02 +01:00

Initialize Pth which is now required.

(interactive_shell): New command "readpk".
This commit is contained in:
Werner Koch 2004-07-01 18:09:25 +00:00
parent 8f81ba17dc
commit c4e52b1531
2 changed files with 43 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2004-07-01 Werner Koch <wk@gnupg.org>
* sc-investigate.c: Initialize Pth which is now required.
(interactive_shell): New command "readpk".
* app-openpgp.c (do_getattr): Fix for sending CA-FPR.
2004-06-30 Werner Koch <wk@gnupg.org>

View File

@ -26,6 +26,9 @@
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
#ifdef USE_GNU_PTH
# include <pth.h>
#endif
#ifdef HAVE_READLINE_READLINE_H
#include <readline/readline.h>
@ -88,6 +91,12 @@ static ARGPARSE_OPTS opts[] = {
};
#ifdef USE_GNU_PTH
/* Pth wrapper function definitions. */
GCRY_THREAD_OPTION_PTH_IMPL;
#endif /*USE_GNU_PTH*/
static void interactive_shell (int slot);
static void dump_other_cards (int slot);
@ -151,7 +160,18 @@ main (int argc, char **argv )
/* Try to auto set the character set. */
set_native_charset (NULL);
/* check that the libraries are suitable. Do it here because
/* Libgcrypt requires us to register the threading model first.
Note that this will also do the pth_init. */
#ifdef USE_GNU_PTH
rc = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
if (rc)
{
log_fatal ("can't register GNU Pth with Libgcrypt: %s\n",
gpg_strerror (rc));
}
#endif /*USE_GNU_PTH*/
/* Check that the libraries are suitable. Do it here because
the option parsing may need services of the library */
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
{
@ -411,6 +431,7 @@ interactive_shell (int slot)
cmdDEBUG,
cmdVERIFY,
cmdCHANGEREF,
cmdREADPK,
cmdINVCMD
};
@ -439,6 +460,7 @@ interactive_shell (int slot)
{ "verify" , cmdVERIFY, "verify CHVNO PIN" },
{ "ver" , cmdVERIFY, NULL },
{ "changeref", cmdCHANGEREF, "change reference data" },
{ "readpk", cmdREADPK, "read a public key" },
{ NULL, cmdINVCMD }
};
enum cmdids cmd = cmdNOP;
@ -655,6 +677,23 @@ interactive_shell (int slot)
}
break;
case cmdREADPK:
if (arg_number < 1 || arg_number > 255)
printf ("usage: readpk CRTBYTE1\n");
else
{
unsigned char crt[2];
crt[0] = arg_number;
crt[1] = 0;
err = iso7816_read_public_key(slot, crt, 2,
&result, &resultlen);
if (!err)
dump_or_store_buffer (arg_string, result, resultlen);
}
break;
case cmdINVCMD:
default:
printf ("\n");