From 4f048514ecae879fa4bb7b8522baf801229be522 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 4 Feb 2011 20:21:45 +0100 Subject: Nuked almost all trailing whitespace. Check and install the standard git pre-commit hook. --- AUTHORS | 4 +- ChangeLog | 75 +- Makefile.am | 11 +- NEWS | 24 +- README | 31 +- autogen.sh | 50 +- cipher/Makefile.am | 2 +- cipher/ac.c | 62 +- cipher/arcfour.c | 15 +- cipher/blowfish.c | 8 +- cipher/camellia-glue.c | 8 +- cipher/camellia.c | 26 +- cipher/camellia.h | 16 +- cipher/cast5.c | 2 +- cipher/cipher.c | 152 ++-- cipher/des.c | 22 +- cipher/dsa.c | 77 +- cipher/elgamal.c | 39 +- cipher/hash-common.c | 17 +- cipher/hash-common.h | 6 +- cipher/hmac-tests.c | 36 +- cipher/md.c | 54 +- cipher/md4.c | 9 +- cipher/md5.c | 14 +- cipher/primegen.c | 187 +++-- cipher/rfc2268.c | 31 +- cipher/rijndael-tables.h | 1817 +++++++++++++++++++++++----------------------- cipher/rijndael.c | 174 ++--- cipher/rmd.h | 3 +- cipher/rmd160.c | 4 +- cipher/rsa.c | 119 ++- cipher/seed.c | 6 +- cipher/serpent.c | 4 +- cipher/sha1.c | 23 +- cipher/sha256.c | 52 +- cipher/sha512.c | 34 +- cipher/test-getrusage.c | 16 +- cipher/tiger.c | 6 +- cipher/twofish.c | 10 +- cipher/whirlpool.c | 4 +- compat/Makefile.am | 8 +- compat/clock.c | 4 +- compat/compat.c | 3 +- compat/getpid.c | 2 +- doc/ChangeLog | 8 +- doc/HACKING | 19 +- doc/Makefile.am | 5 +- doc/gcrypt.texi | 182 +++-- doc/gpl.texi | 4 +- m4/ChangeLog | 3 +- mpi/ChangeLog | 10 +- mpi/Makefile.am | 18 +- mpi/config.links | 3 +- mpi/ec.c | 83 ++- mpi/mpi-add.c | 1 - mpi/mpi-bit.c | 13 +- mpi/mpi-div.c | 3 - mpi/mpi-gcd.c | 3 - mpi/mpi-inline.c | 1 - mpi/mpi-internal.h | 1 - mpi/mpi-mod.c | 15 +- mpi/mpi-mpow.c | 1 - mpi/mpi-mul.c | 3 +- mpi/mpi-pow.c | 51 +- mpi/mpi-scan.c | 2 - mpi/mpicoder.c | 67 +- mpi/mpih-div.c | 2 - mpi/mpih-mul.c | 2 - mpi/mpiutil.c | 19 +- random/ChangeLog | 5 +- random/Makefile.am | 4 +- random/rand-internal.h | 10 +- random/random-csprng.c | 100 +-- random/random-daemon.c | 16 +- random/random-fips.c | 70 +- random/random.c | 8 +- random/random.h | 8 +- random/rndegd.c | 14 +- random/rndhw.c | 12 +- random/rndlinux.c | 16 +- random/rndunix.c | 24 +- random/rndw32.c | 62 +- random/rndw32ce.c | 8 +- src/ChangeLog | 86 +-- src/Makefile.am | 7 +- src/ath.c | 13 +- src/ath.h | 10 +- src/cipher-proto.h | 6 +- src/cipher.h | 16 +- src/dumpsexp.c | 59 +- src/fips.c | 66 +- src/g10lib.h | 20 +- src/gcrypt-module.h | 12 +- src/gcrypt.h.in | 62 +- src/gcryptrnd.c | 39 +- src/getrandom.c | 25 +- src/global.c | 74 +- src/hmac256.c | 62 +- src/hwfeatures.c | 24 +- src/libgcrypt.def | 26 +- src/libgcrypt.m4 | 4 +- src/libgcrypt.vers | 23 +- src/misc.c | 14 +- src/missing-string.c | 3 +- src/module.c | 4 +- src/mpi.h | 18 +- src/secmem.c | 14 +- src/sexp.c | 136 ++-- src/stdmem.c | 28 +- src/versioninfo.rc.in | 5 +- src/visibility.c | 56 +- src/visibility.h | 392 +++++----- tests/ChangeLog | 20 +- tests/ac-data.c | 6 +- tests/ac-schemes.c | 14 +- tests/ac.c | 4 +- tests/aeswrap.c | 14 +- tests/basic.c | 102 +-- tests/benchmark.c | 29 +- tests/cavs_driver.pl | 44 +- tests/cavs_tests.sh | 10 +- tests/fips186-dsa.c | 14 +- tests/fipsdrv.c | 173 +++-- tests/fipsrngdrv.c | 19 +- tests/keygen.c | 19 +- tests/keygrip.c | 16 +- tests/mpitests.c | 31 +- tests/pkbench.c | 18 +- tests/prime.c | 2 +- tests/pubkey.c | 64 +- tests/random.c | 18 +- tests/register.c | 4 +- tests/rsacvt.c | 31 +- tests/t-mpi-bit.c | 14 +- tests/tsexp.c | 40 +- tests/version.c | 11 +- 136 files changed, 3052 insertions(+), 3112 deletions(-) diff --git a/AUTHORS b/AUTHORS index 571dcb1d..3ef65582 100644 --- a/AUTHORS +++ b/AUTHORS @@ -81,7 +81,7 @@ Assigns Past and Future Changes perky@freebsd.org (SEED cipher) -LIBGCRYPT Werner Dittmann 2009-05-20 +LIBGCRYPT Werner Dittmann 2009-05-20 Assigns Past and Future Changes werner.dittmann@t-online.de (mpi/amd64, tests/mpitests.c) @@ -132,5 +132,3 @@ security corporation. See the file for details. 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. - - diff --git a/ChangeLog b/ChangeLog index dc19f234..03461e46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-02-04 Werner Koch + + * autogen.sh: Install the git pre-commit if not yet done. + 2010-12-23 Werner Koch * configure.ac (BUILD_REVISION): Use git_revision. @@ -120,7 +124,7 @@ 2008-08-19 Werner Koch Release 1.4.2rc1. - + * configure.ac: Bump LT version to C16/A5/R0. 2008-08-18 Werner Koch @@ -140,7 +144,7 @@ 2008-04-25 Werner Koch Release 1.4.1. - + * configure.ac: Bump LT version to C15/A4/R4. 2008-04-22 Werner Koch @@ -178,7 +182,7 @@ 2007-12-10 Werner Koch Released 1.4.0. - + * configure.ac: Set LT to C15/A4/R3. 2007-12-05 Werner Koch @@ -218,7 +222,7 @@ in the test program which lurked there for 4 years. Adjusted name of libtools global_system_pipe variable and add extra cut stage. Reported by Gregor Riepl. - + 2007-06-15 Werner Koch * autogen.sh (FORCE): Use = and not == in test to be POSIXly correct. @@ -255,7 +259,7 @@ Released 1.3.0. * configure.ac: Set LT to C15/A4/R0. - + * configure.ac: Require automake 1.10 (AM_PROG_CC_C_O): New. @@ -265,7 +269,7 @@ 2007-05-02 Werner Koch - * configure.ac (LIBGCRYPT_DIGESTS, LIBGCRYPT_CIPHERS) + * configure.ac (LIBGCRYPT_DIGESTS, LIBGCRYPT_CIPHERS) (LIBGCRYPT_PUBKEY_CIPHERS): Ac_define lists of algorithms. (default_ciphers): Don't make camellia a default. @@ -309,7 +313,7 @@ * configure.ac: Bump LT version to C14/A3/R0 in preparation for a release. - + * autogen.sh: Add option --force. * configure.ac: New option --disable-endian-check. Use a real noexecstack test instead of requiring an option. Add SVN version @@ -362,7 +366,7 @@ 2006-07-26 Werner Koch * configure.ac: New options --enable-noexecstack and - --disable-optimization. + --disable-optimization. 2006-07-04 Marcus Brinkmann @@ -404,7 +408,7 @@ * configure.ac: Move detection of basic stuff to the top. For example we need to know whether gcc is used before testing for it. Reported by Ralf Fassel. - + 2005-04-23 Moritz Schulte * acinclude.m4 (TYPE_SOCKLEN_T): New type definition test; @@ -426,8 +430,8 @@ 2005-01-04 Werner Koch Updated to automake 1.9. - - * acinclude.m4: Updated for use with automake 1.9. + + * acinclude.m4: Updated for use with automake 1.9. * configure.ac: Require libgpg-error 1.0; not really needed but that is the first stable version. @@ -462,7 +466,7 @@ 2004-04-15 Werner Koch Released 1.2.0. - + * configure.ac: Set LT to C12/A1/R1. 2004-04-06 Werner Koch @@ -487,7 +491,7 @@ Released 1.1.93. - * configure.ac (LIBGCRYPT_CONFIG_SONAME_NUMBER): Replaced by + * configure.ac (LIBGCRYPT_CONFIG_SONAME_NUMBER): Replaced by LIBGCRYPT_CONPIG_API_VERSION. Set it to 1. Set LT to C11/A0/R1. 2004-03-05 Werner Koch @@ -497,7 +501,7 @@ 2004-02-20 Werner Koch Released 1.1.92. - + * configure.ac: Set LT to C11/A0/R0. 2004-02-11 Werner Koch @@ -515,7 +519,7 @@ 2003-12-19 Werner Koch Released 1.1.91. - + * configure.ac: Bumbed LT version to C10/A3/R1. 2003-12-08 Werner Koch @@ -533,9 +537,9 @@ 2003-11-14 Werner Koch Released 1.1.90. - + * configure.ac: Bumbed LT version to C10/A3/R0. - + * configure.ac (have_ld_version_script): Set the default in a separate test. (PRINTABLE_OS_NAME): Don't handle the Hurd extra, this leads to @@ -553,7 +557,7 @@ development Released 1.1.44. - + * acinclude.m4 (AC_CHECK_PTH): Added. * configure.ac: Use it here instead of the generic lib test. Bumbed LT vesion to C9/A2/R0. @@ -596,7 +600,7 @@ 2003-07-31 Werner Koch Released 1.1.42. - + * configure.ac: Set LT version to 7/0/0. 2003-07-30 Werner Koch @@ -620,7 +624,7 @@ 2003-07-05 Moritz Schulte * README: Few changes, mention libgpg-error. - + 2003-06-18 Moritz Schulte * configure.ac (available_ciphers): Removed Serpent, hrrm. @@ -633,7 +637,7 @@ GNUPG_SYS_SYMBOL_UNDERSCORE, GNUPG_FUNC_MKDIR_TAKES_ONE_ARG, GPH_PROG_DB2ANY. Added macro definitions: AM_PATH_GPG_ERROR. - + * configure.ac: Use alternative approach for building based on conditional sources, which does not make automake eat all your memory, etc. @@ -708,7 +712,7 @@ * configure.ac: Removed code for generating contruct.c. Remove digest modules from the static_modules list, only handle random module selection. - + 2003-03-24 Moritz Schulte @@ -725,7 +729,7 @@ 2003-01-21 Werner Koch - * README (Configure options): New. + * README (Configure options): New. * configure.ac (have_ld_version_script): New option --enable-ld-version-script. @@ -736,13 +740,13 @@ 2003-01-20 Werner Koch Released 1.1.12. - + * configure.ac (LIBGCRYPT_LT_REVISION): Bumbed up. 2002-12-21 Werner Koch Released 1.1.11. - + * configure.ac (LIBGCRYPT_LT_CURRENT: Bumbed to 6/5/0 due to a new interface @@ -767,7 +771,7 @@ 2002-09-18 Timo Schulz * configure.ac: Added makefile for the W32 DLL. - + 2002-09-17 Werner Koch * configure.ac: Check for Pth and Pthreads. @@ -775,7 +779,7 @@ 2002-08-23 Werner Koch Released 1.1.9. - + * configure.ac (LIBGCRYPT_CONFIG_CFLAGS): Renamed from LIBGCRYPT_CFLAGS and removed the libpath because it is set by the config script. @@ -784,13 +788,13 @@ 2002-06-25 Werner Koch Released 1.1.8. - - * configure.ac: Set LT version to 5/4/0. + + * configure.ac: Set LT version to 5/4/0. 2002-05-21 Werner Koch Released 1.1.7. - + * configure.ac: Set LT version to 4/3/0. 2002-05-17 Werner Koch @@ -816,7 +820,7 @@ * configure.ac (jnlib/Makefile): Removed. * configure.ac: Define _REENTRANT. - + 2002-02-18 Werner Koch * configure.ac (MPI_EXTRA_ASM_OBJS): Use .lo suffix. @@ -824,7 +828,7 @@ 2002-02-07 Werner Koch - Released 1.1.6. + Released 1.1.6. 2002-01-24 Werner Koch @@ -853,7 +857,7 @@ Released 1.1.4. * acinclude.m4 (GNUPG_CHECK_TYPEDEF): Define GNU Source. - + Migrated to autoconf 2.52. * acinclude.m4: Removed GNUPG_LINK_FILES and converted. * acconfig.h: Removed @@ -864,7 +868,7 @@ * tests/: New. * Makefile.am: Included tests directory - + * configure.in (DYNLINK_MOD_CFLAGS): Use -shared with dec-osf. Reported by Chris Adams. Merged some cases. @@ -1414,7 +1418,7 @@ Fri Feb 13 19:43:41 1998 Werner Koch (wk@isil.d.shuttle.de) * configure.in : Fixed zlib stuff * Makefile.am: Likewise - + Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. @@ -1425,4 +1429,3 @@ Fri Feb 13 19:43:41 1998 Werner Koch (wk@isil.d.shuttle.de) 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. - diff --git a/Makefile.am b/Makefile.am index 2e0224c4..fbb5744b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,12 +25,12 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-random-daemon \ DIST_SUBDIRS = m4 compat mpi cipher random src doc tests SUBDIRS = compat mpi cipher random src doc tests EXTRA_DIST = autogen.sh README.SVN -DISTCLEANFILES = +DISTCLEANFILES = # Add all the files listed in "distfiles" files to the distribution, # apply version number s to some files and create a VERSION file which -# we need for the Prereq: patch file trick. +# we need for the Prereq: patch file trick. dist-hook: @set -e; \ for file in `cd $(top_srcdir); \ @@ -44,10 +44,5 @@ dist-hook: @set -e; \ echo "$(VERSION)" > $(distdir)/VERSION -stowinstall: +stowinstall: $(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/libgcrypt - - - - - diff --git a/NEWS b/NEWS index 374c31e9..7dbb54ad 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ Noteworthy changes in version 1.5.x (unreleased) ------------------------------------------------ - * New variants of the TIGER algorithm. + * New variants of the TIGER algorithm. * New cipher algorithm mode for AES-WRAP. @@ -16,7 +16,7 @@ Noteworthy changes in version 1.5.x (unreleased) * Boosted SHA-512 performance by 30% on ia32 boxes and gcc 4.3; SHA-256 went up by 25%. - * Support for WindowsCE. + * Support for WindowsCE. * Support ECDH. @@ -41,7 +41,7 @@ Noteworthy changes in version 1.4.4 (2009-01-22) ------------------------------------------------ * Publish GCRY_MODULE_ID_USER and GCRY_MODULE_ID_USER_LAST constants. - This functionality has been in Libgcrypt since 1.3.0. + This functionality has been in Libgcrypt since 1.3.0. * MD5 may now be used in non-enforced fips mode. @@ -223,7 +223,7 @@ Noteworthy changes in version 1.3.0 (2007-05-04) GCRY_CIPHER_CAMELLIA128 NEW GCRY_CIPHER_CAMELLIA192 NEW GCRY_CIPHER_CAMELLIA256 NEW - GCRYCTL_FAKED_RANDOM_P NEW + GCRYCTL_FAKED_RANDOM_P NEW GCRYCTL_PRINT_CONFIG NEW GCRYCTL_SET_RNDEGD_SOCKET NEW. gcry_mpi_scan CHANGED: Argument BUFFER is now void*. @@ -317,7 +317,7 @@ Noteworthy changes in version 1.1.90 (2003-11-14) * gcry_sexp_build now supports a "%b" format to include a memory buffer. * Minor configuration fixes. - + * Interface changes relative to the 1.1.44 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_create_nonce NEW @@ -360,7 +360,7 @@ Noteworthy changes in version 1.1.42 (2003-07-31) However, this is only for ease of transition. NO DEPRECATED FUNCTION OR DATA TYPE IS CONSIDERED A PART OF THE API OR ABI AND WILL BE DROPPED IN THE FUTURE WITHOUT CHANGING THE SONAME OF THE - LIBRARY. + LIBRARY. * If gcrypt.h is included in sources compiled by GCC 3.1 or later, deprecated attributes will warn about use of obsolete functions and @@ -384,7 +384,7 @@ Noteworthy changes in version 1.1.42 (2003-07-31) gcry_err_make_from_errno, gcry_err_code_from_errno, gcry_err_code_to_errno, gcry_strsource. - * New function gcry_mpi_dump to help in debugging. + * New function gcry_mpi_dump to help in debugging. * Added alternative interface for asymmetric cryptography. @@ -403,7 +403,7 @@ Noteworthy changes in version 1.1.42 (2003-07-31) * CTR mode for block ciphers is now supported. - * The public RSA exponent can now be specified in key generation. + * The public RSA exponent can now be specified in key generation. * RSA blinding is now supported and is used automatically for RSA decryption. It can be explicitely disabled by using the @@ -569,8 +569,8 @@ Noteworthy changes in version 1.1.7 (2002-05-21) ------------------------------------------------ * Libgcrypt is now distributed under the terms of the GNU Lesser - General Public License; see the README file for details. - + General Public License; see the README file for details. + * It is possible to use libgcrypt w/o intialized secure memory. * Libgcrypt should now be thread safe after the initialization. @@ -594,7 +594,7 @@ Noteworthy changes in version 1.1.6 (2002-02-07) ------------------------------------------------ * Enhanced the S-expression conversion functions. - + Noteworthy changes in version 1.1.5 (2001-12-18) ------------------------------------------------ @@ -608,7 +608,7 @@ Noteworthy changes in version 1.1.5 (2001-12-18) Noteworthy changes in version 1.1.4 (2001-08-03) ------------------------------------------------ - * Arcfour does now work. + * Arcfour does now work. * Some minor fixes. diff --git a/README b/README index fc534b0e..514464ab 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Libgcrypt - The GNU Crypto Library ------------------------------------ Version 1.5.x - + WARNING: THIS VERSION OF LIBGCRYPT IS UNDER DEVELOPMENT. THE STABLE VERSION IS THE 1.4. @@ -34,7 +34,7 @@ The download canonical location for libgcrypt is: ftp://ftp.gnupg.org/gcrypt/libgcrypt/ - + To build libgcrypt you need libgpg-error: ftp://ftp.gnupg.org/gcrypt/libgpg-error/ @@ -62,7 +62,7 @@ ./autogen.sh --build-w32 make make install - + By default this command sequences expectsd a libgpg-error installed below $HOME/w32root and installs libgcrypt to that directory too. See the autogen.sh code for details. @@ -73,7 +73,7 @@ cd doc make pdf - + Mailing List ------------ @@ -84,9 +84,9 @@ list is available at http://lists.gnupg.org . - Configure options + Configure options ----------------- - Here is a list of configure options which are sometimes useful + Here is a list of configure options which are sometimes useful for installation. --enable-m-guard @@ -96,9 +96,9 @@ you a bus error. --disable-asm - Do not use assembler modules. It is not possible + Do not use assembler modules. It is not possible to use this on some CPU types. - + --enable-ld-version-script Libgcrypt tries to build a library where internal symbols are not exported. This requires support @@ -110,7 +110,7 @@ option to disable the use of version scripts. Note, that you should never ever use an undocumented symbol or one which is prefixed with - an underscore. + an underscore. --enable-ciphers=list --enable-pubkey-ciphers=list @@ -144,7 +144,7 @@ Take care: The generated library may crash on non-compatible CPUs. - --enable-random=NAME + --enable-random=NAME Force the use of the random gathering module NAME. Default is either to use /dev/random or the auto mode. Possible values for NAME are: @@ -156,9 +156,9 @@ linux - Use the module which accesses /dev/random. This is the first choice and the default one for GNU/Linux or *BSD. - auto - Compile linux, egd and unix in and + auto - Compile linux, egd and unix in and automagically select at runtime. - + --enable-hmac-binary-check Include support to check the binary at runtime against a HMAC checksum. This works only in FIPS @@ -180,7 +180,7 @@ the feature under the assumption that either good CFLAGS are given or the compiler can grok the code. - + Build Problems @@ -218,7 +218,7 @@ CFLAGS="-O -K pentium" ./configure --disable-asm * SunOS 4.1.4 - + ./configure ac_cv_sys_symbol_underscore=yes * Sparc64 CPUs @@ -230,7 +230,7 @@ License ------- - + The library is distributed under the terms of the GNU Lesser General Public License (LGPL); see the file COPYING.LIB for the actual terms. The helper programs (e.g. gcryptrnd and getrandom) @@ -270,4 +270,3 @@ 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. - diff --git a/autogen.sh b/autogen.sh index b31f144e..d9a65869 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Run this to generate all the initial makefiles, etc. +# Run this to generate all the initial makefiles, etc. # # Copyright (C) 2003 g10 Code GmbH # @@ -43,7 +43,7 @@ w32ce_toolprefixes= w32ce_extraoptions= amd64_toolprefixes= # End list of optional variables sourced from ~/.gnupg-autogen.rc -# What follows are variables which are sourced but default to +# What follows are variables which are sourced but default to # environment variables or lacking them hardcoded values. #w32root= #w32ce_root= @@ -55,7 +55,7 @@ if [ -f "$HOME/.gnupg-autogen.rc" ]; then fi # Convenience option to use certain configure options for some hosts. -myhost="" +myhost="" myhostsub="" case "$1" in --build-w32) @@ -101,7 +101,7 @@ if [ "$myhost" = "w32" ]; then ;; esac echo "Using $w32root as standard install directory" >&2 - + # Locate the cross compiler crossbindir= for host in $toolprefixes; do @@ -113,14 +113,14 @@ if [ "$myhost" = "w32" ]; then done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 - if [ -z "$sub" ]; then + if [ -z "$sub" ]; then echo "Under Debian GNU/Linux, you may install it using" >&2 - echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 fi echo "Stop." >&2 exit 1 fi - + if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then echo "Pease run a 'make distclean' first" >&2 @@ -150,7 +150,7 @@ if [ "$myhost" = "amd64" ]; then [ -z "$amd64root" ] && amd64root="$HOME/amd64root" echo "Using $amd64root as standard install directory" >&2 - + # Locate the cross compiler crossbindir= for host in x86_64-linux-gnu amd64-linux-gnu; do @@ -165,7 +165,7 @@ if [ "$myhost" = "amd64" ]; then echo "Stop." >&2 exit 1 fi - + if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then echo "Please run a 'make distclean' first" >&2 @@ -175,27 +175,27 @@ if [ "$myhost" = "amd64" ]; then $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${amd64root} - + --with-gpg-error-prefix=${amd64root} + rc=$? exit $rc fi # ***** end AMD64 cross build script ******* # Grep the required versions from configure.ac -autoconf_vers=`sed -n '/^AC_PREREQ(/ { +autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p q }' ${configure_ac}` autoconf_vers_num=`echo "$autoconf_vers" | cvtver` -automake_vers=`sed -n '/^min_automake_version=/ { +automake_vers=`sed -n '/^min_automake_version=/ { s/^.*="\(.*\)"/\1/p q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` -#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { +#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { #s/^.*(\(.*\))/\1/p #q #}' ${configure_ac}` @@ -232,13 +232,29 @@ fi if test "$DIE" = "yes"; then cat <&2 +*** Activating trailing whitespace git pre-commit hook. *** + For more information see this thread: + http://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084html + To deactivate this pre-commit hook again move .git/hooks/pre-commit + and .git/hooks/pre-commit.sample out of the way. +EOF + cp -av .git/hooks/pre-commit.sample .git/hooks/pre-commit + chmod -c +x .git/hooks/pre-commit + fi +fi + + echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..." $ACLOCAL -I m4 $ACLOCAL_FLAGS echo "Running autoheader..." @@ -248,6 +264,6 @@ $AUTOMAKE --gnu; echo "Running autoconf${FORCE} ..." $AUTOCONF${FORCE} -echo "You may now run: +echo "You may now run: ./configure --enable-maintainer-mode && make " diff --git a/cipher/Makefile.am b/cipher/Makefile.am index 44704339..cdc6dfc7 100644 --- a/cipher/Makefile.am +++ b/cipher/Makefile.am @@ -23,7 +23,7 @@ EXTRA_DIST = Manifest # Need to include ../src in addition to top_srcdir because gcrypt.h is # a built header. -AM_CPPFLAGS = -I../src -I$(top_srcdir)/src +AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) diff --git a/cipher/ac.c b/cipher/ac.c index 14569cc0..f5e946a2 100644 --- a/cipher/ac.c +++ b/cipher/ac.c @@ -1,19 +1,19 @@ /* ac.c - Alternative interface for asymmetric cryptography. Copyright (C) 2003, 2004, 2005, 2006 2007, 2008 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, see . */ @@ -115,7 +115,7 @@ struct gcry_ac_key_pair -/* +/* * Functions for working with data sets. */ @@ -151,7 +151,7 @@ static void ac_data_values_destroy (gcry_ac_data_t data) { unsigned int i; - + for (i = 0; i < data->data_n; i++) if (data->data[i].flags & GCRY_AC_FLAG_DEALLOC) { @@ -256,7 +256,7 @@ _gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data) err = ac_data_mpi_copy (data->data, data->data_n, &data_mpis); if (err) goto out; - + data_new->data_n = data->data_n; data_new->data = data_mpis; *data_cp = data_new; @@ -524,13 +524,13 @@ _gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp, i++; } identifiers_n = i; - + if (! identifiers_n) /* If there are NO identifiers, we still add surrounding braces so that we have a list of named MPI value lists. Otherwise it wouldn't be too much fun to process these lists. */ sexp_buffer_n += 2; - + data_n = _gcry_ac_data_length (data); for (i = 0; i < data_n; i++) { @@ -666,7 +666,7 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp, /* Identifier matches. Now we have to distinguish two cases: - + (i) we are at the last identifier: leave loop @@ -725,7 +725,7 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp, skip_name = 0; /* Create data set from S-expression data. */ - + err = gcry_ac_data_new (&data_set_new); if (err) goto out; @@ -793,7 +793,7 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp, gcry_sexp_release (sexp_tmp); gcry_mpi_release (mpi); gcry_free (string); - + if (err) gcry_ac_data_destroy (data_set_new); @@ -1005,7 +1005,7 @@ _gcry_ac_io_read (gcry_ac_io_t *ac_io, unsigned int nread, unsigned char *buffer, size_t *buffer_n) { gcry_error_t err; - + gcry_assert (ac_io->mode == GCRY_AC_IO_READABLE); err = 0; @@ -1072,7 +1072,7 @@ _gcry_ac_io_read_all (gcry_ac_io_t *ac_io, unsigned char **buffer, size_t *buffe err = gcry_error_from_errno (errno); break; } - + if (buffer_new != p) buffer_new = p; @@ -1132,7 +1132,7 @@ _gcry_ac_io_process (gcry_ac_io_t *ac_io, -/* +/* * Functions for converting data between the native ac and the * S-expression structure used by the pk interface. */ @@ -1403,7 +1403,7 @@ _gcry_ac_open (gcry_ac_handle_t *handle, err = _gcry_pk_module_lookup (algorithm, &module); if (err) goto out; - + /* Allocate. */ handle_new = gcry_malloc (sizeof (*handle_new)); if (! handle_new) @@ -1420,7 +1420,7 @@ _gcry_ac_open (gcry_ac_handle_t *handle, *handle = handle_new; out: - + /* Deallocate resources. */ if (err) _gcry_pk_module_release (module); @@ -1443,7 +1443,7 @@ _gcry_ac_close (gcry_ac_handle_t handle) -/* +/* * Key management. */ @@ -1662,7 +1662,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits, out: /* Deallocate resources. */ - + gcry_free (genkey_format); gcry_free (arg_list); gcry_sexp_release (genkey_sexp_request); @@ -1682,7 +1682,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits, /* Returns the key of type WHICH out of the key pair KEY_PAIR. */ gcry_ac_key_t -_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair, +_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair, gcry_ac_key_type_t which) { gcry_ac_key_t key; @@ -1851,7 +1851,7 @@ _gcry_ac_key_get_grip (gcry_ac_handle_t handle, -/* +/* * Functions performing cryptographic operations. */ @@ -2176,7 +2176,7 @@ em_randomize_nonzero (unsigned char *buffer, size_t buffer_n, for (i = 0; i < buffer_n; i++) buffer[i] = 0; - + do { /* Count zeros. */ @@ -2384,7 +2384,7 @@ emsa_pkcs_v1_5_encode (unsigned int flags, void *opts, unsigned int i; (void)flags; - + options = opts; buffer = NULL; md = NULL; @@ -2656,7 +2656,7 @@ _gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, size_t *os_n) err = gcry_error_from_errno (errno); goto out; } - + _gcry_ac_mpi_to_os (mpi, buffer, buffer_n); *os = buffer; *os_n = buffer_n; @@ -2676,7 +2676,7 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n) gcry_mpi_t xi; gcry_mpi_t x; gcry_mpi_t a; - + if (fips_mode ()) return; @@ -2692,7 +2692,7 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n) gcry_mpi_add (x, x, xi); gcry_mpi_mul_ui (a, a, 256); } - + gcry_mpi_release (xi); gcry_mpi_release (a); @@ -2702,7 +2702,7 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n) -/* +/* * Implementation of Encryption Schemes (ES) and Signature Schemes * with Appendix (SSA). */ @@ -2824,7 +2824,7 @@ ac_dencode_prepare (gcry_ac_handle_t handle, gcry_ac_key_t key, void *opts, err = gcry_error_from_errno (errno); goto out; } - + err = (*scheme.dencode_prepare) (handle, key, opts, options_em); if (err) goto out; @@ -3065,7 +3065,7 @@ _gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle, goto out; out: - + _gcry_ac_data_destroy (data_encrypted); gcry_mpi_release (mpi_encrypted); gcry_mpi_release (mpi_decrypted); @@ -3270,7 +3270,7 @@ _gcry_ac_data_verify_scheme (gcry_ac_handle_t handle, gcry_mpi_release (mpi_signature); mpi_signature = NULL; - + err = _gcry_ac_data_verify (handle, key, mpi_data, data_signed); out: @@ -3287,7 +3287,7 @@ _gcry_ac_data_verify_scheme (gcry_ac_handle_t handle, } -/* +/* * General functions. */ diff --git a/cipher/arcfour.c b/cipher/arcfour.c index 6bb0555c..6ef07fb2 100644 --- a/cipher/arcfour.c +++ b/cipher/arcfour.c @@ -45,7 +45,7 @@ do_encrypt_stream( ARCFOUR_context *ctx, register int i = ctx->idx_i; register int j = ctx->idx_j; register byte *sbox = ctx->sbox; - register int t; + register int t; while ( length-- ) { @@ -56,7 +56,7 @@ do_encrypt_stream( ARCFOUR_context *ctx, t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t; *outbuf++ = *inbuf++ ^ sbox[(sbox[i] + sbox[j]) & 255]; } - + ctx->idx_i = i; ctx->idx_j = j; } @@ -80,7 +80,7 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen) byte karr[256]; ARCFOUR_context *ctx = (ARCFOUR_context *) context; - if (!initialized ) + if (!initialized ) { initialized = 1; selftest_failed = selftest(); @@ -98,14 +98,14 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen) ctx->sbox[i] = i; for (i=0; i < 256; i++ ) karr[i] = key[i%keylen]; - for (i=j=0; i < 256; i++ ) + for (i=j=0; i < 256; i++ ) { int t; j = (j + ctx->sbox[i] + karr[i]) % 256; t = ctx->sbox[i]; ctx->sbox[i] = ctx->sbox[j]; ctx->sbox[j] = t; - } + } memset( karr, 0, 256 ); return GPG_ERR_NO_ERROR; @@ -125,8 +125,8 @@ static const char* selftest(void) { ARCFOUR_context ctx; - byte scratch[16]; - + byte scratch[16]; + /* Test vector from Cryptlib labeled there: "from the State/Commerce Department". */ static byte key_1[] = @@ -153,4 +153,3 @@ gcry_cipher_spec_t _gcry_cipher_spec_arcfour = "ARCFOUR", NULL, NULL, 1, 128, sizeof (ARCFOUR_context), arcfour_setkey, NULL, NULL, encrypt_stream, encrypt_stream, }; - diff --git a/cipher/blowfish.c b/cipher/blowfish.c index 6ef68e37..b4d2b9c9 100644 --- a/cipher/blowfish.c +++ b/cipher/blowfish.c @@ -501,7 +501,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen) static int initialized; static const char *selftest_failed; - if( !initialized ) + if( !initialized ) { initialized = 1; selftest_failed = selftest(); @@ -513,7 +513,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen) for(i=0; i < BLOWFISH_ROUNDS+2; i++ ) c->p[i] = ps[i]; - for(i=0; i < 256; i++ ) + for(i=0; i < 256; i++ ) { c->s0[i] = ks0[i]; c->s1[i] = ks1[i]; @@ -521,7 +521,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen) c->s3[i] = ks3[i]; } - for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ ) + for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ ) { #ifdef WORDS_BIGENDIAN ((byte*)&data)[0] = key[j]; @@ -545,7 +545,7 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen) c->p[i] = datal; c->p[i+1] = datar; } - for(i=0; i < 256; i += 2 ) + for(i=0; i < 256; i += 2 ) { do_encrypt( c, &datal, &datar ); c->s0[i] = datal; diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c index 067af85b..a2636217 100644 --- a/cipher/camellia-glue.c +++ b/cipher/camellia-glue.c @@ -32,7 +32,7 @@ * space of the library clean. The following macro is thus useful: * * #define CAMELLIA_EXT_SYM_PREFIX foo_ - * + * * This prefixes all external symbols with "foo_". */ #ifdef HAVE_CONFIG_H @@ -50,7 +50,7 @@ #define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128) #define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256) #define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128) -#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192) +#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192) #define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256) #endif /*CAMELLIA_EXT_SYM_PREFIX*/ @@ -99,7 +99,7 @@ camellia_setkey(void *c, const byte *key, unsigned keylen) +(4+32)*sizeof(u32)+2*sizeof(void*) /* camellia_setup192 */ +0+sizeof(int)+2*sizeof(void*) /* Camellia_Ekeygen */ +3*2*sizeof(void*) /* Function calls. */ - ); + ); return 0; } @@ -137,7 +137,7 @@ selftest(void) { CAMELLIA_context ctx; byte scratch[16]; - + /* These test vectors are from RFC-3713 */ const byte plaintext[]= { diff --git a/cipher/camellia.c b/cipher/camellia.c index 79cd49b7..2e28bce2 100644 --- a/cipher/camellia.c +++ b/cipher/camellia.c @@ -19,7 +19,7 @@ */ /* - * Algorithm Specification + * Algorithm Specification * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html */ @@ -937,7 +937,7 @@ void camellia_setup256(const unsigned char *key, u32 *subkey) CamelliaSubkeyR(30) = CamelliaSubkeyL(30) ^ dw, CamelliaSubkeyL(30) = dw; dw = CamelliaSubkeyL(31) ^ CamelliaSubkeyR(31), dw = CAMELLIA_RL8(dw); CamelliaSubkeyR(31) = CamelliaSubkeyL(31) ^ dw,CamelliaSubkeyL(31) = dw; - + return; } @@ -1049,14 +1049,14 @@ void camellia_encrypt128(const u32 *subkey, u32 *io) io[1] = io[3]; io[2] = t0; io[3] = t1; - + return; } void camellia_decrypt128(const u32 *subkey, u32 *io) { u32 il,ir,t0,t1; /* temporary valiables */ - + /* pre whitening but absorb kw2*/ io[0] ^= CamelliaSubkeyL(24); io[1] ^= CamelliaSubkeyR(24); @@ -1267,7 +1267,7 @@ void camellia_decrypt256(const u32 *subkey, u32 *io) /* pre whitening but absorb kw2*/ io[0] ^= CamelliaSubkeyL(32); io[1] ^= CamelliaSubkeyR(32); - + /* main iteration */ CAMELLIA_ROUNDSM(io[0],io[1], CamelliaSubkeyL(31),CamelliaSubkeyR(31), @@ -1379,8 +1379,8 @@ void camellia_decrypt256(const u32 *subkey, u32 *io) * API for compatibility */ -void Camellia_Ekeygen(const int keyBitLength, - const unsigned char *rawKey, +void Camellia_Ekeygen(const int keyBitLength, + const unsigned char *rawKey, KEY_TABLE_TYPE keyTable) { switch(keyBitLength) { @@ -1399,9 +1399,9 @@ void Camellia_Ekeygen(const int keyBitLength, } -void Camellia_EncryptBlock(const int keyBitLength, - const unsigned char *plaintext, - const KEY_TABLE_TYPE keyTable, +void Camellia_EncryptBlock(const int keyBitLength, + const unsigned char *plaintext, + const KEY_TABLE_TYPE keyTable, unsigned char *ciphertext) { u32 tmp[4]; @@ -1430,9 +1430,9 @@ void Camellia_EncryptBlock(const int keyBitLength, PUTU32(ciphertext + 12, tmp[3]); } -void Camellia_DecryptBlock(const int keyBitLength, - const unsigned char *ciphertext, - const KEY_TABLE_TYPE keyTable, +void Camellia_DecryptBlock(const int keyBitLength, + const unsigned char *ciphertext, + const KEY_TABLE_TYPE keyTable, unsigned char *plaintext) { u32 tmp[4]; diff --git a/cipher/camellia.h b/cipher/camellia.h index 4425a3a2..cccf786c 100644 --- a/cipher/camellia.h +++ b/cipher/camellia.h @@ -25,7 +25,7 @@ * space of the library clean. The following macro is thus useful: * * #define CAMELLIA_EXT_SYM_PREFIX foo_ - * + * * This prefixes all external symbols with "foo_". */ #ifdef HAVE_CONFIG_H @@ -43,7 +43,7 @@ #define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128) #define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256) #define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128) -#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192) +#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192) #define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256) #endif /*CAMELLIA_EXT_SYM_PREFIX*/ @@ -60,17 +60,17 @@ typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; void Camellia_Ekeygen(const int keyBitLength, - const unsigned char *rawKey, + const unsigned char *rawKey, KEY_TABLE_TYPE keyTable); void Camellia_EncryptBlock(const int keyBitLength, - const unsigned char *plaintext, - const KEY_TABLE_TYPE keyTable, + const unsigned char *plaintext, + const KEY_TABLE_TYPE keyTable, unsigned char *cipherText); -void Camellia_DecryptBlock(const int keyBitLength, - const unsigned char *cipherText, - const KEY_TABLE_TYPE keyTable, +void Camellia_DecryptBlock(const int keyBitLength, + const unsigned char *cipherText, + const KEY_TABLE_TYPE keyTable, unsigned char *plaintext); diff --git a/cipher/cast5.c b/cipher/cast5.c index 333d55e9..9905f5cb 100644 --- a/cipher/cast5.c +++ b/cipher/cast5.c @@ -569,7 +569,7 @@ do_cast_setkey( CAST5_context *c, const byte *key, unsigned keylen ) u32 z[4]; u32 k[16]; - if( !initialized ) + if( !initialized ) { initialized = 1; selftest_failed = selftest(); diff --git a/cipher/cipher.c b/cipher/cipher.c index 03455e1e..af91b81d 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -58,39 +58,39 @@ static struct cipher_table_entry &dummy_extra_spec, GCRY_CIPHER_BLOWFISH }, #endif #if USE_DES - { &_gcry_cipher_spec_des, + { &_gcry_cipher_spec_des, &dummy_extra_spec, GCRY_CIPHER_DES }, { &_gcry_cipher_spec_tripledes, &_gcry_cipher_extraspec_tripledes, GCRY_CIPHER_3DES, 1 }, #endif #if USE_ARCFOUR - { &_gcry_cipher_spec_arcfour, + { &_gcry_cipher_spec_arcfour, &dummy_extra_spec, GCRY_CIPHER_ARCFOUR }, #endif #if USE_CAST5 - { &_gcry_cipher_spec_cast5, + { &_gcry_cipher_spec_cast5, &dummy_extra_spec, GCRY_CIPHER_CAST5 }, #endif #if USE_AES - { &_gcry_cipher_spec_aes, + { &_gcry_cipher_spec_aes, &_gcry_cipher_extraspec_aes, GCRY_CIPHER_AES, 1 }, - { &_gcry_cipher_spec_aes192, + { &_gcry_cipher_spec_aes192, &_gcry_cipher_extraspec_aes192, GCRY_CIPHER_AES192, 1 }, - { &_gcry_cipher_spec_aes256, + { &_gcry_cipher_spec_aes256, &_gcry_cipher_extraspec_aes256, GCRY_CIPHER_AES256, 1 }, #endif #if USE_TWOFISH { &_gcry_cipher_spec_twofish, &dummy_extra_spec, GCRY_CIPHER_TWOFISH }, - { &_gcry_cipher_spec_twofish128, + { &_gcry_cipher_spec_twofish128, &dummy_extra_spec, GCRY_CIPHER_TWOFISH128 }, #endif #if USE_SERPENT - { &_gcry_cipher_spec_serpent128, + { &_gcry_cipher_spec_serpent128, &dummy_extra_spec, GCRY_CIPHER_SERPENT128 }, { &_gcry_cipher_spec_serpent192, &dummy_extra_spec, GCRY_CIPHER_SERPENT192 }, - { &_gcry_cipher_spec_serpent256, + { &_gcry_cipher_spec_serpent256, &dummy_extra_spec, GCRY_CIPHER_SERPENT256 }, #endif #if USE_RFC2268 @@ -98,13 +98,13 @@ static struct cipher_table_entry &dummy_extra_spec, GCRY_CIPHER_RFC2268_40 }, #endif #if USE_SEED - { &_gcry_cipher_spec_seed, + { &_gcry_cipher_spec_seed, &dummy_extra_spec, GCRY_CIPHER_SEED }, #endif #if USE_CAMELLIA { &_gcry_cipher_spec_camellia128, &dummy_extra_spec, GCRY_CIPHER_CAMELLIA128 }, - { &_gcry_cipher_spec_camellia192, + { &_gcry_cipher_spec_camellia192, &dummy_extra_spec, GCRY_CIPHER_CAMELLIA192 }, { &_gcry_cipher_spec_camellia256, &dummy_extra_spec, GCRY_CIPHER_CAMELLIA256 }, @@ -144,12 +144,12 @@ static int default_ciphers_registered; that the entire context structure is a aligned on that boundary. We achieve this by defining a new type and use that instead of our usual alignment type. */ -typedef union +typedef union { PROPERLY_ALIGNED_TYPE foo; #ifdef NEED_16BYTE_ALIGNED_CONTEXT char bar[16] __attribute__ ((aligned (16))); -#endif +#endif char c[1]; } cipher_context_alignment_t; @@ -166,7 +166,7 @@ struct gcry_cipher_handle /* The algorithm id. This is a hack required because the module interface does not easily allow to retrieve this value. */ - int algo; + int algo; /* A structure with function pointers for bulk operations. Due to limitations of the module system (we don't want to change the @@ -174,16 +174,16 @@ struct gcry_cipher_handle open function intializes them and the actual encryption routines use them if they are not NULL. */ struct { - void (*cfb_enc)(void *context, unsigned char *iv, + void (*cfb_enc)(void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks); - void (*cfb_dec)(void *context, unsigned char *iv, + void (*cfb_dec)(void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks); - void (*cbc_enc)(void *context, unsigned char *iv, + void (*cbc_enc)(void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks, int cbc_mac); - void (*cbc_dec)(void *context, unsigned char *iv, + void (*cbc_dec)(void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks); } bulk; @@ -200,9 +200,9 @@ struct gcry_cipher_handle /* The initialization vector. To help code optimization we make sure that it is aligned on an unsigned long and u32 boundary. */ union { - unsigned long dummy_iv; + unsigned long dummy_iv; u32 dummy_u32_iv; - unsigned char iv[MAX_BLOCKSIZE]; + unsigned char iv[MAX_BLOCKSIZE]; } u_iv; unsigned char lastiv[MAX_BLOCKSIZE]; @@ -227,7 +227,7 @@ struct gcry_cipher_handle static gcry_err_code_t dummy_setkey (void *c, const unsigned char *key, unsigned int keylen) { - (void)c; + (void)c; (void)key; (void)keylen; return GPG_ERR_NO_ERROR; @@ -286,7 +286,7 @@ cipher_register_default (void) { gcry_err_code_t err = GPG_ERR_NO_ERROR; int i; - + for (i = 0; !err && cipher_table[i].cipher; i++) { if (! cipher_table[i].cipher->setkey) @@ -389,8 +389,8 @@ _gcry_cipher_register (gcry_cipher_spec_t *cipher, ath_mutex_lock (&ciphers_registered_lock); err = _gcry_module_add (&ciphers_registered, 0, - (void *)cipher, - (void *)(extraspec? extraspec : &dummy_extra_spec), + (void *)cipher, + (void *)(extraspec? extraspec : &dummy_extra_spec), &mod); ath_mutex_unlock (&ciphers_registered_lock); @@ -420,7 +420,7 @@ gcry_cipher_unregister (gcry_module_t module) ispassed as NULL. A pointer to the specification of the module implementing this algorithm is return in OID_SPEC unless passed as NULL.*/ -static int +static int search_oid (const char *oid, int *algorithm, gcry_cipher_oid_spec_t *oid_spec) { gcry_module_t module; @@ -484,7 +484,7 @@ gcry_cipher_map_name (const char *string) } ath_mutex_unlock (&ciphers_registered_lock); - + return algorithm; } @@ -593,7 +593,7 @@ check_cipher_algo (int algorithm) else err = GPG_ERR_CIPHER_ALGO; ath_mutex_unlock (&ciphers_registered_lock); - + return err; } @@ -683,7 +683,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle, /* If the application missed to call the random poll function, we do it here to ensure that it is used once in a while. */ _gcry_fast_random_poll (); - + REGISTER_DEFAULT_CIPHERS; /* Fetch the according module and check whether the cipher is marked @@ -711,7 +711,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle, /* check flags */ if ((! err) - && ((flags & ~(0 + && ((flags & ~(0 | GCRY_CIPHER_SECURE | GCRY_CIPHER_ENABLE_SYNC | GCRY_CIPHER_CBC_CTS @@ -812,7 +812,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle, h->bulk.cbc_dec = _gcry_aes_cbc_dec; break; #endif /*USE_AES*/ - + default: break; } @@ -902,7 +902,7 @@ static void cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen ) { memset (c->u_iv.iv, 0, c->cipher->blocksize); - if (iv) + if (iv) { if (ivlen != c->cipher->blocksize) { @@ -944,7 +944,7 @@ do_ecb_encrypt (gcry_cipher_hd_t c, { unsigned int blocksize = c->cipher->blocksize; unsigned int n, nblocks; - + if (outbuflen < inbuflen) return GPG_ERR_BUFFER_TOO_SHORT; if ((inbuflen % blocksize)) @@ -975,7 +975,7 @@ do_ecb_decrypt (gcry_cipher_hd_t c, return GPG_ERR_INV_LENGTH; nblocks = inbuflen / c->cipher->blocksize; - for (n=0; n < nblocks; n++ ) + for (n=0; n < nblocks; n++ ) { c->cipher->decrypt (&c->context.c, outbuf, (byte*)/*arggg*/inbuf ); inbuf += blocksize; @@ -1005,7 +1005,7 @@ do_cbc_encrypt (gcry_cipher_hd_t c, && (c->flags & GCRY_CIPHER_CBC_CTS))) return GPG_ERR_INV_LENGTH; - if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize) + if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize) { if ((inbuflen % blocksize) == 0) nblocks--; @@ -1014,7 +1014,7 @@ do_cbc_encrypt (gcry_cipher_hd_t c, if (c->bulk.cbc_enc) { c->bulk.cbc_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks, - (c->flags & GCRY_CIPHER_CBC_MAC)); + (c->flags & GCRY_CIPHER_CBC_MAC)); inbuf += nblocks * blocksize; if (!(c->flags & GCRY_CIPHER_CBC_MAC)) outbuf += nblocks * blocksize; @@ -1054,7 +1054,7 @@ do_cbc_encrypt (gcry_cipher_hd_t c, } for (; i < blocksize; i++) outbuf[i] = 0 ^ *ivp++; - + c->cipher->encrypt (&c->context.c, outbuf, outbuf); memcpy (c->u_iv.iv, outbuf, blocksize); } @@ -1092,13 +1092,13 @@ do_cbc_decrypt (gcry_cipher_hd_t c, if (c->bulk.cbc_dec) { - c->bulk.cbc_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks); + c->bulk.cbc_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks); inbuf += nblocks * blocksize; outbuf += nblocks * blocksize; } else { - for (n=0; n < nblocks; n++ ) + for (n=0; n < nblocks; n++ ) { /* Because outbuf and inbuf might be the same, we have to * save the original ciphertext block. We use LASTIV for @@ -1113,22 +1113,22 @@ do_cbc_decrypt (gcry_cipher_hd_t c, } } - if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize) + if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize) { int restbytes; - + if ((inbuflen % blocksize) == 0) restbytes = blocksize; else restbytes = inbuflen % blocksize; - + memcpy (c->lastiv, c->u_iv.iv, blocksize ); /* Save Cn-2. */ memcpy (c->u_iv.iv, inbuf + blocksize, restbytes ); /* Save Cn. */ c->cipher->decrypt ( &c->context.c, outbuf, inbuf ); for (ivp=c->u_iv.iv,i=0; i < restbytes; i++ ) outbuf[i] ^= *ivp++; - + memcpy(outbuf + blocksize, outbuf, restbytes); for(i=restbytes; i < blocksize; i++) c->u_iv.iv[i] = outbuf[i]; @@ -1150,7 +1150,7 @@ do_cfb_encrypt (gcry_cipher_hd_t c, unsigned char *ivp; size_t blocksize = c->cipher->blocksize; size_t blocksize_x_2 = blocksize + blocksize; - + if (outbuflen < inbuflen) return GPG_ERR_BUFFER_TOO_SHORT; @@ -1179,7 +1179,7 @@ do_cfb_encrypt (gcry_cipher_hd_t c, if (inbuflen >= blocksize_x_2 && c->bulk.cfb_enc) { unsigned int nblocks = inbuflen / blocksize; - c->bulk.cfb_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks); + c->bulk.cfb_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks); outbuf += nblocks * blocksize; inbuf += nblocks * blocksize; inbuflen -= nblocks * blocksize; @@ -1209,7 +1209,7 @@ do_cfb_encrypt (gcry_cipher_hd_t c, *outbuf++ = (*ivp++ ^= *inbuf++); inbuflen -= blocksize; } - if ( inbuflen ) + if ( inbuflen ) { /* Save the current IV and then encrypt the IV. */ memcpy( c->lastiv, c->u_iv.iv, blocksize ); @@ -1234,7 +1234,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c, int i; size_t blocksize = c->cipher->blocksize; size_t blocksize_x_2 = blocksize + blocksize; - + if (outbuflen < inbuflen) return GPG_ERR_BUFFER_TOO_SHORT; @@ -1243,7 +1243,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c, /* Short enough to be encoded by the remaining XOR mask. */ /* XOR the input with the IV and store input into IV. */ for (ivp=c->u_iv.iv+blocksize - c->unused; - inbuflen; + inbuflen; inbuflen--, c->unused--) { temp = *inbuf++; @@ -1252,7 +1252,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c, } return 0; } - + if (c->unused) { /* XOR the input with the IV and store input into IV. */ @@ -1264,14 +1264,14 @@ do_cfb_decrypt (gcry_cipher_hd_t c, *ivp++ = temp; } } - + /* Now we can process complete blocks. We use a loop as long as we have at least 2 blocks and use conditions for the rest. This also allows to use a bulk encryption function if available. */ if (inbuflen >= blocksize_x_2 && c->bulk.cfb_dec) { unsigned int nblocks = inbuflen / blocksize; - c->bulk.cfb_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks); + c->bulk.cfb_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks); outbuf += nblocks * blocksize; inbuf += nblocks * blocksize; inbuflen -= nblocks * blocksize; @@ -1309,7 +1309,7 @@ do_cfb_decrypt (gcry_cipher_hd_t c, } if (inbuflen) - { + { /* Save the current IV and then encrypt the IV. */ memcpy ( c->lastiv, c->u_iv.iv, blocksize ); c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv ); @@ -1363,7 +1363,7 @@ do_ofb_encrypt (gcry_cipher_hd_t c, /* Encrypt the IV (and save the current one). */ memcpy( c->lastiv, c->u_iv.iv, blocksize ); c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv ); - + for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ ) *outbuf++ = (*ivp++ ^ *inbuf++); inbuflen -= blocksize; @@ -1387,7 +1387,7 @@ do_ofb_decrypt (gcry_cipher_hd_t c, { unsigned char *ivp; size_t blocksize = c->cipher->blocksize; - + if (outbuflen < inbuflen) return GPG_ERR_BUFFER_TOO_SHORT; @@ -1417,7 +1417,7 @@ do_ofb_decrypt (gcry_cipher_hd_t c, *outbuf++ = *ivp++ ^ *inbuf++; inbuflen -= blocksize; } - if ( inbuflen ) + if ( inbuflen ) { /* Process the remaining bytes. */ /* Encrypt the IV (and save the current one). */ memcpy( c->lastiv, c->u_iv.iv, blocksize ); @@ -1495,15 +1495,15 @@ do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, #endif /* We require a cipher with a 128 bit block length. */ if (c->cipher->blocksize != 16) - return GPG_ERR_INV_LENGTH; - + return GPG_ERR_INV_LENGTH; + /* The output buffer must be able to hold the input data plus one additional block. */ if (outbuflen < inbuflen + 8) return GPG_ERR_BUFFER_TOO_SHORT; /* Input data must be multiple of 64 bits. */ if (inbuflen % 8) - return GPG_ERR_INV_ARG; + return GPG_ERR_INV_ARG; n = inbuflen / 8; @@ -1511,7 +1511,7 @@ do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, if (n < 2) return GPG_ERR_INV_ARG; - r = outbuf; + r = outbuf; a = outbuf; /* We store A directly in OUTBUF. */ b = c->ctr; /* B is also used to concatenate stuff. */ @@ -1549,7 +1549,7 @@ do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, memcpy (r+i*8, b+8, 8); } } - + return 0; } @@ -1570,8 +1570,8 @@ do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, #endif /* We require a cipher with a 128 bit block length. */ if (c->cipher->blocksize != 16) - return GPG_ERR_INV_LENGTH; - + return GPG_ERR_INV_LENGTH; + /* The output buffer must be able to hold the input data minus one additional block. Fixme: The caller has more restrictive checks - we may want to fix them for this mode. */ @@ -1579,7 +1579,7 @@ do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, return GPG_ERR_BUFFER_TOO_SHORT; /* Input data must be multiple of 64 bits. */ if (inbuflen % 8) - return GPG_ERR_INV_ARG; + return GPG_ERR_INV_ARG; n = inbuflen / 8; @@ -1587,7 +1587,7 @@ do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, if (n < 3) return GPG_ERR_INV_ARG; - r = outbuf; + r = outbuf; a = c->lastiv; /* We use c->LASTIV as buffer for A. */ b = c->ctr; /* B is also used to concatenate stuff. */ @@ -1663,7 +1663,7 @@ cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, case GCRY_CIPHER_MODE_CBC: rc = do_cbc_encrypt (c, outbuf, outbuflen, inbuf, inbuflen); break; - + case GCRY_CIPHER_MODE_CFB: rc = do_cfb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen); break; @@ -1699,7 +1699,7 @@ cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, rc = 0; } break; - + default: log_fatal ("cipher_encrypt: invalid mode %d\n", c->mode ); rc = GPG_ERR_INV_CIPHER_MODE; @@ -1728,7 +1728,7 @@ gcry_cipher_encrypt (gcry_cipher_hd_t h, void *out, size_t outsize, /* Failsafe: Make sure that the plaintext will never make it into OUT if the encryption returned an error. */ if (err && out) - memset (out, 0x42, outsize); + memset (out, 0x42, outsize); return gcry_error (err); } @@ -1791,7 +1791,7 @@ cipher_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen, rc = 0; } break; - + default: log_fatal ("cipher_decrypt: invalid mode %d\n", c->mode ); rc = GPG_ERR_INV_CIPHER_MODE; @@ -1928,7 +1928,7 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) case 61: /* Disable weak key detection (private). */ if (h->extraspec->set_extra_info) - rc = h->extraspec->set_extra_info + rc = h->extraspec->set_extra_info (&h->context.c, CIPHER_INFO_NO_WEAK_KEY, NULL, 0); else rc = GPG_ERR_NOT_SUPPORTED; @@ -1936,7 +1936,7 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) case 62: /* Return current input vector (private). */ /* This is the input block as used in CFB and OFB mode which has - initially been set as IV. The returned format is: + initially been set as IV. The returned format is: 1 byte Actual length of the block in bytes. n byte The block. If the provided buffer is too short, an error is returned. */ @@ -1947,7 +1947,7 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) unsigned char *ivp; unsigned char *dst = buffer; int n = h->unused; - + if (!n) n = h->cipher->blocksize; gcry_assert (n <= h->cipher->blocksize); @@ -1969,10 +1969,10 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) /* Return information about the cipher handle H. CMD is the kind of information requested. BUFFER and NBYTES are reserved for now. - There are no values for CMD yet defined. + There are no values for CMD yet defined. The function always returns GPG_ERR_INV_OP. - + */ gcry_error_t gcry_cipher_info (gcry_cipher_hd_t h, int cmd, void *buffer, size_t *nbytes) @@ -2009,7 +2009,7 @@ gcry_cipher_info (gcry_cipher_hd_t h, int cmd, void *buffer, size_t *nbytes) GCRYCTL_TEST_ALGO: Returns 0 if the specified algorithm ALGO is available for use. BUFFER and NBYTES must be zero. - + Note: Because this function is in most cases used to return an integer value, we can make it easier for the caller to just look at the return value. The caller will in all cases consult the value @@ -2078,7 +2078,7 @@ gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes) gcry_cipher_algo_info because it allows for proper type checking. */ size_t -gcry_cipher_get_algo_keylen (int algo) +gcry_cipher_get_algo_keylen (int algo) { size_t n; @@ -2094,7 +2094,7 @@ gcry_cipher_get_algo_keylen (int algo) gcry_cipher_algo_info because it allows for proper type checking. */ size_t -gcry_cipher_get_algo_blklen (int algo) +gcry_cipher_get_algo_blklen (int algo) { size_t n; @@ -2155,7 +2155,7 @@ _gcry_cipher_selftest (int algo, int extended, selftest_report_func_t report) { ec = GPG_ERR_CIPHER_ALGO; if (report) - report ("cipher", algo, "module", + report ("cipher", algo, "module", module && !(module->flags & FLAG_MODULE_DISABLED)? "no selftest available" : module? "algorithm disabled" : "algorithm not found"); diff --git a/cipher/des.c b/cipher/des.c index e7f14fd6..96b06ae3 100644 --- a/cipher/des.c +++ b/cipher/des.c @@ -22,7 +22,7 @@ * Bruce Schneier: Applied Cryptography. Second Edition. * John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff. * This implementation is according to the definition of DES in FIPS - * PUB 46-2 from December 1993. + * PUB 46-2 from December 1993. */ @@ -388,7 +388,7 @@ static byte weak_keys[64][8] = }; static unsigned char weak_keys_chksum[20] = { 0xD0, 0xCF, 0x07, 0x38, 0x93, 0x70, 0x8A, 0x83, 0x7D, 0xD7, - 0x8A, 0x36, 0x65, 0x29, 0x6C, 0x1F, 0x7C, 0x3F, 0xD3, 0x41 + 0x8A, 0x36, 0x65, 0x29, 0x6C, 0x1F, 0x7C, 0x3F, 0xD3, 0x41 }; @@ -888,12 +888,12 @@ selftest (void) if (memcmp (input, result, 8)) return "Triple-DES test failed."; } - + /* * More Triple-DES test. These are testvectors as used by SSLeay, * thanks to Jeroen C. van Gelderen. */ - { + { struct { byte key[24]; byte plain[8]; byte cipher[8]; } testdata[] = { { { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, @@ -901,7 +901,7 @@ selftest (void) { 0x95,0xF8,0xA5,0xE5,0xDD,0x31,0xD9,0x00 }, { 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } }, - + { { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 }, @@ -966,7 +966,7 @@ selftest (void) { tripledes_set3keys (des3, testdata[i].key, testdata[i].key + 8, testdata[i].key + 16); - + tripledes_ecb_encrypt (des3, testdata[i].plain, result); if (memcmp (testdata[i].cipher, result, 8)) return "Triple-DES SSLeay test failed on encryption."; @@ -1047,7 +1047,7 @@ do_tripledes_set_extra_info (void *context, int what, break; default: - ec = GPG_ERR_INV_OP; + ec = GPG_ERR_INV_OP; break; } return ec; @@ -1112,7 +1112,7 @@ do_des_decrypt( void *context, byte *outbuf, const byte *inbuf ) -/* +/* Self-test section. */ @@ -1123,7 +1123,7 @@ selftest_fips (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + (void)extended; /* No extended tests available. */ what = "low-level"; @@ -1160,7 +1160,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_CIPHER_ALGO; break; - + } return ec; } @@ -1189,7 +1189,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_tripledes = do_tripledes_setkey, do_tripledes_encrypt, do_tripledes_decrypt }; -cipher_extra_spec_t _gcry_cipher_extraspec_tripledes = +cipher_extra_spec_t _gcry_cipher_extraspec_tripledes = { run_selftests, do_tripledes_set_extra_info diff --git a/cipher/dsa.c b/cipher/dsa.c index ceb94965..d7631a16 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -74,7 +74,7 @@ static const char sample_secret_key[] = " 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)" " (x #11D54E4ADBD3034160F2CED4B7CD292A4EBF3EC0#)))"; /* A sample 1024 bit DSA key used for the selftests (public only). */ -static const char sample_public_key[] = +static const char sample_public_key[] = "(public-key" " (dsa" " (p #00AD7C0025BA1A15F775F3F2D673718391D00456978D347B33D7B49E7F32EDAB" @@ -143,12 +143,12 @@ gen_k( gcry_mpi_t q ) if ( DBG_CIPHER ) log_debug("choosing a random k "); - for (;;) + for (;;) { if( DBG_CIPHER ) progress('.'); - if ( !rndbuf || nbits < 32 ) + if ( !rndbuf || nbits < 32 ) { gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( (nbits+7)/8, GCRY_STRONG_RANDOM ); @@ -172,7 +172,7 @@ gen_k( gcry_mpi_t q ) } if( !(mpi_cmp( k, q ) < 0) ) /* check: k < q */ - { + { if( DBG_CIPHER ) progress('+'); continue; /* no */ @@ -188,7 +188,7 @@ gen_k( gcry_mpi_t q ) gcry_free(rndbuf); if( DBG_CIPHER ) progress('\n'); - + return k; } @@ -315,7 +315,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, mpi_add_ui (h, h, 1); /* g = h^e mod p */ gcry_mpi_powm (g, h, e, p); - } + } while (!mpi_cmp_ui (g, 1)); /* Continue until g != 1. */ } @@ -330,13 +330,13 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, x = mpi_alloc_secure( mpi_get_nlimbs(q) ); mpi_sub_ui( h, q, 1 ); /* put q-1 into h */ rndbuf = NULL; - do + do { if( DBG_CIPHER ) progress('.'); if( !rndbuf ) rndbuf = gcry_random_bytes_secure ((qbits+7)/8, random_level); - else + else { /* Change only some of the higher bits (= 2 bytes)*/ char *r = gcry_random_bytes_secure (2, random_level); memcpy(rndbuf, r, 2 ); @@ -345,7 +345,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, _gcry_mpi_set_buffer( x, rndbuf, (qbits+7)/8, 0 ); mpi_clear_highbit( x, qbits+1 ); - } + } while ( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, h )<0 ) ); gcry_free(rndbuf); mpi_free( e ); @@ -355,7 +355,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, y = mpi_alloc( mpi_get_nlimbs(p) ); gcry_mpi_powm( y, g, x, p ); - if( DBG_CIPHER ) + if( DBG_CIPHER ) { progress('\n'); log_mpidump("dsa p", p ); @@ -406,8 +406,8 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, const void *seed; size_t seedlen; } initial_seed = { NULL, NULL, 0 }; - gcry_mpi_t prime_q = NULL; - gcry_mpi_t prime_p = NULL; + gcry_mpi_t prime_q = NULL; + gcry_mpi_t prime_p = NULL; gcry_mpi_t value_g = NULL; /* The generator. */ gcry_mpi_t value_y = NULL; /* g^x mod p */ gcry_mpi_t value_x = NULL; /* The secret exponent. */ @@ -467,15 +467,15 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, initial_seed.seed = gcry_sexp_nth_data (initial_seed.sexp, 1, &initial_seed.seedlen); } - + /* Fixme: Enable 186-3 after it has been approved and after fixing the generation function. */ /* if (use_fips186_2) */ (void)use_fips186_2; - ec = _gcry_generate_fips186_2_prime (nbits, qbits, - initial_seed.seed, + ec = _gcry_generate_fips186_2_prime (nbits, qbits, + initial_seed.seed, initial_seed.seedlen, - &prime_q, &prime_p, + &prime_q, &prime_p, r_counter, r_seed, r_seedlen); /* else */ @@ -493,33 +493,33 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, mpi_sub_ui (value_e, prime_p, 1); mpi_fdiv_q (value_e, value_e, prime_q ); value_g = mpi_alloc_like (prime_p); - value_h = mpi_alloc_set_ui (1); + value_h = mpi_alloc_set_ui (1); do { mpi_add_ui (value_h, value_h, 1); /* g = h^e mod p */ mpi_powm (value_g, value_h, value_e, prime_p); - } + } while (!mpi_cmp_ui (value_g, 1)); /* Continue until g != 1. */ } /* Select a random number x with: 0 < x < q */ value_x = gcry_mpi_snew (qbits); - do + do { if( DBG_CIPHER ) progress('.'); gcry_mpi_randomize (value_x, qbits, GCRY_VERY_STRONG_RANDOM); mpi_clear_highbit (value_x, qbits+1); - } + } while (!(mpi_cmp_ui (value_x, 0) > 0 && mpi_cmp (value_x, prime_q) < 0)); /* y = g^x mod p */ value_y = mpi_alloc_like (prime_p); gcry_mpi_powm (value_y, value_g, value_x, prime_p); - if (DBG_CIPHER) + if (DBG_CIPHER) { progress('\n'); log_mpidump("dsa p", prime_p ); @@ -691,7 +691,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, int use_fips186_2 = 0; int use_fips186 = 0; dsa_domain_t domain; - + (void)algo; /* No need to check it. */ (void)evalue; /* Not required for DSA. */ @@ -700,7 +700,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, if (genparms) { gcry_sexp_t domainsexp; - + /* Parse the optional qbits element. */ l1 = gcry_sexp_find_token (genparms, "qbits", 0); if (l1) @@ -708,7 +708,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, char buf[50]; const char *s; size_t n; - + s = gcry_sexp_nth_data (l1, 1, &n); if (!s || n >= DIM (buf) - 1 ) { @@ -760,7 +760,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, gcry_sexp_release (deriveparms); return GPG_ERR_INV_VALUE; } - + /* Put all domain parameters into the domain object. */ l1 = gcry_sexp_find_token (domainsexp, "p", 0); domain.p = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG); @@ -804,7 +804,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, { /* Format the seed-values unless domain parameters are used for which a H_VALUE of NULL is an indication. */ - ec = gpg_err_code (gcry_sexp_build + ec = gpg_err_code (gcry_sexp_build (&seedinfo, NULL, "(seed-values(counter %d)(seed %b)(h %m))", counter, (int)seedlen, seed, h_value)); @@ -879,7 +879,7 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, p = stpcpy (p, ")"); } p = stpcpy (p, ")"); - + /* Allocate space for the list of factors plus one for an S-expression plus an extra NULL entry for safety and fill it with the factors. */ @@ -894,8 +894,8 @@ dsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, for (j=0; j < nfactors; j++) arg_list[i++] = (*retfactors) + j; arg_list[i] = NULL; - - ec = gpg_err_code (gcry_sexp_build_array + + ec = gpg_err_code (gcry_sexp_build_array (r_extrainfo, NULL, format, arg_list)); } } @@ -1023,17 +1023,17 @@ dsa_get_nbits (int algo, gcry_mpi_t *pkey) -/* +/* Self-test section. */ static const char * selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey) { - static const char sample_data[] = + static const char sample_data[] = "(data (flags pkcs1)" " (hash sha1 #a0b1c2d3e4f500102030405060708090a1b2c3d4#))"; - static const char sample_data_bad[] = + static const char sample_data_bad[] = "(data (flags pkcs1)" " (hash sha1 #a0b1c2d3e4f510102030405060708090a1b2c3d4#))"; @@ -1046,7 +1046,7 @@ selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey) err = gcry_sexp_sscan (&data, NULL, sample_data, strlen (sample_data)); if (!err) - err = gcry_sexp_sscan (&data_bad, NULL, + err = gcry_sexp_sscan (&data_bad, NULL, sample_data_bad, strlen (sample_data_bad)); if (err) { @@ -1093,10 +1093,10 @@ selftests_dsa (selftest_report_func_t report) /* Convert the S-expressions into the internal representation. */ what = "convert"; - err = gcry_sexp_sscan (&skey, NULL, + err = gcry_sexp_sscan (&skey, NULL, sample_secret_key, strlen (sample_secret_key)); if (!err) - err = gcry_sexp_sscan (&pkey, NULL, + err = gcry_sexp_sscan (&pkey, NULL, sample_public_key, strlen (sample_public_key)); if (err) { @@ -1146,7 +1146,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_PUBKEY_ALGO; break; - + } return ec; } @@ -1163,7 +1163,7 @@ static const char *dsa_names[] = gcry_pk_spec_t _gcry_pubkey_spec_dsa = { - "DSA", dsa_names, + "DSA", dsa_names, "pqgy", "pqgyx", "", "rs", "pqgy", GCRY_PK_USAGE_SIGN, dsa_generate, @@ -1174,9 +1174,8 @@ gcry_pk_spec_t _gcry_pubkey_spec_dsa = dsa_verify, dsa_get_nbits }; -pk_extra_spec_t _gcry_pubkey_extraspec_dsa = +pk_extra_spec_t _gcry_pubkey_extraspec_dsa = { run_selftests, dsa_generate_ext }; - diff --git a/cipher/elgamal.c b/cipher/elgamal.c index 0b0c07cb..ce4be852 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -115,7 +115,7 @@ wiener_map( unsigned int n ) }; int i; - for(i=0; t[i].p_n; i++ ) + for(i=0; t[i].p_n; i++ ) { if( n <= t[i].p_n ) return t[i].q_n; @@ -158,7 +158,7 @@ test_keys ( ELG_secret_key *sk, unsigned int nbits, int nodie ) log_fatal ("Elgamal test key for %s %s failed\n", (failed & 1)? "encrypt+decrypt":"", (failed & 2)? "sign+verify":""); - if (failed && DBG_CIPHER) + if (failed && DBG_CIPHER) log_debug ("Elgamal test key for %s %s failed\n", (failed & 1)? "encrypt+decrypt":"", (failed & 2)? "sign+verify":""); @@ -199,15 +199,15 @@ gen_k( gcry_mpi_t p, int small_k ) if( DBG_CIPHER ) log_debug("choosing a random k "); mpi_sub_ui( p_1, p, 1); - for(;;) + for(;;) { - if( !rndbuf || nbits < 32 ) + if( !rndbuf || nbits < 32 ) { gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( nbytes, GCRY_STRONG_RANDOM ); } else - { + { /* Change only some of the higher bits. We could improve this by directly requesting more memory at the first call to get_random_bytes() and use this the here maybe it is @@ -218,7 +218,7 @@ gen_k( gcry_mpi_t p, int small_k ) gcry_free(pp); } _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 ); - + for(;;) { if( !(mpi_cmp( k, p_1 ) < 0) ) /* check: k < (p-1) */ @@ -294,7 +294,7 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors ) if( DBG_CIPHER ) log_debug("choosing a random x of size %u", xbits ); rndbuf = NULL; - do + do { if( DBG_CIPHER ) progress('.'); @@ -314,21 +314,21 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors ) gcry_free(r); } } - else + else { rndbuf = gcry_random_bytes_secure( (xbits+7)/8, GCRY_VERY_STRONG_RANDOM ); } _gcry_mpi_set_buffer( x, rndbuf, (xbits+7)/8, 0 ); mpi_clear_highbit( x, xbits+1 ); - } + } while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, p_min1 )<0 ) ); gcry_free(rndbuf); y = gcry_mpi_new (nbits); gcry_mpi_powm( y, g, x, p ); - if( DBG_CIPHER ) + if( DBG_CIPHER ) { progress('\n'); log_mpidump("elg p= ", p ); @@ -354,7 +354,7 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors ) value for the secret key but the one given as X. This is useful to implement a passphrase based decryption for a public key based encryption. It has appliactions in backup systems. - + Returns: A structure filled with all needed values and an array with n-1 factors of (p-1). */ static gcry_err_code_t @@ -399,7 +399,7 @@ generate_using_x (ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t x, y = gcry_mpi_new (nbits); gcry_mpi_powm ( y, g, x, p ); - if ( DBG_CIPHER ) + if ( DBG_CIPHER ) { progress ('\n'); log_mpidump ("elg p= ", p ); @@ -493,7 +493,7 @@ decrypt(gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey ) mpi_invm( t1, t1, skey->p ); mpi_mulm( output, b, t1, skey->p ); #if 0 - if( DBG_CIPHER ) + if( DBG_CIPHER ) { log_mpidump("elg decrypted x= ", skey->x); log_mpidump("elg decrypted p= ", skey->p); @@ -533,7 +533,7 @@ sign(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_secret_key *skey ) mpi_mulm(b, t, inv, p_1 ); #if 0 - if( DBG_CIPHER ) + if( DBG_CIPHER ) { log_mpidump("elg sign p= ", skey->p); log_mpidump("elg sign g= ", skey->g); @@ -652,7 +652,7 @@ elg_generate_ext (int algo, unsigned int nbits, unsigned long evalue, skey[1] = sk.g; skey[2] = sk.y; skey[3] = sk.x; - + return ec; } @@ -671,7 +671,7 @@ elg_generate (int algo, unsigned int nbits, unsigned long evalue, skey[1] = sk.g; skey[2] = sk.y; skey[3] = sk.x; - + return GPG_ERR_NO_ERROR; } @@ -692,7 +692,7 @@ elg_check_secret_key (int algo, gcry_mpi_t *skey) sk.g = skey[1]; sk.y = skey[2]; sk.x = skey[3]; - + if (! check_secret_key (&sk)) err = GPG_ERR_BAD_SECKEY; } @@ -773,7 +773,7 @@ elg_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey) resarr[1] = mpi_alloc (mpi_get_nlimbs (sk.p)); sign (resarr[0], resarr[1], data, &sk); } - + return err; } @@ -837,10 +837,9 @@ gcry_pk_spec_t _gcry_pubkey_spec_elg = elg_get_nbits }; -pk_extra_spec_t _gcry_pubkey_extraspec_elg = +pk_extra_spec_t _gcry_pubkey_extraspec_elg = { NULL, elg_generate_ext, NULL }; - diff --git a/cipher/hash-common.c b/cipher/hash-common.c index 656e180e..8c413bcb 100644 --- a/cipher/hash-common.c +++ b/cipher/hash-common.c @@ -21,7 +21,7 @@ #include #include #include -#ifdef HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include #endif @@ -35,10 +35,10 @@ describing the error. DATAMODE controls what will be hashed according to this table: - + 0 - Hash the supplied DATA of DATALEN. 1 - Hash one million times a 'a'. DATA and DATALEN are ignored. - + */ const char * _gcry_hash_selftest_check_one (int algo, @@ -49,14 +49,14 @@ _gcry_hash_selftest_check_one (int algo, gcry_error_t err = 0; gcry_md_hd_t hd; unsigned char *digest; - + if (_gcry_md_get_algo_dlen (algo) != expectlen) return "digest size does not match expected size"; - + err = _gcry_md_open (&hd, algo, 0); if (err) return "gcry_md_open failed"; - + switch (datamode) { case 0: @@ -64,7 +64,7 @@ _gcry_hash_selftest_check_one (int algo, break; case 1: /* Hash one million times an "a". */ - { + { char aaa[1000]; int i; @@ -82,7 +82,7 @@ _gcry_hash_selftest_check_one (int algo, if (!result) { digest = _gcry_md_read (hd, algo); - + if ( memcmp (digest, expect, expectlen) ) result = "digest mismatch"; } @@ -91,4 +91,3 @@ _gcry_hash_selftest_check_one (int algo, return result; } - diff --git a/cipher/hash-common.h b/cipher/hash-common.h index 9c4e3335..fdebef42 100644 --- a/cipher/hash-common.h +++ b/cipher/hash-common.h @@ -21,11 +21,11 @@ #define GCRY_HASH_COMMON_H -const char * _gcry_hash_selftest_check_one -/**/ (int algo, +const char * _gcry_hash_selftest_check_one +/**/ (int algo, int datamode, const void *data, size_t datalen, const void *expect, size_t expectlen); - + diff --git a/cipher/hmac-tests.c b/cipher/hmac-tests.c index 56c9b203..a32ece75 100644 --- a/cipher/hmac-tests.c +++ b/cipher/hmac-tests.c @@ -17,7 +17,7 @@ * License along with this program; if not, see . */ -/* +/* Although algorithm self-tests are usually implemented in the module implementing the algorithm, the case for HMAC is different because HMAC is implemnetd on a higher level using a special feature of the @@ -33,7 +33,7 @@ #include #include #include -#ifdef HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include #endif @@ -47,7 +47,7 @@ succdess or a string describing the failure. */ static const char * check_one (int algo, - const void *data, size_t datalen, + const void *data, size_t datalen, const void *key, size_t keylen, const void *expect, size_t expectlen) { @@ -88,7 +88,7 @@ check_one (int algo, return "does not match"; } _gcry_md_close (hd); - return NULL; + return NULL; } @@ -123,7 +123,7 @@ selftests_sha1 (int extended, selftest_report_func_t report) "\xa4\x58\x30\x73\x7d\x5c\xc6\xc7\x5d\x24", 20); if (errtxt) goto failed; - + what = "FIPS-198a, A.3"; for (i=0, j=0x50; i < 100; i++) key[i] = j++; @@ -134,7 +134,7 @@ selftests_sha1 (int extended, selftest_report_func_t report) "\x5c\xaf\x7c\xb0\x92\xec\xf8\xd1\xa3\xaa", 20 ); if (errtxt) goto failed; - + what = "FIPS-198a, A.4"; for (i=0, j=0x70; i < 49; i++) key[i] = j++; @@ -160,7 +160,7 @@ selftests_sha1 (int extended, selftest_report_func_t report) static gpg_err_code_t selftests_sha224 (int extended, selftest_report_func_t report) { - static struct + static struct { const char * const desc; const char * const data; @@ -169,7 +169,7 @@ selftests_sha224 (int extended, selftest_report_func_t report) } tv[] = { { "data-28 key-4", - "what do ya want for nothing?", + "what do ya want for nothing?", "Jefe", { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf, 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f, @@ -248,7 +248,7 @@ selftests_sha224 (int extended, selftest_report_func_t report) const char *what; const char *errtxt; int tvidx; - + for (tvidx=0; tv[tvidx].desc; tvidx++) { what = tv[tvidx].desc; @@ -274,7 +274,7 @@ selftests_sha224 (int extended, selftest_report_func_t report) static gpg_err_code_t selftests_sha256 (int extended, selftest_report_func_t report) { - static struct + static struct { const char * const desc; const char * const data; @@ -283,7 +283,7 @@ selftests_sha256 (int extended, selftest_report_func_t report) } tv[] = { { "data-28 key-4", - "what do ya want for nothing?", + "what do ya want for nothing?", "Jefe", { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, @@ -362,7 +362,7 @@ selftests_sha256 (int extended, selftest_report_func_t report) const char *what; const char *errtxt; int tvidx; - + for (tvidx=0; tv[tvidx].desc; tvidx++) { hmac256_context_t hmachd; @@ -416,7 +416,7 @@ selftests_sha256 (int extended, selftest_report_func_t report) static gpg_err_code_t selftests_sha384 (int extended, selftest_report_func_t report) { - static struct + static struct { const char * const desc; const char * const data; @@ -425,7 +425,7 @@ selftests_sha384 (int extended, selftest_report_func_t report) } tv[] = { { "data-28 key-4", - "what do ya want for nothing?", + "what do ya want for nothing?", "Jefe", { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31, 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b, @@ -516,7 +516,7 @@ selftests_sha384 (int extended, selftest_report_func_t report) const char *what; const char *errtxt; int tvidx; - + for (tvidx=0; tv[tvidx].desc; tvidx++) { what = tv[tvidx].desc; @@ -542,7 +542,7 @@ selftests_sha384 (int extended, selftest_report_func_t report) static gpg_err_code_t selftests_sha512 (int extended, selftest_report_func_t report) { - static struct + static struct { const char * const desc; const char * const data; @@ -551,7 +551,7 @@ selftests_sha512 (int extended, selftest_report_func_t report) } tv[] = { { "data-28 key-4", - "what do ya want for nothing?", + "what do ya want for nothing?", "Jefe", { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2, 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3, @@ -654,7 +654,7 @@ selftests_sha512 (int extended, selftest_report_func_t report) const char *what; const char *errtxt; int tvidx; - + for (tvidx=0; tv[tvidx].desc; tvidx++) { what = tv[tvidx].desc; diff --git a/cipher/md.c b/cipher/md.c index 5f121267..053eab13 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -43,15 +43,15 @@ static struct digest_table_entry gcry_md_spec_t *digest; md_extra_spec_t *extraspec; unsigned int algorithm; - int fips_allowed; + int fips_allowed; } digest_table[] = { -#if USE_CRC +#if USE_CRC /* We allow the CRC algorithms even in FIPS mode because they are actually no cryptographic primitives. */ - { &_gcry_digest_spec_crc32, + { &_gcry_digest_spec_crc32, &dummy_extra_spec, GCRY_MD_CRC32, 1 }, - { &_gcry_digest_spec_crc32_rfc1510, + { &_gcry_digest_spec_crc32_rfc1510, &dummy_extra_spec, GCRY_MD_CRC32_RFC1510, 1 }, { &_gcry_digest_spec_crc24_rfc2440, &dummy_extra_spec, GCRY_MD_CRC24_RFC2440, 1 }, @@ -69,7 +69,7 @@ static struct digest_table_entry &dummy_extra_spec, GCRY_MD_RMD160 }, #endif #if USE_SHA1 - { &_gcry_digest_spec_sha1, + { &_gcry_digest_spec_sha1, &_gcry_digest_extraspec_sha1, GCRY_MD_SHA1, 1 }, #endif #if USE_SHA256 @@ -177,7 +177,7 @@ md_register_default (void) { gcry_err_code_t err = 0; int i; - + for (i = 0; !err && digest_table[i].digest; i++) { if ( fips_mode ()) @@ -230,7 +230,7 @@ gcry_md_lookup_func_oid (void *spec, void *data) } /* Internal function. Lookup a digest entry by it's name. */ -static gcry_module_t +static gcry_module_t gcry_md_lookup_name (const char *name) { gcry_module_t digest; @@ -271,11 +271,11 @@ _gcry_md_register (gcry_md_spec_t *digest, ath_mutex_lock (&digests_registered_lock); err = _gcry_module_add (&digests_registered, 0, - (void *) digest, - (void *)(extraspec? extraspec : &dummy_extra_spec), + (void *) digest, + (void *)(extraspec? extraspec : &dummy_extra_spec), &mod); ath_mutex_unlock (&digests_registered_lock); - + if (! err) { *module = mod; @@ -296,7 +296,7 @@ gcry_md_unregister (gcry_module_t module) } -static int +static int search_oid (const char *oid, int *algorithm, gcry_md_oid_spec_t *oid_spec) { gcry_module_t module; @@ -567,7 +567,7 @@ md_enable (gcry_md_hd_t hd, int algorithm) else digest = (gcry_md_spec_t *) module->spec; - + if (!err && algorithm == GCRY_MD_MD5 && fips_mode ()) { _gcry_inactivate_fips_mode ("MD5 used"); @@ -578,7 +578,7 @@ md_enable (gcry_md_hd_t hd, int algorithm) err = GPG_ERR_DIGEST_ALGO; } } - + if (!err) { size_t size = (sizeof (*entry) @@ -635,7 +635,7 @@ md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd) GcryDigestEntry *ar, *br; gcry_md_hd_t bhd; size_t n; - + if (ahd->bufpos) md_write (ahd, NULL, 0); @@ -697,7 +697,7 @@ md_copy (gcry_md_hd_t ahd, gcry_md_hd_t *b_hd) - sizeof (ar->context))); br->next = b->list; b->list = br; - + /* Add a reference to the module. */ ath_mutex_lock (&digests_registered_lock); _gcry_module_use (br->module); @@ -787,7 +787,7 @@ static void md_write (gcry_md_hd_t a, const void *inbuf, size_t inlen) { GcryDigestEntry *r; - + if (a->ctx->debug) { if (a->bufpos && fwrite (a->buf, a->bufpos, 1, a->ctx->debug) != 1) @@ -838,8 +838,8 @@ md_final (gcry_md_hd_t a) if (err) _gcry_fatal_error (err, NULL); - md_write (om, - (a->ctx->macpads)+(a->ctx->macpads_Bsize), + md_write (om, + (a->ctx->macpads)+(a->ctx->macpads_Bsize), a->ctx->macpads_Bsize); md_write (om, p, dlen); md_final (om); @@ -860,7 +860,7 @@ prepare_macpads (gcry_md_hd_t hd, const unsigned char *key, size_t keylen) if (!algo) return GPG_ERR_DIGEST_ALGO; /* Might happen if no algo is enabled. */ - if ( keylen > hd->ctx->macpads_Bsize ) + if ( keylen > hd->ctx->macpads_Bsize ) { helpkey = gcry_malloc_secure (md_digest_length (algo)); if (!helpkey) @@ -876,7 +876,7 @@ prepare_macpads (gcry_md_hd_t hd, const unsigned char *key, size_t keylen) opad = (hd->ctx->macpads)+(hd->ctx->macpads_Bsize); memcpy ( ipad, key, keylen ); memcpy ( opad, key, keylen ); - for (i=0; i < hd->ctx->macpads_Bsize; i++ ) + for (i=0; i < hd->ctx->macpads_Bsize; i++ ) { ipad[i] ^= 0x36; opad[i] ^= 0x5c; @@ -890,7 +890,7 @@ gcry_error_t gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen) { gcry_err_code_t rc = 0; - + switch (cmd) { case GCRYCTL_FINALIZE: @@ -1167,7 +1167,7 @@ gcry_md_algo_info (int algo, int what, void *buffer, size_t *nbytes) { const char unsigned *asn; size_t asnlen; - + asn = md_asn_oid (algo, &asnlen, NULL); if (buffer && (*nbytes >= asnlen)) { @@ -1202,7 +1202,7 @@ md_start_debug ( gcry_md_hd_t md, const char *suffix ) if (fips_mode ()) return; - + if ( md->ctx->debug ) { log_debug("Oops: md debug already started\n"); @@ -1268,7 +1268,7 @@ gcry_md_info (gcry_md_hd_t h, int cmd, void *buffer, size_t *nbytes) else { algo = *(int*)buffer; - + *nbytes = 0; for(r=h->ctx->list; r; r = r->next ) { if (r->module->mod_id == algo) @@ -1302,7 +1302,7 @@ _gcry_md_init (void) int -gcry_md_is_secure (gcry_md_hd_t a) +gcry_md_is_secure (gcry_md_hd_t a) { size_t value; @@ -1314,7 +1314,7 @@ gcry_md_is_secure (gcry_md_hd_t a) int -gcry_md_is_enabled (gcry_md_hd_t a, int algo) +gcry_md_is_enabled (gcry_md_hd_t a, int algo) { size_t value; @@ -1366,7 +1366,7 @@ _gcry_md_selftest (int algo, int extended, selftest_report_func_t report) { ec = GPG_ERR_DIGEST_ALGO; if (report) - report ("digest", algo, "module", + report ("digest", algo, "module", module && !(module->flags & FLAG_MODULE_DISABLED)? "no selftest available" : module? "algorithm disabled" : "algorithm not found"); diff --git a/cipher/md4.c b/cipher/md4.c index a13c45c9..8909ec4a 100644 --- a/cipher/md4.c +++ b/cipher/md4.c @@ -197,7 +197,7 @@ md4_write ( void *context, const void *inbuf_arg, size_t inlen) MD4_CONTEXT *hd = context; if( hd->count == 64 ) /* flush the buffer */ - { + { transform( hd, hd->buf ); _gcry_burn_stack (80+6*sizeof(void*)); hd->count = 0; @@ -258,15 +258,15 @@ md4_final( void *context ) lsb <<= 3; msb <<= 3; msb |= t >> 29; - + if( hd->count < 56 ) /* enough room */ { hd->buf[hd->count++] = 0x80; /* pad */ while( hd->count < 56 ) hd->buf[hd->count++] = 0; /* pad */ } - else /* need one extra block */ - { + else /* need one extra block */ + { hd->buf[hd->count++] = 0x80; /* pad character */ while( hd->count < 64 ) hd->buf[hd->count++] = 0; @@ -324,4 +324,3 @@ gcry_md_spec_t _gcry_digest_spec_md4 = md4_init, md4_write, md4_final, md4_read, sizeof (MD4_CONTEXT) }; - diff --git a/cipher/md5.c b/cipher/md5.c index 051fc81b..4793882a 100644 --- a/cipher/md5.c +++ b/cipher/md5.c @@ -20,8 +20,8 @@ * * According to the definition of MD5 in RFC 1321 from April 1992. * NOTE: This is *not* the same file as the one from glibc. - * Written by Ulrich Drepper , 1995. - * heavily modified for GnuPG by Werner Koch + * Written by Ulrich Drepper , 1995. + * heavily modified for GnuPG by Werner Koch */ /* Test values: @@ -87,9 +87,9 @@ transform ( MD5_CONTEXT *ctx, const unsigned char *data ) register u32 C = ctx->C; register u32 D = ctx->D; u32 *cwp = correct_words; - + #ifdef WORDS_BIGENDIAN - { + { int i; byte *p2, *p1; for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 ) @@ -220,7 +220,7 @@ md5_write( void *context, const void *inbuf_arg , size_t inlen) { const unsigned char *inbuf = inbuf_arg; MD5_CONTEXT *hd = context; - + if( hd->count == 64 ) /* flush the buffer */ { transform( hd, hd->buf ); @@ -241,7 +241,7 @@ md5_write( void *context, const void *inbuf_arg , size_t inlen) } _gcry_burn_stack (80+6*sizeof(void*)); - while( inlen >= 64 ) + while( inlen >= 64 ) { transform( hd, inbuf ); hd->count = 0; @@ -268,7 +268,7 @@ md5_final( void *context) MD5_CONTEXT *hd = context; u32 t, msb, lsb; byte *p; - + md5_write(hd, NULL, 0); /* flush */; t = hd->nblocks; diff --git a/cipher/primegen.c b/cipher/primegen.c index f0727754..edeb7c87 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -31,7 +31,7 @@ #include "cipher.h" #include "ath.h" -static gcry_mpi_t gen_prime (unsigned int nbits, int secret, int randomlevel, +static gcry_mpi_t gen_prime (unsigned int nbits, int secret, int randomlevel, int (*extra_check)(void *, gcry_mpi_t), void *extra_check_arg); static int check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds, @@ -132,7 +132,7 @@ static int no_of_small_prime_numbers = DIM (small_prime_numbers) - 1; /* An object and a list to build up a global pool of primes. See save_pool_prime and get_pool_prime. */ -struct primepool_s +struct primepool_s { struct primepool_s *next; gcry_mpi_t prime; /* If this is NULL the entry is not used. */ @@ -163,7 +163,7 @@ save_pool_prime (gcry_mpi_t prime, gcry_random_level_t randomlevel) /* Remove some of the entries. Our strategy is removing the last third from the list. */ int i; - + for (i=0, item2 = primepool; item2; item2 = item2->next) { if (i >= n/3*2) @@ -182,7 +182,7 @@ save_pool_prime (gcry_mpi_t prime, gcry_random_level_t randomlevel) { /* Out of memory. Silently giving up. */ gcry_mpi_release (prime); - return; + return; } item->next = primepool; primepool = item; @@ -359,7 +359,7 @@ prime_generate_internal (int need_q_factor, fbits = (pbits - req_qbits -1) / n; qbits = pbits - n * fbits; } - + if (DBG_CIPHER) log_debug ("gen prime: pbits=%u qbits=%u fbits=%u/%u n=%d\n", pbits, req_qbits, qbits, fbits, n); @@ -373,7 +373,7 @@ prime_generate_internal (int need_q_factor, /* Generate a specific Q-Factor if requested. */ if (need_q_factor) q_factor = gen_prime (req_qbits, is_secret, randomlevel, NULL, NULL); - + /* Allocate an array to hold all factors + 2 for later usage. */ factors = gcry_calloc (n + 2, sizeof (*factors)); if (!factors) @@ -391,10 +391,10 @@ prime_generate_internal (int need_q_factor, } for (i=0; i < n; i++) pool_in_use[i] = -1; - + /* Make a pool of 3n+5 primes (this is an arbitrary value). We - require at least 30 primes for are useful selection process. - + require at least 30 primes for are useful selection process. + Fixme: We need to research the best formula for sizing the pool. */ m = n * 3 + 5; @@ -443,7 +443,7 @@ prime_generate_internal (int need_q_factor, is_locked = 1; for (i = 0; i < n; i++) { - perms[i] = 1; + perms[i] = 1; /* At a maximum we use strong random for the factors. This saves us a lot of entropy. Given that Q and possible Q-factor are also used in the final prime @@ -523,12 +523,12 @@ prime_generate_internal (int need_q_factor, gcry_free (perms); perms = NULL; progress ('!'); - goto next_try; + goto next_try; } } /* Generate next prime candidate: - p = 2 * q [ * q_factor] * factor_0 * factor_1 * ... * factor_n + 1. + p = 2 * q [ * q_factor] * factor_0 * factor_1 * ... * factor_n + 1. */ mpi_set (prime, q); mpi_mul_ui (prime, prime, 2); @@ -553,7 +553,7 @@ prime_generate_internal (int need_q_factor, } else count1 = 0; - + if (nprime > pbits) { if (++count2 > 20) @@ -624,14 +624,14 @@ prime_generate_internal (int need_q_factor, factors_new[i] = mpi_copy (factors[i]); } } - + if (g) { /* Create a generator (start with 3). */ gcry_mpi_t tmp = mpi_alloc (mpi_get_nlimbs (prime)); gcry_mpi_t b = mpi_alloc (mpi_get_nlimbs (prime)); gcry_mpi_t pmin1 = mpi_alloc (mpi_get_nlimbs (prime)); - + if (need_q_factor) err = GPG_ERR_NOT_IMPLEMENTED; else @@ -662,7 +662,7 @@ prime_generate_internal (int need_q_factor, } if (DBG_CIPHER) progress('\n'); - } + } while (i < n + 2); mpi_free (factors[n+1]); @@ -671,7 +671,7 @@ prime_generate_internal (int need_q_factor, mpi_free (pmin1); } } - + if (! DBG_CIPHER) progress ('\n'); @@ -740,7 +740,7 @@ _gcry_generate_elg_prime (int mode, unsigned pbits, unsigned qbits, { gcry_err_code_t err = GPG_ERR_NO_ERROR; gcry_mpi_t prime = NULL; - + err = prime_generate_internal ((mode == 1), &prime, pbits, qbits, g, ret_factors, GCRY_WEAK_RANDOM, 0, 0, NULL, NULL); @@ -750,7 +750,7 @@ _gcry_generate_elg_prime (int mode, unsigned pbits, unsigned qbits, static gcry_mpi_t -gen_prime (unsigned int nbits, int secret, int randomlevel, +gen_prime (unsigned int nbits, int secret, int randomlevel, int (*extra_check)(void *, gcry_mpi_t), void *extra_check_arg) { gcry_mpi_t prime, ptest, pminus1, val_2, val_3, result; @@ -758,7 +758,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, unsigned int x, step; unsigned int count1, count2; int *mods; - + /* if ( DBG_CIPHER ) */ /* log_debug ("generate a prime of %u bits ", nbits ); */ @@ -777,10 +777,10 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, for (;;) { /* try forvever */ int dotcount=0; - + /* generate a random number */ gcry_mpi_randomize( prime, nbits, randomlevel ); - + /* Set high order bit to 1, set low order bit to 1. If we are generating a secret prime we are most probably doing that for RSA, to make sure that the modulus does have the @@ -789,17 +789,17 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, if (secret) mpi_set_bit (prime, nbits-2); mpi_set_bit(prime, 0); - + /* Calculate all remainders. */ for (i=0; (x = small_prime_numbers[i]); i++ ) mods[i] = mpi_fdiv_r_ui(NULL, prime, x); - + /* Now try some primes starting with prime. */ - for(step=0; step < 20000; step += 2 ) + for(step=0; step < 20000; step += 2 ) { /* Check against all the small primes we have in mods. */ count1++; - for (i=0; (x = small_prime_numbers[i]); i++ ) + for (i=0; (x = small_prime_numbers[i]); i++ ) { while ( mods[i] + step >= x ) mods[i] -= x; @@ -808,7 +808,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, } if ( x ) continue; /* Found a multiple of an already known prime. */ - + mpi_add_ui( ptest, prime, step ); /* Do a fast Fermat test now. */ @@ -816,7 +816,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, mpi_sub_ui( pminus1, ptest, 1); gcry_mpi_powm( result, val_2, pminus1, ptest ); if ( !mpi_cmp_ui( result, 1 ) ) - { + { /* Not composite, perform stronger tests */ if (is_prime(ptest, 5, &count2 )) { @@ -828,13 +828,13 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, } if (extra_check && extra_check (extra_check_arg, ptest)) - { + { /* The extra check told us that this prime is not of the caller's taste. */ progress ('/'); } else - { + { /* Got it. */ mpi_free(val_2); mpi_free(val_3); @@ -842,7 +842,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, mpi_free(pminus1); mpi_free(prime); gcry_free(mods); - return ptest; + return ptest; } } } @@ -883,7 +883,7 @@ check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds, gcry_mpi_powm( result, val_2, pminus1, prime ); mpi_free( pminus1 ); if ( mpi_cmp_ui( result, 1 ) ) - { + { /* Is composite. */ mpi_free( result ); progress('.'); @@ -924,7 +924,7 @@ is_prime (gcry_mpi_t n, int steps, unsigned int *count) unsigned nbits = mpi_get_nbits( n ); if (steps < 5) /* Make sure that we do at least 5 rounds. */ - steps = 5; + steps = 5; mpi_sub_ui( nminus1, n, 1 ); @@ -996,7 +996,7 @@ is_prime (gcry_mpi_t n, int steps, unsigned int *count) j++; if (j == m) goto ready; - + This code is based on the algorithm 452 from the "Collected Algorithms From ACM, Volume II" by C. N. Liu and D. T. Tang. */ @@ -1010,7 +1010,7 @@ m_out_of_n ( char *array, int m, int n ) /* Need to handle this simple case separately. */ if( m == 1 ) - { + { for (i=0; i < n; i++ ) { if ( array[i] ) @@ -1060,7 +1060,7 @@ m_out_of_n ( char *array, int m, int n ) else k1 = k2 + 1; } - else + else { /* M is even. */ if( !array[n-1] ) @@ -1069,7 +1069,7 @@ m_out_of_n ( char *array, int m, int n ) k2 = k1 + 1; goto leave; } - + if( !(j1 & 1) ) { k1 = n - j1; @@ -1080,7 +1080,7 @@ m_out_of_n ( char *array, int m, int n ) } scan: jp = n - j1 - 1; - for (i=1; i <= jp; i++ ) + for (i=1; i <= jp; i++ ) { i1 = jp + 2 - i; if( array[i1-1] ) @@ -1128,7 +1128,7 @@ gcry_prime_generate (gcry_mpi_t *prime, unsigned int prime_bits, if (!prime) return gpg_error (GPG_ERR_INV_ARG); - *prime = NULL; + *prime = NULL; if (flags & GCRY_PRIME_FLAG_SPECIAL_FACTOR) mode = 1; @@ -1156,7 +1156,7 @@ gcry_prime_generate (gcry_mpi_t *prime, unsigned int prime_bits, mpi_free (factors_generated[i]); gcry_free (factors_generated); } - err = GPG_ERR_GENERAL; + err = GPG_ERR_GENERAL; } } @@ -1207,29 +1207,29 @@ gcry_prime_group_generator (gcry_mpi_t *r_g, if (!factors || !r_g || !prime) return gpg_error (GPG_ERR_INV_ARG); - *r_g = NULL; + *r_g = NULL; for (n=0; factors[n]; n++) ; if (n < 2) return gpg_error (GPG_ERR_INV_ARG); - /* Extra sanity check - usually disabled. */ + /* Extra sanity check - usually disabled. */ /* mpi_set (tmp, factors[0]); */ /* for(i = 1; i < n; i++) */ /* mpi_mul (tmp, tmp, factors[i]); */ /* mpi_add_ui (tmp, tmp, 1); */ /* if (mpi_cmp (prime, tmp)) */ /* return gpg_error (GPG_ERR_INV_ARG); */ - - gcry_mpi_sub_ui (pmin1, prime, 1); - do + + gcry_mpi_sub_ui (pmin1, prime, 1); + do { if (first) first = 0; else gcry_mpi_add_ui (g, g, 1); - + if (DBG_CIPHER) { log_debug ("checking g:"); @@ -1238,7 +1238,7 @@ gcry_prime_group_generator (gcry_mpi_t *r_g, } else progress('^'); - + for (i = 0; i < n; i++) { mpi_fdiv_q (tmp, pmin1, factors[i]); @@ -1250,13 +1250,13 @@ gcry_prime_group_generator (gcry_mpi_t *r_g, progress('\n'); } while (i < n); - + gcry_mpi_release (tmp); - gcry_mpi_release (b); - gcry_mpi_release (pmin1); - *r_g = g; + gcry_mpi_release (b); + gcry_mpi_release (pmin1); + *r_g = g; - return 0; + return 0; } /* Convenience function to release the factors array. */ @@ -1266,7 +1266,7 @@ gcry_prime_release_factors (gcry_mpi_t *factors) if (factors) { int i; - + for (i=0; factors[i]; i++) mpi_free (factors[i]); gcry_free (factors); @@ -1279,11 +1279,11 @@ gcry_prime_release_factors (gcry_mpi_t *factors) static gcry_mpi_t find_x931_prime (const gcry_mpi_t pfirst) { - gcry_mpi_t val_2 = mpi_alloc_set_ui (2); + gcry_mpi_t val_2 = mpi_alloc_set_ui (2); gcry_mpi_t prime; - + prime = gcry_mpi_copy (pfirst); - /* If P is even add 1. */ + /* If P is even add 1. */ mpi_set_bit (prime, 0); /* We use 64 Rabin-Miller rounds which is better and thus @@ -1299,7 +1299,7 @@ find_x931_prime (const gcry_mpi_t pfirst) } -/* Generate a prime using the algorithm from X9.31 appendix B.4. +/* Generate a prime using the algorithm from X9.31 appendix B.4. This function requires that the provided public exponent E is odd. XP, XP1 and XP2 are the seed values. All values are mandatory. @@ -1308,7 +1308,7 @@ find_x931_prime (const gcry_mpi_t pfirst) internal values P1 and P2 are saved at these addresses. On error NULL is returned. */ gcry_mpi_t -_gcry_derive_x931_prime (const gcry_mpi_t xp, +_gcry_derive_x931_prime (const gcry_mpi_t xp, const gcry_mpi_t xp1, const gcry_mpi_t xp2, const gcry_mpi_t e, gcry_mpi_t *r_p1, gcry_mpi_t *r_p2) @@ -1327,20 +1327,20 @@ _gcry_derive_x931_prime (const gcry_mpi_t xp, { gcry_mpi_t r1, tmp; - + /* r1 = (p2^{-1} mod p1)p2 - (p1^{-1} mod p2) */ tmp = mpi_alloc_like (p1); mpi_invm (tmp, p2, p1); mpi_mul (tmp, tmp, p2); r1 = tmp; - + tmp = mpi_alloc_like (p2); mpi_invm (tmp, p1, p2); mpi_mul (tmp, tmp, p1); mpi_sub (r1, r1, tmp); /* Fixup a negative value. */ - if (mpi_is_neg (r1)) + if (mpi_is_neg (r1)) mpi_add (r1, r1, p1p2); /* yp0 = xp + (r1 - xp mod p1*p2) */ @@ -1350,7 +1350,7 @@ _gcry_derive_x931_prime (const gcry_mpi_t xp, mpi_free (r1); /* Fixup a negative value. */ - if (mpi_cmp (yp0, xp) < 0 ) + if (mpi_cmp (yp0, xp) < 0 ) mpi_add (yp0, yp0, p1p2); } @@ -1378,10 +1378,10 @@ _gcry_derive_x931_prime (const gcry_mpi_t xp, */ { - gcry_mpi_t val_2 = mpi_alloc_set_ui (2); + gcry_mpi_t val_2 = mpi_alloc_set_ui (2); gcry_mpi_t gcdtmp = mpi_alloc_like (yp0); int gcdres; - + mpi_sub_ui (p1p2, p1p2, 1); /* Adjust for loop body. */ mpi_sub_ui (yp0, yp0, 1); /* Ditto. */ for (;;) @@ -1453,7 +1453,7 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, ; /* No seed value given: We are asked to generate it. */ else if (!seed || seedlen < qbits/8) return GPG_ERR_INV_ARG; - + /* Allocate a buffer to later compute SEED+some_increment. */ seed_plus = gcry_malloc (seedlen < 20? 20:seedlen); if (!seed_plus) @@ -1468,7 +1468,7 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, value_w = gcry_mpi_new (pbits); value_x = gcry_mpi_new (pbits); - restart: + restart: /* Generate Q. */ for (;;) { @@ -1479,7 +1479,7 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, gcry_create_nonce (seed_help_buffer, seedlen); seed = seed_help_buffer; } - + /* Step 2: U = sha1(seed) ^ sha1((seed+1) mod 2^{qbits}) */ memcpy (seed_plus, seed, seedlen); for (i=seedlen-1; i >= 0; i--) @@ -1492,16 +1492,16 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen); for (i=0; i < sizeof value_u; i++) value_u[i] ^= digest[i]; - + /* Step 3: Form q from U */ gcry_mpi_release (prime_q); prime_q = NULL; - ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG, + ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG, value_u, sizeof value_u, NULL)); if (ec) goto leave; mpi_set_highbit (prime_q, qbits-1 ); mpi_set_bit (prime_q, 0); - + /* Step 4: Test whether Q is prime using 64 round of Rabin-Miller. */ if (check_prime (prime_q, val_2, 64, NULL, NULL)) break; /* Yes, Q is prime. */ @@ -1509,7 +1509,7 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, /* Step 5. */ seed = NULL; /* Force a new seed at Step 1. */ } - + /* Step 6. Note that we do no use an explicit offset but increment SEED_PLUS accordingly. SEED_PLUS is currently SEED+1. */ counter = 0; @@ -1518,12 +1518,12 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, prime_p = gcry_mpi_new (pbits); for (;;) { - /* Step 7: For k = 0,...n let - V_k = sha1(seed+offset+k) mod 2^{qbits} - Step 8: W = V_0 + V_1*2^160 + - ... + /* Step 7: For k = 0,...n let + V_k = sha1(seed+offset+k) mod 2^{qbits} + Step 8: W = V_0 + V_1*2^160 + + ... + V_{n-1}*2^{(n-1)*160} - + (V_{n} mod 2^b)*2^{n*160} + + (V_{n} mod 2^b)*2^{n*160} */ mpi_set_ui (value_w, 0); for (value_k=0; value_k <= value_n; value_k++) @@ -1542,7 +1542,7 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, break; } gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen); - + gcry_mpi_release (tmpval); tmpval = NULL; ec = gpg_err_code (gcry_mpi_scan (&tmpval, GCRYMPI_FMT_USG, digest, sizeof digest, NULL)); @@ -1631,7 +1631,7 @@ _gcry_generate_fips186_2_prime (unsigned int pbits, unsigned int qbits, value is stored at R_COUNTER and the seed actually used for generation is stored at R_SEED and R_SEEDVALUE. The hash algorithm used is stored at R_HASHALGO. - + Note that this function is very similar to the fips186_2 code. Due to the minor differences, other buffer sizes and for documentarion, we use a separate function. @@ -1652,7 +1652,7 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, gcry_mpi_t tmpval = NULL; /* Helper variable. */ int hashalgo; /* The id of the Approved Hash Function. */ int i; - + unsigned char value_u[256/8]; int value_n, value_b, value_j; int counter; @@ -1690,10 +1690,10 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, ; /* No seed value given: We are asked to generate it. */ else if (!seed || seedlen < qbits/8) return GPG_ERR_INV_ARG; - + /* Allocate a buffer to later compute SEED+some_increment and a few helper variables. */ - seed_plus = gcry_malloc (seedlen < sizeof seed_help_buffer? + seed_plus = gcry_malloc (seedlen < sizeof seed_help_buffer? sizeof seed_help_buffer : seedlen); if (!seed_plus) { @@ -1709,7 +1709,7 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, /* Step 4: b = L - 1 - (n * outlen) */ value_b = pbits - 1 - (value_n * qbits); - restart: + restart: /* Generate Q. */ for (;;) { @@ -1721,7 +1721,7 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, gcry_create_nonce (seed_help_buffer, seedlen); seed = seed_help_buffer; } - + /* Step 6: U = hash(seed) */ gcry_md_hash_buffer (hashalgo, value_u, seed, seedlen); @@ -1736,12 +1736,12 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, } } gcry_mpi_release (prime_q); prime_q = NULL; - ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG, + ec = gpg_err_code (gcry_mpi_scan (&prime_q, GCRYMPI_FMT_USG, value_u, sizeof value_u, NULL)); if (ec) goto leave; mpi_set_highbit (prime_q, qbits-1 ); - + /* Step 8: Test whether Q is prime using 64 round of Rabin-Miller. According to table C.1 this is sufficient for all supported prime sizes (i.e. up 3072/256). */ @@ -1751,7 +1751,7 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, /* Step 8. */ seed = NULL; /* Force a new seed at Step 5. */ } - + /* Step 11. Note that we do no use an explicit offset but increment SEED_PLUS accordingly. */ memcpy (seed_plus, seed, seedlen); @@ -1761,12 +1761,12 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, prime_p = gcry_mpi_new (pbits); for (;;) { - /* Step 11.1: For j = 0,...n let - V_j = hash(seed+offset+j) - Step 11.2: W = V_0 + V_1*2^outlen + - ... + /* Step 11.1: For j = 0,...n let + V_j = hash(seed+offset+j) + Step 11.2: W = V_0 + V_1*2^outlen + + ... + V_{n-1}*2^{(n-1)*outlen} - + (V_{n} mod 2^b)*2^{n*outlen} + + (V_{n} mod 2^b)*2^{n*outlen} */ mpi_set_ui (value_w, 0); for (value_j=0; value_j <= value_n; value_j++) @@ -1783,7 +1783,7 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, break; } gcry_md_hash_buffer (GCRY_MD_SHA1, digest, seed_plus, seedlen); - + gcry_mpi_release (tmpval); tmpval = NULL; ec = gpg_err_code (gcry_mpi_scan (&tmpval, GCRYMPI_FMT_USG, digest, sizeof digest, NULL)); @@ -1813,7 +1813,7 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, if (mpi_get_nbits (prime_p) >= pbits-1 && check_prime (prime_p, val_2, 64, NULL, NULL) ) break; /* Yes, P is prime, continue with Step 15. */ - + /* Step 11.9: counter = counter + 1, offset = offset + n + 1. If counter >= 4L goto Step 5. */ counter++; @@ -1859,4 +1859,3 @@ _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, gcry_mpi_release (val_2); return ec; } - diff --git a/cipher/rfc2268.c b/cipher/rfc2268.c index 9575ca68..1c9c8d41 100644 --- a/cipher/rfc2268.c +++ b/cipher/rfc2268.c @@ -38,15 +38,15 @@ #define RFC2268_BLOCKSIZE 8 -typedef struct +typedef struct { u16 S[64]; } RFC2268_context; -static const unsigned char rfc2268_sbox[] = { - 217, 120, 249, 196, 25, 221, 181, 237, +static const unsigned char rfc2268_sbox[] = { + 217, 120, 249, 196, 25, 221, 181, 237, 40, 233, 253, 121, 74, 160, 216, 157, - 198, 126, 55, 131, 43, 118, 83, 142, + 198, 126, 55, 131, 43, 118, 83, 142, 98, 76, 100, 136, 68, 139, 251, 162, 23, 154, 89, 245, 135, 179, 79, 19, 97, 69, 109, 141, 9, 129, 125, 50, @@ -106,10 +106,10 @@ do_encrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf) /* For some reason I cannot combine those steps. */ word0 += (word1 & ~word3) + (word2 & word3) + ctx->S[j]; word0 = rotl16(word0, 1); - + word1 += (word2 & ~word0) + (word3 & word0) + ctx->S[j + 1]; word1 = rotl16(word1, 2); - + word2 += (word3 & ~word1) + (word0 & word1) + ctx->S[j + 2]; word2 = rotl16(word2, 3); @@ -152,7 +152,7 @@ do_decrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf) word3 = (word3 << 8) | inbuf[7]; word3 = (word3 << 8) | inbuf[6]; - for (i = 15; i >= 0; i--) + for (i = 15; i >= 0; i--) { j = i * 4; @@ -168,7 +168,7 @@ do_decrypt (void *context, unsigned char *outbuf, const unsigned char *inbuf) word0 = rotr16(word0, 1); word0 -= (word1 & ~word3) + (word2 & word3) + ctx->S[j]; - if (i == 5 || i == 11) + if (i == 5 || i == 11) { word3 = word3 - ctx->S[word2 & 63]; word2 = word2 - ctx->S[word1 & 63]; @@ -214,7 +214,7 @@ setkey_core (void *context, const unsigned char *key, unsigned int keylen, int w return GPG_ERR_INV_KEYLEN; S = (unsigned char *) ctx->S; - + for (i = 0; i < keylen; i++) S[i] = key[i]; @@ -232,8 +232,8 @@ setkey_core (void *context, const unsigned char *key, unsigned int keylen, int w i = 128 - len; x = rfc2268_sbox[S[i] & (255 >> (7 & -bits))]; S[i] = x; - - while (i--) + + while (i--) { x = rfc2268_sbox[x ^ S[i + len]]; S[i] = x; @@ -241,7 +241,7 @@ setkey_core (void *context, const unsigned char *key, unsigned int keylen, int w } /* Make the expanded key, endian independent. */ - for (i = 0; i < 64; i++) + for (i = 0; i < 64; i++) ctx->S[i] = ( (u16) S[i * 2] | (((u16) S[i * 2 + 1]) << 8)); return 0; @@ -297,7 +297,7 @@ selftest (void) return "RFC2268 encryption test 1 failed."; setkey_core (&ctx, key_1, sizeof(key_1), 0); - do_decrypt (&ctx, scratch, scratch); + do_decrypt (&ctx, scratch, scratch); if (memcmp (scratch, plaintext_1, sizeof(plaintext_1))) return "RFC2268 decryption test 1 failed."; @@ -308,7 +308,7 @@ selftest (void) return "RFC2268 encryption test 2 failed."; setkey_core (&ctx, key_2, sizeof(key_2), 0); - do_decrypt (&ctx, scratch, scratch); + do_decrypt (&ctx, scratch, scratch); if (memcmp (scratch, plaintext_2, sizeof(plaintext_2))) return "RFC2268 decryption test 2 failed."; @@ -320,7 +320,7 @@ selftest (void) return "RFC2268 encryption test 3 failed."; setkey_core (&ctx, key_3, sizeof(key_3), 0); - do_decrypt (&ctx, scratch, scratch); + do_decrypt (&ctx, scratch, scratch); if (memcmp(scratch, plaintext_3, sizeof(plaintext_3))) return "RFC2268 decryption test 3 failed."; @@ -342,4 +342,3 @@ gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40 = { RFC2268_BLOCKSIZE, 40, sizeof(RFC2268_context), do_setkey, do_encrypt, do_decrypt }; - diff --git a/cipher/rijndael-tables.h b/cipher/rijndael-tables.h index c9b6d779..b6a5b158 100644 --- a/cipher/rijndael-tables.h +++ b/cipher/rijndael-tables.h @@ -1,4 +1,4 @@ -/* rijndael-tables.h - Rijndael (AES) for GnuPG, +/* rijndael-tables.h - Rijndael (AES) for GnuPG, * Copyright (C) 2000, 2001, 2002, 2003, 2007, * 2008 Free Software Foundation, Inc. * @@ -21,1100 +21,1100 @@ /* To keep the actual implementation at a readable size we use this include file to define the tables. */ -static const unsigned char S[256] = +static const unsigned char S[256] = { 99, 124, 119, 123, 242, 107, 111, 197, - 48, 1, 103, 43, 254, 215, 171, 118, + 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, - 173, 212, 162, 175, 156, 164, 114, 192, + 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, - 52, 165, 229, 241, 113, 216, 49, 21, + 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, - 7, 18, 128, 226, 235, 39, 178, 117, - 9, 131, 44, 26, 27, 110, 90, 160, - 82, 59, 214, 179, 41, 227, 47, 132, + 7, 18, 128, 226, 235, 39, 178, 117, + 9, 131, 44, 26, 27, 110, 90, 160, + 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, - 106, 203, 190, 57, 74, 76, 88, 207, + 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, - 69, 249, 2, 127, 80, 60, 159, 168, + 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, - 188, 182, 218, 33, 16, 255, 243, 210, + 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, - 196, 167, 126, 61, 100, 93, 25, 115, + 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, - 70, 238, 184, 20, 222, 94, 11, 219, + 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, - 194, 211, 172, 98, 145, 149, 228, 121, - 231, 200, 55, 109, 141, 213, 78, 169, - 108, 86, 244, 234, 101, 122, 174, 8, - 186, 120, 37, 46, 28, 166, 180, 198, - 232, 221, 116, 31, 75, 189, 139, 138, + 194, 211, 172, 98, 145, 149, 228, 121, + 231, 200, 55, 109, 141, 213, 78, 169, + 108, 86, 244, 234, 101, 122, 174, 8, + 186, 120, 37, 46, 28, 166, 180, 198, + 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, - 97, 53, 87, 185, 134, 193, 29, 158, + 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, - 155, 30, 135, 233, 206, 85, 40, 223, - 140, 161, 137, 13, 191, 230, 66, 104, + 155, 30, 135, 233, 206, 85, 40, 223, + 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22 }; -static const unsigned char T1[256][4] = +static const unsigned char T1[256][4] = { { 0xc6,0x63,0x63,0xa5 }, { 0xf8,0x7c,0x7c,0x84 }, - { 0xee,0x77,0x77,0x99 }, { 0xf6,0x7b,0x7b,0x8d }, + { 0xee,0x77,0x77,0x99 }, { 0xf6,0x7b,0x7b,0x8d }, { 0xff,0xf2,0xf2,0x0d }, { 0xd6,0x6b,0x6b,0xbd }, - { 0xde,0x6f,0x6f,0xb1 }, { 0x91,0xc5,0xc5,0x54 }, + { 0xde,0x6f,0x6f,0xb1 }, { 0x91,0xc5,0xc5,0x54 }, { 0x60,0x30,0x30,0x50 }, { 0x02,0x01,0x01,0x03 }, - { 0xce,0x67,0x67,0xa9 }, { 0x56,0x2b,0x2b,0x7d }, + { 0xce,0x67,0x67,0xa9 }, { 0x56,0x2b,0x2b,0x7d }, { 0xe7,0xfe,0xfe,0x19 }, { 0xb5,0xd7,0xd7,0x62 }, - { 0x4d,0xab,0xab,0xe6 }, { 0xec,0x76,0x76,0x9a }, + { 0x4d,0xab,0xab,0xe6 }, { 0xec,0x76,0x76,0x9a }, { 0x8f,0xca,0xca,0x45 }, { 0x1f,0x82,0x82,0x9d }, - { 0x89,0xc9,0xc9,0x40 }, { 0xfa,0x7d,0x7d,0x87 }, - { 0xef,0xfa,0xfa,0x15 }, { 0xb2,0x59,0x59,0xeb }, - { 0x8e,0x47,0x47,0xc9 }, { 0xfb,0xf0,0xf0,0x0b }, + { 0x89,0xc9,0xc9,0x40 }, { 0xfa,0x7d,0x7d,0x87 }, + { 0xef,0xfa,0xfa,0x15 }, { 0xb2,0x59,0x59,0xeb }, + { 0x8e,0x47,0x47,0xc9 }, { 0xfb,0xf0,0xf0,0x0b }, { 0x41,0xad,0xad,0xec }, { 0xb3,0xd4,0xd4,0x67 }, - { 0x5f,0xa2,0xa2,0xfd }, { 0x45,0xaf,0xaf,0xea }, + { 0x5f,0xa2,0xa2,0xfd }, { 0x45,0xaf,0xaf,0xea }, { 0x23,0x9c,0x9c,0xbf }, { 0x53,0xa4,0xa4,0xf7 }, - { 0xe4,0x72,0x72,0x96 }, { 0x9b,0xc0,0xc0,0x5b }, + { 0xe4,0x72,0x72,0x96 }, { 0x9b,0xc0,0xc0,0x5b }, { 0x75,0xb7,0xb7,0xc2 }, { 0xe1,0xfd,0xfd,0x1c }, - { 0x3d,0x93,0x93,0xae }, { 0x4c,0x26,0x26,0x6a }, + { 0x3d,0x93,0x93,0xae }, { 0x4c,0x26,0x26,0x6a }, { 0x6c,0x36,0x36,0x5a }, { 0x7e,0x3f,0x3f,0x41 }, - { 0xf5,0xf7,0xf7,0x02 }, { 0x83,0xcc,0xcc,0x4f }, - { 0x68,0x34,0x34,0x5c }, { 0x51,0xa5,0xa5,0xf4 }, - { 0xd1,0xe5,0xe5,0x34 }, { 0xf9,0xf1,0xf1,0x08 }, + { 0xf5,0xf7,0xf7,0x02 }, { 0x83,0xcc,0xcc,0x4f }, + { 0x68,0x34,0x34,0x5c }, { 0x51,0xa5,0xa5,0xf4 }, + { 0xd1,0xe5,0xe5,0x34 }, { 0xf9,0xf1,0xf1,0x08 }, { 0xe2,0x71,0x71,0x93 }, { 0xab,0xd8,0xd8,0x73 }, - { 0x62,0x31,0x31,0x53 }, { 0x2a,0x15,0x15,0x3f }, + { 0x62,0x31,0x31,0x53 }, { 0x2a,0x15,0x15,0x3f }, { 0x08,0x04,0x04,0x0c }, { 0x95,0xc7,0xc7,0x52 }, - { 0x46,0x23,0x23,0x65 }, { 0x9d,0xc3,0xc3,0x5e }, + { 0x46,0x23,0x23,0x65 }, { 0x9d,0xc3,0xc3,0x5e }, { 0x30,0x18,0x18,0x28 }, { 0x37,0x96,0x96,0xa1 }, - { 0x0a,0x05,0x05,0x0f }, { 0x2f,0x9a,0x9a,0xb5 }, + { 0x0a,0x05,0x05,0x0f }, { 0x2f,0x9a,0x9a,0xb5 }, { 0x0e,0x07,0x07,0x09 }, { 0x24,0x12,0x12,0x36 }, - { 0x1b,0x80,0x80,0x9b }, { 0xdf,0xe2,0xe2,0x3d }, + { 0x1b,0x80,0x80,0x9b }, { 0xdf,0xe2,0xe2,0x3d }, { 0xcd,0xeb,0xeb,0x26 }, { 0x4e,0x27,0x27,0x69 }, - { 0x7f,0xb2,0xb2,0xcd }, { 0xea,0x75,0x75,0x9f }, + { 0x7f,0xb2,0xb2,0xcd }, { 0xea,0x75,0x75,0x9f }, { 0x12,0x09,0x09,0x1b }, { 0x1d,0x83,0x83,0x9e }, - { 0x58,0x2c,0x2c,0x74 }, { 0x34,0x1a,0x1a,0x2e }, - { 0x36,0x1b,0x1b,0x2d }, { 0xdc,0x6e,0x6e,0xb2 }, - { 0xb4,0x5a,0x5a,0xee }, { 0x5b,0xa0,0xa0,0xfb }, + { 0x58,0x2c,0x2c,0x74 }, { 0x34,0x1a,0x1a,0x2e }, + { 0x36,0x1b,0x1b,0x2d }, { 0xdc,0x6e,0x6e,0xb2 }, + { 0xb4,0x5a,0x5a,0xee }, { 0x5b,0xa0,0xa0,0xfb }, { 0xa4,0x52,0x52,0xf6 }, { 0x76,0x3b,0x3b,0x4d }, - { 0xb7,0xd6,0xd6,0x61 }, { 0x7d,0xb3,0xb3,0xce }, - { 0x52,0x29,0x29,0x7b }, { 0xdd,0xe3,0xe3,0x3e }, - { 0x5e,0x2f,0x2f,0x71 }, { 0x13,0x84,0x84,0x97 }, - { 0xa6,0x53,0x53,0xf5 }, { 0xb9,0xd1,0xd1,0x68 }, - { 0x00,0x00,0x00,0x00 }, { 0xc1,0xed,0xed,0x2c }, + { 0xb7,0xd6,0xd6,0x61 }, { 0x7d,0xb3,0xb3,0xce }, + { 0x52,0x29,0x29,0x7b }, { 0xdd,0xe3,0xe3,0x3e }, + { 0x5e,0x2f,0x2f,0x71 }, { 0x13,0x84,0x84,0x97 }, + { 0xa6,0x53,0x53,0xf5 }, { 0xb9,0xd1,0xd1,0x68 }, + { 0x00,0x00,0x00,0x00 }, { 0xc1,0xed,0xed,0x2c }, { 0x40,0x20,0x20,0x60 }, { 0xe3,0xfc,0xfc,0x1f }, - { 0x79,0xb1,0xb1,0xc8 }, { 0xb6,0x5b,0x5b,0xed }, + { 0x79,0xb1,0xb1,0xc8 }, { 0xb6,0x5b,0x5b,0xed }, { 0xd4,0x6a,0x6a,0xbe }, { 0x8d,0xcb,0xcb,0x46 }, - { 0x67,0xbe,0xbe,0xd9 }, { 0x72,0x39,0x39,0x4b }, + { 0x67,0xbe,0xbe,0xd9 }, { 0x72,0x39,0x39,0x4b }, { 0x94,0x4a,0x4a,0xde }, { 0x98,0x4c,0x4c,0xd4 }, - { 0xb0,0x58,0x58,0xe8 }, { 0x85,0xcf,0xcf,0x4a }, + { 0xb0,0x58,0x58,0xe8 }, { 0x85,0xcf,0xcf,0x4a }, { 0xbb,0xd0,0xd0,0x6b }, { 0xc5,0xef,0xef,0x2a }, - { 0x4f,0xaa,0xaa,0xe5 }, { 0xed,0xfb,0xfb,0x16 }, + { 0x4f,0xaa,0xaa,0xe5 }, { 0xed,0xfb,0xfb,0x16 }, { 0x86,0x43,0x43,0xc5 }, { 0x9a,0x4d,0x4d,0xd7 }, - { 0x66,0x33,0x33,0x55 }, { 0x11,0x85,0x85,0x94 }, + { 0x66,0x33,0x33,0x55 }, { 0x11,0x85,0x85,0x94 }, { 0x8a,0x45,0x45,0xcf }, { 0xe9,0xf9,0xf9,0x10 }, - { 0x04,0x02,0x02,0x06 }, { 0xfe,0x7f,0x7f,0x81 }, + { 0x04,0x02,0x02,0x06 }, { 0xfe,0x7f,0x7f,0x81 }, { 0xa0,0x50,0x50,0xf0 }, { 0x78,0x3c,0x3c,0x44 }, - { 0x25,0x9f,0x9f,0xba }, { 0x4b,0xa8,0xa8,0xe3 }, + { 0x25,0x9f,0x9f,0xba }, { 0x4b,0xa8,0xa8,0xe3 }, { 0xa2,0x51,0x51,0xf3 }, { 0x5d,0xa3,0xa3,0xfe }, - { 0x80,0x40,0x40,0xc0 }, { 0x05,0x8f,0x8f,0x8a }, + { 0x80,0x40,0x40,0xc0 }, { 0x05,0x8f,0x8f,0x8a }, { 0x3f,0x92,0x92,0xad }, { 0x21,0x9d,0x9d,0xbc }, - { 0x70,0x38,0x38,0x48 }, { 0xf1,0xf5,0xf5,0x04 }, + { 0x70,0x38,0x38,0x48 }, { 0xf1,0xf5,0xf5,0x04 }, { 0x63,0xbc,0xbc,0xdf }, { 0x77,0xb6,0xb6,0xc1 }, - { 0xaf,0xda,0xda,0x75 }, { 0x42,0x21,0x21,0x63 }, + { 0xaf,0xda,0xda,0x75 }, { 0x42,0x21,0x21,0x63 }, { 0x20,0x10,0x10,0x30 }, { 0xe5,0xff,0xff,0x1a }, - { 0xfd,0xf3,0xf3,0x0e }, { 0xbf,0xd2,0xd2,0x6d }, + { 0xfd,0xf3,0xf3,0x0e }, { 0xbf,0xd2,0xd2,0x6d }, { 0x81,0xcd,0xcd,0x4c }, { 0x18,0x0c,0x0c,0x14 }, - { 0x26,0x13,0x13,0x35 }, { 0xc3,0xec,0xec,0x2f }, + { 0x26,0x13,0x13,0x35 }, { 0xc3,0xec,0xec,0x2f }, { 0xbe,0x5f,0x5f,0xe1 }, { 0x35,0x97,0x97,0xa2 }, - { 0x88,0x44,0x44,0xcc }, { 0x2e,0x17,0x17,0x39 }, + { 0x88,0x44,0x44,0xcc }, { 0x2e,0x17,0x17,0x39 }, { 0x93,0xc4,0xc4,0x57 }, { 0x55,0xa7,0xa7,0xf2 }, - { 0xfc,0x7e,0x7e,0x82 }, { 0x7a,0x3d,0x3d,0x47 }, + { 0xfc,0x7e,0x7e,0x82 }, { 0x7a,0x3d,0x3d,0x47 }, { 0xc8,0x64,0x64,0xac }, { 0xba,0x5d,0x5d,0xe7 }, - { 0x32,0x19,0x19,0x2b }, { 0xe6,0x73,0x73,0x95 }, + { 0x32,0x19,0x19,0x2b }, { 0xe6,0x73,0x73,0x95 }, { 0xc0,0x60,0x60,0xa0 }, { 0x19,0x81,0x81,0x98 }, - { 0x9e,0x4f,0x4f,0xd1 }, { 0xa3,0xdc,0xdc,0x7f }, + { 0x9e,0x4f,0x4f,0xd1 }, { 0xa3,0xdc,0xdc,0x7f }, { 0x44,0x22,0x22,0x66 }, { 0x54,0x2a,0x2a,0x7e }, - { 0x3b,0x90,0x90,0xab }, { 0x0b,0x88,0x88,0x83 }, + { 0x3b,0x90,0x90,0xab }, { 0x0b,0x88,0x88,0x83 }, { 0x8c,0x46,0x46,0xca }, { 0xc7,0xee,0xee,0x29 }, - { 0x6b,0xb8,0xb8,0xd3 }, { 0x28,0x14,0x14,0x3c }, + { 0x6b,0xb8,0xb8,0xd3 }, { 0x28,0x14,0x14,0x3c }, { 0xa7,0xde,0xde,0x79 }, { 0xbc,0x5e,0x5e,0xe2 }, - { 0x16,0x0b,0x0b,0x1d }, { 0xad,0xdb,0xdb,0x76 }, + { 0x16,0x0b,0x0b,0x1d }, { 0xad,0xdb,0xdb,0x76 }, { 0xdb,0xe0,0xe0,0x3b }, { 0x64,0x32,0x32,0x56 }, - { 0x74,0x3a,0x3a,0x4e }, { 0x14,0x0a,0x0a,0x1e }, + { 0x74,0x3a,0x3a,0x4e }, { 0x14,0x0a,0x0a,0x1e }, { 0x92,0x49,0x49,0xdb }, { 0x0c,0x06,0x06,0x0a }, - { 0x48,0x24,0x24,0x6c }, { 0xb8,0x5c,0x5c,0xe4 }, + { 0x48,0x24,0x24,0x6c }, { 0xb8,0x5c,0x5c,0xe4 }, { 0x9f,0xc2,0xc2,0x5d }, { 0xbd,0xd3,0xd3,0x6e }, - { 0x43,0xac,0xac,0xef }, { 0xc4,0x62,0x62,0xa6 }, + { 0x43,0xac,0xac,0xef }, { 0xc4,0x62,0x62,0xa6 }, { 0x39,0x91,0x91,0xa8 }, { 0x31,0x95,0x95,0xa4 }, - { 0xd3,0xe4,0xe4,0x37 }, { 0xf2,0x79,0x79,0x8b }, + { 0xd3,0xe4,0xe4,0x37 }, { 0xf2,0x79,0x79,0x8b }, { 0xd5,0xe7,0xe7,0x32 }, { 0x8b,0xc8,0xc8,0x43 }, - { 0x6e,0x37,0x37,0x59 }, { 0xda,0x6d,0x6d,0xb7 }, + { 0x6e,0x37,0x37,0x59 }, { 0xda,0x6d,0x6d,0xb7 }, { 0x01,0x8d,0x8d,0x8c }, { 0xb1,0xd5,0xd5,0x64 }, - { 0x9c,0x4e,0x4e,0xd2 }, { 0x49,0xa9,0xa9,0xe0 }, + { 0x9c,0x4e,0x4e,0xd2 }, { 0x49,0xa9,0xa9,0xe0 }, { 0xd8,0x6c,0x6c,0xb4 }, { 0xac,0x56,0x56,0xfa }, - { 0xf3,0xf4,0xf4,0x07 }, { 0xcf,0xea,0xea,0x25 }, + { 0xf3,0xf4,0xf4,0x07 }, { 0xcf,0xea,0xea,0x25 }, { 0xca,0x65,0x65,0xaf }, { 0xf4,0x7a,0x7a,0x8e }, - { 0x47,0xae,0xae,0xe9 }, { 0x10,0x08,0x08,0x18 }, + { 0x47,0xae,0xae,0xe9 }, { 0x10,0x08,0x08,0x18 }, { 0x6f,0xba,0xba,0xd5 }, { 0xf0,0x78,0x78,0x88 }, - { 0x4a,0x25,0x25,0x6f }, { 0x5c,0x2e,0x2e,0x72 }, + { 0x4a,0x25,0x25,0x6f }, { 0x5c,0x2e,0x2e,0x72 }, { 0x38,0x1c,0x1c,0x24 }, { 0x57,0xa6,0xa6,0xf1 }, - { 0x73,0xb4,0xb4,0xc7 }, { 0x97,0xc6,0xc6,0x51 }, + { 0x73,0xb4,0xb4,0xc7 }, { 0x97,0xc6,0xc6,0x51 }, { 0xcb,0xe8,0xe8,0x23 }, { 0xa1,0xdd,0xdd,0x7c }, - { 0xe8,0x74,0x74,0x9c }, { 0x3e,0x1f,0x1f,0x21 }, - { 0x96,0x4b,0x4b,0xdd }, { 0x61,0xbd,0xbd,0xdc }, - { 0x0d,0x8b,0x8b,0x86 }, { 0x0f,0x8a,0x8a,0x85 }, + { 0xe8,0x74,0x74,0x9c }, { 0x3e,0x1f,0x1f,0x21 }, + { 0x96,0x4b,0x4b,0xdd }, { 0x61,0xbd,0xbd,0xdc }, + { 0x0d,0x8b,0x8b,0x86 }, { 0x0f,0x8a,0x8a,0x85 }, { 0xe0,0x70,0x70,0x90 }, { 0x7c,0x3e,0x3e,0x42 }, - { 0x71,0xb5,0xb5,0xc4 }, { 0xcc,0x66,0x66,0xaa }, + { 0x71,0xb5,0xb5,0xc4 }, { 0xcc,0x66,0x66,0xaa }, { 0x90,0x48,0x48,0xd8 }, { 0x06,0x03,0x03,0x05 }, - { 0xf7,0xf6,0xf6,0x01 }, { 0x1c,0x0e,0x0e,0x12 }, + { 0xf7,0xf6,0xf6,0x01 }, { 0x1c,0x0e,0x0e,0x12 }, { 0xc2,0x61,0x61,0xa3 }, { 0x6a,0x35,0x35,0x5f }, - { 0xae,0x57,0x57,0xf9 }, { 0x69,0xb9,0xb9,0xd0 }, + { 0xae,0x57,0x57,0xf9 }, { 0x69,0xb9,0xb9,0xd0 }, { 0x17,0x86,0x86,0x91 }, { 0x99,0xc1,0xc1,0x58 }, - { 0x3a,0x1d,0x1d,0x27 }, { 0x27,0x9e,0x9e,0xb9 }, + { 0x3a,0x1d,0x1d,0x27 }, { 0x27,0x9e,0x9e,0xb9 }, { 0xd9,0xe1,0xe1,0x38 }, { 0xeb,0xf8,0xf8,0x13 }, - { 0x2b,0x98,0x98,0xb3 }, { 0x22,0x11,0x11,0x33 }, + { 0x2b,0x98,0x98,0xb3 }, { 0x22,0x11,0x11,0x33 }, { 0xd2,0x69,0x69,0xbb }, { 0xa9,0xd9,0xd9,0x70 }, - { 0x07,0x8e,0x8e,0x89 }, { 0x33,0x94,0x94,0xa7 }, + { 0x07,0x8e,0x8e,0x89 }, { 0x33,0x94,0x94,0xa7 }, { 0x2d,0x9b,0x9b,0xb6 }, { 0x3c,0x1e,0x1e,0x22 }, - { 0x15,0x87,0x87,0x92 }, { 0xc9,0xe9,0xe9,0x20 }, + { 0x15,0x87,0x87,0x92 }, { 0xc9,0xe9,0xe9,0x20 }, { 0x87,0xce,0xce,0x49 }, { 0xaa,0x55,0x55,0xff }, - { 0x50,0x28,0x28,0x78 }, { 0xa5,0xdf,0xdf,0x7a }, + { 0x50,0x28,0x28,0x78 }, { 0xa5,0xdf,0xdf,0x7a }, { 0x03,0x8c,0x8c,0x8f }, { 0x59,0xa1,0xa1,0xf8 }, - { 0x09,0x89,0x89,0x80 }, { 0x1a,0x0d,0x0d,0x17 }, + { 0x09,0x89,0x89,0x80 }, { 0x1a,0x0d,0x0d,0x17 }, { 0x65,0xbf,0xbf,0xda }, { 0xd7,0xe6,0xe6,0x31 }, - { 0x84,0x42,0x42,0xc6 }, { 0xd0,0x68,0x68,0xb8 }, + { 0x84,0x42,0x42,0xc6 }, { 0xd0,0x68,0x68,0xb8 }, { 0x82,0x41,0x41,0xc3 }, { 0x29,0x99,0x99,0xb0 }, - { 0x5a,0x2d,0x2d,0x77 }, { 0x1e,0x0f,0x0f,0x11 }, + { 0x5a,0x2d,0x2d,0x77 }, { 0x1e,0x0f,0x0f,0x11 }, { 0x7b,0xb0,0xb0,0xcb }, { 0xa8,0x54,0x54,0xfc }, { 0x6d,0xbb,0xbb,0xd6 }, { 0x2c,0x16,0x16,0x3a } }; -static const unsigned char T2[256][4] = +static const unsigned char T2[256][4] = { { 0xa5,0xc6,0x63,0x63 }, { 0x84,0xf8,0x7c,0x7c }, - { 0x99,0xee,0x77,0x77 }, { 0x8d,0xf6,0x7b,0x7b }, + { 0x99,0xee,0x77,0x77 }, { 0x8d,0xf6,0x7b,0x7b }, { 0x0d,0xff,0xf2,0xf2 }, { 0xbd,0xd6,0x6b,0x6b }, - { 0xb1,0xde,0x6f,0x6f }, { 0x54,0x91,0xc5,0xc5 }, + { 0xb1,0xde,0x6f,0x6f }, { 0x54,0x91,0xc5,0xc5 }, { 0x50,0x60,0x30,0x30 }, { 0x03,0x02,0x01,0x01 }, - { 0xa9,0xce,0x67,0x67 }, { 0x7d,0x56,0x2b,0x2b }, - { 0x19,0xe7,0xfe,0xfe }, { 0x62,0xb5,0xd7,0xd7 }, - { 0xe6,0x4d,0xab,0xab }, { 0x9a,0xec,0x76,0x76 }, - { 0x45,0x8f,0xca,0xca }, { 0x9d,0x1f,0x82,0x82 }, - { 0x40,0x89,0xc9,0xc9 }, { 0x87,0xfa,0x7d,0x7d }, - { 0x15,0xef,0xfa,0xfa }, { 0xeb,0xb2,0x59,0x59 }, - { 0xc9,0x8e,0x47,0x47 }, { 0x0b,0xfb,0xf0,0xf0 }, - { 0xec,0x41,0xad,0xad }, { 0x67,0xb3,0xd4,0xd4 }, - { 0xfd,0x5f,0xa2,0xa2 }, { 0xea,0x45,0xaf,0xaf }, - { 0xbf,0x23,0x9c,0x9c }, { 0xf7,0x53,0xa4,0xa4 }, - { 0x96,0xe4,0x72,0x72 }, { 0x5b,0x9b,0xc0,0xc0 }, - { 0xc2,0x75,0xb7,0xb7 }, { 0x1c,0xe1,0xfd,0xfd }, - { 0xae,0x3d,0x93,0x93 }, { 0x6a,0x4c,0x26,0x26 }, + { 0xa9,0xce,0x67,0x67 }, { 0x7d,0x56,0x2b,0x2b }, + { 0x19,0xe7,0xfe,0xfe }, { 0x62,0xb5,0xd7,0xd7 }, + { 0xe6,0x4d,0xab,0xab }, { 0x9a,0xec,0x76,0x76 }, + { 0x45,0x8f,0xca,0xca }, { 0x9d,0x1f,0x82,0x82 }, + { 0x40,0x89,0xc9,0xc9 }, { 0x87,0xfa,0x7d,0x7d }, + { 0x15,0xef,0xfa,0xfa }, { 0xeb,0xb2,0x59,0x59 }, + { 0xc9,0x8e,0x47,0x47 }, { 0x0b,0xfb,0xf0,0xf0 }, + { 0xec,0x41,0xad,0xad }, { 0x67,0xb3,0xd4,0xd4 }, + { 0xfd,0x5f,0xa2,0xa2 }, { 0xea,0x45,0xaf,0xaf }, + { 0xbf,0x23,0x9c,0x9c }, { 0xf7,0x53,0xa4,0xa4 }, + { 0x96,0xe4,0x72,0x72 }, { 0x5b,0x9b,0xc0,0xc0 }, + { 0xc2,0x75,0xb7,0xb7 }, { 0x1c,0xe1,0xfd,0xfd }, + { 0xae,0x3d,0x93,0x93 }, { 0x6a,0x4c,0x26,0x26 }, { 0x5a,0x6c,0x36,0x36 }, { 0x41,0x7e,0x3f,0x3f }, - { 0x02,0xf5,0xf7,0xf7 }, { 0x4f,0x83,0xcc,0xcc }, + { 0x02,0xf5,0xf7,0xf7 }, { 0x4f,0x83,0xcc,0xcc }, { 0x5c,0x68,0x34,0x34 }, { 0xf4,0x51,0xa5,0xa5 }, - { 0x34,0xd1,0xe5,0xe5 }, { 0x08,0xf9,0xf1,0xf1 }, + { 0x34,0xd1,0xe5,0xe5 }, { 0x08,0xf9,0xf1,0xf1 }, { 0x93,0xe2,0x71,0x71 }, { 0x73,0xab,0xd8,0xd8 }, - { 0x53,0x62,0x31,0x31 }, { 0x3f,0x2a,0x15,0x15 }, - { 0x0c,0x08,0x04,0x04 }, { 0x52,0x95,0xc7,0xc7 }, - { 0x65,0x46,0x23,0x23 }, { 0x5e,0x9d,0xc3,0xc3 }, - { 0x28,0x30,0x18,0x18 }, { 0xa1,0x37,0x96,0x96 }, - { 0x0f,0x0a,0x05,0x05 }, { 0xb5,0x2f,0x9a,0x9a }, + { 0x53,0x62,0x31,0x31 }, { 0x3f,0x2a,0x15,0x15 }, + { 0x0c,0x08,0x04,0x04 }, { 0x52,0x95,0xc7,0xc7 }, + { 0x65,0x46,0x23,0x23 }, { 0x5e,0x9d,0xc3,0xc3 }, + { 0x28,0x30,0x18,0x18 }, { 0xa1,0x37,0x96,0x96 }, + { 0x0f,0x0a,0x05,0x05 }, { 0xb5,0x2f,0x9a,0x9a }, { 0x09,0x0e,0x07,0x07 }, { 0x36,0x24,0x12,0x12 }, - { 0x9b,0x1b,0x80,0x80 }, { 0x3d,0xdf,0xe2,0xe2 }, - { 0x26,0xcd,0xeb,0xeb }, { 0x69,0x4e,0x27,0x27 }, - { 0xcd,0x7f,0xb2,0xb2 }, { 0x9f,0xea,0x75,0x75 }, + { 0x9b,0x1b,0x80,0x80 }, { 0x3d,0xdf,0xe2,0xe2 }, + { 0x26,0xcd,0xeb,0xeb }, { 0x69,0x4e,0x27,0x27 }, + { 0xcd,0x7f,0xb2,0xb2 }, { 0x9f,0xea,0x75,0x75 }, { 0x1b,0x12,0x09,0x09 }, { 0x9e,0x1d,0x83,0x83 }, - { 0x74,0x58,0x2c,0x2c }, { 0x2e,0x34,0x1a,0x1a }, + { 0x74,0x58,0x2c,0x2c }, { 0x2e,0x34,0x1a,0x1a }, { 0x2d,0x36,0x1b,0x1b }, { 0xb2,0xdc,0x6e,0x6e }, - { 0xee,0xb4,0x5a,0x5a }, { 0xfb,0x5b,0xa0,0xa0 }, + { 0xee,0xb4,0x5a,0x5a }, { 0xfb,0x5b,0xa0,0xa0 }, { 0xf6,0xa4,0x52,0x52 }, { 0x4d,0x76,0x3b,0x3b }, - { 0x61,0xb7,0xd6,0xd6 }, { 0xce,0x7d,0xb3,0xb3 }, - { 0x7b,0x52,0x29,0x29 }, { 0x3e,0xdd,0xe3,0xe3 }, - { 0x71,0x5e,0x2f,0x2f }, { 0x97,0x13,0x84,0x84 }, - { 0xf5,0xa6,0x53,0x53 }, { 0x68,0xb9,0xd1,0xd1 }, - { 0x00,0x00,0x00,0x00 }, { 0x2c,0xc1,0xed,0xed }, - { 0x60,0x40,0x20,0x20 }, { 0x1f,0xe3,0xfc,0xfc }, - { 0xc8,0x79,0xb1,0xb1 }, { 0xed,0xb6,0x5b,0x5b }, - { 0xbe,0xd4,0x6a,0x6a }, { 0x46,0x8d,0xcb,0xcb }, - { 0xd9,0x67,0xbe,0xbe }, { 0x4b,0x72,0x39,0x39 }, - { 0xde,0x94,0x4a,0x4a }, { 0xd4,0x98,0x4c,0x4c }, - { 0xe8,0xb0,0x58,0x58 }, { 0x4a,0x85,0xcf,0xcf }, + { 0x61,0xb7,0xd6,0xd6 }, { 0xce,0x7d,0xb3,0xb3 }, + { 0x7b,0x52,0x29,0x29 }, { 0x3e,0xdd,0xe3,0xe3 }, + { 0x71,0x5e,0x2f,0x2f }, { 0x97,0x13,0x84,0x84 }, + { 0xf5,0xa6,0x53,0x53 }, { 0x68,0xb9,0xd1,0xd1 }, + { 0x00,0x00,0x00,0x00 }, { 0x2c,0xc1,0xed,0xed }, + { 0x60,0x40,0x20,0x20 }, { 0x1f,0xe3,0xfc,0xfc }, + { 0xc8,0x79,0xb1,0xb1 }, { 0xed,0xb6,0x5b,0x5b }, + { 0xbe,0xd4,0x6a,0x6a }, { 0x46,0x8d,0xcb,0xcb }, + { 0xd9,0x67,0xbe,0xbe }, { 0x4b,0x72,0x39,0x39 }, + { 0xde,0x94,0x4a,0x4a }, { 0xd4,0x98,0x4c,0x4c }, + { 0xe8,0xb0,0x58,0x58 }, { 0x4a,0x85,0xcf,0xcf }, { 0x6b,0xbb,0xd0,0xd0 }, { 0x2a,0xc5,0xef,0xef }, - { 0xe5,0x4f,0xaa,0xaa }, { 0x16,0xed,0xfb,0xfb }, - { 0xc5,0x86,0x43,0x43 }, { 0xd7,0x9a,0x4d,0x4d }, - { 0x55,0x66,0x33,0x33 }, { 0x94,0x11,0x85,0x85 }, - { 0xcf,0x8a,0x45,0x45 }, { 0x10,0xe9,0xf9,0xf9 }, - { 0x06,0x04,0x02,0x02 }, { 0x81,0xfe,0x7f,0x7f }, + { 0xe5,0x4f,0xaa,0xaa }, { 0x16,0xed,0xfb,0xfb }, + { 0xc5,0x86,0x43,0x43 }, { 0xd7,0x9a,0x4d,0x4d }, + { 0x55,0x66,0x33,0x33 }, { 0x94,0x11,0x85,0x85 }, + { 0xcf,0x8a,0x45,0x45 }, { 0x10,0xe9,0xf9,0xf9 }, + { 0x06,0x04,0x02,0x02 }, { 0x81,0xfe,0x7f,0x7f }, { 0xf0,0xa0,0x50,0x50 }, { 0x44,0x78,0x3c,0x3c }, - { 0xba,0x25,0x9f,0x9f }, { 0xe3,0x4b,0xa8,0xa8 }, + { 0xba,0x25,0x9f,0x9f }, { 0xe3,0x4b,0xa8,0xa8 }, { 0xf3,0xa2,0x51,0x51 }, { 0xfe,0x5d,0xa3,0xa3 }, - { 0xc0,0x80,0x40,0x40 }, { 0x8a,0x05,0x8f,0x8f }, + { 0xc0,0x80,0x40,0x40 }, { 0x8a,0x05,0x8f,0x8f }, { 0xad,0x3f,0x92,0x92 }, { 0xbc,0x21,0x9d,0x9d }, - { 0x48,0x70,0x38,0x38 }, { 0x04,0xf1,0xf5,0xf5 }, + { 0x48,0x70,0x38,0x38 }, { 0x04,0xf1,0xf5,0xf5 }, { 0xdf,0x63,0xbc,0xbc }, { 0xc1,0x77,0xb6,0xb6 }, - { 0x75,0xaf,0xda,0xda }, { 0x63,0x42,0x21,0x21 }, + { 0x75,0xaf,0xda,0xda }, { 0x63,0x42,0x21,0x21 }, { 0x30,0x20,0x10,0x10 }, { 0x1a,0xe5,0xff,0xff }, - { 0x0e,0xfd,0xf3,0xf3 }, { 0x6d,0xbf,0xd2,0xd2 }, + { 0x0e,0xfd,0xf3,0xf3 }, { 0x6d,0xbf,0xd2,0xd2 }, { 0x4c,0x81,0xcd,0xcd }, { 0x14,0x18,0x0c,0x0c }, - { 0x35,0x26,0x13,0x13 }, { 0x2f,0xc3,0xec,0xec }, + { 0x35,0x26,0x13,0x13 }, { 0x2f,0xc3,0xec,0xec }, { 0xe1,0xbe,0x5f,0x5f }, { 0xa2,0x35,0x97,0x97 }, - { 0xcc,0x88,0x44,0x44 }, { 0x39,0x2e,0x17,0x17 }, + { 0xcc,0x88,0x44,0x44 }, { 0x39,0x2e,0x17,0x17 }, { 0x57,0x93,0xc4,0xc4 }, { 0xf2,0x55,0xa7,0xa7 }, - { 0x82,0xfc,0x7e,0x7e }, { 0x47,0x7a,0x3d,0x3d }, + { 0x82,0xfc,0x7e,0x7e }, { 0x47,0x7a,0x3d,0x3d }, { 0xac,0xc8,0x64,0x64 }, { 0xe7,0xba,0x5d,0x5d }, - { 0x2b,0x32,0x19,0x19 }, { 0x95,0xe6,0x73,0x73 }, - { 0xa0,0xc0,0x60,0x60 }, { 0x98,0x19,0x81,0x81 }, - { 0xd1,0x9e,0x4f,0x4f }, { 0x7f,0xa3,0xdc,0xdc }, - { 0x66,0x44,0x22,0x22 }, { 0x7e,0x54,0x2a,0x2a }, - { 0xab,0x3b,0x90,0x90 }, { 0x83,0x0b,0x88,0x88 }, + { 0x2b,0x32,0x19,0x19 }, { 0x95,0xe6,0x73,0x73 }, + { 0xa0,0xc0,0x60,0x60 }, { 0x98,0x19,0x81,0x81 }, + { 0xd1,0x9e,0x4f,0x4f }, { 0x7f,0xa3,0xdc,0xdc }, + { 0x66,0x44,0x22,0x22 }, { 0x7e,0x54,0x2a,0x2a }, + { 0xab,0x3b,0x90,0x90 }, { 0x83,0x0b,0x88,0x88 }, { 0xca,0x8c,0x46,0x46 }, { 0x29,0xc7,0xee,0xee }, - { 0xd3,0x6b,0xb8,0xb8 }, { 0x3c,0x28,0x14,0x14 }, + { 0xd3,0x6b,0xb8,0xb8 }, { 0x3c,0x28,0x14,0x14 }, { 0x79,0xa7,0xde,0xde }, { 0xe2,0xbc,0x5e,0x5e }, - { 0x1d,0x16,0x0b,0x0b }, { 0x76,0xad,0xdb,0xdb }, + { 0x1d,0x16,0x0b,0x0b }, { 0x76,0xad,0xdb,0xdb }, { 0x3b,0xdb,0xe0,0xe0 }, { 0x56,0x64,0x32,0x32 }, - { 0x4e,0x74,0x3a,0x3a }, { 0x1e,0x14,0x0a,0x0a }, + { 0x4e,0x74,0x3a,0x3a }, { 0x1e,0x14,0x0a,0x0a }, { 0xdb,0x92,0x49,0x49 }, { 0x0a,0x0c,0x06,0x06 }, - { 0x6c,0x48,0x24,0x24 }, { 0xe4,0xb8,0x5c,0x5c }, - { 0x5d,0x9f,0xc2,0xc2 }, { 0x6e,0xbd,0xd3,0xd3 }, - { 0xef,0x43,0xac,0xac }, { 0xa6,0xc4,0x62,0x62 }, + { 0x6c,0x48,0x24,0x24 }, { 0xe4,0xb8,0x5c,0x5c }, + { 0x5d,0x9f,0xc2,0xc2 }, { 0x6e,0xbd,0xd3,0xd3 }, + { 0xef,0x43,0xac,0xac }, { 0xa6,0xc4,0x62,0x62 }, { 0xa8,0x39,0x91,0x91 }, { 0xa4,0x31,0x95,0x95 }, - { 0x37,0xd3,0xe4,0xe4 }, { 0x8b,0xf2,0x79,0x79 }, + { 0x37,0xd3,0xe4,0xe4 }, { 0x8b,0xf2,0x79,0x79 }, { 0x32,0xd5,0xe7,0xe7 }, { 0x43,0x8b,0xc8,0xc8 }, - { 0x59,0x6e,0x37,0x37 }, { 0xb7,0xda,0x6d,0x6d }, + { 0x59,0x6e,0x37,0x37 }, { 0xb7,0xda,0x6d,0x6d }, { 0x8c,0x01,0x8d,0x8d }, { 0x64,0xb1,0xd5,0xd5 }, - { 0xd2,0x9c,0x4e,0x4e }, { 0xe0,0x49,0xa9,0xa9 }, + { 0xd2,0x9c,0x4e,0x4e }, { 0xe0,0x49,0xa9,0xa9 }, { 0xb4,0xd8,0x6c,0x6c }, { 0xfa,0xac,0x56,0x56 }, - { 0x07,0xf3,0xf4,0xf4 }, { 0x25,0xcf,0xea,0xea }, + { 0x07,0xf3,0xf4,0xf4 }, { 0x25,0xcf,0xea,0xea }, { 0xaf,0xca,0x65,0x65 }, { 0x8e,0xf4,0x7a,0x7a }, - { 0xe9,0x47,0xae,0xae }, { 0x18,0x10,0x08,0x08 }, - { 0xd5,0x6f,0xba,0xba }, { 0x88,0xf0,0x78,0x78 }, - { 0x6f,0x4a,0x25,0x25 }, { 0x72,0x5c,0x2e,0x2e }, - { 0x24,0x38,0x1c,0x1c }, { 0xf1,0x57,0xa6,0xa6 }, - { 0xc7,0x73,0xb4,0xb4 }, { 0x51,0x97,0xc6,0xc6 }, + { 0xe9,0x47,0xae,0xae }, { 0x18,0x10,0x08,0x08 }, + { 0xd5,0x6f,0xba,0xba }, { 0x88,0xf0,0x78,0x78 }, + { 0x6f,0x4a,0x25,0x25 }, { 0x72,0x5c,0x2e,0x2e }, + { 0x24,0x38,0x1c,0x1c }, { 0xf1,0x57,0xa6,0xa6 }, + { 0xc7,0x73,0xb4,0xb4 }, { 0x51,0x97,0xc6,0xc6 }, { 0x23,0xcb,0xe8,0xe8 }, { 0x7c,0xa1,0xdd,0xdd }, - { 0x9c,0xe8,0x74,0x74 }, { 0x21,0x3e,0x1f,0x1f }, + { 0x9c,0xe8,0x74,0x74 }, { 0x21,0x3e,0x1f,0x1f }, { 0xdd,0x96,0x4b,0x4b }, { 0xdc,0x61,0xbd,0xbd }, - { 0x86,0x0d,0x8b,0x8b }, { 0x85,0x0f,0x8a,0x8a }, - { 0x90,0xe0,0x70,0x70 }, { 0x42,0x7c,0x3e,0x3e }, - { 0xc4,0x71,0xb5,0xb5 }, { 0xaa,0xcc,0x66,0x66 }, + { 0x86,0x0d,0x8b,0x8b }, { 0x85,0x0f,0x8a,0x8a }, + { 0x90,0xe0,0x70,0x70 }, { 0x42,0x7c,0x3e,0x3e }, + { 0xc4,0x71,0xb5,0xb5 }, { 0xaa,0xcc,0x66,0x66 }, { 0xd8,0x90,0x48,0x48 }, { 0x05,0x06,0x03,0x03 }, - { 0x01,0xf7,0xf6,0xf6 }, { 0x12,0x1c,0x0e,0x0e }, + { 0x01,0xf7,0xf6,0xf6 }, { 0x12,0x1c,0x0e,0x0e }, { 0xa3,0xc2,0x61,0x61 }, { 0x5f,0x6a,0x35,0x35 }, - { 0xf9,0xae,0x57,0x57 }, { 0xd0,0x69,0xb9,0xb9 }, - { 0x91,0x17,0x86,0x86 }, { 0x58,0x99,0xc1,0xc1 }, - { 0x27,0x3a,0x1d,0x1d }, { 0xb9,0x27,0x9e,0x9e }, + { 0xf9,0xae,0x57,0x57 }, { 0xd0,0x69,0xb9,0xb9 }, + { 0x91,0x17,0x86,0x86 }, { 0x58,0x99,0xc1,0xc1 }, + { 0x27,0x3a,0x1d,0x1d }, { 0xb9,0x27,0x9e,0x9e }, { 0x38,0xd9,0xe1,0xe1 }, { 0x13,0xeb,0xf8,0xf8 }, - { 0xb3,0x2b,0x98,0x98 }, { 0x33,0x22,0x11,0x11 }, + { 0xb3,0x2b,0x98,0x98 }, { 0x33,0x22,0x11,0x11 }, { 0xbb,0xd2,0x69,0x69 }, { 0x70,0xa9,0xd9,0xd9 }, - { 0x89,0x07,0x8e,0x8e }, { 0xa7,0x33,0x94,0x94 }, + { 0x89,0x07,0x8e,0x8e }, { 0xa7,0x33,0x94,0x94 }, { 0xb6,0x2d,0x9b,0x9b }, { 0x22,0x3c,0x1e,0x1e }, - { 0x92,0x15,0x87,0x87 }, { 0x20,0xc9,0xe9,0xe9 }, + { 0x92,0x15,0x87,0x87 }, { 0x20,0xc9,0xe9,0xe9 }, { 0x49,0x87,0xce,0xce }, { 0xff,0xaa,0x55,0x55 }, - { 0x78,0x50,0x28,0x28 }, { 0x7a,0xa5,0xdf,0xdf }, - { 0x8f,0x03,0x8c,0x8c }, { 0xf8,0x59,0xa1,0xa1 }, - { 0x80,0x09,0x89,0x89 }, { 0x17,0x1a,0x0d,0x0d }, + { 0x78,0x50,0x28,0x28 }, { 0x7a,0xa5,0xdf,0xdf }, + { 0x8f,0x03,0x8c,0x8c }, { 0xf8,0x59,0xa1,0xa1 }, + { 0x80,0x09,0x89,0x89 }, { 0x17,0x1a,0x0d,0x0d }, { 0xda,0x65,0xbf,0xbf }, { 0x31,0xd7,0xe6,0xe6 }, - { 0xc6,0x84,0x42,0x42 }, { 0xb8,0xd0,0x68,0x68 }, - { 0xc3,0x82,0x41,0x41 }, { 0xb0,0x29,0x99,0x99 }, - { 0x77,0x5a,0x2d,0x2d }, { 0x11,0x1e,0x0f,0x0f }, - { 0xcb,0x7b,0xb0,0xb0 }, { 0xfc,0xa8,0x54,0x54 }, + { 0xc6,0x84,0x42,0x42 }, { 0xb8,0xd0,0x68,0x68 }, + { 0xc3,0x82,0x41,0x41 }, { 0xb0,0x29,0x99,0x99 }, + { 0x77,0x5a,0x2d,0x2d }, { 0x11,0x1e,0x0f,0x0f }, + { 0xcb,0x7b,0xb0,0xb0 }, { 0xfc,0xa8,0x54,0x54 }, { 0xd6,0x6d,0xbb,0xbb }, { 0x3a,0x2c,0x16,0x16 } }; -static const unsigned char T3[256][4] = +static const unsigned char T3[256][4] = { { 0x63,0xa5,0xc6,0x63 }, { 0x7c,0x84,0xf8,0x7c }, - { 0x77,0x99,0xee,0x77 }, { 0x7b,0x8d,0xf6,0x7b }, + { 0x77,0x99,0xee,0x77 }, { 0x7b,0x8d,0xf6,0x7b }, { 0xf2,0x0d,0xff,0xf2 }, { 0x6b,0xbd,0xd6,0x6b }, - { 0x6f,0xb1,0xde,0x6f }, { 0xc5,0x54,0x91,0xc5 }, + { 0x6f,0xb1,0xde,0x6f }, { 0xc5,0x54,0x91,0xc5 }, { 0x30,0x50,0x60,0x30 }, { 0x01,0x03,0x02,0x01 }, - { 0x67,0xa9,0xce,0x67 }, { 0x2b,0x7d,0x56,0x2b }, - { 0xfe,0x19,0xe7,0xfe }, { 0xd7,0x62,0xb5,0xd7 }, - { 0xab,0xe6,0x4d,0xab }, { 0x76,0x9a,0xec,0x76 }, + { 0x67,0xa9,0xce,0x67 }, { 0x2b,0x7d,0x56,0x2b }, + { 0xfe,0x19,0xe7,0xfe }, { 0xd7,0x62,0xb5,0xd7 }, + { 0xab,0xe6,0x4d,0xab }, { 0x76,0x9a,0xec,0x76 }, { 0xca,0x45,0x8f,0xca }, { 0x82,0x9d,0x1f,0x82 }, - { 0xc9,0x40,0x89,0xc9 }, { 0x7d,0x87,0xfa,0x7d }, - { 0xfa,0x15,0xef,0xfa }, { 0x59,0xeb,0xb2,0x59 }, - { 0x47,0xc9,0x8e,0x47 }, { 0xf0,0x0b,0xfb,0xf0 }, - { 0xad,0xec,0x41,0xad }, { 0xd4,0x67,0xb3,0xd4 }, - { 0xa2,0xfd,0x5f,0xa2 }, { 0xaf,0xea,0x45,0xaf }, + { 0xc9,0x40,0x89,0xc9 }, { 0x7d,0x87,0xfa,0x7d }, + { 0xfa,0x15,0xef,0xfa }, { 0x59,0xeb,0xb2,0x59 }, + { 0x47,0xc9,0x8e,0x47 }, { 0xf0,0x0b,0xfb,0xf0 }, + { 0xad,0xec,0x41,0xad }, { 0xd4,0x67,0xb3,0xd4 }, + { 0xa2,0xfd,0x5f,0xa2 }, { 0xaf,0xea,0x45,0xaf }, { 0x9c,0xbf,0x23,0x9c }, { 0xa4,0xf7,0x53,0xa4 }, - { 0x72,0x96,0xe4,0x72 }, { 0xc0,0x5b,0x9b,0xc0 }, - { 0xb7,0xc2,0x75,0xb7 }, { 0xfd,0x1c,0xe1,0xfd }, - { 0x93,0xae,0x3d,0x93 }, { 0x26,0x6a,0x4c,0x26 }, + { 0x72,0x96,0xe4,0x72 }, { 0xc0,0x5b,0x9b,0xc0 }, + { 0xb7,0xc2,0x75,0xb7 }, { 0xfd,0x1c,0xe1,0xfd }, + { 0x93,0xae,0x3d,0x93 }, { 0x26,0x6a,0x4c,0x26 }, { 0x36,0x5a,0x6c,0x36 }, { 0x3f,0x41,0x7e,0x3f }, - { 0xf7,0x02,0xf5,0xf7 }, { 0xcc,0x4f,0x83,0xcc }, + { 0xf7,0x02,0xf5,0xf7 }, { 0xcc,0x4f,0x83,0xcc }, { 0x34,0x5c,0x68,0x34 }, { 0xa5,0xf4,0x51,0xa5 }, - { 0xe5,0x34,0xd1,0xe5 }, { 0xf1,0x08,0xf9,0xf1 }, + { 0xe5,0x34,0xd1,0xe5 }, { 0xf1,0x08,0xf9,0xf1 }, { 0x71,0x93,0xe2,0x71 }, { 0xd8,0x73,0xab,0xd8 }, - { 0x31,0x53,0x62,0x31 }, { 0x15,0x3f,0x2a,0x15 }, - { 0x04,0x0c,0x08,0x04 }, { 0xc7,0x52,0x95,0xc7 }, - { 0x23,0x65,0x46,0x23 }, { 0xc3,0x5e,0x9d,0xc3 }, + { 0x31,0x53,0x62,0x31 }, { 0x15,0x3f,0x2a,0x15 }, + { 0x04,0x0c,0x08,0x04 }, { 0xc7,0x52,0x95,0xc7 }, + { 0x23,0x65,0x46,0x23 }, { 0xc3,0x5e,0x9d,0xc3 }, { 0x18,0x28,0x30,0x18 }, { 0x96,0xa1,0x37,0x96 }, - { 0x05,0x0f,0x0a,0x05 }, { 0x9a,0xb5,0x2f,0x9a }, - { 0x07,0x09,0x0e,0x07 }, { 0x12,0x36,0x24,0x12 }, - { 0x80,0x9b,0x1b,0x80 }, { 0xe2,0x3d,0xdf,0xe2 }, + { 0x05,0x0f,0x0a,0x05 }, { 0x9a,0xb5,0x2f,0x9a }, + { 0x07,0x09,0x0e,0x07 }, { 0x12,0x36,0x24,0x12 }, + { 0x80,0x9b,0x1b,0x80 }, { 0xe2,0x3d,0xdf,0xe2 }, { 0xeb,0x26,0xcd,0xeb }, { 0x27,0x69,0x4e,0x27 }, - { 0xb2,0xcd,0x7f,0xb2 }, { 0x75,0x9f,0xea,0x75 }, + { 0xb2,0xcd,0x7f,0xb2 }, { 0x75,0x9f,0xea,0x75 }, { 0x09,0x1b,0x12,0x09 }, { 0x83,0x9e,0x1d,0x83 }, - { 0x2c,0x74,0x58,0x2c }, { 0x1a,0x2e,0x34,0x1a }, + { 0x2c,0x74,0x58,0x2c }, { 0x1a,0x2e,0x34,0x1a }, { 0x1b,0x2d,0x36,0x1b }, { 0x6e,0xb2,0xdc,0x6e }, - { 0x5a,0xee,0xb4,0x5a }, { 0xa0,0xfb,0x5b,0xa0 }, + { 0x5a,0xee,0xb4,0x5a }, { 0xa0,0xfb,0x5b,0xa0 }, { 0x52,0xf6,0xa4,0x52 }, { 0x3b,0x4d,0x76,0x3b }, - { 0xd6,0x61,0xb7,0xd6 }, { 0xb3,0xce,0x7d,0xb3 }, - { 0x29,0x7b,0x52,0x29 }, { 0xe3,0x3e,0xdd,0xe3 }, - { 0x2f,0x71,0x5e,0x2f }, { 0x84,0x97,0x13,0x84 }, + { 0xd6,0x61,0xb7,0xd6 }, { 0xb3,0xce,0x7d,0xb3 }, + { 0x29,0x7b,0x52,0x29 }, { 0xe3,0x3e,0xdd,0xe3 }, + { 0x2f,0x71,0x5e,0x2f }, { 0x84,0x97,0x13,0x84 }, { 0x53,0xf5,0xa6,0x53 }, { 0xd1,0x68,0xb9,0xd1 }, - { 0x00,0x00,0x00,0x00 }, { 0xed,0x2c,0xc1,0xed }, + { 0x00,0x00,0x00,0x00 }, { 0xed,0x2c,0xc1,0xed }, { 0x20,0x60,0x40,0x20 }, { 0xfc,0x1f,0xe3,0xfc }, - { 0xb1,0xc8,0x79,0xb1 }, { 0x5b,0xed,0xb6,0x5b }, + { 0xb1,0xc8,0x79,0xb1 }, { 0x5b,0xed,0xb6,0x5b }, { 0x6a,0xbe,0xd4,0x6a }, { 0xcb,0x46,0x8d,0xcb }, - { 0xbe,0xd9,0x67,0xbe }, { 0x39,0x4b,0x72,0x39 }, + { 0xbe,0xd9,0x67,0xbe }, { 0x39,0x4b,0x72,0x39 }, { 0x4a,0xde,0x94,0x4a }, { 0x4c,0xd4,0x98,0x4c }, - { 0x58,0xe8,0xb0,0x58 }, { 0xcf,0x4a,0x85,0xcf }, + { 0x58,0xe8,0xb0,0x58 }, { 0xcf,0x4a,0x85,0xcf }, { 0xd0,0x6b,0xbb,0xd0 }, { 0xef,0x2a,0xc5,0xef }, - { 0xaa,0xe5,0x4f,0xaa }, { 0xfb,0x16,0xed,0xfb }, + { 0xaa,0xe5,0x4f,0xaa }, { 0xfb,0x16,0xed,0xfb }, { 0x43,0xc5,0x86,0x43 }, { 0x4d,0xd7,0x9a,0x4d }, - { 0x33,0x55,0x66,0x33 }, { 0x85,0x94,0x11,0x85 }, + { 0x33,0x55,0x66,0x33 }, { 0x85,0x94,0x11,0x85 }, { 0x45,0xcf,0x8a,0x45 }, { 0xf9,0x10,0xe9,0xf9 }, - { 0x02,0x06,0x04,0x02 }, { 0x7f,0x81,0xfe,0x7f }, + { 0x02,0x06,0x04,0x02 }, { 0x7f,0x81,0xfe,0x7f }, { 0x50,0xf0,0xa0,0x50 }, { 0x3c,0x44,0x78,0x3c }, - { 0x9f,0xba,0x25,0x9f }, { 0xa8,0xe3,0x4b,0xa8 }, + { 0x9f,0xba,0x25,0x9f }, { 0xa8,0xe3,0x4b,0xa8 }, { 0x51,0xf3,0xa2,0x51 }, { 0xa3,0xfe,0x5d,0xa3 }, - { 0x40,0xc0,0x80,0x40 }, { 0x8f,0x8a,0x05,0x8f }, + { 0x40,0xc0,0x80,0x40 }, { 0x8f,0x8a,0x05,0x8f }, { 0x92,0xad,0x3f,0x92 }, { 0x9d,0xbc,0x21,0x9d }, - { 0x38,0x48,0x70,0x38 }, { 0xf5,0x04,0xf1,0xf5 }, + { 0x38,0x48,0x70,0x38 }, { 0xf5,0x04,0xf1,0xf5 }, { 0xbc,0xdf,0x63,0xbc }, { 0xb6,0xc1,0x77,0xb6 }, - { 0xda,0x75,0xaf,0xda }, { 0x21,0x63,0x42,0x21 }, + { 0xda,0x75,0xaf,0xda }, { 0x21,0x63,0x42,0x21 }, { 0x10,0x30,0x20,0x10 }, { 0xff,0x1a,0xe5,0xff }, - { 0xf3,0x0e,0xfd,0xf3 }, { 0xd2,0x6d,0xbf,0xd2 }, - { 0xcd,0x4c,0x81,0xcd }, { 0x0c,0x14,0x18,0x0c }, - { 0x13,0x35,0x26,0x13 }, { 0xec,0x2f,0xc3,0xec }, + { 0xf3,0x0e,0xfd,0xf3 }, { 0xd2,0x6d,0xbf,0xd2 }, + { 0xcd,0x4c,0x81,0xcd }, { 0x0c,0x14,0x18,0x0c }, + { 0x13,0x35,0x26,0x13 }, { 0xec,0x2f,0xc3,0xec }, { 0x5f,0xe1,0xbe,0x5f }, { 0x97,0xa2,0x35,0x97 }, - { 0x44,0xcc,0x88,0x44 }, { 0x17,0x39,0x2e,0x17 }, + { 0x44,0xcc,0x88,0x44 }, { 0x17,0x39,0x2e,0x17 }, { 0xc4,0x57,0x93,0xc4 }, { 0xa7,0xf2,0x55,0xa7 }, - { 0x7e,0x82,0xfc,0x7e }, { 0x3d,0x47,0x7a,0x3d }, + { 0x7e,0x82,0xfc,0x7e }, { 0x3d,0x47,0x7a,0x3d }, { 0x64,0xac,0xc8,0x64 }, { 0x5d,0xe7,0xba,0x5d }, - { 0x19,0x2b,0x32,0x19 }, { 0x73,0x95,0xe6,0x73 }, + { 0x19,0x2b,0x32,0x19 }, { 0x73,0x95,0xe6,0x73 }, { 0x60,0xa0,0xc0,0x60 }, { 0x81,0x98,0x19,0x81 }, - { 0x4f,0xd1,0x9e,0x4f }, { 0xdc,0x7f,0xa3,0xdc }, + { 0x4f,0xd1,0x9e,0x4f }, { 0xdc,0x7f,0xa3,0xdc }, { 0x22,0x66,0x44,0x22 }, { 0x2a,0x7e,0x54,0x2a }, - { 0x90,0xab,0x3b,0x90 }, { 0x88,0x83,0x0b,0x88 }, + { 0x90,0xab,0x3b,0x90 }, { 0x88,0x83,0x0b,0x88 }, { 0x46,0xca,0x8c,0x46 }, { 0xee,0x29,0xc7,0xee }, - { 0xb8,0xd3,0x6b,0xb8 }, { 0x14,0x3c,0x28,0x14 }, - { 0xde,0x79,0xa7,0xde }, { 0x5e,0xe2,0xbc,0x5e }, - { 0x0b,0x1d,0x16,0x0b }, { 0xdb,0x76,0xad,0xdb }, + { 0xb8,0xd3,0x6b,0xb8 }, { 0x14,0x3c,0x28,0x14 }, + { 0xde,0x79,0xa7,0xde }, { 0x5e,0xe2,0xbc,0x5e }, + { 0x0b,0x1d,0x16,0x0b }, { 0xdb,0x76,0xad,0xdb }, { 0xe0,0x3b,0xdb,0xe0 }, { 0x32,0x56,0x64,0x32 }, - { 0x3a,0x4e,0x74,0x3a }, { 0x0a,0x1e,0x14,0x0a }, + { 0x3a,0x4e,0x74,0x3a }, { 0x0a,0x1e,0x14,0x0a }, { 0x49,0xdb,0x92,0x49 }, { 0x06,0x0a,0x0c,0x06 }, - { 0x24,0x6c,0x48,0x24 }, { 0x5c,0xe4,0xb8,0x5c }, + { 0x24,0x6c,0x48,0x24 }, { 0x5c,0xe4,0xb8,0x5c }, { 0xc2,0x5d,0x9f,0xc2 }, { 0xd3,0x6e,0xbd,0xd3 }, - { 0xac,0xef,0x43,0xac }, { 0x62,0xa6,0xc4,0x62 }, + { 0xac,0xef,0x43,0xac }, { 0x62,0xa6,0xc4,0x62 }, { 0x91,0xa8,0x39,0x91 }, { 0x95,0xa4,0x31,0x95 }, - { 0xe4,0x37,0xd3,0xe4 }, { 0x79,0x8b,0xf2,0x79 }, - { 0xe7,0x32,0xd5,0xe7 }, { 0xc8,0x43,0x8b,0xc8 }, - { 0x37,0x59,0x6e,0x37 }, { 0x6d,0xb7,0xda,0x6d }, - { 0x8d,0x8c,0x01,0x8d }, { 0xd5,0x64,0xb1,0xd5 }, - { 0x4e,0xd2,0x9c,0x4e }, { 0xa9,0xe0,0x49,0xa9 }, + { 0xe4,0x37,0xd3,0xe4 }, { 0x79,0x8b,0xf2,0x79 }, + { 0xe7,0x32,0xd5,0xe7 }, { 0xc8,0x43,0x8b,0xc8 }, + { 0x37,0x59,0x6e,0x37 }, { 0x6d,0xb7,0xda,0x6d }, + { 0x8d,0x8c,0x01,0x8d }, { 0xd5,0x64,0xb1,0xd5 }, + { 0x4e,0xd2,0x9c,0x4e }, { 0xa9,0xe0,0x49,0xa9 }, { 0x6c,0xb4,0xd8,0x6c }, { 0x56,0xfa,0xac,0x56 }, - { 0xf4,0x07,0xf3,0xf4 }, { 0xea,0x25,0xcf,0xea }, - { 0x65,0xaf,0xca,0x65 }, { 0x7a,0x8e,0xf4,0x7a }, - { 0xae,0xe9,0x47,0xae }, { 0x08,0x18,0x10,0x08 }, - { 0xba,0xd5,0x6f,0xba }, { 0x78,0x88,0xf0,0x78 }, - { 0x25,0x6f,0x4a,0x25 }, { 0x2e,0x72,0x5c,0x2e }, - { 0x1c,0x24,0x38,0x1c }, { 0xa6,0xf1,0x57,0xa6 }, - { 0xb4,0xc7,0x73,0xb4 }, { 0xc6,0x51,0x97,0xc6 }, + { 0xf4,0x07,0xf3,0xf4 }, { 0xea,0x25,0xcf,0xea }, + { 0x65,0xaf,0xca,0x65 }, { 0x7a,0x8e,0xf4,0x7a }, + { 0xae,0xe9,0x47,0xae }, { 0x08,0x18,0x10,0x08 }, + { 0xba,0xd5,0x6f,0xba }, { 0x78,0x88,0xf0,0x78 }, + { 0x25,0x6f,0x4a,0x25 }, { 0x2e,0x72,0x5c,0x2e }, + { 0x1c,0x24,0x38,0x1c }, { 0xa6,0xf1,0x57,0xa6 }, + { 0xb4,0xc7,0x73,0xb4 }, { 0xc6,0x51,0x97,0xc6 }, { 0xe8,0x23,0xcb,0xe8 }, { 0xdd,0x7c,0xa1,0xdd }, - { 0x74,0x9c,0xe8,0x74 }, { 0x1f,0x21,0x3e,0x1f }, + { 0x74,0x9c,0xe8,0x74 }, { 0x1f,0x21,0x3e,0x1f }, { 0x4b,0xdd,0x96,0x4b }, { 0xbd,0xdc,0x61,0xbd }, - { 0x8b,0x86,0x0d,0x8b }, { 0x8a,0x85,0x0f,0x8a }, + { 0x8b,0x86,0x0d,0x8b }, { 0x8a,0x85,0x0f,0x8a }, { 0x70,0x90,0xe0,0x70 }, { 0x3e,0x42,0x7c,0x3e }, - { 0xb5,0xc4,0x71,0xb5 }, { 0x66,0xaa,0xcc,0x66 }, + { 0xb5,0xc4,0x71,0xb5 }, { 0x66,0xaa,0xcc,0x66 }, { 0x48,0xd8,0x90,0x48 }, { 0x03,0x05,0x06,0x03 }, - { 0xf6,0x01,0xf7,0xf6 }, { 0x0e,0x12,0x1c,0x0e }, + { 0xf6,0x01,0xf7,0xf6 }, { 0x0e,0x12,0x1c,0x0e }, { 0x61,0xa3,0xc2,0x61 }, { 0x35,0x5f,0x6a,0x35 }, - { 0x57,0xf9,0xae,0x57 }, { 0xb9,0xd0,0x69,0xb9 }, - { 0x86,0x91,0x17,0x86 }, { 0xc1,0x58,0x99,0xc1 }, - { 0x1d,0x27,0x3a,0x1d }, { 0x9e,0xb9,0x27,0x9e }, + { 0x57,0xf9,0xae,0x57 }, { 0xb9,0xd0,0x69,0xb9 }, + { 0x86,0x91,0x17,0x86 }, { 0xc1,0x58,0x99,0xc1 }, + { 0x1d,0x27,0x3a,0x1d }, { 0x9e,0xb9,0x27,0x9e }, { 0xe1,0x38,0xd9,0xe1 }, { 0xf8,0x13,0xeb,0xf8 }, - { 0x98,0xb3,0x2b,0x98 }, { 0x11,0x33,0x22,0x11 }, + { 0x98,0xb3,0x2b,0x98 }, { 0x11,0x33,0x22,0x11 }, { 0x69,0xbb,0xd2,0x69 }, { 0xd9,0x70,0xa9,0xd9 }, - { 0x8e,0x89,0x07,0x8e }, { 0x94,0xa7,0x33,0x94 }, + { 0x8e,0x89,0x07,0x8e }, { 0x94,0xa7,0x33,0x94 }, { 0x9b,0xb6,0x2d,0x9b }, { 0x1e,0x22,0x3c,0x1e }, - { 0x87,0x92,0x15,0x87 }, { 0xe9,0x20,0xc9,0xe9 }, + { 0x87,0x92,0x15,0x87 }, { 0xe9,0x20,0xc9,0xe9 }, { 0xce,0x49,0x87,0xce }, { 0x55,0xff,0xaa,0x55 }, - { 0x28,0x78,0x50,0x28 }, { 0xdf,0x7a,0xa5,0xdf }, + { 0x28,0x78,0x50,0x28 }, { 0xdf,0x7a,0xa5,0xdf }, { 0x8c,0x8f,0x03,0x8c }, { 0xa1,0xf8,0x59,0xa1 }, - { 0x89,0x80,0x09,0x89 }, { 0x0d,0x17,0x1a,0x0d }, + { 0x89,0x80,0x09,0x89 }, { 0x0d,0x17,0x1a,0x0d }, { 0xbf,0xda,0x65,0xbf }, { 0xe6,0x31,0xd7,0xe6 }, - { 0x42,0xc6,0x84,0x42 }, { 0x68,0xb8,0xd0,0x68 }, + { 0x42,0xc6,0x84,0x42 }, { 0x68,0xb8,0xd0,0x68 }, { 0x41,0xc3,0x82,0x41 }, { 0x99,0xb0,0x29,0x99 }, - { 0x2d,0x77,0x5a,0x2d }, { 0x0f,0x11,0x1e,0x0f }, + { 0x2d,0x77,0x5a,0x2d }, { 0x0f,0x11,0x1e,0x0f }, { 0xb0,0xcb,0x7b,0xb0 }, { 0x54,0xfc,0xa8,0x54 }, { 0xbb,0xd6,0x6d,0xbb }, { 0x16,0x3a,0x2c,0x16 } }; -static const unsigned char T4[256][4] = +static const unsigned char T4[256][4] = { { 0x63,0x63,0xa5,0xc6 }, { 0x7c,0x7c,0x84,0xf8 }, - { 0x77,0x77,0x99,0xee }, { 0x7b,0x7b,0x8d,0xf6 }, - { 0xf2,0xf2,0x0d,0xff }, { 0x6b,0x6b,0xbd,0xd6 }, - { 0x6f,0x6f,0xb1,0xde }, { 0xc5,0xc5,0x54,0x91 }, + { 0x77,0x77,0x99,0xee }, { 0x7b,0x7b,0x8d,0xf6 }, + { 0xf2,0xf2,0x0d,0xff }, { 0x6b,0x6b,0xbd,0xd6 }, + { 0x6f,0x6f,0xb1,0xde }, { 0xc5,0xc5,0x54,0x91 }, { 0x30,0x30,0x50,0x60 }, { 0x01,0x01,0x03,0x02 }, - { 0x67,0x67,0xa9,0xce }, { 0x2b,0x2b,0x7d,0x56 }, + { 0x67,0x67,0xa9,0xce }, { 0x2b,0x2b,0x7d,0x56 }, { 0xfe,0xfe,0x19,0xe7 }, { 0xd7,0xd7,0x62,0xb5 }, - { 0xab,0xab,0xe6,0x4d }, { 0x76,0x76,0x9a,0xec }, + { 0xab,0xab,0xe6,0x4d }, { 0x76,0x76,0x9a,0xec }, { 0xca,0xca,0x45,0x8f }, { 0x82,0x82,0x9d,0x1f }, - { 0xc9,0xc9,0x40,0x89 }, { 0x7d,0x7d,0x87,0xfa }, + { 0xc9,0xc9,0x40,0x89 }, { 0x7d,0x7d,0x87,0xfa }, { 0xfa,0xfa,0x15,0xef }, { 0x59,0x59,0xeb,0xb2 }, - { 0x47,0x47,0xc9,0x8e }, { 0xf0,0xf0,0x0b,0xfb }, + { 0x47,0x47,0xc9,0x8e }, { 0xf0,0xf0,0x0b,0xfb }, { 0xad,0xad,0xec,0x41 }, { 0xd4,0xd4,0x67,0xb3 }, - { 0xa2,0xa2,0xfd,0x5f }, { 0xaf,0xaf,0xea,0x45 }, + { 0xa2,0xa2,0xfd,0x5f }, { 0xaf,0xaf,0xea,0x45 }, { 0x9c,0x9c,0xbf,0x23 }, { 0xa4,0xa4,0xf7,0x53 }, - { 0x72,0x72,0x96,0xe4 }, { 0xc0,0xc0,0x5b,0x9b }, + { 0x72,0x72,0x96,0xe4 }, { 0xc0,0xc0,0x5b,0x9b }, { 0xb7,0xb7,0xc2,0x75 }, { 0xfd,0xfd,0x1c,0xe1 }, - { 0x93,0x93,0xae,0x3d }, { 0x26,0x26,0x6a,0x4c }, + { 0x93,0x93,0xae,0x3d }, { 0x26,0x26,0x6a,0x4c }, { 0x36,0x36,0x5a,0x6c }, { 0x3f,0x3f,0x41,0x7e }, - { 0xf7,0xf7,0x02,0xf5 }, { 0xcc,0xcc,0x4f,0x83 }, + { 0xf7,0xf7,0x02,0xf5 }, { 0xcc,0xcc,0x4f,0x83 }, { 0x34,0x34,0x5c,0x68 }, { 0xa5,0xa5,0xf4,0x51 }, - { 0xe5,0xe5,0x34,0xd1 }, { 0xf1,0xf1,0x08,0xf9 }, + { 0xe5,0xe5,0x34,0xd1 }, { 0xf1,0xf1,0x08,0xf9 }, { 0x71,0x71,0x93,0xe2 }, { 0xd8,0xd8,0x73,0xab }, - { 0x31,0x31,0x53,0x62 }, { 0x15,0x15,0x3f,0x2a }, + { 0x31,0x31,0x53,0x62 }, { 0x15,0x15,0x3f,0x2a }, { 0x04,0x04,0x0c,0x08 }, { 0xc7,0xc7,0x52,0x95 }, - { 0x23,0x23,0x65,0x46 }, { 0xc3,0xc3,0x5e,0x9d }, + { 0x23,0x23,0x65,0x46 }, { 0xc3,0xc3,0x5e,0x9d }, { 0x18,0x18,0x28,0x30 }, { 0x96,0x96,0xa1,0x37 }, - { 0x05,0x05,0x0f,0x0a }, { 0x9a,0x9a,0xb5,0x2f }, + { 0x05,0x05,0x0f,0x0a }, { 0x9a,0x9a,0xb5,0x2f }, { 0x07,0x07,0x09,0x0e }, { 0x12,0x12,0x36,0x24 }, - { 0x80,0x80,0x9b,0x1b }, { 0xe2,0xe2,0x3d,0xdf }, + { 0x80,0x80,0x9b,0x1b }, { 0xe2,0xe2,0x3d,0xdf }, { 0xeb,0xeb,0x26,0xcd }, { 0x27,0x27,0x69,0x4e }, - { 0xb2,0xb2,0xcd,0x7f }, { 0x75,0x75,0x9f,0xea }, + { 0xb2,0xb2,0xcd,0x7f }, { 0x75,0x75,0x9f,0xea }, { 0x09,0x09,0x1b,0x12 }, { 0x83,0x83,0x9e,0x1d }, - { 0x2c,0x2c,0x74,0x58 }, { 0x1a,0x1a,0x2e,0x34 }, + { 0x2c,0x2c,0x74,0x58 }, { 0x1a,0x1a,0x2e,0x34 }, { 0x1b,0x1b,0x2d,0x36 }, { 0x6e,0x6e,0xb2,0xdc }, - { 0x5a,0x5a,0xee,0xb4 }, { 0xa0,0xa0,0xfb,0x5b }, + { 0x5a,0x5a,0xee,0xb4 }, { 0xa0,0xa0,0xfb,0x5b }, { 0x52,0x52,0xf6,0xa4 }, { 0x3b,0x3b,0x4d,0x76 }, - { 0xd6,0xd6,0x61,0xb7 }, { 0xb3,0xb3,0xce,0x7d }, + { 0xd6,0xd6,0x61,0xb7 }, { 0xb3,0xb3,0xce,0x7d }, { 0x29,0x29,0x7b,0x52 }, { 0xe3,0xe3,0x3e,0xdd }, - { 0x2f,0x2f,0x71,0x5e }, { 0x84,0x84,0x97,0x13 }, + { 0x2f,0x2f,0x71,0x5e }, { 0x84,0x84,0x97,0x13 }, { 0x53,0x53,0xf5,0xa6 }, { 0xd1,0xd1,0x68,0xb9 }, - { 0x00,0x00,0x00,0x00 }, { 0xed,0xed,0x2c,0xc1 }, + { 0x00,0x00,0x00,0x00 }, { 0xed,0xed,0x2c,0xc1 }, { 0x20,0x20,0x60,0x40 }, { 0xfc,0xfc,0x1f,0xe3 }, - { 0xb1,0xb1,0xc8,0x79 }, { 0x5b,0x5b,0xed,0xb6 }, + { 0xb1,0xb1,0xc8,0x79 }, { 0x5b,0x5b,0xed,0xb6 }, { 0x6a,0x6a,0xbe,0xd4 }, { 0xcb,0xcb,0x46,0x8d }, - { 0xbe,0xbe,0xd9,0x67 }, { 0x39,0x39,0x4b,0x72 }, + { 0xbe,0xbe,0xd9,0x67 }, { 0x39,0x39,0x4b,0x72 }, { 0x4a,0x4a,0xde,0x94 }, { 0x4c,0x4c,0xd4,0x98 }, - { 0x58,0x58,0xe8,0xb0 }, { 0xcf,0xcf,0x4a,0x85 }, + { 0x58,0x58,0xe8,0xb0 }, { 0xcf,0xcf,0x4a,0x85 }, { 0xd0,0xd0,0x6b,0xbb }, { 0xef,0xef,0x2a,0xc5 }, - { 0xaa,0xaa,0xe5,0x4f }, { 0xfb,0xfb,0x16,0xed }, + { 0xaa,0xaa,0xe5,0x4f }, { 0xfb,0xfb,0x16,0xed }, { 0x43,0x43,0xc5,0x86 }, { 0x4d,0x4d,0xd7,0x9a }, - { 0x33,0x33,0x55,0x66 }, { 0x85,0x85,0x94,0x11 }, + { 0x33,0x33,0x55,0x66 }, { 0x85,0x85,0x94,0x11 }, { 0x45,0x45,0xcf,0x8a }, { 0xf9,0xf9,0x10,0xe9 }, - { 0x02,0x02,0x06,0x04 }, { 0x7f,0x7f,0x81,0xfe }, + { 0x02,0x02,0x06,0x04 }, { 0x7f,0x7f,0x81,0xfe }, { 0x50,0x50,0xf0,0xa0 }, { 0x3c,0x3c,0x44,0x78 }, - { 0x9f,0x9f,0xba,0x25 }, { 0xa8,0xa8,0xe3,0x4b }, + { 0x9f,0x9f,0xba,0x25 }, { 0xa8,0xa8,0xe3,0x4b }, { 0x51,0x51,0xf3,0xa2 }, { 0xa3,0xa3,0xfe,0x5d }, - { 0x40,0x40,0xc0,0x80 }, { 0x8f,0x8f,0x8a,0x05 }, + { 0x40,0x40,0xc0,0x80 }, { 0x8f,0x8f,0x8a,0x05 }, { 0x92,0x92,0xad,0x3f }, { 0x9d,0x9d,0xbc,0x21 }, - { 0x38,0x38,0x48,0x70 }, { 0xf5,0xf5,0x04,0xf1 }, + { 0x38,0x38,0x48,0x70 }, { 0xf5,0xf5,0x04,0xf1 }, { 0xbc,0xbc,0xdf,0x63 }, { 0xb6,0xb6,0xc1,0x77 }, - { 0xda,0xda,0x75,0xaf }, { 0x21,0x21,0x63,0x42 }, + { 0xda,0xda,0x75,0xaf }, { 0x21,0x21,0x63,0x42 }, { 0x10,0x10,0x30,0x20 }, { 0xff,0xff,0x1a,0xe5 }, - { 0xf3,0xf3,0x0e,0xfd }, { 0xd2,0xd2,0x6d,0xbf }, + { 0xf3,0xf3,0x0e,0xfd }, { 0xd2,0xd2,0x6d,0xbf }, { 0xcd,0xcd,0x4c,0x81 }, { 0x0c,0x0c,0x14,0x18 }, - { 0x13,0x13,0x35,0x26 }, { 0xec,0xec,0x2f,0xc3 }, + { 0x13,0x13,0x35,0x26 }, { 0xec,0xec,0x2f,0xc3 }, { 0x5f,0x5f,0xe1,0xbe }, { 0x97,0x97,0xa2,0x35 }, - { 0x44,0x44,0xcc,0x88 }, { 0x17,0x17,0x39,0x2e }, + { 0x44,0x44,0xcc,0x88 }, { 0x17,0x17,0x39,0x2e }, { 0xc4,0xc4,0x57,0x93 }, { 0xa7,0xa7,0xf2,0x55 }, - { 0x7e,0x7e,0x82,0xfc }, { 0x3d,0x3d,0x47,0x7a }, + { 0x7e,0x7e,0x82,0xfc }, { 0x3d,0x3d,0x47,0x7a }, { 0x64,0x64,0xac,0xc8 }, { 0x5d,0x5d,0xe7,0xba }, - { 0x19,0x19,0x2b,0x32 }, { 0x73,0x73,0x95,0xe6 }, + { 0x19,0x19,0x2b,0x32 }, { 0x73,0x73,0x95,0xe6 }, { 0x60,0x60,0xa0,0xc0 }, { 0x81,0x81,0x98,0x19 }, - { 0x4f,0x4f,0xd1,0x9e }, { 0xdc,0xdc,0x7f,0xa3 }, + { 0x4f,0x4f,0xd1,0x9e }, { 0xdc,0xdc,0x7f,0xa3 }, { 0x22,0x22,0x66,0x44 }, { 0x2a,0x2a,0x7e,0x54 }, - { 0x90,0x90,0xab,0x3b }, { 0x88,0x88,0x83,0x0b }, + { 0x90,0x90,0xab,0x3b }, { 0x88,0x88,0x83,0x0b }, { 0x46,0x46,0xca,0x8c }, { 0xee,0xee,0x29,0xc7 }, - { 0xb8,0xb8,0xd3,0x6b }, { 0x14,0x14,0x3c,0x28 }, + { 0xb8,0xb8,0xd3,0x6b }, { 0x14,0x14,0x3c,0x28 }, { 0xde,0xde,0x79,0xa7 }, { 0x5e,0x5e,0xe2,0xbc }, - { 0x0b,0x0b,0x1d,0x16 }, { 0xdb,0xdb,0x76,0xad }, + { 0x0b,0x0b,0x1d,0x16 }, { 0xdb,0xdb,0x76,0xad }, { 0xe0,0xe0,0x3b,0xdb }, { 0x32,0x32,0x56,0x64 }, - { 0x3a,0x3a,0x4e,0x74 }, { 0x0a,0x0a,0x1e,0x14 }, + { 0x3a,0x3a,0x4e,0x74 }, { 0x0a,0x0a,0x1e,0x14 }, { 0x49,0x49,0xdb,0x92 }, { 0x06,0x06,0x0a,0x0c }, - { 0x24,0x24,0x6c,0x48 }, { 0x5c,0x5c,0xe4,0xb8 }, + { 0x24,0x24,0x6c,0x48 }, { 0x5c,0x5c,0xe4,0xb8 }, { 0xc2,0xc2,0x5d,0x9f }, { 0xd3,0xd3,0x6e,0xbd }, - { 0xac,0xac,0xef,0x43 }, { 0x62,0x62,0xa6,0xc4 }, + { 0xac,0xac,0xef,0x43 }, { 0x62,0x62,0xa6,0xc4 }, { 0x91,0x91,0xa8,0x39 }, { 0x95,0x95,0xa4,0x31 }, - { 0xe4,0xe4,0x37,0xd3 }, { 0x79,0x79,0x8b,0xf2 }, + { 0xe4,0xe4,0x37,0xd3 }, { 0x79,0x79,0x8b,0xf2 }, { 0xe7,0xe7,0x32,0xd5 }, { 0xc8,0xc8,0x43,0x8b }, - { 0x37,0x37,0x59,0x6e }, { 0x6d,0x6d,0xb7,0xda }, - { 0x8d,0x8d,0x8c,0x01 }, { 0xd5,0xd5,0x64,0xb1 }, - { 0x4e,0x4e,0xd2,0x9c }, { 0xa9,0xa9,0xe0,0x49 }, - { 0x6c,0x6c,0xb4,0xd8 }, { 0x56,0x56,0xfa,0xac }, - { 0xf4,0xf4,0x07,0xf3 }, { 0xea,0xea,0x25,0xcf }, - { 0x65,0x65,0xaf,0xca }, { 0x7a,0x7a,0x8e,0xf4 }, - { 0xae,0xae,0xe9,0x47 }, { 0x08,0x08,0x18,0x10 }, - { 0xba,0xba,0xd5,0x6f }, { 0x78,0x78,0x88,0xf0 }, - { 0x25,0x25,0x6f,0x4a }, { 0x2e,0x2e,0x72,0x5c }, + { 0x37,0x37,0x59,0x6e }, { 0x6d,0x6d,0xb7,0xda }, + { 0x8d,0x8d,0x8c,0x01 }, { 0xd5,0xd5,0x64,0xb1 }, + { 0x4e,0x4e,0xd2,0x9c }, { 0xa9,0xa9,0xe0,0x49 }, + { 0x6c,0x6c,0xb4,0xd8 }, { 0x56,0x56,0xfa,0xac }, + { 0xf4,0xf4,0x07,0xf3 }, { 0xea,0xea,0x25,0xcf }, + { 0x65,0x65,0xaf,0xca }, { 0x7a,0x7a,0x8e,0xf4 }, + { 0xae,0xae,0xe9,0x47 }, { 0x08,0x08,0x18,0x10 }, + { 0xba,0xba,0xd5,0x6f }, { 0x78,0x78,0x88,0xf0 }, + { 0x25,0x25,0x6f,0x4a }, { 0x2e,0x2e,0x72,0x5c }, { 0x1c,0x1c,0x24,0x38 }, { 0xa6,0xa6,0xf1,0x57 }, - { 0xb4,0xb4,0xc7,0x73 }, { 0xc6,0xc6,0x51,0x97 }, + { 0xb4,0xb4,0xc7,0x73 }, { 0xc6,0xc6,0x51,0x97 }, { 0xe8,0xe8,0x23,0xcb }, { 0xdd,0xdd,0x7c,0xa1 }, - { 0x74,0x74,0x9c,0xe8 }, { 0x1f,0x1f,0x21,0x3e }, + { 0x74,0x74,0x9c,0xe8 }, { 0x1f,0x1f,0x21,0x3e }, { 0x4b,0x4b,0xdd,0x96 }, { 0xbd,0xbd,0xdc,0x61 }, - { 0x8b,0x8b,0x86,0x0d }, { 0x8a,0x8a,0x85,0x0f }, + { 0x8b,0x8b,0x86,0x0d }, { 0x8a,0x8a,0x85,0x0f }, { 0x70,0x70,0x90,0xe0 }, { 0x3e,0x3e,0x42,0x7c }, - { 0xb5,0xb5,0xc4,0x71 }, { 0x66,0x66,0xaa,0xcc }, + { 0xb5,0xb5,0xc4,0x71 }, { 0x66,0x66,0xaa,0xcc }, { 0x48,0x48,0xd8,0x90 }, { 0x03,0x03,0x05,0x06 }, - { 0xf6,0xf6,0x01,0xf7 }, { 0x0e,0x0e,0x12,0x1c }, + { 0xf6,0xf6,0x01,0xf7 }, { 0x0e,0x0e,0x12,0x1c }, { 0x61,0x61,0xa3,0xc2 }, { 0x35,0x35,0x5f,0x6a }, - { 0x57,0x57,0xf9,0xae }, { 0xb9,0xb9,0xd0,0x69 }, + { 0x57,0x57,0xf9,0xae }, { 0xb9,0xb9,0xd0,0x69 }, { 0x86,0x86,0x91,0x17 }, { 0xc1,0xc1,0x58,0x99 }, - { 0x1d,0x1d,0x27,0x3a }, { 0x9e,0x9e,0xb9,0x27 }, + { 0x1d,0x1d,0x27,0x3a }, { 0x9e,0x9e,0xb9,0x27 }, { 0xe1,0xe1,0x38,0xd9 }, { 0xf8,0xf8,0x13,0xeb }, - { 0x98,0x98,0xb3,0x2b }, { 0x11,0x11,0x33,0x22 }, + { 0x98,0x98,0xb3,0x2b }, { 0x11,0x11,0x33,0x22 }, { 0x69,0x69,0xbb,0xd2 }, { 0xd9,0xd9,0x70,0xa9 }, - { 0x8e,0x8e,0x89,0x07 }, { 0x94,0x94,0xa7,0x33 }, + { 0x8e,0x8e,0x89,0x07 }, { 0x94,0x94,0xa7,0x33 }, { 0x9b,0x9b,0xb6,0x2d }, { 0x1e,0x1e,0x22,0x3c }, - { 0x87,0x87,0x92,0x15 }, { 0xe9,0xe9,0x20,0xc9 }, + { 0x87,0x87,0x92,0x15 }, { 0xe9,0xe9,0x20,0xc9 }, { 0xce,0xce,0x49,0x87 }, { 0x55,0x55,0xff,0xaa }, - { 0x28,0x28,0x78,0x50 }, { 0xdf,0xdf,0x7a,0xa5 }, + { 0x28,0x28,0x78,0x50 }, { 0xdf,0xdf,0x7a,0xa5 }, { 0x8c,0x8c,0x8f,0x03 }, { 0xa1,0xa1,0xf8,0x59 }, - { 0x89,0x89,0x80,0x09 }, { 0x0d,0x0d,0x17,0x1a }, - { 0xbf,0xbf,0xda,0x65 }, { 0xe6,0xe6,0x31,0xd7 }, - { 0x42,0x42,0xc6,0x84 }, { 0x68,0x68,0xb8,0xd0 }, + { 0x89,0x89,0x80,0x09 }, { 0x0d,0x0d,0x17,0x1a }, + { 0xbf,0xbf,0xda,0x65 }, { 0xe6,0xe6,0x31,0xd7 }, + { 0x42,0x42,0xc6,0x84 }, { 0x68,0x68,0xb8,0xd0 }, { 0x41,0x41,0xc3,0x82 }, { 0x99,0x99,0xb0,0x29 }, - { 0x2d,0x2d,0x77,0x5a }, { 0x0f,0x0f,0x11,0x1e }, + { 0x2d,0x2d,0x77,0x5a }, { 0x0f,0x0f,0x11,0x1e }, { 0xb0,0xb0,0xcb,0x7b }, { 0x54,0x54,0xfc,0xa8 }, { 0xbb,0xbb,0xd6,0x6d }, { 0x16,0x16,0x3a,0x2c } }; -static const unsigned char T5[256][4] = +static const unsigned char T5[256][4] = { - { 0x51,0xf4,0xa7,0x50 }, { 0x7e,0x41,0x65,0x53 }, - { 0x1a,0x17,0xa4,0xc3 }, { 0x3a,0x27,0x5e,0x96 }, + { 0x51,0xf4,0xa7,0x50 }, { 0x7e,0x41,0x65,0x53 }, + { 0x1a,0x17,0xa4,0xc3 }, { 0x3a,0x27,0x5e,0x96 }, { 0x3b,0xab,0x6b,0xcb }, { 0x1f,0x9d,0x45,0xf1 }, - { 0xac,0xfa,0x58,0xab }, { 0x4b,0xe3,0x03,0x93 }, + { 0xac,0xfa,0x58,0xab }, { 0x4b,0xe3,0x03,0x93 }, { 0x20,0x30,0xfa,0x55 }, { 0xad,0x76,0x6d,0xf6 }, - { 0x88,0xcc,0x76,0x91 }, { 0xf5,0x02,0x4c,0x25 }, + { 0x88,0xcc,0x76,0x91 }, { 0xf5,0x02,0x4c,0x25 }, { 0x4f,0xe5,0xd7,0xfc }, { 0xc5,0x2a,0xcb,0xd7 }, - { 0x26,0x35,0x44,0x80 }, { 0xb5,0x62,0xa3,0x8f }, + { 0x26,0x35,0x44,0x80 }, { 0xb5,0x62,0xa3,0x8f }, { 0xde,0xb1,0x5a,0x49 }, { 0x25,0xba,0x1b,0x67 }, - { 0x45,0xea,0x0e,0x98 }, { 0x5d,0xfe,0xc0,0xe1 }, + { 0x45,0xea,0x0e,0x98 }, { 0x5d,0xfe,0xc0,0xe1 }, { 0xc3,0x2f,0x75,0x02 }, { 0x81,0x4c,0xf0,0x12 }, - { 0x8d,0x46,0x97,0xa3 }, { 0x6b,0xd3,0xf9,0xc6 }, + { 0x8d,0x46,0x97,0xa3 }, { 0x6b,0xd3,0xf9,0xc6 }, { 0x03,0x8f,0x5f,0xe7 }, { 0x15,0x92,0x9c,0x95 }, - { 0xbf,0x6d,0x7a,0xeb }, { 0x95,0x52,0x59,0xda }, + { 0xbf,0x6d,0x7a,0xeb }, { 0x95,0x52,0x59,0xda }, { 0xd4,0xbe,0x83,0x2d }, { 0x58,0x74,0x21,0xd3 }, - { 0x49,0xe0,0x69,0x29 }, { 0x8e,0xc9,0xc8,0x44 }, + { 0x49,0xe0,0x69,0x29 }, { 0x8e,0xc9,0xc8,0x44 }, { 0x75,0xc2,0x89,0x6a }, { 0xf4,0x8e,0x79,0x78 }, - { 0x99,0x58,0x3e,0x6b }, { 0x27,0xb9,0x71,0xdd }, + { 0x99,0x58,0x3e,0x6b }, { 0x27,0xb9,0x71,0xdd }, { 0xbe,0xe1,0x4f,0xb6 }, { 0xf0,0x88,0xad,0x17 }, - { 0xc9,0x20,0xac,0x66 }, { 0x7d,0xce,0x3a,0xb4 }, + { 0xc9,0x20,0xac,0x66 }, { 0x7d,0xce,0x3a,0xb4 }, { 0x63,0xdf,0x4a,0x18 }, { 0xe5,0x1a,0x31,0x82 }, - { 0x97,0x51,0x33,0x60 }, { 0x62,0x53,0x7f,0x45 }, - { 0xb1,0x64,0x77,0xe0 }, { 0xbb,0x6b,0xae,0x84 }, - { 0xfe,0x81,0xa0,0x1c }, { 0xf9,0x08,0x2b,0x94 }, - { 0x70,0x48,0x68,0x58 }, { 0x8f,0x45,0xfd,0x19 }, - { 0x94,0xde,0x6c,0x87 }, { 0x52,0x7b,0xf8,0xb7 }, + { 0x97,0x51,0x33,0x60 }, { 0x62,0x53,0x7f,0x45 }, + { 0xb1,0x64,0x77,0xe0 }, { 0xbb,0x6b,0xae,0x84 }, + { 0xfe,0x81,0xa0,0x1c }, { 0xf9,0x08,0x2b,0x94 }, + { 0x70,0x48,0x68,0x58 }, { 0x8f,0x45,0xfd,0x19 }, + { 0x94,0xde,0x6c,0x87 }, { 0x52,0x7b,0xf8,0xb7 }, { 0xab,0x73,0xd3,0x23 }, { 0x72,0x4b,0x02,0xe2 }, - { 0xe3,0x1f,0x8f,0x57 }, { 0x66,0x55,0xab,0x2a }, + { 0xe3,0x1f,0x8f,0x57 }, { 0x66,0x55,0xab,0x2a }, { 0xb2,0xeb,0x28,0x07 }, { 0x2f,0xb5,0xc2,0x03 }, - { 0x86,0xc5,0x7b,0x9a }, { 0xd3,0x37,0x08,0xa5 }, + { 0x86,0xc5,0x7b,0x9a }, { 0xd3,0x37,0x08,0xa5 }, { 0x30,0x28,0x87,0xf2 }, { 0x23,0xbf,0xa5,0xb2 }, - { 0x02,0x03,0x6a,0xba }, { 0xed,0x16,0x82,0x5c }, + { 0x02,0x03,0x6a,0xba }, { 0xed,0x16,0x82,0x5c }, { 0x8a,0xcf,0x1c,0x2b }, { 0xa7,0x79,0xb4,0x92 }, - { 0xf3,0x07,0xf2,0xf0 }, { 0x4e,0x69,0xe2,0xa1 }, + { 0xf3,0x07,0xf2,0xf0 }, { 0x4e,0x69,0xe2,0xa1 }, { 0x65,0xda,0xf4,0xcd }, { 0x06,0x05,0xbe,0xd5 }, - { 0xd1,0x34,0x62,0x1f }, { 0xc4,0xa6,0xfe,0x8a }, + { 0xd1,0x34,0x62,0x1f }, { 0xc4,0xa6,0xfe,0x8a }, { 0x34,0x2e,0x53,0x9d }, { 0xa2,0xf3,0x55,0xa0 }, - { 0x05,0x8a,0xe1,0x32 }, { 0xa4,0xf6,0xeb,0x75 }, + { 0x05,0x8a,0xe1,0x32 }, { 0xa4,0xf6,0xeb,0x75 }, { 0x0b,0x83,0xec,0x39 }, { 0x40,0x60,0xef,0xaa }, - { 0x5e,0x71,0x9f,0x06 }, { 0xbd,0x6e,0x10,0x51 }, - { 0x3e,0x21,0x8a,0xf9 }, { 0x96,0xdd,0x06,0x3d }, - { 0xdd,0x3e,0x05,0xae }, { 0x4d,0xe6,0xbd,0x46 }, - { 0x91,0x54,0x8d,0xb5 }, { 0x71,0xc4,0x5d,0x05 }, - { 0x04,0x06,0xd4,0x6f }, { 0x60,0x50,0x15,0xff }, + { 0x5e,0x71,0x9f,0x06 }, { 0xbd,0x6e,0x10,0x51 }, + { 0x3e,0x21,0x8a,0xf9 }, { 0x96,0xdd,0x06,0x3d }, + { 0xdd,0x3e,0x05,0xae }, { 0x4d,0xe6,0xbd,0x46 }, + { 0x91,0x54,0x8d,0xb5 }, { 0x71,0xc4,0x5d,0x05 }, + { 0x04,0x06,0xd4,0x6f }, { 0x60,0x50,0x15,0xff }, { 0x19,0x98,0xfb,0x24 }, { 0xd6,0xbd,0xe9,0x97 }, - { 0x89,0x40,0x43,0xcc }, { 0x67,0xd9,0x9e,0x77 }, + { 0x89,0x40,0x43,0xcc }, { 0x67,0xd9,0x9e,0x77 }, { 0xb0,0xe8,0x42,0xbd }, { 0x07,0x89,0x8b,0x88 }, - { 0xe7,0x19,0x5b,0x38 }, { 0x79,0xc8,0xee,0xdb }, + { 0xe7,0x19,0x5b,0x38 }, { 0x79,0xc8,0xee,0xdb }, { 0xa1,0x7c,0x0a,0x47 }, { 0x7c,0x42,0x0f,0xe9 }, - { 0xf8,0x84,0x1e,0xc9 }, { 0x00,0x00,0x00,0x00 }, + { 0xf8,0x84,0x1e,0xc9 }, { 0x00,0x00,0x00,0x00 }, { 0x09,0x80,0x86,0x83 }, { 0x32,0x2b,0xed,0x48 }, - { 0x1e,0x11,0x70,0xac }, { 0x6c,0x5a,0x72,0x4e }, + { 0x1e,0x11,0x70,0xac }, { 0x6c,0x5a,0x72,0x4e }, { 0xfd,0x0e,0xff,0xfb }, { 0x0f,0x85,0x38,0x56 }, - { 0x3d,0xae,0xd5,0x1e }, { 0x36,0x2d,0x39,0x27 }, + { 0x3d,0xae,0xd5,0x1e }, { 0x36,0x2d,0x39,0x27 }, { 0x0a,0x0f,0xd9,0x64 }, { 0x68,0x5c,0xa6,0x21 }, - { 0x9b,0x5b,0x54,0xd1 }, { 0x24,0x36,0x2e,0x3a }, + { 0x9b,0x5b,0x54,0xd1 }, { 0x24,0x36,0x2e,0x3a }, { 0x0c,0x0a,0x67,0xb1 }, { 0x93,0x57,0xe7,0x0f }, - { 0xb4,0xee,0x96,0xd2 }, { 0x1b,0x9b,0x91,0x9e }, + { 0xb4,0xee,0x96,0xd2 }, { 0x1b,0x9b,0x91,0x9e }, { 0x80,0xc0,0xc5,0x4f }, { 0x61,0xdc,0x20,0xa2 }, - { 0x5a,0x77,0x4b,0x69 }, { 0x1c,0x12,0x1a,0x16 }, - { 0xe2,0x93,0xba,0x0a }, { 0xc0,0xa0,0x2a,0xe5 }, - { 0x3c,0x22,0xe0,0x43 }, { 0x12,0x1b,0x17,0x1d }, - { 0x0e,0x09,0x0d,0x0b }, { 0xf2,0x8b,0xc7,0xad }, - { 0x2d,0xb6,0xa8,0xb9 }, { 0x14,0x1e,0xa9,0xc8 }, - { 0x57,0xf1,0x19,0x85 }, { 0xaf,0x75,0x07,0x4c }, - { 0xee,0x99,0xdd,0xbb }, { 0xa3,0x7f,0x60,0xfd }, + { 0x5a,0x77,0x4b,0x69 }, { 0x1c,0x12,0x1a,0x16 }, + { 0xe2,0x93,0xba,0x0a }, { 0xc0,0xa0,0x2a,0xe5 }, + { 0x3c,0x22,0xe0,0x43 }, { 0x12,0x1b,0x17,0x1d }, + { 0x0e,0x09,0x0d,0x0b }, { 0xf2,0x8b,0xc7,0xad }, + { 0x2d,0xb6,0xa8,0xb9 }, { 0x14,0x1e,0xa9,0xc8 }, + { 0x57,0xf1,0x19,0x85 }, { 0xaf,0x75,0x07,0x4c }, + { 0xee,0x99,0xdd,0xbb }, { 0xa3,0x7f,0x60,0xfd }, { 0xf7,0x01,0x26,0x9f }, { 0x5c,0x72,0xf5,0xbc }, - { 0x44,0x66,0x3b,0xc5 }, { 0x5b,0xfb,0x7e,0x34 }, + { 0x44,0x66,0x3b,0xc5 }, { 0x5b,0xfb,0x7e,0x34 }, { 0x8b,0x43,0x29,0x76 }, { 0xcb,0x23,0xc6,0xdc }, - { 0xb6,0xed,0xfc,0x68 }, { 0xb8,0xe4,0xf1,0x63 }, + { 0xb6,0xed,0xfc,0x68 }, { 0xb8,0xe4,0xf1,0x63 }, { 0xd7,0x31,0xdc,0xca }, { 0x42,0x63,0x85,0x10 }, - { 0x13,0x97,0x22,0x40 }, { 0x84,0xc6,0x11,0x20 }, - { 0x85,0x4a,0x24,0x7d }, { 0xd2,0xbb,0x3d,0xf8 }, - { 0xae,0xf9,0x32,0x11 }, { 0xc7,0x29,0xa1,0x6d }, + { 0x13,0x97,0x22,0x40 }, { 0x84,0xc6,0x11,0x20 }, + { 0x85,0x4a,0x24,0x7d }, { 0xd2,0xbb,0x3d,0xf8 }, + { 0xae,0xf9,0x32,0x11 }, { 0xc7,0x29,0xa1,0x6d }, { 0x1d,0x9e,0x2f,0x4b }, { 0xdc,0xb2,0x30,0xf3 }, - { 0x0d,0x86,0x52,0xec }, { 0x77,0xc1,0xe3,0xd0 }, + { 0x0d,0x86,0x52,0xec }, { 0x77,0xc1,0xe3,0xd0 }, { 0x2b,0xb3,0x16,0x6c }, { 0xa9,0x70,0xb9,0x99 }, - { 0x11,0x94,0x48,0xfa }, { 0x47,0xe9,0x64,0x22 }, + { 0x11,0x94,0x48,0xfa }, { 0x47,0xe9,0x64,0x22 }, { 0xa8,0xfc,0x8c,0xc4 }, { 0xa0,0xf0,0x3f,0x1a }, - { 0x56,0x7d,0x2c,0xd8 }, { 0x22,0x33,0x90,0xef }, - { 0x87,0x49,0x4e,0xc7 }, { 0xd9,0x38,0xd1,0xc1 }, - { 0x8c,0xca,0xa2,0xfe }, { 0x98,0xd4,0x0b,0x36 }, - { 0xa6,0xf5,0x81,0xcf }, { 0xa5,0x7a,0xde,0x28 }, - { 0xda,0xb7,0x8e,0x26 }, { 0x3f,0xad,0xbf,0xa4 }, - { 0x2c,0x3a,0x9d,0xe4 }, { 0x50,0x78,0x92,0x0d }, - { 0x6a,0x5f,0xcc,0x9b }, { 0x54,0x7e,0x46,0x62 }, - { 0xf6,0x8d,0x13,0xc2 }, { 0x90,0xd8,0xb8,0xe8 }, - { 0x2e,0x39,0xf7,0x5e }, { 0x82,0xc3,0xaf,0xf5 }, + { 0x56,0x7d,0x2c,0xd8 }, { 0x22,0x33,0x90,0xef }, + { 0x87,0x49,0x4e,0xc7 }, { 0xd9,0x38,0xd1,0xc1 }, + { 0x8c,0xca,0xa2,0xfe }, { 0x98,0xd4,0x0b,0x36 }, + { 0xa6,0xf5,0x81,0xcf }, { 0xa5,0x7a,0xde,0x28 }, + { 0xda,0xb7,0x8e,0x26 }, { 0x3f,0xad,0xbf,0xa4 }, + { 0x2c,0x3a,0x9d,0xe4 }, { 0x50,0x78,0x92,0x0d }, + { 0x6a,0x5f,0xcc,0x9b }, { 0x54,0x7e,0x46,0x62 }, + { 0xf6,0x8d,0x13,0xc2 }, { 0x90,0xd8,0xb8,0xe8 }, + { 0x2e,0x39,0xf7,0x5e }, { 0x82,0xc3,0xaf,0xf5 }, { 0x9f,0x5d,0x80,0xbe }, { 0x69,0xd0,0x93,0x7c }, - { 0x6f,0xd5,0x2d,0xa9 }, { 0xcf,0x25,0x12,0xb3 }, + { 0x6f,0xd5,0x2d,0xa9 }, { 0xcf,0x25,0x12,0xb3 }, { 0xc8,0xac,0x99,0x3b }, { 0x10,0x18,0x7d,0xa7 }, - { 0xe8,0x9c,0x63,0x6e }, { 0xdb,0x3b,0xbb,0x7b }, + { 0xe8,0x9c,0x63,0x6e }, { 0xdb,0x3b,0xbb,0x7b }, { 0xcd,0x26,0x78,0x09 }, { 0x6e,0x59,0x18,0xf4 }, - { 0xec,0x9a,0xb7,0x01 }, { 0x83,0x4f,0x9a,0xa8 }, - { 0xe6,0x95,0x6e,0x65 }, { 0xaa,0xff,0xe6,0x7e }, - { 0x21,0xbc,0xcf,0x08 }, { 0xef,0x15,0xe8,0xe6 }, - { 0xba,0xe7,0x9b,0xd9 }, { 0x4a,0x6f,0x36,0xce }, - { 0xea,0x9f,0x09,0xd4 }, { 0x29,0xb0,0x7c,0xd6 }, - { 0x31,0xa4,0xb2,0xaf }, { 0x2a,0x3f,0x23,0x31 }, - { 0xc6,0xa5,0x94,0x30 }, { 0x35,0xa2,0x66,0xc0 }, - { 0x74,0x4e,0xbc,0x37 }, { 0xfc,0x82,0xca,0xa6 }, - { 0xe0,0x90,0xd0,0xb0 }, { 0x33,0xa7,0xd8,0x15 }, + { 0xec,0x9a,0xb7,0x01 }, { 0x83,0x4f,0x9a,0xa8 }, + { 0xe6,0x95,0x6e,0x65 }, { 0xaa,0xff,0xe6,0x7e }, + { 0x21,0xbc,0xcf,0x08 }, { 0xef,0x15,0xe8,0xe6 }, + { 0xba,0xe7,0x9b,0xd9 }, { 0x4a,0x6f,0x36,0xce }, + { 0xea,0x9f,0x09,0xd4 }, { 0x29,0xb0,0x7c,0xd6 }, + { 0x31,0xa4,0xb2,0xaf }, { 0x2a,0x3f,0x23,0x31 }, + { 0xc6,0xa5,0x94,0x30 }, { 0x35,0xa2,0x66,0xc0 }, + { 0x74,0x4e,0xbc,0x37 }, { 0xfc,0x82,0xca,0xa6 }, + { 0xe0,0x90,0xd0,0xb0 }, { 0x33,0xa7,0xd8,0x15 }, { 0xf1,0x04,0x98,0x4a }, { 0x41,0xec,0xda,0xf7 }, - { 0x7f,0xcd,0x50,0x0e }, { 0x17,0x91,0xf6,0x2f }, + { 0x7f,0xcd,0x50,0x0e }, { 0x17,0x91,0xf6,0x2f }, { 0x76,0x4d,0xd6,0x8d }, { 0x43,0xef,0xb0,0x4d }, - { 0xcc,0xaa,0x4d,0x54 }, { 0xe4,0x96,0x04,0xdf }, + { 0xcc,0xaa,0x4d,0x54 }, { 0xe4,0x96,0x04,0xdf }, { 0x9e,0xd1,0xb5,0xe3 }, { 0x4c,0x6a,0x88,0x1b }, - { 0xc1,0x2c,0x1f,0xb8 }, { 0x46,0x65,0x51,0x7f }, + { 0xc1,0x2c,0x1f,0xb8 }, { 0x46,0x65,0x51,0x7f }, { 0x9d,0x5e,0xea,0x04 }, { 0x01,0x8c,0x35,0x5d }, - { 0xfa,0x87,0x74,0x73 }, { 0xfb,0x0b,0x41,0x2e }, + { 0xfa,0x87,0x74,0x73 }, { 0xfb,0x0b,0x41,0x2e }, { 0xb3,0x67,0x1d,0x5a }, { 0x92,0xdb,0xd2,0x52 }, - { 0xe9,0x10,0x56,0x33 }, { 0x6d,0xd6,0x47,0x13 }, + { 0xe9,0x10,0x56,0x33 }, { 0x6d,0xd6,0x47,0x13 }, { 0x9a,0xd7,0x61,0x8c }, { 0x37,0xa1,0x0c,0x7a }, - { 0x59,0xf8,0x14,0x8e }, { 0xeb,0x13,0x3c,0x89 }, + { 0x59,0xf8,0x14,0x8e }, { 0xeb,0x13,0x3c,0x89 }, { 0xce,0xa9,0x27,0xee }, { 0xb7,0x61,0xc9,0x35 }, - { 0xe1,0x1c,0xe5,0xed }, { 0x7a,0x47,0xb1,0x3c }, - { 0x9c,0xd2,0xdf,0x59 }, { 0x55,0xf2,0x73,0x3f }, - { 0x18,0x14,0xce,0x79 }, { 0x73,0xc7,0x37,0xbf }, + { 0xe1,0x1c,0xe5,0xed }, { 0x7a,0x47,0xb1,0x3c }, + { 0x9c,0xd2,0xdf,0x59 }, { 0x55,0xf2,0x73,0x3f }, + { 0x18,0x14,0xce,0x79 }, { 0x73,0xc7,0x37,0xbf }, { 0x53,0xf7,0xcd,0xea }, { 0x5f,0xfd,0xaa,0x5b }, - { 0xdf,0x3d,0x6f,0x14 }, { 0x78,0x44,0xdb,0x86 }, - { 0xca,0xaf,0xf3,0x81 }, { 0xb9,0x68,0xc4,0x3e }, - { 0x38,0x24,0x34,0x2c }, { 0xc2,0xa3,0x40,0x5f }, - { 0x16,0x1d,0xc3,0x72 }, { 0xbc,0xe2,0x25,0x0c }, - { 0x28,0x3c,0x49,0x8b }, { 0xff,0x0d,0x95,0x41 }, - { 0x39,0xa8,0x01,0x71 }, { 0x08,0x0c,0xb3,0xde }, - { 0xd8,0xb4,0xe4,0x9c }, { 0x64,0x56,0xc1,0x90 }, + { 0xdf,0x3d,0x6f,0x14 }, { 0x78,0x44,0xdb,0x86 }, + { 0xca,0xaf,0xf3,0x81 }, { 0xb9,0x68,0xc4,0x3e }, + { 0x38,0x24,0x34,0x2c }, { 0xc2,0xa3,0x40,0x5f }, + { 0x16,0x1d,0xc3,0x72 }, { 0xbc,0xe2,0x25,0x0c }, + { 0x28,0x3c,0x49,0x8b }, { 0xff,0x0d,0x95,0x41 }, + { 0x39,0xa8,0x01,0x71 }, { 0x08,0x0c,0xb3,0xde }, + { 0xd8,0xb4,0xe4,0x9c }, { 0x64,0x56,0xc1,0x90 }, { 0x7b,0xcb,0x84,0x61 }, { 0xd5,0x32,0xb6,0x70 }, { 0x48,0x6c,0x5c,0x74 }, { 0xd0,0xb8,0x57,0x42 } }; -static const unsigned char T6[256][4] = +static const unsigned char T6[256][4] = { - { 0x50,0x51,0xf4,0xa7 }, { 0x53,0x7e,0x41,0x65 }, - { 0xc3,0x1a,0x17,0xa4 }, { 0x96,0x3a,0x27,0x5e }, + { 0x50,0x51,0xf4,0xa7 }, { 0x53,0x7e,0x41,0x65 }, + { 0xc3,0x1a,0x17,0xa4 }, { 0x96,0x3a,0x27,0x5e }, { 0xcb,0x3b,0xab,0x6b }, { 0xf1,0x1f,0x9d,0x45 }, - { 0xab,0xac,0xfa,0x58 }, { 0x93,0x4b,0xe3,0x03 }, + { 0xab,0xac,0xfa,0x58 }, { 0x93,0x4b,0xe3,0x03 }, { 0x55,0x20,0x30,0xfa }, { 0xf6,0xad,0x76,0x6d }, - { 0x91,0x88,0xcc,0x76 }, { 0x25,0xf5,0x02,0x4c }, + { 0x91,0x88,0xcc,0x76 }, { 0x25,0xf5,0x02,0x4c }, { 0xfc,0x4f,0xe5,0xd7 }, { 0xd7,0xc5,0x2a,0xcb }, - { 0x80,0x26,0x35,0x44 }, { 0x8f,0xb5,0x62,0xa3 }, - { 0x49,0xde,0xb1,0x5a }, { 0x67,0x25,0xba,0x1b }, - { 0x98,0x45,0xea,0x0e }, { 0xe1,0x5d,0xfe,0xc0 }, + { 0x80,0x26,0x35,0x44 }, { 0x8f,0xb5,0x62,0xa3 }, + { 0x49,0xde,0xb1,0x5a }, { 0x67,0x25,0xba,0x1b }, + { 0x98,0x45,0xea,0x0e }, { 0xe1,0x5d,0xfe,0xc0 }, { 0x02,0xc3,0x2f,0x75 }, { 0x12,0x81,0x4c,0xf0 }, - { 0xa3,0x8d,0x46,0x97 }, { 0xc6,0x6b,0xd3,0xf9 }, + { 0xa3,0x8d,0x46,0x97 }, { 0xc6,0x6b,0xd3,0xf9 }, { 0xe7,0x03,0x8f,0x5f }, { 0x95,0x15,0x92,0x9c }, - { 0xeb,0xbf,0x6d,0x7a }, { 0xda,0x95,0x52,0x59 }, + { 0xeb,0xbf,0x6d,0x7a }, { 0xda,0x95,0x52,0x59 }, { 0x2d,0xd4,0xbe,0x83 }, { 0xd3,0x58,0x74,0x21 }, - { 0x29,0x49,0xe0,0x69 }, { 0x44,0x8e,0xc9,0xc8 }, + { 0x29,0x49,0xe0,0x69 }, { 0x44,0x8e,0xc9,0xc8 }, { 0x6a,0x75,0xc2,0x89 }, { 0x78,0xf4,0x8e,0x79 }, - { 0x6b,0x99,0x58,0x3e }, { 0xdd,0x27,0xb9,0x71 }, + { 0x6b,0x99,0x58,0x3e }, { 0xdd,0x27,0xb9,0x71 }, { 0xb6,0xbe,0xe1,0x4f }, { 0x17,0xf0,0x88,0xad }, - { 0x66,0xc9,0x20,0xac }, { 0xb4,0x7d,0xce,0x3a }, + { 0x66,0xc9,0x20,0xac }, { 0xb4,0x7d,0xce,0x3a }, { 0x18,0x63,0xdf,0x4a }, { 0x82,0xe5,0x1a,0x31 }, - { 0x60,0x97,0x51,0x33 }, { 0x45,0x62,0x53,0x7f }, + { 0x60,0x97,0x51,0x33 }, { 0x45,0x62,0x53,0x7f }, { 0xe0,0xb1,0x64,0x77 }, { 0x84,0xbb,0x6b,0xae }, - { 0x1c,0xfe,0x81,0xa0 }, { 0x94,0xf9,0x08,0x2b }, + { 0x1c,0xfe,0x81,0xa0 }, { 0x94,0xf9,0x08,0x2b }, { 0x58,0x70,0x48,0x68 }, { 0x19,0x8f,0x45,0xfd }, - { 0x87,0x94,0xde,0x6c }, { 0xb7,0x52,0x7b,0xf8 }, + { 0x87,0x94,0xde,0x6c }, { 0xb7,0x52,0x7b,0xf8 }, { 0x23,0xab,0x73,0xd3 }, { 0xe2,0x72,0x4b,0x02 }, - { 0x57,0xe3,0x1f,0x8f }, { 0x2a,0x66,0x55,0xab }, + { 0x57,0xe3,0x1f,0x8f }, { 0x2a,0x66,0x55,0xab }, { 0x07,0xb2,0xeb,0x28 }, { 0x03,0x2f,0xb5,0xc2 }, - { 0x9a,0x86,0xc5,0x7b }, { 0xa5,0xd3,0x37,0x08 }, + { 0x9a,0x86,0xc5,0x7b }, { 0xa5,0xd3,0x37,0x08 }, { 0xf2,0x30,0x28,0x87 }, { 0xb2,0x23,0xbf,0xa5 }, - { 0xba,0x02,0x03,0x6a }, { 0x5c,0xed,0x16,0x82 }, + { 0xba,0x02,0x03,0x6a }, { 0x5c,0xed,0x16,0x82 }, { 0x2b,0x8a,0xcf,0x1c }, { 0x92,0xa7,0x79,0xb4 }, - { 0xf0,0xf3,0x07,0xf2 }, { 0xa1,0x4e,0x69,0xe2 }, + { 0xf0,0xf3,0x07,0xf2 }, { 0xa1,0x4e,0x69,0xe2 }, { 0xcd,0x65,0xda,0xf4 }, { 0xd5,0x06,0x05,0xbe }, - { 0x1f,0xd1,0x34,0x62 }, { 0x8a,0xc4,0xa6,0xfe }, + { 0x1f,0xd1,0x34,0x62 }, { 0x8a,0xc4,0xa6,0xfe }, { 0x9d,0x34,0x2e,0x53 }, { 0xa0,0xa2,0xf3,0x55 }, - { 0x32,0x05,0x8a,0xe1 }, { 0x75,0xa4,0xf6,0xeb }, + { 0x32,0x05,0x8a,0xe1 }, { 0x75,0xa4,0xf6,0xeb }, { 0x39,0x0b,0x83,0xec }, { 0xaa,0x40,0x60,0xef }, - { 0x06,0x5e,0x71,0x9f }, { 0x51,0xbd,0x6e,0x10 }, + { 0x06,0x5e,0x71,0x9f }, { 0x51,0xbd,0x6e,0x10 }, { 0xf9,0x3e,0x21,0x8a }, { 0x3d,0x96,0xdd,0x06 }, - { 0xae,0xdd,0x3e,0x05 }, { 0x46,0x4d,0xe6,0xbd }, + { 0xae,0xdd,0x3e,0x05 }, { 0x46,0x4d,0xe6,0xbd }, { 0xb5,0x91,0x54,0x8d }, { 0x05,0x71,0xc4,0x5d }, - { 0x6f,0x04,0x06,0xd4 }, { 0xff,0x60,0x50,0x15 }, + { 0x6f,0x04,0x06,0xd4 }, { 0xff,0x60,0x50,0x15 }, { 0x24,0x19,0x98,0xfb }, { 0x97,0xd6,0xbd,0xe9 }, - { 0xcc,0x89,0x40,0x43 }, { 0x77,0x67,0xd9,0x9e }, + { 0xcc,0x89,0x40,0x43 }, { 0x77,0x67,0xd9,0x9e }, { 0xbd,0xb0,0xe8,0x42 }, { 0x88,0x07,0x89,0x8b }, - { 0x38,0xe7,0x19,0x5b }, { 0xdb,0x79,0xc8,0xee }, + { 0x38,0xe7,0x19,0x5b }, { 0xdb,0x79,0xc8,0xee }, { 0x47,0xa1,0x7c,0x0a }, { 0xe9,0x7c,0x42,0x0f }, - { 0xc9,0xf8,0x84,0x1e }, { 0x00,0x00,0x00,0x00 }, + { 0xc9,0xf8,0x84,0x1e }, { 0x00,0x00,0x00,0x00 }, { 0x83,0x09,0x80,0x86 }, { 0x48,0x32,0x2b,0xed }, - { 0xac,0x1e,0x11,0x70 }, { 0x4e,0x6c,0x5a,0x72 }, + { 0xac,0x1e,0x11,0x70 }, { 0x4e,0x6c,0x5a,0x72 }, { 0xfb,0xfd,0x0e,0xff }, { 0x56,0x0f,0x85,0x38 }, - { 0x1e,0x3d,0xae,0xd5 }, { 0x27,0x36,0x2d,0x39 }, + { 0x1e,0x3d,0xae,0xd5 }, { 0x27,0x36,0x2d,0x39 }, { 0x64,0x0a,0x0f,0xd9 }, { 0x21,0x68,0x5c,0xa6 }, - { 0xd1,0x9b,0x5b,0x54 }, { 0x3a,0x24,0x36,0x2e }, + { 0xd1,0x9b,0x5b,0x54 }, { 0x3a,0x24,0x36,0x2e }, { 0xb1,0x0c,0x0a,0x67 }, { 0x0f,0x93,0x57,0xe7 }, - { 0xd2,0xb4,0xee,0x96 }, { 0x9e,0x1b,0x9b,0x91 }, - { 0x4f,0x80,0xc0,0xc5 }, { 0xa2,0x61,0xdc,0x20 }, - { 0x69,0x5a,0x77,0x4b }, { 0x16,0x1c,0x12,0x1a }, + { 0xd2,0xb4,0xee,0x96 }, { 0x9e,0x1b,0x9b,0x91 }, + { 0x4f,0x80,0xc0,0xc5 }, { 0xa2,0x61,0xdc,0x20 }, + { 0x69,0x5a,0x77,0x4b }, { 0x16,0x1c,0x12,0x1a }, { 0x0a,0xe2,0x93,0xba }, { 0xe5,0xc0,0xa0,0x2a }, - { 0x43,0x3c,0x22,0xe0 }, { 0x1d,0x12,0x1b,0x17 }, + { 0x43,0x3c,0x22,0xe0 }, { 0x1d,0x12,0x1b,0x17 }, { 0x0b,0x0e,0x09,0x0d }, { 0xad,0xf2,0x8b,0xc7 }, - { 0xb9,0x2d,0xb6,0xa8 }, { 0xc8,0x14,0x1e,0xa9 }, + { 0xb9,0x2d,0xb6,0xa8 }, { 0xc8,0x14,0x1e,0xa9 }, { 0x85,0x57,0xf1,0x19 }, { 0x4c,0xaf,0x75,0x07 }, - { 0xbb,0xee,0x99,0xdd }, { 0xfd,0xa3,0x7f,0x60 }, + { 0xbb,0xee,0x99,0xdd }, { 0xfd,0xa3,0x7f,0x60 }, { 0x9f,0xf7,0x01,0x26 }, { 0xbc,0x5c,0x72,0xf5 }, - { 0xc5,0x44,0x66,0x3b }, { 0x34,0x5b,0xfb,0x7e }, + { 0xc5,0x44,0x66,0x3b }, { 0x34,0x5b,0xfb,0x7e }, { 0x76,0x8b,0x43,0x29 }, { 0xdc,0xcb,0x23,0xc6 }, - { 0x68,0xb6,0xed,0xfc }, { 0x63,0xb8,0xe4,0xf1 }, + { 0x68,0xb6,0xed,0xfc }, { 0x63,0xb8,0xe4,0xf1 }, { 0xca,0xd7,0x31,0xdc }, { 0x10,0x42,0x63,0x85 }, - { 0x40,0x13,0x97,0x22 }, { 0x20,0x84,0xc6,0x11 }, + { 0x40,0x13,0x97,0x22 }, { 0x20,0x84,0xc6,0x11 }, { 0x7d,0x85,0x4a,0x24 }, { 0xf8,0xd2,0xbb,0x3d }, - { 0x11,0xae,0xf9,0x32 }, { 0x6d,0xc7,0x29,0xa1 }, + { 0x11,0xae,0xf9,0x32 }, { 0x6d,0xc7,0x29,0xa1 }, { 0x4b,0x1d,0x9e,0x2f }, { 0xf3,0xdc,0xb2,0x30 }, - { 0xec,0x0d,0x86,0x52 }, { 0xd0,0x77,0xc1,0xe3 }, - { 0x6c,0x2b,0xb3,0x16 }, { 0x99,0xa9,0x70,0xb9 }, - { 0xfa,0x11,0x94,0x48 }, { 0x22,0x47,0xe9,0x64 }, - { 0xc4,0xa8,0xfc,0x8c }, { 0x1a,0xa0,0xf0,0x3f }, - { 0xd8,0x56,0x7d,0x2c }, { 0xef,0x22,0x33,0x90 }, + { 0xec,0x0d,0x86,0x52 }, { 0xd0,0x77,0xc1,0xe3 }, + { 0x6c,0x2b,0xb3,0x16 }, { 0x99,0xa9,0x70,0xb9 }, + { 0xfa,0x11,0x94,0x48 }, { 0x22,0x47,0xe9,0x64 }, + { 0xc4,0xa8,0xfc,0x8c }, { 0x1a,0xa0,0xf0,0x3f }, + { 0xd8,0x56,0x7d,0x2c }, { 0xef,0x22,0x33,0x90 }, { 0xc7,0x87,0x49,0x4e }, { 0xc1,0xd9,0x38,0xd1 }, - { 0xfe,0x8c,0xca,0xa2 }, { 0x36,0x98,0xd4,0x0b }, - { 0xcf,0xa6,0xf5,0x81 }, { 0x28,0xa5,0x7a,0xde }, - { 0x26,0xda,0xb7,0x8e }, { 0xa4,0x3f,0xad,0xbf }, - { 0xe4,0x2c,0x3a,0x9d }, { 0x0d,0x50,0x78,0x92 }, - { 0x9b,0x6a,0x5f,0xcc }, { 0x62,0x54,0x7e,0x46 }, - { 0xc2,0xf6,0x8d,0x13 }, { 0xe8,0x90,0xd8,0xb8 }, - { 0x5e,0x2e,0x39,0xf7 }, { 0xf5,0x82,0xc3,0xaf }, + { 0xfe,0x8c,0xca,0xa2 }, { 0x36,0x98,0xd4,0x0b }, + { 0xcf,0xa6,0xf5,0x81 }, { 0x28,0xa5,0x7a,0xde }, + { 0x26,0xda,0xb7,0x8e }, { 0xa4,0x3f,0xad,0xbf }, + { 0xe4,0x2c,0x3a,0x9d }, { 0x0d,0x50,0x78,0x92 }, + { 0x9b,0x6a,0x5f,0xcc }, { 0x62,0x54,0x7e,0x46 }, + { 0xc2,0xf6,0x8d,0x13 }, { 0xe8,0x90,0xd8,0xb8 }, + { 0x5e,0x2e,0x39,0xf7 }, { 0xf5,0x82,0xc3,0xaf }, { 0xbe,0x9f,0x5d,0x80 }, { 0x7c,0x69,0xd0,0x93 }, - { 0xa9,0x6f,0xd5,0x2d }, { 0xb3,0xcf,0x25,0x12 }, - { 0x3b,0xc8,0xac,0x99 }, { 0xa7,0x10,0x18,0x7d }, - { 0x6e,0xe8,0x9c,0x63 }, { 0x7b,0xdb,0x3b,0xbb }, + { 0xa9,0x6f,0xd5,0x2d }, { 0xb3,0xcf,0x25,0x12 }, + { 0x3b,0xc8,0xac,0x99 }, { 0xa7,0x10,0x18,0x7d }, + { 0x6e,0xe8,0x9c,0x63 }, { 0x7b,0xdb,0x3b,0xbb }, { 0x09,0xcd,0x26,0x78 }, { 0xf4,0x6e,0x59,0x18 }, - { 0x01,0xec,0x9a,0xb7 }, { 0xa8,0x83,0x4f,0x9a }, - { 0x65,0xe6,0x95,0x6e }, { 0x7e,0xaa,0xff,0xe6 }, - { 0x08,0x21,0xbc,0xcf }, { 0xe6,0xef,0x15,0xe8 }, + { 0x01,0xec,0x9a,0xb7 }, { 0xa8,0x83,0x4f,0x9a }, + { 0x65,0xe6,0x95,0x6e }, { 0x7e,0xaa,0xff,0xe6 }, + { 0x08,0x21,0xbc,0xcf }, { 0xe6,0xef,0x15,0xe8 }, { 0xd9,0xba,0xe7,0x9b }, { 0xce,0x4a,0x6f,0x36 }, - { 0xd4,0xea,0x9f,0x09 }, { 0xd6,0x29,0xb0,0x7c }, + { 0xd4,0xea,0x9f,0x09 }, { 0xd6,0x29,0xb0,0x7c }, { 0xaf,0x31,0xa4,0xb2 }, { 0x31,0x2a,0x3f,0x23 }, - { 0x30,0xc6,0xa5,0x94 }, { 0xc0,0x35,0xa2,0x66 }, - { 0x37,0x74,0x4e,0xbc }, { 0xa6,0xfc,0x82,0xca }, - { 0xb0,0xe0,0x90,0xd0 }, { 0x15,0x33,0xa7,0xd8 }, + { 0x30,0xc6,0xa5,0x94 }, { 0xc0,0x35,0xa2,0x66 }, + { 0x37,0x74,0x4e,0xbc }, { 0xa6,0xfc,0x82,0xca }, + { 0xb0,0xe0,0x90,0xd0 }, { 0x15,0x33,0xa7,0xd8 }, { 0x4a,0xf1,0x04,0x98 }, { 0xf7,0x41,0xec,0xda }, - { 0x0e,0x7f,0xcd,0x50 }, { 0x2f,0x17,0x91,0xf6 }, + { 0x0e,0x7f,0xcd,0x50 }, { 0x2f,0x17,0x91,0xf6 }, { 0x8d,0x76,0x4d,0xd6 }, { 0x4d,0x43,0xef,0xb0 }, - { 0x54,0xcc,0xaa,0x4d }, { 0xdf,0xe4,0x96,0x04 }, + { 0x54,0xcc,0xaa,0x4d }, { 0xdf,0xe4,0x96,0x04 }, { 0xe3,0x9e,0xd1,0xb5 }, { 0x1b,0x4c,0x6a,0x88 }, - { 0xb8,0xc1,0x2c,0x1f }, { 0x7f,0x46,0x65,0x51 }, + { 0xb8,0xc1,0x2c,0x1f }, { 0x7f,0x46,0x65,0x51 }, { 0x04,0x9d,0x5e,0xea }, { 0x5d,0x01,0x8c,0x35 }, - { 0x73,0xfa,0x87,0x74 }, { 0x2e,0xfb,0x0b,0x41 }, + { 0x73,0xfa,0x87,0x74 }, { 0x2e,0xfb,0x0b,0x41 }, { 0x5a,0xb3,0x67,0x1d }, { 0x52,0x92,0xdb,0xd2 }, - { 0x33,0xe9,0x10,0x56 }, { 0x13,0x6d,0xd6,0x47 }, - { 0x8c,0x9a,0xd7,0x61 }, { 0x7a,0x37,0xa1,0x0c }, - { 0x8e,0x59,0xf8,0x14 }, { 0x89,0xeb,0x13,0x3c }, + { 0x33,0xe9,0x10,0x56 }, { 0x13,0x6d,0xd6,0x47 }, + { 0x8c,0x9a,0xd7,0x61 }, { 0x7a,0x37,0xa1,0x0c }, + { 0x8e,0x59,0xf8,0x14 }, { 0x89,0xeb,0x13,0x3c }, { 0xee,0xce,0xa9,0x27 }, { 0x35,0xb7,0x61,0xc9 }, - { 0xed,0xe1,0x1c,0xe5 }, { 0x3c,0x7a,0x47,0xb1 }, + { 0xed,0xe1,0x1c,0xe5 }, { 0x3c,0x7a,0x47,0xb1 }, { 0x59,0x9c,0xd2,0xdf }, { 0x3f,0x55,0xf2,0x73 }, - { 0x79,0x18,0x14,0xce }, { 0xbf,0x73,0xc7,0x37 }, + { 0x79,0x18,0x14,0xce }, { 0xbf,0x73,0xc7,0x37 }, { 0xea,0x53,0xf7,0xcd }, { 0x5b,0x5f,0xfd,0xaa }, - { 0x14,0xdf,0x3d,0x6f }, { 0x86,0x78,0x44,0xdb }, + { 0x14,0xdf,0x3d,0x6f }, { 0x86,0x78,0x44,0xdb }, { 0x81,0xca,0xaf,0xf3 }, { 0x3e,0xb9,0x68,0xc4 }, - { 0x2c,0x38,0x24,0x34 }, { 0x5f,0xc2,0xa3,0x40 }, + { 0x2c,0x38,0x24,0x34 }, { 0x5f,0xc2,0xa3,0x40 }, { 0x72,0x16,0x1d,0xc3 }, { 0x0c,0xbc,0xe2,0x25 }, - { 0x8b,0x28,0x3c,0x49 }, { 0x41,0xff,0x0d,0x95 }, + { 0x8b,0x28,0x3c,0x49 }, { 0x41,0xff,0x0d,0x95 }, { 0x71,0x39,0xa8,0x01 }, { 0xde,0x08,0x0c,0xb3 }, - { 0x9c,0xd8,0xb4,0xe4 }, { 0x90,0x64,0x56,0xc1 }, + { 0x9c,0xd8,0xb4,0xe4 }, { 0x90,0x64,0x56,0xc1 }, { 0x61,0x7b,0xcb,0x84 }, { 0x70,0xd5,0x32,0xb6 }, { 0x74,0x48,0x6c,0x5c }, { 0x42,0xd0,0xb8,0x57 } }; -static const unsigned char T7[256][4] = +static const unsigned char T7[256][4] = { { 0xa7,0x50,0x51,0xf4 }, { 0x65,0x53,0x7e,0x41 }, - { 0xa4,0xc3,0x1a,0x17 }, { 0x5e,0x96,0x3a,0x27 }, + { 0xa4,0xc3,0x1a,0x17 }, { 0x5e,0x96,0x3a,0x27 }, { 0x6b,0xcb,0x3b,0xab }, { 0x45,0xf1,0x1f,0x9d }, - { 0x58,0xab,0xac,0xfa }, { 0x03,0x93,0x4b,0xe3 }, + { 0x58,0xab,0xac,0xfa }, { 0x03,0x93,0x4b,0xe3 }, { 0xfa,0x55,0x20,0x30 }, { 0x6d,0xf6,0xad,0x76 }, - { 0x76,0x91,0x88,0xcc }, { 0x4c,0x25,0xf5,0x02 }, + { 0x76,0x91,0x88,0xcc }, { 0x4c,0x25,0xf5,0x02 }, { 0xd7,0xfc,0x4f,0xe5 }, { 0xcb,0xd7,0xc5,0x2a }, - { 0x44,0x80,0x26,0x35 }, { 0xa3,0x8f,0xb5,0x62 }, - { 0x5a,0x49,0xde,0xb1 }, { 0x1b,0x67,0x25,0xba }, - { 0x0e,0x98,0x45,0xea }, { 0xc0,0xe1,0x5d,0xfe }, + { 0x44,0x80,0x26,0x35 }, { 0xa3,0x8f,0xb5,0x62 }, + { 0x5a,0x49,0xde,0xb1 }, { 0x1b,0x67,0x25,0xba }, + { 0x0e,0x98,0x45,0xea }, { 0xc0,0xe1,0x5d,0xfe }, { 0x75,0x02,0xc3,0x2f }, { 0xf0,0x12,0x81,0x4c }, - { 0x97,0xa3,0x8d,0x46 }, { 0xf9,0xc6,0x6b,0xd3 }, + { 0x97,0xa3,0x8d,0x46 }, { 0xf9,0xc6,0x6b,0xd3 }, { 0x5f,0xe7,0x03,0x8f }, { 0x9c,0x95,0x15,0x92 }, - { 0x7a,0xeb,0xbf,0x6d }, { 0x59,0xda,0x95,0x52 }, + { 0x7a,0xeb,0xbf,0x6d }, { 0x59,0xda,0x95,0x52 }, { 0x83,0x2d,0xd4,0xbe }, { 0x21,0xd3,0x58,0x74 }, - { 0x69,0x29,0x49,0xe0 }, { 0xc8,0x44,0x8e,0xc9 }, - { 0x89,0x6a,0x75,0xc2 }, { 0x79,0x78,0xf4,0x8e }, - { 0x3e,0x6b,0x99,0x58 }, { 0x71,0xdd,0x27,0xb9 }, + { 0x69,0x29,0x49,0xe0 }, { 0xc8,0x44,0x8e,0xc9 }, + { 0x89,0x6a,0x75,0xc2 }, { 0x79,0x78,0xf4,0x8e }, + { 0x3e,0x6b,0x99,0x58 }, { 0x71,0xdd,0x27,0xb9 }, { 0x4f,0xb6,0xbe,0xe1 }, { 0xad,0x17,0xf0,0x88 }, - { 0xac,0x66,0xc9,0x20 }, { 0x3a,0xb4,0x7d,0xce }, + { 0xac,0x66,0xc9,0x20 }, { 0x3a,0xb4,0x7d,0xce }, { 0x4a,0x18,0x63,0xdf }, { 0x31,0x82,0xe5,0x1a }, - { 0x33,0x60,0x97,0x51 }, { 0x7f,0x45,0x62,0x53 }, + { 0x33,0x60,0x97,0x51 }, { 0x7f,0x45,0x62,0x53 }, { 0x77,0xe0,0xb1,0x64 }, { 0xae,0x84,0xbb,0x6b }, - { 0xa0,0x1c,0xfe,0x81 }, { 0x2b,0x94,0xf9,0x08 }, + { 0xa0,0x1c,0xfe,0x81 }, { 0x2b,0x94,0xf9,0x08 }, { 0x68,0x58,0x70,0x48 }, { 0xfd,0x19,0x8f,0x45 }, - { 0x6c,0x87,0x94,0xde }, { 0xf8,0xb7,0x52,0x7b }, + { 0x6c,0x87,0x94,0xde }, { 0xf8,0xb7,0x52,0x7b }, { 0xd3,0x23,0xab,0x73 }, { 0x02,0xe2,0x72,0x4b }, - { 0x8f,0x57,0xe3,0x1f }, { 0xab,0x2a,0x66,0x55 }, + { 0x8f,0x57,0xe3,0x1f }, { 0xab,0x2a,0x66,0x55 }, { 0x28,0x07,0xb2,0xeb }, { 0xc2,0x03,0x2f,0xb5 }, - { 0x7b,0x9a,0x86,0xc5 }, { 0x08,0xa5,0xd3,0x37 }, + { 0x7b,0x9a,0x86,0xc5 }, { 0x08,0xa5,0xd3,0x37 }, { 0x87,0xf2,0x30,0x28 }, { 0xa5,0xb2,0x23,0xbf }, - { 0x6a,0xba,0x02,0x03 }, { 0x82,0x5c,0xed,0x16 }, - { 0x1c,0x2b,0x8a,0xcf }, { 0xb4,0x92,0xa7,0x79 }, - { 0xf2,0xf0,0xf3,0x07 }, { 0xe2,0xa1,0x4e,0x69 }, + { 0x6a,0xba,0x02,0x03 }, { 0x82,0x5c,0xed,0x16 }, + { 0x1c,0x2b,0x8a,0xcf }, { 0xb4,0x92,0xa7,0x79 }, + { 0xf2,0xf0,0xf3,0x07 }, { 0xe2,0xa1,0x4e,0x69 }, { 0xf4,0xcd,0x65,0xda }, { 0xbe,0xd5,0x06,0x05 }, - { 0x62,0x1f,0xd1,0x34 }, { 0xfe,0x8a,0xc4,0xa6 }, + { 0x62,0x1f,0xd1,0x34 }, { 0xfe,0x8a,0xc4,0xa6 }, { 0x53,0x9d,0x34,0x2e }, { 0x55,0xa0,0xa2,0xf3 }, - { 0xe1,0x32,0x05,0x8a }, { 0xeb,0x75,0xa4,0xf6 }, + { 0xe1,0x32,0x05,0x8a }, { 0xeb,0x75,0xa4,0xf6 }, { 0xec,0x39,0x0b,0x83 }, { 0xef,0xaa,0x40,0x60 }, - { 0x9f,0x06,0x5e,0x71 }, { 0x10,0x51,0xbd,0x6e }, + { 0x9f,0x06,0x5e,0x71 }, { 0x10,0x51,0xbd,0x6e }, { 0x8a,0xf9,0x3e,0x21 }, { 0x06,0x3d,0x96,0xdd }, - { 0x05,0xae,0xdd,0x3e }, { 0xbd,0x46,0x4d,0xe6 }, + { 0x05,0xae,0xdd,0x3e }, { 0xbd,0x46,0x4d,0xe6 }, { 0x8d,0xb5,0x91,0x54 }, { 0x5d,0x05,0x71,0xc4 }, - { 0xd4,0x6f,0x04,0x06 }, { 0x15,0xff,0x60,0x50 }, - { 0xfb,0x24,0x19,0x98 }, { 0xe9,0x97,0xd6,0xbd }, - { 0x43,0xcc,0x89,0x40 }, { 0x9e,0x77,0x67,0xd9 }, + { 0xd4,0x6f,0x04,0x06 }, { 0x15,0xff,0x60,0x50 }, + { 0xfb,0x24,0x19,0x98 }, { 0xe9,0x97,0xd6,0xbd }, + { 0x43,0xcc,0x89,0x40 }, { 0x9e,0x77,0x67,0xd9 }, { 0x42,0xbd,0xb0,0xe8 }, { 0x8b,0x88,0x07,0x89 }, - { 0x5b,0x38,0xe7,0x19 }, { 0xee,0xdb,0x79,0xc8 }, + { 0x5b,0x38,0xe7,0x19 }, { 0xee,0xdb,0x79,0xc8 }, { 0x0a,0x47,0xa1,0x7c }, { 0x0f,0xe9,0x7c,0x42 }, - { 0x1e,0xc9,0xf8,0x84 }, { 0x00,0x00,0x00,0x00 }, + { 0x1e,0xc9,0xf8,0x84 }, { 0x00,0x00,0x00,0x00 }, { 0x86,0x83,0x09,0x80 }, { 0xed,0x48,0x32,0x2b }, - { 0x70,0xac,0x1e,0x11 }, { 0x72,0x4e,0x6c,0x5a }, + { 0x70,0xac,0x1e,0x11 }, { 0x72,0x4e,0x6c,0x5a }, { 0xff,0xfb,0xfd,0x0e }, { 0x38,0x56,0x0f,0x85 }, - { 0xd5,0x1e,0x3d,0xae }, { 0x39,0x27,0x36,0x2d }, + { 0xd5,0x1e,0x3d,0xae }, { 0x39,0x27,0x36,0x2d }, { 0xd9,0x64,0x0a,0x0f }, { 0xa6,0x21,0x68,0x5c }, - { 0x54,0xd1,0x9b,0x5b }, { 0x2e,0x3a,0x24,0x36 }, + { 0x54,0xd1,0x9b,0x5b }, { 0x2e,0x3a,0x24,0x36 }, { 0x67,0xb1,0x0c,0x0a }, { 0xe7,0x0f,0x93,0x57 }, - { 0x96,0xd2,0xb4,0xee }, { 0x91,0x9e,0x1b,0x9b }, + { 0x96,0xd2,0xb4,0xee }, { 0x91,0x9e,0x1b,0x9b }, { 0xc5,0x4f,0x80,0xc0 }, { 0x20,0xa2,0x61,0xdc }, - { 0x4b,0x69,0x5a,0x77 }, { 0x1a,0x16,0x1c,0x12 }, + { 0x4b,0x69,0x5a,0x77 }, { 0x1a,0x16,0x1c,0x12 }, { 0xba,0x0a,0xe2,0x93 }, { 0x2a,0xe5,0xc0,0xa0 }, - { 0xe0,0x43,0x3c,0x22 }, { 0x17,0x1d,0x12,0x1b }, + { 0xe0,0x43,0x3c,0x22 }, { 0x17,0x1d,0x12,0x1b }, { 0x0d,0x0b,0x0e,0x09 }, { 0xc7,0xad,0xf2,0x8b }, - { 0xa8,0xb9,0x2d,0xb6 }, { 0xa9,0xc8,0x14,0x1e }, + { 0xa8,0xb9,0x2d,0xb6 }, { 0xa9,0xc8,0x14,0x1e }, { 0x19,0x85,0x57,0xf1 }, { 0x07,0x4c,0xaf,0x75 }, - { 0xdd,0xbb,0xee,0x99 }, { 0x60,0xfd,0xa3,0x7f }, + { 0xdd,0xbb,0xee,0x99 }, { 0x60,0xfd,0xa3,0x7f }, { 0x26,0x9f,0xf7,0x01 }, { 0xf5,0xbc,0x5c,0x72 }, - { 0x3b,0xc5,0x44,0x66 }, { 0x7e,0x34,0x5b,0xfb }, + { 0x3b,0xc5,0x44,0x66 }, { 0x7e,0x34,0x5b,0xfb }, { 0x29,0x76,0x8b,0x43 }, { 0xc6,0xdc,0xcb,0x23 }, - { 0xfc,0x68,0xb6,0xed }, { 0xf1,0x63,0xb8,0xe4 }, + { 0xfc,0x68,0xb6,0xed }, { 0xf1,0x63,0xb8,0xe4 }, { 0xdc,0xca,0xd7,0x31 }, { 0x85,0x10,0x42,0x63 }, - { 0x22,0x40,0x13,0x97 }, { 0x11,0x20,0x84,0xc6 }, + { 0x22,0x40,0x13,0x97 }, { 0x11,0x20,0x84,0xc6 }, { 0x24,0x7d,0x85,0x4a }, { 0x3d,0xf8,0xd2,0xbb }, - { 0x32,0x11,0xae,0xf9 }, { 0xa1,0x6d,0xc7,0x29 }, + { 0x32,0x11,0xae,0xf9 }, { 0xa1,0x6d,0xc7,0x29 }, { 0x2f,0x4b,0x1d,0x9e }, { 0x30,0xf3,0xdc,0xb2 }, - { 0x52,0xec,0x0d,0x86 }, { 0xe3,0xd0,0x77,0xc1 }, + { 0x52,0xec,0x0d,0x86 }, { 0xe3,0xd0,0x77,0xc1 }, { 0x16,0x6c,0x2b,0xb3 }, { 0xb9,0x99,0xa9,0x70 }, - { 0x48,0xfa,0x11,0x94 }, { 0x64,0x22,0x47,0xe9 }, + { 0x48,0xfa,0x11,0x94 }, { 0x64,0x22,0x47,0xe9 }, { 0x8c,0xc4,0xa8,0xfc }, { 0x3f,0x1a,0xa0,0xf0 }, - { 0x2c,0xd8,0x56,0x7d }, { 0x90,0xef,0x22,0x33 }, + { 0x2c,0xd8,0x56,0x7d }, { 0x90,0xef,0x22,0x33 }, { 0x4e,0xc7,0x87,0x49 }, { 0xd1,0xc1,0xd9,0x38 }, - { 0xa2,0xfe,0x8c,0xca }, { 0x0b,0x36,0x98,0xd4 }, + { 0xa2,0xfe,0x8c,0xca }, { 0x0b,0x36,0x98,0xd4 }, { 0x81,0xcf,0xa6,0xf5 }, { 0xde,0x28,0xa5,0x7a }, - { 0x8e,0x26,0xda,0xb7 }, { 0xbf,0xa4,0x3f,0xad }, + { 0x8e,0x26,0xda,0xb7 }, { 0xbf,0xa4,0x3f,0xad }, { 0x9d,0xe4,0x2c,0x3a }, { 0x92,0x0d,0x50,0x78 }, - { 0xcc,0x9b,0x6a,0x5f }, { 0x46,0x62,0x54,0x7e }, + { 0xcc,0x9b,0x6a,0x5f }, { 0x46,0x62,0x54,0x7e }, { 0x13,0xc2,0xf6,0x8d }, { 0xb8,0xe8,0x90,0xd8 }, - { 0xf7,0x5e,0x2e,0x39 }, { 0xaf,0xf5,0x82,0xc3 }, + { 0xf7,0x5e,0x2e,0x39 }, { 0xaf,0xf5,0x82,0xc3 }, { 0x80,0xbe,0x9f,0x5d }, { 0x93,0x7c,0x69,0xd0 }, - { 0x2d,0xa9,0x6f,0xd5 }, { 0x12,0xb3,0xcf,0x25 }, + { 0x2d,0xa9,0x6f,0xd5 }, { 0x12,0xb3,0xcf,0x25 }, { 0x99,0x3b,0xc8,0xac }, { 0x7d,0xa7,0x10,0x18 }, - { 0x63,0x6e,0xe8,0x9c }, { 0xbb,0x7b,0xdb,0x3b }, - { 0x78,0x09,0xcd,0x26 }, { 0x18,0xf4,0x6e,0x59 }, - { 0xb7,0x01,0xec,0x9a }, { 0x9a,0xa8,0x83,0x4f }, + { 0x63,0x6e,0xe8,0x9c }, { 0xbb,0x7b,0xdb,0x3b }, + { 0x78,0x09,0xcd,0x26 }, { 0x18,0xf4,0x6e,0x59 }, + { 0xb7,0x01,0xec,0x9a }, { 0x9a,0xa8,0x83,0x4f }, { 0x6e,0x65,0xe6,0x95 }, { 0xe6,0x7e,0xaa,0xff }, - { 0xcf,0x08,0x21,0xbc }, { 0xe8,0xe6,0xef,0x15 }, + { 0xcf,0x08,0x21,0xbc }, { 0xe8,0xe6,0xef,0x15 }, { 0x9b,0xd9,0xba,0xe7 }, { 0x36,0xce,0x4a,0x6f }, - { 0x09,0xd4,0xea,0x9f }, { 0x7c,0xd6,0x29,0xb0 }, + { 0x09,0xd4,0xea,0x9f }, { 0x7c,0xd6,0x29,0xb0 }, { 0xb2,0xaf,0x31,0xa4 }, { 0x23,0x31,0x2a,0x3f }, - { 0x94,0x30,0xc6,0xa5 }, { 0x66,0xc0,0x35,0xa2 }, + { 0x94,0x30,0xc6,0xa5 }, { 0x66,0xc0,0x35,0xa2 }, { 0xbc,0x37,0x74,0x4e }, { 0xca,0xa6,0xfc,0x82 }, - { 0xd0,0xb0,0xe0,0x90 }, { 0xd8,0x15,0x33,0xa7 }, + { 0xd0,0xb0,0xe0,0x90 }, { 0xd8,0x15,0x33,0xa7 }, { 0x98,0x4a,0xf1,0x04 }, { 0xda,0xf7,0x41,0xec }, - { 0x50,0x0e,0x7f,0xcd }, { 0xf6,0x2f,0x17,0x91 }, - { 0xd6,0x8d,0x76,0x4d }, { 0xb0,0x4d,0x43,0xef }, - { 0x4d,0x54,0xcc,0xaa }, { 0x04,0xdf,0xe4,0x96 }, + { 0x50,0x0e,0x7f,0xcd }, { 0xf6,0x2f,0x17,0x91 }, + { 0xd6,0x8d,0x76,0x4d }, { 0xb0,0x4d,0x43,0xef }, + { 0x4d,0x54,0xcc,0xaa }, { 0x04,0xdf,0xe4,0x96 }, { 0xb5,0xe3,0x9e,0xd1 }, { 0x88,0x1b,0x4c,0x6a }, - { 0x1f,0xb8,0xc1,0x2c }, { 0x51,0x7f,0x46,0x65 }, + { 0x1f,0xb8,0xc1,0x2c }, { 0x51,0x7f,0x46,0x65 }, { 0xea,0x04,0x9d,0x5e }, { 0x35,0x5d,0x01,0x8c }, - { 0x74,0x73,0xfa,0x87 }, { 0x41,0x2e,0xfb,0x0b }, + { 0x74,0x73,0xfa,0x87 }, { 0x41,0x2e,0xfb,0x0b }, { 0x1d,0x5a,0xb3,0x67 }, { 0xd2,0x52,0x92,0xdb }, - { 0x56,0x33,0xe9,0x10 }, { 0x47,0x13,0x6d,0xd6 }, + { 0x56,0x33,0xe9,0x10 }, { 0x47,0x13,0x6d,0xd6 }, { 0x61,0x8c,0x9a,0xd7 }, { 0x0c,0x7a,0x37,0xa1 }, - { 0x14,0x8e,0x59,0xf8 }, { 0x3c,0x89,0xeb,0x13 }, + { 0x14,0x8e,0x59,0xf8 }, { 0x3c,0x89,0xeb,0x13 }, { 0x27,0xee,0xce,0xa9 }, { 0xc9,0x35,0xb7,0x61 }, - { 0xe5,0xed,0xe1,0x1c }, { 0xb1,0x3c,0x7a,0x47 }, + { 0xe5,0xed,0xe1,0x1c }, { 0xb1,0x3c,0x7a,0x47 }, { 0xdf,0x59,0x9c,0xd2 }, { 0x73,0x3f,0x55,0xf2 }, - { 0xce,0x79,0x18,0x14 }, { 0x37,0xbf,0x73,0xc7 }, + { 0xce,0x79,0x18,0x14 }, { 0x37,0xbf,0x73,0xc7 }, { 0xcd,0xea,0x53,0xf7 }, { 0xaa,0x5b,0x5f,0xfd }, - { 0x6f,0x14,0xdf,0x3d }, { 0xdb,0x86,0x78,0x44 }, + { 0x6f,0x14,0xdf,0x3d }, { 0xdb,0x86,0x78,0x44 }, { 0xf3,0x81,0xca,0xaf }, { 0xc4,0x3e,0xb9,0x68 }, - { 0x34,0x2c,0x38,0x24 }, { 0x40,0x5f,0xc2,0xa3 }, + { 0x34,0x2c,0x38,0x24 }, { 0x40,0x5f,0xc2,0xa3 }, { 0xc3,0x72,0x16,0x1d }, { 0x25,0x0c,0xbc,0xe2 }, - { 0x49,0x8b,0x28,0x3c }, { 0x95,0x41,0xff,0x0d }, + { 0x49,0x8b,0x28,0x3c }, { 0x95,0x41,0xff,0x0d }, { 0x01,0x71,0x39,0xa8 }, { 0xb3,0xde,0x08,0x0c }, - { 0xe4,0x9c,0xd8,0xb4 }, { 0xc1,0x90,0x64,0x56 }, + { 0xe4,0x9c,0xd8,0xb4 }, { 0xc1,0x90,0x64,0x56 }, { 0x84,0x61,0x7b,0xcb }, { 0xb6,0x70,0xd5,0x32 }, { 0x5c,0x74,0x48,0x6c }, { 0x57,0x42,0xd0,0xb8 } }; -static const unsigned char T8[256][4] = +static const unsigned char T8[256][4] = { { 0xf4,0xa7,0x50,0x51 }, { 0x41,0x65,0x53,0x7e }, - { 0x17,0xa4,0xc3,0x1a }, { 0x27,0x5e,0x96,0x3a }, + { 0x17,0xa4,0xc3,0x1a }, { 0x27,0x5e,0x96,0x3a }, { 0xab,0x6b,0xcb,0x3b }, { 0x9d,0x45,0xf1,0x1f }, - { 0xfa,0x58,0xab,0xac }, { 0xe3,0x03,0x93,0x4b }, + { 0xfa,0x58,0xab,0xac }, { 0xe3,0x03,0x93,0x4b }, { 0x30,0xfa,0x55,0x20 }, { 0x76,0x6d,0xf6,0xad }, - { 0xcc,0x76,0x91,0x88 }, { 0x02,0x4c,0x25,0xf5 }, + { 0xcc,0x76,0x91,0x88 }, { 0x02,0x4c,0x25,0xf5 }, { 0xe5,0xd7,0xfc,0x4f }, { 0x2a,0xcb,0xd7,0xc5 }, - { 0x35,0x44,0x80,0x26 }, { 0x62,0xa3,0x8f,0xb5 }, + { 0x35,0x44,0x80,0x26 }, { 0x62,0xa3,0x8f,0xb5 }, { 0xb1,0x5a,0x49,0xde }, { 0xba,0x1b,0x67,0x25 }, - { 0xea,0x0e,0x98,0x45 }, { 0xfe,0xc0,0xe1,0x5d }, + { 0xea,0x0e,0x98,0x45 }, { 0xfe,0xc0,0xe1,0x5d }, { 0x2f,0x75,0x02,0xc3 }, { 0x4c,0xf0,0x12,0x81 }, - { 0x46,0x97,0xa3,0x8d }, { 0xd3,0xf9,0xc6,0x6b }, + { 0x46,0x97,0xa3,0x8d }, { 0xd3,0xf9,0xc6,0x6b }, { 0x8f,0x5f,0xe7,0x03 }, { 0x92,0x9c,0x95,0x15 }, - { 0x6d,0x7a,0xeb,0xbf }, { 0x52,0x59,0xda,0x95 }, + { 0x6d,0x7a,0xeb,0xbf }, { 0x52,0x59,0xda,0x95 }, { 0xbe,0x83,0x2d,0xd4 }, { 0x74,0x21,0xd3,0x58 }, - { 0xe0,0x69,0x29,0x49 }, { 0xc9,0xc8,0x44,0x8e }, + { 0xe0,0x69,0x29,0x49 }, { 0xc9,0xc8,0x44,0x8e }, { 0xc2,0x89,0x6a,0x75 }, { 0x8e,0x79,0x78,0xf4 }, - { 0x58,0x3e,0x6b,0x99 }, { 0xb9,0x71,0xdd,0x27 }, + { 0x58,0x3e,0x6b,0x99 }, { 0xb9,0x71,0xdd,0x27 }, { 0xe1,0x4f,0xb6,0xbe }, { 0x88,0xad,0x17,0xf0 }, - { 0x20,0xac,0x66,0xc9 }, { 0xce,0x3a,0xb4,0x7d }, + { 0x20,0xac,0x66,0xc9 }, { 0xce,0x3a,0xb4,0x7d }, { 0xdf,0x4a,0x18,0x63 }, { 0x1a,0x31,0x82,0xe5 }, - { 0x51,0x33,0x60,0x97 }, { 0x53,0x7f,0x45,0x62 }, + { 0x51,0x33,0x60,0x97 }, { 0x53,0x7f,0x45,0x62 }, { 0x64,0x77,0xe0,0xb1 }, { 0x6b,0xae,0x84,0xbb }, - { 0x81,0xa0,0x1c,0xfe }, { 0x08,0x2b,0x94,0xf9 }, + { 0x81,0xa0,0x1c,0xfe }, { 0x08,0x2b,0x94,0xf9 }, { 0x48,0x68,0x58,0x70 }, { 0x45,0xfd,0x19,0x8f }, - { 0xde,0x6c,0x87,0x94 }, { 0x7b,0xf8,0xb7,0x52 }, + { 0xde,0x6c,0x87,0x94 }, { 0x7b,0xf8,0xb7,0x52 }, { 0x73,0xd3,0x23,0xab }, { 0x4b,0x02,0xe2,0x72 }, - { 0x1f,0x8f,0x57,0xe3 }, { 0x55,0xab,0x2a,0x66 }, + { 0x1f,0x8f,0x57,0xe3 }, { 0x55,0xab,0x2a,0x66 }, { 0xeb,0x28,0x07,0xb2 }, { 0xb5,0xc2,0x03,0x2f }, - { 0xc5,0x7b,0x9a,0x86 }, { 0x37,0x08,0xa5,0xd3 }, + { 0xc5,0x7b,0x9a,0x86 }, { 0x37,0x08,0xa5,0xd3 }, { 0x28,0x87,0xf2,0x30 }, { 0xbf,0xa5,0xb2,0x23 }, - { 0x03,0x6a,0xba,0x02 }, { 0x16,0x82,0x5c,0xed }, + { 0x03,0x6a,0xba,0x02 }, { 0x16,0x82,0x5c,0xed }, { 0xcf,0x1c,0x2b,0x8a }, { 0x79,0xb4,0x92,0xa7 }, - { 0x07,0xf2,0xf0,0xf3 }, { 0x69,0xe2,0xa1,0x4e }, + { 0x07,0xf2,0xf0,0xf3 }, { 0x69,0xe2,0xa1,0x4e }, { 0xda,0xf4,0xcd,0x65 }, { 0x05,0xbe,0xd5,0x06 }, - { 0x34,0x62,0x1f,0xd1 }, { 0xa6,0xfe,0x8a,0xc4 }, + { 0x34,0x62,0x1f,0xd1 }, { 0xa6,0xfe,0x8a,0xc4 }, { 0x2e,0x53,0x9d,0x34 }, { 0xf3,0x55,0xa0,0xa2 }, - { 0x8a,0xe1,0x32,0x05 }, { 0xf6,0xeb,0x75,0xa4 }, + { 0x8a,0xe1,0x32,0x05 }, { 0xf6,0xeb,0x75,0xa4 }, { 0x83,0xec,0x39,0x0b }, { 0x60,0xef,0xaa,0x40 }, - { 0x71,0x9f,0x06,0x5e }, { 0x6e,0x10,0x51,0xbd }, + { 0x71,0x9f,0x06,0x5e }, { 0x6e,0x10,0x51,0xbd }, { 0x21,0x8a,0xf9,0x3e }, { 0xdd,0x06,0x3d,0x96 }, - { 0x3e,0x05,0xae,0xdd }, { 0xe6,0xbd,0x46,0x4d }, + { 0x3e,0x05,0xae,0xdd }, { 0xe6,0xbd,0x46,0x4d }, { 0x54,0x8d,0xb5,0x91 }, { 0xc4,0x5d,0x05,0x71 }, - { 0x06,0xd4,0x6f,0x04 }, { 0x50,0x15,0xff,0x60 }, + { 0x06,0xd4,0x6f,0x04 }, { 0x50,0x15,0xff,0x60 }, { 0x98,0xfb,0x24,0x19 }, { 0xbd,0xe9,0x97,0xd6 }, - { 0x40,0x43,0xcc,0x89 }, { 0xd9,0x9e,0x77,0x67 }, + { 0x40,0x43,0xcc,0x89 }, { 0xd9,0x9e,0x77,0x67 }, { 0xe8,0x42,0xbd,0xb0 }, { 0x89,0x8b,0x88,0x07 }, - { 0x19,0x5b,0x38,0xe7 }, { 0xc8,0xee,0xdb,0x79 }, + { 0x19,0x5b,0x38,0xe7 }, { 0xc8,0xee,0xdb,0x79 }, { 0x7c,0x0a,0x47,0xa1 }, { 0x42,0x0f,0xe9,0x7c }, - { 0x84,0x1e,0xc9,0xf8 }, { 0x00,0x00,0x00,0x00 }, + { 0x84,0x1e,0xc9,0xf8 }, { 0x00,0x00,0x00,0x00 }, { 0x80,0x86,0x83,0x09 }, { 0x2b,0xed,0x48,0x32 }, - { 0x11,0x70,0xac,0x1e }, { 0x5a,0x72,0x4e,0x6c }, - { 0x0e,0xff,0xfb,0xfd }, { 0x85,0x38,0x56,0x0f }, - { 0xae,0xd5,0x1e,0x3d }, { 0x2d,0x39,0x27,0x36 }, + { 0x11,0x70,0xac,0x1e }, { 0x5a,0x72,0x4e,0x6c }, + { 0x0e,0xff,0xfb,0xfd }, { 0x85,0x38,0x56,0x0f }, + { 0xae,0xd5,0x1e,0x3d }, { 0x2d,0x39,0x27,0x36 }, { 0x0f,0xd9,0x64,0x0a }, { 0x5c,0xa6,0x21,0x68 }, - { 0x5b,0x54,0xd1,0x9b }, { 0x36,0x2e,0x3a,0x24 }, + { 0x5b,0x54,0xd1,0x9b }, { 0x36,0x2e,0x3a,0x24 }, { 0x0a,0x67,0xb1,0x0c }, { 0x57,0xe7,0x0f,0x93 }, - { 0xee,0x96,0xd2,0xb4 }, { 0x9b,0x91,0x9e,0x1b }, + { 0xee,0x96,0xd2,0xb4 }, { 0x9b,0x91,0x9e,0x1b }, { 0xc0,0xc5,0x4f,0x80 }, { 0xdc,0x20,0xa2,0x61 }, - { 0x77,0x4b,0x69,0x5a }, { 0x12,0x1a,0x16,0x1c }, + { 0x77,0x4b,0x69,0x5a }, { 0x12,0x1a,0x16,0x1c }, { 0x93,0xba,0x0a,0xe2 }, { 0xa0,0x2a,0xe5,0xc0 }, - { 0x22,0xe0,0x43,0x3c }, { 0x1b,0x17,0x1d,0x12 }, + { 0x22,0xe0,0x43,0x3c }, { 0x1b,0x17,0x1d,0x12 }, { 0x09,0x0d,0x0b,0x0e }, { 0x8b,0xc7,0xad,0xf2 }, - { 0xb6,0xa8,0xb9,0x2d }, { 0x1e,0xa9,0xc8,0x14 }, + { 0xb6,0xa8,0xb9,0x2d }, { 0x1e,0xa9,0xc8,0x14 }, { 0xf1,0x19,0x85,0x57 }, { 0x75,0x07,0x4c,0xaf }, - { 0x99,0xdd,0xbb,0xee }, { 0x7f,0x60,0xfd,0xa3 }, + { 0x99,0xdd,0xbb,0xee }, { 0x7f,0x60,0xfd,0xa3 }, { 0x01,0x26,0x9f,0xf7 }, { 0x72,0xf5,0xbc,0x5c }, - { 0x66,0x3b,0xc5,0x44 }, { 0xfb,0x7e,0x34,0x5b }, + { 0x66,0x3b,0xc5,0x44 }, { 0xfb,0x7e,0x34,0x5b }, { 0x43,0x29,0x76,0x8b }, { 0x23,0xc6,0xdc,0xcb }, - { 0xed,0xfc,0x68,0xb6 }, { 0xe4,0xf1,0x63,0xb8 }, + { 0xed,0xfc,0x68,0xb6 }, { 0xe4,0xf1,0x63,0xb8 }, { 0x31,0xdc,0xca,0xd7 }, { 0x63,0x85,0x10,0x42 }, - { 0x97,0x22,0x40,0x13 }, { 0xc6,0x11,0x20,0x84 }, - { 0x4a,0x24,0x7d,0x85 }, { 0xbb,0x3d,0xf8,0xd2 }, - { 0xf9,0x32,0x11,0xae }, { 0x29,0xa1,0x6d,0xc7 }, + { 0x97,0x22,0x40,0x13 }, { 0xc6,0x11,0x20,0x84 }, + { 0x4a,0x24,0x7d,0x85 }, { 0xbb,0x3d,0xf8,0xd2 }, + { 0xf9,0x32,0x11,0xae }, { 0x29,0xa1,0x6d,0xc7 }, { 0x9e,0x2f,0x4b,0x1d }, { 0xb2,0x30,0xf3,0xdc }, - { 0x86,0x52,0xec,0x0d }, { 0xc1,0xe3,0xd0,0x77 }, + { 0x86,0x52,0xec,0x0d }, { 0xc1,0xe3,0xd0,0x77 }, { 0xb3,0x16,0x6c,0x2b }, { 0x70,0xb9,0x99,0xa9 }, - { 0x94,0x48,0xfa,0x11 }, { 0xe9,0x64,0x22,0x47 }, + { 0x94,0x48,0xfa,0x11 }, { 0xe9,0x64,0x22,0x47 }, { 0xfc,0x8c,0xc4,0xa8 }, { 0xf0,0x3f,0x1a,0xa0 }, - { 0x7d,0x2c,0xd8,0x56 }, { 0x33,0x90,0xef,0x22 }, + { 0x7d,0x2c,0xd8,0x56 }, { 0x33,0x90,0xef,0x22 }, { 0x49,0x4e,0xc7,0x87 }, { 0x38,0xd1,0xc1,0xd9 }, - { 0xca,0xa2,0xfe,0x8c }, { 0xd4,0x0b,0x36,0x98 }, + { 0xca,0xa2,0xfe,0x8c }, { 0xd4,0x0b,0x36,0x98 }, { 0xf5,0x81,0xcf,0xa6 }, { 0x7a,0xde,0x28,0xa5 }, - { 0xb7,0x8e,0x26,0xda }, { 0xad,0xbf,0xa4,0x3f }, + { 0xb7,0x8e,0x26,0xda }, { 0xad,0xbf,0xa4,0x3f }, { 0x3a,0x9d,0xe4,0x2c }, { 0x78,0x92,0x0d,0x50 }, - { 0x5f,0xcc,0x9b,0x6a }, { 0x7e,0x46,0x62,0x54 }, + { 0x5f,0xcc,0x9b,0x6a }, { 0x7e,0x46,0x62,0x54 }, { 0x8d,0x13,0xc2,0xf6 }, { 0xd8,0xb8,0xe8,0x90 }, - { 0x39,0xf7,0x5e,0x2e }, { 0xc3,0xaf,0xf5,0x82 }, + { 0x39,0xf7,0x5e,0x2e }, { 0xc3,0xaf,0xf5,0x82 }, { 0x5d,0x80,0xbe,0x9f }, { 0xd0,0x93,0x7c,0x69 }, - { 0xd5,0x2d,0xa9,0x6f }, { 0x25,0x12,0xb3,0xcf }, + { 0xd5,0x2d,0xa9,0x6f }, { 0x25,0x12,0xb3,0xcf }, { 0xac,0x99,0x3b,0xc8 }, { 0x18,0x7d,0xa7,0x10 }, - { 0x9c,0x63,0x6e,0xe8 }, { 0x3b,0xbb,0x7b,0xdb }, + { 0x9c,0x63,0x6e,0xe8 }, { 0x3b,0xbb,0x7b,0xdb }, { 0x26,0x78,0x09,0xcd }, { 0x59,0x18,0xf4,0x6e }, - { 0x9a,0xb7,0x01,0xec }, { 0x4f,0x9a,0xa8,0x83 }, + { 0x9a,0xb7,0x01,0xec }, { 0x4f,0x9a,0xa8,0x83 }, { 0x95,0x6e,0x65,0xe6 }, { 0xff,0xe6,0x7e,0xaa }, - { 0xbc,0xcf,0x08,0x21 }, { 0x15,0xe8,0xe6,0xef }, + { 0xbc,0xcf,0x08,0x21 }, { 0x15,0xe8,0xe6,0xef }, { 0xe7,0x9b,0xd9,0xba }, { 0x6f,0x36,0xce,0x4a }, - { 0x9f,0x09,0xd4,0xea }, { 0xb0,0x7c,0xd6,0x29 }, + { 0x9f,0x09,0xd4,0xea }, { 0xb0,0x7c,0xd6,0x29 }, { 0xa4,0xb2,0xaf,0x31 }, { 0x3f,0x23,0x31,0x2a }, - { 0xa5,0x94,0x30,0xc6 }, { 0xa2,0x66,0xc0,0x35 }, + { 0xa5,0x94,0x30,0xc6 }, { 0xa2,0x66,0xc0,0x35 }, { 0x4e,0xbc,0x37,0x74 }, { 0x82,0xca,0xa6,0xfc }, - { 0x90,0xd0,0xb0,0xe0 }, { 0xa7,0xd8,0x15,0x33 }, + { 0x90,0xd0,0xb0,0xe0 }, { 0xa7,0xd8,0x15,0x33 }, { 0x04,0x98,0x4a,0xf1 }, { 0xec,0xda,0xf7,0x41 }, - { 0xcd,0x50,0x0e,0x7f }, { 0x91,0xf6,0x2f,0x17 }, - { 0x4d,0xd6,0x8d,0x76 }, { 0xef,0xb0,0x4d,0x43 }, - { 0xaa,0x4d,0x54,0xcc }, { 0x96,0x04,0xdf,0xe4 }, + { 0xcd,0x50,0x0e,0x7f }, { 0x91,0xf6,0x2f,0x17 }, + { 0x4d,0xd6,0x8d,0x76 }, { 0xef,0xb0,0x4d,0x43 }, + { 0xaa,0x4d,0x54,0xcc }, { 0x96,0x04,0xdf,0xe4 }, { 0xd1,0xb5,0xe3,0x9e }, { 0x6a,0x88,0x1b,0x4c }, - { 0x2c,0x1f,0xb8,0xc1 }, { 0x65,0x51,0x7f,0x46 }, + { 0x2c,0x1f,0xb8,0xc1 }, { 0x65,0x51,0x7f,0x46 }, { 0x5e,0xea,0x04,0x9d }, { 0x8c,0x35,0x5d,0x01 }, - { 0x87,0x74,0x73,0xfa }, { 0x0b,0x41,0x2e,0xfb }, + { 0x87,0x74,0x73,0xfa }, { 0x0b,0x41,0x2e,0xfb }, { 0x67,0x1d,0x5a,0xb3 }, { 0xdb,0xd2,0x52,0x92 }, - { 0x10,0x56,0x33,0xe9 }, { 0xd6,0x47,0x13,0x6d }, + { 0x10,0x56,0x33,0xe9 }, { 0xd6,0x47,0x13,0x6d }, { 0xd7,0x61,0x8c,0x9a }, { 0xa1,0x0c,0x7a,0x37 }, - { 0xf8,0x14,0x8e,0x59 }, { 0x13,0x3c,0x89,0xeb }, + { 0xf8,0x14,0x8e,0x59 }, { 0x13,0x3c,0x89,0xeb }, { 0xa9,0x27,0xee,0xce }, { 0x61,0xc9,0x35,0xb7 }, - { 0x1c,0xe5,0xed,0xe1 }, { 0x47,0xb1,0x3c,0x7a }, + { 0x1c,0xe5,0xed,0xe1 }, { 0x47,0xb1,0x3c,0x7a }, { 0xd2,0xdf,0x59,0x9c }, { 0xf2,0x73,0x3f,0x55 }, - { 0x14,0xce,0x79,0x18 }, { 0xc7,0x37,0xbf,0x73 }, + { 0x14,0xce,0x79,0x18 }, { 0xc7,0x37,0xbf,0x73 }, { 0xf7,0xcd,0xea,0x53 }, { 0xfd,0xaa,0x5b,0x5f }, - { 0x3d,0x6f,0x14,0xdf }, { 0x44,0xdb,0x86,0x78 }, + { 0x3d,0x6f,0x14,0xdf }, { 0x44,0xdb,0x86,0x78 }, { 0xaf,0xf3,0x81,0xca }, { 0x68,0xc4,0x3e,0xb9 }, - { 0x24,0x34,0x2c,0x38 }, { 0xa3,0x40,0x5f,0xc2 }, + { 0x24,0x34,0x2c,0x38 }, { 0xa3,0x40,0x5f,0xc2 }, { 0x1d,0xc3,0x72,0x16 }, { 0xe2,0x25,0x0c,0xbc }, - { 0x3c,0x49,0x8b,0x28 }, { 0x0d,0x95,0x41,0xff }, + { 0x3c,0x49,0x8b,0x28 }, { 0x0d,0x95,0x41,0xff }, { 0xa8,0x01,0x71,0x39 }, { 0x0c,0xb3,0xde,0x08 }, - { 0xb4,0xe4,0x9c,0xd8 }, { 0x56,0xc1,0x90,0x64 }, + { 0xb4,0xe4,0x9c,0xd8 }, { 0x56,0xc1,0x90,0x64 }, { 0xcb,0x84,0x61,0x7b }, { 0x32,0xb6,0x70,0xd5 }, { 0x6c,0x5c,0x74,0x48 }, { 0xb8,0x57,0x42,0xd0 } }; -static const unsigned char S5[256] = +static const unsigned char S5[256] = { 0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38, 0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb, @@ -1150,398 +1150,398 @@ static const unsigned char S5[256] = 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d }; -static const unsigned char U1[256][4] = +static const unsigned char U1[256][4] = { { 0x00,0x00,0x00,0x00 }, { 0x0e,0x09,0x0d,0x0b }, - { 0x1c,0x12,0x1a,0x16 }, { 0x12,0x1b,0x17,0x1d }, + { 0x1c,0x12,0x1a,0x16 }, { 0x12,0x1b,0x17,0x1d }, { 0x38,0x24,0x34,0x2c }, { 0x36,0x2d,0x39,0x27 }, - { 0x24,0x36,0x2e,0x3a }, { 0x2a,0x3f,0x23,0x31 }, + { 0x24,0x36,0x2e,0x3a }, { 0x2a,0x3f,0x23,0x31 }, { 0x70,0x48,0x68,0x58 }, { 0x7e,0x41,0x65,0x53 }, - { 0x6c,0x5a,0x72,0x4e }, { 0x62,0x53,0x7f,0x45 }, + { 0x6c,0x5a,0x72,0x4e }, { 0x62,0x53,0x7f,0x45 }, { 0x48,0x6c,0x5c,0x74 }, { 0x46,0x65,0x51,0x7f }, - { 0x54,0x7e,0x46,0x62 }, { 0x5a,0x77,0x4b,0x69 }, + { 0x54,0x7e,0x46,0x62 }, { 0x5a,0x77,0x4b,0x69 }, { 0xe0,0x90,0xd0,0xb0 }, { 0xee,0x99,0xdd,0xbb }, - { 0xfc,0x82,0xca,0xa6 }, { 0xf2,0x8b,0xc7,0xad }, + { 0xfc,0x82,0xca,0xa6 }, { 0xf2,0x8b,0xc7,0xad }, { 0xd8,0xb4,0xe4,0x9c }, { 0xd6,0xbd,0xe9,0x97 }, - { 0xc4,0xa6,0xfe,0x8a }, { 0xca,0xaf,0xf3,0x81 }, + { 0xc4,0xa6,0xfe,0x8a }, { 0xca,0xaf,0xf3,0x81 }, { 0x90,0xd8,0xb8,0xe8 }, { 0x9e,0xd1,0xb5,0xe3 }, - { 0x8c,0xca,0xa2,0xfe }, { 0x82,0xc3,0xaf,0xf5 }, + { 0x8c,0xca,0xa2,0xfe }, { 0x82,0xc3,0xaf,0xf5 }, { 0xa8,0xfc,0x8c,0xc4 }, { 0xa6,0xf5,0x81,0xcf }, - { 0xb4,0xee,0x96,0xd2 }, { 0xba,0xe7,0x9b,0xd9 }, + { 0xb4,0xee,0x96,0xd2 }, { 0xba,0xe7,0x9b,0xd9 }, { 0xdb,0x3b,0xbb,0x7b }, { 0xd5,0x32,0xb6,0x70 }, - { 0xc7,0x29,0xa1,0x6d }, { 0xc9,0x20,0xac,0x66 }, + { 0xc7,0x29,0xa1,0x6d }, { 0xc9,0x20,0xac,0x66 }, { 0xe3,0x1f,0x8f,0x57 }, { 0xed,0x16,0x82,0x5c }, - { 0xff,0x0d,0x95,0x41 }, { 0xf1,0x04,0x98,0x4a }, + { 0xff,0x0d,0x95,0x41 }, { 0xf1,0x04,0x98,0x4a }, { 0xab,0x73,0xd3,0x23 }, { 0xa5,0x7a,0xde,0x28 }, - { 0xb7,0x61,0xc9,0x35 }, { 0xb9,0x68,0xc4,0x3e }, + { 0xb7,0x61,0xc9,0x35 }, { 0xb9,0x68,0xc4,0x3e }, { 0x93,0x57,0xe7,0x0f }, { 0x9d,0x5e,0xea,0x04 }, - { 0x8f,0x45,0xfd,0x19 }, { 0x81,0x4c,0xf0,0x12 }, + { 0x8f,0x45,0xfd,0x19 }, { 0x81,0x4c,0xf0,0x12 }, { 0x3b,0xab,0x6b,0xcb }, { 0x35,0xa2,0x66,0xc0 }, - { 0x27,0xb9,0x71,0xdd }, { 0x29,0xb0,0x7c,0xd6 }, + { 0x27,0xb9,0x71,0xdd }, { 0x29,0xb0,0x7c,0xd6 }, { 0x03,0x8f,0x5f,0xe7 }, { 0x0d,0x86,0x52,0xec }, - { 0x1f,0x9d,0x45,0xf1 }, { 0x11,0x94,0x48,0xfa }, + { 0x1f,0x9d,0x45,0xf1 }, { 0x11,0x94,0x48,0xfa }, { 0x4b,0xe3,0x03,0x93 }, { 0x45,0xea,0x0e,0x98 }, - { 0x57,0xf1,0x19,0x85 }, { 0x59,0xf8,0x14,0x8e }, + { 0x57,0xf1,0x19,0x85 }, { 0x59,0xf8,0x14,0x8e }, { 0x73,0xc7,0x37,0xbf }, { 0x7d,0xce,0x3a,0xb4 }, - { 0x6f,0xd5,0x2d,0xa9 }, { 0x61,0xdc,0x20,0xa2 }, + { 0x6f,0xd5,0x2d,0xa9 }, { 0x61,0xdc,0x20,0xa2 }, { 0xad,0x76,0x6d,0xf6 }, { 0xa3,0x7f,0x60,0xfd }, - { 0xb1,0x64,0x77,0xe0 }, { 0xbf,0x6d,0x7a,0xeb }, + { 0xb1,0x64,0x77,0xe0 }, { 0xbf,0x6d,0x7a,0xeb }, { 0x95,0x52,0x59,0xda }, { 0x9b,0x5b,0x54,0xd1 }, - { 0x89,0x40,0x43,0xcc }, { 0x87,0x49,0x4e,0xc7 }, + { 0x89,0x40,0x43,0xcc }, { 0x87,0x49,0x4e,0xc7 }, { 0xdd,0x3e,0x05,0xae }, { 0xd3,0x37,0x08,0xa5 }, - { 0xc1,0x2c,0x1f,0xb8 }, { 0xcf,0x25,0x12,0xb3 }, + { 0xc1,0x2c,0x1f,0xb8 }, { 0xcf,0x25,0x12,0xb3 }, { 0xe5,0x1a,0x31,0x82 }, { 0xeb,0x13,0x3c,0x89 }, - { 0xf9,0x08,0x2b,0x94 }, { 0xf7,0x01,0x26,0x9f }, + { 0xf9,0x08,0x2b,0x94 }, { 0xf7,0x01,0x26,0x9f }, { 0x4d,0xe6,0xbd,0x46 }, { 0x43,0xef,0xb0,0x4d }, - { 0x51,0xf4,0xa7,0x50 }, { 0x5f,0xfd,0xaa,0x5b }, + { 0x51,0xf4,0xa7,0x50 }, { 0x5f,0xfd,0xaa,0x5b }, { 0x75,0xc2,0x89,0x6a }, { 0x7b,0xcb,0x84,0x61 }, - { 0x69,0xd0,0x93,0x7c }, { 0x67,0xd9,0x9e,0x77 }, + { 0x69,0xd0,0x93,0x7c }, { 0x67,0xd9,0x9e,0x77 }, { 0x3d,0xae,0xd5,0x1e }, { 0x33,0xa7,0xd8,0x15 }, - { 0x21,0xbc,0xcf,0x08 }, { 0x2f,0xb5,0xc2,0x03 }, + { 0x21,0xbc,0xcf,0x08 }, { 0x2f,0xb5,0xc2,0x03 }, { 0x05,0x8a,0xe1,0x32 }, { 0x0b,0x83,0xec,0x39 }, - { 0x19,0x98,0xfb,0x24 }, { 0x17,0x91,0xf6,0x2f }, + { 0x19,0x98,0xfb,0x24 }, { 0x17,0x91,0xf6,0x2f }, { 0x76,0x4d,0xd6,0x8d }, { 0x78,0x44,0xdb,0x86 }, - { 0x6a,0x5f,0xcc,0x9b }, { 0x64,0x56,0xc1,0x90 }, + { 0x6a,0x5f,0xcc,0x9b }, { 0x64,0x56,0xc1,0x90 }, { 0x4e,0x69,0xe2,0xa1 }, { 0x40,0x60,0xef,0xaa }, - { 0x52,0x7b,0xf8,0xb7 }, { 0x5c,0x72,0xf5,0xbc }, + { 0x52,0x7b,0xf8,0xb7 }, { 0x5c,0x72,0xf5,0xbc }, { 0x06,0x05,0xbe,0xd5 }, { 0x08,0x0c,0xb3,0xde }, - { 0x1a,0x17,0xa4,0xc3 }, { 0x14,0x1e,0xa9,0xc8 }, + { 0x1a,0x17,0xa4,0xc3 }, { 0x14,0x1e,0xa9,0xc8 }, { 0x3e,0x21,0x8a,0xf9 }, { 0x30,0x28,0x87,0xf2 }, - { 0x22,0x33,0x90,0xef }, { 0x2c,0x3a,0x9d,0xe4 }, + { 0x22,0x33,0x90,0xef }, { 0x2c,0x3a,0x9d,0xe4 }, { 0x96,0xdd,0x06,0x3d }, { 0x98,0xd4,0x0b,0x36 }, - { 0x8a,0xcf,0x1c,0x2b }, { 0x84,0xc6,0x11,0x20 }, + { 0x8a,0xcf,0x1c,0x2b }, { 0x84,0xc6,0x11,0x20 }, { 0xae,0xf9,0x32,0x11 }, { 0xa0,0xf0,0x3f,0x1a }, - { 0xb2,0xeb,0x28,0x07 }, { 0xbc,0xe2,0x25,0x0c }, + { 0xb2,0xeb,0x28,0x07 }, { 0xbc,0xe2,0x25,0x0c }, { 0xe6,0x95,0x6e,0x65 }, { 0xe8,0x9c,0x63,0x6e }, - { 0xfa,0x87,0x74,0x73 }, { 0xf4,0x8e,0x79,0x78 }, + { 0xfa,0x87,0x74,0x73 }, { 0xf4,0x8e,0x79,0x78 }, { 0xde,0xb1,0x5a,0x49 }, { 0xd0,0xb8,0x57,0x42 }, - { 0xc2,0xa3,0x40,0x5f }, { 0xcc,0xaa,0x4d,0x54 }, + { 0xc2,0xa3,0x40,0x5f }, { 0xcc,0xaa,0x4d,0x54 }, { 0x41,0xec,0xda,0xf7 }, { 0x4f,0xe5,0xd7,0xfc }, - { 0x5d,0xfe,0xc0,0xe1 }, { 0x53,0xf7,0xcd,0xea }, + { 0x5d,0xfe,0xc0,0xe1 }, { 0x53,0xf7,0xcd,0xea }, { 0x79,0xc8,0xee,0xdb }, { 0x77,0xc1,0xe3,0xd0 }, - { 0x65,0xda,0xf4,0xcd }, { 0x6b,0xd3,0xf9,0xc6 }, + { 0x65,0xda,0xf4,0xcd }, { 0x6b,0xd3,0xf9,0xc6 }, { 0x31,0xa4,0xb2,0xaf }, { 0x3f,0xad,0xbf,0xa4 }, - { 0x2d,0xb6,0xa8,0xb9 }, { 0x23,0xbf,0xa5,0xb2 }, + { 0x2d,0xb6,0xa8,0xb9 }, { 0x23,0xbf,0xa5,0xb2 }, { 0x09,0x80,0x86,0x83 }, { 0x07,0x89,0x8b,0x88 }, - { 0x15,0x92,0x9c,0x95 }, { 0x1b,0x9b,0x91,0x9e }, + { 0x15,0x92,0x9c,0x95 }, { 0x1b,0x9b,0x91,0x9e }, { 0xa1,0x7c,0x0a,0x47 }, { 0xaf,0x75,0x07,0x4c }, - { 0xbd,0x6e,0x10,0x51 }, { 0xb3,0x67,0x1d,0x5a }, + { 0xbd,0x6e,0x10,0x51 }, { 0xb3,0x67,0x1d,0x5a }, { 0x99,0x58,0x3e,0x6b }, { 0x97,0x51,0x33,0x60 }, - { 0x85,0x4a,0x24,0x7d }, { 0x8b,0x43,0x29,0x76 }, + { 0x85,0x4a,0x24,0x7d }, { 0x8b,0x43,0x29,0x76 }, { 0xd1,0x34,0x62,0x1f }, { 0xdf,0x3d,0x6f,0x14 }, - { 0xcd,0x26,0x78,0x09 }, { 0xc3,0x2f,0x75,0x02 }, + { 0xcd,0x26,0x78,0x09 }, { 0xc3,0x2f,0x75,0x02 }, { 0xe9,0x10,0x56,0x33 }, { 0xe7,0x19,0x5b,0x38 }, - { 0xf5,0x02,0x4c,0x25 }, { 0xfb,0x0b,0x41,0x2e }, - { 0x9a,0xd7,0x61,0x8c }, { 0x94,0xde,0x6c,0x87 }, - { 0x86,0xc5,0x7b,0x9a }, { 0x88,0xcc,0x76,0x91 }, + { 0xf5,0x02,0x4c,0x25 }, { 0xfb,0x0b,0x41,0x2e }, + { 0x9a,0xd7,0x61,0x8c }, { 0x94,0xde,0x6c,0x87 }, + { 0x86,0xc5,0x7b,0x9a }, { 0x88,0xcc,0x76,0x91 }, { 0xa2,0xf3,0x55,0xa0 }, { 0xac,0xfa,0x58,0xab }, - { 0xbe,0xe1,0x4f,0xb6 }, { 0xb0,0xe8,0x42,0xbd }, + { 0xbe,0xe1,0x4f,0xb6 }, { 0xb0,0xe8,0x42,0xbd }, { 0xea,0x9f,0x09,0xd4 }, { 0xe4,0x96,0x04,0xdf }, - { 0xf6,0x8d,0x13,0xc2 }, { 0xf8,0x84,0x1e,0xc9 }, + { 0xf6,0x8d,0x13,0xc2 }, { 0xf8,0x84,0x1e,0xc9 }, { 0xd2,0xbb,0x3d,0xf8 }, { 0xdc,0xb2,0x30,0xf3 }, - { 0xce,0xa9,0x27,0xee }, { 0xc0,0xa0,0x2a,0xe5 }, - { 0x7a,0x47,0xb1,0x3c }, { 0x74,0x4e,0xbc,0x37 }, - { 0x66,0x55,0xab,0x2a }, { 0x68,0x5c,0xa6,0x21 }, + { 0xce,0xa9,0x27,0xee }, { 0xc0,0xa0,0x2a,0xe5 }, + { 0x7a,0x47,0xb1,0x3c }, { 0x74,0x4e,0xbc,0x37 }, + { 0x66,0x55,0xab,0x2a }, { 0x68,0x5c,0xa6,0x21 }, { 0x42,0x63,0x85,0x10 }, { 0x4c,0x6a,0x88,0x1b }, - { 0x5e,0x71,0x9f,0x06 }, { 0x50,0x78,0x92,0x0d }, + { 0x5e,0x71,0x9f,0x06 }, { 0x50,0x78,0x92,0x0d }, { 0x0a,0x0f,0xd9,0x64 }, { 0x04,0x06,0xd4,0x6f }, - { 0x16,0x1d,0xc3,0x72 }, { 0x18,0x14,0xce,0x79 }, + { 0x16,0x1d,0xc3,0x72 }, { 0x18,0x14,0xce,0x79 }, { 0x32,0x2b,0xed,0x48 }, { 0x3c,0x22,0xe0,0x43 }, - { 0x2e,0x39,0xf7,0x5e }, { 0x20,0x30,0xfa,0x55 }, + { 0x2e,0x39,0xf7,0x5e }, { 0x20,0x30,0xfa,0x55 }, { 0xec,0x9a,0xb7,0x01 }, { 0xe2,0x93,0xba,0x0a }, - { 0xf0,0x88,0xad,0x17 }, { 0xfe,0x81,0xa0,0x1c }, + { 0xf0,0x88,0xad,0x17 }, { 0xfe,0x81,0xa0,0x1c }, { 0xd4,0xbe,0x83,0x2d }, { 0xda,0xb7,0x8e,0x26 }, - { 0xc8,0xac,0x99,0x3b }, { 0xc6,0xa5,0x94,0x30 }, + { 0xc8,0xac,0x99,0x3b }, { 0xc6,0xa5,0x94,0x30 }, { 0x9c,0xd2,0xdf,0x59 }, { 0x92,0xdb,0xd2,0x52 }, - { 0x80,0xc0,0xc5,0x4f }, { 0x8e,0xc9,0xc8,0x44 }, + { 0x80,0xc0,0xc5,0x4f }, { 0x8e,0xc9,0xc8,0x44 }, { 0xa4,0xf6,0xeb,0x75 }, { 0xaa,0xff,0xe6,0x7e }, - { 0xb8,0xe4,0xf1,0x63 }, { 0xb6,0xed,0xfc,0x68 }, + { 0xb8,0xe4,0xf1,0x63 }, { 0xb6,0xed,0xfc,0x68 }, { 0x0c,0x0a,0x67,0xb1 }, { 0x02,0x03,0x6a,0xba }, - { 0x10,0x18,0x7d,0xa7 }, { 0x1e,0x11,0x70,0xac }, + { 0x10,0x18,0x7d,0xa7 }, { 0x1e,0x11,0x70,0xac }, { 0x34,0x2e,0x53,0x9d }, { 0x3a,0x27,0x5e,0x96 }, - { 0x28,0x3c,0x49,0x8b }, { 0x26,0x35,0x44,0x80 }, + { 0x28,0x3c,0x49,0x8b }, { 0x26,0x35,0x44,0x80 }, { 0x7c,0x42,0x0f,0xe9 }, { 0x72,0x4b,0x02,0xe2 }, - { 0x60,0x50,0x15,0xff }, { 0x6e,0x59,0x18,0xf4 }, + { 0x60,0x50,0x15,0xff }, { 0x6e,0x59,0x18,0xf4 }, { 0x44,0x66,0x3b,0xc5 }, { 0x4a,0x6f,0x36,0xce }, - { 0x58,0x74,0x21,0xd3 }, { 0x56,0x7d,0x2c,0xd8 }, + { 0x58,0x74,0x21,0xd3 }, { 0x56,0x7d,0x2c,0xd8 }, { 0x37,0xa1,0x0c,0x7a }, { 0x39,0xa8,0x01,0x71 }, - { 0x2b,0xb3,0x16,0x6c }, { 0x25,0xba,0x1b,0x67 }, + { 0x2b,0xb3,0x16,0x6c }, { 0x25,0xba,0x1b,0x67 }, { 0x0f,0x85,0x38,0x56 }, { 0x01,0x8c,0x35,0x5d }, - { 0x13,0x97,0x22,0x40 }, { 0x1d,0x9e,0x2f,0x4b }, + { 0x13,0x97,0x22,0x40 }, { 0x1d,0x9e,0x2f,0x4b }, { 0x47,0xe9,0x64,0x22 }, { 0x49,0xe0,0x69,0x29 }, - { 0x5b,0xfb,0x7e,0x34 }, { 0x55,0xf2,0x73,0x3f }, + { 0x5b,0xfb,0x7e,0x34 }, { 0x55,0xf2,0x73,0x3f }, { 0x7f,0xcd,0x50,0x0e }, { 0x71,0xc4,0x5d,0x05 }, - { 0x63,0xdf,0x4a,0x18 }, { 0x6d,0xd6,0x47,0x13 }, + { 0x63,0xdf,0x4a,0x18 }, { 0x6d,0xd6,0x47,0x13 }, { 0xd7,0x31,0xdc,0xca }, { 0xd9,0x38,0xd1,0xc1 }, - { 0xcb,0x23,0xc6,0xdc }, { 0xc5,0x2a,0xcb,0xd7 }, + { 0xcb,0x23,0xc6,0xdc }, { 0xc5,0x2a,0xcb,0xd7 }, { 0xef,0x15,0xe8,0xe6 }, { 0xe1,0x1c,0xe5,0xed }, - { 0xf3,0x07,0xf2,0xf0 }, { 0xfd,0x0e,0xff,0xfb }, + { 0xf3,0x07,0xf2,0xf0 }, { 0xfd,0x0e,0xff,0xfb }, { 0xa7,0x79,0xb4,0x92 }, { 0xa9,0x70,0xb9,0x99 }, - { 0xbb,0x6b,0xae,0x84 }, { 0xb5,0x62,0xa3,0x8f }, + { 0xbb,0x6b,0xae,0x84 }, { 0xb5,0x62,0xa3,0x8f }, { 0x9f,0x5d,0x80,0xbe }, { 0x91,0x54,0x8d,0xb5 }, { 0x83,0x4f,0x9a,0xa8 }, { 0x8d,0x46,0x97,0xa3 } }; -static const unsigned char U2[256][4] = +static const unsigned char U2[256][4] = { { 0x00,0x00,0x00,0x00 }, { 0x0b,0x0e,0x09,0x0d }, - { 0x16,0x1c,0x12,0x1a }, { 0x1d,0x12,0x1b,0x17 }, + { 0x16,0x1c,0x12,0x1a }, { 0x1d,0x12,0x1b,0x17 }, { 0x2c,0x38,0x24,0x34 }, { 0x27,0x36,0x2d,0x39 }, - { 0x3a,0x24,0x36,0x2e }, { 0x31,0x2a,0x3f,0x23 }, - { 0x58,0x70,0x48,0x68 }, { 0x53,0x7e,0x41,0x65 }, - { 0x4e,0x6c,0x5a,0x72 }, { 0x45,0x62,0x53,0x7f }, + { 0x3a,0x24,0x36,0x2e }, { 0x31,0x2a,0x3f,0x23 }, + { 0x58,0x70,0x48,0x68 }, { 0x53,0x7e,0x41,0x65 }, + { 0x4e,0x6c,0x5a,0x72 }, { 0x45,0x62,0x53,0x7f }, { 0x74,0x48,0x6c,0x5c }, { 0x7f,0x46,0x65,0x51 }, - { 0x62,0x54,0x7e,0x46 }, { 0x69,0x5a,0x77,0x4b }, - { 0xb0,0xe0,0x90,0xd0 }, { 0xbb,0xee,0x99,0xdd }, - { 0xa6,0xfc,0x82,0xca }, { 0xad,0xf2,0x8b,0xc7 }, - { 0x9c,0xd8,0xb4,0xe4 }, { 0x97,0xd6,0xbd,0xe9 }, - { 0x8a,0xc4,0xa6,0xfe }, { 0x81,0xca,0xaf,0xf3 }, + { 0x62,0x54,0x7e,0x46 }, { 0x69,0x5a,0x77,0x4b }, + { 0xb0,0xe0,0x90,0xd0 }, { 0xbb,0xee,0x99,0xdd }, + { 0xa6,0xfc,0x82,0xca }, { 0xad,0xf2,0x8b,0xc7 }, + { 0x9c,0xd8,0xb4,0xe4 }, { 0x97,0xd6,0xbd,0xe9 }, + { 0x8a,0xc4,0xa6,0xfe }, { 0x81,0xca,0xaf,0xf3 }, { 0xe8,0x90,0xd8,0xb8 }, { 0xe3,0x9e,0xd1,0xb5 }, - { 0xfe,0x8c,0xca,0xa2 }, { 0xf5,0x82,0xc3,0xaf }, - { 0xc4,0xa8,0xfc,0x8c }, { 0xcf,0xa6,0xf5,0x81 }, - { 0xd2,0xb4,0xee,0x96 }, { 0xd9,0xba,0xe7,0x9b }, - { 0x7b,0xdb,0x3b,0xbb }, { 0x70,0xd5,0x32,0xb6 }, - { 0x6d,0xc7,0x29,0xa1 }, { 0x66,0xc9,0x20,0xac }, - { 0x57,0xe3,0x1f,0x8f }, { 0x5c,0xed,0x16,0x82 }, - { 0x41,0xff,0x0d,0x95 }, { 0x4a,0xf1,0x04,0x98 }, + { 0xfe,0x8c,0xca,0xa2 }, { 0xf5,0x82,0xc3,0xaf }, + { 0xc4,0xa8,0xfc,0x8c }, { 0xcf,0xa6,0xf5,0x81 }, + { 0xd2,0xb4,0xee,0x96 }, { 0xd9,0xba,0xe7,0x9b }, + { 0x7b,0xdb,0x3b,0xbb }, { 0x70,0xd5,0x32,0xb6 }, + { 0x6d,0xc7,0x29,0xa1 }, { 0x66,0xc9,0x20,0xac }, + { 0x57,0xe3,0x1f,0x8f }, { 0x5c,0xed,0x16,0x82 }, + { 0x41,0xff,0x0d,0x95 }, { 0x4a,0xf1,0x04,0x98 }, { 0x23,0xab,0x73,0xd3 }, { 0x28,0xa5,0x7a,0xde }, - { 0x35,0xb7,0x61,0xc9 }, { 0x3e,0xb9,0x68,0xc4 }, + { 0x35,0xb7,0x61,0xc9 }, { 0x3e,0xb9,0x68,0xc4 }, { 0x0f,0x93,0x57,0xe7 }, { 0x04,0x9d,0x5e,0xea }, - { 0x19,0x8f,0x45,0xfd }, { 0x12,0x81,0x4c,0xf0 }, + { 0x19,0x8f,0x45,0xfd }, { 0x12,0x81,0x4c,0xf0 }, { 0xcb,0x3b,0xab,0x6b }, { 0xc0,0x35,0xa2,0x66 }, - { 0xdd,0x27,0xb9,0x71 }, { 0xd6,0x29,0xb0,0x7c }, + { 0xdd,0x27,0xb9,0x71 }, { 0xd6,0x29,0xb0,0x7c }, { 0xe7,0x03,0x8f,0x5f }, { 0xec,0x0d,0x86,0x52 }, - { 0xf1,0x1f,0x9d,0x45 }, { 0xfa,0x11,0x94,0x48 }, - { 0x93,0x4b,0xe3,0x03 }, { 0x98,0x45,0xea,0x0e }, - { 0x85,0x57,0xf1,0x19 }, { 0x8e,0x59,0xf8,0x14 }, + { 0xf1,0x1f,0x9d,0x45 }, { 0xfa,0x11,0x94,0x48 }, + { 0x93,0x4b,0xe3,0x03 }, { 0x98,0x45,0xea,0x0e }, + { 0x85,0x57,0xf1,0x19 }, { 0x8e,0x59,0xf8,0x14 }, { 0xbf,0x73,0xc7,0x37 }, { 0xb4,0x7d,0xce,0x3a }, - { 0xa9,0x6f,0xd5,0x2d }, { 0xa2,0x61,0xdc,0x20 }, - { 0xf6,0xad,0x76,0x6d }, { 0xfd,0xa3,0x7f,0x60 }, - { 0xe0,0xb1,0x64,0x77 }, { 0xeb,0xbf,0x6d,0x7a }, - { 0xda,0x95,0x52,0x59 }, { 0xd1,0x9b,0x5b,0x54 }, - { 0xcc,0x89,0x40,0x43 }, { 0xc7,0x87,0x49,0x4e }, + { 0xa9,0x6f,0xd5,0x2d }, { 0xa2,0x61,0xdc,0x20 }, + { 0xf6,0xad,0x76,0x6d }, { 0xfd,0xa3,0x7f,0x60 }, + { 0xe0,0xb1,0x64,0x77 }, { 0xeb,0xbf,0x6d,0x7a }, + { 0xda,0x95,0x52,0x59 }, { 0xd1,0x9b,0x5b,0x54 }, + { 0xcc,0x89,0x40,0x43 }, { 0xc7,0x87,0x49,0x4e }, { 0xae,0xdd,0x3e,0x05 }, { 0xa5,0xd3,0x37,0x08 }, - { 0xb8,0xc1,0x2c,0x1f }, { 0xb3,0xcf,0x25,0x12 }, + { 0xb8,0xc1,0x2c,0x1f }, { 0xb3,0xcf,0x25,0x12 }, { 0x82,0xe5,0x1a,0x31 }, { 0x89,0xeb,0x13,0x3c }, - { 0x94,0xf9,0x08,0x2b }, { 0x9f,0xf7,0x01,0x26 }, + { 0x94,0xf9,0x08,0x2b }, { 0x9f,0xf7,0x01,0x26 }, { 0x46,0x4d,0xe6,0xbd }, { 0x4d,0x43,0xef,0xb0 }, - { 0x50,0x51,0xf4,0xa7 }, { 0x5b,0x5f,0xfd,0xaa }, + { 0x50,0x51,0xf4,0xa7 }, { 0x5b,0x5f,0xfd,0xaa }, { 0x6a,0x75,0xc2,0x89 }, { 0x61,0x7b,0xcb,0x84 }, - { 0x7c,0x69,0xd0,0x93 }, { 0x77,0x67,0xd9,0x9e }, + { 0x7c,0x69,0xd0,0x93 }, { 0x77,0x67,0xd9,0x9e }, { 0x1e,0x3d,0xae,0xd5 }, { 0x15,0x33,0xa7,0xd8 }, - { 0x08,0x21,0xbc,0xcf }, { 0x03,0x2f,0xb5,0xc2 }, + { 0x08,0x21,0xbc,0xcf }, { 0x03,0x2f,0xb5,0xc2 }, { 0x32,0x05,0x8a,0xe1 }, { 0x39,0x0b,0x83,0xec }, - { 0x24,0x19,0x98,0xfb }, { 0x2f,0x17,0x91,0xf6 }, + { 0x24,0x19,0x98,0xfb }, { 0x2f,0x17,0x91,0xf6 }, { 0x8d,0x76,0x4d,0xd6 }, { 0x86,0x78,0x44,0xdb }, - { 0x9b,0x6a,0x5f,0xcc }, { 0x90,0x64,0x56,0xc1 }, + { 0x9b,0x6a,0x5f,0xcc }, { 0x90,0x64,0x56,0xc1 }, { 0xa1,0x4e,0x69,0xe2 }, { 0xaa,0x40,0x60,0xef }, - { 0xb7,0x52,0x7b,0xf8 }, { 0xbc,0x5c,0x72,0xf5 }, + { 0xb7,0x52,0x7b,0xf8 }, { 0xbc,0x5c,0x72,0xf5 }, { 0xd5,0x06,0x05,0xbe }, { 0xde,0x08,0x0c,0xb3 }, - { 0xc3,0x1a,0x17,0xa4 }, { 0xc8,0x14,0x1e,0xa9 }, + { 0xc3,0x1a,0x17,0xa4 }, { 0xc8,0x14,0x1e,0xa9 }, { 0xf9,0x3e,0x21,0x8a }, { 0xf2,0x30,0x28,0x87 }, - { 0xef,0x22,0x33,0x90 }, { 0xe4,0x2c,0x3a,0x9d }, + { 0xef,0x22,0x33,0x90 }, { 0xe4,0x2c,0x3a,0x9d }, { 0x3d,0x96,0xdd,0x06 }, { 0x36,0x98,0xd4,0x0b }, - { 0x2b,0x8a,0xcf,0x1c }, { 0x20,0x84,0xc6,0x11 }, + { 0x2b,0x8a,0xcf,0x1c }, { 0x20,0x84,0xc6,0x11 }, { 0x11,0xae,0xf9,0x32 }, { 0x1a,0xa0,0xf0,0x3f }, - { 0x07,0xb2,0xeb,0x28 }, { 0x0c,0xbc,0xe2,0x25 }, + { 0x07,0xb2,0xeb,0x28 }, { 0x0c,0xbc,0xe2,0x25 }, { 0x65,0xe6,0x95,0x6e }, { 0x6e,0xe8,0x9c,0x63 }, - { 0x73,0xfa,0x87,0x74 }, { 0x78,0xf4,0x8e,0x79 }, + { 0x73,0xfa,0x87,0x74 }, { 0x78,0xf4,0x8e,0x79 }, { 0x49,0xde,0xb1,0x5a }, { 0x42,0xd0,0xb8,0x57 }, - { 0x5f,0xc2,0xa3,0x40 }, { 0x54,0xcc,0xaa,0x4d }, + { 0x5f,0xc2,0xa3,0x40 }, { 0x54,0xcc,0xaa,0x4d }, { 0xf7,0x41,0xec,0xda }, { 0xfc,0x4f,0xe5,0xd7 }, - { 0xe1,0x5d,0xfe,0xc0 }, { 0xea,0x53,0xf7,0xcd }, + { 0xe1,0x5d,0xfe,0xc0 }, { 0xea,0x53,0xf7,0xcd }, { 0xdb,0x79,0xc8,0xee }, { 0xd0,0x77,0xc1,0xe3 }, - { 0xcd,0x65,0xda,0xf4 }, { 0xc6,0x6b,0xd3,0xf9 }, + { 0xcd,0x65,0xda,0xf4 }, { 0xc6,0x6b,0xd3,0xf9 }, { 0xaf,0x31,0xa4,0xb2 }, { 0xa4,0x3f,0xad,0xbf }, - { 0xb9,0x2d,0xb6,0xa8 }, { 0xb2,0x23,0xbf,0xa5 }, + { 0xb9,0x2d,0xb6,0xa8 }, { 0xb2,0x23,0xbf,0xa5 }, { 0x83,0x09,0x80,0x86 }, { 0x88,0x07,0x89,0x8b }, - { 0x95,0x15,0x92,0x9c }, { 0x9e,0x1b,0x9b,0x91 }, + { 0x95,0x15,0x92,0x9c }, { 0x9e,0x1b,0x9b,0x91 }, { 0x47,0xa1,0x7c,0x0a }, { 0x4c,0xaf,0x75,0x07 }, - { 0x51,0xbd,0x6e,0x10 }, { 0x5a,0xb3,0x67,0x1d }, + { 0x51,0xbd,0x6e,0x10 }, { 0x5a,0xb3,0x67,0x1d }, { 0x6b,0x99,0x58,0x3e }, { 0x60,0x97,0x51,0x33 }, - { 0x7d,0x85,0x4a,0x24 }, { 0x76,0x8b,0x43,0x29 }, + { 0x7d,0x85,0x4a,0x24 }, { 0x76,0x8b,0x43,0x29 }, { 0x1f,0xd1,0x34,0x62 }, { 0x14,0xdf,0x3d,0x6f }, - { 0x09,0xcd,0x26,0x78 }, { 0x02,0xc3,0x2f,0x75 }, + { 0x09,0xcd,0x26,0x78 }, { 0x02,0xc3,0x2f,0x75 }, { 0x33,0xe9,0x10,0x56 }, { 0x38,0xe7,0x19,0x5b }, - { 0x25,0xf5,0x02,0x4c }, { 0x2e,0xfb,0x0b,0x41 }, + { 0x25,0xf5,0x02,0x4c }, { 0x2e,0xfb,0x0b,0x41 }, { 0x8c,0x9a,0xd7,0x61 }, { 0x87,0x94,0xde,0x6c }, - { 0x9a,0x86,0xc5,0x7b }, { 0x91,0x88,0xcc,0x76 }, + { 0x9a,0x86,0xc5,0x7b }, { 0x91,0x88,0xcc,0x76 }, { 0xa0,0xa2,0xf3,0x55 }, { 0xab,0xac,0xfa,0x58 }, - { 0xb6,0xbe,0xe1,0x4f }, { 0xbd,0xb0,0xe8,0x42 }, + { 0xb6,0xbe,0xe1,0x4f }, { 0xbd,0xb0,0xe8,0x42 }, { 0xd4,0xea,0x9f,0x09 }, { 0xdf,0xe4,0x96,0x04 }, - { 0xc2,0xf6,0x8d,0x13 }, { 0xc9,0xf8,0x84,0x1e }, + { 0xc2,0xf6,0x8d,0x13 }, { 0xc9,0xf8,0x84,0x1e }, { 0xf8,0xd2,0xbb,0x3d }, { 0xf3,0xdc,0xb2,0x30 }, - { 0xee,0xce,0xa9,0x27 }, { 0xe5,0xc0,0xa0,0x2a }, + { 0xee,0xce,0xa9,0x27 }, { 0xe5,0xc0,0xa0,0x2a }, { 0x3c,0x7a,0x47,0xb1 }, { 0x37,0x74,0x4e,0xbc }, - { 0x2a,0x66,0x55,0xab }, { 0x21,0x68,0x5c,0xa6 }, + { 0x2a,0x66,0x55,0xab }, { 0x21,0x68,0x5c,0xa6 }, { 0x10,0x42,0x63,0x85 }, { 0x1b,0x4c,0x6a,0x88 }, - { 0x06,0x5e,0x71,0x9f }, { 0x0d,0x50,0x78,0x92 }, + { 0x06,0x5e,0x71,0x9f }, { 0x0d,0x50,0x78,0x92 }, { 0x64,0x0a,0x0f,0xd9 }, { 0x6f,0x04,0x06,0xd4 }, - { 0x72,0x16,0x1d,0xc3 }, { 0x79,0x18,0x14,0xce }, + { 0x72,0x16,0x1d,0xc3 }, { 0x79,0x18,0x14,0xce }, { 0x48,0x32,0x2b,0xed }, { 0x43,0x3c,0x22,0xe0 }, - { 0x5e,0x2e,0x39,0xf7 }, { 0x55,0x20,0x30,0xfa }, + { 0x5e,0x2e,0x39,0xf7 }, { 0x55,0x20,0x30,0xfa }, { 0x01,0xec,0x9a,0xb7 }, { 0x0a,0xe2,0x93,0xba }, - { 0x17,0xf0,0x88,0xad }, { 0x1c,0xfe,0x81,0xa0 }, + { 0x17,0xf0,0x88,0xad }, { 0x1c,0xfe,0x81,0xa0 }, { 0x2d,0xd4,0xbe,0x83 }, { 0x26,0xda,0xb7,0x8e }, - { 0x3b,0xc8,0xac,0x99 }, { 0x30,0xc6,0xa5,0x94 }, + { 0x3b,0xc8,0xac,0x99 }, { 0x30,0xc6,0xa5,0x94 }, { 0x59,0x9c,0xd2,0xdf }, { 0x52,0x92,0xdb,0xd2 }, - { 0x4f,0x80,0xc0,0xc5 }, { 0x44,0x8e,0xc9,0xc8 }, + { 0x4f,0x80,0xc0,0xc5 }, { 0x44,0x8e,0xc9,0xc8 }, { 0x75,0xa4,0xf6,0xeb }, { 0x7e,0xaa,0xff,0xe6 }, - { 0x63,0xb8,0xe4,0xf1 }, { 0x68,0xb6,0xed,0xfc }, + { 0x63,0xb8,0xe4,0xf1 }, { 0x68,0xb6,0xed,0xfc }, { 0xb1,0x0c,0x0a,0x67 }, { 0xba,0x02,0x03,0x6a }, - { 0xa7,0x10,0x18,0x7d }, { 0xac,0x1e,0x11,0x70 }, + { 0xa7,0x10,0x18,0x7d }, { 0xac,0x1e,0x11,0x70 }, { 0x9d,0x34,0x2e,0x53 }, { 0x96,0x3a,0x27,0x5e }, - { 0x8b,0x28,0x3c,0x49 }, { 0x80,0x26,0x35,0x44 }, + { 0x8b,0x28,0x3c,0x49 }, { 0x80,0x26,0x35,0x44 }, { 0xe9,0x7c,0x42,0x0f }, { 0xe2,0x72,0x4b,0x02 }, - { 0xff,0x60,0x50,0x15 }, { 0xf4,0x6e,0x59,0x18 }, + { 0xff,0x60,0x50,0x15 }, { 0xf4,0x6e,0x59,0x18 }, { 0xc5,0x44,0x66,0x3b }, { 0xce,0x4a,0x6f,0x36 }, - { 0xd3,0x58,0x74,0x21 }, { 0xd8,0x56,0x7d,0x2c }, + { 0xd3,0x58,0x74,0x21 }, { 0xd8,0x56,0x7d,0x2c }, { 0x7a,0x37,0xa1,0x0c }, { 0x71,0x39,0xa8,0x01 }, - { 0x6c,0x2b,0xb3,0x16 }, { 0x67,0x25,0xba,0x1b }, + { 0x6c,0x2b,0xb3,0x16 }, { 0x67,0x25,0xba,0x1b }, { 0x56,0x0f,0x85,0x38 }, { 0x5d,0x01,0x8c,0x35 }, - { 0x40,0x13,0x97,0x22 }, { 0x4b,0x1d,0x9e,0x2f }, + { 0x40,0x13,0x97,0x22 }, { 0x4b,0x1d,0x9e,0x2f }, { 0x22,0x47,0xe9,0x64 }, { 0x29,0x49,0xe0,0x69 }, - { 0x34,0x5b,0xfb,0x7e }, { 0x3f,0x55,0xf2,0x73 }, + { 0x34,0x5b,0xfb,0x7e }, { 0x3f,0x55,0xf2,0x73 }, { 0x0e,0x7f,0xcd,0x50 }, { 0x05,0x71,0xc4,0x5d }, - { 0x18,0x63,0xdf,0x4a }, { 0x13,0x6d,0xd6,0x47 }, + { 0x18,0x63,0xdf,0x4a }, { 0x13,0x6d,0xd6,0x47 }, { 0xca,0xd7,0x31,0xdc }, { 0xc1,0xd9,0x38,0xd1 }, - { 0xdc,0xcb,0x23,0xc6 }, { 0xd7,0xc5,0x2a,0xcb }, + { 0xdc,0xcb,0x23,0xc6 }, { 0xd7,0xc5,0x2a,0xcb }, { 0xe6,0xef,0x15,0xe8 }, { 0xed,0xe1,0x1c,0xe5 }, - { 0xf0,0xf3,0x07,0xf2 }, { 0xfb,0xfd,0x0e,0xff }, + { 0xf0,0xf3,0x07,0xf2 }, { 0xfb,0xfd,0x0e,0xff }, { 0x92,0xa7,0x79,0xb4 }, { 0x99,0xa9,0x70,0xb9 }, - { 0x84,0xbb,0x6b,0xae }, { 0x8f,0xb5,0x62,0xa3 }, + { 0x84,0xbb,0x6b,0xae }, { 0x8f,0xb5,0x62,0xa3 }, { 0xbe,0x9f,0x5d,0x80 }, { 0xb5,0x91,0x54,0x8d }, { 0xa8,0x83,0x4f,0x9a }, { 0xa3,0x8d,0x46,0x97 } }; -static const unsigned char U3[256][4] = +static const unsigned char U3[256][4] = { { 0x00,0x00,0x00,0x00 }, { 0x0d,0x0b,0x0e,0x09 }, - { 0x1a,0x16,0x1c,0x12 }, { 0x17,0x1d,0x12,0x1b }, + { 0x1a,0x16,0x1c,0x12 }, { 0x17,0x1d,0x12,0x1b }, { 0x34,0x2c,0x38,0x24 }, { 0x39,0x27,0x36,0x2d }, - { 0x2e,0x3a,0x24,0x36 }, { 0x23,0x31,0x2a,0x3f }, + { 0x2e,0x3a,0x24,0x36 }, { 0x23,0x31,0x2a,0x3f }, { 0x68,0x58,0x70,0x48 }, { 0x65,0x53,0x7e,0x41 }, - { 0x72,0x4e,0x6c,0x5a }, { 0x7f,0x45,0x62,0x53 }, + { 0x72,0x4e,0x6c,0x5a }, { 0x7f,0x45,0x62,0x53 }, { 0x5c,0x74,0x48,0x6c }, { 0x51,0x7f,0x46,0x65 }, - { 0x46,0x62,0x54,0x7e }, { 0x4b,0x69,0x5a,0x77 }, + { 0x46,0x62,0x54,0x7e }, { 0x4b,0x69,0x5a,0x77 }, { 0xd0,0xb0,0xe0,0x90 }, { 0xdd,0xbb,0xee,0x99 }, - { 0xca,0xa6,0xfc,0x82 }, { 0xc7,0xad,0xf2,0x8b }, + { 0xca,0xa6,0xfc,0x82 }, { 0xc7,0xad,0xf2,0x8b }, { 0xe4,0x9c,0xd8,0xb4 }, { 0xe9,0x97,0xd6,0xbd }, - { 0xfe,0x8a,0xc4,0xa6 }, { 0xf3,0x81,0xca,0xaf }, + { 0xfe,0x8a,0xc4,0xa6 }, { 0xf3,0x81,0xca,0xaf }, { 0xb8,0xe8,0x90,0xd8 }, { 0xb5,0xe3,0x9e,0xd1 }, - { 0xa2,0xfe,0x8c,0xca }, { 0xaf,0xf5,0x82,0xc3 }, + { 0xa2,0xfe,0x8c,0xca }, { 0xaf,0xf5,0x82,0xc3 }, { 0x8c,0xc4,0xa8,0xfc }, { 0x81,0xcf,0xa6,0xf5 }, - { 0x96,0xd2,0xb4,0xee }, { 0x9b,0xd9,0xba,0xe7 }, + { 0x96,0xd2,0xb4,0xee }, { 0x9b,0xd9,0xba,0xe7 }, { 0xbb,0x7b,0xdb,0x3b }, { 0xb6,0x70,0xd5,0x32 }, - { 0xa1,0x6d,0xc7,0x29 }, { 0xac,0x66,0xc9,0x20 }, + { 0xa1,0x6d,0xc7,0x29 }, { 0xac,0x66,0xc9,0x20 }, { 0x8f,0x57,0xe3,0x1f }, { 0x82,0x5c,0xed,0x16 }, - { 0x95,0x41,0xff,0x0d }, { 0x98,0x4a,0xf1,0x04 }, + { 0x95,0x41,0xff,0x0d }, { 0x98,0x4a,0xf1,0x04 }, { 0xd3,0x23,0xab,0x73 }, { 0xde,0x28,0xa5,0x7a }, - { 0xc9,0x35,0xb7,0x61 }, { 0xc4,0x3e,0xb9,0x68 }, + { 0xc9,0x35,0xb7,0x61 }, { 0xc4,0x3e,0xb9,0x68 }, { 0xe7,0x0f,0x93,0x57 }, { 0xea,0x04,0x9d,0x5e }, - { 0xfd,0x19,0x8f,0x45 }, { 0xf0,0x12,0x81,0x4c }, + { 0xfd,0x19,0x8f,0x45 }, { 0xf0,0x12,0x81,0x4c }, { 0x6b,0xcb,0x3b,0xab }, { 0x66,0xc0,0x35,0xa2 }, - { 0x71,0xdd,0x27,0xb9 }, { 0x7c,0xd6,0x29,0xb0 }, + { 0x71,0xdd,0x27,0xb9 }, { 0x7c,0xd6,0x29,0xb0 }, { 0x5f,0xe7,0x03,0x8f }, { 0x52,0xec,0x0d,0x86 }, - { 0x45,0xf1,0x1f,0x9d }, { 0x48,0xfa,0x11,0x94 }, + { 0x45,0xf1,0x1f,0x9d }, { 0x48,0xfa,0x11,0x94 }, { 0x03,0x93,0x4b,0xe3 }, { 0x0e,0x98,0x45,0xea }, - { 0x19,0x85,0x57,0xf1 }, { 0x14,0x8e,0x59,0xf8 }, - { 0x37,0xbf,0x73,0xc7 }, { 0x3a,0xb4,0x7d,0xce }, - { 0x2d,0xa9,0x6f,0xd5 }, { 0x20,0xa2,0x61,0xdc }, + { 0x19,0x85,0x57,0xf1 }, { 0x14,0x8e,0x59,0xf8 }, + { 0x37,0xbf,0x73,0xc7 }, { 0x3a,0xb4,0x7d,0xce }, + { 0x2d,0xa9,0x6f,0xd5 }, { 0x20,0xa2,0x61,0xdc }, { 0x6d,0xf6,0xad,0x76 }, { 0x60,0xfd,0xa3,0x7f }, - { 0x77,0xe0,0xb1,0x64 }, { 0x7a,0xeb,0xbf,0x6d }, + { 0x77,0xe0,0xb1,0x64 }, { 0x7a,0xeb,0xbf,0x6d }, { 0x59,0xda,0x95,0x52 }, { 0x54,0xd1,0x9b,0x5b }, - { 0x43,0xcc,0x89,0x40 }, { 0x4e,0xc7,0x87,0x49 }, + { 0x43,0xcc,0x89,0x40 }, { 0x4e,0xc7,0x87,0x49 }, { 0x05,0xae,0xdd,0x3e }, { 0x08,0xa5,0xd3,0x37 }, - { 0x1f,0xb8,0xc1,0x2c }, { 0x12,0xb3,0xcf,0x25 }, - { 0x31,0x82,0xe5,0x1a }, { 0x3c,0x89,0xeb,0x13 }, - { 0x2b,0x94,0xf9,0x08 }, { 0x26,0x9f,0xf7,0x01 }, - { 0xbd,0x46,0x4d,0xe6 }, { 0xb0,0x4d,0x43,0xef }, - { 0xa7,0x50,0x51,0xf4 }, { 0xaa,0x5b,0x5f,0xfd }, - { 0x89,0x6a,0x75,0xc2 }, { 0x84,0x61,0x7b,0xcb }, - { 0x93,0x7c,0x69,0xd0 }, { 0x9e,0x77,0x67,0xd9 }, + { 0x1f,0xb8,0xc1,0x2c }, { 0x12,0xb3,0xcf,0x25 }, + { 0x31,0x82,0xe5,0x1a }, { 0x3c,0x89,0xeb,0x13 }, + { 0x2b,0x94,0xf9,0x08 }, { 0x26,0x9f,0xf7,0x01 }, + { 0xbd,0x46,0x4d,0xe6 }, { 0xb0,0x4d,0x43,0xef }, + { 0xa7,0x50,0x51,0xf4 }, { 0xaa,0x5b,0x5f,0xfd }, + { 0x89,0x6a,0x75,0xc2 }, { 0x84,0x61,0x7b,0xcb }, + { 0x93,0x7c,0x69,0xd0 }, { 0x9e,0x77,0x67,0xd9 }, { 0xd5,0x1e,0x3d,0xae }, { 0xd8,0x15,0x33,0xa7 }, - { 0xcf,0x08,0x21,0xbc }, { 0xc2,0x03,0x2f,0xb5 }, + { 0xcf,0x08,0x21,0xbc }, { 0xc2,0x03,0x2f,0xb5 }, { 0xe1,0x32,0x05,0x8a }, { 0xec,0x39,0x0b,0x83 }, - { 0xfb,0x24,0x19,0x98 }, { 0xf6,0x2f,0x17,0x91 }, - { 0xd6,0x8d,0x76,0x4d }, { 0xdb,0x86,0x78,0x44 }, - { 0xcc,0x9b,0x6a,0x5f }, { 0xc1,0x90,0x64,0x56 }, - { 0xe2,0xa1,0x4e,0x69 }, { 0xef,0xaa,0x40,0x60 }, - { 0xf8,0xb7,0x52,0x7b }, { 0xf5,0xbc,0x5c,0x72 }, - { 0xbe,0xd5,0x06,0x05 }, { 0xb3,0xde,0x08,0x0c }, - { 0xa4,0xc3,0x1a,0x17 }, { 0xa9,0xc8,0x14,0x1e }, + { 0xfb,0x24,0x19,0x98 }, { 0xf6,0x2f,0x17,0x91 }, + { 0xd6,0x8d,0x76,0x4d }, { 0xdb,0x86,0x78,0x44 }, + { 0xcc,0x9b,0x6a,0x5f }, { 0xc1,0x90,0x64,0x56 }, + { 0xe2,0xa1,0x4e,0x69 }, { 0xef,0xaa,0x40,0x60 }, + { 0xf8,0xb7,0x52,0x7b }, { 0xf5,0xbc,0x5c,0x72 }, + { 0xbe,0xd5,0x06,0x05 }, { 0xb3,0xde,0x08,0x0c }, + { 0xa4,0xc3,0x1a,0x17 }, { 0xa9,0xc8,0x14,0x1e }, { 0x8a,0xf9,0x3e,0x21 }, { 0x87,0xf2,0x30,0x28 }, - { 0x90,0xef,0x22,0x33 }, { 0x9d,0xe4,0x2c,0x3a }, + { 0x90,0xef,0x22,0x33 }, { 0x9d,0xe4,0x2c,0x3a }, { 0x06,0x3d,0x96,0xdd }, { 0x0b,0x36,0x98,0xd4 }, - { 0x1c,0x2b,0x8a,0xcf }, { 0x11,0x20,0x84,0xc6 }, + { 0x1c,0x2b,0x8a,0xcf }, { 0x11,0x20,0x84,0xc6 }, { 0x32,0x11,0xae,0xf9 }, { 0x3f,0x1a,0xa0,0xf0 }, - { 0x28,0x07,0xb2,0xeb }, { 0x25,0x0c,0xbc,0xe2 }, + { 0x28,0x07,0xb2,0xeb }, { 0x25,0x0c,0xbc,0xe2 }, { 0x6e,0x65,0xe6,0x95 }, { 0x63,0x6e,0xe8,0x9c }, - { 0x74,0x73,0xfa,0x87 }, { 0x79,0x78,0xf4,0x8e }, + { 0x74,0x73,0xfa,0x87 }, { 0x79,0x78,0xf4,0x8e }, { 0x5a,0x49,0xde,0xb1 }, { 0x57,0x42,0xd0,0xb8 }, - { 0x40,0x5f,0xc2,0xa3 }, { 0x4d,0x54,0xcc,0xaa }, + { 0x40,0x5f,0xc2,0xa3 }, { 0x4d,0x54,0xcc,0xaa }, { 0xda,0xf7,0x41,0xec }, { 0xd7,0xfc,0x4f,0xe5 }, - { 0xc0,0xe1,0x5d,0xfe }, { 0xcd,0xea,0x53,0xf7 }, + { 0xc0,0xe1,0x5d,0xfe }, { 0xcd,0xea,0x53,0xf7 }, { 0xee,0xdb,0x79,0xc8 }, { 0xe3,0xd0,0x77,0xc1 }, - { 0xf4,0xcd,0x65,0xda }, { 0xf9,0xc6,0x6b,0xd3 }, + { 0xf4,0xcd,0x65,0xda }, { 0xf9,0xc6,0x6b,0xd3 }, { 0xb2,0xaf,0x31,0xa4 }, { 0xbf,0xa4,0x3f,0xad }, - { 0xa8,0xb9,0x2d,0xb6 }, { 0xa5,0xb2,0x23,0xbf }, + { 0xa8,0xb9,0x2d,0xb6 }, { 0xa5,0xb2,0x23,0xbf }, { 0x86,0x83,0x09,0x80 }, { 0x8b,0x88,0x07,0x89 }, - { 0x9c,0x95,0x15,0x92 }, { 0x91,0x9e,0x1b,0x9b }, + { 0x9c,0x95,0x15,0x92 }, { 0x91,0x9e,0x1b,0x9b }, { 0x0a,0x47,0xa1,0x7c }, { 0x07,0x4c,0xaf,0x75 }, - { 0x10,0x51,0xbd,0x6e }, { 0x1d,0x5a,0xb3,0x67 }, + { 0x10,0x51,0xbd,0x6e }, { 0x1d,0x5a,0xb3,0x67 }, { 0x3e,0x6b,0x99,0x58 }, { 0x33,0x60,0x97,0x51 }, - { 0x24,0x7d,0x85,0x4a }, { 0x29,0x76,0x8b,0x43 }, + { 0x24,0x7d,0x85,0x4a }, { 0x29,0x76,0x8b,0x43 }, { 0x62,0x1f,0xd1,0x34 }, { 0x6f,0x14,0xdf,0x3d }, - { 0x78,0x09,0xcd,0x26 }, { 0x75,0x02,0xc3,0x2f }, + { 0x78,0x09,0xcd,0x26 }, { 0x75,0x02,0xc3,0x2f }, { 0x56,0x33,0xe9,0x10 }, { 0x5b,0x38,0xe7,0x19 }, - { 0x4c,0x25,0xf5,0x02 }, { 0x41,0x2e,0xfb,0x0b }, + { 0x4c,0x25,0xf5,0x02 }, { 0x41,0x2e,0xfb,0x0b }, { 0x61,0x8c,0x9a,0xd7 }, { 0x6c,0x87,0x94,0xde }, - { 0x7b,0x9a,0x86,0xc5 }, { 0x76,0x91,0x88,0xcc }, + { 0x7b,0x9a,0x86,0xc5 }, { 0x76,0x91,0x88,0xcc }, { 0x55,0xa0,0xa2,0xf3 }, { 0x58,0xab,0xac,0xfa }, - { 0x4f,0xb6,0xbe,0xe1 }, { 0x42,0xbd,0xb0,0xe8 }, + { 0x4f,0xb6,0xbe,0xe1 }, { 0x42,0xbd,0xb0,0xe8 }, { 0x09,0xd4,0xea,0x9f }, { 0x04,0xdf,0xe4,0x96 }, - { 0x13,0xc2,0xf6,0x8d }, { 0x1e,0xc9,0xf8,0x84 }, + { 0x13,0xc2,0xf6,0x8d }, { 0x1e,0xc9,0xf8,0x84 }, { 0x3d,0xf8,0xd2,0xbb }, { 0x30,0xf3,0xdc,0xb2 }, - { 0x27,0xee,0xce,0xa9 }, { 0x2a,0xe5,0xc0,0xa0 }, + { 0x27,0xee,0xce,0xa9 }, { 0x2a,0xe5,0xc0,0xa0 }, { 0xb1,0x3c,0x7a,0x47 }, { 0xbc,0x37,0x74,0x4e }, - { 0xab,0x2a,0x66,0x55 }, { 0xa6,0x21,0x68,0x5c }, + { 0xab,0x2a,0x66,0x55 }, { 0xa6,0x21,0x68,0x5c }, { 0x85,0x10,0x42,0x63 }, { 0x88,0x1b,0x4c,0x6a }, - { 0x9f,0x06,0x5e,0x71 }, { 0x92,0x0d,0x50,0x78 }, + { 0x9f,0x06,0x5e,0x71 }, { 0x92,0x0d,0x50,0x78 }, { 0xd9,0x64,0x0a,0x0f }, { 0xd4,0x6f,0x04,0x06 }, - { 0xc3,0x72,0x16,0x1d }, { 0xce,0x79,0x18,0x14 }, + { 0xc3,0x72,0x16,0x1d }, { 0xce,0x79,0x18,0x14 }, { 0xed,0x48,0x32,0x2b }, { 0xe0,0x43,0x3c,0x22 }, - { 0xf7,0x5e,0x2e,0x39 }, { 0xfa,0x55,0x20,0x30 }, + { 0xf7,0x5e,0x2e,0x39 }, { 0xfa,0x55,0x20,0x30 }, { 0xb7,0x01,0xec,0x9a }, { 0xba,0x0a,0xe2,0x93 }, - { 0xad,0x17,0xf0,0x88 }, { 0xa0,0x1c,0xfe,0x81 }, + { 0xad,0x17,0xf0,0x88 }, { 0xa0,0x1c,0xfe,0x81 }, { 0x83,0x2d,0xd4,0xbe }, { 0x8e,0x26,0xda,0xb7 }, - { 0x99,0x3b,0xc8,0xac }, { 0x94,0x30,0xc6,0xa5 }, + { 0x99,0x3b,0xc8,0xac }, { 0x94,0x30,0xc6,0xa5 }, { 0xdf,0x59,0x9c,0xd2 }, { 0xd2,0x52,0x92,0xdb }, - { 0xc5,0x4f,0x80,0xc0 }, { 0xc8,0x44,0x8e,0xc9 }, + { 0xc5,0x4f,0x80,0xc0 }, { 0xc8,0x44,0x8e,0xc9 }, { 0xeb,0x75,0xa4,0xf6 }, { 0xe6,0x7e,0xaa,0xff }, - { 0xf1,0x63,0xb8,0xe4 }, { 0xfc,0x68,0xb6,0xed }, + { 0xf1,0x63,0xb8,0xe4 }, { 0xfc,0x68,0xb6,0xed }, { 0x67,0xb1,0x0c,0x0a }, { 0x6a,0xba,0x02,0x03 }, - { 0x7d,0xa7,0x10,0x18 }, { 0x70,0xac,0x1e,0x11 }, + { 0x7d,0xa7,0x10,0x18 }, { 0x70,0xac,0x1e,0x11 }, { 0x53,0x9d,0x34,0x2e }, { 0x5e,0x96,0x3a,0x27 }, - { 0x49,0x8b,0x28,0x3c }, { 0x44,0x80,0x26,0x35 }, + { 0x49,0x8b,0x28,0x3c }, { 0x44,0x80,0x26,0x35 }, { 0x0f,0xe9,0x7c,0x42 }, { 0x02,0xe2,0x72,0x4b }, - { 0x15,0xff,0x60,0x50 }, { 0x18,0xf4,0x6e,0x59 }, + { 0x15,0xff,0x60,0x50 }, { 0x18,0xf4,0x6e,0x59 }, { 0x3b,0xc5,0x44,0x66 }, { 0x36,0xce,0x4a,0x6f }, - { 0x21,0xd3,0x58,0x74 }, { 0x2c,0xd8,0x56,0x7d }, + { 0x21,0xd3,0x58,0x74 }, { 0x2c,0xd8,0x56,0x7d }, { 0x0c,0x7a,0x37,0xa1 }, { 0x01,0x71,0x39,0xa8 }, - { 0x16,0x6c,0x2b,0xb3 }, { 0x1b,0x67,0x25,0xba }, + { 0x16,0x6c,0x2b,0xb3 }, { 0x1b,0x67,0x25,0xba }, { 0x38,0x56,0x0f,0x85 }, { 0x35,0x5d,0x01,0x8c }, - { 0x22,0x40,0x13,0x97 }, { 0x2f,0x4b,0x1d,0x9e }, + { 0x22,0x40,0x13,0x97 }, { 0x2f,0x4b,0x1d,0x9e }, { 0x64,0x22,0x47,0xe9 }, { 0x69,0x29,0x49,0xe0 }, - { 0x7e,0x34,0x5b,0xfb }, { 0x73,0x3f,0x55,0xf2 }, + { 0x7e,0x34,0x5b,0xfb }, { 0x73,0x3f,0x55,0xf2 }, { 0x50,0x0e,0x7f,0xcd }, { 0x5d,0x05,0x71,0xc4 }, - { 0x4a,0x18,0x63,0xdf }, { 0x47,0x13,0x6d,0xd6 }, + { 0x4a,0x18,0x63,0xdf }, { 0x47,0x13,0x6d,0xd6 }, { 0xdc,0xca,0xd7,0x31 }, { 0xd1,0xc1,0xd9,0x38 }, - { 0xc6,0xdc,0xcb,0x23 }, { 0xcb,0xd7,0xc5,0x2a }, + { 0xc6,0xdc,0xcb,0x23 }, { 0xcb,0xd7,0xc5,0x2a }, { 0xe8,0xe6,0xef,0x15 }, { 0xe5,0xed,0xe1,0x1c }, - { 0xf2,0xf0,0xf3,0x07 }, { 0xff,0xfb,0xfd,0x0e }, + { 0xf2,0xf0,0xf3,0x07 }, { 0xff,0xfb,0xfd,0x0e }, { 0xb4,0x92,0xa7,0x79 }, { 0xb9,0x99,0xa9,0x70 }, - { 0xae,0x84,0xbb,0x6b }, { 0xa3,0x8f,0xb5,0x62 }, + { 0xae,0x84,0xbb,0x6b }, { 0xa3,0x8f,0xb5,0x62 }, { 0x80,0xbe,0x9f,0x5d }, { 0x8d,0xb5,0x91,0x54 }, { 0x9a,0xa8,0x83,0x4f }, { 0x97,0xa3,0x8d,0x46 } }; @@ -1549,139 +1549,138 @@ static const unsigned char U3[256][4] = static const unsigned char U4[256][4] = { { 0x00,0x00,0x00,0x00 }, { 0x09,0x0d,0x0b,0x0e }, - { 0x12,0x1a,0x16,0x1c }, { 0x1b,0x17,0x1d,0x12 }, + { 0x12,0x1a,0x16,0x1c }, { 0x1b,0x17,0x1d,0x12 }, { 0x24,0x34,0x2c,0x38 }, { 0x2d,0x39,0x27,0x36 }, - { 0x36,0x2e,0x3a,0x24 }, { 0x3f,0x23,0x31,0x2a }, + { 0x36,0x2e,0x3a,0x24 }, { 0x3f,0x23,0x31,0x2a }, { 0x48,0x68,0x58,0x70 }, { 0x41,0x65,0x53,0x7e }, - { 0x5a,0x72,0x4e,0x6c }, { 0x53,0x7f,0x45,0x62 }, + { 0x5a,0x72,0x4e,0x6c }, { 0x53,0x7f,0x45,0x62 }, { 0x6c,0x5c,0x74,0x48 }, { 0x65,0x51,0x7f,0x46 }, - { 0x7e,0x46,0x62,0x54 }, { 0x77,0x4b,0x69,0x5a }, + { 0x7e,0x46,0x62,0x54 }, { 0x77,0x4b,0x69,0x5a }, { 0x90,0xd0,0xb0,0xe0 }, { 0x99,0xdd,0xbb,0xee }, - { 0x82,0xca,0xa6,0xfc }, { 0x8b,0xc7,0xad,0xf2 }, + { 0x82,0xca,0xa6,0xfc }, { 0x8b,0xc7,0xad,0xf2 }, { 0xb4,0xe4,0x9c,0xd8 }, { 0xbd,0xe9,0x97,0xd6 }, - { 0xa6,0xfe,0x8a,0xc4 }, { 0xaf,0xf3,0x81,0xca }, + { 0xa6,0xfe,0x8a,0xc4 }, { 0xaf,0xf3,0x81,0xca }, { 0xd8,0xb8,0xe8,0x90 }, { 0xd1,0xb5,0xe3,0x9e }, - { 0xca,0xa2,0xfe,0x8c }, { 0xc3,0xaf,0xf5,0x82 }, + { 0xca,0xa2,0xfe,0x8c }, { 0xc3,0xaf,0xf5,0x82 }, { 0xfc,0x8c,0xc4,0xa8 }, { 0xf5,0x81,0xcf,0xa6 }, - { 0xee,0x96,0xd2,0xb4 }, { 0xe7,0x9b,0xd9,0xba }, + { 0xee,0x96,0xd2,0xb4 }, { 0xe7,0x9b,0xd9,0xba }, { 0x3b,0xbb,0x7b,0xdb }, { 0x32,0xb6,0x70,0xd5 }, - { 0x29,0xa1,0x6d,0xc7 }, { 0x20,0xac,0x66,0xc9 }, + { 0x29,0xa1,0x6d,0xc7 }, { 0x20,0xac,0x66,0xc9 }, { 0x1f,0x8f,0x57,0xe3 }, { 0x16,0x82,0x5c,0xed }, - { 0x0d,0x95,0x41,0xff }, { 0x04,0x98,0x4a,0xf1 }, + { 0x0d,0x95,0x41,0xff }, { 0x04,0x98,0x4a,0xf1 }, { 0x73,0xd3,0x23,0xab }, { 0x7a,0xde,0x28,0xa5 }, - { 0x61,0xc9,0x35,0xb7 }, { 0x68,0xc4,0x3e,0xb9 }, + { 0x61,0xc9,0x35,0xb7 }, { 0x68,0xc4,0x3e,0xb9 }, { 0x57,0xe7,0x0f,0x93 }, { 0x5e,0xea,0x04,0x9d }, - { 0x45,0xfd,0x19,0x8f }, { 0x4c,0xf0,0x12,0x81 }, + { 0x45,0xfd,0x19,0x8f }, { 0x4c,0xf0,0x12,0x81 }, { 0xab,0x6b,0xcb,0x3b }, { 0xa2,0x66,0xc0,0x35 }, - { 0xb9,0x71,0xdd,0x27 }, { 0xb0,0x7c,0xd6,0x29 }, + { 0xb9,0x71,0xdd,0x27 }, { 0xb0,0x7c,0xd6,0x29 }, { 0x8f,0x5f,0xe7,0x03 }, { 0x86,0x52,0xec,0x0d }, - { 0x9d,0x45,0xf1,0x1f }, { 0x94,0x48,0xfa,0x11 }, + { 0x9d,0x45,0xf1,0x1f }, { 0x94,0x48,0xfa,0x11 }, { 0xe3,0x03,0x93,0x4b }, { 0xea,0x0e,0x98,0x45 }, - { 0xf1,0x19,0x85,0x57 }, { 0xf8,0x14,0x8e,0x59 }, + { 0xf1,0x19,0x85,0x57 }, { 0xf8,0x14,0x8e,0x59 }, { 0xc7,0x37,0xbf,0x73 }, { 0xce,0x3a,0xb4,0x7d }, - { 0xd5,0x2d,0xa9,0x6f }, { 0xdc,0x20,0xa2,0x61 }, + { 0xd5,0x2d,0xa9,0x6f }, { 0xdc,0x20,0xa2,0x61 }, { 0x76,0x6d,0xf6,0xad }, { 0x7f,0x60,0xfd,0xa3 }, - { 0x64,0x77,0xe0,0xb1 }, { 0x6d,0x7a,0xeb,0xbf }, + { 0x64,0x77,0xe0,0xb1 }, { 0x6d,0x7a,0xeb,0xbf }, { 0x52,0x59,0xda,0x95 }, { 0x5b,0x54,0xd1,0x9b }, - { 0x40,0x43,0xcc,0x89 }, { 0x49,0x4e,0xc7,0x87 }, + { 0x40,0x43,0xcc,0x89 }, { 0x49,0x4e,0xc7,0x87 }, { 0x3e,0x05,0xae,0xdd }, { 0x37,0x08,0xa5,0xd3 }, - { 0x2c,0x1f,0xb8,0xc1 }, { 0x25,0x12,0xb3,0xcf }, + { 0x2c,0x1f,0xb8,0xc1 }, { 0x25,0x12,0xb3,0xcf }, { 0x1a,0x31,0x82,0xe5 }, { 0x13,0x3c,0x89,0xeb }, - { 0x08,0x2b,0x94,0xf9 }, { 0x01,0x26,0x9f,0xf7 }, + { 0x08,0x2b,0x94,0xf9 }, { 0x01,0x26,0x9f,0xf7 }, { 0xe6,0xbd,0x46,0x4d }, { 0xef,0xb0,0x4d,0x43 }, - { 0xf4,0xa7,0x50,0x51 }, { 0xfd,0xaa,0x5b,0x5f }, + { 0xf4,0xa7,0x50,0x51 }, { 0xfd,0xaa,0x5b,0x5f }, { 0xc2,0x89,0x6a,0x75 }, { 0xcb,0x84,0x61,0x7b }, - { 0xd0,0x93,0x7c,0x69 }, { 0xd9,0x9e,0x77,0x67 }, + { 0xd0,0x93,0x7c,0x69 }, { 0xd9,0x9e,0x77,0x67 }, { 0xae,0xd5,0x1e,0x3d }, { 0xa7,0xd8,0x15,0x33 }, - { 0xbc,0xcf,0x08,0x21 }, { 0xb5,0xc2,0x03,0x2f }, + { 0xbc,0xcf,0x08,0x21 }, { 0xb5,0xc2,0x03,0x2f }, { 0x8a,0xe1,0x32,0x05 }, { 0x83,0xec,0x39,0x0b }, - { 0x98,0xfb,0x24,0x19 }, { 0x91,0xf6,0x2f,0x17 }, + { 0x98,0xfb,0x24,0x19 }, { 0x91,0xf6,0x2f,0x17 }, { 0x4d,0xd6,0x8d,0x76 }, { 0x44,0xdb,0x86,0x78 }, - { 0x5f,0xcc,0x9b,0x6a }, { 0x56,0xc1,0x90,0x64 }, + { 0x5f,0xcc,0x9b,0x6a }, { 0x56,0xc1,0x90,0x64 }, { 0x69,0xe2,0xa1,0x4e }, { 0x60,0xef,0xaa,0x40 }, - { 0x7b,0xf8,0xb7,0x52 }, { 0x72,0xf5,0xbc,0x5c }, + { 0x7b,0xf8,0xb7,0x52 }, { 0x72,0xf5,0xbc,0x5c }, { 0x05,0xbe,0xd5,0x06 }, { 0x0c,0xb3,0xde,0x08 }, - { 0x17,0xa4,0xc3,0x1a }, { 0x1e,0xa9,0xc8,0x14 }, + { 0x17,0xa4,0xc3,0x1a }, { 0x1e,0xa9,0xc8,0x14 }, { 0x21,0x8a,0xf9,0x3e }, { 0x28,0x87,0xf2,0x30 }, - { 0x33,0x90,0xef,0x22 }, { 0x3a,0x9d,0xe4,0x2c }, + { 0x33,0x90,0xef,0x22 }, { 0x3a,0x9d,0xe4,0x2c }, { 0xdd,0x06,0x3d,0x96 }, { 0xd4,0x0b,0x36,0x98 }, - { 0xcf,0x1c,0x2b,0x8a }, { 0xc6,0x11,0x20,0x84 }, + { 0xcf,0x1c,0x2b,0x8a }, { 0xc6,0x11,0x20,0x84 }, { 0xf9,0x32,0x11,0xae }, { 0xf0,0x3f,0x1a,0xa0 }, - { 0xeb,0x28,0x07,0xb2 }, { 0xe2,0x25,0x0c,0xbc }, + { 0xeb,0x28,0x07,0xb2 }, { 0xe2,0x25,0x0c,0xbc }, { 0x95,0x6e,0x65,0xe6 }, { 0x9c,0x63,0x6e,0xe8 }, - { 0x87,0x74,0x73,0xfa }, { 0x8e,0x79,0x78,0xf4 }, + { 0x87,0x74,0x73,0xfa }, { 0x8e,0x79,0x78,0xf4 }, { 0xb1,0x5a,0x49,0xde }, { 0xb8,0x57,0x42,0xd0 }, - { 0xa3,0x40,0x5f,0xc2 }, { 0xaa,0x4d,0x54,0xcc }, + { 0xa3,0x40,0x5f,0xc2 }, { 0xaa,0x4d,0x54,0xcc }, { 0xec,0xda,0xf7,0x41 }, { 0xe5,0xd7,0xfc,0x4f }, - { 0xfe,0xc0,0xe1,0x5d }, { 0xf7,0xcd,0xea,0x53 }, + { 0xfe,0xc0,0xe1,0x5d }, { 0xf7,0xcd,0xea,0x53 }, { 0xc8,0xee,0xdb,0x79 }, { 0xc1,0xe3,0xd0,0x77 }, - { 0xda,0xf4,0xcd,0x65 }, { 0xd3,0xf9,0xc6,0x6b }, + { 0xda,0xf4,0xcd,0x65 }, { 0xd3,0xf9,0xc6,0x6b }, { 0xa4,0xb2,0xaf,0x31 }, { 0xad,0xbf,0xa4,0x3f }, - { 0xb6,0xa8,0xb9,0x2d }, { 0xbf,0xa5,0xb2,0x23 }, + { 0xb6,0xa8,0xb9,0x2d }, { 0xbf,0xa5,0xb2,0x23 }, { 0x80,0x86,0x83,0x09 }, { 0x89,0x8b,0x88,0x07 }, - { 0x92,0x9c,0x95,0x15 }, { 0x9b,0x91,0x9e,0x1b }, + { 0x92,0x9c,0x95,0x15 }, { 0x9b,0x91,0x9e,0x1b }, { 0x7c,0x0a,0x47,0xa1 }, { 0x75,0x07,0x4c,0xaf }, - { 0x6e,0x10,0x51,0xbd }, { 0x67,0x1d,0x5a,0xb3 }, + { 0x6e,0x10,0x51,0xbd }, { 0x67,0x1d,0x5a,0xb3 }, { 0x58,0x3e,0x6b,0x99 }, { 0x51,0x33,0x60,0x97 }, - { 0x4a,0x24,0x7d,0x85 }, { 0x43,0x29,0x76,0x8b }, + { 0x4a,0x24,0x7d,0x85 }, { 0x43,0x29,0x76,0x8b }, { 0x34,0x62,0x1f,0xd1 }, { 0x3d,0x6f,0x14,0xdf }, - { 0x26,0x78,0x09,0xcd }, { 0x2f,0x75,0x02,0xc3 }, + { 0x26,0x78,0x09,0xcd }, { 0x2f,0x75,0x02,0xc3 }, { 0x10,0x56,0x33,0xe9 }, { 0x19,0x5b,0x38,0xe7 }, - { 0x02,0x4c,0x25,0xf5 }, { 0x0b,0x41,0x2e,0xfb }, + { 0x02,0x4c,0x25,0xf5 }, { 0x0b,0x41,0x2e,0xfb }, { 0xd7,0x61,0x8c,0x9a }, { 0xde,0x6c,0x87,0x94 }, - { 0xc5,0x7b,0x9a,0x86 }, { 0xcc,0x76,0x91,0x88 }, + { 0xc5,0x7b,0x9a,0x86 }, { 0xcc,0x76,0x91,0x88 }, { 0xf3,0x55,0xa0,0xa2 }, { 0xfa,0x58,0xab,0xac }, - { 0xe1,0x4f,0xb6,0xbe }, { 0xe8,0x42,0xbd,0xb0 }, + { 0xe1,0x4f,0xb6,0xbe }, { 0xe8,0x42,0xbd,0xb0 }, { 0x9f,0x09,0xd4,0xea }, { 0x96,0x04,0xdf,0xe4 }, - { 0x8d,0x13,0xc2,0xf6 }, { 0x84,0x1e,0xc9,0xf8 }, + { 0x8d,0x13,0xc2,0xf6 }, { 0x84,0x1e,0xc9,0xf8 }, { 0xbb,0x3d,0xf8,0xd2 }, { 0xb2,0x30,0xf3,0xdc }, - { 0xa9,0x27,0xee,0xce }, { 0xa0,0x2a,0xe5,0xc0 }, + { 0xa9,0x27,0xee,0xce }, { 0xa0,0x2a,0xe5,0xc0 }, { 0x47,0xb1,0x3c,0x7a }, { 0x4e,0xbc,0x37,0x74 }, - { 0x55,0xab,0x2a,0x66 }, { 0x5c,0xa6,0x21,0x68 }, + { 0x55,0xab,0x2a,0x66 }, { 0x5c,0xa6,0x21,0x68 }, { 0x63,0x85,0x10,0x42 }, { 0x6a,0x88,0x1b,0x4c }, - { 0x71,0x9f,0x06,0x5e }, { 0x78,0x92,0x0d,0x50 }, + { 0x71,0x9f,0x06,0x5e }, { 0x78,0x92,0x0d,0x50 }, { 0x0f,0xd9,0x64,0x0a }, { 0x06,0xd4,0x6f,0x04 }, - { 0x1d,0xc3,0x72,0x16 }, { 0x14,0xce,0x79,0x18 }, + { 0x1d,0xc3,0x72,0x16 }, { 0x14,0xce,0x79,0x18 }, { 0x2b,0xed,0x48,0x32 }, { 0x22,0xe0,0x43,0x3c }, - { 0x39,0xf7,0x5e,0x2e }, { 0x30,0xfa,0x55,0x20 }, - { 0x9a,0xb7,0x01,0xec }, { 0x93,0xba,0x0a,0xe2 }, - { 0x88,0xad,0x17,0xf0 }, { 0x81,0xa0,0x1c,0xfe }, + { 0x39,0xf7,0x5e,0x2e }, { 0x30,0xfa,0x55,0x20 }, + { 0x9a,0xb7,0x01,0xec }, { 0x93,0xba,0x0a,0xe2 }, + { 0x88,0xad,0x17,0xf0 }, { 0x81,0xa0,0x1c,0xfe }, { 0xbe,0x83,0x2d,0xd4 }, { 0xb7,0x8e,0x26,0xda }, - { 0xac,0x99,0x3b,0xc8 }, { 0xa5,0x94,0x30,0xc6 }, - { 0xd2,0xdf,0x59,0x9c }, { 0xdb,0xd2,0x52,0x92 }, - { 0xc0,0xc5,0x4f,0x80 }, { 0xc9,0xc8,0x44,0x8e }, + { 0xac,0x99,0x3b,0xc8 }, { 0xa5,0x94,0x30,0xc6 }, + { 0xd2,0xdf,0x59,0x9c }, { 0xdb,0xd2,0x52,0x92 }, + { 0xc0,0xc5,0x4f,0x80 }, { 0xc9,0xc8,0x44,0x8e }, { 0xf6,0xeb,0x75,0xa4 }, { 0xff,0xe6,0x7e,0xaa }, - { 0xe4,0xf1,0x63,0xb8 }, { 0xed,0xfc,0x68,0xb6 }, + { 0xe4,0xf1,0x63,0xb8 }, { 0xed,0xfc,0x68,0xb6 }, { 0x0a,0x67,0xb1,0x0c }, { 0x03,0x6a,0xba,0x02 }, - { 0x18,0x7d,0xa7,0x10 }, { 0x11,0x70,0xac,0x1e }, + { 0x18,0x7d,0xa7,0x10 }, { 0x11,0x70,0xac,0x1e }, { 0x2e,0x53,0x9d,0x34 }, { 0x27,0x5e,0x96,0x3a }, - { 0x3c,0x49,0x8b,0x28 }, { 0x35,0x44,0x80,0x26 }, - { 0x42,0x0f,0xe9,0x7c }, { 0x4b,0x02,0xe2,0x72 }, - { 0x50,0x15,0xff,0x60 }, { 0x59,0x18,0xf4,0x6e }, + { 0x3c,0x49,0x8b,0x28 }, { 0x35,0x44,0x80,0x26 }, + { 0x42,0x0f,0xe9,0x7c }, { 0x4b,0x02,0xe2,0x72 }, + { 0x50,0x15,0xff,0x60 }, { 0x59,0x18,0xf4,0x6e }, { 0x66,0x3b,0xc5,0x44 }, { 0x6f,0x36,0xce,0x4a }, - { 0x74,0x21,0xd3,0x58 }, { 0x7d,0x2c,0xd8,0x56 }, + { 0x74,0x21,0xd3,0x58 }, { 0x7d,0x2c,0xd8,0x56 }, { 0xa1,0x0c,0x7a,0x37 }, { 0xa8,0x01,0x71,0x39 }, - { 0xb3,0x16,0x6c,0x2b }, { 0xba,0x1b,0x67,0x25 }, + { 0xb3,0x16,0x6c,0x2b }, { 0xba,0x1b,0x67,0x25 }, { 0x85,0x38,0x56,0x0f }, { 0x8c,0x35,0x5d,0x01 }, - { 0x97,0x22,0x40,0x13 }, { 0x9e,0x2f,0x4b,0x1d }, - { 0xe9,0x64,0x22,0x47 }, { 0xe0,0x69,0x29,0x49 }, - { 0xfb,0x7e,0x34,0x5b }, { 0xf2,0x73,0x3f,0x55 }, + { 0x97,0x22,0x40,0x13 }, { 0x9e,0x2f,0x4b,0x1d }, + { 0xe9,0x64,0x22,0x47 }, { 0xe0,0x69,0x29,0x49 }, + { 0xfb,0x7e,0x34,0x5b }, { 0xf2,0x73,0x3f,0x55 }, { 0xcd,0x50,0x0e,0x7f }, { 0xc4,0x5d,0x05,0x71 }, - { 0xdf,0x4a,0x18,0x63 }, { 0xd6,0x47,0x13,0x6d }, + { 0xdf,0x4a,0x18,0x63 }, { 0xd6,0x47,0x13,0x6d }, { 0x31,0xdc,0xca,0xd7 }, { 0x38,0xd1,0xc1,0xd9 }, - { 0x23,0xc6,0xdc,0xcb }, { 0x2a,0xcb,0xd7,0xc5 }, + { 0x23,0xc6,0xdc,0xcb }, { 0x2a,0xcb,0xd7,0xc5 }, { 0x15,0xe8,0xe6,0xef }, { 0x1c,0xe5,0xed,0xe1 }, - { 0x07,0xf2,0xf0,0xf3 }, { 0x0e,0xff,0xfb,0xfd }, + { 0x07,0xf2,0xf0,0xf3 }, { 0x0e,0xff,0xfb,0xfd }, { 0x79,0xb4,0x92,0xa7 }, { 0x70,0xb9,0x99,0xa9 }, - { 0x6b,0xae,0x84,0xbb }, { 0x62,0xa3,0x8f,0xb5 }, + { 0x6b,0xae,0x84,0xbb }, { 0x62,0xa3,0x8f,0xb5 }, { 0x5d,0x80,0xbe,0x9f }, { 0x54,0x8d,0xb5,0x91 }, { 0x4f,0x9a,0xa8,0x83 }, { 0x46,0x97,0xa3,0x8d } }; -static const u32 rcon[30] = - { +static const u32 rcon[30] = + { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91 }; - diff --git a/cipher/rijndael.c b/cipher/rijndael.c index d43b349b..08707b6d 100644 --- a/cipher/rijndael.c +++ b/cipher/rijndael.c @@ -62,7 +62,7 @@ static const char *selftest(void); -typedef struct +typedef struct { int ROUNDS; /* Key-length-dependent number of rounds. */ int decryption_prepared; /* The decryption key schedule is available. */ @@ -79,7 +79,7 @@ typedef struct union { PROPERLY_ALIGNED_TYPE dummy; - byte keyschedule[MAXROUNDS+1][4][4]; + byte keyschedule[MAXROUNDS+1][4][4]; } u2; } RIJNDAEL_context; @@ -90,7 +90,7 @@ typedef struct #include "rijndael-tables.h" -/* Perform the key setup. */ +/* Perform the key setup. */ static gcry_err_code_t do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) { @@ -110,12 +110,12 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) PROPERLY_ALIGNED_TYPE dummy; byte tk[MAXKC][4]; } tk; -#define tk tk.tk +#define tk tk.tk /* The on-the-fly self tests are only run in non-fips mode. In fips mode explicit self-tests are required. Actually the on-the-fly self-tests are not fully thread-safe and it might happen that a - failed self-test won't get noticed in another thread. + failed self-test won't get noticed in another thread. FIXME: We might want to have a central registry of succeeded self-tests. */ @@ -171,12 +171,12 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) #endif /*USE_PADLOCK*/ { #define W (ctx->keySched) - for (i = 0; i < keylen; i++) + for (i = 0; i < keylen; i++) { - k[i >> 2][i & 3] = key[i]; + k[i >> 2][i & 3] = key[i]; } - - for (j = KC-1; j >= 0; j--) + + for (j = KC-1; j >= 0; j--) { *((u32*)tk[j]) = *((u32*)k[j]); } @@ -195,7 +195,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) t = 0; } } - + while (r < ROUNDS + 1) { /* While not enough round key material calculated calculate @@ -205,15 +205,15 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) tk[0][2] ^= S[tk[KC-1][3]]; tk[0][3] ^= S[tk[KC-1][0]]; tk[0][0] ^= rcon[rconpointer++]; - + if (KC != 8) { - for (j = 1; j < KC; j++) + for (j = 1; j < KC; j++) { *((u32*)tk[j]) ^= *((u32*)tk[j-1]); } - } - else + } + else { for (j = 1; j < KC/2; j++) { @@ -228,7 +228,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) *((u32*)tk[j]) ^= *((u32*)tk[j-1]); } } - + /* Copy values into round key array. */ for (j = 0; (j < KC) && (r < ROUNDS + 1); ) { @@ -242,8 +242,8 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) t = 0; } } - } -#undef W + } +#undef W } return 0; @@ -288,29 +288,29 @@ prepare_decryption( RIJNDAEL_context *ctx ) w = W[r][0]; *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]]) ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]); - + w = W[r][1]; *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]]) ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]); - + w = W[r][2]; *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]]) ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]); - + w = W[r][3]; *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]]) ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]); } #undef W #undef w -} +} /* Encrypt one block. A and B need to be aligned on a 4 byte boundary. A and B may be the same. */ static void -do_encrypt_aligned (const RIJNDAEL_context *ctx, +do_encrypt_aligned (const RIJNDAEL_context *ctx, unsigned char *b, const unsigned char *a) { #define rk (ctx->keySched) @@ -328,19 +328,19 @@ do_encrypt_aligned (const RIJNDAEL_context *ctx, *((u32*)u.temp[3]) = *((u32*)(a+12)) ^ *((u32*)rk[0][3]); *((u32*)(b )) = (*((u32*)T1[u.temp[0][0]]) ^ *((u32*)T2[u.temp[1][1]]) - ^ *((u32*)T3[u.temp[2][2]]) + ^ *((u32*)T3[u.temp[2][2]]) ^ *((u32*)T4[u.temp[3][3]])); *((u32*)(b + 4)) = (*((u32*)T1[u.temp[1][0]]) ^ *((u32*)T2[u.temp[2][1]]) - ^ *((u32*)T3[u.temp[3][2]]) + ^ *((u32*)T3[u.temp[3][2]]) ^ *((u32*)T4[u.temp[0][3]])); *((u32*)(b + 8)) = (*((u32*)T1[u.temp[2][0]]) ^ *((u32*)T2[u.temp[3][1]]) - ^ *((u32*)T3[u.temp[0][2]]) + ^ *((u32*)T3[u.temp[0][2]]) ^ *((u32*)T4[u.temp[1][3]])); *((u32*)(b +12)) = (*((u32*)T1[u.temp[3][0]]) ^ *((u32*)T2[u.temp[0][1]]) - ^ *((u32*)T3[u.temp[1][2]]) + ^ *((u32*)T3[u.temp[1][2]]) ^ *((u32*)T4[u.temp[2][3]])); for (r = 1; r < ROUNDS-1; r++) @@ -352,23 +352,23 @@ do_encrypt_aligned (const RIJNDAEL_context *ctx, *((u32*)(b )) = (*((u32*)T1[u.temp[0][0]]) ^ *((u32*)T2[u.temp[1][1]]) - ^ *((u32*)T3[u.temp[2][2]]) + ^ *((u32*)T3[u.temp[2][2]]) ^ *((u32*)T4[u.temp[3][3]])); *((u32*)(b + 4)) = (*((u32*)T1[u.temp[1][0]]) ^ *((u32*)T2[u.temp[2][1]]) - ^ *((u32*)T3[u.temp[3][2]]) + ^ *((u32*)T3[u.temp[3][2]]) ^ *((u32*)T4[u.temp[0][3]])); *((u32*)(b + 8)) = (*((u32*)T1[u.temp[2][0]]) ^ *((u32*)T2[u.temp[3][1]]) - ^ *((u32*)T3[u.temp[0][2]]) + ^ *((u32*)T3[u.temp[0][2]]) ^ *((u32*)T4[u.temp[1][3]])); *((u32*)(b +12)) = (*((u32*)T1[u.temp[3][0]]) ^ *((u32*)T2[u.temp[0][1]]) - ^ *((u32*)T3[u.temp[1][2]]) + ^ *((u32*)T3[u.temp[1][2]]) ^ *((u32*)T4[u.temp[2][3]])); } - /* Last round is special. */ + /* Last round is special. */ *((u32*)u.temp[0]) = *((u32*)(b )) ^ *((u32*)rk[ROUNDS-1][0]); *((u32*)u.temp[1]) = *((u32*)(b+ 4)) ^ *((u32*)rk[ROUNDS-1][1]); *((u32*)u.temp[2]) = *((u32*)(b+ 8)) ^ *((u32*)rk[ROUNDS-1][2]); @@ -405,12 +405,12 @@ do_encrypt (const RIJNDAEL_context *ctx, copy them here. */ union { - u32 dummy[4]; + u32 dummy[4]; byte a[16]; } a; union { - u32 dummy[4]; + u32 dummy[4]; byte b[16]; } b; @@ -444,9 +444,9 @@ do_padlock (const RIJNDAEL_context *ctx, int decrypt_flag, cword[0] |= 0x00000200; memcpy (a, ax, 16); - - asm volatile - ("pushfl\n\t" /* Force key reload. */ + + asm volatile + ("pushfl\n\t" /* Force key reload. */ "popfl\n\t" "xchg %3, %%ebx\n\t" /* Load key. */ "movl $1, %%ecx\n\t" /* Init counter for just one block. */ @@ -488,7 +488,7 @@ rijndael_encrypt (void *context, byte *b, const byte *a) function is only intended for the bulk encryption feature of cipher.c. */ void -_gcry_aes_cfb_enc (void *context, unsigned char *iv, +_gcry_aes_cfb_enc (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks) { @@ -533,7 +533,7 @@ _gcry_aes_cfb_enc (void *context, unsigned char *iv, function is only intended for the bulk encryption feature of cipher.c. */ void -_gcry_aes_cbc_enc (void *context, unsigned char *iv, +_gcry_aes_cbc_enc (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks, int cbc_mac) { @@ -570,13 +570,13 @@ _gcry_aes_cbc_enc (void *context, unsigned char *iv, and the decryption must have been prepared. A and B may be the same. */ static void -do_decrypt_aligned (RIJNDAEL_context *ctx, +do_decrypt_aligned (RIJNDAEL_context *ctx, unsigned char *b, const unsigned char *a) { #define rk (ctx->keySched2) - int ROUNDS = ctx->ROUNDS; + int ROUNDS = ctx->ROUNDS; int r; - union + union { u32 tempu32[4]; /* Force correct alignment. */ byte temp[4][4]; @@ -587,22 +587,22 @@ do_decrypt_aligned (RIJNDAEL_context *ctx, *((u32*)u.temp[1]) = *((u32*)(a+ 4)) ^ *((u32*)rk[ROUNDS][1]); *((u32*)u.temp[2]) = *((u32*)(a+ 8)) ^ *((u32*)rk[ROUNDS][2]); *((u32*)u.temp[3]) = *((u32*)(a+12)) ^ *((u32*)rk[ROUNDS][3]); - + *((u32*)(b )) = (*((u32*)T5[u.temp[0][0]]) ^ *((u32*)T6[u.temp[3][1]]) - ^ *((u32*)T7[u.temp[2][2]]) + ^ *((u32*)T7[u.temp[2][2]]) ^ *((u32*)T8[u.temp[1][3]])); *((u32*)(b+ 4)) = (*((u32*)T5[u.temp[1][0]]) ^ *((u32*)T6[u.temp[0][1]]) - ^ *((u32*)T7[u.temp[3][2]]) + ^ *((u32*)T7[u.temp[3][2]]) ^ *((u32*)T8[u.temp[2][3]])); *((u32*)(b+ 8)) = (*((u32*)T5[u.temp[2][0]]) ^ *((u32*)T6[u.temp[1][1]]) - ^ *((u32*)T7[u.temp[0][2]]) + ^ *((u32*)T7[u.temp[0][2]]) ^ *((u32*)T8[u.temp[3][3]])); *((u32*)(b+12)) = (*((u32*)T5[u.temp[3][0]]) ^ *((u32*)T6[u.temp[2][1]]) - ^ *((u32*)T7[u.temp[1][2]]) + ^ *((u32*)T7[u.temp[1][2]]) ^ *((u32*)T8[u.temp[0][3]])); for (r = ROUNDS-1; r > 1; r--) @@ -613,23 +613,23 @@ do_decrypt_aligned (RIJNDAEL_context *ctx, *((u32*)u.temp[3]) = *((u32*)(b+12)) ^ *((u32*)rk[r][3]); *((u32*)(b )) = (*((u32*)T5[u.temp[0][0]]) ^ *((u32*)T6[u.temp[3][1]]) - ^ *((u32*)T7[u.temp[2][2]]) + ^ *((u32*)T7[u.temp[2][2]]) ^ *((u32*)T8[u.temp[1][3]])); *((u32*)(b+ 4)) = (*((u32*)T5[u.temp[1][0]]) ^ *((u32*)T6[u.temp[0][1]]) - ^ *((u32*)T7[u.temp[3][2]]) + ^ *((u32*)T7[u.temp[3][2]]) ^ *((u32*)T8[u.temp[2][3]])); *((u32*)(b+ 8)) = (*((u32*)T5[u.temp[2][0]]) ^ *((u32*)T6[u.temp[1][1]]) - ^ *((u32*)T7[u.temp[0][2]]) + ^ *((u32*)T7[u.temp[0][2]]) ^ *((u32*)T8[u.temp[3][3]])); *((u32*)(b+12)) = (*((u32*)T5[u.temp[3][0]]) ^ *((u32*)T6[u.temp[2][1]]) - ^ *((u32*)T7[u.temp[1][2]]) + ^ *((u32*)T7[u.temp[1][2]]) ^ *((u32*)T8[u.temp[0][3]])); } - /* Last round is special. */ + /* Last round is special. */ *((u32*)u.temp[0]) = *((u32*)(b )) ^ *((u32*)rk[1][0]); *((u32*)u.temp[1]) = *((u32*)(b+ 4)) ^ *((u32*)rk[1][1]); *((u32*)u.temp[2]) = *((u32*)(b+ 8)) ^ *((u32*)rk[1][2]); @@ -666,12 +666,12 @@ do_decrypt (RIJNDAEL_context *ctx, byte *bx, const byte *ax) copy them here. */ union { - u32 dummy[4]; + u32 dummy[4]; byte a[16]; } a; union { - u32 dummy[4]; + u32 dummy[4]; byte b[16]; } b; @@ -687,7 +687,7 @@ do_decrypt (RIJNDAEL_context *ctx, byte *bx, const byte *ax) memcpy (bx, b.b, 16); #undef rk } - + @@ -716,7 +716,7 @@ rijndael_decrypt (void *context, byte *b, const byte *a) function is only intended for the bulk encryption feature of cipher.c. */ void -_gcry_aes_cfb_dec (void *context, unsigned char *iv, +_gcry_aes_cfb_dec (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks) { @@ -766,7 +766,7 @@ _gcry_aes_cfb_dec (void *context, unsigned char *iv, function is only intended for the bulk encryption feature of cipher.c. */ void -_gcry_aes_cbc_dec (void *context, unsigned char *iv, +_gcry_aes_cbc_dec (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks) { @@ -808,11 +808,11 @@ static const char* selftest_basic_128 (void) { RIJNDAEL_context ctx; - unsigned char scratch[16]; + unsigned char scratch[16]; /* The test vectors are from the AES supplied ones; more or less randomly taken from ecb_tbl.txt (I=42,81,14) */ - static const unsigned char plaintext_128[16] = + static const unsigned char plaintext_128[16] = { 0x01,0x4B,0xAF,0x22,0x78,0xA6,0x9D,0x33, 0x1D,0x51,0x80,0x10,0x36,0x43,0xE9,0x9A @@ -827,7 +827,7 @@ selftest_basic_128 (void) 0x67,0x43,0xC3,0xD1,0x51,0x9A,0xB4,0xF2, 0xCD,0x9A,0x78,0xAB,0x09,0xA5,0x11,0xBD }; - + rijndael_setkey (&ctx, key_128, sizeof (key_128)); rijndael_encrypt (&ctx, scratch, plaintext_128); if (memcmp (scratch, ciphertext_128, sizeof (ciphertext_128))) @@ -835,7 +835,7 @@ selftest_basic_128 (void) rijndael_decrypt (&ctx, scratch, scratch); if (memcmp (scratch, plaintext_128, sizeof (plaintext_128))) return "AES-128 test decryption failed."; - + return NULL; } @@ -844,14 +844,14 @@ static const char* selftest_basic_192 (void) { RIJNDAEL_context ctx; - unsigned char scratch[16]; - - static unsigned char plaintext_192[16] = + unsigned char scratch[16]; + + static unsigned char plaintext_192[16] = { 0x76,0x77,0x74,0x75,0xF1,0xF2,0xF3,0xF4, 0xF8,0xF9,0xE6,0xE7,0x77,0x70,0x71,0x72 }; - static unsigned char key_192[24] = + static unsigned char key_192[24] = { 0x04,0x05,0x06,0x07,0x09,0x0A,0x0B,0x0C, 0x0E,0x0F,0x10,0x11,0x13,0x14,0x15,0x16, @@ -862,7 +862,7 @@ selftest_basic_192 (void) 0x5D,0x1E,0xF2,0x0D,0xCE,0xD6,0xBC,0xBC, 0x12,0x13,0x1A,0xC7,0xC5,0x47,0x88,0xAA }; - + rijndael_setkey (&ctx, key_192, sizeof(key_192)); rijndael_encrypt (&ctx, scratch, plaintext_192); if (memcmp (scratch, ciphertext_192, sizeof (ciphertext_192))) @@ -870,7 +870,7 @@ selftest_basic_192 (void) rijndael_decrypt (&ctx, scratch, scratch); if (memcmp (scratch, plaintext_192, sizeof (plaintext_192))) return "AES-192 test decryption failed."; - + return NULL; } @@ -880,21 +880,21 @@ static const char* selftest_basic_256 (void) { RIJNDAEL_context ctx; - unsigned char scratch[16]; + unsigned char scratch[16]; - static unsigned char plaintext_256[16] = + static unsigned char plaintext_256[16] = { 0x06,0x9A,0x00,0x7F,0xC7,0x6A,0x45,0x9F, 0x98,0xBA,0xF9,0x17,0xFE,0xDF,0x95,0x21 }; - static unsigned char key_256[32] = + static unsigned char key_256[32] = { 0x08,0x09,0x0A,0x0B,0x0D,0x0E,0x0F,0x10, 0x12,0x13,0x14,0x15,0x17,0x18,0x19,0x1A, 0x1C,0x1D,0x1E,0x1F,0x21,0x22,0x23,0x24, 0x26,0x27,0x28,0x29,0x2B,0x2C,0x2D,0x2E }; - static const unsigned char ciphertext_256[16] = + static const unsigned char ciphertext_256[16] = { 0x08,0x0E,0x95,0x17,0xEB,0x16,0x77,0x71, 0x9A,0xCF,0x72,0x80,0x86,0x04,0x0A,0xE3 @@ -907,7 +907,7 @@ selftest_basic_256 (void) rijndael_decrypt (&ctx, scratch, scratch); if (memcmp (scratch, plaintext_256, sizeof (plaintext_256))) return "AES-256 test decryption failed."; - + return NULL; } @@ -936,7 +936,7 @@ selftest_fips_128_38a (int requested_mode) int mode; const unsigned char key[16]; const unsigned char iv[16]; - struct + struct { const unsigned char input[16]; const unsigned char output[16]; @@ -947,24 +947,24 @@ selftest_fips_128_38a (int requested_mode) GCRY_CIPHER_MODE_CFB, /* F.3.13, CFB128-AES128 */ { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { { { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a }, { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a } }, - + { { 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51 }, { 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f, 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b } }, - - { { 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + + { { 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef }, { 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40, 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf } }, - + { { 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, { 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e, @@ -975,7 +975,7 @@ selftest_fips_128_38a (int requested_mode) GCRY_CIPHER_MODE_OFB, { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { { { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, @@ -987,7 +987,7 @@ selftest_fips_128_38a (int requested_mode) 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51 }, { 0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03, 0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25 } }, - + { { 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef }, { 0x97, 0x40, 0x05, 0x1e, 0x9c, 0x5f, 0xec, 0xf6, @@ -1057,7 +1057,7 @@ selftest_fips_128_38a (int requested_mode) #undef Fail _gcry_cipher_close (hdenc); - _gcry_cipher_close (hddec); + _gcry_cipher_close (hddec); return NULL; } @@ -1068,7 +1068,7 @@ selftest_fips_128 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + what = "low-level"; errtxt = selftest_basic_128 (); if (errtxt) @@ -1080,7 +1080,7 @@ selftest_fips_128 (int extended, selftest_report_func_t report) errtxt = selftest_fips_128_38a (GCRY_CIPHER_MODE_CFB); if (errtxt) goto failed; - + what = "ofb"; errtxt = selftest_fips_128_38a (GCRY_CIPHER_MODE_OFB); if (errtxt) @@ -1125,7 +1125,7 @@ selftest_fips_256 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + (void)extended; /* No extended tests available. */ what = "low-level"; @@ -1163,7 +1163,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_CIPHER_ALGO; break; - + } return ec; } @@ -1193,7 +1193,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes = "AES", rijndael_names, rijndael_oids, 16, 128, sizeof (RIJNDAEL_context), rijndael_setkey, rijndael_encrypt, rijndael_decrypt }; -cipher_extra_spec_t _gcry_cipher_extraspec_aes = +cipher_extra_spec_t _gcry_cipher_extraspec_aes = { run_selftests }; @@ -1219,7 +1219,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes192 = "AES192", rijndael192_names, rijndael192_oids, 16, 192, sizeof (RIJNDAEL_context), rijndael_setkey, rijndael_encrypt, rijndael_decrypt }; -cipher_extra_spec_t _gcry_cipher_extraspec_aes192 = +cipher_extra_spec_t _gcry_cipher_extraspec_aes192 = { run_selftests }; @@ -1247,7 +1247,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes256 = rijndael_setkey, rijndael_encrypt, rijndael_decrypt }; -cipher_extra_spec_t _gcry_cipher_extraspec_aes256 = +cipher_extra_spec_t _gcry_cipher_extraspec_aes256 = { run_selftests }; diff --git a/cipher/rmd.h b/cipher/rmd.h index f4ce9c67..6a9fe313 100644 --- a/cipher/rmd.h +++ b/cipher/rmd.h @@ -22,7 +22,7 @@ /* We need this here because random.c must have direct access. */ -typedef struct +typedef struct { u32 h0,h1,h2,h3,h4; u32 nblocks; @@ -34,4 +34,3 @@ void _gcry_rmd160_init ( void *context ); void _gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte ); #endif /*G10_RMD_H*/ - diff --git a/cipher/rmd160.c b/cipher/rmd160.c index 3fdc41cc..552cff92 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -414,7 +414,7 @@ rmd160_write ( void *context, const void *inbuf_arg, size_t inlen) } if( !inbuf ) return; - if( hd->count ) + if( hd->count ) { for( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; @@ -467,7 +467,7 @@ rmd160_final( void *context ) RMD160_CONTEXT *hd = context; u32 t, msb, lsb; byte *p; - + rmd160_write(hd, NULL, 0); /* flush */; t = hd->nblocks; diff --git a/cipher/rsa.c b/cipher/rsa.c index 6102cc40..1973280e 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -72,7 +72,7 @@ static const char sample_secret_key[] = " (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891e" " ebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)))"; /* A sample 1024 bit RSA key used for the selftests (public only). */ -static const char sample_public_key[] = +static const char sample_public_key[] = "(public-key" " (rsa" " (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa" @@ -127,7 +127,7 @@ test_keys (RSA_secret_key *sk, unsigned int nbits) /* Use the RSA secret function to create a signature of the plaintext. */ secret (signature, plaintext, sk); - + /* Use the RSA public function to verify this signature. */ public (decr_plaintext, signature, &pk); if (gcry_mpi_cmp (decr_plaintext, plaintext)) @@ -158,7 +158,7 @@ check_exponent (void *arg, gcry_mpi_t a) gcry_mpi_t e = arg; gcry_mpi_t tmp; int result; - + mpi_sub_ui (a, a, 1); tmp = _gcry_mpi_alloc_like (a); result = !gcry_mpi_gcd(tmp, e, a); /* GCD is not 1. */ @@ -168,12 +168,12 @@ check_exponent (void *arg, gcry_mpi_t a) } /**************** - * Generate a key pair with a key of size NBITS. + * Generate a key pair with a key of size NBITS. * USE_E = 0 let Libcgrypt decide what exponent to use. - * = 1 request the use of a "secure" exponent; this is required by some + * = 1 request the use of a "secure" exponent; this is required by some * specification to be 65537. * > 2 Use this public exponent. If the given exponent - * is not odd one is internally added to it. + * is not odd one is internally added to it. * TRANSIENT_KEY: If true, generate the primes using the standard RNG. * Returns: 2 structures filled with all needed values */ @@ -205,7 +205,7 @@ generate_std (RSA_secret_key *sk, unsigned int nbits, unsigned long use_e, /* Make sure that nbits is even so that we generate p, q of equal size. */ if ( (nbits&1) ) - nbits++; + nbits++; if (use_e == 1) /* Alias for a secure value */ use_e = 65537; /* as demanded by Sphinx. */ @@ -213,7 +213,7 @@ generate_std (RSA_secret_key *sk, unsigned int nbits, unsigned long use_e, /* Public exponent: In general we use 41 as this is quite fast and more secure than the commonly used 17. Benchmarking the RSA verify function - with a 1024 bit key yields (2001-11-08): + with a 1024 bit key yields (2001-11-08): e=17 0.54 ms e=41 0.75 ms e=257 0.95 ms @@ -222,12 +222,12 @@ generate_std (RSA_secret_key *sk, unsigned int nbits, unsigned long use_e, e = mpi_alloc( (32+BITS_PER_MPI_LIMB-1)/BITS_PER_MPI_LIMB ); if (!use_e) mpi_set_ui (e, 41); /* This is a reasonable secure and fast value */ - else + else { use_e |= 1; /* make sure this is odd */ - mpi_set_ui (e, use_e); + mpi_set_ui (e, use_e); } - + n = gcry_mpi_new (nbits); p = q = NULL; @@ -329,14 +329,14 @@ generate_std (RSA_secret_key *sk, unsigned int nbits, unsigned long use_e, /* Helper for generate_x931. */ -static gcry_mpi_t +static gcry_mpi_t gen_x931_parm_xp (unsigned int nbits) { gcry_mpi_t xp; xp = gcry_mpi_snew (nbits); gcry_mpi_randomize (xp, nbits, GCRY_VERY_STRONG_RANDOM); - + /* The requirement for Xp is: sqrt{2}*2^{nbits-1} <= xp <= 2^{nbits} - 1 @@ -347,13 +347,13 @@ gen_x931_parm_xp (unsigned int nbits) mpi_set_highbit (xp, nbits-1); mpi_set_bit (xp, nbits-2); gcry_assert ( mpi_get_nbits (xp) == nbits ); - + return xp; -} +} /* Helper for generate_x931. */ -static gcry_mpi_t +static gcry_mpi_t gen_x931_parm_xi (void) { gcry_mpi_t xi; @@ -362,9 +362,9 @@ gen_x931_parm_xi (void) gcry_mpi_randomize (xi, 101, GCRY_VERY_STRONG_RANDOM); mpi_set_highbit (xi, 100); gcry_assert ( mpi_get_nbits (xi) == 101 ); - + return xi; -} +} @@ -389,19 +389,19 @@ generate_x931 (RSA_secret_key *sk, unsigned int nbits, unsigned long e_value, *swapped = 0; if (e_value == 1) /* Alias for a secure value. */ - e_value = 65537; + e_value = 65537; /* Point 1 of section 4.1: k = 1024 + 256s with S >= 0 */ if (nbits < 1024 || (nbits % 256)) return GPG_ERR_INV_VALUE; - + /* Point 2: 2 <= bitlength(e) < 2^{k-2} Note that we do not need to check the upper bound because we use an unsigned long for E and thus there is no way for E to reach that limit. */ if (e_value < 3) return GPG_ERR_INV_VALUE; - + /* Our implementaion requires E to be odd. */ if (!(e_value & 1)) return GPG_ERR_INV_VALUE; @@ -458,7 +458,7 @@ generate_x931 (RSA_secret_key *sk, unsigned int nbits, unsigned long e_value, }; int idx; gcry_sexp_t oneparm; - + tbl[0].value = &xp1; tbl[1].value = &xp2; tbl[2].value = &xp; @@ -487,8 +487,8 @@ generate_x931 (RSA_secret_key *sk, unsigned int nbits, unsigned long e_value, return GPG_ERR_MISSING_VALUE; } } - - e = mpi_alloc_set_ui (e_value); + + e = mpi_alloc_set_ui (e_value); /* Find two prime numbers. */ p = _gcry_derive_x931_prime (xp, xp1, xp2, e, NULL, NULL); @@ -496,7 +496,7 @@ generate_x931 (RSA_secret_key *sk, unsigned int nbits, unsigned long e_value, gcry_mpi_release (xp); xp = NULL; gcry_mpi_release (xp1); xp1 = NULL; gcry_mpi_release (xp2); xp2 = NULL; - gcry_mpi_release (xq); xq = NULL; + gcry_mpi_release (xq); xq = NULL; gcry_mpi_release (xq1); xq1 = NULL; gcry_mpi_release (xq2); xq2 = NULL; if (!p || !q) @@ -590,7 +590,7 @@ check_secret_key( RSA_secret_key *sk ) { int rc; gcry_mpi_t temp = mpi_alloc( mpi_get_nlimbs(sk->p)*2 ); - + mpi_mul(temp, sk->p, sk->q ); rc = mpi_cmp( temp, sk->n ); mpi_free(temp); @@ -692,9 +692,9 @@ stronger_key_check ( RSA_secret_key *skey ) * * Or faster: * - * m1 = c ^ (d mod (p-1)) mod p - * m2 = c ^ (d mod (q-1)) mod q - * h = u * (m2 - m1) mod q + * m1 = c ^ (d mod (p-1)) mod p + * m2 = c ^ (d mod (q-1)) mod q + * h = u * (m2 - m1) mod q * m = m1 + h * p * * Where m is OUTPUT, c is INPUT and d,n,p,q,u are elements of SKEY. @@ -711,10 +711,10 @@ secret(gcry_mpi_t output, gcry_mpi_t input, RSA_secret_key *skey ) gcry_mpi_t m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); gcry_mpi_t m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); gcry_mpi_t h = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); - + /* m1 = c ^ (d mod (p-1)) mod p */ mpi_sub_ui( h, skey->p, 1 ); - mpi_fdiv_r( h, skey->d, h ); + mpi_fdiv_r( h, skey->d, h ); mpi_powm( m1, input, h, skey->p ); /* m2 = c ^ (d mod (q-1)) mod q */ mpi_sub_ui( h, skey->q, 1 ); @@ -722,13 +722,13 @@ secret(gcry_mpi_t output, gcry_mpi_t input, RSA_secret_key *skey ) mpi_powm( m2, input, h, skey->q ); /* h = u * ( m2 - m1 ) mod q */ mpi_sub( h, m2, m1 ); - if ( mpi_is_neg( h ) ) + if ( mpi_is_neg( h ) ) mpi_add ( h, h, skey->q ); - mpi_mulm( h, skey->u, h, skey->q ); + mpi_mulm( h, skey->u, h, skey->q ); /* m = m2 + h * p */ mpi_mul ( h, h, skey->p ); mpi_add ( output, m1, h ); - + mpi_free ( h ); mpi_free ( m1 ); mpi_free ( m2 ); @@ -749,7 +749,7 @@ rsa_blind (gcry_mpi_t x, gcry_mpi_t r, gcry_mpi_t e, gcry_mpi_t n) a = gcry_mpi_snew (gcry_mpi_get_nbits (n)); y = gcry_mpi_snew (gcry_mpi_get_nbits (n)); - + /* Now we calculate: y = (x * r^e) mod n, where r is the random number, e is the public exponent, x is the non-blinded data and n is the RSA modulus. */ @@ -796,7 +796,7 @@ rsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, gcry_sexp_t l1; (void)algo; - + *retfactors = NULL; /* We don't return them. */ deriveparms = (genparms? @@ -819,7 +819,7 @@ rsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, gcry_sexp_release (deriveparms); if (!ec && r_extrainfo && swapped) { - ec = gcry_sexp_new (r_extrainfo, + ec = gcry_sexp_new (r_extrainfo, "(misc-key-info(p-q-swapped))", 0, 1); if (ec) { @@ -854,7 +854,7 @@ rsa_generate_ext (int algo, unsigned int nbits, unsigned long evalue, skey[4] = sk.q; skey[5] = sk.u; } - + return ec; } @@ -900,12 +900,12 @@ rsa_encrypt (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, (void)algo; (void)flags; - + pk.n = pkey[0]; pk.e = pkey[1]; resarr[0] = mpi_alloc (mpi_get_nlimbs (pk.n)); public (resarr[0], data, &pk); - + return GPG_ERR_NO_ERROR; } @@ -935,11 +935,11 @@ rsa_decrypt (int algo, gcry_mpi_t *result, gcry_mpi_t *data, /* We use blinding by default to mitigate timing attacks which can be practically mounted over the network as shown by Brumley and - Boney in 2003. */ + Boney in 2003. */ if (! (flags & PUBKEY_FLAG_NO_BLINDING)) { /* Initialize blinding. */ - + /* First, we need a random number r between 0 and n - 1, which is relatively prime to n (i.e. it is neither p nor q). The random number needs to be only unpredictable, thus we employ @@ -947,7 +947,7 @@ rsa_decrypt (int algo, gcry_mpi_t *result, gcry_mpi_t *data, gcry_mpi_randomize. */ r = gcry_mpi_snew (gcry_mpi_get_nbits (sk.n)); ri = gcry_mpi_snew (gcry_mpi_get_nbits (sk.n)); - + gcry_mpi_randomize (r, gcry_mpi_get_nbits (sk.n), GCRY_WEAK_RANDOM); gcry_mpi_mod (r, r, sk.n); @@ -970,7 +970,7 @@ rsa_decrypt (int algo, gcry_mpi_t *result, gcry_mpi_t *data, { /* Undo blinding. */ gcry_mpi_t a = gcry_mpi_copy (y); - + gcry_mpi_release (y); y = rsa_unblind (a, ri, sk.n); @@ -987,7 +987,7 @@ rsa_decrypt (int algo, gcry_mpi_t *result, gcry_mpi_t *data, /* Copy out result. */ *result = y; - + return GPG_ERR_NO_ERROR; } @@ -998,7 +998,7 @@ rsa_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey) RSA_secret_key sk; (void)algo; - + sk.n = skey[0]; sk.e = skey[1]; sk.d = skey[2]; @@ -1039,7 +1039,7 @@ rsa_verify (int algo, gcry_mpi_t hash, gcry_mpi_t *data, gcry_mpi_t *pkey, /*rc = (*cmp)( opaquev, result );*/ rc = mpi_cmp (result, hash) ? GPG_ERR_BAD_SIGNATURE : GPG_ERR_NO_ERROR; gcry_mpi_release (result); - + return rc; } @@ -1061,7 +1061,7 @@ rsa_get_nbits (int algo, gcry_mpi_t *pkey) (rsa (n #00B...#) (e #010001#)) - + PKCS-15 says that for RSA only the modulus should be hashed - however, it is not clear whether this is meant to use the raw bytes (assuming this is an unsigned integer) or whether the DER required @@ -1093,17 +1093,17 @@ compute_keygrip (gcry_md_hd_t md, gcry_sexp_t keyparam) -/* +/* Self-test section. */ static const char * selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey) { - static const char sample_data[] = + static const char sample_data[] = "(data (flags pkcs1)" " (hash sha1 #11223344556677889900aabbccddeeff10203040#))"; - static const char sample_data_bad[] = + static const char sample_data_bad[] = "(data (flags pkcs1)" " (hash sha1 #11223344556677889900aabbccddeeff80203040#))"; @@ -1116,7 +1116,7 @@ selftest_sign_1024 (gcry_sexp_t pkey, gcry_sexp_t skey) err = gcry_sexp_sscan (&data, NULL, sample_data, strlen (sample_data)); if (!err) - err = gcry_sexp_sscan (&data_bad, NULL, + err = gcry_sexp_sscan (&data_bad, NULL, sample_data_bad, strlen (sample_data_bad)); if (err) { @@ -1202,7 +1202,7 @@ selftest_encr_1024 (gcry_sexp_t pkey, gcry_sexp_t skey) /* Create plaintext. The plaintext is actually a big integer number. */ plaintext = gcry_mpi_new (nbits); gcry_mpi_randomize (plaintext, nbits, GCRY_WEAK_RANDOM); - + /* Put the plaintext into an S-expression. */ err = gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %m))", plaintext); @@ -1262,7 +1262,7 @@ selftest_encr_1024 (gcry_sexp_t pkey, gcry_sexp_t skey) errtxt = "decrypt returned no plaintext"; goto leave; } - + /* Check that the decrypted plaintext matches the original plaintext. */ if (gcry_mpi_cmp (plaintext, decr_plaintext)) { @@ -1290,13 +1290,13 @@ selftests_rsa (selftest_report_func_t report) gcry_error_t err; gcry_sexp_t skey = NULL; gcry_sexp_t pkey = NULL; - + /* Convert the S-expressions into the internal representation. */ what = "convert"; - err = gcry_sexp_sscan (&skey, NULL, + err = gcry_sexp_sscan (&skey, NULL, sample_secret_key, strlen (sample_secret_key)); if (!err) - err = gcry_sexp_sscan (&pkey, NULL, + err = gcry_sexp_sscan (&pkey, NULL, sample_public_key, strlen (sample_public_key)); if (err) { @@ -1351,7 +1351,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_PUBKEY_ALGO; break; - + } return ec; } @@ -1380,10 +1380,9 @@ gcry_pk_spec_t _gcry_pubkey_spec_rsa = rsa_verify, rsa_get_nbits, }; -pk_extra_spec_t _gcry_pubkey_extraspec_rsa = +pk_extra_spec_t _gcry_pubkey_extraspec_rsa = { run_selftests, rsa_generate_ext, compute_keygrip }; - diff --git a/cipher/seed.c b/cipher/seed.c index b0980d61..ae26e674 100644 --- a/cipher/seed.c +++ b/cipher/seed.c @@ -59,7 +59,7 @@ union wordbuf static const char *selftest(void); -typedef struct +typedef struct { u32 keyschedule[32]; } SEED_context; @@ -258,7 +258,7 @@ static const u32 KC[NUMKC] = { /* Perform the key setup. - */ + */ static gcry_err_code_t do_setkey (SEED_context *ctx, const byte *key, const unsigned keylen) { @@ -432,7 +432,7 @@ static const char* selftest (void) { SEED_context ctx; - byte scratch[16]; + byte scratch[16]; /* The test vector is taken from the appendix section B.3 of RFC4269. */ diff --git a/cipher/serpent.c b/cipher/serpent.c index 6b7e655a..a78e018a 100644 --- a/cipher/serpent.c +++ b/cipher/serpent.c @@ -54,7 +54,7 @@ typedef struct serpent_context /* A prototype. */ static const char *serpent_test (void); - + #define byte_swap_32(x) \ (0 \ @@ -684,7 +684,7 @@ serpent_setkey (void *ctx, static const char *serpent_test_ret; static int serpent_init_done; gcry_err_code_t ret = GPG_ERR_NO_ERROR; - + if (! serpent_init_done) { /* Execute a self-test the first time, Serpent is used. */ diff --git a/cipher/sha1.c b/cipher/sha1.c index 0b5dc430..4b784acf 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -32,7 +32,7 @@ #include #include #include -#ifdef HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include #endif @@ -54,7 +54,7 @@ #define TRANSFORM(x,d,n) transform ((x), (d), (n)) -typedef struct +typedef struct { u32 h0,h1,h2,h3,h4; u32 nblocks; @@ -110,7 +110,7 @@ transform (SHA1_CONTEXT *hd, const unsigned char *data, size_t nblocks) register u32 a, b, c, d, e; /* Local copies of the chaining variables. */ register u32 tm; /* Helper. */ u32 x[16]; /* The array we work on. */ - + /* Loop over all blocks. */ for ( ;nblocks; nblocks--) { @@ -287,7 +287,7 @@ static void sha1_final(void *context) { SHA1_CONTEXT *hd = context; - + u32 t, msb, lsb; unsigned char *p; @@ -374,7 +374,7 @@ _gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length) -/* +/* Self-test section. */ @@ -384,10 +384,10 @@ selftests_sha1 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + what = "short string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA1, 0, + (GCRY_MD_SHA1, 0, "abc", 3, "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E" "\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D", 20); @@ -398,13 +398,13 @@ selftests_sha1 (int extended, selftest_report_func_t report) { what = "long string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA1, 0, + (GCRY_MD_SHA1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56, "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE" "\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1", 20); if (errtxt) goto failed; - + what = "one million \"a\""; errtxt = _gcry_hash_selftest_check_one (GCRY_MD_SHA1, 1, @@ -438,7 +438,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_DIGEST_ALGO; break; - + } return ec; } @@ -471,8 +471,7 @@ gcry_md_spec_t _gcry_digest_spec_sha1 = sha1_init, sha1_write, sha1_final, sha1_read, sizeof (SHA1_CONTEXT) }; -md_extra_spec_t _gcry_digest_extraspec_sha1 = +md_extra_spec_t _gcry_digest_extraspec_sha1 = { run_selftests }; - diff --git a/cipher/sha256.c b/cipher/sha256.c index 8063592f..309fa3b9 100644 --- a/cipher/sha256.c +++ b/cipher/sha256.c @@ -19,7 +19,7 @@ /* Test vectors: - + "abc" SHA224: 23097d22 3405d822 8642a477 bda255b3 2aadbce4 bda0b3f7 e36c9da7 SHA256: ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad @@ -27,7 +27,7 @@ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" SHA224: 75388b16 512776cc 5dba5da1 fd890150 b0c6455c b4f58b19 52522525 SHA256: 248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1 - + "a" one million times SHA224: 20794655 980c91d8 bbb4c1ea 97618a4b f03f4258 1948b2ee 4ee7ad67 SHA256: cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0 @@ -123,7 +123,7 @@ Maj (u32 x, u32 y, u32 z) { return ((x & y) | (z & (x|y))); } - + /* (4.4) */ static inline u32 Sum0 (u32 x) @@ -138,7 +138,7 @@ Sum1 (u32 x) return (ror (x, 6) ^ ror (x, 11) ^ ror (x, 25)); } - + static void transform (SHA256_CONTEXT *hd, const unsigned char *data) { @@ -146,7 +146,7 @@ transform (SHA256_CONTEXT *hd, const unsigned char *data) 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, @@ -165,7 +165,7 @@ transform (SHA256_CONTEXT *hd, const unsigned char *data) u32 x[16]; u32 w[64]; int i; - + a = hd->h0; b = hd->h1; c = hd->h2; @@ -174,14 +174,14 @@ transform (SHA256_CONTEXT *hd, const unsigned char *data) f = hd->h5; g = hd->h6; h = hd->h7; - + #ifdef WORDS_BIGENDIAN memcpy (x, data, 64); #else - { + { byte *p2; - - for (i=0, p2=(byte*)x; i < 16; i++, p2 += 4 ) + + for (i=0, p2=(byte*)x; i < 16; i++, p2 += 4 ) { p2[3] = *data++; p2[2] = *data++; @@ -202,7 +202,7 @@ transform (SHA256_CONTEXT *hd, const unsigned char *data) R(a,b,c,d,e,f,g,h,K[i],w[i]); i++; #else - t1 = h + Sum1 (e) + Cho (e, f, g) + K[i] + w[i]; + t1 = h + Sum1 (e) + Cho (e, f, g) + K[i] + w[i]; t2 = Sum0 (a) + Maj (a, b, c); d += t1; h = t1 + t2; @@ -311,7 +311,7 @@ sha256_final(void *context) SHA256_CONTEXT *hd = context; u32 t, msb, lsb; byte *p; - + sha256_write (hd, NULL, 0); /* flush */; t = hd->nblocks; @@ -382,7 +382,7 @@ sha256_read (void *context) -/* +/* Self-test section. */ @@ -392,10 +392,10 @@ selftests_sha224 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + what = "short string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA224, 0, + (GCRY_MD_SHA224, 0, "abc", 3, "\x23\x09\x7d\x22\x34\x05\xd8\x22\x86\x42\xa4\x77\xbd\xa2\x55\xb3" "\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7\xe3\x6c\x9d\xa7", 28); @@ -406,13 +406,13 @@ selftests_sha224 (int extended, selftest_report_func_t report) { what = "long string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA224, 0, + (GCRY_MD_SHA224, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56, "\x75\x38\x8b\x16\x51\x27\x76\xcc\x5d\xba\x5d\xa1\xfd\x89\x01\x50" "\xb0\xc6\x45\x5c\xb4\xf5\x8b\x19\x52\x52\x25\x25", 28); if (errtxt) goto failed; - + what = "one million \"a\""; errtxt = _gcry_hash_selftest_check_one (GCRY_MD_SHA224, 1, @@ -436,10 +436,10 @@ selftests_sha256 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + what = "short string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA256, 0, + (GCRY_MD_SHA256, 0, "abc", 3, "\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23" "\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad", 32); @@ -450,14 +450,14 @@ selftests_sha256 (int extended, selftest_report_func_t report) { what = "long string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA256, 0, + (GCRY_MD_SHA256, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56, "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39" "\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1", 32); if (errtxt) goto failed; - + what = "one million \"a\""; errtxt = _gcry_hash_selftest_check_one (GCRY_MD_SHA256, 1, @@ -495,7 +495,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_DIGEST_ALGO; break; - + } return ec; } @@ -512,7 +512,7 @@ static byte asn224[19] = /* Object ID is 2.16.840.1.101.3.4.2.4 */ static gcry_md_oid_spec_t oid_spec_sha224[] = { /* From RFC3874, Section 4 */ - { "2.16.840.1.101.3.4.2.4" }, + { "2.16.840.1.101.3.4.2.4" }, { NULL }, }; @@ -524,7 +524,7 @@ static byte asn256[19] = /* Object ID is 2.16.840.1.101.3.4.2.1 */ static gcry_md_oid_spec_t oid_spec_sha256[] = { /* According to the OpenPGP draft rfc2440-bis06 */ - { "2.16.840.1.101.3.4.2.1" }, + { "2.16.840.1.101.3.4.2.1" }, /* PKCS#1 sha256WithRSAEncryption */ { "1.2.840.113549.1.1.11" }, @@ -537,7 +537,7 @@ gcry_md_spec_t _gcry_digest_spec_sha224 = sha224_init, sha256_write, sha256_final, sha256_read, sizeof (SHA256_CONTEXT) }; -md_extra_spec_t _gcry_digest_extraspec_sha224 = +md_extra_spec_t _gcry_digest_extraspec_sha224 = { run_selftests }; @@ -548,7 +548,7 @@ gcry_md_spec_t _gcry_digest_spec_sha256 = sha256_init, sha256_write, sha256_final, sha256_read, sizeof (SHA256_CONTEXT) }; -md_extra_spec_t _gcry_digest_extraspec_sha256 = +md_extra_spec_t _gcry_digest_extraspec_sha256 = { run_selftests }; diff --git a/cipher/sha512.c b/cipher/sha512.c index 59c3e658..2163e600 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -283,7 +283,7 @@ transform (SHA512_CONTEXT *hd, const unsigned char *data) t2 = Sum0 (b) + Maj (b, c, d); e += t1; a = t1 + t2; - + t += 8; #endif } @@ -438,7 +438,7 @@ sha512_read (void *context) -/* +/* Self-test section. */ @@ -448,10 +448,10 @@ selftests_sha384 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + what = "short string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA384, 0, + (GCRY_MD_SHA384, 0, "abc", 3, "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b\xb5\xa0\x3d\x69\x9a\xc6\x50\x07" "\x27\x2c\x32\xab\x0e\xde\xd1\x63\x1a\x8b\x60\x5a\x43\xff\x5b\xed" @@ -463,9 +463,9 @@ selftests_sha384 (int extended, selftest_report_func_t report) { what = "long string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA384, 0, + (GCRY_MD_SHA384, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" - "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112, + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112, "\x09\x33\x0C\x33\xF7\x11\x47\xE8\x3D\x19\x2F\xC7\x82\xCD\x1B\x47" "\x53\x11\x1B\x17\x3B\x3B\x05\xD2\x2F\xA0\x80\x86\xE3\xB0\xF7\x12" "\xFC\xC7\xC7\x1A\x55\x7E\x2D\xB9\x66\xC3\xE9\xFA\x91\x74\x60\x39", @@ -498,10 +498,10 @@ selftests_sha512 (int extended, selftest_report_func_t report) { const char *what; const char *errtxt; - + what = "short string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA512, 0, + (GCRY_MD_SHA512, 0, "abc", 3, "\xDD\xAF\x35\xA1\x93\x61\x7A\xBA\xCC\x41\x73\x49\xAE\x20\x41\x31" "\x12\xE6\xFA\x4E\x89\xA9\x7E\xA2\x0A\x9E\xEE\xE6\x4B\x55\xD3\x9A" @@ -514,9 +514,9 @@ selftests_sha512 (int extended, selftest_report_func_t report) { what = "long string"; errtxt = _gcry_hash_selftest_check_one - (GCRY_MD_SHA512, 0, + (GCRY_MD_SHA512, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" - "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112, + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 112, "\x8E\x95\x9B\x75\xDA\xE3\x13\xDA\x8C\xF4\xF7\x28\x14\xFC\x14\x3F" "\x8F\x77\x79\xC6\xEB\x9F\x7F\xA1\x72\x99\xAE\xAD\xB6\x88\x90\x18" "\x50\x1D\x28\x9E\x49\x00\xF7\xE4\x33\x1B\x99\xDE\xC4\xB5\x43\x3A" @@ -524,7 +524,7 @@ selftests_sha512 (int extended, selftest_report_func_t report) 64); if (errtxt) goto failed; - + what = "one million \"a\""; errtxt = _gcry_hash_selftest_check_one (GCRY_MD_SHA512, 1, @@ -564,7 +564,7 @@ run_selftests (int algo, int extended, selftest_report_func_t report) default: ec = GPG_ERR_DIGEST_ALGO; break; - + } return ec; } @@ -589,13 +589,13 @@ static gcry_md_oid_spec_t oid_spec_sha512[] = { NULL } }; -gcry_md_spec_t _gcry_digest_spec_sha512 = +gcry_md_spec_t _gcry_digest_spec_sha512 = { "SHA512", sha512_asn, DIM (sha512_asn), oid_spec_sha512, 64, sha512_init, sha512_write, sha512_final, sha512_read, sizeof (SHA512_CONTEXT), }; -md_extra_spec_t _gcry_digest_extraspec_sha512 = +md_extra_spec_t _gcry_digest_extraspec_sha512 = { run_selftests }; @@ -609,7 +609,7 @@ static byte sha384_asn[] = /* Object ID is 2.16.840.1.101.3.4.2.2 */ static gcry_md_oid_spec_t oid_spec_sha384[] = { - { "2.16.840.1.101.3.4.2.2" }, + { "2.16.840.1.101.3.4.2.2" }, /* PKCS#1 sha384WithRSAEncryption */ { "1.2.840.113549.1.1.12" }, @@ -617,13 +617,13 @@ static gcry_md_oid_spec_t oid_spec_sha384[] = { NULL }, }; -gcry_md_spec_t _gcry_digest_spec_sha384 = +gcry_md_spec_t _gcry_digest_spec_sha384 = { "SHA384", sha384_asn, DIM (sha384_asn), oid_spec_sha384, 48, sha384_init, sha512_write, sha512_final, sha512_read, sizeof (SHA512_CONTEXT), }; -md_extra_spec_t _gcry_digest_extraspec_sha384 = +md_extra_spec_t _gcry_digest_extraspec_sha384 = { run_selftests }; diff --git a/cipher/test-getrusage.c b/cipher/test-getrusage.c index 479eaab8..6fc8372d 100644 --- a/cipher/test-getrusage.c +++ b/cipher/test-getrusage.c @@ -27,7 +27,7 @@ main (int argc, char **argv) } printf ("ru_utime = %ld.%06ld\n", - buf.ru_utime.tv_sec, buf.ru_utime.tv_usec); + buf.ru_utime.tv_sec, buf.ru_utime.tv_usec); printf ("ru_stime = %ld.%06ld\n", buf.ru_stime.tv_sec, buf.ru_stime.tv_usec); printf ("ru_maxrss = %ld\n", buf.ru_maxrss ); @@ -60,7 +60,7 @@ collect_rusage_stats (struct rusage *rb) { static int idx; static struct rusage buf[100]; - + if (!rb) { int i; @@ -68,12 +68,12 @@ collect_rusage_stats (struct rusage *rb) fprintf (stderr, "ru_utime ru_stime ru_minflt ru_nvcsw ru_nivcsw\n"); for (i=0; i < idx; i++) fprintf (stderr, "%ld.%06ld %ld.%06ld %5ld %5ld %5ld\n", - buf[i].ru_utime.tv_sec, buf[i].ru_utime.tv_usec, - buf[i].ru_stime.tv_sec, buf[i].ru_stime.tv_usec, - buf[i].ru_minflt, + buf[i].ru_utime.tv_sec, buf[i].ru_utime.tv_usec, + buf[i].ru_stime.tv_sec, buf[i].ru_stime.tv_usec, + buf[i].ru_minflt, buf[i].ru_nvcsw, buf[i].ru_nivcsw); - } + } else if (idx < DIM(buf)) { buf[idx++] = *rb; @@ -99,7 +99,5 @@ collect_rusage_stats (struct rusage *rb) add_randomness( &buf, sizeof buf, 1 ); memset( &buf, 0, sizeof buf ); } - -*/ - +*/ diff --git a/cipher/tiger.c b/cipher/tiger.c index 4ad6ce53..d4ad514a 100644 --- a/cipher/tiger.c +++ b/cipher/tiger.c @@ -625,14 +625,14 @@ tiger_round( u64 *ra, u64 *rb, u64 *rc, u64 x, int mul ) u64 a = *ra; u64 b = *rb; u64 c = *rc; - + c ^= x; a -= ( sbox1[ c & 0xff ] ^ sbox2[ (c >> 16) & 0xff ] ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ]); b += ( sbox4[ (c >> 8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ] ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ]); b *= mul; - + *ra = a; *rb = b; *rc = c; @@ -751,7 +751,7 @@ tiger_write ( void *context, const void *inbuf_arg, size_t inlen) } if( !inbuf ) return; - if( hd->count ) + if( hd->count ) { for( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; diff --git a/cipher/twofish.c b/cipher/twofish.c index 68b2c7ac..f1a93ca8 100644 --- a/cipher/twofish.c +++ b/cipher/twofish.c @@ -575,10 +575,10 @@ do_twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen) * 128-bit keys use only sa through sh; 256-bit use all of them. */ byte sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0, sh = 0; byte si = 0, sj = 0, sk = 0, sl = 0, sm = 0, sn = 0, so = 0, sp = 0; - + /* Temporary for CALC_S. */ byte tmp; - + /* Flags for self-test. */ static int initialized = 0; static const char *selftest_failed=0; @@ -668,7 +668,7 @@ do_twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen) CALC_K256 (k, 28, 0x84, 0x8A, 0x54, 0x00); CALC_K256 (k, 30, 0xDF, 0xBC, 0x23, 0x9D); } - else + else { /* Compute the S-boxes. */ for(i=j=0,k=1; i < 256; i++, j += 2, k += 2 ) @@ -980,7 +980,7 @@ main() timer = clock (); /* Encryption test. */ - for (i = 0; i < 125; i++) + for (i = 0; i < 125; i++) { twofish_setkey (&ctx, buffer[0], sizeof (buffer[0])); for (j = 0; j < 1000; j++) @@ -998,7 +998,7 @@ main() "encryption failure!\n" : "encryption OK!\n"; /* Decryption test. */ - for (i = 0; i < 125; i++) + for (i = 0; i < 125; i++) { twofish_setkey (&ctx, buffer[2], sizeof (buffer[2])*2); for (j = 0; j < 1000; j++) { diff --git a/cipher/whirlpool.c b/cipher/whirlpool.c index e6c226c0..c89a5729 100644 --- a/cipher/whirlpool.c +++ b/cipher/whirlpool.c @@ -117,7 +117,7 @@ static const u64 rc[R] = U64_C (0xfbee7c66dd17479e), U64_C (0xca2dbf07ad5a8333), }; - + /* Main lookup boxes. */ @@ -1322,7 +1322,7 @@ whirlpool_add (whirlpool_context_t *context, } /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */ - while (buffer_n >= BLOCK_SIZE) + while (buffer_n >= BLOCK_SIZE) { whirlpool_transform (context, buffer); context->count = 0; diff --git a/compat/Makefile.am b/compat/Makefile.am index 0e0c54a4..f0ddf34d 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -37,14 +37,12 @@ AM_CPPFLAGS = -I../src -I$(top_srcdir)/src $(GPG_ERROR_CFLAGS) noinst_LTLIBRARIES = libcompat.la # We only need one file so that the library is guaranteed to have at -# least one member. +# least one member. libcompat_la_SOURCES = compat.c libcompat.h -libcompat_la_DEPENDENCIES = @LTLIBOBJS@ -libcompat_la_LIBADD = @LTLIBOBJS@ +libcompat_la_DEPENDENCIES = @LTLIBOBJS@ +libcompat_la_LIBADD = @LTLIBOBJS@ # AC_LIBOBJ files are: # getpid.c # clock.c # - - diff --git a/compat/clock.c b/compat/clock.c index 0d1a1671..7f250f33 100644 --- a/compat/clock.c +++ b/compat/clock.c @@ -19,11 +19,11 @@ #include #include -clock_t +clock_t _gcry_clock (void) { assert (CLOCKS_PER_SEC == 1000); -#warning Replace by a correct implementaion. +#warning Replace by a correct implementaion. /* It seems that GetProcessTimes is available in the kernel but without a declaration. If that fails we would need to walk over all threads and tally up the GetThreadTimes. */ diff --git a/compat/compat.c b/compat/compat.c index 8f1d9c86..4a38ec7c 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -25,7 +25,7 @@ const char * _gcry_compat_identification (void) { - static const char blurb[] = + static const char blurb[] = "\n\n" "This is Libgcrypt - The GNU Crypto Library\n" "Copyright 2000, 2002, 2003, 2004, 2007, 2008, 2009,\n" @@ -33,4 +33,3 @@ _gcry_compat_identification (void) "\n\n"; return blurb; } - diff --git a/compat/getpid.c b/compat/getpid.c index b93d057f..032387c3 100644 --- a/compat/getpid.c +++ b/compat/getpid.c @@ -18,7 +18,7 @@ #include #include -pid_t +pid_t _gcry_getpid (void) { return GetCurrentProcessId (); diff --git a/doc/ChangeLog b/doc/ChangeLog index f83f0aad..992c63bd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -5,7 +5,7 @@ 2009-07-02 Daiki Ueno * gcrypt.texi (Working with S-expressions): Describe format - character '%S'. Typo fixes. Fixes bug#1079. + character '%S'. Typo fixes. Fixes bug#1079. 2009-05-10 Werner Koch @@ -44,7 +44,7 @@ 2008-09-18 Werner Koch * gcrypt.texi: Add a couple of index items. - (FIPS Mode): Reflect recent changes. + (FIPS Mode): Reflect recent changes. (Controlling the library): Describe gcry_fips_mode_active. 2008-09-16 Werner Koch @@ -249,7 +249,7 @@ * gcrypt.texi: Minor cleanups (Working with keys): Clarified generation of RSA's E parameter. (Multi Threading): Clarified. - + 2003-11-11 Werner Koch * gcrypt.texi (Working with S-expressions): Added "%b". @@ -341,7 +341,7 @@ * gcrypt.texi (Hash Functions): Adjusteded description of gcry_md_copy. - + 2003-06-12 Moritz Schulte * gcrypt.texi (Public Key Functions): Fix example S-Exp, i.e.: diff --git a/doc/HACKING b/doc/HACKING index 51380b17..3f94772c 100644 --- a/doc/HACKING +++ b/doc/HACKING @@ -29,38 +29,37 @@ Debugging math stuff: ===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<===================== - diff --git a/doc/Makefile.am b/doc/Makefile.am index f2510643..fc12745a 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -20,7 +20,7 @@ EXTRA_DIST = README.apichanges HACKING \ libgcrypt-modules.eps fips-fsm.eps \ libgcrypt-modules.png fips-fsm.png \ - libgcrypt-modules.pdf fips-fsm.pdf + libgcrypt-modules.pdf fips-fsm.pdf DISTCLEANFILES = gcrypt.cps @@ -67,5 +67,4 @@ online: gcrypt.html gcrypt.pdf gcrypt.info fi ; \ cd gcrypt.html ; \ rsync -vr --exclude='.svn' . \ - $${user}@trithemius.gnupg.org:webspace/manuals/gcrypt$${dashdevel}/ - + $${user}@trithemius.gnupg.org:webspace/manuals/gcrypt$${dashdevel}/ diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index 886c3962..4026621e 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -352,7 +352,7 @@ memory is not a problem, you should initialize Libgcrypt this way: fputs ("libgcrypt version mismatch\n", stderr); exit (2); @} - + /* Disable secure memory. */ gcry_control (GCRYCTL_DISABLE_SECMEM, 0); @@ -383,7 +383,7 @@ and freed memory, you need to initialize Libgcrypt this way: gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); /* ... If required, other initialization goes here. Note that the - process might still be running with increased privileges and that + process might still be running with increased privileges and that the secure memory has not been intialized. */ /* Allocate a pool of 16k secure memory. This make the secure memory @@ -410,7 +410,7 @@ want to check for finished initialization using: @{ fputs ("libgcrypt has not been initialized\n", stderr); abort (); - @} + @} @end example Instead of terminating the process, the library may instead print a @@ -422,7 +422,7 @@ multi-threading below for more pitfalls. @node Multi-Threading @section Multi-Threading -As mentioned earlier, the Libgcrypt library is +As mentioned earlier, the Libgcrypt library is thread-safe if you adhere to the following requirements: @itemize @bullet @@ -544,18 +544,18 @@ explicitly. Three alternative mechanisms are provided to switch Libgcrypt into this mode: @itemize -@item +@item If the file @file{/proc/sys/crypto/fips_enabled} exists and contains a numeric value other than @code{0}, Libgcrypt is put into FIPS mode at initialization time. Obviously this works only on systems with a @code{proc} file system (i.e. GNU/Linux). -@item +@item If the file @file{/etc/gcrypt/fips_enabled} exists, Libgcrypt is put into FIPS mode at initialization time. Note that this filename is hardwired and does not depend on any configuration options. -@item +@item If the application requests FIPS mode using the control command @code{GCRYCTL_FORCE_FIPS_MODE}. This must be done prior to any initialization (i.e. before @code{gcry_check_version}). @@ -645,7 +645,7 @@ mode this command has no effect at all. Many applications do not require secure memory, so they should disable it right away. This command should be executed right after -@code{gcry_check_version}. +@code{gcry_check_version}. @item GCRYCTL_INIT_SECMEM; Arguments: int nbytes This command is used to allocate a pool of secure memory and thus @@ -671,9 +671,9 @@ subsystem. This command should be run right after @code{gcry_check_version}. @item GCRYCTL_SUSPEND_SECMEM_WARN; Arguments: none -Postpone warning messages from the secure memory subsystem. +Postpone warning messages from the secure memory subsystem. @xref{sample-use-suspend-secmem,,the initialization example}, on how to -use it. +use it. @item GCRYCTL_RESUME_SECMEM_WARN; Arguments: none Resume warning messages from the secure memory subsystem. @@ -1202,7 +1202,7 @@ above: gcry_cipher_hd_t handle; gcry_error_t err = 0; - err = gcry_cipher_open (&handle, GCRY_CIPHER_AES, + err = gcry_cipher_open (&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, 0); if (err) @{ @@ -1220,7 +1220,7 @@ above: @chapter Handler Functions Libgcrypt makes it possible to install so called `handler functions', -which get called by Libgcrypt in case of certain events. +which get called by Libgcrypt in case of certain events. @menu * Progress handler:: Using a progress handler function. @@ -1423,7 +1423,7 @@ are ignored. @item GCRY_CIPHER_CAST5 @cindex CAST5 CAST128-5 block cipher algorithm. The key size is 128 bits. - + @item GCRY_CIPHER_BLOWFISH @cindex Blowfish The blowfish algorithm. The current implementation allows only for a key @@ -1432,10 +1432,10 @@ size of 128 bits. @item GCRY_CIPHER_SAFER_SK128 Reserved and not currently implemented. -@item GCRY_CIPHER_DES_SK +@item GCRY_CIPHER_DES_SK Reserved and not currently implemented. - -@item GCRY_CIPHER_AES + +@item GCRY_CIPHER_AES @itemx GCRY_CIPHER_AES128 @itemx GCRY_CIPHER_RIJNDAEL @itemx GCRY_CIPHER_RIJNDAEL128 @@ -1444,27 +1444,27 @@ Reserved and not currently implemented. @cindex Advanced Encryption Standard AES (Rijndael) with a 128 bit key. -@item GCRY_CIPHER_AES192 +@item GCRY_CIPHER_AES192 @itemx GCRY_CIPHER_RIJNDAEL192 AES (Rijndael) with a 192 bit key. -@item GCRY_CIPHER_AES256 +@item GCRY_CIPHER_AES256 @itemx GCRY_CIPHER_RIJNDAEL256 AES (Rijndael) with a 256 bit key. - + @item GCRY_CIPHER_TWOFISH @cindex Twofish The Twofish algorithm with a 256 bit key. - + @item GCRY_CIPHER_TWOFISH128 The Twofish algorithm with a 128 bit key. - -@item GCRY_CIPHER_ARCFOUR + +@item GCRY_CIPHER_ARCFOUR @cindex Arcfour @cindex RC4 An algorithm which is 100% compatible with RSA Inc.'s RC4 algorithm. Note that this is a stream cipher and must be used very carefully to -avoid a couple of weaknesses. +avoid a couple of weaknesses. @item GCRY_CIPHER_DES @cindex DES @@ -1622,7 +1622,7 @@ set, this mode may be used to bypass the actual encryption. @item GCRY_CIPHER_MODE_ECB @cindex ECB, Electronic Codebook mode -Electronic Codebook mode. +Electronic Codebook mode. @item GCRY_CIPHER_MODE_CFB @cindex CFB, Cipher Feedback mode @@ -1700,7 +1700,7 @@ useful when the key material is highly confidential. @item GCRY_CIPHER_ENABLE_SYNC @cindex sync mode (OpenPGP) This flag enables the CFB sync mode, which is a special feature of -Libgcrypt's CFB mode implementation to allow for OpenPGP's CFB variant. +Libgcrypt's CFB mode implementation to allow for OpenPGP's CFB variant. See @code{gcry_cipher_sync}. @item GCRY_CIPHER_CBC_CTS @cindex cipher text stealing @@ -1714,7 +1714,7 @@ Compute CBC-MAC keyed checksums. This is the same as CBC mode, but only output the last block. Cannot be used simultaneous as GCRY_CIPHER_CBC_CTS. @end table -@end deftypefun +@end deftypefun Use the following function to release an existing handle: @@ -1860,7 +1860,7 @@ information requested as @var{what}. The result is either returned as the return code of the function or copied to the provided @var{buffer} whose allocated length must be available in an integer variable with the address passed in @var{nbytes}. This variable will also receive the -actual used length of the buffer. +actual used length of the buffer. Here is a list of supported codes for @var{what}: @@ -1879,8 +1879,8 @@ number of octets in @var{nbytes}; @var{buffer} must be zero. @item GCRYCTL_TEST_ALGO: Returns @code{0} when the specified algorithm is available for use. @var{buffer} and @var{nbytes} must be zero. - -@end table + +@end table @c end constants for gcry_cipher_algo_info @end deftypefun @@ -2032,7 +2032,7 @@ but greatly improve the performance. Either all of these optional parameters must be given or none of them. They are mandatory for gcry_pk_testkey. -Note that OpenSSL uses slighly different parameters: @math{q < p} and +Note that OpenSSL uses slighly different parameters: @math{q < p} and @math{u = q^{-1} \bmod p}. To use these parameters you will need to swap the values and recompute @math{u}. Here is example code to do this: @@ -2304,7 +2304,7 @@ number. @noindent Note that we will in future allow to use keys without p,q and u specified and may also support other parameters for performance -reasons. +reasons. @noindent @@ -2341,7 +2341,7 @@ operation, like e.g. padding rules. If you don't want to let Libgcrypt handle the padding, you must pass an appropriate MPI using this expression for @var{data}: -@example +@example (data (flags raw) (value @var{mpi})) @@ -2353,7 +2353,7 @@ the actual data, already padded appropriate for your protocol. Most systems however use PKCS#1 padding and so you can use this S-expression for @var{data}: -@example +@example (data (flags pkcs1) (value @var{block})) @@ -2448,7 +2448,7 @@ private key @var{skey} and place it into the variable at the address of with just one MPI or a modern and more versatile S-expression which allows to let Libgcrypt handle padding: -@example +@example (data (flags pkcs1) (hash @var{hash-algo} @var{block})) @@ -2597,9 +2597,9 @@ algorithm. This may be 0 for "don't care" or the bit-wise OR of these flags: @table @code -@item GCRY_PK_USAGE_SIGN +@item GCRY_PK_USAGE_SIGN Algorithm is usable for signing. -@item GCRY_PK_USAGE_ENCR +@item GCRY_PK_USAGE_ENCR Algorithm is usable for encryption. @end table @@ -2717,7 +2717,7 @@ If this parameter is not used, Libgcrypt uses for historic reasons @item qbits This is only meanigful for DSA keys. If it is given the DSA key is -generated with a Q parameyer of this size. If it is not given or zero +generated with a Q parameyer of this size. If it is not given or zero Q is deduced from NBITS in this way: @table @samp @item 512 <= N <= 1024 @@ -2857,7 +2857,7 @@ Note that the order of the elements is not defined, e.g. the private key may be stored before the public key. @var{n1 n2 ... nn} is a list of prime numbers used to composite @var{p-mpi}; this is in general not a very useful information and only available if the key generation -algorithm provides them. +algorithm provides them. @end deftypefun @c end gcry_pk_genkey @@ -3739,7 +3739,7 @@ function should be used for large blocks of data. Pass the byte in @var{c} to the digest object with handle @var{h} to update the digest value. This is an efficient function, implemented as -a macro to buffer the data before an actual update. +a macro to buffer the data before an actual update. @end deftypefun The semantics of the hash functions do not provide for reading out intermediate @@ -3773,7 +3773,7 @@ been enabled. @end deftypefun Because it is often necessary to get the message digest of one block of -memory, a fast convenience function is available for this task: +memory, a fast convenience function is available for this task: @deftypefun void gcry_md_hash_buffer (int @var{algo}, void *@var{digest}, const void *@var{buffer}, size_t @var{length}); @@ -3834,7 +3834,7 @@ returns 0 on success. To test whether an algorithm is actually available for use, the following macro should be used: -@deftypefun gcry_error_t gcry_md_test_algo (int @var{algo}) +@deftypefun gcry_error_t gcry_md_test_algo (int @var{algo}) The macro returns 0 if the algorithm @var{algo} is available for use. @end deftypefun @@ -4026,7 +4026,7 @@ the external formats: This is the generic function to create an new S-expression object from its external representation in @var{buffer} of @var{length} bytes. On -success the result is stored at the address given by @var{r_sexp}. +success the result is stored at the address given by @var{r_sexp}. With @var{autodetect} set to 0, the data in @var{buffer} is expected to be in canonized format, with @var{autodetect} set to 1 the parses any of the defined external formats. If @var{buffer} does not hold a valid @@ -4263,7 +4263,7 @@ can't be converted to an MPI, @code{NULL} is returned. Public key cryptography is based on mathematics with large numbers. To implement the public key functions, a library for handling these large numbers is required. Because of the general usefulness of such a -library, its interface is exposed by Libgcrypt. +library, its interface is exposed by Libgcrypt. In the context of Libgcrypt and in most other applications, these large numbers are called MPIs (multi-precision-integers). @@ -4485,7 +4485,7 @@ as @code{NULL}. @var{round} should be negative or 0. @deftypefun int gcry_mpi_gcd (@w{gcry_mpi_t @var{g}}, @w{gcry_mpi_t @var{a}}, @w{gcry_mpi_t @var{b}}) -Set @var{g} to the greatest common divisor of @var{a} and @var{b}. +Set @var{g} to the greatest common divisor of @var{a} and @var{b}. Return true if the @var{g} is 1. @end deftypefun @@ -4804,13 +4804,13 @@ following main functions are available: @table @code -@item gcry_pk_encrypt +@item gcry_pk_encrypt Encrypt data using a public key. -@item gcry_pk_decrypt +@item gcry_pk_decrypt Decrypt data using a private key. -@item gcry_pk_sign +@item gcry_pk_sign Sign data using a private key. @item gcry_pk_verify @@ -4878,13 +4878,13 @@ algorithm and mode. Release an instance. @item gcry_cipher_setkey -Set a key to be used for encryption or decryption. +Set a key to be used for encryption or decryption. @item gcry_cipher_setiv Set an initialization vector to be used for encryption or decryption. @item gcry_cipher_encrypt -@itemx gcry_cipher_decrypt +@itemx gcry_cipher_decrypt Encrypt or decrypt data. These functions may be called with arbitrary amounts of data and as often as needed to encrypt or decrypt all data. @@ -4966,7 +4966,7 @@ Major features of Libgcrypt's multi-precision-integer code compared to GMP are: @itemize -@item +@item Avoidance of stack based allocations to allow protection against swapping out of sensitive data and for easy zeroing of sensitive intermediate results. @@ -5053,10 +5053,10 @@ for weaker usages like nonces. There is also a level multi-precision-integer using the @code{gcry_create_nonce} function. @noindent -There are two distinct random generators available: +There are two distinct random generators available: @itemize -@item +@item The Continuously Seeded Pseudo Random Number Generator (CSPRNG), which is based on the classic GnuPG derived big pool implementation. Implemented in @code{random/random-csprng.c} and used by default. @@ -5183,19 +5183,19 @@ incremented on each use. @c @node Helper Subsystems Architecture @c @section Helper Subsystems Architecture -@c +@c @c There are a few smaller subsystems which are mainly used internally by @c Libgcrypt but also available to applications. -@c +@c @c @menu @c * S-expression Subsystem Architecture:: Details about the S-expression architecture. @c * Memory Subsystem Architecture:: Details about the memory allocation architecture. @c * Miscellaneous Subsystems Architecture:: Details about other subsystems. @c @end menu -@c +@c @c @node S-expression Subsystem Architecture @c @subsection S-expression Subsystem Architecture -@c +@c @c Libgcrypt provides an interface to S-expression to create and parse @c them. To use an S-expression with Libgcrypt it needs first be @c converted into the internal representation used by Libgcrypt (the type @@ -5203,25 +5203,25 @@ incremented on each use. @c of the S-expression specification and further fature a printf like @c function to convert a list of big integers or other binary data into @c an S-expression. -@c +@c @c Libgcrypt currently implements S-expressions using a tagged linked @c list. However this is not exposed to an application and may be @c changed in future releases to reduce overhead when already working @c with canonically encoded S-expressions. Secure memory is supported by @c this S-expressions implementation. -@c -@c @node Memory Subsystem Architecture -@c @subsection Memory Subsystem Architecture -@c +@c +@c @node Memory Subsystem Architecture +@c @subsection Memory Subsystem Architecture +@c @c TBD. -@c -@c +@c +@c @c @node Miscellaneous Subsystems Architecture @c @subsection Miscellaneous Subsystems Architecture -@c +@c @c TBD. -@c -@c +@c +@c @@ -5250,7 +5250,7 @@ the library into the ``Error'' state. @c -------------------------------- @section Power-Up Tests -Power-up tests are only performed if Libgcrypt is in FIPS mode. +Power-up tests are only performed if Libgcrypt is in FIPS mode. @subsection Symmetric Cipher Algorithm Power-Up Tests @@ -5339,7 +5339,7 @@ A known answer test using 28 byte of data and a 4 byte key is run. The DRNG is tested during power-up this way: @enumerate -@item +@item Requesting one block of random using the public interface to check general working and the duplicated block detection. @item @@ -5357,10 +5357,10 @@ The public key algorithms are tested during power-up: A pre-defined 1024 bit RSA key is used and these tests are run in turn: @enumerate -@item -Conversion of S-expression to internal format. +@item +Conversion of S-expression to internal format. (@code{cipher/@/rsa.c:@/selftests_rsa}) -@item +@item Private key consistency check. (@code{cipher/@/rsa.c:@/selftests_rsa}) @item @@ -5501,7 +5501,7 @@ using the high level functions is run for block modes CFB and OFB. @subsection Hash Algorithm Tests -The following hash algorithm tests are run in addition to the +The following hash algorithm tests are run in addition to the power-up tests: @table @asis @@ -5511,7 +5511,7 @@ power-up tests: @enumerate @item A known answer test using a 56 byte string is run. -@item +@item A known answer test using a string of one million letters "a" is run. @end enumerate (@code{cipher/@/sha1.c:@/selftests_sha1}, @@ -5522,7 +5522,7 @@ A known answer test using a string of one million letters "a" is run. @enumerate @item A known answer test using a 112 byte string is run. -@item +@item A known answer test using a string of one million letters "a" is run. @end enumerate (@code{cipher/@/sha512.c:@/selftests_sha384}, @@ -5617,7 +5617,7 @@ HMAC using a SHA-384 message digest. @item GCRY_MD_SHA512,GCRY_MD_FLAG_HMAC HMAC using a SHA-512 message digest. @item GCRY_PK_RSA -RSA encryption and signing. +RSA encryption and signing. @item GCRY_PK_DSA DSA signing. @end table @@ -5627,7 +5627,7 @@ and thus are in addition available. @item RSA key generation refuses to create a key with a keysize of -less than 1024 bits. +less than 1024 bits. @item DSA key generation refuses to create a key with a keysize other @@ -5639,7 +5639,7 @@ The @code{transient-key} flag for RSA and DSA key generation is ignored. @item Support for the VIA Padlock engine is disabled. -@item +@item FIPS mode may only be used on systems with a /dev/random device. Switching into FIPS mode on other systems will fail at runtime. @@ -5660,13 +5660,13 @@ supported and all API calls return an error. @item Registration of external modules is not supported. -@item +@item Message digest debugging is disabled. @item All debug output related to cryptographic data is suppressed. -@item +@item On-the-fly self-tests are not performed, instead self-tests are run before entering operational state. @@ -5680,7 +5680,7 @@ The digest algorithm MD5 may not be used. If it is used Libgcrypt disables FIPS mode unless Enforced FIPS mode is enabled, in which case Libgcrypt will enter the error state. -@item +@item In Enforced FIPS mode the command @code{GCRYCTL_DISABLE_SECMEM} is ignored. In standard FIPS mode it disables FIPS mode. @@ -5713,7 +5713,7 @@ transitions (@pxref{tbl:fips-state-transitions}) may happen. States used by the FIPS FSM: @table @asis -@item Power-Off +@item Power-Off Libgcrypt is not runtime linked to another application. This usually means that the library is not loaded into main memory. This state is documentation only. @@ -5729,7 +5729,7 @@ The Libgcrypt initialization functions are performed and the library has not yet run any self-test. @item Self-Test -Libgcrypt is performing self-tests. +Libgcrypt is performing self-tests. @item Operational Libgcrypt is in the operational state and all interfaces may be used. @@ -5737,11 +5737,11 @@ Libgcrypt is in the operational state and all interfaces may be used. @item Error Libgrypt is in the error state. When calling any FIPS relevant interfaces they either return an error (@code{GPG_ERR_NOT_OPERATIONAL}) -or put Libgcrypt into the Fatal-Error state and won't return. +or put Libgcrypt into the Fatal-Error state and won't return. @item Fatal-Error -Libgcrypt is in a non-recoverable error state and -will automatically transit into the Shutdown state. +Libgcrypt is in a non-recoverable error state and +will automatically transit into the Shutdown state. @item Shutdown Libgcrypt is about to be terminated and removed from the memory. The @@ -5756,7 +5756,7 @@ application may at this point still runing cleanup handlers. @noindent The valid state transitions (@pxref{fig:fips-fsm}) are: @table @code -@item 1 +@item 1 Power-Off to Power-On is implicitly done by the OS loading Libgcrypt as a shared library and having it linked to an application. @@ -5768,9 +5768,9 @@ Libgcrypt intialization function @code{gcry_check_version}. Init to Self-Test is either triggred by a dedicated API call or implicit by invoking a libgrypt service conrolled by the FSM. -@item 4 +@item 4 Self-Test to Operational is triggered after all self-tests passed -successfully. +successfully. @item 5 Operational to Shutdown is an artifical state without any direct action @@ -5798,7 +5798,7 @@ Error to Fatal-Error is triggred if Libgrypt detects an fatal error while already being in Error state. @item 10 -Fatal-Error to Shutdown is automatically entered by Libgcrypt +Fatal-Error to Shutdown is automatically entered by Libgcrypt after having reported the error. @item 11 @@ -5900,7 +5900,3 @@ these functions are not really thread safe. @c LocalWords: int HD - - - - diff --git a/doc/gpl.texi b/doc/gpl.texi index d9655618..35b15f28 100644 --- a/doc/gpl.texi +++ b/doc/gpl.texi @@ -364,7 +364,7 @@ when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' +to redistribute it under certain conditions; type `show c' for details. @end smallexample @@ -382,7 +382,7 @@ necessary. Here is a sample; alter the names: @group Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' -(which makes passes at compilers) written +(which makes passes at compilers) written by James Hacker. @var{signature of Ty Coon}, 1 April 1989 diff --git a/m4/ChangeLog b/m4/ChangeLog index fc1433b0..fcced599 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -24,7 +24,7 @@ 2006-07-04 Marcus Brinkmann * sys_socket_h.m4, socklen.m4, onceonly.m4: New files from gnulib. - + 2004-04-06 Werner Koch * libtool.m4: Updated from 1.5.4 @@ -32,4 +32,3 @@ 2003-12-08 Werner Koch * libtool.m4: New. - diff --git a/mpi/ChangeLog b/mpi/ChangeLog index 2bf3f2bf..227f4515 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -74,7 +74,7 @@ 2007-10-29 Werner Koch * config.links: No Candadian Cross here, thus use $host instead of - $target. + $target. 2007-10-26 Werner Koch @@ -95,7 +95,7 @@ 2007-05-04 Werner Koch - * config.links (path): Allowthe sue of colons as delimiters. + * config.links (path): Allowthe sue of colons as delimiters. 2007-05-03 Werner Koch @@ -449,7 +449,7 @@ with _gcry_ or gcry_. Renamed also all mpihelp_ to just mpih_ so that functions names are not getting to long an unreadable and for better matching with the filenames. - + 2001-05-28 Werner Koch * mpicoder.c (mpi_fromstr): Made static and assume that all input @@ -479,14 +479,14 @@ Major change: Removed all GnuPG stuff and renamed this piece of software - to gcrypt. + to gcrypt. 2000-11-14 Werner Koch * mpi-internal.h, mpi.h: Changed the way they are called and introduced DID_MPI_LIMP_TYPEDEF hack. Very ugly, should all be revamped. - + * Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency problems. diff --git a/mpi/Makefile.am b/mpi/Makefile.am index edfc5dfd..e900539a 100644 --- a/mpi/Makefile.am +++ b/mpi/Makefile.am @@ -65,7 +65,7 @@ else if MPI_MOD_C_MPIH_ADD1 mpih_add1 = mpih-add1.c else -mpih_add1 = +mpih_add1 = endif endif @@ -75,7 +75,7 @@ else if MPI_MOD_C_MPIH_SUB1 mpih_sub1 = mpih-sub1.c else -mpih_sub1 = +mpih_sub1 = endif endif @@ -85,7 +85,7 @@ else if MPI_MOD_C_MPIH_MUL1 mpih_mul1 = mpih-mul1.c else -mpih_mul1 = +mpih_mul1 = endif endif @@ -95,7 +95,7 @@ else if MPI_MOD_C_MPIH_MUL2 mpih_mul2 = mpih-mul2.c else -mpih_mul2 = +mpih_mul2 = endif endif @@ -105,7 +105,7 @@ else if MPI_MOD_C_MPIH_MUL3 mpih_mul3 = mpih-mul3.c else -mpih_mul3 = +mpih_mul3 = endif endif @@ -115,7 +115,7 @@ else if MPI_MOD_C_MPIH_LSHIFT mpih_lshift = mpih-lshift.c else -mpih_lshift = +mpih_lshift = endif endif @@ -125,7 +125,7 @@ else if MPI_MOD_C_MPIH_RSHIFT mpih_rshift = mpih-rshift.c else -mpih_rshift = +mpih_rshift = endif endif @@ -135,7 +135,7 @@ else if MPI_MOD_C_UDIV udiv = udiv.c else -udiv = +udiv = endif endif @@ -145,7 +145,7 @@ else if MPI_MOD_C_UDIV_QRNND udiv_qrnnd = udiv-qrnnd.c else -udiv_qrnnd = +udiv_qrnnd = endif endif diff --git a/mpi/config.links b/mpi/config.links index 79506379..7e910ee3 100644 --- a/mpi/config.links +++ b/mpi/config.links @@ -310,7 +310,7 @@ fi mpi_required_modules=$mpi_standard_modules if test "$mpi_extra_modules" != ""; then for fn in $mpi_extra_modules; do - for i in $mpi_optional_modules; do + for i in $mpi_optional_modules; do if test "$fn" = "$i" ; then mpi_required_modules="$mpi_required_modules $fn" fi @@ -358,4 +358,3 @@ for dir in $path ; do break; fi done - diff --git a/mpi/ec.c b/mpi/ec.c index 4a3a5f8c..e3253580 100644 --- a/mpi/ec.c +++ b/mpi/ec.c @@ -2,17 +2,17 @@ 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, @@ -54,7 +54,7 @@ struct mpi_ec_ctx_s /* Scratch variables. */ gcry_mpi_t scratch[11]; - + /* Helper for fast reduction. */ /* int nist_nbits; /\* If this is a NIST curve, the number of bits. *\/ */ /* gcry_mpi_t s[10]; */ @@ -177,7 +177,7 @@ ec_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, mpi_ec_t ctx) i = 0; } while (0) #define X(a) do { sp[i++] = wp[(a)];} while (0) #define X0(a) do { sp[i++] = 0; } while (0) - NEXT(0); + NEXT(0); X(0);X(1);X(2);X(3);X(4);X(5);X(6);X(7);X(8);X(9);X(10);X(11); NEXT(1); X0();X0();X0();X0();X(21);X(22);X(23);X0();X0();X0();X0();X0(); @@ -239,10 +239,10 @@ ec_invm (gcry_mpi_t x, gcry_mpi_t a, mpi_ec_t ctx) /* This function returns a new context for elliptic curve based on the field GF(p). P is the prime specifying thuis field, A is the first - coefficient. + coefficient. This context needs to be released using _gcry_mpi_ec_free. */ -mpi_ec_t +mpi_ec_t _gcry_mpi_ec_init (gcry_mpi_t p, gcry_mpi_t a) { int i; @@ -392,7 +392,7 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx) #define l3 (ctx->scratch[5]) if (!mpi_cmp_ui (point->y, 0) || !mpi_cmp_ui (point->z, 0)) - { + { /* P_y == 0 || P_z == 0 => [1:1:0] */ mpi_set_ui (x3, 1); mpi_set_ui (y3, 1); @@ -401,29 +401,29 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx) else { if (ctx->a_is_pminus3) /* Use the faster case. */ - { + { /* L1 = 3(X - Z^2)(X + Z^2) */ /* T1: used for Z^2. */ /* T2: used for the right term. */ - ec_powm (t1, point->z, ctx->two, ctx); - ec_subm (l1, point->x, t1, ctx); + ec_powm (t1, point->z, ctx->two, ctx); + ec_subm (l1, point->x, t1, ctx); ec_mulm (l1, l1, ctx->three, ctx); - ec_addm (t2, point->x, t1, ctx); - ec_mulm (l1, l1, t2, ctx); + ec_addm (t2, point->x, t1, ctx); + ec_mulm (l1, l1, t2, ctx); } else /* Standard case. */ { /* L1 = 3X^2 + aZ^4 */ /* T1: used for aZ^4. */ - ec_powm (l1, point->x, ctx->two, ctx); - ec_mulm (l1, l1, ctx->three, ctx); - ec_powm (t1, point->z, ctx->four, ctx); - ec_mulm (t1, t1, ctx->a, ctx); - ec_addm (l1, l1, t1, ctx); + ec_powm (l1, point->x, ctx->two, ctx); + ec_mulm (l1, l1, ctx->three, ctx); + ec_powm (t1, point->z, ctx->four, ctx); + ec_mulm (t1, t1, ctx->a, ctx); + ec_addm (l1, l1, t1, ctx); } /* Z3 = 2YZ */ ec_mulm (z3, point->y, point->z, ctx); - ec_mulm (z3, z3, ctx->two, ctx); + ec_mulm (z3, z3, ctx->two, ctx); /* L2 = 4XY^2 */ /* T2: used for Y2; required later. */ @@ -436,10 +436,10 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx) ec_powm (x3, l1, ctx->two, ctx); ec_mulm (t1, l2, ctx->two, ctx); ec_subm (x3, x3, t1, ctx); - + /* L3 = 8Y^4 */ /* T2: taken from above. */ - ec_powm (t2, t2, ctx->two, ctx); + ec_powm (t2, t2, ctx->two, ctx); ec_mulm (l3, t2, ctx->eight, ctx); /* Y3 = L1(L2 - X3) - L3 */ @@ -463,8 +463,8 @@ _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx) /* RESULT = P1 + P2 */ void -_gcry_mpi_ec_add_points (mpi_point_t *result, - mpi_point_t *p1, mpi_point_t *p2, +_gcry_mpi_ec_add_points (mpi_point_t *result, + mpi_point_t *p1, mpi_point_t *p2, mpi_ec_t ctx) { #define x1 (p1->x ) @@ -518,14 +518,14 @@ _gcry_mpi_ec_add_points (mpi_point_t *result, mpi_set (l1, x1); else { - ec_powm (l1, z2, ctx->two, ctx); + ec_powm (l1, z2, ctx->two, ctx); ec_mulm (l1, l1, x1, ctx); } if (z1_is_one) mpi_set (l2, x1); else { - ec_powm (l2, z1, ctx->two, ctx); + ec_powm (l2, z1, ctx->two, ctx); ec_mulm (l2, l2, x2, ctx); } /* l3 = l1 - l2 */ @@ -620,16 +620,16 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, nbits = mpi_get_nbits (scalar); mpi_set_ui (result->x, 1); mpi_set_ui (result->y, 1); - mpi_set_ui (result->z, 0); + mpi_set_ui (result->z, 0); for (i=nbits-1; i >= 0; i--) { _gcry_mpi_ec_dup_point (result, result, ctx); if (mpi_test_bit (scalar, i) == 1) - _gcry_mpi_ec_add_points (result, result, point, ctx); + _gcry_mpi_ec_add_points (result, result, point, ctx); } -#else +#else gcry_mpi_t x1, y1, z1, k, h, yy; unsigned int i, loops; mpi_point_t p1, p2, p1inv; @@ -638,16 +638,16 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, y1 = mpi_alloc_like (ctx->p); h = mpi_alloc_like (ctx->p); k = mpi_copy (scalar); - yy = mpi_copy (point->y); + yy = mpi_copy (point->y); if ( mpi_is_neg (k) ) - { + { k->sign = 0; ec_invm (yy, yy, ctx); } if (!mpi_cmp_ui (point->z, 1)) - { + { mpi_set (x1, point->x); mpi_set (y1, yy); } @@ -657,12 +657,12 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, z2 = mpi_alloc_like (ctx->p); z3 = mpi_alloc_like (ctx->p); - ec_mulm (z2, point->z, point->z, ctx); - ec_mulm (z3, point->z, z2, ctx); - ec_invm (z2, z2, ctx); + ec_mulm (z2, point->z, point->z, ctx); + ec_mulm (z3, point->z, z2, ctx); + ec_invm (z2, z2, ctx); ec_mulm (x1, point->x, z2, ctx); - ec_invm (z3, z3, ctx); - ec_mulm (y1, yy, z3, ctx); + ec_invm (z3, z3, ctx); + ec_mulm (y1, yy, z3, ctx); mpi_free (z2); mpi_free (z3); } @@ -673,7 +673,7 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, mpi_set (result->x, point->x); mpi_set (result->y, yy); mpi_free (yy); yy = NULL; - mpi_set (result->z, point->z); + mpi_set (result->z, point->z); p1.x = x1; x1 = NULL; p1.y = y1; y1 = NULL; @@ -682,12 +682,12 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, point_init (&p1inv); for (i=loops-2; i > 0; i--) - { + { _gcry_mpi_ec_dup_point (result, result, ctx); if (mpi_test_bit (h, i) == 1 && mpi_test_bit (k, i) == 0) - { + { point_set (&p2, result); - _gcry_mpi_ec_add_points (result, &p2, &p1, ctx); + _gcry_mpi_ec_add_points (result, &p2, &p1, ctx); } if (mpi_test_bit (h, i) == 0 && mpi_test_bit (k, i) == 1) { @@ -695,7 +695,7 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, /* Invert point: y = p - y mod p */ point_set (&p1inv, &p1); ec_subm (p1inv.y, ctx->p, p1inv.y, ctx); - _gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx); + _gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx); } } @@ -706,4 +706,3 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result, mpi_free (k); #endif } - diff --git a/mpi/mpi-add.c b/mpi/mpi-add.c index ada257ae..98abc565 100644 --- a/mpi/mpi-add.c +++ b/mpi/mpi-add.c @@ -233,4 +233,3 @@ gcry_mpi_subm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m) gcry_mpi_sub(w, u, v); _gcry_mpi_fdiv_r( w, w, m ); } - diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c index dbfdfcfa..cdc6b0b3 100644 --- a/mpi/mpi-bit.c +++ b/mpi/mpi-bit.c @@ -120,7 +120,7 @@ gcry_mpi_set_bit( gcry_mpi_t a, unsigned int n ) limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; - if ( limbno >= a->nlimbs ) + if ( limbno >= a->nlimbs ) { mpi_resize (a, limbno+1 ); a->nlimbs = limbno+1; @@ -135,12 +135,12 @@ void gcry_mpi_set_highbit( gcry_mpi_t a, unsigned int n ) { unsigned int limbno, bitno; - + limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; - - if ( limbno >= a->nlimbs ) - { + + if ( limbno >= a->nlimbs ) + { mpi_resize (a, limbno+1 ); a->nlimbs = limbno+1; } @@ -276,7 +276,7 @@ gcry_mpi_rshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) x->sign = a->sign; RESIZE_IF_NEEDED (x, xsize); x->nlimbs = xsize; - + if ( xsize ) { if (nbits ) @@ -362,4 +362,3 @@ gcry_mpi_lshift ( gcry_mpi_t x, gcry_mpi_t a, unsigned int n ) MPN_NORMALIZE (x->d, x->nlimbs); } - diff --git a/mpi/mpi-div.c b/mpi/mpi-div.c index 0d8a2d16..a6ee3006 100644 --- a/mpi/mpi-div.c +++ b/mpi/mpi-div.c @@ -353,6 +353,3 @@ gcry_mpi_div (gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t d else log_bug ("mpi rounding to ceiling not yet implemented\n"); } - - - diff --git a/mpi/mpi-gcd.c b/mpi/mpi-gcd.c index 51841e78..5cbefa12 100644 --- a/mpi/mpi-gcd.c +++ b/mpi/mpi-gcd.c @@ -49,6 +49,3 @@ gcry_mpi_gcd( gcry_mpi_t g, gcry_mpi_t xa, gcry_mpi_t xb ) mpi_free(b); return !gcry_mpi_cmp_ui( g, 1); } - - - diff --git a/mpi/mpi-inline.c b/mpi/mpi-inline.c index fdccb8f1..39e22224 100644 --- a/mpi/mpi-inline.c +++ b/mpi/mpi-inline.c @@ -33,4 +33,3 @@ * of the macro allows us to do so */ #include "mpi-inline.h" - diff --git a/mpi/mpi-internal.h b/mpi/mpi-internal.h index f9c1f9d4..e75b7c6d 100644 --- a/mpi/mpi-internal.h +++ b/mpi/mpi-internal.h @@ -275,4 +275,3 @@ mpi_limb_t _gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, #endif #endif /*G10_MPI_INTERNAL_H*/ - diff --git a/mpi/mpi-mod.c b/mpi/mpi-mod.c index 948bf231..7ebfe6dc 100644 --- a/mpi/mpi-mod.c +++ b/mpi/mpi-mod.c @@ -3,17 +3,17 @@ 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, @@ -35,7 +35,7 @@ struct barrett_ctx_s gcry_mpi_t m; /* The modulus - may not be modified. */ int m_copied; /* If true, M needs to be released. */ int k; - gcry_mpi_t y; + gcry_mpi_t y; gcry_mpi_t r1; /* Helper MPI. */ gcry_mpi_t r2; /* Helper MPI. */ gcry_mpi_t r3; /* Helper MPI allocated on demand. */ @@ -56,7 +56,7 @@ _gcry_mpi_mod (gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor) _gcry_mpi_barrett_free. If COPY is true M will be transferred to the context and the user may change M. If COPY is false, M may not be changed until gcry_mpi_barrett_free has been called. */ -mpi_barrett_t +mpi_barrett_t _gcry_mpi_barrett_init (gcry_mpi_t m, int copy) { mpi_barrett_t ctx; @@ -137,7 +137,7 @@ _gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx) /* 1. q1 = floor( x / b^k-1) * q2 = q1 * y * q3 = floor( q2 / b^k+1 ) - * Actually, we don't need qx, we can work direct on r2 + * Actually, we don't need qx, we can work direct on r2 */ mpi_set ( r2, x ); mpi_rshift_limbs ( r2, k-1 ); @@ -167,7 +167,7 @@ _gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx) } mpi_add ( r, r, ctx->r3 ); } - + /* 4. while r >= m do r = r - m */ while ( mpi_cmp( r, m ) >= 0 ) mpi_sub ( r, r, m ); @@ -182,4 +182,3 @@ _gcry_mpi_mul_barrett (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_mul (w, u, v); mpi_mod_barrett (w, w, ctx); } - diff --git a/mpi/mpi-mpow.c b/mpi/mpi-mpow.c index 131c5b67..ca5b3f18 100644 --- a/mpi/mpi-mpow.c +++ b/mpi/mpi-mpow.c @@ -221,4 +221,3 @@ calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcr return 0; } #endif /* USE_BARRETT */ - diff --git a/mpi/mpi-mul.c b/mpi/mpi-mul.c index 25aeaa0a..9aefd217 100644 --- a/mpi/mpi-mul.c +++ b/mpi/mpi-mul.c @@ -144,7 +144,7 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) wsize = usize + vsize; if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) { /* w is not allocated in secure space but u or v is. To make sure - * that no temporray results are stored in w, we temporary use + * that no temporray results are stored in w, we temporary use * a newly allocated limb space for w */ wp = mpi_alloc_limb_space( wsize, 1 ); assign_wp = 2; /* mark it as 2 so that we can later copy it back to @@ -210,4 +210,3 @@ gcry_mpi_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m) gcry_mpi_mul(w, u, v); _gcry_mpi_fdiv_r( w, w, m ); } - diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c index ca7ead02..fbdb7ce5 100644 --- a/mpi/mpi-pow.c +++ b/mpi/mpi-pow.c @@ -37,7 +37,7 @@ * RES = BASE ^ EXPO mod MOD */ void -gcry_mpi_powm (gcry_mpi_t res, +gcry_mpi_powm (gcry_mpi_t res, gcry_mpi_t base, gcry_mpi_t expo, gcry_mpi_t mod) { /* Pointer to the limbs of the arguments, their size and signs. */ @@ -45,7 +45,7 @@ gcry_mpi_powm (gcry_mpi_t res, mpi_size_t esize, msize, bsize, rsize; int msign, bsign, rsign; /* Flags telling the secure allocation status of the arguments. */ - int esec, msec, bsec, rsec; + int esec, msec, bsec, rsec; /* Size of the result including space for temporary values. */ mpi_size_t size; /* Helper. */ @@ -60,14 +60,14 @@ gcry_mpi_powm (gcry_mpi_t res, unsigned int ep_nlimbs = 0; unsigned int xp_nlimbs = 0; mpi_ptr_t tspace = NULL; - mpi_size_t tsize = 0; + mpi_size_t tsize = 0; esize = expo->nlimbs; msize = mod->nlimbs; size = 2 * msize; msign = mod->sign; - + esec = mpi_is_secure(expo); msec = mpi_is_secure(mod); bsec = mpi_is_secure(base); @@ -79,7 +79,7 @@ gcry_mpi_powm (gcry_mpi_t res, if (!msize) msize = 1 / msize; /* Provoke a signal. */ - if (!esize) + if (!esize) { /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 depending on if MOD equals 1. */ @@ -103,7 +103,7 @@ gcry_mpi_powm (gcry_mpi_t res, bsize = base->nlimbs; bsign = base->sign; - if (bsize > msize) + if (bsize > msize) { /* The base is larger than the module. Reduce it. @@ -147,7 +147,7 @@ gcry_mpi_powm (gcry_mpi_t res, ep = ep_marker = mpi_alloc_limb_space( esize, esec ); MPN_COPY(ep, rp, esize); } - if ( rp == mp ) + if ( rp == mp ) { /* RES and MOD are identical. Allocate temporary space for MOD.*/ gcry_assert (!mp_marker); @@ -165,7 +165,7 @@ gcry_mpi_powm (gcry_mpi_t res, MPN_COPY ( rp, bp, bsize ); rsize = bsize; rsign = bsign; - + /* Main processing. */ { mpi_size_t i; @@ -174,13 +174,13 @@ gcry_mpi_powm (gcry_mpi_t res, mpi_limb_t e; mpi_limb_t carry_limb; struct karatsuba_ctx karactx; - + xp_nlimbs = msec? (2 * (msize + 1)):0; xp = xp_marker = mpi_alloc_limb_space( 2 * (msize + 1), msec ); - + memset( &karactx, 0, sizeof karactx ); negative_result = (ep[0] & 1) && base->sign; - + i = esize - 1; e = ep[i]; count_leading_zeros (c, e); @@ -188,7 +188,7 @@ gcry_mpi_powm (gcry_mpi_t res, c = BITS_PER_MPI_LIMB - 1 - c; /* Main loop. - + Make the result be pointed to alternately by XP and RP. This helps us avoid block copying, which would otherwise be necessary with the overlap restrictions of @@ -197,17 +197,17 @@ gcry_mpi_powm (gcry_mpi_t res, and with 50% probability in the area originally pointed to by XP. */ for (;;) { - while (c) + while (c) { mpi_ptr_t tp; mpi_size_t xsize; - + /*mpih_mul_n(xp, rp, rp, rsize);*/ if ( rsize < KARATSUBA_THRESHOLD ) _gcry_mpih_sqr_n_basecase( xp, rp, rsize ); - else + else { - if ( !tspace ) + if ( !tspace ) { tsize = 2 * rsize; tspace = mpi_alloc_limb_space( tsize, 0 ); @@ -234,19 +234,19 @@ gcry_mpi_powm (gcry_mpi_t res, if ( (mpi_limb_signed_t)e < 0 ) { /*mpih_mul( xp, rp, rsize, bp, bsize );*/ - if( bsize < KARATSUBA_THRESHOLD ) + if( bsize < KARATSUBA_THRESHOLD ) _gcry_mpih_mul ( xp, rp, rsize, bp, bsize ); - else + else _gcry_mpih_mul_karatsuba_case (xp, rp, rsize, bp, bsize, &karactx); - + xsize = rsize + bsize; - if ( xsize > msize ) + if ( xsize > msize ) { _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize); xsize = msize; } - + tp = rp; rp = xp; xp = tp; rsize = xsize; } @@ -267,7 +267,7 @@ gcry_mpi_powm (gcry_mpi_t res, Also make sure the result is put in RES->d (where it already might be, see above). */ - if ( mod_shift_cnt ) + if ( mod_shift_cnt ) { carry_limb = _gcry_mpih_lshift( res->d, rp, rsize, mod_shift_cnt); rp = res->d; @@ -283,7 +283,7 @@ gcry_mpi_powm (gcry_mpi_t res, rp = res->d; } - if ( rsize >= msize ) + if ( rsize >= msize ) { _gcry_mpih_divrem(rp + msize, 0, rp, rsize, mp, msize); rsize = msize; @@ -293,7 +293,7 @@ gcry_mpi_powm (gcry_mpi_t res, if ( mod_shift_cnt ) _gcry_mpih_rshift( rp, rp, rsize, mod_shift_cnt); MPN_NORMALIZE (rp, rsize); - + _gcry_mpih_release_karatsuba_ctx (&karactx ); } @@ -310,7 +310,7 @@ gcry_mpi_powm (gcry_mpi_t res, gcry_assert (res->d == rp); res->nlimbs = rsize; res->sign = rsign; - + leave: if (mp_marker) _gcry_mpi_free_limb_space( mp_marker, mp_nlimbs ); @@ -323,4 +323,3 @@ gcry_mpi_powm (gcry_mpi_t res, if (tspace) _gcry_mpi_free_limb_space( tspace, 0 ); } - diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c index 90699cdd..2473cd9b 100644 --- a/mpi/mpi-scan.c +++ b/mpi/mpi-scan.c @@ -128,5 +128,3 @@ _gcry_mpi_trailing_zeros( gcry_mpi_t a ) return count; } - - diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index d73b5624..f499796d 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -37,7 +37,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread, unsigned int nbits, nbytes, nlimbs, nread=0; mpi_limb_t a; gcry_mpi_t val = MPI_NULL; - + if ( *ret_nread < 2 ) goto leave; nbits = buffer[0] << 8 | buffer[1]; @@ -59,7 +59,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread, for ( ; j > 0; j-- ) { a = 0; - for (; i < BYTES_PER_MPI_LIMB; i++ ) + for (; i < BYTES_PER_MPI_LIMB; i++ ) { if ( ++nread > *ret_nread ) { @@ -74,7 +74,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread, i = 0; val->d[j-1] = a; } - + leave: *ret_nread = nread; return val; @@ -159,7 +159,7 @@ mpi_fromstr (gcry_mpi_t val, const char *str) c |= c2 - 'a' + 10; else if( c2 >= 'A' && c2 <= 'F' ) c |= c2 - 'A' + 10; - else + else { mpi_clear(val); return 1; /* Error. */ @@ -170,7 +170,7 @@ mpi_fromstr (gcry_mpi_t val, const char *str) i = 0; val->d[j-1] = a; } - + return 0; /* Okay. */ } @@ -179,7 +179,7 @@ mpi_fromstr (gcry_mpi_t val, const char *str) Libgcrypt's logging stream. Note that one leading space but no trailing space or linefeed will be printed. It is okay to pass NULL for A. */ -void +void gcry_mpi_dump (const gcry_mpi_t a) { int i; @@ -187,7 +187,7 @@ gcry_mpi_dump (const gcry_mpi_t a) log_printf (" "); if (!a) log_printf ("[MPI_NULL]"); - else + else { if (a->sign) log_printf ( "-"); @@ -235,7 +235,7 @@ do_get_buffer (gcry_mpi_t a, unsigned int *nbytes, int *sign, int force_secure) mpi_limb_t alimb; int i; size_t n; - + if (sign) *sign = a->sign; @@ -304,12 +304,12 @@ _gcry_mpi_set_buffer (gcry_mpi_t a, const void *buffer_arg, mpi_limb_t alimb; int nlimbs; int i; - + nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB; RESIZE_IF_NEEDED(a, nlimbs); a->sign = sign; - - for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) + + for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) { #if BYTES_PER_MPI_LIMB == 4 alimb = *p-- ; @@ -383,7 +383,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, len = 0; else len = buflen; - + if (format == GCRYMPI_FMT_STD) { const unsigned char *s = buffer; @@ -392,7 +392,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, /BYTES_PER_MPI_LIMB) : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB); if (len) - { + { a->sign = !!(*s & 0x80); if (a->sign) { @@ -450,7 +450,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, { const unsigned char *s = buffer; size_t n; - + /* This test is not strictly necessary and an assert (!len) would be sufficient. We keep this test in case we later allow the BUFLEN argument to act as a sanitiy check. Same @@ -459,7 +459,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, return gcry_error (GPG_ERR_TOO_SHORT); n = (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); - s += 4; + s += 4; if (len) len -= 4; if (len && n > len) @@ -495,7 +495,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, { /* We can only handle C strings for now. */ if (buflen) - return gcry_error (GPG_ERR_INV_ARG); + return gcry_error (GPG_ERR_INV_ARG); a = secure? mpi_alloc_secure (0) : mpi_alloc(0); if (mpi_fromstr (a, (const char *)buffer)) @@ -503,7 +503,7 @@ gcry_mpi_scan (struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, mpi_free (a); return gcry_error (GPG_ERR_INV_OBJ); } - if (ret_mpi) + if (ret_mpi) { mpi_normalize ( a ); *ret_mpi = a; @@ -531,18 +531,18 @@ gcry_mpi_print (enum gcry_mpi_format format, unsigned int nbits = mpi_get_nbits (a); size_t len; size_t dummy_nwritten; - + if (!nwritten) nwritten = &dummy_nwritten; len = buflen; *nwritten = 0; - if (format == GCRYMPI_FMT_STD) + if (format == GCRYMPI_FMT_STD) { unsigned char *tmp; int extra = 0; unsigned int n; - + if (a->sign) return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */ @@ -554,12 +554,12 @@ gcry_mpi_print (enum gcry_mpi_format format, n++; extra=1; } - + if (buffer && n > len) { /* The provided buffer is too short. */ gcry_free (tmp); - return gcry_error (GPG_ERR_TOO_SHORT); + return gcry_error (GPG_ERR_TOO_SHORT); } if (buffer) { @@ -598,10 +598,10 @@ gcry_mpi_print (enum gcry_mpi_format format, else if (format == GCRYMPI_FMT_PGP) { unsigned int n = (nbits + 7)/8; - + /* The PGP format can only handle unsigned integers. */ if( a->sign ) - return gcry_error (GPG_ERR_INV_ARG); + return gcry_error (GPG_ERR_INV_ARG); if (buffer && n+2 > len) return gcry_error (GPG_ERR_TOO_SHORT); @@ -613,7 +613,7 @@ gcry_mpi_print (enum gcry_mpi_format format, s[0] = nbits >> 8; s[1] = nbits; - + tmp = _gcry_mpi_get_buffer (a, &n, NULL); if (!tmp) return gpg_error_from_syserror (); @@ -628,10 +628,10 @@ gcry_mpi_print (enum gcry_mpi_format format, unsigned char *tmp; int extra = 0; unsigned int n; - + if (a->sign) return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */ - + tmp = _gcry_mpi_get_buffer (a, &n, NULL); if (!tmp) return gpg_error_from_syserror (); @@ -650,14 +650,14 @@ gcry_mpi_print (enum gcry_mpi_format format, if (buffer) { unsigned char *s = buffer; - + *s++ = n >> 24; *s++ = n >> 16; *s++ = n >> 8; *s++ = n; if (extra) *s++ = 0; - + memcpy (s, tmp, n-extra); } gcry_free (tmp); @@ -670,7 +670,7 @@ gcry_mpi_print (enum gcry_mpi_format format, int i; int extra = 0; unsigned int n = 0; - + tmp = _gcry_mpi_get_buffer (a, &n, NULL); if (!tmp) return gpg_error_from_syserror (); @@ -693,7 +693,7 @@ gcry_mpi_print (enum gcry_mpi_format format, *s++ = '0'; *s++ = '0'; } - + for (i=0; i < n; i++) { unsigned int c = tmp[i]; @@ -705,7 +705,7 @@ gcry_mpi_print (enum gcry_mpi_format format, *s++ = 0; *nwritten = s - buffer; } - else + else { *nwritten = 2*n + extra + !!a->sign + 1; } @@ -729,7 +729,7 @@ gcry_mpi_aprint (enum gcry_mpi_format format, { size_t n; gcry_error_t rc; - + *buffer = NULL; rc = gcry_mpi_print (format, NULL, 0, &n, a); if (rc) @@ -748,4 +748,3 @@ gcry_mpi_aprint (enum gcry_mpi_format format, *nwritten = n; return rc; } - diff --git a/mpi/mpih-div.c b/mpi/mpih-div.c index e41e205e..224b8108 100644 --- a/mpi/mpih-div.c +++ b/mpi/mpih-div.c @@ -531,5 +531,3 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, return r; } } - - diff --git a/mpi/mpih-mul.c b/mpi/mpih-mul.c index e1f6f58e..b8e05617 100644 --- a/mpi/mpih-mul.c +++ b/mpi/mpih-mul.c @@ -526,5 +526,3 @@ _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, _gcry_mpih_release_karatsuba_ctx( &ctx ); return *prod_endp; } - - diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index 950e4ea5..76630a62 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -100,7 +100,7 @@ _gcry_mpi_free_limb_space( mpi_ptr_t a, unsigned int nlimbs) if (a) { size_t len = nlimbs * sizeof(mpi_limb_t); - + /* If we have information on the number of allocated limbs, we better wipe that space out. This is a failsafe feature if secure memory has been disabled or was not properly @@ -137,7 +137,7 @@ _gcry_mpi_resize (gcry_mpi_t a, unsigned nlimbs) limb space is already of the correct size. */ for (i=a->nlimbs; i < a->alloced; i++) a->d[i] = 0; - return; + return; } /* Actually resize the limb space. */ @@ -207,12 +207,12 @@ mpi_set_secure( gcry_mpi_t a ) gcry_mpi_t gcry_mpi_set_opaque( gcry_mpi_t a, void *p, unsigned int nbits ) { - if (!a) + if (!a) a = mpi_alloc(0); - + if( a->flags & 4 ) gcry_free( a->d ); - else + else _gcry_mpi_free_limb_space (a->d, a->alloced); a->d = p; @@ -302,7 +302,7 @@ gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u) mpi_ptr_t wp, up; mpi_size_t usize = u->nlimbs; int usign = u->sign; - + if (!w) w = _gcry_mpi_alloc( mpi_get_nlimbs(u) ); RESIZE_IF_NEEDED(w, usize); @@ -346,7 +346,7 @@ _gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u) if (! err) *u = x; - + return err; } @@ -356,7 +356,7 @@ gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u) gcry_err_code_t err = GPG_ERR_NO_ERROR; err = _gcry_mpi_get_ui (w, u); - + return gcry_error (err); } @@ -406,7 +406,7 @@ gcry_mpi_randomize( gcry_mpi_t w, { unsigned char *p; size_t nbytes = (nbits+7)/8; - + if (level == GCRY_WEAK_RANDOM) { p = mpi_is_secure(w) ? gcry_xmalloc_secure (nbytes) @@ -458,4 +458,3 @@ gcry_mpi_get_flag( gcry_mpi_t a, enum gcry_mpi_flag flag ) /*NOTREACHED*/ return 0; } - diff --git a/random/ChangeLog b/random/ChangeLog index f70f30b4..7784d44e 100644 --- a/random/ChangeLog +++ b/random/ChangeLog @@ -64,14 +64,14 @@ 2008-09-15 Werner Koch * random.c (_gcry_random_init_external_test): New. - (_gcry_random_run_external_test): New. + (_gcry_random_run_external_test): New. (_gcry_random_deinit_external_test): New. * random-fips.c (struct rng_context): Turn TEST_DT_COUNTER into a 32 bit integer. (x931_get_dt): Ditto. (selftest_kat): Intialize it accordingly. (_gcry_rngfips_init_external_test): New. - (_gcry_rngfips_run_external_test): New. + (_gcry_rngfips_run_external_test): New. (_gcry_rngfips_deinit_external_test): New. 2008-09-05 Werner Koch @@ -173,4 +173,3 @@ 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. - diff --git a/random/Makefile.am b/random/Makefile.am index 2058d563..603226d8 100644 --- a/random/Makefile.am +++ b/random/Makefile.am @@ -20,7 +20,7 @@ # Need to include ../src in addition to top_srcdir because gcrypt.h is # a built header. -AM_CPPFLAGS = -I../src -I$(top_srcdir)/src +AM_CPPFLAGS = -I../src -I$(top_srcdir)/src AM_CFLAGS = $(GPG_ERROR_CFLAGS) noinst_LTLIBRARIES = librandom.la @@ -38,7 +38,7 @@ random-fips.c \ rndhw.c if USE_RANDOM_DAEMON -librandom_la_SOURCES += random-daemon.c +librandom_la_SOURCES += random-daemon.c endif USE_RANDOM_DAEMON diff --git a/random/rand-internal.h b/random/rand-internal.h index 2cce9065..a04a2d41 100644 --- a/random/rand-internal.h +++ b/random/rand-internal.h @@ -24,7 +24,7 @@ /* Constants used to define the origin of random added to the pool. The code is sensitive to the order of the values. */ -enum random_origins +enum random_origins { RANDOM_ORIGIN_INIT = 0, /* Used only for initialization. */ RANDOM_ORIGIN_EXTERNAL = 1, /* Added from an external source. */ @@ -54,7 +54,7 @@ gcry_error_t _gcry_rngcsprng_add_bytes (const void *buf, size_t buflen, int quality); void *_gcry_rngcsprng_get_bytes (size_t nbytes, enum gcry_random_level level); -void *_gcry_rngcsprng_get_bytes_secure (size_t nbytes, +void *_gcry_rngcsprng_get_bytes_secure (size_t nbytes, enum gcry_random_level level); void _gcry_rngcsprng_randomize (void *buffer, size_t length, enum gcry_random_level level); @@ -71,7 +71,7 @@ gcry_error_t _gcry_rngfips_add_bytes (const void *buf, size_t buflen, int quality); void *_gcry_rngfips_get_bytes (size_t nbytes, enum gcry_random_level level); -void *_gcry_rngfips_get_bytes_secure (size_t nbytes, +void *_gcry_rngfips_get_bytes_secure (size_t nbytes, enum gcry_random_level level); void _gcry_rngfips_randomize (void *buffer, size_t length, enum gcry_random_level level); @@ -119,7 +119,7 @@ int _gcry_rndw32_gather_random (void (*add) (const void *, size_t, enum random_origins), enum random_origins origin, size_t length, int level); -void _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, +void _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, enum random_origins), enum random_origins origin ); @@ -128,7 +128,7 @@ int _gcry_rndw32ce_gather_random (void (*add) (const void *, size_t, enum random_origins), enum random_origins origin, size_t length, int level); -void _gcry_rndw32ce_gather_random_fast (void (*add)(const void*, size_t, +void _gcry_rndw32ce_gather_random_fast (void (*add)(const void*, size_t, enum random_origins), enum random_origins origin ); diff --git a/random/random-csprng.c b/random/random-csprng.c index 1d2e5191..096a6748 100644 --- a/random/random-csprng.c +++ b/random/random-csprng.c @@ -101,11 +101,11 @@ up. Its allocated size is POOLSIZE+BLOCKLEN. Note that this is also an indication on whether the module has been fully initialized. */ -static unsigned char *rndpool; +static unsigned char *rndpool; /* KEYPOOL is used as a scratch copy to read out random from RNDPOOL. Its allocated size is also POOLSIZE+BLOCKLEN. */ -static unsigned char *keypool; +static unsigned char *keypool; /* This is the offset into RNDPOOL where the next random bytes are to be mixed in. */ @@ -221,7 +221,7 @@ static struct test this flag in a locked state because a wrong value does not harm and the trhead will find out itself that the daemon does not work and set it (again) to false. */ -static int allow_daemon; +static int allow_daemon; /* During initialization, the user may set a non-default socket name for accessing the random daemon. If this value is NULL, the @@ -234,12 +234,12 @@ static char *daemon_socket_name; /* --- Prototypes --- */ static void read_pool (byte *buffer, size_t length, int level ); -static void add_randomness (const void *buffer, size_t length, +static void add_randomness (const void *buffer, size_t length, enum random_origins origin); static void random_poll (void); static void do_fast_random_poll (void); -static int (*getfnc_gather_random (void))(void (*)(const void*, size_t, - enum random_origins), +static int (*getfnc_gather_random (void))(void (*)(const void*, size_t, + enum random_origins), enum random_origins, size_t, int); static void (*getfnc_fast_random_poll (void))(void (*)(const void*, size_t, enum random_origins), @@ -271,7 +271,7 @@ initialize_basics(void) err = ath_mutex_init (&pool_lock); if (err) log_fatal ("failed to create the pool lock: %s\n", strerror (err) ); - + err = ath_mutex_init (&nonce_buffer_lock); if (err) log_fatal ("failed to create the nonce buffer lock: %s\n", @@ -283,7 +283,7 @@ initialize_basics(void) /* Make sure that we are still using the values we have traditionally used for the random levels. */ - gcry_assert (GCRY_WEAK_RANDOM == 0 + gcry_assert (GCRY_WEAK_RANDOM == 0 && GCRY_STRONG_RANDOM == 1 && GCRY_VERY_STRONG_RANDOM == 2); } @@ -293,7 +293,7 @@ initialize_basics(void) static void lock_pool (void) { - int err; + int err; err = ath_mutex_lock (&pool_lock); if (err) @@ -305,7 +305,7 @@ lock_pool (void) static void unlock_pool (void) { - int err; + int err; pool_is_locked = 0; err = ath_mutex_unlock (&pool_lock); @@ -345,7 +345,7 @@ initialize(void) faked_rng = 1; slow_gather_fnc = gather_faked; } - + /* Setup the fast entropy gathering function. */ fast_gather_fnc = getfnc_fast_random_poll (); @@ -427,7 +427,7 @@ _gcry_rngcsprng_use_daemon (int onoff) { #ifdef USE_RANDOM_DAEMON int last; - + /* This is not really thread safe. However it is expected that this function is being called during initialization and at that point we are for other reasons not really thread safe. We do not want @@ -472,7 +472,7 @@ _gcry_rngcsprng_add_bytes (const void *buf, size_t buflen, int quality) quality = 100; else if (quality < 0) quality = 0; - + if (!buf) return gpg_error (GPG_ERR_INV_ARG); @@ -496,9 +496,9 @@ _gcry_rngcsprng_add_bytes (const void *buf, size_t buflen, int quality) buflen -= nbytes; } return 0; -} +} + - /* Public function to fill the buffer with LENGTH bytes of cryptographically strong random bytes. Level GCRY_WEAK_RANDOM is not very strong, GCRY_STRONG_RANDOM is strong enough for most @@ -564,13 +564,13 @@ _gcry_rngcsprng_randomize (void *buffer, size_t length, Mix the pool: |........blocks*20byte........|20byte|..44byte..| - <..44byte..> <20byte> + <..44byte..> <20byte> | | | +------+ +---------------------------|----------+ v v |........blocks*20byte........|20byte|..44byte..| - <.....64bytes.....> + <.....64bytes.....> | +----------------------------------+ Hash @@ -590,7 +590,7 @@ _gcry_rngcsprng_randomize (void *buffer, size_t length, |.............................|20byte|..44byte..| <20byte><20byte><..44byte..> - and so on until we did this for all blocks. + and so on until we did this for all blocks. To better protect against implementation errors in this code, we xor a digest of the entire pool into the pool before mixing. @@ -627,7 +627,7 @@ mix_pool(unsigned char *pool) for (i=0; i < 20; i++) pool[i] ^= failsafe_digest[i]; } - + p = pool; for (n=1; n < POOLBLOCKS; n++) { @@ -636,10 +636,10 @@ mix_pool(unsigned char *pool) p += DIGESTLEN; if (p+DIGESTLEN+BLOCKLEN < pend) memcpy (hashbuf+DIGESTLEN, p+DIGESTLEN, BLOCKLEN-DIGESTLEN); - else + else { unsigned char *pp = p + DIGESTLEN; - + for (i=DIGESTLEN; i < BLOCKLEN; i++ ) { if ( pp >= pend ) @@ -647,7 +647,7 @@ mix_pool(unsigned char *pool) hashbuf[i] = *pp++; } } - + _gcry_rmd160_mixblock ( &md, hashbuf); memcpy(p, hashbuf, 20 ); } @@ -705,7 +705,7 @@ lock_seed_file (int fd, const char *fname, int for_write) if (backoff > 2) /* Show the first message after ~2.25 seconds. */ log_info( _("waiting for lock on `%s'...\n"), fname); - + tv.tv_sec = backoff; tv.tv_usec = 250000; select (0, NULL, NULL, NULL, &tv); @@ -744,7 +744,7 @@ read_seed_file (void) if (!seed_file_name) return 0; - + #ifdef HAVE_DOSISH_SYSTEM fd = open( seed_file_name, O_RDONLY | O_BINARY ); #else @@ -785,7 +785,7 @@ read_seed_file (void) allow_seed_file_update = 1; return 0; } - if (sb.st_size != POOLSIZE ) + if (sb.st_size != POOLSIZE ) { log_info(_("warning: invalid size of random_seed file - not used\n") ); close(fd); @@ -795,7 +795,7 @@ read_seed_file (void) do { n = read( fd, buffer, POOLSIZE ); - } + } while (n == -1 && errno == EINTR ); if (n != POOLSIZE) @@ -804,12 +804,12 @@ read_seed_file (void) close(fd);/*NOTREACHED*/ return 0; } - + close(fd); add_randomness( buffer, POOLSIZE, RANDOM_ORIGIN_INIT ); /* add some minor entropy to the pool now (this will also force a mixing) */ - { + { pid_t x = getpid(); add_randomness( &x, sizeof(x), RANDOM_ORIGIN_INIT ); } @@ -817,7 +817,7 @@ read_seed_file (void) time_t x = time(NULL); add_randomness( &x, sizeof(x), RANDOM_ORIGIN_INIT ); } - { + { clock_t x = clock(); add_randomness( &x, sizeof(x), RANDOM_ORIGIN_INIT ); } @@ -865,7 +865,7 @@ _gcry_rngcsprng_update_seed_file (void) /* Copy the entropy pool to a scratch pool and mix both of them. */ for (i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool; - i < POOLWORDS; i++, dp++, sp++ ) + i < POOLWORDS; i++, dp++, sp++ ) { *dp = *sp + ADD_VALUE; } @@ -896,19 +896,19 @@ _gcry_rngcsprng_update_seed_file (void) close (fd); } #endif /*LOCK_SEED_FILE*/ - else + else { do { i = write (fd, keypool, POOLSIZE ); - } + } while (i == -1 && errno == EINTR); - if (i != POOLSIZE) + if (i != POOLSIZE) log_info (_("can't write `%s': %s\n"),seed_file_name, strerror(errno)); if (close(fd)) log_info (_("can't close `%s': %s\n"),seed_file_name, strerror(errno)); } - + unlock_pool (); } @@ -928,7 +928,7 @@ read_pool (byte *buffer, size_t length, int level) Note that we keep a pid in a static variable as well as in a stack based one; the latter is to detect ill behaving thread libraries, ignoring the pool mutexes. */ - static volatile pid_t my_pid = (pid_t)(-1); + static volatile pid_t my_pid = (pid_t)(-1); volatile pid_t my_pid2; gcry_assert (pool_is_locked); @@ -936,7 +936,7 @@ read_pool (byte *buffer, size_t length, int level) retry: /* Get our own pid, so that we can detect a fork. */ my_pid2 = getpid (); - if (my_pid == (pid_t)(-1)) + if (my_pid == (pid_t)(-1)) my_pid = my_pid2; if ( my_pid != my_pid2 ) { @@ -987,7 +987,7 @@ read_pool (byte *buffer, size_t length, int level) if (level == GCRY_VERY_STRONG_RANDOM && pool_balance < length) { size_t needed; - + if (pool_balance < 0) pool_balance = 0; needed = length - pool_balance; @@ -1004,7 +1004,7 @@ read_pool (byte *buffer, size_t length, int level) /* Always do a fast random poll (we have to use the unlocked version). */ do_fast_random_poll(); - + /* Mix the pid in so that we for sure won't deliver the same random after a fork. */ { @@ -1037,7 +1037,7 @@ read_pool (byte *buffer, size_t length, int level) pool_readpos = 0; pool_balance--; } - + if (pool_balance < 0) pool_balance = 0; @@ -1112,13 +1112,13 @@ random_poll() /* Runtime determination of the slow entropy gathering module. */ static int (* -getfnc_gather_random (void))(void (*)(const void*, size_t, - enum random_origins), +getfnc_gather_random (void))(void (*)(const void*, size_t, + enum random_origins), enum random_origins, size_t, int) { - int (*fnc)(void (*)(const void*, size_t, enum random_origins), + int (*fnc)(void (*)(const void*, size_t, enum random_origins), enum random_origins, size_t, int); - + #if USE_RNDLINUX if ( !access (NAME_OF_DEV_RANDOM, R_OK) && !access (NAME_OF_DEV_URANDOM, R_OK)) @@ -1186,13 +1186,13 @@ do_fast_random_poll (void) /* Continue with the generic functions. */ #if HAVE_GETHRTIME - { + { hrtime_t tv; tv = gethrtime(); add_randomness( &tv, sizeof(tv), RANDOM_ORIGIN_FASTPOLL ); } #elif HAVE_GETTIMEOFDAY - { + { struct timeval tv; if( gettimeofday( &tv, NULL ) ) BUG(); @@ -1217,7 +1217,7 @@ do_fast_random_poll (void) #ifdef HAVE_GETRUSAGE # ifdef RUSAGE_SELF - { + { struct rusage buf; /* QNX/Neutrino does return ENOSYS - so we just ignore it and add whatever is in buf. In a chroot environment it might not work @@ -1240,7 +1240,7 @@ do_fast_random_poll (void) time_t x = time(NULL); add_randomness( &x, sizeof(x), RANDOM_ORIGIN_FASTPOLL ); } - { + { clock_t x = clock(); add_randomness( &x, sizeof(x), RANDOM_ORIGIN_FASTPOLL ); } @@ -1292,10 +1292,10 @@ gather_faked (void (*add)(const void*, size_t, enum random_origins), static int initialized=0; size_t n; char *buffer, *p; - + (void)add; (void)level; - + if ( !initialized ) { log_info(_("WARNING: using insecure random number generator!!\n")); @@ -1371,7 +1371,7 @@ _gcry_rngcsprng_create_nonce (void *buffer, size_t length) p = nonce_buffer; memcpy (p, &xpid, sizeof xpid); p += sizeof xpid; - memcpy (p, &atime, sizeof atime); + memcpy (p, &atime, sizeof atime); /* Initialize the never changing private part of 64 bits. */ gcry_randomize (nonce_buffer+20, 8, GCRY_WEAK_RANDOM); diff --git a/random/random-daemon.c b/random/random-daemon.c index 2e03ba00..d8bfe4c6 100644 --- a/random/random-daemon.c +++ b/random/random-daemon.c @@ -53,7 +53,7 @@ static ath_mutex_t daemon_lock = ATH_MUTEX_INITIALIZER; /* The socket connected to the daemon. */ -static int daemon_socket = -1; +static int daemon_socket = -1; /* Creates a socket connected to the daemon. On success, store the socket fd in *SOCK. Returns error code. */ @@ -78,7 +78,7 @@ connect_to_socket (const char *socketname, int *sock) } /* Set up address. */ - srvr_addr = gcry_malloc (sizeof *srvr_addr); + srvr_addr = gcry_malloc (sizeof *srvr_addr); if (! srvr_addr) { log_error ("malloc failed: %s\n", strerror (errno)); @@ -148,7 +148,7 @@ static int writen (int fd, const void *buffer, size_t length) { ssize_t n; - + while (length) { do @@ -171,7 +171,7 @@ readn (int fd, void *buf, size_t buflen, size_t *ret_nread) size_t nleft = buflen; int nread; char *p; - + p = buf; while (nleft > 0) { @@ -180,7 +180,7 @@ readn (int fd, void *buf, size_t buflen, size_t *ret_nread) { if (nread == EINTR) nread = 0; - else + else return -1; } else if (!nread) @@ -262,7 +262,7 @@ call_daemon (const char *socketname, err = gcry_error_from_errno (errno); break; } - + /* Retrieve response. */ rc = readn (daemon_socket, buf, 2, &nread); @@ -310,7 +310,7 @@ call_daemon (const char *socketname, log_error ("read error: %s\n", gcry_strerror (err)); break; } - + if (nread != nbytes) { log_error ("too little random data read\n"); @@ -333,7 +333,7 @@ call_daemon (const char *socketname, support GCRY_STRONG_RANDOM and GCRY_VERY_STRONG_RANDOM here. Return 0 on success. */ int -_gcry_daemon_randomize (const char *socketname, +_gcry_daemon_randomize (const char *socketname, void *buffer, size_t length, enum gcry_random_level level) { diff --git a/random/random-fips.c b/random/random-fips.c index f9a21d08..307d2b2a 100644 --- a/random/random-fips.c +++ b/random/random-fips.c @@ -157,7 +157,7 @@ struct rng_context /* We need to keep track of the process which did the initialization so that we can detect a fork. The volatile modifier is required so that the compiler does not optimize it away in case the getpid - function is badly attributed. */ + function is badly attributed. */ pid_t key_init_pid; pid_t seed_init_pid; }; @@ -200,10 +200,10 @@ basic_initialization (void) if (my_errno) log_fatal ("failed to create the RNG lock: %s\n", strerror (my_errno)); fips_rng_is_locked = 0; - + /* Make sure that we are still using the values we have traditionally used for the random levels. */ - gcry_assert (GCRY_WEAK_RANDOM == 0 + gcry_assert (GCRY_WEAK_RANDOM == 0 && GCRY_STRONG_RANDOM == 1 && GCRY_VERY_STRONG_RANDOM == 2); @@ -262,7 +262,7 @@ check_guards (rng_context_t rng_ctx) timestamp we construct is made up the real time and three counters: Buffer: 00112233445566778899AABBCCDDEEFF - !--+---!!-+-!!+!!--+---!!--+---! + !--+---!!-+-!!+!!--+---!!--+---! seconds ---------/ | | | | microseconds -----------/ | | | counter2 -------------------/ | | @@ -272,7 +272,7 @@ check_guards (rng_context_t rng_ctx) Counter 2 is just 12 bits wide and used to track fractions of milliseconds whereas counters 1 and 0 are combined to a free running 64 bit counter. */ -static void +static void x931_get_dt (unsigned char *buffer, size_t length, rng_context_t rng_ctx) { gcry_assert (length == 16); /* This length is required for use with AES. */ @@ -281,7 +281,7 @@ x931_get_dt (unsigned char *buffer, size_t length, rng_context_t rng_ctx) /* If the random context indicates that a test DT should be used, take the DT value from the context. For safety reasons we do this only if the context is not one of the regular contexts. */ - if (rng_ctx->test_dt_ptr + if (rng_ctx->test_dt_ptr && rng_ctx != nonce_context && rng_ctx != std_rng_context && rng_ctx != strong_rng_context) @@ -301,7 +301,7 @@ x931_get_dt (unsigned char *buffer, size_t length, rng_context_t rng_ctx) static u32 last_sec, last_usec; static u32 counter1, counter0; static u16 counter2; - + unsigned int usec; struct timeval tv; @@ -350,11 +350,11 @@ x931_get_dt (unsigned char *buffer, size_t length, rng_context_t rng_ctx) /* Add the free running counter. */ buffer[8] = ((counter1 >> 24) & 0xff); buffer[9] = ((counter1 >> 16) & 0xff); - buffer[10] = ((counter1 >> 8) & 0xff); + buffer[10] = ((counter1 >> 8) & 0xff); buffer[11] = ((counter1) & 0xff); buffer[12] = ((counter0 >> 24) & 0xff); buffer[13] = ((counter0 >> 16) & 0xff); - buffer[14] = ((counter0 >> 8) & 0xff); + buffer[14] = ((counter0 >> 8) & 0xff); buffer[15] = ((counter0) & 0xff); /* Bump up that counter. */ if (!++counter0) @@ -372,7 +372,7 @@ x931_get_dt (unsigned char *buffer, size_t length, rng_context_t rng_ctx) the result at R. R needs to be provided by the caller with a size of at least LENGTH bytes. */ static void -xor_buffer (unsigned char *r, +xor_buffer (unsigned char *r, const unsigned char *a, const unsigned char *b, size_t length) { for ( ; length; length--, a++, b++, r++) @@ -383,7 +383,7 @@ xor_buffer (unsigned char *r, /* Encrypt LENGTH bytes of INPUT to OUTPUT using KEY. LENGTH needs to be 16. */ static void -encrypt_aes (gcry_cipher_hd_t key, +encrypt_aes (gcry_cipher_hd_t key, unsigned char *output, const unsigned char *input, size_t length) { gpg_error_t err; @@ -406,7 +406,7 @@ encrypt_aes (gcry_cipher_hd_t key, On return the result is stored at RESULT_R and the SEED_V is updated. May only be used while holding the lock. */ static void -x931_aes (unsigned char result_R[16], +x931_aes (unsigned char result_R[16], unsigned char datetime_DT[16], unsigned char seed_V[16], gcry_cipher_hd_t key, unsigned char intermediate_I[16], unsigned char temp_xor[16]) @@ -415,7 +415,7 @@ x931_aes (unsigned char result_R[16], Let V be a 128-bit seed value which is also kept secret, and XOR be the exclusive-or operator. Let DT be a date/time vector which - is updated on each iteration. I is a intermediate value. + is updated on each iteration. I is a intermediate value. I = ede*K(DT) */ encrypt_aes (key, intermediate_I, datetime_DT, 16); @@ -509,7 +509,7 @@ x931_aes_driver (unsigned char *output, size_t length, rng_context_t rng_ctx) } memcpy (rng_ctx->compare_value, result_buffer, 16); } - + /* Append to outbut. */ memcpy (output, result_buffer, nbytes); wipememory (result_buffer, 16); @@ -564,7 +564,7 @@ get_entropy (size_t nbytes) X931_AES_KEYLEN, GCRY_VERY_STRONG_RANDOM); #elif USE_RNDW32 - do + do { rc = _gcry_rndw32_gather_random (entropy_collect_cb, 0, X931_AES_KEYLEN, @@ -762,7 +762,7 @@ _gcry_rngfips_initialize (int full) std_rng_context = gcry_xcalloc_secure (1, sizeof *std_rng_context); setup_guards (std_rng_context); - + strong_rng_context = gcry_xcalloc_secure (1, sizeof *strong_rng_context); setup_guards (strong_rng_context); } @@ -807,9 +807,9 @@ _gcry_rngfips_add_bytes (const void *buf, size_t buflen, int quality) (void)buflen; (void)quality; return 0; /* Not implemented. */ -} +} + - /* Public function to fill the buffer with LENGTH bytes of cryptographically strong random bytes. Level GCRY_WEAK_RANDOM is here mapped to GCRY_STRONG_RANDOM, GCRY_STRONG_RANDOM is strong @@ -820,7 +820,7 @@ _gcry_rngfips_randomize (void *buffer, size_t length, enum gcry_random_level level) { _gcry_rngfips_initialize (1); /* Auto-initialize if needed. */ - + lock_rng (); if (level == GCRY_VERY_STRONG_RANDOM) get_random (buffer, length, strong_rng_context); @@ -850,7 +850,7 @@ _gcry_rngfips_create_nonce (void *buffer, size_t length) static gcry_err_code_t selftest_kat (selftest_report_func_t report) { - static struct + static struct { const unsigned char key[16]; const unsigned char dt[16]; @@ -880,7 +880,7 @@ selftest_kat (selftest_report_func_t report) 0x13, 0xd3, 0x13, 0xfa, 0x20, 0xe9, 0x8d, 0xbc }, { 0xc8, 0xd1, 0xe5, 0x11, 0x59, 0x52, 0xf7, 0xfa, 0x37, 0x38, 0xb4, 0xc5, 0xce, 0xb2, 0xb0, 0x9a }, - { 0x0d, 0x9c, 0xc5, 0x0d, 0x16, 0xe1, 0xbc, 0xed, + { 0x0d, 0x9c, 0xc5, 0x0d, 0x16, 0xe1, 0xbc, 0xed, 0xcf, 0x60, 0x62, 0x09, 0x9d, 0x20, 0x83, 0x7e } } }, { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, @@ -892,7 +892,7 @@ selftest_kat (selftest_report_func_t report) 0x63, 0x19, 0x37, 0x6f, 0x15, 0x22, 0x57, 0x56 }, { 0x7a, 0x14, 0x76, 0x77, 0x95, 0x17, 0x7e, 0xc8, 0x92, 0xe8, 0xdd, 0x15, 0xcb, 0x1f, 0xbc, 0xb1 }, - { 0x25, 0x3e, 0x2e, 0xa2, 0x41, 0x1b, 0xdd, 0xf5, + { 0x25, 0x3e, 0x2e, 0xa2, 0x41, 0x1b, 0xdd, 0xf5, 0x21, 0x48, 0x41, 0x71, 0xb3, 0x8d, 0x2f, 0x4c } } } }; int tvidx, ridx; @@ -905,7 +905,7 @@ selftest_kat (selftest_report_func_t report) test_ctx = gcry_xcalloc (1, sizeof *test_ctx); setup_guards (test_ctx); - + lock_rng (); for (tvidx=0; tvidx < DIM (tv); tvidx++) @@ -927,15 +927,15 @@ selftest_kat (selftest_report_func_t report) goto leave; } test_ctx->key_init_pid = getpid (); - + /* Setup the seed. */ memcpy (test_ctx->seed_V, tv[tvidx].v, 16); test_ctx->is_seeded = 1; test_ctx->seed_init_pid = getpid (); - + /* Setup a DT value. */ test_ctx->test_dt_ptr = tv[tvidx].dt; - test_ctx->test_dt_counter = ( (tv[tvidx].dt[12] << 24) + test_ctx->test_dt_counter = ( (tv[tvidx].dt[12] << 24) |(tv[tvidx].dt[13] << 16) |(tv[tvidx].dt[14] << 8) |(tv[tvidx].dt[15]) ); @@ -949,7 +949,7 @@ selftest_kat (selftest_report_func_t report) errtxt = "X9.31 RNG core function failed"; goto leave; } - + /* Compare it to the known value. */ if (memcmp (result, tv[tvidx].r[ridx], 16)) { @@ -1026,9 +1026,9 @@ _gcry_rngfips_init_external_test (void **r_context, unsigned int flags, rng_context_t test_ctx; _gcry_rngfips_initialize (1); /* Auto-initialize if needed. */ - + if (!r_context - || !key || keylen != 16 + || !key || keylen != 16 || !seed || seedlen != 16 || !dt || dtlen != 16 ) return GPG_ERR_INV_ARG; @@ -1037,7 +1037,7 @@ _gcry_rngfips_init_external_test (void **r_context, unsigned int flags, if (!test_ctx) return gpg_err_code_from_syserror (); setup_guards (test_ctx); - + /* Setup the key. */ err = gcry_cipher_open (&test_ctx->cipher_hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, @@ -1050,18 +1050,18 @@ _gcry_rngfips_init_external_test (void **r_context, unsigned int flags, goto leave; test_ctx->key_init_pid = getpid (); - + /* Setup the seed. */ memcpy (test_ctx->seed_V, seed, seedlen); test_ctx->is_seeded = 1; test_ctx->seed_init_pid = getpid (); - + /* Setup a DT value. Because our context structure only stores a pointer we copy the DT value to the extra space we allocated in the test_ctx and set the pointer to that address. */ memcpy ((unsigned char*)test_ctx + sizeof *test_ctx, dt, dtlen); - test_ctx->test_dt_ptr = (unsigned char*)test_ctx + sizeof *test_ctx; - test_ctx->test_dt_counter = ( (test_ctx->test_dt_ptr[12] << 24) + test_ctx->test_dt_ptr = (unsigned char*)test_ctx + sizeof *test_ctx; + test_ctx->test_dt_counter = ( (test_ctx->test_dt_ptr[12] << 24) |(test_ctx->test_dt_ptr[13] << 16) |(test_ctx->test_dt_ptr[14] << 8) |(test_ctx->test_dt_ptr[15]) ); @@ -1114,5 +1114,3 @@ _gcry_rngfips_deinit_external_test (void *context) gcry_free (test_ctx); } } - - diff --git a/random/random.c b/random/random.c index 8465abbd..40661ab0 100644 --- a/random/random.c +++ b/random/random.c @@ -161,10 +161,10 @@ gcry_random_add_bytes (const void *buf, size_t buflen, int quality) return 0; /* No need for this in fips mode. */ else return _gcry_rngcsprng_add_bytes (buf, buflen, quality); -} +} + - -/* Helper function. */ +/* Helper function. */ static void do_randomize (void *buffer, size_t length, enum gcry_random_level level) { @@ -288,7 +288,7 @@ _gcry_random_selftest (selftest_report_func_t report) success the test context is stored at R_CONTEXT; on failure NULL is stored at R_CONTEXT and an error code is returned. */ gcry_err_code_t -_gcry_random_init_external_test (void **r_context, +_gcry_random_init_external_test (void **r_context, unsigned int flags, const void *key, size_t keylen, const void *seed, size_t seedlen, diff --git a/random/random.h b/random/random.h index 9075d9a3..7a9585cd 100644 --- a/random/random.h +++ b/random/random.h @@ -39,13 +39,13 @@ void _gcry_update_random_seed_file (void); byte *_gcry_get_random_bits( size_t nbits, int level, int secure ); void _gcry_fast_random_poll( void ); -gcry_err_code_t _gcry_random_init_external_test (void **r_context, +gcry_err_code_t _gcry_random_init_external_test (void **r_context, unsigned int flags, const void *key, size_t keylen, const void *seed, size_t seedlen, - const void *dt, + const void *dt, size_t dtlen); gcry_err_code_t _gcry_random_run_external_test (void *context, char *buffer, size_t buflen); @@ -66,7 +66,3 @@ int _gcry_daemon_create_nonce (const char *socketname, #endif /*USE_RANDOM_DAEMON*/ #endif /*G10_RANDOM_H*/ - - - - diff --git a/random/rndegd.c b/random/rndegd.c index c194225e..464edf3d 100644 --- a/random/rndegd.c +++ b/random/rndegd.c @@ -79,8 +79,8 @@ do_write( int fd, void *buf, size_t nbytes ) { size_t nleft = nbytes; int nwritten; - - while( nleft > 0 ) + + while( nleft > 0 ) { nwritten = write( fd, buf, nleft); if( nwritten < 0 ) @@ -105,7 +105,7 @@ do_read( int fd, void *buf, size_t nbytes ) do { n = read(fd, (char*)buf + nread, nbytes ); - } + } while( n == -1 && errno == EINTR ); if( n == -1) return nread? nread:-1; @@ -113,7 +113,7 @@ do_read( int fd, void *buf, size_t nbytes ) return -1; nread += n; nbytes -= n; - } + } while( nread < nbytes ); return nread; } @@ -177,13 +177,13 @@ _gcry_rndegd_connect_socket (int nofail) if (strlen(name)+1 >= sizeof addr.sun_path) log_fatal ("EGD socketname is too long\n"); - + memset( &addr, 0, sizeof addr ); addr.sun_family = AF_UNIX; - strcpy( addr.sun_path, name ); + strcpy( addr.sun_path, name ); addr_len = (offsetof( struct sockaddr_un, sun_path ) + strlen( addr.sun_path )); - + fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1 && !nofail) log_fatal("can't create unix domain socket: %s\n", strerror(errno) ); diff --git a/random/rndhw.c b/random/rndhw.c index 0961d106..82faab45 100644 --- a/random/rndhw.c +++ b/random/rndhw.c @@ -44,7 +44,7 @@ poll_padlock (void (*add)(const void*, size_t, enum random_origins), volatile char buffer[64+8] __attribute__ ((aligned (8))); volatile char *p; unsigned int nbytes, status; - + /* Peter Gutmann's cryptlib tests again whether the RNG is enabled but we don't do so. We would have to do this also for our AES implementaion and that is definitely too time consuming. There @@ -55,7 +55,7 @@ poll_padlock (void (*add)(const void*, size_t, enum random_origins), nbytes = 0; while (nbytes < 64) { - asm volatile + asm volatile ("movl %1, %%edi\n\t" /* Set buffer. */ "xorl %%edx, %%edx\n\t" /* Request up to 8 bytes. */ ".byte 0x0f, 0xa7, 0xc0\n\t" /* XSTORE RNG. */ @@ -75,13 +75,13 @@ poll_padlock (void (*add)(const void*, size_t, enum random_origins), break; /* Don't get into the loop with the fast flag set. */ p += (status & 0x1f); } - else + else { /* If there was an error we need to break the loop and record that there is something wrong with the padlock RNG. */ rng_failed = 1; - break; + break; } } @@ -114,7 +114,7 @@ _gcry_rndhw_poll_fast (void (*add)(const void*, size_t, enum random_origins), #ifdef USE_PADLOCK if ((_gcry_get_hw_features () & HWF_PADLOCK_RNG)) poll_padlock (add, origin, 1); -#endif +#endif } @@ -132,7 +132,7 @@ _gcry_rndhw_poll_slow (void (*add)(const void*, size_t, enum random_origins), #ifdef USE_PADLOCK if ((_gcry_get_hw_features () & HWF_PADLOCK_RNG)) nbytes += poll_padlock (add, origin, 0); -#endif +#endif return nbytes; } diff --git a/random/rndlinux.c b/random/rndlinux.c index ec140a83..5b84a19c 100644 --- a/random/rndlinux.c +++ b/random/rndlinux.c @@ -71,8 +71,8 @@ open_device ( const char *name ) /* We used to do the following check, however it turned out that this is not portable since more OSes provide a random device which is - sometimes implemented as another device type. - + sometimes implemented as another device type. + struct stat sb; if( fstat( fd, &sb ) ) @@ -133,7 +133,7 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, fd_set rfds; struct timeval tv; int rc; - + FD_ZERO(&rfds); FD_SET(fd, &rfds); tv.tv_sec = delay; @@ -159,16 +159,16 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, continue; } - do + do { int nbytes = length < sizeof(buffer)? length : sizeof(buffer); n = read(fd, buffer, nbytes ); - if( n >= 0 && n > nbytes ) + if( n >= 0 && n > nbytes ) { log_error("bogus read from random device (n=%d)\n", n ); n = nbytes; } - } + } while( n == -1 && errno == EINTR ); if ( n == -1 ) log_fatal("read error on random device: %s\n", strerror(errno)); @@ -176,9 +176,9 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, length -= n; } memset(buffer, 0, sizeof(buffer) ); - + if (any_need_entropy) _gcry_random_progress ("need_entropy", 'X', (int)want, (int)want); - + return 0; /* success */ } diff --git a/random/rndunix.c b/random/rndunix.c index 2db718da..cc5eb145 100644 --- a/random/rndunix.c +++ b/random/rndunix.c @@ -51,32 +51,32 @@ Subject: Re: LGPL for the windows entropy gatherer To: wk@gnupg.org Date: Wed, 22 Aug 2007 03:05:42 +1200 - + Hi, - + >As of now libgcrypt is GPL under Windows due to that module and some people >would really like to see it under LGPL too. Can you do such a license change >to LGPL version 2? Note that LGPL give the user the option to relicense it >under GPL, so the change would be pretty easy and backwar compatible. - + Sure. I assumed that since GPG was GPLd, you'd prefer the GPL for the entropy code as well, but Ian asked for LGPL as an option so as of the next release I'll have LGPL in there. You can consider it to be retroactive, so your current version will be LGPLd as well. - + Peter. ========== From: pgut001 Subject: Re: LGPL for the windows entropy gatherer To: wk@gnupg.org Date: Wed, 22 Aug 2007 20:50:08 +1200 - + >Would you mind to extend this also to the Unix entropy gatherer which is >still used on systems without /dev/random and when EGD is not installed? That >would be the last GPLed piece in Libgcrypt. - + Sure, it covers the entire entropy-gathering subsystem. - + Peter. ========= */ @@ -325,10 +325,10 @@ static struct RI { /* This is a complex and screwball program. Some systems have things * like rX_dmn, x = integer, for RAID systems, but the statistics are * pretty dodgy */ -#ifdef __QNXNTO__ +#ifdef __QNXNTO__ { "/bin/pidin", "-F%A%B%c%d%E%I%J%K%m%M%n%N%p%P%S%s%T", SC(0.3), NULL, 0, 0, 0, 0 }, -#endif +#endif #if 0 /* The following aren't enabled since they're somewhat slow and not very * unpredictable, however they give an indication of the sort of sources @@ -591,19 +591,19 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes ) { /* FIXME: Because we run several tools at once it is unlikely that we will see a block in select at all. */ - if (!any_need_entropy + if (!any_need_entropy || last_so_far != (gather_buffer_size - bufPos) ) { last_so_far = gather_buffer_size - bufPos; _gcry_random_progress ("need_entropy", 'X', - last_so_far, + last_so_far, gather_buffer_size); any_need_entropy = 1; } delay = 10; /* Use 10 seconds henceforth. */ /* Note that the fd_set is setup again at the end of this loop. */ } - + /* One of the sources has data available, read it into the buffer */ for (i = 0; dataSources[i].path != NULL; i++) { if( dataSources[i].pipe && FD_ISSET(dataSources[i].pipeFD, &fds)) { diff --git a/random/rndw32.c b/random/rndw32.c index c48eba76..f8a83b60 100644 --- a/random/rndw32.c +++ b/random/rndw32.c @@ -74,7 +74,7 @@ #include #include #include -#ifdef __GNUC__ +#ifdef __GNUC__ #include #endif @@ -141,22 +141,22 @@ typedef DWORD (WINAPI *NTPOWERINFORMATION) /* Type definitions for function pointers to call CryptoAPI functions. */ typedef BOOL (WINAPI *CRYPTACQUIRECONTEXT)(HCRYPTPROV *phProv, LPCTSTR pszContainer, - LPCTSTR pszProvider, + LPCTSTR pszProvider, DWORD dwProvType, DWORD dwFlags); typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer); typedef BOOL (WINAPI *CRYPTRELEASECONTEXT)(HCRYPTPROV hProv, DWORD dwFlags); -/* Somewhat alternative functionality available as a direct call, for +/* Somewhat alternative functionality available as a direct call, for Windows XP and newer. This is the CryptoAPI RNG, which isn't anywhere near as good as the HW RNG, but we use it if it's present on the basis - that at least it can't make things any worse. This direct access version + that at least it can't make things any worse. This direct access version is only available under Windows XP, we don't go out of our way to access - the more general CryptoAPI one since the main purpose of using it is to - take advantage of any possible future hardware RNGs that may be added, + the more general CryptoAPI one since the main purpose of using it is to + take advantage of any possible future hardware RNGs that may be added, for example via TCPA devices. */ -typedef BOOL (WINAPI *RTLGENRANDOM)(PVOID RandomBuffer, +typedef BOOL (WINAPI *RTLGENRANDOM)(PVOID RandomBuffer, ULONG RandomBufferLength); @@ -167,13 +167,13 @@ typedef BOOL (WINAPI *RTLGENRANDOM)(PVOID RandomBuffer, #define SMBType char #define SensorType char -typedef struct +typedef struct { SensorType iType; /* Type of sensor. */ int Count; /* Number of sensor for that type. */ } SharedIndex; -typedef struct +typedef struct { SensorType ssType; /* Type of sensor */ unsigned char ssName[12]; /* Name of sensor */ @@ -252,7 +252,7 @@ static int system_is_w2000; /* True if running on W2000. */ /* Try and connect to the system RNG if there's one present. */ -static void +static void init_system_rng (void) { system_rng_available = 0; @@ -268,16 +268,16 @@ init_system_rng (void) GetProcAddress (hAdvAPI32, "CryptGenRandom"); pCryptReleaseContext = (CRYPTRELEASECONTEXT) GetProcAddress (hAdvAPI32, "CryptReleaseContext"); - - /* Get a pointer to the native randomness function if it's available. + + /* Get a pointer to the native randomness function if it's available. This isn't exported by name, so we have to get it by ordinal. */ pRtlGenRandom = (RTLGENRANDOM) GetProcAddress (hAdvAPI32, "SystemFunction036"); - /* Try and connect to the PIII RNG CSP. The AMD 768 southbridge (from - the 760 MP chipset) also has a hardware RNG, but there doesn't appear - to be any driver support for this as there is for the Intel RNG so we - can't do much with it. OTOH the Intel RNG is also effectively dead + /* Try and connect to the PIII RNG CSP. The AMD 768 southbridge (from + the 760 MP chipset) also has a hardware RNG, but there doesn't appear + to be any driver support for this as there is for the Intel RNG so we + can't do much with it. OTOH the Intel RNG is also effectively dead as well, mostly due to virtually nonexistent support/marketing by Intel, it's included here mostly for form's sake. */ if ( (!pCryptAcquireContext || !pCryptGenRandom || !pCryptReleaseContext @@ -293,7 +293,7 @@ init_system_rng (void) /* Read data from the system RNG if availavle. */ -static void +static void read_system_rng (void (*add)(const void*, size_t, enum random_origins), enum random_origins requester) { @@ -330,7 +330,7 @@ read_system_rng (void (*add)(const void*, size_t, enum random_origins), /* Read data from MBM. This communicates via shared memory, so all we need to do is map a file and read the data out. */ static void -read_mbm_data (void (*add)(const void*, size_t, enum random_origins), +read_mbm_data (void (*add)(const void*, size_t, enum random_origins), enum random_origins requester) { HANDLE hMBMData; @@ -355,7 +355,7 @@ read_mbm_data (void (*add)(const void*, size_t, enum random_origins), /* Fallback method using the registry to poll the statistics. */ static void -registry_poll (void (*add)(const void*, size_t, enum random_origins), +registry_poll (void (*add)(const void*, size_t, enum random_origins), enum random_origins requester) { static int cbPerfData = PERFORMANCE_BUFFER_SIZE; @@ -421,7 +421,7 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins), if (getenv ("GNUPG_RNDW32_NOPERF")) { static int shown; - + if (!shown) { shown = 1; @@ -436,7 +436,7 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins), dwSize = cbPerfData; if ( debug_me ) log_debug ("rndw32#slow_gatherer_nt: get perf data\n" ); - + status = RegQueryValueEx (HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, (LPBYTE) pPerfData, &dwSize); if (status == ERROR_SUCCESS) @@ -455,7 +455,7 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins), else { static int been_here; - + /* Silence the error message. In particular under Wine (as of 2008) we would get swamped with such diagnotiscs. One such diagnotiscs should be enough. */ @@ -481,7 +481,7 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins), static void -slow_gatherer ( void (*add)(const void*, size_t, enum random_origins), +slow_gatherer ( void (*add)(const void*, size_t, enum random_origins), enum random_origins requester ) { static int is_initialized = 0; @@ -568,7 +568,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins), is_initialized = 1; } - + read_system_rng ( add, requester ); read_mbm_data ( add, requester ); @@ -579,7 +579,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins), In any case the network statistics return almost no randomness. */ { LPBYTE lpBuffer; - + if (hNetAPI32 && !pNetStatisticsGet (NULL, is_workstation ? L"LanmanWorkstation" : @@ -599,7 +599,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins), { char diskPerformance[SIZEOF_DISK_PERFORMANCE_STRUCT + 8]; char szDevice[50]; - + /* Check whether we can access this device. */ snprintf (szDevice, sizeof szDevice, "\\\\.\\PhysicalDrive%d", drive_no); @@ -607,7 +607,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins), NULL, OPEN_EXISTING, 0, NULL); if (hDevice == INVALID_HANDLE_VALUE) break; /* No more drives. */ - + /* Note: This only works if you have turned on the disk performance counters with 'diskperf -y'. These counters are off by default. */ dwSize = sizeof diskPerformance; @@ -949,7 +949,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, shouldn't really be a problem. Under WinCE it's completely platform- dependant, if there's no hardware performance counter available, it uses the 1ms system timer. - + Another feature of the TSC (although it doesn't really affect us here) is that mobile CPUs will turn off the TSC when they idle, Pentiums will change the rate of the counter when they clock-throttle (to @@ -957,11 +957,11 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, it off when both threads are idle (this more or less makes sense, since the CPU will be in the halted state and not executing any instructions to count). - + To make things unambiguous, we detect a CPU new enough to call RDTSC directly by checking for CPUID capabilities, and fall back to QPC if this isn't present. */ -#ifdef __GNUC__ +#ifdef __GNUC__ /* FIXME: We would need to implement the CPU feature tests first. */ /* if (cpu_has_feature_rdtsc) */ /* { */ @@ -975,7 +975,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, #endif /*!__GNUC__*/ { LARGE_INTEGER performanceCount; - + if (QueryPerformanceCounter (&performanceCount)) { if ( debug_me ) diff --git a/random/rndw32ce.c b/random/rndw32ce.c index 6cd5d57e..b485eef2 100644 --- a/random/rndw32ce.c +++ b/random/rndw32ce.c @@ -82,7 +82,7 @@ _gcry_rndw32ce_gather_random (void (*add)(const void*, size_t, if (length+8 < buflen) buflen = length+8; /* Return a bit more than requested. */ - if (!CryptAcquireContext (&prov, NULL, NULL, PROV_RSA_FULL, + if (!CryptAcquireContext (&prov, NULL, NULL, PROV_RSA_FULL, (CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) ) log_debug ("CryptAcquireContext failed: rc=%d\n", (int)GetLastError ()); else @@ -184,16 +184,16 @@ _gcry_rndw32ce_gather_random_fast (void (*add)(const void*, size_t, (*add) ( &userTime, sizeof (userTime), origin ); } - + /* In case the OEM provides a high precision timer get this. If none is available the default implementation returns the GetTickCount. */ { LARGE_INTEGER performanceCount; - + if (QueryPerformanceCounter (&performanceCount)) (*add) (&performanceCount, sizeof (performanceCount), origin); } - + } diff --git a/src/ChangeLog b/src/ChangeLog index 1a0910b5..8c0ef73b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -149,7 +149,7 @@ * cipher-proto.h (pk_ext_generate_t): Add field EXTRAINFO changed all implementors. - * cipher-proto.h (pk_ext_generate_t): Simplify. + * cipher-proto.h (pk_ext_generate_t): Simplify. (pk_get_param): New. (pk_extra_spec_t): Add field GET_PARAM. * cipher.h (PUBKEY_FLAG_TRANSIENT_KEY): Remove. @@ -169,7 +169,7 @@ 2008-10-24 Werner Koch - * global.c (inactive_fips_mode): Move to fips.c. + * global.c (inactive_fips_mode): Move to fips.c. (gcry_set_allocation_handler): Factor code out to ... * fips.c (_gcry_inactivate_fips_mode): New. (_gcry_is_fips_mode_inactive): New. @@ -242,7 +242,7 @@ 2008-09-12 Werner Koch * fips.c (_gcry_fips_run_selftests): Add arg EXTENDED. - (run_cipher_selftests, run_digest_selftests, run_hmac_selftests) + (run_cipher_selftests, run_digest_selftests, run_hmac_selftests) (run_pubkey_selftests): Ditto. * cipher-proto.h (selftest_func_t): Add arg EXTENDED @@ -334,17 +334,17 @@ * gcrypt.h.in (gcry_cipher_setkey): Replace macro by function. (gcry_cipher_setiv): Ditto. (gcry_cipher_setctr): Ditto. - * visibility.c (gcry_cipher_setkey, gcry_cipher_setiv) + * visibility.c (gcry_cipher_setkey, gcry_cipher_setiv) (gcry_cipher_setctr): New. - * visibility.h (gcry_cipher_setkey, gcry_cipher_setiv) + * visibility.h (gcry_cipher_setkey, gcry_cipher_setiv) (gcry_cipher_setctr): New. * libgcrypt.vers (gcry_cipher_setkey, gcry_cipher_setiv) (gcry_cipher_setctr): New. - * libgcrypt.def (gcry_cipher_setkey, gcry_cipher_setiv) + * libgcrypt.def (gcry_cipher_setkey, gcry_cipher_setiv) (gcry_cipher_setctr): New. * hmac256.h, hmac256.c: New. - * Makefile.am (hmac256_SOURCES): New. + * Makefile.am (hmac256_SOURCES): New. * Makefile.am (bin_PROGRAMS): Add hmac256. * gcrypt.h.in (struct gcry_thread_cbs): Change type of OPTION to @@ -352,13 +352,13 @@ difference. * ath.c (ath_install): Take the version of the option field in account. - + * visibility.c (gcry_pk_encrypt, gcry_pk_decrypt, gcry_pk_sign) (gcry_pk_verify, gcry_pk_testkey, gcry_pk_genkey) (gcry_pk_get_nbits, gcry_pk_get_keygrip) - (gcry_md_open, gcry_md_copy, gcry_md_enable) - (gcry_md_write, md_final, gcry_md_ctl, gcry_md_setkey) - (gcry_md_hash_buffer, gcry_md_get_algo, gcry_md_info) + (gcry_md_open, gcry_md_copy, gcry_md_enable) + (gcry_md_write, md_final, gcry_md_ctl, gcry_md_setkey) + (gcry_md_hash_buffer, gcry_md_get_algo, gcry_md_info) (gcry_md_is_enabled) (gcry_cipher_open, gcry_cipher_encrypt) (gcry_cipher_decrypt, gcry_cipher_ctl) @@ -368,7 +368,7 @@ * cipher.h: Include cipher-proto.h. * visibility.h: Remove duplicate macro definitions. Remove gcry_cipher_register, gcry_md_register, gcry_pk_register macros. - * visibility.c: Include cipher-proto.h. + * visibility.c: Include cipher-proto.h. (gcry_cipher_register): Pass dummy extra args to the internal register function. (gcry_md_register, gcry_pk_register): Ditto. @@ -401,7 +401,7 @@ * gcrypt.h.in (gcry_ac_em_t, gcry_ac_scheme_t): Remove trailing comma for full C-89 compatibility. - + 2008-01-21 Marcus Brinkmann * hwfeatures.c (detect_ia32_gnuc): Fix inline asm. @@ -517,7 +517,7 @@ * secmem.c (init_pool): Use sysconf() if available to determine page size. - + 2007-03-22 Werner Koch * mpi.h (mpi_mod): New. @@ -670,7 +670,7 @@ [_WIN32 || __WIN32__]: Do not include , but and . Suggested by Simon Josefsson . - + * Makefile.am (install-data-local, uninstall-local, %.lo, (install-def-file, uninstall-def-file): New targets. (LTRCCOMPILE, gcrypt_res, gcrypt_res_ldflag, no_undefined, @@ -690,8 +690,8 @@ (sexp_sscan): Remove all xmalloc style calls and return proper error codes on allocation failures. (gcry_sexp_find_token): Ditto. - (gcry_sexp_nth): - + (gcry_sexp_nth): + * sexp.c (gcry_sexp_find_token): Re-indented and removed a cruft "while(level);" which fortunately had no effect. @@ -704,7 +704,7 @@ 2006-04-22 Moritz Schulte * gcrypt.h (gcry_ctl_cmds): New commands: - GCRYCTL_SET_RANDOM_DAEMON_SOCKET, GCRYCTL_USE_RANDOM_DAEMON. + GCRYCTL_SET_RANDOM_DAEMON_SOCKET, GCRYCTL_USE_RANDOM_DAEMON. * global.c (gcry_control): Handle new commands, calling _gcry_set_random_daemon_socket() and _gcry_use_random_daemon(). @@ -754,7 +754,7 @@ GnuPG relict (Libgcrypt does not define this symbol anywhere). (FLAG_MODULE_DISABLED): Don't forget parantheses around shifted value. - + Removed GCC_ATTR_PURE macro definitions, since gcrypt.h does already contain such a macro named _GCRY_GCC_ATTR_PURE, which we can use here as well. @@ -861,7 +861,7 @@ 2004-08-23 Moritz Schulte - * global.c: Do not include . + * global.c: Do not include . * sexp.c: Likewise. * module.c: Likewise. * misc.c: Likewise. @@ -945,7 +945,7 @@ (libgcrypt_la_DEPENDENCIES): ... this. (libgcrypt_real_la_LIBADD): Merge with ... (libgcrypt_la_LIBADD): ... this. - * libgcrypt-config.in (libs_pthread, libs_pth, cflags_pth) + * libgcrypt-config.in (libs_pthread, libs_pth, cflags_pth) (cflags_pthread, thread_module, thread_modules): Removed. (Options): Remove --thread option from help output. If the option is specified, output an error and exit. @@ -980,7 +980,7 @@ $(ath_pthread_src). * ath-compat.c, ath-pth-compat.c, ath-pthread-compat.c: Files removed. - + 2004-02-20 Werner Koch * gcrypt.h (GCRY_PRIME_CHECK_AT_GOT_PRIME) @@ -1023,7 +1023,7 @@ gcry_ac_key_get_nbits, gcry_ac_key_get_grip. * gcrypt.h (GCRY_AC_FLAG_DATA_NO_BLINDING): Removed symbol. - (GCRY_AC_FLAG_DEALLOC, GCRY_AC_FLAG_COPY) + (GCRY_AC_FLAG_DEALLOC, GCRY_AC_FLAG_COPY) (GCRY_AC_FLAG_NO_BLINDING): New symbols. * global.c (gcry_strdup): Removed function. @@ -1278,7 +1278,7 @@ * gcrypt.h (enum gcry_md_flags): Removed, used define instead, since that is more common than an enumeration list when it comes to flags that can be bitwise ORed. - + 2003-07-08 Moritz Schulte * global.c: Use new types for handlers. @@ -1291,7 +1291,7 @@ Thanks to Simon Josefsson . * gcrypt.h: Declare: gcry_cipher_list, gcry_pk_list, gcry_md_list. - + 2003-07-05 Moritz Schulte * gcrypt.h: Declare: gcry_cipher_register, gcry_cipher_unregister, @@ -1423,7 +1423,7 @@ * g10lib.h: Declare: _gcry_cipher_init, _gcry_md_init, _gcry_pk_init. - + * global.c (gcry_strerror): Remove compatibility code. * Makefile.am: Remove support libgpg-error special handling. @@ -1445,7 +1445,7 @@ GPG_ERR_SOURCE_DEFAULT, so that libgpg-error still works despite the use of the old gcrypt error codes. (gcry_md_copy): Swapped arguments. - + 2003-06-09 Moritz Schulte * Makefile.am: Support for libgpg-error. @@ -1464,7 +1464,7 @@ before the '#'. This is not required by C89, but there are some compilers out there that don't like it. Replaced any occurence of the now deprecated type names with the new ones. - + * gcrypt.h: Re-organized checking for gcc features; New macro: _GCRY_GCC_ATTR_DEPRECATED. Include copy of libgpg-error's gpg-error.h in order to make it @@ -1509,7 +1509,7 @@ * gcrypt.h: Changed declarations for: gcry_pk_algo_info, gcry_md_open, gcry_md_copy, gcry_md_algo_info, gcry_md_info, gcry_md_get_algo, gcry_random_add_bytes. - + (gcry_md_is_secure): Adjust macro for new API. 2003-05-29 Moritz Schulte @@ -1634,10 +1634,10 @@ gcry_digest_register, gcry_digest_unregister, gcry_pubkey_register, gcry_pubkey_unregister): Function declarations removed - for now. - + * gcrypt.h (GcryModule): Declaration removed. * gcrypt.h (GcryPubkeySpec, GcryDigestSpec, GcryCipherSpec): - Types Moved... + Types Moved... * cipher.h: ... here. 2003-04-17 Moritz Schulte @@ -1727,7 +1727,7 @@ values. * secmem.c (_gcry_secmem_set_flags): Likewise. * secmem.c (_gcry_secmem_get_flags): Likewise. - + 2003-03-03 Moritz Schulte * misc.c: Removed old FIXME, since there is already a function to @@ -1766,7 +1766,7 @@ 2003-01-23 Werner Koch - * gcrypt.h (GCRY_ENABLE_QUICK_RANDOM): New. + * gcrypt.h (GCRY_ENABLE_QUICK_RANDOM): New. * global.c (gcry_control): Make use of it. 2003-01-21 Werner Koch @@ -1776,7 +1776,7 @@ 2003-01-21 Timo Schulz * gcrypt.h (gcry_random_add_bytes): New. - + 2003-01-20 Simon Josefsson * gcrypt.h (gcry_md_algos): Add GCRY_MD_CRC32, @@ -1800,13 +1800,13 @@ 2003-01-02 Werner Koch * libgcrypt.vers: Temporary export _gcry_generate_elg_prime for - use by GNUTLS. + use by GNUTLS. 2002-12-21 Werner Koch - * gcrypt.h: Make use of gcc's pure and malloc attributes + * gcrypt.h: Make use of gcc's pure and malloc attributes (gcry_md_putc): Use a helper variable to avoid multiple - evaluation of H. + evaluation of H. * g10lib.h, stdmem.h, secmem.h: Use gcc attributes pure and malloc. * stdmem.c (use_m_guard): Don't default to yes. @@ -1815,7 +1815,7 @@ * global.c (global_init): The meat was never run due to a faulty check. Thanks to Nikos for pointing this out. - + * global.c (gcry_control): Return 1 and not -1 for the initialization tests. @@ -1829,7 +1829,7 @@ 2002-12-09 Werner Koch * global.c (gcry_calloc,gcry_calloc_secure): Check for overflow. - Noted by Florian Weimer. + Noted by Florian Weimer. 2002-11-10 Simon Josefsson @@ -1839,7 +1839,7 @@ 2002-11-10 Werner Koch - * gcrypt.h (GCRY_MD_MD4): New. We use a non OpenPGP value here. + * gcrypt.h (GCRY_MD_MD4): New. We use a non OpenPGP value here. 2002-09-20 Werner Koch @@ -2057,11 +2057,11 @@ * gcrypt.h, mpi.h: Made some mpi functions public. * wrapper.c: Removed. - * global.c: Renamed all g10_ prefixed functions which had wrappers + * global.c: Renamed all g10_ prefixed functions which had wrappers to gcry_xxx. So we now use the exported memory functions inernally. Renamed all g10_ prefixed functions to _gcry_ prefixed ones. - + * g10lib.h (_GCRYPT_IN_LIBGCRYPT): Replace defintion by a test on it. 2001-05-28 Werner Koch @@ -2080,7 +2080,7 @@ Major change: Removed all GnuPG stuff and renamed this piece of software - to gcrypt. + to gcrypt. 2000-11-14 Werner Koch diff --git a/src/Makefile.am b/src/Makefile.am index 8ceed983..20eb0d62 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,14 +41,14 @@ arch_gpg_error_cflags = $(GPG_ERROR_CFLAGS) arch_gpg_error_libs = $(GPG_ERROR_LIBS) else arch_gpg_error_cflags = -arch_gpg_error_libs = +arch_gpg_error_libs = endif if HAVE_LD_VERSION_SCRIPT libgcrypt_version_script_cmd = -Wl,--version-script=$(srcdir)/libgcrypt.vers else - libgcrypt_version_script_cmd = + libgcrypt_version_script_cmd = endif libgcrypt_la_CFLAGS = $(GPG_ERROR_CFLAGS) @@ -105,7 +105,7 @@ libgcrypt_la_DEPENDENCIES = \ ../random/librandom.la \ ../mpi/libmpi.la \ ../compat/libcompat.la \ - $(srcdir)/libgcrypt.vers $(gcrypt_deps) + $(srcdir)/libgcrypt.vers $(gcrypt_deps) libgcrypt_la_LIBADD = $(gcrypt_res) \ ../cipher/libcipher.la \ ../random/librandom.la \ @@ -141,4 +141,3 @@ uninstall-local: uninstall-def-file # ./hmac256 "What am I, a doctor or a moonshuttle conductor?" \ # < $(DESTDIR)$(libdir)/libgcrypt.so.11.5.0 \ # > $(DESTDIR)$(libdir)/.libgcrypt.so.11.5.0.hmac - diff --git a/src/ath.c b/src/ath.c index 0c274cde..656ed896 100644 --- a/src/ath.c +++ b/src/ath.c @@ -2,17 +2,17 @@ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of Libgcrypt. - + Libgcrypt is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Libgcrypt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Libgcrypt; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -88,7 +88,7 @@ ath_install (struct ath_ops *ath_ops, int check_only) if (check_only) { unsigned int option = 0; - + /* Check if the requested thread option is compatible to the thread option we are already committed to. */ if (ath_ops) @@ -105,7 +105,7 @@ ath_install (struct ath_ops *ath_ops, int check_only) return 0; } - + if (ath_ops) { /* It is convenient to not require DESTROY. */ @@ -257,7 +257,7 @@ ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, #endif } - + ssize_t ath_waitpid (pid_t pid, int *status, int options) { @@ -342,4 +342,3 @@ ath_recvmsg (int s, struct msghdr *msg, int flags) return recvmsg (s, msg, flags); #endif } - diff --git a/src/ath.h b/src/ath.h index 68e2ef6b..8769551b 100644 --- a/src/ath.h +++ b/src/ath.h @@ -2,17 +2,17 @@ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of Libgcrypt. - + Libgcrypt is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + Libgcrypt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Libgcrypt; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA @@ -77,7 +77,7 @@ enum ath_thread_option struct ath_ops { /* The OPTION field encodes the thread model and the version number - of this structure. + of this structure. Bits 7 - 0 are used for the thread model Bits 15 - 8 are used for the version number. */ @@ -142,6 +142,6 @@ int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr); int ath_connect (int s, struct sockaddr *addr, socklen_t length); int ath_sendmsg (int s, const struct msghdr *msg, int flags); int ath_recvmsg (int s, struct msghdr *msg, int flags); -#endif +#endif #endif /* ATH_H */ diff --git a/src/cipher-proto.h b/src/cipher-proto.h index e936eeae..347681ff 100644 --- a/src/cipher-proto.h +++ b/src/cipher-proto.h @@ -23,14 +23,14 @@ #ifndef G10_CIPHER_PROTO_H #define G10_CIPHER_PROTO_H -/* Definition of a function used to report selftest failures. +/* Definition of a function used to report selftest failures. DOMAIN is a string describing the function block: "cipher", "digest", "pubkey or "random", ALGO is the algorithm under test, WHAT is a string describing what has been tested, DESC is a string describing the error. */ typedef void (*selftest_report_func_t)(const char *domain, - int algo, + int algo, const char *what, const char *errdesc); @@ -110,7 +110,7 @@ gcry_error_t _gcry_pk_register (gcry_pk_spec_t *cipher, gcry_module_t *module); /* The selftest functions. */ -gcry_error_t _gcry_cipher_selftest (int algo, int extended, +gcry_error_t _gcry_cipher_selftest (int algo, int extended, selftest_report_func_t report); gcry_error_t _gcry_md_selftest (int algo, int extended, selftest_report_func_t report); diff --git a/src/cipher.h b/src/cipher.h index 2be8787a..ca2d9564 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -41,16 +41,16 @@ void _gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length); /*-- rijndael.c --*/ -void _gcry_aes_cfb_enc (void *context, unsigned char *iv, +void _gcry_aes_cfb_enc (void *context, unsigned char *iv, void *outbuf, const void *inbuf, unsigned int nblocks); -void _gcry_aes_cfb_dec (void *context, unsigned char *iv, +void _gcry_aes_cfb_dec (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks); -void _gcry_aes_cbc_enc (void *context, unsigned char *iv, +void _gcry_aes_cbc_enc (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks, int cbc_mac); -void _gcry_aes_cbc_dec (void *context, unsigned char *iv, +void _gcry_aes_cbc_dec (void *context, unsigned char *iv, void *outbuf_arg, const void *inbuf_arg, unsigned int nblocks); @@ -131,10 +131,10 @@ extern gcry_pk_spec_t _gcry_pubkey_spec_dsa; extern gcry_pk_spec_t _gcry_pubkey_spec_ecdsa; extern gcry_pk_spec_t _gcry_pubkey_spec_ecdh; -extern pk_extra_spec_t _gcry_pubkey_extraspec_rsa; -extern pk_extra_spec_t _gcry_pubkey_extraspec_dsa; -extern pk_extra_spec_t _gcry_pubkey_extraspec_elg; -extern pk_extra_spec_t _gcry_pubkey_extraspec_ecdsa; +extern pk_extra_spec_t _gcry_pubkey_extraspec_rsa; +extern pk_extra_spec_t _gcry_pubkey_extraspec_dsa; +extern pk_extra_spec_t _gcry_pubkey_extraspec_elg; +extern pk_extra_spec_t _gcry_pubkey_extraspec_ecdsa; #endif /*G10_CIPHER_H*/ diff --git a/src/dumpsexp.c b/src/dumpsexp.c index d93cd676..a397b241 100644 --- a/src/dumpsexp.c +++ b/src/dumpsexp.c @@ -48,7 +48,7 @@ print_version (int with_help) "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n", stdout); - + if (with_help) fputs ("\n" "Usage: " PGM " [OPTIONS] [file]\n" @@ -61,7 +61,7 @@ print_version (int with_help) " --version Print version of the program and exit\n" " --help Display this help and exit\n" BUGREPORT_LINE, stdout ); - + exit (0); } @@ -90,7 +90,7 @@ print_usage (void) to the S-expressions definition. */ static inline int whitespace_p (int c) -{ +{ switch (c) { case ' ': case '\t': case '\v': case '\f': case '\r': case '\n': return 1; @@ -220,11 +220,11 @@ addrawdata (int c) } -static void +static void printcursor (int both) { int i; - + flushdatabuffer (); printf ("%8s ", ""); for (i=0; i < sizeof (databuffer); i++) @@ -250,14 +250,14 @@ printcursor (int both) databufferlen = skipdatabufferlen = nbytesprinted; } -static void +static void printerr (const char *text) { printcursor (1); printf ("\n Error: %s\n", text); } -static void +static void printctl (const char *text) { if (verbose && !advanced) @@ -267,7 +267,7 @@ printctl (const char *text) } } -static void +static void printchr (int c) { putchar (c); @@ -297,7 +297,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, DATALEN n; char numbuf[20]; int i, indent = 0; - + s = list? list->d : empty; d = buffer; while ( *s != ST_STOP ) @@ -307,7 +307,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, case ST_OPEN: s++; if (indent) - putchar ('\n'); + putchar ('\n'); for (i=0; i < indent; i++) putchar (' '); putchar ('('); @@ -331,7 +331,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, { int type; size_t nn; - + switch ( (type=suitable_encoding (s, n))) { case 1: nn = convert_to_string (s, n, NULL); break; @@ -361,7 +361,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, BUG (); } } - putchar ('\n'); + putchar ('\n'); return len; } #endif @@ -405,14 +405,14 @@ parse_and_print (FILE *fp) unsigned long datalen = 0; char quote_buf[10]; int quote_idx = 0; - enum + enum { INIT_STATE = 0, IN_NUMBER, PRE_DATA, IN_DATA, IN_STRING, IN_ESCAPE, IN_OCT_ESC, IN_HEX_ESC, CR_ESC, LF_ESC, IN_HEXFMT, IN_BASE64 } state = INIT_STATE; - + while ((c = my_getc (fp)) != EOF ) { @@ -566,7 +566,7 @@ parse_and_print (FILE *fp) printctl ("endstring"); flush_data (); state = INIT_STATE; - } + } else if (c == '\\') state = IN_ESCAPE; else @@ -585,23 +585,23 @@ parse_and_print (FILE *fp) case '"': push_data ('"'); state = IN_STRING; break; case '\'': push_data ('\''); state = IN_STRING; break; case '\\': push_data ('\\'); state = IN_STRING; break; - + case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': state = IN_OCT_ESC; quote_idx = 0; - quote_buf[quote_idx++] = c; + quote_buf[quote_idx++] = c; break; - + case 'x': state = IN_HEX_ESC; quote_idx = 0; break; - + case '\r': state = CR_ESC; break; - + case '\n': state = LF_ESC; break; @@ -612,11 +612,11 @@ parse_and_print (FILE *fp) break; } break; - - case IN_OCT_ESC: + + case IN_OCT_ESC: if (quote_idx < 3 && strchr ("01234567", c)) { - quote_buf[quote_idx++] = c; + quote_buf[quote_idx++] = c; if (quote_idx == 3) { push_data ((unsigned int)quote_buf[0] * 8 * 8 @@ -628,10 +628,10 @@ parse_and_print (FILE *fp) else state = IN_STRING; break; - case IN_HEX_ESC: + case IN_HEX_ESC: if (quote_idx < 2 && strchr ("0123456789abcdefABCDEF", c)) { - quote_buf[quote_idx++] = c; + quote_buf[quote_idx++] = c; if (quote_idx == 2) { push_data (xtoi_1 (quote_buf[0]) * 16 @@ -694,7 +694,7 @@ parse_and_print (FILE *fp) -int +int main (int argc, char **argv) { int rc; @@ -736,7 +736,7 @@ main (int argc, char **argv) } else print_usage (); - } + } if (!argc) { @@ -753,7 +753,7 @@ main (int argc, char **argv) logit ("can't open `%s': %s\n", *argv, strerror (errno)); rc = 1; } - else + else { if (parse_and_print (fp)) rc = 1; @@ -761,7 +761,6 @@ main (int argc, char **argv) } } } - + return !!rc; } - diff --git a/src/fips.c b/src/fips.c index 9f46f717..8bc45e7c 100644 --- a/src/fips.c +++ b/src/fips.c @@ -24,7 +24,7 @@ #include #include #ifdef ENABLE_HMAC_BINARY_CHECK -# include +# include #endif #ifdef HAVE_SYSLOG # include @@ -41,7 +41,7 @@ /* The states of the finite state machine used in fips mode. */ -enum module_states +enum module_states { /* POWEROFF cannot be represented. */ STATE_POWERON = 0, @@ -102,7 +102,7 @@ _gcry_initialize_fips_mode (int force) { static int done; gpg_error_t err; - + /* Make sure we are not accidently called twice. */ if (done) { @@ -144,7 +144,7 @@ _gcry_initialize_fips_mode (int force) if (fp) { char line[256]; - + if (fgets (line, sizeof line, fp) && atoi (line)) { /* System is in fips mode. */ @@ -170,7 +170,7 @@ _gcry_initialize_fips_mode (int force) abort (); } } - + /* Fips not not requested, set flag. */ no_fips_mode_required = 1; @@ -197,14 +197,14 @@ _gcry_initialize_fips_mode (int force) abort (); } - + /* If the FIPS force files exists, is readable and has a number != 0 on its first line, we enable the enforced fips mode. */ fp = fopen (FIPS_FORCE_FILE, "r"); if (fp) { char line[256]; - + if (fgets (line, sizeof line, fp) && atoi (line)) enforced_fips_mode = 1; fclose (fp); @@ -212,7 +212,7 @@ _gcry_initialize_fips_mode (int force) /* Now get us into the INIT state. */ fips_new_state (STATE_INIT); - + } return; } @@ -225,7 +225,7 @@ lock_fsm (void) err = ath_mutex_lock (&fsm_lock); if (err) { - log_info ("FATAL: failed to acquire the FSM lock in libgrypt: %s\n", + log_info ("FATAL: failed to acquire the FSM lock in libgrypt: %s\n", strerror (err)); #ifdef HAVE_SYSLOG syslog (LOG_USER|LOG_ERR, "Libgcrypt error: " @@ -271,7 +271,7 @@ _gcry_fips_mode (void) /* Return a flag telling whether we are in the enforced fips mode. */ -int +int _gcry_enforced_fips_mode (void) { return enforced_fips_mode; @@ -347,7 +347,7 @@ state2str (enum module_states state) /* Return true if the library is in the operational state. */ -int +int _gcry_fips_is_operational (void) { int result; @@ -437,8 +437,8 @@ reporter (const char *domain, int algo, const char *what, const char *errtxt) !strcmp (domain, "digest")? _gcry_md_algo_name (algo) : !strcmp (domain, "hmac")? _gcry_md_algo_name (algo) : !strcmp (domain, "pubkey")? _gcry_pk_algo_name (algo) : "", - algo, errtxt? errtxt:"Okay", - what?" (":"", what? what:"", what?")":""); + algo, errtxt? errtxt:"Okay", + what?" (":"", what? what:"", what?")":""); } /* Run self-tests for all required cipher algorithms. Return 0 on @@ -446,7 +446,7 @@ reporter (const char *domain, int algo, const char *what, const char *errtxt) static int run_cipher_selftests (int extended) { - static int algos[] = + static int algos[] = { GCRY_CIPHER_3DES, GCRY_CIPHER_AES128, @@ -475,7 +475,7 @@ run_cipher_selftests (int extended) static int run_digest_selftests (int extended) { - static int algos[] = + static int algos[] = { GCRY_MD_SHA1, GCRY_MD_SHA224, @@ -504,7 +504,7 @@ run_digest_selftests (int extended) static int run_hmac_selftests (int extended) { - static int algos[] = + static int algos[] = { GCRY_MD_SHA1, GCRY_MD_SHA224, @@ -534,7 +534,7 @@ run_hmac_selftests (int extended) static int run_pubkey_selftests (int extended) { - static int algos[] = + static int algos[] = { GCRY_PK_RSA, GCRY_PK_DSA, @@ -566,7 +566,7 @@ run_random_selftests (void) err = _gcry_random_selftest (reporter); reporter ("random", 0, NULL, err? gpg_strerror (err):NULL); - + return !!err; } @@ -581,7 +581,7 @@ check_binary_integrity (void) int dlen; char *fname = NULL; const char key[] = "What am I, a doctor or a moonshuttle conductor?"; - + if (!dladdr ("gcry_check_version", &info)) err = gpg_error_from_syserror (); else @@ -621,7 +621,7 @@ check_binary_integrity (void) { /* A buffer of 64 bytes plus one for a LF and one to detect garbage. */ - unsigned char buffer[64+1+1]; + unsigned char buffer[64+1+1]; const unsigned char *s; int n; @@ -667,7 +667,7 @@ _gcry_fips_run_selftests (int extended) { enum module_states result = STATE_ERROR; gcry_err_code_t ec = GPG_ERR_SELFTEST_FAILED; - + if (fips_mode ()) fips_new_state (STATE_SELFTEST); @@ -726,14 +726,14 @@ _gcry_fips_signal_error (const char *srcfile, int srcline, const char *srcfunc, /* Print error. */ log_info ("%serror in libgcrypt, file %s, line %d%s%s: %s\n", is_fatal? "fatal ":"", - srcfile, srcline, + srcfile, srcline, srcfunc? ", function ":"", srcfunc? srcfunc:"", description? description : "no description available"); #ifdef HAVE_SYSLOG syslog (LOG_USER|LOG_ERR, "Libgcrypt error: " "%serror in file %s, line %d%s%s: %s", is_fatal? "fatal ":"", - srcfile, srcline, + srcfile, srcline, srcfunc? ", function ":"", srcfunc? srcfunc:"", description? description : "no description available"); #endif /*HAVE_SYSLOG*/ @@ -766,22 +766,22 @@ fips_new_state (enum module_states new_state) || new_state == STATE_FATALERROR) ok = 1; break; - + case STATE_SELFTEST: if (new_state == STATE_OPERATIONAL || new_state == STATE_ERROR || new_state == STATE_FATALERROR) ok = 1; break; - + case STATE_OPERATIONAL: - if (new_state == STATE_SHUTDOWN + if (new_state == STATE_SHUTDOWN || new_state == STATE_SELFTEST || new_state == STATE_ERROR || new_state == STATE_FATALERROR) ok = 1; break; - + case STATE_ERROR: if (new_state == STATE_SHUTDOWN || new_state == STATE_ERROR @@ -789,18 +789,18 @@ fips_new_state (enum module_states new_state) || new_state == STATE_SELFTEST) ok = 1; break; - + case STATE_FATALERROR: if (new_state == STATE_SHUTDOWN ) ok = 1; break; - + case STATE_SHUTDOWN: /* We won't see any transition *from* Shutdown because the only allowed new state is Power-Off and that one can't be represented. */ break; - + } if (ok) @@ -814,12 +814,12 @@ fips_new_state (enum module_states new_state) log_info ("libgcrypt state transition %s => %s %s\n", state2str (last_state), state2str (new_state), ok? "granted":"denied"); - + if (!ok) { /* Invalid state transition. Halting library. */ #ifdef HAVE_SYSLOG - syslog (LOG_USER|LOG_ERR, + syslog (LOG_USER|LOG_ERR, "Libgcrypt error: invalid state transition %s => %s", state2str (last_state), state2str (new_state)); #endif /*HAVE_SYSLOG*/ @@ -828,7 +828,7 @@ fips_new_state (enum module_states new_state) else if (new_state == STATE_ERROR || new_state == STATE_FATALERROR) { #ifdef HAVE_SYSLOG - syslog (LOG_USER|LOG_WARNING, + syslog (LOG_USER|LOG_WARNING, "Libgcrypt notice: state transition %s => %s", state2str (last_state), state2str (new_state)); #endif /*HAVE_SYSLOG*/ diff --git a/src/g10lib.h b/src/g10lib.h index d8e967a6..60773fd8 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -29,7 +29,7 @@ #error gcrypt.h already included #endif -#ifndef _GCRYPT_IN_LIBGCRYPT +#ifndef _GCRYPT_IN_LIBGCRYPT #error something is wrong with config.h #endif @@ -55,15 +55,15 @@ #define JNLIB_GCC_A_NR #define JNLIB_GCC_A_PRINTF( f, a ) #define JNLIB_GCC_A_NR_PRINTF( f, a ) -#define GCC_ATTR_NORETURN +#define GCC_ATTR_NORETURN #endif -#if __GNUC__ >= 3 +#if __GNUC__ >= 3 /* According to glibc this attribute is available since 2.8 however we better play safe and use it only with gcc 3 or newer. */ #define GCC_ATTR_FORMAT_ARG(a) __attribute__ ((format_arg (a))) #else -#define GCC_ATTR_FORMAT_ARG(a) +#define GCC_ATTR_FORMAT_ARG(a) #endif @@ -175,10 +175,10 @@ gcry_mpi_t _gcry_generate_public_prime (unsigned int nbits, gcry_random_level_t random_level, int (*extra_check)(void*, gcry_mpi_t), void *extra_check_arg); -gcry_mpi_t _gcry_generate_elg_prime (int mode, +gcry_mpi_t _gcry_generate_elg_prime (int mode, unsigned int pbits, unsigned int qbits, gcry_mpi_t g, gcry_mpi_t **factors); -gcry_mpi_t _gcry_derive_x931_prime (const gcry_mpi_t xp, +gcry_mpi_t _gcry_derive_x931_prime (const gcry_mpi_t xp, const gcry_mpi_t xp1, const gcry_mpi_t xp2, const gcry_mpi_t e, gcry_mpi_t *r_p1, gcry_mpi_t *r_p2); @@ -188,7 +188,7 @@ gpg_err_code_t _gcry_generate_fips186_2_prime gcry_mpi_t *r_q, gcry_mpi_t *r_p, int *r_counter, void **r_seed, size_t *r_seedlen); -gpg_err_code_t _gcry_generate_fips186_3_prime +gpg_err_code_t _gcry_generate_fips186_3_prime (unsigned int pbits, unsigned int qbits, const void *seed, size_t seedlen, gcry_mpi_t *r_q, gcry_mpi_t *r_p, @@ -312,7 +312,7 @@ gcry_err_code_t _gcry_pk_get_elements (int algo, char **enc, char **sig); /*-- sexp.c --*/ -gcry_error_t _gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff, +gcry_error_t _gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff, const char *format, va_list arg_ptr); char *_gcry_sexp_nth_string (const gcry_sexp_t list, int number); @@ -330,8 +330,8 @@ void _gcry_inactivate_fips_mode (const char *text); int _gcry_is_fips_mode_inactive (void); -void _gcry_fips_signal_error (const char *srcfile, - int srcline, +void _gcry_fips_signal_error (const char *srcfile, + int srcline, const char *srcfunc, int is_fatal, const char *description); diff --git a/src/gcrypt-module.h b/src/gcrypt-module.h index e717b70c..d8a8cefc 100644 --- a/src/gcrypt-module.h +++ b/src/gcrypt-module.h @@ -1,25 +1,25 @@ /* gcrypt-module.h - GNU Cryptographic Library Interface Copyright (C) 2003, 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, see . */ /* This file contains the necessary declarations/definitions for - working with Libgcrypt modules. + working with Libgcrypt modules. */ #ifndef _GCRYPT_MODULE_H @@ -35,7 +35,7 @@ extern "C" { /* The interfaces using the module system reserve a certain range of IDs for application use. These IDs are not valid within Libgcrypt but Libgcrypt makes sure never to allocate such a module ID. */ -#define GCRY_MODULE_ID_USER 1024 +#define GCRY_MODULE_ID_USER 1024 #define GCRY_MODULE_ID_USER_LAST 4095 diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index 1b32de05..f8daeb35 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -1,19 +1,19 @@ /* gcrypt.h - GNU Cryptographic Library Interface -*- c -*- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 2007, 2008, 2009, 2010, 2011 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, see . @@ -198,7 +198,7 @@ enum gcry_thread_option struct gcry_thread_cbs { /* The OPTION field encodes the thread model and the version number - of this structure. + of this structure. Bits 7 - 0 are used for the thread model Bits 15 - 8 are used for the version number. */ @@ -357,7 +357,7 @@ const char *gcry_check_version (const char *req_version); /* Codes for function dispatchers. */ /* Codes used with the gcry_control function. */ -enum gcry_ctl_cmds +enum gcry_ctl_cmds { GCRYCTL_SET_KEY = 1, GCRYCTL_SET_IV = 2, @@ -422,7 +422,7 @@ enum gcry_ctl_cmds gcry_error_t gcry_control (enum gcry_ctl_cmds CMD, ...); -/* S-expression management. */ +/* S-expression management. */ /* The object to represent an S-expression as used with the public key functions. */ @@ -476,7 +476,7 @@ void gcry_sexp_release (gcry_sexp_t sexp); /* Calculate the length of an canonized S-expresion in BUFFER and check for a valid encoding. */ -size_t gcry_sexp_canon_len (const unsigned char *buffer, size_t length, +size_t gcry_sexp_canon_len (const unsigned char *buffer, size_t length, size_t *erroff, gcry_error_t *errcode); /* Copies the S-expression object SEXP into BUFFER using the format @@ -558,7 +558,7 @@ gcry_mpi_t gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt); *******************************************/ /* Different formats of external big integer representation. */ -enum gcry_mpi_format +enum gcry_mpi_format { GCRYMPI_FMT_NONE= 0, GCRYMPI_FMT_STD = 1, /* Twos complement stored without length. */ @@ -569,7 +569,7 @@ enum gcry_mpi_format }; /* Flags used for creating big integers. */ -enum gcry_mpi_flag +enum gcry_mpi_flag { GCRYMPI_FLAG_SECURE = 1, /* Allocate the number in "secure" memory. */ GCRYMPI_FLAG_OPAQUE = 2 /* The number is not a real one but just @@ -614,7 +614,7 @@ int gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v); RET_MPI. If NSCANNED is not NULL, it will receive the number of bytes actually scanned after a successful operation. */ gcry_error_t gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format, - const void *buffer, size_t buflen, + const void *buffer, size_t buflen, size_t *nscanned); /* Convert the big integer A into the external representation @@ -685,7 +685,7 @@ void gcry_mpi_powm (gcry_mpi_t w, const gcry_mpi_t b, const gcry_mpi_t e, const gcry_mpi_t m); -/* Set G to the greatest common divisor of A and B. +/* Set G to the greatest common divisor of A and B. Return true if the G is 1. */ int gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b); @@ -719,7 +719,7 @@ void gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n); void gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n); /* Store NBITS of the value P points to in A and mark A as an opaque - value. WARNING: Never use an opaque MPI for anything thing else then + value. WARNING: Never use an opaque MPI for anything thing else then gcry_mpi_release, gcry_mpi_get_opaque. */ gcry_mpi_t gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits); @@ -758,7 +758,7 @@ int gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag); #define mpi_set_ui( w, u) gcry_mpi_set_ui( (w), (u) ) #define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) ) #define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) ) - + #define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v)) #define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v)) #define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m)) @@ -838,15 +838,15 @@ enum gcry_cipher_algos }; /* The Rijndael algorithm is basically AES, so provide some macros. */ -#define GCRY_CIPHER_AES128 GCRY_CIPHER_AES -#define GCRY_CIPHER_RIJNDAEL GCRY_CIPHER_AES -#define GCRY_CIPHER_RIJNDAEL128 GCRY_CIPHER_AES128 -#define GCRY_CIPHER_RIJNDAEL192 GCRY_CIPHER_AES192 -#define GCRY_CIPHER_RIJNDAEL256 GCRY_CIPHER_AES256 +#define GCRY_CIPHER_AES128 GCRY_CIPHER_AES +#define GCRY_CIPHER_RIJNDAEL GCRY_CIPHER_AES +#define GCRY_CIPHER_RIJNDAEL128 GCRY_CIPHER_AES128 +#define GCRY_CIPHER_RIJNDAEL192 GCRY_CIPHER_AES192 +#define GCRY_CIPHER_RIJNDAEL256 GCRY_CIPHER_AES256 /* The supported encryption modes. Note that not all of them are supported for each algorithm. */ -enum gcry_cipher_modes +enum gcry_cipher_modes { GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */ GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */ @@ -858,7 +858,7 @@ enum gcry_cipher_modes GCRY_CIPHER_MODE_AESWRAP= 7 /* AES-WRAP algorithm. */ }; -/* Flags used with the open function. */ +/* Flags used with the open function. */ enum gcry_cipher_flags { GCRY_CIPHER_SECURE = 1, /* Allocate in secure memory. */ @@ -967,7 +967,7 @@ gcry_error_t gcry_cipher_list (int *list, int *list_length); ************************************/ /* The algorithms and their IDs we support. */ -enum gcry_pk_algos +enum gcry_pk_algos { GCRY_PK_RSA = 1, GCRY_PK_RSA_E = 2, /* (deprecated) */ @@ -980,11 +980,11 @@ enum gcry_pk_algos }; /* Flags describing usage capabilities of a PK algorithm. */ -#define GCRY_PK_USAGE_SIGN 1 /* Good for signatures. */ -#define GCRY_PK_USAGE_ENCR 2 /* Good for encryption. */ +#define GCRY_PK_USAGE_SIGN 1 /* Good for signatures. */ +#define GCRY_PK_USAGE_ENCR 2 /* Good for encryption. */ #define GCRY_PK_USAGE_CERT 4 /* Good to certify other keys. */ -#define GCRY_PK_USAGE_AUTH 8 /* Good for authentication. */ -#define GCRY_PK_USAGE_UNKN 128 /* Unknown usage flag. */ +#define GCRY_PK_USAGE_AUTH 8 /* Good for authentication. */ +#define GCRY_PK_USAGE_UNKN 128 /* Unknown usage flag. */ /* Encrypt the DATA using the public key PKEY and store the result as a newly created S-expression at RESULT. */ @@ -1069,7 +1069,7 @@ gcry_error_t gcry_pk_list (int *list, int *list_length); are implemnted. */ enum gcry_md_algos { - GCRY_MD_NONE = 0, + GCRY_MD_NONE = 0, GCRY_MD_MD5 = 1, GCRY_MD_SHA1 = 2, GCRY_MD_RMD160 = 3, @@ -1102,11 +1102,11 @@ struct gcry_md_context; /* This object is used to hold a handle to a message digest object. This structure is private - only to be used by the public gcry_md_* macros. */ -typedef struct gcry_md_handle +typedef struct gcry_md_handle { /* Actual context. */ struct gcry_md_context *ctx; - + /* Buffer management. */ int bufpos; int bufsize; @@ -1612,7 +1612,7 @@ gcry_error_t gcry_ac_data_verify_scheme (gcry_ac_handle_t handle, gcry_pk_algo_name. */ #ifndef GCRYPT_NO_DEPRECATED gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t algorithm, - const char **name) + const char **name) /* */ _GCRY_GCC_ATTR_DEPRECATED; /* Store the numeric ID of the algorithm whose textual representation is contained in NAME in ALGORITHM. This function is deprecated; @@ -1750,7 +1750,7 @@ gcry_error_t gcry_prime_check (gcry_mpi_t x, unsigned int flags); ************************************/ /* Log levels used by the internal logging facility. */ -enum gcry_log_levels +enum gcry_log_levels { GCRY_LOG_CONT = 0, /* (Continue the last log line.) */ GCRY_LOG_INFO = 10, diff --git a/src/gcryptrnd.c b/src/gcryptrnd.c index 34c24733..b13931b6 100644 --- a/src/gcryptrnd.c +++ b/src/gcryptrnd.c @@ -118,7 +118,7 @@ my_gcry_logger (void *dummy, int level, const char *format, va_list arg_ptr) case GCRY_LOG_FATAL:level = LOG_CRIT; break; case GCRY_LOG_BUG: level = LOG_CRIT; break; case GCRY_LOG_DEBUG:level = LOG_DEBUG; break; - default: level = LOG_ERR; break; + default: level = LOG_ERR; break; } if (running_detached) { @@ -152,24 +152,24 @@ daemonize (void) fflush (NULL); pid = fork (); - if (pid == (pid_t)-1) + if (pid == (pid_t)-1) { logit (LOG_CRIT, "fork failed: %s", strerror (errno)); exit (1); } if (pid) - exit (0); + exit (0); if (setsid() == -1) { logit (LOG_CRIT, "setsid() failed: %s", strerror(errno)); exit (1); } - + signal (SIGHUP, SIG_IGN); pid = fork (); - if (pid == (pid_t)-1) + if (pid == (pid_t)-1) { logit (LOG_CRIT, PGM ": second fork failed: %s", strerror (errno)); exit (1); @@ -221,7 +221,7 @@ print_version (int with_help) "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n", stdout); - + if (with_help) fputs ("\n" "Usage: " PGM " [OPTIONS] [SOCKETNAME]\n" @@ -229,11 +229,11 @@ print_version (int with_help) " on socket SOCKETNAME\n" "SOCKETNAME defaults to XXX\n" "\n" - " --no-detach do not deatach from the console\n" + " --no-detach do not deatach from the console\n" " --version print version of the program and exit\n" " --help display this help and exit\n" BUGREPORT_LINE, stdout ); - + exit (0); } @@ -246,7 +246,7 @@ print_usage (void) } -int +int main (int argc, char **argv) { int no_detach = 0; @@ -257,7 +257,7 @@ main (int argc, char **argv) int rc; const char *socketname = "/var/run/libgcrypt/S.gcryptrnd"; - + if (argc) { argc--; argv++; @@ -280,8 +280,8 @@ main (int argc, char **argv) } else print_usage (); - } - + } + if (argc == 1) socketname = argv[0]; else if (argc > 1) @@ -336,7 +336,7 @@ main (int argc, char **argv) logit (LOG_CRIT, "can't create socket: %s", strerror (errno)); exit (1); } - srvr_addr = gcry_xmalloc (sizeof *srvr_addr); + srvr_addr = gcry_xmalloc (sizeof *srvr_addr); memset (srvr_addr, 0, sizeof *srvr_addr); srvr_addr->sun_family = AF_UNIX; if (strlen (socketname) + 1 >= sizeof (srvr_addr->sun_path)) @@ -367,7 +367,7 @@ main (int argc, char **argv) close (fd); exit (1); } - + logit (LOG_INFO, "listening on socket `%s', fd=%d", srvr_addr->sun_path, fd); @@ -556,7 +556,7 @@ connection_thread (void *arg) close (fd); logit (LOG_INFO, "connection handler for fd %d terminated", fd); active_connections--; - + return NULL; } @@ -573,11 +573,11 @@ handle_signal (int signo) case SIGHUP: logit (LOG_NOTICE, "SIGHUP received - re-reading configuration"); break; - + case SIGUSR1: logit (LOG_NOTICE, "SIGUSR1 received - no action defined"); break; - + case SIGUSR2: logit (LOG_NOTICE, "SIGUSR2 received - no action defined"); break; @@ -595,7 +595,7 @@ handle_signal (int signo) return 1; } break; - + case SIGINT: logit (LOG_NOTICE, "SIGINT received - immediate shutdown"); return 1; @@ -675,7 +675,6 @@ serve (int listen_fd) close (fd); } } - + pth_event_free (ev, PTH_FREE_ALL); } - diff --git a/src/getrandom.c b/src/getrandom.c index f4c9b4b2..f9bb5c0c 100644 --- a/src/getrandom.c +++ b/src/getrandom.c @@ -56,7 +56,7 @@ writen (int fd, const void *buffer, size_t length) while (length) { ssize_t n; - + do n = write (fd, buffer, length); while (n < 0 && errno == EINTR); @@ -84,7 +84,7 @@ print_version (int with_help) "This is free software: you are free to change and redistribute it.\n" "There is NO WARRANTY, to the extent permitted by law.\n", stdout); - + if (with_help) fputs ("\n" "Usage: " PGM " [OPTIONS] NBYTES\n" @@ -94,13 +94,13 @@ print_version (int with_help) " --nonce Return weak random suitable for a nonce\n" " --very-strong Return very strong random\n" " --ping Send a ping\n" - " --socket NAME Name of sockket to connect to\n" + " --socket NAME Name of sockket to connect to\n" " --hex Return result as a hex dump\n" " --verbose Show what we are doing\n" " --version Print version of the program and exit\n" " --help Display this help and exit\n" BUGREPORT_LINE, stdout ); - + exit (0); } @@ -113,7 +113,7 @@ print_usage (void) } -int +int main (int argc, char **argv) { struct sockaddr_un *srvr_addr; @@ -130,7 +130,7 @@ main (int argc, char **argv) int verbose = 0; int fail = 0; int do_hex = 0; - + if (argc) { argc--; argv++; @@ -179,15 +179,15 @@ main (int argc, char **argv) } else print_usage (); - } + } + - if (!argc && do_ping) ; /* This is allowed. */ else if (argc != 1) print_usage (); req_nbytes = argc? atoi (*argv) : 0; - + if (req_nbytes < 0) print_usage (); @@ -198,7 +198,7 @@ main (int argc, char **argv) logit ("can't create socket: %s", strerror (errno)); exit (1); } - srvr_addr = malloc (sizeof *srvr_addr); + srvr_addr = malloc (sizeof *srvr_addr); if (!srvr_addr) { logit ("malloc failed: %s", strerror (errno)); @@ -244,7 +244,7 @@ main (int argc, char **argv) { for (nleft=2, nread=0; nleft > 0; ) { - do + do n = read (fd, buffer+nread, nleft); while (n < 0 && errno == EINTR); if (n < 0) @@ -281,7 +281,7 @@ main (int argc, char **argv) for (nleft=nbytes, nread=0; nleft > 0; ) { - do + do n = read (fd, buffer+nread, nleft); while (n < 0 && errno == EINTR); if (n < 0) @@ -324,4 +324,3 @@ main (int argc, char **argv) free (srvr_addr); return fail? 1 : 0; } - diff --git a/src/global.c b/src/global.c index 2944b2c5..096ac98c 100644 --- a/src/global.c +++ b/src/global.c @@ -87,7 +87,7 @@ global_init (void) err = ath_init (); if (err) goto fail; - + /* See whether the system is in FIPS mode. This needs to come as early as possible put after the ATH has been initialized. */ _gcry_initialize_fips_mode (force_fips_mode); @@ -126,7 +126,7 @@ global_init (void) sure that the minimal initialization has been done. This is far from a perfect solution and hides problems with an improper initialization but at least in single-threaded mode it should work - reliable. + reliable. The reason we need this is that a lot of applications don't use Libgcrypt properly by not running any initialization code at all. @@ -266,7 +266,7 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp) { HWF_PADLOCK_AES, "padlock-aes" }, { HWF_PADLOCK_SHA, "padlock-sha" }, { HWF_INTEL_AES, "intel-aes" }, - { 0, NULL} + { 0, NULL} }; int i; @@ -298,7 +298,7 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp) /* We use y/n instead of 1/0 for the simple reason that Emacsen's compile error parser would accidently flag that line when printed during "make check" as an error. */ - fnc (fp, "fips-mode:%c:%c:\n", + fnc (fp, "fips-mode:%c:%c:\n", fips_mode ()? 'y':'n', _gcry_enforced_fips_mode ()? 'y':'n' ); } @@ -313,7 +313,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) { static int init_finished = 0; gcry_err_code_t err = 0; - + switch (cmd) { case GCRYCTL_ENABLE_M_GUARD: @@ -351,7 +351,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) case GCRYCTL_DISABLE_SECMEM: global_init (); no_secure_memory = 1; - break; + break; case GCRYCTL_INIT_SECMEM: global_init (); @@ -451,7 +451,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) _gcry_random_initialize (1); if ( fips_is_operational () ) - _gcry_fast_random_poll (); + _gcry_fast_random_poll (); break; case GCRYCTL_SET_RNDEGD_SOCKET: @@ -472,7 +472,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) _gcry_random_initialize (1); _gcry_use_random_daemon (!! va_arg (arg_ptr, int)); break; - + /* This command dumps information pertaining to the configuration of libgcrypt to the given stream. It may be used before the initialization has been finished but not @@ -492,8 +492,8 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) break; case GCRYCTL_FIPS_MODE_P: - if (fips_mode () - && !_gcry_is_fips_mode_inactive () + if (fips_mode () + && !_gcry_is_fips_mode_inactive () && !no_secure_memory) err = GPG_ERR_GENERAL; /* Used as TRUE value */ break; @@ -509,7 +509,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) into fips mode during initialization. */ force_fips_mode = 1; } - else + else { /* Already initialized. If we are already operational we run a selftest. If not we use the is_operational call to @@ -583,7 +583,7 @@ gcry_control (enum gcry_ctl_cmds cmd, ...) { gcry_error_t err; va_list arg_ptr; - + va_start (arg_ptr, cmd); err = _gcry_vcontrol (cmd, arg_ptr); va_end(arg_ptr); @@ -626,7 +626,7 @@ gcry_err_code_to_errno (gcry_err_code_t code) return gpg_err_code_from_errno (code); } - + /* Return an error value with the error source SOURCE and the system error ERR. */ gcry_error_t @@ -699,7 +699,7 @@ gcry_set_outofcore_handler( int (*f)( void*, size_t, unsigned int ), log_info ("out of core handler ignored in FIPS mode\n"); return; } - + outofcore_handler = f; outofcore_handler_value = value; } @@ -753,7 +753,7 @@ do_malloc (size_t n, unsigned int flags, void **mem) return err; } - + void * gcry_malloc (size_t n) { @@ -788,7 +788,7 @@ void _gcry_check_heap( const void *a ) { (void)a; - + /* FIXME: implement this*/ #if 0 if( some_handler ) @@ -841,7 +841,7 @@ gcry_calloc (size_t n, size_t m) bytes = n * m; /* size_t is unsigned so the behavior on overflow is defined. */ - if (m && bytes / m != n) + if (m && bytes / m != n) { gpg_err_set_errno (ENOMEM); return NULL; @@ -861,12 +861,12 @@ gcry_calloc_secure (size_t n, size_t m) bytes = n * m; /* size_t is unsigned so the behavior on overflow is defined. */ - if (m && bytes / m != n) + if (m && bytes / m != n) { gpg_err_set_errno (ENOMEM); return NULL; } - + p = gcry_malloc_secure (bytes); if (p) memset (p, 0, bytes); @@ -890,7 +890,7 @@ gcry_strdup (const char *string) string_cp = gcry_malloc_secure (string_n + 1); else string_cp = gcry_malloc (string_n + 1); - + if (string_cp) strcpy (string_cp, string); @@ -902,10 +902,10 @@ void * gcry_xmalloc( size_t n ) { void *p; - - while ( !(p = gcry_malloc( n )) ) + + while ( !(p = gcry_malloc( n )) ) { - if ( fips_mode () + if ( fips_mode () || !outofcore_handler || !outofcore_handler (outofcore_handler_value, n, 0) ) { @@ -919,7 +919,7 @@ void * gcry_xrealloc( void *a, size_t n ) { void *p; - + while ( !(p = gcry_realloc( a, n )) ) { if ( fips_mode () @@ -937,8 +937,8 @@ void * gcry_xmalloc_secure( size_t n ) { void *p; - - while ( !(p = gcry_malloc_secure( n )) ) + + while ( !(p = gcry_malloc_secure( n )) ) { if ( fips_mode () || !outofcore_handler @@ -958,8 +958,8 @@ gcry_xcalloc( size_t n, size_t m ) size_t nbytes; void *p; - nbytes = n * m; - if (m && nbytes / m != n) + nbytes = n * m; + if (m && nbytes / m != n) { gpg_err_set_errno (ENOMEM); _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL ); @@ -976,8 +976,8 @@ gcry_xcalloc_secure( size_t n, size_t m ) size_t nbytes; void *p; - nbytes = n * m; - if (m && nbytes / m != n) + nbytes = n * m; + if (m && nbytes / m != n) { gpg_err_set_errno (ENOMEM); _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL ); @@ -992,15 +992,15 @@ char * gcry_xstrdup (const char *string) { char *p; - - while ( !(p = gcry_strdup (string)) ) + + while ( !(p = gcry_strdup (string)) ) { size_t n = strlen (string); int is_sec = !!gcry_is_secure (string); - + if (fips_mode () || !outofcore_handler - || !outofcore_handler (outofcore_handler_value, n, is_sec) ) + || !outofcore_handler (outofcore_handler_value, n, is_sec) ) { _gcry_fatal_error (gpg_err_code_from_errno (errno), is_sec? _("out of core in secure memory"):NULL); @@ -1022,7 +1022,7 @@ _gcry_get_debug_flag (unsigned int mask) /* It is often useful to get some feedback of long running operations. - This function may be used to register a handler for this. + This function may be used to register a handler for this. The callback function CB is used as: void cb (void *opaque, const char *what, int printchar, @@ -1051,10 +1051,10 @@ _gcry_get_debug_flag (unsigned int mask) ':' Restart with a new random value '+' - Rabin Miller test passed + Rabin Miller test passed "pk_elg" '+','-','.','\n' 0 0 Only used in debugging mode. - "pk_dsa" + "pk_dsa" Only used in debugging mode. */ void diff --git a/src/hmac256.c b/src/hmac256.c index 6e31d200..f3bc0924 100644 --- a/src/hmac256.c +++ b/src/hmac256.c @@ -17,7 +17,7 @@ * License along with this program; if not, see . */ -/* +/* This is a standalone HMAC-SHA-256 implementation based on the code from ../cipher/sha256.c. It is a second implementation to allow comparing against the standard implementations and to be used for @@ -33,7 +33,7 @@ Constants: - WORDS_BIGENDIAN Defined to 1 on big endian systems. + WORDS_BIGENDIAN Defined to 1 on big endian systems. inline If defined, it should yield the keyword used to inline a function. HAVE_U32_TYPEDEF Defined if the u32 type is available. @@ -91,7 +91,7 @@ struct hmac256_context u32 nblocks; int count; int finalized:1; - int use_hmac:1; + int use_hmac:1; unsigned char buf[64]; unsigned char opad[64]; }; @@ -121,7 +121,7 @@ ror(u32 x, int n) -/* +/* The SHA-256 core: Transform the message X which consists of 16 32-bit-words. See FIPS 180-2 for details. */ @@ -149,13 +149,13 @@ transform (hmac256_context_t hd, const void *data_arg) b = a; \ a = t1 + t2; \ } while (0) - - static const u32 K[64] = + + static const u32 K[64] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, @@ -174,7 +174,7 @@ transform (hmac256_context_t hd, const void *data_arg) u32 x[16]; u32 w[64]; int i; - + a = hd->h0; b = hd->h1; c = hd->h2; @@ -183,14 +183,14 @@ transform (hmac256_context_t hd, const void *data_arg) f = hd->h5; g = hd->h6; h = hd->h7; - + #ifdef WORDS_BIGENDIAN memcpy (x, data, 64); #else /*!WORDS_BIGENDIAN*/ - { + { unsigned char *p2; - - for (i=0, p2=(unsigned char*)x; i < 16; i++, p2 += 4 ) + + for (i=0, p2=(unsigned char*)x; i < 16; i++, p2 += 4 ) { p2[3] = *data++; p2[2] = *data++; @@ -232,7 +232,7 @@ finalize (hmac256_context_t hd) { u32 t, msb, lsb; unsigned char *p; - + if (hd->finalized) return; /* Silently ignore a finalized context. */ @@ -336,7 +336,7 @@ _gcry_hmac256_new (const void *key, size_t keylen) else { hmac256_context_t tmphd; - + tmphd = _gcry_hmac256_new (NULL, 0); if (!tmphd) { @@ -349,7 +349,7 @@ _gcry_hmac256_new (const void *key, size_t keylen) memcpy (hd->opad, tmphd->buf, 32); _gcry_hmac256_release (tmphd); } - for (i=0; i < 64; i++) + for (i=0; i < 64; i++) { ipad[i] ^= 0x36; hd->opad[i] ^= 0x5c; @@ -358,7 +358,7 @@ _gcry_hmac256_new (const void *key, size_t keylen) _gcry_hmac256_update (hd, ipad, 64); my_wipememory (ipad, 64); } - + return hd; } @@ -389,7 +389,7 @@ _gcry_hmac256_update (hmac256_context_t hd, return; /* Silently ignore a finalized context. */ if (hd->count == 64) - { + { /* Flush the buffer. */ transform (hd, hd->buf); hd->count = 0; @@ -431,7 +431,7 @@ _gcry_hmac256_finalize (hmac256_context_t hd, size_t *r_dlen) if (hd->use_hmac) { hmac256_context_t tmphd; - + tmphd = _gcry_hmac256_new (NULL, 0); if (!tmphd) { @@ -456,7 +456,7 @@ _gcry_hmac256_finalize (hmac256_context_t hd, size_t *r_dlen) FILENAME. KEY and KEYLEN are as described for _gcry_hmac256_new. On success the function returns the valid length of the result buffer (which will be 32) or -1 on error. On error ERRNO is set - appropriate. */ + appropriate. */ int _gcry_hmac256_file (void *result, size_t resultsize, const char *filename, const void *key, size_t keylen) @@ -466,7 +466,7 @@ _gcry_hmac256_file (void *result, size_t resultsize, const char *filename, size_t buffer_size, nread, digestlen; char *buffer; const unsigned char *digest; - + fp = fopen (filename, "rb"); if (!fp) return -1; @@ -507,7 +507,7 @@ _gcry_hmac256_file (void *result, size_t resultsize, const char *filename, _gcry_hmac256_release (hd); return -1; } - + if (digestlen > resultsize) { _gcry_hmac256_release (hd); @@ -526,7 +526,7 @@ _gcry_hmac256_file (void *result, size_t resultsize, const char *filename, static int selftest (void) { - static struct + static struct { const char * const desc; const char * const data; @@ -535,7 +535,7 @@ selftest (void) } tv[] = { { "data-28 key-4", - "what do ya want for nothing?", + "what do ya want for nothing?", "Jefe", { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, @@ -612,7 +612,7 @@ selftest (void) { NULL } }; int tvidx; - + for (tvidx=0; tv[tvidx].desc; tvidx++) { hmac256_context_t hmachd; @@ -637,12 +637,12 @@ selftest (void) } _gcry_hmac256_release (hmachd); } - + return 0; /* Succeeded. */ } -int +int main (int argc, char **argv) { const char *pgm; @@ -699,7 +699,7 @@ main (int argc, char **argv) argc--; argv++; use_binary = 1; } - } + } if (argc < 1) { @@ -729,14 +729,14 @@ main (int argc, char **argv) fp = use_stdin? stdin : fopen (fname, "rb"); if (!fp) { - fprintf (stderr, "%s: can't open `%s': %s\n", + fprintf (stderr, "%s: can't open `%s': %s\n", pgm, fname, strerror (errno)); exit (1); } hd = _gcry_hmac256_new (key, keylen); if (!hd) { - fprintf (stderr, "%s: can't allocate context: %s\n", + fprintf (stderr, "%s: can't allocate context: %s\n", pgm, strerror (errno)); exit (1); } @@ -744,7 +744,7 @@ main (int argc, char **argv) _gcry_hmac256_update (hd, buffer, n); if (ferror (fp)) { - fprintf (stderr, "%s: error reading `%s': %s\n", + fprintf (stderr, "%s: error reading `%s': %s\n", pgm, fname, strerror (errno)); exit (1); } @@ -762,7 +762,7 @@ main (int argc, char **argv) { if (fwrite (digest, dlen, 1, stdout) != 1) { - fprintf (stderr, "%s: error writing output: %s\n", + fprintf (stderr, "%s: error writing output: %s\n", pgm, strerror (errno)); exit (1); } diff --git a/src/hwfeatures.c b/src/hwfeatures.c index da5d303a..99c9347e 100644 --- a/src/hwfeatures.c +++ b/src/hwfeatures.c @@ -48,7 +48,7 @@ detect_ia32_gnuc (void) build it if that support has been disabled. */ int has_cpuid = 0; char vendor_id[12+1]; - + /* Detect the CPUID feature by testing some undefined behaviour (16 vs 32 bit pushf/popf). */ asm volatile @@ -56,9 +56,9 @@ detect_ia32_gnuc (void) "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" /* Save flags into ECX. */ "xorl $0x200000, %%eax\n\t" /* Toggle ID bit and copy it to the flags. */ - "pushl %%eax\n\t" - "popf\n\t" - "pushf\n\t" /* Copy changed flags again to EAX. */ + "pushl %%eax\n\t" + "popf\n\t" + "pushf\n\t" /* Copy changed flags again to EAX. */ "popl %%eax\n\t" "pushl %%ecx\n\t" /* Restore flags from ECX. */ "popf\n\t" @@ -70,10 +70,10 @@ detect_ia32_gnuc (void) : : "%eax", "%ecx", "cc" ); - + if (!has_cpuid) return; /* No way. */ - + asm volatile ("pushl %%ebx\n\t" /* Save GOT register. */ "xorl %%eax, %%eax\n\t" /* 0 -> EAX. */ @@ -90,11 +90,11 @@ detect_ia32_gnuc (void) if (0) ; /* Just to make "else if" and ifdef macros look pretty. */ -#ifdef ENABLE_PADLOCK_SUPPORT +#ifdef ENABLE_PADLOCK_SUPPORT else if (!strcmp (vendor_id, "CentaurHauls")) { /* This is a VIA CPU. Check what PadLock features we have. */ - asm volatile + asm volatile ("pushl %%ebx\n\t" /* Save GOT register. */ "movl $0xC0000000, %%eax\n\t" /* Check for extended centaur */ "cpuid\n\t" /* feature flags. */ @@ -144,7 +144,7 @@ detect_ia32_gnuc (void) else if (!strcmp (vendor_id, "GenuineIntel")) { /* This is an Intel CPU. */ - asm volatile + asm volatile ("pushl %%ebx\n\t" /* Save GOT register. */ "movl $1, %%eax\n\t" /* Get CPU info and feature flags. */ "cpuid\n" @@ -177,14 +177,14 @@ _gcry_detect_hw_features (void) hw_features = 0; if (fips_mode ()) - return; /* Hardware support is not to be evaluated. */ + return; /* Hardware support is not to be evaluated. */ #if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 -#ifdef __GNUC__ +#ifdef __GNUC__ detect_ia32_gnuc (); #endif #elif defined (__i386__) && SIZEOF_UNSIGNED_LONG == 8 -#ifdef __GNUC__ +#ifdef __GNUC__ #endif #endif } diff --git a/src/libgcrypt.def b/src/libgcrypt.def index 3db4cb5a..ac3d575e 100644 --- a/src/libgcrypt.def +++ b/src/libgcrypt.def @@ -1,6 +1,6 @@ ;; libgcrypt.defs - Exported symbols for W32 ;; Copyright (C) 2003, 2007 Free Software Foundation, Inc. -;; +;; ;; This file is part of Libgcrypt. ;; ;; Libgcrypt is free software; you can redistribute it and/or modify @@ -25,7 +25,7 @@ EXPORTS gcry_check_version @1 gcry_control @2 - + gcry_malloc @3 gcry_calloc @4 gcry_malloc_secure @5 @@ -40,21 +40,21 @@ EXPORTS gcry_xstrdup @14 gcry_is_secure @15 gcry_free @16 - + gcry_set_progress_handler @17 gcry_set_allocation_handler @18 gcry_set_outofcore_handler @19 gcry_set_fatalerror_handler @20 gcry_set_log_handler @21 gcry_set_gettext_handler @22 - + gcry_strerror @23 gcry_strsource @24 gcry_err_code_from_errno @25 gcry_err_code_to_errno @26 gcry_err_make_from_errno @27 gcry_error_from_errno @28 - + gcry_sexp_new @29 gcry_sexp_create @30 gcry_sexp_sscan @31 @@ -77,7 +77,7 @@ EXPORTS gcry_sexp_cadr @48 gcry_sexp_nth_data @49 gcry_sexp_nth_mpi @50 - + gcry_mpi_new @51 gcry_mpi_snew @52 gcry_mpi_release @53 @@ -119,7 +119,7 @@ EXPORTS gcry_mpi_clear_flag @89 gcry_mpi_get_flag @90 - + gcry_cipher_open @92 gcry_cipher_close @93 gcry_cipher_ctl @94 @@ -133,7 +133,7 @@ EXPORTS gcry_cipher_get_algo_keylen @102 gcry_cipher_get_algo_blklen @103 gcry_cipher_list @104 - + gcry_pk_encrypt @105 gcry_pk_decrypt @106 gcry_pk_sign @107 @@ -147,7 +147,7 @@ EXPORTS gcry_pk_get_nbits @115 gcry_pk_get_keygrip @116 gcry_pk_list @117 - + gcry_ac_data_new @118 gcry_ac_data_destroy @119 gcry_ac_data_set @120 @@ -173,7 +173,7 @@ EXPORTS gcry_ac_data_verify @140 gcry_ac_id_to_name @141 gcry_ac_name_to_id @142 - + gcry_md_open @143 gcry_md_close @144 gcry_md_enable @145 @@ -193,13 +193,13 @@ EXPORTS gcry_md_map_name @159 gcry_md_setkey @160 gcry_md_list @161 - + gcry_randomize @162 gcry_random_add_bytes @163 gcry_random_bytes @164 gcry_random_bytes_secure @165 gcry_mpi_randomize @166 - + gcry_prime_generate @167 gcry_prime_group_generator @168 gcry_prime_release_factors @169 @@ -215,7 +215,7 @@ EXPORTS gcry_md_unregister @176 gcry_pk_register @177 gcry_pk_unregister @178 - + gcry_ac_data_from_sexp @179 gcry_ac_data_to_sexp @180 gcry_ac_io_init @181 diff --git a/src/libgcrypt.m4 b/src/libgcrypt.m4 index 854eaaa8..0f60165a 100644 --- a/src/libgcrypt.m4 +++ b/src/libgcrypt.m4 @@ -15,7 +15,7 @@ dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed dnl with the API version to also check the API compatibility. Example: -dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed +dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using dnl this features allows to prevent build against newer versions of libgcrypt dnl with a changed API. @@ -59,7 +59,7 @@ AC_DEFUN([AM_PATH_LIBGCRYPT], sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes - else + else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes diff --git a/src/libgcrypt.vers b/src/libgcrypt.vers index f2a3513d..fbeb47bd 100644 --- a/src/libgcrypt.vers +++ b/src/libgcrypt.vers @@ -26,24 +26,24 @@ GCRYPT_1.2 { gcry_set_allocation_handler; gcry_set_fatalerror_handler; gcry_set_gettext_handler; gcry_set_log_handler; gcry_set_outofcore_handler; gcry_set_progress_handler; - + gcry_err_code_from_errno; gcry_err_code_to_errno; gcry_err_make_from_errno; gcry_error_from_errno; gcry_strerror; gcry_strsource; - + gcry_free; gcry_malloc; gcry_malloc_secure; gcry_calloc; gcry_calloc_secure; gcry_realloc; gcry_strdup; gcry_is_secure; gcry_xcalloc; gcry_xcalloc_secure; gcry_xmalloc; gcry_xmalloc_secure; gcry_xrealloc; gcry_xstrdup; - + gcry_md_algo_info; gcry_md_algo_name; gcry_md_close; gcry_md_copy; gcry_md_ctl; gcry_md_enable; gcry_md_get; gcry_md_get_algo; gcry_md_get_algo_dlen; gcry_md_hash_buffer; gcry_md_info; gcry_md_is_enabled; gcry_md_is_secure; gcry_md_list; gcry_md_map_name; gcry_md_open; gcry_md_read; - gcry_md_register; gcry_md_reset; gcry_md_setkey; + gcry_md_register; gcry_md_reset; gcry_md_setkey; gcry_md_unregister; gcry_md_write; gcry_md_debug; - + gcry_cipher_algo_info; gcry_cipher_algo_name; gcry_cipher_close; gcry_cipher_ctl; gcry_cipher_decrypt; gcry_cipher_encrypt; gcry_cipher_get_algo_blklen; gcry_cipher_get_algo_keylen; @@ -51,7 +51,7 @@ GCRYPT_1.2 { gcry_cipher_mode_from_oid; gcry_cipher_open; gcry_cipher_register; gcry_cipher_unregister; gcry_cipher_setkey; gcry_cipher_setiv; gcry_cipher_setctr; - + gcry_pk_algo_info; gcry_pk_algo_name; gcry_pk_ctl; gcry_pk_decrypt; gcry_pk_encrypt; gcry_pk_genkey; gcry_pk_get_keygrip; gcry_pk_get_nbits; gcry_pk_list; @@ -69,18 +69,18 @@ GCRYPT_1.2 { gcry_ac_data_sign; gcry_ac_data_verify; gcry_ac_id_to_name; gcry_ac_name_to_id; gcry_ac_list; gcry_ac_data_encode; gcry_ac_data_decode; gcry_ac_mpi_to_os; gcry_ac_mpi_to_os_alloc; - gcry_ac_os_to_mpi; gcry_ac_data_encrypt_scheme; + gcry_ac_os_to_mpi; gcry_ac_data_encrypt_scheme; gcry_ac_data_decrypt_scheme; gcry_ac_data_sign_scheme; gcry_ac_data_verify_scheme; gcry_ac_data_to_sexp; gcry_ac_data_from_sexp; gcry_ac_io_init; gcry_ac_io_init_va; - gcry_prime_check; gcry_prime_generate; + gcry_prime_check; gcry_prime_generate; gcry_prime_group_generator; gcry_prime_release_factors; - + gcry_random_add_bytes; gcry_random_bytes; gcry_random_bytes_secure; gcry_randomize; gcry_create_nonce; - + gcry_sexp_alist; gcry_sexp_append; gcry_sexp_build; gcry_sexp_build_array; gcry_sexp_cadr; gcry_sexp_canon_len; gcry_sexp_car; gcry_sexp_cdr; gcry_sexp_cons; gcry_sexp_create; @@ -89,7 +89,7 @@ GCRYPT_1.2 { gcry_sexp_nth_mpi; gcry_sexp_prepend; gcry_sexp_release; gcry_sexp_sprint; gcry_sexp_sscan; gcry_sexp_vlist; gcry_sexp_nth_string; - + gcry_mpi_add; gcry_mpi_add_ui; gcry_mpi_addm; gcry_mpi_aprint; gcry_mpi_clear_bit; gcry_mpi_clear_flag; gcry_mpi_clear_highbit; gcry_mpi_cmp; gcry_mpi_cmp_ui; gcry_mpi_copy; gcry_mpi_div; @@ -107,4 +107,3 @@ GCRYPT_1.2 { *; }; - diff --git a/src/misc.c b/src/misc.c index 9a6de2f2..17bd5467 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1,5 +1,5 @@ /* misc.c - * Copyright (C) 1999, 2001, 2002, 2003, 2007, + * Copyright (C) 1999, 2001, 2002, 2003, 2007, * 2008 Free Software Foundation, Inc. * * This file is part of Libgcrypt. @@ -118,9 +118,9 @@ _gcry_logv( int level, const char *fmt, va_list arg_ptr ) { if (log_handler) log_handler (log_handler_value, level, fmt, arg_ptr); - else + else { - switch (level) + switch (level) { case GCRY_LOG_CONT: break; case GCRY_LOG_INFO: break; @@ -133,7 +133,7 @@ _gcry_logv( int level, const char *fmt, va_list arg_ptr ) } vfprintf(stderr,fmt,arg_ptr) ; } - + if ( level == GCRY_LOG_FATAL || level == GCRY_LOG_BUG ) { fips_signal_fatal_error ("internal error (fatal or bug)"); @@ -257,8 +257,8 @@ void _gcry_log_printf (const char *fmt, ...) { va_list arg_ptr; - - if (fmt) + + if (fmt) { va_start( arg_ptr, fmt ) ; _gcry_logv (GCRY_LOG_CONT, fmt, arg_ptr); @@ -290,7 +290,7 @@ void _gcry_burn_stack (int bytes) { char buf[64]; - + wipememory (buf, sizeof buf); bytes -= sizeof buf; if (bytes > 0) diff --git a/src/missing-string.c b/src/missing-string.c index a5e56c3f..4756c00e 100644 --- a/src/missing-string.c +++ b/src/missing-string.c @@ -1,5 +1,5 @@ /* missing-string.c - missing string utilities - * Copyright (C) 1994, 1998, 1999, 2000, 2001, + * Copyright (C) 1994, 1998, 1999, 2000, 2001, * 2003 Free Software Foundation, Inc. * * This file is part of Libgcrypt. @@ -52,4 +52,3 @@ strcasecmp( const char *a, const char *b ) return *(const byte*)a - *(const byte*)b; } #endif - diff --git a/src/module.c b/src/module.c index 4f282af2..32f668de 100644 --- a/src/module.c +++ b/src/module.c @@ -127,7 +127,7 @@ _gcry_module_drop (gcry_module_t entry) /* Lookup a module specification by it's ID. After a successful lookup, the module has it's resource counter incremented. */ -gcry_module_t +gcry_module_t _gcry_module_lookup_id (gcry_module_t entries, unsigned int mod_id) { gcry_module_t entry; @@ -146,7 +146,7 @@ _gcry_module_lookup_id (gcry_module_t entries, unsigned int mod_id) module has it's resource counter incremented. FUNC is a function provided by the caller, which is responsible for identifying the wanted module. */ -gcry_module_t +gcry_module_t _gcry_module_lookup (gcry_module_t entries, void *data, gcry_module_lookup_t func) { diff --git a/src/mpi.h b/src/mpi.h index 21d4a4eb..65a4f97e 100644 --- a/src/mpi.h +++ b/src/mpi.h @@ -62,7 +62,7 @@ #define DBG_MPI _gcry_get_debug_flag( 2 ); -struct gcry_mpi +struct gcry_mpi { int alloced; /* Array size (# of allocated limbs). */ int nlimbs; /* Number of valid limbs. */ @@ -107,13 +107,13 @@ struct gcry_mpi #define mpi_is_opaque(a) ((a) && ((a)->flags&4)) #define mpi_is_secure(a) ((a) && ((a)->flags&1)) #define mpi_clear(a) _gcry_mpi_clear ((a)) -#define mpi_alloc_like(a) _gcry_mpi_alloc_like((a)) -#define mpi_set(a,b) _gcry_mpi_set ((a),(b)) -#define mpi_set_ui(a,b) _gcry_mpi_set_ui ((a),(b)) +#define mpi_alloc_like(a) _gcry_mpi_alloc_like((a)) +#define mpi_set(a,b) _gcry_mpi_set ((a),(b)) +#define mpi_set_ui(a,b) _gcry_mpi_set_ui ((a),(b)) #define mpi_get_ui(a,b) _gcry_mpi_get_ui ((a),(b)) #define mpi_alloc_set_ui(a) _gcry_mpi_alloc_set_ui ((a)) -#define mpi_m_check(a) _gcry_mpi_m_check ((a)) -#define mpi_swap(a,b) _gcry_mpi_swap ((a),(b)) +#define mpi_m_check(a) _gcry_mpi_m_check ((a)) +#define mpi_swap(a,b) _gcry_mpi_swap ((a),(b)) #define mpi_new(n) _gcry_mpi_new ((n)) #define mpi_snew(n) _gcry_mpi_snew ((n)) @@ -131,7 +131,7 @@ void _gcry_log_mpidump( const char *text, gcry_mpi_t a ); u32 _gcry_mpi_get_keyid( gcry_mpi_t a, u32 *keyid ); byte *_gcry_mpi_get_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign ); byte *_gcry_mpi_get_secure_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign ); -void _gcry_mpi_set_buffer ( gcry_mpi_t a, const void *buffer, +void _gcry_mpi_set_buffer ( gcry_mpi_t a, const void *buffer, unsigned int nbytes, int sign ); #define log_mpidump _gcry_log_mpidump @@ -249,10 +249,10 @@ mpi_ec_t _gcry_mpi_ec_init (gcry_mpi_t p, gcry_mpi_t a); void _gcry_mpi_ec_free (mpi_ec_t ctx); int _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t *point, mpi_ec_t ctx); -void _gcry_mpi_ec_dup_point (mpi_point_t *result, +void _gcry_mpi_ec_dup_point (mpi_point_t *result, mpi_point_t *point, mpi_ec_t ctx); void _gcry_mpi_ec_add_points (mpi_point_t *result, - mpi_point_t *p1, mpi_point_t *p2, + mpi_point_t *p1, mpi_point_t *p2, mpi_ec_t ctx); void _gcry_mpi_ec_mul_point (mpi_point_t *result, gcry_mpi_t scalar, mpi_point_t *point, diff --git a/src/secmem.c b/src/secmem.c index 1e375bfd..30c27774 100644 --- a/src/secmem.c +++ b/src/secmem.c @@ -136,7 +136,7 @@ mb_get_next (memblock_t *mb) memblock_t *mb_next; mb_next = (memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size); - + if (! ptr_into_pool_p (mb_next)) mb_next = NULL; @@ -192,7 +192,7 @@ static memblock_t * mb_get_new (memblock_t *block, size_t size) { memblock_t *mb, *mb_split; - + for (mb = block; ptr_into_pool_p (mb); mb = mb_get_next (mb)) if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size) { @@ -202,7 +202,7 @@ mb_get_new (memblock_t *block, size_t size) if (mb->size - size > BLOCK_HEAD_SIZE) { /* Split block. */ - + mb_split = (memblock_t *) (((char *) mb) + BLOCK_HEAD_SIZE + size); mb_split->size = mb->size - size - BLOCK_HEAD_SIZE; mb_split->flags = 0; @@ -271,7 +271,7 @@ lock_pool (void *p, size_t n) /* Under HP/UX mlock segfaults if called by non-root. Note, we have noch checked whether mlock does really work under AIX where we also detected a broken nlock. Note further, that using plock () - is not a good idea under AIX. */ + is not a good idea under AIX. */ if (uid) { errno = EPERM; @@ -323,7 +323,7 @@ lock_pool (void *p, size_t n) (void)p; (void)n; #elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__) - /* It does not make sense to print such a warning, given the fact that + /* It does not make sense to print such a warning, given the fact that * this whole Windows !@#$% and their user base are inherently insecure. */ (void)p; (void)n; @@ -548,7 +548,7 @@ _gcry_secmem_malloc (size_t size) SECMEM_LOCK; p = _gcry_secmem_malloc_internal (size); SECMEM_UNLOCK; - + return p; } @@ -666,7 +666,7 @@ _gcry_secmem_term () void _gcry_secmem_dump_stats () { -#if 1 +#if 1 SECMEM_LOCK; if (pool_okay) diff --git a/src/sexp.c b/src/sexp.c index a64ad424..ed4e9402 100644 --- a/src/sexp.c +++ b/src/sexp.c @@ -68,7 +68,7 @@ sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, #undef whitespacep static GPG_ERR_INLINE int whitespacep (const char *p) -{ +{ switch (*p) { case ' ': case '\t': case '\v': case '\f': case '\r': case '\n': return 1; @@ -98,7 +98,7 @@ dump_string (const byte *p, size_t n, int delim ) { for (; n; n--, p++ ) { - if ((*p & 0x80) || iscntrl( *p ) || *p == delim ) + if ((*p & 0x80) || iscntrl( *p ) || *p == delim ) { if( *p == '\n' ) log_printf ("\\n"); @@ -110,7 +110,7 @@ dump_string (const byte *p, size_t n, int delim ) log_printf ("\\v"); else if( *p == '\b' ) log_printf ("\\b"); - else if( !*p ) + else if( !*p ) log_printf ("\\0"); else log_printf ("\\x%02x", *p ); @@ -178,7 +178,7 @@ normalize ( gcry_sexp_t list ) if ( !list ) return NULL; p = list->d; - if ( *p == ST_STOP ) + if ( *p == ST_STOP ) { /* this is "" */ gcry_sexp_release ( list ); @@ -190,7 +190,7 @@ normalize ( gcry_sexp_t list ) gcry_sexp_release ( list ); return NULL; } - + return list; } @@ -200,13 +200,13 @@ normalize ( gcry_sexp_t list ) the buffer is transferred to the newly created object. FREEFNC should be the freefnc used to release BUFFER; there is no guarantee at which point this function is called; most likey you want to use - free() or gcry_free(). - + free() or gcry_free(). + Passing LENGTH and AUTODETECT as 0 is allowed to indicate that BUFFER points to a valid canonical encoded S-expression. A LENGTH of 0 and AUTODETECT 1 indicates that buffer points to a null-terminated string. - + This function returns 0 and and the pointer to the new object in RETSEXP or an error code in which case RETSEXP is set to NULL. */ gcry_error_t @@ -283,7 +283,7 @@ gcry_sexp_release( gcry_sexp_t sexp ) break; case ST_CLOSE: break; - case ST_DATA: + case ST_DATA: { DATALEN n; memcpy ( &n, p, sizeof n ); @@ -386,7 +386,7 @@ gcry_sexp_find_token( const gcry_sexp_t list, const char *tok, size_t toklen ) { const byte *p; DATALEN n; - + if ( !list ) return NULL; @@ -396,7 +396,7 @@ gcry_sexp_find_token( const gcry_sexp_t list, const char *tok, size_t toklen ) p = list->d; while ( *p != ST_STOP ) { - if ( *p == ST_OPEN && p[1] == ST_DATA ) + if ( *p == ST_OPEN && p[1] == ST_DATA ) { const byte *head = p; @@ -410,7 +410,7 @@ gcry_sexp_find_token( const gcry_sexp_t list, const char *tok, size_t toklen ) int level = 1; /* Look for the end of the list. */ - for ( p += n; level; p++ ) + for ( p += n; level; p++ ) { if ( *p == ST_DATA ) { @@ -418,15 +418,15 @@ gcry_sexp_find_token( const gcry_sexp_t list, const char *tok, size_t toklen ) p += sizeof n + n; p--; /* Compensate for later increment. */ } - else if ( *p == ST_OPEN ) + else if ( *p == ST_OPEN ) { level++; } - else if ( *p == ST_CLOSE ) + else if ( *p == ST_CLOSE ) { level--; } - else if ( *p == ST_STOP ) + else if ( *p == ST_STOP ) { BUG (); } @@ -505,15 +505,15 @@ get_internal_buffer (const gcry_sexp_t list, size_t *r_off) DATALEN n; int type; int level = 0; - + *r_off = 0; if (list) { p = list->d; - while ( (type=*p) != ST_STOP ) + while ( (type=*p) != ST_STOP ) { p++; - if (type == ST_DATA) + if (type == ST_DATA) { memcpy (&n, p, sizeof n); p += sizeof n + n; @@ -635,9 +635,9 @@ sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen) const byte *p; DATALEN n; int level = 0; - + *datalen = 0; - if ( !list ) + if ( !list ) return NULL; p = list->d; @@ -647,9 +647,9 @@ sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen) return NULL; /* Not a list but N > 0 requested. */ /* Skip over N elements. */ - while ( number > 0 ) + while ( number > 0 ) { - if ( *p == ST_DATA ) + if ( *p == ST_DATA ) { memcpy ( &n, ++p, sizeof n ); p += sizeof n + n; @@ -657,17 +657,17 @@ sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen) if ( !level ) number--; } - else if ( *p == ST_OPEN ) + else if ( *p == ST_OPEN ) { level++; } - else if ( *p == ST_CLOSE ) + else if ( *p == ST_CLOSE ) { level--; if ( !level ) number--; } - else if ( *p == ST_STOP ) + else if ( *p == ST_STOP ) { return NULL; } @@ -681,7 +681,7 @@ sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen) *datalen = n; return (const char*)p + sizeof n; } - + return NULL; } @@ -859,13 +859,13 @@ static gpg_err_code_t make_space ( struct make_space_ctx *c, size_t n ) { size_t used = c->pos - c->sexp->d; - + if ( used + n + sizeof(DATALEN) + 1 >= c->allocated ) { gcry_sexp_t newsexp; byte *newhead; size_t newsize; - + newsize = c->allocated + 2*(n+sizeof(DATALEN)+1); if (newsize <= c->allocated) return GPG_ERR_TOO_LARGE; @@ -914,7 +914,7 @@ unquote_string (const char *string, size_t length, unsigned char *buf) s++; n--; } break; - + case '\n': /* ignore LF[,CR] */ if (n>1 && s[1] == '\r') { @@ -946,7 +946,7 @@ unquote_string (const char *string, size_t length, unsigned char *buf) esc = 1; else *d++ = *s; - } + } return d - buf; } @@ -961,10 +961,10 @@ unquote_string (const char *string, size_t length, unsigned char *buf) * %m - MPI * %s - string (no autoswitch to secure allocation) * %d - integer stored as string (no autoswitch to secure allocation) - * %b - memory buffer; this takes _two_ arguments: an integer with the + * %b - memory buffer; this takes _two_ arguments: an integer with the * length of the buffer and a pointer to the buffer. * %S - Copy an gcry_sexp_t here. The S-expression needs to be a - * regular one, starting with a parenthesis. + * regular one, starting with a parenthesis. * (no autoswitch to secure allocation) * all other format elements are currently not defined and return an error. * this includes the "%%" sequence becauce the percent sign is not an @@ -1100,7 +1100,7 @@ vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, n -= 2; quoted_esc = 0; break; - + case 'x': if (!((n > 2) && hexdigitp (p+1) && hexdigitp (p+2))) { @@ -1149,7 +1149,7 @@ vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, never be larger. */ unsigned char *save; size_t len; - + quoted++; /* Skip leading quote. */ MAKE_SPACE (p - quoted); *c.pos++ = ST_DATA; @@ -1256,7 +1256,7 @@ vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, size_t nm = 0; ARG_NEXT (m, gcry_mpi_t); - + if (gcry_mpi_get_flag (m, GCRYMPI_FLAG_OPAQUE)) { void *mp; @@ -1336,7 +1336,7 @@ vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, ARG_NEXT (astr, const char *); alen = strlen (astr); - + MAKE_SPACE (alen); *c.pos++ = ST_DATA; STORE_LEN (c.pos, alen); @@ -1351,7 +1351,7 @@ vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, ARG_NEXT (alen, int); ARG_NEXT (astr, const char *); - + MAKE_SPACE (alen); if (alen && !gcry_is_secure (c.sexp->d) @@ -1386,7 +1386,7 @@ vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, int aint; size_t alen; char buf[20]; - + ARG_NEXT (aint, int); sprintf (buf, "%d", aint); alen = strlen (buf); @@ -1559,12 +1559,12 @@ sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, { gcry_error_t rc; va_list arg_ptr; - + va_start (arg_ptr, arg_list); rc = vsexp_sscan (retsexp, erroff, buffer, length, argflag, arg_list, arg_ptr); va_end (arg_ptr); - + return rc; } @@ -1574,18 +1574,18 @@ gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, const char *format, ...) { gcry_error_t rc; va_list arg_ptr; - + va_start (arg_ptr, format); rc = vsexp_sscan (retsexp, erroff, format, strlen(format), 1, NULL, arg_ptr); va_end (arg_ptr); - + return rc; } gcry_error_t -_gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff, +_gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff, const char *format, va_list arg_ptr) { return vsexp_sscan (retsexp, erroff, format, strlen(format), 1, @@ -1624,7 +1624,7 @@ suitable_encoding (const unsigned char *buffer, size_t length) if (!length) return 1; - + for (s=buffer; length; s++, length--) { if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0)) @@ -1676,10 +1676,10 @@ convert_to_string (const unsigned char *s, size_t len, char *dest) case '\"': *p++ = '\\'; *p++ = '\"'; break; case '\'': *p++ = '\\'; *p++ = '\''; break; case '\\': *p++ = '\\'; *p++ = '\\'; break; - default: + default: if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0))) { - sprintf (p, "\\x%02x", *s); + sprintf (p, "\\x%02x", *s); p += 4; } else @@ -1696,16 +1696,16 @@ convert_to_string (const unsigned char *s, size_t len, char *dest) { switch (*s) { - case '\b': - case '\t': - case '\v': - case '\n': - case '\f': - case '\r': + case '\b': + case '\t': + case '\v': + case '\n': + case '\f': + case '\r': case '\"': case '\'': case '\\': count += 2; break; - default: + default: if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0))) count += 4; else @@ -1744,7 +1744,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, int mode, char numbuf[20]; size_t len = 0; int i, indent = 0; - + s = list? list->d : empty; d = buffer; while ( *s != ST_STOP ) @@ -1756,18 +1756,18 @@ gcry_sexp_sprint (const gcry_sexp_t list, int mode, if ( mode != GCRYSEXP_FMT_CANON ) { if (indent) - len++; + len++; len += indent; } len++; - if ( buffer ) + if ( buffer ) { if ( len >= maxlength ) return 0; if ( mode != GCRYSEXP_FMT_CANON ) { if (indent) - *d++ = '\n'; + *d++ = '\n'; for (i=0; i < indent; i++) *d++ = ' '; } @@ -1778,7 +1778,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, int mode, case ST_CLOSE: s++; len++; - if ( buffer ) + if ( buffer ) { if ( len >= maxlength ) return 0; @@ -1841,7 +1841,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, int mode, { sprintf (numbuf, "%u:", (unsigned int)n ); len += strlen (numbuf) + n; - if ( buffer ) + if ( buffer ) { if ( len >= maxlength ) return 0; @@ -1862,10 +1862,10 @@ gcry_sexp_sprint (const gcry_sexp_t list, int mode, { if ( len >= maxlength ) return 0; - *d++ = '\n'; + *d++ = '\n'; } } - if (buffer) + if (buffer) { if ( len >= maxlength ) return 0; @@ -1885,7 +1885,7 @@ gcry_sexp_sprint (const gcry_sexp_t list, int mode, data passed from outside. errorcode and erroff may both be passed as NULL. */ size_t -gcry_sexp_canon_len (const unsigned char *buffer, size_t length, +gcry_sexp_canon_len (const unsigned char *buffer, size_t length, size_t *erroff, gcry_error_t *errcode) { const unsigned char *p; @@ -1919,7 +1919,7 @@ gcry_sexp_canon_len (const unsigned char *buffer, size_t length, *errcode = gcry_error (GPG_ERR_SEXP_STRING_TOO_LONG); return 0; } - + if (datalen) { if (*p == ':') @@ -1936,7 +1936,7 @@ gcry_sexp_canon_len (const unsigned char *buffer, size_t length, } else if (digitp(p)) datalen = datalen*10 + atoi_1(p); - else + else { *erroff = count; *errcode = gcry_error (GPG_ERR_SEXP_INV_LEN_SPEC); @@ -1972,7 +1972,7 @@ gcry_sexp_canon_len (const unsigned char *buffer, size_t length, } else if (*p == '[') { - if (disphint) + if (disphint) { *erroff = count; *errcode = gcry_error (GPG_ERR_SEXP_NESTED_DH); @@ -1982,7 +1982,7 @@ gcry_sexp_canon_len (const unsigned char *buffer, size_t length, } else if (*p == ']') { - if ( !disphint ) + if ( !disphint ) { *erroff = count; *errcode = gcry_error (GPG_ERR_SEXP_UNMATCHED_DH); @@ -1993,7 +1993,7 @@ gcry_sexp_canon_len (const unsigned char *buffer, size_t length, else if (digitp (p) ) { if (*p == '0') - { + { *erroff = count; *errcode = gcry_error (GPG_ERR_SEXP_ZERO_PREFIX); return 0; @@ -2007,7 +2007,7 @@ gcry_sexp_canon_len (const unsigned char *buffer, size_t length, return 0; } else - { + { *erroff = count; *errcode = gcry_error (GPG_ERR_SEXP_BAD_CHARACTER); return 0; diff --git a/src/stdmem.c b/src/stdmem.c index bb8adeab..c20c4b4f 100644 --- a/src/stdmem.c +++ b/src/stdmem.c @@ -25,8 +25,8 @@ * | * \ / * global.c: [MM entrance points] -----> [user callbacks] - * | | - * | | + * | | + * | | * \ / \ / * * stdmem.c: [non-secure handlers] [secure handlers] @@ -87,13 +87,13 @@ _gcry_private_enable_m_guard (void) void * _gcry_private_malloc (size_t n) { - if (!n) + if (!n) return NULL; /* Allocating 0 bytes is undefined - we better return an error to detect such coding errors. */ - if (use_m_guard) + if (use_m_guard) { char *p; - + if ( !(p = malloc (n + EXTRA_ALIGN+5)) ) return NULL; ((byte*)p)[EXTRA_ALIGN+0] = n; @@ -103,7 +103,7 @@ _gcry_private_malloc (size_t n) p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE; return p+EXTRA_ALIGN+4; } - else + else { return malloc( n ); } @@ -117,13 +117,13 @@ _gcry_private_malloc (size_t n) void * _gcry_private_malloc_secure (size_t n) { - if (!n) + if (!n) return NULL; /* Allocating 0 bytes is undefined - better return an error to detect such coding errors. */ - if (use_m_guard) + if (use_m_guard) { char *p; - + if ( !(p = _gcry_secmem_malloc (n +EXTRA_ALIGN+ 5)) ) return NULL; ((byte*)p)[EXTRA_ALIGN+0] = n; @@ -152,10 +152,10 @@ _gcry_private_realloc ( void *a, size_t n ) unsigned char *p = a; char *b; size_t len; - + if (!a) return _gcry_private_malloc(n); - + _gcry_private_check_heap(p); len = p[-4]; len |= p[-3] << 8; @@ -191,10 +191,10 @@ _gcry_private_check_heap (const void *a) { const byte *p = a; size_t len; - + if (!p) return; - + if ( !(p[-1] == MAGIC_NOR_BYTE || p[-1] == MAGIC_SEC_BYTE) ) _gcry_log_fatal ("memory at %p corrupted (underflow=%02x)\n", p, p[-1]); len = p[-4]; @@ -231,5 +231,3 @@ _gcry_private_free (void *a) else free(p); } - - diff --git a/src/versioninfo.rc.in b/src/versioninfo.rc.in index e5e87e0b..2e9402d1 100644 --- a/src/versioninfo.rc.in +++ b/src/versioninfo.rc.in @@ -1,6 +1,6 @@ /* versioninfo.rc.in - for libgcrypt * Copyright (C) 2005, 2006 g10 Code GmbH - * + * * This file is free software; as a special exception the author gives * unlimited permission to copy and/or distribute it, with or without * modifications, as long as this notice is preserved. @@ -9,7 +9,7 @@ * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + /* This file is processed by configure to create versioninfo.rc */ #line __LINE__ "versioninfo.rc.in" @@ -49,4 +49,3 @@ BEGIN END END END - diff --git a/src/visibility.c b/src/visibility.c index c4fd09da..2d203f9a 100644 --- a/src/visibility.c +++ b/src/visibility.c @@ -20,7 +20,7 @@ #include #include -#define _GCRY_INCLUDED_BY_VISIBILITY_C +#define _GCRY_INCLUDED_BY_VISIBILITY_C #include "g10lib.h" #include "cipher-proto.h" @@ -38,7 +38,7 @@ gcry_strsource (gcry_error_t err) return _gcry_strsource (err); } -gcry_err_code_t +gcry_err_code_t gcry_err_code_from_errno (int err) { return _gcry_err_code_from_errno (err); @@ -50,13 +50,13 @@ gcry_err_code_to_errno (gcry_err_code_t code) return _gcry_err_code_to_errno (code); } -gcry_error_t +gcry_error_t gcry_err_make_from_errno (gcry_err_source_t source, int err) { return _gcry_err_make_from_errno (source, err); } -gcry_err_code_t +gcry_err_code_t gcry_error_from_errno (int err) { return _gcry_error_from_errno (err); @@ -68,19 +68,19 @@ gcry_check_version (const char *req_version) return _gcry_check_version (req_version); } -gcry_error_t +gcry_error_t gcry_control (enum gcry_ctl_cmds cmd, ...) { gcry_error_t err; va_list arg_ptr; - + va_start (arg_ptr, cmd); err = _gcry_vcontrol (cmd, arg_ptr); va_end(arg_ptr); return err; } -gcry_error_t +gcry_error_t gcry_sexp_new (gcry_sexp_t *retsexp, const void *buffer, size_t length, int autodetect) @@ -88,7 +88,7 @@ gcry_sexp_new (gcry_sexp_t *retsexp, return _gcry_sexp_new (retsexp, buffer, length, autodetect); } -gcry_error_t +gcry_error_t gcry_sexp_create (gcry_sexp_t *retsexp, void *buffer, size_t length, int autodetect, void (*freefnc) (void *)) @@ -97,53 +97,53 @@ gcry_sexp_create (gcry_sexp_t *retsexp, autodetect, freefnc); } -gcry_error_t +gcry_error_t gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, const char *buffer, size_t length) { return _gcry_sexp_sscan (retsexp, erroff, buffer, length); } -gcry_error_t +gcry_error_t gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, const char *format, ...) { gcry_error_t err; va_list arg_ptr; - + va_start (arg_ptr, format); err = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr); va_end (arg_ptr); return err; } -gcry_error_t +gcry_error_t gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff, const char *format, void **arg_list) { return _gcry_sexp_build_array (retsexp, erroff, format, arg_list); } -void +void gcry_sexp_release (gcry_sexp_t sexp) { _gcry_sexp_release (sexp); } -size_t -gcry_sexp_canon_len (const unsigned char *buffer, size_t length, +size_t +gcry_sexp_canon_len (const unsigned char *buffer, size_t length, size_t *erroff, gcry_error_t *errcode) { return _gcry_sexp_canon_len (buffer, length, erroff, errcode); } -size_t +size_t gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, size_t maxlength) { return _gcry_sexp_sprint (sexp, mode, buffer, maxlength); } -void +void gcry_sexp_dump (const gcry_sexp_t a) { _gcry_sexp_dump (a); @@ -249,7 +249,7 @@ gcry_mpi_snew (unsigned int nbits) return _gcry_mpi_snew (nbits); } -void +void gcry_mpi_release (gcry_mpi_t a) { _gcry_mpi_release (a); @@ -293,7 +293,7 @@ gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v) gcry_error_t gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format, - const void *buffer, size_t buflen, + const void *buffer, size_t buflen, size_t *nscanned) { return _gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned); @@ -591,7 +591,7 @@ gcry_cipher_encrypt (gcry_cipher_hd_t h, { /* Make sure that the plaintext will never make it to OUT. */ if (out) - memset (out, 0x42, outsize); + memset (out, 0x42, outsize); return gpg_error (fips_not_operational ()); } @@ -777,7 +777,7 @@ gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags) return _gcry_md_open (h, algo, flags); } -void +void gcry_md_close (gcry_md_hd_t hd) { _gcry_md_close (hd); @@ -833,7 +833,7 @@ gcry_md_read (gcry_md_hd_t hd, int algo) return _gcry_md_read (hd, algo); } -void +void gcry_md_hash_buffer (int algo, void *digest, const void *buffer, size_t length) { @@ -1105,7 +1105,7 @@ gcry_ac_data_encrypt (gcry_ac_handle_t handle, gcry_mpi_t data_plain, gcry_ac_data_t *data_encrypted) { - return _gcry_ac_data_encrypt (handle, flags, key, + return _gcry_ac_data_encrypt (handle, flags, key, data_plain, data_encrypted); } @@ -1187,7 +1187,7 @@ gcry_ac_data_verify_scheme (gcry_ac_handle_t handle, } gcry_error_t -gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name) +gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name) { /* This function is deprecated. We implement it in terms of the suggested replacement. */ @@ -1217,7 +1217,7 @@ gcry_randomize (void *buffer, size_t length, enum gcry_random_level level) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } _gcry_randomize (buffer, length, level); } @@ -1237,7 +1237,7 @@ gcry_random_bytes (size_t nbytes, enum gcry_random_level level) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } return _gcry_random_bytes (nbytes,level); @@ -1250,7 +1250,7 @@ gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } return _gcry_random_bytes_secure (nbytes, level); @@ -1270,7 +1270,7 @@ gcry_create_nonce (void *buffer, size_t length) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } _gcry_create_nonce (buffer, length); } diff --git a/src/visibility.h b/src/visibility.h index cf5a3ff3..6a054c5c 100644 --- a/src/visibility.h +++ b/src/visibility.h @@ -52,7 +52,7 @@ #define gcry_xmalloc_secure _gcry_xmalloc_secure #define gcry_xrealloc _gcry_xrealloc #define gcry_xstrdup _gcry_xstrdup - + #define gcry_md_algo_info _gcry_md_algo_info #define gcry_md_algo_name _gcry_md_algo_name #define gcry_md_close _gcry_md_close @@ -246,7 +246,7 @@ #endif /* Prototypes of functions exported but not ready for use. */ -gcry_err_code_t gcry_md_get (gcry_md_hd_t hd, int algo, +gcry_err_code_t gcry_md_get (gcry_md_hd_t hd, int algo, unsigned char *buffer, int buflen); void gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n); gcry_error_t gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, @@ -257,7 +257,7 @@ void gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n); /* Our use of the ELF visibility feature works by passing -fvisibiliy=hidden on the command line and by explicitly marking - all exported functions as visible. + all exported functions as visible. NOTE: When adding new functions, please make sure to add them to libgcrypt.vers and libgcrypt.def as well. */ @@ -279,214 +279,214 @@ void gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n); /* First undef all redefined symbols so that we set the attribute on the correct version name. */ -#undef gcry_check_version -#undef gcry_control +#undef gcry_check_version +#undef gcry_control #undef gcry_set_allocation_handler #undef gcry_set_fatalerror_handler -#undef gcry_set_gettext_handler -#undef gcry_set_log_handler -#undef gcry_set_outofcore_handler -#undef gcry_set_progress_handler -#undef gcry_err_code_from_errno -#undef gcry_err_code_to_errno -#undef gcry_err_make_from_errno -#undef gcry_error_from_errno -#undef gcry_strerror -#undef gcry_strsource - -#undef gcry_free -#undef gcry_malloc -#undef gcry_malloc_secure -#undef gcry_calloc -#undef gcry_calloc_secure -#undef gcry_realloc -#undef gcry_strdup -#undef gcry_is_secure -#undef gcry_xcalloc -#undef gcry_xcalloc_secure -#undef gcry_xmalloc -#undef gcry_xmalloc_secure -#undef gcry_xrealloc -#undef gcry_xstrdup - -#undef gcry_md_algo_info -#undef gcry_md_algo_name -#undef gcry_md_close -#undef gcry_md_copy -#undef gcry_md_ctl -#undef gcry_md_enable -#undef gcry_md_get -#undef gcry_md_get_algo -#undef gcry_md_get_algo_dlen -#undef gcry_md_hash_buffer -#undef gcry_md_info -#undef gcry_md_is_enabled -#undef gcry_md_is_secure -#undef gcry_md_list -#undef gcry_md_map_name -#undef gcry_md_open -#undef gcry_md_read +#undef gcry_set_gettext_handler +#undef gcry_set_log_handler +#undef gcry_set_outofcore_handler +#undef gcry_set_progress_handler +#undef gcry_err_code_from_errno +#undef gcry_err_code_to_errno +#undef gcry_err_make_from_errno +#undef gcry_error_from_errno +#undef gcry_strerror +#undef gcry_strsource + +#undef gcry_free +#undef gcry_malloc +#undef gcry_malloc_secure +#undef gcry_calloc +#undef gcry_calloc_secure +#undef gcry_realloc +#undef gcry_strdup +#undef gcry_is_secure +#undef gcry_xcalloc +#undef gcry_xcalloc_secure +#undef gcry_xmalloc +#undef gcry_xmalloc_secure +#undef gcry_xrealloc +#undef gcry_xstrdup + +#undef gcry_md_algo_info +#undef gcry_md_algo_name +#undef gcry_md_close +#undef gcry_md_copy +#undef gcry_md_ctl +#undef gcry_md_enable +#undef gcry_md_get +#undef gcry_md_get_algo +#undef gcry_md_get_algo_dlen +#undef gcry_md_hash_buffer +#undef gcry_md_info +#undef gcry_md_is_enabled +#undef gcry_md_is_secure +#undef gcry_md_list +#undef gcry_md_map_name +#undef gcry_md_open +#undef gcry_md_read /* gcry_md_register is not anymore a macro. */ -#undef gcry_md_unregister -#undef gcry_md_reset -#undef gcry_md_setkey -#undef gcry_md_write -#undef gcry_md_debug - -#undef gcry_cipher_algo_info -#undef gcry_cipher_algo_name -#undef gcry_cipher_close +#undef gcry_md_unregister +#undef gcry_md_reset +#undef gcry_md_setkey +#undef gcry_md_write +#undef gcry_md_debug + +#undef gcry_cipher_algo_info +#undef gcry_cipher_algo_name +#undef gcry_cipher_close #undef gcry_cipher_setkey #undef gcry_cipher_setiv #undef gcry_cipher_setctr -#undef gcry_cipher_ctl -#undef gcry_cipher_decrypt -#undef gcry_cipher_encrypt +#undef gcry_cipher_ctl +#undef gcry_cipher_decrypt +#undef gcry_cipher_encrypt #undef gcry_cipher_get_algo_blklen #undef gcry_cipher_get_algo_keylen -#undef gcry_cipher_info -#undef gcry_cipher_list -#undef gcry_cipher_map_name -#undef gcry_cipher_mode_from_oid -#undef gcry_cipher_open +#undef gcry_cipher_info +#undef gcry_cipher_list +#undef gcry_cipher_map_name +#undef gcry_cipher_mode_from_oid +#undef gcry_cipher_open /* gcry_cipher_register is not anymore a macro. */ -#undef gcry_cipher_unregister - -#undef gcry_pk_algo_info -#undef gcry_pk_algo_name -#undef gcry_pk_ctl -#undef gcry_pk_decrypt -#undef gcry_pk_encrypt -#undef gcry_pk_genkey -#undef gcry_pk_get_keygrip +#undef gcry_cipher_unregister + +#undef gcry_pk_algo_info +#undef gcry_pk_algo_name +#undef gcry_pk_ctl +#undef gcry_pk_decrypt +#undef gcry_pk_encrypt +#undef gcry_pk_genkey +#undef gcry_pk_get_keygrip #undef gcry_pk_get_curve #undef gcry_pk_get_param -#undef gcry_pk_get_nbits -#undef gcry_pk_list -#undef gcry_pk_map_name +#undef gcry_pk_get_nbits +#undef gcry_pk_list +#undef gcry_pk_map_name /* gcry_pk_register is not anymore a macro. */ -#undef gcry_pk_unregister -#undef gcry_pk_sign -#undef gcry_pk_testkey -#undef gcry_pk_verify - -#undef gcry_ac_data_new -#undef gcry_ac_data_destroy -#undef gcry_ac_data_copy -#undef gcry_ac_data_length -#undef gcry_ac_data_clear -#undef gcry_ac_data_set -#undef gcry_ac_data_get_name -#undef gcry_ac_data_get_index -#undef gcry_ac_open -#undef gcry_ac_close -#undef gcry_ac_key_init -#undef gcry_ac_key_pair_generate -#undef gcry_ac_key_pair_extract -#undef gcry_ac_key_data_get -#undef gcry_ac_key_test -#undef gcry_ac_key_get_nbits -#undef gcry_ac_key_get_grip -#undef gcry_ac_key_destroy -#undef gcry_ac_key_pair_destroy -#undef gcry_ac_data_encrypt -#undef gcry_ac_data_decrypt -#undef gcry_ac_data_sign -#undef gcry_ac_data_verify -#undef gcry_ac_id_to_name -#undef gcry_ac_name_to_id -#undef gcry_ac_data_encode -#undef gcry_ac_data_decode -#undef gcry_ac_mpi_to_os -#undef gcry_ac_mpi_to_os_alloc -#undef gcry_ac_os_to_mpi +#undef gcry_pk_unregister +#undef gcry_pk_sign +#undef gcry_pk_testkey +#undef gcry_pk_verify + +#undef gcry_ac_data_new +#undef gcry_ac_data_destroy +#undef gcry_ac_data_copy +#undef gcry_ac_data_length +#undef gcry_ac_data_clear +#undef gcry_ac_data_set +#undef gcry_ac_data_get_name +#undef gcry_ac_data_get_index +#undef gcry_ac_open +#undef gcry_ac_close +#undef gcry_ac_key_init +#undef gcry_ac_key_pair_generate +#undef gcry_ac_key_pair_extract +#undef gcry_ac_key_data_get +#undef gcry_ac_key_test +#undef gcry_ac_key_get_nbits +#undef gcry_ac_key_get_grip +#undef gcry_ac_key_destroy +#undef gcry_ac_key_pair_destroy +#undef gcry_ac_data_encrypt +#undef gcry_ac_data_decrypt +#undef gcry_ac_data_sign +#undef gcry_ac_data_verify +#undef gcry_ac_id_to_name +#undef gcry_ac_name_to_id +#undef gcry_ac_data_encode +#undef gcry_ac_data_decode +#undef gcry_ac_mpi_to_os +#undef gcry_ac_mpi_to_os_alloc +#undef gcry_ac_os_to_mpi #undef gcry_ac_data_encrypt_scheme #undef gcry_ac_data_decrypt_scheme -#undef gcry_ac_data_sign_scheme -#undef gcry_ac_data_verify_scheme -#undef gcry_ac_data_to_sexp -#undef gcry_ac_data_from_sexp -#undef gcry_ac_io_init -#undef gcry_ac_io_init_va - -#undef gcry_prime_check -#undef gcry_prime_generate -#undef gcry_prime_group_generator -#undef gcry_prime_release_factors - -#undef gcry_random_add_bytes -#undef gcry_random_bytes -#undef gcry_random_bytes_secure -#undef gcry_randomize -#undef gcry_create_nonce - -#undef gcry_sexp_alist -#undef gcry_sexp_append -#undef gcry_sexp_build -#undef gcry_sexp_build_array -#undef gcry_sexp_cadr -#undef gcry_sexp_canon_len -#undef gcry_sexp_car -#undef gcry_sexp_cdr -#undef gcry_sexp_cons -#undef gcry_sexp_create -#undef gcry_sexp_dump -#undef gcry_sexp_find_token -#undef gcry_sexp_length -#undef gcry_sexp_new -#undef gcry_sexp_nth -#undef gcry_sexp_nth_data -#undef gcry_sexp_nth_mpi -#undef gcry_sexp_prepend -#undef gcry_sexp_release -#undef gcry_sexp_sprint -#undef gcry_sexp_sscan -#undef gcry_sexp_vlist -#undef gcry_sexp_nth_string - -#undef gcry_mpi_add -#undef gcry_mpi_add_ui -#undef gcry_mpi_addm -#undef gcry_mpi_aprint -#undef gcry_mpi_clear_bit -#undef gcry_mpi_clear_flag -#undef gcry_mpi_clear_highbit -#undef gcry_mpi_cmp -#undef gcry_mpi_cmp_ui -#undef gcry_mpi_copy -#undef gcry_mpi_div -#undef gcry_mpi_dump -#undef gcry_mpi_gcd -#undef gcry_mpi_get_flag -#undef gcry_mpi_get_nbits -#undef gcry_mpi_get_opaque -#undef gcry_mpi_invm -#undef gcry_mpi_mod -#undef gcry_mpi_mul -#undef gcry_mpi_mul_2exp -#undef gcry_mpi_mul_ui -#undef gcry_mpi_mulm -#undef gcry_mpi_new -#undef gcry_mpi_powm -#undef gcry_mpi_print -#undef gcry_mpi_randomize -#undef gcry_mpi_release -#undef gcry_mpi_rshift -#undef gcry_mpi_lshift -#undef gcry_mpi_scan -#undef gcry_mpi_set -#undef gcry_mpi_set_bit -#undef gcry_mpi_set_flag -#undef gcry_mpi_set_highbit -#undef gcry_mpi_set_opaque -#undef gcry_mpi_set_ui -#undef gcry_mpi_snew -#undef gcry_mpi_sub -#undef gcry_mpi_sub_ui -#undef gcry_mpi_subm -#undef gcry_mpi_swap -#undef gcry_mpi_test_bit +#undef gcry_ac_data_sign_scheme +#undef gcry_ac_data_verify_scheme +#undef gcry_ac_data_to_sexp +#undef gcry_ac_data_from_sexp +#undef gcry_ac_io_init +#undef gcry_ac_io_init_va + +#undef gcry_prime_check +#undef gcry_prime_generate +#undef gcry_prime_group_generator +#undef gcry_prime_release_factors + +#undef gcry_random_add_bytes +#undef gcry_random_bytes +#undef gcry_random_bytes_secure +#undef gcry_randomize +#undef gcry_create_nonce + +#undef gcry_sexp_alist +#undef gcry_sexp_append +#undef gcry_sexp_build +#undef gcry_sexp_build_array +#undef gcry_sexp_cadr +#undef gcry_sexp_canon_len +#undef gcry_sexp_car +#undef gcry_sexp_cdr +#undef gcry_sexp_cons +#undef gcry_sexp_create +#undef gcry_sexp_dump +#undef gcry_sexp_find_token +#undef gcry_sexp_length +#undef gcry_sexp_new +#undef gcry_sexp_nth +#undef gcry_sexp_nth_data +#undef gcry_sexp_nth_mpi +#undef gcry_sexp_prepend +#undef gcry_sexp_release +#undef gcry_sexp_sprint +#undef gcry_sexp_sscan +#undef gcry_sexp_vlist +#undef gcry_sexp_nth_string + +#undef gcry_mpi_add +#undef gcry_mpi_add_ui +#undef gcry_mpi_addm +#undef gcry_mpi_aprint +#undef gcry_mpi_clear_bit +#undef gcry_mpi_clear_flag +#undef gcry_mpi_clear_highbit +#undef gcry_mpi_cmp +#undef gcry_mpi_cmp_ui +#undef gcry_mpi_copy +#undef gcry_mpi_div +#undef gcry_mpi_dump +#undef gcry_mpi_gcd +#undef gcry_mpi_get_flag +#undef gcry_mpi_get_nbits +#undef gcry_mpi_get_opaque +#undef gcry_mpi_invm +#undef gcry_mpi_mod +#undef gcry_mpi_mul +#undef gcry_mpi_mul_2exp +#undef gcry_mpi_mul_ui +#undef gcry_mpi_mulm +#undef gcry_mpi_new +#undef gcry_mpi_powm +#undef gcry_mpi_print +#undef gcry_mpi_randomize +#undef gcry_mpi_release +#undef gcry_mpi_rshift +#undef gcry_mpi_lshift +#undef gcry_mpi_scan +#undef gcry_mpi_set +#undef gcry_mpi_set_bit +#undef gcry_mpi_set_flag +#undef gcry_mpi_set_highbit +#undef gcry_mpi_set_opaque +#undef gcry_mpi_set_ui +#undef gcry_mpi_snew +#undef gcry_mpi_sub +#undef gcry_mpi_sub_ui +#undef gcry_mpi_subm +#undef gcry_mpi_swap +#undef gcry_mpi_test_bit /* Now mark all symbols. */ diff --git a/tests/ChangeLog b/tests/ChangeLog index 1836d0e0..ac79a28b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -196,7 +196,7 @@ (run_rsa_gen, run_rsa_sign): New. (main): Add modes rsa-gen, rsa-sign and rsa-verify. - + 2008-09-29 Werner Koch * fipsdrv.c: Merge code from fipsrngdrv.c @@ -205,7 +205,7 @@ 2008-09-26 Werner Koch * Makefile.am: Distribute cavs_driver.pl. - * cavs_tests.sh: New. + * cavs_tests.sh: New. * fipsdrv.c: New. 2008-09-18 Werner Koch @@ -250,7 +250,7 @@ 2008-08-26 Werner Koch - * basic.c (get_keys_new): Use transient-key flag. + * basic.c (get_keys_new): Use transient-key flag. * benchmark.c (main): First check options then do the libgcrypt initialization. (rsa_bench): Use transient-key flag if not in fips mode. @@ -343,7 +343,7 @@ 2007-04-12 Marcus Brinkmann * ac-schemes.c (scheme_spec): Revert last change. - + * ac-schemes.c (scheme_spec): Remove const qualifier from member M. (es_check): Remove const qualifier from C and M2. @@ -375,7 +375,7 @@ 2007-02-23 Werner Koch - * Makefile.am (TEST): Run benchmark as last. + * Makefile.am (TEST): Run benchmark as last. * ac-data.c (check_sexp_conversion): Print label only in verbose mode. @@ -456,7 +456,7 @@ 2006-01-18 Brad Hards (wk 2006-03-07) * basic.c: Added test cases for OFB and CFB modes. Fixed some - compiler warnings for signedness. + compiler warnings for signedness. 2005-11-12 Moritz Schulte @@ -545,7 +545,7 @@ 2003-11-11 Werner Koch * tsexp.c (basic): Add pass structure and a test for the %b - format. + format. 2003-11-04 Werner Koch @@ -685,7 +685,7 @@ * basic.c, keygen.c, pubkey.c, register.c, tsexp.c: Changed to use new API. - + 2003-06-01 Moritz Schulte * tsexp.c (canon_len): Adjust for new gcry_sexp_canon_len API. @@ -754,7 +754,7 @@ 2003-01-23 Werner Koch - * keygen.c: New. + * keygen.c: New. 2003-01-20 Simon Josefsson @@ -817,7 +817,7 @@ * tsexp.c: New. - + Copyright 2001, 2002, 2003, 2008 Free Software Foundation, Inc. This file is free software; as a special exception the author gives diff --git a/tests/ac-data.c b/tests/ac-data.c index 65b66ec9..56fedbc6 100644 --- a/tests/ac-data.c +++ b/tests/ac-data.c @@ -177,9 +177,9 @@ check_run (void) if (verbose) printf ("data-set-test-2 succeeded\n"); - + gcry_ac_data_destroy (data); - + } @@ -203,6 +203,6 @@ main (int argc, char **argv) for (; i > 0; i--) check_run (); - + return 0; } diff --git a/tests/ac-schemes.c b/tests/ac-schemes.c index dcef0bf7..58180c07 100644 --- a/tests/ac-schemes.c +++ b/tests/ac-schemes.c @@ -81,7 +81,7 @@ scheme_get_opts (scheme_spec_t specs, void **opts) case GCRY_AC_SSA_PKCS_V1_5: { gcry_ac_ssa_pkcs_v1_5_t *opts_pkcs_v1_5 = NULL; - + opts_new = gcry_malloc (sizeof (gcry_ac_ssa_pkcs_v1_5_t)); if (! opts_new) err = gpg_err_code_from_errno (ENOMEM); @@ -123,7 +123,7 @@ es_check (gcry_ac_handle_t handle, scheme_spec_t spec, gcry_ac_io_t io_m; gcry_ac_io_t io_c; gcry_ac_io_t io_m2; - + if (spec.flags & SCHEME_SPEC_FLAG_GET_OPTS) err = scheme_get_opts (spec, &opts); if (! err) @@ -173,7 +173,7 @@ ssa_check (gcry_ac_handle_t handle, scheme_spec_t spec, void *opts = NULL; gcry_ac_io_t io_m; gcry_ac_io_t io_s; - + if (spec.flags & SCHEME_SPEC_FLAG_GET_OPTS) err = scheme_get_opts (spec, &opts); if (! err) @@ -295,7 +295,7 @@ key_init (gcry_ac_key_type_t type, gcry_ac_key_t *key) if (key_data) gcry_ac_data_destroy (key_data); - + if (! err) *key = key_new; @@ -312,7 +312,7 @@ check_run (void) err = key_init (GCRY_AC_KEY_PUBLIC, &key_public); if (! err) err = key_init (GCRY_AC_KEY_SECRET, &key_secret); - + if (! err) err = gcry_ac_open (&handle, GCRY_AC_RSA, 0); if (! err) @@ -320,7 +320,7 @@ check_run (void) es_checks (handle, key_public, key_secret); ssa_checks (handle, key_public, key_secret); } - + assert (! err); } @@ -342,6 +342,6 @@ main (int argc, char **argv) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); check_run (); - + return 0; } diff --git a/tests/ac.c b/tests/ac.c index d734360a..8b2d252e 100644 --- a/tests/ac.c +++ b/tests/ac.c @@ -114,7 +114,7 @@ check_one (gcry_mpi_t x) err = gcry_ac_data_get_index (data, 0, 0, &label, &y); assert (! err); gcry_mpi_add_ui (y, y, 1); - + err = gcry_ac_data_verify (handle, key_pub, x, data); assert (gcry_err_code (err) == GPG_ERR_BAD_SIGNATURE); } @@ -157,6 +157,6 @@ main (int argc, char **argv) for (; i > 0; i--) check_run (); - + return 0; } diff --git a/tests/aeswrap.c b/tests/aeswrap.c index 39ef1e72..bb52fc90 100644 --- a/tests/aeswrap.c +++ b/tests/aeswrap.c @@ -174,7 +174,7 @@ check_all (void) { if (verbose) fprintf (stderr, "4.1 Wrap 128 bits of Key Data with a 128-bit KEK\n"); - check + check (GCRY_CIPHER_AES128, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F", 16, "\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF", 16, @@ -183,7 +183,7 @@ check_all (void) if (verbose) fprintf (stderr, "4.2 Wrap 128 bits of Key Data with a 192-bit KEK\n"); - check + check (GCRY_CIPHER_AES192, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" "\x10\x11\x12\x13\x14\x15\x16\x17", 24, @@ -193,7 +193,7 @@ check_all (void) if (verbose) fprintf (stderr, "4.3 Wrap 128 bits of Key Data with a 256-bit KEK\n"); - check + check (GCRY_CIPHER_AES256, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", 32, @@ -203,7 +203,7 @@ check_all (void) if (verbose) fprintf (stderr, "4.4 Wrap 192 bits of Key Data with a 192-bit KEK\n"); - check + check (GCRY_CIPHER_AES192, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" "\x10\x11\x12\x13\x14\x15\x16\x17", 24, @@ -211,10 +211,10 @@ check_all (void) "\x00\x01\x02\x03\x04\x05\x06\x07", 24, "\x03\x1D\x33\x26\x4E\x15\xD3\x32\x68\xF2\x4E\xC2\x60\x74\x3E\xDC" "\xE1\xC6\xC7\xDD\xEE\x72\x5A\x93\x6B\xA8\x14\x91\x5C\x67\x62\xD2", 32); - + if (verbose) fprintf (stderr, "4.5 Wrap 192 bits of Key Data with a 256-bit KEK\n"); - check + check (GCRY_CIPHER_AES256, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", 32, @@ -225,7 +225,7 @@ check_all (void) if (verbose) fprintf (stderr, "4.6 Wrap 256 bits of Key Data with a 256-bit KEK\n"); - check + check (GCRY_CIPHER_AES, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", 32, diff --git a/tests/basic.c b/tests/basic.c index a6186540..066ae41c 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -84,7 +84,7 @@ progress_handler (void *cb_data, const char *what, int printchar, (void)what; (void)current; (void)total; - + if (printchar == '\n') fputs ( "", stdout); else @@ -182,7 +182,7 @@ check_cbc_mac_cipher (void) } if (verbose) - fprintf (stderr, " checking CBC MAC for %s [%i]\n", + fprintf (stderr, " checking CBC MAC for %s [%i]\n", gcry_cipher_algo_name (tv[i].algo), tv[i].algo); err = gcry_cipher_encrypt (hd, @@ -460,7 +460,7 @@ check_ctr_cipher (void) } if (verbose) - fprintf (stderr, " checking CTR mode for %s [%i]\n", + fprintf (stderr, " checking CTR mode for %s [%i]\n", gcry_cipher_algo_name (tv[i].algo), tv[i].algo); for (j = 0; tv[i].data[j].inlen; j++) @@ -496,38 +496,38 @@ check_ctr_cipher (void) fail ("aes-ctr, decrypt mismatch entry %d:%d\n", i, j); } - + /* Now check that we get valid return codes back for good and bad inputs. */ err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, "1234567890123456", 16); if (err) fail ("aes-ctr, encryption failed for valid input"); - + err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, "1234567890123456", 15); if (gpg_err_code (err) != GPG_ERR_INV_LENGTH) fail ("aes-ctr, too short input returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, "12345678901234567", 17); if (gpg_err_code (err) != GPG_ERR_INV_LENGTH) fail ("aes-ctr, too long input returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_encrypt (hde, out, 15, "1234567890123456", 16); if (gpg_err_code (err) != GPG_ERR_BUFFER_TOO_SHORT) fail ("aes-ctr, too short output buffer returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_encrypt (hde, out, 0, "1234567890123456", 16); if (gpg_err_code (err) != GPG_ERR_BUFFER_TOO_SHORT) fail ("aes-ctr, 0 length output buffer returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_encrypt (hde, out, 16, "1234567890123456", 16); if (err) @@ -539,37 +539,37 @@ check_ctr_cipher (void) "1234567890123456", 16); if (err) fail ("aes-ctr, decryption failed for valid input"); - + err = gcry_cipher_decrypt (hde, out, MAX_DATA_LEN, "1234567890123456", 15); if (gpg_err_code (err) != GPG_ERR_INV_LENGTH) fail ("aes-ctr, too short input returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_decrypt (hde, out, MAX_DATA_LEN, "12345678901234567", 17); if (gpg_err_code (err) != GPG_ERR_INV_LENGTH) fail ("aes-ctr, too long input returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_decrypt (hde, out, 15, "1234567890123456", 16); if (gpg_err_code (err) != GPG_ERR_BUFFER_TOO_SHORT) fail ("aes-ctr, too short output buffer returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_decrypt (hde, out, 0, "1234567890123456", 16); if (gpg_err_code (err) != GPG_ERR_BUFFER_TOO_SHORT) fail ("aes-ctr, 0 length output buffer returned wrong error: %s\n", gpg_strerror (err)); - + err = gcry_cipher_decrypt (hde, out, 16, "1234567890123456", 16); if (err) fail ("aes-ctr, correct length output buffer returned error: %s\n", gpg_strerror (err)); - + gcry_cipher_close (hde); gcry_cipher_close (hdd); } @@ -656,11 +656,11 @@ check_cfb_cipher (void) if (verbose) fprintf (stderr, " Starting CFB checks.\n"); - + for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) { if (verbose) - fprintf (stderr, " checking CFB mode for %s [%i]\n", + fprintf (stderr, " checking CFB mode for %s [%i]\n", gcry_cipher_algo_name (tv[i].algo), tv[i].algo); err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_CFB, 0); @@ -827,11 +827,11 @@ check_ofb_cipher (void) if (verbose) fprintf (stderr, " Starting OFB checks.\n"); - + for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) { if (verbose) - fprintf (stderr, " checking OFB mode for %s [%i]\n", + fprintf (stderr, " checking OFB mode for %s [%i]\n", gcry_cipher_algo_name (tv[i].algo), tv[i].algo); err = gcry_cipher_open (&hde, tv[i].algo, GCRY_CIPHER_MODE_OFB, 0); @@ -941,7 +941,7 @@ check_ofb_cipher (void) for (j = 0; tv[i].data[j].inlen; j++) { int byteNum; - for (byteNum = 0; byteNum < tv[i].data[j].inlen; ++byteNum) + for (byteNum = 0; byteNum < tv[i].data[j].inlen; ++byteNum) { err = gcry_cipher_encrypt (hde, out+byteNum, 1, (tv[i].data[j].plaintext) + byteNum, @@ -959,7 +959,7 @@ check_ofb_cipher (void) if (memcmp (tv[i].data[j].out, out, tv[i].data[j].inlen)) fail ("aes-ofb, encrypt mismatch entry %d:%d\n", i, j); - for (byteNum = 0; byteNum < tv[i].data[j].inlen; ++byteNum) + for (byteNum = 0; byteNum < tv[i].data[j].inlen; ++byteNum) { err = gcry_cipher_decrypt (hdd, out+byteNum, 1, NULL, 0); if (err) @@ -1181,16 +1181,16 @@ check_ciphers (void) static void check_cipher_modes(void) -{ +{ if (verbose) fprintf (stderr, "Starting Cipher Mode checks.\n"); - + check_aes128_cbc_cts_cipher (); check_cbc_mac_cipher (); check_ctr_cipher (); check_cfb_cipher (); check_ofb_cipher (); - + if (verbose) fprintf (stderr, "Completed Cipher Mode checks.\n"); } @@ -1405,16 +1405,16 @@ check_digests (void) { GCRY_MD_TIGER1, "abcdefghijklmnopqrstuvwxyz", "\x17\x14\xA4\x72\xEE\xE5\x7D\x30\x04\x04\x12\xBF" "\xCC\x55\x03\x2A\x0B\x11\x60\x2F\xF3\x7B\xEE\xE9" }, - { GCRY_MD_TIGER1, + { GCRY_MD_TIGER1, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\x0F\x7B\xF9\xA1\x9B\x9C\x58\xF2\xB7\x61\x0D\xF7" "\xE8\x4F\x0A\xC3\xA7\x1C\x63\x1E\x7B\x53\xF7\x8E" }, - { GCRY_MD_TIGER1, + { GCRY_MD_TIGER1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789", "\x8D\xCE\xA6\x80\xA1\x75\x83\xEE\x50\x2B\xA3\x8A" "\x3C\x36\x86\x51\x89\x0F\xFB\xCC\xDC\x49\xA8\xCC" }, - { GCRY_MD_TIGER1, + { GCRY_MD_TIGER1, "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890", "\x1C\x14\x79\x55\x29\xFD\x9F\x20\x7A\x95\x8F\x84" @@ -1438,16 +1438,16 @@ check_digests (void) { GCRY_MD_TIGER2, "abcdefghijklmnopqrstuvwxyz", "\xF5\xB6\xB6\xA7\x8C\x40\x5C\x85\x47\xE9\x1C\xD8" "\x62\x4C\xB8\xBE\x83\xFC\x80\x4A\x47\x44\x88\xFD" }, - { GCRY_MD_TIGER2, + { GCRY_MD_TIGER2, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\xA6\x73\x7F\x39\x97\xE8\xFB\xB6\x3D\x20\xD2\xDF" "\x88\xF8\x63\x76\xB5\xFE\x2D\x5C\xE3\x66\x46\xA9" }, - { GCRY_MD_TIGER2, + { GCRY_MD_TIGER2, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789", "\xEA\x9A\xB6\x22\x8C\xEE\x7B\x51\xB7\x75\x44\xFC" "\xA6\x06\x6C\x8C\xBB\x5B\xBA\xE6\x31\x95\x05\xCD" }, - { GCRY_MD_TIGER2, + { GCRY_MD_TIGER2, "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890", "\xD8\x52\x78\x11\x53\x29\xEB\xAA\x0E\xEC\x85\xEC" @@ -1501,10 +1501,10 @@ check_digests (void) continue; } if (verbose) - fprintf (stderr, " checking %s [%i] for length %zi\n", + fprintf (stderr, " checking %s [%i] for length %zi\n", gcry_md_algo_name (algos[i].md), algos[i].md, - !strcmp (algos[i].data, "!")? + !strcmp (algos[i].data, "!")? 1000000 : strlen(algos[i].data)); check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data), @@ -1516,7 +1516,7 @@ check_digests (void) } static void -check_one_hmac (int algo, const char *data, int datalen, +check_one_hmac (int algo, const char *data, int datalen, const char *key, int keylen, const char *expect) { gcry_md_hd_t hd, hd2; @@ -1650,7 +1650,7 @@ check_hmac (void) "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "\x82\x55\x8a\x38\x9a\x44\x3c\x0e\xa4\xcc\x81\x98\x99\xf2\x08" "\x3a\x85\xf0\xfa\xa3\xe5\x78\xf8\x07\x7a\x2e\x3f\xf4\x67\x29\x66\x5b" }, - { GCRY_MD_SHA256, + { GCRY_MD_SHA256, "Test Using Larger Than Block-Size Key - Hash Key First", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1663,7 +1663,7 @@ check_hmac (void) "\xaa\xaa\xaa", "\x60\xe4\x31\x59\x1e\xe0\xb6\x7f\x0d\x8a\x26\xaa\xcb\xf5\xb7\x7f" "\x8e\x0b\xc6\x21\x37\x28\xc5\x14\x05\x46\x04\x0f\x0e\xe3\x7f\x54" }, - { GCRY_MD_SHA256, + { GCRY_MD_SHA256, "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1703,7 +1703,7 @@ check_hmac (void) "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "\x6c\x11\x50\x68\x74\x01\x3c\xac\x6a\x2a\xbc\x1b\xb3\x82\x62" "\x7c\xec\x6a\x90\xd8\x6e\xfc\x01\x2d\xe7\xaf\xec\x5a" }, - { GCRY_MD_SHA224, + { GCRY_MD_SHA224, "Test Using Larger Than Block-Size Key - Hash Key First", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1716,7 +1716,7 @@ check_hmac (void) "\xaa\xaa\xaa", "\x95\xe9\xa0\xdb\x96\x20\x95\xad\xae\xbe\x9b\x2d\x6f\x0d\xbc\xe2" "\xd4\x99\xf1\x12\xf2\xd2\xb7\x27\x3f\xa6\x87\x0e" }, - { GCRY_MD_SHA224, + { GCRY_MD_SHA224, "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1760,7 +1760,7 @@ check_hmac (void) "\x3e\x8a\x69\xb7\x78\x3c\x25\x85\x19\x33\xab\x62\x90\xaf\x6c\xa7" "\x7a\x99\x81\x48\x08\x50\x00\x9c\xc5\x57\x7c\x6e\x1f\x57\x3b\x4e" "\x68\x01\xdd\x23\xc4\xa7\xd6\x79\xcc\xf8\xa3\x86\xc6\x74\xcf\xfb" }, - { GCRY_MD_SHA384, + { GCRY_MD_SHA384, "Test Using Larger Than Block-Size Key - Hash Key First", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1774,7 +1774,7 @@ check_hmac (void) "\x4e\xce\x08\x44\x85\x81\x3e\x90\x88\xd2\xc6\x3a\x04\x1b\xc5\xb4" "\x4f\x9e\xf1\x01\x2a\x2b\x58\x8f\x3c\xd1\x1f\x05\x03\x3a\xc4\xc6" "\x0c\x2e\xf6\xab\x40\x30\xfe\x82\x96\x24\x8d\xf1\x63\xf4\x49\x52" }, - { GCRY_MD_SHA384, + { GCRY_MD_SHA384, "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1823,7 +1823,7 @@ check_hmac (void) "\xe5\x76\xd9\x7f\xf9\x4b\x87\x2d\xe7\x6f\x80\x50\x36\x1e\xe3\xdb" "\xa9\x1c\xa5\xc1\x1a\xa2\x5e\xb4\xd6\x79\x27\x5c\xc5\x78\x80\x63" "\xa5\xf1\x97\x41\x12\x0c\x4f\x2d\xe2\xad\xeb\xeb\x10\xa2\x98\xdd" }, - { GCRY_MD_SHA512, + { GCRY_MD_SHA512, "Test Using Larger Than Block-Size Key - Hash Key First", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1838,7 +1838,7 @@ check_hmac (void) "\x9b\x46\xd1\xf4\x1b\x4a\xee\xc1\x12\x1b\x01\x37\x83\xf8\xf3\x52" "\x6b\x56\xd0\x37\xe0\x5f\x25\x98\xbd\x0f\xd2\x21\x5d\x6a\x1e\x52" "\x95\xe6\x4f\x73\xf6\x3f\x0a\xec\x8b\x91\x5a\x98\x5d\x78\x65\x98" }, - { GCRY_MD_SHA512, + { GCRY_MD_SHA512, "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -1871,8 +1871,8 @@ check_hmac (void) continue; } if (verbose) - fprintf (stderr, - " checking %s [%i] for %zi byte key and %zi byte data\n", + fprintf (stderr, + " checking %s [%i] for %zi byte key and %zi byte data\n", gcry_md_algo_name (algos[i].md), algos[i].md, strlen(algos[i].key), strlen(algos[i].data)); @@ -2026,7 +2026,7 @@ check_one_pubkey (int n, test_spec_pubkey_t spec) do_check_one_pubkey (n, skey, pkey, (const unsigned char*)spec.key.grip, spec.flags); - + gcry_sexp_release (skey); gcry_sexp_release (pkey); } @@ -2037,10 +2037,10 @@ get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; if (verbose) - fprintf (stderr, " generating RSA key:"); + fprintf (stderr, " generating RSA key:"); rc = gcry_sexp_new (&key_spec, in_fips_mode ? "(genkey (rsa (nbits 4:1024)))" - : "(genkey (rsa (nbits 4:1024)(transient-key)))", + : "(genkey (rsa (nbits 4:1024)(transient-key)))", 0, 1); if (rc) die ("error creating S-expression: %s\n", gpg_strerror (rc)); @@ -2048,7 +2048,7 @@ get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating RSA key: %s\n", gpg_strerror (rc)); - + pub_key = gcry_sexp_find_token (key, "public-key", 0); if (! pub_key) die ("public part missing in key\n"); @@ -2219,7 +2219,7 @@ check_pubkey (void) int main (int argc, char **argv) -{ +{ gpg_error_t err; int last_argc = -1; int debug = 0; @@ -2258,7 +2258,7 @@ main (int argc, char **argv) verbose += 2; argc--; argv++; } - } + } gcry_control (GCRYCTL_SET_VERBOSITY, (int)verbose); @@ -2302,7 +2302,7 @@ main (int argc, char **argv) gcry_control (GCRYCTL_FORCE_FIPS_MODE, 0); if (!gcry_control (GCRYCTL_OPERATIONAL_P, 0)) fail ("not in operational state after self-test\n"); - + /* Get us into the error state. */ err = gcry_md_open (&md, GCRY_MD_SHA1, 0); if (err) @@ -2335,7 +2335,7 @@ main (int argc, char **argv) } } } - + } else { diff --git a/tests/benchmark.c b/tests/benchmark.c index ab2aeb29..76dcd485 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -360,7 +360,7 @@ progress_cb (void *cb_data, const char *what, int printchar, int current, int total) { (void)cb_data; - + fprintf (stderr, PGM ": progress (%s %c %d %d)\n", what, printchar, current, total); fflush (stderr); @@ -606,10 +606,10 @@ cipher_bench ( const char *algoname ) fprintf (stderr, PGM ": error opening cipher `%s'\n", algoname); exit (1); } - + err = gcry_cipher_setkey (hd, key, keylen); if (err) - { + { fprintf (stderr, "gcry_cipher_setkey failed: %s\n", gpg_strerror (err)); gcry_cipher_close (hd); @@ -619,7 +619,7 @@ cipher_bench ( const char *algoname ) buflen = allocated_buflen; if (modes[modeidx].blocked) buflen = (buflen / blklen) * blklen; - + start_timer (); for (i=err=0; !err && i < repetitions; i++) err = gcry_cipher_encrypt ( hd, outbuf, buflen, buf, buflen); @@ -629,7 +629,7 @@ cipher_bench ( const char *algoname ) fflush (stdout); gcry_cipher_close (hd); if (err) - { + { fprintf (stderr, "gcry_cipher_encrypt failed: %s\n", gpg_strerror (err) ); exit (1); @@ -641,10 +641,10 @@ cipher_bench ( const char *algoname ) fprintf (stderr, PGM ": error opening cipher `%s'/n", algoname); exit (1); } - + err = gcry_cipher_setkey (hd, key, keylen); if (err) - { + { fprintf (stderr, "gcry_cipher_setkey failed: %s\n", gpg_strerror (err)); gcry_cipher_close (hd); @@ -659,7 +659,7 @@ cipher_bench ( const char *algoname ) fflush (stdout); gcry_cipher_close (hd); if (err) - { + { fprintf (stderr, "gcry_cipher_decrypt failed: %s\n", gpg_strerror (err) ); exit (1); @@ -1032,17 +1032,17 @@ mpi_bench (void) do_powm ( "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E4", - "29", + "29", "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8" ); do_powm ( "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA40716", - "29", + "29", "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847" ); do_powm ( "20A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA4071620A94417D4D5EF2B2DA99165C7DC87DADB3979B72961AF90D09D59BA24CB9A10166FDCCC9C659F2B9626EC23F3FA425F564A072BA941B03FA81767CC289E41071F0246879A442658FBD18C1771571E7073EEEB2160BA0CBFB3404D627069A6CFBD53867AD2D9D40231648000787B5C84176B4336144644AE71A403CA40716", - "29", + "29", "B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847B870187A323F1ECD5B8A0B4249507335A1C4CE8394F38FD76B08C78A42C58F6EA136ACF90DFE8603697B1694A3D81114D6117AC1811979C51C4DD013D52F8FC4EE4BB446B83E48ABED7DB81CBF5E81DE4759E8D68AC985846D999F96B0D8A80E5C69D272C766AB8A23B40D50A4FA889FBC2BD2624222D8EB297F4BAEF8593847" ); @@ -1127,7 +1127,7 @@ main( int argc, char **argv ) argc--; argv++; with_progress = 1; } - } + } gcry_control (GCRYCTL_SET_VERBOSITY, (int)verbose); @@ -1154,7 +1154,7 @@ main( int argc, char **argv ) cipher_repetitions = 1; if (hash_repetitions < 1) hash_repetitions = 1; - + if ( !argc ) { gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); @@ -1227,7 +1227,6 @@ main( int argc, char **argv ) if (in_fips_mode && !gcry_fips_mode_active ()) fprintf (stderr, PGM ": FIPS mode is not anymore active\n"); - + return 0; } - diff --git a/tests/cavs_driver.pl b/tests/cavs_driver.pl index 7111f0f4..b95e9b14 100755 --- a/tests/cavs_driver.pl +++ b/tests/cavs_driver.pl @@ -11,7 +11,7 @@ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: +# furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. @@ -255,7 +255,7 @@ my $dsa_verify; # generate a new DSA key with the following properties: # PEM format -# $1 keyfile name +# $1 keyfile name # return: file created, hash with keys of P, Q, G in hex format my $gen_dsakey; @@ -497,7 +497,7 @@ sub libgcrypt_hmac($$$$) { my $hashtype = shift; my $program = "fipsdrv --key $key --algo $hashtype hmac-sha"; - return pipe_through_program($msg, $program); + return pipe_through_program($msg, $program); } sub libgcrypt_dsa_pqggen($) { @@ -623,7 +623,7 @@ sub pipe_through_program($@) { my ($CO, $CI); my $pid = open2($CO, $CI, @args); - + my $out = ""; my $len = length($in); my $first = 1; @@ -659,7 +659,7 @@ sub pipe_through_program($@) { } close $CO or die "broken pipe: $!"; waitpid $pid, 0; - + return $out; } @@ -881,7 +881,7 @@ sub der_pos_bigint($) { # returns number as signed DER integer encoding sub der_int($) { my $n = shift; - + return der_bigint(int_base256_signed($n)); } @@ -958,11 +958,11 @@ sub der_unit_test { # OpenSSL missing functionality workarounds ## Format of an RSA public key: -# 0:d=0 hl=3 l= 159 cons: SEQUENCE -# 3:d=1 hl=2 l= 13 cons: SEQUENCE +# 0:d=0 hl=3 l= 159 cons: SEQUENCE +# 3:d=1 hl=2 l= 13 cons: SEQUENCE # 5:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption -# 16:d=2 hl=2 l= 0 prim: NULL -# 18:d=1 hl=3 l= 141 prim: BIT STRING +# 16:d=2 hl=2 l= 0 prim: NULL +# 18:d=1 hl=3 l= 141 prim: BIT STRING # [ sequence: INTEGER (n), INTEGER (e) ] # generate RSA pub key in PEM format @@ -1073,7 +1073,7 @@ sub kat($$$$$$$$) { $out .= "KEY3 = $key3\n"; $key1= $key1 . $key3; } - + $out .= "IV = $iv\n" if (defined($iv) && $iv ne ""); if ($enc) { $out .= "PLAINTEXT = $pt\n"; @@ -1250,7 +1250,7 @@ sub crypto_mct($$$$$$$$) { #print STDERR "calc_data=", bin2hex($calc_data), "\n"; if ( (!$enc && $ciph =~ /des/) || - $ciph =~ /rc4/ || + $ciph =~ /rc4/ || $cipher =~ /ecb/ ) { #TDES in decryption mode, RC4 and ECB mode #have a special rule @@ -1269,7 +1269,7 @@ sub crypto_mct($$$$$$$$) { } else { $out .= "PLAINTEXT = ". bin2hex($calc_data). "\n\n"; } - + if ( $ciph =~ /aes/ ) { $key1 ^= substr($old_calc_data . $calc_data, -$keylen); #print STDERR bin2hex($key1)."\n"; @@ -1445,20 +1445,20 @@ sub rsa_keygen($$$$$$$$) { my ($P, $Q, $N, $D) = split(/\n/, $ret); - $out .= "e = $e\n"; - $out .= "xp1 = $xp1\n"; - $out .= "xp2 = $xp2\n"; - $out .= "Xp = $Xp\n"; + $out .= "e = $e\n"; + $out .= "xp1 = $xp1\n"; + $out .= "xp2 = $xp2\n"; + $out .= "Xp = $Xp\n"; $out .= "p = $P\n"; - $out .= "xq1 = $xq1\n"; - $out .= "xq2 = $xq2\n"; - $out .= "Xq = $Xq\n"; + $out .= "xq1 = $xq1\n"; + $out .= "xq2 = $xq2\n"; + $out .= "Xq = $Xq\n"; $out .= "q = $Q\n"; $out .= "n = $N\n"; $out .= "d = $D\n\n"; return $out; - + } # X9.31 RNG test @@ -1693,7 +1693,7 @@ sub parse($$) { # '# "SigVer PKCS#1 Ver 1.5" information for "IBMRHEL5"' # '# "SigGen PKCS#1 Ver 1.5" information for "IBMRHEL5"' # '#RC4VS MCT test data' - + # avoid false positives from user specified 'for "PRODUCT"' strings my $tmpline = $line; $tmpline =~ s/ for ".*"//; diff --git a/tests/cavs_tests.sh b/tests/cavs_tests.sh index b9aa6216..7d8499bd 100755 --- a/tests/cavs_tests.sh +++ b/tests/cavs_tests.sh @@ -14,7 +14,7 @@ # # 1. Cd to the libgcrypt/tests directory # -# 2. Unpack the test vector tarball into subdirectory named "cavs". +# 2. Unpack the test vector tarball into subdirectory named "cavs". # An example directory layout after unpacking might be: # libgcrypt/tests/cavs/AES/req/CBCGFSbox128.req # libgcrypt/tests/cavs/AES/req/CFB128MCT128.req @@ -39,7 +39,7 @@ continue_mode=no [ "$1" = "--continue" ] && continue_mode=yes -# Function to run one test. +# Function to run one test. # The argument is the request file name. function run_one_test () { local reqfile="$1" @@ -57,12 +57,12 @@ function run_one_test () { if echo "$reqfile" | grep '/DSA/req/' >/dev/null 2>/dev/null; then dflag="-D" - fi - + fi + if ./cavs_driver.pl -I libgcrypt $dflag "$reqfile"; then if [ -f "$tmprspfile" ]; then mv "$tmprspfile" "$rspfile" - else + else echo "failed test: $reqfile" >&2 : >"$errors_seen_file" fi diff --git a/tests/fips186-dsa.c b/tests/fips186-dsa.c index cdb507b6..401acff0 100644 --- a/tests/fips186-dsa.c +++ b/tests/fips186-dsa.c @@ -140,7 +140,7 @@ extract_cmp_mpi (gcry_sexp_t sexp, const char *name, const char *expected) l1 = gcry_sexp_find_token (sexp, name, 0); a = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG); b = mpi_from_string (expected); - if (!a) + if (!a) fail ("parameter \"%s\" missing in key\n", name); else if ( gcry_mpi_cmp (a, b) ) fail ("parameter \"%s\" does not match expected value\n", name); @@ -162,7 +162,7 @@ extract_cmp_data (gcry_sexp_t sexp, const char *name, const char *expected) l1 = gcry_sexp_find_token (sexp, name, 0); a = gcry_sexp_nth_data (l1, 1, &alen); b = data_from_hex (expected, &blen); - if (!a) + if (!a) fail ("parameter \"%s\" missing in key\n", name); else if ( alen != blen || memcmp (a, b, alen) ) fail ("parameter \"%s\" does not match expected value\n", name); @@ -178,7 +178,7 @@ extract_cmp_int (gcry_sexp_t sexp, const char *name, int expected) l1 = gcry_sexp_find_token (sexp, name, 0); a = gcry_sexp_nth_string (l1, 1); - if (!a) + if (!a) fail ("parameter \"%s\" missing in key\n", name); else if ( strtoul (a, NULL, 10) != expected ) fail ("parameter \"%s\" does not match expected value\n", name); @@ -290,7 +290,7 @@ check_dsa_gen_186_2 (void) }, /* These tests are generated by the OpenSSL FIPS version. */ - { + { 1024, "A404363903FDCE86839BCFD953AAD2DA2B0E70CAED3B5FF5D68F15A1C4BB0A793C" "A9D58FC956804C5901DE0AF99F345ED1A8617C687864BAC044B7C3C3E732A2B255" @@ -351,7 +351,7 @@ check_dsa_gen_186_2 (void) 397, "02" }, - { + { 1024, "D40E4F6461E145859CCF60FD57962840BD75FFF12C22F76626F566842252AD068" "29745F0147056354F6C016CF12762B0E331787925B8128CF5AF81F9B176A51934" @@ -398,7 +398,7 @@ check_dsa_gen_186_2 (void) fail ("error generating key %d: %s\n", tno, gpg_strerror (err)); continue; } - + if (verbose > 1) show_sexp ("generated key:\n", key); @@ -444,7 +444,7 @@ main (int argc, char **argv) verbose = 1; else if (argc > 1 && !strcmp (argv[1], "--debug")) { - verbose = 2; + verbose = 2; debug = 1; } diff --git a/tests/fipsdrv.c b/tests/fipsdrv.c index 29ceedde..2d4c3624 100644 --- a/tests/fipsdrv.c +++ b/tests/fipsdrv.c @@ -2,17 +2,17 @@ Copyright (C) 2008 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, see . */ @@ -129,14 +129,14 @@ enum }; /* ASN.1 Parser object. */ -struct tag_info +struct tag_info { int class; /* Object class. */ unsigned long tag; /* The tag of the object. */ unsigned long length; /* Length of the values. */ int nhdr; /* Length of the header (TL). */ unsigned int ndef:1; /* The object has an indefinite length. */ - unsigned int cons:1; /* This is a constructed object. */ + unsigned int cons:1; /* This is a constructed object. */ }; @@ -249,7 +249,7 @@ read_textline (FILE *fp) /* Read line but skip over initial empty lines. */ do { - do + do { if (!fgets (line, sizeof line, fp)) { @@ -330,14 +330,14 @@ read_file (FILE *fp, int decode, size_t *r_length) #endif buffer = NULL; buflen = 0; - do + do { bufsize += NCHUNK; if (!buffer) buffer = gcry_xmalloc (bufsize); else buffer = gcry_xrealloc (buffer, bufsize); - + nread = fread (buffer + buflen, 1, NCHUNK, fp); if (nread < NCHUNK && ferror (fp)) { @@ -379,7 +379,7 @@ read_file (FILE *fp, int decode, size_t *r_length) static size_t base64_decode (char *buffer, size_t length) { - static unsigned char const asctobin[128] = + static unsigned char const asctobin[128] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -391,7 +391,7 @@ base64_decode (char *buffer, size_t length) 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff + 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff }; int idx = 0; @@ -408,7 +408,7 @@ base64_decode (char *buffer, size_t length) for (; length && *s != '\n'; length--, s++) ; break; - } + } lfseen = (*s == '\n'); } @@ -463,7 +463,7 @@ base64_decode (char *buffer, size_t length) from the TLV triplet. Update BUFFER and BUFLEN on success. Checks that the encoded length does not exhaust the length of the provided buffer. */ -static int +static int parse_tag (unsigned char const **buffer, size_t *buflen, struct tag_info *ti) { int c; @@ -529,13 +529,13 @@ parse_tag (unsigned char const **buffer, size_t *buflen, struct tag_info *ti) } ti->length = len; } - + if (ti->class == UNIVERSAL && !ti->tag) ti->length = 0; if (ti->length > length) return -1; /* Data larger than buffer. */ - + *buffer = buf; *buflen = length; return 0; @@ -569,7 +569,7 @@ read_private_key_file (const char *fname, int show) fclose (fp); buflen = base64_decode (buffer, buflen); - + /* Parse the ASN.1 structure. */ der = (const unsigned char*)buffer; derlen = buflen; @@ -607,13 +607,13 @@ read_private_key_file (const char *fname, int show) gcry_free (buffer); /* Convert from OpenSSL parameter ordering to the OpenPGP order. */ - /* First check that p < q; if not swap p and q and recompute u. */ + /* First check that p < q; if not swap p and q and recompute u. */ if (gcry_mpi_cmp (keyparms[3], keyparms[4]) > 0) { gcry_mpi_swap (keyparms[3], keyparms[4]); gcry_mpi_invm (keyparms[7], keyparms[3], keyparms[4]); } - + /* Build the S-expression. */ err = gcry_sexp_build (&s_key, NULL, "(private-key(rsa(n%m)(e%m)" @@ -622,12 +622,12 @@ read_private_key_file (const char *fname, int show) keyparms[3], keyparms[4], keyparms[7] ); if (err) die ("error building S-expression: %s\n", gpg_strerror (err)); - + for (idx=0; idx < n_keyparms; idx++) gcry_mpi_release (keyparms[idx]); - + return s_key; - + bad_asn1: die ("invalid ASN.1 structure in `%s'\n", fname); return NULL; /*NOTREACHED*/ @@ -661,7 +661,7 @@ read_public_key_file (const char *fname, int show) fclose (fp); buflen = base64_decode (buffer, buflen); - + /* Parse the ASN.1 structure. */ der = (const unsigned char*)buffer; derlen = buflen; @@ -673,7 +673,7 @@ read_public_key_file (const char *fname, int show) goto bad_asn1; /* We skip the description of the key parameters and assume it is RSA. */ der += ti.length; derlen -= ti.length; - + if ( parse_tag (&der, &derlen, &ti) || ti.tag != TAG_BIT_STRING || ti.class || ti.cons || ti.ndef) goto bad_asn1; @@ -715,12 +715,12 @@ read_public_key_file (const char *fname, int show) keyparms[0], keyparms[1] ); if (err) die ("error building S-expression: %s\n", gpg_strerror (err)); - + for (idx=0; idx < n_keyparms; idx++) gcry_mpi_release (keyparms[idx]); - + return s_key; - + bad_asn1: die ("invalid ASN.1 structure in `%s'\n", fname); return NULL; /*NOTREACHED*/ @@ -796,10 +796,10 @@ print_buffer (const void *buffer, size_t length) if (base64_output) { - static const unsigned char bintoasc[64+1] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; + static const unsigned char bintoasc[64+1] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; const unsigned char *p; unsigned char inbuf[4]; char outbuf[4]; @@ -820,7 +820,7 @@ print_buffer (const void *buffer, size_t length) if (fwrite (outbuf, 4, 1, stdout) != 1) writerr = 1; idx = 0; - if (++quads >= (64/4)) + if (++quads >= (64/4)) { if (fwrite ("\n", 1, 1, stdout) != 1) writerr = 1; @@ -836,8 +836,8 @@ print_buffer (const void *buffer, size_t length) outbuf[1] = bintoasc[((*inbuf<<4)&060)&077]; outbuf[2] = outbuf[3] = '='; } - else - { + else + { outbuf[1] = bintoasc[(((*inbuf<<4)&060) |((inbuf[1]>>4)&017))&077]; outbuf[2] = bintoasc[((inbuf[1]<<2)&074)&077]; @@ -858,7 +858,7 @@ print_buffer (const void *buffer, size_t length) else { const unsigned char *p = buffer; - + if (verbose > 1) showhex ("sent line", buffer, length); while (length-- && !ferror (stdout) ) @@ -895,7 +895,7 @@ print_mpi_line (gcry_mpi_t a, int no_lz) p = buf; if (no_lz && p[0] == '0' && p[1] == '0' && p[2]) p += 2; - + printf ("%s\n", p); if (ferror (stdout)) writerr++; @@ -913,7 +913,7 @@ print_data_line (const void *data, size_t datalen) { const unsigned char *p = data; int writerr = 0; - + while (data && datalen-- && !ferror (stdout) ) printf ("%02X", *p++); putchar ('\n'); @@ -944,13 +944,13 @@ print_sexp (gcry_sexp_t a, FILE *fp) static gcry_error_t -init_external_rng_test (void **r_context, +init_external_rng_test (void **r_context, unsigned int flags, const void *key, size_t keylen, const void *seed, size_t seedlen, const void *dt, size_t dtlen) { - return gcry_control (PRIV_CTL_INIT_EXTRNG_TEST, + return gcry_control (PRIV_CTL_INIT_EXTRNG_TEST, r_context, flags, key, keylen, seed, seedlen, @@ -973,14 +973,14 @@ deinit_external_rng_test (void *context) /* Given an OpenSSL cipher name NAME, return the Libgcrypt algirithm identified and store the libgcrypt mode at R_MODE. Returns 0 on error. */ -static int +static int map_openssl_cipher_name (const char *name, int *r_mode) { static struct { const char *name; int algo; int mode; - } table[] = + } table[] = { { "bf-cbc", GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CBC }, { "bf", GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CBC }, @@ -1020,7 +1020,7 @@ map_openssl_cipher_name (const char *name, int *r_mode) { "aes-192-cfb", GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CFB }, { "aes-192-ecb", GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_ECB }, { "aes-192-ofb", GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_OFB }, - + { "aes-256-cbc", GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC }, { "aes-256", GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC }, { "aes-256-cfb", GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB }, @@ -1048,7 +1048,7 @@ map_openssl_cipher_name (const char *name, int *r_mode) processes it and writes it out until EOF. */ static void run_encrypt_decrypt (int encrypt_mode, - int cipher_algo, int cipher_mode, + int cipher_algo, int cipher_mode, const void *iv_buffer, size_t iv_buflen, const void *key_buffer, size_t key_buflen, const void *data, size_t datalen, FILE *fp) @@ -1063,7 +1063,7 @@ run_encrypt_decrypt (int encrypt_mode, err = gcry_cipher_open (&hd, cipher_algo, cipher_mode, 0); if (err) - die ("gcry_cipher_open failed for algo %d, mode %d: %s\n", + die ("gcry_cipher_open failed for algo %d, mode %d: %s\n", cipher_algo, cipher_mode, gpg_strerror (err)); blocklen = gcry_cipher_get_algo_blklen (cipher_algo); @@ -1108,7 +1108,7 @@ run_encrypt_decrypt (int encrypt_mode, if (err) die ("gcry_cipher_%scrypt failed: %s\n", encrypt_mode? "en":"de", gpg_strerror (err)); - + print_buffer (outbuf, outbuflen); } while (inbuf); @@ -1133,7 +1133,7 @@ get_current_iv (gcry_cipher_hd_t hd, void *buffer, size_t buflen) /* Run the inner loop of the CAVS monte carlo test. */ static void -run_cipher_mct_loop (int encrypt_mode, int cipher_algo, int cipher_mode, +run_cipher_mct_loop (int encrypt_mode, int cipher_algo, int cipher_mode, const void *iv_buffer, size_t iv_buflen, const void *key_buffer, size_t key_buflen, const void *data, size_t datalen, int iterations) @@ -1146,12 +1146,12 @@ run_cipher_mct_loop (int encrypt_mode, int cipher_algo, int cipher_mode, char output[16]; char last_output[16]; char last_last_output[16]; - char last_iv[16]; + char last_iv[16]; err = gcry_cipher_open (&hd, cipher_algo, cipher_mode, 0); if (err) - die ("gcry_cipher_open failed for algo %d, mode %d: %s\n", + die ("gcry_cipher_open failed for algo %d, mode %d: %s\n", cipher_algo, cipher_mode, gpg_strerror (err)); blocklen = gcry_cipher_get_algo_blklen (cipher_algo); @@ -1175,7 +1175,7 @@ run_cipher_mct_loop (int encrypt_mode, int cipher_algo, int cipher_mode, } if (datalen != blocklen) - die ("length of input (%u) does not match block length (%u)\n", + die ("length of input (%u) does not match block length (%u)\n", (unsigned int)datalen, (unsigned int)blocklen); memcpy (input, data, datalen); memset (output, 0, sizeof output); @@ -1194,7 +1194,7 @@ run_cipher_mct_loop (int encrypt_mode, int cipher_algo, int cipher_mode, die ("gcry_cipher_%scrypt failed: %s\n", encrypt_mode? "en":"de", gpg_strerror (err)); - + if (encrypt_mode && (cipher_mode == GCRY_CIPHER_MODE_CFB || cipher_mode == GCRY_CIPHER_MODE_CBC)) memcpy (input, last_iv, blocklen); @@ -1243,7 +1243,7 @@ run_digest (int digest_algo, const void *data, size_t datalen) err = gcry_md_open (&hd, digest_algo, 0); if (err) - die ("gcry_md_open failed for algo %d: %s\n", + die ("gcry_md_open failed for algo %d: %s\n", digest_algo, gpg_strerror (err)); gcry_md_write (hd, data, datalen); @@ -1256,7 +1256,7 @@ run_digest (int digest_algo, const void *data, size_t datalen) /* Run a HMAC operation. */ static void -run_hmac (int digest_algo, const void *key, size_t keylen, +run_hmac (int digest_algo, const void *key, size_t keylen, const void *data, size_t datalen) { gpg_error_t err; @@ -1266,12 +1266,12 @@ run_hmac (int digest_algo, const void *key, size_t keylen, err = gcry_md_open (&hd, digest_algo, GCRY_MD_FLAG_HMAC); if (err) - die ("gcry_md_open failed for HMAC algo %d: %s\n", + die ("gcry_md_open failed for HMAC algo %d: %s\n", digest_algo, gpg_strerror (err)); gcry_md_setkey (hd, key, keylen); if (err) - die ("gcry_md_setkey failed for HMAC algo %d: %s\n", + die ("gcry_md_setkey failed for HMAC algo %d: %s\n", digest_algo, gpg_strerror (err)); gcry_md_write (hd, data, datalen); @@ -1349,7 +1349,7 @@ run_rsa_derive (const void *data, size_t datalen) static size_t compute_tag_length (size_t n) -{ +{ int needed = 0; if (n < 128) @@ -1366,7 +1366,7 @@ compute_tag_length (size_t n) static unsigned char * store_tag_length (unsigned char *p, int tag, size_t n) -{ +{ if (tag == TAG_SEQUENCE) tag |= 0x20; /* constructed */ @@ -1394,11 +1394,11 @@ store_tag_length (unsigned char *p, int tag, size_t n) is: SEQUENCE { - INTEGER (0) -- Unknown constant. + INTEGER (0) -- Unknown constant. INTEGER -- n INTEGER -- e INTEGER -- d - INTEGER -- p + INTEGER -- p INTEGER -- q (with p < q) INTEGER -- dmp1 = d mod (p-1) INTEGER -- dmq1 = d mod (q-1) @@ -1418,7 +1418,7 @@ run_rsa_gen (int keysize, int pubexp) size_t derlen, needed, n; unsigned char *derbuf, *der; - err = gcry_sexp_build (&keyspec, NULL, + err = gcry_sexp_build (&keyspec, NULL, "(genkey (rsa (nbits %d)(rsa-use-e %d)))", keysize, pubexp); if (err) @@ -1428,7 +1428,7 @@ run_rsa_gen (int keysize, int pubexp) err = gcry_pk_genkey (&key, keyspec); if (err) die ("gcry_pk_genkey failed for RSA: %s\n", gpg_strerror (err)); - + gcry_sexp_release (keyspec); l1 = gcry_sexp_find_token (key, "private-key", 0); @@ -1445,7 +1445,7 @@ run_rsa_gen (int keysize, int pubexp) /* Extract the parameters from the S-expression and store them in a well defined order in KEYPARMS. */ - for (idx=0; idx < DIM(keyparms); idx++) + for (idx=0; idx < DIM(keyparms); idx++) { if (keyelems[idx] == '.') { @@ -1464,7 +1464,7 @@ run_rsa_gen (int keysize, int pubexp) gcry_sexp_release (key); - /* Check that p < q; if not swap p and q and recompute u. */ + /* Check that p < q; if not swap p and q and recompute u. */ if (gcry_mpi_cmp (keyparms[3], keyparms[4]) > 0) { gcry_mpi_swap (keyparms[3], keyparms[4]); @@ -1478,8 +1478,8 @@ run_rsa_gen (int keysize, int pubexp) gcry_mpi_mod (keyparms[6], keyparms[2], keyparms[6]); /* Compute the length of the DER encoding. */ - needed = compute_tag_length (1) + 1; - for (idx=0; idx < DIM(keyparms); idx++) + needed = compute_tag_length (1) + 1; + for (idx=0; idx < DIM(keyparms); idx++) { err = gcry_mpi_print (GCRYMPI_FMT_STD, NULL, 0, &n, keyparms[idx]); if (err) @@ -1487,7 +1487,7 @@ run_rsa_gen (int keysize, int pubexp) keyparmslen[idx] = n; needed += compute_tag_length (n) + n; } - + /* Store the key parameters. */ derlen = compute_tag_length (needed) + needed; der = derbuf = gcry_xmalloc (derlen); @@ -1495,10 +1495,10 @@ run_rsa_gen (int keysize, int pubexp) der = store_tag_length (der, TAG_SEQUENCE, needed); der = store_tag_length (der, TAG_INTEGER, 1); *der++ = 0; - for (idx=0; idx < DIM(keyparms); idx++) + for (idx=0; idx < DIM(keyparms); idx++) { der = store_tag_length (der, TAG_INTEGER, keyparmslen[idx]); - err = gcry_mpi_print (GCRYMPI_FMT_STD, der, + err = gcry_mpi_print (GCRYMPI_FMT_STD, der, keyparmslen[idx], NULL, keyparms[idx]); if (err) die ("error formatting parameter: %s\n", gpg_strerror (err)); @@ -1506,7 +1506,7 @@ run_rsa_gen (int keysize, int pubexp) } /* Print the stuff. */ - for (idx=0; idx < DIM(keyparms); idx++) + for (idx=0; idx < DIM(keyparms); idx++) gcry_mpi_release (keyparms[idx]); assert (der - derbuf == derlen); @@ -1534,7 +1534,7 @@ run_rsa_sign (const void *data, size_t datalen, gcry_mpi_t sig_mpi = NULL; unsigned char *outbuf; size_t outlen; - + /* showhex ("D", data, datalen); */ if (pkcs1) { @@ -1598,7 +1598,7 @@ run_rsa_sign (const void *data, size_t datalen, } } gcry_sexp_release (s_sig); - + if (!sig_mpi) die ("no value in returned S-expression\n"); err = gcry_mpi_aprint (GCRYMPI_FMT_STD, &outbuf, &outlen, sig_mpi); @@ -1622,7 +1622,7 @@ run_rsa_verify (const void *data, size_t datalen, int hashalgo, int pkcs1, { gpg_error_t err; gcry_sexp_t s_data, s_key, s_sig; - + if (pkcs1) { unsigned char hash[64]; @@ -1680,7 +1680,7 @@ dsa_gen (int keysize) gpg_error_t err; gcry_sexp_t keyspec, key; - err = gcry_sexp_build (&keyspec, NULL, + err = gcry_sexp_build (&keyspec, NULL, "(genkey (dsa (nbits %d)(use-fips186-2)))", keysize); if (err) @@ -1690,7 +1690,7 @@ dsa_gen (int keysize) err = gcry_pk_genkey (&key, keyspec); if (err) die ("gcry_pk_genkey failed for DSA: %s\n", gpg_strerror (err)); - + gcry_sexp_release (keyspec); return key; @@ -1705,7 +1705,7 @@ dsa_gen_with_seed (int keysize, const void *seed, size_t seedlen) gpg_error_t err; gcry_sexp_t keyspec, key; - err = gcry_sexp_build (&keyspec, NULL, + err = gcry_sexp_build (&keyspec, NULL, "(genkey" " (dsa" " (nbits %d)" @@ -1720,7 +1720,7 @@ dsa_gen_with_seed (int keysize, const void *seed, size_t seedlen) err = gcry_pk_genkey (&key, keyspec); if (err) die ("gcry_pk_genkey failed for DSA: %s\n", gpg_strerror (err)); - + gcry_sexp_release (keyspec); return key; @@ -1731,7 +1731,7 @@ dsa_gen_with_seed (int keysize, const void *seed, size_t seedlen) is the complete key as returned by dsa_gen. We print to stdout with one parameter per line in hex format using this order: p, q, g, seed, counter, h. */ -static void +static void print_dsa_domain_parameters (gcry_sexp_t key) { gcry_sexp_t l1, l2; @@ -1752,7 +1752,7 @@ print_dsa_domain_parameters (gcry_sexp_t key) l1 = l2; /* Extract the parameters from the S-expression and print them to stdout. */ - for (idx=0; "pqg"[idx]; idx++) + for (idx=0; "pqg"[idx]; idx++) { l2 = gcry_sexp_find_token (l1, "pqg"+idx, 1); if (!l2) @@ -1940,7 +1940,7 @@ run_dsa_sign (const void *data, size_t datalen, const char *keyfile) print_mpi_line (tmpmpi, 1); gcry_mpi_release (tmpmpi); gcry_sexp_release (s_tmp); - + s_tmp = gcry_sexp_find_token (s_sig, "s", 0); tmpmpi = gcry_sexp_nth_mpi (s_tmp, 1, GCRYMPI_FMT_USG); if (!tmpmpi) @@ -2005,7 +2005,7 @@ usage (int show_help) { if (!show_help) { - fputs ("usage: " PGM + fputs ("usage: " PGM " [OPTION] [FILE] (try --help for more information)\n", stderr); exit (2); } @@ -2175,7 +2175,7 @@ main (int argc, char **argv) standalone_mode = 1; argc--; argv++; } - } + } if (!argc || argc > 2) usage (0); @@ -2223,7 +2223,7 @@ main (int argc, char **argv) if (!data) die ("error reading%s input\n", binary_input?"":" and decoding"); if (verbose) - fprintf (stderr, PGM ": %u bytes of input data\n", + fprintf (stderr, PGM ": %u bytes of input data\n", (unsigned int)datalen); } else @@ -2274,7 +2274,7 @@ main (int argc, char **argv) if (!(data = read_hexline (input, &datalen))) die ("no data in input\n"); skip_to_empty_line (input); - + run_cipher_mct_loop ((*mode_string == 'e'), cipher_algo, cipher_mode, iv_buffer, iv_buflen, @@ -2348,7 +2348,7 @@ main (int argc, char **argv) if (err) die ("init external RNG test failed: %s\n", gpg_strerror (err)); - do + do { err = run_external_rng_test (context, buffer, sizeof buffer); if (err) @@ -2357,12 +2357,12 @@ main (int argc, char **argv) if (progress) { if (!(++count % 1000)) - fprintf (stderr, PGM ": %lu random bytes so far\n", + fprintf (stderr, PGM ": %lu random bytes so far\n", (unsigned long int)count * sizeof buffer); } } while (loop_mode); - + if (progress) fprintf (stderr, PGM ": %lu random bytes\n", (unsigned long int)count * sizeof buffer); @@ -2409,7 +2409,7 @@ main (int argc, char **argv) else if (!strcmp (mode_string, "rsa-gen")) { int keysize; - + if (!binary_output) base64_output = 1; @@ -2464,7 +2464,7 @@ main (int argc, char **argv) else if (!strcmp (mode_string, "dsa-pqg-gen")) { int keysize; - + keysize = keysize_string? atoi (keysize_string) : 0; if (keysize < 1024 || keysize > 3072) die ("invalid keysize specified; needs to be 1024 .. 3072\n"); @@ -2473,7 +2473,7 @@ main (int argc, char **argv) else if (!strcmp (mode_string, "dsa-gen")) { int keysize; - + keysize = keysize_string? atoi (keysize_string) : 0; if (keysize < 1024 || keysize > 3072) die ("invalid keysize specified; needs to be 1024 .. 3072\n"); @@ -2523,4 +2523,3 @@ main (int argc, char **argv) return 0; } - diff --git a/tests/fipsrngdrv.c b/tests/fipsrngdrv.c index de2ad1ff..0fc19d56 100644 --- a/tests/fipsrngdrv.c +++ b/tests/fipsrngdrv.c @@ -2,17 +2,17 @@ Copyright (C) 2008 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, see . */ @@ -89,13 +89,13 @@ hex2bin (const char *string, void *buffer, size_t length) static gcry_error_t -init_external_test (void **r_context, +init_external_test (void **r_context, unsigned int flags, const void *key, size_t keylen, const void *seed, size_t seedlen, const void *dt, size_t dtlen) { - return gcry_control (58, + return gcry_control (58, r_context, flags, key, keylen, seed, seedlen, @@ -152,7 +152,7 @@ main (int argc, char **argv) } else if (!strcmp (*argv, "--help")) { - fputs ("usage: " PGM + fputs ("usage: " PGM " [--verbose] [--binary] [--loop] [--progress] KEY V DT\n", stdout); exit (0); @@ -182,8 +182,8 @@ main (int argc, char **argv) progress = 1; argc--; argv++; } - } - + } + if (!argc) { memcpy (key, "1234567890123456", 16); @@ -222,7 +222,7 @@ main (int argc, char **argv) if (err) die ("init external test failed: %s\n", gpg_strerror (err)); - do + do { int writerr = 0; @@ -269,4 +269,3 @@ main (int argc, char **argv) return 0; } - diff --git a/tests/keygen.c b/tests/keygen.c index f5d5610c..3774624e 100644 --- a/tests/keygen.c +++ b/tests/keygen.c @@ -95,7 +95,7 @@ check_generated_rsa_key (gcry_sexp_t key, unsigned long expected_e) if (verbose) print_mpi ("e", e); } - else if ( gcry_mpi_cmp_ui (e, expected_e)) + else if ( gcry_mpi_cmp_ui (e, expected_e)) { print_mpi ("e", e); fail ("public exponent is not %lu\n", expected_e); @@ -104,7 +104,7 @@ check_generated_rsa_key (gcry_sexp_t key, unsigned long expected_e) gcry_mpi_release (e); gcry_sexp_release (pkey); } - + skey = gcry_sexp_find_token (key, "private-key", 0); if (!skey) fail ("private part missing in return value\n"); @@ -131,7 +131,7 @@ check_rsa_keys (void) fprintf (stderr, "creating 5 1024 bit DSA keys\n"); for (i=0; i < 5; i++) { - rc = gcry_sexp_new (&keyparm, + rc = gcry_sexp_new (&keyparm, "(genkey\n" " (dsa\n" " (nbits 4:1024)\n" @@ -149,7 +149,7 @@ check_rsa_keys (void) if (verbose) fprintf (stderr, "creating 1536 bit DSA key\n"); - rc = gcry_sexp_new (&keyparm, + rc = gcry_sexp_new (&keyparm, "(genkey\n" " (dsa\n" " (nbits 4:1536)\n" @@ -173,7 +173,7 @@ check_rsa_keys (void) if (verbose) fprintf (stderr, "creating 1024 bit RSA key\n"); - rc = gcry_sexp_new (&keyparm, + rc = gcry_sexp_new (&keyparm, "(genkey\n" " (rsa\n" " (nbits 4:1024)\n" @@ -191,7 +191,7 @@ check_rsa_keys (void) if (verbose) fprintf (stderr, "creating 512 bit RSA key with e=257\n"); - rc = gcry_sexp_new (&keyparm, + rc = gcry_sexp_new (&keyparm, "(genkey\n" " (rsa\n" " (nbits 3:512)\n" @@ -209,7 +209,7 @@ check_rsa_keys (void) if (verbose) fprintf (stderr, "creating 512 bit RSA key with default e\n"); - rc = gcry_sexp_new (&keyparm, + rc = gcry_sexp_new (&keyparm, "(genkey\n" " (rsa\n" " (nbits 3:512)\n" @@ -275,7 +275,7 @@ progress_cb (void *cb_data, const char *what, int printchar, (void)what; (void)current; (void)total; - + if (printchar == '\n') fputs ( "", stdout); else @@ -305,7 +305,6 @@ main (int argc, char **argv) check_rsa_keys (); check_nonce (); - + return error_count? 1:0; } - diff --git a/tests/keygrip.c b/tests/keygrip.c index e1908ba3..a33053fa 100644 --- a/tests/keygrip.c +++ b/tests/keygrip.c @@ -87,7 +87,7 @@ static struct " (g #44370CEE0FE8609994183DBFEBA7EEA97D466838BCF65EFF506E35616DA93FA4E572A2F08886B74977BC00CA8CD3DBEA7AEB7DB8CBB180E6975E0D2CA76E023E6DE9F8CCD8826EBA2F72B8516532F6001DEFFAE76AA5E59E0FA33DBA3999B4E92D1703098CDEDCC416CF008801964084CDE1980132B2B78CB4CE9C15A559528B#)" " (y #3D5DD14AFA2BF24A791E285B90232213D0E3BA74AB1109E768AED19639A322F84BB7D959E2BA92EF73DE4C7F381AA9F4053CFA3CD4527EF9043E304E5B95ED0A3A5A9D590AA641C13DB2B6E32B9B964A6A2C730DD3EA7C8E13F7A140AFF1A91CE375E9B9B960384779DC4EA180FA1F827C52288F366C0770A220F50D6D8FD6F6#)))", "\x04\xA3\x4F\xA0\x2B\x03\x94\xD7\x32\xAD\xD5\x9B\x50\xAF\xDB\x5D\x57\x22\xA6\x10" - + }, { GCRY_PK_DSA, @@ -100,7 +100,7 @@ static struct " (x #0087F9E91BFBCC1163DE71ED86D557708E32F8ADDE#)))", "\x04\xA3\x4F\xA0\x2B\x03\x94\xD7\x32\xAD\xD5\x9B\x50\xAF\xDB\x5D\x57\x22\xA6\x10" }, - { + { GCRY_PK_ECDSA, "(public-key" " (ecdsa" @@ -112,7 +112,7 @@ static struct " (q #04C8A4CEC2E9A9BC8E173531A67B0840DF345C32E261ADD780E6D83D56EFADFD5DE872F8B854819B59543CE0B7F822330464FBC4E6324DADDCD9D059554F63B344#)))", "\xE6\xDF\x94\x2D\xBD\x8C\x77\x05\xA3\xDD\x41\x6E\xFC\x04\x01\xDB\x31\x0E\x99\xB6" }, - { + { GCRY_PK_ECDSA, "(public-key" " (ecdsa" @@ -124,7 +124,7 @@ static struct " (q #04C8A4CEC2E9A9BC8E173531A67B0840DF345C32E261ADD780E6D83D56EFADFD5DE872F8B854819B59543CE0B7F822330464FBC4E6324DADDCD9D059554F63B344#)))", "\xE6\xDF\x94\x2D\xBD\x8C\x77\x05\xA3\xDD\x41\x6E\xFC\x04\x01\xDB\x31\x0E\x99\xB6" }, - { + { GCRY_PK_ECDSA, "(public-key" " (ecdsa" @@ -149,7 +149,7 @@ check (void) if (gcry_pk_test_algo (key_grips[i].algo)) { if (verbose) - fprintf (stderr, "algo %d not available; test skipped\n", + fprintf (stderr, "algo %d not available; test skipped\n", key_grips[i].algo); continue; } @@ -160,11 +160,11 @@ check (void) ret = gcry_pk_get_keygrip (sexp, buf); if (!ret) die ("gcry_pk_get_keygrip failed for %d\n", i); - + if ( memcmp (key_grips[i].grip, buf, sizeof (buf)) ) { print_hex ("keygrip: ", buf, sizeof buf); - die ("keygrip for %d does not match\n", i); + die ("keygrip for %d does not match\n", i); } gcry_sexp_release (sexp); @@ -199,7 +199,7 @@ main (int argc, char **argv) die ("version mismatch\n"); gcry_set_progress_handler (progress_handler, NULL); - + gcry_control (GCRYCTL_DISABLE_SECMEM, 0); check (); diff --git a/tests/mpitests.c b/tests/mpitests.c index 3ccfae00..cf828425 100644 --- a/tests/mpitests.c +++ b/tests/mpitests.c @@ -16,7 +16,7 @@ * 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. + * USA. */ #ifdef HAVE_CONFIG_H @@ -89,7 +89,7 @@ unsigned char manyff[] = { -static int +static int test_add (void) { gcry_mpi_t one; @@ -97,12 +97,12 @@ test_add (void) gcry_mpi_t ff; gcry_mpi_t result; unsigned char* pc; - + gcry_mpi_scan(&one, GCRYMPI_FMT_USG, ones, sizeof(ones), NULL); gcry_mpi_scan(&two, GCRYMPI_FMT_USG, twos, sizeof(twos), NULL); gcry_mpi_scan(&ff, GCRYMPI_FMT_USG, manyff, sizeof(manyff), NULL); result = gcry_mpi_new(0); - + gcry_mpi_add(result, one, two); gcry_mpi_aprint(GCRYMPI_FMT_HEX, &pc, NULL, result); if (verbose) @@ -114,7 +114,7 @@ test_add (void) if (verbose) printf("Result of ff plus one:\n%s\n", pc); gcry_free(pc); - + gcry_mpi_release(one); gcry_mpi_release(two); gcry_mpi_release(ff); @@ -123,24 +123,24 @@ test_add (void) } -static int +static int test_sub (void) { gcry_mpi_t one; gcry_mpi_t two; gcry_mpi_t result; unsigned char* pc; - + gcry_mpi_scan(&one, GCRYMPI_FMT_USG, ones, sizeof(ones), NULL); gcry_mpi_scan(&two, GCRYMPI_FMT_USG, twos, sizeof(twos), NULL); result = gcry_mpi_new(0); gcry_mpi_sub(result, two, one); - + gcry_mpi_aprint(GCRYMPI_FMT_HEX, &pc, NULL, result); if (verbose) printf("Result of two minus one:\n%s\n", pc); gcry_free(pc); - + gcry_mpi_release(one); gcry_mpi_release(two); gcry_mpi_release(result); @@ -148,24 +148,24 @@ test_sub (void) } -static int +static int test_mul (void) { gcry_mpi_t two; gcry_mpi_t three; gcry_mpi_t result; unsigned char* pc; - + gcry_mpi_scan(&two, GCRYMPI_FMT_USG, twos, sizeof(twos), NULL); gcry_mpi_scan(&three, GCRYMPI_FMT_USG, threes, sizeof(threes), NULL); result = gcry_mpi_new(0); gcry_mpi_mul(result, two, three); - + gcry_mpi_aprint(GCRYMPI_FMT_HEX, &pc, NULL, result); if (verbose) printf("Result of two mul three:\n%s\n", pc); gcry_free(pc); - + gcry_mpi_release(two); gcry_mpi_release(three); gcry_mpi_release(result); @@ -180,7 +180,7 @@ test_powm (void) { int b_int = 17; int e_int = 3; - int m_int = 19; + int m_int = 19; gcry_mpi_t base = gcry_mpi_set_ui (NULL, b_int); gcry_mpi_t exp = gcry_mpi_set_ui (NULL, e_int); gcry_mpi_t mod = gcry_mpi_set_ui (NULL, m_int); @@ -277,7 +277,7 @@ test_powm (void) } -int +int main (int argc, char* argv[]) { if (argc > 1 && !strcmp (argv[1], "--verbose")) @@ -299,4 +299,3 @@ main (int argc, char* argv[]) return 0; } - diff --git a/tests/pkbench.c b/tests/pkbench.c index 67b94dc9..15192f0f 100644 --- a/tests/pkbench.c +++ b/tests/pkbench.c @@ -102,14 +102,14 @@ read_file (const char *fname, size_t *r_length) struct stat st; char *buf; size_t buflen; - + fp = fopen (fname, "rb"); if (!fp) { fail ("can't open `%s': %s\n", fname, strerror (errno)); return NULL; } - + if (fstat (fileno(fp), &st)) { fail ("can't stat `%s': %s\n", fname, strerror (errno)); @@ -209,7 +209,7 @@ work_decrypt (context_t context, unsigned int final) else { gcry_sexp_t data_decrypted = NULL; - + err = gcry_pk_decrypt (&data_decrypted, context->data_encrypted, context->key_secret); @@ -279,7 +279,7 @@ work_verify (context_t context, unsigned int final) gcry_sexp_release (context->data_signed); context->data_signed = NULL; } - + return ret; } @@ -468,7 +468,7 @@ main (int argc, char **argv) fips_mode = 1; argc--; argv++; } - } + } gcry_control (GCRYCTL_SET_VERBOSITY, (int)verbose); @@ -486,12 +486,12 @@ main (int argc, char **argv) { /* No valuable keys are create, so we can speed up our RNG. */ gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - } + } if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); - + if (genkey_mode && argc == 2) { generate_key (argv[0], argv[1]); @@ -499,7 +499,7 @@ main (int argc, char **argv) else if (!genkey_mode && argc) { int i; - + for (i = 0; i < argc; i++) process_key_pair_file (argv[i]); } @@ -509,6 +509,6 @@ main (int argc, char **argv) " [OPTIONS] [FILES] (try --help for more information)\n"); exit (1); } - + return error_count ? 1 : 0; } diff --git a/tests/prime.c b/tests/prime.c index 12bcc894..b365a14c 100644 --- a/tests/prime.c +++ b/tests/prime.c @@ -82,7 +82,7 @@ check_primes (void) err = gcry_prime_group_generator (&g, prime, factors, NULL); assert (!err); gcry_prime_release_factors (factors); factors = NULL; - + if (verbose) { fprintf (stderr, " %d: g = ", i); diff --git a/tests/pubkey.c b/tests/pubkey.c index e5ec464a..92e5f5da 100644 --- a/tests/pubkey.c +++ b/tests/pubkey.c @@ -196,11 +196,11 @@ check_keys (gcry_sexp_t pkey, gcry_sexp_t skey, unsigned int nbits_data, gcry_sexp_t plain; gcry_mpi_t x; int rc; - + /* Create plain text. */ x = gcry_mpi_new (nbits_data); gcry_mpi_randomize (x, nbits_data, GCRY_WEAK_RANDOM); - + rc = gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %m))", x); if (rc) die ("converting data for encryption failed: %s\n", @@ -213,8 +213,8 @@ check_keys (gcry_sexp_t pkey, gcry_sexp_t skey, unsigned int nbits_data, /* Create plain text. */ x = gcry_mpi_new (nbits_data); gcry_mpi_randomize (x, nbits_data, GCRY_WEAK_RANDOM); - - rc = gcry_sexp_build (&plain, NULL, + + rc = gcry_sexp_build (&plain, NULL, "(data (flags raw no-blinding) (value %m))", x); if (rc) die ("converting data for encryption failed: %s\n", @@ -256,7 +256,7 @@ get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) { gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - + rc = gcry_sexp_new (&key_spec, "(genkey (rsa (nbits 4:1024)))", 0, 1); if (rc) @@ -265,7 +265,7 @@ get_keys_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating RSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated RSA key:\n", key); @@ -288,7 +288,7 @@ get_keys_x931_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) { gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - + rc = gcry_sexp_new (&key_spec, "(genkey (rsa (nbits 4:1024)(use-x931)))", 0, 1); if (rc) @@ -297,7 +297,7 @@ get_keys_x931_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating RSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated RSA (X9.31) key:\n", key); @@ -321,8 +321,8 @@ get_elg_key_new (gcry_sexp_t *pkey, gcry_sexp_t *skey, int fixed_x) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - rc = gcry_sexp_new - (&key_spec, + rc = gcry_sexp_new + (&key_spec, (fixed_x ? "(genkey (elg (nbits 4:1024)(xvalue my.not-so-secret.key)))" : "(genkey (elg (nbits 3:512)))"), @@ -334,7 +334,7 @@ get_elg_key_new (gcry_sexp_t *pkey, gcry_sexp_t *skey, int fixed_x) gcry_sexp_release (key_spec); if (rc) die ("error generating Elgamal key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated ELG key:\n", key); @@ -358,7 +358,7 @@ get_dsa_key_new (gcry_sexp_t *pkey, gcry_sexp_t *skey, int transient_key) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - rc = gcry_sexp_new (&key_spec, + rc = gcry_sexp_new (&key_spec, transient_key ? "(genkey (dsa (nbits 4:1024)(transient-key)))" : "(genkey (dsa (nbits 4:1024)))", @@ -369,7 +369,7 @@ get_dsa_key_new (gcry_sexp_t *pkey, gcry_sexp_t *skey, int transient_key) gcry_sexp_release (key_spec); if (rc) die ("error generating DSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated DSA key:\n", key); @@ -393,7 +393,7 @@ get_dsa_key_fips186_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - rc = gcry_sexp_new + rc = gcry_sexp_new (&key_spec, "(genkey (dsa (nbits 4:1024)(use-fips186)))", 0, 1); if (rc) die ("error creating S-expression: %s\n", gcry_strerror (rc)); @@ -401,7 +401,7 @@ get_dsa_key_fips186_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating DSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated DSA key (fips 186):\n", key); @@ -425,8 +425,8 @@ get_dsa_key_with_domain_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - rc = gcry_sexp_new - (&key_spec, + rc = gcry_sexp_new + (&key_spec, "(genkey (dsa (transient-key)(domain" "(p #d3aed1876054db831d0c1348fbb1ada72507e5fbf9a62cbd47a63aeb7859d6921" "4adeb9146a6ec3f43520f0fd8e3125dd8bbc5d87405d1ac5f82073cd762a3f8d7" @@ -444,7 +444,7 @@ get_dsa_key_with_domain_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating DSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated DSA key:\n", key); @@ -467,8 +467,8 @@ get_dsa_key_fips186_with_domain_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - rc = gcry_sexp_new - (&key_spec, + rc = gcry_sexp_new + (&key_spec, "(genkey (dsa (transient-key)(use-fips186)(domain" "(p #d3aed1876054db831d0c1348fbb1ada72507e5fbf9a62cbd47a63aeb7859d6921" "4adeb9146a6ec3f43520f0fd8e3125dd8bbc5d87405d1ac5f82073cd762a3f8d7" @@ -486,7 +486,7 @@ get_dsa_key_fips186_with_domain_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating DSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated DSA key:\n", key); @@ -510,10 +510,10 @@ get_dsa_key_fips186_with_seed_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_t key_spec, key, pub_key, sec_key; int rc; - rc = gcry_sexp_new + rc = gcry_sexp_new (&key_spec, "(genkey" - " (dsa" + " (dsa" " (nbits 4:1024)" " (use-fips186)" " (transient-key)" @@ -526,7 +526,7 @@ get_dsa_key_fips186_with_seed_new (gcry_sexp_t *pkey, gcry_sexp_t *skey) gcry_sexp_release (key_spec); if (rc) die ("error generating DSA key: %s\n", gcry_strerror (rc)); - + if (verbose > 1) show_sexp ("generated DSA key (fips 186 with seed):\n", key); @@ -698,7 +698,7 @@ check_x931_derived_key (int what) "B93BCA16B541B33F80C933A3B769285C462ED5677BFE89DF07BED5C127FD13" "241D3C4B" }, - + { /* Second example from X9.31 (D.2.1). */ "(genkey\n" " (rsa\n" @@ -734,12 +734,12 @@ check_x931_derived_key (int what) "DE30F38728FE7C8635E324E2CD5D8EBCAA1C51993315FD73B38904E107D7A7" "B7B10EDCA3896906FCF87BE367BB858CA1B27E2FC3C8674ECC8B0F92C0E270" "BA2ECA3701311F68AFCE208DCC499B4B3DB30FF0605CE055D893BC1461D342" - "EF32E7D9720B" + "EF32E7D9720B" This is a bug in X9.31, obviously introduced by using d = e^{-1} mod (p-1)(q-1) - + instead of using the universal exponent as required by 4.1.3: d = e^{-1} mod lcm(p-1,q-1) @@ -750,7 +750,7 @@ check_x931_derived_key (int what) me several hours to figure out that the bugs are in the document and not in my code. */ - }, + }, { /* First example from NIST RSAVS (B.1.1). */ "(genkey\n" @@ -821,7 +821,7 @@ check_x931_derived_key (int what) gcry_sexp_release (key_spec); if (err) die ("error generating RSA key [%d]: %s\n", what, gpg_strerror (err)); - + pub_key = gcry_sexp_find_token (key, "public-key", 0); if (!pub_key) die ("public part missing in key [%d]\n", what); @@ -830,7 +830,7 @@ check_x931_derived_key (int what) if (!sec_key) die ("private part missing in key [%d]\n", what); - err = gcry_mpi_scan + err = gcry_mpi_scan (&d_expected, GCRYMPI_FMT_HEX, testtable[what].expected_d, 0, NULL); if (err) die ("error converting string [%d]\n", what); @@ -844,7 +844,7 @@ check_x931_derived_key (int what) if (gcry_mpi_cmp (d_expected, d_have)) { show_sexp (NULL, sec_key); - die ("parameter d does match expected value [%d]\n", what); + die ("parameter d does match expected value [%d]\n", what); } gcry_mpi_release (d_expected); gcry_mpi_release (d_have); @@ -885,6 +885,6 @@ main (int argc, char **argv) for (i=0; i < 4; i++) check_x931_derived_key (i); - + return 0; } diff --git a/tests/random.c b/tests/random.c index 502a3758..0575e8a0 100644 --- a/tests/random.c +++ b/tests/random.c @@ -61,7 +61,7 @@ writen (int fd, const void *buf, size_t nbytes) { size_t nleft = nbytes; int nwritten; - + while (nleft > 0) { nwritten = write (fd, buf, nleft); @@ -69,13 +69,13 @@ writen (int fd, const void *buf, size_t nbytes) { if (errno == EINTR) nwritten = 0; - else + else return -1; } nleft -= nwritten; buf = (const char*)buf + nwritten; } - + return 0; } @@ -85,7 +85,7 @@ readn (int fd, void *buf, size_t buflen, size_t *ret_nread) size_t nleft = buflen; int nread; char *p; - + p = buf; while ( nleft > 0 ) { @@ -94,7 +94,7 @@ readn (int fd, void *buf, size_t buflen, size_t *ret_nread) { if (nread == EINTR) nread = 0; - else + else return -1; } else if (!nread) @@ -118,7 +118,7 @@ check_forking (void) int i, status; size_t nread; char tmp1[16], tmp1c[16], tmp1p[16]; - + /* We better make sure that the RNG has been initialzied. */ gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM); if (verbose) @@ -148,7 +148,7 @@ check_forking (void) close (rp[1]); if (readn (rp[0], tmp1c, sizeof tmp1c, &nread)) - die ("read failed: %s\n", strerror (errno)); + die ("read failed: %s\n", strerror (errno)); if (nread != sizeof tmp1c) die ("read too short\n"); @@ -175,7 +175,7 @@ check_nonce_forking (void) int i, status; size_t nread; char nonce1[10], nonce1c[10], nonce1p[10]; - + /* We won't get the same nonce back if we never initialized the nonce subsystem, thus we get one nonce here and forget about it. */ @@ -207,7 +207,7 @@ check_nonce_forking (void) close (rp[1]); if (readn (rp[0], nonce1c, sizeof nonce1c, &nread)) - die ("read failed: %s\n", strerror (errno)); + die ("read failed: %s\n", strerror (errno)); if (nread != sizeof nonce1c) die ("read too short\n"); diff --git a/tests/register.c b/tests/register.c index df90fe09..4d8cebe8 100644 --- a/tests/register.c +++ b/tests/register.c @@ -96,7 +96,7 @@ check_list (int algorithm) list = malloc (sizeof (int) * list_length); assert (list); err = gcry_cipher_list (list, &list_length); - + for (i = 0; i < list_length && (! ret); i++) if (list[i] == algorithm) ret = 1; @@ -183,5 +183,5 @@ main (int argc, char **argv) /* In fips mode we let the Makefile skip this test because a PASS would not make much sense with all egistering disabled. */ - return in_fips_mode? 77:0; + return in_fips_mode? 77:0; } diff --git a/tests/rsacvt.c b/tests/rsacvt.c index b8a20a1b..014cd2a3 100644 --- a/tests/rsacvt.c +++ b/tests/rsacvt.c @@ -2,17 +2,17 @@ Copyright (C) 2009 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, see . */ @@ -25,7 +25,7 @@ e861b700e17e8afe68[...]f1 f7a7ca5367c661f8e6[...]61 10001 -# After an empty line another input block may follow. +# After an empty line another input block may follow. 7861b700e17e8afe68[...]f3 e7a7ca5367c661f8e6[...]71 3 @@ -81,7 +81,7 @@ static int verbose; static int with_labels; /* Do not suppress leading zeroes. */ -static int keep_lz; +static int keep_lz; /* Create parameters as specified by OpenPGP (rfc4880). That is we don't store dmp1 and dmp1 but d and make sure that p is less than q. */ @@ -112,7 +112,7 @@ read_textline (FILE *fp) /* Read line but skip over initial empty lines. */ do { - do + do { if (!fgets (line, sizeof line, fp)) { @@ -201,7 +201,7 @@ print_mpi_line (const char *label, gcry_mpi_t a) p = buf; if (!keep_lz && p[0] == '0' && p[1] == '0' && p[2]) p += 2; - + printf ("%s\n", p); if (ferror (stdout)) writerr++; @@ -230,7 +230,7 @@ compute_missing (gcry_mpi_t rsa_p, gcry_mpi_t rsa_q, gcry_mpi_t rsa_e) tmp_f = gcry_mpi_new (0); tmp_g = gcry_mpi_new (0); - /* Check that p < q; if not swap p and q. */ + /* Check that p < q; if not swap p and q. */ if (openpgp_mode && gcry_mpi_cmp (rsa_p, rsa_q) > 0) { fprintf (stderr, PGM ": swapping p and q\n"); @@ -238,7 +238,7 @@ compute_missing (gcry_mpi_t rsa_p, gcry_mpi_t rsa_q, gcry_mpi_t rsa_e) } gcry_mpi_mul (rsa_n, rsa_p, rsa_q); - + /* Compute the Euler totient: phi = (p-1)(q-1) */ gcry_mpi_sub_ui (rsa_pm1, rsa_p, 1); @@ -259,7 +259,7 @@ compute_missing (gcry_mpi_t rsa_p, gcry_mpi_t rsa_q, gcry_mpi_t rsa_e) gcry_mpi_mod (rsa_pm1, rsa_d, rsa_pm1); gcry_mpi_mod (rsa_qm1, rsa_d, rsa_qm1); - /* Compute the CRT value: OpenPGP: u = p^{-1} mod q + /* Compute the CRT value: OpenPGP: u = p^{-1} mod q Standard: iqmp = q^{-1} mod p */ if (openpgp_mode) gcry_mpi_invm (rsa_u, rsa_p, rsa_q); @@ -300,7 +300,7 @@ usage (int show_help) { if (!show_help) { - fputs ("usage: " PGM + fputs ("usage: " PGM " [OPTION] [FILE] (try --help for more information)\n", stderr); exit (2); } @@ -370,7 +370,7 @@ main (int argc, char **argv) openpgp_mode = 1; argc--; argv++; } - } + } if (argc > 1) usage (0); @@ -408,12 +408,12 @@ main (int argc, char **argv) if (!rsa_e) die ("RSA parameter 'e' missing or not properly hex encoded\n"); got_eof = skip_to_empty_line (input); - + if (any) putchar ('\n'); compute_missing (rsa_p, rsa_q, rsa_e); - + gcry_mpi_release (rsa_p); gcry_mpi_release (rsa_q); gcry_mpi_release (rsa_e); @@ -421,7 +421,6 @@ main (int argc, char **argv) any = 1; } while (!got_eof); - + return 0; } - diff --git a/tests/t-mpi-bit.c b/tests/t-mpi-bit.c index aaad0f1d..85bd32e9 100644 --- a/tests/t-mpi-bit.c +++ b/tests/t-mpi-bit.c @@ -15,7 +15,7 @@ * * 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, + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ @@ -91,7 +91,7 @@ static char * mpi2bitstr (gcry_mpi_t a, size_t length) { char *p, *buf; - + buf = p = xmalloc (length+1); while (length--) *p++ = gcry_mpi_test_bit (a, length) ? '1':'0'; @@ -147,7 +147,7 @@ lshiftbitstring (const char *string, size_t n) if (len+n+1 < len) die ("internal overflow\n"); - /* Allocate enough space. */ + /* Allocate enough space. */ result = xmalloc (len+n+1); for (; *string == '0' && string[1]; string++, len--) ; @@ -282,7 +282,7 @@ test_lshift (int pass) for (i=0; i < 75; i++) { gcry_mpi_lshift (b, a, i); - + result = mpi2bitstr_nlz (b); tmpstr = mpi2bitstr_nlz (a); result2 = lshiftbitstring (tmpstr, i); @@ -296,11 +296,11 @@ test_lshift (int pass) xfree (result); xfree (result2); } - + /* Again. This time using in-place operation. */ gcry_mpi_randomize (a, size_list[size_idx], GCRY_WEAK_RANDOM); gcry_mpi_clear_highbit (a, size_list[size_idx]); - + for (i=0; i < 75; i++) { gcry_mpi_release (b); @@ -355,7 +355,7 @@ main (int argc, char **argv) for (i=0; i < 5; i++) test_lshift (i); /* Run several times due to random initializations. */ - + show ("All tests completed. Errors: %d\n", error_count); return error_count ? 1 : 0; } diff --git a/tests/tsexp.c b/tests/tsexp.c index 21d54a62..73d3d6ed 100644 --- a/tests/tsexp.c +++ b/tests/tsexp.c @@ -81,7 +81,7 @@ basic (void) { NULL } }; - info ("doing some pretty pointless tests\n"); + info ("doing some pretty pointless tests\n"); secure_buffer_len = 99; secure_buffer = gcry_xmalloc_secure (secure_buffer_len); @@ -94,7 +94,7 @@ basic (void) case 0: string = ("(public-key (dsa (p #41424344#) (y this_is_y) " "(q #61626364656667#) (g %m)))"); - + if ( gcry_sexp_build (&sexp, NULL, string, gcry_mpi_set_ui (NULL, 42)) ) { @@ -102,12 +102,12 @@ basic (void) return; } break; - + case 1: string = ("(public-key (dsa (p #41424344#) (y this_is_y) " "(q %b) (g %m)))"); - - if ( gcry_sexp_build (&sexp, NULL, string, + + if ( gcry_sexp_build (&sexp, NULL, string, 15, "foo\0\x01\0x02789012345", gcry_mpi_set_ui (NULL, 42)) ) { @@ -119,8 +119,8 @@ basic (void) case 2: string = ("(public-key (dsa (p #41424344#) (y silly_y_value) " "(q %b) (g %m)))"); - - if ( gcry_sexp_build (&sexp, NULL, string, + + if ( gcry_sexp_build (&sexp, NULL, string, secure_buffer_len, secure_buffer, gcry_mpi_set_ui (NULL, 17)) ) { @@ -154,8 +154,8 @@ basic (void) gcry_sexp_release (help_sexp); } break; - - + + default: return; /* Ready. */ } @@ -187,7 +187,7 @@ basic (void) info ("car=`%.*s'\n", (int)n, p); s2 = gcry_sexp_cdr (s1); - if (!s2) + if (!s2) { fail ("no cdr for `%s'\n", token); continue; @@ -209,20 +209,20 @@ basic (void) continue; } p = gcry_sexp_nth_data (s2, 0, &n); - if (!p) + if (!p) { fail("no car for `%s'\n", parm ); continue; } info ("car=`%.*s'\n", (int)n, p); p = gcry_sexp_nth_data (s2, 1, &n); - if (!p) + if (!p) { fail("no cdr for `%s'\n", parm ); continue; } info ("cdr=`%.*s'\n", (int)n, p); - + a = gcry_sexp_nth_mpi (s2, 0, GCRYMPI_FMT_USG); if (!a) { @@ -231,7 +231,7 @@ basic (void) } } } - + gcry_sexp_release (sexp); sexp = NULL; } @@ -247,7 +247,7 @@ canon_len (void) size_t expected;/* expected length or 0 on error and then ... */ size_t erroff; /* ... and at this offset */ gcry_error_t errcode; /* ... with this error code */ - const char *text; + const char *text; } values[] = { { 14, 13, 0, GPG_ERR_NO_ERROR, "(9:abcdefghi) " }, { 16, 15, 0, GPG_ERR_NO_ERROR, "(10:abcdefghix)" }, @@ -274,9 +274,9 @@ canon_len (void) for (idx=0; values[idx].text; idx++) { n = gcry_sexp_canon_len ((const unsigned char*)values[idx].text, - values[idx].textlen, + values[idx].textlen, &erroff, &errcode); - + if (n && n == values[idx].expected) ; /* success */ else if (!n && !values[idx].expected) @@ -356,7 +356,7 @@ back_and_forth_one (int testno, const char *buffer, size_t length) if (*p1 != '\x55' || p1[n1+1] != '\xaa') fail ("baf %d: memory corrupted (3)\n", testno); gcry_free (p1); - + /* FIXME: we need a lot more tests */ gcry_sexp_release (se); @@ -396,7 +396,7 @@ check_sscan (void) { static struct { const char *text; - gcry_error_t expected_err; + gcry_error_t expected_err; } values[] = { /* Bug reported by Olivier L'Heureux 2003-10-07 */ { "(7:sig-val(3:dsa" @@ -451,6 +451,6 @@ main (int argc, char **argv) canon_len (); back_and_forth (); check_sscan (); - + return error_count? 1:0; } diff --git a/tests/version.c b/tests/version.c index 03259af7..3cbecbcb 100644 --- a/tests/version.c +++ b/tests/version.c @@ -2,17 +2,17 @@ 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, @@ -23,8 +23,8 @@ 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 #endif @@ -55,4 +55,3 @@ main (int argc, char **argv) return 0; } - -- cgit v1.2.1