11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved. 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 51cb0ef41Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 61cb0ef41Sopenharmony_ci * in the file LICENSE in the source distribution or at 71cb0ef41Sopenharmony_ci * https://www.openssl.org/source/license.html 81cb0ef41Sopenharmony_ci */ 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include <string.h> 111cb0ef41Sopenharmony_ci#include <stdio.h> 121cb0ef41Sopenharmony_ci#include <openssl/opensslconf.h> 131cb0ef41Sopenharmony_ci#include <openssl/core.h> 141cb0ef41Sopenharmony_ci#include <openssl/core_dispatch.h> 151cb0ef41Sopenharmony_ci#include <openssl/core_names.h> 161cb0ef41Sopenharmony_ci#include <openssl/params.h> 171cb0ef41Sopenharmony_ci#include "prov/bio.h" 181cb0ef41Sopenharmony_ci#include "prov/provider_ctx.h" 191cb0ef41Sopenharmony_ci#include "prov/providercommon.h" 201cb0ef41Sopenharmony_ci#include "prov/implementations.h" 211cb0ef41Sopenharmony_ci#include "prov/names.h" 221cb0ef41Sopenharmony_ci#include "prov/provider_util.h" 231cb0ef41Sopenharmony_ci#include "prov/seeding.h" 241cb0ef41Sopenharmony_ci#include "internal/nelem.h" 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci/* 271cb0ef41Sopenharmony_ci * Forward declarations to ensure that interface functions are correctly 281cb0ef41Sopenharmony_ci * defined. 291cb0ef41Sopenharmony_ci */ 301cb0ef41Sopenharmony_cistatic OSSL_FUNC_provider_gettable_params_fn deflt_gettable_params; 311cb0ef41Sopenharmony_cistatic OSSL_FUNC_provider_get_params_fn deflt_get_params; 321cb0ef41Sopenharmony_cistatic OSSL_FUNC_provider_query_operation_fn deflt_query; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci#define ALGC(NAMES, FUNC, CHECK) { { NAMES, "provider=default", FUNC }, CHECK } 351cb0ef41Sopenharmony_ci#define ALG(NAMES, FUNC) ALGC(NAMES, FUNC, NULL) 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci/* Functions provided by the core */ 381cb0ef41Sopenharmony_cistatic OSSL_FUNC_core_gettable_params_fn *c_gettable_params = NULL; 391cb0ef41Sopenharmony_cistatic OSSL_FUNC_core_get_params_fn *c_get_params = NULL; 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci/* Parameters we provide to the core */ 421cb0ef41Sopenharmony_cistatic const OSSL_PARAM deflt_param_types[] = { 431cb0ef41Sopenharmony_ci OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0), 441cb0ef41Sopenharmony_ci OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0), 451cb0ef41Sopenharmony_ci OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0), 461cb0ef41Sopenharmony_ci OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0), 471cb0ef41Sopenharmony_ci OSSL_PARAM_END 481cb0ef41Sopenharmony_ci}; 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_cistatic const OSSL_PARAM *deflt_gettable_params(void *provctx) 511cb0ef41Sopenharmony_ci{ 521cb0ef41Sopenharmony_ci return deflt_param_types; 531cb0ef41Sopenharmony_ci} 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_cistatic int deflt_get_params(void *provctx, OSSL_PARAM params[]) 561cb0ef41Sopenharmony_ci{ 571cb0ef41Sopenharmony_ci OSSL_PARAM *p; 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); 601cb0ef41Sopenharmony_ci if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Default Provider")) 611cb0ef41Sopenharmony_ci return 0; 621cb0ef41Sopenharmony_ci p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION); 631cb0ef41Sopenharmony_ci if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR)) 641cb0ef41Sopenharmony_ci return 0; 651cb0ef41Sopenharmony_ci p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO); 661cb0ef41Sopenharmony_ci if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_FULL_VERSION_STR)) 671cb0ef41Sopenharmony_ci return 0; 681cb0ef41Sopenharmony_ci p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS); 691cb0ef41Sopenharmony_ci if (p != NULL && !OSSL_PARAM_set_int(p, ossl_prov_is_running())) 701cb0ef41Sopenharmony_ci return 0; 711cb0ef41Sopenharmony_ci return 1; 721cb0ef41Sopenharmony_ci} 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci/* 751cb0ef41Sopenharmony_ci * For the algorithm names, we use the following formula for our primary 761cb0ef41Sopenharmony_ci * names: 771cb0ef41Sopenharmony_ci * 781cb0ef41Sopenharmony_ci * ALGNAME[VERSION?][-SUBNAME[VERSION?]?][-SIZE?][-MODE?] 791cb0ef41Sopenharmony_ci * 801cb0ef41Sopenharmony_ci * VERSION is only present if there are multiple versions of 811cb0ef41Sopenharmony_ci * an alg (MD2, MD4, MD5). It may be omitted if there is only 821cb0ef41Sopenharmony_ci * one version (if a subsequent version is released in the future, 831cb0ef41Sopenharmony_ci * we can always change the canonical name, and add the old name 841cb0ef41Sopenharmony_ci * as an alias). 851cb0ef41Sopenharmony_ci * 861cb0ef41Sopenharmony_ci * SUBNAME may be present where we are combining multiple 871cb0ef41Sopenharmony_ci * algorithms together, e.g. MD5-SHA1. 881cb0ef41Sopenharmony_ci * 891cb0ef41Sopenharmony_ci * SIZE is only present if multiple versions of an algorithm exist 901cb0ef41Sopenharmony_ci * with different sizes (e.g. AES-128-CBC, AES-256-CBC) 911cb0ef41Sopenharmony_ci * 921cb0ef41Sopenharmony_ci * MODE is only present where applicable. 931cb0ef41Sopenharmony_ci * 941cb0ef41Sopenharmony_ci * We add diverse other names where applicable, such as the names that 951cb0ef41Sopenharmony_ci * NIST uses, or that are used for ASN.1 OBJECT IDENTIFIERs, or names 961cb0ef41Sopenharmony_ci * we have used historically. 971cb0ef41Sopenharmony_ci * 981cb0ef41Sopenharmony_ci * Algorithm names are case insensitive, but we use all caps in our "canonical" 991cb0ef41Sopenharmony_ci * names for consistency. 1001cb0ef41Sopenharmony_ci */ 1011cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_digests[] = { 1021cb0ef41Sopenharmony_ci /* Our primary name:NIST name[:our older names] */ 1031cb0ef41Sopenharmony_ci { PROV_NAMES_SHA1, "provider=default", ossl_sha1_functions }, 1041cb0ef41Sopenharmony_ci { PROV_NAMES_SHA2_224, "provider=default", ossl_sha224_functions }, 1051cb0ef41Sopenharmony_ci { PROV_NAMES_SHA2_256, "provider=default", ossl_sha256_functions }, 1061cb0ef41Sopenharmony_ci { PROV_NAMES_SHA2_384, "provider=default", ossl_sha384_functions }, 1071cb0ef41Sopenharmony_ci { PROV_NAMES_SHA2_512, "provider=default", ossl_sha512_functions }, 1081cb0ef41Sopenharmony_ci { PROV_NAMES_SHA2_512_224, "provider=default", ossl_sha512_224_functions }, 1091cb0ef41Sopenharmony_ci { PROV_NAMES_SHA2_512_256, "provider=default", ossl_sha512_256_functions }, 1101cb0ef41Sopenharmony_ci 1111cb0ef41Sopenharmony_ci /* We agree with NIST here, so one name only */ 1121cb0ef41Sopenharmony_ci { PROV_NAMES_SHA3_224, "provider=default", ossl_sha3_224_functions }, 1131cb0ef41Sopenharmony_ci { PROV_NAMES_SHA3_256, "provider=default", ossl_sha3_256_functions }, 1141cb0ef41Sopenharmony_ci { PROV_NAMES_SHA3_384, "provider=default", ossl_sha3_384_functions }, 1151cb0ef41Sopenharmony_ci { PROV_NAMES_SHA3_512, "provider=default", ossl_sha3_512_functions }, 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci /* 1181cb0ef41Sopenharmony_ci * KECCAK-KMAC-128 and KECCAK-KMAC-256 as hashes are mostly useful for 1191cb0ef41Sopenharmony_ci * the KMAC-128 and KMAC-256. 1201cb0ef41Sopenharmony_ci */ 1211cb0ef41Sopenharmony_ci { PROV_NAMES_KECCAK_KMAC_128, "provider=default", 1221cb0ef41Sopenharmony_ci ossl_keccak_kmac_128_functions }, 1231cb0ef41Sopenharmony_ci { PROV_NAMES_KECCAK_KMAC_256, "provider=default", 1241cb0ef41Sopenharmony_ci ossl_keccak_kmac_256_functions }, 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_ci /* Our primary name:NIST name */ 1271cb0ef41Sopenharmony_ci { PROV_NAMES_SHAKE_128, "provider=default", ossl_shake_128_functions }, 1281cb0ef41Sopenharmony_ci { PROV_NAMES_SHAKE_256, "provider=default", ossl_shake_256_functions }, 1291cb0ef41Sopenharmony_ci 1301cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_BLAKE2 1311cb0ef41Sopenharmony_ci /* 1321cb0ef41Sopenharmony_ci * https://blake2.net/ doesn't specify size variants, 1331cb0ef41Sopenharmony_ci * but mentions that Bouncy Castle uses the names 1341cb0ef41Sopenharmony_ci * BLAKE2b-160, BLAKE2b-256, BLAKE2b-384, and BLAKE2b-512 1351cb0ef41Sopenharmony_ci * If we assume that "2b" and "2s" are versions, that pattern 1361cb0ef41Sopenharmony_ci * fits with ours. We also add our historical names. 1371cb0ef41Sopenharmony_ci */ 1381cb0ef41Sopenharmony_ci { PROV_NAMES_BLAKE2S_256, "provider=default", ossl_blake2s256_functions }, 1391cb0ef41Sopenharmony_ci { PROV_NAMES_BLAKE2B_512, "provider=default", ossl_blake2b512_functions }, 1401cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_BLAKE2 */ 1411cb0ef41Sopenharmony_ci 1421cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SM3 1431cb0ef41Sopenharmony_ci { PROV_NAMES_SM3, "provider=default", ossl_sm3_functions }, 1441cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_SM3 */ 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_MD5 1471cb0ef41Sopenharmony_ci { PROV_NAMES_MD5, "provider=default", ossl_md5_functions }, 1481cb0ef41Sopenharmony_ci { PROV_NAMES_MD5_SHA1, "provider=default", ossl_md5_sha1_functions }, 1491cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_MD5 */ 1501cb0ef41Sopenharmony_ci 1511cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_RMD160 1521cb0ef41Sopenharmony_ci { PROV_NAMES_RIPEMD_160, "provider=default", ossl_ripemd160_functions }, 1531cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_RMD160 */ 1541cb0ef41Sopenharmony_ci 1551cb0ef41Sopenharmony_ci { PROV_NAMES_NULL, "provider=default", ossl_nullmd_functions }, 1561cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 1571cb0ef41Sopenharmony_ci}; 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM_CAPABLE deflt_ciphers[] = { 1601cb0ef41Sopenharmony_ci ALG(PROV_NAMES_NULL, ossl_null_functions), 1611cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_ECB, ossl_aes256ecb_functions), 1621cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_ECB, ossl_aes192ecb_functions), 1631cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_ECB, ossl_aes128ecb_functions), 1641cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CBC, ossl_aes256cbc_functions), 1651cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CBC, ossl_aes192cbc_functions), 1661cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CBC, ossl_aes128cbc_functions), 1671cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CBC_CTS, ossl_aes128cbc_cts_functions), 1681cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CBC_CTS, ossl_aes192cbc_cts_functions), 1691cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CBC_CTS, ossl_aes256cbc_cts_functions), 1701cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_OFB, ossl_aes256ofb_functions), 1711cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_OFB, ossl_aes192ofb_functions), 1721cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_OFB, ossl_aes128ofb_functions), 1731cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CFB, ossl_aes256cfb_functions), 1741cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CFB, ossl_aes192cfb_functions), 1751cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CFB, ossl_aes128cfb_functions), 1761cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CFB1, ossl_aes256cfb1_functions), 1771cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CFB1, ossl_aes192cfb1_functions), 1781cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CFB1, ossl_aes128cfb1_functions), 1791cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CFB8, ossl_aes256cfb8_functions), 1801cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CFB8, ossl_aes192cfb8_functions), 1811cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CFB8, ossl_aes128cfb8_functions), 1821cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CTR, ossl_aes256ctr_functions), 1831cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CTR, ossl_aes192ctr_functions), 1841cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CTR, ossl_aes128ctr_functions), 1851cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_XTS, ossl_aes256xts_functions), 1861cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_XTS, ossl_aes128xts_functions), 1871cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_OCB 1881cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_OCB, ossl_aes256ocb_functions), 1891cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_OCB, ossl_aes192ocb_functions), 1901cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_OCB, ossl_aes128ocb_functions), 1911cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_OCB */ 1921cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SIV 1931cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_SIV, ossl_aes128siv_functions), 1941cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_SIV, ossl_aes192siv_functions), 1951cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_SIV, ossl_aes256siv_functions), 1961cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_SIV */ 1971cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_GCM, ossl_aes256gcm_functions), 1981cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_GCM, ossl_aes192gcm_functions), 1991cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_GCM, ossl_aes128gcm_functions), 2001cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_CCM, ossl_aes256ccm_functions), 2011cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_CCM, ossl_aes192ccm_functions), 2021cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_CCM, ossl_aes128ccm_functions), 2031cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_WRAP, ossl_aes256wrap_functions), 2041cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_WRAP, ossl_aes192wrap_functions), 2051cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_WRAP, ossl_aes128wrap_functions), 2061cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_WRAP_PAD, ossl_aes256wrappad_functions), 2071cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_WRAP_PAD, ossl_aes192wrappad_functions), 2081cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_WRAP_PAD, ossl_aes128wrappad_functions), 2091cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_WRAP_INV, ossl_aes256wrapinv_functions), 2101cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_WRAP_INV, ossl_aes192wrapinv_functions), 2111cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_WRAP_INV, ossl_aes128wrapinv_functions), 2121cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_256_WRAP_PAD_INV, ossl_aes256wrappadinv_functions), 2131cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_192_WRAP_PAD_INV, ossl_aes192wrappadinv_functions), 2141cb0ef41Sopenharmony_ci ALG(PROV_NAMES_AES_128_WRAP_PAD_INV, ossl_aes128wrappadinv_functions), 2151cb0ef41Sopenharmony_ci ALGC(PROV_NAMES_AES_128_CBC_HMAC_SHA1, ossl_aes128cbc_hmac_sha1_functions, 2161cb0ef41Sopenharmony_ci ossl_cipher_capable_aes_cbc_hmac_sha1), 2171cb0ef41Sopenharmony_ci ALGC(PROV_NAMES_AES_256_CBC_HMAC_SHA1, ossl_aes256cbc_hmac_sha1_functions, 2181cb0ef41Sopenharmony_ci ossl_cipher_capable_aes_cbc_hmac_sha1), 2191cb0ef41Sopenharmony_ci ALGC(PROV_NAMES_AES_128_CBC_HMAC_SHA256, ossl_aes128cbc_hmac_sha256_functions, 2201cb0ef41Sopenharmony_ci ossl_cipher_capable_aes_cbc_hmac_sha256), 2211cb0ef41Sopenharmony_ci ALGC(PROV_NAMES_AES_256_CBC_HMAC_SHA256, ossl_aes256cbc_hmac_sha256_functions, 2221cb0ef41Sopenharmony_ci ossl_cipher_capable_aes_cbc_hmac_sha256), 2231cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_ARIA 2241cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_GCM, ossl_aria256gcm_functions), 2251cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_GCM, ossl_aria192gcm_functions), 2261cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_GCM, ossl_aria128gcm_functions), 2271cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_CCM, ossl_aria256ccm_functions), 2281cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_CCM, ossl_aria192ccm_functions), 2291cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_CCM, ossl_aria128ccm_functions), 2301cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_ECB, ossl_aria256ecb_functions), 2311cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_ECB, ossl_aria192ecb_functions), 2321cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_ECB, ossl_aria128ecb_functions), 2331cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_CBC, ossl_aria256cbc_functions), 2341cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_CBC, ossl_aria192cbc_functions), 2351cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_CBC, ossl_aria128cbc_functions), 2361cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_OFB, ossl_aria256ofb_functions), 2371cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_OFB, ossl_aria192ofb_functions), 2381cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_OFB, ossl_aria128ofb_functions), 2391cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_CFB, ossl_aria256cfb_functions), 2401cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_CFB, ossl_aria192cfb_functions), 2411cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_CFB, ossl_aria128cfb_functions), 2421cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_CFB1, ossl_aria256cfb1_functions), 2431cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_CFB1, ossl_aria192cfb1_functions), 2441cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_CFB1, ossl_aria128cfb1_functions), 2451cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_CFB8, ossl_aria256cfb8_functions), 2461cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_CFB8, ossl_aria192cfb8_functions), 2471cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_CFB8, ossl_aria128cfb8_functions), 2481cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_256_CTR, ossl_aria256ctr_functions), 2491cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_192_CTR, ossl_aria192ctr_functions), 2501cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ARIA_128_CTR, ossl_aria128ctr_functions), 2511cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_ARIA */ 2521cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_CAMELLIA 2531cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_ECB, ossl_camellia256ecb_functions), 2541cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_ECB, ossl_camellia192ecb_functions), 2551cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_ECB, ossl_camellia128ecb_functions), 2561cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_CBC, ossl_camellia256cbc_functions), 2571cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_CBC, ossl_camellia192cbc_functions), 2581cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_CBC, ossl_camellia128cbc_functions), 2591cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_CBC_CTS, ossl_camellia128cbc_cts_functions), 2601cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_CBC_CTS, ossl_camellia192cbc_cts_functions), 2611cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_CBC_CTS, ossl_camellia256cbc_cts_functions), 2621cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_OFB, ossl_camellia256ofb_functions), 2631cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_OFB, ossl_camellia192ofb_functions), 2641cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_OFB, ossl_camellia128ofb_functions), 2651cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_CFB, ossl_camellia256cfb_functions), 2661cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_CFB, ossl_camellia192cfb_functions), 2671cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_CFB, ossl_camellia128cfb_functions), 2681cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_CFB1, ossl_camellia256cfb1_functions), 2691cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_CFB1, ossl_camellia192cfb1_functions), 2701cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_CFB1, ossl_camellia128cfb1_functions), 2711cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_CFB8, ossl_camellia256cfb8_functions), 2721cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_CFB8, ossl_camellia192cfb8_functions), 2731cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_CFB8, ossl_camellia128cfb8_functions), 2741cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_256_CTR, ossl_camellia256ctr_functions), 2751cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_192_CTR, ossl_camellia192ctr_functions), 2761cb0ef41Sopenharmony_ci ALG(PROV_NAMES_CAMELLIA_128_CTR, ossl_camellia128ctr_functions), 2771cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_CAMELLIA */ 2781cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_DES 2791cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE3_ECB, ossl_tdes_ede3_ecb_functions), 2801cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE3_CBC, ossl_tdes_ede3_cbc_functions), 2811cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE3_OFB, ossl_tdes_ede3_ofb_functions), 2821cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE3_CFB, ossl_tdes_ede3_cfb_functions), 2831cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE3_CFB8, ossl_tdes_ede3_cfb8_functions), 2841cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE3_CFB1, ossl_tdes_ede3_cfb1_functions), 2851cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES3_WRAP, ossl_tdes_wrap_cbc_functions), 2861cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE_ECB, ossl_tdes_ede2_ecb_functions), 2871cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE_CBC, ossl_tdes_ede2_cbc_functions), 2881cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE_OFB, ossl_tdes_ede2_ofb_functions), 2891cb0ef41Sopenharmony_ci ALG(PROV_NAMES_DES_EDE_CFB, ossl_tdes_ede2_cfb_functions), 2901cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_DES */ 2911cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SM4 2921cb0ef41Sopenharmony_ci ALG(PROV_NAMES_SM4_ECB, ossl_sm4128ecb_functions), 2931cb0ef41Sopenharmony_ci ALG(PROV_NAMES_SM4_CBC, ossl_sm4128cbc_functions), 2941cb0ef41Sopenharmony_ci ALG(PROV_NAMES_SM4_CTR, ossl_sm4128ctr_functions), 2951cb0ef41Sopenharmony_ci ALG(PROV_NAMES_SM4_OFB, ossl_sm4128ofb128_functions), 2961cb0ef41Sopenharmony_ci ALG(PROV_NAMES_SM4_CFB, ossl_sm4128cfb128_functions), 2971cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_SM4 */ 2981cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_CHACHA 2991cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ChaCha20, ossl_chacha20_functions), 3001cb0ef41Sopenharmony_ci# ifndef OPENSSL_NO_POLY1305 3011cb0ef41Sopenharmony_ci ALG(PROV_NAMES_ChaCha20_Poly1305, ossl_chacha20_ossl_poly1305_functions), 3021cb0ef41Sopenharmony_ci# endif /* OPENSSL_NO_POLY1305 */ 3031cb0ef41Sopenharmony_ci#endif /* OPENSSL_NO_CHACHA */ 3041cb0ef41Sopenharmony_ci { { NULL, NULL, NULL }, NULL } 3051cb0ef41Sopenharmony_ci}; 3061cb0ef41Sopenharmony_cistatic OSSL_ALGORITHM exported_ciphers[OSSL_NELEM(deflt_ciphers)]; 3071cb0ef41Sopenharmony_ci 3081cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_macs[] = { 3091cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_BLAKE2 3101cb0ef41Sopenharmony_ci { PROV_NAMES_BLAKE2BMAC, "provider=default", ossl_blake2bmac_functions }, 3111cb0ef41Sopenharmony_ci { PROV_NAMES_BLAKE2SMAC, "provider=default", ossl_blake2smac_functions }, 3121cb0ef41Sopenharmony_ci#endif 3131cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_CMAC 3141cb0ef41Sopenharmony_ci { PROV_NAMES_CMAC, "provider=default", ossl_cmac_functions }, 3151cb0ef41Sopenharmony_ci#endif 3161cb0ef41Sopenharmony_ci { PROV_NAMES_GMAC, "provider=default", ossl_gmac_functions }, 3171cb0ef41Sopenharmony_ci { PROV_NAMES_HMAC, "provider=default", ossl_hmac_functions }, 3181cb0ef41Sopenharmony_ci { PROV_NAMES_KMAC_128, "provider=default", ossl_kmac128_functions }, 3191cb0ef41Sopenharmony_ci { PROV_NAMES_KMAC_256, "provider=default", ossl_kmac256_functions }, 3201cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SIPHASH 3211cb0ef41Sopenharmony_ci { PROV_NAMES_SIPHASH, "provider=default", ossl_siphash_functions }, 3221cb0ef41Sopenharmony_ci#endif 3231cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_POLY1305 3241cb0ef41Sopenharmony_ci { PROV_NAMES_POLY1305, "provider=default", ossl_poly1305_functions }, 3251cb0ef41Sopenharmony_ci#endif 3261cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 3271cb0ef41Sopenharmony_ci}; 3281cb0ef41Sopenharmony_ci 3291cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_kdfs[] = { 3301cb0ef41Sopenharmony_ci { PROV_NAMES_HKDF, "provider=default", ossl_kdf_hkdf_functions }, 3311cb0ef41Sopenharmony_ci { PROV_NAMES_TLS1_3_KDF, "provider=default", 3321cb0ef41Sopenharmony_ci ossl_kdf_tls1_3_kdf_functions }, 3331cb0ef41Sopenharmony_ci { PROV_NAMES_SSKDF, "provider=default", ossl_kdf_sskdf_functions }, 3341cb0ef41Sopenharmony_ci { PROV_NAMES_PBKDF2, "provider=default", ossl_kdf_pbkdf2_functions }, 3351cb0ef41Sopenharmony_ci { PROV_NAMES_PKCS12KDF, "provider=default", ossl_kdf_pkcs12_functions }, 3361cb0ef41Sopenharmony_ci { PROV_NAMES_SSHKDF, "provider=default", ossl_kdf_sshkdf_functions }, 3371cb0ef41Sopenharmony_ci { PROV_NAMES_X963KDF, "provider=default", ossl_kdf_x963_kdf_functions }, 3381cb0ef41Sopenharmony_ci { PROV_NAMES_TLS1_PRF, "provider=default", ossl_kdf_tls1_prf_functions }, 3391cb0ef41Sopenharmony_ci { PROV_NAMES_KBKDF, "provider=default", ossl_kdf_kbkdf_functions }, 3401cb0ef41Sopenharmony_ci { PROV_NAMES_X942KDF_ASN1, "provider=default", ossl_kdf_x942_kdf_functions }, 3411cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SCRYPT 3421cb0ef41Sopenharmony_ci { PROV_NAMES_SCRYPT, "provider=default", ossl_kdf_scrypt_functions }, 3431cb0ef41Sopenharmony_ci#endif 3441cb0ef41Sopenharmony_ci { PROV_NAMES_KRB5KDF, "provider=default", ossl_kdf_krb5kdf_functions }, 3451cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 3461cb0ef41Sopenharmony_ci}; 3471cb0ef41Sopenharmony_ci 3481cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_keyexch[] = { 3491cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_DH 3501cb0ef41Sopenharmony_ci { PROV_NAMES_DH, "provider=default", ossl_dh_keyexch_functions }, 3511cb0ef41Sopenharmony_ci#endif 3521cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_EC 3531cb0ef41Sopenharmony_ci { PROV_NAMES_ECDH, "provider=default", ossl_ecdh_keyexch_functions }, 3541cb0ef41Sopenharmony_ci { PROV_NAMES_X25519, "provider=default", ossl_x25519_keyexch_functions }, 3551cb0ef41Sopenharmony_ci { PROV_NAMES_X448, "provider=default", ossl_x448_keyexch_functions }, 3561cb0ef41Sopenharmony_ci#endif 3571cb0ef41Sopenharmony_ci { PROV_NAMES_TLS1_PRF, "provider=default", ossl_kdf_tls1_prf_keyexch_functions }, 3581cb0ef41Sopenharmony_ci { PROV_NAMES_HKDF, "provider=default", ossl_kdf_hkdf_keyexch_functions }, 3591cb0ef41Sopenharmony_ci { PROV_NAMES_SCRYPT, "provider=default", 3601cb0ef41Sopenharmony_ci ossl_kdf_scrypt_keyexch_functions }, 3611cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 3621cb0ef41Sopenharmony_ci}; 3631cb0ef41Sopenharmony_ci 3641cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_rands[] = { 3651cb0ef41Sopenharmony_ci { PROV_NAMES_CTR_DRBG, "provider=default", ossl_drbg_ctr_functions }, 3661cb0ef41Sopenharmony_ci { PROV_NAMES_HASH_DRBG, "provider=default", ossl_drbg_hash_functions }, 3671cb0ef41Sopenharmony_ci { PROV_NAMES_HMAC_DRBG, "provider=default", ossl_drbg_ossl_hmac_functions }, 3681cb0ef41Sopenharmony_ci { PROV_NAMES_SEED_SRC, "provider=default", ossl_seed_src_functions }, 3691cb0ef41Sopenharmony_ci { PROV_NAMES_TEST_RAND, "provider=default", ossl_test_rng_functions }, 3701cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 3711cb0ef41Sopenharmony_ci}; 3721cb0ef41Sopenharmony_ci 3731cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_signature[] = { 3741cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_DSA 3751cb0ef41Sopenharmony_ci { PROV_NAMES_DSA, "provider=default", ossl_dsa_signature_functions }, 3761cb0ef41Sopenharmony_ci#endif 3771cb0ef41Sopenharmony_ci { PROV_NAMES_RSA, "provider=default", ossl_rsa_signature_functions }, 3781cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_EC 3791cb0ef41Sopenharmony_ci { PROV_NAMES_ED25519, "provider=default", ossl_ed25519_signature_functions }, 3801cb0ef41Sopenharmony_ci { PROV_NAMES_ED448, "provider=default", ossl_ed448_signature_functions }, 3811cb0ef41Sopenharmony_ci { PROV_NAMES_ECDSA, "provider=default", ossl_ecdsa_signature_functions }, 3821cb0ef41Sopenharmony_ci# ifndef OPENSSL_NO_SM2 3831cb0ef41Sopenharmony_ci { PROV_NAMES_SM2, "provider=default", ossl_sm2_signature_functions }, 3841cb0ef41Sopenharmony_ci# endif 3851cb0ef41Sopenharmony_ci#endif 3861cb0ef41Sopenharmony_ci { PROV_NAMES_HMAC, "provider=default", ossl_mac_legacy_hmac_signature_functions }, 3871cb0ef41Sopenharmony_ci { PROV_NAMES_SIPHASH, "provider=default", 3881cb0ef41Sopenharmony_ci ossl_mac_legacy_siphash_signature_functions }, 3891cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_POLY1305 3901cb0ef41Sopenharmony_ci { PROV_NAMES_POLY1305, "provider=default", 3911cb0ef41Sopenharmony_ci ossl_mac_legacy_poly1305_signature_functions }, 3921cb0ef41Sopenharmony_ci#endif 3931cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_CMAC 3941cb0ef41Sopenharmony_ci { PROV_NAMES_CMAC, "provider=default", ossl_mac_legacy_cmac_signature_functions }, 3951cb0ef41Sopenharmony_ci#endif 3961cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 3971cb0ef41Sopenharmony_ci}; 3981cb0ef41Sopenharmony_ci 3991cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_asym_cipher[] = { 4001cb0ef41Sopenharmony_ci { PROV_NAMES_RSA, "provider=default", ossl_rsa_asym_cipher_functions }, 4011cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SM2 4021cb0ef41Sopenharmony_ci { PROV_NAMES_SM2, "provider=default", ossl_sm2_asym_cipher_functions }, 4031cb0ef41Sopenharmony_ci#endif 4041cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 4051cb0ef41Sopenharmony_ci}; 4061cb0ef41Sopenharmony_ci 4071cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_asym_kem[] = { 4081cb0ef41Sopenharmony_ci { PROV_NAMES_RSA, "provider=default", ossl_rsa_asym_kem_functions }, 4091cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 4101cb0ef41Sopenharmony_ci}; 4111cb0ef41Sopenharmony_ci 4121cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_keymgmt[] = { 4131cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_DH 4141cb0ef41Sopenharmony_ci { PROV_NAMES_DH, "provider=default", ossl_dh_keymgmt_functions, 4151cb0ef41Sopenharmony_ci PROV_DESCS_DH }, 4161cb0ef41Sopenharmony_ci { PROV_NAMES_DHX, "provider=default", ossl_dhx_keymgmt_functions, 4171cb0ef41Sopenharmony_ci PROV_DESCS_DHX }, 4181cb0ef41Sopenharmony_ci#endif 4191cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_DSA 4201cb0ef41Sopenharmony_ci { PROV_NAMES_DSA, "provider=default", ossl_dsa_keymgmt_functions, 4211cb0ef41Sopenharmony_ci PROV_DESCS_DSA}, 4221cb0ef41Sopenharmony_ci#endif 4231cb0ef41Sopenharmony_ci { PROV_NAMES_RSA, "provider=default", ossl_rsa_keymgmt_functions, 4241cb0ef41Sopenharmony_ci PROV_DESCS_RSA }, 4251cb0ef41Sopenharmony_ci { PROV_NAMES_RSA_PSS, "provider=default", ossl_rsapss_keymgmt_functions, 4261cb0ef41Sopenharmony_ci PROV_DESCS_RSA_PSS }, 4271cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_EC 4281cb0ef41Sopenharmony_ci { PROV_NAMES_EC, "provider=default", ossl_ec_keymgmt_functions, 4291cb0ef41Sopenharmony_ci PROV_DESCS_EC }, 4301cb0ef41Sopenharmony_ci { PROV_NAMES_X25519, "provider=default", ossl_x25519_keymgmt_functions, 4311cb0ef41Sopenharmony_ci PROV_DESCS_X25519 }, 4321cb0ef41Sopenharmony_ci { PROV_NAMES_X448, "provider=default", ossl_x448_keymgmt_functions, 4331cb0ef41Sopenharmony_ci PROV_DESCS_X448 }, 4341cb0ef41Sopenharmony_ci { PROV_NAMES_ED25519, "provider=default", ossl_ed25519_keymgmt_functions, 4351cb0ef41Sopenharmony_ci PROV_DESCS_ED25519 }, 4361cb0ef41Sopenharmony_ci { PROV_NAMES_ED448, "provider=default", ossl_ed448_keymgmt_functions, 4371cb0ef41Sopenharmony_ci PROV_DESCS_ED448 }, 4381cb0ef41Sopenharmony_ci#endif 4391cb0ef41Sopenharmony_ci { PROV_NAMES_TLS1_PRF, "provider=default", ossl_kdf_keymgmt_functions, 4401cb0ef41Sopenharmony_ci PROV_DESCS_TLS1_PRF_SIGN }, 4411cb0ef41Sopenharmony_ci { PROV_NAMES_HKDF, "provider=default", ossl_kdf_keymgmt_functions, 4421cb0ef41Sopenharmony_ci PROV_DESCS_HKDF_SIGN }, 4431cb0ef41Sopenharmony_ci { PROV_NAMES_SCRYPT, "provider=default", ossl_kdf_keymgmt_functions, 4441cb0ef41Sopenharmony_ci PROV_DESCS_SCRYPT_SIGN }, 4451cb0ef41Sopenharmony_ci { PROV_NAMES_HMAC, "provider=default", ossl_mac_legacy_keymgmt_functions, 4461cb0ef41Sopenharmony_ci PROV_DESCS_HMAC_SIGN }, 4471cb0ef41Sopenharmony_ci { PROV_NAMES_SIPHASH, "provider=default", ossl_mac_legacy_keymgmt_functions, 4481cb0ef41Sopenharmony_ci PROV_DESCS_SIPHASH_SIGN }, 4491cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_POLY1305 4501cb0ef41Sopenharmony_ci { PROV_NAMES_POLY1305, "provider=default", ossl_mac_legacy_keymgmt_functions, 4511cb0ef41Sopenharmony_ci PROV_DESCS_POLY1305_SIGN }, 4521cb0ef41Sopenharmony_ci#endif 4531cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_CMAC 4541cb0ef41Sopenharmony_ci { PROV_NAMES_CMAC, "provider=default", ossl_cmac_legacy_keymgmt_functions, 4551cb0ef41Sopenharmony_ci PROV_DESCS_CMAC_SIGN }, 4561cb0ef41Sopenharmony_ci#endif 4571cb0ef41Sopenharmony_ci#ifndef OPENSSL_NO_SM2 4581cb0ef41Sopenharmony_ci { PROV_NAMES_SM2, "provider=default", ossl_sm2_keymgmt_functions, 4591cb0ef41Sopenharmony_ci PROV_DESCS_SM2 }, 4601cb0ef41Sopenharmony_ci#endif 4611cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 4621cb0ef41Sopenharmony_ci}; 4631cb0ef41Sopenharmony_ci 4641cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_encoder[] = { 4651cb0ef41Sopenharmony_ci#define ENCODER_PROVIDER "default" 4661cb0ef41Sopenharmony_ci#include "encoders.inc" 4671cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 4681cb0ef41Sopenharmony_ci#undef ENCODER_PROVIDER 4691cb0ef41Sopenharmony_ci}; 4701cb0ef41Sopenharmony_ci 4711cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_decoder[] = { 4721cb0ef41Sopenharmony_ci#define DECODER_PROVIDER "default" 4731cb0ef41Sopenharmony_ci#include "decoders.inc" 4741cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 4751cb0ef41Sopenharmony_ci#undef DECODER_PROVIDER 4761cb0ef41Sopenharmony_ci}; 4771cb0ef41Sopenharmony_ci 4781cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM deflt_store[] = { 4791cb0ef41Sopenharmony_ci#define STORE(name, _fips, func_table) \ 4801cb0ef41Sopenharmony_ci { name, "provider=default,fips=" _fips, (func_table) }, 4811cb0ef41Sopenharmony_ci 4821cb0ef41Sopenharmony_ci#include "stores.inc" 4831cb0ef41Sopenharmony_ci { NULL, NULL, NULL } 4841cb0ef41Sopenharmony_ci#undef STORE 4851cb0ef41Sopenharmony_ci}; 4861cb0ef41Sopenharmony_ci 4871cb0ef41Sopenharmony_cistatic const OSSL_ALGORITHM *deflt_query(void *provctx, int operation_id, 4881cb0ef41Sopenharmony_ci int *no_cache) 4891cb0ef41Sopenharmony_ci{ 4901cb0ef41Sopenharmony_ci *no_cache = 0; 4911cb0ef41Sopenharmony_ci switch (operation_id) { 4921cb0ef41Sopenharmony_ci case OSSL_OP_DIGEST: 4931cb0ef41Sopenharmony_ci return deflt_digests; 4941cb0ef41Sopenharmony_ci case OSSL_OP_CIPHER: 4951cb0ef41Sopenharmony_ci return exported_ciphers; 4961cb0ef41Sopenharmony_ci case OSSL_OP_MAC: 4971cb0ef41Sopenharmony_ci return deflt_macs; 4981cb0ef41Sopenharmony_ci case OSSL_OP_KDF: 4991cb0ef41Sopenharmony_ci return deflt_kdfs; 5001cb0ef41Sopenharmony_ci case OSSL_OP_RAND: 5011cb0ef41Sopenharmony_ci return deflt_rands; 5021cb0ef41Sopenharmony_ci case OSSL_OP_KEYMGMT: 5031cb0ef41Sopenharmony_ci return deflt_keymgmt; 5041cb0ef41Sopenharmony_ci case OSSL_OP_KEYEXCH: 5051cb0ef41Sopenharmony_ci return deflt_keyexch; 5061cb0ef41Sopenharmony_ci case OSSL_OP_SIGNATURE: 5071cb0ef41Sopenharmony_ci return deflt_signature; 5081cb0ef41Sopenharmony_ci case OSSL_OP_ASYM_CIPHER: 5091cb0ef41Sopenharmony_ci return deflt_asym_cipher; 5101cb0ef41Sopenharmony_ci case OSSL_OP_KEM: 5111cb0ef41Sopenharmony_ci return deflt_asym_kem; 5121cb0ef41Sopenharmony_ci case OSSL_OP_ENCODER: 5131cb0ef41Sopenharmony_ci return deflt_encoder; 5141cb0ef41Sopenharmony_ci case OSSL_OP_DECODER: 5151cb0ef41Sopenharmony_ci return deflt_decoder; 5161cb0ef41Sopenharmony_ci case OSSL_OP_STORE: 5171cb0ef41Sopenharmony_ci return deflt_store; 5181cb0ef41Sopenharmony_ci } 5191cb0ef41Sopenharmony_ci return NULL; 5201cb0ef41Sopenharmony_ci} 5211cb0ef41Sopenharmony_ci 5221cb0ef41Sopenharmony_ci 5231cb0ef41Sopenharmony_cistatic void deflt_teardown(void *provctx) 5241cb0ef41Sopenharmony_ci{ 5251cb0ef41Sopenharmony_ci BIO_meth_free(ossl_prov_ctx_get0_core_bio_method(provctx)); 5261cb0ef41Sopenharmony_ci ossl_prov_ctx_free(provctx); 5271cb0ef41Sopenharmony_ci} 5281cb0ef41Sopenharmony_ci 5291cb0ef41Sopenharmony_ci/* Functions we provide to the core */ 5301cb0ef41Sopenharmony_cistatic const OSSL_DISPATCH deflt_dispatch_table[] = { 5311cb0ef41Sopenharmony_ci { OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))deflt_teardown }, 5321cb0ef41Sopenharmony_ci { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))deflt_gettable_params }, 5331cb0ef41Sopenharmony_ci { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))deflt_get_params }, 5341cb0ef41Sopenharmony_ci { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))deflt_query }, 5351cb0ef41Sopenharmony_ci { OSSL_FUNC_PROVIDER_GET_CAPABILITIES, 5361cb0ef41Sopenharmony_ci (void (*)(void))ossl_prov_get_capabilities }, 5371cb0ef41Sopenharmony_ci { 0, NULL } 5381cb0ef41Sopenharmony_ci}; 5391cb0ef41Sopenharmony_ci 5401cb0ef41Sopenharmony_ciOSSL_provider_init_fn ossl_default_provider_init; 5411cb0ef41Sopenharmony_ci 5421cb0ef41Sopenharmony_ciint ossl_default_provider_init(const OSSL_CORE_HANDLE *handle, 5431cb0ef41Sopenharmony_ci const OSSL_DISPATCH *in, 5441cb0ef41Sopenharmony_ci const OSSL_DISPATCH **out, 5451cb0ef41Sopenharmony_ci void **provctx) 5461cb0ef41Sopenharmony_ci{ 5471cb0ef41Sopenharmony_ci OSSL_FUNC_core_get_libctx_fn *c_get_libctx = NULL; 5481cb0ef41Sopenharmony_ci BIO_METHOD *corebiometh; 5491cb0ef41Sopenharmony_ci 5501cb0ef41Sopenharmony_ci if (!ossl_prov_bio_from_dispatch(in) 5511cb0ef41Sopenharmony_ci || !ossl_prov_seeding_from_dispatch(in)) 5521cb0ef41Sopenharmony_ci return 0; 5531cb0ef41Sopenharmony_ci for (; in->function_id != 0; in++) { 5541cb0ef41Sopenharmony_ci switch (in->function_id) { 5551cb0ef41Sopenharmony_ci case OSSL_FUNC_CORE_GETTABLE_PARAMS: 5561cb0ef41Sopenharmony_ci c_gettable_params = OSSL_FUNC_core_gettable_params(in); 5571cb0ef41Sopenharmony_ci break; 5581cb0ef41Sopenharmony_ci case OSSL_FUNC_CORE_GET_PARAMS: 5591cb0ef41Sopenharmony_ci c_get_params = OSSL_FUNC_core_get_params(in); 5601cb0ef41Sopenharmony_ci break; 5611cb0ef41Sopenharmony_ci case OSSL_FUNC_CORE_GET_LIBCTX: 5621cb0ef41Sopenharmony_ci c_get_libctx = OSSL_FUNC_core_get_libctx(in); 5631cb0ef41Sopenharmony_ci break; 5641cb0ef41Sopenharmony_ci default: 5651cb0ef41Sopenharmony_ci /* Just ignore anything we don't understand */ 5661cb0ef41Sopenharmony_ci break; 5671cb0ef41Sopenharmony_ci } 5681cb0ef41Sopenharmony_ci } 5691cb0ef41Sopenharmony_ci 5701cb0ef41Sopenharmony_ci if (c_get_libctx == NULL) 5711cb0ef41Sopenharmony_ci return 0; 5721cb0ef41Sopenharmony_ci 5731cb0ef41Sopenharmony_ci /* 5741cb0ef41Sopenharmony_ci * We want to make sure that all calls from this provider that requires 5751cb0ef41Sopenharmony_ci * a library context use the same context as the one used to call our 5761cb0ef41Sopenharmony_ci * functions. We do that by passing it along in the provider context. 5771cb0ef41Sopenharmony_ci * 5781cb0ef41Sopenharmony_ci * This only works for built-in providers. Most providers should 5791cb0ef41Sopenharmony_ci * create their own library context. 5801cb0ef41Sopenharmony_ci */ 5811cb0ef41Sopenharmony_ci if ((*provctx = ossl_prov_ctx_new()) == NULL 5821cb0ef41Sopenharmony_ci || (corebiometh = ossl_bio_prov_init_bio_method()) == NULL) { 5831cb0ef41Sopenharmony_ci ossl_prov_ctx_free(*provctx); 5841cb0ef41Sopenharmony_ci *provctx = NULL; 5851cb0ef41Sopenharmony_ci return 0; 5861cb0ef41Sopenharmony_ci } 5871cb0ef41Sopenharmony_ci ossl_prov_ctx_set0_libctx(*provctx, 5881cb0ef41Sopenharmony_ci (OSSL_LIB_CTX *)c_get_libctx(handle)); 5891cb0ef41Sopenharmony_ci ossl_prov_ctx_set0_handle(*provctx, handle); 5901cb0ef41Sopenharmony_ci ossl_prov_ctx_set0_core_bio_method(*provctx, corebiometh); 5911cb0ef41Sopenharmony_ci 5921cb0ef41Sopenharmony_ci *out = deflt_dispatch_table; 5931cb0ef41Sopenharmony_ci ossl_prov_cache_exported_algorithms(deflt_ciphers, exported_ciphers); 5941cb0ef41Sopenharmony_ci 5951cb0ef41Sopenharmony_ci return 1; 5961cb0ef41Sopenharmony_ci} 597