mirror of
https://github.com/openssl/openssl.git
synced 2024-12-21 06:09:35 +08:00
23b2fc0b50
The functions being: rsa_check_crt_components, rsa_check_key, rsa_check_pminusq_diff, rsa_check_prime_factor, rsa_check_prime_factor_range, rsa_check_private_exponent, rsa_check_public_exponent, rsa_digestinfo_encoding, rsa_fips186_4_gen_prob_primes, rsa_fromdata, rsa_get0_all_params, rsa_get0_libctx, rsa_get0_pss_params_30, rsa_get_lcm, rsa_mgf_nid2name, rsa_mp_coeff_names, rsa_mp_exp_names, rsa_mp_factor_names, rsa_new_with_ctx, rsa_oaeppss_md2nid, rsa_oaeppss_nid2name, rsa_padding_add_PKCS1_OAEP_mgf1_with_libctx, rsa_padding_add_PKCS1_type_2_with_libctx, rsa_padding_add_SSLv23_with_libctx, rsa_padding_check_PKCS1_type_2_TLS, rsa_pkey_method, rsa_pss_params_30_copy, rsa_pss_params_30_fromdata, rsa_pss_params_30_hashalg, rsa_pss_params_30_is_unrestricted, rsa_pss_params_30_maskgenalg, rsa_pss_params_30_maskgenhashalg, rsa_pss_params_30_saltlen, rsa_pss_params_30_set_defaults, rsa_pss_params_30_set_hashalg, rsa_pss_params_30_set_maskgenalg, rsa_pss_params_30_set_maskgenhashalg, rsa_pss_params_30_set_saltlen, rsa_pss_params_30_set_trailerfield, rsa_pss_params_30_todata, rsa_pss_params_30_trailerfield, rsa_pss_pkey_method, rsa_set0_all_params, rsa_sp800_56b_check_keypair, rsa_sp800_56b_check_private, rsa_sp800_56b_check_public, rsa_sp800_56b_derive_params_from_pq, rsa_sp800_56b_generate_key, rsa_sp800_56b_pairwise_test, rsa_sp800_56b_validate_strength, rsa_todata, rsa_validate_pairwise, rsa_validate_private and rsa_validate_public. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13040)
87 lines
2.5 KiB
C
87 lines
2.5 KiB
C
/*
|
|
* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
|
|
*
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*/
|
|
|
|
#include <openssl/core.h>
|
|
#include <openssl/core_names.h>
|
|
#include <openssl/evp.h>
|
|
#include <openssl/obj_mac.h>
|
|
#include "internal/nelem.h"
|
|
#include "crypto/rsa.h"
|
|
|
|
static int meth2nid(const void *meth,
|
|
int (*meth_is_a)(const void *meth, const char *name),
|
|
const OSSL_ITEM *items, size_t items_n)
|
|
{
|
|
size_t i;
|
|
|
|
if (meth != NULL)
|
|
for (i = 0; i < items_n; i++)
|
|
if (meth_is_a(meth, items[i].ptr))
|
|
return (int)items[i].id;
|
|
return NID_undef;
|
|
}
|
|
|
|
static const char *nid2name(int meth, const OSSL_ITEM *items, size_t items_n)
|
|
{
|
|
size_t i;
|
|
|
|
for (i = 0; i < items_n; i++)
|
|
if (meth == (int)items[i].id)
|
|
return items[i].ptr;
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* The list of permitted hash functions are taken from
|
|
* https://tools.ietf.org/html/rfc8017#appendix-A.2.1:
|
|
*
|
|
* OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
|
|
* { OID id-sha1 PARAMETERS NULL }|
|
|
* { OID id-sha224 PARAMETERS NULL }|
|
|
* { OID id-sha256 PARAMETERS NULL }|
|
|
* { OID id-sha384 PARAMETERS NULL }|
|
|
* { OID id-sha512 PARAMETERS NULL }|
|
|
* { OID id-sha512-224 PARAMETERS NULL }|
|
|
* { OID id-sha512-256 PARAMETERS NULL },
|
|
* ... -- Allows for future expansion --
|
|
* }
|
|
*/
|
|
static const OSSL_ITEM oaeppss_name_nid_map[] = {
|
|
{ NID_sha1, OSSL_DIGEST_NAME_SHA1 },
|
|
{ NID_sha224, OSSL_DIGEST_NAME_SHA2_224 },
|
|
{ NID_sha256, OSSL_DIGEST_NAME_SHA2_256 },
|
|
{ NID_sha384, OSSL_DIGEST_NAME_SHA2_384 },
|
|
{ NID_sha512, OSSL_DIGEST_NAME_SHA2_512 },
|
|
{ NID_sha512_224, OSSL_DIGEST_NAME_SHA2_512_224 },
|
|
{ NID_sha512_256, OSSL_DIGEST_NAME_SHA2_512_256 },
|
|
};
|
|
|
|
static int md_is_a(const void *md, const char *name)
|
|
{
|
|
return EVP_MD_is_a(md, name);
|
|
}
|
|
|
|
int ossl_rsa_oaeppss_md2nid(const EVP_MD *md)
|
|
{
|
|
return meth2nid(md, md_is_a,
|
|
oaeppss_name_nid_map, OSSL_NELEM(oaeppss_name_nid_map));
|
|
}
|
|
|
|
const char *ossl_rsa_oaeppss_nid2name(int md)
|
|
{
|
|
return nid2name(md, oaeppss_name_nid_map, OSSL_NELEM(oaeppss_name_nid_map));
|
|
}
|
|
|
|
const char *ossl_rsa_mgf_nid2name(int mgf)
|
|
{
|
|
if (mgf == NID_mgf1)
|
|
return SN_mgf1;
|
|
return NULL;
|
|
}
|