[svn] gcry - r1238 - in trunk: . doc mpi src tests
svn author wk
cvs at cvs.gnupg.org
Mon Apr 30 16:10:03 CEST 2007
Author: wk
Date: 2007-04-30 16:09:33 +0200 (Mon, 30 Apr 2007)
New Revision: 1238
Added:
trunk/doc/HACKING
trunk/doc/Notes-wk
trunk/doc/README.apichanges
trunk/tests/version.c
Removed:
trunk/Notes-wk
trunk/README.apichanges
trunk/w32-dll/
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/NEWS
trunk/doc/ChangeLog
trunk/doc/Makefile.am
trunk/doc/gcrypt.texi
trunk/mpi/ChangeLog
trunk/mpi/Makefile.am
trunk/mpi/config.links
trunk/mpi/mpiutil.c
trunk/src/ChangeLog
trunk/src/g10lib.h
trunk/src/gcrypt.h.in
trunk/src/global.c
trunk/tests/ChangeLog
trunk/tests/Makefile.am
Log:
./
* README.apichanges: Move to doc/.
* Makefile.am (EXTRA_DIST): Removed that file.
doc/
* HACKING: New. Two items by Marcus.
* README.apichanges: Move from .. to here.
* Makefile.am (EXTRA_DIST): Add new files.
mpi/
* config.links: Create a file mod-source-info.h.
* Makefile.am (DISTCLEANFILES): Add that file.
* mpiutil.c (_gcry_mpi_get_hw_config): New.
src/
* global.c (gcry_control): New.
* gcrypt.h.in (GCRYCTL_DUMP_CONFIG): New.
tests/
* version.c: New.
* Makefile.am (TESTS): Add version.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/ChangeLog 2007-04-30 14:09:33 UTC (rev 1238)
@@ -1,3 +1,8 @@
+2007-04-30 Werner Koch <wk at g10code.com>
+
+ * README.apichanges: Move to doc/.
+ * Makefile.am (EXTRA_DIST): Removed that file.
+
2007-04-28 Marcus Brinkmann <marcus at g10code.de>
* configure.ac: Allow to specify additional search directories
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/Makefile.am 2007-04-30 14:09:33 UTC (rev 1238)
@@ -23,7 +23,7 @@
DIST_SUBDIRS = m4 mpi cipher src doc tests
SUBDIRS = mpi cipher src doc tests
-EXTRA_DIST = BUGS autogen.sh README.apichanges README.SVN
+EXTRA_DIST = BUGS autogen.sh README.SVN
DISTCLEANFILES =
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/NEWS 2007-04-30 14:09:33 UTC (rev 1238)
@@ -51,6 +51,7 @@
gcry_md_debug NEW
gcry_sexp_nth_string NEW
GCRYCTL_FAKED_RANDOM_P NEW
+ GCRYCTL_DUMP_CONFIG NEW
GCRY_MD_SHA224 NEW
GCRY_PK_USAGE_CERT NEW
GCRY_PK_USAGE_AUTH NEW
Deleted: trunk/Notes-wk
Deleted: trunk/README.apichanges
Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/doc/ChangeLog 2007-04-30 14:09:33 UTC (rev 1238)
@@ -1,3 +1,9 @@
+2007-04-30 Werner Koch <wk at g10code.com>
+
+ * HACKING: New. Two items by Marcus.
+ * README.apichanges: Move from .. to here.
+ * Makefile.am (EXTRA_DIST): Add new files.
+
2007-04-09 Marcus Brinkmann <marcus at g10code.de>
* gcrypt.texi: Fix some typos.
Added: trunk/doc/HACKING
===================================================================
--- trunk/doc/HACKING 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/doc/HACKING 2007-04-30 14:09:33 UTC (rev 1238)
@@ -0,0 +1,66 @@
+ Various hacking notes -*- text -*-
+ =======================
+
+
+Taking optimized MPI code out of GMP:
+-------------------------------------
+
+ I generated the pentium4/* files by glueing the existing assembler
+ prologues to the GMP 4.2.1 assembler files generated with the m4
+ tool in GMP's build process, for example:
+
+ $ m4 -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_rshift -DPIC \
+ rshift.asm >tmp-rshift.s
+
+ Then tmp-rshift will contain the assembler instructions for the
+ configured platform. Unfortunately, this way the comments are lost.
+ For most files I re-inserted some of the comments, but this is
+ tedious work.
+
+
+Debugging math stuff:
+---------------------
+
+ While debugging the ECC code in libgcrypt, I was in need for some
+ computer algebra system which would allow me to verify the numbers
+ in the debugging easily. I found that PARI (pari-gp package in
+ Debian) has support for elliptic curves. The below commands shows
+ how they are set up and used with an example.
+
+ ===8<========
+ hextodec(s)=local(v=Vec(s),a=10,b=11,c=12,d=13,e=14,f=15,A=10,B=11,C=12,D=13,E=14,F=15,h);if(#setunion(Set(v),Vec("0123456789ABCDEFabcdef"))>22,error);for(i=1,#v,h=shift(h,4)+eval(v[i]));h
+
+ p = hextodec("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
+ a = hextodec("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC")
+ b = hextodec("51953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00")
+
+ /* Set up y^2 = x^3 + ax + b mod (p). */
+ e = ellinit(Mod(1,p)*[0,0,0,a,b]);
+
+ gx = hextodec ("00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66")
+ gy = hextodec ("011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650")
+ g = Mod(1,p)*[gx,gy]
+
+ n = hextodec ("01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409")
+
+ /* Verify that G is on the curve, and that n is the order. */
+ ellisoncurve (e,g)
+ isprime (n)
+ ellpow (e,g,n)
+
+ d = hextodec ("018F9573F25059571BDF614529953DE2540497CEDABD04F3AF78813BED7BB163A2FD919EECF822848FCA39EF55E500F8CE861C7D53D371857F7774B79428E887F81B")
+
+ qx = hextodec ("00316AAAD3E905875938F588BD9E8A4785EF9BDB76D62A83A5340F82CB8E800B25619F5C3EA02B7A4FA43D7497C7702F7DFBEAC8E8F92C3CAABD9F84182FDA391B3B")
+ /* Note: WRONG! (It is apparent that this is the same as X shifted by
+ 8 bit). */
+ qy = hextodec ("0000316AAAD3E905875938F588BD9E8A4785EF9BDB76D62A83A5340F82CB8E800B25619F5C3EA02B7A4FA43D7497C7702F7DFBEAC8E8F92C3CAABD9F84182FDA391B")
+ q = Mod(1,p)*[qx,qy]
+
+ /* Calculate what Q should be given d. */
+ ellpow (e,g,d)
+
+ /* This is not 0 and thus shows that libgcrypt gave Q and d that do
+ not match. */
+ ellpow (e,g,d) - q
+ ====8<=====================
+
Modified: trunk/doc/Makefile.am
===================================================================
--- trunk/doc/Makefile.am 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/doc/Makefile.am 2007-04-30 14:09:33 UTC (rev 1238)
@@ -17,6 +17,8 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+EXTRA_DIST = README.apichanges HACKING
+
DISTCLEANFILES = gcrypt.cps
info_TEXINFOS = gcrypt.texi
Copied: trunk/doc/Notes-wk (from rev 1237, trunk/Notes-wk)
Copied: trunk/doc/README.apichanges (from rev 1237, trunk/README.apichanges)
===================================================================
--- trunk/README.apichanges 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/doc/README.apichanges 2007-04-30 14:09:33 UTC (rev 1238)
@@ -0,0 +1,115 @@
+README.apichanges 2003-07-28
+
+ NOTE: THESE ARE API CHANGES DONE BEFORE THE FIRST STABLE RELEASE SO
+ THEY ARE NOT RELEVANT ANYMORE [stable is 1.2.4 right now]
+
+We decided to change a couple of annoying things in Libgcrypt and to
+cleanup the API. The new API better fits into a multi-threaded
+environment and is more consistent. One import change is that all
+functions return error codes from a set of error codes shared between
+GnuPG, GPGME and Libgcrypt.
+
+This file contains some hints on how to port your application from
+libgcrypt <= 1.1.12 to the current API as of 1.1.42. We hope that
+there won't be another need for such a major change.
+
+
+* Types
+
+ All types definitions changed to a foo_t scheme; for some time we
+ will support the old names but you better start to rename them:
+
+ s/GCRY_MPI/gcry_mpi_t/
+ s/GcryMPI/gcry_mpi_t/
+ s/GCRY_SEXP/gcry_sexp_t/
+ s/GcrySexp/gcry_sexp_t/
+ s/GCRY_CIPHER_HD/gcry_cipher_hd_t/
+ s/GcryCipherHd/gcry_cipher_hd_t/
+ s/GCRY_MD_HD/gcry_md_hd_t/
+ s/GcryMDHd/gcry_md_hd_t/
+
+* Initialization
+
+ For proper initialization of the library, you must call
+ gcry_check_version() before calling any other function except for
+ these gcry_control operations:
+ GCRYCTL_SUSPEND_SECMEM_WARN
+ GCRYCTL_DISABLE_INTERNAL_LOCKING
+ GCRYCTL_ANY_INITIALIZATION_P
+ GCRYCTL_INITIALIZATION_FINISHED_P
+
+
+* Handles
+
+ gcry_cipher_open and gcry_md_open do now return an error code
+ instead of a NULL handle; the handle is now returned by
+ asigning it to the first argument. Example on how to change your
+ code:
+
+ Old:
+
+ hd = gcry_md_open (algo, flags);
+ if (!hd)
+ {
+ fprintf (stderr, "md_open failed: %s\n", gcry_errno (-1));
+ ....
+
+ New:
+
+ rc = gcry_md_open (&hd, algo, flags);
+ if (rc)
+ {
+ fprintf (stderr, "md_open failed: %s\n", gcry_strerror (rc));
+ ....
+
+ If you are not interested in the error code, you can do it in a
+ simplified way:
+
+ gcry_md_open (&hd, algo, flags);
+ if (!hd)
+ abort ();
+
+ i.e. the function makes sure that HD points to NULL in case of an error.
+ The required change for gcry_cipher_open is similar.
+
+* Message Digests
+
+ The order of the arguments to gcry_md_copy has been changed in order
+ to be more consistent with other functions of this type. This means
+ that the new message digest handle will be a copy of the message
+ handle specified by the second argument and stored at the address
+ pointed to by the first argument.
+
+* Error codes
+
+ gcry_errno () has been removed because it is hard to use in
+ multi-threaded environment. You need to save the error code
+ returned by the functions and use it either numerical or passing it
+ to gcry_strerror (since gcry_strerror is a wrapper function for
+ gpg_strerror, the latter function can also be used).
+
+ Instead of using the error codes GCRYERR_*, you have to use the
+ GPG_ERR_* names.
+
+* S-expressions
+
+ gcry_sexp_canon_len used to return a `historical' error code in
+ `errcode', this is not the case anymore; the value returned in
+ `errcode' is now a standard Libgcrypt (i.e. gpg-error) error code.
+
+* MPI
+
+ gcry_mpi_scan and gcry_mpi_print need the size of a provided buffer
+ as input and return the number of bytes actually scanned/printed to
+ the user. The old API used a single size_t Pointer for both tasks,
+ the new API distinguishes between the input and the output values.
+
+* Public Key cryptography
+
+ gcry_pk_decrypt used to return a `simple S-expression part' that
+ contains a single MPI value. In case the `data' S-expression
+ contains a `flags' element, the result S-expression is filled with a
+ complete S-expression of the following format:
+
+ (value PLAINTEXT)
+
Modified: trunk/doc/gcrypt.texi
===================================================================
--- trunk/doc/gcrypt.texi 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/doc/gcrypt.texi 2007-04-30 14:09:33 UTC (rev 1238)
@@ -535,6 +535,11 @@
This command dumps secure memory manamgent related statistics to the
librarys logging stream.
+ at item GCRYCTL_DUMP_CONFIG
+This command dumps information pertaining to the configuration of
+libgcrypt to the logging stream. It may be used before the
+intialization has been finished but not before a gcry_version_check.
+
@item GCRYCTL_DROP_PRIVS
This command disables the use of secure memory and drops the priviliges
of the current process. FIXME.
Modified: trunk/mpi/ChangeLog
===================================================================
--- trunk/mpi/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/mpi/ChangeLog 2007-04-30 14:09:33 UTC (rev 1238)
@@ -1,3 +1,9 @@
+2007-04-30 Werner Koch <wk at g10code.com>
+
+ * config.links: Create a file mod-source-info.h.
+ * Makefile.am (DISTCLEANFILES): Add that file.
+ * mpiutil.c (_gcry_mpi_get_hw_config): New.
+
2007-04-28 Marcus Brinkmann <marcus at g10code.de>
* config.links: Add additional assembler search directories.
Modified: trunk/mpi/Makefile.am
===================================================================
--- trunk/mpi/Makefile.am 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/mpi/Makefile.am 2007-04-30 14:09:33 UTC (rev 1238)
@@ -38,7 +38,8 @@
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 sysdep.h
+ mpih-lshift.S mpih-rshift.S mpih-sub1.S asm-syntax.h \
+ sysdep.h mod-source-info.h
# Note: we only use .S files so we should delete all left over .s
CLEANFILES = _*.s __*.s
Modified: trunk/mpi/config.links
===================================================================
--- trunk/mpi/config.links 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/mpi/config.links 2007-04-30 14:09:33 UTC (rev 1238)
@@ -318,11 +318,14 @@
done
fi
-# try to get file to link from the assembler subdirectory and
+# Try to get file to link from the assembler subdirectory and
# if this fails get it from the generic subdirectory.
mpi_ln_list=
mpi_mod_list=
path="$mpi_extra_path $path generic"
+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
for fn in $mpi_required_modules ; do
fnu=`echo $fn | sed 's/-/_/g'`
eval mpi_mod_c_${fnu}=no
@@ -330,11 +333,13 @@
for dir in $path ; do
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"
eval mpi_mod_asm_${fnu}=yes
mpi_mod_list="$mpi_mod_list $fn"
break;
elif test -f $srcdir/mpi/$dir/$fn.c ; then
+ echo " \":$dir/$fn.c\"" >>./mpi/mod-source-info.h
mpi_ln_list="$mpi_ln_list mpi/$fn.c:mpi/$dir/$fn.c"
eval mpi_mod_c_${fnu}=yes
mpi_mod_list="$mpi_mod_list $fn"
@@ -342,6 +347,7 @@
fi
done
done
+echo " ;" >>./mpi/mod-source-info.h
# Same thing for the file which defines the limb size
path="$path generic"
Modified: trunk/mpi/mpiutil.c
===================================================================
--- trunk/mpi/mpiutil.c 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/mpi/mpiutil.c 2007-04-30 14:09:33 UTC (rev 1238)
@@ -27,7 +27,16 @@
#include "g10lib.h"
#include "mpi-internal.h"
#include "memory.h"
+#include "mod-source-info.h"
+
+const char *
+_gcry_mpi_get_hw_config (void)
+{
+ return mod_source_info + 1;
+}
+
+
/****************
* Note: It was a bad idea to use the number of limbs to allocate
* because on a alpha the limbs are large but we normally need
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/src/ChangeLog 2007-04-30 14:09:33 UTC (rev 1238)
@@ -1,3 +1,9 @@
+2007-04-30 Werner Koch <wk at g10code.com>
+
+ * global.c (gcry_control): New.
+
+ * gcrypt.h.in (GCRYCTL_DUMP_CONFIG): New.
+
2007-04-18 Werner Koch <wk at g10code.com>
* gcrypt.h.in (gcry_sexp_nth_string): New.
Modified: trunk/src/g10lib.h
===================================================================
--- trunk/src/g10lib.h 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/src/g10lib.h 2007-04-30 14:09:33 UTC (rev 1238)
@@ -105,7 +105,10 @@
+/*-- mpi/mpiutil.c --*/
+const char *_gcry_mpi_get_hw_config (void);
+
/*-- cipher/pubkey.c --*/
/* FIXME: shouldn't this go into mpi.h? */
Modified: trunk/src/gcrypt.h.in
===================================================================
--- trunk/src/gcrypt.h.in 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/src/gcrypt.h.in 2007-04-30 14:09:33 UTC (rev 1238)
@@ -355,7 +355,8 @@
GCRYCTL_FAST_POLL = 48,
GCRYCTL_SET_RANDOM_DAEMON_SOCKET = 49,
GCRYCTL_USE_RANDOM_DAEMON = 50,
- GCRYCTL_FAKED_RANDOM_P = 51
+ GCRYCTL_FAKED_RANDOM_P = 51,
+ GCRYCTL_DUMP_CONFIG = 52
};
/* Perform various operations defined by CMD. */
Modified: trunk/src/global.c
===================================================================
--- trunk/src/global.c 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/src/global.c 2007-04-30 14:09:33 UTC (rev 1238)
@@ -354,6 +354,15 @@
_gcry_use_random_daemon (!! va_arg (arg_ptr, int));
break;
+ /* This command dumps information pertaining to the
+ configuration of libgcrypt to the logging stream. It may be
+ used before the intialization has been finished but not
+ before a gcry_version_check. */
+ case GCRYCTL_DUMP_CONFIG:
+ log_info ("version=%s\n", VERSION);
+ log_info ("mpi-asm=%s\n", _gcry_mpi_get_hw_config ());
+ break;
+
default:
err = GPG_ERR_INV_OP;
}
Modified: trunk/tests/ChangeLog
===================================================================
--- trunk/tests/ChangeLog 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/tests/ChangeLog 2007-04-30 14:09:33 UTC (rev 1238)
@@ -1,3 +1,8 @@
+2007-04-30 Werner Koch <wk at g10code.com>
+
+ * version.c: New.
+ * Makefile.am (TESTS): Add version.
+
2007-04-30 Marcus Brinkmann <marcus at g10code.de>
* benchmark.c (ecc_bench): Release KEY_SPEC.
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/tests/Makefile.am 2007-04-30 14:09:33 UTC (rev 1238)
@@ -18,7 +18,7 @@
## Process this file with automake to produce Makefile.in
-TESTS = t-mpi-bit prime register ac ac-schemes ac-data basic \
+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.
Added: trunk/tests/version.c
===================================================================
--- trunk/tests/version.c 2007-04-29 23:49:56 UTC (rev 1237)
+++ trunk/tests/version.c 2007-04-30 14:09:33 UTC (rev 1238)
@@ -0,0 +1,58 @@
+/* version.c - This version test should be run first.
+ 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 Lesser 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. */
+
+/* This test should be run first because due to a failing config.links
+ script or bad configure parameters the just build libgcrypt may
+ crash in case MPI function for specific CPU revisions have been
+ enabled. Running this test first will print out information so to
+ make it easier to figure out the problem. */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "../src/gcrypt.h"
+
+#define PGM "version"
+
+
+int
+main (int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+
+ gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
+ if (!gcry_check_version (GCRYPT_VERSION))
+ {
+ fprintf (stderr, PGM ": version mismatch\n");
+ exit (1);
+ }
+
+ gcry_control (GCRYCTL_DUMP_CONFIG, 0);
+
+ return 0;
+}
+
More information about the Gnupg-commits
mailing list