Lines Matching refs:rsa
88 RSA *rsa = OPENSSL_malloc(sizeof(RSA)); in RSA_new_method() local
89 if (rsa == NULL) { in RSA_new_method()
94 OPENSSL_memset(rsa, 0, sizeof(RSA)); in RSA_new_method()
97 rsa->meth = ENGINE_get_RSA_method(engine); in RSA_new_method()
100 if (rsa->meth == NULL) { in RSA_new_method()
101 rsa->meth = (RSA_METHOD *) RSA_default_method(); in RSA_new_method()
103 METHOD_ref(rsa->meth); in RSA_new_method()
105 rsa->references = 1; in RSA_new_method()
106 rsa->flags = rsa->meth->flags; in RSA_new_method()
107 CRYPTO_MUTEX_init(&rsa->lock); in RSA_new_method()
108 CRYPTO_new_ex_data(&rsa->ex_data); in RSA_new_method()
110 if (rsa->meth->init && !rsa->meth->init(rsa)) { in RSA_new_method()
111 CRYPTO_free_ex_data(g_rsa_ex_data_class_bss_get(), rsa, &rsa->ex_data); in RSA_new_method()
112 CRYPTO_MUTEX_cleanup(&rsa->lock); in RSA_new_method()
113 METHOD_unref(rsa->meth); in RSA_new_method()
114 OPENSSL_free(rsa); in RSA_new_method()
118 return rsa; in RSA_new_method()
121 void RSA_free(RSA *rsa) { in RSA_free() argument
124 if (rsa == NULL) { in RSA_free()
128 if (!CRYPTO_refcount_dec_and_test_zero(&rsa->references)) { in RSA_free()
132 if (rsa->meth->finish) { in RSA_free()
133 rsa->meth->finish(rsa); in RSA_free()
135 METHOD_unref(rsa->meth); in RSA_free()
137 CRYPTO_free_ex_data(g_rsa_ex_data_class_bss_get(), rsa, &rsa->ex_data); in RSA_free()
139 BN_free(rsa->n); in RSA_free()
140 BN_free(rsa->e); in RSA_free()
141 BN_free(rsa->d); in RSA_free()
142 BN_free(rsa->p); in RSA_free()
143 BN_free(rsa->q); in RSA_free()
144 BN_free(rsa->dmp1); in RSA_free()
145 BN_free(rsa->dmq1); in RSA_free()
146 BN_free(rsa->iqmp); in RSA_free()
147 BN_MONT_CTX_free(rsa->mont_n); in RSA_free()
148 BN_MONT_CTX_free(rsa->mont_p); in RSA_free()
149 BN_MONT_CTX_free(rsa->mont_q); in RSA_free()
150 BN_free(rsa->d_fixed); in RSA_free()
151 BN_free(rsa->dmp1_fixed); in RSA_free()
152 BN_free(rsa->dmq1_fixed); in RSA_free()
153 BN_free(rsa->inv_small_mod_large_mont); in RSA_free()
154 for (u = 0; u < rsa->num_blindings; u++) { in RSA_free()
155 BN_BLINDING_free(rsa->blindings[u]); in RSA_free()
157 OPENSSL_free(rsa->blindings); in RSA_free()
158 OPENSSL_free(rsa->blindings_inuse); in RSA_free()
159 CRYPTO_MUTEX_cleanup(&rsa->lock); in RSA_free()
160 OPENSSL_free(rsa); in RSA_free()
163 int RSA_up_ref(RSA *rsa) { in RSA_up_ref() argument
164 CRYPTO_refcount_inc(&rsa->references); in RSA_up_ref()
168 unsigned RSA_bits(const RSA *rsa) { return BN_num_bits(rsa->n); } in RSA_bits() argument
170 void RSA_get0_key(const RSA *rsa, const BIGNUM **out_n, const BIGNUM **out_e, in RSA_get0_key() argument
173 *out_n = rsa->n; in RSA_get0_key()
176 *out_e = rsa->e; in RSA_get0_key()
179 *out_d = rsa->d; in RSA_get0_key()
183 void RSA_get0_factors(const RSA *rsa, const BIGNUM **out_p, in RSA_get0_factors() argument
186 *out_p = rsa->p; in RSA_get0_factors()
189 *out_q = rsa->q; in RSA_get0_factors()
193 void RSA_get0_crt_params(const RSA *rsa, const BIGNUM **out_dmp1, in RSA_get0_crt_params() argument
196 *out_dmp1 = rsa->dmp1; in RSA_get0_crt_params()
199 *out_dmq1 = rsa->dmq1; in RSA_get0_crt_params()
202 *out_iqmp = rsa->iqmp; in RSA_get0_crt_params()
206 int RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d) { in RSA_set0_key() argument
207 if ((rsa->n == NULL && n == NULL) || in RSA_set0_key()
208 (rsa->e == NULL && e == NULL)) { in RSA_set0_key()
213 BN_free(rsa->n); in RSA_set0_key()
214 rsa->n = n; in RSA_set0_key()
217 BN_free(rsa->e); in RSA_set0_key()
218 rsa->e = e; in RSA_set0_key()
221 BN_free(rsa->d); in RSA_set0_key()
222 rsa->d = d; in RSA_set0_key()
228 int RSA_set0_factors(RSA *rsa, BIGNUM *p, BIGNUM *q) { in RSA_set0_factors() argument
229 if ((rsa->p == NULL && p == NULL) || in RSA_set0_factors()
230 (rsa->q == NULL && q == NULL)) { in RSA_set0_factors()
235 BN_free(rsa->p); in RSA_set0_factors()
236 rsa->p = p; in RSA_set0_factors()
239 BN_free(rsa->q); in RSA_set0_factors()
240 rsa->q = q; in RSA_set0_factors()
246 int RSA_set0_crt_params(RSA *rsa, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) { in RSA_set0_crt_params() argument
247 if ((rsa->dmp1 == NULL && dmp1 == NULL) || in RSA_set0_crt_params()
248 (rsa->dmq1 == NULL && dmq1 == NULL) || in RSA_set0_crt_params()
249 (rsa->iqmp == NULL && iqmp == NULL)) { in RSA_set0_crt_params()
254 BN_free(rsa->dmp1); in RSA_set0_crt_params()
255 rsa->dmp1 = dmp1; in RSA_set0_crt_params()
258 BN_free(rsa->dmq1); in RSA_set0_crt_params()
259 rsa->dmq1 = dmq1; in RSA_set0_crt_params()
262 BN_free(rsa->iqmp); in RSA_set0_crt_params()
263 rsa->iqmp = iqmp; in RSA_set0_crt_params()
269 int RSA_public_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, in RSA_public_encrypt() argument
273 if (!RSA_encrypt(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { in RSA_public_encrypt()
284 int RSA_sign_raw(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, in RSA_sign_raw() argument
286 if (rsa->meth->sign_raw) { in RSA_sign_raw()
287 return rsa->meth->sign_raw(rsa, out_len, out, max_out, in, in_len, padding); in RSA_sign_raw()
290 return rsa_default_sign_raw(rsa, out_len, out, max_out, in, in_len, padding); in RSA_sign_raw()
293 int RSA_private_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, in RSA_private_encrypt() argument
297 if (!RSA_sign_raw(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { in RSA_private_encrypt()
308 int RSA_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, in RSA_decrypt() argument
310 if (rsa->meth->decrypt) { in RSA_decrypt()
311 return rsa->meth->decrypt(rsa, out_len, out, max_out, in, in_len, padding); in RSA_decrypt()
314 return rsa_default_decrypt(rsa, out_len, out, max_out, in, in_len, padding); in RSA_decrypt()
317 int RSA_private_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, in RSA_private_decrypt() argument
321 if (!RSA_decrypt(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { in RSA_private_decrypt()
332 int RSA_public_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, in RSA_public_decrypt() argument
336 if (!RSA_verify_raw(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { in RSA_public_decrypt()
347 unsigned RSA_size(const RSA *rsa) { in RSA_size() argument
348 if (rsa->meth->size) { in RSA_size()
349 return rsa->meth->size(rsa); in RSA_size()
352 return rsa_default_size(rsa); in RSA_size()
355 int RSA_is_opaque(const RSA *rsa) { in RSA_is_opaque() argument
356 return rsa->meth && (rsa->meth->flags & RSA_FLAG_OPAQUE); in RSA_is_opaque()
369 int RSA_set_ex_data(RSA *rsa, int idx, void *arg) { in RSA_set_ex_data() argument
370 return CRYPTO_set_ex_data(&rsa->ex_data, idx, arg); in RSA_set_ex_data()
373 void *RSA_get_ex_data(const RSA *rsa, int idx) { in RSA_get_ex_data() argument
374 return CRYPTO_get_ex_data(&rsa->ex_data, idx); in RSA_get_ex_data()
505 unsigned *out_len, RSA *rsa) { in RSA_sign() argument
506 const unsigned rsa_size = RSA_size(rsa); in RSA_sign()
513 if (rsa->meth->sign) { in RSA_sign()
514 return rsa->meth->sign(hash_nid, in, in_len, out, out_len, rsa); in RSA_sign()
519 !RSA_sign_raw(rsa, &size_t_out_len, out, rsa_size, signed_msg, in RSA_sign()
534 int RSA_sign_pss_mgf1(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, in RSA_sign_pss_mgf1() argument
542 size_t padded_len = RSA_size(rsa); in RSA_sign_pss_mgf1()
550 RSA_padding_add_PKCS1_PSS_mgf1(rsa, padded, in, md, mgf1_md, salt_len) && in RSA_sign_pss_mgf1()
551 RSA_sign_raw(rsa, out_len, out, max_out, padded, padded_len, in RSA_sign_pss_mgf1()
558 const uint8_t *sig, size_t sig_len, RSA *rsa) { in RSA_verify() argument
559 if (rsa->n == NULL || rsa->e == NULL) { in RSA_verify()
564 const size_t rsa_size = RSA_size(rsa); in RSA_verify()
582 if (!RSA_verify_raw(rsa, &len, buf, rsa_size, sig, sig_len, in RSA_verify()
609 int RSA_verify_pss_mgf1(RSA *rsa, const uint8_t *msg, size_t msg_len, in RSA_verify_pss_mgf1() argument
617 size_t em_len = RSA_size(rsa); in RSA_verify_pss_mgf1()
625 if (!RSA_verify_raw(rsa, &em_len, em, em_len, sig, sig_len, RSA_NO_PADDING)) { in RSA_verify_pss_mgf1()
629 if (em_len != RSA_size(rsa)) { in RSA_verify_pss_mgf1()
634 ret = RSA_verify_PKCS1_PSS_mgf1(rsa, msg, md, mgf1_md, em, salt_len); in RSA_verify_pss_mgf1()
866 int RSA_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, in RSA_private_transform() argument
868 if (rsa->meth->private_transform) { in RSA_private_transform()
869 return rsa->meth->private_transform(rsa, out, in, len); in RSA_private_transform()
872 return rsa_default_private_transform(rsa, out, in, len); in RSA_private_transform()
875 int RSA_flags(const RSA *rsa) { return rsa->flags; } in RSA_flags() argument
877 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx) { in RSA_blinding_on() argument