evp.h 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. /*
  2. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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 HEADER_ENVELOPE_H
  10. # define HEADER_ENVELOPE_H
  11. # include <openssl/opensslconf.h>
  12. # include <openssl/ossl_typ.h>
  13. # include <openssl/symhacks.h>
  14. # include <openssl/bio.h>
  15. # include <openssl/evperr.h>
  16. # define EVP_MAX_MD_SIZE 64/* longest known is SHA512 */
  17. # define EVP_MAX_KEY_LENGTH 64
  18. # define EVP_MAX_IV_LENGTH 16
  19. # define EVP_MAX_BLOCK_LENGTH 32
  20. # define PKCS5_SALT_LEN 8
  21. /* Default PKCS#5 iteration count */
  22. # define PKCS5_DEFAULT_ITER 2048
  23. # include <openssl/objects.h>
  24. # define EVP_PK_RSA 0x0001
  25. # define EVP_PK_DSA 0x0002
  26. # define EVP_PK_DH 0x0004
  27. # define EVP_PK_EC 0x0008
  28. # define EVP_PKT_SIGN 0x0010
  29. # define EVP_PKT_ENC 0x0020
  30. # define EVP_PKT_EXCH 0x0040
  31. # define EVP_PKS_RSA 0x0100
  32. # define EVP_PKS_DSA 0x0200
  33. # define EVP_PKS_EC 0x0400
  34. # define EVP_PKEY_NONE NID_undef
  35. # define EVP_PKEY_RSA NID_rsaEncryption
  36. # define EVP_PKEY_RSA2 NID_rsa
  37. # define EVP_PKEY_RSA_PSS NID_rsassaPss
  38. # define EVP_PKEY_DSA NID_dsa
  39. # define EVP_PKEY_DSA1 NID_dsa_2
  40. # define EVP_PKEY_DSA2 NID_dsaWithSHA
  41. # define EVP_PKEY_DSA3 NID_dsaWithSHA1
  42. # define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
  43. # define EVP_PKEY_DH NID_dhKeyAgreement
  44. # define EVP_PKEY_DHX NID_dhpublicnumber
  45. # define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
  46. # define EVP_PKEY_HMAC NID_hmac
  47. # define EVP_PKEY_CMAC NID_cmac
  48. # define EVP_PKEY_SCRYPT NID_id_scrypt
  49. # define EVP_PKEY_TLS1_PRF NID_tls1_prf
  50. # define EVP_PKEY_HKDF NID_hkdf
  51. # define EVP_PKEY_POLY1305 NID_poly1305
  52. # define EVP_PKEY_SIPHASH NID_siphash
  53. # define EVP_PKEY_X25519 NID_X25519
  54. # define EVP_PKEY_ED25519 NID_ED25519
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. # define EVP_PKEY_MO_SIGN 0x0001
  59. # define EVP_PKEY_MO_VERIFY 0x0002
  60. # define EVP_PKEY_MO_ENCRYPT 0x0004
  61. # define EVP_PKEY_MO_DECRYPT 0x0008
  62. # ifndef EVP_MD
  63. EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);
  64. EVP_MD *EVP_MD_meth_dup(const EVP_MD *md);
  65. void EVP_MD_meth_free(EVP_MD *md);
  66. int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize);
  67. int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize);
  68. int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize);
  69. int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags);
  70. int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx));
  71. int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx,
  72. const void *data,
  73. size_t count));
  74. int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx,
  75. unsigned char *md));
  76. int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to,
  77. const EVP_MD_CTX *from));
  78. int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx));
  79. int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd,
  80. int p1, void *p2));
  81. int EVP_MD_meth_get_input_blocksize(const EVP_MD *md);
  82. int EVP_MD_meth_get_result_size(const EVP_MD *md);
  83. int EVP_MD_meth_get_app_datasize(const EVP_MD *md);
  84. unsigned long EVP_MD_meth_get_flags(const EVP_MD *md);
  85. int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx);
  86. int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx,
  87. const void *data,
  88. size_t count);
  89. int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx,
  90. unsigned char *md);
  91. int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to,
  92. const EVP_MD_CTX *from);
  93. int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx);
  94. int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,
  95. int p1, void *p2);
  96. /* digest can only handle a single block */
  97. # define EVP_MD_FLAG_ONESHOT 0x0001
  98. /* digest is extensible-output function, XOF */
  99. # define EVP_MD_FLAG_XOF 0x0002
  100. /* DigestAlgorithmIdentifier flags... */
  101. # define EVP_MD_FLAG_DIGALGID_MASK 0x0018
  102. /* NULL or absent parameter accepted. Use NULL */
  103. # define EVP_MD_FLAG_DIGALGID_NULL 0x0000
  104. /* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */
  105. # define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008
  106. /* Custom handling via ctrl */
  107. # define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018
  108. /* Note if suitable for use in FIPS mode */
  109. # define EVP_MD_FLAG_FIPS 0x0400
  110. /* Digest ctrls */
  111. # define EVP_MD_CTRL_DIGALGID 0x1
  112. # define EVP_MD_CTRL_MICALG 0x2
  113. # define EVP_MD_CTRL_XOF_LEN 0x3
  114. /* Minimum Algorithm specific ctrl value */
  115. # define EVP_MD_CTRL_ALG_CTRL 0x1000
  116. # endif /* !EVP_MD */
  117. /* values for EVP_MD_CTX flags */
  118. # define EVP_MD_CTX_FLAG_ONESHOT 0x0001/* digest update will be
  119. * called once only */
  120. # define EVP_MD_CTX_FLAG_CLEANED 0x0002/* context has already been
  121. * cleaned */
  122. # define EVP_MD_CTX_FLAG_REUSE 0x0004/* Don't free up ctx->md_data
  123. * in EVP_MD_CTX_reset */
  124. /*
  125. * FIPS and pad options are ignored in 1.0.0, definitions are here so we
  126. * don't accidentally reuse the values for other purposes.
  127. */
  128. # define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008/* Allow use of non FIPS
  129. * digest in FIPS mode */
  130. /*
  131. * The following PAD options are also currently ignored in 1.0.0, digest
  132. * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()
  133. * instead.
  134. */
  135. # define EVP_MD_CTX_FLAG_PAD_MASK 0xF0/* RSA mode to use */
  136. # define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00/* PKCS#1 v1.5 mode */
  137. # define EVP_MD_CTX_FLAG_PAD_X931 0x10/* X9.31 mode */
  138. # define EVP_MD_CTX_FLAG_PAD_PSS 0x20/* PSS mode */
  139. # define EVP_MD_CTX_FLAG_NO_INIT 0x0100/* Don't initialize md_data */
  140. /*
  141. * Some functions such as EVP_DigestSign only finalise copies of internal
  142. * contexts so additional data can be included after the finalisation call.
  143. * This is inefficient if this functionality is not required: it is disabled
  144. * if the following flag is set.
  145. */
  146. # define EVP_MD_CTX_FLAG_FINALISE 0x0200
  147. EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);
  148. EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);
  149. void EVP_CIPHER_meth_free(EVP_CIPHER *cipher);
  150. int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);
  151. int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);
  152. int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);
  153. int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,
  154. int (*init) (EVP_CIPHER_CTX *ctx,
  155. const unsigned char *key,
  156. const unsigned char *iv,
  157. int enc));
  158. int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,
  159. int (*do_cipher) (EVP_CIPHER_CTX *ctx,
  160. unsigned char *out,
  161. const unsigned char *in,
  162. size_t inl));
  163. int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,
  164. int (*cleanup) (EVP_CIPHER_CTX *));
  165. int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,
  166. int (*set_asn1_parameters) (EVP_CIPHER_CTX *,
  167. ASN1_TYPE *));
  168. int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,
  169. int (*get_asn1_parameters) (EVP_CIPHER_CTX *,
  170. ASN1_TYPE *));
  171. int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,
  172. int (*ctrl) (EVP_CIPHER_CTX *, int type,
  173. int arg, void *ptr));
  174. int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
  175. const unsigned char *key,
  176. const unsigned char *iv,
  177. int enc);
  178. int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
  179. unsigned char *out,
  180. const unsigned char *in,
  181. size_t inl);
  182. int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);
  183. int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
  184. ASN1_TYPE *);
  185. int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
  186. ASN1_TYPE *);
  187. int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
  188. int type, int arg,
  189. void *ptr);
  190. /* Values for cipher flags */
  191. /* Modes for ciphers */
  192. # define EVP_CIPH_STREAM_CIPHER 0x0
  193. # define EVP_CIPH_ECB_MODE 0x1
  194. # define EVP_CIPH_CBC_MODE 0x2
  195. # define EVP_CIPH_CFB_MODE 0x3
  196. # define EVP_CIPH_OFB_MODE 0x4
  197. # define EVP_CIPH_CTR_MODE 0x5
  198. # define EVP_CIPH_GCM_MODE 0x6
  199. # define EVP_CIPH_CCM_MODE 0x7
  200. # define EVP_CIPH_XTS_MODE 0x10001
  201. # define EVP_CIPH_WRAP_MODE 0x10002
  202. # define EVP_CIPH_OCB_MODE 0x10003
  203. # define EVP_CIPH_MODE 0xF0007
  204. /* Set if variable length cipher */
  205. # define EVP_CIPH_VARIABLE_LENGTH 0x8
  206. /* Set if the iv handling should be done by the cipher itself */
  207. # define EVP_CIPH_CUSTOM_IV 0x10
  208. /* Set if the cipher's init() function should be called if key is NULL */
  209. # define EVP_CIPH_ALWAYS_CALL_INIT 0x20
  210. /* Call ctrl() to init cipher parameters */
  211. # define EVP_CIPH_CTRL_INIT 0x40
  212. /* Don't use standard key length function */
  213. # define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
  214. /* Don't use standard block padding */
  215. # define EVP_CIPH_NO_PADDING 0x100
  216. /* cipher handles random key generation */
  217. # define EVP_CIPH_RAND_KEY 0x200
  218. /* cipher has its own additional copying logic */
  219. # define EVP_CIPH_CUSTOM_COPY 0x400
  220. /* Allow use default ASN1 get/set iv */
  221. # define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000
  222. /* Buffer length in bits not bytes: CFB1 mode only */
  223. # define EVP_CIPH_FLAG_LENGTH_BITS 0x2000
  224. /* Note if suitable for use in FIPS mode */
  225. # define EVP_CIPH_FLAG_FIPS 0x4000
  226. /* Allow non FIPS cipher in FIPS mode */
  227. # define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x8000
  228. /*
  229. * Cipher handles any and all padding logic as well as finalisation.
  230. */
  231. # define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000
  232. # define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000
  233. # define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000
  234. /* Cipher can handle pipeline operations */
  235. # define EVP_CIPH_FLAG_PIPELINE 0X800000
  236. /*
  237. * Cipher context flag to indicate we can handle wrap mode: if allowed in
  238. * older applications it could overflow buffers.
  239. */
  240. # define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1
  241. /* ctrl() values */
  242. # define EVP_CTRL_INIT 0x0
  243. # define EVP_CTRL_SET_KEY_LENGTH 0x1
  244. # define EVP_CTRL_GET_RC2_KEY_BITS 0x2
  245. # define EVP_CTRL_SET_RC2_KEY_BITS 0x3
  246. # define EVP_CTRL_GET_RC5_ROUNDS 0x4
  247. # define EVP_CTRL_SET_RC5_ROUNDS 0x5
  248. # define EVP_CTRL_RAND_KEY 0x6
  249. # define EVP_CTRL_PBE_PRF_NID 0x7
  250. # define EVP_CTRL_COPY 0x8
  251. # define EVP_CTRL_AEAD_SET_IVLEN 0x9
  252. # define EVP_CTRL_AEAD_GET_TAG 0x10
  253. # define EVP_CTRL_AEAD_SET_TAG 0x11
  254. # define EVP_CTRL_AEAD_SET_IV_FIXED 0x12
  255. # define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
  256. # define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
  257. # define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
  258. # define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
  259. # define EVP_CTRL_GCM_IV_GEN 0x13
  260. # define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
  261. # define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
  262. # define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
  263. # define EVP_CTRL_CCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
  264. # define EVP_CTRL_CCM_SET_L 0x14
  265. # define EVP_CTRL_CCM_SET_MSGLEN 0x15
  266. /*
  267. * AEAD cipher deduces payload length and returns number of bytes required to
  268. * store MAC and eventual padding. Subsequent call to EVP_Cipher even
  269. * appends/verifies MAC.
  270. */
  271. # define EVP_CTRL_AEAD_TLS1_AAD 0x16
  272. /* Used by composite AEAD ciphers, no-op in GCM, CCM... */
  273. # define EVP_CTRL_AEAD_SET_MAC_KEY 0x17
  274. /* Set the GCM invocation field, decrypt only */
  275. # define EVP_CTRL_GCM_SET_IV_INV 0x18
  276. # define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19
  277. # define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a
  278. # define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b
  279. # define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c
  280. # define EVP_CTRL_SSL3_MASTER_SECRET 0x1d
  281. /* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */
  282. # define EVP_CTRL_SET_SBOX 0x1e
  283. /*
  284. * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a
  285. * pre-allocated buffer with specified size
  286. */
  287. # define EVP_CTRL_SBOX_USED 0x1f
  288. /* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after,
  289. * 0 switches meshing off
  290. */
  291. # define EVP_CTRL_KEY_MESH 0x20
  292. /* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */
  293. # define EVP_CTRL_BLOCK_PADDING_MODE 0x21
  294. /* Set the output buffers to use for a pipelined operation */
  295. # define EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS 0x22
  296. /* Set the input buffers to use for a pipelined operation */
  297. # define EVP_CTRL_SET_PIPELINE_INPUT_BUFS 0x23
  298. /* Set the input buffer lengths to use for a pipelined operation */
  299. # define EVP_CTRL_SET_PIPELINE_INPUT_LENS 0x24
  300. /* Padding modes */
  301. #define EVP_PADDING_PKCS7 1
  302. #define EVP_PADDING_ISO7816_4 2
  303. #define EVP_PADDING_ANSI923 3
  304. #define EVP_PADDING_ISO10126 4
  305. #define EVP_PADDING_ZERO 5
  306. /* RFC 5246 defines additional data to be 13 bytes in length */
  307. # define EVP_AEAD_TLS1_AAD_LEN 13
  308. typedef struct {
  309. unsigned char *out;
  310. const unsigned char *inp;
  311. size_t len;
  312. unsigned int interleave;
  313. } EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;
  314. /* GCM TLS constants */
  315. /* Length of fixed part of IV derived from PRF */
  316. # define EVP_GCM_TLS_FIXED_IV_LEN 4
  317. /* Length of explicit part of IV part of TLS records */
  318. # define EVP_GCM_TLS_EXPLICIT_IV_LEN 8
  319. /* Length of tag for TLS */
  320. # define EVP_GCM_TLS_TAG_LEN 16
  321. /* CCM TLS constants */
  322. /* Length of fixed part of IV derived from PRF */
  323. # define EVP_CCM_TLS_FIXED_IV_LEN 4
  324. /* Length of explicit part of IV part of TLS records */
  325. # define EVP_CCM_TLS_EXPLICIT_IV_LEN 8
  326. /* Total length of CCM IV length for TLS */
  327. # define EVP_CCM_TLS_IV_LEN 12
  328. /* Length of tag for TLS */
  329. # define EVP_CCM_TLS_TAG_LEN 16
  330. /* Length of CCM8 tag for TLS */
  331. # define EVP_CCM8_TLS_TAG_LEN 8
  332. /* Length of tag for TLS */
  333. # define EVP_CHACHAPOLY_TLS_TAG_LEN 16
  334. typedef struct evp_cipher_info_st {
  335. const EVP_CIPHER *cipher;
  336. unsigned char iv[EVP_MAX_IV_LENGTH];
  337. } EVP_CIPHER_INFO;
  338. /* Password based encryption function */
  339. typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,
  340. int passlen, ASN1_TYPE *param,
  341. const EVP_CIPHER *cipher, const EVP_MD *md,
  342. int en_de);
  343. # ifndef OPENSSL_NO_RSA
  344. # define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
  345. (char *)(rsa))
  346. # endif
  347. # ifndef OPENSSL_NO_DSA
  348. # define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
  349. (char *)(dsa))
  350. # endif
  351. # ifndef OPENSSL_NO_DH
  352. # define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
  353. (char *)(dh))
  354. # endif
  355. # ifndef OPENSSL_NO_EC
  356. # define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
  357. (char *)(eckey))
  358. # endif
  359. # ifndef OPENSSL_NO_SIPHASH
  360. # define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),EVP_PKEY_SIPHASH,\
  361. (char *)(shkey))
  362. # endif
  363. # ifndef OPENSSL_NO_POLY1305
  364. # define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),EVP_PKEY_POLY1305,\
  365. (char *)(polykey))
  366. # endif
  367. /* Add some extra combinations */
  368. # define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
  369. # define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
  370. # define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
  371. # define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
  372. int EVP_MD_type(const EVP_MD *md);
  373. # define EVP_MD_nid(e) EVP_MD_type(e)
  374. # define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
  375. int EVP_MD_pkey_type(const EVP_MD *md);
  376. int EVP_MD_size(const EVP_MD *md);
  377. int EVP_MD_block_size(const EVP_MD *md);
  378. unsigned long EVP_MD_flags(const EVP_MD *md);
  379. const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
  380. int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx,
  381. const void *data, size_t count);
  382. void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx,
  383. int (*update) (EVP_MD_CTX *ctx,
  384. const void *data, size_t count));
  385. # define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
  386. # define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
  387. # define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
  388. EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx);
  389. void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);
  390. int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
  391. # define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
  392. int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
  393. int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);
  394. int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
  395. int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
  396. unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
  397. # define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)
  398. const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
  399. int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx);
  400. int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
  401. int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
  402. int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
  403. int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
  404. const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx);
  405. const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx);
  406. unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx);
  407. unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);
  408. int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx);
  409. void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);
  410. int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
  411. void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
  412. void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
  413. void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);
  414. void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);
  415. # define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
  416. # if OPENSSL_API_COMPAT < 0x10100000L
  417. # define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))
  418. # endif
  419. # define EVP_CIPHER_CTX_mode(c) EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))
  420. # define EVP_ENCODE_LENGTH(l) ((((l)+2)/3*4)+((l)/48+1)*2+80)
  421. # define EVP_DECODE_LENGTH(l) (((l)+3)/4*3+80)
  422. # define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
  423. # define EVP_SignInit(a,b) EVP_DigestInit(a,b)
  424. # define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
  425. # define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
  426. # define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
  427. # define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
  428. # define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
  429. # define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
  430. # define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
  431. # define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
  432. # ifdef CONST_STRICT
  433. void BIO_set_md(BIO *, const EVP_MD *md);
  434. # else
  435. # define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)(md))
  436. # endif
  437. # define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)(mdp))
  438. # define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0, \
  439. (char *)(mdcp))
  440. # define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0, \
  441. (char *)(mdcp))
  442. # define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
  443. # define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0, \
  444. (char *)(c_pp))
  445. /*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c,
  446. unsigned char *out,
  447. const unsigned char *in, unsigned int inl);
  448. # define EVP_add_cipher_alias(n,alias) \
  449. OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
  450. # define EVP_add_digest_alias(n,alias) \
  451. OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
  452. # define EVP_delete_cipher_alias(alias) \
  453. OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
  454. # define EVP_delete_digest_alias(alias) \
  455. OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
  456. int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
  457. EVP_MD_CTX *EVP_MD_CTX_new(void);
  458. int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
  459. void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
  460. # define EVP_MD_CTX_create() EVP_MD_CTX_new()
  461. # define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
  462. # define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
  463. __owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
  464. void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
  465. void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
  466. int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
  467. __owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
  468. ENGINE *impl);
  469. __owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,
  470. size_t cnt);
  471. __owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
  472. unsigned int *s);
  473. __owur int EVP_Digest(const void *data, size_t count,
  474. unsigned char *md, unsigned int *size,
  475. const EVP_MD *type, ENGINE *impl);
  476. __owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);
  477. __owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
  478. __owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
  479. unsigned int *s);
  480. __owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md,
  481. size_t len);
  482. int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);
  483. int EVP_read_pw_string_min(char *buf, int minlen, int maxlen,
  484. const char *prompt, int verify);
  485. void EVP_set_pw_prompt(const char *prompt);
  486. char *EVP_get_pw_prompt(void);
  487. __owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
  488. const unsigned char *salt,
  489. const unsigned char *data, int datal, int count,
  490. unsigned char *key, unsigned char *iv);
  491. void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
  492. void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
  493. int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);
  494. __owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  495. const unsigned char *key, const unsigned char *iv);
  496. /*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,
  497. const EVP_CIPHER *cipher, ENGINE *impl,
  498. const unsigned char *key,
  499. const unsigned char *iv);
  500. /*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  501. int *outl, const unsigned char *in, int inl);
  502. /*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
  503. int *outl);
  504. /*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
  505. int *outl);
  506. __owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  507. const unsigned char *key, const unsigned char *iv);
  508. /*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,
  509. const EVP_CIPHER *cipher, ENGINE *impl,
  510. const unsigned char *key,
  511. const unsigned char *iv);
  512. /*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  513. int *outl, const unsigned char *in, int inl);
  514. __owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
  515. int *outl);
  516. /*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
  517. int *outl);
  518. __owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
  519. const unsigned char *key, const unsigned char *iv,
  520. int enc);
  521. /*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,
  522. const EVP_CIPHER *cipher, ENGINE *impl,
  523. const unsigned char *key,
  524. const unsigned char *iv, int enc);
  525. __owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  526. int *outl, const unsigned char *in, int inl);
  527. __owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
  528. int *outl);
  529. __owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
  530. int *outl);
  531. __owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
  532. EVP_PKEY *pkey);
  533. __owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret,
  534. size_t *siglen, const unsigned char *tbs,
  535. size_t tbslen);
  536. __owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
  537. unsigned int siglen, EVP_PKEY *pkey);
  538. __owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
  539. size_t siglen, const unsigned char *tbs,
  540. size_t tbslen);
  541. /*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
  542. const EVP_MD *type, ENGINE *e,
  543. EVP_PKEY *pkey);
  544. __owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
  545. size_t *siglen);
  546. __owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
  547. const EVP_MD *type, ENGINE *e,
  548. EVP_PKEY *pkey);
  549. __owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
  550. size_t siglen);
  551. # ifndef OPENSSL_NO_RSA
  552. __owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  553. const unsigned char *ek, int ekl,
  554. const unsigned char *iv, EVP_PKEY *priv);
  555. __owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
  556. __owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  557. unsigned char **ek, int *ekl, unsigned char *iv,
  558. EVP_PKEY **pubk, int npubk);
  559. __owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
  560. # endif
  561. EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);
  562. void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);
  563. int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx);
  564. int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx);
  565. void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
  566. int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
  567. const unsigned char *in, int inl);
  568. void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);
  569. int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
  570. void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
  571. int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
  572. const unsigned char *in, int inl);
  573. int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
  574. char *out, int *outl);
  575. int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
  576. # if OPENSSL_API_COMPAT < 0x10100000L
  577. # define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c)
  578. # define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c)
  579. # endif
  580. EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
  581. int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
  582. void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c);
  583. int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
  584. int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
  585. int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
  586. int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
  587. const BIO_METHOD *BIO_f_md(void);
  588. const BIO_METHOD *BIO_f_base64(void);
  589. const BIO_METHOD *BIO_f_cipher(void);
  590. const BIO_METHOD *BIO_f_reliable(void);
  591. __owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,
  592. const unsigned char *i, int enc);
  593. const EVP_MD *EVP_md_null(void);
  594. # ifndef OPENSSL_NO_MD2
  595. const EVP_MD *EVP_md2(void);
  596. # endif
  597. # ifndef OPENSSL_NO_MD4
  598. const EVP_MD *EVP_md4(void);
  599. # endif
  600. # ifndef OPENSSL_NO_MD5
  601. const EVP_MD *EVP_md5(void);
  602. const EVP_MD *EVP_md5_sha1(void);
  603. # endif
  604. # ifndef OPENSSL_NO_BLAKE2
  605. const EVP_MD *EVP_blake2b512(void);
  606. const EVP_MD *EVP_blake2s256(void);
  607. # endif
  608. const EVP_MD *EVP_sha1(void);
  609. const EVP_MD *EVP_sha224(void);
  610. const EVP_MD *EVP_sha256(void);
  611. const EVP_MD *EVP_sha384(void);
  612. const EVP_MD *EVP_sha512(void);
  613. const EVP_MD *EVP_sha512_224(void);
  614. const EVP_MD *EVP_sha512_256(void);
  615. const EVP_MD *EVP_sha3_224(void);
  616. const EVP_MD *EVP_sha3_256(void);
  617. const EVP_MD *EVP_sha3_384(void);
  618. const EVP_MD *EVP_sha3_512(void);
  619. const EVP_MD *EVP_shake128(void);
  620. const EVP_MD *EVP_shake256(void);
  621. # ifndef OPENSSL_NO_MDC2
  622. const EVP_MD *EVP_mdc2(void);
  623. # endif
  624. # ifndef OPENSSL_NO_RMD160
  625. const EVP_MD *EVP_ripemd160(void);
  626. # endif
  627. # ifndef OPENSSL_NO_WHIRLPOOL
  628. const EVP_MD *EVP_whirlpool(void);
  629. # endif
  630. # ifndef OPENSSL_NO_SM3
  631. const EVP_MD *EVP_sm3(void);
  632. # endif
  633. const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
  634. # ifndef OPENSSL_NO_DES
  635. const EVP_CIPHER *EVP_des_ecb(void);
  636. const EVP_CIPHER *EVP_des_ede(void);
  637. const EVP_CIPHER *EVP_des_ede3(void);
  638. const EVP_CIPHER *EVP_des_ede_ecb(void);
  639. const EVP_CIPHER *EVP_des_ede3_ecb(void);
  640. const EVP_CIPHER *EVP_des_cfb64(void);
  641. # define EVP_des_cfb EVP_des_cfb64
  642. const EVP_CIPHER *EVP_des_cfb1(void);
  643. const EVP_CIPHER *EVP_des_cfb8(void);
  644. const EVP_CIPHER *EVP_des_ede_cfb64(void);
  645. # define EVP_des_ede_cfb EVP_des_ede_cfb64
  646. const EVP_CIPHER *EVP_des_ede3_cfb64(void);
  647. # define EVP_des_ede3_cfb EVP_des_ede3_cfb64
  648. const EVP_CIPHER *EVP_des_ede3_cfb1(void);
  649. const EVP_CIPHER *EVP_des_ede3_cfb8(void);
  650. const EVP_CIPHER *EVP_des_ofb(void);
  651. const EVP_CIPHER *EVP_des_ede_ofb(void);
  652. const EVP_CIPHER *EVP_des_ede3_ofb(void);
  653. const EVP_CIPHER *EVP_des_cbc(void);
  654. const EVP_CIPHER *EVP_des_ede_cbc(void);
  655. const EVP_CIPHER *EVP_des_ede3_cbc(void);
  656. const EVP_CIPHER *EVP_desx_cbc(void);
  657. const EVP_CIPHER *EVP_des_ede3_wrap(void);
  658. /*
  659. * This should now be supported through the dev_crypto ENGINE. But also, why
  660. * are rc4 and md5 declarations made here inside a "NO_DES" precompiler
  661. * branch?
  662. */
  663. # endif
  664. # ifndef OPENSSL_NO_RC4
  665. const EVP_CIPHER *EVP_rc4(void);
  666. const EVP_CIPHER *EVP_rc4_40(void);
  667. # ifndef OPENSSL_NO_MD5
  668. const EVP_CIPHER *EVP_rc4_hmac_md5(void);
  669. # endif
  670. # endif
  671. # ifndef OPENSSL_NO_IDEA
  672. const EVP_CIPHER *EVP_idea_ecb(void);
  673. const EVP_CIPHER *EVP_idea_cfb64(void);
  674. # define EVP_idea_cfb EVP_idea_cfb64
  675. const EVP_CIPHER *EVP_idea_ofb(void);
  676. const EVP_CIPHER *EVP_idea_cbc(void);
  677. # endif
  678. # ifndef OPENSSL_NO_RC2
  679. const EVP_CIPHER *EVP_rc2_ecb(void);
  680. const EVP_CIPHER *EVP_rc2_cbc(void);
  681. const EVP_CIPHER *EVP_rc2_40_cbc(void);
  682. const EVP_CIPHER *EVP_rc2_64_cbc(void);
  683. const EVP_CIPHER *EVP_rc2_cfb64(void);
  684. # define EVP_rc2_cfb EVP_rc2_cfb64
  685. const EVP_CIPHER *EVP_rc2_ofb(void);
  686. # endif
  687. # ifndef OPENSSL_NO_BF
  688. const EVP_CIPHER *EVP_bf_ecb(void);
  689. const EVP_CIPHER *EVP_bf_cbc(void);
  690. const EVP_CIPHER *EVP_bf_cfb64(void);
  691. # define EVP_bf_cfb EVP_bf_cfb64
  692. const EVP_CIPHER *EVP_bf_ofb(void);
  693. # endif
  694. # ifndef OPENSSL_NO_CAST
  695. const EVP_CIPHER *EVP_cast5_ecb(void);
  696. const EVP_CIPHER *EVP_cast5_cbc(void);
  697. const EVP_CIPHER *EVP_cast5_cfb64(void);
  698. # define EVP_cast5_cfb EVP_cast5_cfb64
  699. const EVP_CIPHER *EVP_cast5_ofb(void);
  700. # endif
  701. # ifndef OPENSSL_NO_RC5
  702. const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
  703. const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
  704. const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
  705. # define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64
  706. const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
  707. # endif
  708. const EVP_CIPHER *EVP_aes_128_ecb(void);
  709. const EVP_CIPHER *EVP_aes_128_cbc(void);
  710. const EVP_CIPHER *EVP_aes_128_cfb1(void);
  711. const EVP_CIPHER *EVP_aes_128_cfb8(void);
  712. const EVP_CIPHER *EVP_aes_128_cfb128(void);
  713. # define EVP_aes_128_cfb EVP_aes_128_cfb128
  714. const EVP_CIPHER *EVP_aes_128_ofb(void);
  715. const EVP_CIPHER *EVP_aes_128_ctr(void);
  716. const EVP_CIPHER *EVP_aes_128_ccm(void);
  717. const EVP_CIPHER *EVP_aes_128_gcm(void);
  718. const EVP_CIPHER *EVP_aes_128_xts(void);
  719. const EVP_CIPHER *EVP_aes_128_wrap(void);
  720. const EVP_CIPHER *EVP_aes_128_wrap_pad(void);
  721. # ifndef OPENSSL_NO_OCB
  722. const EVP_CIPHER *EVP_aes_128_ocb(void);
  723. # endif
  724. const EVP_CIPHER *EVP_aes_192_ecb(void);
  725. const EVP_CIPHER *EVP_aes_192_cbc(void);
  726. const EVP_CIPHER *EVP_aes_192_cfb1(void);
  727. const EVP_CIPHER *EVP_aes_192_cfb8(void);
  728. const EVP_CIPHER *EVP_aes_192_cfb128(void);
  729. # define EVP_aes_192_cfb EVP_aes_192_cfb128
  730. const EVP_CIPHER *EVP_aes_192_ofb(void);
  731. const EVP_CIPHER *EVP_aes_192_ctr(void);
  732. const EVP_CIPHER *EVP_aes_192_ccm(void);
  733. const EVP_CIPHER *EVP_aes_192_gcm(void);
  734. const EVP_CIPHER *EVP_aes_192_wrap(void);
  735. const EVP_CIPHER *EVP_aes_192_wrap_pad(void);
  736. # ifndef OPENSSL_NO_OCB
  737. const EVP_CIPHER *EVP_aes_192_ocb(void);
  738. # endif
  739. const EVP_CIPHER *EVP_aes_256_ecb(void);
  740. const EVP_CIPHER *EVP_aes_256_cbc(void);
  741. const EVP_CIPHER *EVP_aes_256_cfb1(void);
  742. const EVP_CIPHER *EVP_aes_256_cfb8(void);
  743. const EVP_CIPHER *EVP_aes_256_cfb128(void);
  744. # define EVP_aes_256_cfb EVP_aes_256_cfb128
  745. const EVP_CIPHER *EVP_aes_256_ofb(void);
  746. const EVP_CIPHER *EVP_aes_256_ctr(void);
  747. const EVP_CIPHER *EVP_aes_256_ccm(void);
  748. const EVP_CIPHER *EVP_aes_256_gcm(void);
  749. const EVP_CIPHER *EVP_aes_256_xts(void);
  750. const EVP_CIPHER *EVP_aes_256_wrap(void);
  751. const EVP_CIPHER *EVP_aes_256_wrap_pad(void);
  752. # ifndef OPENSSL_NO_OCB
  753. const EVP_CIPHER *EVP_aes_256_ocb(void);
  754. # endif
  755. const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
  756. const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
  757. const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);
  758. const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);
  759. # ifndef OPENSSL_NO_ARIA
  760. const EVP_CIPHER *EVP_aria_128_ecb(void);
  761. const EVP_CIPHER *EVP_aria_128_cbc(void);
  762. const EVP_CIPHER *EVP_aria_128_cfb1(void);
  763. const EVP_CIPHER *EVP_aria_128_cfb8(void);
  764. const EVP_CIPHER *EVP_aria_128_cfb128(void);
  765. # define EVP_aria_128_cfb EVP_aria_128_cfb128
  766. const EVP_CIPHER *EVP_aria_128_ctr(void);
  767. const EVP_CIPHER *EVP_aria_128_ofb(void);
  768. const EVP_CIPHER *EVP_aria_128_gcm(void);
  769. const EVP_CIPHER *EVP_aria_128_ccm(void);
  770. const EVP_CIPHER *EVP_aria_192_ecb(void);
  771. const EVP_CIPHER *EVP_aria_192_cbc(void);
  772. const EVP_CIPHER *EVP_aria_192_cfb1(void);
  773. const EVP_CIPHER *EVP_aria_192_cfb8(void);
  774. const EVP_CIPHER *EVP_aria_192_cfb128(void);
  775. # define EVP_aria_192_cfb EVP_aria_192_cfb128
  776. const EVP_CIPHER *EVP_aria_192_ctr(void);
  777. const EVP_CIPHER *EVP_aria_192_ofb(void);
  778. const EVP_CIPHER *EVP_aria_192_gcm(void);
  779. const EVP_CIPHER *EVP_aria_192_ccm(void);
  780. const EVP_CIPHER *EVP_aria_256_ecb(void);
  781. const EVP_CIPHER *EVP_aria_256_cbc(void);
  782. const EVP_CIPHER *EVP_aria_256_cfb1(void);
  783. const EVP_CIPHER *EVP_aria_256_cfb8(void);
  784. const EVP_CIPHER *EVP_aria_256_cfb128(void);
  785. # define EVP_aria_256_cfb EVP_aria_256_cfb128
  786. const EVP_CIPHER *EVP_aria_256_ctr(void);
  787. const EVP_CIPHER *EVP_aria_256_ofb(void);
  788. const EVP_CIPHER *EVP_aria_256_gcm(void);
  789. const EVP_CIPHER *EVP_aria_256_ccm(void);
  790. # endif
  791. # ifndef OPENSSL_NO_CAMELLIA
  792. const EVP_CIPHER *EVP_camellia_128_ecb(void);
  793. const EVP_CIPHER *EVP_camellia_128_cbc(void);
  794. const EVP_CIPHER *EVP_camellia_128_cfb1(void);
  795. const EVP_CIPHER *EVP_camellia_128_cfb8(void);
  796. const EVP_CIPHER *EVP_camellia_128_cfb128(void);
  797. # define EVP_camellia_128_cfb EVP_camellia_128_cfb128
  798. const EVP_CIPHER *EVP_camellia_128_ofb(void);
  799. const EVP_CIPHER *EVP_camellia_128_ctr(void);
  800. const EVP_CIPHER *EVP_camellia_192_ecb(void);
  801. const EVP_CIPHER *EVP_camellia_192_cbc(void);
  802. const EVP_CIPHER *EVP_camellia_192_cfb1(void);
  803. const EVP_CIPHER *EVP_camellia_192_cfb8(void);
  804. const EVP_CIPHER *EVP_camellia_192_cfb128(void);
  805. # define EVP_camellia_192_cfb EVP_camellia_192_cfb128
  806. const EVP_CIPHER *EVP_camellia_192_ofb(void);
  807. const EVP_CIPHER *EVP_camellia_192_ctr(void);
  808. const EVP_CIPHER *EVP_camellia_256_ecb(void);
  809. const EVP_CIPHER *EVP_camellia_256_cbc(void);
  810. const EVP_CIPHER *EVP_camellia_256_cfb1(void);
  811. const EVP_CIPHER *EVP_camellia_256_cfb8(void);
  812. const EVP_CIPHER *EVP_camellia_256_cfb128(void);
  813. # define EVP_camellia_256_cfb EVP_camellia_256_cfb128
  814. const EVP_CIPHER *EVP_camellia_256_ofb(void);
  815. const EVP_CIPHER *EVP_camellia_256_ctr(void);
  816. # endif
  817. # ifndef OPENSSL_NO_CHACHA
  818. const EVP_CIPHER *EVP_chacha20(void);
  819. # ifndef OPENSSL_NO_POLY1305
  820. const EVP_CIPHER *EVP_chacha20_poly1305(void);
  821. # endif
  822. # endif
  823. # ifndef OPENSSL_NO_SEED
  824. const EVP_CIPHER *EVP_seed_ecb(void);
  825. const EVP_CIPHER *EVP_seed_cbc(void);
  826. const EVP_CIPHER *EVP_seed_cfb128(void);
  827. # define EVP_seed_cfb EVP_seed_cfb128
  828. const EVP_CIPHER *EVP_seed_ofb(void);
  829. # endif
  830. # ifndef OPENSSL_NO_SM4
  831. const EVP_CIPHER *EVP_sm4_ecb(void);
  832. const EVP_CIPHER *EVP_sm4_cbc(void);
  833. const EVP_CIPHER *EVP_sm4_cfb128(void);
  834. # define EVP_sm4_cfb EVP_sm4_cfb128
  835. const EVP_CIPHER *EVP_sm4_ofb(void);
  836. const EVP_CIPHER *EVP_sm4_ctr(void);
  837. # endif
  838. # if OPENSSL_API_COMPAT < 0x10100000L
  839. # define OPENSSL_add_all_algorithms_conf() \
  840. OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
  841. | OPENSSL_INIT_ADD_ALL_DIGESTS \
  842. | OPENSSL_INIT_LOAD_CONFIG, NULL)
  843. # define OPENSSL_add_all_algorithms_noconf() \
  844. OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
  845. | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
  846. # ifdef OPENSSL_LOAD_CONF
  847. # define OpenSSL_add_all_algorithms() \
  848. OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
  849. | OPENSSL_INIT_ADD_ALL_DIGESTS \
  850. | OPENSSL_INIT_LOAD_CONFIG, NULL)
  851. # else
  852. # define OpenSSL_add_all_algorithms() \
  853. OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
  854. | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
  855. # endif
  856. # define OpenSSL_add_all_ciphers() \
  857. OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)
  858. # define OpenSSL_add_all_digests() \
  859. OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
  860. # define EVP_cleanup() while(0) continue
  861. # endif
  862. int EVP_add_cipher(const EVP_CIPHER *cipher);
  863. int EVP_add_digest(const EVP_MD *digest);
  864. const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
  865. const EVP_MD *EVP_get_digestbyname(const char *name);
  866. void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,
  867. const char *from, const char *to, void *x),
  868. void *arg);
  869. void EVP_CIPHER_do_all_sorted(void (*fn)
  870. (const EVP_CIPHER *ciph, const char *from,
  871. const char *to, void *x), void *arg);
  872. void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,
  873. const char *from, const char *to, void *x),
  874. void *arg);
  875. void EVP_MD_do_all_sorted(void (*fn)
  876. (const EVP_MD *ciph, const char *from,
  877. const char *to, void *x), void *arg);
  878. int EVP_PKEY_decrypt_old(unsigned char *dec_key,
  879. const unsigned char *enc_key, int enc_key_len,
  880. EVP_PKEY *private_key);
  881. int EVP_PKEY_encrypt_old(unsigned char *enc_key,
  882. const unsigned char *key, int key_len,
  883. EVP_PKEY *pub_key);
  884. int EVP_PKEY_type(int type);
  885. int EVP_PKEY_id(const EVP_PKEY *pkey);
  886. int EVP_PKEY_base_id(const EVP_PKEY *pkey);
  887. int EVP_PKEY_bits(const EVP_PKEY *pkey);
  888. int EVP_PKEY_security_bits(const EVP_PKEY *pkey);
  889. int EVP_PKEY_size(EVP_PKEY *pkey);
  890. int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
  891. int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
  892. # ifndef OPENSSL_NO_ENGINE
  893. int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e);
  894. # endif
  895. int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);
  896. void *EVP_PKEY_get0(const EVP_PKEY *pkey);
  897. const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
  898. # ifndef OPENSSL_NO_POLY1305
  899. const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);
  900. # endif
  901. # ifndef OPENSSL_NO_SIPHASH
  902. const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);
  903. # endif
  904. # ifndef OPENSSL_NO_RSA
  905. struct rsa_st;
  906. int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
  907. struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
  908. struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
  909. # endif
  910. # ifndef OPENSSL_NO_DSA
  911. struct dsa_st;
  912. int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
  913. struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);
  914. struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
  915. # endif
  916. # ifndef OPENSSL_NO_DH
  917. struct dh_st;
  918. int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
  919. struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey);
  920. struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
  921. # endif
  922. # ifndef OPENSSL_NO_EC
  923. struct ec_key_st;
  924. int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
  925. struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
  926. struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
  927. # endif
  928. EVP_PKEY *EVP_PKEY_new(void);
  929. int EVP_PKEY_up_ref(EVP_PKEY *pkey);
  930. void EVP_PKEY_free(EVP_PKEY *pkey);
  931. EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
  932. long length);
  933. int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
  934. EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
  935. long length);
  936. EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
  937. long length);
  938. int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
  939. int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
  940. int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
  941. int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);
  942. int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
  943. int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
  944. int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
  945. int indent, ASN1_PCTX *pctx);
  946. int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
  947. int indent, ASN1_PCTX *pctx);
  948. int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
  949. int indent, ASN1_PCTX *pctx);
  950. int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
  951. int EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey,
  952. const unsigned char *pt, size_t ptlen);
  953. size_t EVP_PKEY_get1_tls_encodedpoint(EVP_PKEY *pkey, unsigned char **ppt);
  954. int EVP_CIPHER_type(const EVP_CIPHER *ctx);
  955. /* calls methods */
  956. int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
  957. int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
  958. /* These are used by EVP_CIPHER methods */
  959. int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
  960. int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
  961. /* PKCS5 password based encryption */
  962. int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
  963. ASN1_TYPE *param, const EVP_CIPHER *cipher,
  964. const EVP_MD *md, int en_de);
  965. int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
  966. const unsigned char *salt, int saltlen, int iter,
  967. int keylen, unsigned char *out);
  968. int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
  969. const unsigned char *salt, int saltlen, int iter,
  970. const EVP_MD *digest, int keylen, unsigned char *out);
  971. int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
  972. ASN1_TYPE *param, const EVP_CIPHER *cipher,
  973. const EVP_MD *md, int en_de);
  974. #ifndef OPENSSL_NO_SCRYPT
  975. int EVP_PBE_scrypt(const char *pass, size_t passlen,
  976. const unsigned char *salt, size_t saltlen,
  977. uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,
  978. unsigned char *key, size_t keylen);
  979. int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
  980. int passlen, ASN1_TYPE *param,
  981. const EVP_CIPHER *c, const EVP_MD *md, int en_de);
  982. #endif
  983. void PKCS5_PBE_add(void);
  984. int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
  985. ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
  986. /* PBE type */
  987. /* Can appear as the outermost AlgorithmIdentifier */
  988. # define EVP_PBE_TYPE_OUTER 0x0
  989. /* Is an PRF type OID */
  990. # define EVP_PBE_TYPE_PRF 0x1
  991. /* Is a PKCS#5 v2.0 KDF */
  992. # define EVP_PBE_TYPE_KDF 0x2
  993. int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
  994. int md_nid, EVP_PBE_KEYGEN *keygen);
  995. int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
  996. EVP_PBE_KEYGEN *keygen);
  997. int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,
  998. EVP_PBE_KEYGEN **pkeygen);
  999. void EVP_PBE_cleanup(void);
  1000. int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num);
  1001. # define ASN1_PKEY_ALIAS 0x1
  1002. # define ASN1_PKEY_DYNAMIC 0x2
  1003. # define ASN1_PKEY_SIGPARAM_NULL 0x4
  1004. # define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1
  1005. # define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2
  1006. # define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3
  1007. # define ASN1_PKEY_CTRL_CMS_SIGN 0x5
  1008. # define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7
  1009. # define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8
  1010. # define ASN1_PKEY_CTRL_SET1_TLS_ENCPT 0x9
  1011. # define ASN1_PKEY_CTRL_GET1_TLS_ENCPT 0xa
  1012. int EVP_PKEY_asn1_get_count(void);
  1013. const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
  1014. const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
  1015. const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
  1016. const char *str, int len);
  1017. int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
  1018. int EVP_PKEY_asn1_add_alias(int to, int from);
  1019. int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,
  1020. int *ppkey_flags, const char **pinfo,
  1021. const char **ppem_str,
  1022. const EVP_PKEY_ASN1_METHOD *ameth);
  1023. const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey);
  1024. EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
  1025. const char *pem_str,
  1026. const char *info);
  1027. void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
  1028. const EVP_PKEY_ASN1_METHOD *src);
  1029. void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
  1030. void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
  1031. int (*pub_decode) (EVP_PKEY *pk,
  1032. X509_PUBKEY *pub),
  1033. int (*pub_encode) (X509_PUBKEY *pub,
  1034. const EVP_PKEY *pk),
  1035. int (*pub_cmp) (const EVP_PKEY *a,
  1036. const EVP_PKEY *b),
  1037. int (*pub_print) (BIO *out,
  1038. const EVP_PKEY *pkey,
  1039. int indent, ASN1_PCTX *pctx),
  1040. int (*pkey_size) (const EVP_PKEY *pk),
  1041. int (*pkey_bits) (const EVP_PKEY *pk));
  1042. void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
  1043. int (*priv_decode) (EVP_PKEY *pk,
  1044. const PKCS8_PRIV_KEY_INFO
  1045. *p8inf),
  1046. int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,
  1047. const EVP_PKEY *pk),
  1048. int (*priv_print) (BIO *out,
  1049. const EVP_PKEY *pkey,
  1050. int indent,
  1051. ASN1_PCTX *pctx));
  1052. void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
  1053. int (*param_decode) (EVP_PKEY *pkey,
  1054. const unsigned char **pder,
  1055. int derlen),
  1056. int (*param_encode) (const EVP_PKEY *pkey,
  1057. unsigned char **pder),
  1058. int (*param_missing) (const EVP_PKEY *pk),
  1059. int (*param_copy) (EVP_PKEY *to,
  1060. const EVP_PKEY *from),
  1061. int (*param_cmp) (const EVP_PKEY *a,
  1062. const EVP_PKEY *b),
  1063. int (*param_print) (BIO *out,
  1064. const EVP_PKEY *pkey,
  1065. int indent,
  1066. ASN1_PCTX *pctx));
  1067. void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
  1068. void (*pkey_free) (EVP_PKEY *pkey));
  1069. void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
  1070. int (*pkey_ctrl) (EVP_PKEY *pkey, int op,
  1071. long arg1, void *arg2));
  1072. void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,
  1073. int (*item_verify) (EVP_MD_CTX *ctx,
  1074. const ASN1_ITEM *it,
  1075. void *asn,
  1076. X509_ALGOR *a,
  1077. ASN1_BIT_STRING *sig,
  1078. EVP_PKEY *pkey),
  1079. int (*item_sign) (EVP_MD_CTX *ctx,
  1080. const ASN1_ITEM *it,
  1081. void *asn,
  1082. X509_ALGOR *alg1,
  1083. X509_ALGOR *alg2,
  1084. ASN1_BIT_STRING *sig));
  1085. void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,
  1086. int (*siginf_set) (X509_SIG_INFO *siginf,
  1087. const X509_ALGOR *alg,
  1088. const ASN1_STRING *sig));
  1089. void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
  1090. int (*pkey_check) (const EVP_PKEY *pk));
  1091. void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,
  1092. int (*pkey_pub_check) (const EVP_PKEY *pk));
  1093. void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,
  1094. int (*pkey_param_check) (const EVP_PKEY *pk));
  1095. void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
  1096. int (*pkey_security_bits) (const EVP_PKEY
  1097. *pk));
  1098. # define EVP_PKEY_OP_UNDEFINED 0
  1099. # define EVP_PKEY_OP_PARAMGEN (1<<1)
  1100. # define EVP_PKEY_OP_KEYGEN (1<<2)
  1101. # define EVP_PKEY_OP_SIGN (1<<3)
  1102. # define EVP_PKEY_OP_VERIFY (1<<4)
  1103. # define EVP_PKEY_OP_VERIFYRECOVER (1<<5)
  1104. # define EVP_PKEY_OP_SIGNCTX (1<<6)
  1105. # define EVP_PKEY_OP_VERIFYCTX (1<<7)
  1106. # define EVP_PKEY_OP_ENCRYPT (1<<8)
  1107. # define EVP_PKEY_OP_DECRYPT (1<<9)
  1108. # define EVP_PKEY_OP_DERIVE (1<<10)
  1109. # define EVP_PKEY_OP_TYPE_SIG \
  1110. (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \
  1111. | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)
  1112. # define EVP_PKEY_OP_TYPE_CRYPT \
  1113. (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)
  1114. # define EVP_PKEY_OP_TYPE_NOGEN \
  1115. (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE)
  1116. # define EVP_PKEY_OP_TYPE_GEN \
  1117. (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
  1118. # define EVP_PKEY_CTX_set_signature_md(ctx, md) \
  1119. EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
  1120. EVP_PKEY_CTRL_MD, 0, (void *)(md))
  1121. # define EVP_PKEY_CTX_get_signature_md(ctx, pmd) \
  1122. EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
  1123. EVP_PKEY_CTRL_GET_MD, 0, (void *)(pmd))
  1124. # define EVP_PKEY_CTX_set_mac_key(ctx, key, len) \
  1125. EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN, \
  1126. EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)(key))
  1127. # define EVP_PKEY_CTRL_MD 1
  1128. # define EVP_PKEY_CTRL_PEER_KEY 2
  1129. # define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3
  1130. # define EVP_PKEY_CTRL_PKCS7_DECRYPT 4
  1131. # define EVP_PKEY_CTRL_PKCS7_SIGN 5
  1132. # define EVP_PKEY_CTRL_SET_MAC_KEY 6
  1133. # define EVP_PKEY_CTRL_DIGESTINIT 7
  1134. /* Used by GOST key encryption in TLS */
  1135. # define EVP_PKEY_CTRL_SET_IV 8
  1136. # define EVP_PKEY_CTRL_CMS_ENCRYPT 9
  1137. # define EVP_PKEY_CTRL_CMS_DECRYPT 10
  1138. # define EVP_PKEY_CTRL_CMS_SIGN 11
  1139. # define EVP_PKEY_CTRL_CIPHER 12
  1140. # define EVP_PKEY_CTRL_GET_MD 13
  1141. # define EVP_PKEY_CTRL_SET_DIGEST_SIZE 14
  1142. # define EVP_PKEY_ALG_CTRL 0x1000
  1143. # define EVP_PKEY_FLAG_AUTOARGLEN 2
  1144. /*
  1145. * Method handles all operations: don't assume any digest related defaults.
  1146. */
  1147. # define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4
  1148. const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
  1149. EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
  1150. void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
  1151. const EVP_PKEY_METHOD *meth);
  1152. void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
  1153. void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
  1154. int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
  1155. int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);
  1156. size_t EVP_PKEY_meth_get_count(void);
  1157. const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx);
  1158. EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
  1159. EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
  1160. EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);
  1161. void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
  1162. int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
  1163. int cmd, int p1, void *p2);
  1164. int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
  1165. const char *value);
  1166. int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype,
  1167. int cmd, uint64_t value);
  1168. int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);
  1169. int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);
  1170. int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md);
  1171. int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
  1172. void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
  1173. EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
  1174. const unsigned char *key, int keylen);
  1175. void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
  1176. void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
  1177. EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
  1178. EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);
  1179. void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
  1180. void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
  1181. int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
  1182. int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
  1183. unsigned char *sig, size_t *siglen,
  1184. const unsigned char *tbs, size_t tbslen);
  1185. int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
  1186. int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
  1187. const unsigned char *sig, size_t siglen,
  1188. const unsigned char *tbs, size_t tbslen);
  1189. int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
  1190. int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
  1191. unsigned char *rout, size_t *routlen,
  1192. const unsigned char *sig, size_t siglen);
  1193. int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
  1194. int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
  1195. unsigned char *out, size_t *outlen,
  1196. const unsigned char *in, size_t inlen);
  1197. int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
  1198. int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
  1199. unsigned char *out, size_t *outlen,
  1200. const unsigned char *in, size_t inlen);
  1201. int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
  1202. int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
  1203. int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
  1204. typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
  1205. int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
  1206. int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
  1207. int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
  1208. int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
  1209. int EVP_PKEY_check(EVP_PKEY_CTX *ctx);
  1210. int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);
  1211. int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
  1212. void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
  1213. EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
  1214. int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
  1215. void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
  1216. int (*init) (EVP_PKEY_CTX *ctx));
  1217. void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
  1218. int (*copy) (EVP_PKEY_CTX *dst,
  1219. EVP_PKEY_CTX *src));
  1220. void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
  1221. void (*cleanup) (EVP_PKEY_CTX *ctx));
  1222. void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
  1223. int (*paramgen_init) (EVP_PKEY_CTX *ctx),
  1224. int (*paramgen) (EVP_PKEY_CTX *ctx,
  1225. EVP_PKEY *pkey));
  1226. void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
  1227. int (*keygen_init) (EVP_PKEY_CTX *ctx),
  1228. int (*keygen) (EVP_PKEY_CTX *ctx,
  1229. EVP_PKEY *pkey));
  1230. void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
  1231. int (*sign_init) (EVP_PKEY_CTX *ctx),
  1232. int (*sign) (EVP_PKEY_CTX *ctx,
  1233. unsigned char *sig, size_t *siglen,
  1234. const unsigned char *tbs,
  1235. size_t tbslen));
  1236. void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
  1237. int (*verify_init) (EVP_PKEY_CTX *ctx),
  1238. int (*verify) (EVP_PKEY_CTX *ctx,
  1239. const unsigned char *sig,
  1240. size_t siglen,
  1241. const unsigned char *tbs,
  1242. size_t tbslen));
  1243. void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
  1244. int (*verify_recover_init) (EVP_PKEY_CTX
  1245. *ctx),
  1246. int (*verify_recover) (EVP_PKEY_CTX
  1247. *ctx,
  1248. unsigned char
  1249. *sig,
  1250. size_t *siglen,
  1251. const unsigned
  1252. char *tbs,
  1253. size_t tbslen));
  1254. void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
  1255. int (*signctx_init) (EVP_PKEY_CTX *ctx,
  1256. EVP_MD_CTX *mctx),
  1257. int (*signctx) (EVP_PKEY_CTX *ctx,
  1258. unsigned char *sig,
  1259. size_t *siglen,
  1260. EVP_MD_CTX *mctx));
  1261. void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
  1262. int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
  1263. EVP_MD_CTX *mctx),
  1264. int (*verifyctx) (EVP_PKEY_CTX *ctx,
  1265. const unsigned char *sig,
  1266. int siglen,
  1267. EVP_MD_CTX *mctx));
  1268. void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
  1269. int (*encrypt_init) (EVP_PKEY_CTX *ctx),
  1270. int (*encryptfn) (EVP_PKEY_CTX *ctx,
  1271. unsigned char *out,
  1272. size_t *outlen,
  1273. const unsigned char *in,
  1274. size_t inlen));
  1275. void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
  1276. int (*decrypt_init) (EVP_PKEY_CTX *ctx),
  1277. int (*decrypt) (EVP_PKEY_CTX *ctx,
  1278. unsigned char *out,
  1279. size_t *outlen,
  1280. const unsigned char *in,
  1281. size_t inlen));
  1282. void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
  1283. int (*derive_init) (EVP_PKEY_CTX *ctx),
  1284. int (*derive) (EVP_PKEY_CTX *ctx,
  1285. unsigned char *key,
  1286. size_t *keylen));
  1287. void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
  1288. int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
  1289. void *p2),
  1290. int (*ctrl_str) (EVP_PKEY_CTX *ctx,
  1291. const char *type,
  1292. const char *value));
  1293. void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,
  1294. int (*check) (EVP_PKEY *pkey));
  1295. void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
  1296. int (*check) (EVP_PKEY *pkey));
  1297. void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
  1298. int (*check) (EVP_PKEY *pkey));
  1299. void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth,
  1300. int (**pinit) (EVP_PKEY_CTX *ctx));
  1301. void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth,
  1302. int (**pcopy) (EVP_PKEY_CTX *dst,
  1303. EVP_PKEY_CTX *src));
  1304. void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth,
  1305. void (**pcleanup) (EVP_PKEY_CTX *ctx));
  1306. void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth,
  1307. int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
  1308. int (**pparamgen) (EVP_PKEY_CTX *ctx,
  1309. EVP_PKEY *pkey));
  1310. void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth,
  1311. int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
  1312. int (**pkeygen) (EVP_PKEY_CTX *ctx,
  1313. EVP_PKEY *pkey));
  1314. void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth,
  1315. int (**psign_init) (EVP_PKEY_CTX *ctx),
  1316. int (**psign) (EVP_PKEY_CTX *ctx,
  1317. unsigned char *sig, size_t *siglen,
  1318. const unsigned char *tbs,
  1319. size_t tbslen));
  1320. void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth,
  1321. int (**pverify_init) (EVP_PKEY_CTX *ctx),
  1322. int (**pverify) (EVP_PKEY_CTX *ctx,
  1323. const unsigned char *sig,
  1324. size_t siglen,
  1325. const unsigned char *tbs,
  1326. size_t tbslen));
  1327. void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth,
  1328. int (**pverify_recover_init) (EVP_PKEY_CTX
  1329. *ctx),
  1330. int (**pverify_recover) (EVP_PKEY_CTX
  1331. *ctx,
  1332. unsigned char
  1333. *sig,
  1334. size_t *siglen,
  1335. const unsigned
  1336. char *tbs,
  1337. size_t tbslen));
  1338. void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth,
  1339. int (**psignctx_init) (EVP_PKEY_CTX *ctx,
  1340. EVP_MD_CTX *mctx),
  1341. int (**psignctx) (EVP_PKEY_CTX *ctx,
  1342. unsigned char *sig,
  1343. size_t *siglen,
  1344. EVP_MD_CTX *mctx));
  1345. void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth,
  1346. int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
  1347. EVP_MD_CTX *mctx),
  1348. int (**pverifyctx) (EVP_PKEY_CTX *ctx,
  1349. const unsigned char *sig,
  1350. int siglen,
  1351. EVP_MD_CTX *mctx));
  1352. void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth,
  1353. int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
  1354. int (**pencryptfn) (EVP_PKEY_CTX *ctx,
  1355. unsigned char *out,
  1356. size_t *outlen,
  1357. const unsigned char *in,
  1358. size_t inlen));
  1359. void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth,
  1360. int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
  1361. int (**pdecrypt) (EVP_PKEY_CTX *ctx,
  1362. unsigned char *out,
  1363. size_t *outlen,
  1364. const unsigned char *in,
  1365. size_t inlen));
  1366. void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth,
  1367. int (**pderive_init) (EVP_PKEY_CTX *ctx),
  1368. int (**pderive) (EVP_PKEY_CTX *ctx,
  1369. unsigned char *key,
  1370. size_t *keylen));
  1371. void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth,
  1372. int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
  1373. void *p2),
  1374. int (**pctrl_str) (EVP_PKEY_CTX *ctx,
  1375. const char *type,
  1376. const char *value));
  1377. void EVP_PKEY_meth_get_check(EVP_PKEY_METHOD *pmeth,
  1378. int (**pcheck) (EVP_PKEY *pkey));
  1379. void EVP_PKEY_meth_get_public_check(EVP_PKEY_METHOD *pmeth,
  1380. int (**pcheck) (EVP_PKEY *pkey));
  1381. void EVP_PKEY_meth_get_param_check(EVP_PKEY_METHOD *pmeth,
  1382. int (**pcheck) (EVP_PKEY *pkey));
  1383. void EVP_add_alg_module(void);
  1384. # ifdef __cplusplus
  1385. }
  1386. # endif
  1387. #endif