summaryrefslogtreecommitdiffstats
path: root/include/internal
AgeCommit message (Collapse)Author
2021-06-24Fix a race in ossl_provider_add_to_store()Matt Caswell
If two threads both attempt to load the same provider at the same time, they will first both check to see if the provider already exists. If it doesn't then they will both then create new provider objects and call the init function. However only one of the threads will be successful in adding the provider to the store. For the "losing" thread we should still return "success", but we should deinitialise and free the no longer required provider object, and return the object that exists in the store. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
2021-06-24Merge ossl_provider_activate() and ossl_provider_activate_child()Matt Caswell
These 2 functions have become so close to each other that they may as well be just one function. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
2021-06-24Set use_fallbacks to zero when we add a provider to the storeMatt Caswell
Update use_fallbacks to zero when we add a provider to the store rather than when we activate it. Its only at the point that we add it to the store that it is actually usable and visible to other threads. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
2021-06-24Remove flag_couldbechildMatt Caswell
Now that a provider is no longer put into the store until after it has been activated we don't need flag_couldbechild any more. This flag was used to indicate whether a provider was eligible for conversion into a child provider or not. This was only really interesting for predefined providers that were automatically created. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
2021-06-24Add a new provider to the store only after we activate itMatt Caswell
Rather than creating the provider, adding to the store and then activating it, we do things the other way around, i.e. activate first and then add to the store. This means that the activation should occur before other threads are aware of the provider. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
2021-06-24Instantiate predefined providers just-in-timeMatt Caswell
Previously we instantiated all the predefined providers at the point that we create the provider store. Instead we move them to be instantiated as we need them. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
2021-06-22Fix definition of ossl_intmax_t and ossl_uintmax_tRichard Levitte
These definitions were located away from our definitions of other sized int and uint types. Also, the fallback typedef wasn't quite correct, and this changes it to be aliases for int64_t and uint64_t, since those are the largest integers we commonly handle. We also make sure to define corresponding numbers: OSSL_INTMAX_MIN, OSSL_INTMAX_MAX and OSSL_UINTMAX_MAX Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15825)
2021-06-21Refactor KTLS tests to better support TLS 1.3.John Baldwin
- Use SSL_set_ciphersuites for TLS 1.3 tests instead of using SSL_set_cipher_list. - Don't bother passing a sequence number size to KTLS test functions. These functions always test TLS (and not DTLS) for which the sequence size is always the same. In addition, even for DTLS the check in question (verifying that the sequence number fields in SSL do not change) should still pass when doing a before/after comparison of the field. - Define a helper structure to hold the TLS version and cipher name for a single KTLS test. - Define an array of such structures with valid KTLS ciphers and move #ifdef's for TLS versions and supported ciphers out of test functions and instead use them to define the valid members of this array. This also permits using TLS 1.3 cipher suite names for TLS 1.3 tests. - Use separate tests per cipher for test_ktls to give more fine-grained pass/fail results as is already done for test_ktls_sendfile. - While here, rename test_ktls_sendfile to execute_test_ktls_sendfile and test_ktls_sendfile_anytls to test_ktls_sendfile. This is more consistent with the naming used for test_ktls as well as other tests in this file. - Close the file descriptors used for temporary sockets in ktls tests. - Don't assume that KTLS is supported for all compile-time supported cipher suites at runtime. If the kernel fails to offload a given cipher suite, skip the test rather than failing it. FreeBSD kernels may not offload all of the cipher suites supported by its KTLS if a suitable driver or KTLS backend is not present. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15814)
2021-06-16CORE: Do a bit of cleanup of core fetchingRichard Levitte
Some data, like the library context, were passed both through higher level callback structures and through arguments to those same higher level callbacks. This is a bit unnecessary, so we rearrange the callback arguments to simply pass that callback structure and rely on the higher level fetching functionality to pick out what data they need from that structure. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15750)
2021-06-15Add the internal function ossl_method_store_do_all()Richard Levitte
It will simply call the given callback for every method found in the given store. Fixes #15538 Fixes #14837 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15604)
2021-06-15CORE: Move away the allocation of the temporary no_cache method storeRichard Levitte
The responsibility for managing the temporary store for methods from algorithm implementations flaged "no_store" is moved up to the diverse method fetching functions. This allows them to allocate it "just in time", or in other words not at all if there is not such algorithm implementation. This makes this temporary store more flexible if it's needed outside of the core fetching functionality, and slightly faster when this temporary store isn't necessary at all. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15737)
2021-06-05property: Add functionality to query data from a property definitionRichard Levitte
This required making some OSSL_PROPERTY types a little less private. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15570)
2021-06-01Rename all getters to use get/get0 in nameTomas Mraz
For functions that exist in 1.1.1 provide a simple aliases via #define. Fixes #15236 Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_, EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_, EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_, EVP_MD_, and EVP_CIPHER_ prefixes are renamed. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-28Rework and make DEBUG macros consistent.Rich Salz
Remove unused -DCONF_DEBUG and -DBN_CTX_DEBUG. Rename REF_PRINT to REF_DEBUG for consistency, and add a new tracing category and use it for printing reference counts. Rename -DDEBUG_UNUSED to -DUNUSED_RESULT_DEBUG Fix BN_DEBUG_RAND so it compiles and, when set, force DEBUG_RAND to be set also. Rename engine_debug_ref to be ENGINE_REF_PRINT also for consistency. Fixes #15357 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15353)
2021-05-27Use <> for #include openssl/xxxRich Salz
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15468)
2021-05-26err: rename err_load_xxx_strings_int functionsPauli
The new names are ossl_err_load_xxx_strings. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15446)
2021-05-24core: condition out more in FIPS buildsPauli
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15278)
2021-05-20Ensure mirroring of properties works for subsequent updatesMatt Caswell
If the global properties are updated after a provider with a child libctx has already started we need to make sure those updates are mirrored in that child. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15242)
2021-05-20Add a callback for providers to know about global properties changesMatt Caswell
Where a child libctx is in use it needs to know what the current global properties are. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15242)
2021-05-20Implement the ability to convert a PROPERTY_LIST to a stringMatt Caswell
We have the ability to parse a string into a PROPERTY_LIST already. Now we have the ability to go the other way. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15242)
2021-05-19Fix include/internal/sockets.h for VMSRichard Levitte
It needs to include <openssl/opensslconf.h> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15319)
2021-05-18Move ossl_sleep() to e_os.h and use it in appsDr. David von Oheimb
Fixes #15304 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15308)
2021-05-17Fix a use-after-free in the child provider codeMatt Caswell
If the child provider context data gets cleaned up before all usage of providers has finished then a use-after-free can occur. We change the priority of this data so that it gets freed later. Fixes #15284 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15286)
2021-05-15Init the child providers immediately on creation of the child libctxMatt Caswell
We were deferring the initial creation of the child providers until the first fetch. This is a carry over from an earlier iteration of the child lib ctx development and is no longer necessary. In fact we need to init the child providers immediately otherwise not all providers quite init correctly. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15270)
2021-05-13Export/import flags for FFC params changed to seperate fields.Shane Lontis
An extra field got added to the ffc flags related to FIPS-186-2 key validation, but this field was not handled by the export/import since the flags were done as string combinations. To keep this consistent with other object flags they are now passed as seperate OSSL_PARAM fields. Fixes 'no-cached-fetch' build which uses export/import. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15210)
2021-05-11Don't convert pre-existing providers into childrenMatt Caswell
If a provider explicitly loads another provider into a child libctx where it wasn't previously loaded then we don't start treating it like a child if the parent libctx subsequently loads the same provider. Fixes #14925 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14991)
2021-05-11Add support for child provider to up_ref/free their parentMatt Caswell
If the ref counts on a child provider change, then this needs to be reflected in the parent so we add callbacks to do this. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14991)
2021-05-11Add the concept of a child OSSL_LIB_CTXMatt Caswell
Add a child OSSL_LIB_CTX that will mirror the providers loaded into the parent libctx. This is useful for providers that want to use algorithms from other providers and just need to inherit the providers used by the application. Fixes #14925 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14991)
2021-05-11Add the ability for ex_data to have a priorityMatt Caswell
Where an object has multiple ex_data associated with it, then we free that ex_data in order of priority (high priority first). Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14991)
2021-05-07provider: flush the store cache when providers are loaded/unloaded.Pauli
When the providers change, the method cache needs to be flushed. This also impacts the cache is full partial flushes and the algorithm flushing by ID. A new function is introduced to clear all of the operation bits in all providers in a library context. Fixes #15032 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15042)
2021-05-04Create libcrypto support for BIO_new_from_core_bio()Matt Caswell
Previously the concept of wrapping an OSSL_CORE_BIO in a real BIO was an internal only concept for our own providers. Since this is likely to be generally useful, we make it a part of the public API. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15072)
2021-04-28Store the list of activated providers in the libctxMatt Caswell
The provider config module was storing the list of activated providers in a global variable. However, because different libctxs can each load providers via config files we need to keep the list of activated providers separate and in the libctx. Partially fixes #15030 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15033)
2021-04-26Add type_name member to provided methods and use itTomas Mraz
Fixes #14701 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14898)
2021-04-12Add OSSL_PARAM_dup() and OSSL_PARAM_merge().Shane Lontis
These functions are prerequisites for implementing EVP_PKEY_todata(). OSSL_PARAM_dup() is required to make a deep copy of the exported params (since the provider export() uses a OSSL_PARAM_BLD which throws away the data after the call), and then use OSSL_PARAM_merge() to add some additional params that can be passed to the EVP_PKEY_todata(). Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14785)
2021-04-08Update copyright yearMatt Caswell
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14801)
2021-04-08Add a constant time zero check function for 64-bit integersAmitay Isaacs
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14784)
2021-04-08numbers: Define 128-bit integers if compiler supportsAmitay Isaacs
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14784)
2021-04-08property: lock the lib ctx when updating the property definition cachePauli
Although the store being used is adequately and properly locked, the library context is not. Due to the mechanisms used for fetching, it is possible for multiple stores to live within the same library context for short periods. This fix prevents threading issues resulting from such coincidences. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14773)
2021-04-08property: check return values from the property locking calls.Pauli
A failure to obtain a lock would have resulted in much badness, now it results in a failure return. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14773)
2021-04-01Corrected missing definitions from NonStop SPT build.Randall S. Becker
This change includes swapping the PUT and SPT configuration, includes of sys/stat.h and sys/types.h in the correct scope to be picked up by SPT definitions. Fixes: #14698 Fixes: #14734 CLA: The author has the permission to grant the OpenSSL Team the right to use this change. Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14736)
2021-03-24Fix a windows build breakFdaSilvaYY
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14635)
2021-03-18Add ossl_ symbols for sm3 and sm4Shane Lontis
Partial fix for #12964 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14473)
2021-03-18Add ossl_ conf symbolsShane Lontis
Partial fix for #12964 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14473)
2021-03-18Add ossl_asn1 symbolsShane Lontis
Partial fix for #12964 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14473)
2021-03-18Fix misc external ossl_ symbols.Shane Lontis
Partial fix for #12964 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14473)
2021-03-18Fix external symbols for crypto_*Shane Lontis
Partial fix for #12964 This adds ossl_ names for symbols related to crypto_* Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14473)
2021-03-18ASN1: add an internal header to validate Unicode rangesBeat Bolli
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14185)
2021-03-16property: default queries create the property values.Pauli
Without this, it is necessary to query an algorithm before setting the default property query. With this, the value will be created and the default will work. Fixes #14516 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14542)
2021-03-12rename ossl_provider_forall_loaded to ossl_provider_doall_activatedPauli
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14489)
2021-03-11Update copyright yearMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14512)