rsa_pmeth.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /* crypto/rsa/rsa_pmeth.c */
  2. /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  3. * project 2006.
  4. */
  5. /* ====================================================================
  6. * Copyright (c) 2006 The OpenSSL Project. All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. All advertising materials mentioning features or use of this
  21. * software must display the following acknowledgment:
  22. * "This product includes software developed by the OpenSSL Project
  23. * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
  24. *
  25. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  26. * endorse or promote products derived from this software without
  27. * prior written permission. For written permission, please contact
  28. * licensing@OpenSSL.org.
  29. *
  30. * 5. Products derived from this software may not be called "OpenSSL"
  31. * nor may "OpenSSL" appear in their names without prior written
  32. * permission of the OpenSSL Project.
  33. *
  34. * 6. Redistributions of any form whatsoever must retain the following
  35. * acknowledgment:
  36. * "This product includes software developed by the OpenSSL Project
  37. * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
  38. *
  39. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  40. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  41. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  42. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  43. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  44. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  45. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  46. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  48. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  49. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  50. * OF THE POSSIBILITY OF SUCH DAMAGE.
  51. * ====================================================================
  52. *
  53. * This product includes cryptographic software written by Eric Young
  54. * (eay@cryptsoft.com). This product includes software written by Tim
  55. * Hudson (tjh@cryptsoft.com).
  56. *
  57. */
  58. #include <stdio.h>
  59. #include "cryptlib.h"
  60. #include <openssl/asn1t.h>
  61. #include <openssl/x509.h>
  62. #include <openssl/rsa.h>
  63. #include <openssl/bn.h>
  64. #include <openssl/evp.h>
  65. #include "evp_locl.h"
  66. #include "rsa_locl.h"
  67. /* RSA pkey context structure */
  68. typedef struct
  69. {
  70. /* Key gen parameters */
  71. int nbits;
  72. BIGNUM *pub_exp;
  73. /* Keygen callback info */
  74. int gentmp[2];
  75. /* RSA padding mode */
  76. int pad_mode;
  77. /* message digest */
  78. const EVP_MD *md;
  79. /* message digest for MGF1 */
  80. const EVP_MD *mgf1md;
  81. /* PSS/OAEP salt length */
  82. int saltlen;
  83. /* Temp buffer */
  84. unsigned char *tbuf;
  85. } RSA_PKEY_CTX;
  86. static int pkey_rsa_init(EVP_PKEY_CTX *ctx)
  87. {
  88. RSA_PKEY_CTX *rctx;
  89. rctx = OPENSSL_malloc(sizeof(RSA_PKEY_CTX));
  90. if (!rctx)
  91. return 0;
  92. rctx->nbits = 1024;
  93. rctx->pub_exp = NULL;
  94. rctx->pad_mode = RSA_PKCS1_PADDING;
  95. rctx->md = NULL;
  96. rctx->mgf1md = NULL;
  97. rctx->tbuf = NULL;
  98. rctx->saltlen = -2;
  99. ctx->data = rctx;
  100. ctx->keygen_info = rctx->gentmp;
  101. ctx->keygen_info_count = 2;
  102. return 1;
  103. }
  104. static int pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
  105. {
  106. RSA_PKEY_CTX *dctx, *sctx;
  107. if (!pkey_rsa_init(dst))
  108. return 0;
  109. sctx = src->data;
  110. dctx = dst->data;
  111. dctx->nbits = sctx->nbits;
  112. if (sctx->pub_exp)
  113. {
  114. dctx->pub_exp = BN_dup(sctx->pub_exp);
  115. if (!dctx->pub_exp)
  116. return 0;
  117. }
  118. dctx->pad_mode = sctx->pad_mode;
  119. dctx->md = sctx->md;
  120. return 1;
  121. }
  122. static int setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk)
  123. {
  124. if (ctx->tbuf)
  125. return 1;
  126. ctx->tbuf = OPENSSL_malloc(EVP_PKEY_size(pk->pkey));
  127. if (!ctx->tbuf)
  128. return 0;
  129. return 1;
  130. }
  131. static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx)
  132. {
  133. RSA_PKEY_CTX *rctx = ctx->data;
  134. if (rctx)
  135. {
  136. if (rctx->pub_exp)
  137. BN_free(rctx->pub_exp);
  138. if (rctx->tbuf)
  139. OPENSSL_free(rctx->tbuf);
  140. OPENSSL_free(rctx);
  141. }
  142. }
  143. static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
  144. const unsigned char *tbs, size_t tbslen)
  145. {
  146. int ret;
  147. RSA_PKEY_CTX *rctx = ctx->data;
  148. RSA *rsa = ctx->pkey->pkey.rsa;
  149. if (rctx->md)
  150. {
  151. if (tbslen != (size_t)EVP_MD_size(rctx->md))
  152. {
  153. RSAerr(RSA_F_PKEY_RSA_SIGN,
  154. RSA_R_INVALID_DIGEST_LENGTH);
  155. return -1;
  156. }
  157. if (rctx->pad_mode == RSA_X931_PADDING)
  158. {
  159. if (!setup_tbuf(rctx, ctx))
  160. return -1;
  161. memcpy(rctx->tbuf, tbs, tbslen);
  162. rctx->tbuf[tbslen] =
  163. RSA_X931_hash_id(EVP_MD_type(rctx->md));
  164. ret = RSA_private_encrypt(tbslen + 1, rctx->tbuf,
  165. sig, rsa, RSA_X931_PADDING);
  166. }
  167. else if (rctx->pad_mode == RSA_PKCS1_PADDING)
  168. {
  169. unsigned int sltmp;
  170. ret = RSA_sign(EVP_MD_type(rctx->md),
  171. tbs, tbslen, sig, &sltmp, rsa);
  172. if (ret <= 0)
  173. return ret;
  174. ret = sltmp;
  175. }
  176. else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING)
  177. {
  178. if (!setup_tbuf(rctx, ctx))
  179. return -1;
  180. if (!RSA_padding_add_PKCS1_PSS_mgf1(rsa,
  181. rctx->tbuf, tbs,
  182. rctx->md, rctx->mgf1md,
  183. rctx->saltlen))
  184. return -1;
  185. ret = RSA_private_encrypt(RSA_size(rsa), rctx->tbuf,
  186. sig, rsa, RSA_NO_PADDING);
  187. }
  188. else
  189. return -1;
  190. }
  191. else
  192. ret = RSA_private_encrypt(tbslen, tbs, sig, ctx->pkey->pkey.rsa,
  193. rctx->pad_mode);
  194. if (ret < 0)
  195. return ret;
  196. *siglen = ret;
  197. return 1;
  198. }
  199. static int pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx,
  200. unsigned char *rout, size_t *routlen,
  201. const unsigned char *sig, size_t siglen)
  202. {
  203. int ret;
  204. RSA_PKEY_CTX *rctx = ctx->data;
  205. if (rctx->md)
  206. {
  207. if (rctx->pad_mode == RSA_X931_PADDING)
  208. {
  209. if (!setup_tbuf(rctx, ctx))
  210. return -1;
  211. ret = RSA_public_decrypt(siglen, sig,
  212. rctx->tbuf, ctx->pkey->pkey.rsa,
  213. RSA_X931_PADDING);
  214. if (ret < 1)
  215. return 0;
  216. ret--;
  217. if (rctx->tbuf[ret] !=
  218. RSA_X931_hash_id(EVP_MD_type(rctx->md)))
  219. {
  220. RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER,
  221. RSA_R_ALGORITHM_MISMATCH);
  222. return 0;
  223. }
  224. if (ret != EVP_MD_size(rctx->md))
  225. {
  226. RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER,
  227. RSA_R_INVALID_DIGEST_LENGTH);
  228. return 0;
  229. }
  230. if (rout)
  231. memcpy(rout, rctx->tbuf, ret);
  232. }
  233. else if (rctx->pad_mode == RSA_PKCS1_PADDING)
  234. {
  235. size_t sltmp;
  236. ret = int_rsa_verify(EVP_MD_type(rctx->md),
  237. NULL, 0, rout, &sltmp,
  238. sig, siglen, ctx->pkey->pkey.rsa);
  239. if (ret <= 0)
  240. return 0;
  241. ret = sltmp;
  242. }
  243. else
  244. return -1;
  245. }
  246. else
  247. ret = RSA_public_decrypt(siglen, sig, rout, ctx->pkey->pkey.rsa,
  248. rctx->pad_mode);
  249. if (ret < 0)
  250. return ret;
  251. *routlen = ret;
  252. return 1;
  253. }
  254. static int pkey_rsa_verify(EVP_PKEY_CTX *ctx,
  255. const unsigned char *sig, size_t siglen,
  256. const unsigned char *tbs, size_t tbslen)
  257. {
  258. RSA_PKEY_CTX *rctx = ctx->data;
  259. RSA *rsa = ctx->pkey->pkey.rsa;
  260. size_t rslen;
  261. if (rctx->md)
  262. {
  263. if (rctx->pad_mode == RSA_PKCS1_PADDING)
  264. return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,
  265. sig, siglen, rsa);
  266. if (rctx->pad_mode == RSA_X931_PADDING)
  267. {
  268. if (pkey_rsa_verifyrecover(ctx, NULL, &rslen,
  269. sig, siglen) <= 0)
  270. return 0;
  271. }
  272. else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING)
  273. {
  274. int ret;
  275. if (!setup_tbuf(rctx, ctx))
  276. return -1;
  277. ret = RSA_public_decrypt(siglen, sig, rctx->tbuf,
  278. rsa, RSA_NO_PADDING);
  279. if (ret <= 0)
  280. return 0;
  281. ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs,
  282. rctx->md, rctx->mgf1md,
  283. rctx->tbuf, rctx->saltlen);
  284. if (ret <= 0)
  285. return 0;
  286. return 1;
  287. }
  288. else
  289. return -1;
  290. }
  291. else
  292. {
  293. if (!setup_tbuf(rctx, ctx))
  294. return -1;
  295. rslen = RSA_public_decrypt(siglen, sig, rctx->tbuf,
  296. rsa, rctx->pad_mode);
  297. if (rslen == 0)
  298. return 0;
  299. }
  300. if ((rslen != tbslen) || memcmp(tbs, rctx->tbuf, rslen))
  301. return 0;
  302. return 1;
  303. }
  304. static int pkey_rsa_encrypt(EVP_PKEY_CTX *ctx,
  305. unsigned char *out, size_t *outlen,
  306. const unsigned char *in, size_t inlen)
  307. {
  308. int ret;
  309. RSA_PKEY_CTX *rctx = ctx->data;
  310. ret = RSA_public_encrypt(inlen, in, out, ctx->pkey->pkey.rsa,
  311. rctx->pad_mode);
  312. if (ret < 0)
  313. return ret;
  314. *outlen = ret;
  315. return 1;
  316. }
  317. static int pkey_rsa_decrypt(EVP_PKEY_CTX *ctx,
  318. unsigned char *out, size_t *outlen,
  319. const unsigned char *in, size_t inlen)
  320. {
  321. int ret;
  322. RSA_PKEY_CTX *rctx = ctx->data;
  323. ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa,
  324. rctx->pad_mode);
  325. if (ret < 0)
  326. return ret;
  327. *outlen = ret;
  328. return 1;
  329. }
  330. static int check_padding_md(const EVP_MD *md, int padding)
  331. {
  332. if (!md)
  333. return 1;
  334. if (padding == RSA_NO_PADDING)
  335. {
  336. RSAerr(RSA_F_CHECK_PADDING_MD, RSA_R_INVALID_PADDING_MODE);
  337. return 0;
  338. }
  339. if (padding == RSA_X931_PADDING)
  340. {
  341. if (RSA_X931_hash_id(EVP_MD_type(md)) == -1)
  342. {
  343. RSAerr(RSA_F_CHECK_PADDING_MD,
  344. RSA_R_INVALID_X931_DIGEST);
  345. return 0;
  346. }
  347. return 1;
  348. }
  349. return 1;
  350. }
  351. static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
  352. {
  353. RSA_PKEY_CTX *rctx = ctx->data;
  354. switch (type)
  355. {
  356. case EVP_PKEY_CTRL_RSA_PADDING:
  357. if ((p1 >= RSA_PKCS1_PADDING) && (p1 <= RSA_PKCS1_PSS_PADDING))
  358. {
  359. if (!check_padding_md(rctx->md, p1))
  360. return 0;
  361. if (p1 == RSA_PKCS1_PSS_PADDING)
  362. {
  363. if (!(ctx->operation &
  364. (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY)))
  365. goto bad_pad;
  366. if (!rctx->md)
  367. rctx->md = EVP_sha1();
  368. }
  369. if (p1 == RSA_PKCS1_OAEP_PADDING)
  370. {
  371. if (!(ctx->operation & EVP_PKEY_OP_TYPE_CRYPT))
  372. goto bad_pad;
  373. if (!rctx->md)
  374. rctx->md = EVP_sha1();
  375. }
  376. rctx->pad_mode = p1;
  377. return 1;
  378. }
  379. bad_pad:
  380. RSAerr(RSA_F_PKEY_RSA_CTRL,
  381. RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE);
  382. return -2;
  383. case EVP_PKEY_CTRL_GET_RSA_PADDING:
  384. *(int *)p2 = rctx->pad_mode;
  385. return 1;
  386. case EVP_PKEY_CTRL_RSA_PSS_SALTLEN:
  387. case EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN:
  388. if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING)
  389. {
  390. RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_PSS_SALTLEN);
  391. return -2;
  392. }
  393. if (type == EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN)
  394. *(int *)p2 = rctx->saltlen;
  395. else
  396. {
  397. if (p1 < -2)
  398. return -2;
  399. rctx->saltlen = p1;
  400. }
  401. return 1;
  402. case EVP_PKEY_CTRL_RSA_KEYGEN_BITS:
  403. if (p1 < 256)
  404. {
  405. RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_KEYBITS);
  406. return -2;
  407. }
  408. rctx->nbits = p1;
  409. return 1;
  410. case EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP:
  411. if (!p2)
  412. return -2;
  413. rctx->pub_exp = p2;
  414. return 1;
  415. case EVP_PKEY_CTRL_MD:
  416. if (!check_padding_md(p2, rctx->pad_mode))
  417. return 0;
  418. rctx->md = p2;
  419. return 1;
  420. case EVP_PKEY_CTRL_RSA_MGF1_MD:
  421. case EVP_PKEY_CTRL_GET_RSA_MGF1_MD:
  422. if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING)
  423. {
  424. RSAerr(RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_MGF1_MD);
  425. return -2;
  426. }
  427. if (type == EVP_PKEY_CTRL_GET_RSA_MGF1_MD)
  428. {
  429. if (rctx->mgf1md)
  430. *(const EVP_MD **)p2 = rctx->mgf1md;
  431. else
  432. *(const EVP_MD **)p2 = rctx->md;
  433. }
  434. else
  435. rctx->mgf1md = p2;
  436. return 1;
  437. case EVP_PKEY_CTRL_DIGESTINIT:
  438. case EVP_PKEY_CTRL_PKCS7_ENCRYPT:
  439. case EVP_PKEY_CTRL_PKCS7_DECRYPT:
  440. case EVP_PKEY_CTRL_PKCS7_SIGN:
  441. #ifndef OPENSSL_NO_CMS
  442. case EVP_PKEY_CTRL_CMS_ENCRYPT:
  443. case EVP_PKEY_CTRL_CMS_DECRYPT:
  444. case EVP_PKEY_CTRL_CMS_SIGN:
  445. #endif
  446. return 1;
  447. case EVP_PKEY_CTRL_PEER_KEY:
  448. RSAerr(RSA_F_PKEY_RSA_CTRL,
  449. RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
  450. return -2;
  451. default:
  452. return -2;
  453. }
  454. }
  455. static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx,
  456. const char *type, const char *value)
  457. {
  458. if (!value)
  459. {
  460. RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_VALUE_MISSING);
  461. return 0;
  462. }
  463. if (!strcmp(type, "rsa_padding_mode"))
  464. {
  465. int pm;
  466. if (!strcmp(value, "pkcs1"))
  467. pm = RSA_PKCS1_PADDING;
  468. else if (!strcmp(value, "sslv23"))
  469. pm = RSA_SSLV23_PADDING;
  470. else if (!strcmp(value, "none"))
  471. pm = RSA_NO_PADDING;
  472. else if (!strcmp(value, "oeap"))
  473. pm = RSA_PKCS1_OAEP_PADDING;
  474. else if (!strcmp(value, "x931"))
  475. pm = RSA_X931_PADDING;
  476. else if (!strcmp(value, "pss"))
  477. pm = RSA_PKCS1_PSS_PADDING;
  478. else
  479. {
  480. RSAerr(RSA_F_PKEY_RSA_CTRL_STR,
  481. RSA_R_UNKNOWN_PADDING_TYPE);
  482. return -2;
  483. }
  484. return EVP_PKEY_CTX_set_rsa_padding(ctx, pm);
  485. }
  486. if (!strcmp(type, "rsa_pss_saltlen"))
  487. {
  488. int saltlen;
  489. saltlen = atoi(value);
  490. return EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, saltlen);
  491. }
  492. if (!strcmp(type, "rsa_keygen_bits"))
  493. {
  494. int nbits;
  495. nbits = atoi(value);
  496. return EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, nbits);
  497. }
  498. if (!strcmp(type, "rsa_keygen_pubexp"))
  499. {
  500. int ret;
  501. BIGNUM *pubexp = NULL;
  502. if (!BN_asc2bn(&pubexp, value))
  503. return 0;
  504. ret = EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp);
  505. if (ret <= 0)
  506. BN_free(pubexp);
  507. return ret;
  508. }
  509. return -2;
  510. }
  511. static int pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
  512. {
  513. RSA *rsa = NULL;
  514. RSA_PKEY_CTX *rctx = ctx->data;
  515. BN_GENCB *pcb, cb;
  516. int ret;
  517. if (!rctx->pub_exp)
  518. {
  519. rctx->pub_exp = BN_new();
  520. if (!rctx->pub_exp || !BN_set_word(rctx->pub_exp, RSA_F4))
  521. return 0;
  522. }
  523. rsa = RSA_new();
  524. if (!rsa)
  525. return 0;
  526. if (ctx->pkey_gencb)
  527. {
  528. pcb = &cb;
  529. evp_pkey_set_cb_translate(pcb, ctx);
  530. }
  531. else
  532. pcb = NULL;
  533. ret = RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb);
  534. if (ret > 0)
  535. EVP_PKEY_assign_RSA(pkey, rsa);
  536. else
  537. RSA_free(rsa);
  538. return ret;
  539. }
  540. const EVP_PKEY_METHOD rsa_pkey_meth =
  541. {
  542. EVP_PKEY_RSA,
  543. EVP_PKEY_FLAG_AUTOARGLEN,
  544. pkey_rsa_init,
  545. pkey_rsa_copy,
  546. pkey_rsa_cleanup,
  547. 0,0,
  548. 0,
  549. pkey_rsa_keygen,
  550. 0,
  551. pkey_rsa_sign,
  552. 0,
  553. pkey_rsa_verify,
  554. 0,
  555. pkey_rsa_verifyrecover,
  556. 0,0,0,0,
  557. 0,
  558. pkey_rsa_encrypt,
  559. 0,
  560. pkey_rsa_decrypt,
  561. 0,0,
  562. pkey_rsa_ctrl,
  563. pkey_rsa_ctrl_str
  564. };