Lines Matching refs:prsactx
83 PROV_RSA_CTX *prsactx; in rsa_newctx() local
87 prsactx = OPENSSL_zalloc(sizeof(PROV_RSA_CTX)); in rsa_newctx()
88 if (prsactx == NULL) in rsa_newctx()
90 prsactx->libctx = PROV_LIBCTX_OF(provctx); in rsa_newctx()
91 OSSL_FIPS_IND_INIT(prsactx) in rsa_newctx()
93 return prsactx; in rsa_newctx()
99 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; in rsa_init() local
102 if (!ossl_prov_is_running() || prsactx == NULL || vrsa == NULL) in rsa_init()
109 RSA_free(prsactx->rsa); in rsa_init()
110 prsactx->rsa = vrsa; in rsa_init()
111 prsactx->operation = operation; in rsa_init()
112 prsactx->implicit_rejection = 1; in rsa_init()
114 switch (RSA_test_flags(prsactx->rsa, RSA_FLAG_TYPE_MASK)) { in rsa_init()
116 prsactx->pad_mode = RSA_PKCS1_PADDING; in rsa_init()
124 OSSL_FIPS_IND_SET_APPROVED(prsactx) in rsa_init()
125 if (!rsa_set_ctx_params(prsactx, params)) in rsa_init()
128 if (!ossl_fips_ind_rsa_key_check(OSSL_FIPS_IND_GET(prsactx), in rsa_init()
129 OSSL_FIPS_IND_SETTABLE0, prsactx->libctx, in rsa_init()
130 prsactx->rsa, desc, protect)) in rsa_init()
153 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; in rsa_encrypt() local
160 if ((prsactx->pad_mode == RSA_PKCS1_PADDING in rsa_encrypt()
161 || prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) in rsa_encrypt()
162 && !OSSL_FIPS_IND_ON_UNAPPROVED(prsactx, OSSL_FIPS_IND_SETTABLE1, in rsa_encrypt()
163 prsactx->libctx, "RSA Encrypt", in rsa_encrypt()
172 size_t len = RSA_size(prsactx->rsa); in rsa_encrypt()
182 if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING) { in rsa_encrypt()
183 int rsasize = RSA_size(prsactx->rsa); in rsa_encrypt()
188 if (prsactx->oaep_md == NULL) { in rsa_encrypt()
189 prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL); in rsa_encrypt()
190 if (prsactx->oaep_md == NULL) { in rsa_encrypt()
197 ossl_rsa_padding_add_PKCS1_OAEP_mgf1_ex(prsactx->libctx, tbuf, in rsa_encrypt()
199 prsactx->oaep_label, in rsa_encrypt()
200 prsactx->oaep_labellen, in rsa_encrypt()
201 prsactx->oaep_md, in rsa_encrypt()
202 prsactx->mgf1_md); in rsa_encrypt()
208 ret = RSA_public_encrypt(rsasize, tbuf, out, prsactx->rsa, in rsa_encrypt()
212 ret = RSA_public_encrypt(inlen, in, out, prsactx->rsa, in rsa_encrypt()
213 prsactx->pad_mode); in rsa_encrypt()
225 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; in rsa_decrypt() local
228 size_t len = RSA_size(prsactx->rsa); in rsa_decrypt()
233 if (prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) { in rsa_decrypt()
258 if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING in rsa_decrypt()
259 || prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) { in rsa_decrypt()
264 ret = RSA_private_decrypt(inlen, in, tbuf, prsactx->rsa, in rsa_decrypt()
275 if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING) { in rsa_decrypt()
276 if (prsactx->oaep_md == NULL) { in rsa_decrypt()
277 prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL); in rsa_decrypt()
278 if (prsactx->oaep_md == NULL) { in rsa_decrypt()
286 prsactx->oaep_label, in rsa_decrypt()
287 prsactx->oaep_labellen, in rsa_decrypt()
288 prsactx->oaep_md, in rsa_decrypt()
289 prsactx->mgf1_md); in rsa_decrypt()
292 if (prsactx->client_version <= 0) { in rsa_decrypt()
298 prsactx->libctx, out, outsize, tbuf, len, in rsa_decrypt()
299 prsactx->client_version, prsactx->alt_version); in rsa_decrypt()
303 if ((prsactx->implicit_rejection == 0) && in rsa_decrypt()
304 (prsactx->pad_mode == RSA_PKCS1_PADDING)) in rsa_decrypt()
307 pad_mode = prsactx->pad_mode; in rsa_decrypt()
308 ret = RSA_private_decrypt(inlen, in, out, prsactx->rsa, pad_mode); in rsa_decrypt()
317 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; in rsa_freectx() local
319 RSA_free(prsactx->rsa); in rsa_freectx()
321 EVP_MD_free(prsactx->oaep_md); in rsa_freectx()
322 EVP_MD_free(prsactx->mgf1_md); in rsa_freectx()
323 OPENSSL_free(prsactx->oaep_label); in rsa_freectx()
325 OPENSSL_free(prsactx); in rsa_freectx()
364 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; in rsa_get_ctx_params() local
367 if (prsactx == NULL) in rsa_get_ctx_params()
374 if (!OSSL_PARAM_set_int(p, prsactx->pad_mode)) in rsa_get_ctx_params()
383 if (prsactx->pad_mode == (int)padding_item[i].id) { in rsa_get_ctx_params()
402 if (p != NULL && !OSSL_PARAM_set_utf8_string(p, prsactx->oaep_md == NULL in rsa_get_ctx_params()
404 : EVP_MD_get0_name(prsactx->oaep_md))) in rsa_get_ctx_params()
409 EVP_MD *mgf1_md = prsactx->mgf1_md == NULL ? prsactx->oaep_md in rsa_get_ctx_params()
410 : prsactx->mgf1_md; in rsa_get_ctx_params()
420 !OSSL_PARAM_set_octet_ptr(p, prsactx->oaep_label, in rsa_get_ctx_params()
421 prsactx->oaep_labellen)) in rsa_get_ctx_params()
425 if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->client_version)) in rsa_get_ctx_params()
429 if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->alt_version)) in rsa_get_ctx_params()
433 if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->implicit_rejection)) in rsa_get_ctx_params()
435 if (!OSSL_FIPS_IND_GET_CTX_PARAM(prsactx, params)) in rsa_get_ctx_params()
461 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; in rsa_set_ctx_params() local
467 if (prsactx == NULL) in rsa_set_ctx_params()
472 if (!OSSL_FIPS_IND_SET_CTX_PARAM(prsactx, OSSL_FIPS_IND_SETTABLE0, params, in rsa_set_ctx_params()
475 if (!OSSL_FIPS_IND_SET_CTX_PARAM(prsactx, OSSL_FIPS_IND_SETTABLE1, params, in rsa_set_ctx_params()
493 EVP_MD_free(prsactx->oaep_md); in rsa_set_ctx_params()
494 prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, mdname, mdprops); in rsa_set_ctx_params()
496 if (prsactx->oaep_md == NULL) in rsa_set_ctx_params()
534 if (pad_mode == RSA_PKCS1_OAEP_PADDING && prsactx->oaep_md == NULL) { in rsa_set_ctx_params()
535 prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA1", mdprops); in rsa_set_ctx_params()
536 if (prsactx->oaep_md == NULL) in rsa_set_ctx_params()
539 prsactx->pad_mode = pad_mode; in rsa_set_ctx_params()
558 EVP_MD_free(prsactx->mgf1_md); in rsa_set_ctx_params()
559 prsactx->mgf1_md = EVP_MD_fetch(prsactx->libctx, mdname, str); in rsa_set_ctx_params()
561 if (prsactx->mgf1_md == NULL) in rsa_set_ctx_params()
572 OPENSSL_free(prsactx->oaep_label); in rsa_set_ctx_params()
573 prsactx->oaep_label = (unsigned char *)tmp_label; in rsa_set_ctx_params()
574 prsactx->oaep_labellen = tmp_labellen; in rsa_set_ctx_params()
583 prsactx->client_version = client_version; in rsa_set_ctx_params()
592 prsactx->alt_version = alt_version; in rsa_set_ctx_params()
600 prsactx->implicit_rejection = implicit_rejection; in rsa_set_ctx_params()