[svn] GnuPG - r4749 - in trunk: common g10 include jnlib po scd sm
svn author wk
cvs at cvs.gnupg.org
Fri Apr 18 11:20:31 CEST 2008
Author: wk
Date: 2008-04-18 11:20:25 +0200 (Fri, 18 Apr 2008)
New Revision: 4749
Modified:
trunk/common/ChangeLog
trunk/common/i18n.c
trunk/g10/ChangeLog
trunk/g10/main.h
trunk/g10/misc.c
trunk/g10/parse-packet.c
trunk/include/ChangeLog
trunk/include/cipher.h
trunk/jnlib/ChangeLog
trunk/jnlib/w32-gettext.c
trunk/jnlib/w32help.h
trunk/po/de.po
trunk/scd/ccid-driver.c
trunk/sm/ChangeLog
trunk/sm/verify.c
Log:
Adjust for the changed Camellia draft.
W32 gettext changes.
Comment and typo fixes.
Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/common/ChangeLog 2008-04-18 09:20:25 UTC (rev 4749)
@@ -1,3 +1,8 @@
+2008-04-08 Werner Koch <wk at g10code.com>
+
+ * i18n.c (i18n_switchto_utf8, i18n_switchback)
+ [USE_SIMPLE_GETTEXT]: Implement.
+
2008-04-07 Werner Koch <wk at g10code.com>
* b64enc.c (b64enc_start): Detect PGP mode.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/g10/ChangeLog 2008-04-18 09:20:25 UTC (rev 4749)
@@ -1,3 +1,10 @@
+2008-04-18 Werner Koch <wk at 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 at jabberwocky.com>
* getkey.c (merge_selfsigs_subkey): If there are multiple 0x19
Modified: trunk/include/ChangeLog
===================================================================
--- trunk/include/ChangeLog 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/include/ChangeLog 2008-04-18 09:20:25 UTC (rev 4749)
@@ -1,3 +1,8 @@
+2008-04-18 Werner Koch <wk at g10code.com>
+
+ * cipher.h (CIPHER_ALGO_CAMELLIA256): Change ID to 13.
+ (CIPHER_ALGO_CAMELLIA192): New.
+
2007-12-12 Werner Koch <wk at g10code.com>
* cipher.h (CIPHER_ALGO_CAMELLIA128, CIPHER_ALGO_CAMELLIA256): New.
Modified: trunk/jnlib/ChangeLog
===================================================================
--- trunk/jnlib/ChangeLog 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/jnlib/ChangeLog 2008-04-18 09:20:25 UTC (rev 4749)
@@ -1,3 +1,9 @@
+2008-04-08 Werner Koch <wk at 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 at g10code.com>
* w32-gettext.c (_nl_locale_name): New. Taken from
@@ -555,7 +561,7 @@
***********************************************************
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
Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/sm/ChangeLog 2008-04-18 09:20:25 UTC (rev 4749)
@@ -1,3 +1,7 @@
+2008-04-09 Werner Koch <wk at g10code.com>
+
+ * verify.c (gpgsm_verify): Print the message hash values on error.
+
2008-03-31 Werner Koch <wk at g10code.com>
* call-dirmngr.c (start_dirmngr): Use log_info instead of
Modified: trunk/common/i18n.c
===================================================================
--- trunk/common/i18n.c 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/common/i18n.c 2008-04-18 09:20:25 UTC (rev 4749)
@@ -45,17 +45,19 @@
/* 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 @@
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);
Modified: trunk/g10/main.h
===================================================================
--- trunk/g10/main.h 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/g10/main.h 2008-04-18 09:20:25 UTC (rev 4749)
@@ -82,6 +82,7 @@
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 );
Modified: trunk/g10/misc.c
===================================================================
--- trunk/g10/misc.c 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/g10/misc.c 2008-04-18 09:20:25 UTC (rev 4749)
@@ -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 @@
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 @@
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 @@
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 @@
return gcry_cipher_algo_name (map_cipher_openpgp_to_gcry (algo));
}
-
-
int
openpgp_pk_test_algo( int algo )
{
Modified: trunk/g10/parse-packet.c
===================================================================
--- trunk/g10/parse-packet.c 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/g10/parse-packet.c 2008-04-18 09:20:25 UTC (rev 4749)
@@ -1901,19 +1901,13 @@
* 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 )
Modified: trunk/include/cipher.h
===================================================================
--- trunk/include/cipher.h 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/include/cipher.h 2008-04-18 09:20:25 UTC (rev 4749)
@@ -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
Modified: trunk/jnlib/w32-gettext.c
===================================================================
--- trunk/jnlib/w32-gettext.c 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/jnlib/w32-gettext.c 2008-04-18 09:20:25 UTC (rev 4749)
@@ -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 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,7 +113,9 @@
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 @@
return NULL;
}
- data = jnlib_malloc (size);
+ data = (2*size <= size)? NULL : jnlib_malloc (2*size);
if (!data)
{
fclose (fp);
@@ -1278,38 +1282,39 @@
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 @@
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 @@
}
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 @@
return (const char*)os->d;
p = "ERROR in GETTEXT\n";
}
+ else
+ p = "ERROR in GETEXT mapping";
+
return (const char*)p;
}
@@ -1660,4 +1690,11 @@
}
+void
+gettext_select_utf8 (int value)
+{
+ want_utf8 = value;
+}
+
+
#endif /* USE_SIMPLE_GETTEXT */
Modified: trunk/jnlib/w32help.h
===================================================================
--- trunk/jnlib/w32help.h 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/jnlib/w32help.h 2008-04-18 09:20:25 UTC (rev 4749)
@@ -33,6 +33,7 @@
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*/
Modified: trunk/po/de.po [not shown]
Modified: trunk/scd/ccid-driver.c
===================================================================
--- trunk/scd/ccid-driver.c 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/scd/ccid-driver.c 2008-04-18 09:20:25 UTC (rev 4749)
@@ -282,7 +282,7 @@
/* 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)
{
Modified: trunk/sm/verify.c
===================================================================
--- trunk/sm/verify.c 2008-04-17 17:40:30 UTC (rev 4748)
+++ trunk/sm/verify.c 2008-04-18 09:20:25 UTC (rev 4749)
@@ -467,8 +467,16 @@
{
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);
More information about the Gnupg-commits
mailing list