From 717bce345c5da62de5abc10ea4f58ac71755bd13 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sat, 5 Jun 1999 13:36:15 +0000 Subject: [PATCH] See ChangeLog: Sat Jun 5 15:30:33 CEST 1999 Werner Koch --- ChangeLog | 4 ++++ NEWS | 2 ++ TODO | 2 ++ doc/gpg.1pod | 33 +++++++++++++++-------------- g10/pkclist.c | 56 ++++++++++++++++++++++++++++++++++++++----------- util/ChangeLog | 4 ++++ util/strgutil.c | 30 ++++++++++++++++---------- 7 files changed, 92 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b62f4f53..c03f7b609 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jun 5 15:30:33 CEST 1999 Werner Koch + + * pkclist.c (key_present_in_pk_list): New (Michael). + Tue May 25 19:50:32 CEST 1999 Werner Koch * configure.in (IS_DEVELOPMENT_VERSION): Fixed detection. diff --git a/NEWS b/NEWS index b5f64333e..cb919eab2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ * Another hack to cope with pgp2 generated detached signatures. + * latin-2 character set works (--charset=iso-8859-2). + Noteworthy changes in version 0.9.7 ----------------------------------- diff --git a/TODO b/TODO index faba47d65..47ceaa70b 100644 --- a/TODO +++ b/TODO @@ -27,6 +27,8 @@ * find a way to allow the import of non-self-signed keys. This is needed for the IN ENCR/SIGN hack. + * convert the given user ID to UTF-8 and add an option to suppress this. + Nice to have ------------ * Let take --help an option to select some topics. diff --git a/doc/gpg.1pod b/doc/gpg.1pod index af4186964..55f0143aa 100644 --- a/doc/gpg.1pod +++ b/doc/gpg.1pod @@ -72,7 +72,7 @@ B<-k> [I] [I] B -B<--list-keys> [I] +B<--list-keys> [I] B<--list-public-keys> [I] List all keys from the public keyrings, or just the ones given on the command line. @@ -81,7 +81,7 @@ B<--list-secret-keys> [I] List all keys from the secret keyrings, or just the ones given on the command line. -B<--list-sigs> [I] +B<--list-sigs> [I] Same as B<--list-keys>, but the signatures are listed too. @@ -141,7 +141,7 @@ B<--edit-key> I B Revoke a subkey. B - Change the key expiration time. If a key is + Change the key expiration time. If a key is selected, the time of this key will be changed. With no selection the key expiration of the primary key is changed. @@ -212,7 +212,7 @@ B<--export-secret-keys> [I] This is normally not very useful. B<--import>, B<--fast-import> - Import/merge keys. The fast version does not build + Import/merge keys. The fast version does not build the trustdb; this can be done at any time with the command B<--update-trustdb>. @@ -234,7 +234,7 @@ B<--import-ownertrust> [I] Long options can be put in an options file (default F<~/.gnupg/options>). Do not write the 2 dashes, but simply the name of the option and any -required arguments. Lines with a hash as the first non-white-space +required arguments. Lines with a hash as the first non-white-space character are ignored. Commands may be put in this file too, but that does not make sense. @@ -257,7 +257,7 @@ B<--default-key> I is not used the default user-id is the first user-id from the secret keyring. -B<-r> I, B<--recipient> I +B<-r> I, B<--recipient> I Encrypt for user id I. If this option is not specified, GnuPG asks for the user id. @@ -351,7 +351,8 @@ B<--charset> I Set the name of the native character set. This is used to convert some strings to proper UTF-8 encoding. Valid values for I are: - B This is the default. + B This is the default Latin 1 set. + B The Latin 2 set. B The usual Russian set (rfc1489). B<--options> I @@ -548,11 +549,11 @@ a signature was bad, and other error codes for fatal errors. =head1 EXAMPLES - -se -r Bob [file] sign and encrypt for user Bob - -sat [file] make a clear text signature - -sb [file] make a detached signature - -k [userid] show keys - -kc [userid] show fingerprint + -se -r Bob [file] sign and encrypt for user Bob + -sat [file] make a clear text signature + -sb [file] make a detached signature + -k [userid] show keys + -kc [userid] show fingerprint =head1 ENVIRONMENT @@ -570,7 +571,7 @@ F<~/.gnupg/pubring.gpg.lock> and the lock file F<~/.gnupg/trustdb.gpg> The trust database F<~/.gnupg/trustdb.gpg.lock> and the lock file -F<~/.gnupg/options> May contain options +F<~/.gnupg/options> May contain options F Skeleton file F Default location for extensions @@ -595,8 +596,8 @@ is B easy to spy out your passphrase! On many systems this program should be installed as setuid(root). This is necessary to lock memory pages. Locking memory pages prevents the -operating system from writing memory pages to disk. If you get no -warning message about insecure memory your operating system supports -locking without being root. The program drops root privileges as soon +operating system from writing memory pages to disk. If you get no +warning message about insecure memory your operating system supports +locking without being root. The program drops root privileges as soon as locked memory is allocated. diff --git a/g10/pkclist.c b/g10/pkclist.c index a170a3dd3..39ed0e5f2 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -547,6 +547,17 @@ release_pk_list( PK_LIST pk_list ) } } + +static int +key_present_in_pk_list(PK_LIST pk_list, PKT_public_key *pk) +{ + for( ; pk_list; pk_list = pk_list->next) + if (cmp_public_keys(pk_list->pk, pk) == 0) + return 0; + + return -1; +} + int build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) { @@ -569,13 +580,22 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) ); } else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) { - PK_LIST r; - r = m_alloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->mark = 0; - pk_list = r; + /* Skip the actual key if the key is already present + * in the list */ + if (key_present_in_pk_list(pk_list, pk) == 0) { + free_public_key(pk); pk = NULL; + log_info(_("%s: skipped: public key already present\n"), + rov->d); + } + else { + PK_LIST r; + r = m_alloc( sizeof *r ); + r->pk = pk; pk = NULL; + r->next = pk_list; + r->mark = 0; + pk_list = r; + } } else { free_public_key( pk ); pk = NULL; @@ -655,14 +675,26 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) } else if( do_we_trust_pre( pk, trustlevel ) ) { /* note: do_we_trust may have changed the trustlevel */ - PK_LIST r; - r = m_alloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->mark = 0; - pk_list = r; + /* We have at least one valid recipient. It doesn't matters + * if this recipient is already present. */ any_recipients = 1; + + /* Skip the actual key if the key is already present + * in the list */ + if (key_present_in_pk_list(pk_list, pk) == 0) { + free_public_key(pk); pk = NULL; + log_info(_("%s: skipped: public key already present\n"), + remusr->d); + } + else { + PK_LIST r; + r = m_alloc( sizeof *r ); + r->pk = pk; pk = NULL; + r->next = pk_list; + r->mark = 0; + pk_list = r; + } } else { /* we don't trust this pk */ free_public_key( pk ); pk = NULL; diff --git a/util/ChangeLog b/util/ChangeLog index ad2a85a66..0770f7b08 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,7 @@ +Sat Jun 5 15:30:33 CEST 1999 Werner Koch + + * strgutil.c (set_native_charset): Support Latin-2 + Tue Jun 1 16:01:46 CEST 1999 Werner Koch * iobuf.c (iobuf_get_real_fname): Made global and now keep a diff --git a/util/strgutil.c b/util/strgutil.c index 11291766b..94f8a5d6c 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -27,8 +27,7 @@ #include "memory.h" -static int use_koi8 = 0; -static ushort koi82unicode[128] = { +static ushort koi8_unicode[128] = { 0x2500,0x2502,0x250c,0x2510,0x2514,0x2518,0x251c,0x2524, 0x252c,0x2534,0x253c,0x2580,0x2584,0x2588,0x258c,0x2590, 0x2591,0x2592,0x2593,0x2320,0x25a0,0x2219,0x221a,0x2248, @@ -47,7 +46,6 @@ static ushort koi82unicode[128] = { 0x042c,0x042b,0x0417,0x0428,0x042d,0x0429,0x0427,0x042a }; -#if 0 static ushort latin2_unicode[128] = { 0x0080,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087, 0x0088,0x0089,0x008A,0x008B,0x008C,0x008D,0x008E,0x008F, @@ -66,7 +64,9 @@ static ushort latin2_unicode[128] = { 0x0111,0x0144,0x0148,0x00F3,0x00F4,0x0151,0x00F6,0x00F7, 0x0159,0x016F,0x00FA,0x0171,0x00FC,0x00FD,0x0163,0x02D9 }; -#endif + +static const char *active_charset_name = "iso-8859-1"; +static ushort *active_charset = NULL; void @@ -261,10 +261,18 @@ string_count_chr( const char *string, int c ) int set_native_charset( const char *newset ) { - if( !stricmp( newset, "iso-8859-1" ) ) - use_koi8 = 0; - else if( !stricmp( newset, "koi8-r" ) ) - use_koi8 = 1; + if( !stricmp( newset, "iso-8859-1" ) ) { + active_charset_name = "iso-8859-1"; + active_charset = NULL; + } + else if( !stricmp( newset, "iso-8859-2" ) ) { + active_charset_name = "iso-8859-2"; + active_charset = latin2_unicode; + } + else if( !stricmp( newset, "koi8-r" ) ) { + active_charset_name = "koi8-r"; + active_charset = koi8_unicode; + } else return G10ERR_GENERAL; return 0; @@ -273,7 +281,7 @@ set_native_charset( const char *newset ) const char* get_native_charset() { - return use_koi8? "koi8-r" : "iso-8859-1"; + return active_charset_name; } /**************** @@ -288,7 +296,7 @@ native_to_utf8( const char *string ) byte *p; size_t length=0; - if( use_koi8 ) { + if( active_charset ) { for(s=string; *s; s++ ) { length++; if( *s & 0x80 ) @@ -297,7 +305,7 @@ native_to_utf8( const char *string ) buffer = m_alloc( length + 1 ); for(p=buffer, s=string; *s; s++ ) { if( *s & 0x80 ) { - ushort val = koi82unicode[ *s & 0x7f ]; + ushort val = active_charset[ *s & 0x7f ]; if( val < 0x0800 ) { *p++ = 0xc0 | ( (val >> 6) & 0x1f ); *p++ = 0x80 | ( val & 0x3f );