evp.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. /*
  2. * Copyright 2015-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. #ifndef OSSL_CRYPTO_EVP_H
  10. # define OSSL_CRYPTO_EVP_H
  11. # pragma once
  12. # include <openssl/evp.h>
  13. # include <openssl/core_dispatch.h>
  14. # include "internal/refcount.h"
  15. # include "crypto/ecx.h"
  16. /*
  17. * Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag
  18. * values in evp.h
  19. */
  20. #define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400
  21. /*
  22. * An EVP_PKEY_CTX can have the following support states:
  23. *
  24. * Supports legacy implementations only:
  25. *
  26. * engine != NULL || keytype == NULL
  27. *
  28. * Supports provided implementations:
  29. *
  30. * engine == NULL && keytype != NULL
  31. */
  32. #define evp_pkey_ctx_is_legacy(ctx) \
  33. ((ctx)->engine != NULL || (ctx)->keytype == NULL)
  34. #define evp_pkey_ctx_is_provided(ctx) \
  35. (!evp_pkey_ctx_is_legacy(ctx))
  36. struct evp_pkey_ctx_st {
  37. /* Actual operation */
  38. int operation;
  39. /*
  40. * Library context, property query, keytype and keymgmt associated with
  41. * this context
  42. */
  43. OSSL_LIB_CTX *libctx;
  44. char *propquery;
  45. const char *keytype;
  46. EVP_KEYMGMT *keymgmt;
  47. union {
  48. struct {
  49. void *genctx;
  50. } keymgmt;
  51. struct {
  52. EVP_KEYEXCH *exchange;
  53. void *exchprovctx;
  54. } kex;
  55. struct {
  56. EVP_SIGNATURE *signature;
  57. void *sigprovctx;
  58. } sig;
  59. struct {
  60. EVP_ASYM_CIPHER *cipher;
  61. void *ciphprovctx;
  62. } ciph;
  63. struct {
  64. EVP_KEM *kem;
  65. void *kemprovctx;
  66. } encap;
  67. } op;
  68. /*
  69. * Cached parameters. Inits of operations that depend on these should
  70. * call evp_pkey_ctx_use_delayed_data() when the operation has been set
  71. * up properly.
  72. */
  73. struct {
  74. /* Distinguishing Identifier, ISO/IEC 15946-3, FIPS 196 */
  75. char *dist_id_name; /* The name used with EVP_PKEY_CTX_ctrl_str() */
  76. void *dist_id; /* The distinguishing ID itself */
  77. size_t dist_id_len; /* The length of the distinguishing ID */
  78. /* Indicators of what has been set. Keep them together! */
  79. unsigned int dist_id_set : 1;
  80. } cached_parameters;
  81. /* Application specific data, usually used by the callback */
  82. void *app_data;
  83. /* Keygen callback */
  84. EVP_PKEY_gen_cb *pkey_gencb;
  85. /* implementation specific keygen data */
  86. int *keygen_info;
  87. int keygen_info_count;
  88. /* Legacy fields below */
  89. /* EVP_PKEY identity */
  90. int legacy_keytype;
  91. /* Method associated with this operation */
  92. const EVP_PKEY_METHOD *pmeth;
  93. /* Engine that implements this method or NULL if builtin */
  94. ENGINE *engine;
  95. /* Key: may be NULL */
  96. EVP_PKEY *pkey;
  97. /* Peer key for key agreement, may be NULL */
  98. EVP_PKEY *peerkey;
  99. /* Algorithm specific data */
  100. void *data;
  101. /* Indicator if digest_custom needs to be called */
  102. unsigned int flag_call_digest_custom:1;
  103. /*
  104. * Used to support taking custody of memory in the case of a provider being
  105. * used with the deprecated EVP_PKEY_CTX_set_rsa_keygen_pubexp() API. This
  106. * member should NOT be used for any other purpose and should be removed
  107. * when said deprecated API is excised completely.
  108. */
  109. BIGNUM *rsa_pubexp;
  110. } /* EVP_PKEY_CTX */ ;
  111. #define EVP_PKEY_FLAG_DYNAMIC 1
  112. struct evp_pkey_method_st {
  113. int pkey_id;
  114. int flags;
  115. int (*init) (EVP_PKEY_CTX *ctx);
  116. int (*copy) (EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src);
  117. void (*cleanup) (EVP_PKEY_CTX *ctx);
  118. int (*paramgen_init) (EVP_PKEY_CTX *ctx);
  119. int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
  120. int (*keygen_init) (EVP_PKEY_CTX *ctx);
  121. int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
  122. int (*sign_init) (EVP_PKEY_CTX *ctx);
  123. int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
  124. const unsigned char *tbs, size_t tbslen);
  125. int (*verify_init) (EVP_PKEY_CTX *ctx);
  126. int (*verify) (EVP_PKEY_CTX *ctx,
  127. const unsigned char *sig, size_t siglen,
  128. const unsigned char *tbs, size_t tbslen);
  129. int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
  130. int (*verify_recover) (EVP_PKEY_CTX *ctx,
  131. unsigned char *rout, size_t *routlen,
  132. const unsigned char *sig, size_t siglen);
  133. int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
  134. int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
  135. EVP_MD_CTX *mctx);
  136. int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
  137. int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
  138. EVP_MD_CTX *mctx);
  139. int (*encrypt_init) (EVP_PKEY_CTX *ctx);
  140. int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
  141. const unsigned char *in, size_t inlen);
  142. int (*decrypt_init) (EVP_PKEY_CTX *ctx);
  143. int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
  144. const unsigned char *in, size_t inlen);
  145. int (*derive_init) (EVP_PKEY_CTX *ctx);
  146. int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
  147. int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
  148. int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
  149. int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
  150. const unsigned char *tbs, size_t tbslen);
  151. int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
  152. size_t siglen, const unsigned char *tbs,
  153. size_t tbslen);
  154. int (*check) (EVP_PKEY *pkey);
  155. int (*public_check) (EVP_PKEY *pkey);
  156. int (*param_check) (EVP_PKEY *pkey);
  157. int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
  158. } /* EVP_PKEY_METHOD */ ;
  159. DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD)
  160. void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
  161. const EVP_PKEY_METHOD *ossl_dh_pkey_method(void);
  162. const EVP_PKEY_METHOD *ossl_dhx_pkey_method(void);
  163. const EVP_PKEY_METHOD *ossl_dsa_pkey_method(void);
  164. const EVP_PKEY_METHOD *ossl_ec_pkey_method(void);
  165. const EVP_PKEY_METHOD *ossl_ecx25519_pkey_method(void);
  166. const EVP_PKEY_METHOD *ossl_ecx448_pkey_method(void);
  167. const EVP_PKEY_METHOD *ossl_ed25519_pkey_method(void);
  168. const EVP_PKEY_METHOD *ossl_ed448_pkey_method(void);
  169. const EVP_PKEY_METHOD *ossl_rsa_pkey_method(void);
  170. const EVP_PKEY_METHOD *ossl_rsa_pss_pkey_method(void);
  171. struct evp_mac_st {
  172. OSSL_PROVIDER *prov;
  173. int name_id;
  174. const char *description;
  175. CRYPTO_REF_COUNT refcnt;
  176. CRYPTO_RWLOCK *lock;
  177. OSSL_FUNC_mac_newctx_fn *newctx;
  178. OSSL_FUNC_mac_dupctx_fn *dupctx;
  179. OSSL_FUNC_mac_freectx_fn *freectx;
  180. OSSL_FUNC_mac_init_fn *init;
  181. OSSL_FUNC_mac_update_fn *update;
  182. OSSL_FUNC_mac_final_fn *final;
  183. OSSL_FUNC_mac_gettable_params_fn *gettable_params;
  184. OSSL_FUNC_mac_gettable_ctx_params_fn *gettable_ctx_params;
  185. OSSL_FUNC_mac_settable_ctx_params_fn *settable_ctx_params;
  186. OSSL_FUNC_mac_get_params_fn *get_params;
  187. OSSL_FUNC_mac_get_ctx_params_fn *get_ctx_params;
  188. OSSL_FUNC_mac_set_ctx_params_fn *set_ctx_params;
  189. };
  190. struct evp_kdf_st {
  191. OSSL_PROVIDER *prov;
  192. int name_id;
  193. const char *description;
  194. CRYPTO_REF_COUNT refcnt;
  195. CRYPTO_RWLOCK *lock;
  196. OSSL_FUNC_kdf_newctx_fn *newctx;
  197. OSSL_FUNC_kdf_dupctx_fn *dupctx;
  198. OSSL_FUNC_kdf_freectx_fn *freectx;
  199. OSSL_FUNC_kdf_reset_fn *reset;
  200. OSSL_FUNC_kdf_derive_fn *derive;
  201. OSSL_FUNC_kdf_gettable_params_fn *gettable_params;
  202. OSSL_FUNC_kdf_gettable_ctx_params_fn *gettable_ctx_params;
  203. OSSL_FUNC_kdf_settable_ctx_params_fn *settable_ctx_params;
  204. OSSL_FUNC_kdf_get_params_fn *get_params;
  205. OSSL_FUNC_kdf_get_ctx_params_fn *get_ctx_params;
  206. OSSL_FUNC_kdf_set_ctx_params_fn *set_ctx_params;
  207. };
  208. #define EVP_ORIG_DYNAMIC 0
  209. #define EVP_ORIG_GLOBAL 1
  210. #define EVP_ORIG_METH 2
  211. struct evp_md_st {
  212. /* nid */
  213. int type;
  214. /* Legacy structure members */
  215. int pkey_type;
  216. int md_size;
  217. unsigned long flags;
  218. int origin;
  219. int (*init) (EVP_MD_CTX *ctx);
  220. int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
  221. int (*final) (EVP_MD_CTX *ctx, unsigned char *md);
  222. int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);
  223. int (*cleanup) (EVP_MD_CTX *ctx);
  224. int block_size;
  225. int ctx_size; /* how big does the ctx->md_data need to be */
  226. /* control function */
  227. int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
  228. /* New structure members */
  229. /* Above comment to be removed when legacy has gone */
  230. int name_id;
  231. const char *description;
  232. OSSL_PROVIDER *prov;
  233. CRYPTO_REF_COUNT refcnt;
  234. CRYPTO_RWLOCK *lock;
  235. OSSL_FUNC_digest_newctx_fn *newctx;
  236. OSSL_FUNC_digest_init_fn *dinit;
  237. OSSL_FUNC_digest_update_fn *dupdate;
  238. OSSL_FUNC_digest_final_fn *dfinal;
  239. OSSL_FUNC_digest_digest_fn *digest;
  240. OSSL_FUNC_digest_freectx_fn *freectx;
  241. OSSL_FUNC_digest_dupctx_fn *dupctx;
  242. OSSL_FUNC_digest_get_params_fn *get_params;
  243. OSSL_FUNC_digest_set_ctx_params_fn *set_ctx_params;
  244. OSSL_FUNC_digest_get_ctx_params_fn *get_ctx_params;
  245. OSSL_FUNC_digest_gettable_params_fn *gettable_params;
  246. OSSL_FUNC_digest_settable_ctx_params_fn *settable_ctx_params;
  247. OSSL_FUNC_digest_gettable_ctx_params_fn *gettable_ctx_params;
  248. } /* EVP_MD */ ;
  249. struct evp_cipher_st {
  250. int nid;
  251. int block_size;
  252. /* Default value for variable length ciphers */
  253. int key_len;
  254. int iv_len;
  255. /* Legacy structure members */
  256. /* Various flags */
  257. unsigned long flags;
  258. /* How the EVP_CIPHER was created. */
  259. int origin;
  260. /* init key */
  261. int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,
  262. const unsigned char *iv, int enc);
  263. /* encrypt/decrypt data */
  264. int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,
  265. const unsigned char *in, size_t inl);
  266. /* cleanup ctx */
  267. int (*cleanup) (EVP_CIPHER_CTX *);
  268. /* how big ctx->cipher_data needs to be */
  269. int ctx_size;
  270. /* Populate a ASN1_TYPE with parameters */
  271. int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
  272. /* Get parameters from a ASN1_TYPE */
  273. int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
  274. /* Miscellaneous operations */
  275. int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);
  276. /* Application data */
  277. void *app_data;
  278. /* New structure members */
  279. /* Above comment to be removed when legacy has gone */
  280. int name_id;
  281. const char *description;
  282. OSSL_PROVIDER *prov;
  283. CRYPTO_REF_COUNT refcnt;
  284. CRYPTO_RWLOCK *lock;
  285. OSSL_FUNC_cipher_newctx_fn *newctx;
  286. OSSL_FUNC_cipher_encrypt_init_fn *einit;
  287. OSSL_FUNC_cipher_decrypt_init_fn *dinit;
  288. OSSL_FUNC_cipher_update_fn *cupdate;
  289. OSSL_FUNC_cipher_final_fn *cfinal;
  290. OSSL_FUNC_cipher_cipher_fn *ccipher;
  291. OSSL_FUNC_cipher_freectx_fn *freectx;
  292. OSSL_FUNC_cipher_dupctx_fn *dupctx;
  293. OSSL_FUNC_cipher_get_params_fn *get_params;
  294. OSSL_FUNC_cipher_get_ctx_params_fn *get_ctx_params;
  295. OSSL_FUNC_cipher_set_ctx_params_fn *set_ctx_params;
  296. OSSL_FUNC_cipher_gettable_params_fn *gettable_params;
  297. OSSL_FUNC_cipher_gettable_ctx_params_fn *gettable_ctx_params;
  298. OSSL_FUNC_cipher_settable_ctx_params_fn *settable_ctx_params;
  299. } /* EVP_CIPHER */ ;
  300. /* Macros to code block cipher wrappers */
  301. /* Wrapper functions for each cipher mode */
  302. #define EVP_C_DATA(kstruct, ctx) \
  303. ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx))
  304. #define BLOCK_CIPHER_ecb_loop() \
  305. size_t i, bl; \
  306. bl = EVP_CIPHER_CTX_get0_cipher(ctx)->block_size; \
  307. if (inl < bl) return 1;\
  308. inl -= bl; \
  309. for (i=0; i <= inl; i+=bl)
  310. #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
  311. static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
  312. {\
  313. BLOCK_CIPHER_ecb_loop() \
  314. cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \
  315. return 1;\
  316. }
  317. #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
  318. #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
  319. static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
  320. {\
  321. while(inl>=EVP_MAXCHUNK) {\
  322. int num = EVP_CIPHER_CTX_num(ctx);\
  323. cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, &num); \
  324. EVP_CIPHER_CTX_set_num(ctx, num);\
  325. inl-=EVP_MAXCHUNK;\
  326. in +=EVP_MAXCHUNK;\
  327. out+=EVP_MAXCHUNK;\
  328. }\
  329. if (inl) {\
  330. int num = EVP_CIPHER_CTX_num(ctx);\
  331. cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, &num); \
  332. EVP_CIPHER_CTX_set_num(ctx, num);\
  333. }\
  334. return 1;\
  335. }
  336. #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
  337. static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
  338. {\
  339. while(inl>=EVP_MAXCHUNK) \
  340. {\
  341. cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, EVP_CIPHER_CTX_encrypting(ctx));\
  342. inl-=EVP_MAXCHUNK;\
  343. in +=EVP_MAXCHUNK;\
  344. out+=EVP_MAXCHUNK;\
  345. }\
  346. if (inl)\
  347. cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, EVP_CIPHER_CTX_encrypting(ctx));\
  348. return 1;\
  349. }
  350. #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
  351. static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
  352. {\
  353. size_t chunk = EVP_MAXCHUNK;\
  354. if (cbits == 1) chunk >>= 3;\
  355. if (inl < chunk) chunk = inl;\
  356. while (inl && inl >= chunk)\
  357. {\
  358. int num = EVP_CIPHER_CTX_num(ctx);\
  359. cprefix##_cfb##cbits##_encrypt(in, out, (long) \
  360. ((cbits == 1) \
  361. && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \
  362. ? chunk*8 : chunk), \
  363. &EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv,\
  364. &num, EVP_CIPHER_CTX_encrypting(ctx));\
  365. EVP_CIPHER_CTX_set_num(ctx, num);\
  366. inl -= chunk;\
  367. in += chunk;\
  368. out += chunk;\
  369. if (inl < chunk) chunk = inl;\
  370. }\
  371. return 1;\
  372. }
  373. #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
  374. BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
  375. BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
  376. BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
  377. BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
  378. #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
  379. key_len, iv_len, flags, init_key, cleanup, \
  380. set_asn1, get_asn1, ctrl) \
  381. static const EVP_CIPHER cname##_##mode = { \
  382. nid##_##nmode, block_size, key_len, iv_len, \
  383. flags | EVP_CIPH_##MODE##_MODE, \
  384. EVP_ORIG_GLOBAL, \
  385. init_key, \
  386. cname##_##mode##_cipher, \
  387. cleanup, \
  388. sizeof(kstruct), \
  389. set_asn1, get_asn1,\
  390. ctrl, \
  391. NULL \
  392. }; \
  393. const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
  394. #define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
  395. iv_len, flags, init_key, cleanup, set_asn1, \
  396. get_asn1, ctrl) \
  397. BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
  398. iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
  399. #define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
  400. iv_len, cbits, flags, init_key, cleanup, \
  401. set_asn1, get_asn1, ctrl) \
  402. BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
  403. key_len, iv_len, flags, init_key, cleanup, set_asn1, \
  404. get_asn1, ctrl)
  405. #define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
  406. iv_len, cbits, flags, init_key, cleanup, \
  407. set_asn1, get_asn1, ctrl) \
  408. BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
  409. key_len, iv_len, flags, init_key, cleanup, set_asn1, \
  410. get_asn1, ctrl)
  411. #define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
  412. flags, init_key, cleanup, set_asn1, \
  413. get_asn1, ctrl) \
  414. BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
  415. 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
  416. #define BLOCK_CIPHER_defs(cname, kstruct, \
  417. nid, block_size, key_len, iv_len, cbits, flags, \
  418. init_key, cleanup, set_asn1, get_asn1, ctrl) \
  419. BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
  420. init_key, cleanup, set_asn1, get_asn1, ctrl) \
  421. BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
  422. flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
  423. BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
  424. flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
  425. BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
  426. init_key, cleanup, set_asn1, get_asn1, ctrl)
  427. /*-
  428. #define BLOCK_CIPHER_defs(cname, kstruct, \
  429. nid, block_size, key_len, iv_len, flags,\
  430. init_key, cleanup, set_asn1, get_asn1, ctrl)\
  431. static const EVP_CIPHER cname##_cbc = {\
  432. nid##_cbc, block_size, key_len, iv_len, \
  433. flags | EVP_CIPH_CBC_MODE,\
  434. EVP_ORIG_GLOBAL,\
  435. init_key,\
  436. cname##_cbc_cipher,\
  437. cleanup,\
  438. sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
  439. sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
  440. set_asn1, get_asn1,\
  441. ctrl, \
  442. NULL \
  443. };\
  444. const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
  445. static const EVP_CIPHER cname##_cfb = {\
  446. nid##_cfb64, 1, key_len, iv_len, \
  447. flags | EVP_CIPH_CFB_MODE,\
  448. EVP_ORIG_GLOBAL,\
  449. init_key,\
  450. cname##_cfb_cipher,\
  451. cleanup,\
  452. sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
  453. sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
  454. set_asn1, get_asn1,\
  455. ctrl,\
  456. NULL \
  457. };\
  458. const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
  459. static const EVP_CIPHER cname##_ofb = {\
  460. nid##_ofb64, 1, key_len, iv_len, \
  461. flags | EVP_CIPH_OFB_MODE,\
  462. EVP_ORIG_GLOBAL,\
  463. init_key,\
  464. cname##_ofb_cipher,\
  465. cleanup,\
  466. sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
  467. sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
  468. set_asn1, get_asn1,\
  469. ctrl,\
  470. NULL \
  471. };\
  472. const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
  473. static const EVP_CIPHER cname##_ecb = {\
  474. nid##_ecb, block_size, key_len, iv_len, \
  475. flags | EVP_CIPH_ECB_MODE,\
  476. EVP_ORIG_GLOBAL,\
  477. init_key,\
  478. cname##_ecb_cipher,\
  479. cleanup,\
  480. sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
  481. sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
  482. set_asn1, get_asn1,\
  483. ctrl,\
  484. NULL \
  485. };\
  486. const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
  487. */
  488. #define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
  489. block_size, key_len, iv_len, cbits, \
  490. flags, init_key, \
  491. cleanup, set_asn1, get_asn1, ctrl) \
  492. BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
  493. BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
  494. cbits, flags, init_key, cleanup, set_asn1, \
  495. get_asn1, ctrl)
  496. #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \
  497. BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
  498. BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
  499. NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
  500. (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
  501. cipher##_init_key, NULL, NULL, NULL, NULL)
  502. typedef struct {
  503. unsigned char iv[EVP_MAX_IV_LENGTH];
  504. unsigned int iv_len;
  505. unsigned int tag_len;
  506. } evp_cipher_aead_asn1_params;
  507. int evp_cipher_param_to_asn1_ex(EVP_CIPHER_CTX *c, ASN1_TYPE *type,
  508. evp_cipher_aead_asn1_params *params);
  509. int evp_cipher_asn1_to_param_ex(EVP_CIPHER_CTX *c, ASN1_TYPE *type,
  510. evp_cipher_aead_asn1_params *params);
  511. /*
  512. * To support transparent execution of operation in backends other
  513. * than the "origin" key, we support transparent export/import to
  514. * those providers, and maintain a cache of the imported keydata,
  515. * so we don't need to redo the export/import every time we perform
  516. * the same operation in that same provider.
  517. * This requires that the "origin" backend (whether it's a legacy or a
  518. * provider "origin") implements exports, and that the target provider
  519. * has an EVP_KEYMGMT that implements import.
  520. */
  521. typedef struct {
  522. EVP_KEYMGMT *keymgmt;
  523. void *keydata;
  524. } OP_CACHE_ELEM;
  525. DEFINE_STACK_OF(OP_CACHE_ELEM)
  526. /*
  527. * An EVP_PKEY can have the following states:
  528. *
  529. * untyped & empty:
  530. *
  531. * type == EVP_PKEY_NONE && keymgmt == NULL
  532. *
  533. * typed & empty:
  534. *
  535. * (type != EVP_PKEY_NONE && pkey.ptr == NULL) ## legacy (libcrypto only)
  536. * || (keymgmt != NULL && keydata == NULL) ## provider side
  537. *
  538. * fully assigned:
  539. *
  540. * (type != EVP_PKEY_NONE && pkey.ptr != NULL) ## legacy (libcrypto only)
  541. * || (keymgmt != NULL && keydata != NULL) ## provider side
  542. *
  543. * The easiest way to detect a legacy key is:
  544. *
  545. * keymgmt == NULL && type != EVP_PKEY_NONE
  546. *
  547. * The easiest way to detect a provider side key is:
  548. *
  549. * keymgmt != NULL
  550. */
  551. #define evp_pkey_is_blank(pk) \
  552. ((pk)->type == EVP_PKEY_NONE && (pk)->keymgmt == NULL)
  553. #define evp_pkey_is_typed(pk) \
  554. ((pk)->type != EVP_PKEY_NONE || (pk)->keymgmt != NULL)
  555. #ifndef FIPS_MODULE
  556. # define evp_pkey_is_assigned(pk) \
  557. ((pk)->pkey.ptr != NULL || (pk)->keydata != NULL)
  558. #else
  559. # define evp_pkey_is_assigned(pk) \
  560. ((pk)->keydata != NULL)
  561. #endif
  562. #define evp_pkey_is_legacy(pk) \
  563. ((pk)->type != EVP_PKEY_NONE && (pk)->keymgmt == NULL)
  564. #define evp_pkey_is_provided(pk) \
  565. ((pk)->keymgmt != NULL)
  566. union legacy_pkey_st {
  567. void *ptr;
  568. struct rsa_st *rsa; /* RSA */
  569. # ifndef OPENSSL_NO_DSA
  570. struct dsa_st *dsa; /* DSA */
  571. # endif
  572. # ifndef OPENSSL_NO_DH
  573. struct dh_st *dh; /* DH */
  574. # endif
  575. # ifndef OPENSSL_NO_EC
  576. struct ec_key_st *ec; /* ECC */
  577. ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
  578. # endif
  579. };
  580. struct evp_pkey_st {
  581. /* == Legacy attributes == */
  582. int type;
  583. int save_type;
  584. # ifndef FIPS_MODULE
  585. /*
  586. * Legacy key "origin" is composed of a pointer to an EVP_PKEY_ASN1_METHOD,
  587. * a pointer to a low level key and possibly a pointer to an engine.
  588. */
  589. const EVP_PKEY_ASN1_METHOD *ameth;
  590. ENGINE *engine;
  591. ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
  592. /* Union to store the reference to an origin legacy key */
  593. union legacy_pkey_st pkey;
  594. /* Union to store the reference to a non-origin legacy key */
  595. union legacy_pkey_st legacy_cache_pkey;
  596. # endif
  597. /* == Common attributes == */
  598. CRYPTO_REF_COUNT references;
  599. CRYPTO_RWLOCK *lock;
  600. #ifndef FIPS_MODULE
  601. STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
  602. int save_parameters;
  603. int foreign:1; /* the low-level key is using an engine or an app-method */
  604. CRYPTO_EX_DATA ex_data;
  605. #endif
  606. /* == Provider attributes == */
  607. /*
  608. * Provider keydata "origin" is composed of a pointer to an EVP_KEYMGMT
  609. * and a pointer to the provider side key data. This is never used at
  610. * the same time as the legacy key data above.
  611. */
  612. EVP_KEYMGMT *keymgmt;
  613. void *keydata;
  614. /*
  615. * If any libcrypto code does anything that may modify the keydata
  616. * contents, this dirty counter must be incremented.
  617. */
  618. size_t dirty_cnt;
  619. /*
  620. * To support transparent execution of operation in backends other
  621. * than the "origin" key, we support transparent export/import to
  622. * those providers, and maintain a cache of the imported keydata,
  623. * so we don't need to redo the export/import every time we perform
  624. * the same operation in that same provider.
  625. */
  626. STACK_OF(OP_CACHE_ELEM) *operation_cache;
  627. /*
  628. * We keep a copy of that "origin"'s dirty count, so we know if the
  629. * operation cache needs flushing.
  630. */
  631. size_t dirty_cnt_copy;
  632. /* Cache of key object information */
  633. struct {
  634. int bits;
  635. int security_bits;
  636. int size;
  637. } cache;
  638. } /* EVP_PKEY */ ;
  639. #define EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx) \
  640. ((ctx)->operation == EVP_PKEY_OP_SIGN \
  641. || (ctx)->operation == EVP_PKEY_OP_SIGNCTX \
  642. || (ctx)->operation == EVP_PKEY_OP_VERIFY \
  643. || (ctx)->operation == EVP_PKEY_OP_VERIFYCTX \
  644. || (ctx)->operation == EVP_PKEY_OP_VERIFYRECOVER)
  645. #define EVP_PKEY_CTX_IS_DERIVE_OP(ctx) \
  646. ((ctx)->operation == EVP_PKEY_OP_DERIVE)
  647. #define EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx) \
  648. ((ctx)->operation == EVP_PKEY_OP_ENCRYPT \
  649. || (ctx)->operation == EVP_PKEY_OP_DECRYPT)
  650. #define EVP_PKEY_CTX_IS_GEN_OP(ctx) \
  651. ((ctx)->operation == EVP_PKEY_OP_PARAMGEN \
  652. || (ctx)->operation == EVP_PKEY_OP_KEYGEN)
  653. #define EVP_PKEY_CTX_IS_FROMDATA_OP(ctx) \
  654. ((ctx)->operation == EVP_PKEY_OP_FROMDATA)
  655. #define EVP_PKEY_CTX_IS_KEM_OP(ctx) \
  656. ((ctx)->operation == EVP_PKEY_OP_ENCAPSULATE \
  657. || (ctx)->operation == EVP_PKEY_OP_DECAPSULATE)
  658. void openssl_add_all_ciphers_int(void);
  659. void openssl_add_all_digests_int(void);
  660. void evp_cleanup_int(void);
  661. void evp_app_cleanup_int(void);
  662. void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx,
  663. EVP_KEYMGMT **keymgmt,
  664. const char *propquery);
  665. #ifndef FIPS_MODULE
  666. int evp_pkey_copy_downgraded(EVP_PKEY **dest, const EVP_PKEY *src);
  667. void *evp_pkey_get_legacy(EVP_PKEY *pk);
  668. void evp_pkey_free_legacy(EVP_PKEY *x);
  669. EVP_PKEY *evp_pkcs82pkey_legacy(const PKCS8_PRIV_KEY_INFO *p8inf,
  670. OSSL_LIB_CTX *libctx, const char *propq);
  671. #endif
  672. /*
  673. * KEYMGMT utility functions
  674. */
  675. /*
  676. * Key import structure and helper function, to be used as an export callback
  677. */
  678. struct evp_keymgmt_util_try_import_data_st {
  679. EVP_KEYMGMT *keymgmt;
  680. void *keydata;
  681. int selection;
  682. };
  683. int evp_keymgmt_util_try_import(const OSSL_PARAM params[], void *arg);
  684. int evp_keymgmt_util_assign_pkey(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt,
  685. void *keydata);
  686. EVP_PKEY *evp_keymgmt_util_make_pkey(EVP_KEYMGMT *keymgmt, void *keydata);
  687. int evp_keymgmt_util_export(const EVP_PKEY *pk, int selection,
  688. OSSL_CALLBACK *export_cb, void *export_cbarg);
  689. void *evp_keymgmt_util_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt);
  690. OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk,
  691. EVP_KEYMGMT *keymgmt);
  692. int evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk, int locking);
  693. int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk,
  694. EVP_KEYMGMT *keymgmt, void *keydata);
  695. void evp_keymgmt_util_cache_keyinfo(EVP_PKEY *pk);
  696. void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
  697. int selection, const OSSL_PARAM params[]);
  698. int evp_keymgmt_util_has(EVP_PKEY *pk, int selection);
  699. int evp_keymgmt_util_match(EVP_PKEY *pk1, EVP_PKEY *pk2, int selection);
  700. int evp_keymgmt_util_copy(EVP_PKEY *to, EVP_PKEY *from, int selection);
  701. void *evp_keymgmt_util_gen(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
  702. void *genctx, OSSL_CALLBACK *cb, void *cbarg);
  703. int evp_keymgmt_util_get_deflt_digest_name(EVP_KEYMGMT *keymgmt,
  704. void *keydata,
  705. char *mdname, size_t mdname_sz);
  706. /*
  707. * KEYMGMT provider interface functions
  708. */
  709. void *evp_keymgmt_newdata(const EVP_KEYMGMT *keymgmt);
  710. void evp_keymgmt_freedata(const EVP_KEYMGMT *keymgmt, void *keyddata);
  711. int evp_keymgmt_get_params(const EVP_KEYMGMT *keymgmt,
  712. void *keydata, OSSL_PARAM params[]);
  713. int evp_keymgmt_set_params(const EVP_KEYMGMT *keymgmt,
  714. void *keydata, const OSSL_PARAM params[]);
  715. void *evp_keymgmt_gen_init(const EVP_KEYMGMT *keymgmt, int selection,
  716. const OSSL_PARAM params[]);
  717. int evp_keymgmt_gen_set_template(const EVP_KEYMGMT *keymgmt, void *genctx,
  718. void *template);
  719. int evp_keymgmt_gen_set_params(const EVP_KEYMGMT *keymgmt, void *genctx,
  720. const OSSL_PARAM params[]);
  721. void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx,
  722. OSSL_CALLBACK *cb, void *cbarg);
  723. void evp_keymgmt_gen_cleanup(const EVP_KEYMGMT *keymgmt, void *genctx);
  724. void *evp_keymgmt_load(const EVP_KEYMGMT *keymgmt,
  725. const void *objref, size_t objref_sz);
  726. int evp_keymgmt_has(const EVP_KEYMGMT *keymgmt, void *keyddata, int selection);
  727. int evp_keymgmt_validate(const EVP_KEYMGMT *keymgmt, void *keydata,
  728. int selection, int checktype);
  729. int evp_keymgmt_match(const EVP_KEYMGMT *keymgmt,
  730. const void *keydata1, const void *keydata2,
  731. int selection);
  732. int evp_keymgmt_import(const EVP_KEYMGMT *keymgmt, void *keydata,
  733. int selection, const OSSL_PARAM params[]);
  734. const OSSL_PARAM *evp_keymgmt_import_types(const EVP_KEYMGMT *keymgmt,
  735. int selection);
  736. int evp_keymgmt_export(const EVP_KEYMGMT *keymgmt, void *keydata,
  737. int selection, OSSL_CALLBACK *param_cb, void *cbarg);
  738. const OSSL_PARAM *evp_keymgmt_export_types(const EVP_KEYMGMT *keymgmt,
  739. int selection);
  740. void *evp_keymgmt_dup(const EVP_KEYMGMT *keymgmt,
  741. const void *keydata_from, int selection);
  742. /* Pulling defines out of C source files */
  743. # define EVP_RC4_KEY_SIZE 16
  744. # ifndef TLS1_1_VERSION
  745. # define TLS1_1_VERSION 0x0302
  746. # endif
  747. void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags);
  748. /* EVP_ENCODE_CTX flags */
  749. /* Don't generate new lines when encoding */
  750. #define EVP_ENCODE_CTX_NO_NEWLINES 1
  751. /* Use the SRP base64 alphabet instead of the standard one */
  752. #define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2
  753. const EVP_CIPHER *evp_get_cipherbyname_ex(OSSL_LIB_CTX *libctx,
  754. const char *name);
  755. const EVP_MD *evp_get_digestbyname_ex(OSSL_LIB_CTX *libctx,
  756. const char *name);
  757. int ossl_pkcs5_pbkdf2_hmac_ex(const char *pass, int passlen,
  758. const unsigned char *salt, int saltlen, int iter,
  759. const EVP_MD *digest, int keylen,
  760. unsigned char *out,
  761. OSSL_LIB_CTX *libctx, const char *propq);
  762. # ifndef FIPS_MODULE
  763. /*
  764. * Internal helpers for stricter EVP_PKEY_CTX_{set,get}_params().
  765. *
  766. * Return 1 on success, 0 or negative for errors.
  767. *
  768. * In particular they return -2 if any of the params is not supported.
  769. *
  770. * They are not available in FIPS_MODULE as they depend on
  771. * - EVP_PKEY_CTX_{get,set}_params()
  772. * - EVP_PKEY_CTX_{gettable,settable}_params()
  773. *
  774. */
  775. int evp_pkey_ctx_set_params_strict(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
  776. int evp_pkey_ctx_get_params_strict(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
  777. EVP_MD_CTX *evp_md_ctx_new_ex(EVP_PKEY *pkey, const ASN1_OCTET_STRING *id,
  778. OSSL_LIB_CTX *libctx, const char *propq);
  779. int evp_pkey_name2type(const char *name);
  780. const char *evp_pkey_type2name(int type);
  781. int evp_pkey_ctx_set1_id_prov(EVP_PKEY_CTX *ctx, const void *id, int len);
  782. int evp_pkey_ctx_get1_id_prov(EVP_PKEY_CTX *ctx, void *id);
  783. int evp_pkey_ctx_get1_id_len_prov(EVP_PKEY_CTX *ctx, size_t *id_len);
  784. int evp_pkey_ctx_use_cached_data(EVP_PKEY_CTX *ctx);
  785. # endif /* !defined(FIPS_MODULE) */
  786. int evp_method_store_flush(OSSL_LIB_CTX *libctx);
  787. int evp_set_default_properties_int(OSSL_LIB_CTX *libctx, const char *propq,
  788. int loadconfig);
  789. void evp_md_ctx_clear_digest(EVP_MD_CTX *ctx, int force);
  790. /* Three possible states: */
  791. # define EVP_PKEY_STATE_UNKNOWN 0
  792. # define EVP_PKEY_STATE_LEGACY 1
  793. # define EVP_PKEY_STATE_PROVIDER 2
  794. int evp_pkey_ctx_state(const EVP_PKEY_CTX *ctx);
  795. /* These two must ONLY be called for provider side operations */
  796. int evp_pkey_ctx_ctrl_to_param(EVP_PKEY_CTX *ctx,
  797. int keytype, int optype,
  798. int cmd, int p1, void *p2);
  799. int evp_pkey_ctx_ctrl_str_to_param(EVP_PKEY_CTX *ctx,
  800. const char *name, const char *value);
  801. /* These two must ONLY be called for legacy operations */
  802. int evp_pkey_ctx_set_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
  803. int evp_pkey_ctx_get_params_to_ctrl(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
  804. /* This must ONLY be called for legacy EVP_PKEYs */
  805. int evp_pkey_get_params_to_ctrl(const EVP_PKEY *pkey, OSSL_PARAM *params);
  806. /* Same as the public get0 functions but are not const */
  807. # ifndef OPENSSL_NO_DEPRECATED_3_0
  808. DH *evp_pkey_get0_DH_int(const EVP_PKEY *pkey);
  809. EC_KEY *evp_pkey_get0_EC_KEY_int(const EVP_PKEY *pkey);
  810. RSA *evp_pkey_get0_RSA_int(const EVP_PKEY *pkey);
  811. # endif
  812. #endif /* OSSL_CRYPTO_EVP_H */