Go to the documentation of this file.
73 #include "../bn/internal.h"
74 #include "../delocate.h"
75 #include "../../internal.h"
100 if (rsa->
meth == NULL) {
217 if (out_dmp1 != NULL) {
218 *out_dmp1 = rsa->
dmp1;
220 if (out_dmq1 != NULL) {
221 *out_dmq1 = rsa->
dmq1;
223 if (out_iqmp != NULL) {
224 *out_iqmp = rsa->
iqmp;
229 if ((rsa->
n == NULL &&
n == NULL) ||
230 (rsa->
e == NULL && e == NULL)) {
251 if ((rsa->
p == NULL &&
p == NULL) ||
252 (rsa->
q == NULL && q == NULL)) {
269 if ((rsa->
dmp1 == NULL && dmp1 == NULL) ||
270 (rsa->
dmq1 == NULL && dmq1 == NULL) ||
271 (rsa->
iqmp == NULL && iqmp == NULL)) {
299 if (out_len > INT_MAX) {
307 const uint8_t *
in,
size_t in_len,
int padding) {
323 if (out_len > INT_MAX) {
331 const uint8_t *
in,
size_t in_len,
int padding) {
347 if (out_len > INT_MAX) {
362 if (out_len > INT_MAX) {
423 {0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
424 0x02, 0x05, 0x05, 0x00, 0x04, 0x10},
430 {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05,
437 {0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
438 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1c},
444 {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
445 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20},
451 {0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
452 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30},
458 {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,
459 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40},
490 if (digest_len != sig_prefix->
hash_len) {
496 unsigned prefix_len = sig_prefix->
len;
497 unsigned signed_msg_len;
500 signed_msg_len = prefix_len + digest_len;
501 if (signed_msg_len < prefix_len) {
515 *out_msg = signed_msg;
516 *out_msg_len = signed_msg_len;
528 const unsigned rsa_size =
RSA_size(rsa);
531 size_t signed_msg_len = 0;
532 int signed_msg_is_alloced = 0;
533 size_t size_t_out_len;
540 &signed_msg_is_alloced,
hash_nid, digest,
547 *out_len = size_t_out_len;
551 if (signed_msg_is_alloced) {
558 const uint8_t *digest,
size_t digest_len,
567 if (padded == NULL) {
581 const uint8_t *sig,
size_t sig_len,
RSA *rsa) {
582 if (rsa->
n == NULL || rsa->
e == NULL) {
587 const size_t rsa_size =
RSA_size(rsa);
591 size_t signed_msg_len = 0,
len;
592 int signed_msg_is_alloced = 0;
611 &signed_msg_is_alloced,
hash_nid, digest,
627 if (signed_msg_is_alloced) {
635 const uint8_t *sig,
size_t sig_len) {
666 const BIGNUM *
m,
unsigned m_min_bits,
704 if ((
key->p != NULL) != (
key->q != NULL)) {
711 if (
key->d != NULL &&
717 if (
key->d == NULL ||
key->p == NULL) {
778 int has_crt_values =
key->dmp1 != NULL;
779 if (has_crt_values != (
key->dmq1 != NULL) ||
780 has_crt_values != (
key->iqmp != NULL)) {
785 if (has_crt_values) {
786 int dmp1_ok, dmq1_ok, iqmp_ok;
797 if (!dmp1_ok || !dmq1_ok || !iqmp_ok) {
820 TOBN(0xc4309333, 0x3ef4e3e1), TOBN(0x71161eb6, 0xcd2d655f),
821 TOBN(0x95e2238c, 0x0bf94862), TOBN(0x3eb233d3, 0x24f7912b),
822 TOBN(0x6b55514b, 0xbf26c483), TOBN(0x0a84d817, 0x5a144871),
823 TOBN(0x77d12fee, 0x9b82210a), TOBN(0xdb5b93c2, 0x97f050b3),
824 TOBN(0x4acad6b9, 0x4d6c026b), TOBN(0xeb7751f3, 0x54aec893),
825 TOBN(0xdba53368, 0x36bc85c4), TOBN(0xd85a1b28, 0x7f5ec78e),
826 TOBN(0x2eb072d8, 0x6b322244), TOBN(0xbba51112, 0x5e2b3aea),
827 TOBN(0x36ed1a6c, 0x0e2486bf), TOBN(0x5f270460, 0xec0c5727),
885 if (!
ret ||
key->d == NULL ||
key->p == NULL) {
908 #if defined(BORINGSSL_FIPS_BREAK_RSA_PWCT)
#define RSA_R_VALUE_MISSING
#define RSA_R_N_NOT_EQUAL_P_Q
#define RSA_R_INCONSISTENT_SET_OF_CRT_VALUES
#define RSA_R_D_OUT_OF_RANGE
const RSA_METHOD * RSA_default_method(void)
int RSA_private_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, int padding)
int RSA_set_ex_data(RSA *rsa, int idx, void *arg)
int(* sign)(int type, const uint8_t *m, unsigned int m_length, uint8_t *sigret, unsigned int *siglen, const RSA *rsa)
static const BN_ULONG kSmallFactorsLimbs[]
static int OPENSSL_memcmp(const void *s1, const void *s2, size_t n)
#define BN_FLG_STATIC_DATA
const BIGNUM * RSA_get0_dmq1(const RSA *rsa)
int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, void **from_d, int index, long argl, void *argp)
#define DEFINE_STATIC_EX_DATA_CLASS(name)
#define RSA_verify_PKCS1_PSS_mgf1
int RSA_add_pkcs1_prefix(uint8_t **out_msg, size_t *out_msg_len, int *is_alloced, int hash_nid, const uint8_t *digest, size_t digest_len)
#define OPENSSL_PUT_ERROR(library, reason)
#define OPENSSL_ARRAY_SIZE(array)
static int check_mod_inverse(int *out_ok, const BIGNUM *a, const BIGNUM *ainv, const BIGNUM *m, unsigned m_min_bits, BN_CTX *ctx)
const BIGNUM * RSA_get0_n(const RSA *rsa)
int RSA_public_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, int padding)
int RSA_sign_raw(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding)
int RSA_set0_crt_params(RSA *rsa, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
OPENSSL_EXPORT pem_password_cb void * u
static const unsigned SSL_SIG_LENGTH
#define ENGINE_get_RSA_method
@ bn_non_prime_power_composite
int RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d)
#define CRYPTO_MUTEX_init
#define rsa_default_private_transform
static void * OPENSSL_memset(void *dst, int c, size_t n)
int RSA_check_key(const RSA *key)
const BIGNUM * RSA_get0_d(const RSA *rsa)
const OPENSSL_EXPORT BIGNUM * BN_value_one(void)
#define RSA_R_INVALID_MESSAGE_LENGTH
#define CRYPTO_free_ex_data
size_t(* size)(const RSA *rsa)
#define RSA_padding_add_PKCS1_PSS_mgf1
#define SHA384_DIGEST_LENGTH
#define RSA_PKCS1_PADDING
int RSA_is_opaque(const RSA *rsa)
#define RSA_R_ONLY_ONE_OF_P_Q_GIVEN
#define BN_enhanced_miller_rabin_primality_test
int RSA_verify(int hash_nid, const uint8_t *digest, size_t digest_len, const uint8_t *sig, size_t sig_len, RSA *rsa)
RSA * RSA_new_method(const ENGINE *engine)
void RSA_get0_factors(const RSA *rsa, const BIGNUM **out_p, const BIGNUM **out_q)
unsigned RSA_size(const RSA *rsa)
#define RSA_R_UNKNOWN_ALGORITHM_TYPE
int RSA_private_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, int padding)
BIGNUM * inv_small_mod_large_mont
#define bn_usub_consttime
static const struct pkcs1_sig_prefix kPKCS1SigPrefixes[]
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
#define rsa_default_sign_raw
int RSA_blinding_on(RSA *rsa, BN_CTX *ctx)
#define ERR_R_INTERNAL_ERROR
int(* sign_raw)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding)
#define CRYPTO_new_ex_data
#define RSA_R_D_E_NOT_CONGRUENT_TO_1
void RSA_get0_crt_params(const RSA *rsa, const BIGNUM **out_dmp1, const BIGNUM **out_dmq1, const BIGNUM **out_iqmp)
#define SHA512_DIGEST_LENGTH
#define OPENSSL_DECLARE_ERROR_REASON(lib, reason)
const RSA_PSS_PARAMS * RSA_get0_pss_params(const RSA *rsa)
void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int index, long argl, void *argp)
const BIGNUM * RSA_get0_iqmp(const RSA *rsa)
unsigned char * blindings_inuse
#define CRYPTO_get_ex_data
int RSA_verify_pss_mgf1(RSA *rsa, const uint8_t *digest, size_t digest_len, const EVP_MD *md, const EVP_MD *mgf1_md, int salt_len, const uint8_t *sig, size_t sig_len)
int RSA_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, size_t len)
#define CRYPTO_MUTEX_cleanup
const BIGNUM * RSA_get0_e(const RSA *rsa)
#define CRYPTO_get_ex_new_index
#define SHA224_DIGEST_LENGTH
int RSA_sign(int hash_nid, const uint8_t *digest, unsigned digest_len, uint8_t *out, unsigned *out_len, RSA *rsa)
#define RSA_R_BAD_SIGNATURE
void RSA_get0_key(const RSA *rsa, const BIGNUM **out_n, const BIGNUM **out_e, const BIGNUM **out_d)
int RSA_flags(const RSA *rsa)
UniquePtr< SSL_SESSION > ret
int RSA_public_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, int padding)
const BIGNUM * RSA_get0_p(const RSA *rsa)
#define SHA256_DIGEST_LENGTH
#define MD5_DIGEST_LENGTH
unsigned RSA_bits(const RSA *rsa)
static const char prefix[]
CRYPTO_refcount_t references
#define RSA_R_PUBLIC_KEY_VALIDATION_FAILED
DEFINE_LOCAL_DATA(BIGNUM, g_small_factors)
#define SHA_DIGEST_LENGTH
int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused, CRYPTO_EX_dup *dup_unused, CRYPTO_EX_free *free_func)
int(* private_transform)(RSA *rsa, uint8_t *out, const uint8_t *in, size_t len)
void * RSA_get_ex_data(const RSA *rsa, int idx)
int RSA_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding)
#define CRYPTO_refcount_inc
int RSA_sign_pss_mgf1(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *digest, size_t digest_len, const EVP_MD *md, const EVP_MD *mgf1_md, int salt_len)
int RSA_check_fips(RSA *key)
#define rsa_check_public_key
#define CRYPTO_set_ex_data
const BIGNUM * RSA_get0_q(const RSA *rsa)
int(* decrypt)(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding)
int RSA_set0_factors(RSA *rsa, BIGNUM *p, BIGNUM *q)
#define rsa_default_decrypt
#define ERR_R_MALLOC_FAILURE
#define RSA_R_CRT_VALUES_INCORRECT
#define CRYPTO_refcount_dec_and_test_zero
#define BN_prime_checks_for_generation
const BIGNUM * RSA_get0_dmp1(const RSA *rsa)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:13