From cvs at cvs.gnupg.org Tue May 1 14:02:16 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 01 May 2007 14:02:16 +0200 Subject: [svn] gcry - r1241 - in trunk: cipher tests Message-ID: Author: wk Date: 2007-05-01 14:01:47 +0200 (Tue, 01 May 2007) New Revision: 1241 Modified: trunk/cipher/ChangeLog trunk/cipher/cipher.c trunk/tests/ChangeLog trunk/tests/basic.c Log: USE_cipher related fixed (#if instead of #ifdef) by David. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-04-30 17:00:21 UTC (rev 1240) +++ trunk/cipher/ChangeLog 2007-05-01 12:01:47 UTC (rev 1241) @@ -1,3 +1,8 @@ +2007-04-30 David Shaw + + * cipher.c: Use #if instead of #ifdef as configure defines the + USE_cipher defines as 0 for disabled. + 2007-04-30 Werner Koch * rndegd.c (_gcry_rndegd_set_socket_name): New. Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2007-04-30 17:00:21 UTC (rev 1240) +++ trunk/cipher/cipher.c 2007-05-01 12:01:47 UTC (rev 1241) @@ -69,10 +69,10 @@ { &_gcry_cipher_spec_serpent192, GCRY_CIPHER_SERPENT192 }, { &_gcry_cipher_spec_serpent256, GCRY_CIPHER_SERPENT256 }, #endif -#ifdef USE_RFC2268 +#if USE_RFC2268 { &_gcry_cipher_spec_rfc2268_40, GCRY_CIPHER_RFC2268_40 }, #endif -#ifdef USE_SEED +#if USE_SEED { &_gcry_cipher_spec_seed, GCRY_CIPHER_SEED }, #endif { NULL } Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-04-30 17:00:21 UTC (rev 1240) +++ trunk/tests/ChangeLog 2007-05-01 12:01:47 UTC (rev 1241) @@ -1,3 +1,8 @@ +2007-04-30 David Shaw + + * basic.c (check_ciphers): #if out ciphers we don't have. Add + test for GCRY_CIPHER_RFC2268_40. + 2007-04-30 Werner Koch * version.c: New. Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2007-04-30 17:00:21 UTC (rev 1240) +++ trunk/tests/basic.c 2007-05-01 12:01:47 UTC (rev 1241) @@ -956,23 +956,42 @@ check_ciphers (void) { static int algos[] = { +#if USE_BLOWFISH + GCRY_CIPHER_BLOWFISH, +#endif +#if USE_DES + GCRY_CIPHER_DES, GCRY_CIPHER_3DES, +#endif +#if USE_CAST5 GCRY_CIPHER_CAST5, - GCRY_CIPHER_BLOWFISH, +#endif +#if USE_AES GCRY_CIPHER_AES, GCRY_CIPHER_AES192, GCRY_CIPHER_AES256, +#endif +#if USE_TWOFISH GCRY_CIPHER_TWOFISH, GCRY_CIPHER_TWOFISH128, - GCRY_CIPHER_DES, +#endif +#if USE_SERPENT GCRY_CIPHER_SERPENT128, GCRY_CIPHER_SERPENT192, GCRY_CIPHER_SERPENT256, +#endif +#if USE_RFC2268 + GCRY_CIPHER_RFC2268_40, +#endif +#if USE_SEED GCRY_CIPHER_SEED, +#endif 0 }; static int algos2[] = { +#if USE_ARCFOUR GCRY_CIPHER_ARCFOUR, +#endif 0 }; int i; From cvs at cvs.gnupg.org Tue May 1 18:26:12 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 01 May 2007 18:26:12 +0200 Subject: [svn] ksba - r272 - in trunk: . src Message-ID: Author: wk Date: 2007-05-01 18:25:43 +0200 (Tue, 01 May 2007) New Revision: 272 Modified: trunk/THANKS trunk/src/ChangeLog trunk/src/asn1-parse.y trunk/src/ksba.h Log: Small fixes by Peter O'Gorman Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-04-20 10:53:07 UTC (rev 271) +++ trunk/THANKS 2007-05-01 16:25:43 UTC (rev 272) @@ -4,6 +4,7 @@ Bernhard Herzog bh at intevation.de Brad Hards bradh at frogmouth.net Daiki Ueno ueno at unixuser.org +Peter O'Gorman gnupg-devel at mlists.thewrittenword.com St?phane Corth?sy stephane at sente.ch Thomas Koester tkoester at intevation.de Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-04-20 10:53:07 UTC (rev 271) +++ trunk/src/ChangeLog 2007-05-01 16:25:43 UTC (rev 272) @@ -1,3 +1,10 @@ +2007-05-01 Werner Koch + + * crl.c (do_hash): Cast BUFFER to char* for arithmetics. + * ksba.h (ksba_stop_reason_t): Remove trailing comma. + * asn1-parse.y (CONST_IMPLICIT): Ditto. Reported by Peter + O'Gorman. + 2007-04-20 Werner Koch * keyinfo.c: Add OIDs for brainpool curves. Modified: trunk/src/asn1-parse.y =================================================================== --- trunk/src/asn1-parse.y 2007-04-20 10:53:07 UTC (rev 271) +++ trunk/src/asn1-parse.y 2007-05-01 16:25:43 UTC (rev 272) @@ -54,7 +54,7 @@ /* constants used in the grammar */ enum { CONST_EXPLICIT = 1, - CONST_IMPLICIT, + CONST_IMPLICIT }; struct parser_control_s { Modified: trunk/src/ksba.h =================================================================== --- trunk/src/ksba.h 2007-04-20 10:53:07 UTC (rev 271) +++ trunk/src/ksba.h 2007-05-01 16:25:43 UTC (rev 272) @@ -78,7 +78,7 @@ KSBA_SR_DETACHED_DATA = 8, KSBA_SR_BEGIN_ITEMS = 9, KSBA_SR_GOT_ITEM = 10, - KSBA_SR_END_ITEMS = 11, + KSBA_SR_END_ITEMS = 11 } ksba_stop_reason_t; typedef ksba_stop_reason_t KsbaStopReason _KSBA_DEPRECATED; From cvs at cvs.gnupg.org Tue May 1 18:28:50 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 01 May 2007 18:28:50 +0200 Subject: [svn] assuan - r235 - in trunk: . src Message-ID: Author: wk Date: 2007-05-01 18:28:21 +0200 (Tue, 01 May 2007) New Revision: 235 Modified: trunk/NEWS trunk/THANKS trunk/TODO trunk/configure.ac trunk/src/ChangeLog Log: Small pointer arithmetics fix Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-12-02 23:45:46 UTC (rev 234) +++ trunk/NEWS 2007-05-01 16:28:21 UTC (rev 235) @@ -1,3 +1,7 @@ +Noteworthy changes in version 1.0.2 +------------------------------------------------ + + Noteworthy changes in version 1.0.1 (2006-11-22) ------------------------------------------------ Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2006-12-02 23:45:46 UTC (rev 234) +++ trunk/THANKS 2007-05-01 16:28:21 UTC (rev 235) @@ -3,6 +3,7 @@ Marc Mutz mutz at kde.org Michael Nottebrock michaelnottebrock at gmx.net Nelson H. F. Beebe beebe at math dot utah dot edu +Peter O'Gorman gnupg-devel at mlists dot thewrittenword dot com Rex Dieter rdieter at math dot unl dot edu Ville Skytt? ville.skytta at iki.fi Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-12-02 23:45:46 UTC (rev 234) +++ trunk/TODO 2007-05-01 16:28:21 UTC (rev 235) @@ -8,3 +8,6 @@ for unknown inquiries, albeit dirmngr itself would handle the returns for assuan_inquire gracefully. We need to check all applications whether it is safe to change this. + +* XOPEN_SOURCE and snprintf + See Peter O'Gorman's mail. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-12-02 23:45:46 UTC (rev 234) +++ trunk/configure.ac 2007-05-01 16:28:21 UTC (rev 235) @@ -26,8 +26,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.0.1]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.0.2]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-12-02 23:45:46 UTC (rev 234) +++ trunk/src/ChangeLog 2007-05-01 16:28:21 UTC (rev 235) @@ -1,3 +1,8 @@ +2007-05-01 Werner Koch + + * assuan-uds.c (uds_reader): Cast void ptr for arithmetics. + Reported by Peter O'Gorman. + 2006-12-03 Marcus Brinkmann * assuan-handler.c (assuan_command_parse_fd): Also allow white From cvs at cvs.gnupg.org Tue May 1 18:36:37 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 01 May 2007 18:36:37 +0200 Subject: [svn] assuan - r236 - trunk/src Message-ID: Author: wk Date: 2007-05-01 18:36:08 +0200 (Tue, 01 May 2007) New Revision: 236 Modified: trunk/src/assuan-uds.c Log: Forgot to commit that file Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2007-05-01 16:28:21 UTC (rev 235) +++ trunk/src/assuan-uds.c 2007-05-01 16:36:08 UTC (rev 236) @@ -152,7 +152,7 @@ if (len > buflen) /* We have more than the user requested. */ len = buflen; - memcpy (buf, ctx->uds.buffer + ctx->uds.bufferoffset, len); + memcpy (buf, (char*)ctx->uds.buffer + ctx->uds.bufferoffset, len); ctx->uds.buffersize -= len; assert (ctx->uds.buffersize >= 0); ctx->uds.bufferoffset += len; From cvs at cvs.gnupg.org Wed May 2 08:27:41 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 02 May 2007 08:27:41 +0200 Subject: [svn] gcry - r1242 - in trunk: . cipher src tests Message-ID: Author: dshaw Date: 2007-05-02 08:27:11 +0200 (Wed, 02 May 2007) New Revision: 1242 Modified: trunk/ChangeLog trunk/NEWS trunk/cipher/ChangeLog trunk/cipher/Makefile.am trunk/cipher/cipher.c trunk/configure.ac trunk/src/ChangeLog trunk/src/cipher.h trunk/src/gcrypt.h.in trunk/tests/ChangeLog trunk/tests/basic.c Log: Add Camellia support. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/ChangeLog 2007-05-02 06:27:11 UTC (rev 1242) @@ -1,3 +1,7 @@ +2007-05-02 David Shaw + + * NEWS, configure.ac: Add Camellia. + 2007-04-30 Werner Koch * README.apichanges: Move to doc/. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/NEWS 2007-05-02 06:27:11 UTC (rev 1242) @@ -16,6 +16,10 @@ * Support for the SEED cipher. + * Support for the Camellia cipher. Note that Camellia is disabled by + default, and that enabling it changes the license of libgcrypt from + LGPL to GPL. + * Support for OFB encryption mode. * gcry_mpi_rshift does not anymore truncate the shift count. @@ -56,6 +60,9 @@ GCRY_PK_USAGE_UNKN NEW GCRY_PK_ECDSA NEW GCRY_CIPHER_SEED NEW + GCRY_CIPHER_CAMELLIA128 NEW + GCRY_CIPHER_CAMELLIA192 NEW + GCRY_CIPHER_CAMELLIA256 NEW GCRYCTL_FAKED_RANDOM_P NEW GCRYCTL_PRINT_CONFIG NEW GCRYCTL_SET_RNDEGD_SOCKET NEW. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/cipher/ChangeLog 2007-05-02 06:27:11 UTC (rev 1242) @@ -1,3 +1,13 @@ +2007-05-02 David Shaw + + * Makefile.am, cipher.c: Add Camellia. + + * camellia-glue.c: New. The necessary glue to interface libgcrypt + to the stock NTT Camellia distribution. + + * camellia.h, camellia.c: The stock NTT Camellia distribution + (GPL). + 2007-04-30 David Shaw * cipher.c: Use #if instead of #ifdef as configure defines the Modified: trunk/cipher/Makefile.am =================================================================== --- trunk/cipher/Makefile.am 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/cipher/Makefile.am 2007-05-02 06:27:11 UTC (rev 1242) @@ -75,7 +75,8 @@ tiger.c \ whirlpool.c \ twofish.c \ -rfc2268.c +rfc2268.c \ +camellia.c camellia.h camellia-glue.c # We need to lower the optimization for this module. tiger.o: $(srcdir)/tiger.c Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/cipher/cipher.c 2007-05-02 06:27:11 UTC (rev 1242) @@ -75,6 +75,11 @@ #if USE_SEED { &_gcry_cipher_spec_seed, GCRY_CIPHER_SEED }, #endif +#if USE_CAMELLIA + { &_gcry_cipher_spec_camellia128, GCRY_CIPHER_CAMELLIA128 }, + { &_gcry_cipher_spec_camellia192, GCRY_CIPHER_CAMELLIA192 }, + { &_gcry_cipher_spec_camellia256, GCRY_CIPHER_CAMELLIA256 }, +#endif { NULL } }; Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/configure.ac 2007-05-02 06:27:11 UTC (rev 1242) @@ -502,7 +502,7 @@ if test "$PTH_CONFIG" = "no"; then AC_MSG_WARN([[ *** -*** To build the Libgcrypt's random humber daemon +*** To build the Libgcrypt's random number daemon *** we need the support of the GNU Portable Threads Library. *** Download it from ftp://ftp.gnu.org/gnu/pth/ *** On a Debian GNU/Linux system you might want to try @@ -813,6 +813,11 @@ AC_DEFINE_UNQUOTED(USE_SEED, $found, [Defined if this module should be included]) +LIST_MEMBER(camellia, $enabled_ciphers) +test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo" && gpl="$gpl camellia" +AC_DEFINE_UNQUOTED(USE_CAMELLIA, $found, + [Defined if this module should be included]) + LIST_MEMBER(dsa, $enabled_pubkey_ciphers) test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo" AC_DEFINE_UNQUOTED(USE_DSA, $found, @@ -963,13 +968,12 @@ G10EOF fi -warn="" for file in "random_modules"; do - case "$file" in rndunix | rndw32) warn="$warn $file";; esac + case "$file" in rndunix | rndw32) gpl="$gpl $file";; esac done -if test -n "$warn"; then +if test -n "$gpl"; then echo "Please note that you are building a version of Libgcrypt with" - echo " $warn" + echo " $gpl" echo "included. These parts are licensed under the GPL and thus the" echo "use of this library has to comply with the conditions of the GPL." fi Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/src/ChangeLog 2007-05-02 06:27:11 UTC (rev 1242) @@ -1,3 +1,7 @@ +2007-05-02 David Shaw + + * cipher.h, gcrypt.h.in: Add Camellia. + 2007-04-30 Werner Koch * gcrypt.h.in (GCRYCTL_PRINT_CONFIG): New. Modified: trunk/src/cipher.h =================================================================== --- trunk/src/cipher.h 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/src/cipher.h 2007-05-02 06:27:11 UTC (rev 1242) @@ -83,6 +83,9 @@ extern gcry_cipher_spec_t _gcry_cipher_spec_serpent256; extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40; extern gcry_cipher_spec_t _gcry_cipher_spec_seed; +extern gcry_cipher_spec_t _gcry_cipher_spec_camellia128; +extern gcry_cipher_spec_t _gcry_cipher_spec_camellia192; +extern gcry_cipher_spec_t _gcry_cipher_spec_camellia256; /* Declarations for the digest specifications. */ extern gcry_md_spec_t _gcry_digest_spec_crc32; Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/src/gcrypt.h.in 2007-05-02 06:27:11 UTC (rev 1242) @@ -765,7 +765,10 @@ GCRY_CIPHER_SERPENT256 = 306, GCRY_CIPHER_RFC2268_40 = 307, /* Ron's Cipher 2 (40 bit). */ GCRY_CIPHER_RFC2268_128 = 308, /* Ron's Cipher 2 (128 bit). */ - GCRY_CIPHER_SEED = 309 /* 128 bit cipher described in RFC4269. */ + GCRY_CIPHER_SEED = 309, /* 128 bit cipher described in RFC4269. */ + GCRY_CIPHER_CAMELLIA128 = 310, + GCRY_CIPHER_CAMELLIA192 = 311, + GCRY_CIPHER_CAMELLIA256 = 312 }; /* The Rijndael algorithm is basically AES, so provide some macros. */ Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/tests/ChangeLog 2007-05-02 06:27:11 UTC (rev 1242) @@ -1,3 +1,7 @@ +2007-05-02 David Shaw + + * basic.c (check_ciphers): Add Camellia. + 2007-04-30 David Shaw * basic.c (check_ciphers): #if out ciphers we don't have. Add Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2007-05-01 12:01:47 UTC (rev 1241) +++ trunk/tests/basic.c 2007-05-02 06:27:11 UTC (rev 1242) @@ -986,6 +986,11 @@ #if USE_SEED GCRY_CIPHER_SEED, #endif +#if USE_CAMELLIA + GCRY_CIPHER_CAMELLIA128, + GCRY_CIPHER_CAMELLIA192, + GCRY_CIPHER_CAMELLIA256, +#endif 0 }; static int algos2[] = { From cvs at cvs.gnupg.org Wed May 2 08:28:53 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 02 May 2007 08:28:53 +0200 Subject: [svn] gcry - r1243 - trunk/cipher Message-ID: Author: dshaw Date: 2007-05-02 08:28:23 +0200 (Wed, 02 May 2007) New Revision: 1243 Added: trunk/cipher/camellia-glue.c trunk/cipher/camellia.c trunk/cipher/camellia.h Log: New files for Camellia. Added: trunk/cipher/camellia-glue.c =================================================================== --- trunk/cipher/camellia-glue.c 2007-05-02 06:27:11 UTC (rev 1242) +++ trunk/cipher/camellia-glue.c 2007-05-02 06:28:23 UTC (rev 1243) @@ -0,0 +1,209 @@ +/* camellia-glue.c - Glue for the Camellia cipher + * Copyright (C) 2007 Free Software Foundation, Inc. + * + * This file is part of Libgcrypt. + * + * Libgcrypt is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgcrypt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/* I put all the libgcrypt-specific stuff in this file to keep the + camellia.c/camellia.h files exactly as provided by NTT. If they + update their code, this should make it easier to bring the changes + in. - dshaw */ + +#include +#include "types.h" +#include "g10lib.h" +#include "cipher.h" +#include "camellia.h" + +typedef struct +{ + int keybitlength; + KEY_TABLE_TYPE keytable; +} CAMELLIA_context; + +static const char *selftest(void); + +static gcry_err_code_t +camellia_setkey(void *c, const byte *key, unsigned keylen) +{ + CAMELLIA_context *ctx=c; + static int initialized=0; + static const char *selftest_failed=NULL; + + if(keylen!=16 && keylen!=24 && keylen!=32) + return GPG_ERR_INV_KEYLEN; + + if(!initialized) + { + initialized=1; + selftest_failed=selftest(); + if(selftest_failed) + log_error("%s\n",selftest_failed); + } + + if(selftest_failed) + return GPG_ERR_SELFTEST_FAILED; + + ctx->keybitlength=keylen*8; + Camellia_Ekeygen(ctx->keybitlength,key,ctx->keytable); + _gcry_burn_stack(4+4+6+34+34+sizeof(unsigned char *)+sizeof(u32 *)); + + return 0; +} + +static void +camellia_encrypt(void *c, byte *outbuf, const byte *inbuf) +{ + CAMELLIA_context *ctx=c; + + Camellia_EncryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf); + _gcry_burn_stack(sizeof(int)+sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE) + +sizeof(unsigned char *)+16+4+4+4+4+sizeof(u32 *) + +sizeof(u32 *)); +} + +static void +camellia_decrypt(void *c, byte *outbuf, const byte *inbuf) +{ + CAMELLIA_context *ctx=c; + + Camellia_DecryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf); + _gcry_burn_stack(sizeof(int)+sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE) + +sizeof(unsigned char *)+16+4+4+4+4+sizeof(u32 *) + +sizeof(u32 *)); +} + +static const char * +selftest(void) +{ + CAMELLIA_context ctx; + byte scratch[16]; + + /* These test vectors are from RFC-3713 */ + const byte plaintext[]= + { + 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, + 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10 + }; + const byte key_128[]= + { + 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, + 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10 + }; + const byte ciphertext_128[]= + { + 0x67,0x67,0x31,0x38,0x54,0x96,0x69,0x73, + 0x08,0x57,0x06,0x56,0x48,0xea,0xbe,0x43 + }; + const byte key_192[]= + { + 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98, + 0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77 + }; + const byte ciphertext_192[]= + { + 0xb4,0x99,0x34,0x01,0xb3,0xe9,0x96,0xf8, + 0x4e,0xe5,0xce,0xe7,0xd7,0x9b,0x09,0xb9 + }; + const byte key_256[]= + { + 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba, + 0x98,0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55, + 0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff + }; + const byte ciphertext_256[]= + { + 0x9a,0xcc,0x23,0x7d,0xff,0x16,0xd7,0x6c, + 0x20,0xef,0x7c,0x91,0x9e,0x3a,0x75,0x09 + }; + + camellia_setkey(&ctx,key_128,sizeof(key_128)); + camellia_encrypt(&ctx,scratch,plaintext); + if(memcmp(scratch,ciphertext_128,sizeof(ciphertext_128))!=0) + return "CAMELLIA-128 test encryption failed."; + camellia_decrypt(&ctx,scratch,scratch); + if(memcmp(scratch,plaintext,sizeof(plaintext))!=0) + return "CAMELLIA-128 test decryption failed."; + + camellia_setkey(&ctx,key_192,sizeof(key_192)); + camellia_encrypt(&ctx,scratch,plaintext); + if(memcmp(scratch,ciphertext_192,sizeof(ciphertext_192))!=0) + return "CAMELLIA-192 test encryption failed."; + camellia_decrypt(&ctx,scratch,scratch); + if(memcmp(scratch,plaintext,sizeof(plaintext))!=0) + return "CAMELLIA-192 test decryption failed."; + + camellia_setkey(&ctx,key_256,sizeof(key_256)); + camellia_encrypt(&ctx,scratch,plaintext); + if(memcmp(scratch,ciphertext_256,sizeof(ciphertext_256))!=0) + return "CAMELLIA-256 test encryption failed."; + camellia_decrypt(&ctx,scratch,scratch); + if(memcmp(scratch,plaintext,sizeof(plaintext))!=0) + return "CAMELLIA-256 test decryption failed."; + + return NULL; +} + +/* These oids are from + , + retrieved May 1, 2007. */ + +static gcry_cipher_oid_spec_t camellia128_oids[] = + { + {"1.2.392.200011.61.1.1.1.2", GCRY_CIPHER_MODE_CBC}, + {"0.3.4401.5.3.1.9.1", GCRY_CIPHER_MODE_ECB}, + {"0.3.4401.5.3.1.9.3", GCRY_CIPHER_MODE_OFB}, + {"0.3.4401.5.3.1.9.4", GCRY_CIPHER_MODE_CFB}, + { NULL } + }; + +static gcry_cipher_oid_spec_t camellia192_oids[] = + { + {"1.2.392.200011.61.1.1.1.3", GCRY_CIPHER_MODE_CBC}, + {"0.3.4401.5.3.1.9.21", GCRY_CIPHER_MODE_ECB}, + {"0.3.4401.5.3.1.9.23", GCRY_CIPHER_MODE_OFB}, + {"0.3.4401.5.3.1.9.24", GCRY_CIPHER_MODE_CFB}, + { NULL } + }; + +static gcry_cipher_oid_spec_t camellia256_oids[] = + { + {"1.2.392.200011.61.1.1.1.4", GCRY_CIPHER_MODE_CBC}, + {"0.3.4401.5.3.1.9.41", GCRY_CIPHER_MODE_ECB}, + {"0.3.4401.5.3.1.9.43", GCRY_CIPHER_MODE_OFB}, + {"0.3.4401.5.3.1.9.44", GCRY_CIPHER_MODE_CFB}, + { NULL } + }; + +gcry_cipher_spec_t _gcry_cipher_spec_camellia128 = + { + "CAMELLIA128",NULL,camellia128_oids,CAMELLIA_BLOCK_SIZE,128, + sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt + }; + +gcry_cipher_spec_t _gcry_cipher_spec_camellia192 = + { + "CAMELLIA192",NULL,camellia192_oids,CAMELLIA_BLOCK_SIZE,192, + sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt + }; + +gcry_cipher_spec_t _gcry_cipher_spec_camellia256 = + { + "CAMELLIA256",NULL,camellia256_oids,CAMELLIA_BLOCK_SIZE,256, + sizeof(CAMELLIA_context),camellia_setkey,camellia_encrypt,camellia_decrypt + }; Added: trunk/cipher/camellia.c =================================================================== --- trunk/cipher/camellia.c 2007-05-02 06:27:11 UTC (rev 1242) +++ trunk/cipher/camellia.c 2007-05-02 06:28:23 UTC (rev 1243) @@ -0,0 +1,1461 @@ +/* camellia.h ver 1.2.0 + * + * Copyright (C) 2006,2007 + * NTT (Nippon Telegraph and Telephone Corporation). + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * Algorithm Specification + * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html + */ + +#include +#include + +#include "camellia.h" + +/* u32 must be 32bit word */ +typedef unsigned int u32; +typedef unsigned char u8; + +/* key constants */ + +#define CAMELLIA_SIGMA1L (0xA09E667FL) +#define CAMELLIA_SIGMA1R (0x3BCC908BL) +#define CAMELLIA_SIGMA2L (0xB67AE858L) +#define CAMELLIA_SIGMA2R (0x4CAA73B2L) +#define CAMELLIA_SIGMA3L (0xC6EF372FL) +#define CAMELLIA_SIGMA3R (0xE94F82BEL) +#define CAMELLIA_SIGMA4L (0x54FF53A5L) +#define CAMELLIA_SIGMA4R (0xF1D36F1CL) +#define CAMELLIA_SIGMA5L (0x10E527FAL) +#define CAMELLIA_SIGMA5R (0xDE682D1DL) +#define CAMELLIA_SIGMA6L (0xB05688C2L) +#define CAMELLIA_SIGMA6R (0xB3E6C1FDL) + +/* + * macros + */ + + +#if defined(_MSC_VER) + +# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) +# define GETU32(p) SWAP(*((u32 *)(p))) +# define PUTU32(ct, st) {*((u32 *)(ct)) = SWAP((st));} + +#else /* not MS-VC */ + +# define GETU32(pt) \ + (((u32)(pt)[0] << 24) \ + ^ ((u32)(pt)[1] << 16) \ + ^ ((u32)(pt)[2] << 8) \ + ^ ((u32)(pt)[3])) + +# define PUTU32(ct, st) { \ + (ct)[0] = (u8)((st) >> 24); \ + (ct)[1] = (u8)((st) >> 16); \ + (ct)[2] = (u8)((st) >> 8); \ + (ct)[3] = (u8)(st); } + +#endif + +#define CamelliaSubkeyL(INDEX) (subkey[(INDEX)*2]) +#define CamelliaSubkeyR(INDEX) (subkey[(INDEX)*2 + 1]) + +/* rotation right shift 1byte */ +#define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24)) +/* rotation left shift 1bit */ +#define CAMELLIA_RL1(x) (((x) << 1) + ((x) >> 31)) +/* rotation left shift 1byte */ +#define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24)) + +#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits) \ + do { \ + w0 = ll; \ + ll = (ll << bits) + (lr >> (32 - bits)); \ + lr = (lr << bits) + (rl >> (32 - bits)); \ + rl = (rl << bits) + (rr >> (32 - bits)); \ + rr = (rr << bits) + (w0 >> (32 - bits)); \ + } while(0) + +#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits) \ + do { \ + w0 = ll; \ + w1 = lr; \ + ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \ + lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \ + rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \ + rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \ + } while(0) + +#define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)]) +#define CAMELLIA_SP0222(INDEX) (camellia_sp0222[(INDEX)]) +#define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)]) +#define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)]) + +#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \ + do { \ + il = xl ^ kl; \ + ir = xr ^ kr; \ + t0 = il >> 16; \ + t1 = ir >> 16; \ + yl = CAMELLIA_SP1110(ir & 0xff) \ + ^ CAMELLIA_SP0222((t1 >> 8) & 0xff) \ + ^ CAMELLIA_SP3033(t1 & 0xff) \ + ^ CAMELLIA_SP4404((ir >> 8) & 0xff); \ + yr = CAMELLIA_SP1110((t0 >> 8) & 0xff) \ + ^ CAMELLIA_SP0222(t0 & 0xff) \ + ^ CAMELLIA_SP3033((il >> 8) & 0xff) \ + ^ CAMELLIA_SP4404(il & 0xff); \ + yl ^= yr; \ + yr = CAMELLIA_RR8(yr); \ + yr ^= yl; \ + } while(0) + + +/* + * for speed up + * + */ +#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \ + do { \ + t0 = kll; \ + t0 &= ll; \ + lr ^= CAMELLIA_RL1(t0); \ + t1 = klr; \ + t1 |= lr; \ + ll ^= t1; \ + \ + t2 = krr; \ + t2 |= rr; \ + rl ^= t2; \ + t3 = krl; \ + t3 &= rl; \ + rr ^= CAMELLIA_RL1(t3); \ + } while(0) + +#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1) \ + do { \ + ir = CAMELLIA_SP1110(xr & 0xff) \ + ^ CAMELLIA_SP0222((xr >> 24) & 0xff) \ + ^ CAMELLIA_SP3033((xr >> 16) & 0xff) \ + ^ CAMELLIA_SP4404((xr >> 8) & 0xff); \ + il = CAMELLIA_SP1110((xl >> 24) & 0xff) \ + ^ CAMELLIA_SP0222((xl >> 16) & 0xff) \ + ^ CAMELLIA_SP3033((xl >> 8) & 0xff) \ + ^ CAMELLIA_SP4404(xl & 0xff); \ + il ^= kl; \ + ir ^= kr; \ + ir ^= il; \ + il = CAMELLIA_RR8(il); \ + il ^= ir; \ + yl ^= ir; \ + yr ^= il; \ + } while(0) + + +static const u32 camellia_sp1110[256] = { + 0x70707000,0x82828200,0x2c2c2c00,0xececec00, + 0xb3b3b300,0x27272700,0xc0c0c000,0xe5e5e500, + 0xe4e4e400,0x85858500,0x57575700,0x35353500, + 0xeaeaea00,0x0c0c0c00,0xaeaeae00,0x41414100, + 0x23232300,0xefefef00,0x6b6b6b00,0x93939300, + 0x45454500,0x19191900,0xa5a5a500,0x21212100, + 0xededed00,0x0e0e0e00,0x4f4f4f00,0x4e4e4e00, + 0x1d1d1d00,0x65656500,0x92929200,0xbdbdbd00, + 0x86868600,0xb8b8b800,0xafafaf00,0x8f8f8f00, + 0x7c7c7c00,0xebebeb00,0x1f1f1f00,0xcecece00, + 0x3e3e3e00,0x30303000,0xdcdcdc00,0x5f5f5f00, + 0x5e5e5e00,0xc5c5c500,0x0b0b0b00,0x1a1a1a00, + 0xa6a6a600,0xe1e1e100,0x39393900,0xcacaca00, + 0xd5d5d500,0x47474700,0x5d5d5d00,0x3d3d3d00, + 0xd9d9d900,0x01010100,0x5a5a5a00,0xd6d6d600, + 0x51515100,0x56565600,0x6c6c6c00,0x4d4d4d00, + 0x8b8b8b00,0x0d0d0d00,0x9a9a9a00,0x66666600, + 0xfbfbfb00,0xcccccc00,0xb0b0b000,0x2d2d2d00, + 0x74747400,0x12121200,0x2b2b2b00,0x20202000, + 0xf0f0f000,0xb1b1b100,0x84848400,0x99999900, + 0xdfdfdf00,0x4c4c4c00,0xcbcbcb00,0xc2c2c200, + 0x34343400,0x7e7e7e00,0x76767600,0x05050500, + 0x6d6d6d00,0xb7b7b700,0xa9a9a900,0x31313100, + 0xd1d1d100,0x17171700,0x04040400,0xd7d7d700, + 0x14141400,0x58585800,0x3a3a3a00,0x61616100, + 0xdedede00,0x1b1b1b00,0x11111100,0x1c1c1c00, + 0x32323200,0x0f0f0f00,0x9c9c9c00,0x16161600, + 0x53535300,0x18181800,0xf2f2f200,0x22222200, + 0xfefefe00,0x44444400,0xcfcfcf00,0xb2b2b200, + 0xc3c3c300,0xb5b5b500,0x7a7a7a00,0x91919100, + 0x24242400,0x08080800,0xe8e8e800,0xa8a8a800, + 0x60606000,0xfcfcfc00,0x69696900,0x50505000, + 0xaaaaaa00,0xd0d0d000,0xa0a0a000,0x7d7d7d00, + 0xa1a1a100,0x89898900,0x62626200,0x97979700, + 0x54545400,0x5b5b5b00,0x1e1e1e00,0x95959500, + 0xe0e0e000,0xffffff00,0x64646400,0xd2d2d200, + 0x10101000,0xc4c4c400,0x00000000,0x48484800, + 0xa3a3a300,0xf7f7f700,0x75757500,0xdbdbdb00, + 0x8a8a8a00,0x03030300,0xe6e6e600,0xdadada00, + 0x09090900,0x3f3f3f00,0xdddddd00,0x94949400, + 0x87878700,0x5c5c5c00,0x83838300,0x02020200, + 0xcdcdcd00,0x4a4a4a00,0x90909000,0x33333300, + 0x73737300,0x67676700,0xf6f6f600,0xf3f3f300, + 0x9d9d9d00,0x7f7f7f00,0xbfbfbf00,0xe2e2e200, + 0x52525200,0x9b9b9b00,0xd8d8d800,0x26262600, + 0xc8c8c800,0x37373700,0xc6c6c600,0x3b3b3b00, + 0x81818100,0x96969600,0x6f6f6f00,0x4b4b4b00, + 0x13131300,0xbebebe00,0x63636300,0x2e2e2e00, + 0xe9e9e900,0x79797900,0xa7a7a700,0x8c8c8c00, + 0x9f9f9f00,0x6e6e6e00,0xbcbcbc00,0x8e8e8e00, + 0x29292900,0xf5f5f500,0xf9f9f900,0xb6b6b600, + 0x2f2f2f00,0xfdfdfd00,0xb4b4b400,0x59595900, + 0x78787800,0x98989800,0x06060600,0x6a6a6a00, + 0xe7e7e700,0x46464600,0x71717100,0xbababa00, + 0xd4d4d400,0x25252500,0xababab00,0x42424200, + 0x88888800,0xa2a2a200,0x8d8d8d00,0xfafafa00, + 0x72727200,0x07070700,0xb9b9b900,0x55555500, + 0xf8f8f800,0xeeeeee00,0xacacac00,0x0a0a0a00, + 0x36363600,0x49494900,0x2a2a2a00,0x68686800, + 0x3c3c3c00,0x38383800,0xf1f1f100,0xa4a4a400, + 0x40404000,0x28282800,0xd3d3d300,0x7b7b7b00, + 0xbbbbbb00,0xc9c9c900,0x43434300,0xc1c1c100, + 0x15151500,0xe3e3e300,0xadadad00,0xf4f4f400, + 0x77777700,0xc7c7c700,0x80808000,0x9e9e9e00, +}; + +static const u32 camellia_sp0222[256] = { + 0x00e0e0e0,0x00050505,0x00585858,0x00d9d9d9, + 0x00676767,0x004e4e4e,0x00818181,0x00cbcbcb, + 0x00c9c9c9,0x000b0b0b,0x00aeaeae,0x006a6a6a, + 0x00d5d5d5,0x00181818,0x005d5d5d,0x00828282, + 0x00464646,0x00dfdfdf,0x00d6d6d6,0x00272727, + 0x008a8a8a,0x00323232,0x004b4b4b,0x00424242, + 0x00dbdbdb,0x001c1c1c,0x009e9e9e,0x009c9c9c, + 0x003a3a3a,0x00cacaca,0x00252525,0x007b7b7b, + 0x000d0d0d,0x00717171,0x005f5f5f,0x001f1f1f, + 0x00f8f8f8,0x00d7d7d7,0x003e3e3e,0x009d9d9d, + 0x007c7c7c,0x00606060,0x00b9b9b9,0x00bebebe, + 0x00bcbcbc,0x008b8b8b,0x00161616,0x00343434, + 0x004d4d4d,0x00c3c3c3,0x00727272,0x00959595, + 0x00ababab,0x008e8e8e,0x00bababa,0x007a7a7a, + 0x00b3b3b3,0x00020202,0x00b4b4b4,0x00adadad, + 0x00a2a2a2,0x00acacac,0x00d8d8d8,0x009a9a9a, + 0x00171717,0x001a1a1a,0x00353535,0x00cccccc, + 0x00f7f7f7,0x00999999,0x00616161,0x005a5a5a, + 0x00e8e8e8,0x00242424,0x00565656,0x00404040, + 0x00e1e1e1,0x00636363,0x00090909,0x00333333, + 0x00bfbfbf,0x00989898,0x00979797,0x00858585, + 0x00686868,0x00fcfcfc,0x00ececec,0x000a0a0a, + 0x00dadada,0x006f6f6f,0x00535353,0x00626262, + 0x00a3a3a3,0x002e2e2e,0x00080808,0x00afafaf, + 0x00282828,0x00b0b0b0,0x00747474,0x00c2c2c2, + 0x00bdbdbd,0x00363636,0x00222222,0x00383838, + 0x00646464,0x001e1e1e,0x00393939,0x002c2c2c, + 0x00a6a6a6,0x00303030,0x00e5e5e5,0x00444444, + 0x00fdfdfd,0x00888888,0x009f9f9f,0x00656565, + 0x00878787,0x006b6b6b,0x00f4f4f4,0x00232323, + 0x00484848,0x00101010,0x00d1d1d1,0x00515151, + 0x00c0c0c0,0x00f9f9f9,0x00d2d2d2,0x00a0a0a0, + 0x00555555,0x00a1a1a1,0x00414141,0x00fafafa, + 0x00434343,0x00131313,0x00c4c4c4,0x002f2f2f, + 0x00a8a8a8,0x00b6b6b6,0x003c3c3c,0x002b2b2b, + 0x00c1c1c1,0x00ffffff,0x00c8c8c8,0x00a5a5a5, + 0x00202020,0x00898989,0x00000000,0x00909090, + 0x00474747,0x00efefef,0x00eaeaea,0x00b7b7b7, + 0x00151515,0x00060606,0x00cdcdcd,0x00b5b5b5, + 0x00121212,0x007e7e7e,0x00bbbbbb,0x00292929, + 0x000f0f0f,0x00b8b8b8,0x00070707,0x00040404, + 0x009b9b9b,0x00949494,0x00212121,0x00666666, + 0x00e6e6e6,0x00cecece,0x00ededed,0x00e7e7e7, + 0x003b3b3b,0x00fefefe,0x007f7f7f,0x00c5c5c5, + 0x00a4a4a4,0x00373737,0x00b1b1b1,0x004c4c4c, + 0x00919191,0x006e6e6e,0x008d8d8d,0x00767676, + 0x00030303,0x002d2d2d,0x00dedede,0x00969696, + 0x00262626,0x007d7d7d,0x00c6c6c6,0x005c5c5c, + 0x00d3d3d3,0x00f2f2f2,0x004f4f4f,0x00191919, + 0x003f3f3f,0x00dcdcdc,0x00797979,0x001d1d1d, + 0x00525252,0x00ebebeb,0x00f3f3f3,0x006d6d6d, + 0x005e5e5e,0x00fbfbfb,0x00696969,0x00b2b2b2, + 0x00f0f0f0,0x00313131,0x000c0c0c,0x00d4d4d4, + 0x00cfcfcf,0x008c8c8c,0x00e2e2e2,0x00757575, + 0x00a9a9a9,0x004a4a4a,0x00575757,0x00848484, + 0x00111111,0x00454545,0x001b1b1b,0x00f5f5f5, + 0x00e4e4e4,0x000e0e0e,0x00737373,0x00aaaaaa, + 0x00f1f1f1,0x00dddddd,0x00595959,0x00141414, + 0x006c6c6c,0x00929292,0x00545454,0x00d0d0d0, + 0x00787878,0x00707070,0x00e3e3e3,0x00494949, + 0x00808080,0x00505050,0x00a7a7a7,0x00f6f6f6, + 0x00777777,0x00939393,0x00868686,0x00838383, + 0x002a2a2a,0x00c7c7c7,0x005b5b5b,0x00e9e9e9, + 0x00eeeeee,0x008f8f8f,0x00010101,0x003d3d3d, +}; + +static const u32 camellia_sp3033[256] = { + 0x38003838,0x41004141,0x16001616,0x76007676, + 0xd900d9d9,0x93009393,0x60006060,0xf200f2f2, + 0x72007272,0xc200c2c2,0xab00abab,0x9a009a9a, + 0x75007575,0x06000606,0x57005757,0xa000a0a0, + 0x91009191,0xf700f7f7,0xb500b5b5,0xc900c9c9, + 0xa200a2a2,0x8c008c8c,0xd200d2d2,0x90009090, + 0xf600f6f6,0x07000707,0xa700a7a7,0x27002727, + 0x8e008e8e,0xb200b2b2,0x49004949,0xde00dede, + 0x43004343,0x5c005c5c,0xd700d7d7,0xc700c7c7, + 0x3e003e3e,0xf500f5f5,0x8f008f8f,0x67006767, + 0x1f001f1f,0x18001818,0x6e006e6e,0xaf00afaf, + 0x2f002f2f,0xe200e2e2,0x85008585,0x0d000d0d, + 0x53005353,0xf000f0f0,0x9c009c9c,0x65006565, + 0xea00eaea,0xa300a3a3,0xae00aeae,0x9e009e9e, + 0xec00ecec,0x80008080,0x2d002d2d,0x6b006b6b, + 0xa800a8a8,0x2b002b2b,0x36003636,0xa600a6a6, + 0xc500c5c5,0x86008686,0x4d004d4d,0x33003333, + 0xfd00fdfd,0x66006666,0x58005858,0x96009696, + 0x3a003a3a,0x09000909,0x95009595,0x10001010, + 0x78007878,0xd800d8d8,0x42004242,0xcc00cccc, + 0xef00efef,0x26002626,0xe500e5e5,0x61006161, + 0x1a001a1a,0x3f003f3f,0x3b003b3b,0x82008282, + 0xb600b6b6,0xdb00dbdb,0xd400d4d4,0x98009898, + 0xe800e8e8,0x8b008b8b,0x02000202,0xeb00ebeb, + 0x0a000a0a,0x2c002c2c,0x1d001d1d,0xb000b0b0, + 0x6f006f6f,0x8d008d8d,0x88008888,0x0e000e0e, + 0x19001919,0x87008787,0x4e004e4e,0x0b000b0b, + 0xa900a9a9,0x0c000c0c,0x79007979,0x11001111, + 0x7f007f7f,0x22002222,0xe700e7e7,0x59005959, + 0xe100e1e1,0xda00dada,0x3d003d3d,0xc800c8c8, + 0x12001212,0x04000404,0x74007474,0x54005454, + 0x30003030,0x7e007e7e,0xb400b4b4,0x28002828, + 0x55005555,0x68006868,0x50005050,0xbe00bebe, + 0xd000d0d0,0xc400c4c4,0x31003131,0xcb00cbcb, + 0x2a002a2a,0xad00adad,0x0f000f0f,0xca00caca, + 0x70007070,0xff00ffff,0x32003232,0x69006969, + 0x08000808,0x62006262,0x00000000,0x24002424, + 0xd100d1d1,0xfb00fbfb,0xba00baba,0xed00eded, + 0x45004545,0x81008181,0x73007373,0x6d006d6d, + 0x84008484,0x9f009f9f,0xee00eeee,0x4a004a4a, + 0xc300c3c3,0x2e002e2e,0xc100c1c1,0x01000101, + 0xe600e6e6,0x25002525,0x48004848,0x99009999, + 0xb900b9b9,0xb300b3b3,0x7b007b7b,0xf900f9f9, + 0xce00cece,0xbf00bfbf,0xdf00dfdf,0x71007171, + 0x29002929,0xcd00cdcd,0x6c006c6c,0x13001313, + 0x64006464,0x9b009b9b,0x63006363,0x9d009d9d, + 0xc000c0c0,0x4b004b4b,0xb700b7b7,0xa500a5a5, + 0x89008989,0x5f005f5f,0xb100b1b1,0x17001717, + 0xf400f4f4,0xbc00bcbc,0xd300d3d3,0x46004646, + 0xcf00cfcf,0x37003737,0x5e005e5e,0x47004747, + 0x94009494,0xfa00fafa,0xfc00fcfc,0x5b005b5b, + 0x97009797,0xfe00fefe,0x5a005a5a,0xac00acac, + 0x3c003c3c,0x4c004c4c,0x03000303,0x35003535, + 0xf300f3f3,0x23002323,0xb800b8b8,0x5d005d5d, + 0x6a006a6a,0x92009292,0xd500d5d5,0x21002121, + 0x44004444,0x51005151,0xc600c6c6,0x7d007d7d, + 0x39003939,0x83008383,0xdc00dcdc,0xaa00aaaa, + 0x7c007c7c,0x77007777,0x56005656,0x05000505, + 0x1b001b1b,0xa400a4a4,0x15001515,0x34003434, + 0x1e001e1e,0x1c001c1c,0xf800f8f8,0x52005252, + 0x20002020,0x14001414,0xe900e9e9,0xbd00bdbd, + 0xdd00dddd,0xe400e4e4,0xa100a1a1,0xe000e0e0, + 0x8a008a8a,0xf100f1f1,0xd600d6d6,0x7a007a7a, + 0xbb00bbbb,0xe300e3e3,0x40004040,0x4f004f4f, +}; + +static const u32 camellia_sp4404[256] = { + 0x70700070,0x2c2c002c,0xb3b300b3,0xc0c000c0, + 0xe4e400e4,0x57570057,0xeaea00ea,0xaeae00ae, + 0x23230023,0x6b6b006b,0x45450045,0xa5a500a5, + 0xeded00ed,0x4f4f004f,0x1d1d001d,0x92920092, + 0x86860086,0xafaf00af,0x7c7c007c,0x1f1f001f, + 0x3e3e003e,0xdcdc00dc,0x5e5e005e,0x0b0b000b, + 0xa6a600a6,0x39390039,0xd5d500d5,0x5d5d005d, + 0xd9d900d9,0x5a5a005a,0x51510051,0x6c6c006c, + 0x8b8b008b,0x9a9a009a,0xfbfb00fb,0xb0b000b0, + 0x74740074,0x2b2b002b,0xf0f000f0,0x84840084, + 0xdfdf00df,0xcbcb00cb,0x34340034,0x76760076, + 0x6d6d006d,0xa9a900a9,0xd1d100d1,0x04040004, + 0x14140014,0x3a3a003a,0xdede00de,0x11110011, + 0x32320032,0x9c9c009c,0x53530053,0xf2f200f2, + 0xfefe00fe,0xcfcf00cf,0xc3c300c3,0x7a7a007a, + 0x24240024,0xe8e800e8,0x60600060,0x69690069, + 0xaaaa00aa,0xa0a000a0,0xa1a100a1,0x62620062, + 0x54540054,0x1e1e001e,0xe0e000e0,0x64640064, + 0x10100010,0x00000000,0xa3a300a3,0x75750075, + 0x8a8a008a,0xe6e600e6,0x09090009,0xdddd00dd, + 0x87870087,0x83830083,0xcdcd00cd,0x90900090, + 0x73730073,0xf6f600f6,0x9d9d009d,0xbfbf00bf, + 0x52520052,0xd8d800d8,0xc8c800c8,0xc6c600c6, + 0x81810081,0x6f6f006f,0x13130013,0x63630063, + 0xe9e900e9,0xa7a700a7,0x9f9f009f,0xbcbc00bc, + 0x29290029,0xf9f900f9,0x2f2f002f,0xb4b400b4, + 0x78780078,0x06060006,0xe7e700e7,0x71710071, + 0xd4d400d4,0xabab00ab,0x88880088,0x8d8d008d, + 0x72720072,0xb9b900b9,0xf8f800f8,0xacac00ac, + 0x36360036,0x2a2a002a,0x3c3c003c,0xf1f100f1, + 0x40400040,0xd3d300d3,0xbbbb00bb,0x43430043, + 0x15150015,0xadad00ad,0x77770077,0x80800080, + 0x82820082,0xecec00ec,0x27270027,0xe5e500e5, + 0x85850085,0x35350035,0x0c0c000c,0x41410041, + 0xefef00ef,0x93930093,0x19190019,0x21210021, + 0x0e0e000e,0x4e4e004e,0x65650065,0xbdbd00bd, + 0xb8b800b8,0x8f8f008f,0xebeb00eb,0xcece00ce, + 0x30300030,0x5f5f005f,0xc5c500c5,0x1a1a001a, + 0xe1e100e1,0xcaca00ca,0x47470047,0x3d3d003d, + 0x01010001,0xd6d600d6,0x56560056,0x4d4d004d, + 0x0d0d000d,0x66660066,0xcccc00cc,0x2d2d002d, + 0x12120012,0x20200020,0xb1b100b1,0x99990099, + 0x4c4c004c,0xc2c200c2,0x7e7e007e,0x05050005, + 0xb7b700b7,0x31310031,0x17170017,0xd7d700d7, + 0x58580058,0x61610061,0x1b1b001b,0x1c1c001c, + 0x0f0f000f,0x16160016,0x18180018,0x22220022, + 0x44440044,0xb2b200b2,0xb5b500b5,0x91910091, + 0x08080008,0xa8a800a8,0xfcfc00fc,0x50500050, + 0xd0d000d0,0x7d7d007d,0x89890089,0x97970097, + 0x5b5b005b,0x95950095,0xffff00ff,0xd2d200d2, + 0xc4c400c4,0x48480048,0xf7f700f7,0xdbdb00db, + 0x03030003,0xdada00da,0x3f3f003f,0x94940094, + 0x5c5c005c,0x02020002,0x4a4a004a,0x33330033, + 0x67670067,0xf3f300f3,0x7f7f007f,0xe2e200e2, + 0x9b9b009b,0x26260026,0x37370037,0x3b3b003b, + 0x96960096,0x4b4b004b,0xbebe00be,0x2e2e002e, + 0x79790079,0x8c8c008c,0x6e6e006e,0x8e8e008e, + 0xf5f500f5,0xb6b600b6,0xfdfd00fd,0x59590059, + 0x98980098,0x6a6a006a,0x46460046,0xbaba00ba, + 0x25250025,0x42420042,0xa2a200a2,0xfafa00fa, + 0x07070007,0x55550055,0xeeee00ee,0x0a0a000a, + 0x49490049,0x68680068,0x38380038,0xa4a400a4, + 0x28280028,0x7b7b007b,0xc9c900c9,0xc1c100c1, + 0xe3e300e3,0xf4f400f4,0xc7c700c7,0x9e9e009e, +}; + + +/** + * Stuff related to the Camellia key schedule + */ +#define subl(x) subL[(x)] +#define subr(x) subR[(x)] + +void camellia_setup128(const unsigned char *key, u32 *subkey) +{ + u32 kll, klr, krl, krr; + u32 il, ir, t0, t1, w0, w1; + u32 kw4l, kw4r, dw, tl, tr; + u32 subL[26]; + u32 subR[26]; + + /** + * k == kll || klr || krl || krr (|| is concatination) + */ + kll = GETU32(key ); + klr = GETU32(key + 4); + krl = GETU32(key + 8); + krr = GETU32(key + 12); + /** + * generate KL dependent subkeys + */ + subl(0) = kll; subr(0) = klr; + subl(1) = krl; subr(1) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(4) = kll; subr(4) = klr; + subl(5) = krl; subr(5) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30); + subl(10) = kll; subr(10) = klr; + subl(11) = krl; subr(11) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(13) = krl; subr(13) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17); + subl(16) = kll; subr(16) = klr; + subl(17) = krl; subr(17) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17); + subl(18) = kll; subr(18) = klr; + subl(19) = krl; subr(19) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17); + subl(22) = kll; subr(22) = klr; + subl(23) = krl; subr(23) = krr; + + /* generate KA */ + kll = subl(0); klr = subr(0); + krl = subl(1); krr = subr(1); + CAMELLIA_F(kll, klr, + CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R, + w0, w1, il, ir, t0, t1); + krl ^= w0; krr ^= w1; + CAMELLIA_F(krl, krr, + CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R, + kll, klr, il, ir, t0, t1); + CAMELLIA_F(kll, klr, + CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R, + krl, krr, il, ir, t0, t1); + krl ^= w0; krr ^= w1; + CAMELLIA_F(krl, krr, + CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R, + w0, w1, il, ir, t0, t1); + kll ^= w0; klr ^= w1; + + /* generate KA dependent subkeys */ + subl(2) = kll; subr(2) = klr; + subl(3) = krl; subr(3) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(6) = kll; subr(6) = klr; + subl(7) = krl; subr(7) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(8) = kll; subr(8) = klr; + subl(9) = krl; subr(9) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(12) = kll; subr(12) = klr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(14) = kll; subr(14) = klr; + subl(15) = krl; subr(15) = krr; + CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34); + subl(20) = kll; subr(20) = klr; + subl(21) = krl; subr(21) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17); + subl(24) = kll; subr(24) = klr; + subl(25) = krl; subr(25) = krr; + + + /* absorb kw2 to other subkeys */ + subl(3) ^= subl(1); subr(3) ^= subr(1); + subl(5) ^= subl(1); subr(5) ^= subr(1); + subl(7) ^= subl(1); subr(7) ^= subr(1); + subl(1) ^= subr(1) & ~subr(9); + dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw); + subl(11) ^= subl(1); subr(11) ^= subr(1); + subl(13) ^= subl(1); subr(13) ^= subr(1); + subl(15) ^= subl(1); subr(15) ^= subr(1); + subl(1) ^= subr(1) & ~subr(17); + dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw); + subl(19) ^= subl(1); subr(19) ^= subr(1); + subl(21) ^= subl(1); subr(21) ^= subr(1); + subl(23) ^= subl(1); subr(23) ^= subr(1); + subl(24) ^= subl(1); subr(24) ^= subr(1); + + /* absorb kw4 to other subkeys */ + kw4l = subl(25); kw4r = subr(25); + subl(22) ^= kw4l; subr(22) ^= kw4r; + subl(20) ^= kw4l; subr(20) ^= kw4r; + subl(18) ^= kw4l; subr(18) ^= kw4r; + kw4l ^= kw4r & ~subr(16); + dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw); + subl(14) ^= kw4l; subr(14) ^= kw4r; + subl(12) ^= kw4l; subr(12) ^= kw4r; + subl(10) ^= kw4l; subr(10) ^= kw4r; + kw4l ^= kw4r & ~subr(8); + dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw); + subl(6) ^= kw4l; subr(6) ^= kw4r; + subl(4) ^= kw4l; subr(4) ^= kw4r; + subl(2) ^= kw4l; subr(2) ^= kw4r; + subl(0) ^= kw4l; subr(0) ^= kw4r; + + /* key XOR is end of F-function */ + CamelliaSubkeyL(0) = subl(0) ^ subl(2); + CamelliaSubkeyR(0) = subr(0) ^ subr(2); + CamelliaSubkeyL(2) = subl(3); + CamelliaSubkeyR(2) = subr(3); + CamelliaSubkeyL(3) = subl(2) ^ subl(4); + CamelliaSubkeyR(3) = subr(2) ^ subr(4); + CamelliaSubkeyL(4) = subl(3) ^ subl(5); + CamelliaSubkeyR(4) = subr(3) ^ subr(5); + CamelliaSubkeyL(5) = subl(4) ^ subl(6); + CamelliaSubkeyR(5) = subr(4) ^ subr(6); + CamelliaSubkeyL(6) = subl(5) ^ subl(7); + CamelliaSubkeyR(6) = subr(5) ^ subr(7); + tl = subl(10) ^ (subr(10) & ~subr(8)); + dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(7) = subl(6) ^ tl; + CamelliaSubkeyR(7) = subr(6) ^ tr; + CamelliaSubkeyL(8) = subl(8); + CamelliaSubkeyR(8) = subr(8); + CamelliaSubkeyL(9) = subl(9); + CamelliaSubkeyR(9) = subr(9); + tl = subl(7) ^ (subr(7) & ~subr(9)); + dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(10) = tl ^ subl(11); + CamelliaSubkeyR(10) = tr ^ subr(11); + CamelliaSubkeyL(11) = subl(10) ^ subl(12); + CamelliaSubkeyR(11) = subr(10) ^ subr(12); + CamelliaSubkeyL(12) = subl(11) ^ subl(13); + CamelliaSubkeyR(12) = subr(11) ^ subr(13); + CamelliaSubkeyL(13) = subl(12) ^ subl(14); + CamelliaSubkeyR(13) = subr(12) ^ subr(14); + CamelliaSubkeyL(14) = subl(13) ^ subl(15); + CamelliaSubkeyR(14) = subr(13) ^ subr(15); + tl = subl(18) ^ (subr(18) & ~subr(16)); + dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(15) = subl(14) ^ tl; + CamelliaSubkeyR(15) = subr(14) ^ tr; + CamelliaSubkeyL(16) = subl(16); + CamelliaSubkeyR(16) = subr(16); + CamelliaSubkeyL(17) = subl(17); + CamelliaSubkeyR(17) = subr(17); + tl = subl(15) ^ (subr(15) & ~subr(17)); + dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(18) = tl ^ subl(19); + CamelliaSubkeyR(18) = tr ^ subr(19); + CamelliaSubkeyL(19) = subl(18) ^ subl(20); + CamelliaSubkeyR(19) = subr(18) ^ subr(20); + CamelliaSubkeyL(20) = subl(19) ^ subl(21); + CamelliaSubkeyR(20) = subr(19) ^ subr(21); + CamelliaSubkeyL(21) = subl(20) ^ subl(22); + CamelliaSubkeyR(21) = subr(20) ^ subr(22); + CamelliaSubkeyL(22) = subl(21) ^ subl(23); + CamelliaSubkeyR(22) = subr(21) ^ subr(23); + CamelliaSubkeyL(23) = subl(22); + CamelliaSubkeyR(23) = subr(22); + CamelliaSubkeyL(24) = subl(24) ^ subl(23); + CamelliaSubkeyR(24) = subr(24) ^ subr(23); + + /* apply the inverse of the last half of P-function */ + dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw; + dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw; + dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw; + dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw; + dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw; + dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw; + dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw; + dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw; + dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw; + dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw; + dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw; + dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw; + dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw; + dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw; + dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw; + dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw; + dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw; + dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw; + + return; +} + +void camellia_setup256(const unsigned char *key, u32 *subkey) +{ + u32 kll,klr,krl,krr; /* left half of key */ + u32 krll,krlr,krrl,krrr; /* right half of key */ + u32 il, ir, t0, t1, w0, w1; /* temporary variables */ + u32 kw4l, kw4r, dw, tl, tr; + u32 subL[34]; + u32 subR[34]; + + /** + * key = (kll || klr || krl || krr || krll || krlr || krrl || krrr) + * (|| is concatination) + */ + + kll = GETU32(key ); + klr = GETU32(key + 4); + krl = GETU32(key + 8); + krr = GETU32(key + 12); + krll = GETU32(key + 16); + krlr = GETU32(key + 20); + krrl = GETU32(key + 24); + krrr = GETU32(key + 28); + + /* generate KL dependent subkeys */ + subl(0) = kll; subr(0) = klr; + subl(1) = krl; subr(1) = krr; + CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 45); + subl(12) = kll; subr(12) = klr; + subl(13) = krl; subr(13) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(16) = kll; subr(16) = klr; + subl(17) = krl; subr(17) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17); + subl(22) = kll; subr(22) = klr; + subl(23) = krl; subr(23) = krr; + CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34); + subl(30) = kll; subr(30) = klr; + subl(31) = krl; subr(31) = krr; + + /* generate KR dependent subkeys */ + CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15); + subl(4) = krll; subr(4) = krlr; + subl(5) = krrl; subr(5) = krrr; + CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15); + subl(8) = krll; subr(8) = krlr; + subl(9) = krrl; subr(9) = krrr; + CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30); + subl(18) = krll; subr(18) = krlr; + subl(19) = krrl; subr(19) = krrr; + CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34); + subl(26) = krll; subr(26) = krlr; + subl(27) = krrl; subr(27) = krrr; + CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34); + + /* generate KA */ + kll = subl(0) ^ krll; klr = subr(0) ^ krlr; + krl = subl(1) ^ krrl; krr = subr(1) ^ krrr; + CAMELLIA_F(kll, klr, + CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R, + w0, w1, il, ir, t0, t1); + krl ^= w0; krr ^= w1; + CAMELLIA_F(krl, krr, + CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R, + kll, klr, il, ir, t0, t1); + kll ^= krll; klr ^= krlr; + CAMELLIA_F(kll, klr, + CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R, + krl, krr, il, ir, t0, t1); + krl ^= w0 ^ krrl; krr ^= w1 ^ krrr; + CAMELLIA_F(krl, krr, + CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R, + w0, w1, il, ir, t0, t1); + kll ^= w0; klr ^= w1; + + /* generate KB */ + krll ^= kll; krlr ^= klr; + krrl ^= krl; krrr ^= krr; + CAMELLIA_F(krll, krlr, + CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R, + w0, w1, il, ir, t0, t1); + krrl ^= w0; krrr ^= w1; + CAMELLIA_F(krrl, krrr, + CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R, + w0, w1, il, ir, t0, t1); + krll ^= w0; krlr ^= w1; + + /* generate KA dependent subkeys */ + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15); + subl(6) = kll; subr(6) = klr; + subl(7) = krl; subr(7) = krr; + CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30); + subl(14) = kll; subr(14) = klr; + subl(15) = krl; subr(15) = krr; + subl(24) = klr; subr(24) = krl; + subl(25) = krr; subr(25) = kll; + CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 49); + subl(28) = kll; subr(28) = klr; + subl(29) = krl; subr(29) = krr; + + /* generate KB dependent subkeys */ + subl(2) = krll; subr(2) = krlr; + subl(3) = krrl; subr(3) = krrr; + CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30); + subl(10) = krll; subr(10) = krlr; + subl(11) = krrl; subr(11) = krrr; + CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30); + subl(20) = krll; subr(20) = krlr; + subl(21) = krrl; subr(21) = krrr; + CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 51); + subl(32) = krll; subr(32) = krlr; + subl(33) = krrl; subr(33) = krrr; + + /* absorb kw2 to other subkeys */ + subl(3) ^= subl(1); subr(3) ^= subr(1); + subl(5) ^= subl(1); subr(5) ^= subr(1); + subl(7) ^= subl(1); subr(7) ^= subr(1); + subl(1) ^= subr(1) & ~subr(9); + dw = subl(1) & subl(9), subr(1) ^= CAMELLIA_RL1(dw); + subl(11) ^= subl(1); subr(11) ^= subr(1); + subl(13) ^= subl(1); subr(13) ^= subr(1); + subl(15) ^= subl(1); subr(15) ^= subr(1); + subl(1) ^= subr(1) & ~subr(17); + dw = subl(1) & subl(17), subr(1) ^= CAMELLIA_RL1(dw); + subl(19) ^= subl(1); subr(19) ^= subr(1); + subl(21) ^= subl(1); subr(21) ^= subr(1); + subl(23) ^= subl(1); subr(23) ^= subr(1); + subl(1) ^= subr(1) & ~subr(25); + dw = subl(1) & subl(25), subr(1) ^= CAMELLIA_RL1(dw); + subl(27) ^= subl(1); subr(27) ^= subr(1); + subl(29) ^= subl(1); subr(29) ^= subr(1); + subl(31) ^= subl(1); subr(31) ^= subr(1); + subl(32) ^= subl(1); subr(32) ^= subr(1); + + /* absorb kw4 to other subkeys */ + kw4l = subl(33); kw4r = subr(33); + subl(30) ^= kw4l; subr(30) ^= kw4r; + subl(28) ^= kw4l; subr(28) ^= kw4r; + subl(26) ^= kw4l; subr(26) ^= kw4r; + kw4l ^= kw4r & ~subr(24); + dw = kw4l & subl(24), kw4r ^= CAMELLIA_RL1(dw); + subl(22) ^= kw4l; subr(22) ^= kw4r; + subl(20) ^= kw4l; subr(20) ^= kw4r; + subl(18) ^= kw4l; subr(18) ^= kw4r; + kw4l ^= kw4r & ~subr(16); + dw = kw4l & subl(16), kw4r ^= CAMELLIA_RL1(dw); + subl(14) ^= kw4l; subr(14) ^= kw4r; + subl(12) ^= kw4l; subr(12) ^= kw4r; + subl(10) ^= kw4l; subr(10) ^= kw4r; + kw4l ^= kw4r & ~subr(8); + dw = kw4l & subl(8), kw4r ^= CAMELLIA_RL1(dw); + subl(6) ^= kw4l; subr(6) ^= kw4r; + subl(4) ^= kw4l; subr(4) ^= kw4r; + subl(2) ^= kw4l; subr(2) ^= kw4r; + subl(0) ^= kw4l; subr(0) ^= kw4r; + + /* key XOR is end of F-function */ + CamelliaSubkeyL(0) = subl(0) ^ subl(2); + CamelliaSubkeyR(0) = subr(0) ^ subr(2); + CamelliaSubkeyL(2) = subl(3); + CamelliaSubkeyR(2) = subr(3); + CamelliaSubkeyL(3) = subl(2) ^ subl(4); + CamelliaSubkeyR(3) = subr(2) ^ subr(4); + CamelliaSubkeyL(4) = subl(3) ^ subl(5); + CamelliaSubkeyR(4) = subr(3) ^ subr(5); + CamelliaSubkeyL(5) = subl(4) ^ subl(6); + CamelliaSubkeyR(5) = subr(4) ^ subr(6); + CamelliaSubkeyL(6) = subl(5) ^ subl(7); + CamelliaSubkeyR(6) = subr(5) ^ subr(7); + tl = subl(10) ^ (subr(10) & ~subr(8)); + dw = tl & subl(8), tr = subr(10) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(7) = subl(6) ^ tl; + CamelliaSubkeyR(7) = subr(6) ^ tr; + CamelliaSubkeyL(8) = subl(8); + CamelliaSubkeyR(8) = subr(8); + CamelliaSubkeyL(9) = subl(9); + CamelliaSubkeyR(9) = subr(9); + tl = subl(7) ^ (subr(7) & ~subr(9)); + dw = tl & subl(9), tr = subr(7) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(10) = tl ^ subl(11); + CamelliaSubkeyR(10) = tr ^ subr(11); + CamelliaSubkeyL(11) = subl(10) ^ subl(12); + CamelliaSubkeyR(11) = subr(10) ^ subr(12); + CamelliaSubkeyL(12) = subl(11) ^ subl(13); + CamelliaSubkeyR(12) = subr(11) ^ subr(13); + CamelliaSubkeyL(13) = subl(12) ^ subl(14); + CamelliaSubkeyR(13) = subr(12) ^ subr(14); + CamelliaSubkeyL(14) = subl(13) ^ subl(15); + CamelliaSubkeyR(14) = subr(13) ^ subr(15); + tl = subl(18) ^ (subr(18) & ~subr(16)); + dw = tl & subl(16), tr = subr(18) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(15) = subl(14) ^ tl; + CamelliaSubkeyR(15) = subr(14) ^ tr; + CamelliaSubkeyL(16) = subl(16); + CamelliaSubkeyR(16) = subr(16); + CamelliaSubkeyL(17) = subl(17); + CamelliaSubkeyR(17) = subr(17); + tl = subl(15) ^ (subr(15) & ~subr(17)); + dw = tl & subl(17), tr = subr(15) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(18) = tl ^ subl(19); + CamelliaSubkeyR(18) = tr ^ subr(19); + CamelliaSubkeyL(19) = subl(18) ^ subl(20); + CamelliaSubkeyR(19) = subr(18) ^ subr(20); + CamelliaSubkeyL(20) = subl(19) ^ subl(21); + CamelliaSubkeyR(20) = subr(19) ^ subr(21); + CamelliaSubkeyL(21) = subl(20) ^ subl(22); + CamelliaSubkeyR(21) = subr(20) ^ subr(22); + CamelliaSubkeyL(22) = subl(21) ^ subl(23); + CamelliaSubkeyR(22) = subr(21) ^ subr(23); + tl = subl(26) ^ (subr(26) & ~subr(24)); + dw = tl & subl(24), tr = subr(26) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(23) = subl(22) ^ tl; + CamelliaSubkeyR(23) = subr(22) ^ tr; + CamelliaSubkeyL(24) = subl(24); + CamelliaSubkeyR(24) = subr(24); + CamelliaSubkeyL(25) = subl(25); + CamelliaSubkeyR(25) = subr(25); + tl = subl(23) ^ (subr(23) & ~subr(25)); + dw = tl & subl(25), tr = subr(23) ^ CAMELLIA_RL1(dw); + CamelliaSubkeyL(26) = tl ^ subl(27); + CamelliaSubkeyR(26) = tr ^ subr(27); + CamelliaSubkeyL(27) = subl(26) ^ subl(28); + CamelliaSubkeyR(27) = subr(26) ^ subr(28); + CamelliaSubkeyL(28) = subl(27) ^ subl(29); + CamelliaSubkeyR(28) = subr(27) ^ subr(29); + CamelliaSubkeyL(29) = subl(28) ^ subl(30); + CamelliaSubkeyR(29) = subr(28) ^ subr(30); + CamelliaSubkeyL(30) = subl(29) ^ subl(31); + CamelliaSubkeyR(30) = subr(29) ^ subr(31); + CamelliaSubkeyL(31) = subl(30); + CamelliaSubkeyR(31) = subr(30); + CamelliaSubkeyL(32) = subl(32) ^ subl(31); + CamelliaSubkeyR(32) = subr(32) ^ subr(31); + + /* apply the inverse of the last half of P-function */ + dw = CamelliaSubkeyL(2) ^ CamelliaSubkeyR(2), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(2) = CamelliaSubkeyL(2) ^ dw, CamelliaSubkeyL(2) = dw; + dw = CamelliaSubkeyL(3) ^ CamelliaSubkeyR(3), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(3) = CamelliaSubkeyL(3) ^ dw, CamelliaSubkeyL(3) = dw; + dw = CamelliaSubkeyL(4) ^ CamelliaSubkeyR(4), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(4) = CamelliaSubkeyL(4) ^ dw, CamelliaSubkeyL(4) = dw; + dw = CamelliaSubkeyL(5) ^ CamelliaSubkeyR(5), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(5) = CamelliaSubkeyL(5) ^ dw, CamelliaSubkeyL(5) = dw; + dw = CamelliaSubkeyL(6) ^ CamelliaSubkeyR(6), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(6) = CamelliaSubkeyL(6) ^ dw, CamelliaSubkeyL(6) = dw; + dw = CamelliaSubkeyL(7) ^ CamelliaSubkeyR(7), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(7) = CamelliaSubkeyL(7) ^ dw, CamelliaSubkeyL(7) = dw; + dw = CamelliaSubkeyL(10) ^ CamelliaSubkeyR(10), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(10) = CamelliaSubkeyL(10) ^ dw, CamelliaSubkeyL(10) = dw; + dw = CamelliaSubkeyL(11) ^ CamelliaSubkeyR(11), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(11) = CamelliaSubkeyL(11) ^ dw, CamelliaSubkeyL(11) = dw; + dw = CamelliaSubkeyL(12) ^ CamelliaSubkeyR(12), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(12) = CamelliaSubkeyL(12) ^ dw, CamelliaSubkeyL(12) = dw; + dw = CamelliaSubkeyL(13) ^ CamelliaSubkeyR(13), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(13) = CamelliaSubkeyL(13) ^ dw, CamelliaSubkeyL(13) = dw; + dw = CamelliaSubkeyL(14) ^ CamelliaSubkeyR(14), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(14) = CamelliaSubkeyL(14) ^ dw, CamelliaSubkeyL(14) = dw; + dw = CamelliaSubkeyL(15) ^ CamelliaSubkeyR(15), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(15) = CamelliaSubkeyL(15) ^ dw, CamelliaSubkeyL(15) = dw; + dw = CamelliaSubkeyL(18) ^ CamelliaSubkeyR(18), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(18) = CamelliaSubkeyL(18) ^ dw, CamelliaSubkeyL(18) = dw; + dw = CamelliaSubkeyL(19) ^ CamelliaSubkeyR(19), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(19) = CamelliaSubkeyL(19) ^ dw, CamelliaSubkeyL(19) = dw; + dw = CamelliaSubkeyL(20) ^ CamelliaSubkeyR(20), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(20) = CamelliaSubkeyL(20) ^ dw, CamelliaSubkeyL(20) = dw; + dw = CamelliaSubkeyL(21) ^ CamelliaSubkeyR(21), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(21) = CamelliaSubkeyL(21) ^ dw, CamelliaSubkeyL(21) = dw; + dw = CamelliaSubkeyL(22) ^ CamelliaSubkeyR(22), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(22) = CamelliaSubkeyL(22) ^ dw, CamelliaSubkeyL(22) = dw; + dw = CamelliaSubkeyL(23) ^ CamelliaSubkeyR(23), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(23) = CamelliaSubkeyL(23) ^ dw, CamelliaSubkeyL(23) = dw; + dw = CamelliaSubkeyL(26) ^ CamelliaSubkeyR(26), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(26) = CamelliaSubkeyL(26) ^ dw, CamelliaSubkeyL(26) = dw; + dw = CamelliaSubkeyL(27) ^ CamelliaSubkeyR(27), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(27) = CamelliaSubkeyL(27) ^ dw, CamelliaSubkeyL(27) = dw; + dw = CamelliaSubkeyL(28) ^ CamelliaSubkeyR(28), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(28) = CamelliaSubkeyL(28) ^ dw, CamelliaSubkeyL(28) = dw; + dw = CamelliaSubkeyL(29) ^ CamelliaSubkeyR(29), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(29) = CamelliaSubkeyL(29) ^ dw, CamelliaSubkeyL(29) = dw; + dw = CamelliaSubkeyL(30) ^ CamelliaSubkeyR(30), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(30) = CamelliaSubkeyL(30) ^ dw, CamelliaSubkeyL(30) = dw; + dw = CamelliaSubkeyL(31) ^ CamelliaSubkeyR(31), dw = CAMELLIA_RL8(dw); + CamelliaSubkeyR(31) = CamelliaSubkeyL(31) ^ dw,CamelliaSubkeyL(31) = dw; + + return; +} + +void camellia_setup192(const unsigned char *key, u32 *subkey) +{ + unsigned char kk[32]; + u32 krll, krlr, krrl,krrr; + + memcpy(kk, key, 24); + memcpy((unsigned char *)&krll, key+16,4); + memcpy((unsigned char *)&krlr, key+20,4); + krrl = ~krll; + krrr = ~krlr; + memcpy(kk+24, (unsigned char *)&krrl, 4); + memcpy(kk+28, (unsigned char *)&krrr, 4); + camellia_setup256(kk, subkey); + return; +} + + +/** + * Stuff related to camellia encryption/decryption + * + * "io" must be 4byte aligned and big-endian data. + */ +void camellia_encrypt128(const u32 *subkey, u32 *io) +{ + u32 il, ir, t0, t1; + + /* pre whitening but absorb kw2*/ + io[0] ^= CamelliaSubkeyL(0); + io[1] ^= CamelliaSubkeyR(0); + /* main iteration */ + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[0],io[1],il,ir,t0,t1); + + /* post whitening but kw4 */ + io[2] ^= CamelliaSubkeyL(24); + io[3] ^= CamelliaSubkeyR(24); + + t0 = io[0]; + t1 = io[1]; + io[0] = io[2]; + io[1] = io[3]; + io[2] = t0; + io[3] = t1; + + return; +} + +void camellia_decrypt128(const u32 *subkey, u32 *io) +{ + u32 il,ir,t0,t1; /* temporary valiables */ + + /* pre whitening but absorb kw2*/ + io[0] ^= CamelliaSubkeyL(24); + io[1] ^= CamelliaSubkeyR(24); + + /* main iteration */ + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[0],io[1],il,ir,t0,t1); + + /* post whitening but kw4 */ + io[2] ^= CamelliaSubkeyL(0); + io[3] ^= CamelliaSubkeyR(0); + + t0 = io[0]; + t1 = io[1]; + io[0] = io[2]; + io[1] = io[3]; + io[2] = t0; + io[3] = t1; + + return; +} + +/** + * stuff for 192 and 256bit encryption/decryption + */ +void camellia_encrypt256(const u32 *subkey, u32 *io) +{ + u32 il,ir,t0,t1; /* temporary valiables */ + + /* pre whitening but absorb kw2*/ + io[0] ^= CamelliaSubkeyL(0); + io[1] ^= CamelliaSubkeyR(0); + + /* main iteration */ + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(24),CamelliaSubkeyR(24), + CamelliaSubkeyL(25),CamelliaSubkeyR(25), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(26),CamelliaSubkeyR(26), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(27),CamelliaSubkeyR(27), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(28),CamelliaSubkeyR(28), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(29),CamelliaSubkeyR(29), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(30),CamelliaSubkeyR(30), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(31),CamelliaSubkeyR(31), + io[0],io[1],il,ir,t0,t1); + + /* post whitening but kw4 */ + io[2] ^= CamelliaSubkeyL(32); + io[3] ^= CamelliaSubkeyR(32); + + t0 = io[0]; + t1 = io[1]; + io[0] = io[2]; + io[1] = io[3]; + io[2] = t0; + io[3] = t1; + + return; +} + +void camellia_decrypt256(const u32 *subkey, u32 *io) +{ + u32 il,ir,t0,t1; /* temporary valiables */ + + /* pre whitening but absorb kw2*/ + io[0] ^= CamelliaSubkeyL(32); + io[1] ^= CamelliaSubkeyR(32); + + /* main iteration */ + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(31),CamelliaSubkeyR(31), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(30),CamelliaSubkeyR(30), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(29),CamelliaSubkeyR(29), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(28),CamelliaSubkeyR(28), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(27),CamelliaSubkeyR(27), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(26),CamelliaSubkeyR(26), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(25),CamelliaSubkeyR(25), + CamelliaSubkeyL(24),CamelliaSubkeyR(24), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(23),CamelliaSubkeyR(23), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(22),CamelliaSubkeyR(22), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(21),CamelliaSubkeyR(21), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(20),CamelliaSubkeyR(20), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(19),CamelliaSubkeyR(19), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(18),CamelliaSubkeyR(18), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(17),CamelliaSubkeyR(17), + CamelliaSubkeyL(16),CamelliaSubkeyR(16), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(15),CamelliaSubkeyR(15), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(14),CamelliaSubkeyR(14), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(13),CamelliaSubkeyR(13), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(12),CamelliaSubkeyR(12), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(11),CamelliaSubkeyR(11), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(10),CamelliaSubkeyR(10), + io[0],io[1],il,ir,t0,t1); + + CAMELLIA_FLS(io[0],io[1],io[2],io[3], + CamelliaSubkeyL(9),CamelliaSubkeyR(9), + CamelliaSubkeyL(8),CamelliaSubkeyR(8), + t0,t1,il,ir); + + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(7),CamelliaSubkeyR(7), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(6),CamelliaSubkeyR(6), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(5),CamelliaSubkeyR(5), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(4),CamelliaSubkeyR(4), + io[0],io[1],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[0],io[1], + CamelliaSubkeyL(3),CamelliaSubkeyR(3), + io[2],io[3],il,ir,t0,t1); + CAMELLIA_ROUNDSM(io[2],io[3], + CamelliaSubkeyL(2),CamelliaSubkeyR(2), + io[0],io[1],il,ir,t0,t1); + + /* post whitening but kw4 */ + io[2] ^= CamelliaSubkeyL(0); + io[3] ^= CamelliaSubkeyR(0); + + t0 = io[0]; + t1 = io[1]; + io[0] = io[2]; + io[1] = io[3]; + io[2] = t0; + io[3] = t1; + + return; +} + +/*** + * + * API for compatibility + */ + +void Camellia_Ekeygen(const int keyBitLength, + const unsigned char *rawKey, + KEY_TABLE_TYPE keyTable) +{ + switch(keyBitLength) { + case 128: + camellia_setup128(rawKey, keyTable); + break; + case 192: + camellia_setup192(rawKey, keyTable); + break; + case 256: + camellia_setup256(rawKey, keyTable); + break; + default: + break; + } +} + + +void Camellia_EncryptBlock(const int keyBitLength, + const unsigned char *plaintext, + const KEY_TABLE_TYPE keyTable, + unsigned char *ciphertext) +{ + u32 tmp[4]; + + tmp[0] = GETU32(plaintext); + tmp[1] = GETU32(plaintext + 4); + tmp[2] = GETU32(plaintext + 8); + tmp[3] = GETU32(plaintext + 12); + + switch (keyBitLength) { + case 128: + camellia_encrypt128(keyTable, tmp); + break; + case 192: + /* fall through */ + case 256: + camellia_encrypt256(keyTable, tmp); + break; + default: + break; + } + + PUTU32(ciphertext, tmp[0]); + PUTU32(ciphertext + 4, tmp[1]); + PUTU32(ciphertext + 8, tmp[2]); + PUTU32(ciphertext + 12, tmp[3]); +} + +void Camellia_DecryptBlock(const int keyBitLength, + const unsigned char *ciphertext, + const KEY_TABLE_TYPE keyTable, + unsigned char *plaintext) +{ + u32 tmp[4]; + + tmp[0] = GETU32(ciphertext); + tmp[1] = GETU32(ciphertext + 4); + tmp[2] = GETU32(ciphertext + 8); + tmp[3] = GETU32(ciphertext + 12); + + switch (keyBitLength) { + case 128: + camellia_decrypt128(keyTable, tmp); + break; + case 192: + /* fall through */ + case 256: + camellia_decrypt256(keyTable, tmp); + break; + default: + break; + } + PUTU32(plaintext, tmp[0]); + PUTU32(plaintext + 4, tmp[1]); + PUTU32(plaintext + 8, tmp[2]); + PUTU32(plaintext + 12, tmp[3]); +} Added: trunk/cipher/camellia.h =================================================================== --- trunk/cipher/camellia.h 2007-05-02 06:27:11 UTC (rev 1242) +++ trunk/cipher/camellia.h 2007-05-02 06:28:23 UTC (rev 1243) @@ -0,0 +1,54 @@ +/* camellia.h ver 1.2.0 + * + * Copyright (C) 2006,2007 + * NTT (Nippon Telegraph and Telephone Corporation). + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef HEADER_CAMELLIA_H +#define HEADER_CAMELLIA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAMELLIA_BLOCK_SIZE 16 +#define CAMELLIA_TABLE_BYTE_LEN 272 +#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) + +typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; + + +void Camellia_Ekeygen(const int keyBitLength, + const unsigned char *rawKey, + KEY_TABLE_TYPE keyTable); + +void Camellia_EncryptBlock(const int keyBitLength, + const unsigned char *plaintext, + const KEY_TABLE_TYPE keyTable, + unsigned char *cipherText); + +void Camellia_DecryptBlock(const int keyBitLength, + const unsigned char *cipherText, + const KEY_TABLE_TYPE keyTable, + unsigned char *plaintext); + + +#ifdef __cplusplus +} +#endif + +#endif /* HEADER_CAMELLIA_H */ From cvs at cvs.gnupg.org Wed May 2 11:47:22 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 May 2007 11:47:22 +0200 Subject: [svn] gcry - r1244 - in trunk: . cipher src Message-ID: Author: wk Date: 2007-05-02 11:46:53 +0200 (Wed, 02 May 2007) New Revision: 1244 Modified: trunk/AUTHORS trunk/ChangeLog trunk/NEWS trunk/README trunk/cipher/ChangeLog trunk/cipher/camellia-glue.c trunk/cipher/camellia.h trunk/configure.ac trunk/src/ChangeLog trunk/src/global.c Log: More info from GCRYCTL_PRINT_CONFIG. Put Camellia symbols into our namespace. Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/AUTHORS 2007-05-02 09:46:53 UTC (rev 1244) @@ -73,18 +73,22 @@ (Added OFB mode. Changed cipher/cipher.c, test/basic.c doc/gcrypt.tex. added SHA-224, changed cipher/sha256.c, added HMAC tests.) - LIBGCRYPT Hye-Shik Chang 2006-09-07 Assigns Past and Future Changes perky at freebsd.org (SEED cipher) - LIBGCRYPT Werner Dittmann ** pending ** werner.dittmann at t-online.de (mpi/amd64, tests/mpitests.c) +GNUPG David Shaw +Assigns past and future changes. +dshaw at jabberwocky.com> +(cipher/camellia-glue.c and related stuff) + + More credits ============ The ATH implementation (src/ath*) has been taken from GPGME and @@ -101,9 +105,12 @@ The ECC code cipher/ecc.c was based on code by Sergi Blanch i Torne, sergi at calcurco dot org. +The implementation of the Camellia cipher has been been taken from the +original NTT provided GPL source. + Copyright 1998, 1999, 2000, 2001, 2002, 2003, - 2006 Free Software Foundation, Inc. + 2006, 2007 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/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/ChangeLog 2007-05-02 09:46:53 UTC (rev 1244) @@ -1,3 +1,8 @@ +2007-05-02 Werner Koch + + * configure.ac (LIBGCRYPT_DIGESTS, LIBGCRYPT_CIPHERS) + (LIBGCRYPT_PUBKEY_CIPHERS): Ac_define lists of algorithms. + 2007-05-02 David Shaw * NEWS, configure.ac: Add Camellia. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/NEWS 2007-05-02 09:46:53 UTC (rev 1244) @@ -43,8 +43,13 @@ * Assembler support for the AMD64 architecture. + * New configure option --enable-mpi-path for optimized builds. + * Experimental support for ECDSA; should only be used for testing. + * New control code GCRYCTL_PRINT_CONFIG to print the build + configuration. + * Minor changes to some function declarations. Buffer arguments are now typed as void pointer. This should not affect any compilation. Fixed two bugs in return values and clarified documentation. Modified: trunk/README =================================================================== --- trunk/README 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/README 2007-05-02 09:46:53 UTC (rev 1244) @@ -23,7 +23,7 @@ Libgcrypt is a general purpose crypto library based on the code used in GnuPG. We can't start with a new version number because - libgcrypt was part of gnupg 1.1 and some applications already used + libgcrypt was part of GnuPG 1.1 and some applications already used it and tested for the version number. We believe that the API can stay as it is, except that new functions may be added in the future. @@ -56,6 +56,7 @@ rndw32 - Entropy gatherer for MS Windows gcryptrnd - The random number daemon. getrandom - A client for that daemon. + camellia - The Camellia cipher. The documentation is available under the terms of the GPL. @@ -112,7 +113,10 @@ features not provided by the system, like 64bit data types. With these switches it is possible to select exactly those algorithm modules, which - should be built. + should be built. The algorithms are to be + separated by spaces, commas or colons. To view + the list used with the current build the program + tests/version may be used. --disable-endian-check Don't let configure test for the endianness but @@ -121,10 +125,35 @@ --enable-random-daemon Include support for a global random damon and - build the daemon. The daemon itself is in an - experimental state. + build the daemon. This is an experimental feature. + --enable-mpi-path=EXTRA_PATH + Prepend EXTRA_PATH to list of CPU specific + optimizations. For example, if you want to add + optimizations forn a Intel Pentium 4 compatible + CPU, you may use + --enable-mpi-path="pentium4/sse2 pentium4/mmx" + Take care: The generated library may crash on + non-compatible CPUs + --enable-random=NAME + Force the use of the random gathering module + NAME. Default is either to use /dev/random or + the auto mode. Possible values for NAME are: + egd - Use the module which accesses the + Entropy Gathering Daemon. See the webpages + for more information about it. + unix - Use the standard Unix module which does not + have a very good performance. + linux - Use the module which accesses /dev/random. + This is the first choice and the default one + for GNU/Linux or *BSD. + auto - Compile linux, egd and unix in and + automagically select at runtime. + + + + Contact ------- Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/cipher/ChangeLog 2007-05-02 09:46:53 UTC (rev 1244) @@ -1,3 +1,7 @@ +2007-05-02 Werner Koch + + * camellia.h: Redefine external symbols. + 2007-05-02 David Shaw * Makefile.am, cipher.c: Add Camellia. Modified: trunk/cipher/camellia-glue.c =================================================================== --- trunk/cipher/camellia-glue.c 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/cipher/camellia-glue.c 2007-05-02 09:46:53 UTC (rev 1244) @@ -22,8 +22,26 @@ /* I put all the libgcrypt-specific stuff in this file to keep the camellia.c/camellia.h files exactly as provided by NTT. If they update their code, this should make it easier to bring the changes - in. - dshaw */ + in. - dshaw + There is one small change which needs to be done: Include the + following code at the top of camellia.h: */ +#if 0 +/* Need to redefine the external symbols to keep the libgcrypt name + space clean. */ +#define Camellia_Ekeygen _gcry_Camellia_Ekeygen +#define Camellia_EncryptBlock _gcry_Camellia_EncryptBlock +#define Camellia_DecryptBlock _gcry_Camellia_DecryptBlock +#define camellia_decrypt128 _gcry_camellia_decrypt128 +#define camellia_decrypt256 _gcry_camellia_decrypt256 +#define camellia_encrypt128 _gcry_camellia_encrypt128 +#define camellia_encrypt256 _gcry_camellia_encrypt256 +#define camellia_setup128 _gcry_camellia_setup128 +#define camellia_setup192 _gcry_camellia_setup192 +#define camellia_setup256 _gcry_camellia_setup256 +#endif /* Code sample. */ + + #include #include "types.h" #include "g10lib.h" Modified: trunk/cipher/camellia.h =================================================================== --- trunk/cipher/camellia.h 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/cipher/camellia.h 2007-05-02 09:46:53 UTC (rev 1244) @@ -21,6 +21,20 @@ #ifndef HEADER_CAMELLIA_H #define HEADER_CAMELLIA_H +/* Need to redefine the external symbols to keep the libgcrypt name + space clean. */ +#define Camellia_Ekeygen _gcry_Camellia_Ekeygen +#define Camellia_EncryptBlock _gcry_Camellia_EncryptBlock +#define Camellia_DecryptBlock _gcry_Camellia_DecryptBlock +#define camellia_decrypt128 _gcry_camellia_decrypt128 +#define camellia_decrypt256 _gcry_camellia_decrypt256 +#define camellia_encrypt128 _gcry_camellia_encrypt128 +#define camellia_encrypt256 _gcry_camellia_encrypt256 +#define camellia_setup128 _gcry_camellia_setup128 +#define camellia_setup192 _gcry_camellia_setup192 +#define camellia_setup256 _gcry_camellia_setup256 + + #ifdef __cplusplus extern "C" { #endif Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/configure.ac 2007-05-02 09:46:53 UTC (rev 1244) @@ -132,6 +132,7 @@ # Definitions for symmetric ciphers. available_ciphers="arcfour blowfish cast5 des aes twofish serpent rfc2268 seed" +available_ciphers="$available_ciphers camellia" enabled_ciphers="" # Definitions for public-key ciphers. @@ -312,7 +313,7 @@ AC_ARG_ENABLE(ciphers, AC_HELP_STRING([--enable-ciphers=ciphers], [select the symmetric ciphers to include]), - [enabled_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`], + [enabled_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`], [enabled_ciphers=""]) if test "x$enabled_ciphers" = "x" \ -o "$enabled_ciphers" = "yes" \ @@ -323,7 +324,7 @@ for cipher in $enabled_ciphers; do LIST_MEMBER($cipher, $available_ciphers) if test "$found" = "0"; then - AC_MSG_ERROR([unsupported cipher specified]) + AC_MSG_ERROR([unsupported cipher "$cipher" specified]) fi done AC_MSG_RESULT([$enabled_ciphers]) @@ -332,7 +333,7 @@ AC_ARG_ENABLE(pubkey-ciphers, AC_HELP_STRING([--enable-pubkey-ciphers=ciphers], [select the public-key ciphers to include]), - [enabled_pubkey_ciphers=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`], + [enabled_pubkey_ciphers=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`], [enabled_pubkey_ciphers=""]) if test "x$enabled_pubkey_ciphers" = "x" \ -o "$enabled_pubkey_ciphers" = "yes" \ @@ -352,7 +353,7 @@ AC_ARG_ENABLE(digests, AC_HELP_STRING([--enable-digests=digests], [select the message digests to include]), - [enabled_digests=`echo $enableval | tr , ' ' | tr '[A-Z]' '[a-z]'`], + [enabled_digests=`echo $enableval | tr ',:' ' ' | tr '[A-Z]' '[a-z]'`], [enabled_digests=""]) if test "x$enabled_digests" = "x" \ -o "$enabled_digests" = "yes" \ @@ -913,7 +914,20 @@ AC_SUBST(LIBGCRYPT_PUBKEY_CIPHERS, $enabled_pubkey_ciphers) AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests) +# For printing the configuration we need a colon separated list of +# algorithm names. +tmp=`echo "$enabled_ciphers" | tr ' ' : ` +AC_DEFINE_UNQUOTED(LIBGCRYPT_CIPHERS, "$tmp", + [List of available cipher algorithms]) +tmp=`echo "$enabled_pubkey_ciphers" | tr ' ' : ` +AC_DEFINE_UNQUOTED(LIBGCRYPT_PUBKEY_CIPHERS, "$tmp", + [List of available public key cipher algorithms]) +tmp=`echo "$enabled_digests" | tr ' ' : ` +AC_DEFINE_UNQUOTED(LIBGCRYPT_DIGESTS, "$tmp", + [List of available digest algorithms]) + + # Generate extended version information for W32. if test "$have_w32_system" = yes; then BUILD_TIMESTAMP=`date --iso-8601=minutes` Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/src/ChangeLog 2007-05-02 09:46:53 UTC (rev 1244) @@ -1,3 +1,7 @@ +2007-05-02 Werner Koch + + * global.c (print_config): Print ciphers, digests and pubkeys. + 2007-05-02 David Shaw * cipher.h, gcrypt.h.in: Add Camellia. Modified: trunk/src/global.c =================================================================== --- trunk/src/global.c 2007-05-02 06:28:23 UTC (rev 1243) +++ trunk/src/global.c 2007-05-02 09:46:53 UTC (rev 1244) @@ -202,7 +202,9 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp) { fnc (fp, "version:%s:\n", VERSION); - fnc (fp, "mpi-asm:%s:\n", _gcry_mpi_get_hw_config ()); + fnc (fp, "ciphers:%s:\n", LIBGCRYPT_CIPHERS); + fnc (fp, "pubkeys:%s:\n", LIBGCRYPT_PUBKEY_CIPHERS); + fnc (fp, "digests:%s:\n", LIBGCRYPT_DIGESTS); fnc (fp, "rnd-mod:" #if USE_RNDEGD "egd:" @@ -217,7 +219,7 @@ "w32:" #endif "\n"); - + fnc (fp, "mpi-asm:%s:\n", _gcry_mpi_get_hw_config ()); } From cvs at cvs.gnupg.org Wed May 2 12:19:14 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 May 2007 12:19:14 +0200 Subject: [svn] gcry - r1245 - trunk/cipher Message-ID: Author: wk Date: 2007-05-02 12:18:46 +0200 (Wed, 02 May 2007) New Revision: 1245 Modified: trunk/cipher/ChangeLog trunk/cipher/camellia-glue.c Log: Changed amount of stack to burn Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-05-02 09:46:53 UTC (rev 1244) +++ trunk/cipher/ChangeLog 2007-05-02 10:18:46 UTC (rev 1245) @@ -1,5 +1,8 @@ 2007-05-02 Werner Koch + * camellia-glue.c (camellia_setkey, camellia_encrypt) + (camellia_decrypt): Recalculated used stack size in called + functions. * camellia.h: Redefine external symbols. 2007-05-02 David Shaw Modified: trunk/cipher/camellia-glue.c =================================================================== --- trunk/cipher/camellia-glue.c 2007-05-02 09:46:53 UTC (rev 1244) +++ trunk/cipher/camellia-glue.c 2007-05-02 10:18:46 UTC (rev 1245) @@ -79,7 +79,12 @@ ctx->keybitlength=keylen*8; Camellia_Ekeygen(ctx->keybitlength,key,ctx->keytable); - _gcry_burn_stack(4+4+6+34+34+sizeof(unsigned char *)+sizeof(u32 *)); + _gcry_burn_stack + ((19+34+34)*sizeof(u32)+2*sizeof(void*) /* camellia_setup256 */ + +(4+32)*sizeof(u32)+2*sizeof(void*) /* camellia_setup192 */ + +0+sizeof(int)+2*sizeof(void*) /* Camellia_Ekeygen */ + +3*2*sizeof(void*) /* Function calls. */ + ); return 0; } @@ -90,9 +95,12 @@ CAMELLIA_context *ctx=c; Camellia_EncryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf); - _gcry_burn_stack(sizeof(int)+sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE) - +sizeof(unsigned char *)+16+4+4+4+4+sizeof(u32 *) - +sizeof(u32 *)); + _gcry_burn_stack + (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE) + +4*sizeof(u32) + +2*sizeof(u32*)+4*sizeof(u32) + +2*2*sizeof(void*) /* Function calls. */ + ); } static void @@ -101,9 +109,12 @@ CAMELLIA_context *ctx=c; Camellia_DecryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf); - _gcry_burn_stack(sizeof(int)+sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE) - +sizeof(unsigned char *)+16+4+4+4+4+sizeof(u32 *) - +sizeof(u32 *)); + _gcry_burn_stack + (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE) + +4*sizeof(u32) + +2*sizeof(u32*)+4*sizeof(u32) + +2*2*sizeof(void*) /* Function calls. */ + ); } static const char * From cvs at cvs.gnupg.org Wed May 2 19:19:26 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 02 May 2007 19:19:26 +0200 Subject: [svn] gcry - r1246 - trunk Message-ID: Author: wk Date: 2007-05-02 19:18:57 +0200 (Wed, 02 May 2007) New Revision: 1246 Modified: trunk/ChangeLog trunk/configure.ac Log: Do not make Camellia a default cipher Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-02 10:18:46 UTC (rev 1245) +++ trunk/ChangeLog 2007-05-02 17:18:57 UTC (rev 1246) @@ -2,6 +2,7 @@ * configure.ac (LIBGCRYPT_DIGESTS, LIBGCRYPT_CIPHERS) (LIBGCRYPT_PUBKEY_CIPHERS): Ac_define lists of algorithms. + (default_ciphers): Don't make camellia a default. 2007-05-02 David Shaw Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-02 10:18:46 UTC (rev 1245) +++ trunk/configure.ac 2007-05-02 17:18:57 UTC (rev 1246) @@ -300,8 +300,8 @@ fi # If not specified otherwise, all available algorithms will be -# included. -default_ciphers="$available_ciphers" +# included. Except for Camellia which is GPLed. +default_ciphers=`echo "$available_ciphers" | sed 's/ camellia//'` default_pubkey_ciphers="$available_pubkey_ciphers" default_digests="$available_digests" From cvs at cvs.gnupg.org Wed May 2 19:21:16 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 02 May 2007 19:21:16 +0200 Subject: [svn] GnuPG - r4490 - branches/STABLE-BRANCH-1-4/checks Message-ID: Author: dshaw Date: 2007-05-02 19:20:45 +0200 (Wed, 02 May 2007) New Revision: 4490 Modified: branches/STABLE-BRANCH-1-4/checks/ChangeLog branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test branches/STABLE-BRANCH-1-4/checks/conventional.test branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test branches/STABLE-BRANCH-1-4/checks/encrypt.test Log: * conventional.test, encrypt.test, encrypt-dsa.test, conventional-mdc.test: Fix some broken tests that were only testing 3DES instead of all available ciphers. Modified: branches/STABLE-BRANCH-1-4/checks/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/checks/ChangeLog 2007-04-28 16:04:44 UTC (rev 4489) +++ branches/STABLE-BRANCH-1-4/checks/ChangeLog 2007-05-02 17:20:45 UTC (rev 4490) @@ -1,3 +1,9 @@ +2007-05-02 David Shaw + + * conventional.test, encrypt.test, encrypt-dsa.test, + conventional-mdc.test: Fix some broken tests that were only + testing 3DES instead of all available ciphers. + 2007-03-04 David Shaw * verify.test: Use --allow-multiple-messages instead of Modified: branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test 2007-04-28 16:04:44 UTC (rev 4489) +++ branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test 2007-05-02 17:20:45 UTC (rev 4490) @@ -4,23 +4,23 @@ algos="3des" -if have_cipher_algo "idea"; then +if have_cipher_algo "IDEA"; then algos="$algos idea" fi -if have_cipher_algo "cast5"; then - algos="$algos idea" +if have_cipher_algo "CAST5"; then + algos="$algos cast5" fi -if have_cipher_algo "blowfish"; then - algos="$algos idea" +if have_cipher_algo "BLOWFISH"; then + algos="$algos blowfish" fi -if have_cipher_algo "aes"; then +if have_cipher_algo "AES"; then algos="$algos aes aes192 aes256" fi -if have_cipher_algo "twofish"; then +if have_cipher_algo "TWOFISH"; then algos="$algos twofish" fi Modified: branches/STABLE-BRANCH-1-4/checks/conventional.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/conventional.test 2007-04-28 16:04:44 UTC (rev 4489) +++ branches/STABLE-BRANCH-1-4/checks/conventional.test 2007-05-02 17:20:45 UTC (rev 4490) @@ -11,6 +11,10 @@ algos="3des" +if have_cipher_algo "IDEA"; then + algos="$algos idea" +fi + if have_cipher_algo "CAST5"; then algos="$algos cast5" fi Modified: branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test 2007-04-28 16:04:44 UTC (rev 4489) +++ branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test 2007-05-02 17:20:45 UTC (rev 4490) @@ -11,23 +11,23 @@ algos="3des" -if have_cipher_algo "idea"; then +if have_cipher_algo "IDEA"; then algos="$algos idea" fi -if have_cipher_algo "cast5"; then - algos="$algos idea" +if have_cipher_algo "CAST5"; then + algos="$algos cast5" fi -if have_cipher_algo "blowfish"; then - algos="$algos idea" +if have_cipher_algo "BLOWFISH"; then + algos="$algos blowfish" fi -if have_cipher_algo "aes"; then +if have_cipher_algo "AES"; then algos="$algos aes aes192 aes256" fi -if have_cipher_algo "twofish"; then +if have_cipher_algo "TWOFISH"; then algos="$algos twofish" fi Modified: branches/STABLE-BRANCH-1-4/checks/encrypt.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/encrypt.test 2007-04-28 16:04:44 UTC (rev 4489) +++ branches/STABLE-BRANCH-1-4/checks/encrypt.test 2007-05-02 17:20:45 UTC (rev 4490) @@ -11,23 +11,23 @@ algos="3des" -if have_cipher_algo "idea"; then +if have_cipher_algo "IDEA"; then algos="$algos idea" fi -if have_cipher_algo "cast5"; then - algos="$algos idea" +if have_cipher_algo "CAST5"; then + algos="$algos cast5" fi -if have_cipher_algo "blowfish"; then - algos="$algos idea" +if have_cipher_algo "BLOWFISH"; then + algos="$algos blowfish" fi -if have_cipher_algo "aes"; then +if have_cipher_algo "AES"; then algos="$algos aes aes192 aes256" fi -if have_cipher_algo "twofish"; then +if have_cipher_algo "TWOFISH"; then algos="$algos twofish" fi From cvs at cvs.gnupg.org Thu May 3 02:54:59 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 03 May 2007 02:54:59 +0200 Subject: [svn] GnuPG - r4491 - trunk/tests/openpgp Message-ID: Author: dshaw Date: 2007-05-03 02:54:28 +0200 (Thu, 03 May 2007) New Revision: 4491 Modified: trunk/tests/openpgp/ChangeLog trunk/tests/openpgp/conventional-mdc.test trunk/tests/openpgp/conventional.test trunk/tests/openpgp/encrypt-dsa.test trunk/tests/openpgp/encrypt.test Log: * conventional.test, encrypt.test, encrypt-dsa.test, conventional-mdc.test: Fix some broken tests that were only testing 3DES instead of all available ciphers. Modified: trunk/tests/openpgp/ChangeLog =================================================================== --- trunk/tests/openpgp/ChangeLog 2007-05-02 17:20:45 UTC (rev 4490) +++ trunk/tests/openpgp/ChangeLog 2007-05-03 00:54:28 UTC (rev 4491) @@ -1,3 +1,9 @@ +2007-05-02 David Shaw + + * conventional.test, encrypt.test, encrypt-dsa.test, + conventional-mdc.test: Fix some broken tests that were only + testing 3DES instead of all available ciphers. + 2007-03-04 David Shaw (wk) * verify.test: Use --allow-multiple-messages instead of Modified: trunk/tests/openpgp/conventional-mdc.test =================================================================== --- trunk/tests/openpgp/conventional-mdc.test 2007-05-02 17:20:45 UTC (rev 4490) +++ trunk/tests/openpgp/conventional-mdc.test 2007-05-03 00:54:28 UTC (rev 4491) @@ -4,23 +4,23 @@ algos="3des" -if have_cipher_algo "idea"; then +if have_cipher_algo "IDEA"; then algos="$algos idea" fi -if have_cipher_algo "cast5"; then - algos="$algos idea" +if have_cipher_algo "CAST5"; then + algos="$algos cast5" fi -if have_cipher_algo "blowfish"; then - algos="$algos idea" +if have_cipher_algo "BLOWFISH"; then + algos="$algos blowfish" fi -if have_cipher_algo "aes"; then +if have_cipher_algo "AES"; then algos="$algos aes aes192 aes256" fi -if have_cipher_algo "twofish"; then +if have_cipher_algo "TWOFISH"; then algos="$algos twofish" fi Modified: trunk/tests/openpgp/conventional.test =================================================================== --- trunk/tests/openpgp/conventional.test 2007-05-02 17:20:45 UTC (rev 4490) +++ trunk/tests/openpgp/conventional.test 2007-05-03 00:54:28 UTC (rev 4491) @@ -11,6 +11,10 @@ algos="3des" +if have_cipher_algo "IDEA"; then + algos="$algos idea" +fi + if have_cipher_algo "CAST5"; then algos="$algos cast5" fi Modified: trunk/tests/openpgp/encrypt-dsa.test =================================================================== --- trunk/tests/openpgp/encrypt-dsa.test 2007-05-02 17:20:45 UTC (rev 4490) +++ trunk/tests/openpgp/encrypt-dsa.test 2007-05-03 00:54:28 UTC (rev 4491) @@ -11,23 +11,23 @@ algos="3des" -if have_cipher_algo "idea"; then +if have_cipher_algo "IDEA"; then algos="$algos idea" fi -if have_cipher_algo "cast5"; then - algos="$algos idea" +if have_cipher_algo "CAST5"; then + algos="$algos cast5" fi -if have_cipher_algo "blowfish"; then - algos="$algos idea" +if have_cipher_algo "BLOWFISH"; then + algos="$algos blowfish" fi -if have_cipher_algo "aes"; then +if have_cipher_algo "AES"; then algos="$algos aes aes192 aes256" fi -if have_cipher_algo "twofish"; then +if have_cipher_algo "TWOFISH"; then algos="$algos twofish" fi Modified: trunk/tests/openpgp/encrypt.test =================================================================== --- trunk/tests/openpgp/encrypt.test 2007-05-02 17:20:45 UTC (rev 4490) +++ trunk/tests/openpgp/encrypt.test 2007-05-03 00:54:28 UTC (rev 4491) @@ -11,23 +11,23 @@ algos="3des" -if have_cipher_algo "idea"; then +if have_cipher_algo "IDEA"; then algos="$algos idea" fi -if have_cipher_algo "cast5"; then - algos="$algos idea" +if have_cipher_algo "CAST5"; then + algos="$algos cast5" fi -if have_cipher_algo "blowfish"; then - algos="$algos idea" +if have_cipher_algo "BLOWFISH"; then + algos="$algos blowfish" fi -if have_cipher_algo "aes"; then +if have_cipher_algo "AES"; then algos="$algos aes aes192 aes256" fi -if have_cipher_algo "twofish"; then +if have_cipher_algo "TWOFISH"; then algos="$algos twofish" fi From cvs at cvs.gnupg.org Thu May 3 06:44:42 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 03 May 2007 06:44:42 +0200 Subject: [svn] GnuPG - r4492 - trunk/g10 Message-ID: Author: dshaw Date: 2007-05-03 06:44:12 +0200 (Thu, 03 May 2007) New Revision: 4492 Modified: trunk/g10/ChangeLog trunk/g10/decrypt.c trunk/g10/mainproc.c trunk/g10/packet.h trunk/g10/verify.c Log: * packet.h, mainproc.c (reset_literals_seen): New function to reset the literals count. * verify.c (verify_one_file), decrypt.c (decrypt_messages): Call it here so we allow multiple literals in --multifile mode (in different files - not concatenated together). Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-05-03 00:54:28 UTC (rev 4491) +++ trunk/g10/ChangeLog 2007-05-03 04:44:12 UTC (rev 4492) @@ -1,3 +1,12 @@ +2007-05-02 David Shaw + + * packet.h, mainproc.c (reset_literals_seen): New function to + reset the literals count. + + * verify.c (verify_one_file), decrypt.c (decrypt_messages): Call + it here so we allow multiple literals in --multifile mode (in + different files - not concatenated together). + 2007-04-26 Marcus Brinkmann * passphrase.c (passphrase_to_dek): Write missing passphrase Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2007-05-03 00:54:28 UTC (rev 4491) +++ trunk/g10/decrypt.c 2007-05-03 04:44:12 UTC (rev 4492) @@ -1,6 +1,6 @@ /* decrypt.c - verify signed data - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 - * 2004 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + * 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -192,6 +192,7 @@ /* Note that we emit file_done even after an error. */ write_status( STATUS_FILE_DONE ); xfree(output); + reset_literals_seen(); } set_next_passphrase(NULL); Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2007-05-03 00:54:28 UTC (rev 4491) +++ trunk/g10/mainproc.c 2007-05-03 04:44:12 UTC (rev 4492) @@ -1,6 +1,6 @@ /* mainproc.c - handle packets - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005, 2006 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + * 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -102,6 +102,12 @@ static void proc_tree( CTX c, KBNODE node ); static int literals_seen; +void +reset_literals_seen(void) +{ + literals_seen=0; +} + static void release_list( CTX c ) { Modified: trunk/g10/packet.h =================================================================== --- trunk/g10/packet.h 2007-05-03 00:54:28 UTC (rev 4491) +++ trunk/g10/packet.h 2007-05-03 04:44:12 UTC (rev 4492) @@ -1,6 +1,6 @@ /* packet.h - OpenPGP packet definitions - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + * 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -368,6 +368,7 @@ }; /*-- mainproc.c --*/ +void reset_literals_seen(void); int proc_packets( void *ctx, iobuf_t a ); int proc_signature_packets( void *ctx, iobuf_t a, strlist_t signedfiles, const char *sigfile ); Modified: trunk/g10/verify.c =================================================================== --- trunk/g10/verify.c 2007-05-03 00:54:28 UTC (rev 4491) +++ trunk/g10/verify.c 2007-05-03 04:44:12 UTC (rev 4492) @@ -1,5 +1,6 @@ /* verify.c - Verify signed data - * Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, + * 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -178,6 +179,8 @@ iobuf_close(fp); write_status( STATUS_FILE_DONE ); + reset_literals_seen(); + leave: release_armor_context (afx); release_progress_context (pfx); From cvs at cvs.gnupg.org Thu May 3 22:33:11 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 03 May 2007 22:33:11 +0200 Subject: [svn] gcry - r1247 - in trunk: . mpi mpi/pentium4 src tests Message-ID: Author: wk Date: 2007-05-03 22:32:42 +0200 (Thu, 03 May 2007) New Revision: 1247 Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/configure.ac trunk/mpi/ChangeLog trunk/mpi/pentium4/distfiles trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/libgcrypt.def trunk/src/versioninfo.rc.in trunk/tests/ChangeLog trunk/tests/Makefile.am Log: Minor fixes for W32 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/ChangeLog 2007-05-03 20:32:42 UTC (rev 1247) @@ -1,3 +1,7 @@ +2007-05-03 Werner Koch + + * configure.ac: Fix detection of GPLed random modules. + 2007-05-02 Werner Koch * configure.ac (LIBGCRYPT_DIGESTS, LIBGCRYPT_CIPHERS) Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/NEWS 2007-05-03 20:32:42 UTC (rev 1247) @@ -469,7 +469,7 @@ into into libgcrypt and GnuPG. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003, 2004, 2007 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/autogen.sh =================================================================== --- trunk/autogen.sh 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/autogen.sh 2007-05-03 20:32:42 UTC (rev 1247) @@ -181,7 +181,7 @@ cat < + + * pentium4/distfiles: Fixed. + 2007-04-30 Werner Koch * config.links: Create a file mod-source-info.h. Modified: trunk/mpi/pentium4/distfiles =================================================================== --- trunk/mpi/pentium4/distfiles 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/mpi/pentium4/distfiles 2007-05-03 20:32:42 UTC (rev 1247) @@ -1,12 +1,3 @@ README -mmx: -mpih-lshift.S -mpih-rshift.S -sse2: -mpih-add1.S -mpih-mul1.S -mpih-mul2.S -mpih-mul3.S -mpih-sub1.S Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/src/ChangeLog 2007-05-03 20:32:42 UTC (rev 1247) @@ -1,3 +1,8 @@ +2007-05-03 Werner Koch + + * libgcrypt.def (gcry_sexp_nth_string): New. + * Makefile.am (EXTRA_DIST): Add libgcrypt.def. + 2007-05-02 Werner Koch * global.c (print_config): Print ciphers, digests and pubkeys. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/src/Makefile.am 2007-05-03 20:32:42 UTC (rev 1247) @@ -21,7 +21,7 @@ ## Process this file with automake to produce Makefile.in EXTRA_DIST = Manifest libgcrypt-config.in libgcrypt.m4 libgcrypt.vers \ - gcrypt.h.in + gcrypt.h.in libgcrypt.def bin_SCRIPTS = libgcrypt-config m4datadir = $(datadir)/aclocal m4data_DATA = libgcrypt.m4 Modified: trunk/src/libgcrypt.def =================================================================== --- trunk/src/libgcrypt.def 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/src/libgcrypt.def 2007-05-03 20:32:42 UTC (rev 1247) @@ -224,3 +224,6 @@ gcry_ac_data_decrypt_scheme @184 gcry_ac_data_sign_scheme @185 gcry_ac_data_verify_scheme @186 + + gcry_sexp_nth_string @187 + Modified: trunk/src/versioninfo.rc.in =================================================================== --- trunk/src/versioninfo.rc.in 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/src/versioninfo.rc.in 2007-05-03 20:32:42 UTC (rev 1247) @@ -34,7 +34,7 @@ BEGIN BLOCK "040904b0" BEGIN - /* Note that the Windows versioin falls under the GPL. */ + /* Note that the Windows version falls under the GPL. */ VALUE "Comments", "Provided under the terms of the GNU General Public License.\0" VALUE "CompanyName", "g10 Code GmbH\0" VALUE "FileDescription", "Libgcrypt - The GNU Crypto Library\0" Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/tests/ChangeLog 2007-05-03 20:32:42 UTC (rev 1247) @@ -1,3 +1,7 @@ +2007-05-03 Werner Koch + + * Makefile.am (EXTRA_DIST): Do not build pkbench.c + 2007-05-02 David Shaw * basic.c (check_ciphers): Add Camellia. Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2007-05-02 17:18:57 UTC (rev 1246) +++ trunk/tests/Makefile.am 2007-05-03 20:32:42 UTC (rev 1247) @@ -21,7 +21,8 @@ TESTS = version t-mpi-bit prime register ac ac-schemes ac-data basic \ mpitests tsexp keygen pubkey hmac keygrip -# random tests forking thus no a test for W32 does not make any sense. + +# random.c uses fork() thus a test for W32 does not make any sense. if !HAVE_W32_SYSTEM TESTS += random endif @@ -37,8 +38,9 @@ LDADD = ../src/libgcrypt.la +EXTRA_PROGRAMS = testapi +noinst_PROGRAMS = $(TESTS) + # pkbench uses mmap for no good reason. Needs to be fixed. Code for # this can be found in libksba/tests. -EXTRA_PROGRAMS = testapi -noinst_PROGRAMS = $(TESTS) pkbench - +EXTRA_DIST = pkbench.c From cvs at cvs.gnupg.org Thu May 3 22:13:09 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 03 May 2007 22:13:09 +0200 Subject: [svn] gpgme - r1215 - trunk/doc Message-ID: Author: marcus Date: 2007-05-03 22:12:40 +0200 (Thu, 03 May 2007) New Revision: 1215 Modified: trunk/doc/ChangeLog trunk/doc/gpgme.texi Log: 2007-05-03 Marcus Brinkmann * gpgme.texi (Registering I/O Callbacks): Fix description of EVENT member of gpgme_event_io_t. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-04-30 18:37:22 UTC (rev 1214) +++ trunk/doc/ChangeLog 2007-05-03 20:12:40 UTC (rev 1215) @@ -1,3 +1,4 @@ + 2006-11-01 Moritz Schulte * gpgme.texi (Data Buffer I/O Operations): Fixed entry for Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2007-04-30 18:37:22 UTC (rev 1214) +++ trunk/doc/gpgme.texi 2007-05-03 20:12:40 UTC (rev 1215) @@ -4915,8 +4915,8 @@ @item gpgme_event_io_cb_t event This is the function called by @acronym{GPGME} to signal an event for -an operation. It is optional, but if you don't specify it, you can -not retrieve the return value of the operation. +an operation. It must be specified, because at least the start event +must be processed. @item void *event_data This is passed as the first argument to the @code{event} function when From cvs at cvs.gnupg.org Fri May 4 11:22:47 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 May 2007 11:22:47 +0200 Subject: [svn] GnuPG - r4493 - in trunk: common jnlib Message-ID: Author: wk Date: 2007-05-04 11:22:18 +0200 (Fri, 04 May 2007) New Revision: 4493 Modified: trunk/common/ChangeLog trunk/common/i18n.h trunk/common/simple-gettext.c trunk/jnlib/ChangeLog trunk/jnlib/argparse.c trunk/jnlib/utf8conv.c trunk/jnlib/utf8conv.h Log: UTF-8 Fixes Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/common/ChangeLog 2007-05-04 09:22:18 UTC (rev 4493) @@ -1,3 +1,8 @@ +2007-04-25 Werner Koch + + * i18n.h (ngettext): New. + * simple-gettext.c (ngettext): New. + 2007-04-20 Werner Koch * miscellaneous.c (my_gcry_logger, my_gcry_outofcore_handler): Modified: trunk/common/i18n.h =================================================================== --- trunk/common/i18n.h 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/common/i18n.h 2007-05-04 09:22:18 UTC (rev 4493) @@ -17,6 +17,8 @@ #ifdef USE_SIMPLE_GETTEXT int set_gettext_file( const char *filename ); const char *gettext( const char *msgid ); + const char *ngettext(const char *msgid1, const char *msgid2, + unsigned long int n); # define _(a) gettext (a) # define N_(a) (a) #else @@ -34,6 +36,7 @@ # else # define _(a) (a) # define N_(a) (a) +# define ngettext(a,b,c) ((c)==1? (a):(b)) # endif #endif /*!USE_SIMPLE_GETTEXT*/ Modified: trunk/common/simple-gettext.c =================================================================== --- trunk/common/simple-gettext.c 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/common/simple-gettext.c 2007-05-04 09:22:18 UTC (rev 4493) @@ -419,6 +419,15 @@ return msgid; } + +const char * +ngettext (const char *msgid1, const char *msgid2, unsigned long int n) +{ + /* We use the simple Germanic plural rule. */ + return gettext (n==1? msgid1 : msgid2); +} + + #if 0 unsigned int cp1, cp2; Modified: trunk/jnlib/ChangeLog =================================================================== --- trunk/jnlib/ChangeLog 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/jnlib/ChangeLog 2007-05-04 09:22:18 UTC (rev 4493) @@ -1,3 +1,7 @@ +2007-04-25 Werner Koch + + * argparse.c (long_opt_strlen): Fixed for utf-8. + 2007-03-07 Werner Koch * argparse.c (strusage): Set copyright year to 2007. Modified: trunk/jnlib/argparse.c =================================================================== --- trunk/jnlib/argparse.c 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/jnlib/argparse.c 2007-05-04 09:22:18 UTC (rev 4493) @@ -1,5 +1,6 @@ /* [argparse.c wk 17.06.97] Argument Parser for option handling - * Copyright (C) 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2006 + * 2007 Free Software Foundation, Inc. * * This file is part of JNLIB. * @@ -29,6 +30,9 @@ #include "mischelp.h" #include "stringhelp.h" #include "logging.h" +#ifdef JNLIB_NEED_UTF8CONV +#include "utf8conv.h" +#endif #include "argparse.h" @@ -438,7 +442,7 @@ for(i=0; opts[i].short_opt; i++ ) if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) ) return i; - #if 0 +#if 0 { ALIAS_DEF a; /* see whether it is an alias */ @@ -450,7 +454,7 @@ } } } - #endif +#endif /* not found, see whether it is an abbreviation */ /* aliases may not be abbreviated */ n = strlen( keyword ); @@ -699,18 +703,28 @@ static size_t long_opt_strlen( ARGPARSE_OPTS *o ) { - size_t n = strlen(o->long_opt); + size_t n = strlen (o->long_opt); - if( o->description && *o->description == '|' ) { - const char *s; - - s=o->description+1; - if( *s != '=' ) - n++; - for(; *s && *s != '|'; s++ ) - n++; + if ( o->description && *o->description == '|' ) + { + const char *s; +#ifdef JNLIB_NEED_UTF8CONV + int is_utf8 = is_native_utf8 (); +#endif + + s=o->description+1; + if ( *s != '=' ) + n++; + /* For a (mostly) correct length calculation we exclude + continuation bytes (10xxxxxx) if we are on a native utf8 + terminal. */ + for (; *s && *s != '|'; s++ ) +#ifdef JNLIB_NEED_UTF8CONV + if ( is_utf8 && (*s&0xc0) != 0x80 ) +#endif + n++; } - return n; + return n; } /**************** @@ -954,17 +968,20 @@ { ARGPARSE_OPTS opts[] = { { 'v', "verbose", 0 , "Laut sein"}, - { 'e', "echo" , 0 , "Zeile ausgeben, damit wir sehen, was wir einegegeben haben"}, - { 'd', "debug", 0 , "Debug\nfalls mal etasws\nSchief geht"}, + { 'e', "echo" , 0 , ("Zeile ausgeben, damit wir sehen, was wir ein" + " gegeben haben")}, + { 'd', "debug", 0 , "Debug\nfalls mal etwas\nschief geht"}, { 'o', "output", 2 }, { 'c', "cross-ref", 2|8, "cross-reference erzeugen\n" }, + /* Note that on a non-utf8 terminal the ? might garble the output. */ + { 's', "street", 0, "|Stra?e|set the name of the street to Stra?e" }, { 'm', "my-option", 1|8 }, { 500, "a-long-option", 0 }, {0} }; ARGPARSE_ARGS pargs = { &argc, &argv, 2|4|32 }; int i; - while( ArgParse( &pargs, opts) ) { + while( arg_parse ( &pargs, opts) ) { switch( pargs.r_opt ) { case -1 : printf( "arg=`%s'\n", pargs.r.ret_str); break; case 'v': opt.verbose++; break; Modified: trunk/jnlib/utf8conv.c =================================================================== --- trunk/jnlib/utf8conv.c 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/jnlib/utf8conv.c 2007-05-04 09:22:18 UTC (rev 4493) @@ -256,7 +256,14 @@ return active_charset_name; } +/* Return true if the native charset is utf-8. */ +int +is_native_utf8 (void) +{ + return no_translation; +} + /* Convert string, which is in native encoding to UTF8 and return a new allocated UTF-8 string. */ char * Modified: trunk/jnlib/utf8conv.h =================================================================== --- trunk/jnlib/utf8conv.h 2007-05-03 04:44:12 UTC (rev 4492) +++ trunk/jnlib/utf8conv.h 2007-05-04 09:22:18 UTC (rev 4493) @@ -24,6 +24,7 @@ int set_native_charset (const char *newset); const char *get_native_charset (void); +int is_native_utf8 (void); char *native_to_utf8 (const char *string); char *utf8_to_native (const char *string, size_t length, int delim); From cvs at cvs.gnupg.org Fri May 4 11:24:21 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 May 2007 11:24:21 +0200 Subject: [svn] GnuPG - r4494 - in trunk: . doc keyserver Message-ID: Author: wk Date: 2007-05-04 11:23:51 +0200 (Fri, 04 May 2007) New Revision: 4494 Added: trunk/keyserver/gpg2keys_mailto.in trunk/keyserver/gpg2keys_test.in Removed: trunk/keyserver/gpgkeys_mailto.in trunk/keyserver/gpgkeys_test.in Modified: trunk/ChangeLog trunk/Makefile.am trunk/configure.ac trunk/doc/gpg-agent.texi trunk/keyserver/ChangeLog trunk/keyserver/Makefile.am Log: Fixed installation of gpg2keys_mailto Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-04 09:22:18 UTC (rev 4493) +++ trunk/ChangeLog 2007-05-04 09:23:51 UTC (rev 4494) @@ -1,3 +1,9 @@ +2007-05-04 Werner Koch + + * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Add --enable-mailto + + * configure.ac (AC_CONFIG_FILES): Rename gpgkeys_ to gpg2keys_. + 2007-03-08 Werner Koch Released 2.0.3. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-05-04 09:22:18 UTC (rev 4493) +++ trunk/Makefile.am 2007-05-04 09:23:51 UTC (rev 4494) @@ -22,7 +22,7 @@ ACLOCAL_AMFLAGS = -I m4 -I gl/m4 AUTOMAKE_OPTIONS = dist-bzip2 -DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun +DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto EXTRA_DIST = scripts/config.rpath autogen.sh README.SVN DISTCLEANFILES = g10defs.h Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-04 09:22:18 UTC (rev 4493) +++ trunk/configure.ac 2007-05-04 09:23:51 UTC (rev 4494) @@ -1321,8 +1321,8 @@ agent/Makefile scd/Makefile keyserver/Makefile -keyserver/gpgkeys_mailto -keyserver/gpgkeys_test +keyserver/gpg2keys_mailto +keyserver/gpg2keys_test tools/gpg-zip tools/Makefile doc/Makefile Modified: trunk/doc/gpg-agent.texi =================================================================== --- trunk/doc/gpg-agent.texi 2007-05-04 09:22:18 UTC (rev 4493) +++ trunk/doc/gpg-agent.texi 2007-05-04 09:23:51 UTC (rev 4494) @@ -268,7 +268,7 @@ @opindex c @opindex csh Format the info output in daemon mode for use with the standard Bourne -shell respective the C-shell . The default ist to guess it based on the +shell respective the C-shell . The default is to guess it based on the environment variable @code{SHELL} which is in almost all cases sufficient. Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2007-05-04 09:22:18 UTC (rev 4493) +++ trunk/keyserver/ChangeLog 2007-05-04 09:23:51 UTC (rev 4494) @@ -1,3 +1,11 @@ +2007-05-04 Werner Koch + + * gpgkeys_test.in: Rename to .. + * gpg2keys_test.in: .. this. + * gpgkeys_mailto.in: Rename to .. + * gpg2keys_mailto.in: .. this + * Makefile.am: Likewise + 2007-03-13 David Shaw From STABLE-BRANCH-1-4 Modified: trunk/keyserver/Makefile.am =================================================================== --- trunk/keyserver/Makefile.am 2007-05-04 09:22:18 UTC (rev 4493) +++ trunk/keyserver/Makefile.am 2007-05-04 09:23:51 UTC (rev 4494) @@ -34,7 +34,7 @@ libexec_PROGRAMS = $(GPGKEYS_LDAP) $(GPGKEYS_HKP) $(GPGKEYS_FINGER) \ $(GPGKEYS_CURL) libexec_SCRIPTS = $(GPGKEYS_MAILTO) -noinst_SCRIPTS = gpgkeys_test +noinst_SCRIPTS = gpg2keys_test common_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) Copied: trunk/keyserver/gpg2keys_mailto.in (from rev 4488, trunk/keyserver/gpgkeys_mailto.in) =================================================================== --- trunk/keyserver/gpgkeys_mailto.in 2007-04-20 16:59:37 UTC (rev 4488) +++ trunk/keyserver/gpg2keys_mailto.in 2007-05-04 09:23:51 UTC (rev 4494) @@ -0,0 +1,225 @@ +#!@PERL@ -w + +# gpg2keys_mailto - talk to a email keyserver +# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of GnuPG. +# +# GnuPG is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GnuPG is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION=1; +$sendmail="@SENDMAIL@ -t"; + +### + +sub VERSION_MESSAGE () +{ + print STDOUT "gpg2keys_mailto (GnuPG) @VERSION@\n"; +} + +sub HELP_MESSAGE () +{ + print STDOUT <$opt_o") || die "Can't open output file $opt_o\n"; +} + +if(@ARGV) +{ + open(STDIN,$ARGV[0]) || die "Can't open input file $ARGV[0]\n"; +} + +($login,$name)=(getpwuid($<))[0,6]; + +$from="$name <$login>"; + +while() +{ + last if($_ eq "\n"); + + if(/^COMMAND (\S+)/) + { + $command=$1; + } + + if(/^OPAQUE (\S+)/) + { + $address=$1; + } + + if(/^PROGRAM (\S+)/) + { + $program=$1; + } + + if(/^OPTION (\S+)/) + { + if($1=~/^verbose$/i) + { + $verbose++; + } + elsif($1=~/^no-verbose$/i) + { + $verbose--; + } + } +} + +$program="(unknown)" if(!defined($program)); + +if(!defined($address)) +{ + print STDERR "gpgkeys: no address provided\n"; + exit(1); +} + +# decode $address + +($address,$args)=split(/\?/,$address); + +if(defined($args)) +{ + @pairs = split(/&/, $args); + foreach $pair (@pairs) + { + ($hdr, $val) = split(/=/, $pair); + $hdr =~ tr/+/ /; + $hdr =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; + $val =~ tr/+/ /; + $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; +# we only handle "from" right now + if($hdr=~/^from$/i) + { + $from=$val; + last; + } + } +} + +while() +{ + last if($_ eq "\n"); + + chomp; + + push(@keys,$_); +} + +# Send response + +print "VERSION 1\n"; +print "OPTION OUTOFBAND\n\n"; + +# Email keyservers get and search the same way + +if($command=~/get/i || $command=~/search/i) +{ + if($command=~/search/i) + { + print "COUNT 0\n"; + } + + foreach $key (@keys) + { + open(MAIL,"|$sendmail") || die "ERROR: Can't open $sendmail\n"; + print MAIL "From: $from\n"; + print MAIL "To: $address\n"; + if($command=~/get/i) + { + # mail keyservers don't like long-form keyids + + if(substr($key,0,2) eq "0x") + { + $key=substr($key,2); + } + + if(length($key)>8) + { + $key=substr($key,-8); + } + + print MAIL "Subject: GET 0x$key\n\n"; + } + else + { + print MAIL "Subject: GET $key\n\n"; + } + print MAIL "GnuPG $program email keyserver request\n"; + close(MAIL); + + # Tell GnuPG not to expect a key + print "KEY $key OUTOFBAND\n"; + + if($verbose) + { + print STDERR "gpgkeys: key $key requested from $address\n"; + } + } +} + +if($command=~/send/i) +{ + while(!eof(STDIN)) + { + open(MAIL,"|$sendmail") || die "ERROR: Can't open $sendmail\n"; + print MAIL "From: $name <$login>\n"; + print MAIL "To: $address\n"; + print MAIL "Subject: ADD\n\n"; + + while() + { + if(/^KEY (\S+) BEGIN$/) + { + $key=$1; + last; + } + } + + while() + { + if(/^KEY \S+ END$/) + { + last; + } + + print MAIL; + } + + close(MAIL); + + if($verbose) + { + print STDERR "gpgkeys: key $key sent to $address\n"; + } + } +} + + +# Local Variables: +# mode:perl +# End: Copied: trunk/keyserver/gpg2keys_test.in (from rev 4488, trunk/keyserver/gpgkeys_test.in) =================================================================== --- trunk/keyserver/gpgkeys_test.in 2007-04-20 16:59:37 UTC (rev 4488) +++ trunk/keyserver/gpg2keys_test.in 2007-05-04 09:23:51 UTC (rev 4494) @@ -0,0 +1,99 @@ +#!@PERL@ + +# gpg2keys_test - keyserver code tester +# Copyright (C) 2001 Free Software Foundation, Inc. +# +# This file is part of GnuPG. +# +# GnuPG is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GnuPG is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION=1; + +$|=1; + +sub VERSION_MESSAGE () +{ + print STDOUT "gpg2keys_test (GnuPG) @VERSION@\n"; +} + +sub HELP_MESSAGE () +{ + print STDOUT <$opt_o") || die "Can't open output file $opt_o\n"; +} + +if(@ARGV) +{ + print STDERR "Using input file $ARGV[0]\n"; + open(STDIN,$ARGV[0]) || die "Can't open input file $ARGV[0]\n"; +} + +# Get the command block + +print STDERR "Command block:\n"; + +while() +{ + last if($_ eq "\n"); + print STDERR "--command-> $_"; + + if(/^COMMAND (\w+)/) + { + $command=$1; + } +} + +# Get the keylist block + +print STDERR "Keylist block:\n"; + +while() +{ + last if($_ eq "\n"); + print STDERR "--keylist-> $_"; +} + +# If it's a SEND, then get the key material + +if($command eq "SEND") +{ + print STDERR "Key material to send:\n"; + + while() + { + print STDERR "$_"; + } +} + +printf STDERR "gpgkeys_test finished\n"; + +# Local Variables: +# mode:perl +# End: Deleted: trunk/keyserver/gpgkeys_mailto.in Deleted: trunk/keyserver/gpgkeys_test.in From cvs at cvs.gnupg.org Fri May 4 12:55:14 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 May 2007 12:55:14 +0200 Subject: [svn] gcry - r1249 - tags Message-ID: Author: wk Date: 2007-05-04 12:54:45 +0200 (Fri, 04 May 2007) New Revision: 1249 Added: tags/libgcrypt-1.3.0/ Log: Released 1.3.0 Copied: tags/libgcrypt-1.3.0 (from rev 1248, trunk) From cvs at cvs.gnupg.org Fri May 4 13:01:46 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 04 May 2007 13:01:46 +0200 Subject: [svn] gcry - r1250 - in trunk: . mpi Message-ID: Author: wk Date: 2007-05-04 13:01:17 +0200 (Fri, 04 May 2007) New Revision: 1250 Modified: trunk/Makefile.am trunk/README trunk/configure.ac trunk/mpi/ChangeLog trunk/mpi/config.links Log: Post release updates. Allow colons as delimiters for --enable-mpi-path. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-05-04 10:54:45 UTC (rev 1249) +++ trunk/Makefile.am 2007-05-04 11:01:17 UTC (rev 1250) @@ -17,12 +17,10 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA -all_ciphers= - ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 DISTCHECK_CONFIGURE_FLAGS = --enable-random-daemon \ - --enable-ciphers="arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia" + --enable-ciphers=arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia DIST_SUBDIRS = m4 mpi cipher src doc tests SUBDIRS = mpi cipher src doc tests Modified: trunk/README =================================================================== --- trunk/README 2007-05-04 10:54:45 UTC (rev 1249) +++ trunk/README 2007-05-04 11:01:17 UTC (rev 1250) @@ -132,9 +132,9 @@ optimizations. For example, if you want to add optimizations forn a Intel Pentium 4 compatible CPU, you may use - --enable-mpi-path="pentium4/sse2 pentium4/mmx" + --enable-mpi-path=pentium4/sse2:pentium4/mmx Take care: The generated library may crash on - non-compatible CPUs + non-compatible CPUs. --enable-random=NAME Force the use of the random gathering module Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-04 10:54:45 UTC (rev 1249) +++ trunk/configure.ac 2007-05-04 11:01:17 UTC (rev 1250) @@ -27,8 +27,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.3.0]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.3.1]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) Modified: trunk/mpi/ChangeLog =================================================================== --- trunk/mpi/ChangeLog 2007-05-04 10:54:45 UTC (rev 1249) +++ trunk/mpi/ChangeLog 2007-05-04 11:01:17 UTC (rev 1250) @@ -1,3 +1,7 @@ +2007-05-04 Werner Koch + + * config.links (path): Allowthe sue of colons as delimiters. + 2007-05-03 Werner Koch * pentium4/distfiles: Fixed. Modified: trunk/mpi/config.links =================================================================== --- trunk/mpi/config.links 2007-05-04 10:54:45 UTC (rev 1249) +++ trunk/mpi/config.links 2007-05-04 11:01:17 UTC (rev 1250) @@ -322,7 +322,7 @@ # if this fails get it from the generic subdirectory. mpi_ln_list= mpi_mod_list= -path="$mpi_extra_path $path generic" +path=`echo "$mpi_extra_path $path generic" | tr ':' ' '` echo '/* Created by config.links - do not edit */' >./mpi/mod-source-info.h echo "/* Target: ${target} */" >>./mpi/mod-source-info.h echo "static char mod_source_info[] =" >>./mpi/mod-source-info.h @@ -350,7 +350,7 @@ echo " ;" >>./mpi/mod-source-info.h # Same thing for the file which defines the limb size -path="$path generic" +path=`echo "$path generic" | tr ':' ' '` for dir in $path ; do rm -f $srcdir/mpi/mpi-asm-defs.h if test -f $srcdir/mpi/$dir/mpi-asm-defs.h ; then From cvs at cvs.gnupg.org Sun May 6 23:58:28 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun, 06 May 2007 23:58:28 +0200 Subject: [svn] assuan - r237 - trunk/doc Message-ID: Author: marcus Date: 2007-05-06 23:57:58 +0200 (Sun, 06 May 2007) New Revision: 237 Modified: trunk/doc/ChangeLog trunk/doc/assuan.texi Log: 2007-05-06 Marcus Brinkmann * assuan.texi: Clean up typos. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-05-01 16:36:08 UTC (rev 236) +++ trunk/doc/ChangeLog 2007-05-06 21:57:58 UTC (rev 237) @@ -1,3 +1,7 @@ +2007-05-06 Marcus Brinkmann + + * assuan.texi: Clean up typos. + 2006-10-31 Werner Koch * assuan.texi: Finished. Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2007-05-01 16:36:08 UTC (rev 236) +++ trunk/doc/assuan.texi 2007-05-06 21:57:58 UTC (rev 237) @@ -136,22 +136,22 @@ @node Introduction @chapter Introduction to Assuan -In an ideal world, Assuan is irrelevant. Assuan's primary use is to -allow a client to interact with a non-persistent server. Using -Assuan, this is accomplished by forking a subprocess and communicating -with it via, for example, a pipe or Unix domain socket. This method -is neither elegant nor efficient especially when there is a lot of -data spread across several transactions: not only is there a penalty -for an increased number of context switches, but also a significant -amount of data is @var{memcpy}ed from the client to a file descriptor -and from the file descriptor to the server. Despite these and other -disadvantages, this type of client/server communication can be useful: -the client is completely separate from the server; they are in -different address spaces. This is especially important in situations -where the server must have a known degree of reliability and data must -be protected: as the Assuan protocol is well defined and clients -cannot corrupt the servers' address space, auditing become much -easier. +In an ideal world, Assuan would not be necessary. Assuan's primary +use is to allow a client to interact with a non-persistent server. +Using Assuan, this is accomplished by forking a subprocess and +communicating with it via, for example, a pipe or Unix domain socket. +This method is neither elegant nor efficient, especially when there is +a lot of data spread across several transactions: not only is there a +penalty for an increased number of context switches, but also a +significant amount of data is @var{memcpy}ed from the client to a file +descriptor and from the file descriptor to the server. Despite these +and other disadvantages, this type of client/server communication can +be useful: the client is completely separate from the server; they are +in different address spaces. This is especially important in +situations where the server must have a known degree of reliability +and data must be protected: as the Assuan protocol is well defined and +clients cannot corrupt the servers' address space, auditing becomes +much easier. Assuan was developed for use by the GNU Privacy Guard, GnuPG, to prevent potentially buggy clients from unwittingly corrupting @@ -162,13 +162,12 @@ encryption front ends. Like a shared library, the interface is well defined and any number of front ends can use it; however, unlike a shared library, the client cannot see or touch the server's data. As -with any modular system, Assuan helps keep the servers small and -understandable help to make code more understandable and less error -prone. +with any modular system, Assuan helps keep the components small, +understandable and less error prone. Assuan is not, however, limited to use with GnuPG servers and clients: -it was design to be flexible enough to meet the demands of almost any -transaction based environment with non-persistent servers. +it was designed to be flexible enough to meet the demands of many +transaction based environments with non-persistent servers. @node Assuan @chapter Description of the Assuan protocol. @@ -210,13 +209,13 @@ The implementation is line based with a maximum line size of 1000 octets. The default IPC mechanism are Unix Domain Sockets. -On a connect request the server responds either with an okay or an error -status. For authentication check the server may send an Inquiry -Response prior to the first Okay, it may also issue Status messages. -The server must check that the client is allowed to connect, this is -done by requesting the credentials for the peer and comparing them to -those of the server. This avoids attacks based on wrong socket -permissions. +On a connect request the server responds either with an okay or an +error status. For authentication check the server may send an Inquiry +Response prior to the first Okay, and it may also issue Status +messages. The server must check that the client is allowed to +connect, this is done by requesting the credentials for the peer and +comparing them to those of the server. This avoids attacks based on +wrong socket permissions. It may choose to delay the first response in case of an error. The server never closes the connection - however the lower protocol may do @@ -325,17 +324,9 @@ all protocols and partly directly supported by the Assuan library: @table @code - at item CANCEL -This command is used for future extensions. - @item BYE Close the connect, the server will reply with an @code{OK}. - at item AUTH -Not yet specified as we don't implement it in the first phase. See my -mail to gpa-dev on 2001-10-25 about the rationale for measurements -against local attacks. - @item RESET Reset the connection but not any existing authentication. The server should release all resources associated with the connection. @@ -359,6 +350,14 @@ allowed but should be ignored. For compatibility reasons, @var{name} may be prefixed with two dashes. The use of the equal sign is optional but suggested if @var{value} is given. + + at item CANCEL +This command is reserved for future extensions. + + at item AUTH +This command is reserved for future extensions. Not yet specified as +we don't implement it in the first phase. See my mail to gpa-dev on +2001-10-25 about the rationale for measurements against local attacks. @end table @@ -615,9 +614,10 @@ @node Reading and Writing @section How to communicate with the peer -What would be a IPC library without the ability to read and write data? -Not very useful. Libassuan has high level functions to take care of of -the more boring stuff but eventfully actually data needs to be written. +What would be an IPC library without the ability to read and write +data? Not very useful. Libassuan has high level functions to take +care of of the more boring stuff but eventually data needs to be +written and read. @noindent The basic read and write functions are: @@ -655,7 +655,7 @@ When used by a client this flush operation does also send the terminating @code{END} command to terminate the response on an -``INQUIRE'' response. Note, that the function @code{assuan_transact} +``INQUIRE'' response. Note that the function @code{assuan_transact} takes care of sending this @code{END} itself. @noindent @@ -706,15 +706,15 @@ If @var{atfork} is not NULL, this function is called in the child right after the fork and the value @var{atforkvalue} is passed as the first argument. That function should only act if the second argument it -received is @code{0}. Such a fork callback is useful to releases +received is @code{0}. Such a fork callback is useful to release additional resources not to be used by the child. - at var{flags} controls how the function acts: With a value of @code{0} it -expects a simple pipe based server and is in that identical to + at var{flags} controls how the function acts: With a value of @code{0} +it expects a simple pipe based server and behaves similar to @code{assuan_pipe_connect}. With a value of @code{1} a sever based on -full-duplex pipes is expected. Such pipes are usually created using the - at code{socketpair} function. It also enables features only available -with such servers. +full-duplex pipes is expected. Such pipes are usually created using +the @code{socketpair} function. It also enables features only +available with such servers. @end deftypefun @@ -723,15 +723,15 @@ @deftypefun assuan_error_t assuan_socket_connect_ext (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}}) -Make a connection to the Unix domain socket @var{name} and return a new -Assuan context at @var{ctx}. @var{server_pid} is currently not used but -may become handy in the future; if you don't know the server's pid, pass - at code{-1}. With @var{flags} set to @code{1} the @code{sendmsg} and - at code{recvmesg} are used for input and output and thereby enabling the -the use of descriptor passing. +Make a connection to the Unix domain socket @var{name} and return a +new Assuan context at @var{ctx}. @var{server_pid} is currently not +used but may become handy in the future; if you don't know the +server's pid, pass @code{-1}. With @var{flags} set to @code{1}, + at code{sendmsg} and @code{recvmesg} are used for input and output and +thereby enabling the the use of descriptor passing. -Connecting a TCP server is not yet implemented. Standard URL schemes -are reserved for @var{name} specifying a TCP server. +Connecting to a TCP server is not yet implemented. Standard URL +schemes are reserved for @var{name} specifying a TCP server. @end deftypefun @@ -751,25 +751,27 @@ @code{NULL} for @var{ctx}, in which case the function does nothing. @end deftypefun -Now that we have a connection to the server all work may be conveniently -done using a couple of callbacks and the transact function: +Now that we have a connection to the server, all work may be +conveniently done using a couple of callbacks and the transact +function: @deftypefun assuan_error_t assuan_transact (@w{assuan_context_t @var{ctx}}, @w{const char *@var{command}}, @w{int (*@var{data_cb})(void *, const void *, size_t)}, @w{void *@var{data_cb_arg}}, @w{int (*@var{inquire_cb})(void*, const char *)}, @w{void *@var{inquire_cb_arg}}, @w{int (*@var{status_cb})(void*, const char *)}, @w{void *@var{status_cb_arg}}) -Here @var{ctx} is the Assuan context opened by one of the connect call. - at var{command} is the actual one liner Assuan command. It shall not end -with a line feed and its length is limited to @code{ASSUAN_LINELENGTH} -(~1000 bytes) +Here @var{ctx} is the Assuan context opened by one of the connect +calls. @var{command} is the actual one liner Assuan command. It +shall not end with a line feed and its length is limited to + at code{ASSUAN_LINELENGTH} (~1000 bytes) @var{data_cb} is called by Libassuan for data lines; @var{data_cb_arg} -is passed to it along with the data and the length. [fixme: needs more -documentation]. +is passed to it along with the data and the length. [FIXME: needs +more documentation]. @var{inquire_cb} is called by Libassuan when the server requests -additional information from the client during the processing of a -request. This callback shall check the provided inquriy name and send -the data as requested back using the @code{assuan_write_data}. The server -passed @var{inquriy_cb_arg} along with the inquiry name to the callback. +additional information from the client while processing the command. +This callback shall check the provided inquiry name and send the data +as requested back using the @code{assuan_write_data}. The server +passed @var{inquiry_cb_arg} along with the inquiry name to the +callback. @var{status_cb} is called by Libassuan for each status line it receives from the server. @var{status_cb_arg} is passed along with the status @@ -790,7 +792,8 @@ Send the descriptor @var{fd} to the peer using the context @var{ctx}. Note, that calling this function with a @var{ctx} of @code{NULL} and @var{fd} of @code{-1} is a valid runtime test to check whether -descriptor passing is available on the platform. +descriptor passing is available on the platform. The descriptor must +be sent before the command is issued that makes use of the descriptor. @end deftypefun @@ -798,8 +801,8 @@ @deftypefun assuan_error_t assuan_receivefd (@w{assuan_context_t @var{ctx}}, @w{int *@var{fd}}) Receive a descriptor pending for the context @var{ctx} from the peer. -This descriptor must be pending before this function is called. To -accomplish this the peer needs to use @code{assuan_sendfd} before the +The descriptor must be pending before this function is called. To +accomplish this, the peer needs to use @code{assuan_sendfd} before the trigger is sent (e.g. using @code{assuan_write_line ("INPUT FD")}. @end deftypefun @@ -830,7 +833,7 @@ @end smallexample For convenience this table is usually put after the actual command -handlers (cmd_foo, cmd_bar) or even put inside the the command_handler. +handlers (cmd_foo, cmd_bar) or even put inside the command_handler. Note that commands with the name ``INPUT'' and ``OUTPUT'' do not require a handler because Libassuan provides a default handler for them. It is however possible to assign a custom handler. @@ -838,7 +841,7 @@ A prerequisite for this example code is that a client has already connected to the server. Often there are two modes combined in one program: A pipe based server, where a client has forked the server -process or a Unix domain socket based server that is listening on the +process, or a Unix domain socket based server that is listening on the socket. @example @@ -866,28 +869,31 @@ @end example @noindent -This is the first part of the command hander. In case this is called as -a pipe based server @var{fd} will be based as @code{fd} and the code -assumes that the server's stdin and stdout are connected to a pipe. The -initialization is thus done using +This is the first part of the command handler. In case this is called +as a pipe based server, @var{fd} will be based as @code{fd} and the +code assumes that the server's @code{stdin} and @code{stdout} file +handles are connected to a pipe. The initialization is thus done +using the function: @deftypefun assuan_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{filedes}[2]}) The function takes the two file descriptors from @var{filedes} and -returns a new Assuan context at @var{r_ctx}. As usual a return value of - at code{0} indicates success and a failure is indicated by a returning an -error code. In case of error @code{NULL} will be stored at @var{r_ctx}. +returns a new Assuan context at @var{r_ctx}. As usual, a return value +of @code{0} indicates success and a failure is indicated by a +returning an error code. In case of error, @code{NULL} will be stored +at @var{r_ctx}. -In case that the server has been called using a bi-directional pipe -(socketpair), @var{filedes} is ignored and the file descriptor is taken -from the environment variable @env{_assuan_connection_fd}. You won't -need to know that because @code{assuan_pipe_connect_ext}, used by the -client to connect to such a server, automagically sets this variable. +In case the server has been called using a bi-directional pipe +(socketpair), @var{filedes} is ignored and the file descriptor is +taken from the environment variable @env{_assuan_connection_fd}. You +won't need to know that because @code{assuan_pipe_connect_ext}, used +by the client to connect to such a server, automagically sets this +variable. @end deftypefun @noindent -If a file descriptor has been passed, the assuan context gets initialized -by +If a file descriptor has been passed, the assuan context gets +initialized by the function: @deftypefun assuan_error_t assuan_init_socket_server_ext (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}}) @@ -897,17 +903,17 @@ @table @code @item Bit 0 -When set @code{sendmsg} and @code{recvmesg} are used for input and +If set, @code{sendmsg} and @code{recvmesg} are used for input and output and thus enabling the use of descriptor passing. @item Bit 1 -When set @var{fd} refers to an already accepted socket. That is, +If set, @var{fd} refers to an already accepted socket. That is, Libassuan won't call @var{accept} for it. It is suggested to set this bit as it allows better control of the connection state. @end table -As usual a return value of @code{0} indicates success and a failure is -indicated by a returning an error code. In case of error @code{NULL} -will be stored at @var{r_ctx}. +As usual, a return value of @code{0} indicates success and a failure +is indicated by a returning an error code. In case of error, + at code{NULL} will be stored at @var{r_ctx}. @end deftypefun @noindent @@ -915,14 +921,14 @@ the server. @example - for (i=0; command_table[i].name; i++) + for (i = 0; command_table[i].name; i++) @{ rc = assuan_register_command (ctx, command_table[i].name, command_table[i].handler); if (rc) @{ - fprintf (stderr, "register failed: %s\n", gpg_strerror(rc)); + fprintf (stderr, "register failed: %s\n", gpg_strerror (rc)); assuan_deinit_server (ctx); return; @} @@ -932,23 +938,21 @@ @deftypefun assuan_error_t assuan_register_command (@w{assuan_context_t @var{ctx}}, @w{const char *@var{cmd_string}}, @w{int (*@var{handler}) (assuan_context_t, char *)}) This registers the command named @var{cmd_string} with the Assuan -context @var{ctx}. @var{handler} is the function called by Libassuan if -this command is received from the client. @var{NULL} may be used - at var{handler} to use a default handler (this only works with a few -pre-defined commands). Note, that several default handlers have already -been registered when the context has been created: ``NOP'', ``CANCEL'', -``OPTION'', ``BYE'', ``AUTH'', ``RESET'' and ``END''. Although -possible, these commands should better not be overridden by the -application. Instead special functions should be used to get hold of -these commands. +context @var{ctx}. @var{handler} is the function called by Libassuan +if this command is received from the client. @var{NULL} may be used +for @var{handler} to use a default handler (this only works with a few +pre-defined commands). Note that several default handlers have +already been registered when the context has been created: ``NOP'', +``CANCEL'', ``OPTION'', ``BYE'', ``AUTH'', ``RESET'' and ``END''. It +is possible, but not recommended, to override these commands. @end deftypefun @deftypefun assuan_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{int @var{err}}) Register a function to be called right after a command has been -processed. @var{err} is the result code from the last internal assuan -operation and not the one returned by the handler. It may be used to -command related cleanup. +processed. @var{err} is the result code from the last internal assuan +operation and not the one returned by the handler. It may be used for +command-related cleanup. @end deftypefun @deftypefun assuan_error_t assuan_register_bye_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) @@ -971,12 +975,13 @@ @deftypefun assuan_error_t assuan_register_option_handler (@w{assuan_context_t @var{ctx}}, @w{int (*@var{fnc})(assuan_context_t, const char*, const char*)}) -Register function @var{fnc} with context @var{ctx} for processing of +Register function @var{fnc} with context @var{ctx} for processing options. That function is being called with the context, the name and the value of the option. Leading and trailing spaces are removed from -the name and the value. The optional leading two dashes of the name are -removed as well. If no value has been given, an empty string is passed. -The function needs to return @code{0} on success or an error code. +the name and the value. The optional leading two dashes of the name +are removed as well. If no value has been given, an empty string is +passed. The function needs to return @code{0} on success or an error +code. @end deftypefun @@ -1005,18 +1010,18 @@ @deftypefun assuan_error_t assuan_set_hello_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) This is not actually a register function but may be called also after -registering commands. It changes the ``Hello'' line, send by the server -to the client as a first response, from a default string to the string - at var{line}. For logging purposes, it is often useful to use such a -custom hello line which may tell version numbers and such. Linefeeds -are allowed in this string, however, each line needs to be shorter than -the Assuan line length limit. +registering commands. It changes the ``Hello'' line, sent by the +server to the client as a first response, from a default string to the +string @var{line}. For logging purposes, it is often useful to use +such a custom hello line which may tell version numbers and such. +Linefeeds are allowed in this string, however, each line needs to be +shorter than the Assuan line length limit. @end deftypefun @noindent -As a last initialization step debugging may be enabled for the current -connection. This is done using +As a last initialization step, debugging may be enabled for the +current connection. This is done using @deftypefun void assuan_set_log_stream (@w{assuan_context_t @var{ctx}}, @w{FILE *@var{fp}}) @@ -1197,22 +1202,24 @@ This is the core of the default ``INPUT'' and ``OUTPUT'' handler. It may be used in custom commands as well to negotiate a file descriptor. -If @var{line} contains @code{FD=@var{n}}, it returns @var{n} assuming a -local file descriptor. If @var{line} contains just @code{FD} it returns -a file descriptor at @var{rdf}; this file descriptor needs to have been -sent by the client right before using @code{assuan_sendfd}. +If @var{line} contains @code{FD=@var{n}}, it returns @var{n} in + at var{rfd} assuming a local file descriptor. If @var{line} contains +just @code{FD} it returns a file descriptor at @var{rfd}; this file +descriptor needs to have been sent by the client right before using + at code{assuan_sendfd}. @end deftypefun @deftypefun int assuan_get_input_fd (@w{assuan_context_t @var{ctx}}) -Return the file descriptor send by the client using the last ``INPUT'' +Return the file descriptor sent by the client using the last ``INPUT'' command. Returns @code{-1} if no file descriptor is available. @end deftypefun @deftypefun int assuan_get_output_fd (@w{assuan_context_t @var{ctx}}) -Return the file descriptor send by the client using the last ``OUTPUT'' -command. Returns @code{-1} if no file descriptor is available. +Return the file descriptor sent by the client using the last +``OUTPUT'' command. Returns @code{-1} if no file descriptor is +available. @end deftypefun @deftypefun assuan_error_t assuan_close_input_fd (@w{assuan_context_t @var{ctx}}) @@ -1234,14 +1241,15 @@ @deftypefun int assuan_set_error (@w{assuan_context_t @var{ctx}}, @w{int @var{err}}, @w{const char *@var{text}}) This is a helper to provide a more descriptive error text with ``ERR'' -lines. For this to work the text needs to be stored in the context +lines. For this to work, the text needs to be stored in the context @var{ctx} while still being in the command handler. This function is commonly called this way @smallexample return assuan_set_error (ctx, err, "commands needs 5 arguments"); @end smallexample - at var{err} is passed through and thus the return value of the command -handler. The provided text further explains that error code to humans. +The value @var{err} is passed through and thus the return value of the +command handler in the example. The provided text further explains +that error code to humans. @end deftypefun From cvs at cvs.gnupg.org Tue May 8 10:16:24 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 08 May 2007 10:16:24 +0200 Subject: [svn] GnuPG - r4497 - trunk/doc Message-ID: Author: wk Date: 2007-05-08 10:15:55 +0200 (Tue, 08 May 2007) New Revision: 4497 Modified: trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/doc/gnupg.texi Log: gnupg.ps build fixes. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-05-07 19:49:12 UTC (rev 4496) +++ trunk/doc/ChangeLog 2007-05-08 08:15:55 UTC (rev 4497) @@ -1,3 +1,9 @@ +2007-05-08 Werner Koch + + * gnupg.texi: Moved the logo for HTML more to the top. + * Makefile.am (install-html-local): New. + (DVIPS): Redefine to include srcdir. + 2007-05-04 Werner Koch * gnupg.texi (Top): Fix typo and a grammar issue. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2007-05-07 19:49:12 UTC (rev 4496) +++ trunk/doc/Makefile.am 2007-05-08 08:15:55 UTC (rev 4497) @@ -44,6 +44,8 @@ tools.texi debugging.texi glossary.texi contrib.texi gpl.texi \ sysnotes.texi gnupg-card-architecture.fig +DVIPS = TEXINPUTS="$(srcdir)$(PATH_SEPARATOR)$$TEXINPUTS" dvips + AM_MAKEINFOFLAGS = -I $(srcdir) --css-include=$(srcdir)/texi.css YAT2M_OPTIONS = -I $(srcdir) \ @@ -132,6 +134,8 @@ gnupg.texi : $(gnupg_TEXINFOS) touch $(srcdir)/gnupg.texi +install-html-local: + cp $(srcdir)/gnupg-logo.png gnupg.html/ online: gnupg.html gnupg.pdf set -e; \ Modified: trunk/doc/gnupg.texi =================================================================== --- trunk/doc/gnupg.texi 2007-05-07 19:49:12 UTC (rev 4496) +++ trunk/doc/gnupg.texi 2007-05-08 08:15:55 UTC (rev 4497) @@ -104,6 +104,10 @@ @page @end ifnothtml + at ifhtml + at center @image{gnupg-logo,6cm,,The GnuPG Logo} + at end ifhtml + @ifnottex @node Top @top @@ -136,13 +140,7 @@ * Index:: Index of concepts and symbol names. @end menu - at ifhtml - at center @image{gnupg-logo,6cm,,The GnuPG Logo} - - at end ifhtml - - @ifhtml @page @summarycontents From cvs at cvs.gnupg.org Tue May 8 16:00:10 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 08 May 2007 16:00:10 +0200 Subject: [svn] GnuPG - r4498 - in trunk: . doc Message-ID: Author: wk Date: 2007-05-08 15:59:41 +0200 (Tue, 08 May 2007) New Revision: 4498 Added: trunk/doc/howto-create-a-server-cert.texi trunk/doc/howtos.texi Modified: trunk/TODO trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/doc/gnupg.texi Log: Add a howto section. Makefile fixes Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-05-08 08:15:55 UTC (rev 4497) +++ trunk/TODO 2007-05-08 13:59:41 UTC (rev 4498) @@ -109,12 +109,8 @@ * Remove -sat PGP2 compatibility hack -* Cleanup m4/ on next gettext update - There is at least one couple of duplicate files: inttype[_-]h.m4. +* UTF-8 specific TODOs -* UTF-8 - (UTF-8 specific TODO0 - * Pinpad Reader We do not yet support P15 applications. The trivial thing using ASCII characters will be easy to implement but the other cases need Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-05-08 08:15:55 UTC (rev 4497) +++ trunk/doc/ChangeLog 2007-05-08 13:59:41 UTC (rev 4498) @@ -1,5 +1,9 @@ 2007-05-08 Werner Koch + * howtos.texi: New. + * howto-create-a-server-cert.texi: New. + * Makefile.am (gnupg_TEXINFOS): Add new files. + * gnupg.texi: Moved the logo for HTML more to the top. * Makefile.am (install-html-local): New. (DVIPS): Redefine to include srcdir. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2007-05-08 08:15:55 UTC (rev 4497) +++ trunk/doc/Makefile.am 2007-05-08 13:59:41 UTC (rev 4498) @@ -42,7 +42,8 @@ gnupg_TEXINFOS = \ gpg.texi gpgsm.texi gpg-agent.texi scdaemon.texi instguide.texi \ tools.texi debugging.texi glossary.texi contrib.texi gpl.texi \ - sysnotes.texi gnupg-card-architecture.fig + sysnotes.texi gnupg-card-architecture.fig \ + howtos.texi howto-create-a-server-cert.texi DVIPS = TEXINPUTS="$(srcdir)$(PATH_SEPARATOR)$$TEXINPUTS" dvips Modified: trunk/doc/gnupg.texi =================================================================== --- trunk/doc/gnupg.texi 2007-05-08 08:15:55 UTC (rev 4497) +++ trunk/doc/gnupg.texi 2007-05-08 13:59:41 UTC (rev 4498) @@ -128,6 +128,7 @@ * Helper Tools:: Description of small helper tools +* Howtos:: How to do certain things. * System Notes:: Notes pertaining to certain OSes. * Debugging:: How to solve problems @@ -163,6 +164,8 @@ @include tools.texi + at include howtos.texi + @include sysnotes.texi @include debugging.texi Added: trunk/doc/howto-create-a-server-cert.texi =================================================================== --- trunk/doc/howto-create-a-server-cert.texi 2007-05-08 08:15:55 UTC (rev 4497) +++ trunk/doc/howto-create-a-server-cert.texi 2007-05-08 13:59:41 UTC (rev 4498) @@ -0,0 +1,288 @@ + at node Howto Create a Server Cert + at section Creating a TLS server certificate + + +Here is a brief run up on how to create a server certificate. It has +actually been done this way to get a certificate from CAcert to be used +on a real server. It has only been tested with this CA, but there +shouldn't be any problem to run this against any other CA. + +Before you start, make sure that gpg-agent is running. As there is no +need for a configuration file, you may simply enter: + + at cartouche + at example + $ gpgsm-gencert.sh >a.p10 + Key type + [1] RSA + [2] Existing key + [3] Direct from card + Your selection: 1 + You selected: RSA + at end example + at end cartouche + +I opted for creating a new RSA key. The other option is to use an +already existing key, by selecting @kbd{2} and entering the so-called +keygrip. Running the command @samp{gpgsm --dump-secret-key USERID} +shows you this keygrip. Using @kbd{3} offers another menu to create a +certificate directly from a smart card based key. + +Let's continue: + + at cartouche + at example + Key length + [1] 1024 + [2] 2048 + Your selection: 1 + You selected: 1024 + at end example + at end cartouche + +The script offers two common key sizes. With the current setup of +CAcert, it does not make much sense to use a 2k key; their policies need +to be revised anyway (a CA root key valid for 30 years is not really +serious). + + at cartouche + at example + Key usage + [1] sign, encrypt + [2] sign + [3] encrypt + Your selection: 1 + You selected: sign, encrypt + at end example + at end cartouche + +We want to sign and encrypt using this key. This is just a suggestion +and the CA may actually assign other key capabilities. + +Now for some real data: + + at cartouche + at example + Name (DN) + > CN=kerckhoffs.g10code.com + at end example + at end cartouche + +This is the most important value for a server certificate. Enter here +the canonical name of your server machine. You may add other virtual +server names later. + + at cartouche + at example + E-Mail addresses (end with an empty line) + > + at end example + at end cartouche + +We don't need email addresses in a server certificate and CAcert would +anyway ignore such a request. Thus just hit enter. + +If you want to create a client certificate for email encryption, this +would be the place to enter your mail address +(e.g. @email{joe@@example.org}). You may enter as many addresses as you like, +however the CA may not accept them all or reject the entire request. + + at cartouche + at example + DNS Names (optional; end with an empty line) + > www.g10code.com + DNS Names (optional; end with an empty line) + > ftp.g10code.com + DNS Names (optional; end with an empty line) + > + at end example + at end cartouche + +Here I entered the names of the servers which actually run on the +machine given in the DN above. The browser will accept a certificate for +any of these names. As usual the CA must approve all of these names. + + at cartouche + at example + URIs (optional; end with an empty line) + > + at end example + at end cartouche + +It is possible to insert arbitrary URIs into a certificate; for a server +certificate this does not make sense. + +We have now entered all required information and @command{gpgsm} will +display what it has gathered and ask whether to create the certificate +request: + + at cartouche + at example + Parameters for certificate request to create: + 1 Key-Type: RSA + 2 Key-Length: 1024 + 3 Key-Usage: sign, encrypt + 4 Name-DN: CN=kerckhoffs.g10code.com + 5 Name-DNS: www.g10code.com + 6 Name-DNS: ftp.g10code.com + + Really create such a CSR? + [1] yes + [2] no + Your selection: 1 + You selected: yes + at end example + at end cartouche + + at command{gpgsm} will now start working on creating the request. As this +includes the creation of an RSA key it may take a while. During this +time you will be asked 3 times for a passphrase to protect the created +private key on your system. A pop up window will appear to ask for +it. The first two prompts are for the new passphrase and for re-entering it; +the third one is required to actually create the certificate signing request. + +When it is ready, you should see the final notice: + + at cartouche + at example + gpgsm: certificate request created + at end example + at end cartouche + +Now, you may look at the created request: + + at cartouche + at example + $ cat a.p10 + -----BEGIN CERTIFICATE REQUEST----- + MIIBnzCCAQgCAQAwITEfMB0GA1UEAxMWa2VyY2tob2Zmcy5nMTBjb2RlLmNvbTCB + nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5h+uKRenpvbe+BnMY6siPO50LVyg + HtB7kr+YISlPJ5JAFO12yQFz9Y0sBLHbjR+V+TOawwP1dZhGjlgnEBkMdWKuEBlS + wFTALLX78GAyvAYAmPqSPDEYXkMECyUXVX/bbGI1bY8Y2OGy4w4D+v7e+xD2NBkm + Bj5cNy+YMbGVldECAwEAAaA+MDwGCSqGSIb3DQEJDjEvMC0wKwYDVR0RBCQwIoIP + d3d3LmcxMGNvZGUuY29tgg9mdHAuZzEwY29kZS5jb20wDQYJKoZIhvcNAQEFBQAD + gYEAzBRIi8KTfKyebOlMtDN6oDYBOv+r9A4w3u/Z1ikjffaiN1Bmd2o9Ez9KXKHA + IezLeSEA/rGUPN5Ur5qIJnRNQ8xrS+iLftr8msWQSZppVnA/vnqMrtqBUpitqAr0 + eYBmt1Uem2Y3UFABrKPglv2xzgGkrKX6AqmFoOnJWQ0QcTw= + -----END CERTIFICATE REQUEST----- + $ + at end example + at end cartouche + +You may now proceed by logging into your account at the CAcert website, +choose @code{Server Certificates - New}, check @code{sign by class 3 root +certificate}, paste the above request block into the text field and +click on @code{Submit}. + +If everything works out fine, a certificate will be shown. Now run + + at cartouche + at example +$ gpgsm --import + at end example + at end cartouche + +and paste the certificate from the CAcert page into your terminal +followed by a Ctrl-D + + at cartouche + at example + -----BEGIN CERTIFICATE----- + MIIEIjCCAgqgAwIBAgIBTDANBgkqhkiG9w0BAQQFADBUMRQwEgYDVQQKEwtDQWNl + cnQgSW5jLjEeMBwGA1UECxMVaHR0cDovL3d3dy5DQWNlcnQub3JnMRwwGgYDVQQD + ExNDQWNlcnQgQ2xhc3MgMyBSb290MB4XDTA1MTAyODE2MjA1MVoXDTA3MTAyODE2 + MjA1MVowITEfMB0GA1UEAxMWa2VyY2tob2Zmcy5nMTBjb2RlLmNvbTCBnzANBgkq + hkiG9w0BAQEFAAOBjQAwgYkCgYEA5h+uKRenpvbe+BnMY6siPO50LVygHtB7kr+Y + ISlPJ5JAFO12yQFz9Y0sBLHbjR+V+TOawwP1dZhGjlgnEBkMdWKuEBlSwFTALLX7 + 8GAyvAYAmPqSPDEYXkMECyUXVX/bbGI1bY8Y2OGy4w4D+v7e+xD2NBkmBj5cNy+Y + MbGVldECAwEAAaOBtTCBsjAMBgNVHRMBAf8EAjAAMDQGA1UdJQQtMCsGCCsGAQUF + BwMCBggrBgEFBQcDAQYJYIZIAYb4QgQBBgorBgEEAYI3CgMDMAsGA1UdDwQEAwIF + oDAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9vY3NwLmNhY2Vy + dC5vcmcwKwYDVR0RBCQwIoIPd3d3LmcxMGNvZGUuY29tgg9mdHAuZzEwY29kZS5j + b20wDQYJKoZIhvcNAQEEBQADggIBAAj5XAHCtzQR8PV6PkQBgZqUCbcfxGO/ZIp9 + aIT6J2z0Jo1OZI6KmConbqnZG9WyDlV5P7msQXW/Z9nBfoj4KSmNR8G/wtb8ClJn + W8s75+K3ZLq1UgEyxBDrS7GjtbVaj7gsfZsuiQzxmk9lbl1gbkpJ3VEMjwVCTMlM + fpjp8etyPhUZqOZaoKVaq//KTOsjhPMwz7TcfOkHvXketPrWTcefJQU7NKLH16D3 + mZAwnBxp3P51H6E6VG8AoJO8xCBuVwsbXKEf/FW+tmKG9pog6CaZQ9WibROTtnKj + NJjSBsrUk5C+JowO/EyZRGm6R1tlok8iFXj+2aimyeBqDcxozNmFgh9F3S5u0wK0 + 6cfYgkPVMHxgwV3f3Qh+tJkgLExN7KfO9hvpZqAh+CLQtxVmvpxEVEXKR6nwBI5U + BaseulvVy3wUfg2daPkG17kDDBzQlsWC0BRF8anH+FWSrvseC3nS0a9g3sXF1Ic3 + gIqeAMhkant1Ac3RR6YCWtJKr2rcQNdDAxXK35/gUSQNCi9dclEzoOgjziuA1Mha + 94jYcvGKcwThn0iITVS5hOsCfaySBLxTzfIruLbPxXlpWuCW/6I/7YyivppKgEZU + rUTFlNElRXCwIl0YcJkIaYYqWf7+A/aqYJCi8+51usZwMy3Jsq3hJ6MA3h1BgwZs + Rtct3tIX + -----END CERTIFICATE----- + gpgsm: issuer certificate (#/CN=CAcert Class 3 Ro[...]) not found + gpgsm: certificate imported + + gpgsm: total number processed: 1 + gpgsm: imported: 1 + at end example + at end cartouche + +gpgsm tells you that it has imported the certificate. It is now +associated with the key you used when creating the request. The root +certificate has not been found, so you may want to import it from the +CACert website. + +To see the content of your certificate, you may now enter: + + at cartouche + at example + $ gpgsm -K kerckhoffs.g10code.com + /home/foo/.gnupg/pubring.kbx + --------------------------- + Serial number: 4C + Issuer: /CN=CAcert Class 3 Root/OU=http:\x2f\x2fwww.[...] + Subject: /CN=kerckhoffs.g10code.com + aka: (dns-name www.g10code.com) + aka: (dns-name ftp.g10code.com) + validity: 2005-10-28 16:20:51 through 2007-10-28 16:20:51 + key type: 1024 bit RSA + key usage: digitalSignature keyEncipherment + ext key usage: clientAuth (suggested), serverAuth (suggested), [...] + fingerprint: 0F:9C:27:B2:DA:05:5F:CB:33:19:D8:E9:65:B9:BD:4F:B1:98:CC:57 + at end example + at end cartouche + +I used @option{-K} above because this will only list certificates for +which a private key is available. To see more details, you may use + at option{--dump-secret-keys} instead of @option{-K}. + + +To make actual use of the certificate you need to install it on your +server. Server software usally expects a PKCS\#12 file with key and +certificate. To create such a file, run: + + at cartouche + at example + $ gpgsm --export-secret-key-p12 -a >kerckhoffs-cert.pem + at end example + at end cartouche + +You will be asked for the passphrase as well as for a new passphrase to +be used to protect the PKCS\#12 file. The file now contains the +certificate as well as the private key: + + at cartouche + at example + $ cat kerckhoffs-cert.pem + Issuer ...: /CN=CAcert Class 3 Root/OU=http:\x2f\x2fwww.CA[...] + Serial ...: 4C + Subject ..: /CN=kerckhoffs.g10code.com + aka ..: (dns-name www.g10code.com) + aka ..: (dns-name ftp.g10code.com) + + -----BEGIN PKCS12----- + MIIHlwIBAzCCB5AGCSqGSIb37QdHAaCCB4EEggd9MIIHeTk1BJ8GCSqGSIb3DQEu + [...many more lines...] + -----END PKCS12----- + $ + at end example + at end cartouche + +Copy this file in a secure way to the server, install it there and +delete the file then. You may export the file again at any time as long +as it is available in GnuPG's private key database. + + Added: trunk/doc/howtos.texi =================================================================== --- trunk/doc/howtos.texi 2007-05-08 08:15:55 UTC (rev 4497) +++ trunk/doc/howtos.texi 2007-05-08 13:59:41 UTC (rev 4498) @@ -0,0 +1,15 @@ + at c Copyright (C) 2007 Free Software Foundation, Inc. + at c This is part of the GnuPG manual. + at c For copying conditions, see the file gnupg.texi. + + at node Howtos + at chapter How to do certain things + +This is a collection of small howto documents. + + at menu +* Howto Create a Server Cert:: Creating a TLS server certificate. + at end menu + + + at include howto-create-a-server-cert.texi From cvs at cvs.gnupg.org Wed May 9 13:34:26 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 09 May 2007 13:34:26 +0200 Subject: [svn] GnuPG - r4500 - tags Message-ID: Author: wk Date: 2007-05-09 13:33:57 +0200 (Wed, 09 May 2007) New Revision: 4500 Added: tags/gnupg-2.0.4/ Log: Tagged new released Copied: tags/gnupg-2.0.4 (from rev 4499, trunk) From cvs at cvs.gnupg.org Wed May 9 20:14:00 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 09 May 2007 20:14:00 +0200 Subject: [svn] gcry - r1251 - in trunk: . mpi Message-ID: Author: marcus Date: 2007-05-09 20:13:31 +0200 (Wed, 09 May 2007) New Revision: 1251 Modified: trunk/ChangeLog trunk/configure.ac trunk/mpi/ChangeLog trunk/mpi/Makefile.am trunk/mpi/config.links Log: 2007-05-09 Marcus Brinkmann * configure.ac (ac_cv_mpi_config_done): Unused variable removed. (ac_cv_mpi_mod_list, MPI_MOD_LIST_LO, MPI_MOD_LIST_O): Removed. (MPI_MOD_ASM_MPIH_ADD1, MPI_MOD_ASM_MPIH_SUB1, MPI_MOD_ASM_MPIH_MUL1, MPI_MOD_ASM_MPIH_MUL2, MPI_MOD_ASM_MPIH_MUL3, MPI_MOD_ASM_MPIH_LSHIFT, MPI_MOD_ASM_MPIH_RSHIFT, MPI_MOD_ASM_MPIH_UDIV, MPI_MOD_ASM_MPIH_UDIV_QRNND, MPI_MOD_C_MPIH_ADD1, MPI_MOD_C_MPIH_SUB1, MPI_MOD_C_MPIH_MUL1, MPI_MOD_C_MPIH_MUL2, MPI_MOD_C_MPIH_MUL3, MPI_MOD_C_MPIH_LSHIFT, MPI_MOD_C_MPIH_RSHIFT, MPI_MOD_C_MPIH_UDIV, MPI_MOD_C_MPIH_UDIV_QRNND): New automake variables. mpi/ 2007-05-09 Marcus Brinkmann * config.links: Rename assembler file links by suffixing "-asm". * Makefile.am (CCASCOMPILE, LTCCASCOMPILE, CLEANFILES, libmpi_la_LIBADD, libmpi_la_DEPENDENCIES, SUFFIXES, .S.o, .S.obj, .S.lo): Removed variables and targets. (mpih_add1, mpih_sub1, mpih_mul1, mpih_mul2, mpih_mul3, mpih_lshift, mpih_rshift, mpih_udiv, mpih_udiv_qrnnd, nodist_libmpi_la_SOURCES): New variables. (DISTCLEANFILES): Rename assembler file links by suffixing "-asm". Add variants for C file links. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-04 11:01:17 UTC (rev 1250) +++ trunk/ChangeLog 2007-05-09 18:13:31 UTC (rev 1251) @@ -1,3 +1,17 @@ +2007-05-09 Marcus Brinkmann + + * configure.ac (ac_cv_mpi_config_done): Unused variable removed. + (ac_cv_mpi_mod_list, MPI_MOD_LIST_LO, MPI_MOD_LIST_O): Removed. + (MPI_MOD_ASM_MPIH_ADD1, MPI_MOD_ASM_MPIH_SUB1, + MPI_MOD_ASM_MPIH_MUL1, MPI_MOD_ASM_MPIH_MUL2, + MPI_MOD_ASM_MPIH_MUL3, MPI_MOD_ASM_MPIH_LSHIFT, + MPI_MOD_ASM_MPIH_RSHIFT, MPI_MOD_ASM_MPIH_UDIV, + MPI_MOD_ASM_MPIH_UDIV_QRNND, MPI_MOD_C_MPIH_ADD1, + MPI_MOD_C_MPIH_SUB1, MPI_MOD_C_MPIH_MUL1, MPI_MOD_C_MPIH_MUL2, + MPI_MOD_C_MPIH_MUL3, MPI_MOD_C_MPIH_LSHIFT, MPI_MOD_C_MPIH_RSHIFT, + MPI_MOD_C_MPIH_UDIV, MPI_MOD_C_MPIH_UDIV_QRNND): New automake + variables. + 2007-05-04 Werner Koch Released 1.3.0. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-04 11:01:17 UTC (rev 1250) +++ trunk/configure.ac 2007-05-09 18:13:31 UTC (rev 1251) @@ -674,27 +674,34 @@ if test -f $srcdir/mpi/config.links ; then . $srcdir/mpi/config.links AC_CONFIG_LINKS("$mpi_ln_list") - ac_cv_mpi_mod_list="$mpi_mod_list" ac_cv_mpi_sflags="$mpi_sflags" - ac_cv_mpi_config_done="yes" AC_MSG_RESULT(done) else AC_MSG_RESULT(failed) AC_MSG_ERROR([mpi/config.links missing!]) fi -MPI_MOD_LIST_LO="" -MPI_MOD_LIST_O="" -if test "$ac_cv_mpi_mod_list" != ""; then - for i in $ac_cv_mpi_mod_list; do - MPI_MOD_LIST_LO="$MPI_MOD_LIST_LO $i.lo" - MPI_MOD_LIST_O="$MPI_MOD_LIST_O $i.o" - done -fi -AC_SUBST(MPI_MOD_LIST_LO) -AC_SUBST(MPI_MOD_LIST_O) MPI_SFLAGS="$ac_cv_mpi_sflags" AC_SUBST(MPI_SFLAGS) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_ADD1, test "$mpi_mod_asm_mpih_add1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_SUB1, test "$mpi_mod_asm_mpih_sub1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL1, test "$mpi_mod_asm_mpih_mul1" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL2, test "$mpi_mod_asm_mpih_mul2" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_mpih_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_mpih_udiv_qrnnd" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL2, test "$mpi_mod_c_mpih_mul2" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes) +AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_mpih_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_mpih_udiv_qrnnd" = yes) + # Allow users to append something to the version string without # flagging it as development version. The user version part is # considered everything after a dash. Modified: trunk/mpi/ChangeLog =================================================================== --- trunk/mpi/ChangeLog 2007-05-04 11:01:17 UTC (rev 1250) +++ trunk/mpi/ChangeLog 2007-05-09 18:13:31 UTC (rev 1251) @@ -1,3 +1,15 @@ +2007-05-09 Marcus Brinkmann + + * config.links: Rename assembler file links by suffixing "-asm". + * Makefile.am (CCASCOMPILE, LTCCASCOMPILE, CLEANFILES, + libmpi_la_LIBADD, libmpi_la_DEPENDENCIES, SUFFIXES, .S.o, .S.obj, + .S.lo): Removed variables and targets. + (mpih_add1, mpih_sub1, mpih_mul1, mpih_mul2, mpih_mul3, + mpih_lshift, mpih_rshift, mpih_udiv, mpih_udiv_qrnnd, + nodist_libmpi_la_SOURCES): New variables. + (DISTCLEANFILES): Rename assembler file links by suffixing "-asm". + Add variants for C file links. + 2007-05-04 Werner Koch * config.links (path): Allowthe sue of colons as delimiters. Modified: trunk/mpi/Makefile.am =================================================================== --- trunk/mpi/Makefile.am 2007-05-04 11:01:17 UTC (rev 1250) +++ trunk/mpi/Makefile.am 2007-05-09 18:13:31 UTC (rev 1251) @@ -29,23 +29,17 @@ AM_ASFLAGS = $(MPI_SFLAGS) AM_CCASFLAGS = $(NOEXECSTACK_FLAGS) - -# We don't have .S sources listed, so automake does not autocreate these -CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) -LTCCASCOMPILE = $(LIBTOOL) --mode=compile $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) - - EXTRA_DIST = Manifest config.links DISTCLEANFILES = mpi-asm-defs.h \ - mpih-add1.S mpih-mul1.S mpih-mul2.S mpih-mul3.S \ - mpih-lshift.S mpih-rshift.S mpih-sub1.S asm-syntax.h \ + mpih-add1-asm.S mpih-mul1-asm.S mpih-mul2-asm.S mpih-mul3-asm.S \ + mpih-lshift-asm.S mpih-rshift-asm.S mpih-sub1-asm.S asm-syntax.h \ + mpih-add1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c \ + mpih-lshift.c mpih-rshift.c mpih-sub1.c \ sysdep.h mod-source-info.h -# Note: we only use .S files so we should delete all left over .s -CLEANFILES = _*.s __*.s # Beware: The following list is not a comment but grepped by # config.links to get the list of symlinked modules -# Optional modules are marked with a 0 in the second column. +# Optional modules are marked with an O in the second column. #BEGIN_ASM_LIST # mpih-add1 C # mpih-sub1 C @@ -65,99 +59,102 @@ # And we need to have conditionals for all modules because # we don't know whether they are .c or .S. Very ugly; I know. # Remember to define them all in configure.ac -# if MPI_MOD_ASM_MPIH_ADD1 -# mpih_add1 = mpih-add1.S -# else -# if MPI_MOD_C_MPIH_ADD1 -# mpih_add1 = mpih-add1.c -# else -# mpih_add1 = -# endif -# endif -# -# if MPI_MOD_ASM_MPIH_SUB1 -# mpih_sub1 = mpih-sub1.S -# else -# if MPI_MOD_C_MPIH_SUB1 -# mpih_sub1 = mpih-sub1.c -# else -# mpih_sub1 = -# endif -# endif -# -# if MPI_MOD_ASM_MPIH_MUL1 -# mpih_mul1 = mpih-mul1.S -# else -# if MPI_MOD_C_MPIH_MUL1 -# mpih_mul1 = mpih-mul1.c -# else -# mpih_mul1 = -# endif -# endif -# -# if MPI_MOD_ASM_MPIH_MUL2 -# mpih_mul2 = mpih-mul2.S -# else -# if MPI_MOD_C_MPIH_MUL2 -# mpih_mul2 = mpih-mul2.c -# else -# mpih_mul2 = -# endif -# endif -# -# if MPI_MOD_ASM_MPIH_MUL3 -# mpih_mul3 = mpih-mul3.S -# else -# if MPI_MOD_C_MPIH_MUL3 -# mpih_mul3 = mpih-mul3.c -# else -# mpih_mul3 = -# endif -# endif -# -# if MPI_MOD_ASM_MPIH_LSHIFT -# mpih_lshift = mpih-lshift.S -# else -# if MPI_MOD_C_MPIH_LSHIFT -# mpih_lshift = mpih-lshift.c -# else -# mpih_lshift = -# endif -# endif -# -# if MPI_MOD_ASM_MPIH_RSHIFT -# mpih_rshift = mpih-rshift.S -# else -# if MPI_MOD_C_MPIH_RSHIFT -# mpih_rshift = mpih-rshift.c -# else -# mpih_rshift = -# endif -# endif -# -# if MPI_MOD_ASM_UDIV -# udiv = udiv.S -# else -# if MPI_MOD_C_UDIV -# udiv = udiv.c -# else -# udiv = -# endif -# endif -# -# if MPI_MOD_ASM_UDIV_QRNND -# udiv_qrnnd = udiv-qrnnd.S -# else -# if MPI_MOD_C_UDIV_QRNND -# udiv_qrnnd = udiv-qrnnd.c -# else -# udiv_qrnnd = -# endif -# endif +if MPI_MOD_ASM_MPIH_ADD1 +mpih_add1 = mpih-add1-asm.S +else +if MPI_MOD_C_MPIH_ADD1 +mpih_add1 = mpih-add1.c +else +mpih_add1 = +endif +endif +if MPI_MOD_ASM_MPIH_SUB1 +mpih_sub1 = mpih-sub1-asm.S +else +if MPI_MOD_C_MPIH_SUB1 +mpih_sub1 = mpih-sub1.c +else +mpih_sub1 = +endif +endif + +if MPI_MOD_ASM_MPIH_MUL1 +mpih_mul1 = mpih-mul1-asm.S +else +if MPI_MOD_C_MPIH_MUL1 +mpih_mul1 = mpih-mul1.c +else +mpih_mul1 = +endif +endif + +if MPI_MOD_ASM_MPIH_MUL2 +mpih_mul2 = mpih-mul2-asm.S +else +if MPI_MOD_C_MPIH_MUL2 +mpih_mul2 = mpih-mul2.c +else +mpih_mul2 = +endif +endif + +if MPI_MOD_ASM_MPIH_MUL3 +mpih_mul3 = mpih-mul3-asm.S +else +if MPI_MOD_C_MPIH_MUL3 +mpih_mul3 = mpih-mul3.c +else +mpih_mul3 = +endif +endif + +if MPI_MOD_ASM_MPIH_LSHIFT +mpih_lshift = mpih-lshift-asm.S +else +if MPI_MOD_C_MPIH_LSHIFT +mpih_lshift = mpih-lshift.c +else +mpih_lshift = +endif +endif + +if MPI_MOD_ASM_MPIH_RSHIFT +mpih_rshift = mpih-rshift-asm.S +else +if MPI_MOD_C_MPIH_RSHIFT +mpih_rshift = mpih-rshift.c +else +mpih_rshift = +endif +endif + +if MPI_MOD_ASM_UDIV +udiv = udiv-asm.S +else +if MPI_MOD_C_UDIV +udiv = udiv.c +else +udiv = +endif +endif + +if MPI_MOD_ASM_UDIV_QRNND +udiv_qrnnd = udiv-qrnnd-asm.S +else +if MPI_MOD_C_UDIV_QRNND +udiv_qrnnd = udiv-qrnnd.c +else +udiv_qrnnd = +endif +endif + noinst_LTLIBRARIES = libmpi.la libmpi_la_LDFLAGS = +nodist_libmpi_la_SOURCES = $(mpih_add1) $(mpih_sub1) $(mpih_mul1) \ + $(mpih_mul2) $(mpih_mul3) $(mpih_lshift) $(mpih_rshift) \ + $(udiv) $(udiv_qrnnd) libmpi_la_SOURCES = longlong.h \ mpi-add.c \ mpi-bit.c \ @@ -178,29 +175,3 @@ mpih-mul.c \ mpiutil.c \ ec.c - -libmpi_la_LIBADD = @MPI_MOD_LIST_LO@ -libmpi_la_DEPENDENCIES = @MPI_MOD_LIST_LO@ - - -# Because we are circumventing automake with regards to assembler -# files, we have to define our own rules. - -SUFFIXES = .S .o .obj .lo - -.S.o: - $(CPP) $(INCLUDES) $(AM_CPPFLAGS) $(DEFS) \ - `test -f '$<' || echo '$(srcdir)/'`$< \ - | grep -v '^#' > $*.s - $(CCASCOMPILE) -c `test -f '$*.s' || echo '$(srcdir)/'`$*.s - rm $*.s - -.S.obj: - $(CCASCOMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` - -.S.lo: - $(CPP) $(INCLUDES) $(AM_CPPFLAGS) $(DEFS) \ - `test -f '$<' || echo '$(srcdir)/'`$< \ - | grep -v '^#' > $*.s - $(LTCCASCOMPILE) -c -o $@ `test -f '$*.s' || echo '$(srcdir)/'`$*.s - rm $*.s Modified: trunk/mpi/config.links =================================================================== --- trunk/mpi/config.links 2007-05-04 11:01:17 UTC (rev 1250) +++ trunk/mpi/config.links 2007-05-09 18:13:31 UTC (rev 1251) @@ -334,7 +334,7 @@ rm -f $srcdir/mpi/$fn.[Sc] if test -f $srcdir/mpi/$dir/$fn.S ; then echo " \":$dir/$fn.S\"" >>./mpi/mod-source-info.h - mpi_ln_list="$mpi_ln_list mpi/$fn.S:mpi/$dir/$fn.S" + mpi_ln_list="$mpi_ln_list mpi/$fn-asm.S:mpi/$dir/$fn.S" eval mpi_mod_asm_${fnu}=yes mpi_mod_list="$mpi_mod_list $fn" break; From cvs at cvs.gnupg.org Thu May 10 00:20:56 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 10 May 2007 00:20:56 +0200 Subject: [svn] gcry - r1252 - in trunk: cipher src Message-ID: Author: marcus Date: 2007-05-10 00:20:26 +0200 (Thu, 10 May 2007) New Revision: 1252 Modified: trunk/cipher/ChangeLog trunk/cipher/ac.c trunk/src/ChangeLog trunk/src/gcrypt.h.in Log: src/ 2007-05-09 Marcus Brinkmann * gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark all members as internal (actually: deprecated). cipher/ 2007-05-09 Marcus Brinkmann * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read): Adjust users of gcry_ac_io_t because union is not anonymous anymore. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-05-09 18:13:31 UTC (rev 1251) +++ trunk/cipher/ChangeLog 2007-05-09 22:20:26 UTC (rev 1252) @@ -1,3 +1,9 @@ +2007-05-09 Marcus Brinkmann + + * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read): + Adjust users of gcry_ac_io_t because union is not anonymous + anymore. + 2007-05-02 Werner Koch * camellia-glue.c (camellia_setkey, camellia_encrypt) Modified: trunk/cipher/ac.c =================================================================== --- trunk/cipher/ac.c 2007-05-09 18:13:31 UTC (rev 1251) +++ trunk/cipher/ac.c 2007-05-09 22:20:26 UTC (rev 1252) @@ -946,13 +946,13 @@ switch (type) { case GCRY_AC_IO_STRING: - ac_io->readable.string.data = va_arg (ap, unsigned char *); - ac_io->readable.string.data_n = va_arg (ap, size_t); + ac_io->io.readable.string.data = va_arg (ap, unsigned char *); + ac_io->io.readable.string.data_n = va_arg (ap, size_t); break; case GCRY_AC_IO_CALLBACK: - ac_io->readable.callback.cb = va_arg (ap, gcry_ac_data_read_cb_t); - ac_io->readable.callback.opaque = va_arg (ap, void *); + ac_io->io.readable.callback.cb = va_arg (ap, gcry_ac_data_read_cb_t); + ac_io->io.readable.callback.opaque = va_arg (ap, void *); break; } break; @@ -960,13 +960,13 @@ switch (type) { case GCRY_AC_IO_STRING: - ac_io->writable.string.data = va_arg (ap, unsigned char **); - ac_io->writable.string.data_n = va_arg (ap, size_t *); + ac_io->io.writable.string.data = va_arg (ap, unsigned char **); + ac_io->io.writable.string.data_n = va_arg (ap, size_t *); break; case GCRY_AC_IO_CALLBACK: - ac_io->writable.callback.cb = va_arg (ap, gcry_ac_data_write_cb_t); - ac_io->writable.callback.opaque = va_arg (ap, void *); + ac_io->io.writable.callback.cb = va_arg (ap, gcry_ac_data_write_cb_t); + ac_io->io.writable.callback.opaque = va_arg (ap, void *); break; } break; @@ -1022,18 +1022,18 @@ { unsigned char *p; - if (*ac_io->writable.string.data) + if (*ac_io->io.writable.string.data) { - p = gcry_realloc (*ac_io->writable.string.data, - *ac_io->writable.string.data_n + buffer_n); + p = gcry_realloc (*ac_io->io.writable.string.data, + *ac_io->io.writable.string.data_n + buffer_n); if (! p) err = gcry_error_from_errno (errno); else { - if (*ac_io->writable.string.data != p) - *ac_io->writable.string.data = p; - memcpy (p + *ac_io->writable.string.data_n, buffer, buffer_n); - *ac_io->writable.string.data_n += buffer_n; + if (*ac_io->io.writable.string.data != p) + *ac_io->io.writable.string.data = p; + memcpy (p + *ac_io->io.writable.string.data_n, buffer, buffer_n); + *ac_io->io.writable.string.data_n += buffer_n; } } else @@ -1047,16 +1047,16 @@ else { memcpy (p, buffer, buffer_n); - *ac_io->writable.string.data = p; - *ac_io->writable.string.data_n = buffer_n; + *ac_io->io.writable.string.data = p; + *ac_io->io.writable.string.data_n = buffer_n; } } } break; case GCRY_AC_IO_CALLBACK: - err = (*ac_io->writable.callback.cb) (ac_io->writable.callback.opaque, - buffer, buffer_n); + err = (*ac_io->io.writable.callback.cb) (ac_io->io.writable.callback.opaque, + buffer, buffer_n); break; } @@ -1084,7 +1084,7 @@ size_t bytes_to_read; size_t bytes_wanted; - bytes_available = ac_io->readable.string.data_n - nread; + bytes_available = ac_io->io.readable.string.data_n - nread; bytes_wanted = *buffer_n; if (bytes_wanted > bytes_available) @@ -1092,15 +1092,15 @@ else bytes_to_read = bytes_wanted; - memcpy (buffer, ac_io->readable.string.data + nread, bytes_to_read); + memcpy (buffer, ac_io->io.readable.string.data + nread, bytes_to_read); *buffer_n = bytes_to_read; err = 0; break; } case GCRY_AC_IO_CALLBACK: - err = (*ac_io->readable.callback.cb) (ac_io->readable.callback.opaque, - buffer, buffer_n); + err = (*ac_io->io.readable.callback.cb) + (ac_io->io.readable.callback.opaque, buffer, buffer_n); break; } Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-09 18:13:31 UTC (rev 1251) +++ trunk/src/ChangeLog 2007-05-09 22:20:26 UTC (rev 1252) @@ -1,3 +1,8 @@ +2007-05-09 Marcus Brinkmann + + * gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark + all members as internal (actually: deprecated). + 2007-05-04 Werner Koch * Makefile.am (.rc.lo): New to replace gmake specific suffix rule. Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2007-05-09 18:13:31 UTC (rev 1251) +++ trunk/src/gcrypt.h.in 2007-05-09 22:20:26 UTC (rev 1252) @@ -101,6 +101,15 @@ #define _GCRY_GCC_ATTR_MALLOC #endif +/* Some members in a public type should only be used internally. + There is no "internal" attribute, so we abuse the deprecated + attribute to discourage external use. */ +#ifdef _GCRYPT_IN_LIBGCRYPT +#define _GCRY_ATTR_INTERNAL +#else +#define _GCRY_ATTR_INTERNAL _GCRY_GCC_ATTR_DEPRECATED +#endif + /* Wrappers for the libgpg-error library. */ typedef gpg_error_t gcry_error_t; @@ -1253,8 +1262,8 @@ typedef struct gcry_ac_io { /* This is an INTERNAL structure, do NOT use manually. */ - gcry_ac_io_mode_t mode; - gcry_ac_io_type_t type; + gcry_ac_io_mode_t mode _GCRY_ATTR_INTERNAL; + gcry_ac_io_type_t type _GCRY_ATTR_INTERNAL; union { union @@ -1285,7 +1294,7 @@ } string; void *opaque; } writable; - }; + } io _GCRY_ATTR_INTERNAL; } gcry_ac_io_t; From cvs at cvs.gnupg.org Thu May 10 16:42:45 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 10 May 2007 16:42:45 +0200 Subject: [svn] pinentry - r157 - in trunk: . pinentry Message-ID: Author: marcus Date: 2007-05-10 16:42:16 +0200 (Thu, 10 May 2007) New Revision: 157 Modified: trunk/ChangeLog trunk/pinentry/pinentry-curses.c Log: 2007-05-10 Marcus Brinkmann * pinentry/pinentry-curses.c (dialog_create): Re-add calculation of cancel button position. Adjust calculation of OK button position if it is the only one used. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-04-13 00:06:55 UTC (rev 156) +++ trunk/ChangeLog 2007-05-10 14:42:16 UTC (rev 157) @@ -1,3 +1,9 @@ +2007-05-10 Marcus Brinkmann + + * pinentry/pinentry-curses.c (dialog_create): Re-add calculation + of cancel button position. Adjust calculation of OK button + position if it is the only one used. + 2007-04-13 Marcus Brinkmann * qt/secqlineedit.h (SecQLineEdit::contextMenuEvent, Modified: trunk/pinentry/pinentry-curses.c =================================================================== --- trunk/pinentry/pinentry-curses.c 2007-04-13 00:06:55 UTC (rev 156) +++ trunk/pinentry/pinentry-curses.c 2007-05-10 14:42:16 UTC (rev 157) @@ -404,18 +404,29 @@ } move (ypos, xpos); addch (ACS_VLINE); - dialog->ok_y = ypos; - /* Calculating the left edge of the left button, rounding down. */ - dialog->ok_x = xpos + 2 + ((x - 4) / 2 - strlen (dialog->ok)) / 2; - move (dialog->ok_y, dialog->ok_x); - addstr (dialog->ok); - if ( dialog->cancel) + + if (dialog->cancel) { + dialog->ok_y = ypos; + /* Calculating the left edge of the left button, rounding down. */ + dialog->ok_x = xpos + 2 + ((x - 4) / 2 - strlen (dialog->ok)) / 2; + move (dialog->ok_y, dialog->ok_x); + addstr (dialog->ok); + dialog->cancel_y = ypos; /* Calculating the left edge of the right button, rounding up. */ + dialog->cancel_x = xpos + x - 2 - ((x - 4) / 2 + strlen (dialog->cancel)) / 2; move (dialog->cancel_y, dialog->cancel_x); addstr (dialog->cancel); } + else + { + dialog->ok_y = ypos; + /* Calculating the left edge of the OK button, rounding down. */ + dialog->ok_x = xpos + x / 2 - strlen (dialog->ok) / 2; + move (dialog->ok_y, dialog->ok_x); + addstr (dialog->ok); + } out: if (description) From cvs at cvs.gnupg.org Thu May 10 19:37:37 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 10 May 2007 19:37:37 +0200 Subject: [svn] pinentry - r158 - in trunk: . pinentry Message-ID: Author: marcus Date: 2007-05-10 19:37:07 +0200 (Thu, 10 May 2007) New Revision: 158 Modified: trunk/ChangeLog trunk/NEWS trunk/README trunk/pinentry/pinentry-curses.c trunk/pinentry/pinentry.c trunk/pinentry/pinentry.h Log: 2007-05-10 Marcus Brinkmann * pinentry/pinentry.h (pinentry_color_t): New type. (struct pinentry): New members COLOR_FG, COLOR_FG_BRIGHT, COLOR_BG, COLOR_SO. * pinentry/pinentry.c (pinentry_parse_opts): Support new option --colors. (parse_color): New function. * pinentry/pinentry-curses.c (USE_COLORS): New macro. (pinentry_color): New static variable. (dialog_create): Redo color management. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-10 14:42:16 UTC (rev 157) +++ trunk/ChangeLog 2007-05-10 17:37:07 UTC (rev 158) @@ -1,5 +1,14 @@ 2007-05-10 Marcus Brinkmann + * pinentry/pinentry.h (pinentry_color_t): New type. + (struct pinentry): New members COLOR_FG, COLOR_FG_BRIGHT, + COLOR_BG, COLOR_SO. + * pinentry/pinentry.c (pinentry_parse_opts): Support new option --colors. + (parse_color): New function. + * pinentry/pinentry-curses.c (USE_COLORS): New macro. + (pinentry_color): New static variable. + (dialog_create): Redo color management. + * pinentry/pinentry-curses.c (dialog_create): Re-add calculation of cancel button position. Adjust calculation of OK button position if it is the only one used. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-10 14:42:16 UTC (rev 157) +++ trunk/NEWS 2007-05-10 17:37:07 UTC (rev 158) @@ -7,7 +7,10 @@ * New Assuan option touch-file to set a file which will be touched after ncurses does not need the display anymore. + * New option --colors=FG,BG,SO to set the colors for the curses + pinentry. + Noteworthy changes in version 0.7.2 (2005-01-27) ------------------------------------------------ Modified: trunk/README =================================================================== --- trunk/README 2007-05-10 14:42:16 UTC (rev 157) +++ trunk/README 2007-05-10 17:37:07 UTC (rev 158) @@ -40,3 +40,29 @@ For security reasons, all internationalization has been removed. The client is expected to tell the PIN entry the text strings to be displayed. + + +Curses Pinentry +--------------- + +The curses pinentry supports colors if the terminal does. The colors +can be specified by the --colors=FG,BG,SO option, which sets the +foreground, background and standout colors respectively. The standout +color is used for error messages. Colors can be named by any of +"black", "red", "green", "yellow", "blue", "magenta", "cyan" and +"white". The foreground and standout color can be prefixed by +"bright-", "bright", "bold-" and "bold", and any of these prefixes has +the same effect of making the color bolder or brighter. Two special +color names are defined as well: "default" chooses the default color, +and "none" disables use of colors. The name "none" is only meaningful +for the standout color and in this case a reversed effect is used for +error messages. For the other colors, disabling colors means the same +as using the defaults. The default colors are as follows: + + Foreground: Terminal default + Background: Terminal default + Standout: Bright red + +Note that color support is limited by the capabilities of the display +terminal. Some color combinations can be very difficult to read, and +please know that colors are perceived differently by different people. Modified: trunk/pinentry/pinentry-curses.c =================================================================== --- trunk/pinentry/pinentry-curses.c 2007-05-10 14:42:16 UTC (rev 157) +++ trunk/pinentry/pinentry-curses.c 2007-05-10 17:37:07 UTC (rev 158) @@ -47,6 +47,10 @@ #define STRING_OK "" #define STRING_CANCEL "" +#define USE_COLORS (has_colors () && COLOR_PAIRS >= 2) +static short pinentry_color[] = { -1, -1, COLOR_BLACK, COLOR_RED, + COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, + COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE }; static int init_screen; typedef enum @@ -352,8 +356,11 @@ move (ypos, xpos); addch (ACS_VLINE); addch (' '); - if (has_colors () && COLOR_PAIRS >= 1) - attron (COLOR_PAIR(1) | A_BOLD); + if (USE_COLORS && pinentry->color_so != PINENTRY_COLOR_NONE) + { + attroff (COLOR_PAIR (1) | (pinentry->color_fg_bright ? A_BOLD : 0)); + attron (COLOR_PAIR (2) | (pinentry->color_so_bright ? A_BOLD : 0)); + } else standout (); for (;*p && *p != '\n'; p++) @@ -362,8 +369,11 @@ i++; addch ((unsigned char) *p); } - if (has_colors () && COLOR_PAIRS >= 1) - attroff (COLOR_PAIR(1) | A_BOLD); + if (USE_COLORS && pinentry->color_so != PINENTRY_COLOR_NONE) + { + attroff (COLOR_PAIR (2) | (pinentry->color_so_bright ? A_BOLD : 0)); + attron (COLOR_PAIR (1) | (pinentry->color_fg_bright ? A_BOLD : 0)); + } else standend (); if (*p == '\n') @@ -610,15 +620,29 @@ nonl (); /* Tell curses not to do NL->CR/NL on output. */ cbreak (); /* Take input chars one at a time, no wait for \n. */ noecho (); /* Don't echo input - in color. */ - refresh (); if (has_colors ()) { start_color (); + use_default_colors (); - if (COLOR_PAIRS >= 1) - init_pair (1, COLOR_RED, COLOR_BLACK); + if (pinentry->color_so == PINENTRY_COLOR_DEFAULT) + { + pinentry->color_so = PINENTRY_COLOR_RED; + pinentry->color_so_bright = 1; + } + if (COLOR_PAIRS >= 2) + { + init_pair (1, pinentry_color[pinentry->color_fg], + pinentry_color[pinentry->color_bg]); + init_pair (2, pinentry_color[pinentry->color_so], + pinentry_color[pinentry->color_bg]); + + bkgd (COLOR_PAIR (1)); + attron (COLOR_PAIR (1) | (pinentry->color_fg_bright ? A_BOLD : 0)); + } } + refresh (); /* XXX */ if (dialog_create (pinentry, &diag)) Modified: trunk/pinentry/pinentry.c =================================================================== --- trunk/pinentry/pinentry.c 2007-05-10 14:42:16 UTC (rev 157) +++ trunk/pinentry/pinentry.c 2007-05-10 17:37:07 UTC (rev 158) @@ -68,7 +68,12 @@ NULL, /* Touch file. */ 0, /* Result. */ 0, /* Locale error flag. */ - 0 /* One-button flag. */ + 0, /* One-button flag. */ + PINENTRY_COLOR_DEFAULT, + 0, + PINENTRY_COLOR_DEFAULT, + PINENTRY_COLOR_DEFAULT, + 0 }; @@ -290,6 +295,56 @@ } +char * +parse_color (char *arg, pinentry_color_t *color_p, int *bright_p) +{ + static struct + { + const char *name; + pinentry_color_t color; + } colors[] = { { "none", PINENTRY_COLOR_NONE }, + { "default", PINENTRY_COLOR_DEFAULT }, + { "black", PINENTRY_COLOR_BLACK }, + { "red", PINENTRY_COLOR_RED }, + { "green", PINENTRY_COLOR_GREEN }, + { "yellow", PINENTRY_COLOR_YELLOW }, + { "blue", PINENTRY_COLOR_BLUE }, + { "magenta", PINENTRY_COLOR_MAGENTA }, + { "cyan", PINENTRY_COLOR_CYAN }, + { "white", PINENTRY_COLOR_WHITE } }; + + int i; + char *new_arg; + pinentry_color_t color = PINENTRY_COLOR_DEFAULT; + + if (!arg) + return NULL; + + new_arg = strchr (arg, ','); + if (new_arg) + new_arg++; + + if (bright_p) + { + const char *bname[] = { "bright-", "bright", "bold-", "bold" }; + + *bright_p = 0; + for (i = 0; i < sizeof (bname) / sizeof (bname[0]); i++) + if (!strncasecmp (arg, bname[i], strlen (bname[i]))) + { + *bright_p = 1; + arg += strlen (bname[i]); + } + } + + for (i = 0; i < sizeof (colors) / sizeof (colors[0]); i++) + if (!strncasecmp (arg, colors[i].name, strlen (colors[i].name))) + color = colors[i].color; + + *color_p = color; + return new_arg; +} + /* Parse the command line options. Returns 1 if user should print version and exit. Can exit the program if only help output is requested. */ @@ -309,6 +364,7 @@ { "enhanced", no_argument, 0, 'e' }, { "no-global-grab", no_argument, 0, 'g' }, { "parent-wid", required_argument, 0, 'W' }, + { "colors", required_argument, 0, 'c' }, { "help", no_argument, 0, 'h' }, { "version", no_argument, &opt_version, 1 }, { NULL, 0, NULL, 0 }}; @@ -380,6 +436,14 @@ /* FIXME: Add some error handling. Use strtol. */ break; + case 'c': + optarg = parse_color (optarg, &pinentry.color_fg, + &pinentry.color_fg_bright); + optarg = parse_color (optarg, &pinentry.color_bg, NULL); + optarg = parse_color (optarg, &pinentry.color_so, + &pinentry.color_so_bright); + break; + default: fprintf (stderr, "%s: oops: option not handled\n", this_pgmname); break; Modified: trunk/pinentry/pinentry.h =================================================================== --- trunk/pinentry/pinentry.h 2007-05-10 14:42:16 UTC (rev 157) +++ trunk/pinentry/pinentry.h 2007-05-10 17:37:07 UTC (rev 158) @@ -28,6 +28,13 @@ #endif #endif +typedef enum { + PINENTRY_COLOR_NONE, PINENTRY_COLOR_DEFAULT, + PINENTRY_COLOR_BLACK, PINENTRY_COLOR_RED, + PINENTRY_COLOR_GREEN, PINENTRY_COLOR_YELLOW, + PINENTRY_COLOR_BLUE, PINENTRY_COLOR_MAGENTA, + PINENTRY_COLOR_CYAN, PINENTRY_COLOR_WHITE +} pinentry_color_t; struct pinentry { @@ -84,6 +91,12 @@ dismiss button is required. */ int one_button; + /* For the curses pinentry, the color of error messages. */ + pinentry_color_t color_fg; + int color_fg_bright; + pinentry_color_t color_bg; + pinentry_color_t color_so; + int color_so_bright; }; typedef struct pinentry *pinentry_t; From cvs at cvs.gnupg.org Mon May 14 10:29:44 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 14 May 2007 10:29:44 +0200 Subject: [svn] ksba - r273 - in trunk: . src Message-ID: Author: wk Date: 2007-05-14 10:29:14 +0200 (Mon, 14 May 2007) New Revision: 273 Modified: trunk/NEWS trunk/TODO trunk/src/ChangeLog trunk/src/cert.c trunk/src/crl.c trunk/src/keyinfo.c trunk/src/ksba.m4 trunk/src/sexp-parse.h trunk/src/util.h Log: src/ * sexp-parse.h (smklen): New. * cert.c: Include sexp-parse.h. (get_name): Use smklen to avoid the snprintf. * ksba.m4: Print found version on success. * crl.c (do_hash): Cast BUFFER to char* for arithmetics. * ksba.h (ksba_stop_reason_t): Remove trailing comma. * asn1-parse.y (CONST_IMPLICIT): Ditto. Reported by Peter O'Gorman. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/NEWS 2007-05-14 08:29:14 UTC (rev 273) @@ -7,7 +7,9 @@ * Experimental support for ECDSA. + * Minor portability fixes. + Noteworthy changes in version 1.0.1 (2006-11-29) ------------------------------------------------ Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/TODO 2007-05-14 08:29:14 UTC (rev 273) @@ -14,8 +14,8 @@ ** should work on a stripped down parse tree -** Allow to specify the desired top element. Or a list so that it - can detect the needed tree itself +** Allow to specify the desired top element. + Or a list so that it can detect the needed tree itself * src/der-encoder.c ** Setting default values is missing @@ -64,3 +64,8 @@ ** Allow fetching of all entry extensions. + + + + + Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/ChangeLog 2007-05-14 08:29:14 UTC (rev 273) @@ -1,3 +1,13 @@ +2007-05-14 Werner Koch + + * sexp-parse.h (smklen): New. + * cert.c: Include sexp-parse.h. + (get_name): Use smklen to avoid the snprintf. + +2007-05-09 Werner Koch + + * ksba.m4: Print found version on success. + 2007-05-01 Werner Koch * crl.c (do_hash): Cast BUFFER to char* for arithmetics. Modified: trunk/src/cert.c =================================================================== --- trunk/src/cert.c 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/cert.c 2007-05-14 08:29:14 UTC (rev 273) @@ -31,8 +31,10 @@ #include "ber-help.h" #include "convert.h" #include "keyinfo.h" +#include "sexp-parse.h" #include "cert.h" + static const char oidstr_subjectKeyIdentifier[] = "2.5.29.14"; static const char oidstr_keyUsage[] = "2.5.29.15"; static const char oidstr_subjectAltName[] = "2.5.29.17"; @@ -664,15 +666,16 @@ } else if (ti.tag == 2 || ti.tag == 6) { /* dNSName or URI - this are implicit IA5_STRINGs */ - char numbuf[30]; + char numbuf[20], *numbufp; + size_t numbuflen; - snprintf (numbuf, DIM(numbuf), "%lu:", ti.length); - p = xtrymalloc (11 + strlen (numbuf) + ti.length + 3); + numbufp = smklen (numbuf, DIM(numbuf), ti.length, &numbuflen); + p = xtrymalloc (11 + numbuflen + ti.length + 3); if (!p) return gpg_error (GPG_ERR_ENOMEM); *result = p; p = stpcpy (p, ti.tag == 2? "(8:dns-name" : "(3:uri"); - p = stpcpy (p, numbuf); + p = stpcpy (p, numbufp); memcpy (p, der, ti.length); p += ti.length; *p++ = ')'; Modified: trunk/src/crl.c =================================================================== --- trunk/src/crl.c 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/crl.c 2007-05-14 08:29:14 UTC (rev 273) @@ -59,7 +59,7 @@ crl->hashbuf.buffer, crl->hashbuf.used); crl->hashbuf.used = 0; } - buffer += n; + buffer = (const char *)buffer + n; length -= n; } } Modified: trunk/src/keyinfo.c =================================================================== --- trunk/src/keyinfo.c 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/keyinfo.c 2007-05-14 08:29:14 UTC (rev 273) @@ -20,8 +20,8 @@ */ /* Instead of using the ASN parser - which is easily possible - we use - a simple handcoded one to speed the oepration up and make it more - robust. */ + a simple handcoded one to speed up the operation and to make it + more robust. */ #include #include Modified: trunk/src/ksba.m4 =================================================================== --- trunk/src/ksba.m4 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/ksba.m4 2007-05-14 08:29:14 UTC (rev 273) @@ -75,7 +75,7 @@ fi fi if test $ok = yes; then - AC_MSG_RESULT(yes) + AC_MSG_RESULT([yes ($ksba_config_version)]) else AC_MSG_RESULT(no) fi Modified: trunk/src/sexp-parse.h =================================================================== --- trunk/src/sexp-parse.h 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/sexp-parse.h 2007-05-14 08:29:14 UTC (rev 273) @@ -1,5 +1,5 @@ /* sexp-parse.h - S-expression helper functions for canonical encodings. - * Copyright (C) 2002, 2003 Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -97,4 +97,34 @@ return 1; } + +/* Format VALUE for use as the length indicatior of an S-expression. + The caler needs to provide a buffer HELP_BUFFER wth a length of + HELP_BUFLEN. The return value is a pointer into HELP_BUFFER with + the formatted length string. The colon and a trailing nul are + appended. HELP_BUFLEN must be at least 3 - a more useful value is + 15. If LENGTH is not NULL, the LENGTH of the resulting string + (excluding the terminating nul) is stored at that address. */ +static inline char * +smklen (char *help_buffer, size_t help_buflen, size_t value, size_t *length) +{ + char *p = help_buffer + help_buflen; + + if (help_buflen >= 3) + { + *--p = 0; + *--p = ':'; + do + { + *--p = '0' + (value % 10); + value /= 10; + } + while (value && p > help_buffer); + } + + if (length) + *length = (help_buffer + help_buflen) - p; + return p; +} + #endif /*SEXP_PARSE_H*/ Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2007-05-01 16:25:43 UTC (rev 272) +++ trunk/src/util.h 2007-05-14 08:29:14 UTC (rev 273) @@ -50,11 +50,12 @@ #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) #ifndef STR - #define STR(v) #v +# define STR(v) #v #endif -#define STR2(v) STR(v) +#ifndef STR2 +# define STR2(v) STR(v) +#endif - #define return_if_fail(expr) do { \ if (!(expr)) { \ fprintf (stderr, "%s:%d: assertion `%s' failed\n", \ @@ -100,9 +101,3 @@ #endif /* UTIL_H */ - - - - - - From cvs at cvs.gnupg.org Tue May 15 01:16:34 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Tue, 15 May 2007 01:16:34 +0200 Subject: [svn] GnuPG - r4501 - branches/STABLE-BRANCH-1-4/checks Message-ID: Author: dshaw Date: 2007-05-15 01:16:05 +0200 (Tue, 15 May 2007) New Revision: 4501 Modified: branches/STABLE-BRANCH-1-4/checks/ChangeLog branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test branches/STABLE-BRANCH-1-4/checks/conventional.test branches/STABLE-BRANCH-1-4/checks/defs.inc branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test branches/STABLE-BRANCH-1-4/checks/encrypt.test Log: * defs.inc (all_cipher_algos): New function to return all ciphers we support. This is safer than the previous setup which could hide that some ciphers weren't being tested. Plus, this automatically tests any new ciphers we may add. * conventional.test, encrypt-test, encrypt-dsa.test, conventional-mdc.test: Use it here. Modified: branches/STABLE-BRANCH-1-4/checks/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/checks/ChangeLog 2007-05-09 11:33:57 UTC (rev 4500) +++ branches/STABLE-BRANCH-1-4/checks/ChangeLog 2007-05-14 23:16:05 UTC (rev 4501) @@ -1,3 +1,13 @@ +2007-05-14 David Shaw + + * defs.inc (all_cipher_algos): New function to return all ciphers + we support. This is safer than the previous setup which could + hide that some ciphers weren't being tested. Plus, this + automatically tests any new ciphers we may add. + + * conventional.test, encrypt-test, encrypt-dsa.test, + conventional-mdc.test: Use it here. + 2007-05-02 David Shaw * conventional.test, encrypt.test, encrypt-dsa.test, Modified: branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test 2007-05-09 11:33:57 UTC (rev 4500) +++ branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test 2007-05-14 23:16:05 UTC (rev 4501) @@ -2,31 +2,10 @@ . $srcdir/defs.inc || exit 3 -algos="3des" - -if have_cipher_algo "IDEA"; then - algos="$algos idea" -fi - -if have_cipher_algo "CAST5"; then - algos="$algos cast5" -fi - -if have_cipher_algo "BLOWFISH"; then - algos="$algos blowfish" -fi - -if have_cipher_algo "AES"; then - algos="$algos aes aes192 aes256" -fi - -if have_cipher_algo "TWOFISH"; then - algos="$algos twofish" -fi - #info Checking conventional encryption -for i in 0 1 2 3 9 10 11 19 20 21 22 23 39 40 41 8192 32000 ; do - for ciph in $algos; do +for ciph in `all_cipher_algos`; do + echo_n "$ciph " + for i in 0 1 2 3 9 10 11 19 20 21 22 23 39 40 41 8192 32000 ; do # *BSD's dd can't cope with a count of 0 if test "$i" = "0"; then : >z @@ -40,3 +19,4 @@ cmp z y || error "$ciph/$i: mismatch" done done +echo_n "| " Modified: branches/STABLE-BRANCH-1-4/checks/conventional.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/conventional.test 2007-05-09 11:33:57 UTC (rev 4500) +++ branches/STABLE-BRANCH-1-4/checks/conventional.test 2007-05-14 23:16:05 UTC (rev 4501) @@ -9,29 +9,8 @@ cmp $i y || error "$i: mismatch" done -algos="3des" - -if have_cipher_algo "IDEA"; then - algos="$algos idea" -fi - -if have_cipher_algo "CAST5"; then - algos="$algos cast5" -fi - -if have_cipher_algo "BLOWFISH"; then - algos="$algos blowfish" -fi - -if have_cipher_algo "AES"; then - algos="$algos aes aes192 aes256" -fi - -if have_cipher_algo "TWOFISH"; then - algos="$algos twofish" -fi - -for a in $algos; do +for a in `all_cipher_algos`; do + echo_n "$a " for i in plain-1 data-80000 ; do echo "Hier spricht HAL" | $GPG --passphrase-fd 0 \ --cipher-algo $a -c -o x --yes $i @@ -39,3 +18,4 @@ cmp $i y || error "$i: ($a) mismatch" done done +echo_n "| " Modified: branches/STABLE-BRANCH-1-4/checks/defs.inc =================================================================== --- branches/STABLE-BRANCH-1-4/checks/defs.inc 2007-05-09 11:33:57 UTC (rev 4500) +++ branches/STABLE-BRANCH-1-4/checks/defs.inc 2007-05-14 23:16:05 UTC (rev 4501) @@ -121,15 +121,6 @@ fi } -have_cipher_algo () { - if ../g10/gpg --homedir . --version | grep "Cipher:.*$1" >/dev/null - then - true - else - false - fi -} - have_hash_algo () { if ../g10/gpg --homedir . --version | grep "Hash:.*$1" >/dev/null then @@ -139,6 +130,10 @@ fi } +all_cipher_algos () { + ../g10/gpg --homedir . --version | grep "Cipher" | sed 's/^Cipher: //; s/,//g' +} + set -e pgmname=`basename $0` #trap cleanup SIGHUP SIGINT SIGQUIT Modified: branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test 2007-05-09 11:33:57 UTC (rev 4500) +++ branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test 2007-05-14 23:16:05 UTC (rev 4501) @@ -9,29 +9,8 @@ cmp $i y || error "$i: mismatch" done -algos="3des" - -if have_cipher_algo "IDEA"; then - algos="$algos idea" -fi - -if have_cipher_algo "CAST5"; then - algos="$algos cast5" -fi - -if have_cipher_algo "BLOWFISH"; then - algos="$algos blowfish" -fi - -if have_cipher_algo "AES"; then - algos="$algos aes aes192 aes256" -fi - -if have_cipher_algo "TWOFISH"; then - algos="$algos twofish" -fi - -for ca in $algos ; do +for ca in `all_cipher_algos` ; do + echo_n "$ca " for i in $plain_files $data_files ; do $GPG $dsa_keyrings --always-trust --cipher-algo $ca -e \ -o x --yes -r "$dsa_usrname2" $i @@ -39,3 +18,4 @@ cmp $i y || error "$i: mismatch" done done +echo_n "| " Modified: branches/STABLE-BRANCH-1-4/checks/encrypt.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/encrypt.test 2007-05-09 11:33:57 UTC (rev 4500) +++ branches/STABLE-BRANCH-1-4/checks/encrypt.test 2007-05-14 23:16:05 UTC (rev 4501) @@ -9,32 +9,12 @@ cmp $i y || error "$i: mismatch" done -algos="3des" - -if have_cipher_algo "IDEA"; then - algos="$algos idea" -fi - -if have_cipher_algo "CAST5"; then - algos="$algos cast5" -fi - -if have_cipher_algo "BLOWFISH"; then - algos="$algos blowfish" -fi - -if have_cipher_algo "AES"; then - algos="$algos aes aes192 aes256" -fi - -if have_cipher_algo "TWOFISH"; then - algos="$algos twofish" -fi - -for ca in $algos ; do +for ca in `all_cipher_algos` ; do + echo_n "$ca " for i in $plain_files $data_files ; do $GPG --always-trust -e -o x --yes -r "$usrname2" --cipher-algo $ca $i $GPG -o y --yes x cmp $i y || error "$i: mismatch" done done +echo_n "| " From cvs at cvs.gnupg.org Tue May 15 18:11:20 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 15 May 2007 18:11:20 +0200 Subject: [svn] GnuPG - r4502 - in trunk: . agent common doc doc/examples gl m4 Message-ID: Author: wk Date: 2007-05-15 18:10:48 +0200 (Tue, 15 May 2007) New Revision: 4502 Added: trunk/common/estream-printf.c trunk/common/estream-printf.h trunk/m4/estream.m4 Removed: trunk/common/vasprintf.c Modified: trunk/ChangeLog trunk/NEWS trunk/README.maint trunk/TODO trunk/agent/ChangeLog trunk/agent/protect.c trunk/common/ChangeLog trunk/common/Makefile.am trunk/common/estream.c trunk/common/estream.h trunk/common/sexp-parse.h trunk/common/sexputil.c trunk/common/util.h trunk/common/xasprintf.c trunk/configure.ac trunk/doc/ChangeLog trunk/doc/examples/gpgconf.conf trunk/doc/gpgsm.texi trunk/gl/Makefile.am trunk/m4/ChangeLog trunk/m4/Makefile.am Log: Use estream_asprintf instead of the GNU asprintf. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/ChangeLog 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,3 +1,9 @@ +2007-05-15 Werner Koch + + * configure.ac: Call ESTREAM_INIT and define the memory + allocators for estream_asprintf. + (gl_MODULES): Remove vasprintf. + 2007-05-09 Werner Koch Released 2.0.4. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/NEWS 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,3 +1,7 @@ +Noteworthy changes in version 2.0.5 +------------------------------------------------ + + Noteworthy changes in version 2.0.4 (2007-05-09) ------------------------------------------------ Modified: trunk/README.maint =================================================================== --- trunk/README.maint 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/README.maint 2007-05-15 16:10:48 UTC (rev 4502) @@ -30,16 +30,18 @@ * Run "./autogen.sh --force" (--force is required for the svn magic in configure.ac and a good idea in any case) + * Run configure as usual. * Run "make distcheck" * Build and test the new tarball (best on a different machine). - * [1.4 only] Build and test the W32 vesion. + * [1.4 only] Build and test the W32 version. + * Using the final test build run a "make -C doc online". * Sign the tarball * Get the previous tarball and run "mkdiff gnupg". You might need to set a different signature key than mine. mkdiff has an option for this. - * If you are satisied with the result tag the release. Use "svn + * If you are satisfied with the result tag the release. Use "svn info" to get the current URL and use an svn cp command similar to - "svn cp svn+ssh://host/gnupg/trunk svn+ssh://host/gnupg/tags/2.n.m" + "svn cp svn+ssh://host/gnupg/trunk svn+ssh://host/gnupg/tags/gnupg-2.n.m" (for 1.4 you should see "branches/STABLE-BRANCH-1-4" instead of "trunk", however tags are all below tags). * Copy the files to the FTP server Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/TODO 2007-05-15 16:10:48 UTC (rev 4502) @@ -121,6 +121,8 @@ scdaemon stays as a zombie and gpg-agent does not perform any more commands. +* Howtos +** Migrate OpenPGP keys to another system Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/agent/ChangeLog 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,3 +1,7 @@ +2007-05-14 Werner Koch + + * protect.c (make_shadow_info): Replace sprintf by smklen. + 2007-04-20 Werner Koch * gpg-agent.c (my_gcry_logger, my_gcry_outofcore_handler): Removed. Modified: trunk/agent/protect.c =================================================================== --- trunk/agent/protect.c 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/agent/protect.c 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,6 +1,6 @@ /* protect.c - Un/Protect a secret key * Copyright (C) 1998, 1999, 2000, 2001, 2002, - * 2003 Free Software Foundation, Inc. + * 2003, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -846,23 +846,21 @@ { const char *s; char *info, *p; - char numbuf[21]; - int n; + char numbuf[20]; + size_t n; for (s=serialno, n=0; *s && s[1]; s += 2) n++; - info = p = xtrymalloc (1 + 21 + n - + 21 + strlen (idstring) + 1 + 1); + info = p = xtrymalloc (1 + sizeof numbuf + n + + sizeof numbuf + strlen (idstring) + 1 + 1); if (!info) return NULL; *p++ = '('; - sprintf (numbuf, "%d:", n); - p = stpcpy (p, numbuf); + p = stpcpy (p, smklen (numbuf, sizeof numbuf, n, NULL)); for (s=serialno; *s && s[1]; s += 2) *(unsigned char *)p++ = xtoi_2 (s); - sprintf (numbuf, "%u:", (unsigned int)strlen (idstring)); - p = stpcpy (p, numbuf); + p = stpcpy (p, smklen (numbuf, sizeof numbuf, strlen (idstring), NULL)); p = stpcpy (p, idstring); *p++ = ')'; *p = 0; Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/ChangeLog 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,3 +1,20 @@ +2007-05-15 Werner Koch + + * util.h: Do not include gnulib's vasprintf. Redefine asprintf + and vasprintf. + + * xasprintf.c (xasprintf, xtryasprintf): Use estream_vasprintf. + + * estream-printf.h, estream-printf.c: New. Taken from current + libestream SVN. + * Makefile.am (common_sources): Add them. + +2007-05-14 Werner Koch + + * sexp-parse.h (smklen): New. + * sexputil.c: Include sexp-parse.h. + (make_simple_sexp_from_hexstr): Replace sprintf by smklen. + 2007-05-07 Werner Koch * signal.c (got_fatal_signal): Protect SIG from being clobbered by Modified: trunk/common/Makefile.am =================================================================== --- trunk/common/Makefile.am 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/Makefile.am 2007-05-15 16:10:48 UTC (rev 4502) @@ -54,7 +54,7 @@ w32reg.c \ signal.c \ dynload.h \ - estream.c estream.h \ + estream.c estream.h estream-printf.c estream-printf.h \ srv.c srv.h \ dns-cert.c dns-cert.h \ pka.c pka.h \ Added: trunk/common/estream-printf.c =================================================================== --- trunk/common/estream-printf.c 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/estream-printf.c 2007-05-15 16:10:48 UTC (rev 4502) @@ -0,0 +1,2139 @@ +/* estream-printf.c - Versatile C-99 compliant printf formatting + * Copyright (C) 2007 g10 Code GmbH + * + * This file is part of Libestream. + * + * Libestream is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * Libestream is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Libestream; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * $Id: estream-printf.c 54 2007-05-15 14:12:06Z wk $ + */ + +/* Required autoconf tests: + + AC_TYPE_LONG_LONG_INT defines HAVE_LONG_LONG_INT + AC_TYPE_LONG_DOUBLE defines HAVE_LONG_DOUBLE + AC_TYPE_INTMAX_T defines HAVE_INTMAX_T + AC_TYPE_UINTMAX_T defines HAVE_UINTMAX_T + AC_CHECK_TYPES([ptrdiff_t]) defines HAVE_PTRDIFF_T + AC_CHECK_SIZEOF([unsigned long]) defines SIZEOF_UNSIGNED_LONG + AC_CHECK_SIZEOF([void *]) defines SIZEOF_VOID_P + HAVE_LANGINFO_THOUSANDS_SEP + + Note that the file estream.m4 provides the autoconf macro + ESTREAM_PRINTF_INIT which runs all required checks. + + + Missing stuff: wchar and wint_t + thousands_sep in pr_float. +*/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T) +# include +#endif +#ifdef HAVE_LANGINFO_THOUSANDS_SEP +#include +#endif +#ifdef TEST +# include +#endif +#ifdef ESTREAM_PRINTF_EXTRA_INCLUDE +#include ESTREAM_PRINTF_EXTRA_INCLUDE +#endif +#include "estream-printf.h" + +/* Allow redefinition of asprintf used malloc functions. */ +#ifdef ESTREAM_ASPRINTF_MALLOC +#define my_asprintf_malloc(a) ESTREAM_ASPRINTF_MALLOC((a)) +#else +#define my_asprintf_malloc(a) malloc((a)) +#endif +#ifdef ESTREAM_ASPRINTF_FREE +#define my_asprintf_free(a) ESTREAM_ASPRINTF_FREE((a)) +#else +#define my_asprintf_free(a) free((a)) +#endif + + +/* Calculate array dimension. */ +#ifndef DIM +#define DIM(array) (sizeof (array) / sizeof (*array)) +#endif + + +/* We allow for that many args without requiring malloced memory. */ +#define DEFAULT_MAX_ARGSPECS 5 + +/* We allow for that many values without requiring malloced memory. */ +#define DEFAULT_MAX_VALUES 8 + +/* We allocate this many new array argspec elements each time. */ +#define ARGSPECS_BUMP_VALUE 10 + +/* Special values for the field width and the precision. */ +#define NO_FIELD_VALUE (-1) +#define STAR_FIELD_VALUE (-2) + +/* Bit valuues used for the conversion flags. */ +#define FLAG_GROUPING 1 +#define FLAG_LEFT_JUST 2 +#define FLAG_PLUS_SIGN 4 +#define FLAG_SPACE_PLUS 8 +#define FLAG_ALT_CONV 16 +#define FLAG_ZERO_PAD 32 + +/* Constants used the length modifiers. */ +typedef enum + { + LENMOD_NONE = 0, + LENMOD_CHAR, /* "hh" */ + LENMOD_SHORT, /* "h" */ + LENMOD_LONG, /* "l" */ + LENMOD_LONGLONG, /* "ll" */ + LENMOD_INTMAX, /* "j" */ + LENMOD_SIZET, /* "z" */ + LENMOD_PTRDIFF, /* "t" */ + LENMOD_LONGDBL /* "L" */ + } lenmod_t; + +/* All the conversion specifiers. */ +typedef enum + { + CONSPEC_UNKNOWN = 0, + CONSPEC_DECIMAL, + CONSPEC_OCTAL, + CONSPEC_UNSIGNED, + CONSPEC_HEX, + CONSPEC_HEX_UP, + CONSPEC_FLOAT, + CONSPEC_FLOAT_UP, + CONSPEC_EXP, + CONSPEC_EXP_UP, + CONSPEC_F_OR_G, + CONSPEC_F_OR_G_UP, + CONSPEC_HEX_EXP, + CONSPEC_HEX_EXP_UP, + CONSPEC_CHAR, + CONSPEC_STRING, + CONSPEC_POINTER, + CONSPEC_STRERROR, + CONSPEC_BYTES_SO_FAR + } conspec_t; + + +/* Constants describing all the suppoorted types. Note that we list + all the types we know about even if certain types are not available + on this system. */ +typedef enum + { + VALTYPE_UNSUPPORTED = 0, /* Artificial type for error detection. */ + VALTYPE_CHAR, + VALTYPE_SCHAR, + VALTYPE_UCHAR, + VALTYPE_SHORT, + VALTYPE_USHORT, + VALTYPE_INT, + VALTYPE_UINT, + VALTYPE_LONG, + VALTYPE_ULONG, + VALTYPE_LONGLONG, + VALTYPE_ULONGLONG, + VALTYPE_DOUBLE, + VALTYPE_LONGDOUBLE, + VALTYPE_STRING, + VALTYPE_INTMAX, + VALTYPE_UINTMAX, + VALTYPE_SIZE, + VALTYPE_PTRDIFF, + VALTYPE_POINTER, + VALTYPE_CHAR_PTR, + VALTYPE_SCHAR_PTR, + VALTYPE_SHORT_PTR, + VALTYPE_INT_PTR, + VALTYPE_LONG_PTR, + VALTYPE_LONGLONG_PTR, + VALTYPE_INTMAX_PTR, + VALTYPE_SIZE_PTR, + VALTYPE_PTRDIFF_PTR + } valtype_t; + + +/* A union used to store the actual values. */ +typedef union +{ + char a_char; + signed char a_schar; + unsigned char a_uchar; + short a_short; + unsigned short a_ushort; + int a_int; + unsigned int a_uint; + long int a_long; + unsigned long int a_ulong; +#ifdef HAVE_LONG_LONG_INT + long long int a_longlong; + unsigned long long int a_ulonglong; +#endif + double a_double; +#ifdef HAVE_LONG_DOUBLE + long double a_longdouble; +#endif + const char *a_string; +#ifdef HAVE_INTMAX_T + intmax_t a_intmax; +#endif +#ifdef HAVE_UINTMAX_T + intmax_t a_uintmax; +#endif + size_t a_size; +#ifdef HAVE_PTRDIFF_T + ptrdiff_t a_ptrdiff; +#endif + void *a_void_ptr; + char *a_char_ptr; + signed char *a_schar_ptr; + short *a_short_ptr; + int *a_int_ptr; + long *a_long_ptr; +#ifdef HAVE_LONG_LONG_INT + long long int *a_longlong_ptr; +#endif +#ifdef HAVE_INTMAX_T + intmax_t *a_intmax_ptr; +#endif + size_t *a_size_ptr; +#ifdef HAVE_PTRDIFF_T + ptrdiff_t *a_ptrdiff_ptr; +#endif +} value_t; + +/* An object used to keep track of a format option and arguments. */ +struct argspec_s +{ + size_t length; /* The length of these args including the percent. */ + unsigned int flags; /* The conversion flags (bits defined by FLAG_foo). */ + int width; /* The field width. */ + int precision; /* The precision. */ + lenmod_t lenmod; /* The length modifier. */ + conspec_t conspec; /* The conversion specifier. */ + int arg_pos; /* The position of the argument. This one may + be -1 to indicate that no value is expected + (e.g. for "%m"). */ + int width_pos; /* The position of the argument for a field + width star's value. 0 for not used. */ + int precision_pos; /* The position of the argument for the a + precision star's value. 0 for not used. */ + valtype_t vt; /* The type of the corresponding argument. */ +}; +typedef struct argspec_s *argspec_t; + +/* An object to build up a table of values and their types. */ +struct valueitem_s +{ + valtype_t vt; /* The type of the value. */ + value_t value; /* The value. */ +}; +typedef struct valueitem_s *valueitem_t; + + +#ifdef TEST +static int verbose; + +static void +dump_argspecs (argspec_t arg, size_t argcount) +{ + int idx; + + for (idx=0; argcount; argcount--, arg++, idx++) + fprintf (stderr, + "%2d: len=%u flags=%u width=%d prec=%d mod=%d " + "con=%d vt=%d pos=%d-%d-%d\n", + idx, + (unsigned int)arg->length, + arg->flags, + arg->width, + arg->precision, + arg->lenmod, + arg->conspec, + arg->vt, + arg->arg_pos, + arg->width_pos, + arg->precision_pos); +} +#endif /*TEST*/ + + +/* Set the vt field for ARG. */ +static void +compute_type (argspec_t arg) +{ + switch (arg->conspec) + { + case CONSPEC_UNKNOWN: + arg->vt = VALTYPE_UNSUPPORTED; + break; + + case CONSPEC_DECIMAL: + switch (arg->lenmod) + { + case LENMOD_CHAR: arg->vt = VALTYPE_SCHAR; break; + case LENMOD_SHORT: arg->vt = VALTYPE_SHORT; break; + case LENMOD_LONG: arg->vt = VALTYPE_LONG; break; + case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break; + case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break; + case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; + case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break; + default: arg->vt = VALTYPE_INT; break; + } + break; + + case CONSPEC_OCTAL: + case CONSPEC_UNSIGNED: + case CONSPEC_HEX: + case CONSPEC_HEX_UP: + switch (arg->lenmod) + { + case LENMOD_CHAR: arg->vt = VALTYPE_UCHAR; break; + case LENMOD_SHORT: arg->vt = VALTYPE_USHORT; break; + case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break; + case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break; + case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break; + case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; + case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break; + default: arg->vt = VALTYPE_UINT; break; + } + break; + + case CONSPEC_FLOAT: + case CONSPEC_FLOAT_UP: + case CONSPEC_EXP: + case CONSPEC_EXP_UP: + case CONSPEC_F_OR_G: + case CONSPEC_F_OR_G_UP: + case CONSPEC_HEX_EXP: + case CONSPEC_HEX_EXP_UP: + switch (arg->lenmod) + { + case LENMOD_LONGDBL: arg->vt = VALTYPE_LONGDOUBLE; break; + case LENMOD_LONG: arg->vt = VALTYPE_DOUBLE; break; + default: arg->vt = VALTYPE_DOUBLE; break; + } + break; + + case CONSPEC_CHAR: + arg->vt = VALTYPE_INT; + break; + + case CONSPEC_STRING: + arg->vt = VALTYPE_STRING; + break; + + case CONSPEC_POINTER: + arg->vt = VALTYPE_POINTER; + break; + + case CONSPEC_STRERROR: + arg->vt = VALTYPE_STRING; + break; + + case CONSPEC_BYTES_SO_FAR: + switch (arg->lenmod) + { + case LENMOD_CHAR: arg->vt = VALTYPE_SCHAR_PTR; break; + case LENMOD_SHORT: arg->vt = VALTYPE_SHORT_PTR; break; + case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break; + case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break; + case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break; + case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break; + case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break; + default: arg->vt = VALTYPE_INT_PTR; break; + } + break; + + } +} + + + +/* Parse the FORMAT string and populate the specification array stored + at the address ARGSPECS_ADDR. The caller has provided enough space + to store up to MAX_ARGSPECS in that buffer. The function may + however ignore the provided buffer and malloc a larger one. On + success the addrrss of that larger buffer will be stored at + ARGSPECS_ADDR. The actual number of specifications will be + returned at R_ARGSPECS_COUNT. */ +static int +parse_format (const char *format, + argspec_t *argspecs_addr, size_t max_argspecs, + size_t *r_argspecs_count) +{ + const char *s; + argspec_t argspecs = *argspecs_addr; + argspec_t arg; + size_t argcount = 0; + + if (!format) + goto leave_einval; + + for (; *format; format++) + { + unsigned int flags; + int width, precision; + lenmod_t lenmod; + conspec_t conspec; + int arg_pos, width_pos, precision_pos; + + if (*format != '%') + continue; + s = ++format; + if (!*s) + goto leave_einval; + if (*s == '%') + continue; /* Just a quoted percent. */ + + /* First check whether there is a positional argument. */ + arg_pos = 0; /* No positional argument given. */ + if (*s >= '1' && *s <= '9') + { + const char *save_s = s; + + arg_pos = (*s++ - '0'); + for (; *s >= '0' && *s <= '9'; s++) + arg_pos = 10*arg_pos + (*s - '0'); + if (arg_pos < 0) + goto leave_einval; /* Overflow during conversion. */ + if (*s == '$') + s++; + else + { + arg_pos = 0; + s = save_s; + } + } + + /* Parse the flags. */ + flags = 0; + for ( ; *s; s++) + { + switch (*s) + { + case '\'': flags |= FLAG_GROUPING; break; + case '-': flags |= FLAG_LEFT_JUST; break; + case '+': flags |= FLAG_PLUS_SIGN; break; + case ' ': flags |= FLAG_SPACE_PLUS; break; + case '#': flags |= FLAG_ALT_CONV; break; + case '0': flags |= FLAG_ZERO_PAD; break; + default: + goto flags_parsed; + } + } + flags_parsed: + + /* Parse the field width. */ + width_pos = 0; + if (*s == '*') + { + width = STAR_FIELD_VALUE; + s++; + /* If we have a positional argument, another one might also + be used to give the position of the star's value. */ + if (arg_pos && *s >= '1' && *s <= '9') + { + width_pos = (*s++ - '0'); + for (; *s >= '0' && *s <= '9'; s++) + width_pos = 10*width_pos + (*s - '0'); + if (width_pos < 1) + goto leave_einval; /* Overflow during conversion. */ + if (*s != '$') + goto leave_einval; /* Not followed by $. */ + s++; + } + } + else if ( *s >= '0' && *s <= '9') + { + width = (*s++ - '0'); + for (; *s >= '0' && *s <= '9'; s++) + { + if (!width && *s == '0') + goto leave_einval; /* Leading zeroes are not allowed. + Fixme: check what other + implementations do. */ + width = 10*width + (*s - '0'); + } + if (width < 0) + goto leave_einval; /* Overflow during conversion. */ + } + else + width = NO_FIELD_VALUE; + + /* Parse the precision. */ + precision_pos = 0; + precision = NO_FIELD_VALUE; + if (*s == '.') + { + int ignore_value = (s[1] == '-'); + + s++; + if (*s == '*') + { + precision = STAR_FIELD_VALUE; + s++; + /* If we have a positional argument, another one might also + be used to give the position of the star's value. */ + if (arg_pos && *s >= '1' && *s <= '9') + { + precision_pos = (*s++ - '0'); + for (; *s >= '0' && *s <= '9'; s++) + precision_pos = 10*precision_pos + (*s - '0'); + if (precision_pos < 1) + goto leave_einval; /* Overflow during conversion. */ + if (*s != '$') + goto leave_einval; /* Not followed by $. */ + s++; + } + } + else if ( *s >= '0' && *s <= '9') + { + precision = (*s++ - '0'); + for (; *s >= '0' && *s <= '9'; s++) + { + if (!precision && *s == '0') + goto leave_einval; /* Leading zeroes are not allowed. + Fixme: check what other + implementations do. */ + precision = 10*precision + (*s - '0'); + } + if (precision < 0) + goto leave_einval; /* Overflow during conversion. */ + } + else + precision = 0; + if (ignore_value) + precision = NO_FIELD_VALUE; + } + + /* Parse the length modifiers. */ + switch (*s) + { + case 'h': + if (s[1] == 'h') + { + lenmod = LENMOD_CHAR; + s++; + } + else + lenmod = LENMOD_SHORT; + s++; + break; + case 'l': + if (s[1] == 'l') + { + lenmod = LENMOD_LONGLONG; + s++; + } + else + lenmod = LENMOD_LONG; + s++; + break; + case 'j': lenmod = LENMOD_INTMAX; s++; break; + case 'z': lenmod = LENMOD_SIZET; s++; break; + case 't': lenmod = LENMOD_PTRDIFF; s++; break; + case 'L': lenmod = LENMOD_LONGDBL; s++; break; + default: lenmod = LENMOD_NONE; break; + } + + /* Parse the conversion specifier. */ + switch (*s) + { + case 'd': + case 'i': conspec = CONSPEC_DECIMAL; break; + case 'o': conspec = CONSPEC_OCTAL; break; + case 'u': conspec = CONSPEC_UNSIGNED; break; + case 'x': conspec = CONSPEC_HEX; break; + case 'X': conspec = CONSPEC_HEX_UP; break; + case 'f': conspec = CONSPEC_FLOAT; break; + case 'F': conspec = CONSPEC_FLOAT_UP; break; + case 'e': conspec = CONSPEC_EXP; break; + case 'E': conspec = CONSPEC_EXP_UP; break; + case 'g': conspec = CONSPEC_F_OR_G; break; + case 'G': conspec = CONSPEC_F_OR_G_UP; break; + case 'a': conspec = CONSPEC_HEX_EXP; break; + case 'A': conspec = CONSPEC_HEX_EXP_UP; break; + case 'c': conspec = CONSPEC_CHAR; break; + case 's': conspec = CONSPEC_STRING; break; + case 'p': conspec = CONSPEC_POINTER; break; + case 'n': conspec = CONSPEC_BYTES_SO_FAR; break; + case 'C': conspec = CONSPEC_CHAR; lenmod = LENMOD_LONG; break; + case 'S': conspec = CONSPEC_STRING; lenmod = LENMOD_LONG; break; + case 'm': conspec = CONSPEC_STRERROR; arg_pos = -1; break; + default: conspec = CONSPEC_UNKNOWN; + } + + /* Save the args. */ + if (argcount >= max_argspecs) + { + /* We either need to allocate a new array instead of the + caller provided one or realloc the array. Instead of + using realloc we allocate a new one and release the + original one then. */ + size_t n, newmax; + argspec_t newarg; + + newmax = max_argspecs + ARGSPECS_BUMP_VALUE; + if (newmax <= max_argspecs) + goto leave_einval; /* Too many arguments. */ + newarg = calloc (newmax, sizeof *newarg); + if (!newarg) + goto leave; + for (n=0; n < argcount; n++) + newarg[n] = argspecs[n]; + if (argspecs != *argspecs_addr) + free (argspecs); + argspecs = newarg; + max_argspecs = newmax; + } + + arg = argspecs + argcount; + arg->length = s - format + 2; + arg->flags = flags; + arg->width = width; + arg->precision = precision; + arg->lenmod = lenmod; + arg->conspec = conspec; + arg->arg_pos = arg_pos; + arg->width_pos = width_pos; + arg->precision_pos = precision_pos; + compute_type (arg); + argcount++; + format = s; + } + + *argspecs_addr = argspecs; + *r_argspecs_count = argcount; + return 0; /* Success. */ + + leave_einval: + errno = EINVAL; + leave: + if (argspecs != *argspecs_addr) + free (argspecs); + *argspecs_addr = NULL; + return -1; +} + +/* This function is used for testing to provide default arguments. */ +static int +read_dummy_value (value_t *value, valtype_t vt) +{ + switch (vt) + { + case VALTYPE_CHAR: value->a_char = 'a'; break; + case VALTYPE_CHAR_PTR: value->a_char_ptr = NULL; break; + case VALTYPE_SCHAR: value->a_schar = 'a'; break; + case VALTYPE_SCHAR_PTR: value->a_schar_ptr = NULL; break; + case VALTYPE_UCHAR: value->a_uchar = 'a'; break; + case VALTYPE_SHORT: value->a_short = -4711; break; + case VALTYPE_USHORT: value->a_ushort = 4711; break; + case VALTYPE_SHORT_PTR: value->a_short_ptr = NULL; break; + case VALTYPE_INT: value->a_int = 42; break; + case VALTYPE_INT_PTR: value->a_int_ptr = NULL; break; + case VALTYPE_UINT: value->a_uint = 65535; break; + case VALTYPE_LONG: value->a_long = 11071961; break; + case VALTYPE_ULONG: value->a_ulong = 19610711; break; + case VALTYPE_LONG_PTR: value->a_long_ptr = NULL; break; +#ifdef HAVE_LONG_LONG_INT + case VALTYPE_LONGLONG: value->a_longlong = 11223344; break; + case VALTYPE_ULONGLONG: value->a_ulonglong = 2233445566u; break; + case VALTYPE_LONGLONG_PTR: value->a_longlong_ptr = NULL; break; +#endif + case VALTYPE_DOUBLE: value->a_double = 3.1415926535; break; +#ifdef HAVE_LONG_DOUBLE + case VALTYPE_LONGDOUBLE: value->a_longdouble = 2.7; break; +#endif + case VALTYPE_STRING: value->a_string = "heart of gold"; break; + case VALTYPE_POINTER: value->a_void_ptr = (void*)0xdeadbeef; break; +#ifdef HAVE_INTMAX_T + case VALTYPE_INTMAX: value->a_intmax = 100; break; + case VALTYPE_INTMAX_PTR: value->a_intmax_ptr = NULL; break; +#endif +#ifdef HAVE_UINTMAX_T + case VALTYPE_UINTMAX: value->a_uintmax = 200; break; +#endif + case VALTYPE_SIZE: value->a_size = 65537; break; + case VALTYPE_SIZE_PTR: value->a_size_ptr = NULL; break; +#ifdef HAVE_PTRDIFF_T + case VALTYPE_PTRDIFF: value->a_ptrdiff = 2; break; + case VALTYPE_PTRDIFF_PTR: value->a_ptrdiff_ptr = NULL; break; +#endif + default: /* Unsupported type. */ + return -1; + } + return 0; +} + + +/* This function reads all the values as specified by VALUETABLE into + VALUETABLE. The values are expected in VAARGS. The function + returns -1 if a specified type is not supported. */ +static int +read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs) +{ + int validx; + + for (validx=0; validx < valuetable_len; validx++) + { + value_t *value = &valuetable[validx].value; + valtype_t vt = valuetable[validx].vt; + + if (!vaargs) + { + if (read_dummy_value (value, vt)) + return -1; + } + else + { + switch (vt) + { + case VALTYPE_CHAR: value->a_char = va_arg (vaargs, int); break; + case VALTYPE_CHAR_PTR: + value->a_char_ptr = va_arg (vaargs, char *); + break; + case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break; + case VALTYPE_SCHAR_PTR: + value->a_schar_ptr = va_arg (vaargs, signed char *); + break; + case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break; + case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break; + case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break; + case VALTYPE_SHORT_PTR: + value->a_short_ptr = va_arg (vaargs, short *); + break; + case VALTYPE_INT: + value->a_int = va_arg (vaargs, int); + break; + case VALTYPE_INT_PTR: + value->a_int_ptr = va_arg (vaargs, int *); + break; + case VALTYPE_UINT: + value->a_uint = va_arg (vaargs, unsigned int); + break; + case VALTYPE_LONG: + value->a_long = va_arg (vaargs, long); + break; + case VALTYPE_ULONG: + value->a_ulong = va_arg (vaargs, unsigned long); + break; + case VALTYPE_LONG_PTR: + value->a_long_ptr = va_arg (vaargs, long *); + break; +#ifdef HAVE_LONG_LONG_INT + case VALTYPE_LONGLONG: + value->a_longlong = va_arg (vaargs, long long int); + break; + case VALTYPE_ULONGLONG: + value->a_ulonglong = va_arg (vaargs, unsigned long long int); + break; + case VALTYPE_LONGLONG_PTR: + value->a_longlong_ptr = va_arg (vaargs, long long *); + break; +#endif + case VALTYPE_DOUBLE: + value->a_double = va_arg (vaargs, double); + break; +#ifdef HAVE_LONG_DOUBLE + case VALTYPE_LONGDOUBLE: + value->a_longdouble = va_arg (vaargs, long double); + break; +#endif + case VALTYPE_STRING: + value->a_string = va_arg (vaargs, const char *); + break; + case VALTYPE_POINTER: + value->a_void_ptr = va_arg (vaargs, void *); + break; +#ifdef HAVE_INTMAX_T + case VALTYPE_INTMAX: + value->a_intmax = va_arg (vaargs, intmax_t); + break; + case VALTYPE_INTMAX_PTR: + value->a_intmax_ptr = va_arg (vaargs, intmax_t *); + break; +#endif +#ifdef HAVE_UINTMAX_T + case VALTYPE_UINTMAX: + value->a_uintmax = va_arg (vaargs, uintmax_t); + break; +#endif + case VALTYPE_SIZE: + value->a_size = va_arg (vaargs, size_t); + break; + case VALTYPE_SIZE_PTR: + value->a_size_ptr = va_arg (vaargs, size_t *); + break; +#ifdef HAVE_PTRDIFF_T + case VALTYPE_PTRDIFF: + value->a_ptrdiff = va_arg (vaargs, ptrdiff_t); + break; + case VALTYPE_PTRDIFF_PTR: + value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *); + break; +#endif + default: /* Unsupported type. */ + return -1; + } + } + } + return 0; +} + + + +/* Output COUNT padding characters PADCHAR and update NBYTES by the + number of bytes actually written. */ +static int +pad_out (estream_printf_out_t outfnc, void *outfncarg, + int padchar, int count, size_t *nbytes) +{ + char buf[32]; + size_t n; + int rc; + + while (count > 0) + { + n = (count <= sizeof buf)? count : sizeof buf; + memset (buf, padchar, n); + rc = outfnc (outfncarg, buf, n); + if (rc) + return rc; + *nbytes += n; + count -= n; + } + + return 0; +} + + +/* "d,i,o,u,x,X" formatting. OUTFNC and OUTFNCARG describes the + output routine, ARG gives the argument description and VALUE the + actual value (its type is available through arg->vt). */ +static int +pr_integer (estream_printf_out_t outfnc, void *outfncarg, + argspec_t arg, value_t value, size_t *nbytes) +{ + int rc; +#ifdef HAVE_LONG_LONG_INT + unsigned long long aulong; +#else + unsigned long aulong; +#endif + char numbuf[100]; + char *p, *pend; + size_t n; + char signchar = 0; + int n_prec; /* Number of extra precision digits required. */ + int n_extra; /* Extra number of prefix or sign characters. */ + + if (arg->conspec == CONSPEC_DECIMAL) + { +#ifdef HAVE_LONG_LONG_INT + long long along; +#else + long along; +#endif + + switch (arg->vt) + { + case VALTYPE_SHORT: along = value.a_short; break; + case VALTYPE_INT: along = value.a_int; break; + case VALTYPE_LONG: along = value.a_long; break; +#ifdef HAVE_LONG_LONG_INT + case VALTYPE_LONGLONG: along = value.a_longlong; break; + case VALTYPE_SIZE: along = value.a_size; break; +# ifdef HAVE_INTMAX_T + case VALTYPE_INTMAX: along = value.a_intmax; break; +# endif +# ifdef HAVE_PTRDIFF_T + case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break; +# endif +#endif /*HAVE_LONG_LONG_INT*/ + default: + return -1; + } + if (along < 0) + { + aulong = -along; + signchar = '-'; + } + else + aulong = along; + } + else + { + switch (arg->vt) + { + case VALTYPE_USHORT: aulong = value.a_ushort; break; + case VALTYPE_UINT: aulong = value.a_uint; break; + case VALTYPE_ULONG: aulong = value.a_ulong; break; +#ifdef HAVE_LONG_LONG_INT + case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break; + case VALTYPE_SIZE: aulong = value.a_size; break; +# ifdef HAVE_UINTMAX_T + case VALTYPE_UINTMAX: aulong = value.a_uintmax; break; +# endif +# ifdef HAVE_PTRDIFF_T + case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break; +# endif +#endif /*HAVE_LONG_LONG_INT*/ + default: + return -1; + } + } + + if (signchar == '-') + ; + else if ((arg->flags & FLAG_PLUS_SIGN)) + signchar = '+'; + else if ((arg->flags & FLAG_SPACE_PLUS)) + signchar = ' '; + + n_extra = !!signchar; + + /* We build the string up backwards. */ + p = pend = numbuf + DIM(numbuf); + if ((!aulong && !arg->precision)) + ; + else if (arg->conspec == CONSPEC_DECIMAL + || arg->conspec == CONSPEC_UNSIGNED) + { + int grouping = -1; + const char * grouping_string = +#ifdef HAVE_LANGINFO_THOUSANDS_SEP + nl_langinfo(THOUSANDS_SEP); +#else + "'"; +#endif + + do + { + if ((arg->flags & FLAG_GROUPING) + && (++grouping == 3) && *grouping_string) + { + *--p = *grouping_string; + grouping = 0; + } + *--p = '0' + (aulong % 10); + aulong /= 10; + } + while (aulong); + } + else if (arg->conspec == CONSPEC_OCTAL) + { + do + { + *--p = '0' + (aulong % 8); + aulong /= 8; + } + while (aulong); + if ((arg->flags & FLAG_ALT_CONV) && *p != '0') + *--p = '0'; + } + else /* HEX or HEXUP */ + { + const char *digits = ((arg->conspec == CONSPEC_HEX) + ? "0123456789abcdef" : "0123456789ABCDEF"); + do + { + *--p = digits[(aulong % 16)]; + aulong /= 16; + } + while (aulong); + if ((arg->flags & FLAG_ALT_CONV)) + n_extra += 2; + } + + n = pend - p; + + if ((arg->flags & FLAG_ZERO_PAD) + && arg->precision == NO_FIELD_VALUE && !(arg->flags & FLAG_LEFT_JUST) + && n && arg->width - n_extra > n ) + n_prec = arg->width - n_extra - n; + else if (arg->precision > 0 && arg->precision > n) + n_prec = arg->precision - n; + else + n_prec = 0; + + if (!(arg->flags & FLAG_LEFT_JUST) + && arg->width >= 0 && arg->width - n_extra > n + && arg->width - n_extra - n >= n_prec ) + { + rc = pad_out (outfnc, outfncarg, ' ', + arg->width - n_extra - n - n_prec, nbytes); + if (rc) + return rc; + } + + if (signchar) + { + rc = outfnc (outfncarg, &signchar, 1); + if (rc) + return rc; + *nbytes += 1; + } + + if ((arg->flags & FLAG_ALT_CONV) + && (arg->conspec == CONSPEC_HEX || arg->conspec == CONSPEC_HEX_UP)) + { + rc = outfnc (outfncarg, arg->conspec == CONSPEC_HEX? "0x": "0X", 2); + if (rc) + return rc; + *nbytes += 2; + } + + if (n_prec) + { + rc = pad_out (outfnc, outfncarg, '0', n_prec, nbytes); + if (rc) + return rc; + } + + rc = outfnc (outfncarg, p, pend - p); + if (rc) + return rc; + *nbytes += pend - p; + + if ((arg->flags & FLAG_LEFT_JUST) + && arg->width >= 0 && arg->width - n_extra - n_prec > n) + { + rc = pad_out (outfnc, outfncarg, ' ', + arg->width - n_extra - n_prec - n, nbytes); + if (rc) + return rc; + } + + return 0; +} + + +/* "e,E,f,F,g,G,a,A" formatting. OUTFNC and OUTFNCARG describes the + output routine, ARG gives the argument description and VALUE the + actual value (its type is available through arg->vt). For + portability reasons sprintf is used for the actual formatting. + This is useful because sprint is the only standard function to + convert a floating number into its ascii representation. To avoid + using malloc we just pass the precision to sprintf and do the final + formatting with our own code. */ +static int +pr_float (estream_printf_out_t outfnc, void *outfncarg, + argspec_t arg, value_t value, size_t *nbytes) +{ + int rc; +#ifdef HAVE_LONG_DOUBLE + long double adblfloat = 0; /* Just to please gcc. */ + int use_dbl = 0; +#endif + double afloat; + char numbuf[200]; + char formatstr[20]; + char *p, *pend; + size_t n; + char signchar = 0; + int n_extra; /* Extra number of prefix or sign characters. */ + + switch (arg->vt) + { + case VALTYPE_DOUBLE: afloat = value.a_double; break; +#ifdef HAVE_LONG_DOUBLE + case VALTYPE_LONGDOUBLE: + afloat = 0; /* Just to please gcc. */ + adblfloat = value.a_longdouble; + use_dbl=1; break; +#endif + default: + return -1; + } + + /* We build the string using sprint. */ + p = formatstr + sizeof formatstr; + *--p = 0; + switch (arg->conspec) + { + case CONSPEC_FLOAT: *--p = 'f'; break; + case CONSPEC_FLOAT_UP: *--p = 'F'; break; + case CONSPEC_EXP: *--p = 'e'; break; + case CONSPEC_EXP_UP: *--p = 'E'; break; + case CONSPEC_F_OR_G: *--p = 'g'; break; + case CONSPEC_F_OR_G_UP: *--p = 'G'; break; + case CONSPEC_HEX_EXP: *--p = 'a'; break; + case CONSPEC_HEX_EXP_UP: *--p = 'A'; break; + default: + return -1; /* Actually a bug. */ + } +#ifdef HAVE_LONG_DOUBLE + if (use_dbl) + *--p = 'L'; +#endif + if (arg->precision != NO_FIELD_VALUE) + { + /* Limit it to a meaningful value so that even a stupid sprintf + won't overflow our buffer. */ + n = arg->precision <= 100? arg->precision : 100; + do + { + *--p = '0' + (n % 10); + n /= 10; + } + while (n); + *--p = '.'; + } + if ((arg->flags & FLAG_ALT_CONV)) + *--p = '#'; + *--p = '%'; +#ifdef HAVE_LONG_DOUBLE + if (use_dbl) + sprintf (numbuf, p, adblfloat); + else +#endif /*HAVE_LONG_DOUBLE*/ + sprintf (numbuf, p, afloat); + p = numbuf; + n = strlen (numbuf); + pend = p + n; + + if (*p =='-') + { + signchar = '-'; + p++; + n--; + } + else if ((arg->flags & FLAG_PLUS_SIGN)) + signchar = '+'; + else if ((arg->flags & FLAG_SPACE_PLUS)) + signchar = ' '; + + n_extra = !!signchar; + + if (!(arg->flags & FLAG_LEFT_JUST) + && arg->width >= 0 && arg->width - n_extra > n) + { + rc = pad_out (outfnc, outfncarg, ' ', arg->width - n_extra - n, nbytes); + if (rc) + return rc; + } + + if (signchar) + { + rc = outfnc (outfncarg, &signchar, 1); + if (rc) + return rc; + *nbytes += 1; + } + + rc = outfnc (outfncarg, p, pend - p); + if (rc) + return rc; + *nbytes += pend - p; + + if ((arg->flags & FLAG_LEFT_JUST) + && arg->width >= 0 && arg->width - n_extra > n) + { + rc = pad_out (outfnc, outfncarg, ' ', arg->width - n_extra - n, nbytes); + if (rc) + return rc; + } + + return 0; +} + + +/* "c" formatting. */ +static int +pr_char (estream_printf_out_t outfnc, void *outfncarg, + argspec_t arg, value_t value, size_t *nbytes) +{ + int rc; + char buf[1]; + + if (arg->vt != VALTYPE_INT) + return -1; + buf[0] = (unsigned int)value.a_int; + rc = outfnc (outfncarg, buf, 1); + if(rc) + return rc; + *nbytes += 1; + + return 0; +} + + +/* "s" formatting. */ +static int +pr_string (estream_printf_out_t outfnc, void *outfncarg, + argspec_t arg, value_t value, size_t *nbytes) +{ + int rc; + size_t n; + const char *string, *s; + + if (arg->vt != VALTYPE_STRING) + return -1; + string = value.a_string; + if (!string) + string = "(null)"; + if (arg->precision >= 0) + { + for (n=0,s=string; *s && n < arg->precision; s++) + n++; + } + else + n = strlen (string); + + if (!(arg->flags & FLAG_LEFT_JUST) + && arg->width >= 0 && arg->width > n ) + { + rc = pad_out (outfnc, outfncarg, ' ', arg->width - n, nbytes); + if (rc) + return rc; + } + + rc = outfnc (outfncarg, string, n); + if (rc) + return rc; + *nbytes += n; + + if ((arg->flags & FLAG_LEFT_JUST) + && arg->width >= 0 && arg->width > n) + { + rc = pad_out (outfnc, outfncarg, ' ', arg->width - n, nbytes); + if (rc) + return rc; + } + + return 0; +} + + +/* "p" formatting. */ +static int +pr_pointer (estream_printf_out_t outfnc, void *outfncarg, + argspec_t arg, value_t value, size_t *nbytes) +{ + int rc; +#ifdef HAVE_LONG_LONG_INT + unsigned long long aulong; +#else + unsigned long aulong; +#endif + char numbuf[100]; + char *p, *pend; + + if (arg->vt != VALTYPE_POINTER) + return -1; + /* We assume that a pointer can be converted to an unsigned long. + That is not correct for a 64 bit Windows, but then we assume that + long long is supported and usable for storing a pointer. */ +#if defined(HAVE_LONG_LONG_INT) && (SIZEOF_UNSIGNED_LONG < SIZEOF_VOID_P) + aulong = (unsigned long long)value.a_void_ptr; +#else + aulong = (unsigned long)value.a_void_ptr; +#endif + + p = pend = numbuf + DIM(numbuf); + do + { + *--p = "0123456789abcdefx"[(aulong % 16)]; + aulong /= 16; + } + while (aulong); + while ((pend-p) < 2*sizeof (aulong)) + *--p = '0'; + *--p = 'x'; + *--p = '0'; + + rc = outfnc (outfncarg, p, pend - p); + if (rc) + return rc; + *nbytes += pend - p; + + return 0; +} + +/* "n" pesudo format operation. */ +static int +pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg, + argspec_t arg, value_t value, size_t *nbytes) +{ + switch (arg->vt) + { + case VALTYPE_SCHAR_PTR: + *value.a_schar_ptr = (signed char)(unsigned int)(*nbytes); + break; + case VALTYPE_SHORT_PTR: + *value.a_short_ptr = (short)(unsigned int)(*nbytes); + break; + case VALTYPE_LONG_PTR: + *value.a_long_ptr = (long)(*nbytes); + break; +#ifdef HAVE_LONG_LONG_INT + case VALTYPE_LONGLONG_PTR: + *value.a_longlong_ptr = (long long)(*nbytes); + break; +#endif +#ifdef HAVE_INTMAX_T + case VALTYPE_INTMAX_PTR: + *value.a_intmax_ptr = (intmax_t)(*nbytes); + break; +#endif + case VALTYPE_SIZE_PTR: + *value.a_size_ptr = (*nbytes); + break; +#ifdef HAVE_PTRDIFF_T + case VALTYPE_PTRDIFF_PTR: + *value.a_ptrdiff_ptr = (ptrdiff_t)(*nbytes); + break; +#endif + case VALTYPE_INT_PTR: + *value.a_int_ptr = (int)(*nbytes); + break; + default: + return -1; /* An unsupported type has been used. */ + } + + return 0; +} + + + +/* Run the actual formatting. OUTFNC and OUTFNCARG are the output + functions. FORMAT is format string ARGSPECS is the parsed format + string, ARGSPECS_LEN the number of items in ARGSPECS. VALUETABLE + holds the values and may be directly addressed using the poistion + arguments given by ARGSPECS. MYERRNO is used for the "%m" + conversion. NBYTES well be updated to reflect the number of bytes + send to the output function. */ +static int +do_format (estream_printf_out_t outfnc, void *outfncarg, + const char *format, argspec_t argspecs, size_t argspecs_len, + valueitem_t valuetable, int myerrno, size_t *nbytes) +{ + int rc = 0; + const char *s; + argspec_t arg = argspecs; + int argidx = 0; /* Only used for assertion. */ + size_t n; + value_t value; + + s = format; + while ( *s ) + { + if (*s != '%') + { + s++; + continue; + } + if (s != format) + { + rc = outfnc (outfncarg, format, (n=s-format)); + if (rc) + return rc; + *nbytes += n; + } + if (s[1] == '%') + { + /* Note that this code ignores one trailing percent escape - + this is however okay as the args parser must have + detected this already. */ + rc = outfnc (outfncarg, s, 1); + if (rc) + return rc; + *nbytes += 1; + s += 2; + format = s; + continue; + } + + /* Save the next start. */ + s += arg->length; + format = s; + + assert (argidx < argspecs_len); + argidx++; + + /* Apply indirect field width and precision values. */ + if (arg->width == STAR_FIELD_VALUE) + { + assert (valuetable[arg->width_pos-1].vt == VALTYPE_INT); + arg->width = valuetable[arg->width_pos-1].value.a_int; + if (arg->width < 0) + { + arg->width = -arg->width; + arg->flags |= FLAG_LEFT_JUST; + } + } + if (arg->precision == STAR_FIELD_VALUE) + { + assert (valuetable[arg->precision_pos-1].vt == VALTYPE_INT); + arg->precision = valuetable[arg->precision_pos-1].value.a_int; + if (arg->precision < 0) + arg->precision = NO_FIELD_VALUE; + } + + if (arg->arg_pos == -1 && arg->conspec == CONSPEC_STRERROR) + value.a_string = strerror (myerrno); + else + { + assert (arg->vt == valuetable[arg->arg_pos-1].vt); + value = valuetable[arg->arg_pos-1].value; + } + + switch (arg->conspec) + { + case CONSPEC_UNKNOWN: assert (!"bug"); break; + + case CONSPEC_DECIMAL: + case CONSPEC_UNSIGNED: + case CONSPEC_OCTAL: + case CONSPEC_HEX: + case CONSPEC_HEX_UP: + rc = pr_integer (outfnc, outfncarg, arg, value, nbytes); + break; + case CONSPEC_FLOAT: + case CONSPEC_FLOAT_UP: + case CONSPEC_EXP: + case CONSPEC_EXP_UP: + case CONSPEC_F_OR_G: + case CONSPEC_F_OR_G_UP: + case CONSPEC_HEX_EXP: + case CONSPEC_HEX_EXP_UP: + rc = pr_float (outfnc, outfncarg, arg, value, nbytes); + break; + case CONSPEC_CHAR: + rc = pr_char (outfnc, outfncarg, arg, value, nbytes); + break; + case CONSPEC_STRING: + case CONSPEC_STRERROR: + rc = pr_string (outfnc, outfncarg, arg, value, nbytes); + break; + case CONSPEC_POINTER: + rc = pr_pointer (outfnc, outfncarg, arg, value, nbytes); + break; + case CONSPEC_BYTES_SO_FAR: + rc = pr_bytes_so_far (outfnc, outfncarg, arg, value, nbytes); + break; + } + if (rc) + return rc; + arg++; + } + + /* Print out any trailing stuff. */ + s++; /* Need to output a terminating nul; take it from format. */ + rc = outfnc (outfncarg, format, (n=s - format)); + if (!rc) + *nbytes += n; + + return rc; +} + + + + +/* The versatile printf formatting routine. It expects a callback + function OUTFNC and an opaque argument OUTFNCARG used for actual + output of the formatted stuff. FORMAT is the format specification + and VAARGS a variable argumemt list matching the arguments of + FORMAT. */ +int +estream_format (estream_printf_out_t outfnc, + void *outfncarg, + const char *format, va_list vaargs) +{ + /* Buffer to hold the argspecs and a pointer to it.*/ + struct argspec_s argspecs_buffer[DEFAULT_MAX_ARGSPECS]; + argspec_t argspecs = argspecs_buffer; + size_t argspecs_len; /* Number of specifications in ARGSPECS. */ + + /* Buffer to hold the description for the values. */ + struct valueitem_s valuetable_buffer[DEFAULT_MAX_VALUES]; + valueitem_t valuetable = valuetable_buffer; + + int rc; /* Return code. */ + size_t argidx; /* Used to index the argspecs array. */ + size_t validx; /* Used to index the valuetable. */ + int max_pos;/* Highest argument position. */ + + size_t nbytes = 0; /* Keep track of the number of bytes passed to + the output function. */ + + int myerrno = errno; /* Save the errno for use with "%m". */ + + + /* Parse the arguments to come up with descriptive list. We can't + do this on the fly because we need to support positional + arguments. */ + rc = parse_format (format, &argspecs, DIM(argspecs_buffer), &argspecs_len); + if (rc) + goto leave; + + /* Check that all ARG_POS fields are set. */ + for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++) + { + if (argspecs[argidx].arg_pos != -1 + && argspecs[argidx].arg_pos > max_pos) + max_pos = argspecs[argidx].arg_pos; + if (argspecs[argidx].width_pos > max_pos) + max_pos = argspecs[argidx].width_pos; + if (argspecs[argidx].precision_pos > max_pos) + max_pos = argspecs[argidx].precision_pos; + } + if (!max_pos) + { + /* Fill in all the positions. */ + for (argidx=0; argidx < argspecs_len; argidx++) + { + if (argspecs[argidx].width == STAR_FIELD_VALUE) + argspecs[argidx].width_pos = ++max_pos; + if (argspecs[argidx].precision == STAR_FIELD_VALUE) + argspecs[argidx].precision_pos = ++max_pos; + if (argspecs[argidx].arg_pos != -1 ) + argspecs[argidx].arg_pos = ++max_pos; + } + } + else + { + /* Check that they are all filled. More test are done later. */ + for (argidx=0; argidx < argspecs_len; argidx++) + { + if (!argspecs[argidx].arg_pos + || (argspecs[argidx].width == STAR_FIELD_VALUE + && !argspecs[argidx].width_pos) + || (argspecs[argidx].precision == STAR_FIELD_VALUE + && !argspecs[argidx].precision_pos)) + goto leave_einval; + } + } + /* Check that there is no overflow in max_pos and that it has a + reasonable length. There may never be more elements than the + number of characters in FORMAT. */ + if (max_pos < 0 || max_pos >= strlen (format)) + goto leave_einval; + +#ifdef TEST + if (verbose > 1) + dump_argspecs (argspecs, argspecs_len); +#endif + + /* Allocate a table to hold the values. If it is small enough we + use a stack allocated buffer. */ + if (max_pos > DIM(valuetable_buffer)) + { + valuetable = calloc (max_pos, sizeof *valuetable); + if (!valuetable) + goto leave_error; + } + else + { + for (validx=0; validx < DIM(valuetable_buffer); validx++) + valuetable[validx].vt = VALTYPE_UNSUPPORTED; + } + for (argidx=0; argidx < argspecs_len; argidx++) + { + if (argspecs[argidx].arg_pos != - 1) + { + validx = argspecs[argidx].arg_pos - 1; + if (valuetable[validx].vt) + goto leave_einval; /* Already defined. */ + valuetable[validx].vt = argspecs[argidx].vt; + } + if (argspecs[argidx].width == STAR_FIELD_VALUE) + { + validx = argspecs[argidx].width_pos - 1; + if (valuetable[validx].vt) + goto leave_einval; /* Already defined. */ + valuetable[validx].vt = VALTYPE_INT; + } + if (argspecs[argidx].precision == STAR_FIELD_VALUE) + { + validx = argspecs[argidx].precision_pos - 1; + if (valuetable[validx].vt) + goto leave_einval; /* Already defined. */ + valuetable[validx].vt = VALTYPE_INT; + } + } + + /* Read all the arguments. This will error out for unsupported + types and for not given positional arguments. */ + rc = read_values (valuetable, max_pos, vaargs); + if (rc) + goto leave_einval; + +/* for (validx=0; validx < max_pos; validx++) */ +/* fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */ + + /* Everything has been collected, go ahead with the formatting. */ + rc = do_format (outfnc, outfncarg, format, + argspecs, argspecs_len, valuetable, myerrno, &nbytes); + + goto leave; + + leave_einval: + errno = EINVAL; + leave_error: + rc = -1; + leave: + if (valuetable != valuetable_buffer) + free (valuetable); + if (argspecs != argspecs_buffer) + free (argspecs); + return rc; +} + + + + +/* A simple output handler utilizing stdio. */ +static int +plain_stdio_out (void *outfncarg, const char *buf, size_t buflen) +{ + FILE *fp = (FILE*)outfncarg; + + fputs ("OUT->", fp); + if ( fwrite (buf, buflen, 1, fp) != 1 ) + return -1; + fputs ("<-\n", fp); + return 0; +} + + +/* A replacement for printf. */ +int +estream_printf (const char *format, ...) +{ + int rc; + va_list arg_ptr; + + va_start (arg_ptr, format); + rc = estream_format (plain_stdio_out, stderr, format, arg_ptr); + va_end (arg_ptr); + + return rc; +} + +/* A replacement for fprintf. */ +int +estream_fprintf (FILE *fp, const char *format, ...) +{ + int rc; + va_list arg_ptr; + + va_start (arg_ptr, format); + rc = estream_format (plain_stdio_out, fp, format, arg_ptr); + va_end (arg_ptr); + + return rc; +} + +/* A replacement for vfprintf. */ +int +estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) +{ + return estream_format (plain_stdio_out, fp, format, arg_ptr); +} + + + +/* Communication object used between estream_snprintf and + fixed_buffer_out. */ +struct fixed_buffer_parm_s +{ + size_t size; /* Size of the buffer. */ + size_t count; /* Number of bytes requested for output. */ + size_t used; /* Used size of the buffer. */ + char *buffer; /* Provided buffer. */ +}; + +/* A simple malloced buffer output handler. */ +static int +fixed_buffer_out (void *outfncarg, const char *buf, size_t buflen) +{ + struct fixed_buffer_parm_s *parm = outfncarg; + + parm->count += buflen; + + if (!parm->buffer) + ; + else if (parm->used + buflen < parm->size) + { + /* Handle the common case that everything fits into the buffer + separately. */ + memcpy (parm->buffer + parm->used, buf, buflen); + parm->used += buflen; + } + else + { + /* The slow version of above. */ + for ( ;buflen && parm->used < parm->size; buflen--) + parm->buffer[parm->used++] = *buf++; + } + + return 0; +} + + +/* A replacement for vsnprintf. */ +int +estream_vsnprintf (char *buf, size_t bufsize, + const char *format, va_list arg_ptr) +{ + struct fixed_buffer_parm_s parm; + int rc; + + parm.size = bufsize? bufsize-1:0; + parm.count = 0; + parm.used = 0; + parm.buffer = bufsize?buf:NULL; + rc = estream_format (fixed_buffer_out, &parm, format, arg_ptr); + if (rc == -1) + return -1; + if (bufsize && buf && parm.count >= parm.size) + buf[parm.size-1] = 0; + + return (int)parm.count; /* Return number of bytes which would have + been written. */ +} + +/* A replacement for snprintf. */ +int +estream_snprintf (char *buf, size_t bufsize, const char *format, ...) +{ + int rc; + va_list arg_ptr; + + va_start (arg_ptr, format); + rc = estream_vsnprintf (buf, bufsize, format, arg_ptr); + va_end (arg_ptr); + + return rc; +} + + + +/* Communication object used between estream_asprintf and + dynamic_buffer_out. */ +struct dynamic_buffer_parm_s +{ + int error_flag; /* Internal helper. */ + size_t alloced; /* Allocated size of the buffer. */ + size_t used; /* Used size of the buffer. */ + char *buffer; /* Malloced buffer. */ +}; + +/* A simple malloced buffer output handler. */ +static int +dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen) +{ + struct dynamic_buffer_parm_s *parm = outfncarg; + + if (parm->error_flag) + { + /* Just in case some formatting routine did not checked for an + error. */ + errno = parm->error_flag; + return -1; + } + + if (parm->used + buflen >= parm->alloced) + { + char *p; + + parm->alloced += buflen + 512; + p = realloc (parm->buffer, parm->alloced); + if (!p) + { + parm->error_flag = errno ? errno : ENOMEM; + /* Wipe out what we already accumulated. This is useful in + case sensitive data is formated. */ + memset (parm->buffer, 0, parm->used); + return -1; + } + parm->buffer = p; + } + memcpy (parm->buffer + parm->used, buf, buflen); + parm->used += buflen; + + return 0; +} + + +/* A replacement for vasprintf. As with the BSD of vasprintf version -1 + will be returned on error and NULL stored at BUFP. On success the + number of bytes printed will be returned. */ +int +estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) +{ + struct dynamic_buffer_parm_s parm; + int rc; + + parm.error_flag = 0; + parm.alloced = 512; + parm.used = 0; + parm.buffer = my_asprintf_malloc (parm.alloced); + if (!parm.buffer) + { + *bufp = NULL; + return -1; + } + + rc = estream_format (dynamic_buffer_out, &parm, format, arg_ptr); + + if (rc != -1 && parm.error_flag) + { + rc = -1; + errno = parm.error_flag; + } + if (rc == -1) + { + memset (parm.buffer, 0, parm.used); + my_asprintf_free (parm.buffer); + *bufp = NULL; + return -1; + } + + *bufp = parm.buffer; + return parm.used - 1; /* Do not include the nul. */ +} + +/* A replacement for asprintf. As with the BSD of asprintf version -1 + will be returned on error and NULL stored at BUFP. On success the + number of bytes printed will be returned. */ +int +estream_asprintf (char **bufp, const char *format, ...) +{ + int rc; + va_list arg_ptr; + + va_start (arg_ptr, format); + rc = estream_vasprintf (bufp, format, arg_ptr); + va_end (arg_ptr); + + return rc; +} + + +#ifdef TEST + +static int +one_test (const char *format, ...) +{ + int rc1, rc2; + va_list arg_ptr; + char *buf1, *buf2; + + if (verbose) + printf ("format: ->%s<-\n", format); + + va_start (arg_ptr, format); + rc1 = vasprintf (&buf1, format, arg_ptr); + va_end (arg_ptr); + if (rc1 == -1) + { + printf (" sys: errno=%d (%s)\n", errno, strerror (errno)); + buf1 = NULL; + } + else if (verbose) + printf (" sys: ->%s<-\n", buf1); + + va_start (arg_ptr, format); + rc2 = estream_vasprintf (&buf2, format, arg_ptr); + va_end (arg_ptr); + if (rc2 == -1) + printf (" our: errno=%d (%s)\n", errno, strerror (errno)); + else if (verbose) + printf (" our: ->%s<-\n", buf2); + + if (rc1 != -1 && rc2 != -1 && strcmp (buf1, buf2)) + printf ("error: output does not match\n" + "format: ->%s<-\n sys: ->%s<-\n our: ->%s<-\n", + format, buf1, buf2); + else if ( rc1 != rc2 ) + printf ("error: return codes are different: sys_rc=%d our_rc=%d\n", + rc1, rc2); + + free (buf2); + free (buf1); + + return 0; +} + + +static void +run_tests (void) +{ +#if 0 + one_test ("%d %% %'d", 17, 19681977); + + one_test ("%d %% %d", 17, 768114563); + one_test ("%d %% %d", 17, -768114563); + + one_test ("%d", 17); + one_test ("%4d", 17); + one_test ("%40d", 17); + one_test ("%-d", 17); + one_test ("%-4d", 17); + one_test ("%-140d", 17); + one_test ("%d", -17); + one_test ("%4d", -17); + one_test ("%40d", -17); + one_test ("%-d", -17); + one_test ("%-4d", -17); + one_test ("%-40d", -17); + + one_test ("%+4d", 17); + one_test ("%+4d", -17); + one_test ("%-+4d", 17); + one_test ("%-+4d", -17); + one_test ("% 4d", 17); + one_test ("% 4d", -17); + one_test ("%- +4d", 17); + one_test ("%- +4d", -17); + + one_test ("%.4d", 17); + one_test ("%.0d", 17); + one_test ("%.0d", 0); + one_test ("%.4d", -17); + one_test ("%.0d", -17); + one_test ("%6.4d", 17); + one_test ("%6.4d", -17); + one_test ("%6.0d", 0); + one_test ("%4.6d", 17); + one_test ("%4.6d", -17); + + one_test ("% 4.6d", 17); + one_test ("% 6.0d", 0); + + one_test ("%.4d", 17); + one_test ("%04d", 17); + one_test ("%.4d", -17); + one_test ("%04d", -17); + one_test ("%0.d", 0); + + one_test ("%*d", 7, 42); + one_test ("%*d", -7, 42); + one_test ("%.*d", 7, 42); + one_test ("%.*d", -7, 42); + one_test ("%*.*d", 10, 7, 42); + one_test ("%*.*d", 10, -7, 42); + one_test ("%*.*d", -10, 7, 42); + one_test ("%*.*d", -10, -7, 42); + + one_test ("%*x", 7, 42); + one_test ("%*x", -7, 42); + one_test ("%.*x", 7, 42); + one_test ("%.*x", -7, 42); + one_test ("%*.*x", 10, 7, 42); + one_test ("%*.*x", 10, -7, 42); + one_test ("%*.*x", -10, 7, 42); + one_test ("%*.*x", -10, -7, 42); + one_test ("%#*x", 7, 42); + one_test ("%#*x", -7, 42); + one_test ("%#.*x", 7, 42); + one_test ("%#.*x", -7, 42); + one_test ("%#*.*x", 10, 7, 42); + one_test ("%#*.*x", 10, -7, 42); + one_test ("%#*.*x", -10, 7, 42); + one_test ("%#*.*x", -10, -7, 42); + + one_test ("%*X", 7, 42); + one_test ("%*X", -7, 42); + one_test ("%.*X", 7, 42); + one_test ("%.*X", -7, 42); + one_test ("%*.*X", 10, 7, 42); + one_test ("%*.*X", 10, -7, 42); + one_test ("%*.*X", -10, 7, 42); + one_test ("%*.*X", -10, -7, 42); + one_test ("%#*X", 7, 42); + one_test ("%#*X", -7, 42); + one_test ("%#.*X", 7, 42); + one_test ("%#.*X", -7, 42); + one_test ("%#*.*X", 10, 7, 42); + one_test ("%#*.*X", 10, -7, 42); + one_test ("%#*.*X", -10, 7, 42); + one_test ("%#*.*X", -10, -7, 42); + + one_test ("%*o", 7, 42); + one_test ("%*o", -7, 42); + one_test ("%.*o", 7, 42); + one_test ("%.*o", -7, 42); + one_test ("%*.*o", 10, 7, 42); + one_test ("%*.*o", 10, -7, 42); + one_test ("%*.*o", -10, 7, 42); + one_test ("%*.*o", -10, -7, 42); + one_test ("%#*o", 7, 42); + one_test ("%#*o", -7, 42); + one_test ("%#.*o", 7, 42); + one_test ("%#.*o", -7, 42); + one_test ("%#*.*o", 10, 7, 42); + one_test ("%#*.*o", 10, -7, 42); + one_test ("%#*.*o", -10, 7, 42); + one_test ("%#*.*o", -10, -7, 42); + + one_test ("%s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%.0s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%.10s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%.48s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%.49s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%.50s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%.51s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%48s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%49s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%50s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%51s", "the quick brown fox jumps over the lazy dogs back"); + one_test ("%-51s", "the quick brown fox jumps over the lazy dogs back"); +#endif + + one_test ("%f", 3.1415926535); + one_test ("%f", -3.1415926535); + one_test ("%.10f", 3.1415926535); + one_test ("%.2f", 3.1415926535); + one_test ("%.1f", 3.1415926535); + one_test ("%.0f", 3.1415926535); + one_test ("%.20f", 3.1415926535); + one_test ("%10.10f", 3.1415926535); + one_test ("%10.2f", 3.1415926535); + one_test ("%10.1f", 3.1415926535); + one_test ("%10.0f", 3.1415926535); + one_test ("%30.20f", 3.1415926535); + one_test ("%10.10f", -3.1415926535); + one_test ("%10.2f", -3.1415926535); + one_test ("%10.1f", -3.1415926535); + one_test ("%10.0f", -3.1415926535); + one_test ("%30.20f", -3.1415926535); + + one_test ("%-10f", 3.1415926535); + one_test ("%-10.10f", 3.1415926535); + one_test ("%-10.2f", 3.1415926535); + one_test ("%-10.1f", 3.1415926535); + one_test ("%-10.0f", 3.1415926535); + one_test ("%-30.20f", 3.1415926535); + one_test ("%-10f", -3.1415926535); + one_test ("%-10.10f", -3.1415926535); + one_test ("%-10.2f", -3.1415926535); + one_test ("%-10.1f", -3.1415926535); + one_test ("%-10.0f", -3.1415926535); + one_test ("%-30.20f", -3.1415926535); + + one_test ("%#.0f", 3.1415926535); + one_test ("%#10.0f", 3.1415926535); + one_test ("%#10.0f", -3.1415926535); + one_test ("%-#10.0f", 3.1415926535); + one_test ("%-#10.0f", -3.1415926535); + + one_test ("%e", 3.1415926535); + one_test ("%g", 3.1415926535); + + one_test ("%a", 1); + one_test ("%a", -1); + one_test ("%a", 3.1415926535); + +#ifdef HAVE_LONG_DOUBLE + one_test ("%La", 1); + one_test ("%La", -1); + one_test ("%La", 3.1415926535); +#endif + +#ifdef __GLIBC__ + /* "%m" is a glibc extension so this _test_ will only work on such a + system. */ + errno = ENOENT; + one_test ("%m"); + errno = ENOENT; + one_test ("%d=%m", 17); + errno = ENOENT; + one_test ("%2$d:%m:%1$d", 42, 17); +#endif /*__GLIBC__*/ + +} + +static void +check_snprintf (void) +{ + char buffer[20]; + int rc; + + rc = estream_snprintf (buffer, 0, "%*s", 18, ""); + if (rc != 19) + printf ("rc=%d\n", rc ); + rc = estream_snprintf (buffer, sizeof buffer, "%*s", 18, ""); + if (rc != 19) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + rc = estream_snprintf (buffer, sizeof buffer, "%*s", 19, ""); + if (rc != 20) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + rc = estream_snprintf (buffer, sizeof buffer, "%*s", 20, ""); + if (rc != 21) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + rc = estream_snprintf (buffer, sizeof buffer, "%*s", 21, ""); + if (rc != 22) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); +} + + + +int +main (int argc, char **argv) +{ + int rc; + + if (argc) {argc--; argv++; } + + setlocale (LC_NUMERIC, ""); + + while (argc && !strcmp (*argv, "--verbose")) + { + verbose++; + argc--; + argv++; + } + + if (!argc) + { + run_tests (); + check_snprintf () ; + } + else + { + rc = estream_vfprintf (stdout, argv[0], NULL); + fflush (stdout); + fprintf (stderr, "[estream_vfprintf returns: %d]\n", rc); + } + + return 0; +} +#endif /*TEST*/ +/* +Local Variables: +compile-command: "cc -Wall -O3 -g -I.. -DHAVE_CONFIG_H -DTEST -o estream-printf estream-printf.c" +End: +*/ Added: trunk/common/estream-printf.h =================================================================== --- trunk/common/estream-printf.h 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/estream-printf.h 2007-05-15 16:10:48 UTC (rev 4502) @@ -0,0 +1,60 @@ +/* estream-printf.h - Versatile C-99 compliant printf formatting. + * Copyright (C) 2007 g10 Code GmbH + * + * This file is part of Libestream. + * + * Libestream is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * Libestream is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Libestream; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * $Id: estream-printf.h 54 2007-05-15 14:12:06Z wk $ + */ + +#ifndef ESTREAM_PRINTF_H +#define ESTREAM_PRINTF_H + +#include +#include + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) +# define ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) +#else +# define ESTREAM_GCC_A_PRINTF( f, a ) +#endif + + +typedef int (*estream_printf_out_t) + (void *outfncarg, const char *buf, size_t buflen); + +int estream_format (estream_printf_out_t outfnc, void *outfncarg, + const char *format, va_list vaargs) + ESTREAM_GCC_A_PRINTF(3,0); +int estream_printf (const char *format, ...) + ESTREAM_GCC_A_PRINTF(1,2); +int estream_fprintf (FILE *fp, const char *format, ... ) + ESTREAM_GCC_A_PRINTF(2,3); +int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) + ESTREAM_GCC_A_PRINTF(2,0); +int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) + ESTREAM_GCC_A_PRINTF(3,4); +int estream_vsnprintf (char *buf,size_t bufsize, + const char *format, va_list arg_ptr) + ESTREAM_GCC_A_PRINTF(3,0); +int estream_asprintf (char **bufp, const char *format, ...) + ESTREAM_GCC_A_PRINTF(2,3); +int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) + ESTREAM_GCC_A_PRINTF(2,0); + + +#endif /*ESTREAM_PRINTF_H*/ Modified: trunk/common/estream.c =================================================================== --- trunk/common/estream.c 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/estream.c 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,5 +1,5 @@ /* estream.c - Extended Stream I/O Library - * Copyright (C) 2004, 2006, 2007 g10 Code GmbH + * Copyright (C) 2004, 2005, 2006, 2007 g10 Code GmbH * * This file is part of Libestream. * @@ -11,7 +11,7 @@ * Libestream is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Libestream; if not, write to the Free Software @@ -49,6 +49,7 @@ # include #endif +/* This is for the special hack to use estream.c in GnuPG. */ #ifdef GNUPG_MAJOR_VERSION #include "../common/util.h" #endif @@ -62,8 +63,8 @@ #endif #include +#include - /* Generally used types. */ @@ -747,8 +748,8 @@ es_convert_mode (const char *mode, unsigned int *flags) { - /* FIXME: We need to allow all combinations for mode flags and for - binary we need to do a + /* FIXME: We need to allow all mode flags permutations and for + binary mode we need to do a #ifdef HAVE_DOSISH_SYSTEM setmode (fd, O_BINARY); @@ -1671,29 +1672,19 @@ } -/* Helper for esprint. */ -#if defined(HAVE_FOPENCOOKIE) || defined(HAVE_FUNOPEN) -static my_funopen_hook_ret_t -print_fun_writer (void *cookie_arg, const char *buffer, size_t size) +/* Output fucntion used for estream_format. */ +static int +print_writer (void *outfncarg, const char *buf, size_t buflen) { - estream_t stream = cookie_arg; + estream_t stream = outfncarg; size_t nwritten; - - /* We don't return an error but let es_print check whether an error - has occured. Internally we skip everything after an error. */ - if (!stream->intern->print_err) - { - if (es_writen (stream, buffer, size, &nwritten)) - { - stream->intern->print_err = 1; - stream->intern->print_errno = errno; - } - else - stream->intern->print_ntotal += nwritten; - } - return 0; + int rc; + + nwritten = 0; + rc = es_writen (stream, buf, buflen, &nwritten); + stream->intern->print_ntotal += nwritten; + return rc; } -#endif /* HAVE_FOPENCOOKIE || HAVE_FUNOPEN */ /* The core of our printf function. This is called in locked state. */ @@ -1701,98 +1692,13 @@ es_print (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, va_list ap) { -#if defined(HAVE_FOPENCOOKIE) || defined(HAVE_FUNOPEN) + int rc; - if (!stream->intern->print_fp) - { -#ifdef HAVE_FOPENCOOKIE - { - cookie_io_functions_t io = { NULL }; - io.write = print_fun_writer; - - stream->intern->print_fp = fopencookie (stream, "w", io); - } -#else /*!HAVE_FOPENCOOKIE*/ - stream->intern->print_fp = funopen (stream, NULL, - print_fun_writer, NULL, NULL); -#endif /*!HAVE_FOPENCOOKIE*/ - if (!stream->intern->print_fp) - return -1; - } - - stream->intern->print_err = 0; - stream->intern->print_errno = 0; stream->intern->print_ntotal = 0; - - if ( vfprintf (stream->intern->print_fp, format, ap) < 0 - || fflush (stream->intern->print_fp) ) - { - stream->intern->print_errno = errno; - stream->intern->print_err = 1; - fclose (stream->intern->print_fp); - stream->intern->print_fp = NULL; - } - if (stream->intern->print_err) - { - errno = stream->intern->print_errno; - return -1; - } - + rc = estream_format (print_writer, stream, format, ap); + if (rc) + return -1; return (int)stream->intern->print_ntotal; - -#else /* No funopen or fopencookie. */ - - char data[BUFFER_BLOCK_SIZE]; - size_t bytes_read; - size_t bytes_written; - FILE *tmp_stream; - int err; - - bytes_written = 0; - tmp_stream = NULL; - err = 0; - - tmp_stream = tmpfile (); - if (! tmp_stream) - { - err = errno; - goto out; - } - - err = vfprintf (tmp_stream, format, ap); - if (err < 0) - goto out; - - err = fseek (tmp_stream, 0, SEEK_SET); - if (err) - goto out; - - while (1) - { - bytes_read = fread (data, 1, sizeof (data), tmp_stream); - if (ferror (tmp_stream)) - { - err = -1; - break; - } - - err = es_writen (stream, data, bytes_read, NULL); - if (err) - break; - else - bytes_written += bytes_read; - if (feof (tmp_stream)) - break; - } - if (err) - goto out; - - out: - if (tmp_stream) - fclose (tmp_stream); - - return err ? -1 : bytes_written; -#endif /* no funopen or fopencookie */ } @@ -2718,7 +2624,7 @@ static int es_fprintf_unlocked (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...) + const char *ES__RESTRICT format, ...) { int ret; @@ -2868,8 +2774,6 @@ return opaque; } - - /* Print a BUFFER to STREAM while replacing all control characters and the characters in DELIMITERS by standard C escape sequences. Returns 0 on success or -1 on error. If BYTES_WRITTEN is not NULL @@ -2992,7 +2896,7 @@ encoding. The interface is the same as es_write_sanitized, however only one delimiter may be supported. - THIS IS NOT A STANDARD ESTREAM FUNCTION AND ONLY USED BY GNUPG. */ + THIS IS NOT A STANDARD ESTREAM FUNCTION AND ONLY USED BY GNUPG!. */ int es_write_sanitized_utf8_buffer (estream_t stream, const void *buffer, size_t length, @@ -3025,6 +2929,3 @@ return es_write_sanitized (stream, p, length, delimiters, bytes_written); } #endif /*GNUPG_MAJOR_VERSION*/ - - - Modified: trunk/common/estream.h =================================================================== --- trunk/common/estream.h 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/estream.h 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,5 +1,5 @@ /* estream.h - Extended stream I/O/ Library - * Copyright (C) 2004 g10 Code GmbH + * Copyright (C) 2004, 2005, 2006, 2007 g10 Code GmbH * * This file is part of Libestream. * @@ -211,7 +211,6 @@ void *es_opaque_get (estream_t stream); - #ifdef GNUPG_MAJOR_VERSION int es_write_sanitized_utf8_buffer (estream_t stream, const void *buffer, size_t length, @@ -220,5 +219,6 @@ #endif /*GNUPG_MAJOR_VERSION*/ + #endif /*ESTREAM_H*/ Modified: trunk/common/sexp-parse.h =================================================================== --- trunk/common/sexp-parse.h 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/sexp-parse.h 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,5 +1,5 @@ /* sexp-parse.h - S-Exp helper functions - * Copyright (C) 2002, 2003 Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -97,4 +97,34 @@ return 1; } +/* Format VALUE for use as the length indicatior of an S-expression. + The caller needs to provide a buffer HELP_BUFFER wth a length of + HELP_BUFLEN. The return value is a pointer into HELP_BUFFER with + the formatted length string. The colon and a trailing nul are + appended. HELP_BUFLEN must be at least 3 - a more useful value is + 15. If LENGTH is not NULL, the LENGTH of the resulting string + (excluding the terminating nul) is stored at that address. */ +static inline char * +smklen (char *help_buffer, size_t help_buflen, size_t value, size_t *length) +{ + char *p = help_buffer + help_buflen; + + if (help_buflen >= 3) + { + *--p = 0; + *--p = ':'; + do + { + *--p = '0' + (value % 10); + value /= 10; + } + while (value && p > help_buffer); + } + + if (length) + *length = (help_buffer + help_buflen) - p; + return p; +} + + #endif /*SEXP_PARSE_H*/ Modified: trunk/common/sexputil.c =================================================================== --- trunk/common/sexputil.c 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/sexputil.c 2007-05-15 16:10:48 UTC (rev 4502) @@ -34,8 +34,8 @@ #endif #include "util.h" +#include "sexp-parse.h" - /* Return the so called "keygrip" which is the SHA-1 hash of the public key parameters expressed in a way depended on the algorithm. @@ -115,7 +115,8 @@ const char *s; unsigned char *buf; unsigned char *p; - char numbuf[50]; + char numbuf[50], *numbufp; + size_t numbuflen; for (n=0, s=line; hexdigitp (s); s++, n++) ; @@ -124,11 +125,12 @@ if (!n) return NULL; len = ((n+1) & ~0x01)/2; - sprintf (numbuf, "(%u:", (unsigned int)len); - buf = xtrymalloc (strlen (numbuf) + len + 1 + 1); + numbufp = smklen (numbuf, sizeof numbuf, len, &numbuflen); + buf = xtrymalloc (1 + numbuflen + len + 1 + 1); if (!buf) return NULL; - p = (unsigned char *)stpcpy ((char *)buf, numbuf); + buf[0] = '('; + p = (unsigned char *)stpcpy ((char *)buf+1, numbufp); s = line; if ((n&1)) { Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/util.h 2007-05-15 16:10:48 UTC (rev 4502) @@ -27,10 +27,6 @@ #include /* We need errno. */ #include /* We need gpg_error_t. */ -/* Common GNUlib includes (-I ../gl/). */ -#include "vasprintf.h" - - /* Hash function used with libksba. */ #define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write) @@ -43,6 +39,14 @@ #include "../jnlib/dotlock.h" #include "../jnlib/utf8conv.h" +/* Redefine asprintf by our estream version which uses our own memory + allocator.. */ +#include "estream-printf.h" +#define asprintf estream_asprintf +#define vasprintf estream_vasprintf + + +/* GCC attributes. */ #if __GNUC__ >= 4 # define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a))) #else @@ -175,13 +179,9 @@ logging subsystem. */ void setup_libgcrypt_logging (void); -/* Same as asprintf but return an allocated buffer suitable to be - freed using xfree. This function simply dies on memory failure, - thus no extra check is required. */ +/* Same as estream_asprintf but die on memory failure. */ char *xasprintf (const char *fmt, ...) JNLIB_GCC_A_PRINTF(1,2); -/* Same as asprintf but return an allocated buffer suitable to be - freed using xfree. This function returns NULL on memory failure and - sets errno. */ +/* This is now an alias to estream_asprintf. */ char *xtryasprintf (const char *fmt, ...) JNLIB_GCC_A_PRINTF(1,2); const char *print_fname_stdout (const char *s); Deleted: trunk/common/vasprintf.c Modified: trunk/common/xasprintf.c =================================================================== --- trunk/common/xasprintf.c 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/common/xasprintf.c 2007-05-15 16:10:48 UTC (rev 4502) @@ -25,7 +25,12 @@ #include "util.h" #include "iobuf.h" +#include "estream-printf.h" +#if !defined(ESTREAM_ASPRINTF_MALLOC) || !defined(ESTREAM_ASPRINTF_FREE) +#error Need to define ESTREAM_ASPRINTF_MALLOC and _FREE +#endif + /* Same as asprintf but return an allocated buffer suitable to be freed using xfree. This function simply dies on memory failure, thus no extra check is required. */ @@ -33,15 +38,13 @@ xasprintf (const char *fmt, ...) { va_list ap; - char *buf, *p; + char *buf; va_start (ap, fmt); - if (vasprintf (&buf, fmt, ap) < 0) - log_fatal ("asprintf failed: %s\n", strerror (errno)); + if (estream_vasprintf (&buf, fmt, ap) < 0) + log_fatal ("estream_asprintf failed: %s\n", strerror (errno)); va_end (ap); - p = xstrdup (buf); - free (buf); - return p; + return buf; } /* Same as above but return NULL on memory failure. */ @@ -50,14 +53,12 @@ { int rc; va_list ap; - char *buf, *p; + char *buf; va_start (ap, fmt); - rc = vasprintf (&buf, fmt, ap); + rc = estream_vasprintf (&buf, fmt, ap); va_end (ap); if (rc < 0) return NULL; - p = xtrystrdup (buf); - free (buf); - return p; + return buf; } Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/configure.ac 2007-05-15 16:10:48 UTC (rev 4502) @@ -26,8 +26,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [2.0.4]) -m4_define([my_issvn], [no]) +m4_define([my_version], [2.0.5]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ @@ -426,6 +426,11 @@ currently enables it by default for no reason. */ #define PTH_SYSCALL_SOFT 0 +/* We want to use the libgcrypt provided memory allocation for + asprintf. */ +#define ESTREAM_ASPRINTF_MALLOC gcry_malloc +#define ESTREAM_ASPRINTF_FREE gcry_free +#define ESTREAM_PRINTF_EXTRA_INCLUDE "util.h" #endif /*GNUPG_CONFIG_H_INCLUDED*/ ]) @@ -986,7 +991,7 @@ # gl_SOURCE_BASE([gl]) gl_M4_BASE([gl/m4]) -gl_MODULES([setenv mkdtemp vasprintf xsize]) +gl_MODULES([setenv mkdtemp xsize]) gl_INIT @@ -1189,6 +1194,12 @@ # +# Prepare building of estream +# +estream_INIT + + +# # Decide what to build # missing_pth=no Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/doc/ChangeLog 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,5 +1,11 @@ +2007-05-11 Werner Koch + + * gpgsm.texi (--export): Enhanced description. + 2007-05-09 Werner Koch + * examples/gpgconf.conf: Remove active example line. + * Makefile.am (online): Distinguish between released and svn manuals. 2007-05-08 Werner Koch Modified: trunk/doc/examples/gpgconf.conf =================================================================== --- trunk/doc/examples/gpgconf.conf 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/doc/examples/gpgconf.conf 2007-05-15 16:10:48 UTC (rev 4502) @@ -52,7 +52,5 @@ #------------------------------------------------------------------- -# Deny all users to change the allow-mark-trusted option. -* gpg-agent allow-mark-trusted [no-change] Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/doc/gpgsm.texi 2007-05-15 16:10:48 UTC (rev 4502) @@ -228,8 +228,14 @@ @item --export [@var{pattern}] @opindex export Export all certificates stored in the Keybox or those specified by the -optional @var{pattern}. When using along with the @code{--armor} option -a few informational lines are prepended before each block. +optional @var{pattern}. Those pattern consist of a list of user ids +(@pxref{how-to-specify-a-user-id}). When used along with the + at option{--armor} option a few informational lines are prepended before +each block. There is one limitation: As there is no commonly agreed +upon way to pack more than one certificate into an ASN.1 structure, the +binary export (i.e. without using @option{armor}) works only for the +export of one certificate. Thus it is required to specify a + at var{pattern} which yields exactly one certificate. @item --export-secret-key-p12 @var{key-id} @opindex export Modified: trunk/gl/Makefile.am =================================================================== --- trunk/gl/Makefile.am 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/gl/Makefile.am 2007-05-15 16:10:48 UTC (rev 4502) @@ -59,18 +59,6 @@ ## end gnulib module setenv -## begin gnulib module vasnprintf - -libgnu_a_SOURCES += printf-args.h printf-parse.h vasnprintf.h - -## end gnulib module vasnprintf - -## begin gnulib module vasprintf - -libgnu_a_SOURCES += vasprintf.h - -## end gnulib module vasprintf - ## begin gnulib module xsize libgnu_a_SOURCES += xsize.h Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/m4/ChangeLog 2007-05-15 16:10:48 UTC (rev 4502) @@ -1,3 +1,7 @@ +2007-05-15 Werner Koch + + * estream.m4: New. + 2007-05-09 Werner Koch * gpg-error.m4, ksba.m4, libassuan.m4, libgcrypt.m4: Updated. Modified: trunk/m4/Makefile.am =================================================================== --- trunk/m4/Makefile.am 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/m4/Makefile.am 2007-05-15 16:10:48 UTC (rev 4502) @@ -8,3 +8,7 @@ EXTRA_DIST += autobuild.m4 +EXTRA_DIST += estream.m4 + + + Added: trunk/m4/estream.m4 =================================================================== --- trunk/m4/estream.m4 2007-05-14 23:16:05 UTC (rev 4501) +++ trunk/m4/estream.m4 2007-05-15 16:10:48 UTC (rev 4502) @@ -0,0 +1,48 @@ +dnl Autoconf macros for libestream +dnl Copyright (C) 2007 g10 Code GmbH +dnl +dnl This file is free software; as a special exception the author gives +dnl unlimited permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl +dnl This file is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl estream_PRINTF_INIT +dnl Prepare build of source included estream-printf.c +dnl +AC_DEFUN([estream_PRINTF_INIT], +[ + AC_MSG_NOTICE([checking system features for estream-printf]) + AC_TYPE_LONG_LONG_INT + AC_TYPE_LONG_DOUBLE + AC_TYPE_INTMAX_T + AC_TYPE_UINTMAX_T + AC_CHECK_TYPES([ptrdiff_t]) + AC_CHECK_SIZEOF([unsigned long]) + AC_CHECK_SIZEOF([void *]) + AC_CACHE_CHECK([for nl_langinfo and THOUSANDS_SEP], + estream_cv_langinfo_thousands_sep, + [AC_TRY_LINK([#include ], + [char* cs = nl_langinfo(THOUSANDS_SEP); return !cs;], + estream_cv_langinfo_thousands_sep=yes, + estream_cv_langinfo_thousands_sep=no) + ]) + if test $estream_cv_langinfo_thousands_sep = yes; then + AC_DEFINE(HAVE_LANGINFO_THOUSANDS_SEP, 1, + [Define if you have and nl_langinfo(THOUSANDS_SEP).]) + fi +]) + + +dnl estream_INIT +dnl Prepare build of source included estream.c +dnl +AC_DEFUN([estream_INIT], +[ + AC_REQUIRE([estream_PRINTF_INIT]) + AC_MSG_NOTICE([checking system features for estream]) + +]) From cvs at cvs.gnupg.org Tue May 15 21:47:44 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 15 May 2007 21:47:44 +0200 Subject: [svn] GnuPG - r4503 - in trunk: . common Message-ID: Author: wk Date: 2007-05-15 21:47:15 +0200 (Tue, 15 May 2007) New Revision: 4503 Modified: trunk/ChangeLog trunk/common/estream-printf.c trunk/common/estream-printf.h trunk/common/estream.h trunk/common/xasprintf.c trunk/configure.ac Log: Adjusted symbols for printf and updated to latest version. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-15 16:10:48 UTC (rev 4502) +++ trunk/ChangeLog 2007-05-15 19:47:15 UTC (rev 4503) @@ -1,6 +1,8 @@ 2007-05-15 Werner Koch - * configure.ac: Call ESTREAM_INIT and define the memory + * configure.ac: Renamed the estream macros. Remove -Wformat-nonliteral. + + * configure.ac: Call ESTREAM_INIT and define the memory allocators for estream_asprintf. (gl_MODULES): Remove vasprintf. Modified: trunk/common/estream-printf.c =================================================================== --- trunk/common/estream-printf.c 2007-05-15 16:10:48 UTC (rev 4502) +++ trunk/common/estream-printf.c 2007-05-15 19:47:15 UTC (rev 4503) @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * - * $Id: estream-printf.c 54 2007-05-15 14:12:06Z wk $ + * $Id: estream-printf.c 56 2007-05-15 18:38:43Z wk $ */ /* Required autoconf tests: @@ -34,8 +34,8 @@ Note that the file estream.m4 provides the autoconf macro ESTREAM_PRINTF_INIT which runs all required checks. + See estream-printf.h for ways to tune this code. - Missing stuff: wchar and wint_t thousands_sep in pr_float. */ @@ -61,21 +61,21 @@ #ifdef TEST # include #endif -#ifdef ESTREAM_PRINTF_EXTRA_INCLUDE -#include ESTREAM_PRINTF_EXTRA_INCLUDE +#ifdef _ESTREAM_PRINTF_EXTRA_INCLUDE +#include _ESTREAM_PRINTF_EXTRA_INCLUDE #endif #include "estream-printf.h" /* Allow redefinition of asprintf used malloc functions. */ -#ifdef ESTREAM_ASPRINTF_MALLOC -#define my_asprintf_malloc(a) ESTREAM_ASPRINTF_MALLOC((a)) +#ifdef _ESTREAM_PRINTF_MALLOC +#define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a)) #else -#define my_asprintf_malloc(a) malloc((a)) +#define my_printf_malloc(a) malloc((a)) #endif -#ifdef ESTREAM_ASPRINTF_FREE -#define my_asprintf_free(a) ESTREAM_ASPRINTF_FREE((a)) +#ifdef _ESTREAM_PRINTF_FREE +#define my_printf_free(a) _ESTREAM_PRINTF_FREE((a)) #else -#define my_asprintf_free(a) free((a)) +#define my_printf_free(a) free((a)) #endif @@ -1799,7 +1799,7 @@ parm.error_flag = 0; parm.alloced = 512; parm.used = 0; - parm.buffer = my_asprintf_malloc (parm.alloced); + parm.buffer = my_printf_malloc (parm.alloced); if (!parm.buffer) { *bufp = NULL; @@ -1816,7 +1816,7 @@ if (rc == -1) { memset (parm.buffer, 0, parm.used); - my_asprintf_free (parm.buffer); + my_printf_free (parm.buffer); *bufp = NULL; return -1; } Modified: trunk/common/estream-printf.h =================================================================== --- trunk/common/estream-printf.h 2007-05-15 16:10:48 UTC (rev 4502) +++ trunk/common/estream-printf.h 2007-05-15 19:47:15 UTC (rev 4503) @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * - * $Id: estream-printf.h 54 2007-05-15 14:12:06Z wk $ + * $Id: estream-printf.h 56 2007-05-15 18:38:43Z wk $ */ #ifndef ESTREAM_PRINTF_H @@ -27,34 +27,88 @@ #include #include +/* To use this file with libraries the following macro is useful: + + #define _ESTREAM_EXT_SYM_PREFIX _foo_ + + This prefixes all external symbols with "_foo_". + + For the implementation of the code (estream-printf.c) the following + macros may be used to tune the implementation for certain systems: + + #define _ESTREAM_PRINTF_MALLOC foo_malloc + #define _ESTREAM_PRINTF_FREE foo_free + + Make estream_asprintf and estream_vasprintf use foo_malloc and + foo_free instead of the standard malloc and free functions to + allocate the memory returned to the caller. + + #define _ESTREAM_PRINTF_EXTRA_INCLUDE "foo.h" + + This includes the file "foo.h" which may provide prototypes for + the custom memory allocation functions. + */ + + +#ifdef _ESTREAM_EXT_SYM_PREFIX +#ifndef _ESTREAM_PREFIX +#define _ESTREAM_PREFIX1(x,y) x ## y +#define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y) +#define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x) +#endif /*_ESTREAM_PREFIX*/ +#define estream_printf_out_t _ESTREAM_PREFIX(estream_printf_out_t) +#define estream_format _ESTREAM_PREFIX(estream_format) +#define estream_printf _ESTREAM_PREFIX(estream_printf) +#define estream_fprintf _ESTREAM_PREFIX(estream_fprintf) +#define estream_vfprintf _ESTREAM_PREFIX(estream_vfprintf) +#define estream_snprintf _ESTREAM_PREFIX(estream_snprintf) +#define estream_vsnprintf _ESTREAM_PREFIX(estream_vsnprintf) +#define estream_asprintf _ESTREAM_PREFIX(estream_asprintf) +#define estream_vasprintf _ESTREAM_PREFIX(estream_vasprintf) +#endif /*_ESTREAM_EXT_SYM_PREFIX*/ + +#ifndef _ESTREAM_GCC_A_PRINTF #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) -# define ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) +# define _ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) #else -# define ESTREAM_GCC_A_PRINTF( f, a ) +# define _ESTREAM_GCC_A_PRINTF( f, a ) #endif +#endif /*_ESTREAM_GCC_A_PRINTF*/ +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif +#endif + + typedef int (*estream_printf_out_t) (void *outfncarg, const char *buf, size_t buflen); int estream_format (estream_printf_out_t outfnc, void *outfncarg, const char *format, va_list vaargs) - ESTREAM_GCC_A_PRINTF(3,0); + _ESTREAM_GCC_A_PRINTF(3,0); int estream_printf (const char *format, ...) - ESTREAM_GCC_A_PRINTF(1,2); + _ESTREAM_GCC_A_PRINTF(1,2); int estream_fprintf (FILE *fp, const char *format, ... ) - ESTREAM_GCC_A_PRINTF(2,3); + _ESTREAM_GCC_A_PRINTF(2,3); int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) - ESTREAM_GCC_A_PRINTF(2,0); + _ESTREAM_GCC_A_PRINTF(2,0); int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) - ESTREAM_GCC_A_PRINTF(3,4); + _ESTREAM_GCC_A_PRINTF(3,4); int estream_vsnprintf (char *buf,size_t bufsize, const char *format, va_list arg_ptr) - ESTREAM_GCC_A_PRINTF(3,0); + _ESTREAM_GCC_A_PRINTF(3,0); int estream_asprintf (char **bufp, const char *format, ...) - ESTREAM_GCC_A_PRINTF(2,3); + _ESTREAM_GCC_A_PRINTF(2,3); int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) - ESTREAM_GCC_A_PRINTF(2,0); + _ESTREAM_GCC_A_PRINTF(2,0); +#ifdef __cplusplus +} +#endif #endif /*ESTREAM_PRINTF_H*/ Modified: trunk/common/estream.h =================================================================== --- trunk/common/estream.h 2007-05-15 16:10:48 UTC (rev 4502) +++ trunk/common/estream.h 2007-05-15 19:47:15 UTC (rev 4503) @@ -26,7 +26,82 @@ #include #include - +/* To use this file with libraries the following macro is useful: + + #define _ESTREAM_EXT_SYM_PREFIX _foo_ + + This prefixes all external symbols with "_foo_". + + */ + + +#ifdef _ESTREAM_EXT_SYM_PREFIX +#ifndef _ESTREAM_PREFIX +#define _ESTREAM_PREFIX1(x,y) x ## y +#define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y) +#define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x) +#endif /*_ESTREAM_PREFIX*/ +#define es_fopen _ESTREAM_PREFIX(es_fopen) +#define es_mopen _ESTREAM_PREFIX(es_mopen) +#define es_open_memstream _ESTREAM_PREFIX(es_open_memstream) +#define es_fdopen _ESTREAM_PREFIX(es_fdopen) +#define es_freopen _ESTREAM_PREFIX(es_freopen) +#define es_fopencookie _ESTREAM_PREFIX(es_fopencookie) +#define es_fclose _ESTREAM_PREFIX(es_fclose) +#define es_fileno _ESTREAM_PREFIX(es_fileno) +#define es_fileno_unlocked _ESTREAM_PREFIX(es_fileno_unlocked) +#define es_flockfile _ESTREAM_PREFIX(es_flockfile) +#define es_ftrylockfile _ESTREAM_PREFIX(es_ftrylockfile) +#define es_funlockfile _ESTREAM_PREFIX(es_funlockfile) +#define es_feof _ESTREAM_PREFIX(es_feof) +#define es_feof_unlocked _ESTREAM_PREFIX(es_feof_unlocked) +#define es_ferror _ESTREAM_PREFIX(es_ferror) +#define es_ferror_unlocked _ESTREAM_PREFIX(es_ferror_unlocked) +#define es_clearerr _ESTREAM_PREFIX(es_clearerr) +#define es_clearerr_unlocked _ESTREAM_PREFIX(es_clearerr_unlocked) +#define es_fflush _ESTREAM_PREFIX(es_fflush) +#define es_fseek _ESTREAM_PREFIX(es_fseek) +#define es_fseeko _ESTREAM_PREFIX(es_fseeko) +#define es_ftell _ESTREAM_PREFIX(es_ftell) +#define es_ftello _ESTREAM_PREFIX(es_ftello) +#define es_rewind _ESTREAM_PREFIX(es_rewind) +#define es_fgetc _ESTREAM_PREFIX(es_fgetc) +#define es_fputc _ESTREAM_PREFIX(es_fputc) +#define _es_getc_underflow _ESTREAM_PREFIX(_es_getc_underflow) +#define _es_putc_overflow _ESTREAM_PREFIX(_es_putc_overflow) +#define es_ungetc _ESTREAM_PREFIX(es_ungetc) +#define es_read _ESTREAM_PREFIX(es_read) +#define es_write _ESTREAM_PREFIX(es_write) +#define es_write_sanitized _ESTREAM_PREFIX(es_write_sanitized) +#define es_write_hexstring _ESTREAM_PREFIX(es_write_hexstring) +#define es_fread _ESTREAM_PREFIX(es_fread) +#define es_fwrite _ESTREAM_PREFIX(es_fwrite) +#define es_fgets _ESTREAM_PREFIX(es_fgets) +#define es_fputs _ESTREAM_PREFIX(es_fputs) +#define es_getline _ESTREAM_PREFIX(es_getline) +#define es_read_line _ESTREAM_PREFIX(es_read_line) +#define es_free _ESTREAM_PREFIX(es_free) +#define es_fprf _ESTREAM_PREFIX(es_fprf) +#define es_vfprf _ESTREAM_PREFIX(es_vfprf) +#define es_setvbuf _ESTREAM_PREFIX(es_setvbuf) +#define es_setbuf _ESTREAM_PREFIX(es_setbuf) +#define es_tmpfile _ESTREAM_PREFIX(es_tmpfile) +#define es_opaque_set _ESTREAM_PREFIX(es_opaque_set) +#define es_opaque_get _ESTREAM_PREFIX(es_opaque_get) +#define es_write_sanitized_utf8_buffer \ + _ESTREAM_PREFIX(es_write_sanitized_utf8_buffer) +#endif /*_ESTREAM_EXT_SYM_PREFIX*/ + + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif +#endif + + /* Forward declaration for the (opaque) internal type. */ struct estream_internal; @@ -90,6 +165,15 @@ } es_cookie_io_functions_t; +#ifndef _ESTREAM_GCC_A_PRINTF +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) +# define _ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) +#else +# define _ESTREAM_GCC_A_PRINTF( f, a ) +#endif +#endif /*_ESTREAM_GCC_A_PRINTF*/ + + #ifndef ES__RESTRICT # if defined __GNUC__ && defined __GNUC_MINOR__ # if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 92)) @@ -191,16 +275,17 @@ ssize_t es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, estream_t stream); -ssize_t es_read_line (estream_t stream, +ssize_t es_read_line (estream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length); void es_free (void *a); int es_fprintf (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...); + const char *ES__RESTRICT format, ...) + _ESTREAM_GCC_A_PRINTF(2,3); int es_vfprintf (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, va_list ap); - + const char *ES__RESTRICT format, va_list ap) + _ESTREAM_GCC_A_PRINTF(2,0); int es_setvbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf, int mode, size_t size); void es_setbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf); @@ -213,12 +298,13 @@ #ifdef GNUPG_MAJOR_VERSION int es_write_sanitized_utf8_buffer (estream_t stream, - const void *buffer, size_t length, + const void *buffer, size_t length, const char *delimiters, size_t *bytes_written); #endif /*GNUPG_MAJOR_VERSION*/ - +#ifdef __cplusplus +} +#endif #endif /*ESTREAM_H*/ - Modified: trunk/common/xasprintf.c =================================================================== --- trunk/common/xasprintf.c 2007-05-15 16:10:48 UTC (rev 4502) +++ trunk/common/xasprintf.c 2007-05-15 19:47:15 UTC (rev 4503) @@ -27,8 +27,8 @@ #include "iobuf.h" #include "estream-printf.h" -#if !defined(ESTREAM_ASPRINTF_MALLOC) || !defined(ESTREAM_ASPRINTF_FREE) -#error Need to define ESTREAM_ASPRINTF_MALLOC and _FREE +#if !defined(_ESTREAM_PRINTF_MALLOC) || !defined(_ESTREAM_PRINTF_FREE) +#error Need to define ESTREAM_PRINTF_MALLOC and _FREE #endif /* Same as asprintf but return an allocated buffer suitable to be Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-15 16:10:48 UTC (rev 4502) +++ trunk/configure.ac 2007-05-15 19:47:15 UTC (rev 4503) @@ -428,9 +428,9 @@ /* We want to use the libgcrypt provided memory allocation for asprintf. */ -#define ESTREAM_ASPRINTF_MALLOC gcry_malloc -#define ESTREAM_ASPRINTF_FREE gcry_free -#define ESTREAM_PRINTF_EXTRA_INCLUDE "util.h" +#define _ESTREAM_PRINTF_MALLOC gcry_malloc +#define _ESTREAM_PRINTF_FREE gcry_free +#define _ESTREAM_PRINTF_EXTRA_INCLUDE "util.h" #endif /*GNUPG_CONFIG_H_INCLUDED*/ ]) @@ -1157,7 +1157,7 @@ # them. if test "$USE_MAINTAINER_MODE" = "yes"; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" - CFLAGS="$CFLAGS -Wno-format-y2k -Wformat-security -Wformat-nonliteral" + CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security" else CFLAGS="$CFLAGS -Wall" fi From cvs at cvs.gnupg.org Wed May 16 13:10:37 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 16 May 2007 13:10:37 +0200 Subject: [svn] GnuPG - r4504 - trunk/g10 Message-ID: Author: wk Date: 2007-05-16 13:10:07 +0200 (Wed, 16 May 2007) New Revision: 4504 Modified: trunk/g10/ChangeLog trunk/g10/sig-check.c Log: Fix for bug 797. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-05-15 19:47:15 UTC (rev 4503) +++ trunk/g10/ChangeLog 2007-05-16 11:10:07 UTC (rev 4504) @@ -1,3 +1,8 @@ +2007-05-16 Werner Koch + + * sig-check.c (check_backsig): Check the digest algorithm before + using it. Fixed bug 797. + 2007-05-09 Werner Koch * openfile.c (overwrite_filep, open_outfile) [W32]: Need to use Modified: trunk/g10/sig-check.c =================================================================== --- trunk/g10/sig-check.c 2007-05-15 19:47:15 UTC (rev 4503) +++ trunk/g10/sig-check.c 2007-05-16 11:10:07 UTC (rev 4504) @@ -438,22 +438,25 @@ gcry_md_hd_t md; int rc; + /* Always check whether the algorithm is available. Although + gcry_md_open woyuld throw an error, some libgcrypt versions will + print a debug message in that case too. */ + if ((rc=openpgp_md_test_algo (backsig->digest_algo))) + return rc; + if(!opt.no_sig_cache && backsig->flags.checked) + return backsig->flags.valid? 0 : gpg_error (GPG_ERR_BAD_SIGNATURE); + + rc = gcry_md_open (&md, backsig->digest_algo,0); + if (!rc) { - if((rc=openpgp_md_test_algo (backsig->digest_algo))) - return rc; - - return backsig->flags.valid? 0 : gpg_error (GPG_ERR_BAD_SIGNATURE); + hash_public_key(md,main_pk); + hash_public_key(md,sub_pk); + rc=do_check(sub_pk,backsig,md,NULL,NULL,NULL); + cache_sig_result(backsig,rc); + gcry_md_close(md); } - if (gcry_md_open (&md, backsig->digest_algo,0)) - BUG (); - hash_public_key(md,main_pk); - hash_public_key(md,sub_pk); - rc=do_check(sub_pk,backsig,md,NULL,NULL,NULL); - cache_sig_result(backsig,rc); - gcry_md_close(md); - return rc; } From cvs at cvs.gnupg.org Sat May 19 00:31:13 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sat, 19 May 2007 00:31:13 +0200 Subject: [svn] gpgme - r1216 - trunk/doc Message-ID: Author: marcus Date: 2007-05-19 00:30:42 +0200 (Sat, 19 May 2007) New Revision: 1216 Modified: trunk/doc/ChangeLog trunk/doc/gpgme.texi Log: 2007-05-18 Marcus Brinkmann * gpgme.texi (Error Strings): Fix documentation of gpgme_strerror_r. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-05-03 20:12:40 UTC (rev 1215) +++ trunk/doc/ChangeLog 2007-05-18 22:30:42 UTC (rev 1216) @@ -1,4 +1,8 @@ +2007-05-18 Marcus Brinkmann + * gpgme.texi (Error Strings): Fix documentation of + gpgme_strerror_r. + 2006-11-01 Moritz Schulte * gpgme.texi (Data Buffer I/O Operations): Fixed entry for Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2007-05-03 20:12:40 UTC (rev 1215) +++ trunk/doc/gpgme.texi 2007-05-18 22:30:42 UTC (rev 1216) @@ -21,7 +21,7 @@ @value{VERSION}. @c NOTE: Don't forget to update the year for the TeX version, too. -Copyright @copyright{} 2002, 2003, 2004, 2005 g10 Code GmbH. +Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH. The GPGME reference manual is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -54,7 +54,7 @@ @center for version @value{VERSION} @page @vskip 0pt plus 1filll -Copyright @copyright{} 2002, 2003, 2004, 2005 g10 Code GmbH. +Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH. The GPGME reference manual is free software; you can redistribute it @@ -1403,12 +1403,15 @@ @end deftypefun - at deftypefun {char *} gpgme_strerror_r (@w{gpgme_error_t @var{err}}) -The function @code{gpgme_strerror_r} returns a pointer to a -dynamically allocated string containing a description of the error -code contained in the error value @var{err}. This string can be used -to output a diagnostic message to the user. When it is not needed -anymore, the user must deallocate it with @code{free}. + at deftypefun {int} gpgme_strerror_r (@w{gpgme_error_t @var{err}}, @w{char *@var{buf}}, @w{size_t @var{buflen}}) +The function @code{gpgme_strerror_r} returns the error string for + at var{err} in the user-supplied buffer @var{buf} of size @var{buflen}. +This function is, in contrast to @code{gpgme_strerror}, thread-safe if +a thread-safe @code{strerror_r} function is provided by the system. +If the function succeeds, 0 is returned and @var{buf} contains the +string describing the error. If the buffer was not large enough, +ERANGE is returned and @var{buf} contains as much of the beginning of +the error string as fits into the buffer. @end deftypefun From cvs at cvs.gnupg.org Sat May 19 00:59:31 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sat, 19 May 2007 00:59:31 +0200 Subject: [svn] GnuPG - r4505 - in trunk: agent g10 sm tools Message-ID: Author: marcus Date: 2007-05-19 00:58:59 +0200 (Sat, 19 May 2007) New Revision: 4505 Modified: trunk/agent/ChangeLog trunk/agent/protect-tool.c trunk/g10/ChangeLog trunk/g10/passphrase.c trunk/sm/ChangeLog trunk/sm/certdump.c trunk/sm/qualified.c trunk/tools/ChangeLog trunk/tools/symcryptrun.c Log: agent/ 2007-05-19 Marcus Brinkmann * protect-tool.c (get_passphrase): Free ORIG_CODESET on error. g10/ 2007-05-19 Marcus Brinkmann * passphrase.c (passphrase_get): Free ORIG_CODESET on error. sm/ 2007-05-18 Marcus Brinkmann * qualified.c (gpgsm_qualified_consent, gpgsm_not_qualified_warning): Free ORIG_CODESET on error. * certdump.c (gpgsm_format_keydesc): Likewise. tools/ 2007-05-19 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Free ORIG_CODESET on error. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/agent/ChangeLog 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,3 +1,7 @@ +2007-05-19 Marcus Brinkmann + + * protect-tool.c (get_passphrase): Free ORIG_CODESET on error. + 2007-05-14 Werner Koch * protect.c (make_shadow_info): Replace sprintf by smklen. Modified: trunk/agent/protect-tool.c =================================================================== --- trunk/agent/protect-tool.c 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/agent/protect-tool.c 2007-05-18 22:58:59 UTC (rev 4505) @@ -1183,7 +1183,10 @@ /* We only switch when we are able to restore the codeset later. */ orig_codeset = xstrdup (orig_codeset); if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) - orig_codeset = NULL; + { + xfree (orig_codeset); + orig_codeset = NULL; + } } #endif Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/g10/ChangeLog 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,3 +1,7 @@ +2007-05-19 Marcus Brinkmann + + * passphrase.c (passphrase_get): Free ORIG_CODESET on error. + 2007-05-16 Werner Koch * sig-check.c (check_backsig): Check the digest algorithm before Modified: trunk/g10/passphrase.c =================================================================== --- trunk/g10/passphrase.c 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/g10/passphrase.c 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,6 +1,6 @@ /* passphrase.c - Get a passphrase * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005, 2006 Free Software Foundation, Inc. + * 2005, 2006, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -289,8 +289,11 @@ if (orig_codeset) { /* We only switch when we are able to restore the codeset later. */ orig_codeset = xstrdup (orig_codeset); - if (!bind_textdomain_codeset (PACKAGE, "utf-8")) - orig_codeset = NULL; + if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) + { + xfree (orig_codeset); + orig_codeset = NULL; + } } #endif Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/sm/ChangeLog 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,3 +1,9 @@ +2007-05-18 Marcus Brinkmann + + * qualified.c (gpgsm_qualified_consent, + gpgsm_not_qualified_warning): Free ORIG_CODESET on error. + * certdump.c (gpgsm_format_keydesc): Likewise. + 2007-05-07 Werner Koch * certcheck.c (MY_GCRY_PK_ECDSA): New. Modified: trunk/sm/certdump.c =================================================================== --- trunk/sm/certdump.c 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/sm/certdump.c 2007-05-18 22:58:59 UTC (rev 4505) @@ -921,7 +921,10 @@ bother printing a diagnostic here. */ orig_codeset = xstrdup (orig_codeset); if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) - orig_codeset = NULL; + { + xfree (orig_codeset); + orig_codeset = NULL; + } } #endif @@ -938,9 +941,11 @@ #ifdef ENABLE_NLS if (orig_codeset) - bind_textdomain_codeset (PACKAGE_GT, orig_codeset); + { + bind_textdomain_codeset (PACKAGE_GT, orig_codeset); + xfree (orig_codeset); + } #endif - xfree (orig_codeset); if (rc < 0) { Modified: trunk/sm/qualified.c =================================================================== --- trunk/sm/qualified.c 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/sm/qualified.c 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,5 +1,5 @@ /* qualified.c - Routines related to qualified signatures - * Copyright (C) 2005 Free Software Foundation, Inc. + * Copyright (C) 2005, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -216,7 +216,10 @@ bother printing a diagnostic here. */ orig_codeset = xstrdup (orig_codeset); if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) - orig_codeset = NULL; + { + xfree (orig_codeset); + orig_codeset = NULL; + } } #endif @@ -313,7 +316,10 @@ bother printing a diagnostic here. */ orig_codeset = xstrdup (orig_codeset); if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) - orig_codeset = NULL; + { + xfree (orig_codeset); + orig_codeset = NULL; + } } #endif @@ -330,9 +336,11 @@ #ifdef ENABLE_NLS if (orig_codeset) - bind_textdomain_codeset (PACKAGE_GT, orig_codeset); + { + bind_textdomain_codeset (PACKAGE_GT, orig_codeset); + xfree (orig_codeset); + } #endif - xfree (orig_codeset); xfree (subject); if (err) Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/tools/ChangeLog 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,3 +1,7 @@ +2007-05-19 Marcus Brinkmann + + * symcryptrun.c (confucius_get_pass): Free ORIG_CODESET on error. + 2007-05-08 Werner Koch * sockprox.c: New. It needs to be build manually. By Moritz Modified: trunk/tools/symcryptrun.c =================================================================== --- trunk/tools/symcryptrun.c 2007-05-16 11:10:07 UTC (rev 4504) +++ trunk/tools/symcryptrun.c 2007-05-18 22:58:59 UTC (rev 4505) @@ -1,5 +1,5 @@ /* symcryptrun.c - Tool to call simple symmetric encryption tools. - * Copyright (C) 2005 Free Software Foundation, Inc. + * Copyright (C) 2005, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -460,7 +460,10 @@ /* We only switch when we are able to restore the codeset later. */ orig_codeset = xstrdup (orig_codeset); if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) - orig_codeset = NULL; + { + xfree (orig_codeset); + orig_codeset = NULL; + } } #endif From cvs at cvs.gnupg.org Sat May 19 01:33:21 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sat, 19 May 2007 01:33:21 +0200 Subject: [svn] GnuPG - r4506 - trunk/g10 Message-ID: Author: marcus Date: 2007-05-19 01:32:51 +0200 (Sat, 19 May 2007) New Revision: 4506 Modified: trunk/g10/ChangeLog trunk/g10/passphrase.c Log: 2007-05-19 Marcus Brinkmann * passphrase.c (passphrase_get): Use PACKAGE_GT, not PACKAGE. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-05-18 22:58:59 UTC (rev 4505) +++ trunk/g10/ChangeLog 2007-05-18 23:32:51 UTC (rev 4506) @@ -1,5 +1,7 @@ 2007-05-19 Marcus Brinkmann + * passphrase.c (passphrase_get): Use PACKAGE_GT, not PACKAGE. + * passphrase.c (passphrase_get): Free ORIG_CODESET on error. 2007-05-16 Werner Koch Modified: trunk/g10/passphrase.c =================================================================== --- trunk/g10/passphrase.c 2007-05-18 22:58:59 UTC (rev 4505) +++ trunk/g10/passphrase.c 2007-05-18 23:32:51 UTC (rev 4506) @@ -281,7 +281,7 @@ #ifdef ENABLE_NLS /* The Assuan agent protocol requires us to transmit utf-8 strings */ - orig_codeset = bind_textdomain_codeset (PACKAGE, NULL); + orig_codeset = bind_textdomain_codeset (PACKAGE_GT, NULL); #ifdef HAVE_LANGINFO_CODESET if (!orig_codeset) orig_codeset = nl_langinfo (CODESET); @@ -396,7 +396,7 @@ #ifdef ENABLE_NLS if (orig_codeset) { - bind_textdomain_codeset (PACKAGE, orig_codeset); + bind_textdomain_codeset (PACKAGE_GT, orig_codeset); xfree (orig_codeset); } #endif From cvs at cvs.gnupg.org Sat May 19 23:32:22 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sat, 19 May 2007 23:32:22 +0200 Subject: [svn] gcry - r1253 - trunk Message-ID: Author: marcus Date: 2007-05-19 23:31:51 +0200 (Sat, 19 May 2007) New Revision: 1253 Modified: trunk/ChangeLog trunk/configure.ac Log: 2007-05-19 Marcus Brinkmann * configure.ac: Fix test for optional UDIV and UDIV_QRNND MPI modules. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-09 22:20:26 UTC (rev 1252) +++ trunk/ChangeLog 2007-05-19 21:31:51 UTC (rev 1253) @@ -1,3 +1,8 @@ +2007-05-19 Marcus Brinkmann + + * configure.ac: Fix test for optional UDIV and UDIV_QRNND MPI + modules. + 2007-05-09 Marcus Brinkmann * configure.ac (ac_cv_mpi_config_done): Unused variable removed. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-09 22:20:26 UTC (rev 1252) +++ trunk/configure.ac 2007-05-19 21:31:51 UTC (rev 1253) @@ -690,8 +690,8 @@ AM_CONDITIONAL(MPI_MOD_ASM_MPIH_MUL3, test "$mpi_mod_asm_mpih_mul3" = yes) AM_CONDITIONAL(MPI_MOD_ASM_MPIH_LSHIFT, test "$mpi_mod_asm_mpih_lshift" = yes) AM_CONDITIONAL(MPI_MOD_ASM_MPIH_RSHIFT, test "$mpi_mod_asm_mpih_rshift" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_mpih_udiv" = yes) -AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_mpih_udiv_qrnnd" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV, test "$mpi_mod_asm_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_ASM_UDIV_QRNND, test "$mpi_mod_asm_udiv_qrnnd" = yes) AM_CONDITIONAL(MPI_MOD_C_MPIH_ADD1, test "$mpi_mod_c_mpih_add1" = yes) AM_CONDITIONAL(MPI_MOD_C_MPIH_SUB1, test "$mpi_mod_c_mpih_sub1" = yes) AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL1, test "$mpi_mod_c_mpih_mul1" = yes) @@ -699,8 +699,8 @@ AM_CONDITIONAL(MPI_MOD_C_MPIH_MUL3, test "$mpi_mod_c_mpih_mul3" = yes) AM_CONDITIONAL(MPI_MOD_C_MPIH_LSHIFT, test "$mpi_mod_c_mpih_lshift" = yes) AM_CONDITIONAL(MPI_MOD_C_MPIH_RSHIFT, test "$mpi_mod_c_mpih_rshift" = yes) -AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_mpih_udiv" = yes) -AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_mpih_udiv_qrnnd" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV, test "$mpi_mod_c_udiv" = yes) +AM_CONDITIONAL(MPI_MOD_C_UDIV_QRNND, test "$mpi_mod_c_udiv_qrnnd" = yes) # Allow users to append something to the version string without # flagging it as development version. The user version part is From cvs at cvs.gnupg.org Sun May 20 00:02:15 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun, 20 May 2007 00:02:15 +0200 Subject: [svn] gpg-error - r193 - in trunk: . lang/cl Message-ID: Author: marcus Date: 2007-05-20 00:01:45 +0200 (Sun, 20 May 2007) New Revision: 193 Modified: trunk/ChangeLog trunk/lang/cl/gpg-error.lisp Log: 2007-05-19 Marcus Brinkmann * lang/cl/gpg-error.lisp (gpg-err-source-t): Add :gpg-err-source-any. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-02-26 15:38:39 UTC (rev 192) +++ trunk/ChangeLog 2007-05-19 22:01:45 UTC (rev 193) @@ -1,3 +1,8 @@ +2007-05-19 Marcus Brinkmann + + * lang/cl/gpg-error.lisp (gpg-err-source-t): Add + :gpg-err-source-any. + 2006-12-09 Marcus Brinkmann * src/Makefile.am (EXTRA_DIST): Add README. Modified: trunk/lang/cl/gpg-error.lisp =================================================================== --- trunk/lang/cl/gpg-error.lisp 2007-02-26 15:38:39 UTC (rev 192) +++ trunk/lang/cl/gpg-error.lisp 2007-05-19 22:01:45 UTC (rev 193) @@ -50,6 +50,7 @@ (:gpg-err-source-ksba 9) (:gpg-err-source-dirmngr 10) (:gpg-err-source-gsti 11) + (:gpg-err-source-any 31) (:gpg-err-source-user-1 32) (:gpg-err-source-user-2 33) (:gpg-err-source-user-3 34) From cvs at cvs.gnupg.org Tue May 29 19:36:54 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 29 May 2007 19:36:54 +0200 Subject: [svn] ksba - r274 - in trunk: . src Message-ID: Author: wk Date: 2007-05-29 19:36:24 +0200 (Tue, 29 May 2007) New Revision: 274 Added: trunk/src/libksba.def trunk/src/versioninfo.rc.in trunk/ylwrap Modified: trunk/ChangeLog trunk/autogen.sh trunk/configure.ac trunk/src/ChangeLog trunk/src/Makefile.am Log: Support for building as a W32 DLL. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/ChangeLog 2007-05-29 17:36:24 UTC (rev 274) @@ -1,3 +1,17 @@ +2007-05-29 Werner Koch + + * configure.ac (AC_LIBTOOL_WIN32_DLL): New. + (HAVE_W32_SYSTEM): New. + (BUILD_REVISION, BUILD_TIMESTAMP, BUILD_FILEVERSION): New. + (AC_CANONICAL_TARGET): New. + + * autogen.sh: Add Option --force. Modernized cross compiler + selection for --build-w32. + +2007-05-24 Werner Koch + + * configure.ac: Use -Wpointer-arith if possible. + 2007-04-06 Werner Koch * configure.ac: Require libgpg-error 1.4. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/autogen.sh 2007-05-29 17:36:24 UTC (rev 274) @@ -29,6 +29,11 @@ } DIE=no +FORCE= +if test "$1" == "--force"; then + FORCE=" --force" + shift +fi # ***** W32 build script ******* @@ -46,27 +51,23 @@ [ -z "$w32root" ] && w32root="$HOME/w32root" echo "Using $w32root as standard install directory" >&2 - # See whether we have the Debian cross compiler package or the - # old mingw32/cpd system - if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then - host=i586-mingw32msvc - crossbindir=/usr/$host/bin - else - host=i386--mingw32 - if ! mingw32 --version >/dev/null; then - echo "We need at least version 0.3 of MingW32/CPD" >&2 - exit 1 - fi - crossbindir=`mingw32 --install-dir`/bin - # Old autoconf version required us to setup the environment - # with the proper tool names. - CC=`mingw32 --get-path gcc` - CPP=`mingw32 --get-path cpp` - AR=`mingw32 --get-path ar` - RANLIB=`mingw32 --get-path ranlib` - export CC CPP AR RANLIB + crossbindir= + for host in i586-mingw32msvc i386-mingw32msvc mingw32; do + if ${host}-gcc --version >/dev/null 2>&1 ; then + crossbindir=/usr/${host}/bin + conf_CC="CC=${host}-gcc" + break; + fi + done + if [ -z "$crossbindir" ]; then + echo "Cross compiler kit not installed" >&2 + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + echo "Stop." >&2 + exit 1 fi + if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then echo "Pease run a 'make distclean' first" >&2 @@ -75,9 +76,8 @@ fi ./configure --enable-maintainer-mode --prefix=${w32root} \ - --host=i586-mingw32msvc --build=${build} \ + --host=${host} --build=${build} \ --with-gpg-error-prefix=${w32root} \ - --disable-shared exit $? fi @@ -198,7 +198,7 @@ $AUTOHEADER echo "Running automake --gnu ..." $AUTOMAKE --gnu; -echo "Running autoconf..." -$AUTOCONF +echo "Running autoconf${FORCE} ..." +$AUTOCONF${FORCE} echo "You may now run \"./configure --enable-maintainer-mode && make\"." Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/configure.ac 2007-05-29 17:36:24 UTC (rev 274) @@ -1,5 +1,5 @@ # configure.ac - for libksba -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 g10 Code GmbH +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH # # This file is part of KSBA # @@ -19,8 +19,8 @@ # USA. # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.57) -min_automake_version="1.9.3" +AC_PREREQ(2.61) +min_automake_version="1.10" # Remember to change the version number immediately *after* a release. @@ -32,7 +32,7 @@ m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) AC_INIT([libksba], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]), - [gpa-dev at gnupg.org]) + [gnupg-devel at gnupg.org]) # LT Version numbers: Remember to change them just *before* a release. # (Interfaces removed: CURRENT++, AGE=0, REVISION=0) @@ -49,11 +49,12 @@ NEED_GPG_ERROR_VERSION=1.4 - +BUILD_REVISION=svn_revision PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION AC_CONFIG_SRCDIR([src/ksba.h]) +AC_CANONICAL_TARGET AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AM_CONFIG_HEADER(config.h) AB_INIT @@ -84,6 +85,10 @@ AC_PROG_AWK AC_PROG_CC AC_PROG_CPP +AM_PROG_CC_C_O +if test "x$ac_cv_prog_cc_c89" = "xno" ; then + AC_MSG_ERROR([[No C-89 compiler found]]) +fi AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET @@ -92,11 +97,23 @@ AC_PROG_YACC AC_C_INLINE +AC_LIBTOOL_WIN32_DLL +AC_LIBTOOL_RC AM_PROG_LIBTOOL if test "$GCC" = yes; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" + AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wpointer-arith" + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_wopt" = xyes ; then + CFLAGS="$CFLAGS -Wpointer-arith" + fi + AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wno-pointer-sign" @@ -109,7 +126,21 @@ fi +# Setup some stuff depending on host/target. +have_w32_system=no +case "${target}" in + *-*-mingw32*) + have_w32_system=yes + ;; + *) + ;; +esac +if test "$have_w32_system" = yes; then + AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) +fi +AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) + # For some systems we know that we have ld_version scripts. # Use it then as default. have_ld_version_script=no @@ -141,6 +172,7 @@ AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_KSBA, [The default error source for libksba.]) + # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([string.h]) @@ -175,11 +207,28 @@ # The Makefiles need to know about cross compiling AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes) + +# Generate extended version information for W32. +if test "$have_w32_system" = yes; then + BUILD_TIMESTAMP=`date --iso-8601=minutes` + changequote(,)dnl + BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` + changequote([,])dnl + BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}" +fi +AC_SUBST(BUILD_REVISION) +AC_SUBST(BUILD_TIMESTAMP) +AC_SUBST(BUILD_FILEVERSION) +AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION", + [Subversion revision used to build this package]) + + AC_CONFIG_FILES([ Makefile gl/Makefile src/Makefile src/ksba-config +src/versioninfo.rc tests/Makefile doc/Makefile ]) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/src/ChangeLog 2007-05-29 17:36:24 UTC (rev 274) @@ -1,3 +1,10 @@ +2007-05-29 Werner Koch + + * versioninfo.rc.in: New. + * libksba.def: New. + * Makefile.am: Add code to build a W32 DLL. + (install-data-local, uninstall-local): New. + 2007-05-14 Werner Koch * sexp-parse.h (smklen): New. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/src/Makefile.am 2007-05-29 17:36:24 UTC (rev 274) @@ -1,5 +1,5 @@ # Makefile.am - for the KSBA ASN.1 and X.509 library -# Copyright (C) 2001, 2002, 2004, 2005 g10 Code GmbH +# Copyright (C) 2001, 2002, 2004, 2005, 2007 g10 Code GmbH # # This file is part of KSBA. # @@ -22,7 +22,7 @@ asn1_modules = tmttv2.asn cms.asn -EXTRA_DIST = ksba-config.in $(asn1_modules) ksba.m4 libksba.vers \ +EXTRA_DIST = ksba-config.in $(asn1_modules) ksba.m4 libksba.vers libksba.def \ asn1-parse.c asn1-tables.c BUILT_SOURCES = asn1-parse.c asn1-tables.c bin_SCRIPTS = ksba-config @@ -47,12 +47,45 @@ endif +if HAVE_W32_SYSTEM +LTRCCOMPILE = $(LIBTOOL) --mode=compile $(RC) \ + `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ + sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -libksba_la_LDFLAGS = $(libksba_version_script_cmd) -version-info \ +.rc.lo: + $(LTRCCOMPILE) -i $< -o $@ + +ksba_res = versioninfo.lo +ksba_res_ldflag = -Wl,.libs/versioninfo.o +no_undefined = -no-undefined +export_symbols = -export-symbols $(srcdir)/libksba.def +ksba_deps = $(ksba_res) libksba.def + +install-def-file: + $(INSTALL) $(srcdir)/libksba.def $(DESTDIR)$(libdir)/libksba.def + +uninstall-def-file: + -rm $(DESTDIR)$(libdir)/libksba.def + +else !HAVE_W32_SYSTEM +ksba_res = +ksba_ldflag = +no_undefined = +export_symbols = +ksba_deps = +install-def-file: +uninstall-def-file: +endif !HAVE_W32_SYSTEM + + +libksba_la_LDFLAGS = $(gcrypt_res_ldflag) $(no_undefined) $(export_symbols) \ + $(libksba_version_script_cmd) -version-info \ @LIBKSBA_LT_CURRENT@:@LIBKSBA_LT_REVISION@:@LIBKSBA_LT_AGE@ libksba_la_INCLUDES = -I$(top_srcdir)/lib -libksba_la_DEPENDENCIES = $(srcdir)/libksba.vers +libksba_la_DEPENDENCIES = $(srcdir)/libksba.vers $(ksba_deps) +libksba_la_LIBADD = @LTLIBOBJS@ @GPG_ERROR_LIBS@ + libksba_la_SOURCES = \ ksba.h \ reader.c reader.h \ @@ -96,3 +129,8 @@ endif +install-data-local: install-def-file + +uninstall-local: uninstall-def-file + + Added: trunk/src/libksba.def =================================================================== --- trunk/src/libksba.def 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/src/libksba.def 2007-05-29 17:36:24 UTC (rev 274) @@ -0,0 +1,180 @@ +;; libksba.def - Exported symbols for W32 +;; Copyright (C) 2007 g10 Code GmbH +;; +;; This file is part of KSBA. +;; +;; KSBA is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2 of the License, or +;; (at your option) any later version. +;; +;; KSBA is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;; USA. + + +EXPORTS + ksba_check_version @1 + + ksba_set_hash_buffer_function @2 + ksba_set_malloc_hooks @3 + ksba_free @4 + ksba_malloc @5 + ksba_calloc @6 + ksba_realloc @7 + ksba_strdup @8 + + ksba_asn_create_tree @9 + ksba_asn_delete_structure @10 + ksba_asn_parse_file @11 + ksba_asn_tree_dump @12 + ksba_asn_tree_release @13 + + ksba_cert_get_auth_key_id @14 + ksba_cert_get_cert_policies @15 + ksba_cert_get_crl_dist_point @16 + ksba_cert_get_digest_algo @17 + ksba_cert_get_ext_key_usages @18 + ksba_cert_get_extension @19 + ksba_cert_get_image @20 + ksba_cert_get_issuer @21 + ksba_cert_get_key_usage @22 + ksba_cert_get_public_key @23 + ksba_cert_get_serial @24 + ksba_cert_get_sig_val @25 + ksba_cert_get_subject @26 + ksba_cert_get_validity @27 + ksba_cert_hash @28 + ksba_cert_init_from_mem @29 + ksba_cert_is_ca @30 + ksba_cert_new @31 + ksba_cert_read_der @32 + ksba_cert_ref @33 + ksba_cert_release @34 + ksba_cert_get_authority_info_access @35 + ksba_cert_get_subject_info_access @36 + ksba_cert_get_subj_key_id @37 + ksba_cert_set_user_data @38 + ksba_cert_get_user_data @39 + + ksba_certreq_add_subject @40 + ksba_certreq_build @41 + ksba_certreq_new @42 + ksba_certreq_release @43 + ksba_certreq_set_hash_function @44 + ksba_certreq_set_public_key @45 + ksba_certreq_set_sig_val @46 + ksba_certreq_set_writer @47 + ksba_certreq_add_extension @48 + + ksba_cms_add_cert @49 + ksba_cms_add_digest_algo @50 + ksba_cms_add_recipient @51 + ksba_cms_add_signer @52 + ksba_cms_build @53 + ksba_cms_get_cert @54 + ksba_cms_get_content_enc_iv @55 + ksba_cms_get_content_oid @56 + ksba_cms_get_content_type @57 + ksba_cms_get_digest_algo @58 + ksba_cms_get_digest_algo_list @59 + ksba_cms_get_enc_val @60 + ksba_cms_get_issuer_serial @61 + ksba_cms_get_message_digest @62 + ksba_cms_get_sig_val @63 + ksba_cms_get_sigattr_oids @64 + ksba_cms_get_signing_time @65 + ksba_cms_hash_signed_attrs @66 + ksba_cms_identify @67 + ksba_cms_new @68 + ksba_cms_parse @69 + ksba_cms_release @70 + ksba_cms_set_content_enc_algo @71 + ksba_cms_set_content_type @72 + ksba_cms_set_enc_val @73 + ksba_cms_set_hash_function @74 + ksba_cms_set_message_digest @75 + ksba_cms_set_reader_writer @76 + ksba_cms_set_sig_val @77 + ksba_cms_set_signing_time @78 + ksba_cms_add_smime_capability @79 + + ksba_crl_get_digest_algo @80 + ksba_crl_get_issuer @81 + ksba_crl_get_item @82 + ksba_crl_get_sig_val @83 + ksba_crl_get_update_times @84 + ksba_crl_new @85 + ksba_crl_parse @86 + ksba_crl_release @87 + ksba_crl_set_hash_function @88 + ksba_crl_set_reader @89 + ksba_crl_get_extension @90 + ksba_crl_get_auth_key_id @91 + ksba_crl_get_crl_number @92 + + ksba_name_enum @93 + ksba_name_get_uri @94 + ksba_name_new @95 + ksba_name_ref @96 + ksba_name_release @97 + + ksba_ocsp_add_cert @98 + ksba_ocsp_add_target @99 + ksba_ocsp_build_request @100 + ksba_ocsp_get_cert @101 + ksba_ocsp_get_digest_algo @102 + ksba_ocsp_get_responder_id @103 + ksba_ocsp_get_sig_val @104 + ksba_ocsp_get_status @105 + ksba_ocsp_hash_request @106 + ksba_ocsp_hash_response @107 + ksba_ocsp_new @108 + ksba_ocsp_parse_response @109 + ksba_ocsp_prepare_request @110 + ksba_ocsp_release @111 + ksba_ocsp_set_digest_algo @112 + ksba_ocsp_set_nonce @113 + ksba_ocsp_set_requestor @114 + ksba_ocsp_set_sig_val @115 + ksba_ocsp_get_extension @116 + + ksba_oid_from_str @117 + ksba_oid_to_str @118 + + ksba_dn_der2str @119 + ksba_dn_str2der @120 + ksba_dn_teststr @121 + + ksba_reader_clear @122 + ksba_reader_error @123 + ksba_reader_new @124 + ksba_reader_read @125 + ksba_reader_release @126 + ksba_reader_set_cb @127 + ksba_reader_set_fd @128 + ksba_reader_set_file @129 + ksba_reader_set_mem @130 + ksba_reader_tell @131 + ksba_reader_unread @132 + + ksba_writer_error @133 + ksba_writer_get_mem @134 + ksba_writer_new @135 + ksba_writer_release @136 + ksba_writer_set_cb @137 + ksba_writer_set_fd @138 + ksba_writer_set_file @139 + ksba_writer_set_filter @140 + ksba_writer_set_mem @141 + ksba_writer_snatch_mem @142 + ksba_writer_tell @143 + ksba_writer_write @144 + ksba_writer_write_octet_string @145 + Added: trunk/src/versioninfo.rc.in =================================================================== --- trunk/src/versioninfo.rc.in 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/src/versioninfo.rc.in 2007-05-29 17:36:24 UTC (rev 274) @@ -0,0 +1,53 @@ +/* versioninfo.rc.in - for libksba + * Copyright (C) 2007 g10 Code GmbH + * + * This file is free software; as a special exception the author gives + * unlimited permission to copy and/or distribute it, with or without + * modifications, as long as this notice is preserved. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* This file is processed by configure to create versioninfo.rc */ + +#line __LINE__ "versioninfo.rc.in" + +#include + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @LIBKSBA_LT_CURRENT@, at LIBKSBA_LT_AGE@, at LIBKSBA_LT_REVISION@, at BUILD_REVISION@ + PRODUCTVERSION @BUILD_FILEVERSION@ + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x21L +#else + FILEFLAGS 0x20L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + /* Note that the Windows version falls under the GPL. */ + VALUE "Comments", "Provided under the terms of the GNU General Public License.\0" + VALUE "CompanyName", "g10 Code GmbH\0" + VALUE "FileDescription", "Libksba - X.509 and CMS Library\0" + VALUE "FileVersion", "@LIBKSBA_LT_CURRENT at .@LIBKSBA_LT_AGE at .@LIBKSBA_LT_REVISION at .@BUILD_REVISION@\0" + VALUE "InternalName", "libksba\0" + VALUE "LegalCopyright", "Copyright ? 2007 g10 Code GmbH\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "libksba.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "libksba\0" + VALUE "ProductVersion", "@VERSION@\0" + VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0" + END + END +END + Added: trunk/ylwrap =================================================================== --- trunk/ylwrap 2007-05-14 08:29:14 UTC (rev 273) +++ trunk/ylwrap 2007-05-29 17:36:24 UTC (rev 274) @@ -0,0 +1,223 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. + +scriptversion=2005-05-14.22 + +# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +case "$1" in + '') + echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 + exit 1 + ;; + --basedir) + basedir=$2 + shift 2 + ;; + -h|--h*) + cat <<\EOF +Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... + +Wrapper for lex/yacc invocations, renaming files as desired. + + INPUT is the input file + OUTPUT is one file PROG generates + DESIRED is the file we actually want instead of OUTPUT + PROGRAM is program to run + ARGS are passed to PROG + +Any number of OUTPUT,DESIRED pairs may be used. + +Report bugs to . +EOF + exit $? + ;; + -v|--v*) + echo "ylwrap $scriptversion" + exit $? + ;; +esac + + +# The input. +input="$1" +shift +case "$input" in + [\\/]* | ?:[\\/]*) + # Absolute path; do nothing. + ;; + *) + # Relative path. Make it absolute. + input="`pwd`/$input" + ;; +esac + +pairlist= +while test "$#" -ne 0; do + if test "$1" = "--"; then + shift + break + fi + pairlist="$pairlist $1" + shift +done + +# The program to run. +prog="$1" +shift +# Make any relative path in $prog absolute. +case "$prog" in + [\\/]* | ?:[\\/]*) ;; + *[\\/]*) prog="`pwd`/$prog" ;; +esac + +# FIXME: add hostname here for parallel makes that run commands on +# other machines. But that might take us over the 14-char limit. +dirname=ylwrap$$ +trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 +mkdir $dirname || exit 1 + +cd $dirname + +case $# in + 0) $prog "$input" ;; + *) $prog "$@" "$input" ;; +esac +ret=$? + +if test $ret -eq 0; then + set X $pairlist + shift + first=yes + # Since DOS filename conventions don't allow two dots, + # the DOS version of Bison writes out y_tab.c instead of y.tab.c + # and y_tab.h instead of y.tab.h. Test to see if this is the case. + y_tab_nodot="no" + if test -f y_tab.c || test -f y_tab.h; then + y_tab_nodot="yes" + fi + + # The directory holding the input. + input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` + # Quote $INPUT_DIR so we can use it in a regexp. + # FIXME: really we should care about more than `.' and `\'. + input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` + + while test "$#" -ne 0; do + from="$1" + # Handle y_tab.c and y_tab.h output by DOS + if test $y_tab_nodot = "yes"; then + if test $from = "y.tab.c"; then + from="y_tab.c" + else + if test $from = "y.tab.h"; then + from="y_tab.h" + fi + fi + fi + if test -f "$from"; then + # If $2 is an absolute path name, then just use that, + # otherwise prepend `../'. + case "$2" in + [\\/]* | ?:[\\/]*) target="$2";; + *) target="../$2";; + esac + + # We do not want to overwrite a header file if it hasn't + # changed. This avoid useless recompilations. However the + # parser itself (the first file) should always be updated, + # because it is the destination of the .y.c rule in the + # Makefile. Divert the output of all other files to a temporary + # file so we can compare them to existing versions. + if test $first = no; then + realtarget="$target" + target="tmp-`echo $target | sed s/.*[\\/]//g`" + fi + # Edit out `#line' or `#' directives. + # + # We don't want the resulting debug information to point at + # an absolute srcdir; it is better for it to just mention the + # .y file with no path. + # + # We want to use the real output file name, not yy.lex.c for + # instance. + # + # We want the include guards to be adjusted too. + FROM=`echo "$from" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + TARGET=`echo "$2" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + + sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ + -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? + + # Check whether header files must be updated. + if test $first = no; then + if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then + echo "$2" is unchanged + rm -f "$target" + else + echo updating "$2" + mv -f "$target" "$realtarget" + fi + fi + else + # A missing file is only an error for the first file. This + # is a blatant hack to let us support using "yacc -d". If -d + # is not specified, we don't want an error when the header + # file is "missing". + if test $first = yes; then + ret=1 + fi + fi + shift + shift + first=no + done +else + ret=$? +fi + +# Remove the directory. +cd .. +rm -rf $dirname + +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: Property changes on: trunk/ylwrap ___________________________________________________________________ Name: svn:executable + * From cvs at cvs.gnupg.org Tue May 29 22:11:47 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 29 May 2007 22:11:47 +0200 Subject: [svn] GnuPG - r4507 - in trunk: . sm Message-ID: Author: wk Date: 2007-05-29 22:11:17 +0200 (Tue, 29 May 2007) New Revision: 4507 Modified: trunk/NEWS trunk/sm/ChangeLog trunk/sm/export.c Log: Print passphrase encoding info only in PEM mode. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-18 23:32:51 UTC (rev 4506) +++ trunk/NEWS 2007-05-29 20:11:17 UTC (rev 4507) @@ -1,7 +1,9 @@ Noteworthy changes in version 2.0.5 ------------------------------------------------ + * Fixed bug when using the --p12-charset without --armor. + Noteworthy changes in version 2.0.4 (2007-05-09) ------------------------------------------------ Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2007-05-18 23:32:51 UTC (rev 4506) +++ trunk/sm/ChangeLog 2007-05-29 20:11:17 UTC (rev 4507) @@ -1,3 +1,8 @@ +2007-05-29 Werner Koch + + * export.c (gpgsm_p12_export): Print passphrase encoding info only + in PEM mode. + 2007-05-18 Marcus Brinkmann * qualified.c (gpgsm_qualified_consent, Modified: trunk/sm/export.c =================================================================== --- trunk/sm/export.c 2007-05-18 23:32:51 UTC (rev 4506) +++ trunk/sm/export.c 2007-05-29 20:11:17 UTC (rev 4507) @@ -416,7 +416,7 @@ putc ('\n', fp); } - if (opt.p12_charset) + if (opt.p12_charset && ctrl->create_pem) { fprintf (fp, "The passphrase is %s encoded.\n\n", opt.p12_charset); From cvs at cvs.gnupg.org Thu May 31 11:48:35 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 31 May 2007 11:48:35 +0200 Subject: [svn] gcry - r1254 - in trunk: . cipher src Message-ID: Author: wk Date: 2007-05-31 11:48:05 +0200 (Thu, 31 May 2007) New Revision: 1254 Modified: trunk/ChangeLog trunk/NEWS trunk/README trunk/TODO trunk/cipher/ChangeLog trunk/cipher/camellia.c trunk/cipher/camellia.h trunk/configure.ac trunk/src/ChangeLog trunk/src/gcrypt.h.in trunk/src/libgcrypt.m4 Log: Camellia is now LGPLed Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/ChangeLog 2007-05-31 09:48:05 UTC (rev 1254) @@ -1,3 +1,11 @@ +2007-05-30 Werner Koch + + * configure.ac: Camellia is no longer GPL. + +2007-05-24 Werner Koch + + * configure.ac: Try to use -Wpointer-arith. + 2007-05-19 Marcus Brinkmann * configure.ac: Fix test for optional UDIV and UDIV_QRNND MPI Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/NEWS 2007-05-31 09:48:05 UTC (rev 1254) @@ -1,3 +1,12 @@ +Noteworthy changes in version 1.3.1 +------------------------------------------------ + + * The Camellia cipher is now under the LGPL and included by default. + + * Interface changes relative to the 1.3.0 release: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Noteworthy changes in version 1.3.0 (2007-05-04) ------------------------------------------------ Modified: trunk/README =================================================================== --- trunk/README 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/README 2007-05-31 09:48:05 UTC (rev 1254) @@ -56,7 +56,6 @@ rndw32 - Entropy gatherer for MS Windows gcryptrnd - The random number daemon. getrandom - A client for that daemon. - camellia - The Camellia cipher. The documentation is available under the terms of the GPL. Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/TODO 2007-05-31 09:48:05 UTC (rev 1254) @@ -1,5 +1,9 @@ What's left to do -*- outline -*- +* Next API break: +** gcry_ac_io_t + Remove use of anonymous union. + * udiv-qrnbd.o should get build as *.lo [HPUX] * Allow operation using RSA keys consisting of the OpenSSL list of @@ -95,14 +99,6 @@ * Add OAEP -* Next API break: -** gcry_ac_io_t - Remove use of anonymous union. - -* ac.c - There are still some things fishy. The fixes I did today - (2006-10-23) seem to cure just a symptom. Needs a complete review. - * gcryptrnd.c Requires a test for pth [done] as well as some other tests. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/cipher/ChangeLog 2007-05-31 09:48:05 UTC (rev 1254) @@ -1,3 +1,8 @@ +2007-05-30 Werner Koch + + * camellia.h, camellia.c: Replace by new LGPL version and adjusted + camellia.h. + 2007-05-09 Marcus Brinkmann * ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read): Modified: trunk/cipher/camellia.c =================================================================== --- trunk/cipher/camellia.c 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/cipher/camellia.c 2007-05-31 09:48:05 UTC (rev 1254) @@ -3,19 +3,19 @@ * Copyright (C) 2006,2007 * NTT (Nippon Telegraph and Telephone Corporation). * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* Modified: trunk/cipher/camellia.h =================================================================== --- trunk/cipher/camellia.h 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/cipher/camellia.h 2007-05-31 09:48:05 UTC (rev 1254) @@ -3,38 +3,47 @@ * Copyright (C) 2006,2007 * NTT (Nippon Telegraph and Telephone Corporation). * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef HEADER_CAMELLIA_H #define HEADER_CAMELLIA_H -/* Need to redefine the external symbols to keep the libgcrypt name - space clean. */ -#define Camellia_Ekeygen _gcry_Camellia_Ekeygen -#define Camellia_EncryptBlock _gcry_Camellia_EncryptBlock -#define Camellia_DecryptBlock _gcry_Camellia_DecryptBlock -#define camellia_decrypt128 _gcry_camellia_decrypt128 -#define camellia_decrypt256 _gcry_camellia_decrypt256 -#define camellia_encrypt128 _gcry_camellia_encrypt128 -#define camellia_encrypt256 _gcry_camellia_encrypt256 -#define camellia_setup128 _gcry_camellia_setup128 -#define camellia_setup192 _gcry_camellia_setup192 -#define camellia_setup256 _gcry_camellia_setup256 +/* To use Camellia with libraries it is often useful to keep the name + * space of the library clean. The following macro is thus useful: + * + * #define CAMELLIA_EXT_SYM_PREFIX foo_ + * + * This prefixes all external symbols with "foo_". + */ +#ifdef CAMELLIA_EXT_SYM_PREFIX +#define CAMELLIA_PREFIX1(x,y) x ## y +#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y) +#define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x) +#define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen) +#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock) +#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock) +#define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128) +#define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256) +#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128) +#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256) +#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128) +#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192) +#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256) +#endif /*CAMELLIA_EXT_SYM_PREFIX*/ - #ifdef __cplusplus extern "C" { #endif Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/configure.ac 2007-05-31 09:48:05 UTC (rev 1254) @@ -5,7 +5,7 @@ # This file is part of Libgcrypt. # # Libgcrypt is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser general Public License as +# it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # @@ -301,8 +301,8 @@ fi # If not specified otherwise, all available algorithms will be -# included. Except for Camellia which is GPLed. -default_ciphers=`echo "$available_ciphers" | sed 's/ camellia//'` +# included. +default_ciphers="$available_ciphers" default_pubkey_ciphers="$available_pubkey_ciphers" default_digests="$available_digests" @@ -736,7 +736,7 @@ test "$more_gcc_warnings" = "yes"; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" if test "$more_gcc_warnings" = "yes"; then - CFLAGS="$CFLAGS -W -Wextra -Wpointer-arith -Wbad-function-cast" + CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast" CFLAGS="$CFLAGS -Wwrite-strings" CFLAGS="$CFLAGS -Wdeclaration-after-statement" CFLAGS="$CFLAGS -Wno-missing-field-initializers" @@ -748,6 +748,16 @@ else CFLAGS="$CFLAGS -Wall" fi + + AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wpointer-arith" + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_wopt" = xyes ; then + CFLAGS="$CFLAGS -Wpointer-arith" + fi fi # Check whether as(1) supports a noeexecstack feature. This test @@ -823,7 +833,7 @@ [Defined if this module should be included]) LIST_MEMBER(camellia, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo" && gpl="$gpl camellia" +test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo" AC_DEFINE_UNQUOTED(USE_CAMELLIA, $found, [Defined if this module should be included]) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/src/ChangeLog 2007-05-31 09:48:05 UTC (rev 1254) @@ -1,3 +1,7 @@ +2007-05-09 Werner Koch + + * libgcrypt.m4: Print found version on success. + 2007-05-09 Marcus Brinkmann * gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/src/gcrypt.h.in 2007-05-31 09:48:05 UTC (rev 1254) @@ -918,7 +918,7 @@ GCRY_PK_ELG_E = 16, /* use only for OpenPGP */ GCRY_PK_DSA = 17, GCRY_PK_ELG = 20, - GCRY_PK_ECDSA = 301 /* Experimental implementaion; not for + GCRY_PK_ECDSA = 301 /* Experimental implementation; not for production. */ }; Modified: trunk/src/libgcrypt.m4 =================================================================== --- trunk/src/libgcrypt.m4 2007-05-19 21:31:51 UTC (rev 1253) +++ trunk/src/libgcrypt.m4 2007-05-31 09:48:05 UTC (rev 1254) @@ -74,7 +74,7 @@ fi fi if test $ok = yes; then - AC_MSG_RESULT(yes) + AC_MSG_RESULT([yes ($libgcrypt_config_version)]) else AC_MSG_RESULT(no) fi @@ -86,7 +86,7 @@ if test "$tmp" -gt 0 ; then AC_MSG_CHECKING([LIBGCRYPT API version]) if test "$req_libgcrypt_api" -eq "$tmp" ; then - AC_MSG_RESULT(okay) + AC_MSG_RESULT([okay]) else ok=no AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp])