Bug 1700349 - Update libgcrypt to 1.9.2. r=kaie
--HG-- extra : rebase_source : 9f63e0bdbc3d2fde559085bd0c83416b73c53dde
This commit is contained in:
Родитель
7688f668df
Коммит
5ae33ac3d2
|
@ -1,7 +1,7 @@
|
|||
Directory ./libgcrypt contains a copy of version 1.9.0 of the libgcrypt library,
|
||||
Directory ./libgcrypt contains a copy of version 1.9.2 of the libgcrypt library,
|
||||
which has been obtained from https://www.gnupg.org/ftp/gcrypt/libgcrypt/ .
|
||||
|
||||
For licensing information, please refer to the included documentation.
|
||||
|
||||
The SHA256SUM of the imported file is:
|
||||
5cf9313eb8ab5101e505f35dc0f3932b30a30e4b142cac06d2e1a6eb7cb3732a libgcrypt-1.9.1.tar.gz
|
||||
b2c10d091513b271e47177274607b1ffba3d95b188bbfa8797f948aec9053c5a libgcrypt-1.9.2.tar.bz2
|
||||
|
|
|
@ -1,3 +1,102 @@
|
|||
2021-02-17 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Release 1.9.2.
|
||||
+ commit 24bd7e8215f7982b0c8db46fd87b47b370a52ec6
|
||||
|
||||
|
||||
2021-02-12 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
random: Fix build for macOS.
|
||||
+ commit d78cdf42854b17e2216890e7b78f9e7e05c0b1f8
|
||||
* random/rndlinux.c [__APPLE__] (HAVE_GETENTROPY): Valid only when the
|
||||
macro __MAC_10_11 is available.
|
||||
|
||||
2021-02-08 Werner Koch <wk@gnupg.org>
|
||||
|
||||
tests: Fix minor glitches.
|
||||
+ commit 82395f11b444651f544f5e51c62fc6b65c04f9ef
|
||||
* tests/basic.c (ALWAYS_INLINE): Make sure it is defined.
|
||||
* tests/version.c (main): Print the config info to stdout.
|
||||
|
||||
New test Makefile target xtestsuite.
|
||||
+ commit ebc4d5670a1ada54ad907a4836eb8f6f573c2c38
|
||||
* tests/Makefile.am (xtestsuite, xcheck): New targets.
|
||||
|
||||
New test driver to allow for standalone regression tests.
|
||||
+ commit b142da4c88deef4798ef96061dac399df3ddd73d
|
||||
* tests/testdrv.c: New.
|
||||
|
||||
2021-02-03 Jussi Kivilinna <jussi.kivilinna@iki.fi>
|
||||
|
||||
sha256-avx2: fix reading beyond end of input buffer.
|
||||
+ commit 24af2a55d862d45fe3aef6b5626a52d9bb0fb17e
|
||||
* cipher/sha256-avx2-bmi2-amd64.S
|
||||
(_gcry_sha256_transform_amd64_avx2): Use 'last block' code path if
|
||||
input length is only one block.
|
||||
* tests/basic.c (check_one_md_final): Use dynamic allocated buffer
|
||||
so that in future similar access errors get detected by
|
||||
tests/basic + valgrind.
|
||||
|
||||
ecc-ecdh: fix memory leak.
|
||||
+ commit 289543544e41cd5fe90352c5c7548ac09da533cc
|
||||
* cipher/ecc-ecdh.c (_gcry_ecc_mul_point): Free 'ec' at function exit.
|
||||
|
||||
tests: allow running 'make check' with ASAN.
|
||||
+ commit f46a6bd9b3d7ef7d1a72c5b6da5cf34ace2ff156
|
||||
* tests/t-secmem.c (main): Skip test if environment variable
|
||||
GCRYPT_IN_ASAN_TEST is defined.
|
||||
* tests/t-sexp.c (main): Do not initialize secmem if environment
|
||||
variable GCRYPT_IN_ASAN_TEST is defined.
|
||||
|
||||
global: make sure that bulk config string is null-terminated.
|
||||
+ commit 8716e4b2ada21456802aee67c2bc8edfec78f820
|
||||
* src/global.c (_gcry_get_config): Append null-terminator to output
|
||||
in the 'what == NULL' case.
|
||||
|
||||
Add handling for -Og with O-flag munging.
|
||||
+ commit a71b7de32b0c7c41359335a488cfe4dd70c65121
|
||||
* cipher/Makefile.am (o_flag_munging): Add handling for '-Og'.
|
||||
* random/Makefile.am (o_flag_munging): Add handling for '-Og'.
|
||||
|
||||
jent: silence ubsan warning about signed overflow.
|
||||
+ commit 6fc11291282a668839040c72a1d558a6ebbd4972
|
||||
* random/jitterentropy-base.c (jent_stuck): Cast 'delta2' values to
|
||||
'uint64_t' for calculation.
|
||||
|
||||
Fix ubsan warnings for i386 build.
|
||||
+ commit 364e9e9d10503b36f98fbb1b489e00026f22c9d7
|
||||
* mpi/mpicoder.c (_gcry_mpi_set_buffer) [BYTES_PER_MPI_LIMB == 4]: Cast
|
||||
"*p--" values to mpi_limb_t before left shifting.
|
||||
* tests/t-lock.c (main): Cast 'time(NULL)' to unsigned type.
|
||||
|
||||
Fix building with --disable-asm on x86.
|
||||
+ commit af23ab5c5482d625ff52e60606cf044e2b0106c8
|
||||
* cipher/keccak.c (USE_64BIT_BMI2, USE_64BIT_SHLD)
|
||||
(USE_32BIT_BMI2): Depend also on HAVE_CPU_ARCH_X86.
|
||||
* random/rndjent.c [__i386__ || __x86_64__] (USE_JENT): Depend
|
||||
also on HAVE_CPU_ARCH_X86.
|
||||
|
||||
md: clear bctx.count at final function.
|
||||
+ commit cb95fc53003e9f34ff80fc33627ceda605de223c
|
||||
* cipher/md4.c (md4_final): Set bctx.count zero after
|
||||
finalizing.
|
||||
* cipher/md5.c (md5_final): Ditto.
|
||||
* cipher/rmd160.c (rmd160_final): Ditto.
|
||||
* cipher/sha1.c (sha1_final): Ditto.
|
||||
* cipher/sha256.c (sha256_final): Ditto.
|
||||
* cipher/sha512.c (sha512_final): Ditto.
|
||||
* cipher/sm3.c (sm3_final): Ditto.
|
||||
* cipher/stribog.c (stribog_final): Ditto.
|
||||
* cipher/tiger.c (tiger_final): Ditto.
|
||||
|
||||
2021-02-02 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
ecc: Add checking key for ECDSA.
|
||||
+ commit 598d0f3e0294a487e01b88cc714a8cd0a47329bb
|
||||
* cipher/ecc-ecdsa.c (_gcry_ecc_ecdsa_verify): Validate public key.
|
||||
* cipher/ecc-gost.c (_gcry_ecc_gost_verify): Likewise.
|
||||
* cipher/ecc-sm2.c (_gcry_ecc_sm2_verify): Likewise.
|
||||
|
||||
2021-01-29 Werner Koch <wk@gnupg.org>
|
||||
|
||||
Release 1.9.1.
|
||||
|
|
|
@ -151,7 +151,7 @@ sign-release:
|
|||
cat "../$(RELEASE_NAME).buildlog" swdb.snippet \
|
||||
| gzip >$(RELEASE_NAME).buildlog ;\
|
||||
echo "Copying to archive $$myarchive ..." ;\
|
||||
scp -vp $${files1} $${files2} $${myarchive}/ || true;\
|
||||
scp -p $${files1} $${files2} $${myarchive}/ || true;\
|
||||
echo '/*' ;\
|
||||
echo ' * All done; for checksums see dist/swdb.snippet' ;\
|
||||
echo ' */' ;\
|
||||
|
|
|
@ -1008,7 +1008,7 @@ sign-release:
|
|||
cat "../$(RELEASE_NAME).buildlog" swdb.snippet \
|
||||
| gzip >$(RELEASE_NAME).buildlog ;\
|
||||
echo "Copying to archive $$myarchive ..." ;\
|
||||
scp -vp $${files1} $${files2} $${myarchive}/ || true;\
|
||||
scp -p $${files1} $${files2} $${myarchive}/ || true;\
|
||||
echo '/*' ;\
|
||||
echo ' * All done; for checksums see dist/swdb.snippet' ;\
|
||||
echo ' */' ;\
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
Noteworthy changes in version 1.9.2 (2021-02-17) [C23/A3/R2]
|
||||
------------------------------------------------
|
||||
|
||||
* Bug fixes:
|
||||
|
||||
- Fix build problem for macOS in the random code. [#5268]
|
||||
|
||||
- Fix building with --disable-asm on x86. [#5277]
|
||||
|
||||
- Check public key for ECDSA verify operation. [#5282]
|
||||
|
||||
- Make sure gcry_get_config (NULL) returns a nul-terminated string.
|
||||
[8716e4b2ad]
|
||||
|
||||
- Fix a memory leak in the ECDH code. [289543544e]
|
||||
|
||||
- Fix a reading beyond end of input buffer in SHA2-avx2.
|
||||
[24af2a55d8]
|
||||
|
||||
* Other features:
|
||||
|
||||
- New test driver to allow for standalone regression
|
||||
tests. [b142da4c88]
|
||||
|
||||
Release-info: https://dev.gnupg.org/T5276
|
||||
|
||||
|
||||
Noteworthy changes in version 1.9.1 (2021-01-29) [C23/A3/R1]
|
||||
------------------------------------------------
|
||||
|
||||
|
@ -39,7 +66,7 @@ Noteworthy changes in version 1.9.1 (2021-01-29) [C23/A3/R1]
|
|||
|
||||
- Add optimized cipher and hash functions for s390x/zSeries.
|
||||
|
||||
- Use hardware bit counting functionx when available.
|
||||
- Use hardware bit counting functions when available.
|
||||
|
||||
* Internal changes:
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.9.1
|
||||
1.9.2
|
||||
|
|
|
@ -147,7 +147,7 @@ gost-s-box: gost-s-box.c
|
|||
|
||||
|
||||
if ENABLE_O_FLAG_MUNGING
|
||||
o_flag_munging = sed -e 's/-O\([2-9s][2-9s]*\)/-O1/' -e 's/-Ofast/-O1/g'
|
||||
o_flag_munging = sed -e 's/-O\([2-9sg][2-9sg]*\)/-O1/' -e 's/-Ofast/-O1/g'
|
||||
else
|
||||
o_flag_munging = cat
|
||||
endif
|
||||
|
|
|
@ -581,7 +581,7 @@ EXTRA_libcipher_la_SOURCES = \
|
|||
blake2b-amd64-avx2.S blake2s-amd64-avx.S
|
||||
|
||||
@ENABLE_O_FLAG_MUNGING_FALSE@o_flag_munging = cat
|
||||
@ENABLE_O_FLAG_MUNGING_TRUE@o_flag_munging = sed -e 's/-O\([2-9s][2-9s]*\)/-O1/' -e 's/-Ofast/-O1/g'
|
||||
@ENABLE_O_FLAG_MUNGING_TRUE@o_flag_munging = sed -e 's/-O\([2-9sg][2-9sg]*\)/-O1/' -e 's/-Ofast/-O1/g'
|
||||
@ENABLE_INSTRUMENTATION_MUNGING_FALSE@instrumentation_munging = cat
|
||||
|
||||
# We need to disable instrumentation for these modules as they use cc as
|
||||
|
|
|
@ -122,5 +122,6 @@ _gcry_ecc_mul_point (int curveid, unsigned char *result,
|
|||
_gcry_mpi_release (x);
|
||||
point_free (&Q);
|
||||
_gcry_mpi_release (mpi_k);
|
||||
_gcry_mpi_ec_free (ec);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,9 @@ _gcry_ecc_ecdsa_verify (gcry_mpi_t input, mpi_ec_t ec,
|
|||
mpi_point_struct Q, Q1, Q2;
|
||||
unsigned int nbits;
|
||||
|
||||
if (!_gcry_mpi_ec_curve_point (ec->Q, ec))
|
||||
return GPG_ERR_BROKEN_PUBKEY;
|
||||
|
||||
if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, ec->n) < 0) )
|
||||
return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */
|
||||
if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, ec->n) < 0) )
|
||||
|
|
|
@ -132,6 +132,9 @@ _gcry_ecc_gost_verify (gcry_mpi_t input, mpi_ec_t ec,
|
|||
gcry_mpi_t e, x, z1, z2, v, rv, zero;
|
||||
mpi_point_struct Q, Q1, Q2;
|
||||
|
||||
if (!_gcry_mpi_ec_curve_point (ec->Q, ec))
|
||||
return GPG_ERR_BROKEN_PUBKEY;
|
||||
|
||||
if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, ec->n) < 0) )
|
||||
return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */
|
||||
if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, ec->n) < 0) )
|
||||
|
|
|
@ -500,6 +500,9 @@ _gcry_ecc_sm2_verify (gcry_mpi_t input, mpi_ec_t ec,
|
|||
gcry_mpi_t x1, y1;
|
||||
unsigned int nbits;
|
||||
|
||||
if (!_gcry_mpi_ec_curve_point (ec->Q, ec))
|
||||
return GPG_ERR_BROKEN_PUBKEY;
|
||||
|
||||
/* r, s within [1, n-1] */
|
||||
if (mpi_cmp_ui (r, 1) < 0 || mpi_cmp (r, ec->n) > 0)
|
||||
return GPG_ERR_BAD_SIGNATURE;
|
||||
|
|
|
@ -40,21 +40,24 @@
|
|||
|
||||
/* USE_64BIT_BMI2 indicates whether to compile with 64-bit Intel BMI2 code. */
|
||||
#undef USE_64BIT_BMI2
|
||||
#if defined(USE_64BIT) && defined(HAVE_GCC_INLINE_ASM_BMI2)
|
||||
#if defined(USE_64BIT) && defined(HAVE_GCC_INLINE_ASM_BMI2) && \
|
||||
defined(HAVE_CPU_ARCH_X86)
|
||||
# define USE_64BIT_BMI2 1
|
||||
#endif
|
||||
|
||||
|
||||
/* USE_64BIT_SHLD indicates whether to compile with 64-bit Intel SHLD code. */
|
||||
#undef USE_64BIT_SHLD
|
||||
#if defined(USE_64BIT) && defined (__GNUC__) && defined(__x86_64__)
|
||||
#if defined(USE_64BIT) && defined (__GNUC__) && defined(__x86_64__) && \
|
||||
defined(HAVE_CPU_ARCH_X86)
|
||||
# define USE_64BIT_SHLD 1
|
||||
#endif
|
||||
|
||||
|
||||
/* USE_32BIT_BMI2 indicates whether to compile with 32-bit Intel BMI2 code. */
|
||||
#undef USE_32BIT_BMI2
|
||||
#if defined(USE_32BIT) && defined(HAVE_GCC_INLINE_ASM_BMI2)
|
||||
#if defined(USE_32BIT) && defined(HAVE_GCC_INLINE_ASM_BMI2) && \
|
||||
defined(HAVE_CPU_ARCH_X86)
|
||||
# define USE_32BIT_BMI2 1
|
||||
#endif
|
||||
|
||||
|
|
|
@ -237,7 +237,6 @@ md4_final( void *context )
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 56, lsb);
|
||||
|
@ -249,7 +248,6 @@ md4_final( void *context )
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 64 + 56, lsb);
|
||||
|
@ -265,6 +263,8 @@ md4_final( void *context )
|
|||
X(D);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,6 @@ md5_final( void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 56, lsb);
|
||||
|
@ -273,7 +272,6 @@ md5_final( void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 64 + 56, lsb);
|
||||
|
@ -289,6 +287,8 @@ md5_final( void *context)
|
|||
X(D);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -434,7 +434,6 @@ rmd160_final( void *context )
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 56, lsb);
|
||||
|
@ -446,7 +445,6 @@ rmd160_final( void *context )
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 64 + 56, lsb);
|
||||
|
@ -463,6 +461,8 @@ rmd160_final( void *context )
|
|||
X(4);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,6 @@ sha1_final(void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_be32(hd->bctx.buf + 56, msb);
|
||||
|
@ -603,7 +602,6 @@ sha1_final(void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_be32(hd->bctx.buf + 64 + 56, msb);
|
||||
|
@ -620,6 +618,8 @@ sha1_final(void *context)
|
|||
X(4);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -285,6 +285,11 @@ _gcry_sha256_transform_amd64_avx2:
|
|||
lea NUM_BLKS, [NUM_BLKS + INP - 64] /* pointer to last block */
|
||||
mov [rsp + _INP_END], NUM_BLKS
|
||||
|
||||
/* Check if only one block of input. Note: Loading initial digest
|
||||
* only uses 'mov' instruction and does not change condition
|
||||
* flags. */
|
||||
cmp NUM_BLKS, INP
|
||||
|
||||
/* ; load initial digest */
|
||||
mov a,[4*0 + CTX]
|
||||
mov b,[4*1 + CTX]
|
||||
|
@ -297,6 +302,8 @@ _gcry_sha256_transform_amd64_avx2:
|
|||
|
||||
mov [rsp + _CTX], CTX
|
||||
|
||||
je .Ldo_last_block
|
||||
|
||||
.Loop0:
|
||||
lea TBL, [.LK256 ADD_RIP]
|
||||
|
||||
|
|
|
@ -584,7 +584,6 @@ sha256_final(void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_be32(hd->bctx.buf + 56, msb);
|
||||
|
@ -596,7 +595,6 @@ sha256_final(void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_be32(hd->bctx.buf + 64 + 56, msb);
|
||||
|
@ -616,6 +614,8 @@ sha256_final(void *context)
|
|||
X(7);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -818,7 +818,6 @@ sha512_final (void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 112)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 112 - hd->bctx.count);
|
||||
hd->bctx.count = 112;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -850,6 +849,8 @@ sha512_final (void *context)
|
|||
X (7);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -294,7 +294,6 @@ sm3_final(void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_be32(hd->bctx.buf + 56, msb);
|
||||
|
@ -306,7 +305,6 @@ sm3_final(void *context)
|
|||
hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_be32(hd->bctx.buf + 64 + 56, msb);
|
||||
|
@ -326,6 +324,8 @@ sm3_final(void *context)
|
|||
X(7);
|
||||
#undef X
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -1304,6 +1304,8 @@ stribog_final (void *context)
|
|||
for (i = 0; i < 8; i++)
|
||||
hd->h[i] = le_bswap64(hd->h[i]);
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (768);
|
||||
}
|
||||
|
||||
|
|
|
@ -760,7 +760,7 @@ tiger_final( void *context )
|
|||
hd->bctx.buf[hd->bctx.count++] = pad;
|
||||
if (hd->bctx.count < 56)
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
|
||||
hd->bctx.count = 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 56, lsb);
|
||||
buf_put_le32(hd->bctx.buf + 60, msb);
|
||||
|
@ -771,7 +771,6 @@ tiger_final( void *context )
|
|||
hd->bctx.buf[hd->bctx.count++] = pad; /* pad character */
|
||||
/* fill pad and next block with zeroes */
|
||||
memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
|
||||
hd->bctx.count = 64 + 56;
|
||||
|
||||
/* append the 64 bit count */
|
||||
buf_put_le32(hd->bctx.buf + 64 + 56, lsb);
|
||||
|
@ -797,6 +796,8 @@ tiger_final( void *context )
|
|||
#undef X
|
||||
#undef Y
|
||||
|
||||
hd->bctx.count = 0;
|
||||
|
||||
_gcry_burn_stack (burn);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
# From configure.ac Revision.
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for libgcrypt 1.9.1.
|
||||
# Generated by GNU Autoconf 2.69 for libgcrypt 1.9.2.
|
||||
#
|
||||
# Report bugs to <https://bugs.gnupg.org>.
|
||||
#
|
||||
|
@ -591,8 +591,8 @@ MAKEFLAGS=
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='libgcrypt'
|
||||
PACKAGE_TARNAME='libgcrypt'
|
||||
PACKAGE_VERSION='1.9.1'
|
||||
PACKAGE_STRING='libgcrypt 1.9.1'
|
||||
PACKAGE_VERSION='1.9.2'
|
||||
PACKAGE_STRING='libgcrypt 1.9.2'
|
||||
PACKAGE_BUGREPORT='https://bugs.gnupg.org'
|
||||
PACKAGE_URL=''
|
||||
|
||||
|
@ -1475,7 +1475,7 @@ if test "$ac_init_help" = "long"; then
|
|||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures libgcrypt 1.9.1 to adapt to many kinds of systems.
|
||||
\`configure' configures libgcrypt 1.9.2 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
|
@ -1546,7 +1546,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of libgcrypt 1.9.1:";;
|
||||
short | recursive ) echo "Configuration of libgcrypt 1.9.2:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -1723,7 +1723,7 @@ fi
|
|||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
libgcrypt configure 1.9.1
|
||||
libgcrypt configure 1.9.2
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
@ -2329,7 +2329,7 @@ cat >config.log <<_ACEOF
|
|||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by libgcrypt $as_me 1.9.1, which was
|
||||
It was created by libgcrypt $as_me 1.9.2, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
@ -2690,7 +2690,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
|||
# (No interfaces changed: REVISION++)
|
||||
LIBGCRYPT_LT_CURRENT=23
|
||||
LIBGCRYPT_LT_AGE=3
|
||||
LIBGCRYPT_LT_REVISION=1
|
||||
LIBGCRYPT_LT_REVISION=2
|
||||
################################################
|
||||
|
||||
|
||||
|
@ -3223,7 +3223,7 @@ fi
|
|||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='libgcrypt'
|
||||
VERSION='1.9.1'
|
||||
VERSION='1.9.2'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
|
@ -5277,7 +5277,7 @@ rm -f core conftest.err conftest.$ac_objext \
|
|||
esac
|
||||
|
||||
|
||||
VERSION_NUMBER=0x010901
|
||||
VERSION_NUMBER=0x010902
|
||||
|
||||
|
||||
# We need to compile and run a program on the build machine.
|
||||
|
@ -19827,7 +19827,7 @@ fi
|
|||
#
|
||||
# Provide information about the build.
|
||||
#
|
||||
BUILD_REVISION="466299b1"
|
||||
BUILD_REVISION="24bd7e82"
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
|
@ -19836,7 +19836,7 @@ _ACEOF
|
|||
|
||||
|
||||
BUILD_VERSION=`echo "$PACKAGE_VERSION" | sed 's/\([0-9.]*\).*/\1./'`
|
||||
BUILD_VERSION="${BUILD_VERSION}18018"
|
||||
BUILD_VERSION="${BUILD_VERSION}9405"
|
||||
BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,`
|
||||
|
||||
|
||||
|
@ -20514,7 +20514,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by libgcrypt $as_me 1.9.1, which was
|
||||
This file was extended by libgcrypt $as_me 1.9.2, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -20584,7 +20584,7 @@ _ACEOF
|
|||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
libgcrypt config.status 1.9.1
|
||||
libgcrypt config.status 1.9.2
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ min_automake_version="1.14"
|
|||
m4_define([mym4_package],[libgcrypt])
|
||||
m4_define([mym4_major], [1])
|
||||
m4_define([mym4_minor], [9])
|
||||
m4_define([mym4_micro], [1])
|
||||
m4_define([mym4_micro], [2])
|
||||
|
||||
# Below is m4 magic to extract and compute the git revision number,
|
||||
# the decimalized short revision number, a beta version string and a
|
||||
|
@ -57,7 +57,7 @@ AC_INIT([mym4_package],[mym4_version],[https://bugs.gnupg.org])
|
|||
# (No interfaces changed: REVISION++)
|
||||
LIBGCRYPT_LT_CURRENT=23
|
||||
LIBGCRYPT_LT_AGE=3
|
||||
LIBGCRYPT_LT_REVISION=1
|
||||
LIBGCRYPT_LT_REVISION=2
|
||||
################################################
|
||||
|
||||
AC_SUBST(LIBGCRYPT_LT_CURRENT)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%!PS-Adobe-3.0 EPSF-3.0
|
||||
%%Title: /home/wk/s/libgcrypt/doc/fips-fsm.fig
|
||||
%%Creator: fig2dev Version 3.2.7a
|
||||
%%CreationDate: 2021-01-29 10:58:47
|
||||
%%CreationDate: 2021-02-17 09:16:49
|
||||
%%BoundingBox: 0 0 497 579
|
||||
%%Magnification: 1.0000
|
||||
%%EndComments
|
||||
|
|
Двоичный файл не отображается.
|
@ -1,6 +1,6 @@
|
|||
This is gcrypt.info, produced by makeinfo version 6.5 from gcrypt.texi.
|
||||
|
||||
This manual is for Libgcrypt version 1.9.1 and was last updated 28
|
||||
This manual is for Libgcrypt version 1.9.2 and was last updated 28
|
||||
January 2021. Libgcrypt is GNU's library of cryptographic building
|
||||
blocks.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
This is gcrypt.info, produced by makeinfo version 6.5 from gcrypt.texi.
|
||||
|
||||
This manual is for Libgcrypt version 1.9.1 and was last updated 28
|
||||
This manual is for Libgcrypt version 1.9.2 and was last updated 28
|
||||
January 2021. Libgcrypt is GNU's library of cryptographic building
|
||||
blocks.
|
||||
|
||||
|
@ -25,7 +25,7 @@ File: gcrypt.info, Node: Top, Next: Introduction, Up: (dir)
|
|||
The Libgcrypt Library
|
||||
*********************
|
||||
|
||||
This manual is for Libgcrypt version 1.9.1 and was last updated 28
|
||||
This manual is for Libgcrypt version 1.9.2 and was last updated 28
|
||||
January 2021. Libgcrypt is GNU's library of cryptographic building
|
||||
blocks.
|
||||
|
||||
|
|
Двоичный файл не отображается.
|
@ -1,7 +1,7 @@
|
|||
%!PS-Adobe-3.0 EPSF-3.0
|
||||
%%Title: /home/wk/s/libgcrypt/doc/libgcrypt-modules.fig
|
||||
%%Creator: fig2dev Version 3.2.7a
|
||||
%%CreationDate: 2021-01-29 10:58:47
|
||||
%%CreationDate: 2021-02-17 09:16:49
|
||||
%%BoundingBox: 0 0 488 300
|
||||
%%Magnification: 1.0000
|
||||
%%EndComments
|
||||
|
|
Двоичный файл не отображается.
|
@ -1,4 +1,4 @@
|
|||
@set UPDATED 28 January 2021
|
||||
@set UPDATED-MONTH January 2021
|
||||
@set EDITION 1.9.1
|
||||
@set VERSION 1.9.1
|
||||
@set EDITION 1.9.2
|
||||
@set VERSION 1.9.2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@set UPDATED 28 January 2021
|
||||
@set UPDATED-MONTH January 2021
|
||||
@set EDITION 1.9.1
|
||||
@set VERSION 1.9.1
|
||||
@set EDITION 1.9.2
|
||||
@set VERSION 1.9.2
|
||||
|
|
|
@ -354,10 +354,10 @@ _gcry_mpi_set_buffer (gcry_mpi_t a, const void *buffer_arg,
|
|||
for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; )
|
||||
{
|
||||
#if BYTES_PER_MPI_LIMB == 4
|
||||
alimb = *p-- ;
|
||||
alimb |= *p-- << 8 ;
|
||||
alimb |= *p-- << 16 ;
|
||||
alimb |= *p-- << 24 ;
|
||||
alimb = (mpi_limb_t)*p-- ;
|
||||
alimb |= (mpi_limb_t)*p-- << 8 ;
|
||||
alimb |= (mpi_limb_t)*p-- << 16 ;
|
||||
alimb |= (mpi_limb_t)*p-- << 24 ;
|
||||
#elif BYTES_PER_MPI_LIMB == 8
|
||||
alimb = (mpi_limb_t)*p-- ;
|
||||
alimb |= (mpi_limb_t)*p-- << 8 ;
|
||||
|
@ -375,13 +375,13 @@ _gcry_mpi_set_buffer (gcry_mpi_t a, const void *buffer_arg,
|
|||
if ( p >= buffer )
|
||||
{
|
||||
#if BYTES_PER_MPI_LIMB == 4
|
||||
alimb = *p--;
|
||||
alimb = (mpi_limb_t)*p--;
|
||||
if (p >= buffer)
|
||||
alimb |= *p-- << 8;
|
||||
alimb |= (mpi_limb_t)*p-- << 8;
|
||||
if (p >= buffer)
|
||||
alimb |= *p-- << 16;
|
||||
alimb |= (mpi_limb_t)*p-- << 16;
|
||||
if (p >= buffer)
|
||||
alimb |= *p-- << 24;
|
||||
alimb |= (mpi_limb_t)*p-- << 24;
|
||||
#elif BYTES_PER_MPI_LIMB == 8
|
||||
alimb = (mpi_limb_t)*p--;
|
||||
if (p >= buffer)
|
||||
|
|
|
@ -55,7 +55,7 @@ jitterentropy-base.c jitterentropy.h jitterentropy-base-user.h
|
|||
|
||||
# The rndjent module needs to be compiled without optimization. */
|
||||
if ENABLE_O_FLAG_MUNGING
|
||||
o_flag_munging = sed -e 's/-O\([1-9s][1-9s]*\)/-O0/g' -e 's/-Ofast/-O0/g'
|
||||
o_flag_munging = sed -e 's/-O\([1-9sg][1-9sg]*\)/-O0/g' -e 's/-Ofast/-O0/g'
|
||||
else
|
||||
o_flag_munging = cat
|
||||
endif
|
||||
|
|
|
@ -396,7 +396,7 @@ jitterentropy-base.c jitterentropy.h jitterentropy-base-user.h
|
|||
@ENABLE_O_FLAG_MUNGING_FALSE@o_flag_munging = cat
|
||||
|
||||
# The rndjent module needs to be compiled without optimization. */
|
||||
@ENABLE_O_FLAG_MUNGING_TRUE@o_flag_munging = sed -e 's/-O\([1-9s][1-9s]*\)/-O0/g' -e 's/-Ofast/-O0/g'
|
||||
@ENABLE_O_FLAG_MUNGING_TRUE@o_flag_munging = sed -e 's/-O\([1-9sg][1-9sg]*\)/-O0/g' -e 's/-Ofast/-O0/g'
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
|
|
@ -306,7 +306,7 @@ static unsigned int jent_memaccess(struct rand_data *ec, uint64_t loop_cnt)
|
|||
static int jent_stuck(struct rand_data *ec, uint64_t current_delta)
|
||||
{
|
||||
int64_t delta2 = ec->last_delta - current_delta;
|
||||
int64_t delta3 = delta2 - ec->last_delta2;
|
||||
int64_t delta3 = (uint64_t)delta2 - (uint64_t)ec->last_delta2;
|
||||
|
||||
ec->last_delta = current_delta;
|
||||
ec->last_delta2 = delta2;
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#define JENT_USES_GETTIME 2
|
||||
#define JENT_USES_READ_REAL_TIME 3
|
||||
#ifdef ENABLE_JENT_SUPPORT
|
||||
# if defined (__i386__) || defined(__x86_64__)
|
||||
# if (defined (__i386__) || defined(__x86_64__)) && defined(HAVE_CPU_ARCH_X86)
|
||||
# define USE_JENT JENT_USES_RDTSC
|
||||
# elif defined (HAVE_CLOCK_GETTIME)
|
||||
# if _AIX
|
||||
|
|
|
@ -33,9 +33,12 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#include <Availability.h>
|
||||
#ifdef __MAC_10_11
|
||||
extern int getentropy (void *buf, size_t buflen) __attribute__ ((weak_import));
|
||||
#define HAVE_GETENTROPY
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__linux__) || !defined(HAVE_GETENTROPY)
|
||||
#ifdef HAVE_SYSCALL
|
||||
# include <sys/syscall.h>
|
||||
|
|
|
@ -434,6 +434,13 @@ _gcry_get_config (int mode, const char *what)
|
|||
return NULL;
|
||||
|
||||
print_config (what, fp);
|
||||
|
||||
if (!what)
|
||||
{
|
||||
/* Null-terminate bulk output. */
|
||||
gpgrt_fwrite ("\0", 1, 1, fp);
|
||||
}
|
||||
|
||||
if (gpgrt_ferror (fp))
|
||||
{
|
||||
save_errno = errno;
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
# Note: Please keep these tests in sync with those in testdrv.c.
|
||||
# We will eventually switch over to the the new driver but as of now
|
||||
# the driver is only used for cross-compiling.
|
||||
tests_bin = \
|
||||
version t-secmem mpitests t-sexp t-convert \
|
||||
t-mpi-bit t-mpi-point curves t-lock \
|
||||
|
@ -52,10 +55,12 @@ standard_ldadd = \
|
|||
../compat/libcompat.la
|
||||
|
||||
EXTRA_PROGRAMS = testapi pkbench
|
||||
noinst_PROGRAMS = $(tests_bin) $(tests_bin_last) fipsdrv rsacvt genhashdata \
|
||||
gchash
|
||||
noinst_PROGRAMS = testdrv $(tests_bin) $(tests_bin_last) \
|
||||
fipsdrv rsacvt genhashdata gchash
|
||||
noinst_HEADERS = t-common.h
|
||||
|
||||
CLEANFILES = testdrv-build
|
||||
|
||||
EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \
|
||||
pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \
|
||||
t-ed25519.inp t-ed448.inp stopwatch.h hashtest-256g.in \
|
||||
|
@ -71,3 +76,38 @@ t_secmem_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
|
|||
testapi_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
|
||||
t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) @LDADD_FOR_TESTS_KLUDGE@
|
||||
t_lock_CFLAGS = $(GPG_ERROR_MT_CFLAGS)
|
||||
testdrv_LDADD = $(LDADD_FOR_TESTS_KLUDGE)
|
||||
|
||||
# Build a version of the test driver for the build platform.
|
||||
testdrv-build: testdrv.c
|
||||
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
|
||||
$(CPPFLAGS_FOR_BUILD) -DTESTDRV_EXEEXT=\"$(EXEEXT)\" \
|
||||
-o $@ $(srcdir)/testdrv.c
|
||||
|
||||
if HAVE_W32_SYSTEM
|
||||
xtestsuite_libs = ../src/.libs/libgcrypt-20.dll \
|
||||
$(prefix)/bin/libgpg-error*-0.dll
|
||||
xtestsuite_driver = .libs/testdrv.exe
|
||||
else
|
||||
xtestsuite_libs = ../src/.libs/libgcrypt.so*
|
||||
xtestsuite_driver = testdrv
|
||||
endif
|
||||
|
||||
# xcheck uses our new testdrv instead of the automake test runner.
|
||||
.PHONY: xcheck xtestsuite
|
||||
xcheck: testdrv$(EXEEXT)
|
||||
srcdir=$(srcdir) ./testdrv$(EXEEXT) --verbose
|
||||
|
||||
# Make a tarballs with all the tests.
|
||||
xtestsuite: testdrv$(EXEEXT) testdrv-build $(TESTS)
|
||||
+(set -e; \
|
||||
name="$(PACKAGE_TARNAME)-tests-$(PACKAGE_VERSION)";\
|
||||
xname="$$name/$(host)" ;\
|
||||
rm -rf $$name; mkdir $$name ; mkdir $$xname ;\
|
||||
cp -L $(xtestsuite_driver) \
|
||||
$$(srcdir=$(srcdir) ./testdrv-build --files|sort|uniq) $$xname/ ;\
|
||||
cp -P $(xtestsuite_libs) $$xname/ ;\
|
||||
touch $$xname/libgcrypt-standalone-tests ;\
|
||||
$(AMTAR) czf "$(PACKAGE_TARNAME)-tests-$(PACKAGE_VERSION)".tar.gz \
|
||||
$$name ;\
|
||||
)
|
||||
|
|
|
@ -109,8 +109,9 @@ build_triplet = @build@
|
|||
host_triplet = @host@
|
||||
TESTS = $(am__EXEEXT_1) $(tests_sh) $(am__EXEEXT_2) $(tests_sh_last)
|
||||
EXTRA_PROGRAMS = testapi$(EXEEXT) pkbench$(EXEEXT)
|
||||
noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) fipsdrv$(EXEEXT) \
|
||||
rsacvt$(EXEEXT) genhashdata$(EXEEXT) gchash$(EXEEXT)
|
||||
noinst_PROGRAMS = testdrv$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \
|
||||
fipsdrv$(EXEEXT) rsacvt$(EXEEXT) genhashdata$(EXEEXT) \
|
||||
gchash$(EXEEXT)
|
||||
subdir = tests
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cc_for_build.m4 \
|
||||
|
@ -272,6 +273,9 @@ t_x448_DEPENDENCIES = $(standard_ldadd) $(am__DEPENDENCIES_1)
|
|||
testapi_SOURCES = testapi.c
|
||||
testapi_OBJECTS = testapi.$(OBJEXT)
|
||||
testapi_DEPENDENCIES = $(standard_ldadd)
|
||||
testdrv_SOURCES = testdrv.c
|
||||
testdrv_OBJECTS = testdrv.$(OBJEXT)
|
||||
testdrv_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
version_SOURCES = version.c
|
||||
version_OBJECTS = version.$(OBJEXT)
|
||||
version_LDADD = $(LDADD)
|
||||
|
@ -307,7 +311,8 @@ am__depfiles_remade = ./$(DEPDIR)/aeswrap.Po ./$(DEPDIR)/basic.Po \
|
|||
./$(DEPDIR)/t-mpi-bit.Po ./$(DEPDIR)/t-mpi-point.Po \
|
||||
./$(DEPDIR)/t-secmem.Po ./$(DEPDIR)/t-sexp.Po \
|
||||
./$(DEPDIR)/t-x448.Po ./$(DEPDIR)/t_lock-t-lock.Po \
|
||||
./$(DEPDIR)/testapi.Po ./$(DEPDIR)/version.Po
|
||||
./$(DEPDIR)/testapi.Po ./$(DEPDIR)/testdrv.Po \
|
||||
./$(DEPDIR)/version.Po
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
|
@ -332,13 +337,15 @@ SOURCES = aeswrap.c basic.c bench-slope.c benchmark.c curves.c \
|
|||
hashtest.c hmac.c keygen.c keygrip.c mpitests.c pkbench.c \
|
||||
pkcs1v2.c prime.c pubkey.c random.c rsacvt.c t-convert.c \
|
||||
t-cv25519.c t-ed25519.c t-ed448.c t-kdf.c t-lock.c t-mpi-bit.c \
|
||||
t-mpi-point.c t-secmem.c t-sexp.c t-x448.c testapi.c version.c
|
||||
t-mpi-point.c t-secmem.c t-sexp.c t-x448.c testapi.c testdrv.c \
|
||||
version.c
|
||||
DIST_SOURCES = aeswrap.c basic.c bench-slope.c benchmark.c curves.c \
|
||||
dsa-rfc6979.c fips186-dsa.c fipsdrv.c gchash.c genhashdata.c \
|
||||
hashtest.c hmac.c keygen.c keygrip.c mpitests.c pkbench.c \
|
||||
pkcs1v2.c prime.c pubkey.c random.c rsacvt.c t-convert.c \
|
||||
t-cv25519.c t-ed25519.c t-ed448.c t-kdf.c t-lock.c t-mpi-bit.c \
|
||||
t-mpi-point.c t-secmem.c t-sexp.c t-x448.c testapi.c version.c
|
||||
t-mpi-point.c t-secmem.c t-sexp.c t-x448.c testapi.c testdrv.c \
|
||||
version.c
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
|
@ -555,6 +562,10 @@ target_alias = @target_alias@
|
|||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
# Note: Please keep these tests in sync with those in testdrv.c.
|
||||
# We will eventually switch over to the the new driver but as of now
|
||||
# the driver is only used for cross-compiling.
|
||||
tests_bin = \
|
||||
version t-secmem mpitests t-sexp t-convert \
|
||||
t-mpi-bit t-mpi-point curves t-lock \
|
||||
|
@ -577,6 +588,7 @@ standard_ldadd = \
|
|||
../compat/libcompat.la
|
||||
|
||||
noinst_HEADERS = t-common.h
|
||||
CLEANFILES = testdrv-build
|
||||
EXTRA_DIST = README rsa-16k.key cavs_tests.sh cavs_driver.pl \
|
||||
pkcs1v2-oaep.h pkcs1v2-pss.h pkcs1v2-v15c.h pkcs1v2-v15s.h \
|
||||
t-ed25519.inp t-ed448.inp stopwatch.h hashtest-256g.in \
|
||||
|
@ -592,6 +604,13 @@ t_secmem_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
|
|||
testapi_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
|
||||
t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) @LDADD_FOR_TESTS_KLUDGE@
|
||||
t_lock_CFLAGS = $(GPG_ERROR_MT_CFLAGS)
|
||||
testdrv_LDADD = $(LDADD_FOR_TESTS_KLUDGE)
|
||||
@HAVE_W32_SYSTEM_FALSE@xtestsuite_libs = ../src/.libs/libgcrypt.so*
|
||||
@HAVE_W32_SYSTEM_TRUE@xtestsuite_libs = ../src/.libs/libgcrypt-20.dll \
|
||||
@HAVE_W32_SYSTEM_TRUE@ $(prefix)/bin/libgpg-error*-0.dll
|
||||
|
||||
@HAVE_W32_SYSTEM_FALSE@xtestsuite_driver = testdrv
|
||||
@HAVE_W32_SYSTEM_TRUE@xtestsuite_driver = .libs/testdrv.exe
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
@ -771,6 +790,10 @@ testapi$(EXEEXT): $(testapi_OBJECTS) $(testapi_DEPENDENCIES) $(EXTRA_testapi_DEP
|
|||
@rm -f testapi$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(testapi_OBJECTS) $(testapi_LDADD) $(LIBS)
|
||||
|
||||
testdrv$(EXEEXT): $(testdrv_OBJECTS) $(testdrv_DEPENDENCIES) $(EXTRA_testdrv_DEPENDENCIES)
|
||||
@rm -f testdrv$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(testdrv_OBJECTS) $(testdrv_LDADD) $(LIBS)
|
||||
|
||||
version$(EXEEXT): $(version_OBJECTS) $(version_DEPENDENCIES) $(EXTRA_version_DEPENDENCIES)
|
||||
@rm -f version$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(version_OBJECTS) $(version_LDADD) $(LIBS)
|
||||
|
@ -814,6 +837,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-x448.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_lock-t-lock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testapi.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdrv.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
|
@ -1068,6 +1092,7 @@ install-strip:
|
|||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
@ -1115,6 +1140,7 @@ distclean: distclean-am
|
|||
-rm -f ./$(DEPDIR)/t-x448.Po
|
||||
-rm -f ./$(DEPDIR)/t_lock-t-lock.Po
|
||||
-rm -f ./$(DEPDIR)/testapi.Po
|
||||
-rm -f ./$(DEPDIR)/testdrv.Po
|
||||
-rm -f ./$(DEPDIR)/version.Po
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
|
@ -1194,6 +1220,7 @@ maintainer-clean: maintainer-clean-am
|
|||
-rm -f ./$(DEPDIR)/t-x448.Po
|
||||
-rm -f ./$(DEPDIR)/t_lock-t-lock.Po
|
||||
-rm -f ./$(DEPDIR)/testapi.Po
|
||||
-rm -f ./$(DEPDIR)/testdrv.Po
|
||||
-rm -f ./$(DEPDIR)/version.Po
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
@ -1236,6 +1263,31 @@ uninstall-am:
|
|||
bench-slope.log: benchmark.log
|
||||
hashtest-256g.log: bench-slope.log
|
||||
|
||||
# Build a version of the test driver for the build platform.
|
||||
testdrv-build: testdrv.c
|
||||
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
|
||||
$(CPPFLAGS_FOR_BUILD) -DTESTDRV_EXEEXT=\"$(EXEEXT)\" \
|
||||
-o $@ $(srcdir)/testdrv.c
|
||||
|
||||
# xcheck uses our new testdrv instead of the automake test runner.
|
||||
.PHONY: xcheck xtestsuite
|
||||
xcheck: testdrv$(EXEEXT)
|
||||
srcdir=$(srcdir) ./testdrv$(EXEEXT) --verbose
|
||||
|
||||
# Make a tarballs with all the tests.
|
||||
xtestsuite: testdrv$(EXEEXT) testdrv-build $(TESTS)
|
||||
+(set -e; \
|
||||
name="$(PACKAGE_TARNAME)-tests-$(PACKAGE_VERSION)";\
|
||||
xname="$$name/$(host)" ;\
|
||||
rm -rf $$name; mkdir $$name ; mkdir $$xname ;\
|
||||
cp -L $(xtestsuite_driver) \
|
||||
$$(srcdir=$(srcdir) ./testdrv-build --files|sort|uniq) $$xname/ ;\
|
||||
cp -P $(xtestsuite_libs) $$xname/ ;\
|
||||
touch $$xname/libgcrypt-standalone-tests ;\
|
||||
$(AMTAR) czf "$(PACKAGE_TARNAME)-tests-$(PACKAGE_VERSION)".tar.gz \
|
||||
$$name ;\
|
||||
)
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#if __GNUC__ >= 4
|
||||
# define ALWAYS_INLINE __attribute__((always_inline))
|
||||
#else
|
||||
# define ALWAYS_INLINE
|
||||
#endif
|
||||
|
||||
typedef struct test_spec_pubkey_key
|
||||
|
@ -10478,7 +10480,8 @@ check_one_md_multi (int algo, const char *data, int len, const char *expect)
|
|||
static void
|
||||
check_one_md_final(int algo, const char *expect, unsigned int expectlen)
|
||||
{
|
||||
char inbuf[288 + 1];
|
||||
const unsigned int max_inbuf_len = 288 + 1;
|
||||
char *inbuf;
|
||||
char xorbuf[64];
|
||||
char digest[64];
|
||||
unsigned int mdlen;
|
||||
|
@ -10499,16 +10502,25 @@ check_one_md_final(int algo, const char *expect, unsigned int expectlen)
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(inbuf); i++)
|
||||
inbuf[i] = i;
|
||||
|
||||
clutter_vector_registers();
|
||||
gcry_md_hash_buffer (algo, xorbuf, NULL, 0);
|
||||
for (i = 1; i < sizeof(inbuf); i++)
|
||||
for (i = 1; i < max_inbuf_len; i++)
|
||||
{
|
||||
inbuf = xmalloc(i);
|
||||
if (!inbuf)
|
||||
{
|
||||
fail ("out-of-memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
inbuf[j] = j;
|
||||
|
||||
gcry_md_hash_buffer (algo, digest, inbuf, i);
|
||||
for (j = 0; j < expectlen; j++)
|
||||
xorbuf[j] ^= digest[j];
|
||||
|
||||
xfree (inbuf);
|
||||
}
|
||||
|
||||
if (memcmp(expect, xorbuf, expectlen) != 0)
|
||||
|
|
|
@ -433,7 +433,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
srand (time(NULL)*getpid());
|
||||
srand ((unsigned int)time(NULL)*getpid());
|
||||
|
||||
if (debug)
|
||||
xgcry_control ((GCRYCTL_SET_DEBUG_FLAGS, 1u, 0));
|
||||
|
|
|
@ -120,6 +120,14 @@ main (int argc, char **argv)
|
|||
long int pgsize_val = -1;
|
||||
size_t pgsize;
|
||||
|
||||
if (getenv ("GCRYPT_IN_ASAN_TEST"))
|
||||
{
|
||||
/* 'mlock' is not available when build with address sanitizer,
|
||||
* so skip test. */
|
||||
fputs ("Note: " PGM " skipped because running with ASAN.\n", stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if HAVE_MMAP
|
||||
# if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
|
||||
pgsize_val = sysconf (_SC_PAGESIZE);
|
||||
|
|
|
@ -1312,7 +1312,14 @@ main (int argc, char **argv)
|
|||
if (debug)
|
||||
xgcry_control ((GCRYCTL_SET_DEBUG_FLAGS, 1u, 0));
|
||||
xgcry_control ((GCRYCTL_DISABLE_SECMEM_WARN));
|
||||
xgcry_control ((GCRYCTL_INIT_SECMEM, 16384, 0));
|
||||
if (getenv ("GCRYPT_IN_ASAN_TEST"))
|
||||
{
|
||||
fputs ("Note: " PGM " not using secmem as running with ASAN.\n", stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
xgcry_control ((GCRYCTL_INIT_SECMEM, 16384, 0));
|
||||
}
|
||||
if (!gcry_check_version (GCRYPT_VERSION))
|
||||
die ("version mismatch");
|
||||
/* #include "../src/gcrypt-int.h" indicates that internal interfaces
|
||||
|
|
|
@ -0,0 +1,888 @@
|
|||
/* testdrv.c - Test driver to run all tests w/o using the Makefile.
|
||||
* Copyright (C) 2021 g10 Code GmbH
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
#include <gpg-error.h> /* For some macros. */
|
||||
|
||||
#include "stopwatch.h"
|
||||
|
||||
#define PGM "testdrv"
|
||||
|
||||
/* Flags for testpgms. */
|
||||
#define LONG_RUNNING 1
|
||||
|
||||
/* This is our list of tests which are run in this order. */
|
||||
static struct {
|
||||
const char *name;
|
||||
const char *pgm;
|
||||
const char *args;
|
||||
unsigned int flags; /* e.g. LONG_RUNNING */
|
||||
} testpgms[] =
|
||||
{
|
||||
{ "version" },
|
||||
{ "t-secmem" },
|
||||
{ "mpitests" },
|
||||
{ "t-sexp" },
|
||||
{ "t-convert" },
|
||||
{ "t-mpi-bit" },
|
||||
{ "t-mpi-point" },
|
||||
{ "curves" },
|
||||
{ "t-lock" },
|
||||
{ "prime" },
|
||||
{ "basic" },
|
||||
{ "basic-disable-all-hwf", "basic", "--disable-hwf all" },
|
||||
{ "keygen" },
|
||||
{ "pubkey" },
|
||||
{ "hmac" },
|
||||
{ "hashtest" },
|
||||
{ "t-kdf" },
|
||||
{ "keygrip" },
|
||||
{ "fips186-dsa" },
|
||||
{ "aeswrap" },
|
||||
{ "pkcs1v2" },
|
||||
{ "random" },
|
||||
{ "dsa-rfc6979" },
|
||||
{ "t-ed25519" },
|
||||
{ "t-cv25519" },
|
||||
{ "t-x448" },
|
||||
{ "t-ed448" },
|
||||
{ "benchmark" },
|
||||
{ "bench-slope" },
|
||||
{ "hashtest-256g", "hashtest", "--gigs 256 SHA1 SHA256 SHA512 SM3",
|
||||
LONG_RUNNING },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* Extra files needed for the above tests. */
|
||||
static const char *extratestfiles[] =
|
||||
{
|
||||
"t-ed25519.inp",
|
||||
"t-ed448.inp",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* A couple of useful macros. */
|
||||
#ifndef DIM
|
||||
# define DIM(v) (sizeof(v)/sizeof((v)[0]))
|
||||
#endif
|
||||
#define DIMof(type,member) DIM(((type *)0)->member)
|
||||
#define xfree(a) free ((a))
|
||||
#define spacep(p) (*(p) == ' ' || *(p) == '\t')
|
||||
|
||||
/* If we have a decent libgpg-error we can use some gcc attributes. */
|
||||
#ifdef GPGRT_ATTR_NORETURN
|
||||
static void die (const char *format, ...)
|
||||
GPGRT_ATTR_UNUSED GPGRT_ATTR_NR_PRINTF(1,2);
|
||||
static void fail (const char *format, ...)
|
||||
GPGRT_ATTR_UNUSED GPGRT_ATTR_PRINTF(1,2);
|
||||
static void info (const char *format, ...) \
|
||||
GPGRT_ATTR_UNUSED GPGRT_ATTR_PRINTF(1,2);
|
||||
static void printresult (const char *format, ...) \
|
||||
GPGRT_ATTR_UNUSED GPGRT_ATTR_PRINTF(1,2);
|
||||
#endif /*GPGRT_ATTR_NORETURN*/
|
||||
|
||||
|
||||
#ifndef TESTDRV_EXEEXT
|
||||
# ifdef HAVE_W32_SYSTEM
|
||||
# define TESTDRV_EXEEXT ".exe"
|
||||
# else
|
||||
# define TESTDRV_EXEEXT ""
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
# define MYPID_T HANDLE
|
||||
# define MYINVALID_PID INVALID_HANDLE_VALUE
|
||||
#else
|
||||
# define MYPID_T pid_t
|
||||
# define MYINVALID_PID ((pid_t)(-1))
|
||||
#endif
|
||||
|
||||
/* Standard global variables. */
|
||||
static int verbose;
|
||||
static int debug;
|
||||
static int error_count;
|
||||
static int die_on_error;
|
||||
static int long_running;
|
||||
static char **myenviron;
|
||||
static int testcount, failcount, passcount, skipcount;
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
static char *
|
||||
my_stpcpy (char *a, const char *b)
|
||||
{
|
||||
while (*b)
|
||||
*a++ = *b++;
|
||||
*a = 0;
|
||||
|
||||
return a;
|
||||
}
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
/* Reporting functions. */
|
||||
static void
|
||||
die (const char *format, ...)
|
||||
{
|
||||
va_list arg_ptr ;
|
||||
|
||||
/* Avoid warning. */
|
||||
(void) debug;
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
flockfile (stderr);
|
||||
#endif
|
||||
fprintf (stderr, "%s: ", PGM);
|
||||
va_start (arg_ptr, format) ;
|
||||
vfprintf (stderr, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
if (*format && format[strlen(format)-1] != '\n')
|
||||
putc ('\n', stderr);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
funlockfile (stderr);
|
||||
#endif
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void *
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
char *p = malloc (n);
|
||||
if (!p)
|
||||
die ("malloc failed");
|
||||
return p;
|
||||
}
|
||||
|
||||
static void *
|
||||
xcalloc (size_t n, size_t m)
|
||||
{
|
||||
char *p = calloc (n, m);
|
||||
if (!p)
|
||||
die ("calloc failed");
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *
|
||||
xstrdup (const char *s)
|
||||
{
|
||||
size_t n = strlen (s);
|
||||
char *p = xmalloc (n+1);
|
||||
strcpy (p, s);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fail (const char *format, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
flockfile (stderr);
|
||||
#endif
|
||||
fprintf (stderr, "%s: ", PGM);
|
||||
va_start (arg_ptr, format);
|
||||
vfprintf (stderr, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
if (*format && format[strlen(format)-1] != '\n')
|
||||
putc ('\n', stderr);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
funlockfile (stderr);
|
||||
#endif
|
||||
if (die_on_error)
|
||||
exit (1);
|
||||
error_count++;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
info (const char *format, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
|
||||
if (!verbose)
|
||||
return;
|
||||
fflush (stdout);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
flockfile (stderr);
|
||||
#endif
|
||||
fprintf (stderr, "%s: ", PGM);
|
||||
va_start (arg_ptr, format);
|
||||
vfprintf (stderr, format, arg_ptr);
|
||||
if (*format && format[strlen(format)-1] != '\n')
|
||||
putc ('\n', stderr);
|
||||
va_end (arg_ptr);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
funlockfile (stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
printresult (const char *format, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
flockfile (stdout);
|
||||
#endif
|
||||
va_start (arg_ptr, format);
|
||||
vfprintf (stdout, format, arg_ptr);
|
||||
if (*format && format[strlen(format)-1] != '\n')
|
||||
putc ('\n', stdout);
|
||||
va_end (arg_ptr);
|
||||
fflush (stdout);
|
||||
#ifdef HAVE_FLOCKFILE
|
||||
funlockfile (stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Tokenize STRING using the set of delimiters in DELIM. Leading
|
||||
* spaces and tabs are removed from all tokens. The caller must free
|
||||
* the result. Returns a malloced and NULL delimited array with the
|
||||
* tokens. */
|
||||
static char **
|
||||
strtokenize (const char *string, const char *delim)
|
||||
{
|
||||
const char *s;
|
||||
size_t fields;
|
||||
size_t bytes, n;
|
||||
char *buffer;
|
||||
char *p, *px, *pend;
|
||||
char **result;
|
||||
|
||||
/* Count the number of fields. */
|
||||
for (fields = 1, s = strpbrk (string, delim); s; s = strpbrk (s + 1, delim))
|
||||
fields++;
|
||||
fields++; /* Add one for the terminating NULL. */
|
||||
|
||||
/* Allocate an array for all fields, a terminating NULL, and space
|
||||
for a copy of the string. */
|
||||
bytes = fields * sizeof *result;
|
||||
if (bytes / sizeof *result != fields)
|
||||
die ("integer overflow at %d\n", __LINE__);
|
||||
n = strlen (string) + 1;
|
||||
bytes += n;
|
||||
if (bytes < n)
|
||||
die ("integer overflow at %d\n", __LINE__);
|
||||
result = xmalloc (bytes);
|
||||
buffer = (char*)(result + fields);
|
||||
|
||||
/* Copy and parse the string. */
|
||||
strcpy (buffer, string);
|
||||
for (n = 0, p = buffer; (pend = strpbrk (p, delim)); p = pend + 1)
|
||||
{
|
||||
*pend = 0;
|
||||
while (spacep (p))
|
||||
p++;
|
||||
for (px = pend - 1; px >= p && spacep (px); px--)
|
||||
*px = 0;
|
||||
result[n++] = p;
|
||||
}
|
||||
while (spacep (p))
|
||||
p++;
|
||||
for (px = p + strlen (p) - 1; px >= p && spacep (px); px--)
|
||||
*px = 0;
|
||||
result[n++] = p;
|
||||
result[n] = NULL;
|
||||
|
||||
if (!((char*)(result + n + 1) == buffer))
|
||||
die ("bug at %d\n", __LINE__);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
/* Helper functions for Windows. */
|
||||
static char *
|
||||
build_w32_commandline_copy (char *buffer, const char *string)
|
||||
{
|
||||
char *p = buffer;
|
||||
const char *s;
|
||||
|
||||
if (!*string) /* Empty string. */
|
||||
p = my_stpcpy (p, "\"\"");
|
||||
else if (strpbrk (string, " \t\n\v\f\""))
|
||||
{
|
||||
/* Need to do some kind of quoting. */
|
||||
p = my_stpcpy (p, "\"");
|
||||
for (s=string; *s; s++)
|
||||
{
|
||||
*p++ = *s;
|
||||
if (*s == '\"')
|
||||
*p++ = *s;
|
||||
}
|
||||
*p++ = '\"';
|
||||
*p = 0;
|
||||
}
|
||||
else
|
||||
p = my_stpcpy (p, string);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Build a command line for use with CreateProcess. This function
|
||||
* either terminates the process or returns a malloced string. */
|
||||
static char *
|
||||
build_w32_commandline (const char *pgmname, char **argv)
|
||||
{
|
||||
int i, n;
|
||||
const char *s;
|
||||
char *buf, *p;
|
||||
|
||||
s = pgmname;
|
||||
n = strlen (s) + 1 + 2; /* (1 space, 2 quoting) */
|
||||
for (; *s; s++)
|
||||
if (*s == '\"')
|
||||
n++; /* Account for to be doubled inner quotes. */
|
||||
for (i=0; argv && (s=argv[i]); i++)
|
||||
{
|
||||
n += strlen (s) + 1 + 2; /* (1 space, 2 quoting) */
|
||||
for (; *s; s++)
|
||||
if (*s == '\"')
|
||||
n++; /* For doubling inner quotes. */
|
||||
}
|
||||
n++; /* String terminator. */
|
||||
|
||||
buf = p = xmalloc (n);
|
||||
p = build_w32_commandline_copy (p, pgmname);
|
||||
for (i=0; argv && argv[i]; i++)
|
||||
{
|
||||
*p++ = ' ';
|
||||
p = build_w32_commandline_copy (p, argv[i]);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static HANDLE
|
||||
w32_open_null (int for_write)
|
||||
{
|
||||
HANDLE hfile;
|
||||
|
||||
hfile = CreateFileW (L"nul",
|
||||
for_write? GENERIC_WRITE : GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hfile == INVALID_HANDLE_VALUE)
|
||||
die ("can't open 'nul': ec=%lu\n", (unsigned long)GetLastError());
|
||||
return hfile;
|
||||
}
|
||||
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
|
||||
|
||||
/* Fork and exec the PGMNAME using ARGV as arguments (w/o pgmmname)
|
||||
* and return the pid at PID. If ENVP is not NULL, add these strings
|
||||
* as environment variables. Return -1 on severe errors. */
|
||||
static int
|
||||
my_spawn (const char *pgmname, char **argv, char **envp, MYPID_T *pid)
|
||||
{
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
int rc;
|
||||
SECURITY_ATTRIBUTES sec_attr;
|
||||
PROCESS_INFORMATION pi = { NULL };
|
||||
STARTUPINFO si;
|
||||
char *cmdline;
|
||||
char *pgmnamefull = NULL;
|
||||
char **saveenviron = NULL;
|
||||
int i;
|
||||
|
||||
/* Prepare security attributes. */
|
||||
memset (&sec_attr, 0, sizeof sec_attr );
|
||||
sec_attr.nLength = sizeof sec_attr;
|
||||
sec_attr.bInheritHandle = FALSE;
|
||||
|
||||
if (!(strlen (pgmname) > 4 && !strcmp (pgmname+strlen(pgmname)-4, ".exe")))
|
||||
{
|
||||
pgmnamefull = xmalloc (strlen (pgmname) + 4 + 1);
|
||||
strcpy (my_stpcpy (pgmnamefull, pgmname), ".exe");
|
||||
pgmname = pgmnamefull;
|
||||
}
|
||||
|
||||
/* Build the command line. */
|
||||
cmdline = build_w32_commandline (pgmname, argv);
|
||||
|
||||
memset (&si, 0, sizeof si);
|
||||
si.cb = sizeof (si);
|
||||
si.dwFlags = STARTF_USESTDHANDLES;
|
||||
si.hStdInput = w32_open_null (0);
|
||||
if (verbose)
|
||||
si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||
else
|
||||
si.hStdOutput = w32_open_null (1);
|
||||
si.hStdError = GetStdHandle (STD_ERROR_HANDLE);
|
||||
|
||||
if (envp)
|
||||
{
|
||||
for (i=0; envp[i]; i++)
|
||||
;
|
||||
saveenviron = xcalloc (i+1, sizeof *saveenviron);
|
||||
for (i=0; envp[i]; i++)
|
||||
saveenviron[i] = xstrdup (envp[i]);
|
||||
for (i=0; envp[i]; i++)
|
||||
putenv (envp[i]);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
info ("CreateProcess, path='%s' cmdline='%s'\n", pgmname, cmdline);
|
||||
if (!CreateProcess (pgmname, /* Program to start. */
|
||||
cmdline, /* Command line arguments. */
|
||||
&sec_attr, /* Process security attributes. */
|
||||
&sec_attr, /* Thread security attributes. */
|
||||
TRUE, /* Inherit handles. */
|
||||
(CREATE_DEFAULT_ERROR_MODE
|
||||
| GetPriorityClass (GetCurrentProcess ())
|
||||
| CREATE_SUSPENDED | DETACHED_PROCESS),
|
||||
NULL, /* Environment. */
|
||||
NULL, /* Use current drive/directory. */
|
||||
&si, /* Startup information. */
|
||||
&pi /* Returns process information. */
|
||||
))
|
||||
{
|
||||
fail ("CreateProcess failed: ec=%lu\n", (unsigned long)GetLastError());
|
||||
rc = -1;
|
||||
}
|
||||
else
|
||||
rc = 0;
|
||||
|
||||
if (saveenviron)
|
||||
{
|
||||
for (i=0; saveenviron[i]; i++)
|
||||
xfree (saveenviron[i]);
|
||||
xfree (saveenviron);
|
||||
}
|
||||
xfree (cmdline);
|
||||
CloseHandle (si.hStdInput);
|
||||
if (!verbose)
|
||||
CloseHandle (si.hStdOutput);
|
||||
xfree (pgmnamefull); pgmname = NULL;
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (debug)
|
||||
info ("CreateProcess ready: hProcess=%p hThread=%p"
|
||||
" dwProcessID=%d dwThreadId=%d\n",
|
||||
pi.hProcess, pi.hThread,
|
||||
(int) pi.dwProcessId, (int) pi.dwThreadId);
|
||||
|
||||
/* Process has been created suspended; resume it now. */
|
||||
ResumeThread (pi.hThread);
|
||||
CloseHandle (pi.hThread);
|
||||
|
||||
*pid = pi.hProcess;
|
||||
return 0;
|
||||
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
|
||||
char **arg_list;
|
||||
int i, j;
|
||||
int fd;
|
||||
|
||||
/* Create the command line argument array. */
|
||||
i = 0;
|
||||
if (argv)
|
||||
while (argv[i])
|
||||
i++;
|
||||
arg_list = xcalloc (i+2, sizeof *arg_list);
|
||||
arg_list[0] = strrchr (pgmname, '/');
|
||||
if (arg_list[0])
|
||||
arg_list[0]++;
|
||||
else
|
||||
arg_list[0] = xstrdup (pgmname);
|
||||
if (argv)
|
||||
for (i=0,j=1; argv[i]; i++, j++)
|
||||
arg_list[j] = (char*)argv[i];
|
||||
|
||||
|
||||
*pid = fork ();
|
||||
if (*pid == MYINVALID_PID)
|
||||
{
|
||||
fail ("error forking process: %s\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!*pid)
|
||||
{
|
||||
/* This is the child. */
|
||||
if (envp)
|
||||
for (i=0; envp[i]; i++)
|
||||
putenv (xstrdup (envp[i]));
|
||||
|
||||
/* Assign /dev/null to stdin. */
|
||||
fd = open ("/dev/null", O_RDONLY);
|
||||
if (fd == -1)
|
||||
die ("failed to open '%s': %s\n", "/dev/null", strerror (errno));
|
||||
if (fd != 0 && dup2 (fd, 0) == -1)
|
||||
die ("dup2(%d,0) failed: %s\n", fd, strerror (errno));
|
||||
/* Assign /dev/null to stdout unless in verbose mode. */
|
||||
if (!verbose)
|
||||
{
|
||||
fd = open ("/dev/null", O_RDONLY);
|
||||
if (fd == -1)
|
||||
die ("failed to open '%s': %s\n", "/dev/null", strerror (errno));
|
||||
if (fd != 1 && dup2 (fd, 1) == -1)
|
||||
die ("dup2(%d,1) failed: %s\n", fd, strerror (errno));
|
||||
}
|
||||
|
||||
/* Exec the program. */
|
||||
execv (pgmname, arg_list);
|
||||
info ("exec '%s' failed: %s\n", pgmname, strerror (errno));
|
||||
_exit (127);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/* This is the parent. */
|
||||
xfree (arg_list);
|
||||
return 0;
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
}
|
||||
|
||||
|
||||
/* Wait for PID and return its exitcode at R_EXITCODE. PGMNAME is
|
||||
* only used for diagnostics. */
|
||||
static int
|
||||
my_wait (const char *pgmname, MYPID_T pid, int *r_exitcode)
|
||||
{
|
||||
int rc = -1;
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
HANDLE procs[1];
|
||||
DWORD exc;
|
||||
int code;
|
||||
|
||||
if (pid == MYINVALID_PID)
|
||||
die ("invalid pid passed to my_wait\n");
|
||||
|
||||
procs[0] = (HANDLE)pid;
|
||||
code = WaitForMultipleObjects (1, procs, TRUE, INFINITE);
|
||||
switch (code)
|
||||
{
|
||||
case WAIT_TIMEOUT: /* Should not happen. */
|
||||
fail ("waiting for process %p (%s) to terminate failed: timeout\n",
|
||||
pid, pgmname);
|
||||
break;
|
||||
|
||||
case WAIT_FAILED:
|
||||
fail ("waiting for process %p (%s) to terminate failed: ec=%lu\n",
|
||||
pid, pgmname, (unsigned long)GetLastError ());
|
||||
break;
|
||||
|
||||
case WAIT_OBJECT_0:
|
||||
if (!GetExitCodeProcess (procs[0], &exc))
|
||||
{
|
||||
fail ("error getting exit code for process %p (%s): ec=%lu\n",
|
||||
pid, pgmname, (unsigned long)GetLastError ());
|
||||
}
|
||||
else
|
||||
{
|
||||
*r_exitcode = (int)exc;
|
||||
rc = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fail ("WaitForMultipleObjects returned unexpected code %d\n", code);
|
||||
break;
|
||||
}
|
||||
CloseHandle ((HANDLE)pid);
|
||||
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
|
||||
int i, status;
|
||||
|
||||
if (pid == MYINVALID_PID)
|
||||
die ("invalid pid passed to my_wait\n");
|
||||
|
||||
while ((i=waitpid (pid, &status, 0)) == MYINVALID_PID
|
||||
&& errno == EINTR)
|
||||
;
|
||||
|
||||
if (i == MYINVALID_PID)
|
||||
{
|
||||
fail ("waiting for process %d (%s) to terminate failed: %s\n",
|
||||
(int)pid, pgmname, strerror (errno));
|
||||
}
|
||||
else if (!i)
|
||||
{
|
||||
die ("waitpid returns unexpected code 0\n");
|
||||
}
|
||||
else if (WIFEXITED (status) && WEXITSTATUS (status) == 127)
|
||||
{
|
||||
fail ("error running '%s': probably not installed\n", pgmname);
|
||||
}
|
||||
else if (WIFEXITED (status) && WEXITSTATUS (status))
|
||||
{
|
||||
*r_exitcode = WEXITSTATUS (status);
|
||||
rc = 0;
|
||||
}
|
||||
else if (!WIFEXITED (status))
|
||||
{
|
||||
info ("error running '%s': terminated\n", pgmname);
|
||||
rc = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*r_exitcode = 0;
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
run_one_test (int idx)
|
||||
{
|
||||
MYPID_T pid;
|
||||
int exitcode, rc;
|
||||
const char *name = testpgms[idx].name;
|
||||
const char *pgm = testpgms[idx].pgm;
|
||||
char **args;
|
||||
|
||||
if (!pgm)
|
||||
pgm = name;
|
||||
|
||||
testcount++;
|
||||
if ((testpgms[idx].flags & LONG_RUNNING)
|
||||
&& !long_running)
|
||||
{
|
||||
printresult ("SKIP: %s\n", name);
|
||||
skipcount++;
|
||||
return;
|
||||
}
|
||||
|
||||
args = testpgms[idx].args? strtokenize (testpgms[idx].args, " ") : NULL;
|
||||
rc = my_spawn (pgm, args, myenviron, &pid);
|
||||
xfree (args);
|
||||
if (rc)
|
||||
{
|
||||
printresult ("FAIL: %s (error invoking test)\n", name);
|
||||
failcount++;
|
||||
return;
|
||||
}
|
||||
rc = my_wait (pgm, pid, &exitcode);
|
||||
if (rc < 0)
|
||||
{
|
||||
printresult ("FAIL: %s (error running test)\n", name);
|
||||
failcount++;
|
||||
}
|
||||
else if (rc)
|
||||
{
|
||||
printresult ("FAIL: %s (test crashed)\n", name);
|
||||
failcount++;
|
||||
}
|
||||
else if (exitcode == 77)
|
||||
{
|
||||
printresult ("SKIP: %s\n", name);
|
||||
skipcount++;
|
||||
}
|
||||
else if (exitcode == 1)
|
||||
{
|
||||
printresult ("FAIL: %s\n", name);
|
||||
failcount++;
|
||||
}
|
||||
else if (exitcode)
|
||||
{
|
||||
printresult ("FAIL: %s (exit code %d)\n", name, exitcode);
|
||||
failcount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
printresult ("PASS: %s\n", name);
|
||||
passcount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
runtests (char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argv && *argv)
|
||||
{
|
||||
for ( ; *argv; argv++)
|
||||
{
|
||||
for (i=0; testpgms[i].name; i++)
|
||||
if (!strcmp (testpgms[i].name, *argv))
|
||||
{
|
||||
run_one_test (i);
|
||||
break;
|
||||
}
|
||||
if (!testpgms[i].name)
|
||||
{
|
||||
fail ("requested test '%s' not found\n", *argv);
|
||||
testcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Run all tests. */
|
||||
{
|
||||
for (i=0; testpgms[i].name; i++)
|
||||
run_one_test (i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int last_argc = -1;
|
||||
int listtests = 0;
|
||||
int i;
|
||||
const char *srcdir;
|
||||
|
||||
if (argc)
|
||||
{ argc--; argv++; }
|
||||
|
||||
while (argc && last_argc != argc )
|
||||
{
|
||||
last_argc = argc;
|
||||
if (!strcmp (*argv, "--"))
|
||||
{
|
||||
argc--; argv++;
|
||||
break;
|
||||
}
|
||||
else if (!strcmp (*argv, "--help"))
|
||||
{
|
||||
fputs ("usage: " PGM " [options] [tests_to_run]\n"
|
||||
"Options:\n"
|
||||
" --verbose print timings etc.\n"
|
||||
" --debug flyswatter\n"
|
||||
" --list list all tests\n"
|
||||
" --files list all files\n"
|
||||
" --long include long running tests\n"
|
||||
, stdout);
|
||||
exit (0);
|
||||
}
|
||||
else if (!strcmp (*argv, "--verbose"))
|
||||
{
|
||||
verbose++;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--debug"))
|
||||
{
|
||||
verbose += 2;
|
||||
debug++;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--list"))
|
||||
{
|
||||
listtests = 1;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--files"))
|
||||
{
|
||||
listtests = 2;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--long"))
|
||||
{
|
||||
long_running = 1;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strncmp (*argv, "--", 2))
|
||||
die ("unknown option '%s'", *argv);
|
||||
}
|
||||
|
||||
srcdir = getenv ("srcdir");
|
||||
|
||||
myenviron = xcalloc (2, sizeof *myenviron);
|
||||
myenviron[0] = xstrdup ("GCRYPT_IN_REGRESSION_TEST=1");
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
if (!access ("libgcrypt-standalone-tests", F_OK))
|
||||
myenviron[1] = xstrdup ("LD_LIBRARY_PATH=.");
|
||||
#endif
|
||||
|
||||
if (listtests == 1)
|
||||
{
|
||||
for (i=0; testpgms[i].name; i++)
|
||||
{
|
||||
printf ("%s", testpgms[i].name);
|
||||
if (testpgms[i].pgm || testpgms[i].args)
|
||||
printf (" (%s %s)",
|
||||
testpgms[i].pgm? testpgms[i].pgm : testpgms[i].name,
|
||||
testpgms[i].args? testpgms[i].args : "");
|
||||
if (testpgms[i].flags)
|
||||
{
|
||||
putchar (' ');
|
||||
putchar ('[');
|
||||
if (testpgms[i].flags)
|
||||
fputs ("long", stdout);
|
||||
putchar (']');
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
}
|
||||
else if (listtests == 2)
|
||||
{
|
||||
for (i=0; testpgms[i].name; i++)
|
||||
printf ("%s%s%s\n",
|
||||
strcmp (TESTDRV_EXEEXT, ".exe")? "":".libs/",
|
||||
testpgms[i].pgm? testpgms[i].pgm : testpgms[i].name,
|
||||
TESTDRV_EXEEXT);
|
||||
for (i=0; extratestfiles[i]; i++)
|
||||
printf ("%s%s%s\n",
|
||||
srcdir? srcdir :"",
|
||||
srcdir? "/" :"",
|
||||
extratestfiles[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
start_timer ();
|
||||
runtests (argv);
|
||||
stop_timer ();
|
||||
|
||||
printresult ("%d tests run, %d succeeded, %d failed, %d skipped.\n",
|
||||
testcount-skipcount, passcount, failcount, skipcount);
|
||||
if (testcount != passcount + failcount + skipcount)
|
||||
printresult ("Warning: Execution of some tests failed\n");
|
||||
|
||||
info ("All tests completed in %s. Errors: %d\n",
|
||||
elapsed_time (1), error_count + failcount);
|
||||
}
|
||||
|
||||
for (i=0; myenviron[i]; i++)
|
||||
xfree (myenviron[i]);
|
||||
xfree (myenviron);
|
||||
|
||||
return !!error_count;
|
||||
}
|
|
@ -157,10 +157,9 @@ main (int argc, char **argv)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
xgcry_control ((GCRYCTL_PRINT_CONFIG, NULL));
|
||||
xgcry_control ((GCRYCTL_PRINT_CONFIG, stdout));
|
||||
|
||||
test_get_config ();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче