Adjust for the changed Camellia draft.

W32 gettext changes.
Comment and typo fixes.
This commit is contained in:
Werner Koch 2008-04-18 09:20:25 +00:00
parent 057558d04b
commit 4896f5f47c
15 changed files with 166 additions and 69 deletions

View File

@ -1,3 +1,8 @@
2008-04-08 Werner Koch <wk@g10code.com>
* i18n.c (i18n_switchto_utf8, i18n_switchback)
[USE_SIMPLE_GETTEXT]: Implement.
2008-04-07 Werner Koch <wk@g10code.com>
* b64enc.c (b64enc_start): Detect PGP mode.

View File

@ -45,17 +45,19 @@ i18n_init (void)
/* The Assuan agent protocol requires us to transmit utf-8 strings
thus we need a fuctnion to temporary switch gettext from native to
thus we need a way to temporary switch gettext from native to
utf8. */
char *
i18n_switchto_utf8 (void)
{
#ifdef ENABLE_NLS
#ifdef USE_SIMPLE_GETTEXT
gettext_select_utf8 (1);
#elif define(ENABLE_NLS)
char *orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL);
#ifdef HAVE_LANGINFO_CODESET
# ifdef HAVE_LANGINFO_CODESET
if (!orig_codeset)
orig_codeset = nl_langinfo (CODESET);
#endif
# endif
if (orig_codeset)
{ /* We only switch when we are able to restore the codeset later.
Note that bind_textdomain_codeset does only return on memory
@ -78,7 +80,9 @@ i18n_switchto_utf8 (void)
void
i18n_switchback (char *saved_codeset)
{
#ifdef ENABLE_NLS
#ifdef USE_SIMPLE_GETTEXT
gettext_select_utf8 (0);
#elif defined(ENABLE_NLS)
if (saved_codeset)
{
bind_textdomain_codeset (PACKAGE_GT, saved_codeset);

View File

@ -1,3 +1,10 @@
2008-04-18 Werner Koch <wk@g10code.com>
* misc.c (map_cipher_openpgp_to_gcry, map_cipher_gcry_to_openpgp)
(openpgp_cipher_test_algo): Add camellia-192.
(openpgp_cipher_blocklen): New.
* parse-packet.c (parse_key): Use new function here.
2008-04-15 David Shaw <dshaw@jabberwocky.com>
* getkey.c (merge_selfsigs_subkey): If there are multiple 0x19

View File

@ -82,6 +82,7 @@ u16 checksum( byte *p, unsigned n );
u16 checksum_mpi( gcry_mpi_t a );
u32 buffer_to_u32( const byte *buffer );
const byte *get_session_marker( size_t *rlen );
int openpgp_cipher_blocklen (int algo);
int openpgp_cipher_test_algo( int algo );
const char *openpgp_cipher_algo_name (int algo);
int openpgp_pk_test_algo( int algo );

View File

@ -1,6 +1,6 @@
/* misc.c - miscellaneous functions
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005, 2006, 2007 Free Software Foundation, Inc.
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -338,6 +338,7 @@ map_cipher_openpgp_to_gcry (int algo)
switch (algo)
{
case CIPHER_ALGO_CAMELLIA128: return 310;
case CIPHER_ALGO_CAMELLIA192: return 311;
case CIPHER_ALGO_CAMELLIA256: return 312;
default: return algo;
}
@ -350,11 +351,36 @@ map_cipher_gcry_to_openpgp (int algo)
switch (algo)
{
case 310: return CIPHER_ALGO_CAMELLIA128;
case 311: return CIPHER_ALGO_CAMELLIA192;
case 312: return CIPHER_ALGO_CAMELLIA256;
default: return algo;
}
}
/* Return the block length of an OpenPGP cipher algorithm. */
int
openpgp_cipher_blocklen (int algo)
{
/* We use the numbers from OpenPGP to be sure that we get the right
block length. This is so that the packet parsing code works even
for unknown algorithms (for which we assume 8 due to tradition).
NOTE: If you change the the returned blocklen above 16, check
the callers because they may use a fixed size buffer of that
size. */
switch (algo)
{
case 7: case 8: case 9: /* AES */
case 10: /* Twofish */
case 11: case 12: case 13: /* Camellia */
return 16;
default:
return 8;
}
}
/****************
* Wrapper around the libgcrypt function with additonal checks on
* the OpenPGP contraints for the algo ID.
@ -370,7 +396,8 @@ openpgp_cipher_test_algo( int algo )
requested. */
#ifndef USE_CAMELLIA
if (algo == CIPHER_ALGO_CAMELLIA128
|| algo == CIPHER_ALGO_CAMELLIA256)
|| algo == CIPHER_ALGO_CAMELLIA192
|| algo == CIPHER_ALGO_CAMELLIA256)
return gpg_error (GPG_ERR_CIPHER_ALGO);
#endif
@ -386,8 +413,6 @@ openpgp_cipher_algo_name (int algo)
return gcry_cipher_algo_name (map_cipher_openpgp_to_gcry (algo));
}
int
openpgp_pk_test_algo( int algo )
{

View File

@ -1901,19 +1901,13 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
* of the IV here in cases we are not aware of the algorithm.
* so a
* sk->protect.ivlen = cipher_get_blocksize(sk->protect.algo);
* won't work. The only solution I see is to hardwire it here.
* won't work. The only solution I see is to hardwire it.
* NOTE: if you change the ivlen above 16, don't forget to
* enlarge temp.
*/
switch( sk->protect.algo ) {
case 7: case 8: case 9: /* AES */
case 10: /* Twofish */
case 11: case 12: /* Camellia */
sk->protect.ivlen = 16;
break;
default:
sk->protect.ivlen = 8;
}
sk->protect.ivlen = openpgp_cipher_blocklen (sk->protect.algo);
assert (sk->protect.ivlen <= sizeof (temp));
if( sk->protect.s2k.mode == 1001 )
sk->protect.ivlen = 0;
else if( sk->protect.s2k.mode == 1002 )

View File

@ -1,3 +1,8 @@
2008-04-18 Werner Koch <wk@g10code.com>
* cipher.h (CIPHER_ALGO_CAMELLIA256): Change ID to 13.
(CIPHER_ALGO_CAMELLIA192): New.
2007-12-12 Werner Koch <wk@g10code.com>
* cipher.h (CIPHER_ALGO_CAMELLIA128, CIPHER_ALGO_CAMELLIA256): New.

View File

@ -47,7 +47,8 @@
#define CIPHER_ALGO_TWOFISH /* 10 */ GCRY_CIPHER_TWOFISH /* 256 bit */
/* Note: Camellia ids don't match those used by libgcrypt. */
#define CIPHER_ALGO_CAMELLIA128 11
#define CIPHER_ALGO_CAMELLIA256 12
#define CIPHER_ALGO_CAMELLIA192 12
#define CIPHER_ALGO_CAMELLIA256 13
#define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */
#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA

View File

@ -1,3 +1,9 @@
2008-04-08 Werner Koch <wk@g10code.com>
* w32-gettext.c (gettext_select_utf8): New.
(get_string): Support switching encodings.
(load_domain): Allocate space for DATA_NATIVE.
2008-03-25 Werner Koch <wk@g10code.com>
* w32-gettext.c (_nl_locale_name): New. Taken from
@ -555,7 +561,7 @@ Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
***********************************************************
Copyright 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007 Free Software Foundation, Inc.
2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without

View File

@ -1,6 +1,6 @@
/* w32-gettext.c - A simplified version of gettext for use under W32.
* Copyright (C) 1995, 1996, 1997, 1999, 2000, 2003,
* 2005, 2007, 2088 Free Software Foundation, Inc.
* 2005, 2007, 2008 Free Software Foundation, Inc.
*
* This file is part of JNLIB.
*
@ -96,11 +96,13 @@ struct overflow_space_s
struct loaded_domain
{
char *data;
char *data_native; /* Data mapped to the native version of the
string. (Allocated along with DATA). */
int must_swap;
u32 nstrings;
char *mapped; /* 0 = not yet mapped, 1 = mapped,
2 = mapped to
overflow space */
char *mapped; /* 0 = not mapped (original utf8),
1 = mapped to native encoding,
2 = mapped to native encoding in overflow space. */
struct overflow_space_s *overflow_space;
struct string_desc *orig_tab;
struct string_desc *trans_tab;
@ -111,6 +113,8 @@ struct loaded_domain
static struct loaded_domain *the_domain;
static char *the_langid;
static int want_utf8; /* True if the user want's utf-8 strings. */
static __inline__ u32
do_swap_u32( u32 i )
@ -1236,7 +1240,7 @@ load_domain (const char *filename)
return NULL;
}
data = jnlib_malloc (size);
data = (2*size <= size)? NULL : jnlib_malloc (2*size);
if (!data)
{
fclose (fp);
@ -1278,38 +1282,39 @@ load_domain (const char *filename)
return NULL;
}
domain->data = (char *) data;
domain->data_native = (char *) data + size;
domain->must_swap = data->magic != MAGIC;
/* Fill in the information about the available tables. */
switch (SWAPIT(domain->must_swap, data->revision))
{
case 0:
domain->nstrings = SWAPIT(domain->must_swap, data->nstrings);
domain->orig_tab = (struct string_desc *)
switch (SWAPIT(domain->must_swap, data->revision))
{
case 0:
domain->nstrings = SWAPIT(domain->must_swap, data->nstrings);
domain->orig_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->orig_tab_offset));
domain->trans_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);
domain->hash_tab = (u32 *)
((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));
break;
domain->trans_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);
domain->hash_tab = (u32 *)
((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));
break;
default: /* This is an invalid revision. */
jnlib_free( data );
jnlib_free( domain );
return NULL;
default: /* This is an invalid revision. */
jnlib_free( data );
jnlib_free( domain );
return NULL;
}
/* Allocate an array to keep track of code page mappings. */
domain->mapped = jnlib_calloc (1, domain->nstrings);
if (!domain->mapped)
{
jnlib_free (data);
jnlib_free (domain);
return NULL;
}
return domain;
/* Allocate an array to keep track of code page mappings. */
domain->mapped = jnlib_calloc (1, domain->nstrings);
if (!domain->mapped)
{
jnlib_free (data);
jnlib_free (domain);
return NULL;
}
return domain;
}
@ -1510,30 +1515,45 @@ set_gettext_file ( const char *filename, const char *regkey )
static const char*
get_string( struct loaded_domain *domain, u32 idx )
get_string (struct loaded_domain *domain, u32 idx)
{
struct overflow_space_s *os;
char *p;
p = domain->data + SWAPIT(domain->must_swap, domain->trans_tab[idx].offset);
if (!domain->mapped[idx])
if (want_utf8)
{
p = (domain->data
+ SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
}
else if (!domain->mapped[idx])
{
/* Not yet mapped - map utf-8 to native encoding. */
const char *p_orig;
size_t plen, buflen;
char *buf;
domain->mapped[idx] = 1;
p_orig = (domain->data
+ SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
p = (domain->data_native
+ SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
plen = strlen (p);
buf = utf8_to_native (p, plen, -1);
plen = strlen (p_orig);
buf = utf8_to_native (p_orig, plen, -1);
buflen = strlen (buf);
if (buflen <= plen)
strcpy (p, buf);
{
/* Copy into the DATA_NATIVE area. */
strcpy (p, buf);
domain->mapped[idx] = 1;
}
else
{
/* There is not enough space for the translation - store it
in the overflow_space else and mark that in the mapped
array. Because we expect that this won't happen too
often, we use a simple linked list. */
in the overflow_space and mark that in the mapped array.
Because UTF-8 strings are in general longer than the
Windows 2 byte encodings, we expect that this won't
happen too often (if at all) and thus we use a linked
list to manage this space. */
os = jnlib_malloc (sizeof *os + buflen);
if (os)
{
@ -1545,9 +1565,16 @@ get_string( struct loaded_domain *domain, u32 idx )
}
else
p = "ERROR in GETTEXT MALLOC";
domain->mapped[idx] = 2;
}
jnlib_free (buf);
}
else if (domain->mapped[idx] == 1)
{
p = (domain->data_native
+ SWAPIT(domain->must_swap, domain->trans_tab[idx].offset));
}
else if (domain->mapped[idx] == 2)
{ /* We need to get the string from the overflow_space. */
for (os=domain->overflow_space; os; os = os->next)
@ -1555,6 +1582,9 @@ get_string( struct loaded_domain *domain, u32 idx )
return (const char*)os->d;
p = "ERROR in GETTEXT\n";
}
else
p = "ERROR in GETEXT mapping";
return (const char*)p;
}
@ -1660,4 +1690,11 @@ gettext_localename (void)
}
void
gettext_select_utf8 (int value)
{
want_utf8 = value;
}
#endif /* USE_SIMPLE_GETTEXT */

View File

@ -33,6 +33,7 @@ const char *gettext (const char *msgid );
const char *ngettext (const char *msgid1, const char *msgid2,
unsigned long int n);
const char *gettext_localename (void);
void gettext_select_utf8 (int value);
#endif /*USE_SIMPLE_GETTEXT*/

View File

@ -10,7 +10,7 @@ msgstr ""
"Project-Id-Version: gnupg-2.0.6\n"
"Report-Msgid-Bugs-To: translations@gnupg.org\n"
"POT-Creation-Date: 2008-03-27 13:41+0100\n"
"PO-Revision-Date: 2008-04-02 17:50+0200\n"
"PO-Revision-Date: 2008-04-08 15:41+0200\n"
"Last-Translator: Walter Koch <koch@u32.de>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
@ -7080,8 +7080,7 @@ msgid ""
"S/N %s, ID 0x%08lX,\n"
"created %s, expires %s.\n"
msgstr ""
"Bitte geben Sie die Passphrase an, um den geheimen Schlüssel\n"
"des X.509 Zertifikats:\n"
"Bitte geben Sie die Passphrase an, um den geheimen Schlüssel des X.509 Zertifikats:\n"
"\"%s\"\n"
"S/N %s, ID 0x%08lX,\n"
"gültig von %s bis %s\n"

View File

@ -282,7 +282,7 @@ set_msg_len (unsigned char *msg, unsigned int length)
/* Pint an error message for a failed CCID command including a textual
error code. MSG is shall be the CCID message of at least 10 bytes. */
error code. MSG shall be the CCID message at a minimum of 10 bytes. */
static void
print_command_failed (const unsigned char *msg)
{

View File

@ -1,3 +1,7 @@
2008-04-09 Werner Koch <wk@g10code.com>
* verify.c (gpgsm_verify): Print the message hash values on error.
2008-03-31 Werner Koch <wk@g10code.com>
* call-dirmngr.c (start_dirmngr): Use log_info instead of

View File

@ -467,8 +467,16 @@ gpgsm_verify (ctrl_t ctrl, int in_fd, int data_fd, FILE *out_fp)
{
char *fpr;
log_error ("invalid signature: message digest attribute "
"does not match calculated one\n");
log_error (_("invalid signature: message digest attribute "
"does not match computed one\n"));
if (DBG_X509)
{
if (msgdigest)
log_printhex ("message: ", msgdigest, msgdigestlen);
if (s)
log_printhex ("computed: ",
s, gcry_md_get_algo_dlen (algo));
}
fpr = gpgsm_fpr_and_name_for_status (cert);
gpgsm_status (ctrl, STATUS_BADSIG, fpr);
xfree (fpr);