[svn] GnuPG - r4226 - in trunk: . common doc g10 tests
tests/openpgp tools
svn author wk
cvs at cvs.gnupg.org
Mon Aug 21 22:20:27 CEST 2006
Author: wk
Date: 2006-08-21 22:20:23 +0200 (Mon, 21 Aug 2006)
New Revision: 4226
Added:
trunk/common/openpgpdefs.h
trunk/doc/DETAILS
trunk/doc/HACKING
trunk/doc/KEYSERVER
trunk/doc/OpenPGP
trunk/doc/TRANSLATE
trunk/doc/faq.raw
trunk/doc/samplekeys.asc
trunk/tests/cms/
trunk/tests/openpgp/
trunk/tests/openpgp/ChangeLog
trunk/tests/openpgp/Makefile.am
trunk/tests/openpgp/armdetach.test
trunk/tests/openpgp/armdetachm.test
trunk/tests/openpgp/armencrypt.test
trunk/tests/openpgp/armencryptp.test
trunk/tests/openpgp/armor.test
trunk/tests/openpgp/armsignencrypt.test
trunk/tests/openpgp/armsigs.test
trunk/tests/openpgp/clearsig.test
trunk/tests/openpgp/conventional-mdc.test
trunk/tests/openpgp/conventional.test
trunk/tests/openpgp/decrypt-dsa.test
trunk/tests/openpgp/decrypt.test
trunk/tests/openpgp/defs.inc
trunk/tests/openpgp/detach.test
trunk/tests/openpgp/detachm.test
trunk/tests/openpgp/encrypt-dsa.test
trunk/tests/openpgp/encrypt.test
trunk/tests/openpgp/encryptp.test
trunk/tests/openpgp/genkey1024.test
trunk/tests/openpgp/gpg.conf.tmpl
trunk/tests/openpgp/mds.test
trunk/tests/openpgp/mkdemodirs
trunk/tests/openpgp/multisig.test
trunk/tests/openpgp/pgp263-test.pub.asc
trunk/tests/openpgp/pgp263-test.sec.asc
trunk/tests/openpgp/plain-1-pgp.asc
trunk/tests/openpgp/plain-1.asc
trunk/tests/openpgp/plain-1o.asc
trunk/tests/openpgp/plain-2.asc
trunk/tests/openpgp/plain-2o.asc
trunk/tests/openpgp/plain-3.asc
trunk/tests/openpgp/plain-3o.asc
trunk/tests/openpgp/pubdemo.asc
trunk/tests/openpgp/pubring.asc
trunk/tests/openpgp/pubring.pkr.asc
trunk/tests/openpgp/seat.test
trunk/tests/openpgp/secdemo.asc
trunk/tests/openpgp/secring.asc
trunk/tests/openpgp/secring.skr.asc
trunk/tests/openpgp/signdemokey
trunk/tests/openpgp/signencrypt-dsa.test
trunk/tests/openpgp/signencrypt.test
trunk/tests/openpgp/sigs-dsa.test
trunk/tests/openpgp/sigs.test
trunk/tests/openpgp/verify.test
trunk/tests/openpgp/version.test
trunk/tools/clean-sat.c
trunk/tools/convert-from-106
trunk/tools/crlf.c
trunk/tools/gpg-zip.in
trunk/tools/gpgsplit.c
trunk/tools/lspgpot
trunk/tools/mail-signed-keys
trunk/tools/make-dns-cert.c
trunk/tools/mk-tdata.c
trunk/tools/pgpgroup-to-gpggroup
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/THANKS
trunk/TODO
trunk/common/ChangeLog
trunk/common/Makefile.am
trunk/configure.ac
trunk/doc/ChangeLog
trunk/doc/Makefile.am
trunk/g10/ChangeLog
trunk/g10/gpg.c
trunk/g10/keydb.h
trunk/g10/keygen.c
trunk/g10/keyserver-internal.h
trunk/g10/mainproc.c
trunk/g10/packet.h
trunk/g10/skclist.c
trunk/tests/ChangeLog
trunk/tests/Makefile.am
trunk/tools/ChangeLog
trunk/tools/Makefile.am
Log:
Migrated more stuff to doc/
Migrated the gpg regression tests.
Some changes tp the gpg code to fix bugs and
for the use in testing.
make distcheck works now with gpg enabled.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1,3 +1,10 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ * configure.ac: Removed docbook tests.
+ (AC_CONFIG_FILES): Added gpgkeys_test and gpgkeys_mailto.
+
+ * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Enable gpg.
+
2006-08-17 Werner Koch <wk at g10code.com>
* THANKS: Merged with the 1.4 one.
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/Makefile.am 2006-08-21 20:20:23 UTC (rev 4226)
@@ -22,6 +22,7 @@
ACLOCAL_AMFLAGS = -I m4 -I gl/m4
AUTOMAKE_OPTIONS = dist-bzip2
+DISTCHECK_CONFIGURE_FLAGS = --enable-gpg
EXTRA_DIST = scripts/config.rpath autogen.sh README.CVS
DISTCLEANFILES = g10defs.h
Modified: trunk/THANKS
===================================================================
--- trunk/THANKS 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/THANKS 2006-08-21 20:20:23 UTC (rev 4226)
@@ -17,6 +17,7 @@
Ariel T Glenn ariel at columbia.edu
Bernhard Herzog bh at intevation.de
Bernhard Reiter bernhard de intevation.de
+Bob Dunlop bob at xyzzy.org.uk
Bob Mathews bobmathews at mindspring.com
Bodo Moeller Bodo_Moeller at public.uni-hamburg.de
Brendan O'Dea bod at debian.org
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/TODO 2006-08-21 20:20:23 UTC (rev 4226)
@@ -115,6 +115,9 @@
Remove the whole stuff?
** qbits
We pass a new qbit parameter to genkey - implement this in libgcrypt.
+** skclist.c
+ As soon as we switch to libgcrypt 1.3 we should remove the hard
+ coded constant in random_is_faked.
* common/
Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/common/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1,3 +1,9 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ * Makefile.am (libcommon_a_SOURCES): Added keyserver.h
+
+ * openpgpdefs.h: New. Stripped from ..g10/packet.h.
+
2006-08-16 Werner Koch <wk at g10code.com>
* keyserver.h: Moved from ../include to here.
Modified: trunk/common/Makefile.am
===================================================================
--- trunk/common/Makefile.am 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/common/Makefile.am 2006-08-21 20:20:23 UTC (rev 4226)
@@ -30,6 +30,8 @@
libcommon_a_SOURCES = \
util.h i18n.h \
errors.h \
+ openpgpdefs.h \
+ keyserver.h \
sexp-parse.h \
sexputil.c \
maperror.c \
@@ -56,7 +58,6 @@
pka.c pka.h \
http.c http.h
-
libsimple_pwquery_a_SOURCES = \
simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h
Added: trunk/common/openpgpdefs.h
===================================================================
--- trunk/common/openpgpdefs.h 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/common/openpgpdefs.h 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,89 @@
+/* openpgpdefs.h - Constants from the OpenPGP standard (rfc2440)
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ * 2006 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.
+ */
+
+#ifndef GNUPG_COMMON_OPENPGPDEFS_H
+#define GNUPG_COMMON_OPENPGPDEFS_H
+
+typedef enum
+ {
+ PKT_NONE = 0,
+ PKT_PUBKEY_ENC = 1, /* Public key encrypted packet. */
+ PKT_SIGNATURE = 2, /* Secret key encrypted packet. */
+ PKT_SYMKEY_ENC = 3, /* Session key packet. */
+ PKT_ONEPASS_SIG = 4, /* One pass sig packet. */
+ PKT_SECRET_KEY = 5, /* Secret key. */
+ PKT_PUBLIC_KEY = 6, /* Public key. */
+ PKT_SECRET_SUBKEY = 7, /* Secret subkey. */
+ PKT_COMPRESSED = 8, /* Compressed data packet. */
+ PKT_ENCRYPTED = 9, /* Conventional encrypted data. */
+ PKT_MARKER = 10, /* Marker packet. */
+ PKT_PLAINTEXT = 11, /* Literal data packet. */
+ PKT_RING_TRUST = 12, /* Keyring trust packet. */
+ PKT_USER_ID = 13, /* User id packet. */
+ PKT_PUBLIC_SUBKEY = 14, /* Public subkey. */
+ PKT_OLD_COMMENT = 16, /* Comment packet from an OpenPGP draft. */
+ PKT_ATTRIBUTE = 17, /* PGP's attribute packet. */
+ PKT_ENCRYPTED_MDC = 18, /* Integrity protected encrypted data. */
+ PKT_MDC = 19, /* Manipulation detection code packet. */
+ PKT_COMMENT = 61, /* new comment packet (GnuPG specific). */
+ PKT_GPG_CONTROL = 63 /* internal control packet (GnuPG specific). */
+ }
+pkttype_t;
+
+
+typedef enum
+ {
+ SIGSUBPKT_TEST_CRITICAL = -3,
+ SIGSUBPKT_LIST_UNHASHED = -2,
+ SIGSUBPKT_LIST_HASHED = -1,
+ SIGSUBPKT_NONE = 0,
+ SIGSUBPKT_SIG_CREATED = 2, /* Signature creation time. */
+ SIGSUBPKT_SIG_EXPIRE = 3, /* Signature expiration time. */
+ SIGSUBPKT_EXPORTABLE = 4, /* Exportable. */
+ SIGSUBPKT_TRUST = 5, /* Trust signature. */
+ SIGSUBPKT_REGEXP = 6, /* Regular expression. */
+ SIGSUBPKT_REVOCABLE = 7, /* Revocable. */
+ SIGSUBPKT_KEY_EXPIRE = 9, /* Key expiration time. */
+ SIGSUBPKT_ARR = 10, /* Additional recipient request. */
+ SIGSUBPKT_PREF_SYM = 11, /* Preferred symmetric algorithms. */
+ SIGSUBPKT_REV_KEY = 12, /* Revocation key. */
+ SIGSUBPKT_ISSUER = 16, /* Issuer key ID. */
+ SIGSUBPKT_NOTATION = 20, /* Notation data. */
+ SIGSUBPKT_PREF_HASH = 21, /* Preferred hash algorithms. */
+ SIGSUBPKT_PREF_COMPR = 22, /* Preferred compression algorithms. */
+ SIGSUBPKT_KS_FLAGS = 23, /* Key server preferences. */
+ SIGSUBPKT_PREF_KS = 24, /* Preferred key server. */
+ SIGSUBPKT_PRIMARY_UID = 25, /* Primary user id. */
+ SIGSUBPKT_POLICY = 26, /* Policy URL. */
+ SIGSUBPKT_KEY_FLAGS = 27, /* Key flags. */
+ SIGSUBPKT_SIGNERS_UID = 28, /* Signer's user id. */
+ SIGSUBPKT_REVOC_REASON = 29, /* Reason for revocation. */
+ SIGSUBPKT_FEATURES = 30, /* Feature flags. */
+
+ SIGSUBPKT_SIGNATURE = 32, /* Embedded signature. */
+
+ SIGSUBPKT_FLAG_CRITICAL = 128
+ }
+sigsubpkttype_t;
+
+
+#endif /*GNUPG_COMMON_OPENPGPDEFS_H*/
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/configure.ac 2006-08-21 20:20:23 UTC (rev 4226)
@@ -442,10 +442,7 @@
AC_ISC_POSIX
gl_EARLY
AC_SYS_LARGEFILE
-AC_CHECK_PROG(DOCBOOK_TO_MAN, docbook-to-man, yes, no)
-AM_CONDITIONAL(HAVE_DOCBOOK_TO_MAN, test "$ac_cv_prog_DOCBOOK_TO_MAN" = yes)
GNUPG_CHECK_FAQPROG
-GNUPG_CHECK_DOCBOOK_TO_TEXI
GNUPG_CHECK_USTAR
@@ -1312,9 +1309,13 @@
agent/Makefile
scd/Makefile
keyserver/Makefile
+keyserver/gpgkeys_mailto
+keyserver/gpgkeys_test
+tools/gpg-zip
tools/Makefile
doc/Makefile
tests/Makefile
+tests/openpgp/Makefile
])
AC_OUTPUT
Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/doc/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1,3 +1,7 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ * Makefile.am: Added other doc files from gpg 1.4.
+
2006-08-17 Werner Koch <wk at g10code.com>
* Makefile.am: Added rules to build man pages.
Copied: trunk/doc/DETAILS (from rev 4225, branches/STABLE-BRANCH-1-4/doc/DETAILS)
Copied: trunk/doc/HACKING (from rev 4225, branches/STABLE-BRANCH-1-4/doc/HACKING)
Copied: trunk/doc/KEYSERVER (from rev 4225, branches/STABLE-BRANCH-1-4/doc/KEYSERVER)
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/doc/Makefile.am 2006-08-21 20:20:23 UTC (rev 4226)
@@ -19,20 +19,22 @@
## Process this file with automake to produce Makefile.in
-EXTRA_DIST = gnupg-badge-openpgp.eps gnupg-badge-openpgp.jpg \
+EXTRA_DIST = DETAILS HACKING TRANSLATE OpenPGP KEYSERVER samplekeys.asc \
+ gnupg-badge-openpgp.eps gnupg-badge-openpgp.jpg \
gnupg-badge-openpgp.pdf \
gnupg-card-architecture.eps gnupg-card-architecture.png \
gnupg-card-architecture.pdf \
- opt-homedir.texi see-also-note.texi
+ faq.raw FAQ faq.html \
+ opt-homedir.texi see-also-note.texi
BUILT_SOURCES = gnupg-card-architecture.eps gnupg-card-architecture.png \
- gnupg-card-architecture.pdf
+ gnupg-card-architecture.pdf FAQ faq.html
noinst_PROGRAMS = yat2m
info_TEXINFOS = gnupg.texi
-dist_pkgdata_DATA = qualified.txt
+dist_pkgdata_DATA = qualified.txt FAQ faq.html
gnupg_TEXINFOS = \
gpg.texi gpgsm.texi gpg-agent.texi scdaemon.texi assuan.texi \
@@ -55,6 +57,9 @@
watchgnupg_SOURCE = gnupg.texi
+
+CLEANFILES = faq.raw.xref
+
DISTCLEANFILES = gnupg.tmp gnupg.ops yat2m-stamp.tmp yat2m-stamp \
$(myman_pages)
@@ -74,6 +79,25 @@
fig2dev -L pdf `test -f '$<' || echo '$(srcdir)/'`$< $@
+FAQ : faq.raw
+if WORKING_FAQPROG
+ $(FAQPROG) -f $< $@ || $(FAQPROG) -f $< $@
+else
+ : Warning: missing faqprog.pl, cannot make $@
+ echo "No $@ due to missing faqprog.pl" > $@
+ echo "See ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl" >> $@
+endif
+
+faq.html : faq.raw
+if WORKING_FAQPROG
+ $(FAQPROG) -h -f $< $@ 2>&1 || $(FAQPROG) -h -f $< $@
+else
+ : Warning: missing faqprog.pl, cannot make $@
+ echo "No $@ due to missing faqprog.pl" > $@
+ echo "See ftp://ftp.gnupg.org/gcrypt/contrib/faqprog.pl" >> $@
+endif
+
+
yat2m-stamp: $(myman_sources)
@rm -f yat2m-stamp.tmp
@touch yat2m-stamp.tmp
Copied: trunk/doc/OpenPGP (from rev 4225, branches/STABLE-BRANCH-1-4/doc/OpenPGP)
Copied: trunk/doc/TRANSLATE (from rev 4225, branches/STABLE-BRANCH-1-4/doc/TRANSLATE)
Copied: trunk/doc/faq.raw (from rev 4225, branches/STABLE-BRANCH-1-4/doc/faq.raw)
Copied: trunk/doc/samplekeys.asc (from rev 4225, branches/STABLE-BRANCH-1-4/doc/samplekeys.asc)
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1,3 +1,17 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ * skclist.c (random_is_faked): Implemented.
+ (is_insecure): Also test for the old uppercase version of the
+ insecure string.
+ * gpg.c (main): Renamed --quick-random to debug-quick-quick-random.
+
+ * gpg.c (print_mds): Do not use the USE_SHA macros.
+
+ * mainproc.c (proc_encrypted): Remove assign inside condition for
+ better readibility.
+
+ * packet.h: Moved consts to new header ../common/openpgpdefs.h.
+
2006-08-16 Werner Koch <wk at g10code.com>
* keyserver.c (GPGKEYS_PREFIX): Rename to gpg2keys_. This is so
Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/gpg.c 2006-08-21 20:20:23 UTC (rev 4226)
@@ -568,7 +568,7 @@
{ oPasswdFile, "passphrase-file",2, "@" },
{ oCommandFD, "command-fd",1, "@" },
{ oCommandFile, "command-file",2, "@" },
- { oQuickRandom, "quick-random", 0, "@"},
+ { oQuickRandom, "debug-quick-random", 0, "@"},
{ oNoVerbose, "no-verbose", 0, "@"},
{ oTrustDBName, "trustdb-name", 2, "@" },
{ oNoSecmemWarn, "no-secmem-warning", 0, "@" },
@@ -2152,8 +2152,9 @@
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
opt.list_sigs=0;
break;
- /* Disabled for now:
- case oQuickRandom: quick_random_gen(1); break;*/
+ case oQuickRandom:
+ gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
+ break;
case oEmitVersion: opt.no_version=0; break;
case oNoEmitVersion: opt.no_version=1; break;
case oCompletesNeeded: opt.completes_needed = pargs.r.ret_int; break;
@@ -2162,17 +2163,17 @@
case oTrustDBName: trustdb_name = pargs.r.ret_str; break;
case oDefaultKey: opt.def_secret_key = pargs.r.ret_str; break;
case oDefRecipient:
- if( *pargs.r.ret_str )
- opt.def_recipient = make_username(pargs.r.ret_str);
- break;
+ if( *pargs.r.ret_str )
+ opt.def_recipient = make_username(pargs.r.ret_str);
+ break;
case oDefRecipientSelf:
- xfree(opt.def_recipient); opt.def_recipient = NULL;
- opt.def_recipient_self = 1;
- break;
+ xfree(opt.def_recipient); opt.def_recipient = NULL;
+ opt.def_recipient_self = 1;
+ break;
case oNoDefRecipient:
- xfree(opt.def_recipient); opt.def_recipient = NULL;
- opt.def_recipient_self = 0;
- break;
+ xfree(opt.def_recipient); opt.def_recipient = NULL;
+ opt.def_recipient_self = 0;
+ break;
case oNoOptions: opt.no_homedir_creation = 1; break; /* no-options */
case oHomedir: break;
case oNoBatch: opt.batch = 0; break;
@@ -4031,14 +4032,14 @@
gcry_md_enable (md, GCRY_MD_MD5);
gcry_md_enable (md, GCRY_MD_SHA1);
gcry_md_enable (md, GCRY_MD_RMD160);
-#ifdef USE_SHA256
- gcry_md_enable (md, DIGEST_ALGO_SHA224);
- gcry_md_enable (md, GCRY_MD_SHA256);
-#endif
-#ifdef USE_SHA512
- gcry_md_enable (md, GCRY_MD_SHA384);
- gcry_md_enable (md, GCRY_MD_SHA512);
-#endif
+ if (!openpgp_md_test_algo (DIGEST_ALGO_SHA224))
+ gcry_md_enable (md, DIGEST_ALGO_SHA224);
+ if (!openpgp_md_test_algo (GCRY_MD_SHA256))
+ gcry_md_enable (md, GCRY_MD_SHA256);
+ if (!openpgp_md_test_algo (GCRY_MD_SHA384))
+ gcry_md_enable (md, GCRY_MD_SHA384);
+ if (!openpgp_md_test_algo (GCRY_MD_SHA512))
+ gcry_md_enable (md, GCRY_MD_SHA512);
}
while( (n=fread( buf, 1, DIM(buf), fp )) )
@@ -4054,15 +4055,14 @@
print_hashline( md, GCRY_MD_MD5, fname );
print_hashline( md, GCRY_MD_SHA1, fname );
print_hashline( md, GCRY_MD_RMD160, fname );
-#ifdef USE_SHA256
- if (!gcry_md_test_algo (DIGEST_ALGO_SHA224)
+ if (!gcry_md_test_algo (DIGEST_ALGO_SHA224))
print_hashline (md, DIGEST_ALGO_SHA224, fname);
- print_hashline( md, GCRY_MD_SHA256, fname );
-#endif
-#ifdef USE_SHA512
- print_hashline( md, GCRY_MD_SHA384, fname );
- print_hashline( md, GCRY_MD_SHA512, fname );
-#endif
+ if (!gcry_md_test_algo (GCRY_MD_SHA256))
+ print_hashline( md, GCRY_MD_SHA256, fname );
+ if (!gcry_md_test_algo (GCRY_MD_SHA384))
+ print_hashline ( md, GCRY_MD_SHA384, fname );
+ if (!gcry_md_test_algo (GCRY_MD_SHA512))
+ print_hashline ( md, GCRY_MD_SHA512, fname );
}
}
else {
@@ -4072,15 +4072,14 @@
print_hex( md, GCRY_MD_MD5, fname );
print_hex( md, GCRY_MD_SHA1, fname );
print_hex( md, GCRY_MD_RMD160, fname );
-#ifdef USE_SHA256
- if (!gcry_md_test_algo (DIGEST_ALGO_SHA224)
+ if (!gcry_md_test_algo (DIGEST_ALGO_SHA224))
print_hex (md, DIGEST_ALGO_SHA224, fname);
- print_hex( md, GCRY_MD_SHA256, fname );
-#endif
-#ifdef USE_SHA512
- print_hex( md, GCRY_MD_SHA384, fname );
- print_hex( md, GCRY_MD_SHA512, fname );
-#endif
+ if (!gcry_md_test_algo (GCRY_MD_SHA256))
+ print_hex( md, GCRY_MD_SHA256, fname );
+ if (!gcry_md_test_algo (GCRY_MD_SHA384))
+ print_hex( md, GCRY_MD_SHA384, fname );
+ if (!gcry_md_test_algo (GCRY_MD_SHA512))
+ print_hex( md, GCRY_MD_SHA512, fname );
}
}
}
Modified: trunk/g10/keydb.h
===================================================================
--- trunk/g10/keydb.h 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/keydb.h 2006-08-21 20:20:23 UTC (rev 4226)
@@ -190,6 +190,7 @@
int select_mdc_from_pklist (PK_LIST pk_list);
/*-- skclist.c --*/
+int random_is_faked (void);
void release_sk_list( SK_LIST sk_list );
int build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
int unlock, unsigned use );
Modified: trunk/g10/keygen.c
===================================================================
--- trunk/g10/keygen.c 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/keygen.c 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1949,11 +1949,9 @@
if( *amail )
p = stpcpy(stpcpy(stpcpy(p," <"), amail),">");
- /* append a warning if we do not have dev/random
- * or it is switched into quick testmode */
- /* FIXME: see skclist.c:random_is_faked */
- /* if( quick_random_gen(-1) ) */
- /* strcpy(p, " (INSECURE!)" ); */
+ /* Append a warning if the RNG is switched into fake mode. */
+ if ( random_is_faked () )
+ strcpy(p, " (insecure!)" );
/* print a note in case that UTF8 mapping has to be done */
for(p=uid; *p; p++ ) {
Modified: trunk/g10/keyserver-internal.h
===================================================================
--- trunk/g10/keyserver-internal.h 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/keyserver-internal.h 2006-08-21 20:20:23 UTC (rev 4226)
@@ -23,7 +23,7 @@
#define _KEYSERVER_INTERNAL_H_
#include <time.h>
-#include "keyserver.h"
+#include "../common/keyserver.h"
#include "../common/iobuf.h"
#include "types.h"
Modified: trunk/g10/mainproc.c
===================================================================
--- trunk/g10/mainproc.c 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/mainproc.c 2006-08-21 20:20:23 UTC (rev 4226)
@@ -508,8 +508,9 @@
}
else
{
- /* assume this is old style conventional encrypted data */
- if ( (algo = opt.def_cipher_algo))
+ /* Assume this is old style conventional encrypted data. */
+ algo = opt.def_cipher_algo;
+ if ( algo )
log_info (_("assuming %s encrypted data\n"),
gcry_cipher_algo_name (algo));
else if ( gcry_cipher_test_algo (CIPHER_ALGO_IDEA) )
@@ -680,6 +681,8 @@
}
rc = handle_plaintext( pt, &c->mfx, c->sigs_only, clearsig );
+ if (rc)
+ log_debug ("handle_plaintext failed: err=%d\n", rc);
if( gpg_err_code (rc) == GPG_ERR_ENOENT && !c->sigs_only)
{
#warning We need to change the test for the error code
Modified: trunk/g10/packet.h
===================================================================
--- trunk/g10/packet.h 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/packet.h 2006-08-21 20:20:23 UTC (rev 4226)
@@ -28,32 +28,10 @@
#include "../jnlib/strlist.h"
#include "cipher.h"
#include "filter.h"
+#include "../common/openpgpdefs.h"
#define DEBUG_PARSE_PACKET 1
-typedef enum {
- PKT_NONE =0,
- PKT_PUBKEY_ENC =1, /* public key encrypted packet */
- PKT_SIGNATURE =2, /* secret key encrypted packet */
- PKT_SYMKEY_ENC =3, /* session key packet (OpenPGP)*/
- PKT_ONEPASS_SIG =4, /* one pass sig packet (OpenPGP)*/
- PKT_SECRET_KEY =5, /* secret key */
- PKT_PUBLIC_KEY =6, /* public key */
- PKT_SECRET_SUBKEY =7, /* secret subkey (OpenPGP) */
- PKT_COMPRESSED =8, /* compressed data packet */
- PKT_ENCRYPTED =9, /* conventional encrypted data */
- PKT_MARKER =10, /* marker packet (OpenPGP) */
- PKT_PLAINTEXT =11, /* plaintext data with filename and mode */
- PKT_RING_TRUST =12, /* keyring trust packet */
- PKT_USER_ID =13, /* user id packet */
- PKT_PUBLIC_SUBKEY =14, /* public subkey (OpenPGP) */
- PKT_OLD_COMMENT =16, /* comment packet from an OpenPGP draft */
- PKT_ATTRIBUTE =17, /* PGP's attribute packet */
- PKT_ENCRYPTED_MDC =18, /* integrity protected encrypted data */
- PKT_MDC =19, /* manipulation detection code packet */
- PKT_COMMENT =61, /* new comment packet (private) */
- PKT_GPG_CONTROL =63 /* internal control packet */
-} pkttype_t;
typedef struct packet_struct PACKET;
@@ -373,39 +351,7 @@
(a)->pkt.generic = NULL; \
} while(0)
-typedef enum {
- SIGSUBPKT_TEST_CRITICAL=-3,
- SIGSUBPKT_LIST_UNHASHED=-2,
- SIGSUBPKT_LIST_HASHED =-1,
- SIGSUBPKT_NONE = 0,
- SIGSUBPKT_SIG_CREATED = 2, /* signature creation time */
- SIGSUBPKT_SIG_EXPIRE = 3, /* signature expiration time */
- SIGSUBPKT_EXPORTABLE = 4, /* exportable */
- SIGSUBPKT_TRUST = 5, /* trust signature */
- SIGSUBPKT_REGEXP = 6, /* regular expression */
- SIGSUBPKT_REVOCABLE = 7, /* revocable */
- SIGSUBPKT_KEY_EXPIRE = 9, /* key expiration time */
- SIGSUBPKT_ARR =10, /* additional recipient request */
- SIGSUBPKT_PREF_SYM =11, /* preferred symmetric algorithms */
- SIGSUBPKT_REV_KEY =12, /* revocation key */
- SIGSUBPKT_ISSUER =16, /* issuer key ID */
- SIGSUBPKT_NOTATION =20, /* notation data */
- SIGSUBPKT_PREF_HASH =21, /* preferred hash algorithms */
- SIGSUBPKT_PREF_COMPR =22, /* preferred compression algorithms */
- SIGSUBPKT_KS_FLAGS =23, /* key server preferences */
- SIGSUBPKT_PREF_KS =24, /* preferred key server */
- SIGSUBPKT_PRIMARY_UID =25, /* primary user id */
- SIGSUBPKT_POLICY =26, /* policy URL */
- SIGSUBPKT_KEY_FLAGS =27, /* key flags */
- SIGSUBPKT_SIGNERS_UID =28, /* signer's user id */
- SIGSUBPKT_REVOC_REASON =29, /* reason for revocation */
- SIGSUBPKT_FEATURES =30, /* feature flags */
- SIGSUBPKT_SIGNATURE =32, /* embedded signature */
-
- SIGSUBPKT_FLAG_CRITICAL=128
-} sigsubpkttype_t;
-
struct notation
{
char *name;
Modified: trunk/g10/skclist.c
===================================================================
--- trunk/g10/skclist.c 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/g10/skclist.c 2006-08-21 20:20:23 UTC (rev 4226)
@@ -35,16 +35,26 @@
#include "i18n.h"
#include "cipher.h"
+#ifndef GCRYCTL_FAKED_RANDOM_P
+#define GCRYCTL_FAKED_RANDOM_P 51
+#endif
-/* There is currently no way to get the status of the quick random
- generator flag from libgcrypt and it is not clear whether this
- faked RNG is really a good idea. Thus for now we use this stub
- function but we should consider to entirely remove this fake RNG
- stuff. */
-static int
+/* Return true if Libgcrypt's RNG is in faked mode. */
+int
random_is_faked (void)
{
- return 0;
+ /* We use a runtime check to allow for slow migrattion of libgcrypt.
+ We can't use the constant becuase that one is actually an enum
+ value. */
+ gpg_error_t err = gcry_control ( 51 /*GCRYCTL_FAKED_RANDOM_P*/, 0);
+
+ if (!err)
+ return 0;
+ if (gpg_err_code (err) != GPG_ERR_INV_OP)
+ return 1;
+ log_info ("WARNING: libgcrypt too old.\n");
+ log_info (" can't check whether we are in faked RNG mode\n");
+ return 0; /* Need to return false. */
}
@@ -82,7 +92,8 @@
continue; /* skip attribute packets */
if ( strstr( id->name, "(insecure!)" )
|| strstr( id->name, "not secure" )
- || strstr( id->name, "do not use" ) ) {
+ || strstr( id->name, "do not use" )
+ || strstr( id->name, "(INSECURE!)" ) ) {
insecure = 1;
break;
}
Modified: trunk/tests/ChangeLog
===================================================================
--- trunk/tests/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1,3 +1,8 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ * Makefile.am (SUBDIRS): New.
+ * openpgp/: New.
+
2006-06-08 Marcus Brinkmann <marcus at g10code.de>
* asschk.c (__func__) [__STDC_VERSION__ < 199901L && __GNUC__ >= 2]:
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/Makefile.am 2006-08-21 20:20:23 UTC (rev 4226)
@@ -29,6 +29,7 @@
#
#SUBDIRS = . ${pkits}
+SUBDIRS = openpgp
GPGSM = ../sm/gpgsm
Copied: trunk/tests/openpgp/ChangeLog (from rev 4225, branches/STABLE-BRANCH-1-4/checks/ChangeLog)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,276 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ Copied tests from 1.4 and adjusted paths.
+
+2006-04-19 David Shaw <dshaw at jabberwocky.com>
+
+ * sigs.test, mds.test: Add tests for SHA-224, SHA-384, and
+ SHA-512.
+
+2006-04-11 Werner Koch <wk at g10code.com>
+
+ * armor.test: New.
+
+2006-03-09 Werner Koch <wk at g10code.com>
+
+ * defs.inc: Removed Basishm by proper redirection.
+
+2006-03-06 Werner Koch <wk at g10code.com>
+
+ * defs.inc: Print error messages also to stderr. Allow for
+ verbose environment variable.
+ (linefeed): New.
+ (suspend_error, resume_error): New.
+ * verify.test: More tests.
+ * multisig.test: Better error printing.
+ (sig_1ls1ls_valid, sig_ls_valid): Moved to the non-valid group.
+
+2006-02-14 Werner Koch <wk at gnupg.org>
+
+ * verify.test: New.
+
+2005-06-21 Werner Koch <wk at g10code.com>
+
+ * conventional.test (algos): Uhh ohh, cut+paste error and not
+ tested.
+
+2005-06-02 Werner Koch <wk at g10code.com>
+
+ * conventional.test: have_cipher_algo now requires uppercase
+ algorithm names. Changed. Noted by John R. Shannon.
+
+2004-02-09 David Shaw <dshaw at jabberwocky.com>
+
+ * clearsig.test, sigs.test: Properly detect RSA being missing, and
+ use the proper key for doing an RSA test.
+
+2003-12-31 David Shaw <dshaw at jabberwocky.com>
+
+ * clearsig.test, conventional-mdc.test, conventional.test,
+ defs.inc, encrypt-dsa.test, encrypt.test, genkey1024.test,
+ plain-1.asc, plain-1-pgp.asc, plain-2.asc, plain-3.asc,
+ pubring.asc, secring.asc, sigs.test: Rework tests to work properly
+ with a gpg binary that doesn't have all ciphers and all pk algos.
+ Basically, we test for the ciphers we have, only test signing with
+ non-160-bit hashes with RSA (we test all hashes as hashes). Test
+ all key lengths of AES.
+
+2003-12-05 David Shaw <dshaw at jabberwocky.com>
+
+ * Makefile.am: Reenable tests now that the Elgamal signature keys
+ are gone.
+
+ * defs.inc, pubring.asc, secring.asc, plain-1.asc, plain-2.asc,
+ plain-3.asc: Remove the old v3 Elgamal keys and replace with
+ RSA+Elgamal and RSA s+e.
+
+2003-12-03 David Shaw <dshaw at jabberwocky.com>
+
+ * options: Remove emulate-md-encode-bug.
+
+2003-11-27 Werner Koch <wk at gnupg.org>
+
+ * Makefile.am (TESTS): Temporary remove tests using ElG signatures.
+
+2003-09-04 David Shaw <dshaw at jabberwocky.com>
+
+ * mds.test, sigs.test: Remove TIGER/192 and make SHA-256 optional
+ (since it might not be compiled in).
+
+2003-07-10 David Shaw <dshaw at jabberwocky.com>
+
+ * Makefile.am: Add --no-permission-warning to avoid spurious
+ warning when importing demo keys.
+
+2003-05-27 Werner Koch <wk at gnupg.org>
+
+ * Makefile.am (CLEANFILES): Add gpg.conf
+
+2003-05-26 David Shaw <dshaw at jabberwocky.com>
+
+ * defs.inc (pgmname): Make sure there is a valid options
+ file. (From wk on stable branch)
+
+ * mds.test: Note that missing algorithms are not errors.
+
+2003-04-23 David Shaw <dshaw at jabberwocky.com>
+
+ * Makefile.am, options.in: Rename options.in to options since it
+ no longer needs to be a generated file.
+
+ * sigs.test: TODO note to add the new SHAs when we start
+ generating them.
+
+ * mds.test: Test the new SHAs.
+
+2002-05-10 Werner Koch <wk at gnupg.org>
+
+ * Makefile.am: Add gpg_dearmor to all targets where it is used.
+ Noted by Andreas Haumer.
+
+2002-04-19 Werner Koch <wk at gnupg.org>
+
+ * signencrypt-dsa.test, sigs-dsa.test: Don't check with MD5 as
+ this is not valid with DSA signatures.
+
+2001-12-22 Werner Koch <wk at gnupg.org>
+
+ * options.in: Add no-permission-warning.
+
+2001-12-21 Werner Koch <wk at gnupg.org>
+
+ * Makefile.am (distclean-local): prefix mkdemodirs with srcdir
+ (DISTCLEANFILES): Add random_seed.
+
+2001-12-19 Werner Koch <wk at gnupg.org>
+
+ * options.in: Remove load-extension tiger
+ * Makefile.am (./options): append it if there is such a module.
+
+2001-10-23 Werner Koch <wk at gnupg.org>
+
+ * defs.inc, Makefile.am: Do not use $srcdir when invoking gpg.
+ Write the logfile to the current directory.
+
+2001-09-28 Werner Koch <wk at gnupg.org>
+
+ * defs.inc: Write a log file for each test.
+ * run-gpg, run-gpgm, run-gpg.patterns: Removed. Replaced in all
+ tests by a simple macro from defs.inc.
+ * Makefile.am (CLEANFILES): Remove log files.
+ (./gpg_dearmor): create it and use it instead of the macro.
+ This is needed in multisig.test due to IFS tricks.
+
+ * armsignencrypt.test, signencrypt-dsa.test, signencrypt.test,
+ armencryptp.test, armencrypt.test, encryptp.test, seat.test,
+ encrypt-dsa.test, encrypt.test: Use --always-trust because the
+ test are not designed to check the validity.
+
+2001-09-06 Werner Koch <wk at gnupg.org>
+
+ * genkey1024.test: Simplified by using a parameter file.
+
+2001-05-30 Werner Koch <wk at gnupg.org>
+
+ * multisig.test (IFS): Reset IFS just before the test.
+
+2001-04-30 Werner Koch <wk at gnupg.org>
+
+ * multisig.test: Add an set +x to avoid ksh problems
+
+2001-04-28 Werner Koch <wk at gnupg.org>
+
+ * run-gpg.patterns: a v3 test key expired yesterday, suppress the
+ messages.
+
+2001-03-27 Werner Koch <wk at gnupg.org>
+
+ * defs.inc: Removed creation of options file.
+ * options.in: New.
+ * Makefile.am: Create options file and fixed import of pubdemo.asc.
+
+ * run-gpg.patterns (gpg): Add some more patterns.
+
+2001-03-20 Werner Koch <wk at gnupg.org>
+
+ * Makefile.am: Import the pubdemo.asc file
+
+ * sigs.test (hash_algo_list): s/tiger/tiger192/
+
+2001-03-19 Werner Koch <wk at gnupg.org>
+
+ * mkdemodirs (GPGDEMO): Add --allow-secret-key-import to all gpg
+ invocations. Use echon -n instead of an argument with \c.
+
+2001-02-12 Werner Koch <wk at gnupg.org>
+
+ * multisig.test: new
+ * Makefile.am (TESTS): Added.
+
+2000-10-18 Werner Koch <wk at gnupg.org>
+
+ * conventional-mdc.test: Add Rijndael and fix for empty plain texts.
+
+Thu Feb 10 17:39:44 CET 2000 Werner Koch <wk at gnupg.de>
+
+ * mkdemodirs: Fixed the --clean loop.
+
+Thu Jan 13 19:31:58 CET 2000 Werner Koch <wk at gnupg.de>
+
+ * defs.inc (chdir): Removed becuase it is unsused an plain old sh
+ does not like this name. Reported by Alec Habig.
+
+Tue Oct 26 20:02:23 1999 Werner Koch (wk at gnupg.org)
+
+ * Makefile.am (GPG_DEARMOR): New and use --no-options.
+
+Tue Aug 31 17:20:44 CEST 1999 Werner Koch <wk at isil.d.shuttle.de>
+
+ * defs.inc: set LC_ALL empty
+
+Wed Aug 4 10:34:18 CEST 1999 Werner Koch <wk at isil.d.shuttle.de>
+
+ * defs.inc (echo_n): New and used instead of /bin/echo "\c"
+
+Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk at isil.d.shuttle.de>
+
+ * mkdemodirs: New
+ * signdemokey: New.
+ * Makefile.am (distclean-local): New.
+
+Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk at isil.d.shuttle.de>
+
+ * mds.test: replaced the "echo -n"
+
+Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk at isil.d.shuttle.de>
+
+ * pubdemo.asc, secdemo.asc: New.
+
+Fri Feb 19 15:49:15 CET 1999 Werner Koch <wk at isil.d.shuttle.de>
+
+ * genkey1024.test: Be really quiet.
+
+1999-01-01 Geoff Keating <geoffk at ozemail.com.au>
+
+ * Makefile.am (CLEANFILES): Also delete trustdb and any leftover
+ lockfiles.
+
+Fri Nov 27 15:30:24 CET 1998 Werner Koch <wk at isil.d.shuttle.de>
+
+ * clearsig.test: Some more test cases.
+
+Sun Oct 25 18:19:35 1998 Werner Koch (wk at isil.d.shuttle.de)
+
+ * mds.test: Check whether TIGER is available.
+ * sigs.tesr: Ditto.
+
+Wed Sep 23 12:25:07 1998 Werner Koch (wk at isil.d.shuttle.de)
+
+ * run-gpg.patterns: New (because Solaris fgrep does not like -f -).
+
+Mon Aug 10 21:33:38 1998 Werner Koch (wk@(none))
+
+ * genkey1024.test: Ariel fixed this.
+
+Wed Jul 8 10:43:47 1998 Werner Koch (wk at isil.d.shuttle.de)
+
+ * seat.test: New.
+
+Mon May 18 15:40:02 1998 Werner Koch (wk at isil.d.shuttle.de)
+
+ * Makefile.am: Now uses mk-tdata to produce random test data.
+
+ * ChangeLog: New.
+
+
+ Copyright 1998, 1999, 2000, 2001 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
+ modifications, as long as this notice is preserved.
+
+ This file 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.
+
+
Copied: trunk/tests/openpgp/Makefile.am (from rev 4225, branches/STABLE-BRANCH-1-4/checks/Makefile.am)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/Makefile.am 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/Makefile.am 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,107 @@
+# Copyright (C) 1998, 1999, 2000, 2001, 2003 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
+
+# Process this file with automake to create Makefile.in
+
+GPG_IMPORT = ../../g10/gpg2 --homedir . \
+ --quiet --yes --no-permission-warning --import
+
+TESTS = version.test mds.test \
+ decrypt.test decrypt-dsa.test \
+ sigs.test sigs-dsa.test \
+ encrypt.test encrypt-dsa.test \
+ seat.test clearsig.test encryptp.test detach.test \
+ armsigs.test armencrypt.test armencryptp.test \
+ signencrypt.test signencrypt-dsa.test \
+ armsignencrypt.test armdetach.test \
+ armdetachm.test detachm.test genkey1024.test \
+ conventional.test conventional-mdc.test \
+ multisig.test verify.test armor.test
+
+
+TEST_FILES = pubring.asc secring.asc plain-1o.asc plain-2o.asc plain-3o.asc \
+ plain-1.asc plain-2.asc plain-3.asc plain-1-pgp.asc \
+ pubring.pkr.asc secring.skr.asc secdemo.asc pubdemo.asc \
+ gpg.conf.tmpl
+
+DATA_FILES = data-500 data-9000 data-32000 data-80000 plain-large
+
+EXTRA_DIST = defs.inc $(TESTS) $(TEST_FILES) \
+ mkdemodirs signdemokey
+CLEANFILES = prepared.stamp x y yy z out err $(DATA_FILES) \
+ plain-1 plain-2 plain-3 trustdb.gpg *.lock .\#lk* \
+ *.test.log gpg_dearmor gpg.conf \
+ pubring.gpg secring.gpg pubring.pkr secring.skr
+DISTCLEANFILES = pubring.gpg~ random_seed
+
+
+all-local: prepared.stamp
+
+distclean-local:
+ $(srcdir)/mkdemodirs --clean
+
+prepared.stamp: ./pubring.gpg ./secring.gpg ./plain-1 ./plain-2 ./plain-3 \
+ ./pubring.pkr ./secring.skr ./gpg_dearmor $(DATA_FILES)
+ $(GPG_IMPORT) $(srcdir)/pubdemo.asc
+ echo timestamp >./prepared.stamp
+
+./gpg_dearmor:
+ echo '#!/bin/sh' >./gpg_dearmor
+ echo "../../g10/gpg2 --no-options --no-greeting \
+ --no-secmem-warning --batch --dearmor" >>./gpg_dearmor
+ chmod 755 ./gpg_dearmor
+
+./pubring.gpg: $(srcdir)/pubring.asc $(srcdir)/pubdemo.asc ./gpg_dearmor
+ ./gpg_dearmor > ./pubring.gpg < $(srcdir)/pubring.asc
+
+./secring.gpg: $(srcdir)/secring.asc ./gpg_dearmor
+ ./gpg_dearmor > ./secring.gpg < $(srcdir)/secring.asc
+
+./pubring.pkr: $(srcdir)/pubring.pkr.asc ./gpg_dearmor
+ ./gpg_dearmor > ./pubring.pkr < $(srcdir)/pubring.pkr.asc
+
+./secring.skr: $(srcdir)/secring.skr.asc ./gpg_dearmor
+ ./gpg_dearmor > ./secring.skr < $(srcdir)/secring.skr.asc
+
+./plain-1: $(srcdir)/plain-1o.asc ./gpg_dearmor
+ ./gpg_dearmor > ./plain-1 < $(srcdir)/plain-1o.asc
+
+./plain-2: $(srcdir)/plain-2o.asc ./gpg_dearmor
+ ./gpg_dearmor > ./plain-2 < $(srcdir)/plain-2o.asc
+
+./plain-3: $(srcdir)/plain-3o.asc ./gpg_dearmor
+ ./gpg_dearmor > ./plain-3 < $(srcdir)/plain-3o.asc
+
+
+data-500:
+ ../../tools/mk-tdata 500 >data-500
+data-9000:
+ ../../tools/mk-tdata 9000 >data-9000
+data-32000:
+ ../../tools/mk-tdata 32000 >data-32000
+data-80000:
+ ../../tools/mk-tdata 80000 >data-80000
+plain-large:
+ cat $(srcdir)/../../doc/HACKING \
+ $(srcdir)/../../doc/DETAILS \
+ $(srcdir)/../../doc/FAQ >plain-large
+
+# To speed up key generation we create a dummy random seed file
+random_seed:
+ ../../tools/mk-tdata 600
+
Copied: trunk/tests/openpgp/armdetach.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armdetach.test)
Copied: trunk/tests/openpgp/armdetachm.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armdetachm.test)
Copied: trunk/tests/openpgp/armencrypt.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armencrypt.test)
Copied: trunk/tests/openpgp/armencryptp.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armencryptp.test)
Copied: trunk/tests/openpgp/armor.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armor.test)
Copied: trunk/tests/openpgp/armsignencrypt.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armsignencrypt.test)
Copied: trunk/tests/openpgp/armsigs.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/armsigs.test)
Copied: trunk/tests/openpgp/clearsig.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/clearsig.test)
Copied: trunk/tests/openpgp/conventional-mdc.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/conventional-mdc.test)
Copied: trunk/tests/openpgp/conventional.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/conventional.test)
Copied: trunk/tests/openpgp/decrypt-dsa.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/decrypt-dsa.test)
Copied: trunk/tests/openpgp/decrypt.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/decrypt.test)
Copied: trunk/tests/openpgp/defs.inc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/defs.inc)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/defs.inc 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/defs.inc 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,160 @@
+# definitions for the check scripts
+
+#--------------------------------
+#------ constants ---------------
+#--------------------------------
+
+# Note that usrpass1 is also used in Makefile.am
+usrname1="one"
+usrpass1="def"
+usrname2="two"
+usrpass2=""
+usrname3="three"
+usrpass3=""
+
+
+dsa_usrname1="pgp5"
+# we use the sub key because we do not yet have the logic to
+# to derive the first encryption key from a keyblock (I guess)
+dsa_usrname2="0xCB879DE9"
+
+dsa_keyrings="--keyring ./pubring.pkr --secret-keyring ./secring.skr"
+
+
+plain_files="plain-1 plain-2 plain-3"
+data_files="data-500 data-9000 data-32000 data-80000"
+exp_files=""
+
+# The testscripts expect the original language
+LANG=
+LANGUAGE=
+LC_ALL=
+LC_MESSAGES=
+
+# Internal use.
+defs_stop_on_error=no
+defs_error_seen=no
+
+#--------------------------------
+#------ utility functions -------
+#--------------------------------
+
+fatal () {
+ echo "$pgmname: fatal:" $* >&2
+ echo "$pgmname: fatal:" $* >&5
+ exit 1;
+}
+
+error () {
+ echo "$pgmname:" $* >&2
+ defs_error_seen=yes
+ echo "$pgmname:" $* >&5
+ if [ x$defs_stop_on_error != xyes ]; then
+ exit 1
+ fi
+}
+
+# Call this at the start of a test and resume_error at the end to keep
+# on running all subtests without immediately exiting on error.
+suspend_error () {
+ defs_stop_on_error=yes
+}
+
+resume_error () {
+ if [ x$defs_error_seen = xyes ]; then
+ exit 1
+ fi
+ defs_stop_on_error=no
+ defs_error_seen=no
+}
+
+info () {
+ echo "$pgmname:" $* >&2
+ if [ -n "${verbose+set}" ]; then
+ echo "$pgmname:" $* >&5
+ fi
+}
+
+linefeed () {
+ echo >&2
+}
+
+
+echo_n_init=no
+echo_n () {
+ if test "$echo_n_init" = "no"; then
+ if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ echo_n_n=
+ echo_n_c='
+'
+ else
+ echo_n_n='-n'
+ echo_n_c=
+ fi
+ else
+ echo_n_n=
+ echo_n_c='\c'
+ fi
+ echo_n_init=yes
+ fi
+ echo $echo_n_n "${1}$echo_n_c"
+}
+
+
+#cleanup () {
+# rm $cleanup_files 2>/dev/null || true
+# echo "#empty" >./gpg.conf
+#}
+
+
+#add_cleanup () {
+# cleanup_files="$cleanup_files $*"
+#}
+
+have_pubkey_algo () {
+ if ../../g10/gpg2 --homedir . --version | grep "Pubkey:.*$1" >/dev/null
+ then
+ true
+ else
+ false
+ fi
+}
+
+have_cipher_algo () {
+ if ../../g10/gpg2 --homedir . --version | grep "Cipher:.*$1" >/dev/null
+ then
+ true
+ else
+ false
+ fi
+}
+
+have_hash_algo () {
+ if ../../g10/gpg2 --homedir . --version | grep "Hash:.*$1" >/dev/null
+ then
+ true
+ else
+ false
+ fi
+}
+
+set -e
+pgmname=`basename $0`
+#trap cleanup SIGHUP SIGINT SIGQUIT
+
+[ -z "$srcdir" ] && fatal "not called from make"
+
+# Make sure we have a valid option files even with VPATH builds.
+if [ -f ./gpg.conf ]; then
+ :
+elif [ -f $srcdir/gpg.conf.tmpl ]; then
+ cat $srcdir/gpg.conf.tmpl >gpg.conf
+fi
+
+GPG="../../g10/gpg2 --no-permission-warning --homedir . "
+
+exec 5>&2 2>${pgmname}.log
+
+:
+# end
Copied: trunk/tests/openpgp/detach.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/detach.test)
Copied: trunk/tests/openpgp/detachm.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/detachm.test)
Copied: trunk/tests/openpgp/encrypt-dsa.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/encrypt-dsa.test)
Copied: trunk/tests/openpgp/encrypt.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/encrypt.test)
Copied: trunk/tests/openpgp/encryptp.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/encryptp.test)
Copied: trunk/tests/openpgp/genkey1024.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/genkey1024.test)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/genkey1024.test 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/genkey1024.test 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+. $srcdir/defs.inc || exit 3
+
+../../g10/gpg2 --quiet --batch --debug-quick-random --homedir . --gen-key <<EOF
+Key-Type: DSA
+Key-Length: 1024
+Subkey-Type: ELG
+Subkey-Length: 1024
+Name-Real: Harry H.
+Name-Comment: test key
+Name-Email: hh@@ddorf.de
+Expire-Date: 1
+Passphrase: abc
+%commit
+EOF
+
+if have_pubkey_algo "RSA"; then
+../../g10/gpg2 --quiet --batch --debug-quick-random --homedir . --gen-key <<EOF
+Key-Type: RSA
+Key-Length: 1024
+Key-Usage: sign,encrypt
+Name-Real: Harry A.
+Name-Comment: RSA test key
+Name-Email: hh@@ddorf.de
+Expire-Date: 2
+Passphrase: abc
+%commit
+EOF
+fi
+
Copied: trunk/tests/openpgp/gpg.conf.tmpl (from rev 4225, branches/STABLE-BRANCH-1-4/checks/options)
Copied: trunk/tests/openpgp/mds.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/mds.test)
Copied: trunk/tests/openpgp/mkdemodirs (from rev 4225, branches/STABLE-BRANCH-1-4/checks/mkdemodirs)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/mkdemodirs 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/mkdemodirs 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+
+GPG="../g10/gpg2 --batch --quiet --no-secmem-warning --allow-secret-key-import"
+NAMES='Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India
+ Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo
+ Sierra Tango Uniform Victor Whisky XRay Yankee Zulu'
+
+if [ "$1" = "--clean" ]; then
+ (for i in $NAMES; do
+ [ -d $i ] && rm -r $i
+ done) || true
+ exit 0
+fi
+
+$GPG --dearmor -o secdemo.gpg --yes ../checks/secdemo.asc
+$GPG --dearmor -o pubdemo.gpg --yes ../checks/pubdemo.asc
+[ -f ./tdb.tmp ] && rm ./tdb.tmp
+GPGDEMO="$GPG --homedir . --trustdb-name ./tdb.tmp --no-default-keyring
+ --keyring pubdemo.gpg --secret-keyring secdemo.gpg"
+echo -n "Creating:"
+for name in $NAMES; do
+ echo -n " $name"
+ [ -d $name ] && rm -r $name
+ mkdir $name
+ $GPGDEMO --export-secret-key -o - $name > $name/Secret.gpg
+ $GPG --homedir $name --import $name/Secret.gpg
+ $GPGDEMO --export -o - $name > $name/Public.gpg
+ $GPG --homedir $name --import $name/Public.gpg
+ [ -f $name/pubring.gpg~ ] && rm $name/pubring.gpg~
+done
+echo "."
+[ -f ./tdb.tmp ] && rm ./tdb.tmp
+rm pubdemo.gpg secdemo.gpg
+
+
Copied: trunk/tests/openpgp/multisig.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/multisig.test)
Copied: trunk/tests/openpgp/pgp263-test.pub.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/pgp263-test.pub.asc)
Copied: trunk/tests/openpgp/pgp263-test.sec.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/pgp263-test.sec.asc)
Copied: trunk/tests/openpgp/plain-1-pgp.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-1-pgp.asc)
Copied: trunk/tests/openpgp/plain-1.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-1.asc)
Copied: trunk/tests/openpgp/plain-1o.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-1o.asc)
Copied: trunk/tests/openpgp/plain-2.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-2.asc)
Copied: trunk/tests/openpgp/plain-2o.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-2o.asc)
Copied: trunk/tests/openpgp/plain-3.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-3.asc)
Copied: trunk/tests/openpgp/plain-3o.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/plain-3o.asc)
Copied: trunk/tests/openpgp/pubdemo.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/pubdemo.asc)
Copied: trunk/tests/openpgp/pubring.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/pubring.asc)
Copied: trunk/tests/openpgp/pubring.pkr.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/pubring.pkr.asc)
Copied: trunk/tests/openpgp/seat.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/seat.test)
Copied: trunk/tests/openpgp/secdemo.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/secdemo.asc)
Copied: trunk/tests/openpgp/secring.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/secring.asc)
Copied: trunk/tests/openpgp/secring.skr.asc (from rev 4225, branches/STABLE-BRANCH-1-4/checks/secring.skr.asc)
Copied: trunk/tests/openpgp/signdemokey (from rev 4225, branches/STABLE-BRANCH-1-4/checks/signdemokey)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/signdemokey 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/signdemokey 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+if [ $# != 3 ]; then
+ echo "Usage: signdemokey name user_id user_id_no"
+ exit 1
+fi
+name="$1"
+user_id="$2"
+user_id_no="$3"
+
+echo "abc" | ../g10/gpg2 --options ./gpg.conf --homedir $name \
+ --sign-key --batch --yes --passphrase-fd 0 $user_id \
+ $user_id_no sign save
+
Copied: trunk/tests/openpgp/signencrypt-dsa.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/signencrypt-dsa.test)
Copied: trunk/tests/openpgp/signencrypt.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/signencrypt.test)
Copied: trunk/tests/openpgp/sigs-dsa.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/sigs-dsa.test)
Copied: trunk/tests/openpgp/sigs.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/sigs.test)
Copied: trunk/tests/openpgp/verify.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/verify.test)
===================================================================
--- branches/STABLE-BRANCH-1-4/checks/verify.test 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tests/openpgp/verify.test 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+. $srcdir/defs.inc || exit 3
+
+suspend_error
+
+#
+# Two simple tests to check that verify fails for bad input data
+#
+info "checking bogus signature 1"
+../../tools/mk-tdata --char 0x2d 64 >x
+$GPG --verify x data-500 && error "no error code from verify"
+info "checking bogus signature 2"
+../../tools/mk-tdata --char 0xca 64 >x
+$GPG --verify x data-500 && error "no error code from verify"
+
+linefeed
+
+# A variable to collect the test names
+tests=""
+
+# A plain signed message created using
+# echo abc | gpg --homedir . --passphrase-fd 0 -u Alpha -z0 -sa msg
+tests="$tests msg_ols_asc"
+msg_ols_asc='-----BEGIN PGP MESSAGE-----
+
+kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo
+dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0
+aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh
+cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp
+cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk
+IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM
+UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0
+D8luT78c/1x45Q==
+=a29i
+-----END PGP MESSAGE-----'
+
+# A plain signed message created using
+# echo abc | gpg --homedir . --passphrase-fd 0 -u Alpha -sa msg
+tests="$tests msg_cols_asc"
+msg_cols_asc='-----BEGIN PGP MESSAGE-----
+
+owGbwMvMwCSoW1RzPCOz3IRxLSN7EnNucboLT6Cgp0JJRmZeNpBMLFFIzMlRKMpM
+zyjRBQtm5qUrFKTmF+SkKmTmgdQVKyTnl+aVFFUqJBalKhRnJmcrJOalcJVkFqWm
+KOSnKSSlgrSU5OekQMzLL0rJzEsEKk9JTU7NK4EZBtKcBtRRWgAzlwtmbnlmSQbU
+GJjxCmDj9RQUPNVzFZJTi0oSM/NyKhXy8kuAYk6lJSBxLlTF2NziqZCYq8elq+Cb
+n1dSqRBQWZKRn8fVYc/MygAKBljYCDIFiTDMT+9seu836Q+bevyHTJ0dzPNuvCjn
+ZpgrwX38z58rJsfYDhwOSS4SkN/d6vUAAA==
+=s6sY
+-----END PGP MESSAGE-----'
+
+# A PGP 2 style message.
+tests="$tests msg_sl_asc"
+msg_sl_asc='-----BEGIN PGP MESSAGE-----
+
+iD8DBQBEDFJaLXJ8x2hpdzQRAkeCAKCZRBk2Pmx4w9h2LgosS0AppNNaWwCgiI5M
+yzgJpGTZtA/Jbk+/HP9ceOWtAQdiA21zZ0QMUlpJIHRoaW5rIHRoYXQgYWxsIHJp
+Z2h0LXRoaW5raW5nIHBlb3BsZSBpbiB0aGlzIGNvdW50cnkgYXJlIHNpY2sgYW5k
+CnRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBvcmRpbmFyeSBkZWNlbnQgcGVvcGxl
+IGFyZSBmZWQgdXAgaW4gdGhpcwpjb3VudHJ5IHdpdGggYmVpbmcgc2ljayBhbmQg
+dGlyZWQuICBJJ20gY2VydGFpbmx5IG5vdC4gIEJ1dCBJJ20Kc2ljayBhbmQgdGly
+ZWQgb2YgYmVpbmcgdG9sZCB0aGF0IEkgYW0uCi0gTW9udHkgUHl0aG9uCg==
+=0ukK
+-----END PGP MESSAGE-----'
+
+# An OpenPGP message lacking the onepass packet. We used to accept
+# such messages but now consider them invalid.
+tests="$tests bad_ls_asc"
+bad_ls_asc='-----BEGIN PGP MESSAGE-----
+
+rQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9w
+bGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0
+b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRo
+aXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRh
+aW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQg
+dGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IA
+oJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Q==
+=Mpiu
+-----END PGP MESSAGE-----'
+
+
+# A signed message prefixed with an unsigned literal packet.
+# (fols = faked-literal-data, one-pass, literal-data, signature)
+# This should throw an error because running gpg to extract the
+# signed data will return both literal data packets
+tests="$tests bad_fols_asc"
+bad_fols_asc='-----BEGIN PGP MESSAGE-----
+
+rF1iDG1zZy51bnNpZ25lZEQMY0x0aW1lc2hhcmluZywgbjoKCUFuIGFjY2VzcyBt
+ZXRob2Qgd2hlcmVieSBvbmUgY29tcHV0ZXIgYWJ1c2VzIG1hbnkgcGVvcGxlLgqQ
+DQMAAhEtcnzHaGl3NAGtAQdiA21zZ0QMUlpJIHRoaW5rIHRoYXQgYWxsIHJpZ2h0
+LXRoaW5raW5nIHBlb3BsZSBpbiB0aGlzIGNvdW50cnkgYXJlIHNpY2sgYW5kCnRp
+cmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBvcmRpbmFyeSBkZWNlbnQgcGVvcGxlIGFy
+ZSBmZWQgdXAgaW4gdGhpcwpjb3VudHJ5IHdpdGggYmVpbmcgc2ljayBhbmQgdGly
+ZWQuICBJJ20gY2VydGFpbmx5IG5vdC4gIEJ1dCBJJ20Kc2ljayBhbmQgdGlyZWQg
+b2YgYmVpbmcgdG9sZCB0aGF0IEkgYW0uCi0gTW9udHkgUHl0aG9uCog/AwUARAxS
+Wi1yfMdoaXc0EQJHggCgmUQZNj5seMPYdi4KLEtAKaTTWlsAoIiOTMs4CaRk2bQP
+yW5Pvxz/XHjl
+=UNM4
+-----END PGP MESSAGE-----'
+
+# A signed message suffixed with an unsigned literal packet.
+# (fols = faked-literal-data, one-pass, literal-data, signature)
+# This should throw an error because running gpg to extract the
+# signed data will return both literal data packets
+tests="$tests bad_olsf_asc"
+bad_olsf_asc='-----BEGIN PGP MESSAGE-----
+
+kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo
+dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0
+aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh
+cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp
+cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk
+IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM
+UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0
+D8luT78c/1x45axdYgxtc2cudW5zaWduZWREDGNMdGltZXNoYXJpbmcsIG46CglB
+biBhY2Nlc3MgbWV0aG9kIHdoZXJlYnkgb25lIGNvbXB1dGVyIGFidXNlcyBtYW55
+IHBlb3BsZS4K
+=3gnG
+-----END PGP MESSAGE-----'
+
+
+# Two standard signed messages in a row
+tests="$tests msg_olsols_asc_multisig"
+msg_olsols_asc_multisig='-----BEGIN PGP MESSAGE-----
+
+kA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGluayB0aGF0IGFsbCByaWdo
+dC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5IGFyZSBzaWNrIGFuZAp0
+aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkgZGVjZW50IHBlb3BsZSBh
+cmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJlaW5nIHNpY2sgYW5kIHRp
+cmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdtCnNpY2sgYW5kIHRpcmVk
+IG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5IFB5dGhvbgqIPwMFAEQM
+UlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk01pbAKCIjkzLOAmkZNm0
+D8luT78c/1x45ZANAwACES1yfMdoaXc0Aa0BB2IDbXNnRAxSWkkgdGhpbmsgdGhh
+dCBhbGwgcmlnaHQtdGhpbmtpbmcgcGVvcGxlIGluIHRoaXMgY291bnRyeSBhcmUg
+c2ljayBhbmQKdGlyZWQgb2YgYmVpbmcgdG9sZCB0aGF0IG9yZGluYXJ5IGRlY2Vu
+dCBwZW9wbGUgYXJlIGZlZCB1cCBpbiB0aGlzCmNvdW50cnkgd2l0aCBiZWluZyBz
+aWNrIGFuZCB0aXJlZC4gIEknbSBjZXJ0YWlubHkgbm90LiAgQnV0IEknbQpzaWNr
+IGFuZCB0aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgSSBhbS4KLSBNb250eSBQeXRo
+b24KiD8DBQBEDFJaLXJ8x2hpdzQRAkeCAKCZRBk2Pmx4w9h2LgosS0AppNNaWwCg
+iI5MyzgJpGTZtA/Jbk+/HP9ceOU=
+=8nLN
+-----END PGP MESSAGE-----'
+
+# A standard message with two signatures (actually the same signature
+# duplicated).
+tests="$tests msg_oolss_asc"
+msg_oolss_asc='-----BEGIN PGP MESSAGE-----
+
+kA0DAAIRLXJ8x2hpdzQBkA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGlu
+ayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5
+IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkg
+ZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJl
+aW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdt
+CnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5
+IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk
+01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Yg/AwUARAxSWi1yfMdoaXc0EQJHggCg
+mUQZNj5seMPYdi4KLEtAKaTTWlsAoIiOTMs4CaRk2bQPyW5Pvxz/XHjl
+=KVw5
+-----END PGP MESSAGE-----'
+
+# A standard message with two one-pass packet but only one signature
+# packet
+tests="$tests bad_ools_asc"
+bad_ools_asc='-----BEGIN PGP MESSAGE-----
+
+kA0DAAIRLXJ8x2hpdzQBkA0DAAIRLXJ8x2hpdzQBrQEHYgNtc2dEDFJaSSB0aGlu
+ayB0aGF0IGFsbCByaWdodC10aGlua2luZyBwZW9wbGUgaW4gdGhpcyBjb3VudHJ5
+IGFyZSBzaWNrIGFuZAp0aXJlZCBvZiBiZWluZyB0b2xkIHRoYXQgb3JkaW5hcnkg
+ZGVjZW50IHBlb3BsZSBhcmUgZmVkIHVwIGluIHRoaXMKY291bnRyeSB3aXRoIGJl
+aW5nIHNpY2sgYW5kIHRpcmVkLiAgSSdtIGNlcnRhaW5seSBub3QuICBCdXQgSSdt
+CnNpY2sgYW5kIHRpcmVkIG9mIGJlaW5nIHRvbGQgdGhhdCBJIGFtLgotIE1vbnR5
+IFB5dGhvbgqIPwMFAEQMUlotcnzHaGl3NBECR4IAoJlEGTY+bHjD2HYuCixLQCmk
+01pbAKCIjkzLOAmkZNm0D8luT78c/1x45Q==
+=1/ix
+-----END PGP MESSAGE-----'
+
+# Standard cleartext signature
+tests="$tests msg_cls_asc"
+msg_cls_asc=`cat <<EOF
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+I think that all right-thinking people in this country are sick and
+tired of being told that ordinary decent people are fed up in this
+country with being sick and tired. I'm certainly not. But I'm
+sick and tired of being told that I am.
+- - Monty Python
+-----BEGIN PGP SIGNATURE-----
+
+iD8DBQFEDVp1LXJ8x2hpdzQRAplUAKCMfpG3GPw/TLN52tosgXP5lNECkwCfQhAa
+emmev7IuQjWYrGF9Lxj+zj8=
+=qJsY
+-----END PGP SIGNATURE-----
+EOF
+`
+
+# Cleartext signature with two signatures
+tests="$tests msg_clss_asc"
+msg_clss_asc=`cat <<EOF
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+What is the difference between a Turing machine and the modern computer?
+It's the same as that between Hillary's ascent of Everest and the
+establishment of a Hilton on its peak.
+-----BEGIN PGP SIGNATURE-----
+
+iD8DBQFEDVz6LXJ8x2hpdzQRAtkGAKCeMhNbHnh339fpjNj9owsYcC4zBwCfYO5l
+2u+KEfXX0FKyk8SMzLjZ536IPwMFAUQNXPr+GAsdqeOwshEC2QYAoPOWAiQm0EF/
+FWIAQUplk7JWbyRKAJ92ZJyJpWfzb0yc1s7MY65r2qEHrg==
+=1Xvv
+-----END PGP SIGNATURE-----
+EOF
+`
+
+# Two clear text signatures in a row
+tests="$tests msg_clsclss_asc"
+msg_clsclss_asc="${msg_cls_asc}
+${msg_clss_asc}"
+
+
+# Fixme: We need more tests with manipulated cleartext signatures.
+
+
+#
+# Now run the tests.
+#
+for i in $tests ; do
+ info "checking: $i"
+ eval "(IFS=; echo \"\$$i\")" >x
+ case "$i" in
+ msg_*_asc)
+ $GPG --verify x || error "verify of $i failed"
+ ;;
+ msg_*_asc_multisig)
+ $GPG --verify --allow-multisig-verification x \
+ || error "verify of $i failed"
+ $GPG --verify x && error "verify of $i succeeded but should not"
+ ;;
+ bad_*_asc)
+ $GPG --verify x && error "verify of $i succeeded but should not"
+ ;;
+ *)
+ error "No handler for test case $i"
+ ;;
+ esac
+ linefeed
+done
+
+
+resume_error
Copied: trunk/tests/openpgp/version.test (from rev 4225, branches/STABLE-BRANCH-1-4/checks/version.test)
Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tools/ChangeLog 2006-08-21 20:20:23 UTC (rev 4226)
@@ -1,3 +1,9 @@
+2006-08-21 Werner Koch <wk at g10code.com>
+
+ * gpgsplit.c: New. Taken from 1.4. Adjusted to GnuPG2.
+
+ * Makefile.am (noinst_PROGRAMS): New.
+
2006-06-09 Marcus Brinkmann <marcus at g10code.de>
* Makefile.am (gpgconf_LDADD): Add $(GPG_ERROR_LIBS).
Modified: trunk/tools/Makefile.am
===================================================================
--- trunk/tools/Makefile.am 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tools/Makefile.am 2006-08-21 20:20:23 UTC (rev 4226)
@@ -18,9 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-EXTRA_DIST = Manifest watchgnupg.c \
- addgnupghome gpgsm-gencert.sh
+EXTRA_DIST = \
+ Manifest watchgnupg.c \
+ addgnupghome gpgsm-gencert.sh \
+ lspgpot mail-signed-keys convert-from-106
+
AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
include $(top_srcdir)/am/cmacros.am
@@ -29,6 +32,9 @@
sbin_SCRIPTS = addgnupghome
bin_SCRIPTS = gpgsm-gencert.sh
+if HAVE_USTAR
+bin_SCRIPTS += gpg-zip
+endif
if BUILD_SYMCRYPTRUN
symcryptrun = symcryptrun
@@ -36,17 +42,24 @@
symcryptrun =
endif
-bin_PROGRAMS = gpgconf gpg-connect-agent gpgkey2ssh ${symcryptrun} gpgparsemail
+bin_PROGRAMS = gpgconf gpg-connect-agent gpgkey2ssh ${symcryptrun} \
+ gpgparsemail gpgsplit
if !HAVE_W32_SYSTEM
bin_PROGRAMS += watchgnupg
endif
+noinst_PROGRAMS = clean-sat mk-tdata make-dns-cert
+
+common_libs = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a
+
+gpgsplit_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(ZLIBS)
+
gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c
# jnlib/common sucks in gpg-error, will they, nil they (some compilers
# do not eliminate the supposed-to-be-unused-inline-functions).
gpgconf_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a \
- ../gl/libgnu.a @LIBINTL@ $(GPG_ERROR_LIBS)
+ ../gl/libgnu.a $(LIBINTL) $(GPG_ERROR_LIBS)
gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h
gpgparsemail_LDADD =
@@ -71,3 +84,5 @@
# some compilers do not eliminate.
gpgkey2ssh_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \
$(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS)
+
+
Copied: trunk/tools/clean-sat.c (from rev 4225, branches/STABLE-BRANCH-1-4/tools/clean-sat.c)
Copied: trunk/tools/convert-from-106 (from rev 4225, branches/STABLE-BRANCH-1-4/tools/convert-from-106)
Copied: trunk/tools/crlf.c (from rev 4225, branches/STABLE-BRANCH-1-4/tools/crlf.c)
Copied: trunk/tools/gpg-zip.in (from rev 4225, branches/STABLE-BRANCH-1-4/tools/gpg-zip.in)
Copied: trunk/tools/gpgsplit.c (from rev 4225, branches/STABLE-BRANCH-1-4/tools/gpgsplit.c)
===================================================================
--- branches/STABLE-BRANCH-1-4/tools/gpgsplit.c 2006-08-21 08:40:45 UTC (rev 4225)
+++ trunk/tools/gpgsplit.c 2006-08-21 20:20:23 UTC (rev 4226)
@@ -0,0 +1,881 @@
+/* gpgsplit.c - An OpenPGP packet splitting tool
+ * Copyright (C) 2001, 2002, 2003 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.
+ */
+
+/*
+ * TODO: Add an option to uncompress packets. This should come quite handy.
+ */
+
+#include <config.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <assert.h>
+#include <sys/types.h>
+#ifdef HAVE_DOSISH_SYSTEM
+# include <fcntl.h> /* for setmode() */
+#endif
+#include <zlib.h>
+#ifdef HAVE_BZIP2
+#include <bzlib.h>
+#endif /* HAVE_BZIP2 */
+#if defined(__riscos__) && defined(USE_ZLIBRISCOS)
+# include "zlib-riscos.h"
+#endif
+
+#define INCLUDED_BY_MAIN_MODULE 1
+#include "util.h"
+#include "openpgpdefs.h"
+
+static int opt_verbose;
+static const char *opt_prefix = "";
+static int opt_uncompress;
+static int opt_secret_to_public;
+static int opt_no_split;
+
+static void g10_exit( int rc );
+static void split_packets (const char *fname);
+
+
+enum cmd_and_opt_values {
+ aNull = 0,
+ oVerbose = 'v',
+ oPrefix = 'p',
+ oUncompress = 500,
+ oSecretToPublic,
+ oNoSplit,
+
+ aTest
+};
+
+
+static ARGPARSE_OPTS opts[] = {
+
+ { 301, NULL, 0, "@Options:\n " },
+
+ { oVerbose, "verbose", 0, "verbose" },
+ { oPrefix, "prefix", 2, "|STRING|Prepend filenames with STRING" },
+ { oUncompress, "uncompress", 0, "uncompress a packet"},
+ { oSecretToPublic, "secret-to-public", 0, "convert secret keys to public keys"},
+ { oNoSplit, "no-split", 0, "write to stdout and don't actually split"},
+{0} };
+
+
+static const char *
+my_strusage (int level)
+{
+ const char *p;
+ switch (level)
+ {
+ case 11: p = "gpgsplit (GnuPG)";
+ break;
+ case 13: p = VERSION; break;
+ case 17: p = PRINTABLE_OS_NAME; break;
+ case 19: p =
+ "Please report bugs to <bug-gnupg at gnu.org>.\n";
+ break;
+ case 1:
+ case 40: p =
+ "Usage: gpgsplit [options] [files] (-h for help)";
+ break;
+ case 41: p =
+ "Syntax: gpgsplit [options] [files]\n"
+ "Split an OpenPGP message into packets\n";
+ break;
+
+ default: p = NULL;
+ }
+ return p;
+}
+
+
+
+int
+main (int argc, char **argv)
+{
+ ARGPARSE_ARGS pargs;
+
+#ifdef HAVE_DOSISH_SYSTEM
+ setmode( fileno(stdin), O_BINARY );
+ setmode( fileno(stdout), O_BINARY );
+#endif
+ log_set_prefix ("gpgsplit", JNLIB_LOG_WITH_PREFIX);
+ set_strusage (my_strusage);
+
+ pargs.argc = &argc;
+ pargs.argv = &argv;
+ pargs.flags= 1; /* do not remove the args */
+ while (optfile_parse( NULL, NULL, NULL, &pargs, opts))
+ {
+ switch (pargs.r_opt)
+ {
+ case oVerbose: opt_verbose = 1; break;
+ case oPrefix: opt_prefix = pargs.r.ret_str; break;
+ case oUncompress: opt_uncompress = 1; break;
+ case oSecretToPublic: opt_secret_to_public = 1; break;
+ case oNoSplit: opt_no_split = 1; break;
+ default : pargs.err = 2; break;
+ }
+ }
+
+ if (log_get_errorcount(0))
+ g10_exit (2);
+
+ if (!argc)
+ split_packets (NULL);
+ else
+ {
+ for ( ;argc; argc--, argv++)
+ split_packets (*argv);
+ }
+
+ g10_exit (0);
+ return 0;
+}
+
+
+static void
+g10_exit (int rc)
+{
+ rc = rc? rc : log_get_errorcount(0)? 2 : 0;
+ exit(rc );
+}
+
+static const char *
+pkttype_to_string (int pkttype)
+{
+ const char *s;
+
+ switch (pkttype)
+ {
+ case PKT_PUBKEY_ENC : s = "pk_enc"; break;
+ case PKT_SIGNATURE : s = "sig"; break;
+ case PKT_SYMKEY_ENC : s = "sym_enc"; break;
+ case PKT_ONEPASS_SIG : s = "onepass_sig"; break;
+ case PKT_SECRET_KEY : s = "secret_key"; break;
+ case PKT_PUBLIC_KEY : s = "public_key"; break;
+ case PKT_SECRET_SUBKEY : s = "secret_subkey"; break;
+ case PKT_COMPRESSED :
+ s = opt_uncompress? "uncompressed":"compressed";
+ break;
+ case PKT_ENCRYPTED : s = "encrypted"; break;
+ case PKT_MARKER : s = "marker"; break;
+ case PKT_PLAINTEXT : s = "plaintext"; break;
+ case PKT_RING_TRUST : s = "ring_trust"; break;
+ case PKT_USER_ID : s = "user_id"; break;
+ case PKT_PUBLIC_SUBKEY : s = "public_subkey"; break;
+ case PKT_OLD_COMMENT : s = "old_comment"; break;
+ case PKT_ATTRIBUTE : s = "attribute"; break;
+ case PKT_ENCRYPTED_MDC : s = "encrypted_mdc"; break;
+ case PKT_MDC : s = "mdc"; break;
+ case PKT_COMMENT : s = "comment"; break;
+ case PKT_GPG_CONTROL : s = "gpg_control"; break;
+ default: s = "unknown"; break;
+ }
+ return s;
+}
+
+
+/*
+ * Create a new filename and a return a pointer to a statically
+ * allocated buffer
+ */
+static char *
+create_filename (int pkttype)
+{
+ static unsigned int partno = 0;
+ static char *name;
+
+ if (!name)
+ name = xmalloc (strlen (opt_prefix) + 100 );
+
+ assert (pkttype < 1000 && pkttype >= 0 );
+ partno++;
+ sprintf (name, "%s%06u-%03d" EXTSEP_S "%.40s",
+ opt_prefix, partno, pkttype, pkttype_to_string (pkttype));
+ return name;
+}
+
+static int
+read_u16 (FILE *fp, size_t *rn)
+{
+ int c;
+
+ if ( (c = getc (fp)) == EOF )
+ return -1;
+ *rn = c << 8;
+ if ( (c = getc (fp)) == EOF )
+ return -1;
+ *rn |= c;
+ return 0;
+}
+
+static int
+read_u32 (FILE *fp, unsigned long *rn)
+{
+ size_t tmp;
+
+ if (read_u16 (fp, &tmp))
+ return -1;
+ *rn = tmp << 16;
+ if (read_u16 (fp, &tmp))
+ return -1;
+ *rn |= tmp;
+ return 0;
+}
+
+static int
+write_old_header (FILE *fp, int pkttype, unsigned int len)
+{
+ int ctb = (0x80 | ((pkttype & 15)<<2));
+
+ if (len < 256)
+ ;
+ else if (len < 65536)
+ ctb |= 1;
+ else
+ ctb |= 2;
+
+ if ( putc ( ctb, fp) == EOF )
+ return -1;
+
+ if ( (ctb & 2) )
+ {
+ if (putc ((len>>24), fp) == EOF)
+ return -1;
+ if (putc ((len>>16), fp) == EOF)
+ return -1;
+ }
+ if ( (ctb & 3) )
+ {
+ if (putc ((len>>8), fp) == EOF)
+ return -1;
+ }
+ if (putc ((len&0xff), fp) == EOF)
+ return -1;
+ return 0;
+}
+
+static int
+write_new_header (FILE *fp, int pkttype, unsigned int len)
+{
+ if ( putc ((0xc0 | (pkttype & 0x3f)), fp) == EOF )
+ return -1;
+
+ if (len < 192)
+ {
+ if (putc (len, fp) == EOF)
+ return -1;
+ }
+ else if (len < 8384)
+ {
+ len -= 192;
+ if (putc ((len/256)+192, fp) == EOF)
+ return -1;
+ if (putc ((len%256), fp) == EOF)
+ return -1;
+ }
+ else
+ {
+ if (putc ( 0xff, fp) == EOF)
+ return -1;
+ if (putc ( (len >> 24), fp) == EOF)
+ return -1;
+ if (putc ( (len >> 16), fp) == EOF)
+ return -1;
+ if (putc ( (len >> 8), fp) == EOF)
+ return -1;
+ if (putc ( (len & 0xff), fp) == EOF)
+ return -1;
+ }
+ return 0;
+}
+
+/* Return the length of the public key given BUF of BUFLEN with a
+ secret key. */
+static int
+public_key_length (const unsigned char *buf, size_t buflen)
+{
+ const unsigned char *s;
+ int nmpis;
+
+ /* byte version number (3 or 4)
+ u32 creation time
+ [u16 valid days (version 3 only)]
+ byte algorithm
+ n MPIs (n and e) */
+ if (!buflen)
+ return 0;
+ if (buf[0] < 2 || buf[0] > 4)
+ return 0; /* wrong version number */
+ if (buflen < (buf[0] == 4? 6:8))
+ return 0;
+ s = buf + (buf[0] == 4? 6:8);
+ buflen -= (buf[0] == 4? 6:8);
+ switch (s[-1])
+ {
+ case 1:
+ case 2:
+ case 3:
+ nmpis = 2;
+ break;
+ case 16:
+ case 20:
+ nmpis = 3;
+ break;
+ case 17:
+ nmpis = 4;
+ break;
+ default:
+ return 0;
+ }
+
+ for (; nmpis; nmpis--)
+ {
+ unsigned int nbits, nbytes;
+
+ if (buflen < 2)
+ return 0;
+ nbits = (s[0] << 8) | s[1];
+ s += 2; buflen -= 2;
+ nbytes = (nbits+7) / 8;
+ if (buflen < nbytes)
+ return 0;
+ s += nbytes; buflen -= nbytes;
+ }
+
+ return s - buf;
+}
+
+static int
+handle_zlib(int algo,FILE *fpin,FILE *fpout)
+{
+ z_stream zs;
+ byte *inbuf, *outbuf;
+ unsigned int inbufsize, outbufsize;
+ int c,zinit_done, zrc, nread, count;
+ size_t n;
+
+ memset (&zs, 0, sizeof zs);
+ inbufsize = 2048;
+ inbuf = xmalloc (inbufsize);
+ outbufsize = 8192;
+ outbuf = xmalloc (outbufsize);
+ zs.avail_in = 0;
+ zinit_done = 0;
+
+ do
+ {
+ if (zs.avail_in < inbufsize)
+ {
+ n = zs.avail_in;
+ if (!n)
+ zs.next_in = (Bytef *) inbuf;
+ count = inbufsize - n;
+ for (nread=0;
+ nread < count && (c=getc (fpin)) != EOF;
+ nread++)
+ inbuf[n+nread] = c;
+
+ n += nread;
+ if (nread < count && algo == 1)
+ {
+ inbuf[n] = 0xFF; /* chew dummy byte */
+ n++;
+ }
+ zs.avail_in = n;
+ }
+ zs.next_out = (Bytef *) outbuf;
+ zs.avail_out = outbufsize;
+
+ if (!zinit_done)
+ {
+ zrc = (algo == 1? inflateInit2 ( &zs, -13)
+ : inflateInit ( &zs ));
+ if (zrc != Z_OK)
+ {
+ log_fatal ("zlib problem: %s\n", zs.msg? zs.msg :
+ zrc == Z_MEM_ERROR ? "out of core" :
+ zrc == Z_VERSION_ERROR ?
+ "invalid lib version" :
+ "unknown error" );
+ }
+ zinit_done = 1;
+ }
+ else
+ {
+#ifdef Z_SYNC_FLUSH
+ zrc = inflate (&zs, Z_SYNC_FLUSH);
+#else
+ zrc = inflate (&zs, Z_PARTIAL_FLUSH);
+#endif
+ if (zrc == Z_STREAM_END)
+ ; /* eof */
+ else if (zrc != Z_OK && zrc != Z_BUF_ERROR)
+ {
+ if (zs.msg)
+ log_fatal ("zlib inflate problem: %s\n", zs.msg );
+ else
+ log_fatal ("zlib inflate problem: rc=%d\n", zrc );
+ }
+ for (n=0; n < outbufsize - zs.avail_out; n++)
+ {
+ if (putc (outbuf[n], fpout) == EOF )
+ return 1;
+ }
+ }
+ }
+ while (zrc != Z_STREAM_END && zrc != Z_BUF_ERROR);
+ inflateEnd (&zs);
+
+ return 0;
+}
+
+#ifdef HAVE_BZIP2
+static int
+handle_bzip2(int algo,FILE *fpin,FILE *fpout)
+{
+ bz_stream bzs;
+ byte *inbuf, *outbuf;
+ unsigned int inbufsize, outbufsize;
+ int c,zinit_done, zrc, nread, count;
+ size_t n;
+
+ memset (&bzs, 0, sizeof bzs);
+ inbufsize = 2048;
+ inbuf = xmalloc (inbufsize);
+ outbufsize = 8192;
+ outbuf = xmalloc (outbufsize);
+ bzs.avail_in = 0;
+ zinit_done = 0;
+
+ do
+ {
+ if (bzs.avail_in < inbufsize)
+ {
+ n = bzs.avail_in;
+ if (!n)
+ bzs.next_in = inbuf;
+ count = inbufsize - n;
+ for (nread=0;
+ nread < count && (c=getc (fpin)) != EOF;
+ nread++)
+ inbuf[n+nread] = c;
+
+ n += nread;
+ if (nread < count && algo == 1)
+ {
+ inbuf[n] = 0xFF; /* chew dummy byte */
+ n++;
+ }
+ bzs.avail_in = n;
+ }
+ bzs.next_out = outbuf;
+ bzs.avail_out = outbufsize;
+
+ if (!zinit_done)
+ {
+ zrc = BZ2_bzDecompressInit(&bzs,0,0);
+ if (zrc != BZ_OK)
+ log_fatal ("bz2lib problem: %d\n",zrc);
+ zinit_done = 1;
+ }
+ else
+ {
+ zrc = BZ2_bzDecompress(&bzs);
+ if (zrc == BZ_STREAM_END)
+ ; /* eof */
+ else if (zrc != BZ_OK && zrc != BZ_PARAM_ERROR)
+ log_fatal ("bz2lib inflate problem: %d\n", zrc );
+ for (n=0; n < outbufsize - bzs.avail_out; n++)
+ {
+ if (putc (outbuf[n], fpout) == EOF )
+ return 1;
+ }
+ }
+ }
+ while (zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR);
+ BZ2_bzDecompressEnd(&bzs);
+
+ return 0;
+}
+#endif /* HAVE_BZIP2 */
+
+/* hdr must point to a buffer large enough to hold all header bytes */
+static int
+write_part ( const char *fname, FILE *fpin, unsigned long pktlen,
+ int pkttype, int partial, unsigned char *hdr, size_t hdrlen)
+{
+ FILE *fpout;
+ int c, first;
+ unsigned char *p;
+ const char *outname = create_filename (pkttype);
+
+#if defined(__riscos__) && defined(USE_ZLIBRISCOS)
+ static int initialized = 0;
+
+ if (!initialized)
+ initialized = riscos_load_module("ZLib", zlib_path, 1);
+#endif
+ if (opt_no_split)
+ fpout = stdout;
+ else
+ {
+ if (opt_verbose)
+ log_info ("writing `%s'\n", outname);
+ fpout = fopen (outname, "wb");
+ if (!fpout)
+ {
+ log_error ("error creating `%s': %s\n", outname, strerror(errno));
+ /* stop right now, otherwise we would mess up the sequence
+ of the part numbers */
+ g10_exit (1);
+ }
+ }
+
+ if (opt_secret_to_public
+ && (pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY))
+ {
+ unsigned char *blob = xmalloc (pktlen);
+ int i, len;
+
+ pkttype = pkttype == PKT_SECRET_KEY? PKT_PUBLIC_KEY:PKT_PUBLIC_SUBKEY;
+
+ for (i=0; i < pktlen; i++)
+ {
+ c = getc (fpin);
+ if (c == EOF)
+ goto read_error;
+ blob[i] = c;
+ }
+ len = public_key_length (blob, pktlen);
+ if (!len)
+ {
+ log_error ("error calcualting public key length\n");
+ g10_exit (1);
+ }
+ if ( (hdr[0] & 0x40) )
+ {
+ if (write_new_header (fpout, pkttype, len))
+ goto write_error;
+ }
+ else
+ {
+ if (write_old_header (fpout, pkttype, len))
+ goto write_error;
+ }
+
+ for (i=0; i < len; i++)
+ {
+ if ( putc (blob[i], fpout) == EOF )
+ goto write_error;
+ }
+
+ goto ready;
+ }
+
+
+ if (!opt_uncompress)
+ {
+ for (p=hdr; hdrlen; p++, hdrlen--)
+ {
+ if ( putc (*p, fpout) == EOF )
+ goto write_error;
+ }
+ }
+
+ first = 1;
+ while (partial)
+ {
+ size_t partlen;
+
+ if (partial == 1)
+ { /* openpgp */
+ if (first )
+ {
+ c = pktlen;
+ assert( c >= 224 && c < 255 );
+ first = 0;
+ }
+ else if ((c = getc (fpin)) == EOF )
+ goto read_error;
+ else
+ hdr[hdrlen++] = c;
+
+ if (c < 192)
+ {
+ pktlen = c;
+ partial = 0; /* (last segment may follow) */
+ }
+ else if (c < 224 )
+ {
+ pktlen = (c - 192) * 256;
+ if ((c = getc (fpin)) == EOF)
+ goto read_error;
+ hdr[hdrlen++] = c;
+ pktlen += c + 192;
+ partial = 0;
+ }
+ else if (c == 255)
+ {
+ if (read_u32 (fpin, &pktlen))
+ goto read_error;
+ hdr[hdrlen++] = pktlen >> 24;
+ hdr[hdrlen++] = pktlen >> 16;
+ hdr[hdrlen++] = pktlen >> 8;
+ hdr[hdrlen++] = pktlen;
+ partial = 0;
+ }
+ else
+ { /* next partial body length */
+ for (p=hdr; hdrlen; p++, hdrlen--)
+ {
+ if ( putc (*p, fpout) == EOF )
+ goto write_error;
+ }
+ partlen = 1 << (c & 0x1f);
+ for (; partlen; partlen--)
+ {
+ if ((c = getc (fpin)) == EOF)
+ goto read_error;
+ if ( putc (c, fpout) == EOF )
+ goto write_error;
+ }
+ }
+ }
+ else if (partial == 2)
+ { /* old gnupg */
+ assert (!pktlen);
+ if ( read_u16 (fpin, &partlen) )
+ goto read_error;
+ hdr[hdrlen++] = partlen >> 8;
+ hdr[hdrlen++] = partlen;
+ for (p=hdr; hdrlen; p++, hdrlen--)
+ {
+ if ( putc (*p, fpout) == EOF )
+ goto write_error;
+ }
+ if (!partlen)
+ partial = 0; /* end of packet */
+ for (; partlen; partlen--)
+ {
+ c = getc (fpin);
+ if (c == EOF)
+ goto read_error;
+ if ( putc (c, fpout) == EOF )
+ goto write_error;
+ }
+ }
+ else
+ { /* compressed: read to end */
+ pktlen = 0;
+ partial = 0;
+ hdrlen = 0;
+ if (opt_uncompress)
+ {
+ if ((c = getc (fpin)) == EOF)
+ goto read_error;
+
+ if(c==1 || c==2)
+ {
+ if(handle_zlib(c,fpin,fpout))
+ goto write_error;
+ }
+#ifdef HAVE_BZIP2
+ else if(c==3)
+ {
+ if(handle_bzip2(c,fpin,fpout))
+ goto write_error;
+ }
+#endif /* HAVE_BZIP2 */
+ else
+ {
+ log_error("invalid compression algorithm (%d)\n",c);
+ goto read_error;
+ }
+ }
+ else
+ {
+ while ( (c=getc (fpin)) != EOF )
+ {
+ if ( putc (c, fpout) == EOF )
+ goto write_error;
+ }
+ }
+ if (!feof (fpin))
+ goto read_error;
+ }
+ }
+
+ for (p=hdr; hdrlen; p++, hdrlen--)
+ {
+ if ( putc (*p, fpout) == EOF )
+ goto write_error;
+ }
+
+ /* standard packet or last segment of partial length encoded packet */
+ for (; pktlen; pktlen--)
+ {
+ c = getc (fpin);
+ if (c == EOF)
+ goto read_error;
+ if ( putc (c, fpout) == EOF )
+ goto write_error;
+ }
+
+ ready:
+ if ( !opt_no_split && fclose (fpout) )
+ log_error ("error closing `%s': %s\n", outname, strerror (errno));
+ return 0;
+
+ write_error:
+ log_error ("error writing `%s': %s\n", outname, strerror (errno));
+ if (!opt_no_split)
+ fclose (fpout);
+ return 2;
+
+ read_error:
+ if (!opt_no_split)
+ {
+ int save = errno;
+ fclose (fpout);
+ errno = save;
+ }
+ return -1;
+}
+
+
+
+static int
+do_split (const char *fname, FILE *fp)
+{
+ int c, ctb, pkttype;
+ unsigned long pktlen = 0;
+ int partial = 0;
+ unsigned char header[20];
+ int header_idx = 0;
+
+ ctb = getc (fp);
+ if (ctb == EOF)
+ return 3; /* ready */
+ header[header_idx++] = ctb;
+
+ if (!(ctb & 0x80))
+ {
+ log_error("invalid CTB %02x\n", ctb );
+ return 1;
+ }
+ if ( (ctb & 0x40) )
+ { /* new CTB */
+ pkttype = (ctb & 0x3f);
+ if( (c = getc (fp)) == EOF )
+ return -1;
+ header[header_idx++] = c;
+
+ if ( c < 192 )
+ pktlen = c;
+ else if ( c < 224 )
+ {
+ pktlen = (c - 192) * 256;
+ if( (c = getc (fp)) == EOF )
+ return -1;
+ header[header_idx++] = c;
+ pktlen += c + 192;
+ }
+ else if ( c == 255 )
+ {
+ if (read_u32 (fp, &pktlen))
+ return -1;
+ header[header_idx++] = pktlen >> 24;
+ header[header_idx++] = pktlen >> 16;
+ header[header_idx++] = pktlen >> 8;
+ header[header_idx++] = pktlen;
+ }
+ else
+ { /* partial body length */
+ pktlen = c;
+ partial = 1;
+ }
+ }
+ else
+ {
+ int lenbytes;
+
+ pkttype = (ctb>>2)&0xf;
+ lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
+ if (!lenbytes )
+ {
+ pktlen = 0; /* don't know the value */
+ if( pkttype == PKT_COMPRESSED )
+ partial = 3;
+ else
+ partial = 2; /* the old GnuPG partial length encoding */
+ }
+ else
+ {
+ for ( ; lenbytes; lenbytes-- )
+ {
+ pktlen <<= 8;
+ if( (c = getc (fp)) == EOF )
+ return -1;
+ header[header_idx++] = c;
+
+ pktlen |= c;
+ }
+ }
+ }
+
+ return write_part (fname, fp, pktlen, pkttype, partial,
+ header, header_idx);
+}
+
+
+static void
+split_packets (const char *fname)
+{
+ FILE *fp;
+ int rc;
+
+ if (!fname || !strcmp (fname, "-"))
+ {
+ fp = stdin;
+ fname = "-";
+ }
+ else if ( !(fp = fopen (fname,"rb")) )
+ {
+ log_error ("can't open `%s': %s\n", fname, strerror (errno));
+ return;
+ }
+
+ while ( !(rc = do_split (fname, fp)) )
+ ;
+ if ( rc > 0 )
+ ; /* error already handled */
+ else if ( ferror (fp) )
+ log_error ("error reading `%s': %s\n", fname, strerror (errno));
+ else
+ log_error ("premature EOF while reading `%s'\n", fname );
+
+ if ( fp != stdin )
+ fclose (fp);
+}
Copied: trunk/tools/lspgpot (from rev 4225, branches/STABLE-BRANCH-1-4/tools/lspgpot)
Copied: trunk/tools/mail-signed-keys (from rev 4225, branches/STABLE-BRANCH-1-4/tools/mail-signed-keys)
Copied: trunk/tools/make-dns-cert.c (from rev 4225, branches/STABLE-BRANCH-1-4/tools/make-dns-cert.c)
Copied: trunk/tools/mk-tdata.c (from rev 4225, branches/STABLE-BRANCH-1-4/tools/mk-tdata.c)
Copied: trunk/tools/pgpgroup-to-gpggroup (from rev 4225, branches/STABLE-BRANCH-1-4/tools/pgpgroup-to-gpggroup)
More information about the Gnupg-commits
mailing list