Still FAILED build of OpenSSL branch master with options -d enable-fuzz-afl no-shared no-module

2021-01-14 Thread OpenSSL run-checker
Platform and configuration command:

$ uname -a
Linux run 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64 
x86_64 x86_64 GNU/Linux
$ CC=afl-clang-fast ../openssl/config -d enable-fuzz-afl no-shared no-module

Commit log since last time:

8bc5b0a570 chacha20: Properly reinitialize the cipher context with NULL key
2ed63033e4 x509v3.h.in: Deprecate CTX_TEST and replace it by X509V3_CTX_TEST
04a1b3fa7b apps/req.c: Make sure -verify option takes effect also with -x509
0ae8d4ca9e apps/req.c: Cosmetic improvements of code and documentation
73b1d24c1a crypto/x509: Rename v3_{skey,skid}.c, v3_{akey,akid}.c, 
v3_{alt,san}.c
b65c5ec8f5 apps/req.c: Add -copy_extensions option for use with -x509; default: 
none
41e597a01d Add X509V3_set_issuer_pkey, needed for AKID of self-issued not 
self-signed cert
ea9fd333d1 apps/req.c: make -subj work with -x509; clean up related code
7836f949c2 X509_PUBKEY_set(): Fix error reporting
855c68163b apps/lib/opt.c: Fix error message on unknown option/digest
f0a057dd53 Add tests for (non-)default SKID and AKID inclusion by 
apps/{req,x509,ca}.c
6ad957f127 apps/req.c: add -CA and -CAkey options; improve code and doc
1579594383 APPS: Allow OPENSSL_CONF to be empty, not loading a config file
ec2bfb7d23 apps/{req,x509,ca}.c Make sure certs have SKID and AKID X.509 
extensions by default
f2a0458731 X509_cmp(): Fix comparison in case x509v3_cache_extensions() failed 
to due to invalid cert
3339606a38 d2i_X509(): Make deallocation behavior consistent with d2i_X509_AUX()
48116c2d0f Fix incorrect use of BN_CTX API
1df333 Fix enable-weak-ssl-ciphers
4dd009180a x509_vfy.c: Fix a regression in find_issuer()
0cbb3602f5 Make PEM_X509_INFO_read_bio_ex() conservative on the error queue
0b7368dda0 TEST: move cert, key, and CSR loading aux functions to new 
testutil/load.c
bf973d0697 Add X509_NAME_hash_ex() to be able to check if it failed due to 
unsupported SHA1
5a2d0ef36f Clean away extraneous library specific FETCH_FAILED reason codes
d6d42cda5f Use centralized fetching errors
0d11846e4b Remove duplicate GENERATE declarations for .pod files
2497e2e7db Configure: warn about duplicate GENERATE declarations in build.info 
files
5e16ac142e Configure: clean away perl syntax faults
507f83800f Configure: Check all SOURCE declarations, to ensure consistency
b209835364 v3_ocsp.c: fix indentation of include directives
3ddf44ea5a Close /dev/crypto file descriptor after CRIOGET ioctl().
678cae0295 APPS: Print help also on -h and --h; print high-level help when no 
cmd given
3372039252 APPS: Fix confusion between program and app/command name used in 
diagnostic/help output
046a7aaa5e apps/pkey.c: Forther improve user guidance, also on non-sensical 
option combinations
1f7643e86e apps/pkey.c: Re-order help output and option documentation
475d10028e apps/pkey.c: Make clear that -passout is not supported for DER output
400e2acfe0 apps.c: Fix crash in case uri arg of IS_HTTP or IS_HTTPS is NULL

Build log ended with (last 100 lines):

# setup_client_ctx:../openssl/apps/cmp.c:1977:CMP info: will contact 
http://127.0.0.1:1700/pkix/
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:165:CMP info: sending IR
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:183:CMP info: received 
IP
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:165:CMP info: sending 
CERTCONF
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:183:CMP info: received 
PKICONF
# save_free_certs:../openssl/apps/cmp.c:2027:CMP info: received 1 enrolled 
certificate(s), saving to file 
'../../../../../enable-fuzz-afl/test-runs/test_cmp_cli/test.certout_popo1.pem'
../../../../../enable-fuzz-afl/util/wrap.pl 
../../../../../enable-fuzz-afl/apps/openssl cmp -config ../Mock/test.cnf 
-section 'Mock enrollment' -certout 
../../../../../enable-fuzz-afl/test-runs/test_cmp_cli/test.cert.pem -proxy '' 
-no_proxy 127.0.0.1 -cmd ir -newkey new.key -newkeypass 'pass:' -popo 0 
-certout 
../../../../../enable-fuzz-afl/test-runs/test_cmp_cli/test.certout_popo1.pem 
-out_trusted root.crt => 0
not ok 43 - popo RAVERIFIED
# --
# cmp_main:../openssl/apps/cmp.c:2661:CMP info: using section(s) 'Mock 
enrollment' of OpenSSL configuration file '../Mock/test.cnf'
# opt_str:../openssl/apps/cmp.c:2260:CMP warning: argument of -proxy option is 
empty string, resetting option
# warn_cert_msg:../openssl/apps/cmp.c:684:CMP warning: certificate from 
'trusted.crt' with subject '/O=openssl_cmp' is not a CA cert
# setup_client_ctx:../openssl/apps/cmp.c:1977:CMP info: will contact 
http://127.0.0.1:1700/pkix/
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:165:CMP info: sending IR
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:183:CMP info: received 
IP
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:165:CMP info: sending 
CERTCONF
# send_receive_check:../openssl/crypto/cmp/cmp_client.c:183:CMP info: received 
PKICONF
# 

[openssl] master update

2021-01-14 Thread Matt Caswell
The branch master has been updated
   via  3bc061eb0a990a95d35c462b9206bdf74905cfa2 (commit)
  from  b11ba50fd9bd3c33e1627ca5c64f08b403e88173 (commit)


- Log -
commit 3bc061eb0a990a95d35c462b9206bdf74905cfa2
Author: Michael Baentsch 
Date:   Wed Jan 13 11:06:13 2021 +0100

Enhance default provider documentation

Bring Wiki and man page documentation in line regarding default provider
fall-back behaviour.

Fixes #13844

Reviewed-by: Tomas Mraz 
Reviewed-by: Matt Caswell 
(Merged from https://github.com/openssl/openssl/pull/13859)

---

Summary of changes:
 doc/man3/OSSL_PROVIDER.pod | 15 ---
 doc/man7/OSSL_PROVIDER-default.pod | 15 +--
 doc/man7/provider.pod  |  4 +++-
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/doc/man3/OSSL_PROVIDER.pod b/doc/man3/OSSL_PROVIDER.pod
index 2baccfffaf..dbae09334f 100644
--- a/doc/man3/OSSL_PROVIDER.pod
+++ b/doc/man3/OSSL_PROVIDER.pod
@@ -78,9 +78,9 @@ or load a provider module with the given name and run its 
provider
 entry point, C.
 
 OSSL_PROVIDER_try_load() functions like OSSL_PROVIDER_load(), except that
-it does not disable the fall-back providers if the provider cannot be
+it does not disable the fallback providers if the provider cannot be
 loaded and initialized.
-If the provider loads successfully, however, the fall-back providers are
+If the provider loads successfully, however, the fallback providers are
 disabled.
 
 OSSL_PROVIDER_unload() unloads the given provider.
@@ -92,7 +92,11 @@ for use.
 
 OSSL_PROVIDER_do_all() iterates over all loaded providers, calling
 I for each one, with the current provider in I and the
-I that comes from the caller.
+I that comes from the caller. If no other provider has been loaded
+before calling this function, the default provider is still available as
+fallback.
+See L for more information on this fallback
+behaviour.
 
 OSSL_PROVIDER_gettable_params() is used to get a provider parameter
 descriptor set as a constant B array.
@@ -140,6 +144,11 @@ OSSL_PROVIDER_get_capabilities() return 1 on success, or 0 
on error.
 OSSL_PROVIDER_load() and OSSL_PROVIDER_try_load() return a pointer to a
 provider object on success, or NULL on error.
 
+OSSL_PROVIDER_do_all() returns 1 if the callback I returns 1 for every
+provider it is called with, or 0 if any provider callback invocation returns 0;
+callback processing stops at the first callback invocation on a provider
+that returns 0.
+
 OSSL_PROVIDER_available() returns 1 if the named provider is available,
 otherwise 0.
 
diff --git a/doc/man7/OSSL_PROVIDER-default.pod 
b/doc/man7/OSSL_PROVIDER-default.pod
index 96144e2260..472bff65fd 100644
--- a/doc/man7/OSSL_PROVIDER-default.pod
+++ b/doc/man7/OSSL_PROVIDER-default.pod
@@ -7,8 +7,19 @@ OSSL_PROVIDER-default - OpenSSL default provider
 =head1 DESCRIPTION
 
 The OpenSSL default provider supplies the majority of OpenSSL's diverse
-algorithm implementations.  It also acts as a fallback when no other
-provider has been loaded.
+algorithm implementations. If an application doesn't specify anything else
+explicitly (e.g. in the application or via config), then this is the
+provider that will be used as fallback: It is loaded automatically the
+first time that an algorithm is fetched from a provider or a function
+acting on providers is called and no other provider has been loaded yet.
+
+If an attempt to load a provider has already been made (whether successful
+or not) then the default provider won't be loaded automatically. Therefore
+if the default provider is to be used in conjunction with other providers
+then it must be loaded explicitly. Automatic loading of the default
+provider only occurs a maximum of once; if the default provider is
+explicitly unloaded then the default provider will not be automatically
+loaded again.
 
 =head2 Properties
 
diff --git a/doc/man7/provider.pod b/doc/man7/provider.pod
index 18a80eff5a..65bbda5063 100644
--- a/doc/man7/provider.pod
+++ b/doc/man7/provider.pod
@@ -196,7 +196,9 @@ This may be NULL to signify the default (global) library 
context, or a
 context created by the user.
 Only providers loaded in this library context (see
 L) will be considered by the fetching
-function.
+function. In case no provider has been loaded in this library context
+the default provider will be loaded as fallback (see
+L).
 
 =item An identifier
 


[openssl] master update

2021-01-14 Thread Matt Caswell
The branch master has been updated
   via  b11ba50fd9bd3c33e1627ca5c64f08b403e88173 (commit)
   via  7dd2cb569358591bb832af66fdabd6a6c580c1d4 (commit)
   via  b457c8f514130d3b92de574620d38c1058eb7b35 (commit)
   via  f5a50c2a07e288187c14b784be253b3a2a23483b (commit)
   via  2c40421440d260ddb97a807b064033f61ae3b2b3 (commit)
   via  c25a1524aad3a2f3a5d74880d8016de31f59adc8 (commit)
   via  886ad0045bf128795049b48f7d7977f72cc7220c (commit)
   via  ae95a40e8d453aa9d4f6499568f658ffc88a7d6e (commit)
   via  f6b72c7d75658e843ea0864e2f202cdc091020f9 (commit)
  from  c476c06f507a2c64a59c8cc86f2109aa00cf5133 (commit)


- Log -
commit b11ba50fd9bd3c33e1627ca5c64f08b403e88173
Author: Matt Caswell 
Date:   Tue Jan 12 16:50:17 2021 +

Fix a failure where fetches can return NULL in multi-threaded code

When a fetch is attempted simultaneously from multiple threads then both
threads can attempt to construct the method. However only one of those
will get added to the global evp method store. The one that "lost" the
race to add the method to the global evp method store ended up with the
fetch call returning NULL, instead of returning the method that was
already available.

Fixes #13682

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit 7dd2cb569358591bb832af66fdabd6a6c580c1d4
Author: Matt Caswell 
Date:   Mon Jan 11 17:02:01 2021 +

Fix an issue in provider_activate_fallbacks()

The above function was running while holding the store lock with a read
lock. Unfortunately it actually modifies the store, so a write lock is
required instead.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit b457c8f514130d3b92de574620d38c1058eb7b35
Author: Matt Caswell 
Date:   Mon Jan 11 17:01:07 2021 +

Extend the threads test to add simple fetch from multi threads

Issue #13682 suggests that doing a simple fetch from multi-threads may
result in issues so we add a test for that.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit f5a50c2a07e288187c14b784be253b3a2a23483b
Author: Matt Caswell 
Date:   Fri Jan 8 13:48:13 2021 +

Enable locking on the primary DRBG when we create it

The primary DRBG may be shared across multiple threads and therefore
we must use locking to access it. Previously we were enabling that locking
lazily when we attempted to obtain one of the child DRBGs. Part of the
process of enabling the lock, is to create the lock. But if we create the
lock lazily then it is too late - we may race with other threads where each
thread is independently attempting to enable the locking. This results
in multiple locks being created - only one of which "sticks" and the rest
are leaked.

Instead we enable locking on the primary when we first create it. This is
already locked and therefore we cannot race.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit 2c40421440d260ddb97a807b064033f61ae3b2b3
Author: Matt Caswell 
Date:   Fri Jan 8 13:22:59 2021 +

Make sure we take the ctx->lock in ossl_lib_ctx_generic_new()

The function ossl_lib_ctx_generic_new() modifies the exdata. This may
be simultaneously being modified by other threads and therefore we need
to make sure we take the lock before doing so.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit c25a1524aad3a2f3a5d74880d8016de31f59adc8
Author: Matt Caswell 
Date:   Fri Dec 11 16:29:25 2020 +

Lock the provider operation_bits

The provider operation_bits array can see concurrent access by multiple
threads and can be reallocated at any time. Therefore we need to ensure
that it is appropriately locked.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit 886ad0045bf128795049b48f7d7977f72cc7220c
Author: Matt Caswell 
Date:   Thu Dec 10 16:57:33 2020 +

Document the core_thread_start upcall

The core_thread_start upcall previously had a placeholder in the docs.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit ae95a40e8d453aa9d4f6499568f658ffc88a7d6e
Author: Matt Caswell 
Date:   Thu Dec 10 15:39:58 2020 +

Add a test for performing work in multiple concurrent threads

We test both the default provider and the fips provider

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13660)

commit f6b72c7d75658e843ea0864e2f202cdc091020f9
Author: Matt Caswell 
Date:   Thu Dec 10 14:44:25 2020 +

Fix a crash with multi-threaded applications using the FIPS 

[openssl] OpenSSL_1_1_1-stable update

2021-01-14 Thread dev
The branch OpenSSL_1_1_1-stable has been updated
   via  76ed0c0ad119569f6e6f6c96b27b76d3b110413b (commit)
  from  fb1e2411042f0367c2560e4ec5e4b1189ca9cd45 (commit)


- Log -
commit 76ed0c0ad119569f6e6f6c96b27b76d3b110413b
Author: Dr. David von Oheimb 
Date:   Mon Dec 28 11:25:59 2020 +0100

x509_vfy.c: Fix a regression in find_isser()

...in case the candidate issuer cert is identical to the target cert.

Fixes #13739

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13749)

---

Summary of changes:
 crypto/x509/x509_vfy.c  | 13 -
 test/recipes/70-test_verify_extra.t |  3 ++-
 test/verify_extra_test.c| 53 ++---
 3 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index 730a0160ff..883c6d7118 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -323,9 +323,10 @@ static int sk_X509_contains(STACK_OF(X509) *sk, X509 *cert)
 }
 
 /*
- * Find in given STACK_OF(X509) sk a non-expired issuer cert (if any) of given 
cert x.
- * The issuer must not be the same as x and must not yet be in ctx->chain, 
where the
- * exceptional case x is self-issued and ctx->chain has just one element is 
allowed.
+ * Find in given STACK_OF(X509) sk an issuer cert of given cert x.
+ * The issuer must not yet be in ctx->chain, where the exceptional case
+ * that x is self-issued and ctx->chain has just one element is allowed.
+ * Prefer the first one that is not expired, else take the last expired one.
  */
 static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x)
 {
@@ -334,11 +335,7 @@ static X509 *find_issuer(X509_STORE_CTX *ctx, 
STACK_OF(X509) *sk, X509 *x)
 
 for (i = 0; i < sk_X509_num(sk); i++) {
 issuer = sk_X509_value(sk, i);
-/*
- * Below check 'issuer != x' is an optimization and safety precaution:
- * Candidate issuer cert cannot be the same as the subject cert 'x'.
- */
-if (issuer != x && ctx->check_issued(ctx, x, issuer)
+if (ctx->check_issued(ctx, x, issuer)
 && (((x->ex_flags & EXFLAG_SI) != 0 && sk_X509_num(ctx->chain) == 
1)
 || !sk_X509_contains(ctx->chain, issuer))) {
 rv = issuer;
diff --git a/test/recipes/70-test_verify_extra.t 
b/test/recipes/70-test_verify_extra.t
index 79a33cd016..e3bdcbaaf9 100644
--- a/test/recipes/70-test_verify_extra.t
+++ b/test/recipes/70-test_verify_extra.t
@@ -16,4 +16,5 @@ plan tests => 1;
 ok(run(test(["verify_extra_test",
  srctop_file("test", "certs", "roots.pem"),
  srctop_file("test", "certs", "untrusted.pem"),
- srctop_file("test", "certs", "bad.pem")])));
+ srctop_file("test", "certs", "bad.pem"),
+ srctop_file("test", "certs", "rootCA.pem")])));
diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c
index d9d1498954..94faa4c78b 100644
--- a/test/verify_extra_test.c
+++ b/test/verify_extra_test.c
@@ -18,6 +18,21 @@
 static const char *roots_f;
 static const char *untrusted_f;
 static const char *bad_f;
+static const char *good_f;
+
+static X509 *load_cert_pem(const char *file)
+{
+X509 *cert = NULL;
+BIO *bio = NULL;
+
+if (!TEST_ptr(bio = BIO_new(BIO_s_file(
+return NULL;
+if (TEST_int_gt(BIO_read_filename(bio, file), 0))
+(void)TEST_ptr(cert = PEM_read_bio_X509(bio, NULL, NULL, NULL));
+
+BIO_free(bio);
+return cert;
+}
 
 static STACK_OF(X509) *load_certs_from_file(const char *filename)
 {
@@ -58,7 +73,7 @@ static STACK_OF(X509) *load_certs_from_file(const char 
*filename)
 return certs;
 }
 
-/*
+/*-
  * Test for CVE-2015-1793 (Alternate Chains Certificate Forgery)
  *
  * Chain is as follows:
@@ -175,16 +190,48 @@ static int test_store_ctx(void)
 return testresult;
 }
 
+static int test_self_signed(const char *filename, int expected)
+{
+X509 *cert = load_cert_pem(filename);
+STACK_OF(X509) *trusted = sk_X509_new_null();
+X509_STORE_CTX *ctx = X509_STORE_CTX_new();
+int ret;
+
+ret = TEST_ptr(cert)
+&& TEST_true(sk_X509_push(trusted, cert))
+&& TEST_true(X509_STORE_CTX_init(ctx, NULL, cert, NULL));
+X509_STORE_CTX_trusted_stack(ctx, trusted);
+ret = ret && TEST_int_eq(X509_verify_cert(ctx), expected);
+
+X509_STORE_CTX_free(ctx);
+sk_X509_free(trusted);
+X509_free(cert);
+return ret;
+}
+
+static int test_self_signed_good(void)
+{
+return test_self_signed(good_f, 1);
+}
+
+static int test_self_signed_bad(void)
+{
+return test_self_signed(bad_f, 0);
+}
+
 int setup_tests(void)
 {
 if (!TEST_ptr(roots_f = test_get_argument(0))
 || !TEST_ptr(untrusted_f = test_get_argument(1))
-|| !TEST_ptr(bad_f = 

[openssl] OpenSSL_1_1_1-stable update

2021-01-14 Thread dev
The branch OpenSSL_1_1_1-stable has been updated
   via  fb1e2411042f0367c2560e4ec5e4b1189ca9cd45 (commit)
  from  2a9785c252df6836da90da33aaeed8edb506e556 (commit)


- Log -
commit fb1e2411042f0367c2560e4ec5e4b1189ca9cd45
Author: Dr. David von Oheimb 
Date:   Wed Dec 30 09:57:49 2020 +0100

X509_cmp(): Fix comparison in case x509v3_cache_extensions() failed to due 
to invalid cert

This is the backport of #13755 to v1.1.1.
Fixes #13698

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13756)

---

Summary of changes:
 crypto/x509/x509_cmp.c| 20 +++-
 crypto/x509/x_all.c   |  2 +-
 crypto/x509v3/v3_purp.c   |  3 ++-
 doc/man3/X509_get_extension_flags.pod |  9 +++--
 include/openssl/x509v3.h  |  5 +++--
 test/certs/invalid-cert.pem   | 19 +++
 test/recipes/80-test_x509aux.t| 13 -
 test/x509aux.c| 17 +++--
 8 files changed, 62 insertions(+), 26 deletions(-)
 create mode 100644 test/certs/invalid-cert.pem

diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c
index ad620af0af..c9d8933640 100644
--- a/crypto/x509/x509_cmp.c
+++ b/crypto/x509/x509_cmp.c
@@ -133,19 +133,21 @@ unsigned long X509_subject_name_hash_old(X509 *x)
  */
 int X509_cmp(const X509 *a, const X509 *b)
 {
-int rv;
+int rv = 0;
 
 if (a == b) /* for efficiency */
 return 0;
-/* ensure hash is valid */
-if (X509_check_purpose((X509 *)a, -1, 0) != 1)
-return -2;
-if (X509_check_purpose((X509 *)b, -1, 0) != 1)
-return -2;
-
-rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
-if (rv)
+
+/* try to make sure hash is valid */
+(void)X509_check_purpose((X509 *)a, -1, 0);
+(void)X509_check_purpose((X509 *)b, -1, 0);
+
+if ((a->ex_flags & EXFLAG_NO_FINGERPRINT) == 0
+&& (b->ex_flags & EXFLAG_NO_FINGERPRINT) == 0)
+rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
+if (rv != 0)
 return rv;
+
 /* Check for match against stored encoding too */
 if (!a->cert_info.enc.modified && !b->cert_info.enc.modified) {
 if (a->cert_info.enc.len < b->cert_info.enc.len)
diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c
index aa5ccba448..bec850af57 100644
--- a/crypto/x509/x_all.c
+++ b/crypto/x509/x_all.c
@@ -363,7 +363,7 @@ int X509_digest(const X509 *data, const EVP_MD *type, 
unsigned char *md,
 unsigned int *len)
 {
 if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0
-&& (data->ex_flags & EXFLAG_INVALID) == 0) {
+&& (data->ex_flags & EXFLAG_NO_FINGERPRINT) == 0) {
 /* Asking for SHA1 and we already computed it. */
 if (len != NULL)
 *len = sizeof(data->sha1_hash);
diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c
index 2b06dba053..93b5ca4d42 100644
--- a/crypto/x509v3/v3_purp.c
+++ b/crypto/x509v3/v3_purp.c
@@ -391,7 +391,8 @@ static void x509v3_cache_extensions(X509 *x)
 }
 
 if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL))
-x->ex_flags |= EXFLAG_INVALID;
+x->ex_flags |= (EXFLAG_NO_FINGERPRINT | EXFLAG_INVALID);
+
 /* V1 should mean no extensions ... */
 if (!X509_get_version(x))
 x->ex_flags |= EXFLAG_V1;
diff --git a/doc/man3/X509_get_extension_flags.pod 
b/doc/man3/X509_get_extension_flags.pod
index 43c9c952c6..cca72c71fc 100644
--- a/doc/man3/X509_get_extension_flags.pod
+++ b/doc/man3/X509_get_extension_flags.pod
@@ -78,12 +78,17 @@ The certificate contains an unhandled critical extension.
 
 =item B
 
-Some certificate extension values are invalid or inconsistent. The
-certificate should be rejected.
+Some certificate extension values are invalid or inconsistent.
+The certificate should be rejected.
 This bit may also be raised after an out-of-memory error while
 processing the X509 object, so it may not be related to the processed
 ASN1 object itself.
 
+=item B
+
+Failed to compute the internal SHA1 hash value of the certificate.
+This may be due to malloc failure or because no SHA1 implementation was found.
+
 =item B
 
 The NID_certificate_policies certificate extension is invalid or
diff --git a/include/openssl/x509v3.h b/include/openssl/x509v3.h
index 6c6eca38a5..b9a8943273 100644
--- a/include/openssl/x509v3.h
+++ b/include/openssl/x509v3.h
@@ -364,8 +364,9 @@ struct ISSUING_DIST_POINT_st {
 
 # define EXFLAG_INVALID_POLICY   0x800
 # define EXFLAG_FRESHEST 0x1000
-/* Self signed */
-# define EXFLAG_SS   0x2000
+# define EXFLAG_SS   0x2000 /* cert is apparently self-signed */
+
+# define EXFLAG_NO_FINGERPRINT   0x10
 
 # define KU_DIGITAL_SIGNATURE0x0080
 # define 

[openssl] master update

2021-01-14 Thread dev
The branch master has been updated
   via  c476c06f507a2c64a59c8cc86f2109aa00cf5133 (commit)
  from  f5f4fbaa44af055e0658c6810b91aa8607e8383a (commit)


- Log -
commit c476c06f507a2c64a59c8cc86f2109aa00cf5133
Author: Dr. David von Oheimb 
Date:   Thu Jan 7 20:02:39 2021 +0100

find_issuer(): When returning an expired issuer, take the most recently 
expired one

Also point out in the documenting comment that a non-expired issuer is 
preferred.

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13805)

---

Summary of changes:
 crypto/x509/x509_vfy.c| 12 +++-
 doc/man1/openssl-verification-options.pod |  2 ++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
index f5849a5603..1bef0a3665 100644
--- a/crypto/x509/x509_vfy.c
+++ b/crypto/x509/x509_vfy.c
@@ -316,10 +316,10 @@ static int sk_X509_contains(STACK_OF(X509) *sk, X509 
*cert)
 }
 
 /*
- * Find in given STACK_OF(X509) sk an issuer cert of given cert x.
- * The issuer must not yet be in ctx->chain, where the exceptional case
- * that x is self-issued and ctx->chain has just one element is allowed.
- * Prefer the first one that is not expired, else take the last expired one.
+ * Find in given STACK_OF(X509) |sk| an issuer cert (if any) of given cert |x|.
+ * The issuer must not yet be in |ctx->chain|, yet allowing the exception that
+ * |x| is self-issued and |ctx->chain| has just one element.
+ * Prefer the first non-expired one, else take the most recently expired one.
  */
 static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x)
 {
@@ -333,7 +333,9 @@ static X509 *find_issuer(X509_STORE_CTX *ctx, 
STACK_OF(X509) *sk, X509 *x)
 || !sk_X509_contains(ctx->chain, issuer))) {
 if (x509_check_cert_time(ctx, issuer, -1))
 return issuer;
-rv = issuer;
+if (rv == NULL || ASN1_TIME_compare(X509_get0_notAfter(issuer),
+X509_get0_notAfter(rv)) > 0)
+rv = issuer;
 }
 }
 return rv;
diff --git a/doc/man1/openssl-verification-options.pod 
b/doc/man1/openssl-verification-options.pod
index af1c7e3a43..620eacf5cc 100644
--- a/doc/man1/openssl-verification-options.pod
+++ b/doc/man1/openssl-verification-options.pod
@@ -36,6 +36,8 @@ name of the current certificate are subject to further tests.
 The relevant authority key identifier components of the current certificate
 (if present) must match the subject key identifier (if present)
 and issuer and serial number of the candidate issuer certificate.
+If there is such a certificate, the first one found that is currently valid
+is taken, otherwise the one that expired most recently of all such 
certificates.
 
 The lookup first searches for issuer certificates in the trust store.
 If it does not find a match there it consults


[openssl] master update

2021-01-14 Thread Richard Levitte
The branch master has been updated
   via  f5f4fbaa44af055e0658c6810b91aa8607e8383a (commit)
  from  4369a882a565c42673b28c586a5c46a8bca98d17 (commit)


- Log -
commit f5f4fbaa44af055e0658c6810b91aa8607e8383a
Author: Richard Levitte 
Date:   Tue Jan 12 15:41:10 2021 +0100

Make the OSSL_CMP manual conform with man-pages(7)

Details from man-pages(7) that are used:

Formatting conventions for manual pages describing functions

...
Variable names should, like argument names, be specified in italics.
...

Formatting conventions (general)

...
Special macros, which are usually in uppercase, are in bold.
Exception: don't boldface NULL.
...

Reviewed-by: Tomas Mraz 
(Merged from https://github.com/openssl/openssl/pull/13846)

---

Summary of changes:
 doc/man3/OSSL_CMP_CTX_new.pod  |  2 +-
 doc/man3/OSSL_CMP_ITAV_set0.pod| 18 +-
 doc/man3/OSSL_CMP_MSG_get0_header.pod  |  4 ++--
 doc/man3/OSSL_CMP_MSG_http_perform.pod |  4 ++--
 doc/man3/OSSL_CMP_SRV_CTX_new.pod  |  8 
 doc/man3/OSSL_CMP_STATUSINFO_new.pod   |  8 
 doc/man3/OSSL_CMP_exec_certreq.pod | 32 
 doc/man3/OSSL_CMP_log_open.pod | 15 ---
 doc/man3/OSSL_CMP_validate_msg.pod | 10 +-
 9 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/doc/man3/OSSL_CMP_CTX_new.pod b/doc/man3/OSSL_CMP_CTX_new.pod
index b468c93272..c2dfce7389 100644
--- a/doc/man3/OSSL_CMP_CTX_new.pod
+++ b/doc/man3/OSSL_CMP_CTX_new.pod
@@ -313,7 +313,7 @@ OSSL_CMP_OPT_LOG_VERBOSITY context option to the given 
level.
 
 OSSL_CMP_CTX_print_errors() outputs any entries in the OpenSSL error queue. It
 is similar to L but uses the CMP log callback function
-if set in the C for uniformity with CMP logging if given. Otherwise it 
uses
+if set in the I for uniformity with CMP logging if given. Otherwise it 
uses
 L to print to STDERR (unless OPENSSL_NO_STDIO is defined).
 
 OSSL_CMP_CTX_set1_serverPath() sets the HTTP path of the CMP server on the 
host,
diff --git a/doc/man3/OSSL_CMP_ITAV_set0.pod b/doc/man3/OSSL_CMP_ITAV_set0.pod
index 276daa7d51..cca4537fd8 100644
--- a/doc/man3/OSSL_CMP_ITAV_set0.pod
+++ b/doc/man3/OSSL_CMP_ITAV_set0.pod
@@ -29,21 +29,21 @@ ITAV is short for InfoTypeAndValue. This type is defined in 
RFC 4210
 section 5.3.19 and Appendix F. It is used at various places in CMP messages,
 e.g., in the generalInfo PKIHeader field, to hold a key-value pair.
 
-OSSL_CMP_ITAV_create() creates a new OSSL_CMP_ITAV structure and fills it in.
-It combines B and B.
+OSSL_CMP_ITAV_create() creates a new B structure and fills it 
in.
+It combines OSSL_CMP_ITAV_new() and OSSL_CMP_ITAV_set0().
 
-OSSL_CMP_ITAV_set0() sets the B with an infoType of B and an
-infoValue of B. This function uses the pointers B and B
+OSSL_CMP_ITAV_set0() sets the I with an infoType of I and an
+infoValue of I. This function uses the pointers I and I
 internally, so they must B be freed up after the call.
 
 OSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the
-B.
+I.
 
 OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in
-the B as generic ASN1_TYPE*.
+the I as generic B pointer.
 
-OSSL_CMP_ITAV_push0_stack_item() pushes B to the stack pointed to
-by B<*itav_sk_p>. It creates a new stack if B<*itav_sk_p> points to NULL.
+OSSL_CMP_ITAV_push0_stack_item() pushes I to the stack pointed to
+by I<*itav_sk_p>. It creates a new stack if I<*itav_sk_p> points to NULL.
 
 =head1 NOTES
 
@@ -65,7 +65,7 @@ OSSL_CMP_ITAV_push0_stack_item() returns 1 on success, 0 on 
error.
 
 The following code creates and sets a structure representing a generic
 InfoTypeAndValue sequence, using an OID created from text as type, and an
-integer as value. Afterwards, it is pushed to the OSSL_CMP_CTX to be later
+integer as value. Afterwards, it is pushed to the B to be later
 included in the requests' PKIHeader's genInfo field.
 
 ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1);
diff --git a/doc/man3/OSSL_CMP_MSG_get0_header.pod 
b/doc/man3/OSSL_CMP_MSG_get0_header.pod
index 8503b74b7c..3896eb0dfb 100644
--- a/doc/man3/OSSL_CMP_MSG_get0_header.pod
+++ b/doc/man3/OSSL_CMP_MSG_get0_header.pod
@@ -39,9 +39,9 @@ then it copies the subject DN from there
 if I is set or the I does not include a subjectAltName.
 The I defines the request identifier to use, which typically is 0.
 
-OSSL_CMP_MSG_read() loads a DER-encoded OSSL_CMP_MSG from B.
+OSSL_CMP_MSG_read() loads a DER-encoded OSSL_CMP_MSG from I.
 
-OSSL_CMP_MSG_write() stores the given OSSL_CMP_MSG to B in DER encoding.
+OSSL_CMP_MSG_write() stores the given OSSL_CMP_MSG to I in DER encoding.
 
 d2i_OSSL_CMP_MSG_bio() parses an ASN.1-encoded 

[openssl] OpenSSL_1_1_1-stable update

2021-01-14 Thread beldmit
The branch OpenSSL_1_1_1-stable has been updated
   via  2a9785c252df6836da90da33aaeed8edb506e556 (commit)
  from  cfd7225fbb9507b2e443a494459bdaab5236d29d (commit)


- Log -
commit 2a9785c252df6836da90da33aaeed8edb506e556
Author: Dmitry Belyavskiy 
Date:   Wed Jan 13 08:51:39 2021 +0100

Skip BOM when reading the config file

Fixes #13840

Reviewed-by: Richard Levitte 
(Merged from https://github.com/openssl/openssl/pull/13857)

(cherry picked from commit 4369a882a565c42673b28c586a5c46a8bca98d17)

---

Summary of changes:
 crypto/conf/conf_def.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index 3d710f12ae..c097ec1286 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -185,6 +185,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
 BUF_MEM *buff = NULL;
 char *s, *p, *end;
 int again;
+int first_call = 1;
 long eline = 0;
 char btmp[DECIMAL_SIZE(eline) + 1];
 CONF_VALUE *v = NULL, *tv;
@@ -233,6 +234,19 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
 BIO_gets(in, p, CONFBUFSIZE - 1);
 p[CONFBUFSIZE - 1] = '\0';
 ii = i = strlen(p);
+if (first_call) {
+/* Other BOMs imply unsupported multibyte encoding,
+ * so don't strip them and let the error raise */
+const unsigned char utf8_bom[3] = {0xEF, 0xBB, 0xBF};
+
+if (i >= 3 && memcmp(p, utf8_bom, 3) == 0) {
+memmove(p, p + 3, i - 3);
+p[i - 3] = 0;
+i -= 3;
+ii -= 3;
+}
+first_call = 0;
+}
 if (i == 0 && !again) {
 /* the currently processed BIO is at EOF */
 BIO *parent;


[openssl] master update

2021-01-14 Thread beldmit
The branch master has been updated
   via  4369a882a565c42673b28c586a5c46a8bca98d17 (commit)
  from  5eb24fbd1c3e0d130ba7f81f1ccf457a2b9d75ad (commit)


- Log -
commit 4369a882a565c42673b28c586a5c46a8bca98d17
Author: Dmitry Belyavskiy 
Date:   Wed Jan 13 08:51:39 2021 +0100

Skip BOM when reading the config file

Fixes #13840

Reviewed-by: Richard Levitte 
(Merged from https://github.com/openssl/openssl/pull/13857)

---

Summary of changes:
 crypto/conf/conf_def.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index a7f5677a26..99063eaf68 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -194,6 +194,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
 BUF_MEM *buff = NULL;
 char *s, *p, *end;
 int again;
+int first_call = 1;
 long eline = 0;
 char btmp[DECIMAL_SIZE(eline) + 1];
 CONF_VALUE *v = NULL, *tv;
@@ -243,6 +244,19 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
 goto err;
 p[CONFBUFSIZE - 1] = '\0';
 ii = i = strlen(p);
+if (first_call) {
+/* Other BOMs imply unsupported multibyte encoding,
+ * so don't strip them and let the error raise */
+const unsigned char utf8_bom[3] = {0xEF, 0xBB, 0xBF};
+
+if (i >= 3 && memcmp(p, utf8_bom, 3) == 0) {
+memmove(p, p + 3, i - 3);
+p[i - 3] = 0;
+i -= 3;
+ii -= 3;
+}
+first_call = 0;
+}
 if (i == 0 && !again) {
 /* the currently processed BIO is NULL or at EOF */
 BIO *parent;


[openssl] OpenSSL_1_1_1-stable update

2021-01-14 Thread Richard Levitte
The branch OpenSSL_1_1_1-stable has been updated
   via  cfd7225fbb9507b2e443a494459bdaab5236d29d (commit)
  from  dfe07182aac02b962a5a72d86cab69e59e90aeca (commit)


- Log -
commit cfd7225fbb9507b2e443a494459bdaab5236d29d
Author: Todd Short 
Date:   Wed Sep 2 16:57:46 2020 -0400

Fix -static builds

Pull in check from #10878
Move disabling of pic, threads and statics up higher before they
are checked.

Fixes #12772

Reviewed-by: Tomas Mraz 
Reviewed-by: Richard Levitte 
(Merged from https://github.com/openssl/openssl/pull/12773)

---

Summary of changes:
 Configure | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Configure b/Configure
index 1d73d06e1b..f25b84bff2 100755
--- a/Configure
+++ b/Configure
@@ -1201,6 +1201,10 @@ foreach (keys %useradd) {
 # At this point, we can forget everything about %user and %useradd,
 # because it's now all been merged into the corresponding $config entry
 
+if (grep { $_ eq '-static' } @{$config{LDFLAGS}}) {
+disable('static', 'pic', 'threads');
+}
+
 # Allow overriding the build file name
 $config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile";
 
@@ -1521,10 +1525,6 @@ if ($strict_warnings)
 }
 }
 
-if (grep { $_ eq '-static' } @{$config{LDFLAGS}}) {
-disable('static', 'pic', 'threads');
-}
-
 $config{CFLAGS} = [ map { $_ eq '--ossl-strict-warnings'
   ? @strict_warnings_collection
   : ( $_ ) }


[openssl] OpenSSL_1_1_1-stable update

2021-01-14 Thread Matt Caswell
The branch OpenSSL_1_1_1-stable has been updated
   via  dfe07182aac02b962a5a72d86cab69e59e90aeca (commit)
  from  fc4ca443c7b999bb47bec6b8ea828973e3c4c7e1 (commit)


- Log -
commit dfe07182aac02b962a5a72d86cab69e59e90aeca
Author: David Carlier 
Date:   Wed Dec 9 20:23:32 2020 +

OPENSSL_cpuid_setup FreeBSD arm update.

when possible using the getauxval equivalent which has similar ids as 
Linux, instead of bad instructions catch approach.

Reviewed-by: Ben Kaduk 
Reviewed-by: Matt Caswell 
(Merged from https://github.com/openssl/openssl/pull/13650)

(cherry picked from commit 5eb24fbd1c3e0d130ba7f81f1ccf457a2b9d75ad)

---

Summary of changes:
 crypto/armcap.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/crypto/armcap.c b/crypto/armcap.c
index 58e54f0da2..53c2855883 100644
--- a/crypto/armcap.c
+++ b/crypto/armcap.c
@@ -69,6 +69,23 @@ void OPENSSL_cpuid_setup(void) __attribute__ ((constructor));
 #   define OSSL_IMPLEMENT_GETAUXVAL
 #  endif
 # endif
+# if defined(__FreeBSD__)
+#  include 
+#  if __FreeBSD_version >= 120
+#   include 
+#   define OSSL_IMPLEMENT_GETAUXVAL
+
+static unsigned long getauxval(unsigned long key)
+{
+  unsigned long val = 0ul;
+
+  if (elf_aux_info((int)key, , sizeof(val)) != 0)
+return 0ul;
+
+  return val;
+}
+#  endif
+# endif
 
 /*
  * ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas


[openssl] master update

2021-01-14 Thread Matt Caswell
The branch master has been updated
   via  5eb24fbd1c3e0d130ba7f81f1ccf457a2b9d75ad (commit)
  from  b57ec7394aace731c460b509aa84039274337600 (commit)


- Log -
commit 5eb24fbd1c3e0d130ba7f81f1ccf457a2b9d75ad
Author: David Carlier 
Date:   Wed Dec 9 20:23:32 2020 +

OPENSSL_cpuid_setup FreeBSD arm update.

when possible using the getauxval equivalent which has similar ids as 
Linux, instead of bad instructions catch approach.

Reviewed-by: Ben Kaduk 
Reviewed-by: Matt Caswell 
(Merged from https://github.com/openssl/openssl/pull/13650)

---

Summary of changes:
 crypto/armcap.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/crypto/armcap.c b/crypto/armcap.c
index 7bd82f8ebc..6c0acda244 100644
--- a/crypto/armcap.c
+++ b/crypto/armcap.c
@@ -71,6 +71,23 @@ void OPENSSL_cpuid_setup(void) __attribute__ ((constructor));
 #   define OSSL_IMPLEMENT_GETAUXVAL
 #  endif
 # endif
+# if defined(__FreeBSD__)
+#  include 
+#  if __FreeBSD_version >= 120
+#   include 
+#   define OSSL_IMPLEMENT_GETAUXVAL
+
+static unsigned long getauxval(unsigned long key)
+{
+  unsigned long val = 0ul;
+
+  if (elf_aux_info((int)key, , sizeof(val)) != 0)
+return 0ul;
+
+  return val;
+}
+#  endif
+# endif
 
 /*
  * ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas


[openssl] OpenSSL_1_1_1-stable update

2021-01-14 Thread Matt Caswell
The branch OpenSSL_1_1_1-stable has been updated
   via  fc4ca443c7b999bb47bec6b8ea828973e3c4c7e1 (commit)
  from  6e3ba20dc49ccbf12ff4c27a4d8b84dcbeb71654 (commit)


- Log -
commit fc4ca443c7b999bb47bec6b8ea828973e3c4c7e1
Author: David Carlier 
Date:   Sat Jan 9 14:17:29 2021 +

OPENSSL_cpuid_setup FreeBSD PowerPC update

Reviewed-by: Ben Kaduk 
Reviewed-by: Matt Caswell 
(Merged from https://github.com/openssl/openssl/pull/13821)

(cherry picked from commit b57ec7394aace731c460b509aa84039274337600)

---

Summary of changes:
 crypto/ppccap.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/crypto/ppccap.c b/crypto/ppccap.c
index b12cd949cc..1d62226965 100644
--- a/crypto/ppccap.c
+++ b/crypto/ppccap.c
@@ -214,6 +214,24 @@ size_t OPENSSL_instrument_bus2(unsigned int *out, size_t 
cnt, size_t max)
 # endif
 #endif
 
+#if defined(__FreeBSD__)
+# include 
+# if __FreeBSD_version >= 120
+#  include 
+#  define OSSL_IMPLEMENT_GETAUXVAL
+
+static unsigned long getauxval(unsigned long key)
+{
+  unsigned long val = 0ul;
+
+  if (elf_aux_info((int)key, , sizeof(val)) != 0)
+return 0ul;
+
+  return val;
+}
+# endif
+#endif
+
 /* I wish  was universally available */
 #define HWCAP   16  /* AT_HWCAP */
 #define HWCAP_PPC64 (1U << 30)


[openssl] master update

2021-01-14 Thread Matt Caswell
The branch master has been updated
   via  b57ec7394aace731c460b509aa84039274337600 (commit)
  from  879365e6d4a53d80e83bbe468fcf2cdd02d30ba1 (commit)


- Log -
commit b57ec7394aace731c460b509aa84039274337600
Author: David Carlier 
Date:   Sat Jan 9 14:17:29 2021 +

OPENSSL_cpuid_setup FreeBSD PowerPC update

Reviewed-by: Ben Kaduk 
Reviewed-by: Matt Caswell 
(Merged from https://github.com/openssl/openssl/pull/13821)

---

Summary of changes:
 crypto/ppccap.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/crypto/ppccap.c b/crypto/ppccap.c
index 4989e43221..d2adb0a441 100644
--- a/crypto/ppccap.c
+++ b/crypto/ppccap.c
@@ -229,6 +229,24 @@ size_t OPENSSL_instrument_bus2(unsigned int *out, size_t 
cnt, size_t max)
 # endif
 #endif
 
+#if defined(__FreeBSD__)
+# include 
+# if __FreeBSD_version >= 120
+#  include 
+#  define OSSL_IMPLEMENT_GETAUXVAL
+
+static unsigned long getauxval(unsigned long key)
+{
+  unsigned long val = 0ul;
+
+  if (elf_aux_info((int)key, , sizeof(val)) != 0)
+return 0ul;
+
+  return val;
+}
+# endif
+#endif
+
 /* I wish  was universally available */
 #define HWCAP   16  /* AT_HWCAP */
 #define HWCAP_PPC64 (1U << 30)