Configuring oqsprovider ======================= This document lists all configuration options for `oqsprovider`. ## Pre-build configuration Significant parts of this code are generated by the script `oqs-template/generate.py`. This script permits integration and activation of all quantum safe algorithms made available by [liboqs](https://github.com/open-quantum-safe/liboqs). The default configuration is as defined in the [algorithm configuration file](oqs-template/generate.yml). Any PR changing this default must include all files changed by `generate.py`. `generate.py` enforces the following rules on `generate.yml`, in the same way for KEMs and signatures: - Algorithm names must be lowercase. Standardized hybrid KEM names (`standard_name`) are the only exception. - A KEM's default ECP hybrid (p256, p384 or p521 by security level) exists if `use_hybrid: true`; further KEM hybrids are listed in `extra_nids` `current` by `hybrid_group`. Signature hybrids are listed in `mix_with`. - TLS code points (KEMs: `nid`, `nid_hybrid` and the `nid` of `extra_nids` `current` entries; signatures: `code_point` of variants and of `mix_with` entries) are set if and only if the algorithm is used in TLS: `enable_kem: true` and `enable_tls: true` for KEMs, `enable: true` and `enable_tls: true` for signatures. - Unless marked `iana: true`, TLS code points must be unique and lie in the RFC 8446 private use range (`0xFE00`-`0xFEFF` for KEMs, `0xFE00`-`0xFFFF` for signatures). - A code point set to `'auto'` is assigned by `generate.py`, which writes it into `generate.yml`: the lowest private use code point not used anywhere in `generate.yml`, including by previous versions of algorithms (`extra_nids` `old`). To enable an algorithm for TLS, set its flags and set its code points, and those of its hybrids, to `'auto'`. ## Build install options ### OPENSSL_ROOT_DIR Defines a non-standard location for an OpenSSL(v3) installation via `cmake` define. By default this value is unset, requiring presence of an OpenSSL3 installation in a standard OS deployment location. ### CMAKE_BUILD_TYPE By setting this `cmake` configuration option to "Release" all debug output is disabled. This is the default setting. In case of any problem, setting this value to "Debug" is _highly_ recommended to activate further warning messages. In particular, when "Debug" has been set, distinct [debugging capabilities](https://github.com/open-quantum-safe/oqs-provider/wiki/Debugging) are activated and additional setup warnings are output. ### CMAKE_PARAMS This environment variable lets you specify additional flags to pass to `cmake` explicitly when using the `fullbuild.sh` script. For example, in order to point `cmake` to a specific library, you might run: ``` env CMAKE_PARAMS="-DOPENSSL_CRYPTO_LIBRARY=/opt/lib64/libcrypto.so" bash scripts/fullbuild.sh ``` ### liboqs_DIR This environment variable must be set to the location of the `liboqs` installation to be utilized in the build. By default, this is un-set, requiring installation of `liboqs` in a standard location for the OS. This uses the [`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html) command in `cmake`, which checks for local builds of a package at `_DIR` ### NOPUBKEY_IN_PRIVKEY By setting this to "ON", it can be specified to omit explicitly serializing the public key in a `privateKey` structure, e.g., for interoperability testing. The default value is `OFF`. ### OQS_KEM_ENCODERS By setting this to "ON", `oqsprovider` is configured to provide encoders and decoders for KEM algorithms both for public and private key file formats. This increases the size of the provider but enables further use cases. The underlying OIDs are chosen at random and should not be relied on for future use. For purposes of interoperability testing the chosen OIDs can always --at runtime-- be set by [environment variables](https://github.com/open-quantum-safe/oqs-provider/blob/main/ALGORITHMS.md#oids) to arbitrary values The default value therefore is `OFF`. ### OQS_PROVIDER_BUILD_STATIC By setting `-DOQS_PROVIDER_BUILD_STATIC=ON` at compile-time, oqs-provider can be compiled as a static library (`oqs-provider.a`). When built as a static library, the name of the provider entrypoint is `oqs_provider_init`. The provider can be added using the [`OSSL_PROVIDER_add_builtin`](https://www.openssl.org/docs/man3.1/man3/OSSL_PROVIDER_add_builtin.html) function: ```c #include // Entrypoint. extern OSSL_provider_init_fn oqs_provider_init; void load_oqs_provider(OSSL_LIB_CTX *libctx) { int err; if (OSSL_PROVIDER_add_builtin(libctx, "oqsprovider", oqs_provider_init) == 1) { if (OSSL_PROVIDER_load(libctx, "oqsprovider") == 1) { fputs("successfully loaded `oqsprovider`.", stderr); } else { fputs("failed to load `oqsprovider`", stderr); } } else { fputs("failed to add the builtin provider `oqsprovider`", stderr); } } ``` > **Warning** > `OQS_PROVIDER_BUILD_STATIC` and `BUILD_SHARED_LIBS` are mutually exclusive. See [`examples/static_oqsprovider.c`](examples/static_oqsprovider.c) for a complete example of how to load oqsprovider using `OSSL_PROVIDER_add_builtin`. ### OQS_PROVIDER_SHARED_TYPE By setting `-DOQS_PROVIDER_SHARED_TYPE=ON` at compile-time, oqs-provider can be compiled as a shared library instead of the default behavior of a shared module. This will provide the shared object with a `SONAME` and `SOVERSION` so it can be directly linked as a shared library, if desired. Since the vast majority of use cases will require the object to have a type `MODULE`, the default value therefore is `OFF`. > **Warning** > `OQS_PROVIDER_SHARED_TYPE` and `NOT BUILD_SHARED_LIBS` are mutually exclusive. ### BUILD_TESTING By setting this to "OFF", no tests or examples will be compiled. ## Convenience build script options For anyone interested in building the complete software stack (`openssl`(v3), `liboqs` and `oqs-provider`) the files `fullbuild.sh` and `runtests.sh` in the `scripts` directory cater for that. These files can be configured via the following environment variables: ### OPENSSL_INSTALL Directory of an existing, non-standard OpenSSL binary distribution. ### OPENSSL_BRANCH Tag of a specific OpenSSL release to be built and used in testing. Care is advised setting this to values lower than "3.0.9" due to many known code deficiencies related to providers in such old OpenSSL branches. ### LIBOQS_BRANCH This defines the branch of `liboqs` against which `oqs-provider` is built. If this variable is not set, the "main" branch is built. Only the algorithm set and code points of the current `generate.yml` are supported; building against older `liboqs` releases is not supported. Please go to the corresponding `oqs-provider` tag to use the desired pair. ### liboqs_DIR If this environment variable is set, `liboqs` is not being built but used from the directory specified in this variable: Both `include` and `lib` directories must be present in that location. By not setting this variable, `liboqs` is build from source. ### MAKE_PARAMS This environment variable permits passing parameters to the `make` command used to build `openssl`, e.g., "-j 8" to activate 8-fold parallel builds to reduce the compilation time on a suitable multicore machine. ### OQSPROV_CMAKE_PARAMS This environment variable permits passing parameters to the `cmake` command used to build `oqsprovider`. ### OQS_SKIP_TESTS By setting this tests environment variable, testing of specific algorithm families as listed [here](https://github.com/open-quantum-safe/openssl#supported-algorithms) can be disabled in testing. By default this variable is unset. Example use: OQS_SKIP_TESTS="slhdsa" ./scripts/runtests.sh excludes all algorithms of the "SLH-DSA" family (speeding up testing significantly). *Note*: By default, interoperability testing with oqs-openssl111 is no longer performed by default but can be manually enabled in the script `scripts/runtests.sh`. ### OPENSSL_CONF This test environment variable can be used to instruct `openssl` to use a configuration file from a non-standard location. Setting this value also disables the automation logic built into `runtests.sh`, thus requiring knowledge of `openssl` operations when setting it. By default this variable is unset. ### OSSL_CONFIG This environment variable can be used to pass arguments to the `./config` command that precedes the `make` of the OpenSSL, e.g. to build in [debug](https://wiki.openssl.org/index.php/Compilation_and_Installation#Debug_Configuration). ### OQS_PROVIDER_SRC_DIR Directory holding the `oqs-provider` sources to be built by `fullbuild.sh`. If this variable is not set, the parent directory of the `fullbuild.sh` script itself is used, so the sources are always found regardless of the directory the script is invoked from. ### OQS_PROVIDER_BUILD_DIR Directory into which `fullbuild.sh` builds `oqs-provider` and in which `runtests.sh` expects the provider module and the `ctest` setup to be found. If this variable is not set, `_build` below the current directory is used. Together with [`OQS_PROVIDER_SRC_DIR`](#oqs_provider_src_dir) this permits building and testing "out of source", i.e., with the build and test target not co-located with the source code: mkdir /tmp/oqsprovider-build && cd /tmp/oqsprovider-build /path/to/oqs-provider/scripts/fullbuild.sh /path/to/oqs-provider/scripts/runtests.sh *Note*: `fullbuild.sh` continues to place its `openssl`, `liboqs` and `.local` working directories below the current directory, so an out-of-source build leaves the source tree untouched. ## LIBOQS configuration options These are [documented in full here](https://github.com/open-quantum-safe/liboqs/wiki/Customizing-liboqs). One option is of particular context here, particularly if building `oqs-provider` static, i.e., as a standalone binary not requiring presence of `liboqs` during deployment: ### OQS_ALGS_ENABLED In order to reduce the size of the oqsprovider, it is possible to limit the number of algorithms supported, e.g., to the set of NIST standardized algorithms. This is facilitated by setting the `liboqs` build option `-DOQS_ALGS_ENABLED=STD` when building `liboqs`. The list of algorithms supported by `oqs-provider` is defined by the contents of the file `generate.yml` documented in the [pre-build configuration](#pre-build-configuration). ## Runtime options The `openssl` [property selection mechanism](https://www.openssl.org/docs/manmaster/man7/property.html) can be utilized to make run-time algorithm selections. ### oqsprovider.security_bits It is possible to select only algorithms of a specific bit strength by using the openssl property selection mechanism on the key "oqsprovider.security_bits", e.g., as such: `openssl list -kem-algorithms -propquery oqsprovider.security_bits=256`. The bit strength of hybrid algorithms is always defined by the bit strength of the classic algorithm.