rsa_enc.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  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. * RSA low level APIs are deprecated for public use, but still ok for
  11. * internal use.
  12. */
  13. #include "internal/deprecated.h"
  14. #include <openssl/crypto.h>
  15. #include <openssl/evp.h>
  16. #include <openssl/core_dispatch.h>
  17. #include <openssl/core_names.h>
  18. #include <openssl/rsa.h>
  19. #include <openssl/params.h>
  20. #include <openssl/err.h>
  21. #include <openssl/proverr.h>
  22. /* Just for SSL_MAX_MASTER_KEY_LENGTH */
  23. #include <openssl/prov_ssl.h>
  24. #include "internal/constant_time.h"
  25. #include "internal/sizes.h"
  26. #include "crypto/rsa.h"
  27. #include "prov/provider_ctx.h"
  28. #include "prov/implementations.h"
  29. #include "prov/providercommon.h"
  30. #include "prov/securitycheck.h"
  31. #include <stdlib.h>
  32. static OSSL_FUNC_asym_cipher_newctx_fn rsa_newctx;
  33. static OSSL_FUNC_asym_cipher_encrypt_init_fn rsa_encrypt_init;
  34. static OSSL_FUNC_asym_cipher_encrypt_fn rsa_encrypt;
  35. static OSSL_FUNC_asym_cipher_decrypt_init_fn rsa_decrypt_init;
  36. static OSSL_FUNC_asym_cipher_decrypt_fn rsa_decrypt;
  37. static OSSL_FUNC_asym_cipher_freectx_fn rsa_freectx;
  38. static OSSL_FUNC_asym_cipher_dupctx_fn rsa_dupctx;
  39. static OSSL_FUNC_asym_cipher_get_ctx_params_fn rsa_get_ctx_params;
  40. static OSSL_FUNC_asym_cipher_gettable_ctx_params_fn rsa_gettable_ctx_params;
  41. static OSSL_FUNC_asym_cipher_set_ctx_params_fn rsa_set_ctx_params;
  42. static OSSL_FUNC_asym_cipher_settable_ctx_params_fn rsa_settable_ctx_params;
  43. static OSSL_ITEM padding_item[] = {
  44. { RSA_PKCS1_PADDING, OSSL_PKEY_RSA_PAD_MODE_PKCSV15 },
  45. { RSA_NO_PADDING, OSSL_PKEY_RSA_PAD_MODE_NONE },
  46. { RSA_PKCS1_OAEP_PADDING, OSSL_PKEY_RSA_PAD_MODE_OAEP }, /* Correct spelling first */
  47. { RSA_PKCS1_OAEP_PADDING, "oeap" },
  48. { RSA_X931_PADDING, OSSL_PKEY_RSA_PAD_MODE_X931 },
  49. { 0, NULL }
  50. };
  51. /*
  52. * What's passed as an actual key is defined by the KEYMGMT interface.
  53. * We happen to know that our KEYMGMT simply passes RSA structures, so
  54. * we use that here too.
  55. */
  56. typedef struct {
  57. OSSL_LIB_CTX *libctx;
  58. RSA *rsa;
  59. int pad_mode;
  60. int operation;
  61. /* OAEP message digest */
  62. EVP_MD *oaep_md;
  63. /* message digest for MGF1 */
  64. EVP_MD *mgf1_md;
  65. /* OAEP label */
  66. unsigned char *oaep_label;
  67. size_t oaep_labellen;
  68. /* TLS padding */
  69. unsigned int client_version;
  70. unsigned int alt_version;
  71. } PROV_RSA_CTX;
  72. static void *rsa_newctx(void *provctx)
  73. {
  74. PROV_RSA_CTX *prsactx;
  75. if (!ossl_prov_is_running())
  76. return NULL;
  77. prsactx = OPENSSL_zalloc(sizeof(PROV_RSA_CTX));
  78. if (prsactx == NULL)
  79. return NULL;
  80. prsactx->libctx = PROV_LIBCTX_OF(provctx);
  81. return prsactx;
  82. }
  83. static int rsa_init(void *vprsactx, void *vrsa, const OSSL_PARAM params[],
  84. int operation)
  85. {
  86. PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
  87. if (!ossl_prov_is_running() || prsactx == NULL || vrsa == NULL)
  88. return 0;
  89. if (!ossl_rsa_check_key(prsactx->libctx, vrsa, operation))
  90. return 0;
  91. if (!RSA_up_ref(vrsa))
  92. return 0;
  93. RSA_free(prsactx->rsa);
  94. prsactx->rsa = vrsa;
  95. prsactx->operation = operation;
  96. switch (RSA_test_flags(prsactx->rsa, RSA_FLAG_TYPE_MASK)) {
  97. case RSA_FLAG_TYPE_RSA:
  98. prsactx->pad_mode = RSA_PKCS1_PADDING;
  99. break;
  100. default:
  101. /* This should not happen due to the check above */
  102. ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
  103. return 0;
  104. }
  105. return rsa_set_ctx_params(prsactx, params);
  106. }
  107. static int rsa_encrypt_init(void *vprsactx, void *vrsa,
  108. const OSSL_PARAM params[])
  109. {
  110. return rsa_init(vprsactx, vrsa, params, EVP_PKEY_OP_ENCRYPT);
  111. }
  112. static int rsa_decrypt_init(void *vprsactx, void *vrsa,
  113. const OSSL_PARAM params[])
  114. {
  115. return rsa_init(vprsactx, vrsa, params, EVP_PKEY_OP_DECRYPT);
  116. }
  117. static int rsa_encrypt(void *vprsactx, unsigned char *out, size_t *outlen,
  118. size_t outsize, const unsigned char *in, size_t inlen)
  119. {
  120. PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
  121. int ret;
  122. if (!ossl_prov_is_running())
  123. return 0;
  124. if (out == NULL) {
  125. size_t len = RSA_size(prsactx->rsa);
  126. if (len == 0) {
  127. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
  128. return 0;
  129. }
  130. *outlen = len;
  131. return 1;
  132. }
  133. if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING) {
  134. int rsasize = RSA_size(prsactx->rsa);
  135. unsigned char *tbuf;
  136. if ((tbuf = OPENSSL_malloc(rsasize)) == NULL)
  137. return 0;
  138. if (prsactx->oaep_md == NULL) {
  139. OPENSSL_free(tbuf);
  140. prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
  141. ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
  142. return 0;
  143. }
  144. ret =
  145. ossl_rsa_padding_add_PKCS1_OAEP_mgf1_ex(prsactx->libctx, tbuf,
  146. rsasize, in, inlen,
  147. prsactx->oaep_label,
  148. prsactx->oaep_labellen,
  149. prsactx->oaep_md,
  150. prsactx->mgf1_md);
  151. if (!ret) {
  152. OPENSSL_free(tbuf);
  153. return 0;
  154. }
  155. ret = RSA_public_encrypt(rsasize, tbuf, out, prsactx->rsa,
  156. RSA_NO_PADDING);
  157. OPENSSL_free(tbuf);
  158. } else {
  159. ret = RSA_public_encrypt(inlen, in, out, prsactx->rsa,
  160. prsactx->pad_mode);
  161. }
  162. /* A ret value of 0 is not an error */
  163. if (ret < 0)
  164. return ret;
  165. *outlen = ret;
  166. return 1;
  167. }
  168. static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
  169. size_t outsize, const unsigned char *in, size_t inlen)
  170. {
  171. PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
  172. int ret;
  173. size_t len = RSA_size(prsactx->rsa);
  174. if (!ossl_prov_is_running())
  175. return 0;
  176. if (prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) {
  177. if (out == NULL) {
  178. *outlen = SSL_MAX_MASTER_KEY_LENGTH;
  179. return 1;
  180. }
  181. if (outsize < SSL_MAX_MASTER_KEY_LENGTH) {
  182. ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH);
  183. return 0;
  184. }
  185. } else {
  186. if (out == NULL) {
  187. if (len == 0) {
  188. ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
  189. return 0;
  190. }
  191. *outlen = len;
  192. return 1;
  193. }
  194. if (outsize < len) {
  195. ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH);
  196. return 0;
  197. }
  198. }
  199. if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING
  200. || prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) {
  201. unsigned char *tbuf;
  202. if ((tbuf = OPENSSL_malloc(len)) == NULL)
  203. return 0;
  204. ret = RSA_private_decrypt(inlen, in, tbuf, prsactx->rsa,
  205. RSA_NO_PADDING);
  206. /*
  207. * With no padding then, on success ret should be len, otherwise an
  208. * error occurred (non-constant time)
  209. */
  210. if (ret != (int)len) {
  211. OPENSSL_free(tbuf);
  212. ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_DECRYPT);
  213. return 0;
  214. }
  215. if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING) {
  216. if (prsactx->oaep_md == NULL) {
  217. prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
  218. if (prsactx->oaep_md == NULL) {
  219. OPENSSL_free(tbuf);
  220. ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
  221. return 0;
  222. }
  223. }
  224. ret = RSA_padding_check_PKCS1_OAEP_mgf1(out, outsize, tbuf,
  225. len, len,
  226. prsactx->oaep_label,
  227. prsactx->oaep_labellen,
  228. prsactx->oaep_md,
  229. prsactx->mgf1_md);
  230. } else {
  231. /* RSA_PKCS1_WITH_TLS_PADDING */
  232. if (prsactx->client_version <= 0) {
  233. ERR_raise(ERR_LIB_PROV, PROV_R_BAD_TLS_CLIENT_VERSION);
  234. OPENSSL_free(tbuf);
  235. return 0;
  236. }
  237. ret = ossl_rsa_padding_check_PKCS1_type_2_TLS(
  238. prsactx->libctx, out, outsize, tbuf, len,
  239. prsactx->client_version, prsactx->alt_version);
  240. }
  241. OPENSSL_free(tbuf);
  242. } else {
  243. ret = RSA_private_decrypt(inlen, in, out, prsactx->rsa,
  244. prsactx->pad_mode);
  245. }
  246. *outlen = constant_time_select_s(constant_time_msb_s(ret), *outlen, ret);
  247. ret = constant_time_select_int(constant_time_msb(ret), 0, 1);
  248. return ret;
  249. }
  250. static void rsa_freectx(void *vprsactx)
  251. {
  252. PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
  253. RSA_free(prsactx->rsa);
  254. EVP_MD_free(prsactx->oaep_md);
  255. EVP_MD_free(prsactx->mgf1_md);
  256. OPENSSL_free(prsactx->oaep_label);
  257. OPENSSL_free(prsactx);
  258. }
  259. static void *rsa_dupctx(void *vprsactx)
  260. {
  261. PROV_RSA_CTX *srcctx = (PROV_RSA_CTX *)vprsactx;
  262. PROV_RSA_CTX *dstctx;
  263. if (!ossl_prov_is_running())
  264. return NULL;
  265. dstctx = OPENSSL_zalloc(sizeof(*srcctx));
  266. if (dstctx == NULL)
  267. return NULL;
  268. *dstctx = *srcctx;
  269. if (dstctx->rsa != NULL && !RSA_up_ref(dstctx->rsa)) {
  270. OPENSSL_free(dstctx);
  271. return NULL;
  272. }
  273. if (dstctx->oaep_md != NULL && !EVP_MD_up_ref(dstctx->oaep_md)) {
  274. RSA_free(dstctx->rsa);
  275. OPENSSL_free(dstctx);
  276. return NULL;
  277. }
  278. if (dstctx->mgf1_md != NULL && !EVP_MD_up_ref(dstctx->mgf1_md)) {
  279. RSA_free(dstctx->rsa);
  280. EVP_MD_free(dstctx->oaep_md);
  281. OPENSSL_free(dstctx);
  282. return NULL;
  283. }
  284. return dstctx;
  285. }
  286. static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
  287. {
  288. PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
  289. OSSL_PARAM *p;
  290. if (prsactx == NULL)
  291. return 0;
  292. p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_PAD_MODE);
  293. if (p != NULL)
  294. switch (p->data_type) {
  295. case OSSL_PARAM_INTEGER: /* Support for legacy pad mode number */
  296. if (!OSSL_PARAM_set_int(p, prsactx->pad_mode))
  297. return 0;
  298. break;
  299. case OSSL_PARAM_UTF8_STRING:
  300. {
  301. int i;
  302. const char *word = NULL;
  303. for (i = 0; padding_item[i].id != 0; i++) {
  304. if (prsactx->pad_mode == (int)padding_item[i].id) {
  305. word = padding_item[i].ptr;
  306. break;
  307. }
  308. }
  309. if (word != NULL) {
  310. if (!OSSL_PARAM_set_utf8_string(p, word))
  311. return 0;
  312. } else {
  313. ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
  314. }
  315. }
  316. break;
  317. default:
  318. return 0;
  319. }
  320. p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST);
  321. if (p != NULL && !OSSL_PARAM_set_utf8_string(p, prsactx->oaep_md == NULL
  322. ? ""
  323. : EVP_MD_get0_name(prsactx->oaep_md)))
  324. return 0;
  325. p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST);
  326. if (p != NULL) {
  327. EVP_MD *mgf1_md = prsactx->mgf1_md == NULL ? prsactx->oaep_md
  328. : prsactx->mgf1_md;
  329. if (!OSSL_PARAM_set_utf8_string(p, mgf1_md == NULL
  330. ? ""
  331. : EVP_MD_get0_name(mgf1_md)))
  332. return 0;
  333. }
  334. p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL);
  335. if (p != NULL &&
  336. !OSSL_PARAM_set_octet_ptr(p, prsactx->oaep_label,
  337. prsactx->oaep_labellen))
  338. return 0;
  339. p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION);
  340. if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->client_version))
  341. return 0;
  342. p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION);
  343. if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->alt_version))
  344. return 0;
  345. return 1;
  346. }
  347. static const OSSL_PARAM known_gettable_ctx_params[] = {
  348. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST, NULL, 0),
  349. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_PAD_MODE, NULL, 0),
  350. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST, NULL, 0),
  351. OSSL_PARAM_DEFN(OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL, OSSL_PARAM_OCTET_PTR,
  352. NULL, 0),
  353. OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION, NULL),
  354. OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION, NULL),
  355. OSSL_PARAM_END
  356. };
  357. static const OSSL_PARAM *rsa_gettable_ctx_params(ossl_unused void *vprsactx,
  358. ossl_unused void *provctx)
  359. {
  360. return known_gettable_ctx_params;
  361. }
  362. static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
  363. {
  364. PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
  365. const OSSL_PARAM *p;
  366. char mdname[OSSL_MAX_NAME_SIZE];
  367. char mdprops[OSSL_MAX_PROPQUERY_SIZE] = { '\0' };
  368. char *str = NULL;
  369. if (prsactx == NULL)
  370. return 0;
  371. if (params == NULL)
  372. return 1;
  373. p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST);
  374. if (p != NULL) {
  375. str = mdname;
  376. if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdname)))
  377. return 0;
  378. p = OSSL_PARAM_locate_const(params,
  379. OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS);
  380. if (p != NULL) {
  381. str = mdprops;
  382. if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdprops)))
  383. return 0;
  384. }
  385. EVP_MD_free(prsactx->oaep_md);
  386. prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, mdname, mdprops);
  387. if (prsactx->oaep_md == NULL)
  388. return 0;
  389. }
  390. p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_PAD_MODE);
  391. if (p != NULL) {
  392. int pad_mode = 0;
  393. switch (p->data_type) {
  394. case OSSL_PARAM_INTEGER: /* Support for legacy pad mode number */
  395. if (!OSSL_PARAM_get_int(p, &pad_mode))
  396. return 0;
  397. break;
  398. case OSSL_PARAM_UTF8_STRING:
  399. {
  400. int i;
  401. if (p->data == NULL)
  402. return 0;
  403. for (i = 0; padding_item[i].id != 0; i++) {
  404. if (strcmp(p->data, padding_item[i].ptr) == 0) {
  405. pad_mode = padding_item[i].id;
  406. break;
  407. }
  408. }
  409. }
  410. break;
  411. default:
  412. return 0;
  413. }
  414. /*
  415. * PSS padding is for signatures only so is not compatible with
  416. * asymmetric cipher use.
  417. */
  418. if (pad_mode == RSA_PKCS1_PSS_PADDING)
  419. return 0;
  420. if (pad_mode == RSA_PKCS1_OAEP_PADDING && prsactx->oaep_md == NULL) {
  421. prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA1", mdprops);
  422. if (prsactx->oaep_md == NULL)
  423. return 0;
  424. }
  425. prsactx->pad_mode = pad_mode;
  426. }
  427. p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST);
  428. if (p != NULL) {
  429. str = mdname;
  430. if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdname)))
  431. return 0;
  432. p = OSSL_PARAM_locate_const(params,
  433. OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS);
  434. if (p != NULL) {
  435. str = mdprops;
  436. if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdprops)))
  437. return 0;
  438. } else {
  439. str = NULL;
  440. }
  441. EVP_MD_free(prsactx->mgf1_md);
  442. prsactx->mgf1_md = EVP_MD_fetch(prsactx->libctx, mdname, str);
  443. if (prsactx->mgf1_md == NULL)
  444. return 0;
  445. }
  446. p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL);
  447. if (p != NULL) {
  448. void *tmp_label = NULL;
  449. size_t tmp_labellen;
  450. if (!OSSL_PARAM_get_octet_string(p, &tmp_label, 0, &tmp_labellen))
  451. return 0;
  452. OPENSSL_free(prsactx->oaep_label);
  453. prsactx->oaep_label = (unsigned char *)tmp_label;
  454. prsactx->oaep_labellen = tmp_labellen;
  455. }
  456. p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION);
  457. if (p != NULL) {
  458. unsigned int client_version;
  459. if (!OSSL_PARAM_get_uint(p, &client_version))
  460. return 0;
  461. prsactx->client_version = client_version;
  462. }
  463. p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION);
  464. if (p != NULL) {
  465. unsigned int alt_version;
  466. if (!OSSL_PARAM_get_uint(p, &alt_version))
  467. return 0;
  468. prsactx->alt_version = alt_version;
  469. }
  470. return 1;
  471. }
  472. static const OSSL_PARAM known_settable_ctx_params[] = {
  473. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST, NULL, 0),
  474. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_PAD_MODE, NULL, 0),
  475. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST, NULL, 0),
  476. OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS, NULL, 0),
  477. OSSL_PARAM_octet_string(OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL, NULL, 0),
  478. OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION, NULL),
  479. OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION, NULL),
  480. OSSL_PARAM_END
  481. };
  482. static const OSSL_PARAM *rsa_settable_ctx_params(ossl_unused void *vprsactx,
  483. ossl_unused void *provctx)
  484. {
  485. return known_settable_ctx_params;
  486. }
  487. const OSSL_DISPATCH ossl_rsa_asym_cipher_functions[] = {
  488. { OSSL_FUNC_ASYM_CIPHER_NEWCTX, (void (*)(void))rsa_newctx },
  489. { OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT, (void (*)(void))rsa_encrypt_init },
  490. { OSSL_FUNC_ASYM_CIPHER_ENCRYPT, (void (*)(void))rsa_encrypt },
  491. { OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT, (void (*)(void))rsa_decrypt_init },
  492. { OSSL_FUNC_ASYM_CIPHER_DECRYPT, (void (*)(void))rsa_decrypt },
  493. { OSSL_FUNC_ASYM_CIPHER_FREECTX, (void (*)(void))rsa_freectx },
  494. { OSSL_FUNC_ASYM_CIPHER_DUPCTX, (void (*)(void))rsa_dupctx },
  495. { OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS,
  496. (void (*)(void))rsa_get_ctx_params },
  497. { OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS,
  498. (void (*)(void))rsa_gettable_ctx_params },
  499. { OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS,
  500. (void (*)(void))rsa_set_ctx_params },
  501. { OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS,
  502. (void (*)(void))rsa_settable_ctx_params },
  503. { 0, NULL }
  504. };