2
0

rsa_enc.c 18 KB

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