mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
more bug fixesand some warning cleanups
This commit is contained in:
parent
2874670be9
commit
d4cd7a3d4b
23 changed files with 164 additions and 61 deletions
|
@ -1,3 +1,23 @@
|
|||
2001-09-09 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* keyedit.c (keyedit_menu): No need to define another p.
|
||||
|
||||
* keylist.c (print_capabilities): s/used/use/ so that it
|
||||
does not shadow a global.
|
||||
* sign.c (sign_file): Renamed arg encrypt to encryptflag
|
||||
* keygen.c: Replaced all "usage" by "use".
|
||||
* misc.c (openpgp_pk_algo_usage): Ditto.
|
||||
|
||||
* pubkey-enc.c (get_it): Renamed arg k to enc so that the later
|
||||
defined k does not shadow it.
|
||||
|
||||
* parse-packet.c (parse_gpg_control): No need to define another i.
|
||||
|
||||
* getkey.c (get_pubkey_byfprint): Must use the enum values and not
|
||||
the fprint_len.
|
||||
* keyring.c (keyring_search): Removed a non-sense break. Both
|
||||
bugs pointed out by Stefan.
|
||||
|
||||
2001-09-07 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* status.c, status.h: Added NO_RECP and ALREADY_SIGNED.
|
||||
|
|
|
@ -911,7 +911,8 @@ get_pubkey_byfprint( PKT_public_key *pk,
|
|||
ctx.not_allocated = 1;
|
||||
ctx.kr_handle = keydb_new (0);
|
||||
ctx.nitems = 1;
|
||||
ctx.items[0].mode = fprint_len;
|
||||
ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
|
||||
: KEYDB_SEARCH_MODE_FPR20;
|
||||
memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
|
||||
rc = lookup( &ctx, &kb, 0 );
|
||||
if (!rc && pk )
|
||||
|
|
|
@ -955,7 +955,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands,
|
|||
|
||||
case cmdUPDPREF:
|
||||
{
|
||||
char *p = keygen_get_std_prefs ();
|
||||
p = keygen_get_std_prefs ();
|
||||
tty_printf (("Current preference list: %s\n"), p);
|
||||
m_free (p);
|
||||
}
|
||||
|
|
46
g10/keygen.c
46
g10/keygen.c
|
@ -124,17 +124,17 @@ write_uid( KBNODE root, const char *s )
|
|||
}
|
||||
|
||||
static void
|
||||
do_add_key_flags (PKT_signature *sig, unsigned int usage)
|
||||
do_add_key_flags (PKT_signature *sig, unsigned int use)
|
||||
{
|
||||
byte buf[1];
|
||||
|
||||
if (!usage)
|
||||
if (!use)
|
||||
return;
|
||||
|
||||
buf[0] = 0;
|
||||
if (usage & PUBKEY_USAGE_SIG)
|
||||
if (use & PUBKEY_USAGE_SIG)
|
||||
buf[0] |= 0x01 | 0x02;
|
||||
if (usage & PUBKEY_USAGE_ENC)
|
||||
if (use & PUBKEY_USAGE_ENC)
|
||||
buf[0] |= 0x04 | 0x08;
|
||||
build_sig_subpkt (sig, SIGSUBPKT_KEY_FLAGS, buf, 1);
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ add_feature_mdc (PKT_signature *sig)
|
|||
return; /* already set */
|
||||
if (!s || !n) { /* create a new one */
|
||||
n = 1;
|
||||
buf = m_alloc (n);
|
||||
buf = m_alloc_clear (n);
|
||||
}
|
||||
else {
|
||||
buf = m_alloc (n);
|
||||
|
@ -358,7 +358,7 @@ keygen_add_std_prefs( PKT_signature *sig, void *opaque )
|
|||
|
||||
static int
|
||||
write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
|
||||
unsigned int usage )
|
||||
unsigned int use )
|
||||
{
|
||||
PACKET *pkt;
|
||||
PKT_signature *sig;
|
||||
|
@ -380,7 +380,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
|
|||
if( !node )
|
||||
BUG();
|
||||
pk = node->pkt->pkt.public_key;
|
||||
pk->pubkey_usage = usage;
|
||||
pk->pubkey_usage = use;
|
||||
/* we have to cache the key, so that the verification of the signature
|
||||
* creation is able to retrieve the public key */
|
||||
cache_public_key (pk);
|
||||
|
@ -402,7 +402,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
|
|||
|
||||
static int
|
||||
write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
|
||||
unsigned int usage )
|
||||
unsigned int use )
|
||||
{
|
||||
PACKET *pkt;
|
||||
PKT_signature *sig;
|
||||
|
@ -433,7 +433,7 @@ write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
|
|||
BUG();
|
||||
|
||||
/* and make the signature */
|
||||
oduap.usage = usage;
|
||||
oduap.usage = use;
|
||||
oduap.pk = subpk;
|
||||
rc = make_keysig_packet( &sig, pk, NULL, subpk, sk, 0x18, 0, 0,
|
||||
keygen_add_key_flags_and_expire, &oduap );
|
||||
|
@ -1296,26 +1296,26 @@ parse_parameter_usage (const char *fname,
|
|||
{
|
||||
struct para_data_s *r = get_parameter( para, key );
|
||||
char *p, *pn;
|
||||
unsigned int usage;
|
||||
unsigned int use;
|
||||
|
||||
if( !r )
|
||||
return 0; /* none (this is an optional parameter)*/
|
||||
|
||||
usage = 0;
|
||||
use = 0;
|
||||
pn = r->u.value;
|
||||
while ( (p = strsep (&pn, " \t,")) ) {
|
||||
if ( !*p)
|
||||
;
|
||||
else if ( !ascii_strcasecmp (p, "sign") )
|
||||
usage |= PUBKEY_USAGE_SIG;
|
||||
use |= PUBKEY_USAGE_SIG;
|
||||
else if ( !ascii_strcasecmp (p, "encrypt") )
|
||||
usage |= PUBKEY_USAGE_ENC;
|
||||
use |= PUBKEY_USAGE_ENC;
|
||||
else {
|
||||
log_error("%s:%d: invalid usage list\n", fname, r->lnr );
|
||||
return -1; /* error */
|
||||
}
|
||||
}
|
||||
r->u.usage = usage;
|
||||
r->u.usage = use;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1662,7 +1662,7 @@ generate_keypair( const char *fname )
|
|||
DEK *dek;
|
||||
STRING2KEY *s2k;
|
||||
int algo;
|
||||
unsigned int usage;
|
||||
unsigned int use;
|
||||
int both = 0;
|
||||
u32 expire;
|
||||
struct para_data_s *para = NULL;
|
||||
|
@ -1676,7 +1676,7 @@ generate_keypair( const char *fname )
|
|||
return;
|
||||
}
|
||||
|
||||
algo = ask_algo( 0, &usage );
|
||||
algo = ask_algo( 0, &use );
|
||||
if( !algo ) { /* default: DSA with ElG subkey of the specified size */
|
||||
both = 1;
|
||||
r = m_alloc_clear( sizeof *r + 20 );
|
||||
|
@ -1705,12 +1705,12 @@ generate_keypair( const char *fname )
|
|||
r->next = para;
|
||||
para = r;
|
||||
|
||||
if (usage) {
|
||||
if (use) {
|
||||
r = m_alloc_clear( sizeof *r + 20 );
|
||||
r->key = pKEYUSAGE;
|
||||
sprintf( r->u.value, "%s%s",
|
||||
(usage & PUBKEY_USAGE_SIG)? "sign ":"",
|
||||
(usage & PUBKEY_USAGE_ENC)? "encrypt ":"" );
|
||||
(use & PUBKEY_USAGE_SIG)? "sign ":"",
|
||||
(use & PUBKEY_USAGE_ENC)? "encrypt ":"" );
|
||||
r->next = para;
|
||||
para = r;
|
||||
}
|
||||
|
@ -1977,7 +1977,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
|
|||
KBNODE node;
|
||||
PKT_secret_key *sk = NULL; /* this is the primary sk */
|
||||
int algo;
|
||||
unsigned int usage;
|
||||
unsigned int use;
|
||||
u32 expire;
|
||||
unsigned nbits;
|
||||
char *passphrase = NULL;
|
||||
|
@ -2031,7 +2031,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
|
|||
goto leave;
|
||||
|
||||
|
||||
algo = ask_algo( 1, &usage );
|
||||
algo = ask_algo( 1, &use );
|
||||
assert(algo);
|
||||
nbits = ask_keysize( algo );
|
||||
expire = ask_expire_interval();
|
||||
|
@ -2050,9 +2050,9 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
|
|||
rc = do_create( algo, nbits, pub_keyblock, sec_keyblock,
|
||||
dek, s2k, NULL, expire );
|
||||
if( !rc )
|
||||
rc = write_keybinding(pub_keyblock, pub_keyblock, sk, usage);
|
||||
rc = write_keybinding(pub_keyblock, pub_keyblock, sk, use);
|
||||
if( !rc )
|
||||
rc = write_keybinding(sec_keyblock, pub_keyblock, sk, usage);
|
||||
rc = write_keybinding(sec_keyblock, pub_keyblock, sk, use);
|
||||
if( !rc ) {
|
||||
okay = 1;
|
||||
write_status_text (STATUS_KEY_CREATED, "S");
|
||||
|
|
|
@ -166,12 +166,12 @@ print_key_data( PKT_public_key *pk, u32 *keyid )
|
|||
static void
|
||||
print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
|
||||
{
|
||||
unsigned int usage = pk? pk->pubkey_usage : sk->pubkey_usage;
|
||||
unsigned int use = pk? pk->pubkey_usage : sk->pubkey_usage;
|
||||
|
||||
if ( usage & PUBKEY_USAGE_ENC ) {
|
||||
if ( use & PUBKEY_USAGE_ENC ) {
|
||||
putchar ('e');
|
||||
}
|
||||
if ( usage & PUBKEY_USAGE_SIG ) {
|
||||
if ( use & PUBKEY_USAGE_SIG ) {
|
||||
putchar ('s');
|
||||
putchar ('c');
|
||||
}
|
||||
|
|
|
@ -795,7 +795,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc)
|
|||
&& desc[n].u.kid[1] == aki[1])
|
||||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FPR16: break;
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
if ((pk||sk) && !memcmp (desc[n].u.fpr, afp, 16))
|
||||
goto found;
|
||||
break;
|
||||
|
|
BIN
g10/keyring.o
BIN
g10/keyring.o
Binary file not shown.
17
g10/misc.c
17
g10/misc.c
|
@ -299,33 +299,32 @@ openpgp_pk_test_algo( int algo, unsigned int usage_flags )
|
|||
int
|
||||
openpgp_pk_algo_usage ( int algo )
|
||||
{
|
||||
int usage = 0;
|
||||
int use = 0;
|
||||
|
||||
/* they are hardwired in gpg 1.0 */
|
||||
switch ( algo ) {
|
||||
case PUBKEY_ALGO_RSA:
|
||||
usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
|
||||
use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
|
||||
break;
|
||||
case PUBKEY_ALGO_RSA_E:
|
||||
usage = PUBKEY_USAGE_ENC;
|
||||
use = PUBKEY_USAGE_ENC;
|
||||
break;
|
||||
case PUBKEY_ALGO_RSA_S:
|
||||
usage = PUBKEY_USAGE_SIG;
|
||||
use = PUBKEY_USAGE_SIG;
|
||||
break;
|
||||
case PUBKEY_ALGO_ELGAMAL_E:
|
||||
usage = PUBKEY_USAGE_ENC;
|
||||
use = PUBKEY_USAGE_ENC;
|
||||
break;
|
||||
case PUBKEY_ALGO_DSA:
|
||||
usage = PUBKEY_USAGE_SIG;
|
||||
use = PUBKEY_USAGE_SIG;
|
||||
break;
|
||||
case PUBKEY_ALGO_ELGAMAL:
|
||||
usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
|
||||
use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return usage;
|
||||
|
||||
return use;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1931,7 +1931,9 @@ parse_gpg_control( IOBUF inp,
|
|||
|
||||
skipit:
|
||||
if ( list_mode ) {
|
||||
int c, i=0 ;
|
||||
int c;
|
||||
|
||||
i=0;
|
||||
printf("- private (rest length %lu)\n", pktlen);
|
||||
if( iobuf_in_block_mode(inp) ) {
|
||||
while( (c=iobuf_get(inp)) != -1 )
|
||||
|
|
|
@ -211,7 +211,7 @@ readn ( int fd, void *buf, size_t buflen, size_t *ret_nread )
|
|||
*/
|
||||
|
||||
static int
|
||||
agent_open ()
|
||||
agent_open (void)
|
||||
{
|
||||
int fd;
|
||||
char *infostr, *p;
|
||||
|
|
|
@ -117,7 +117,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
|
|||
|
||||
|
||||
static int
|
||||
get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid )
|
||||
get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
|
||||
{
|
||||
int rc;
|
||||
MPI plain_dek = NULL;
|
||||
|
@ -125,7 +125,7 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid )
|
|||
unsigned n, nframe;
|
||||
u16 csum, csum2;
|
||||
|
||||
rc = pubkey_decrypt(sk->pubkey_algo, &plain_dek, k->data, sk->skey );
|
||||
rc = pubkey_decrypt(sk->pubkey_algo, &plain_dek, enc->data, sk->skey );
|
||||
if( rc )
|
||||
goto leave;
|
||||
frame = mpi_get_buffer( plain_dek, &nframe, NULL );
|
||||
|
|
16
g10/sign.c
16
g10/sign.c
|
@ -495,7 +495,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
|
|||
* make a detached signature. If FILENAMES->d is NULL read from stdin
|
||||
* and ignore the detached mode. Sign the file with all secret keys
|
||||
* which can be taken from LOCUSR, if this is NULL, use the default one
|
||||
* If ENCRYPT is true, use REMUSER (or ask if it is NULL) to encrypt the
|
||||
* If ENCRYPTFLAG is true, use REMUSER (or ask if it is NULL) to encrypt the
|
||||
* signed data for these users.
|
||||
* If OUTFILE is not NULL; this file is used for output and the function
|
||||
* does not ask for overwrite permission; output is then always
|
||||
|
@ -503,7 +503,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
|
|||
*/
|
||||
int
|
||||
sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
||||
int encrypt, STRLIST remusr, const char *outfile )
|
||||
int encryptflag, STRLIST remusr, const char *outfile )
|
||||
{
|
||||
const char *fname;
|
||||
armor_filter_context_t afx;
|
||||
|
@ -536,7 +536,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
else
|
||||
fname = NULL;
|
||||
|
||||
if( fname && filenames->next && (!detached || encrypt) )
|
||||
if( fname && filenames->next && (!detached || encryptflag) )
|
||||
log_bug("multiple files can only be detached signed");
|
||||
|
||||
if( (rc=build_sk_list( locusr, &sk_list, 1, PUBKEY_USAGE_SIG )) )
|
||||
|
@ -544,7 +544,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
if( !old_style )
|
||||
old_style = only_old_style( sk_list );
|
||||
|
||||
if( encrypt ) {
|
||||
if( encryptflag ) {
|
||||
if( (rc=build_pk_list( remusr, &pk_list, PUBKEY_USAGE_ENC )) )
|
||||
goto leave;
|
||||
if( !old_style )
|
||||
|
@ -586,13 +586,13 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
if( !multifile )
|
||||
iobuf_push_filter( inp, md_filter, &mfx );
|
||||
|
||||
if( detached && !encrypt && !opt.rfc1991 )
|
||||
if( detached && !encryptflag && !opt.rfc1991 )
|
||||
afx.what = 2;
|
||||
|
||||
if( opt.armor && !outfile )
|
||||
iobuf_push_filter( out, armor_filter, &afx );
|
||||
|
||||
if( encrypt ) {
|
||||
if( encryptflag ) {
|
||||
efx.pk_list = pk_list;
|
||||
/* fixme: set efx.cfx.datalen if known */
|
||||
iobuf_push_filter( out, encrypt_filter, &efx );
|
||||
|
@ -604,7 +604,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
else {
|
||||
if( old_style
|
||||
|| compr_algo == 1
|
||||
|| (compr_algo == -1 && !encrypt) )
|
||||
|| (compr_algo == -1 && !encryptflag) )
|
||||
zfx.algo = 1; /* use the non optional algorithm */
|
||||
iobuf_push_filter( out, compress_filter, &zfx );
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||
iobuf_cancel(out);
|
||||
else {
|
||||
iobuf_close(out);
|
||||
if (encrypt)
|
||||
if (encryptflag)
|
||||
write_status( STATUS_END_ENCRYPTION );
|
||||
}
|
||||
iobuf_close(inp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue