1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

See ChangeLog: Fri Feb 26 17:55:41 CET 1999 Werner Koch

This commit is contained in:
Werner Koch 1999-02-26 16:59:48 +00:00
parent 946916a53d
commit 694099b9af
23 changed files with 362 additions and 251 deletions

View file

@ -1,3 +1,18 @@
Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* pkclist.c (build_pk_list): Return error if there are no recipients.
* sig-check.c (signature_check): New signature id feature.
* armor.c (make_radic64_string): New.
* mainproc.c (proc_pubkey_enc): early check for seckey availability.
* pkclist.c (do_we_trust_pre): print user id before asking.
* ringedit.c (add_keyblock_resource,get_keyblock_handle): Cleaner
handling of default resource.
Thu Feb 25 18:47:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* pkclist.c (algo_available): New.

View file

@ -1007,4 +1007,31 @@ armor_filter( void *opaque, int control,
}
/****************
* create a radix64 encoded string.
*/
char *
make_radix64_string( const byte *data, size_t len )
{
char *buffer, *p;
buffer = p = m_alloc( (len+2)/3*4 + 1 );
for( ; len >= 3 ; len -= 3, data += 3 ) {
*p++ = bintoasc[(data[0] >> 2) & 077];
*p++ = bintoasc[(((data[0] <<4)&060)|((data[1] >> 4)&017))&077];
*p++ = bintoasc[(((data[1]<<2)&074)|((data[2]>>6)&03))&077];
*p++ = bintoasc[data[2]&077];
}
if( len == 2 ) {
*p++ = bintoasc[(data[0] >> 2) & 077];
*p++ = bintoasc[(((data[0] <<4)&060)|((data[1] >> 4)&017))&077];
*p++ = bintoasc[((data[1]<<2)&074)];
}
else if( len == 1 ) {
*p++ = bintoasc[(data[0] >> 2) & 077];
*p++ = bintoasc[(data[0] <<4)&060];
}
*p = 0;
return buffer;
}

View file

@ -150,7 +150,13 @@ encode_simple( const char *filename, int mode )
pt = m_alloc( sizeof *pt - 1 );
pt->namelen = 0;
}
if( filename ) {
/* pgp5 has problems to decrypt symmetrically encrypted data from
* GnuPOG if the filelength is in the inner packet. It works
* when only partial length headers are use. Until we have
* tracked this problem down. We use this temporary fix
* (fixme: remove the && !mode )
*/
if( filename && !mode ) {
if( !(filesize = iobuf_get_filelength(inp)) )
log_info(_("%s: WARNING: empty file\n"), filename );
}

View file

@ -49,6 +49,9 @@ void print_pubkey_algo_note( int algo );
void print_cipher_algo_note( int algo );
void print_digest_algo_note( int algo );
/*-- armor.c --*/
char *make_radix64_string( const byte *data, size_t len );
/*-- misc.c --*/
void trap_unaligned(void);
void disable_core_dumps(void);

View file

@ -178,10 +178,13 @@ proc_pubkey_enc( CTX c, PACKET *pkt )
c->last_was_session_key = 1;
enc = pkt->pkt.pubkey_enc;
/*printf("enc: encrypted by a pubkey with keyid %08lX\n", enc->keyid[1] );*/
/* Hmmm: why do I have this algo check here - anyway there is
* function to check it. */
if( is_ELGAMAL(enc->pubkey_algo)
|| enc->pubkey_algo == PUBKEY_ALGO_DSA
|| is_RSA(enc->pubkey_algo) ) {
if ( !c->dek ) {
if ( !c->dek && ((!enc->keyid[0] && !enc->keyid[1])
|| !seckey_available( enc->keyid )) ) {
c->dek = m_alloc_secure( sizeof *c->dek );
if( (result = get_session_key( enc, c->dek )) ) {
/* error: delete the DEK */

View file

@ -230,6 +230,7 @@ _("Could not find a valid trust path to the key. Let's see whether we\n"
}
lid = pk->local_id;
#if 0 /* FIXME: enable this when trustdb stuff works again */
while( enum_cert_paths( &context, &lid, &otrust, &validity ) != -1 ) {
if( lid == pk->local_id )
continue;
@ -256,6 +257,7 @@ _("Could not find a valid trust path to the key. Let's see whether we\n"
}
}
enum_cert_paths( &context, NULL, NULL, NULL ); /* release context */
#endif
if( !any )
tty_printf(_("No path leading to one of our keys found.\n\n") );
@ -374,6 +376,19 @@ do_we_trust_pre( PKT_public_key *pk, int trustlevel )
if( (trustlevel & TRUST_FLAG_REVOKED) && !rc )
return 0;
else if( !opt.batch && !rc ) {
char *p;
u32 keyid[2];
size_t n;
keyid_from_pk( pk, keyid);
tty_printf( "%4u%c/%08lX %s \"",
nbits_from_pk( pk ), pubkey_letter( pk->pubkey_algo ),
(ulong)keyid[1], datestr_from_pk( pk ) );
p = get_user_id( keyid, &n );
tty_print_string( p, n ),
m_free(p);
tty_printf("\"\n\n");
tty_printf(_(
"It is NOT certain that the key belongs to its owner.\n"
"If you *really* know what you are doing, you may answer\n"
@ -382,6 +397,10 @@ do_we_trust_pre( PKT_public_key *pk, int trustlevel )
if( cpr_get_answer_is_yes("untrusted_key.override",
_("Use this key anyway? ")) )
rc = 1;
/* Hmmm: Should we set a flag to tell the user the user about
* his decision the next time he encrypts for this recipient?
*/
}
else if( opt.always_trust && !rc ) {
log_info(_("WARNING: Using untrusted key!\n"));
@ -598,6 +617,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use )
}
}
else {
any_recipients = 0;
for(; remusr; remusr = remusr->next ) {
if( (remusr->flags & 1) )
continue; /* encrypt-to keys are already handled */

View file

@ -79,6 +79,8 @@ typedef struct resource_table_struct RESTBL;
#define MAX_RESOURCES 10
static RESTBL resource_table[MAX_RESOURCES];
static int default_public_resource;
static int default_secret_resource;
static int search( PACKET *pkt, KBPOS *kbpos, int secret );
@ -348,11 +350,17 @@ add_keyblock_resource( const char *url, int force, int secret )
goto leave;
}
/* fixme: avoid duplicate resources */
resource_table[i].used = 1;
resource_table[i].secret = !!secret;
resource_table[i].fname = m_strdup(filename);
resource_table[i].iobuf = iobuf;
resource_table[i].rt = rt;
if( secret )
default_secret_resource = i;
else
default_public_resource = i;
leave:
if( rc )
log_error("keyblock resource `%s': %s\n", filename, g10_errstr(rc) );
@ -386,9 +394,12 @@ keyblock_resource_name( KBPOS *kbpos )
int
get_keyblock_handle( const char *filename, int secret, KBPOS *kbpos )
{
int i;
int i = 0;
for(i=0; i < MAX_RESOURCES; i++ )
if( !filename )
i = secret? default_secret_resource : default_public_resource;
for(; i < MAX_RESOURCES; i++ ) {
if( resource_table[i].used && !resource_table[i].secret == !secret ) {
/* fixme: dos needs case insensitive file compare */
if( !filename || !strcmp( resource_table[i].fname, filename ) ) {
@ -398,6 +409,7 @@ get_keyblock_handle( const char *filename, int secret, KBPOS *kbpos )
return 0;
}
}
}
return -1; /* not found */
}

View file

@ -64,6 +64,34 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
rc = do_check( pk, sig, digest );
free_public_key( pk );
if( !rc && is_status_enabled()
&& ( sig->pubkey_algo == PUBKEY_ALGO_DSA
|| sig->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) ) {
/* If we are using these public key algorithms we can
* calculate an unique signature id, which may be useful
* in an application to prevent replac attacks */
MD_HANDLE md;
int i, nsig = pubkey_get_nsig( sig->pubkey_algo );
byte *p;
md = md_open( DIGEST_ALGO_RMD160, 0);
for(i=0; i < nsig; i++ ) {
unsigned n = mpi_get_nbits( sig->data[i]);
md_putc( md, n>>8);
md_putc( md, n );
p = mpi_get_buffer( sig->data[i], &n, NULL );
md_write( md, p, n );
m_free(p);
}
md_final( md );
p = make_radix64_string( md_read( md, 0 ), 20 );
write_status_text( STATUS_SIG_ID, p );
m_free(p);
md_close(md);
}
return rc;
}

View file

@ -98,6 +98,7 @@ write_status_text ( int no, const char *text)
case STATUS_SHM_GET_HIDDEN : s = "SHM_GET_HIDDEN\n"; break;
case STATUS_NEED_PASSPHRASE: s = "NEED_PASSPHRASE\n"; break;
case STATUS_VALIDSIG : s = "VALIDSIG\n"; break;
case STATUS_SIG_ID : s = "SIG_ID\n"; break;
default: s = "?\n"; break;
}

View file

@ -49,6 +49,7 @@
#define STATUS_NEED_PASSPHRASE 20
#define STATUS_VALIDSIG 21
#define STATUS_SIG_ID 22
/*-- status.c --*/
void set_status_fd ( int fd );