[svn] GnuPG - r4114 - branches/GNUPG-1-9-BRANCH/g10
svn author wk
cvs at cvs.gnupg.org
Wed Apr 19 15:24:37 CEST 2006
Author: wk
Date: 2006-04-19 15:24:36 +0200 (Wed, 19 Apr 2006)
New Revision: 4114
Modified:
branches/GNUPG-1-9-BRANCH/g10/cipher.c
branches/GNUPG-1-9-BRANCH/g10/dearmor.c
branches/GNUPG-1-9-BRANCH/g10/encode.c
branches/GNUPG-1-9-BRANCH/g10/exec.c
branches/GNUPG-1-9-BRANCH/g10/export.c
branches/GNUPG-1-9-BRANCH/g10/filter.h
branches/GNUPG-1-9-BRANCH/g10/gpgv.c
branches/GNUPG-1-9-BRANCH/g10/import.c
branches/GNUPG-1-9-BRANCH/g10/keyedit.c
branches/GNUPG-1-9-BRANCH/g10/keygen.c
branches/GNUPG-1-9-BRANCH/g10/keylist.c
branches/GNUPG-1-9-BRANCH/g10/keyserver.c
branches/GNUPG-1-9-BRANCH/g10/mainproc.c
branches/GNUPG-1-9-BRANCH/g10/parse-packet.c
branches/GNUPG-1-9-BRANCH/g10/passphrase.c
branches/GNUPG-1-9-BRANCH/g10/pkclist.c
branches/GNUPG-1-9-BRANCH/g10/plaintext.c
branches/GNUPG-1-9-BRANCH/g10/seckey-cert.c
branches/GNUPG-1-9-BRANCH/g10/sig-check.c
branches/GNUPG-1-9-BRANCH/g10/sign.c
branches/GNUPG-1-9-BRANCH/g10/skclist.c
branches/GNUPG-1-9-BRANCH/g10/tdbio.c
Log:
Continued with merging.
Still does not build.
Modified: branches/GNUPG-1-9-BRANCH/g10/cipher.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/cipher.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/cipher.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -51,7 +51,7 @@
unsigned int blocksize;
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 )
log_fatal("unsupported blocksize %u\n", blocksize );
@@ -88,8 +88,8 @@
GCRY_CIPHER_MODE_CFB,
(GCRY_CIPHER_SECURE
| ((cfx->dek->use_mdc || cfx->dek->algo >= 100)?
- 0 : GCRY_CIPHER_ENABLE_SYNC));
- if (rc) {
+ 0 : GCRY_CIPHER_ENABLE_SYNC)));
+ if (err) {
/* We should never get an error here cause we already checked,
* that the algorithm is available. */
BUG();
Modified: branches/GNUPG-1-9-BRANCH/g10/dearmor.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/dearmor.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/dearmor.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -58,9 +58,9 @@
errno = EPERM;
}
if (!inp) {
+ rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) );
- rc = G10ERR_OPEN_FILE;
goto leave;
}
@@ -107,9 +107,9 @@
errno = EPERM;
}
if (!inp) {
+ rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) );
- rc = G10ERR_OPEN_FILE;
goto leave;
}
Modified: branches/GNUPG-1-9-BRANCH/g10/encode.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/encode.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/encode.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -92,7 +92,7 @@
BUG ();
if (gcry_cipher_setkey (hd, dek->key, dek->keylen))
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_close (hd);
@@ -190,7 +190,7 @@
}
if( !inp ) {
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) );
return rc;
}
@@ -365,9 +365,9 @@
byte copy_buffer[4096];
int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
- if (iobuf_write(out, copy_buffer, bytes_copied) == -1) {
- rc = G10ERR_WRITE_FILE;
- log_error("copying input to output failed: %s\n", g10_errstr(rc) );
+ if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
+ log_error ("copying input to output failed: %s\n",
+ gpg_strerror (rc) );
break;
}
wipememory(copy_buffer, 4096); /* burn buffer */
@@ -403,7 +403,7 @@
{
xfree(*symkey_dek);
xfree(*symkey_s2k);
- return G10ERR_PASSPHRASE;
+ return gpg_error (GPG_ERR_BAD_PASSPHRASE);
}
return 0;
@@ -412,7 +412,7 @@
static int
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;
byte enckey[33];
@@ -674,10 +674,9 @@
byte copy_buffer[4096];
int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
- if (iobuf_write(out, copy_buffer, bytes_copied) == -1) {
- rc = G10ERR_WRITE_FILE;
- log_error("copying input to output failed: %s\n",
- g10_errstr(rc) );
+ if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
+ log_error ("copying input to output failed: %s\n",
+ gpg_strerror (rc));
break;
}
wipememory(copy_buffer, 4096); /* burn buffer */
@@ -795,7 +794,7 @@
int rc;
for( ; pk_list; pk_list = pk_list->next ) {
- MPI frame;
+ gcry_mpi_t frame;
pk = pk_list->pk;
Modified: branches/GNUPG-1-9-BRANCH/g10/exec.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/exec.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/exec.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -438,8 +438,8 @@
(*info)->tochild=fdopen(to[1],binary?"wb":"w");
if((*info)->tochild==NULL)
{
+ ret = gpg_error_from_errno (errno);
close(to[1]);
- ret=G10ERR_WRITE_FILE;
goto fail;
}
@@ -448,8 +448,8 @@
(*info)->fromchild=iobuf_fdopen(from[0],"r");
if((*info)->fromchild==NULL)
{
+ ret = gpg_error_from_errno (errno);
close(from[0]);
- ret=G10ERR_READ_FILE;
goto fail;
}
@@ -547,9 +547,9 @@
}
if(info->fromchild==NULL)
{
+ ret = gpg_error_from_errno (errno);
log_error(_("unable to read external program response: %s\n"),
strerror(errno));
- ret=G10ERR_READ_FILE;
goto fail;
}
Modified: branches/GNUPG-1-9-BRANCH/g10/export.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/export.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/export.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -594,7 +594,6 @@
if( rc ) {
log_error("build_packet(%d) failed: %s\n",
node->pkt->pkttype, g10_errstr(rc) );
- rc = G10ERR_WRITE_FILE;
goto leave;
}
}
Modified: branches/GNUPG-1-9-BRANCH/g10/filter.h
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/filter.h 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/filter.h 2006-04-19 13:24:36 UTC (rev 4114)
@@ -126,36 +126,36 @@
/* encrypt_filter_context_t defined in main.h */
/*-- 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 );
/*-- armor.c --*/
-int use_armor_filter( IOBUF a );
+int use_armor_filter( iobuf_t a );
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);
void unarmor_pump_release (UnarmorPump x);
int unarmor_pump (UnarmorPump x, int c);
/*-- compress.c --*/
-void push_compress_filter(IOBUF out,compress_filter_context_t *zfx,int algo);
-void push_compress_filter2(IOBUF out,compress_filter_context_t *zfx,
+void push_compress_filter(iobuf_t out,compress_filter_context_t *zfx,int algo);
+void push_compress_filter2(iobuf_t out,compress_filter_context_t *zfx,
int algo,int rel);
/*-- cipher.c --*/
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 --*/
int text_filter( void *opaque, int control,
- IOBUF chain, byte *buf, size_t *ret_len);
-int copy_clearsig_text (IOBUF out, IOBUF inp, gcry_md_hd_t md,
+ iobuf_t chain, byte *buf, size_t *ret_len);
+int copy_clearsig_text (iobuf_t out, iobuf_t inp, gcry_md_hd_t md,
int escape_dash, int escape_from, int pgp2mode);
/*-- progress.c --*/
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,
- IOBUF inp, const char *name);
+ iobuf_t inp, const char *name);
#endif /*G10_FILTER_H*/
Modified: branches/GNUPG-1-9-BRANCH/g10/gpgv.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/gpgv.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/gpgv.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -49,8 +49,6 @@
#include "ttyio.h"
#include "i18n.h"
#include "status.h"
-#include "g10defs.h"
-#include "cardglue.h"
enum cmd_and_opt_values { aNull = 0,
@@ -379,15 +377,15 @@
int check_cipher_algo( int algo ) { return -1;}
unsigned int cipher_get_keylen( 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;}
-void cipher_close( CIPHER_HANDLE c ) {}
-int cipher_setkey( CIPHER_HANDLE c, byte *key, unsigned keylen ) { return -1;}
-void cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen ){}
-void cipher_encrypt( CIPHER_HANDLE c, byte *outbuf,
+gcry_cipher_hd_t cipher_open( int algo, int mode, int secure ) { return NULL;}
+void cipher_close( gcry_cipher_hd_t c ) {}
+int cipher_setkey( gcry_cipher_hd_t c, byte *key, unsigned keylen ) { return -1;}
+void cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen ){}
+void cipher_encrypt( gcry_cipher_hd_t c, byte *outbuf,
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 ) {}
-void cipher_sync( CIPHER_HANDLE c ) {}
+void cipher_sync( gcry_cipher_hd_t c ) {}
/* Stubs to avoid linking to ../cipher/random.c */
void random_dump_stats(void) {}
@@ -404,7 +402,7 @@
MPI generate_secret_prime( unsigned nbits ) { return NULL;}
MPI generate_public_prime( unsigned nbits ) { return NULL;}
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 */
void rndlinux_constructor(void) {}
Modified: branches/GNUPG-1-9-BRANCH/g10/import.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/import.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/import.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -596,9 +596,9 @@
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)
check_prefs_warning(pk);
log_info(_(" \"%s\": preference for cipher"
@@ -608,9 +608,9 @@
}
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)
check_prefs_warning(pk);
log_info(_(" \"%s\": preference for digest"
@@ -620,7 +620,7 @@
}
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);
if(!problem)
@@ -1541,9 +1541,9 @@
else
subkey_seen = 1;
}
- else if( node->pkt->pkttype == PKT_SIGNATURE
- && check_pubkey_algo( node->pkt->pkt.signature->pubkey_algo)
- && node->pkt->pkt.signature->pubkey_algo != PUBKEY_ALGO_RSA )
+ else if (node->pkt->pkttype == PKT_SIGNATURE
+ && openpgp_pk_test_algo (node->pkt->pkt.signature->pubkey_algo)
+ && node->pkt->pkt.signature->pubkey_algo != PUBKEY_ALGO_RSA )
delete_kbnode( node ); /* build_packet() can't handle this */
else if( node->pkt->pkttype == PKT_SIGNATURE &&
!node->pkt->pkt.signature->flags.exportable &&
Modified: branches/GNUPG-1-9-BRANCH/g10/keyedit.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/keyedit.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/keyedit.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -2311,7 +2311,7 @@
tty_printf (_("Cipher: "));
for(i=any=0; prefs[i].type; i++ ) {
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)
tty_printf (", ");
@@ -2328,13 +2328,13 @@
if (!des_seen) {
if (any)
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 (_("Digest: "));
for(i=any=0; prefs[i].type; i++ ) {
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)
tty_printf (", ");
@@ -2351,7 +2351,7 @@
if (!sha1_seen) {
if (any)
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 (_("Compression: "));
@@ -2686,7 +2686,7 @@
if(pk->is_revoked)
{
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"),
revokestr_from_pk(pk),algo?algo:"?",user);
xfree(user);
@@ -2701,9 +2701,9 @@
{
u32 r_keyid[2];
char *user;
- const char *algo=
- pubkey_algo_to_string(pk->revkey[i].algid);
+ const char *algo;
+ algo = gcry_pk_algo_name (pk->revkey[i].algid);
keyid_from_fingerprint(pk->revkey[i].fpr,
MAX_FINGERPRINT_LEN,r_keyid);
Modified: branches/GNUPG-1-9-BRANCH/g10/keygen.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/keygen.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/keygen.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -319,13 +319,13 @@
/* Make sure we do not add more than 15 items here, as we
could overflow the size of dummy_string. We currently
have at most 12. */
- if(!check_cipher_algo(CIPHER_ALGO_AES256))
+ if ( !openpgp_cipher_test_algo (CIPHER_ALGO_AES256) )
strcat(dummy_string,"S9 ");
- if(!check_cipher_algo(CIPHER_ALGO_AES192))
+ if ( !openpgp_cipher_test_algo (CIPHER_ALGO_AES192) )
strcat(dummy_string,"S8 ");
- if(!check_cipher_algo(CIPHER_ALGO_AES))
+ if ( !openpgp_cipher_test_algo (CIPHER_ALGO_AES) )
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,"S2 "); /* 3DES */
/* If we have it, IDEA goes *after* 3DES so it won't be
@@ -335,7 +335,7 @@
break PGP2, but that is difficult with the current
code, and not really worth checking as a non-RSA <=2048
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 ");
/* SHA-1 */
@@ -370,12 +370,12 @@
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))
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))
rc=-1;
@@ -1071,6 +1071,7 @@
static void
genhelp_factors (gcry_sexp_t misc_key_info, KBNODE sec_root)
{
+#if 0 /* Not used anymore */
size_t n;
char *buf;
@@ -1093,6 +1094,7 @@
xfree (buf);
gcry_sexp_release (misc_key_info);
}
+#endif
}
@@ -1484,7 +1486,7 @@
{
tty_printf("\n");
tty_printf(_("Possible actions for a %s key: "),
- pubkey_algo_to_string(algo));
+ gcry_pk_algo_name (algo));
print_key_flags(possible);
tty_printf("\n");
tty_printf(_("Current allowed actions: "));
@@ -1649,7 +1651,7 @@
}
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(;;)
{
@@ -1670,7 +1672,7 @@
if(nbits<min || nbits>max)
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
break;
}
@@ -2136,7 +2138,7 @@
if( digitp( r->u.value ) )
i = atoi( r->u.value );
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)
i = 0; /* we don't want to allow generation of these algorithms */
return i;
@@ -2287,7 +2289,7 @@
if(r)
{
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 );
return -1;
@@ -2316,7 +2318,7 @@
if(r)
{
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 );
return -1;
@@ -3504,7 +3506,7 @@
{
log_error("build_packet(%d) failed: %s\n",
node->pkt->pkttype, g10_errstr(rc) );
- return G10ERR_WRITE_FILE;
+ return rc;
}
}
}
Modified: branches/GNUPG-1-9-BRANCH/g10/keylist.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/keylist.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/keylist.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -917,7 +917,8 @@
rc = check_key_signature( keyblock, node, NULL );
switch( gpg_err_code (rc) ) {
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_UNUSABLE_PUBKEY: stats->no_key++; continue;
default: stats->oth_err++; sigrc = '%'; break;
@@ -1306,11 +1307,11 @@
rc = check_key_signature2( keyblock, node, NULL, signer_pk,
NULL, NULL, NULL );
switch ( gpg_err_code (rc) ) {
- case 0: sigrc = '!'; break;
- case GPG_ERR_BAD_SIGN: sigrc = '-'; break;
+ case 0: sigrc = '!'; break;
+ case GPG_ERR_BAD_SIGNATURE: sigrc = '-'; break;
case GPG_ERR_NO_PUBKEY:
- case GPG_ERR_UNU_PUBKEY: sigrc = '?'; break;
- default: sigrc = '%'; break;
+ case Gpg_Err_UNUSABLE_PUBKEY: sigrc = '?'; break;
+ default: sigrc = '%'; break;
}
if(opt.no_sig_cache)
Modified: branches/GNUPG-1-9-BRANCH/g10/keyserver.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/keyserver.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/keyserver.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -478,7 +478,7 @@
if(keyrec->type)
{
- const char *str=pubkey_algo_to_string(keyrec->type);
+ const char *str = gcry_pk_algo_name (keyrec->type);
if(str)
printf("%s ",str);
@@ -1402,7 +1402,7 @@
maxlen=1024;
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 */
}
Modified: branches/GNUPG-1-9-BRANCH/g10/mainproc.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/mainproc.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/mainproc.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -639,7 +639,7 @@
* documents */
clearsig = (*data == 0x01);
for( data++, datalen--; datalen; datalen--, data++ )
- md_enable( c->mfx.md, *data );
+ gcry_md_enable (c->mfx.md, *data);
any = 1;
break; /* Stop here as one-pass signature packets are not
expected. */
@@ -679,7 +679,7 @@
}
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
/* Can't write output but we hash it anyway to
@@ -1194,7 +1194,7 @@
free_packet(pkt);
/* stop processing when an invalid packet has been encountered
* 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 )
break;
continue;
@@ -2002,7 +2002,7 @@
/* detached signature */
free_md_filter_context( &c->mfx );
if (gcry_md_open (&c->mfx.md, sig->digest_algo, 0))
- BUG ():
+ BUG ();
if( !opt.pgp2_workarounds )
;
Modified: branches/GNUPG-1-9-BRANCH/g10/parse-packet.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/parse-packet.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/parse-packet.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -491,11 +491,10 @@
}
if( out && pkttype ) {
- if( iobuf_write( out, hdr, hdrlen ) == -1 )
- rc = G10ERR_WRITE_FILE;
- else
+ rc = iobuf_write (out, hdr, hdrlen);
+ if (!rc)
rc = copy_packet(inp, out, pkttype, pktlen, partial );
- goto leave;
+ goto leave;
}
if (with_uid && pkttype == PKT_USER_ID)
Modified: branches/GNUPG-1-9-BRANCH/g10/passphrase.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/passphrase.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/passphrase.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -897,7 +897,7 @@
xfree(p);
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"),
nbits_from_pk( pk ), s?s:"?", keystr(keyid),
strtimestamp(pk->timestamp) );
@@ -1011,22 +1011,23 @@
static void
hash_passphrase( DEK *dek, char *pw, STRING2KEY *s2k, int create )
{
- MD_HANDLE md;
+ gcry_md_hd_t md;
int pass, i;
int used = 0;
int pwlen = strlen(pw);
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)) )
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++ ) {
if( pass ) {
- md_reset(md);
+ gcry_md_reset (md);
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 ) {
@@ -1034,7 +1035,7 @@
ulong count = len2;
if( create && !pass ) {
- randomize_buffer(s2k->salt, 8, 1);
+ gcry_randomize (s2k->salt, 8, GCRY_STRONG_RANDOM);
if( s2k->mode == 3 )
s2k->count = 96; /* 65536 iterations */
}
@@ -1046,27 +1047,27 @@
}
/* a little bit complicated because we need a ulong for count */
while( count > len2 ) { /* maybe iterated+salted */
- md_write( md, s2k->salt, 8 );
- md_write( md, pw, pwlen );
+ gcry_md_write ( md, s2k->salt, 8 );
+ gcry_md_write ( md, pw, pwlen );
count -= len2;
}
if( count < 8 )
- md_write( md, s2k->salt, count );
+ gcry_md_write ( md, s2k->salt, count );
else {
- md_write( md, s2k->salt, 8 );
+ gcry_md_write ( md, s2k->salt, 8 );
count -= 8;
- md_write( md, pw, count );
+ gcry_md_write ( md, pw, count );
}
}
else
- md_write( md, pw, pwlen );
- md_final( md );
- i = md_digest_length( s2k->hash_algo );
+ gcry_md_write ( md, pw, pwlen );
+ gcry_md_final( md );
+ i = gcry_md_get_algo_dlen ( s2k->hash_algo );
if( i > dek->keylen - used )
i = dek->keylen - used;
memcpy( dek->key+used, md_read(md, s2k->hash_algo), i );
used += i;
}
- md_close(md);
+ gcry_md_close(md);
}
Modified: branches/GNUPG-1-9-BRANCH/g10/pkclist.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/pkclist.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/pkclist.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -958,7 +958,7 @@
rc = get_pubkey_byname( pk, answer, NULL, NULL, 0 );
if (rc)
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 )
{
Modified: branches/GNUPG-1-9-BRANCH/g10/plaintext.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/plaintext.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/plaintext.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -96,8 +96,8 @@
if( !fname )
fname = ask_outfile_name( pt->name, pt->namelen );
if( !fname ) {
- rc = gpg_error (GPG_ERR_GENERAL) /* Can't create file. */
- goto leave;
+ rc = gpg_error (GPG_ERR_GENERAL); /* Can't create file. */
+ goto leave;
}
}
else {
@@ -119,7 +119,7 @@
char *tmp = ask_outfile_name (NULL, 0);
if ( !tmp || !*tmp ) {
xfree (tmp);
- rc = G10ERR_CREATE_FILE;
+ rc = gpg_error (GPG_ERR_GENERAL); /* G10ERR_CREATE_FILE*/
goto leave;
}
xfree (fname);
@@ -203,16 +203,19 @@
{
if(opt.max_output && (++count)>opt.max_output)
{
- log_error("Error writing to `%s': %s\n",
- fname,"exceeded --max-output limit\n");
+ log_error ("error writing to `%s': %s\n",
+ fname,"exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_GENERAL);
goto leave;
}
else if( putc( c, fp ) == EOF )
{
- log_error("Error writing to `%s': %s\n",
- fname, strerror(errno) );
- rc = G10ERR_WRITE_FILE;
+ if (ferror (fp))
+ rc = gpg_error_from_errno (errno);
+ else
+ rc = gpg_error (GPG_ERR_EOF);
+ log_error ("error writing to `%s': %s\n",
+ fname, strerror(errno) );
goto leave;
}
}
@@ -224,9 +227,9 @@
int len = pt->len > 32768 ? 32768 : pt->len;
len = iobuf_read( pt->buf, buffer, len );
if( len == -1 ) {
- log_error("Problem reading source (%u bytes remaining)\n",
- (unsigned)pt->len);
- rc = G10ERR_READ_FILE;
+ rc = gpg_error_from_errno (errno);
+ log_error ("problem reading source (%u bytes remaining)\n",
+ (unsigned)pt->len);
xfree( buffer );
goto leave;
}
@@ -260,7 +263,7 @@
if( convert ) { /* text mode */
while( (c = iobuf_get(pt->buf)) != -1 ) {
if( mfx->md )
- md_putc(mfx->md, c );
+ gcry_md_putc (mfx->md, c );
#ifndef HAVE_DOSISH_SYSTEM
if( convert && c == '\r' )
continue; /* fixme: this hack might be too simple */
@@ -300,7 +303,7 @@
if( len < 32768 )
eof = 1;
if( mfx->md )
- md_write( mfx->md, buffer, len );
+ gcry_md_write ( mfx->md, buffer, len );
if( fp )
{
if(opt.max_output && (count+=len)>opt.max_output)
@@ -479,8 +482,8 @@
}
else if( !fp )
{
+ rc = gpg_error_from_errno (errno);
log_error(_("can't open `%s': %s\n"), answer, strerror(errno));
- rc = G10ERR_READ_FILE;
goto leave;
}
} while( !fp );
@@ -536,9 +539,10 @@
errno = EPERM;
}
if( !fp ) {
+ int rc = gpg_error_from_errno (errno);
log_error(_("can't open signed data `%s'\n"),
print_fname_stdin(sl->d));
- return G10ERR_OPEN_FILE;
+ return rc;
}
handle_progress (&pfx, fp, sl->d);
do_hash( md, md2, fp, textmode );
Modified: branches/GNUPG-1-9-BRANCH/g10/seckey-cert.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/seckey-cert.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/seckey-cert.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -232,7 +232,7 @@
copy_secret_key( sk, save_sk );
passphrase_clear_cache ( keyid, NULL, sk->pubkey_algo );
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. */
@@ -241,7 +241,7 @@
copy_secret_key( sk, save_sk );
passphrase_clear_cache ( keyid, NULL, sk->pubkey_algo );
free_secret_key( save_sk );
- return G10ERR_BAD_PASS;
+ return gpg_error (GPG_ERR_BAD_PASSPHRASE);
}
free_secret_key( save_sk );
sk->is_protected = 0;
@@ -286,7 +286,7 @@
if( n < 1 )
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;
const char *tryagain = NULL;
if (i) {
Modified: branches/GNUPG-1-9-BRANCH/g10/sig-check.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/sig-check.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/sig-check.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -309,7 +309,7 @@
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;
Modified: branches/GNUPG-1-9-BRANCH/g10/sign.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/sign.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/sign.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -189,7 +189,7 @@
* Helper to hash a user ID packet.
*/
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 ) {
byte buf[5];
@@ -222,7 +222,7 @@
* Helper to hash some parts from the signature
*/
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)
gcry_md_putc (md, sig->version);
@@ -266,7 +266,7 @@
static int
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;
byte *dp;
@@ -315,7 +315,7 @@
xfree (rbuf);
}
#else
- return G10ERR_UNSUPPORTED;
+ return gpg_error (GPG_ERR_NOT_SUPPORTED);
#endif /* ENABLE_CARD_SUPPORT */
}
else
@@ -324,7 +324,7 @@
variable-q DSA stuff makes it into the standard. */
if(!opt.expert
&& 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"));
return G10ERR_GENERAL;
@@ -375,7 +375,7 @@
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;
@@ -419,7 +419,7 @@
prefitem_t *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;
}
@@ -604,10 +604,9 @@
int bytes_copied;
while ((bytes_copied = iobuf_read(inp, copy_buffer, 4096)) != -1)
- if (iobuf_write(out, copy_buffer, bytes_copied) == -1) {
- rc = G10ERR_WRITE_FILE;
+ if ( (rc=iobuf_write(out, copy_buffer, bytes_copied)) ) {
log_error ("copying input to output failed: %s\n",
- g10_errstr(rc));
+ gpg_strerror (rc));
break;
}
wipememory(copy_buffer,4096); /* burn buffer */
@@ -622,7 +621,7 @@
* hash which will not be changes here.
*/
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 status_letter)
{
@@ -632,7 +631,7 @@
for (sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next) {
PKT_secret_key *sk;
PKT_signature *sig;
- MD_HANDLE md;
+ gcry_md_hd_t md;
int rc;
sk = sk_rover->sk;
@@ -774,11 +773,12 @@
inp = NULL;
errno = EPERM;
}
- if( !inp ) {
- log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
- strerror(errno) );
- rc = G10ERR_OPEN_FILE;
- goto leave;
+ if( !inp )
+ {
+ rc = gpg_error_from_errno (errno);
+ log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]",
+ strerror(errno) );
+ goto leave;
}
handle_progress (&pfx, inp, fname);
@@ -793,8 +793,8 @@
out = iobuf_create( outfile );
if( !out )
{
+ rc = gpg_error_from_errno (errno);
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
- rc = G10ERR_CREATE_FILE;
goto leave;
}
else if( opt.verbose )
@@ -810,7 +810,7 @@
iobuf_push_filter( inp, text_filter, &tfx );
}
- if ( gcry_md_open (&,mfx.md, 0, 0) )
+ if ( gcry_md_open (&mfx.md, 0, 0) )
BUG ();
if (DBG_HASHING)
gcry_md_start_debug (mfx.md, "sign");
@@ -1008,7 +1008,7 @@
{
armor_filter_context_t afx;
progress_filter_context_t pfx;
- MD_HANDLE textmd = NULL;
+ gcry_md_hd_t textmd = NULL;
IOBUF inp = NULL, out = NULL;
PACKET pkt;
int rc = 0;
@@ -1051,9 +1051,9 @@
errno = EPERM;
}
if( !inp ) {
- log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
- strerror(errno) );
- rc = G10ERR_OPEN_FILE;
+ rc = gpg_error_from_errno (errno);
+ log_error (_("can't open `%s': %s\n"),
+ fname? fname: "[stdin]", strerror(errno) );
goto leave;
}
handle_progress (&pfx, inp, fname);
@@ -1067,8 +1067,8 @@
out = iobuf_create( outfile );
if( !out )
{
+ rc = gpg_error_from_errno (errno);
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
- rc = G10ERR_CREATE_FILE;
goto leave;
}
else if( opt.verbose )
@@ -1101,7 +1101,7 @@
int i = hash_for(sk);
if( !hashs_seen[ i & 0xff ] ) {
- s = gcry_md_ago_name ( i );
+ s = gcry_md_algo_name ( i );
if( s ) {
hashs_seen[ i & 0xff ] = 1;
if( any )
@@ -1203,9 +1203,9 @@
errno = EPERM;
}
if( !inp ) {
- log_error(_("can't open `%s': %s\n"),
- fname? fname: "[stdin]", strerror(errno) );
- rc = G10ERR_OPEN_FILE;
+ rc = gpg_error_from_errno (errno);
+ log_error (_("can't open `%s': %s\n"),
+ fname? fname: "[stdin]", strerror(errno) );
goto leave;
}
handle_progress (&pfx, inp, fname);
@@ -1222,8 +1222,8 @@
cfx.dek = passphrase_to_dek( NULL, 0, algo, s2k, 2, NULL, NULL);
if (!cfx.dek || !cfx.dek->keylen) {
- rc = G10ERR_PASSPHRASE;
- log_error(_("error creating passphrase: %s\n"), g10_errstr(rc) );
+ rc = gpg_error (GPG_ERR_BAD_PASSPHRASE);
+ log_error(_("error creating passphrase: %s\n"), gpg_strerror (rc) );
goto leave;
}
@@ -1341,7 +1341,7 @@
{
PKT_signature *sig;
int rc=0;
- MD_HANDLE md;
+ gcry_md_hd_t md;
assert( (sigclass >= 0x10 && sigclass <= 0x13) || sigclass == 0x1F
|| sigclass == 0x20 || sigclass == 0x18 || sigclass == 0x19
@@ -1455,7 +1455,7 @@
{
PKT_signature *sig;
int rc=0;
- MD_HANDLE md;
+ gcry_md_hd_t md;
if ((!orig_sig || !pk || !sk)
|| (orig_sig->sig_class >= 0x10 && orig_sig->sig_class <= 0x13 && !uid)
@@ -1506,7 +1506,7 @@
if (!rc) {
hash_sigversion_to_magic (md, sig);
- md_final(md);
+ gcry_md_final (md);
rc = complete_sig( sig, sk, md );
}
Modified: branches/GNUPG-1-9-BRANCH/g10/skclist.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/skclist.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/skclist.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -176,7 +176,7 @@
log_error(_("skipped \"%s\": %s\n"),
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;
if( sk->version == 4 && (use & PUBKEY_USAGE_SIG)
Modified: branches/GNUPG-1-9-BRANCH/g10/tdbio.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/tdbio.c 2006-04-19 11:26:11 UTC (rev 4113)
+++ branches/GNUPG-1-9-BRANCH/g10/tdbio.c 2006-04-19 13:24:36 UTC (rev 4114)
@@ -94,7 +94,6 @@
static int in_transaction;
static void open_db(void);
-static void migrate_from_v2 (void);
@@ -580,8 +579,6 @@
static void
open_db()
{
- byte buf[10];
- int n;
TRUSTREC rec;
assert( db_fd == -1 );
More information about the Gnupg-commits
mailing list