evp.h 75 KB

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