142 Commits

Author SHA1 Message Date
kang1024 145d0c702b Add ML-KEM and ML-DSA support from OpenSSL 3.5.6
Port ML-KEM (FIPS 203) and ML-DSA (FIPS 204) post-quantum cryptography
from OpenSSL 3.5.6 to OpenSSL 3.0.9 with API compatibility adaptations.

Key compatibility shims:
- Add include/openssl/byteorder.h (OPENSSL_load/store_u{16,32,64}_le)
- Add include/internal/fips.h (ossl_fips_self_testing() inline stub)
- Map EVP_DigestSqueeze() to EVP_DigestFinalXOF() + large buffer
- Map EVP_MD_xof() to EVP_MD flags check
- Map OSSL_FUNC_SIGNATURE_SIGN/VERIFY_MESSAGE_INIT dispatch IDs to
  existing SIGN_INIT/VERIFY_INIT (2/4)
- Map EVP_PKEY_sign/verify_message_init() to sign/verify_init_ex()
- Add OSSL_SIGNATURE_PARAM_MU constant
- Add OSSL_FUNC typedef + OSSL_DISPATCH_END macro
- Use correct NID names (NID_id_alg_ml_dsa_44 vs NID_ML_DSA_44)

Provider registrations:
- ML-KEM KEM, ML-KEM/ML-DSA keymgmt, ML-DSA signature providers
- ML-KEM/ML-DSA encoders/decoders (der/pem/text for pub/priv/pkcs8)
- ML-KEM TLS group capabilities

Build system fixes:
- Add providers/common/provider_ctx.c with get_param/bool_param stubs
- Fix DER build.info $COMMON variable override order
- Fix decode_der2key.c PROV_CTX vs OSSL_LIB_CTX type mismatch (6 calls)
- Link ML tests against libcrypto.a (not .so) for internal symbols
- Remove references to missing der_ml_kem_{gen,key}.c

Adapt BUILD.gn for OpenHarmony:
- Add 18 new source files across three build sections (libcommon, libdefault,
  crypto_source) to support ML-KEM/ML-DSA in the OpenHarmony/OHOS build system.

Test infrastructure:
- Add 3 test recipes (evp_extra_ml_kem, internal_ml_kem, ml_dsa)
- Add #include "internal/nelem.h" for OSSL_NELEM in test files
- Add LABELED_BUF_PRINT_WIDTH definition for codec text output

All 253 tests pass (3374 test cases), 0 compilation warnings.

Signed-off-by: kang1024 <yangjiankang3@huawei.com>
2026-04-23 11:54:05 +08:00
Tomas Mraz 960a5e5a57 Add ossl_bn_is_word_fixed_top()
Also correct some BN_FLG_FIXED_TOP flag handling.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>

(cherry picked from commit 2d285fa873028f6cff9484a0cdf690fe05d7fb16)

(Merged from https://github.com/openssl/openssl/pull/24317)

(cherry picked from commit 5dbb2a8ca2c1ba42dfb9445b5ea76adccbdb9744)
Signed-off-by: lcc <lichaochen@huawei.com>
2025-01-22 17:57:55 +08:00
Tomas Mraz d94495cb53 Make BN_generate_dsa_nonce() constant time and non-biased
Co-authored-by: Paul Dale <ppzgs1@gmail.com>

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>

(cherry picked from commit d7d1bdcb6aa3d5000bf7f5ebc5518be5c91fd5a5)

(Merged from https://github.com/openssl/openssl/pull/24317)

(cherry picked from commit 0df711a25da6e99a7ce0dbaf992acb644252385f)
Signed-off-by: lcc <lichaochen@huawei.com>
2025-01-22 17:57:55 +08:00
code4lala 78da00405e openssl-3.0.9.tar.gz
Signed-off-by: code4lala <fengziteng2@huawei.com>
2023-11-16 16:27:34 +08:00
code4lala f7de6b0b2f rm openssl 3.0.7
Signed-off-by: code4lala <fengziteng2@huawei.com>
2023-11-16 16:27:24 +08:00
slontis c571280a0f Fix NULL deference when validating FFC public key.
Fixes CVE-2023-0217

When attempting to do a BN_Copy of params->p there was no NULL check.
Since BN_copy does not check for NULL this is a NULL reference.

As an aside BN_cmp() does do a NULL check, so there are other checks
that fail because a NULL is passed. A more general check for NULL params
has been added for both FFC public and private key validation instead.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Signed-off-by: code4lala <fengziteng2@huawei.com>
Change-Id: I7086365d9f51b6f36fcfb79a45d36f8d032e1f22
2023-04-26 14:20:20 +08:00
code4lala 393e3604f5 tar -xf openssl-openssl-3.0.7.tar.gz
Signed-off-by: code4lala <fengziteng2@huawei.com>
2023-04-12 11:12:14 +08:00
code4lala 05d2ef44d1 rm all
Signed-off-by: code4lala <fengziteng2@huawei.com>
2023-04-12 11:12:06 +08:00
zhao_zhen_zhou 9fc77853dd 版本1.1.1k升级到1.1.ln并兼容MUSL
Signed-off-by: zhao_zhen_zhou <zhaozhenzhou@huawei.com>
2022-07-01 04:57:51 -07:00
HJ 0b759159b9 huangjun42@huawei.com
Signed-off-by: HJ <huangjun42@huawei.com>
2021-08-10 16:32:34 +08:00
h00416433 ab6439910d Merge branch 'upstream/OpenSSL_1_1_1f' into hj20200529
Conflicts:
	CHANGES
	CONTRIBUTING
	Configurations/50-win-onecore.conf
	Configurations/90-team.norelease.conf
	Configurations/unix-Makefile.tmpl
	Configure
	NEWS
	NOTES.ANDROID
	README
	apps/rehash.c
	apps/s_cb.c
	apps/s_server.c
	apps/speed.c
	config
	crypto/aes/asm/aes-s390x.pl
	crypto/aes/asm/aesni-x86_64.pl
	crypto/aes/asm/aesp8-ppc.pl
	crypto/aes/asm/aesv8-armx.pl
	crypto/aes/asm/vpaes-armv8.pl
	crypto/aes/asm/vpaes-x86_64.pl
	crypto/asn1/charmap.h
	crypto/asn1/x_bignum.c
	crypto/bio/b_addr.c
	crypto/bio/bss_file.c
	crypto/bn/asm/armv8-mont.pl
	crypto/bn/asm/mips.pl
	crypto/bn/asm/ppc.pl
	crypto/bn/asm/rsaz-avx2.pl
	crypto/bn/asm/rsaz-x86_64.pl
	crypto/bn/asm/x86_64-mont5.pl
	crypto/bn/bn_local.h
	crypto/bn/bn_prime.c
	crypto/bn/bn_prime.h
	crypto/chacha/asm/chacha-armv8.pl
	crypto/cms/cms_att.c
	crypto/conf/conf_def.h
	crypto/conf/conf_lib.c
	crypto/dh/dh_gen.c
	crypto/dso/dso_dlfcn.c
	crypto/ec/asm/ecp_nistz256-armv8.pl
	crypto/ec/asm/ecp_nistz256-sparcv9.pl
	crypto/ec/asm/ecp_nistz256-x86_64.pl
	crypto/ec/asm/x25519-ppc64.pl
	crypto/ec/ec_asn1.c
	crypto/ec/ec_local.h
	crypto/ec/ecp_nistp224.c
	crypto/ec/ecp_nistp256.c
	crypto/ec/ecp_nistp521.c
	crypto/ec/ecp_nistz256.c
	crypto/ec/ecx_meth.c
	crypto/engine/eng_openssl.c
	crypto/err/err.c
	crypto/err/openssl.txt
	crypto/evp/e_aes.c
	crypto/evp/evp_err.c
	crypto/hmac/hmac.c
	crypto/modes/asm/ghash-x86_64.pl
	crypto/objects/obj_dat.h
	crypto/objects/obj_xref.h
	crypto/perlasm/x86_64-xlate.pl
	crypto/poly1305/asm/poly1305-armv8.pl
	crypto/ppccpuid.pl
	crypto/rand/drbg_lib.c
	crypto/rand/rand_err.c
	crypto/rand/rand_lib.c
	crypto/rand/rand_local.h
	crypto/rand/rand_unix.c
	crypto/rand/rand_vms.c
	crypto/rsa/rsa_ossl.c
	crypto/rsa/rsa_pk1.c
	crypto/rsa/rsa_pmeth.c
	crypto/rsa/rsa_ssl.c
	crypto/sha/asm/keccak1600-armv4.pl
	crypto/sha/asm/keccak1600-armv8.pl
	crypto/sha/asm/sha512-armv8.pl
	crypto/sha/asm/sha512-sparcv9.pl
	crypto/threads_none.c
	crypto/threads_win.c
	crypto/x509/x509_cmp.c
	crypto/x509/x509_vfy.c
	crypto/x509/x_crl.c
	crypto/x509v3/v3_purp.c
	doc/HOWTO/proxy_certificates.txt
	doc/man1/enc.pod
	doc/man1/s_client.pod
	doc/man1/x509.pod
	doc/man3/BN_generate_prime.pod
	doc/man3/CRYPTO_memcmp.pod
	doc/man3/EC_GROUP_copy.pod
	doc/man3/EVP_DigestSignInit.pod
	doc/man3/EVP_DigestVerifyInit.pod
	doc/man3/EVP_PKEY_new.pod
	doc/man3/EVP_SignInit.pod
	doc/man3/OPENSSL_malloc.pod
	doc/man3/RAND_bytes.pod
	doc/man3/RAND_set_rand_method.pod
	doc/man3/RSA_get0_key.pod
	doc/man3/SSL_SESSION_get0_hostname.pod
	doc/man3/SSL_get_error.pod
	doc/man3/X509_LOOKUP_meth_new.pod
	doc/man3/X509_STORE_add_cert.pod
	doc/man3/X509_cmp.pod
	doc/man3/X509_get_extension_flags.pod
	doc/man3/d2i_X509.pod
	doc/man5/config.pod
	doc/man7/Ed25519.pod
	doc/man7/X25519.pod
	e_os.h
	engines/e_afalg.c
	include/crypto/dso_conf.h.in
	include/internal/constant_time.h
	include/openssl/bio.h
	include/openssl/evperr.h
	include/openssl/lhash.h
	include/openssl/obj_mac.h
	include/openssl/opensslv.h
	include/openssl/randerr.h
	include/openssl/sslerr.h
	krb5
	ssl/record/rec_layer_s3.c
	ssl/s3_lib.c
	ssl/ssl_lib.c
	ssl/ssl_local.h
	ssl/statem/extensions.c
	ssl/statem/extensions_srvr.c
	ssl/statem/statem_lib.c
	ssl/statem/statem_srvr.c
	ssl/t1_lib.c
	ssl/tls13_enc.c
	test/bio_memleak_test.c
	test/bntest.c
	test/build.info
	test/certs/root-cert-rsa2.pem
	test/certs/server-pss-restrict-cert.pem
	test/certs/server-pss-restrict-key.pem
	test/certs/setup.sh
	test/dtlstest.c
	test/ec_internal_test.c
	test/ecdsatest.h
	test/ectest.c
	test/evp_extra_test.c
	test/recipes/02-test_errstr.t
	test/recipes/03-test_internal_ec.t
	test/recipes/30-test_evp_data/evpccmcavs.txt
	test/recipes/80-test_cms_data/bad_signtime_attr.cms
	test/recipes/80-test_cms_data/ct_multiple_attr.cms
	test/recipes/80-test_cms_data/no_ct_attr.cms
	test/recipes/80-test_cms_data/no_md_attr.cms
	test/recipes/90-test_bio_memleak.t
	test/recipes/90-test_includes_data/includes-eq-ws.cnf
	test/recipes/90-test_includes_data/includes-eq.cnf
	test/shlibloadtest.c
	test/ssl-tests/29-dtls-sctp-label-bug.conf
	test/ssl-tests/29-dtls-sctp-label-bug.conf.in
	test/sslapitest.c
	test/testutil.h
	test/testutil/random.c
	util/cavs-to-evptest.pl
	util/libcrypto.num
	util/perl/OpenSSL/Test.pm
	util/perl/TLSProxy/CertificateRequest.pm

Change-Id: I388e77b9fc937720aaf18841949f5f954ef2131b
2020-06-16 09:25:29 +08:00
h00416433 cf46376e29 TicketNo:AR000DI992
Description:openssl 1.1.1d used bu libhapverify
Team:OTHERS
Feature or Bugfix:Feature
Binary Source:Yes, it is
PrivateCode(Yes/No):No

Change-Id: I8968f9c0f146b587da17a3e603bd04fb7b4c505b
Reviewed-on: http://mgit-tm.rnd.huawei.com/7842784
Tested-by: public jenkins <public_jenkins@notesmail.huawei.com>
Reviewed-by: houyuezhou 00386575 <hou@huawei.com>
Reviewed-by: linyibin 00246405 <linyibin@huawei.com>
Reviewed-by: weiping 00548480 <ping.wei@huawei.com>
2020-02-27 13:52:11 +08:00
z00416851 68b4f9db72 TicketNo:AR000D76VD
Description:openssl开源社区安全补丁
Team:EMUI
Feature or Bugfix:Feature
Binary Source:NA
PrivateCode(Yes/No):No

Change-Id: Ia942e70461a3a5337de001ab0f40604776fe8f91
Reviewed-on: http://mgit-tm.rnd.huawei.com/6664137
Tested-by: public jenkins <public_jenkins@notesmail.huawei.com>
Reviewed-by: yanglijun 00294367 <yanglijun@huawei.com>
Reviewed-by: luomeiling 00216346 <luomeiling@huawei.com>
Reviewed-by: shenchunlong 00356424 <shenchunlong@huawei.com>
2019-11-08 15:44:13 +08:00
Dr. Matthias St. Pierre fbbfd128c9 Fix header file include guard names
Make the include guards consistent by renaming them systematically according
to the naming conventions below

The public header files (in the 'include/openssl' directory) are not changed
in 1.1.1, because it is a stable release.

For the private header files files, the guard names try to match the path
specified in the include directives, with all letters converted to upper case
and '/' and '.' replaced by '_'. An extra 'OSSL_' is added as prefix.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9681)
2019-09-27 23:58:12 +02:00
Dr. Matthias St. Pierre b5acbf9148 Reorganize local header files
Apart from public and internal header files, there is a third type called
local header files, which are located next to source files in the source
directory. Currently, they have different suffixes like

  '*_lcl.h', '*_local.h', or '*_int.h'

This commit changes the different suffixes to '*_local.h' uniformly.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9681)
2019-09-27 23:58:06 +02:00
Matt Caswell 1cb7eff45b Update copyright year
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9847)
2019-09-10 13:56:40 +01:00
Dr. Matthias St. Pierre 1b0fe00e27 drbg: ensure fork-safety without using a pthread_atfork handler
When the new OpenSSL CSPRNG was introduced in version 1.1.1,
it was announced in the release notes that it would be fork-safe,
which the old CSPRNG hadn't been.

The fork-safety was implemented using a fork count, which was
incremented by a pthread_atfork handler. Initially, this handler
was enabled by default. Unfortunately, the default behaviour
had to be changed for other reasons in commit b5319bdbd0, so
the new OpenSSL CSPRNG failed to keep its promise.

This commit restores the fork-safety using a different approach.
It replaces the fork count by a fork id, which coincides with
the process id on UNIX-like operating systems and is zero on other
operating systems. It is used to detect when an automatic reseed
after a fork is necessary.

To prevent a future regression, it also adds a test to verify that
the child reseeds after fork.

CVE-2019-1549

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9802)
2019-09-09 17:09:06 +01:00
Antoine Cœur a5c83db4ae Fix Typos
CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/9295)
2019-07-31 19:48:30 +02:00
Bernd Edlinger 7fab431040 Add value_barriers in constant time select functions
The barriers prevent the compiler from narrowing down the
possible value range of the mask and ~mask in the select
statements, which avoids the recognition of the select
and turning it into a conditional load or branch.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/9217)

(cherry picked from commit 04edd688b3727835f9b2c7cca7e4c963bf3ed2ba)
2019-07-18 16:02:20 +02:00
Bernd Edlinger 8d64f00fd9 Fix a C++ comment in the refcount.h
Although in a false-conditional code section gcc-4.8.4 flagged this with
a C90 warning :-(

include/internal/refcount.h:108:7: error: C++ style comments are not allowed in ISO C90 [-Werror]
       // under Windows CE we still have old-style Interlocked* functions

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9388)
2019-07-17 14:17:45 +02:00
Dr. Matthias St. Pierre 3003d2dba9 Add regenerated header files
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/9281)
2019-07-02 10:06:15 +02:00
Richard Levitte 35fd99538a Update copyright year
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9034)
2019-05-28 14:49:38 +02:00
Richard Levitte 5fba3afad0 Rework DSO API conditions and configuration option
'no-dso' is meaningless, as it doesn't get any macro defined.
Therefore, we remove all checks of OPENSSL_NO_DSO.  However, there may
be some odd platforms with no DSO scheme.  For those, we generate the
internal macro DSO_NONE aand use it.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8622)
2019-04-10 07:50:17 +02:00
Soujyu Tanaka 1914fddd6c Avoid linking error on WCE700 for _InterlockedExchangeAdd().
This implementation is referenced to https://www.boost.org/doc/libs/1_69_0/boost/detail/interlocked.hpp

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8596)

(cherry picked from commit 88ffc8dea4e313b6acfd3a9ef3868bee96717cf9)
2019-03-29 10:02:05 +00:00
Matt Caswell 72a7a7021f Update copyright year
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8347)
2019-02-26 14:05:09 +00:00
Sam Roberts 3b09585bd6 Remove unnecessary trailing whitespace
Trim trailing whitespace. It doesn't match OpenSSL coding standards,
AFAICT, and it can cause problems with git tooling.

Trailing whitespace remains in test data and external source.

Backport-of: https://github.com/openssl/openssl/pull/8092

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8134)
2019-02-05 16:29:17 +01:00
Klotz, Tobias b6d41ff733 Cleanup vxworks support to be able to compile for VxWorks 7
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/7569)

(cherry picked from commit 5c8b7b4caa0faedb69277063a7c6b3a8e56c6308)
2019-01-24 17:58:27 +01:00
Bernd Edlinger b6769a3865 PPC: Try out if mftb works before using it
If this fails try out if mfspr268 works.

Use OPENSSL_ppccap=0x20 for enabling mftb,
OPENSSL_ppccap=0x40 for enabling mfspr268,
and OPENSSL_ppccap=0 for enabling neither.

Fixes #8012

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8043)

(cherry picked from commit c8f370485c43729db44b680e41e875ddd7f3108c)
2019-01-21 15:45:53 +01:00
Viktor Dukhovni 25eb9299ce More configurable crypto and ssl library initialization
1.  In addition to overriding the default application name,
    one can now also override the configuration file name
    and flags passed to CONF_modules_load_file().

2.  By default we still keep going when configuration file
    processing fails.  But, applications that want to be
    strict about initialization errors can now make explicit
    flag choices via non-null OPENSSL_INIT_SETTINGS that omit
    the CONF_MFLAGS_IGNORE_RETURN_CODES flag (which had so far
    been both undocumented and unused).

3.  In OPENSSL_init_ssl() do not request OPENSSL_INIT_LOAD_CONFIG
    if the options already include OPENSSL_INIT_NO_LOAD_CONFIG.

4.  Don't set up atexit() handlers when called with opts equal to
    OPENSSL_INIT_BASE_ONLY (this flag should only be used alone).

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7969)
2019-01-07 13:53:52 -05:00
Matt Caswell f725fe5b4b Fix a RUN_ONCE bug
We have a number of instances where there are multiple "init" functions for
a single CRYPTO_ONCE variable, e.g. to load config automatically or to not
load config automatically. Unfortunately the RUN_ONCE mechanism was not
correctly giving the right return value where an alternative init function
was being used.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7983)
2019-01-04 20:23:16 +00:00
Andy Polyakov d2cd28b99e err/err.c: add err_clear_last_constant_time.
Expected usage pattern is to unconditionally set error and then
wipe it if there was no actual error.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit f658a3b64d8750642f4975090740865f770c2a1b)
2018-11-30 12:51:58 +00:00
Benjamin Kaduk a649b52f86 Add tsan_decr() API, counterpart of tsan_counter()
The existing tsan_counter() API increments a reference counter.
Provide a new API, tsan_decr(), to decrement such a reference counter.
This can be used, for example, when a reference is added to the session_ctx's
sess_accept stats but should more properly be tracked in the regular ctx's
statistics.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7464)

(cherry picked from commit 95658c32436017aeeef3d8598957071baf6769a9)
2018-11-03 23:27:11 -05:00
Pauli 79c2c74130 Use secure_getenv(3) when available.
Change all calls to getenv() inside libcrypto to use a new wrapper function
that use secure_getenv() if available and an issetugid then getenv if not.

CPU processor override flags are unchanged.

Extra checks for OPENSSL_issetugid() have been removed in favour of the
safe getenv.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/7047)

(cherry picked from commit 5c39a55d04ea6e6f734b627a050b9e702788d50d)
2018-09-24 11:22:22 +10:00
Matt Caswell 1212818eb0 Update copyright year
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7176)
2018-09-11 13:45:17 +01:00
Andy Polyakov a88e328c3a internal/tsan_assist.h: add tsan_ld_acq and tsan_st_rel.
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6996)
2018-08-26 17:46:52 +02:00
Andy Polyakov 96d7852cbd internal/refcount.h: overhaul fencing and add _MSC_VER section.
Relax memory_order on counter decrement itself, because mutable
members of the reference-counted structure should be visible on all
processors independently on counter. [Even re-format and minimize
dependency on other headers.]

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6900)
2018-08-16 09:31:35 +02:00
Andy Polyakov ede3e6653c Add internal/tsan_assist.h.
Goal here is to facilitate writing "thread-opportunistic" code that
withstands Thread Sanitizer's scrutiny. "Thread-opportunistic" is when
exact result is not required, e.g. some statistics, or execution flow
doesn't have to be unambiguous.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6786)
2018-08-07 09:06:50 +02:00
Andy Polyakov ceb8e32cbc crypto/dllmain.c: remove unused OPENSSL_NONPIC_relocated variable.
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6752)
2018-07-25 16:37:31 +02:00
Nicola Tuveri 51f3021d97 Remove stale SM2 error codes
Run `make update ERROR_REBUILD=-rebuild` to remove some stale error
codes for SM2 (which is now using its own submodule for error codes,
i.e., `SM2_*`).

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6690)
2018-07-16 10:17:40 +01:00
Nicola Tuveri 34446a8524 Remove __cplusplus preamble from internal headers
These headers are internal and never exposed to a cpp compiler, hence no
need for the preamble.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6554)
2018-06-22 12:24:59 +02:00
Matt Caswell d8f031e890 Move the loading of the ssl_conf module to libcrypto
The GOST engine needs to be loaded before we initialise libssl. Otherwise
the GOST ciphersuites are not enabled. However the SSL conf module must
be loaded before we initialise libcrypto. Otherwise we will fail to read
the SSL config from a config file properly.

Another problem is that an application may make use of both libcrypto and
libssl. If it performs libcrypto stuff first and OPENSSL_init_crypto()
is called and loads a config file it will fail if that config file has
any libssl stuff in it.

This commit separates out the loading of the SSL conf module from the
interpretation of its contents. The loading piece doesn't know anything
about SSL so this can be moved to libcrypto. The interpretation of what it
means remains in libssl. This means we can load the SSL conf data before
libssl is there and interpret it when it later becomes available.

Fixes #5809

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5818)
2018-04-05 15:30:12 +01:00
Rich Salz faec5c4a8a Remove QNX support
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5756)
2018-03-26 14:10:57 -04:00
Dr. Matthias St. Pierre 6decf9436f Publish the RAND_DRBG API
Fixes #4403

This commit moves the internal header file "internal/rand.h" to
<openssl/rand_drbg.h>, making the RAND_DRBG API public.
The RAND_POOL API remains private, its function prototypes were
moved to "internal/rand_int.h" and converted to lowercase.

Documentation for the new API is work in progress on GitHub #5461.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5462)
2018-03-15 18:58:38 +01:00
Dr. Matthias St. Pierre 4917e91160 RAND_DRBG: add a function for setting the reseeding defaults
The introduction of thread local public and private DRBG instances (#5547)
makes it very cumbersome to change the reseeding (time) intervals for
those instances. This commit provides a function to set the default
values for all subsequently created DRBG instances.

 int RAND_DRBG_set_reseed_defaults(
                                   unsigned int master_reseed_interval,
                                   unsigned int slave_reseed_interval,
                                   time_t master_reseed_time_interval,
                                   time_t slave_reseed_time_interval
                                   );

The function is intended only to be used during application initialization,
before any threads are created and before any random bytes are generated.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5576)
2018-03-10 00:26:30 +01:00
Matt Caswell 0d66475908 Update copyright year
Reviewed-by: Richard Levitte <levitte@openssl.org>
2018-02-27 13:59:42 +00:00
Kurt Roeckx 32bda2b2e4 Switch the DRBGs from AES-128-CTR to AES-256-CTR
Reviewed-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
GH: #5401
2018-02-21 20:40:34 +01:00
Matt Caswell e0fa632420 Add some new constant time functions needed by curve448
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5105)
2018-02-20 12:59:30 +00:00
Dr. Matthias St. Pierre 812b153706 DRBG: make locking api truly private
In PR #5295 it was decided that the locking api should remain private
and used only inside libcrypto. However, the locking functions were added
back to `libcrypto.num` by `mkdef.pl`, because the function prototypes
were still listed in `internal/rand.h`. (This header contains functions
which are internal, but shared between libcrypto and libssl.)

This commit moves the prototypes to `rand_lcl.h` and changes the names
to lowercase, following the convention therein. It also corrects an
outdated documenting comment.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5375)
2018-02-15 12:25:01 +01:00
Dr. Matthias St. Pierre 8164d91d18 DRBG: make the derivation function the default for ctr_drbg
The NIST standard presents two alternative ways for seeding the
CTR DRBG, depending on whether a derivation function is used or not.
In Section 10.2.1 of NIST SP800-90Ar1 the following is assessed:

  The use of the derivation function is optional if either an
  approved RBG or an entropy source provides full entropy output
  when entropy input is requested by the DRBG mechanism.
  Otherwise, the derivation function shall be used.

Since the OpenSSL DRBG supports being reseeded from low entropy random
sources (using RAND_POOL), the use of a derivation function is mandatory.
For that reason we change the default and replace the opt-in flag
RAND_DRBG_FLAG_CTR_USE_DF with an opt-out flag RAND_DRBG_FLAG_CTR_NO_DF.
This change simplifies the RAND_DRBG_new() calls.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5294)
2018-02-13 17:32:54 +01:00
Dr. Matthias St. Pierre 4f9dabbfe3 DRBG: unify initialization and cleanup code
The functions drbg_setup() and drbg_cleanup() used to duplicate a lot of
code from RAND_DRBG_new() and RAND_DRBG_free(). This duplication has been
removed, which simplifies drbg_setup() and makes drbg_cleanup() obsolete.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5294)
2018-02-13 17:32:54 +01:00