]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/crypto/rsa.h
RSA: Be less strict on PSS parameters when exporting to provider
[thirdparty/openssl.git] / include / crypto / rsa.h
CommitLineData
c3a4fa4c 1/*
33388b44 2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
c3a4fa4c
RL
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_INTERNAL_RSA_H
11# define OSSL_INTERNAL_RSA_H
12
4f2271d5
SL
13# include <openssl/core.h>
14# include <openssl/rsa.h>
c3a4fa4c 15
15671090
RL
16typedef struct rsa_pss_params_30_st {
17 int hash_algorithm_nid;
18 struct {
19 int algorithm_nid; /* Currently always NID_mgf1 */
20 int hash_algorithm_nid;
21 } mask_gen;
6ce6ad39
RL
22 int salt_len;
23 int trailer_field;
15671090
RL
24} RSA_PSS_PARAMS_30;
25
26RSA_PSS_PARAMS_30 *rsa_get0_pss_params_30(RSA *r);
27int rsa_pss_params_30_set_defaults(RSA_PSS_PARAMS_30 *rsa_pss_params);
28int rsa_pss_params_30_copy(RSA_PSS_PARAMS_30 *to,
29 const RSA_PSS_PARAMS_30 *from);
30int rsa_pss_params_30_is_unrestricted(const RSA_PSS_PARAMS_30 *rsa_pss_params);
31int rsa_pss_params_30_set_hashalg(RSA_PSS_PARAMS_30 *rsa_pss_params,
32 int hashalg_nid);
33int rsa_pss_params_30_set_maskgenalg(RSA_PSS_PARAMS_30 *rsa_pss_params,
34 int maskgenalg_nid);
35int rsa_pss_params_30_set_maskgenhashalg(RSA_PSS_PARAMS_30 *rsa_pss_params,
36 int maskgenhashalg_nid);
37int rsa_pss_params_30_set_saltlen(RSA_PSS_PARAMS_30 *rsa_pss_params,
38 int saltlen);
39int rsa_pss_params_30_set_trailerfield(RSA_PSS_PARAMS_30 *rsa_pss_params,
40 int trailerfield);
41int rsa_pss_params_30_hashalg(const RSA_PSS_PARAMS_30 *rsa_pss_params);
42int rsa_pss_params_30_maskgenalg(const RSA_PSS_PARAMS_30 *rsa_pss_params);
43int rsa_pss_params_30_maskgenhashalg(const RSA_PSS_PARAMS_30 *rsa_pss_params);
44int rsa_pss_params_30_saltlen(const RSA_PSS_PARAMS_30 *rsa_pss_params);
45int rsa_pss_params_30_trailerfield(const RSA_PSS_PARAMS_30 *rsa_pss_params);
46
e9d6186e
RL
47const char *rsa_mgf_nid2name(int mgf);
48int rsa_oaeppss_md2nid(const EVP_MD *md);
49const char *rsa_oaeppss_nid2name(int md);
50
afb638f1 51RSA *rsa_new_with_ctx(OPENSSL_CTX *libctx);
8a758e96 52OPENSSL_CTX *rsa_get0_libctx(RSA *r);
afb638f1 53
c3a4fa4c
RL
54int rsa_set0_all_params(RSA *r, const STACK_OF(BIGNUM) *primes,
55 const STACK_OF(BIGNUM) *exps,
56 const STACK_OF(BIGNUM) *coeffs);
57int rsa_get0_all_params(RSA *r, STACK_OF(BIGNUM_const) *primes,
58 STACK_OF(BIGNUM_const) *exps,
59 STACK_OF(BIGNUM_const) *coeffs);
645a541a
RL
60
61int rsa_todata(RSA *rsa, OSSL_PARAM_BLD *bld, OSSL_PARAM params[]);
0abae163 62int rsa_fromdata(RSA *rsa, const OSSL_PARAM params[]);
15671090
RL
63int rsa_pss_params_30_todata(const RSA_PSS_PARAMS_30 *pss, const char *propq,
64 OSSL_PARAM_BLD *bld, OSSL_PARAM params[]);
65int rsa_pss_params_30_fromdata(RSA_PSS_PARAMS_30 *pss_params,
66 const OSSL_PARAM params[], OPENSSL_CTX *libctx);
d9a75107 67
0f2deef5
MC
68int rsa_padding_check_PKCS1_type_2_TLS(OPENSSL_CTX *ctx, unsigned char *to,
69 size_t tlen, const unsigned char *from,
70 size_t flen, int client_version,
71 int alt_version);
f7f53d7d
RL
72int rsa_padding_add_PKCS1_OAEP_mgf1_with_libctx(OPENSSL_CTX *libctx,
73 unsigned char *to, int tlen,
74 const unsigned char *from,
75 int flen,
76 const unsigned char *param,
77 int plen, const EVP_MD *md,
78 const EVP_MD *mgf1md);
12603de6
SL
79
80int rsa_validate_public(const RSA *key);
81int rsa_validate_private(const RSA *key);
82int rsa_validate_pairwise(const RSA *key);
83
6f4b7663
RL
84int int_rsa_verify(int dtype, const unsigned char *m,
85 unsigned int m_len, unsigned char *rm,
86 size_t *prm_len, const unsigned char *sigbuf,
87 size_t siglen, RSA *rsa);
88
89const unsigned char *rsa_digestinfo_encoding(int md_nid, size_t *len);
90const unsigned char *rsa_algorithmidentifier_encoding(int md_nid, size_t *len);
91
96ebe52e
SL
92extern const char *rsa_mp_factor_names[];
93extern const char *rsa_mp_exp_names[];
94extern const char *rsa_mp_coeff_names[];
95
4f2271d5
SL
96# if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS)
97int rsa_acvp_test_gen_params_new(OSSL_PARAM **dst, const OSSL_PARAM src[]);
98void rsa_acvp_test_gen_params_free(OSSL_PARAM *dst);
99
100int rsa_acvp_test_set_params(RSA *r, const OSSL_PARAM params[]);
101int rsa_acvp_test_get_params(RSA *r, OSSL_PARAM params[]);
102typedef struct rsa_acvp_test_st RSA_ACVP_TEST;
103void rsa_acvp_test_free(RSA_ACVP_TEST *t);
104# else
105# define RSA_ACVP_TEST void
106# endif
107
c3a4fa4c 108#endif