25 #ifndef WOLFSSL_RSA_H_ 26 #define WOLFSSL_RSA_H_ 29 #include <wolfssl/openssl/err.h> 37 #define RSA_PKCS1_PADDING 0 38 #define RSA_PKCS1_OAEP_PADDING 1 39 #define RSA_PKCS1_PSS_PADDING 2 40 #define RSA_NO_PADDING 3 43 #define RSA_METHOD_FLAG_NO_CHECK (1 << 1) 44 #define RSA_FLAG_CACHE_PUBLIC (1 << 2) 45 #define RSA_FLAG_CACHE_PRIVATE (1 << 3) 46 #define RSA_FLAG_BLINDING (1 << 4) 47 #define RSA_FLAG_THREAD_SAFE (1 << 5) 48 #define RSA_FLAG_EXT_PKEY (1 << 6) 49 #define RSA_FLAG_NO_BLINDING (1 << 7) 50 #define RSA_FLAG_NO_CONSTTIME (1 << 8) 53 #define RSA_PSS_SALTLEN_DIGEST -1 55 #define RSA_PSS_SALTLEN_MAX_SIGN -2 57 #define RSA_PSS_SALTLEN_MAX -3 59 typedef struct WOLFSSL_RSA_METHOD {
64 #ifndef WOLFSSL_RSA_TYPE_DEFINED 65 #define WOLFSSL_RSA_TYPE_DEFINED 67 #ifdef WC_RSA_BLINDING 83 #if defined(OPENSSL_EXTRA) 84 WOLFSSL_RSA_METHOD* meth;
86 #if defined(HAVE_EX_DATA) 87 WOLFSSL_CRYPTO_EX_DATA ex_data;
89 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) 90 wolfSSL_Mutex refMutex;
97 typedef WOLFSSL_RSA_METHOD RSA_METHOD;
102 WOLFSSL_API
int wolfSSL_RSA_generate_key_ex(
WOLFSSL_RSA*,
int bits, WOLFSSL_BIGNUM*,
105 WOLFSSL_API
int wolfSSL_RSA_blinding_on(
WOLFSSL_RSA*, WOLFSSL_BN_CTX*);
106 WOLFSSL_API
int wolfSSL_RSA_public_encrypt(
int len,
const unsigned char* fr,
108 WOLFSSL_API
int wolfSSL_RSA_private_decrypt(
int len,
const unsigned char* fr,
110 WOLFSSL_API
int wolfSSL_RSA_private_encrypt(
int len,
unsigned char* in,
111 unsigned char* out,
WOLFSSL_RSA* rsa,
int padding);
113 WOLFSSL_API
int wolfSSL_RSA_size(
const WOLFSSL_RSA*);
114 WOLFSSL_API
int wolfSSL_RSA_sign(
int type,
const unsigned char* m,
115 unsigned int mLen,
unsigned char* sigRet,
117 WOLFSSL_API
int wolfSSL_RSA_sign_ex(
int type,
const unsigned char* m,
118 unsigned int mLen,
unsigned char* sigRet,
120 WOLFSSL_API
int wolfSSL_RSA_verify(
int type,
const unsigned char* m,
121 unsigned int mLen,
const unsigned char* sig,
123 WOLFSSL_API
int wolfSSL_RSA_public_decrypt(
int flen,
const unsigned char* from,
126 WOLFSSL_API
int wolfSSL_RSA_LoadDer(
WOLFSSL_RSA*,
const unsigned char*,
int sz);
127 WOLFSSL_API
int wolfSSL_RSA_LoadDer_ex(
WOLFSSL_RSA*,
const unsigned char*,
int sz,
int opt);
129 WOLFSSL_API WOLFSSL_RSA_METHOD *wolfSSL_RSA_meth_new(
const char *name,
int flags);
130 WOLFSSL_API
void wolfSSL_RSA_meth_free(WOLFSSL_RSA_METHOD *meth);
131 WOLFSSL_API
int wolfSSL_RSA_meth_set(WOLFSSL_RSA_METHOD *rsa,
void* p);
132 WOLFSSL_API
int wolfSSL_RSA_set_method(
WOLFSSL_RSA *rsa, WOLFSSL_RSA_METHOD *meth);
133 WOLFSSL_API
const WOLFSSL_RSA_METHOD* wolfSSL_RSA_get_method(
const WOLFSSL_RSA *rsa);
134 WOLFSSL_API
const WOLFSSL_RSA_METHOD* wolfSSL_RSA_get_default_method(
void);
136 WOLFSSL_API
void wolfSSL_RSA_get0_key(
const WOLFSSL_RSA *r,
const WOLFSSL_BIGNUM **n,
137 const WOLFSSL_BIGNUM **e,
const WOLFSSL_BIGNUM **d);
138 WOLFSSL_API
int wolfSSL_RSA_set0_key(
WOLFSSL_RSA *r, WOLFSSL_BIGNUM *n, WOLFSSL_BIGNUM *e,
140 WOLFSSL_API
int wolfSSL_RSA_flags(
const WOLFSSL_RSA *r);
141 WOLFSSL_API
void wolfSSL_RSA_set_flags(
WOLFSSL_RSA *r,
int flags);
145 WOLFSSL_API
void* wolfSSL_RSA_get_ex_data(
const WOLFSSL_RSA *rsa,
int idx);
146 WOLFSSL_API
int wolfSSL_RSA_set_ex_data(
WOLFSSL_RSA *rsa,
int idx,
void *data);
149 #define WOLFSSL_RSA_LOAD_PRIVATE 1 150 #define WOLFSSL_RSA_LOAD_PUBLIC 2 151 #define WOLFSSL_RSA_F4 0x10001L 153 #define RSA_new wolfSSL_RSA_new 154 #define RSA_free wolfSSL_RSA_free 156 #define RSA_generate_key_ex wolfSSL_RSA_generate_key_ex 158 #define RSA_blinding_on wolfSSL_RSA_blinding_on 159 #define RSA_public_encrypt wolfSSL_RSA_public_encrypt 160 #define RSA_private_decrypt wolfSSL_RSA_private_decrypt 161 #define RSA_private_encrypt wolfSSL_RSA_private_encrypt 163 #define RSA_size wolfSSL_RSA_size 164 #define RSA_sign wolfSSL_RSA_sign 165 #define RSA_verify wolfSSL_RSA_verify 166 #define RSA_public_decrypt wolfSSL_RSA_public_decrypt 168 #define RSA_meth_new wolfSSL_RSA_meth_new 169 #define RSA_meth_free wolfSSL_RSA_meth_free 170 #define RSA_meth_set_pub_enc wolfSSL_RSA_meth_set 171 #define RSA_meth_set_pub_dec wolfSSL_RSA_meth_set 172 #define RSA_meth_set_priv_enc wolfSSL_RSA_meth_set 173 #define RSA_meth_set_priv_dec wolfSSL_RSA_meth_set 174 #define RSA_meth_set_init wolfSSL_RSA_meth_set 175 #define RSA_meth_set_finish wolfSSL_RSA_meth_set 176 #define RSA_meth_set0_app_data wolfSSL_RSA_meth_set 177 #define RSA_get_default_method wolfSSL_RSA_get_default_method 178 #define RSA_get_method wolfSSL_RSA_get_method 179 #define RSA_set_method wolfSSL_RSA_set_method 180 #define RSA_get0_key wolfSSL_RSA_get0_key 181 #define RSA_set0_key wolfSSL_RSA_set0_key 182 #define RSA_flags wolfSSL_RSA_flags 183 #define RSA_set_flags wolfSSL_RSA_set_flags 185 #define RSAPublicKey_dup wolfSSL_RSAPublicKey_dup 186 #define RSA_get_ex_data wolfSSL_RSA_get_ex_data 187 #define RSA_set_ex_data wolfSSL_RSA_set_ex_data 189 #define RSA_get0_key wolfSSL_RSA_get0_key 191 #define RSA_F4 WOLFSSL_RSA_F4