1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Continued with merging.

Still does not build.
This commit is contained in:
Werner Koch 2006-04-19 13:24:36 +00:00
parent 29b23dea97
commit d0907e64f4
22 changed files with 158 additions and 158 deletions

View File

@ -51,7 +51,7 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
unsigned int blocksize; unsigned int blocksize;
unsigned int nprefix; unsigned int nprefix;
blocksize = gcry_cipher_algo_blklen (cfx->dek->algo); blocksize = gcry_cipher_get_algo_blklen (cfx->dek->algo);
if ( blocksize < 8 || blocksize > 16 ) if ( blocksize < 8 || blocksize > 16 )
log_fatal("unsupported blocksize %u\n", blocksize ); log_fatal("unsupported blocksize %u\n", blocksize );
@ -88,8 +88,8 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
GCRY_CIPHER_MODE_CFB, GCRY_CIPHER_MODE_CFB,
(GCRY_CIPHER_SECURE (GCRY_CIPHER_SECURE
| ((cfx->dek->use_mdc || cfx->dek->algo >= 100)? | ((cfx->dek->use_mdc || cfx->dek->algo >= 100)?
0 : GCRY_CIPHER_ENABLE_SYNC)); 0 : GCRY_CIPHER_ENABLE_SYNC)));
if (rc) { if (err) {
/* We should never get an error here cause we already checked, /* We should never get an error here cause we already checked,
* that the algorithm is available. */ * that the algorithm is available. */
BUG(); BUG();

View File

@ -58,9 +58,9 @@ dearmor_file( const char *fname )
errno = EPERM; errno = EPERM;
} }
if (!inp) { if (!inp) {
rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) ); strerror(errno) );
rc = G10ERR_OPEN_FILE;
goto leave; goto leave;
} }
@ -107,9 +107,9 @@ enarmor_file( const char *fname )
errno = EPERM; errno = EPERM;
} }
if (!inp) { if (!inp) {
rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) ); strerror(errno) );
rc = G10ERR_OPEN_FILE;
goto leave; goto leave;
} }

View File

@ -92,7 +92,7 @@ encode_seskey( DEK *dek, DEK **seskey, byte *enckey )
BUG (); BUG ();
if (gcry_cipher_setkey (hd, dek->key, dek->keylen)) if (gcry_cipher_setkey (hd, dek->key, dek->keylen))
BUG (); BUG ();
gry_cipher_setiv (hd, NULL, 0); gcry_cipher_setiv (hd, NULL, 0);
gcry_cipher_encrypt (hd, buf, (*seskey)->keylen + 1, NULL, 0); gcry_cipher_encrypt (hd, buf, (*seskey)->keylen + 1, NULL, 0);
gcry_cipher_close (hd); gcry_cipher_close (hd);
@ -190,7 +190,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]" log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]",
strerror(errno) ); strerror(errno) );
return rc; return rc;
} }
@ -365,9 +365,9 @@ encode_simple( const char *filename, int mode, int use_seskey )
byte copy_buffer[4096]; byte copy_buffer[4096];
int bytes_copied; int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
if (iobuf_write(out, copy_buffer, bytes_copied) == -1) { if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
rc = G10ERR_WRITE_FILE; log_error ("copying input to output failed: %s\n",
log_error("copying input to output failed: %s\n", g10_errstr(rc) ); gpg_strerror (rc) );
break; break;
} }
wipememory(copy_buffer, 4096); /* burn buffer */ wipememory(copy_buffer, 4096); /* burn buffer */
@ -403,7 +403,7 @@ setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek)
{ {
xfree(*symkey_dek); xfree(*symkey_dek);
xfree(*symkey_s2k); xfree(*symkey_s2k);
return G10ERR_PASSPHRASE; return gpg_error (GPG_ERR_BAD_PASSPHRASE);
} }
return 0; return 0;
@ -412,7 +412,7 @@ setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek)
static int static int
write_symkey_enc(STRING2KEY *symkey_s2k,DEK *symkey_dek,DEK *dek,IOBUF out) write_symkey_enc(STRING2KEY *symkey_s2k,DEK *symkey_dek,DEK *dek,IOBUF out)
{ {
int rc,seskeylen=cipher_get_keylen(dek->algo)/8; int rc, seskeylen = gcry_cipher_get_algo_keylen (dek->algo);
PKT_symkey_enc *enc; PKT_symkey_enc *enc;
byte enckey[33]; byte enckey[33];
@ -674,10 +674,9 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
byte copy_buffer[4096]; byte copy_buffer[4096];
int bytes_copied; int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
if (iobuf_write(out, copy_buffer, bytes_copied) == -1) { if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
rc = G10ERR_WRITE_FILE; log_error ("copying input to output failed: %s\n",
log_error("copying input to output failed: %s\n", gpg_strerror (rc));
g10_errstr(rc) );
break; break;
} }
wipememory(copy_buffer, 4096); /* burn buffer */ wipememory(copy_buffer, 4096); /* burn buffer */
@ -795,7 +794,7 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
int rc; int rc;
for( ; pk_list; pk_list = pk_list->next ) { for( ; pk_list; pk_list = pk_list->next ) {
MPI frame; gcry_mpi_t frame;
pk = pk_list->pk; pk = pk_list->pk;

View File

@ -438,8 +438,8 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->tochild=fdopen(to[1],binary?"wb":"w"); (*info)->tochild=fdopen(to[1],binary?"wb":"w");
if((*info)->tochild==NULL) if((*info)->tochild==NULL)
{ {
ret = gpg_error_from_errno (errno);
close(to[1]); close(to[1]);
ret=G10ERR_WRITE_FILE;
goto fail; goto fail;
} }
@ -448,8 +448,8 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->fromchild=iobuf_fdopen(from[0],"r"); (*info)->fromchild=iobuf_fdopen(from[0],"r");
if((*info)->fromchild==NULL) if((*info)->fromchild==NULL)
{ {
ret = gpg_error_from_errno (errno);
close(from[0]); close(from[0]);
ret=G10ERR_READ_FILE;
goto fail; goto fail;
} }
@ -547,9 +547,9 @@ int exec_read(struct exec_info *info)
} }
if(info->fromchild==NULL) if(info->fromchild==NULL)
{ {
ret = gpg_error_from_errno (errno);
log_error(_("unable to read external program response: %s\n"), log_error(_("unable to read external program response: %s\n"),
strerror(errno)); strerror(errno));
ret=G10ERR_READ_FILE;
goto fail; goto fail;
} }

View File

@ -594,7 +594,6 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
if( rc ) { if( rc ) {
log_error("build_packet(%d) failed: %s\n", log_error("build_packet(%d) failed: %s\n",
node->pkt->pkttype, g10_errstr(rc) ); node->pkt->pkttype, g10_errstr(rc) );
rc = G10ERR_WRITE_FILE;
goto leave; goto leave;
} }
} }

View File

@ -126,36 +126,36 @@ typedef struct {
/* encrypt_filter_context_t defined in main.h */ /* encrypt_filter_context_t defined in main.h */
/*-- mdfilter.c --*/ /*-- mdfilter.c --*/
int md_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len); int md_filter( void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len);
void free_md_filter_context( md_filter_context_t *mfx ); void free_md_filter_context( md_filter_context_t *mfx );
/*-- armor.c --*/ /*-- armor.c --*/
int use_armor_filter( IOBUF a ); int use_armor_filter( iobuf_t a );
int armor_filter( void *opaque, int control, int armor_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len); iobuf_t chain, byte *buf, size_t *ret_len);
UnarmorPump unarmor_pump_new (void); UnarmorPump unarmor_pump_new (void);
void unarmor_pump_release (UnarmorPump x); void unarmor_pump_release (UnarmorPump x);
int unarmor_pump (UnarmorPump x, int c); int unarmor_pump (UnarmorPump x, int c);
/*-- compress.c --*/ /*-- compress.c --*/
void push_compress_filter(IOBUF out,compress_filter_context_t *zfx,int algo); void push_compress_filter(iobuf_t out,compress_filter_context_t *zfx,int algo);
void push_compress_filter2(IOBUF out,compress_filter_context_t *zfx, void push_compress_filter2(iobuf_t out,compress_filter_context_t *zfx,
int algo,int rel); int algo,int rel);
/*-- cipher.c --*/ /*-- cipher.c --*/
int cipher_filter( void *opaque, int control, int cipher_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len); iobuf_t chain, byte *buf, size_t *ret_len);
/*-- textfilter.c --*/ /*-- textfilter.c --*/
int text_filter( void *opaque, int control, int text_filter( void *opaque, int control,
IOBUF chain, byte *buf, size_t *ret_len); iobuf_t chain, byte *buf, size_t *ret_len);
int copy_clearsig_text (IOBUF out, IOBUF inp, gcry_md_hd_t md, int copy_clearsig_text (iobuf_t out, iobuf_t inp, gcry_md_hd_t md,
int escape_dash, int escape_from, int pgp2mode); int escape_dash, int escape_from, int pgp2mode);
/*-- progress.c --*/ /*-- progress.c --*/
int progress_filter (void *opaque, int control, int progress_filter (void *opaque, int control,
IOBUF a, byte *buf, size_t *ret_len); iobuf_t a, byte *buf, size_t *ret_len);
void handle_progress (progress_filter_context_t *pfx, void handle_progress (progress_filter_context_t *pfx,
IOBUF inp, const char *name); iobuf_t inp, const char *name);
#endif /*G10_FILTER_H*/ #endif /*G10_FILTER_H*/

View File

@ -49,8 +49,6 @@
#include "ttyio.h" #include "ttyio.h"
#include "i18n.h" #include "i18n.h"
#include "status.h" #include "status.h"
#include "g10defs.h"
#include "cardglue.h"
enum cmd_and_opt_values { aNull = 0, enum cmd_and_opt_values { aNull = 0,
@ -379,15 +377,15 @@ void disable_cipher_algo( int algo ) {}
int check_cipher_algo( int algo ) { return -1;} int check_cipher_algo( int algo ) { return -1;}
unsigned int cipher_get_keylen( int algo ) { return 0; } unsigned int cipher_get_keylen( int algo ) { return 0; }
unsigned int cipher_get_blocksize( int algo ) {return 0;} unsigned int cipher_get_blocksize( int algo ) {return 0;}
CIPHER_HANDLE cipher_open( int algo, int mode, int secure ) { return NULL;} gcry_cipher_hd_t cipher_open( int algo, int mode, int secure ) { return NULL;}
void cipher_close( CIPHER_HANDLE c ) {} void cipher_close( gcry_cipher_hd_t c ) {}
int cipher_setkey( CIPHER_HANDLE c, byte *key, unsigned keylen ) { return -1;} int cipher_setkey( gcry_cipher_hd_t c, byte *key, unsigned keylen ) { return -1;}
void cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen ){} void cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen ){}
void cipher_encrypt( CIPHER_HANDLE c, byte *outbuf, void cipher_encrypt( gcry_cipher_hd_t c, byte *outbuf,
byte *inbuf, unsigned nbytes ) {} byte *inbuf, unsigned nbytes ) {}
void cipher_decrypt( CIPHER_HANDLE c, byte *outbuf, void cipher_decrypt( gcry_cipher_hd_t c, byte *outbuf,
byte *inbuf, unsigned nbytes ) {} byte *inbuf, unsigned nbytes ) {}
void cipher_sync( CIPHER_HANDLE c ) {} void cipher_sync( gcry_cipher_hd_t c ) {}
/* Stubs to avoid linking to ../cipher/random.c */ /* Stubs to avoid linking to ../cipher/random.c */
void random_dump_stats(void) {} void random_dump_stats(void) {}
@ -404,7 +402,7 @@ void register_primegen_progress ( void (*cb)( void *, int), void *cb_data ) {}
MPI generate_secret_prime( unsigned nbits ) { return NULL;} MPI generate_secret_prime( unsigned nbits ) { return NULL;}
MPI generate_public_prime( unsigned nbits ) { return NULL;} MPI generate_public_prime( unsigned nbits ) { return NULL;}
MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits, MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits,
MPI g, MPI **ret_factors ) { return NULL;} gcry_mpi_t g, gcry_mpi_t **ret_factors ) { return NULL;}
/* Do not link to ../cipher/rndlinux.c */ /* Do not link to ../cipher/rndlinux.c */
void rndlinux_constructor(void) {} void rndlinux_constructor(void) {}

View File

@ -596,9 +596,9 @@ check_prefs(KBNODE keyblock)
if(prefs->type==PREFTYPE_SYM) if(prefs->type==PREFTYPE_SYM)
{ {
if(check_cipher_algo(prefs->value)) if (openpgp_cipher_algo_test (prefs->value))
{ {
const char *algo=cipher_algo_to_string(prefs->value); const char *algo = gcry_cipher_algo_name (prefs->value);
if(!problem) if(!problem)
check_prefs_warning(pk); check_prefs_warning(pk);
log_info(_(" \"%s\": preference for cipher" log_info(_(" \"%s\": preference for cipher"
@ -608,9 +608,9 @@ check_prefs(KBNODE keyblock)
} }
else if(prefs->type==PREFTYPE_HASH) else if(prefs->type==PREFTYPE_HASH)
{ {
if(check_digest_algo(prefs->value)) if(openpgp_md_test_algo(prefs->value))
{ {
const char *algo=digest_algo_to_string(prefs->value); const char *algo = gcry_md_algo_name (prefs->value);
if(!problem) if(!problem)
check_prefs_warning(pk); check_prefs_warning(pk);
log_info(_(" \"%s\": preference for digest" log_info(_(" \"%s\": preference for digest"
@ -620,7 +620,7 @@ check_prefs(KBNODE keyblock)
} }
else if(prefs->type==PREFTYPE_ZIP) else if(prefs->type==PREFTYPE_ZIP)
{ {
if(check_compress_algo(prefs->value)) if(check_compress_algo (prefs->value))
{ {
const char *algo=compress_algo_to_string(prefs->value); const char *algo=compress_algo_to_string(prefs->value);
if(!problem) if(!problem)
@ -1541,9 +1541,9 @@ delete_inv_parts( const char *fname, KBNODE keyblock,
else else
subkey_seen = 1; subkey_seen = 1;
} }
else if( node->pkt->pkttype == PKT_SIGNATURE else if (node->pkt->pkttype == PKT_SIGNATURE
&& check_pubkey_algo( node->pkt->pkt.signature->pubkey_algo) && openpgp_pk_test_algo (node->pkt->pkt.signature->pubkey_algo)
&& node->pkt->pkt.signature->pubkey_algo != PUBKEY_ALGO_RSA ) && node->pkt->pkt.signature->pubkey_algo != PUBKEY_ALGO_RSA )
delete_kbnode( node ); /* build_packet() can't handle this */ delete_kbnode( node ); /* build_packet() can't handle this */
else if( node->pkt->pkttype == PKT_SIGNATURE && else if( node->pkt->pkttype == PKT_SIGNATURE &&
!node->pkt->pkt.signature->flags.exportable && !node->pkt->pkt.signature->flags.exportable &&

View File

@ -2311,7 +2311,7 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose)
tty_printf (_("Cipher: ")); tty_printf (_("Cipher: "));
for(i=any=0; prefs[i].type; i++ ) { for(i=any=0; prefs[i].type; i++ ) {
if( prefs[i].type == PREFTYPE_SYM ) { if( prefs[i].type == PREFTYPE_SYM ) {
const char *s = cipher_algo_to_string (prefs[i].value); const char *s = gcry_cipher_algo_name (prefs[i].value);
if (any) if (any)
tty_printf (", "); tty_printf (", ");
@ -2328,13 +2328,13 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose)
if (!des_seen) { if (!des_seen) {
if (any) if (any)
tty_printf (", "); tty_printf (", ");
tty_printf ("%s",cipher_algo_to_string(CIPHER_ALGO_3DES)); tty_printf ("%s", gcry_cipher_algo_name (CIPHER_ALGO_3DES));
} }
tty_printf ("\n "); tty_printf ("\n ");
tty_printf (_("Digest: ")); tty_printf (_("Digest: "));
for(i=any=0; prefs[i].type; i++ ) { for(i=any=0; prefs[i].type; i++ ) {
if( prefs[i].type == PREFTYPE_HASH ) { if( prefs[i].type == PREFTYPE_HASH ) {
const char *s = digest_algo_to_string (prefs[i].value); const char *s = gcry_md_algo_name (prefs[i].value);
if (any) if (any)
tty_printf (", "); tty_printf (", ");
@ -2351,7 +2351,7 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose)
if (!sha1_seen) { if (!sha1_seen) {
if (any) if (any)
tty_printf (", "); tty_printf (", ");
tty_printf ("%s",digest_algo_to_string(DIGEST_ALGO_SHA1)); tty_printf ("%s", gcry_md_algo_name (DIGEST_ALGO_SHA1));
} }
tty_printf ("\n "); tty_printf ("\n ");
tty_printf (_("Compression: ")); tty_printf (_("Compression: "));
@ -2686,7 +2686,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
if(pk->is_revoked) if(pk->is_revoked)
{ {
char *user=get_user_id_string_native(pk->revoked.keyid); char *user=get_user_id_string_native(pk->revoked.keyid);
const char *algo=pubkey_algo_to_string(pk->revoked.algo); const char *algo = gcry_pk_algo_name (pk->revoked.algo);
tty_printf(_("This key was revoked on %s by %s key %s\n"), tty_printf(_("This key was revoked on %s by %s key %s\n"),
revokestr_from_pk(pk),algo?algo:"?",user); revokestr_from_pk(pk),algo?algo:"?",user);
xfree(user); xfree(user);
@ -2701,9 +2701,9 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
{ {
u32 r_keyid[2]; u32 r_keyid[2];
char *user; char *user;
const char *algo= const char *algo;
pubkey_algo_to_string(pk->revkey[i].algid);
algo = gcry_pk_algo_name (pk->revkey[i].algid);
keyid_from_fingerprint(pk->revkey[i].fpr, keyid_from_fingerprint(pk->revkey[i].fpr,
MAX_FINGERPRINT_LEN,r_keyid); MAX_FINGERPRINT_LEN,r_keyid);

View File

@ -319,13 +319,13 @@ keygen_set_std_prefs (const char *string,int personal)
/* Make sure we do not add more than 15 items here, as we /* Make sure we do not add more than 15 items here, as we
could overflow the size of dummy_string. We currently could overflow the size of dummy_string. We currently
have at most 12. */ have at most 12. */
if(!check_cipher_algo(CIPHER_ALGO_AES256)) if ( !openpgp_cipher_test_algo (CIPHER_ALGO_AES256) )
strcat(dummy_string,"S9 "); strcat(dummy_string,"S9 ");
if(!check_cipher_algo(CIPHER_ALGO_AES192)) if ( !openpgp_cipher_test_algo (CIPHER_ALGO_AES192) )
strcat(dummy_string,"S8 "); strcat(dummy_string,"S8 ");
if(!check_cipher_algo(CIPHER_ALGO_AES)) if ( !openpgp_cipher_test_algo (CIPHER_ALGO_AES) )
strcat(dummy_string,"S7 "); strcat(dummy_string,"S7 ");
if(!check_cipher_algo(CIPHER_ALGO_CAST5)) if ( !openpgp_cipher_test_algo (CIPHER_ALGO_CAST5) )
strcat(dummy_string,"S3 "); strcat(dummy_string,"S3 ");
strcat(dummy_string,"S2 "); /* 3DES */ strcat(dummy_string,"S2 "); /* 3DES */
/* If we have it, IDEA goes *after* 3DES so it won't be /* If we have it, IDEA goes *after* 3DES so it won't be
@ -335,7 +335,7 @@ keygen_set_std_prefs (const char *string,int personal)
break PGP2, but that is difficult with the current break PGP2, but that is difficult with the current
code, and not really worth checking as a non-RSA <=2048 code, and not really worth checking as a non-RSA <=2048
bit key wouldn't be usable by PGP2 anyway. -dms */ bit key wouldn't be usable by PGP2 anyway. -dms */
if(!check_cipher_algo(CIPHER_ALGO_IDEA)) if ( !openpgp_cipher_test_algo (CIPHER_ALGO_IDEA) )
strcat(dummy_string,"S1 "); strcat(dummy_string,"S1 ");
/* SHA-1 */ /* SHA-1 */
@ -370,12 +370,12 @@ keygen_set_std_prefs (const char *string,int personal)
while((tok=strsep(&prefstring," ,"))) while((tok=strsep(&prefstring," ,")))
{ {
if((val=string_to_cipher_algo(tok))) if((val=openpgp_cipher_map_name (tok)))
{ {
if(set_one_pref(val,1,tok,sym,&nsym)) if(set_one_pref(val,1,tok,sym,&nsym))
rc=-1; rc=-1;
} }
else if((val=string_to_digest_algo(tok))) else if((val=openpgp_md_map_name (tok)))
{ {
if(set_one_pref(val,2,tok,hash,&nhash)) if(set_one_pref(val,2,tok,hash,&nhash))
rc=-1; rc=-1;
@ -1071,6 +1071,7 @@ genhelp_protect (DEK *dek, STRING2KEY *s2k, PKT_secret_key *sk)
static void static void
genhelp_factors (gcry_sexp_t misc_key_info, KBNODE sec_root) genhelp_factors (gcry_sexp_t misc_key_info, KBNODE sec_root)
{ {
#if 0 /* Not used anymore */
size_t n; size_t n;
char *buf; char *buf;
@ -1093,6 +1094,7 @@ genhelp_factors (gcry_sexp_t misc_key_info, KBNODE sec_root)
xfree (buf); xfree (buf);
gcry_sexp_release (misc_key_info); gcry_sexp_release (misc_key_info);
} }
#endif
} }
@ -1484,7 +1486,7 @@ ask_key_flags(int algo,int subkey)
{ {
tty_printf("\n"); tty_printf("\n");
tty_printf(_("Possible actions for a %s key: "), tty_printf(_("Possible actions for a %s key: "),
pubkey_algo_to_string(algo)); gcry_pk_algo_name (algo));
print_key_flags(possible); print_key_flags(possible);
tty_printf("\n"); tty_printf("\n");
tty_printf(_("Current allowed actions: ")); tty_printf(_("Current allowed actions: "));
@ -1649,7 +1651,7 @@ ask_keysize( int algo )
} }
tty_printf(_("%s keys may be between %u and %u bits long.\n"), tty_printf(_("%s keys may be between %u and %u bits long.\n"),
pubkey_algo_to_string(algo),min,max); gcry_pk_algo_name (algo), min, max);
for(;;) for(;;)
{ {
@ -1670,7 +1672,7 @@ ask_keysize( int algo )
if(nbits<min || nbits>max) if(nbits<min || nbits>max)
tty_printf(_("%s keysizes must be in the range %u-%u\n"), tty_printf(_("%s keysizes must be in the range %u-%u\n"),
pubkey_algo_to_string(algo),min,max); gcry_pk_algo_name (algo), min, max);
else else
break; break;
} }
@ -2136,7 +2138,7 @@ get_parameter_algo( struct para_data_s *para, enum para_name key )
if( digitp( r->u.value ) ) if( digitp( r->u.value ) )
i = atoi( r->u.value ); i = atoi( r->u.value );
else else
i = string_to_pubkey_algo( r->u.value ); i = openpgp_pk_map_name (r->u.value);
if (i == PUBKEY_ALGO_RSA_E || i == PUBKEY_ALGO_RSA_S) if (i == PUBKEY_ALGO_RSA_E || i == PUBKEY_ALGO_RSA_S)
i = 0; /* we don't want to allow generation of these algorithms */ i = 0; /* we don't want to allow generation of these algorithms */
return i; return i;
@ -2287,7 +2289,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
if(r) if(r)
{ {
algo=get_parameter_algo(para,pKEYTYPE); algo=get_parameter_algo(para,pKEYTYPE);
if(check_pubkey_algo2(algo,PUBKEY_USAGE_SIG)) if (openpgp_pk_test_algo (algo, PUBKEY_USAGE_SIG))
{ {
log_error("%s:%d: invalid algorithm\n", fname, r->lnr ); log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
return -1; return -1;
@ -2316,7 +2318,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
if(r) if(r)
{ {
algo=get_parameter_algo( para, pSUBKEYTYPE); algo=get_parameter_algo( para, pSUBKEYTYPE);
if(check_pubkey_algo(algo)) if (openpgp_pk_test_algo (algo))
{ {
log_error("%s:%d: invalid algorithm\n", fname, r->lnr ); log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
return -1; return -1;
@ -3504,7 +3506,7 @@ write_keyblock( IOBUF out, KBNODE node )
{ {
log_error("build_packet(%d) failed: %s\n", log_error("build_packet(%d) failed: %s\n",
node->pkt->pkttype, g10_errstr(rc) ); node->pkt->pkttype, g10_errstr(rc) );
return G10ERR_WRITE_FILE; return rc;
} }
} }
} }

View File

@ -917,7 +917,8 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
rc = check_key_signature( keyblock, node, NULL ); rc = check_key_signature( keyblock, node, NULL );
switch( gpg_err_code (rc) ) { switch( gpg_err_code (rc) ) {
case 0: sigrc = '!'; break; case 0: sigrc = '!'; break;
case GPG_ERR_BAD_SIGN: stats->inv_sigs++; sigrc = '-'; break; case GPG_ERR_BAD_SIGNATURE:
stats->inv_sigs++; sigrc = '-'; break;
case GPG_ERR_NO_PUBKEY: case GPG_ERR_NO_PUBKEY:
case GPG_ERR_UNUSABLE_PUBKEY: stats->no_key++; continue; case GPG_ERR_UNUSABLE_PUBKEY: stats->no_key++; continue;
default: stats->oth_err++; sigrc = '%'; break; default: stats->oth_err++; sigrc = '%'; break;
@ -1306,11 +1307,11 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
rc = check_key_signature2( keyblock, node, NULL, signer_pk, rc = check_key_signature2( keyblock, node, NULL, signer_pk,
NULL, NULL, NULL ); NULL, NULL, NULL );
switch ( gpg_err_code (rc) ) { switch ( gpg_err_code (rc) ) {
case 0: sigrc = '!'; break; case 0: sigrc = '!'; break;
case GPG_ERR_BAD_SIGN: sigrc = '-'; break; case GPG_ERR_BAD_SIGNATURE: sigrc = '-'; break;
case GPG_ERR_NO_PUBKEY: case GPG_ERR_NO_PUBKEY:
case GPG_ERR_UNU_PUBKEY: sigrc = '?'; break; case Gpg_Err_UNUSABLE_PUBKEY: sigrc = '?'; break;
default: sigrc = '%'; break; default: sigrc = '%'; break;
} }
if(opt.no_sig_cache) if(opt.no_sig_cache)

View File

@ -478,7 +478,7 @@ print_keyrec(int number,struct keyrec *keyrec)
if(keyrec->type) if(keyrec->type)
{ {
const char *str=pubkey_algo_to_string(keyrec->type); const char *str = gcry_pk_algo_name (keyrec->type);
if(str) if(str)
printf("%s ",str); printf("%s ",str);
@ -1402,7 +1402,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
maxlen=1024; maxlen=1024;
if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0) if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0)
{ {
ret=G10ERR_READ_FILE; ret = gpg_error_from_errno (errno);
goto fail; /* i.e. EOF */ goto fail; /* i.e. EOF */
} }

View File

@ -639,7 +639,7 @@ proc_plaintext( CTX c, PACKET *pkt )
* documents */ * documents */
clearsig = (*data == 0x01); clearsig = (*data == 0x01);
for( data++, datalen--; datalen; datalen--, data++ ) for( data++, datalen--; datalen; datalen--, data++ )
md_enable( c->mfx.md, *data ); gcry_md_enable (c->mfx.md, *data);
any = 1; any = 1;
break; /* Stop here as one-pass signature packets are not break; /* Stop here as one-pass signature packets are not
expected. */ expected. */
@ -679,7 +679,7 @@ proc_plaintext( CTX c, PACKET *pkt )
} }
rc = handle_plaintext( pt, &c->mfx, c->sigs_only, clearsig ); rc = handle_plaintext( pt, &c->mfx, c->sigs_only, clearsig );
if( gpg_err_code (rc) == G10ERR_CREATE_FILE && !c->sigs_only) if( gpg_err_code (rc) == GPG_ERR_ENOENT && !c->sigs_only)
{ {
#warning We need to change the test for the error code #warning We need to change the test for the error code
/* Can't write output but we hash it anyway to /* Can't write output but we hash it anyway to
@ -1194,7 +1194,7 @@ do_proc_packets( CTX c, IOBUF a )
free_packet(pkt); free_packet(pkt);
/* stop processing when an invalid packet has been encountered /* stop processing when an invalid packet has been encountered
* but don't do so when we are doing a --list-packets. */ * but don't do so when we are doing a --list-packets. */
if (gpg_err_code (rc) == GPG_ERR_INVALID_PACKET if (gpg_err_code (rc) == GPG_ERR_INV_PACKET
&& opt.list_packets != 2 ) && opt.list_packets != 2 )
break; break;
continue; continue;
@ -2002,7 +2002,7 @@ proc_tree( CTX c, KBNODE node )
/* detached signature */ /* detached signature */
free_md_filter_context( &c->mfx ); free_md_filter_context( &c->mfx );
if (gcry_md_open (&c->mfx.md, sig->digest_algo, 0)) if (gcry_md_open (&c->mfx.md, sig->digest_algo, 0))
BUG (): BUG ();
if( !opt.pgp2_workarounds ) if( !opt.pgp2_workarounds )
; ;

View File

@ -491,11 +491,10 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
} }
if( out && pkttype ) { if( out && pkttype ) {
if( iobuf_write( out, hdr, hdrlen ) == -1 ) rc = iobuf_write (out, hdr, hdrlen);
rc = G10ERR_WRITE_FILE; if (!rc)
else
rc = copy_packet(inp, out, pkttype, pktlen, partial ); rc = copy_packet(inp, out, pkttype, pktlen, partial );
goto leave; goto leave;
} }
if (with_uid && pkttype == PKT_USER_ID) if (with_uid && pkttype == PKT_USER_ID)

View File

@ -897,7 +897,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
xfree(p); xfree(p);
if( !get_pubkey( pk, keyid ) ) { if( !get_pubkey( pk, keyid ) ) {
const char *s = pubkey_algo_to_string( pk->pubkey_algo ); const char *s = gcry_pk_algo_name ( pk->pubkey_algo );
tty_printf( _("%u-bit %s key, ID %s, created %s"), tty_printf( _("%u-bit %s key, ID %s, created %s"),
nbits_from_pk( pk ), s?s:"?", keystr(keyid), nbits_from_pk( pk ), s?s:"?", keystr(keyid),
strtimestamp(pk->timestamp) ); strtimestamp(pk->timestamp) );
@ -1011,22 +1011,23 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
static void static void
hash_passphrase( DEK *dek, char *pw, STRING2KEY *s2k, int create ) hash_passphrase( DEK *dek, char *pw, STRING2KEY *s2k, int create )
{ {
MD_HANDLE md; gcry_md_hd_t md;
int pass, i; int pass, i;
int used = 0; int used = 0;
int pwlen = strlen(pw); int pwlen = strlen(pw);
assert( s2k->hash_algo ); assert( s2k->hash_algo );
dek->keylen = cipher_get_keylen( dek->algo ) / 8; dek->keylen = gcry_cipher_algo_get_keylen (dek->algo );
if( !(dek->keylen > 0 && dek->keylen <= DIM(dek->key)) ) if( !(dek->keylen > 0 && dek->keylen <= DIM(dek->key)) )
BUG(); BUG();
md = md_open( s2k->hash_algo, 1); if (gcry_md_open (&md, s2k->hash_algo, 1))
BUG ();
for(pass=0; used < dek->keylen ; pass++ ) { for(pass=0; used < dek->keylen ; pass++ ) {
if( pass ) { if( pass ) {
md_reset(md); gcry_md_reset (md);
for(i=0; i < pass; i++ ) /* preset the hash context */ for(i=0; i < pass; i++ ) /* preset the hash context */
md_putc(md, 0 ); gcry_md_putc (md, 0 );
} }
if( s2k->mode == 1 || s2k->mode == 3 ) { if( s2k->mode == 1 || s2k->mode == 3 ) {
@ -1034,7 +1035,7 @@ hash_passphrase( DEK *dek, char *pw, STRING2KEY *s2k, int create )
ulong count = len2; ulong count = len2;
if( create && !pass ) { if( create && !pass ) {
randomize_buffer(s2k->salt, 8, 1); gcry_randomize (s2k->salt, 8, GCRY_STRONG_RANDOM);
if( s2k->mode == 3 ) if( s2k->mode == 3 )
s2k->count = 96; /* 65536 iterations */ s2k->count = 96; /* 65536 iterations */
} }
@ -1046,27 +1047,27 @@ hash_passphrase( DEK *dek, char *pw, STRING2KEY *s2k, int create )
} }
/* a little bit complicated because we need a ulong for count */ /* a little bit complicated because we need a ulong for count */
while( count > len2 ) { /* maybe iterated+salted */ while( count > len2 ) { /* maybe iterated+salted */
md_write( md, s2k->salt, 8 ); gcry_md_write ( md, s2k->salt, 8 );
md_write( md, pw, pwlen ); gcry_md_write ( md, pw, pwlen );
count -= len2; count -= len2;
} }
if( count < 8 ) if( count < 8 )
md_write( md, s2k->salt, count ); gcry_md_write ( md, s2k->salt, count );
else { else {
md_write( md, s2k->salt, 8 ); gcry_md_write ( md, s2k->salt, 8 );
count -= 8; count -= 8;
md_write( md, pw, count ); gcry_md_write ( md, pw, count );
} }
} }
else else
md_write( md, pw, pwlen ); gcry_md_write ( md, pw, pwlen );
md_final( md ); gcry_md_final( md );
i = md_digest_length( s2k->hash_algo ); i = gcry_md_get_algo_dlen ( s2k->hash_algo );
if( i > dek->keylen - used ) if( i > dek->keylen - used )
i = dek->keylen - used; i = dek->keylen - used;
memcpy( dek->key+used, md_read(md, s2k->hash_algo), i ); memcpy( dek->key+used, md_read(md, s2k->hash_algo), i );
used += i; used += i;
} }
md_close(md); gcry_md_close(md);
} }

View File

@ -958,7 +958,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned int use )
rc = get_pubkey_byname( pk, answer, NULL, NULL, 0 ); rc = get_pubkey_byname( pk, answer, NULL, NULL, 0 );
if (rc) if (rc)
tty_printf(_("No such user ID.\n")); tty_printf(_("No such user ID.\n"));
else if ( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) ) else if ( !(rc=openpgp_pk_test_algo2 (pk->pubkey_algo, use)) )
{ {
if ( have_def_rec ) if ( have_def_rec )
{ {

View File

@ -96,8 +96,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( !fname ) if( !fname )
fname = ask_outfile_name( pt->name, pt->namelen ); fname = ask_outfile_name( pt->name, pt->namelen );
if( !fname ) { if( !fname ) {
rc = gpg_error (GPG_ERR_GENERAL) /* Can't create file. */ rc = gpg_error (GPG_ERR_GENERAL); /* Can't create file. */
goto leave; goto leave;
} }
} }
else { else {
@ -119,7 +119,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
char *tmp = ask_outfile_name (NULL, 0); char *tmp = ask_outfile_name (NULL, 0);
if ( !tmp || !*tmp ) { if ( !tmp || !*tmp ) {
xfree (tmp); xfree (tmp);
rc = G10ERR_CREATE_FILE; rc = gpg_error (GPG_ERR_GENERAL); /* G10ERR_CREATE_FILE*/
goto leave; goto leave;
} }
xfree (fname); xfree (fname);
@ -203,16 +203,19 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
{ {
if(opt.max_output && (++count)>opt.max_output) if(opt.max_output && (++count)>opt.max_output)
{ {
log_error("Error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname,"exceeded --max-output limit\n"); fname,"exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_GENERAL); rc = gpg_error (GPG_ERR_GENERAL);
goto leave; goto leave;
} }
else if( putc( c, fp ) == EOF ) else if( putc( c, fp ) == EOF )
{ {
log_error("Error writing to `%s': %s\n", if (ferror (fp))
fname, strerror(errno) ); rc = gpg_error_from_errno (errno);
rc = G10ERR_WRITE_FILE; else
rc = gpg_error (GPG_ERR_EOF);
log_error ("error writing to `%s': %s\n",
fname, strerror(errno) );
goto leave; goto leave;
} }
} }
@ -224,9 +227,9 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
int len = pt->len > 32768 ? 32768 : pt->len; int len = pt->len > 32768 ? 32768 : pt->len;
len = iobuf_read( pt->buf, buffer, len ); len = iobuf_read( pt->buf, buffer, len );
if( len == -1 ) { if( len == -1 ) {
log_error("Problem reading source (%u bytes remaining)\n", rc = gpg_error_from_errno (errno);
(unsigned)pt->len); log_error ("problem reading source (%u bytes remaining)\n",
rc = G10ERR_READ_FILE; (unsigned)pt->len);
xfree( buffer ); xfree( buffer );
goto leave; goto leave;
} }
@ -260,7 +263,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( convert ) { /* text mode */ if( convert ) { /* text mode */
while( (c = iobuf_get(pt->buf)) != -1 ) { while( (c = iobuf_get(pt->buf)) != -1 ) {
if( mfx->md ) if( mfx->md )
md_putc(mfx->md, c ); gcry_md_putc (mfx->md, c );
#ifndef HAVE_DOSISH_SYSTEM #ifndef HAVE_DOSISH_SYSTEM
if( convert && c == '\r' ) if( convert && c == '\r' )
continue; /* fixme: this hack might be too simple */ continue; /* fixme: this hack might be too simple */
@ -300,7 +303,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( len < 32768 ) if( len < 32768 )
eof = 1; eof = 1;
if( mfx->md ) if( mfx->md )
md_write( mfx->md, buffer, len ); gcry_md_write ( mfx->md, buffer, len );
if( fp ) if( fp )
{ {
if(opt.max_output && (count+=len)>opt.max_output) if(opt.max_output && (count+=len)>opt.max_output)
@ -479,8 +482,8 @@ ask_for_detached_datafile (gcry_md_hd_t md, gcry_md_hd_t md2,
} }
else if( !fp ) else if( !fp )
{ {
rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), answer, strerror(errno)); log_error(_("can't open `%s': %s\n"), answer, strerror(errno));
rc = G10ERR_READ_FILE;
goto leave; goto leave;
} }
} while( !fp ); } while( !fp );
@ -536,9 +539,10 @@ hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2, STRLIST files,
errno = EPERM; errno = EPERM;
} }
if( !fp ) { if( !fp ) {
int rc = gpg_error_from_errno (errno);
log_error(_("can't open signed data `%s'\n"), log_error(_("can't open signed data `%s'\n"),
print_fname_stdin(sl->d)); print_fname_stdin(sl->d));
return G10ERR_OPEN_FILE; return rc;
} }
handle_progress (&pfx, fp, sl->d); handle_progress (&pfx, fp, sl->d);
do_hash( md, md2, fp, textmode ); do_hash( md, md2, fp, textmode );

View File

@ -232,7 +232,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
copy_secret_key( sk, save_sk ); copy_secret_key( sk, save_sk );
passphrase_clear_cache ( keyid, NULL, sk->pubkey_algo ); passphrase_clear_cache ( keyid, NULL, sk->pubkey_algo );
free_secret_key( save_sk ); free_secret_key( save_sk );
return G10ERR_BAD_PASS; return gpg_error (GPG_ERR_BAD_PASSPHRASE);
} }
/* The checksum may fail, so we also check the key itself. */ /* The checksum may fail, so we also check the key itself. */
@ -241,7 +241,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
copy_secret_key( sk, save_sk ); copy_secret_key( sk, save_sk );
passphrase_clear_cache ( keyid, NULL, sk->pubkey_algo ); passphrase_clear_cache ( keyid, NULL, sk->pubkey_algo );
free_secret_key( save_sk ); free_secret_key( save_sk );
return G10ERR_BAD_PASS; return gpg_error (GPG_ERR_BAD_PASSPHRASE);
} }
free_secret_key( save_sk ); free_secret_key( save_sk );
sk->is_protected = 0; sk->is_protected = 0;
@ -286,7 +286,7 @@ check_secret_key( PKT_secret_key *sk, int n )
if( n < 1 ) if( n < 1 )
n = (opt.batch && !opt.use_agent)? 1 : 3; /* use the default value */ n = (opt.batch && !opt.use_agent)? 1 : 3; /* use the default value */
for(i=0; i < n && gpg_err_code (rc) == G10ERR_BAD_PASS; i++ ) { for(i=0; i < n && gpg_err_code (rc) == GPG_ERR_BAD_PASSPHRASE; i++ ) {
int canceled = 0; int canceled = 0;
const char *tryagain = NULL; const char *tryagain = NULL;
if (i) { if (i) {

View File

@ -309,7 +309,7 @@ do_check( PKT_public_key *pk, PKT_signature *sig, gcry_md_hd_t digest,
static void static void
hash_uid_node( KBNODE unode, MD_HANDLE md, PKT_signature *sig ) hash_uid_node( KBNODE unode, gcry_md_hd_t md, PKT_signature *sig )
{ {
PKT_user_id *uid = unode->pkt->pkt.user_id; PKT_user_id *uid = unode->pkt->pkt.user_id;

View File

@ -189,7 +189,7 @@ mk_notation_policy_etc( PKT_signature *sig,
* Helper to hash a user ID packet. * Helper to hash a user ID packet.
*/ */
static void static void
hash_uid (MD_HANDLE md, int sigversion, const PKT_user_id *uid) hash_uid (gcry_md_hd_t md, int sigversion, const PKT_user_id *uid)
{ {
if ( sigversion >= 4 ) { if ( sigversion >= 4 ) {
byte buf[5]; byte buf[5];
@ -222,7 +222,7 @@ hash_uid (MD_HANDLE md, int sigversion, const PKT_user_id *uid)
* Helper to hash some parts from the signature * Helper to hash some parts from the signature
*/ */
static void static void
hash_sigversion_to_magic (MD_HANDLE md, const PKT_signature *sig) hash_sigversion_to_magic (gcry_md_hd_t md, const PKT_signature *sig)
{ {
if (sig->version >= 4) if (sig->version >= 4)
gcry_md_putc (md, sig->version); gcry_md_putc (md, sig->version);
@ -266,7 +266,7 @@ hash_sigversion_to_magic (MD_HANDLE md, const PKT_signature *sig)
static int static int
do_sign( PKT_secret_key *sk, PKT_signature *sig, do_sign( PKT_secret_key *sk, PKT_signature *sig,
MD_HANDLE md, int digest_algo ) gcry_md_hd_t md, int digest_algo )
{ {
gcry_mpi_t frame; gcry_mpi_t frame;
byte *dp; byte *dp;
@ -315,7 +315,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
xfree (rbuf); xfree (rbuf);
} }
#else #else
return G10ERR_UNSUPPORTED; return gpg_error (GPG_ERR_NOT_SUPPORTED);
#endif /* ENABLE_CARD_SUPPORT */ #endif /* ENABLE_CARD_SUPPORT */
} }
else else
@ -324,7 +324,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
variable-q DSA stuff makes it into the standard. */ variable-q DSA stuff makes it into the standard. */
if(!opt.expert if(!opt.expert
&& sk->pubkey_algo==PUBKEY_ALGO_DSA && sk->pubkey_algo==PUBKEY_ALGO_DSA
&& md_digest_length(digest_algo)!=20) && gcry_md_get_algo_dlen (digest_algo)!=20)
{ {
log_error(_("DSA requires the use of a 160 bit hash algorithm\n")); log_error(_("DSA requires the use of a 160 bit hash algorithm\n"));
return G10ERR_GENERAL; return G10ERR_GENERAL;
@ -375,7 +375,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
int int
complete_sig( PKT_signature *sig, PKT_secret_key *sk, MD_HANDLE md ) complete_sig( PKT_signature *sig, PKT_secret_key *sk, gcry_md_hd_t md )
{ {
int rc=0; int rc=0;
@ -419,7 +419,7 @@ hash_for(PKT_secret_key *sk)
prefitem_t *prefs; prefitem_t *prefs;
for(prefs=opt.personal_digest_prefs;prefs->type;prefs++) for(prefs=opt.personal_digest_prefs;prefs->type;prefs++)
if (gcry_md_get_algo-dlen (prefs->value) == 20) if (gcry_md_get_algo_dlen (prefs->value) == 20)
return prefs->value; return prefs->value;
} }
@ -604,10 +604,9 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode)
int bytes_copied; int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1) while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
if (iobuf_write(out, copy_buffer, bytes_copied) == -1) { if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
rc = G10ERR_WRITE_FILE;
log_error ("copying input to output failed: %s\n", log_error ("copying input to output failed: %s\n",
g10_errstr(rc)); gpg_strerror (rc));
break; break;
} }
wipememory(copy_buffer,4096); /* burn buffer */ wipememory(copy_buffer,4096); /* burn buffer */
@ -622,7 +621,7 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode)
* hash which will not be changes here. * hash which will not be changes here.
*/ */
static int static int
write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash, write_signature_packets (SK_LIST sk_list, IOBUF out, gcry_md_hd_t hash,
int sigclass, u32 timestamp, u32 duration, int sigclass, u32 timestamp, u32 duration,
int status_letter) int status_letter)
{ {
@ -632,7 +631,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
for (sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next) { for (sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next) {
PKT_secret_key *sk; PKT_secret_key *sk;
PKT_signature *sig; PKT_signature *sig;
MD_HANDLE md; gcry_md_hd_t md;
int rc; int rc;
sk = sk_rover->sk; sk = sk_rover->sk;
@ -774,11 +773,12 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
inp = NULL; inp = NULL;
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp )
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", {
strerror(errno) ); rc = gpg_error_from_errno (errno);
rc = G10ERR_OPEN_FILE; log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]",
goto leave; strerror(errno) );
goto leave;
} }
handle_progress (&pfx, inp, fname); handle_progress (&pfx, inp, fname);
@ -793,8 +793,8 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
out = iobuf_create( outfile ); out = iobuf_create( outfile );
if( !out ) if( !out )
{ {
rc = gpg_error_from_errno (errno);
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) ); log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
rc = G10ERR_CREATE_FILE;
goto leave; goto leave;
} }
else if( opt.verbose ) else if( opt.verbose )
@ -810,7 +810,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
iobuf_push_filter( inp, text_filter, &tfx ); iobuf_push_filter( inp, text_filter, &tfx );
} }
if ( gcry_md_open (&,mfx.md, 0, 0) ) if ( gcry_md_open (&mfx.md, 0, 0) )
BUG (); BUG ();
if (DBG_HASHING) if (DBG_HASHING)
gcry_md_start_debug (mfx.md, "sign"); gcry_md_start_debug (mfx.md, "sign");
@ -1008,7 +1008,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
{ {
armor_filter_context_t afx; armor_filter_context_t afx;
progress_filter_context_t pfx; progress_filter_context_t pfx;
MD_HANDLE textmd = NULL; gcry_md_hd_t textmd = NULL;
IOBUF inp = NULL, out = NULL; IOBUF inp = NULL, out = NULL;
PACKET pkt; PACKET pkt;
int rc = 0; int rc = 0;
@ -1051,9 +1051,9 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp ) {
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", rc = gpg_error_from_errno (errno);
strerror(errno) ); log_error (_("can't open `%s': %s\n"),
rc = G10ERR_OPEN_FILE; fname? fname: "[stdin]", strerror(errno) );
goto leave; goto leave;
} }
handle_progress (&pfx, inp, fname); handle_progress (&pfx, inp, fname);
@ -1067,8 +1067,8 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
out = iobuf_create( outfile ); out = iobuf_create( outfile );
if( !out ) if( !out )
{ {
rc = gpg_error_from_errno (errno);
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) ); log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
rc = G10ERR_CREATE_FILE;
goto leave; goto leave;
} }
else if( opt.verbose ) else if( opt.verbose )
@ -1101,7 +1101,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
int i = hash_for(sk); int i = hash_for(sk);
if( !hashs_seen[ i & 0xff ] ) { if( !hashs_seen[ i & 0xff ] ) {
s = gcry_md_ago_name ( i ); s = gcry_md_algo_name ( i );
if( s ) { if( s ) {
hashs_seen[ i & 0xff ] = 1; hashs_seen[ i & 0xff ] = 1;
if( any ) if( any )
@ -1203,9 +1203,9 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp ) {
log_error(_("can't open `%s': %s\n"), rc = gpg_error_from_errno (errno);
fname? fname: "[stdin]", strerror(errno) ); log_error (_("can't open `%s': %s\n"),
rc = G10ERR_OPEN_FILE; fname? fname: "[stdin]", strerror(errno) );
goto leave; goto leave;
} }
handle_progress (&pfx, inp, fname); handle_progress (&pfx, inp, fname);
@ -1222,8 +1222,8 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
cfx.dek = passphrase_to_dek( NULL, 0, algo, s2k, 2, NULL, NULL); cfx.dek = passphrase_to_dek( NULL, 0, algo, s2k, 2, NULL, NULL);
if (!cfx.dek || !cfx.dek->keylen) { if (!cfx.dek || !cfx.dek->keylen) {
rc = G10ERR_PASSPHRASE; rc = gpg_error (GPG_ERR_BAD_PASSPHRASE);
log_error(_("error creating passphrase: %s\n"), g10_errstr(rc) ); log_error(_("error creating passphrase: %s\n"), gpg_strerror (rc) );
goto leave; goto leave;
} }
@ -1341,7 +1341,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk,
{ {
PKT_signature *sig; PKT_signature *sig;
int rc=0; int rc=0;
MD_HANDLE md; gcry_md_hd_t md;
assert( (sigclass >= 0x10 && sigclass <= 0x13) || sigclass == 0x1F assert( (sigclass >= 0x10 && sigclass <= 0x13) || sigclass == 0x1F
|| sigclass == 0x20 || sigclass == 0x18 || sigclass == 0x19 || sigclass == 0x20 || sigclass == 0x18 || sigclass == 0x19
@ -1455,7 +1455,7 @@ update_keysig_packet( PKT_signature **ret_sig,
{ {
PKT_signature *sig; PKT_signature *sig;
int rc=0; int rc=0;
MD_HANDLE md; gcry_md_hd_t md;
if ((!orig_sig || !pk || !sk) if ((!orig_sig || !pk || !sk)
|| (orig_sig->sig_class >= 0x10 && orig_sig->sig_class <= 0x13 && !uid) || (orig_sig->sig_class >= 0x10 && orig_sig->sig_class <= 0x13 && !uid)
@ -1506,7 +1506,7 @@ update_keysig_packet( PKT_signature **ret_sig,
if (!rc) { if (!rc) {
hash_sigversion_to_magic (md, sig); hash_sigversion_to_magic (md, sig);
md_final(md); gcry_md_final (md);
rc = complete_sig( sig, sk, md ); rc = complete_sig( sig, sk, md );
} }

View File

@ -176,7 +176,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
log_error(_("skipped \"%s\": %s\n"), log_error(_("skipped \"%s\": %s\n"),
locusr->d, g10_errstr(rc) ); locusr->d, g10_errstr(rc) );
} }
else if( !(rc=openpgp_pk_test_algo (sk->pubkey_algo, use)) ) { else if( !(rc=openpgp_pk_test_algo2 (sk->pubkey_algo, use)) ) {
SK_LIST r; SK_LIST r;
if( sk->version == 4 && (use & PUBKEY_USAGE_SIG) if( sk->version == 4 && (use & PUBKEY_USAGE_SIG)

View File

@ -94,7 +94,6 @@ static int db_fd = -1;
static int in_transaction; static int in_transaction;
static void open_db(void); static void open_db(void);
static void migrate_from_v2 (void);
@ -580,8 +579,6 @@ tdbio_get_dbname()
static void static void
open_db() open_db()
{ {
byte buf[10];
int n;
TRUSTREC rec; TRUSTREC rec;
assert( db_fd == -1 ); assert( db_fd == -1 );