EVP_EncryptInit.3ossl 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "EVP_ENCRYPTINIT 3ossl"
  136. .TH EVP_ENCRYPTINIT 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. EVP_CIPHER_fetch,
  143. EVP_CIPHER_up_ref,
  144. EVP_CIPHER_free,
  145. EVP_CIPHER_CTX_new,
  146. EVP_CIPHER_CTX_reset,
  147. EVP_CIPHER_CTX_free,
  148. EVP_CIPHER_CTX_dup,
  149. EVP_CIPHER_CTX_copy,
  150. EVP_EncryptInit_ex,
  151. EVP_EncryptInit_ex2,
  152. EVP_EncryptUpdate,
  153. EVP_EncryptFinal_ex,
  154. EVP_DecryptInit_ex,
  155. EVP_DecryptInit_ex2,
  156. EVP_DecryptUpdate,
  157. EVP_DecryptFinal_ex,
  158. EVP_CipherInit_ex,
  159. EVP_CipherInit_ex2,
  160. EVP_CipherUpdate,
  161. EVP_CipherFinal_ex,
  162. EVP_CIPHER_CTX_set_key_length,
  163. EVP_CIPHER_CTX_ctrl,
  164. EVP_EncryptInit,
  165. EVP_EncryptFinal,
  166. EVP_DecryptInit,
  167. EVP_DecryptFinal,
  168. EVP_CipherInit,
  169. EVP_CipherFinal,
  170. EVP_Cipher,
  171. EVP_get_cipherbyname,
  172. EVP_get_cipherbynid,
  173. EVP_get_cipherbyobj,
  174. EVP_CIPHER_is_a,
  175. EVP_CIPHER_get0_name,
  176. EVP_CIPHER_get0_description,
  177. EVP_CIPHER_names_do_all,
  178. EVP_CIPHER_get0_provider,
  179. EVP_CIPHER_get_nid,
  180. EVP_CIPHER_get_params,
  181. EVP_CIPHER_gettable_params,
  182. EVP_CIPHER_get_block_size,
  183. EVP_CIPHER_get_key_length,
  184. EVP_CIPHER_get_iv_length,
  185. EVP_CIPHER_get_flags,
  186. EVP_CIPHER_get_mode,
  187. EVP_CIPHER_get_type,
  188. EVP_CIPHER_CTX_cipher,
  189. EVP_CIPHER_CTX_get0_cipher,
  190. EVP_CIPHER_CTX_get1_cipher,
  191. EVP_CIPHER_CTX_get0_name,
  192. EVP_CIPHER_CTX_get_nid,
  193. EVP_CIPHER_CTX_get_params,
  194. EVP_CIPHER_gettable_ctx_params,
  195. EVP_CIPHER_CTX_gettable_params,
  196. EVP_CIPHER_CTX_set_params,
  197. EVP_CIPHER_settable_ctx_params,
  198. EVP_CIPHER_CTX_settable_params,
  199. EVP_CIPHER_CTX_get_block_size,
  200. EVP_CIPHER_CTX_get_key_length,
  201. EVP_CIPHER_CTX_get_iv_length,
  202. EVP_CIPHER_CTX_get_tag_length,
  203. EVP_CIPHER_CTX_get_app_data,
  204. EVP_CIPHER_CTX_set_app_data,
  205. EVP_CIPHER_CTX_flags,
  206. EVP_CIPHER_CTX_set_flags,
  207. EVP_CIPHER_CTX_clear_flags,
  208. EVP_CIPHER_CTX_test_flags,
  209. EVP_CIPHER_CTX_get_type,
  210. EVP_CIPHER_CTX_get_mode,
  211. EVP_CIPHER_CTX_get_num,
  212. EVP_CIPHER_CTX_set_num,
  213. EVP_CIPHER_CTX_is_encrypting,
  214. EVP_CIPHER_param_to_asn1,
  215. EVP_CIPHER_asn1_to_param,
  216. EVP_CIPHER_CTX_set_padding,
  217. EVP_enc_null,
  218. EVP_CIPHER_do_all_provided,
  219. EVP_CIPHER_nid,
  220. EVP_CIPHER_name,
  221. EVP_CIPHER_block_size,
  222. EVP_CIPHER_key_length,
  223. EVP_CIPHER_iv_length,
  224. EVP_CIPHER_flags,
  225. EVP_CIPHER_mode,
  226. EVP_CIPHER_type,
  227. EVP_CIPHER_CTX_encrypting,
  228. EVP_CIPHER_CTX_nid,
  229. EVP_CIPHER_CTX_block_size,
  230. EVP_CIPHER_CTX_key_length,
  231. EVP_CIPHER_CTX_iv_length,
  232. EVP_CIPHER_CTX_tag_length,
  233. EVP_CIPHER_CTX_num,
  234. EVP_CIPHER_CTX_type,
  235. EVP_CIPHER_CTX_mode
  236. \&\- EVP cipher routines
  237. .SH "SYNOPSIS"
  238. .IX Header "SYNOPSIS"
  239. .Vb 1
  240. \& #include <openssl/evp.h>
  241. \&
  242. \& EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
  243. \& const char *properties);
  244. \& int EVP_CIPHER_up_ref(EVP_CIPHER *cipher);
  245. \& void EVP_CIPHER_free(EVP_CIPHER *cipher);
  246. \& EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
  247. \& int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx);
  248. \& void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx);
  249. \& EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in);
  250. \& int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
  251. \&
  252. \& int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  253. \& ENGINE *impl, const unsigned char *key, const unsigned char *iv);
  254. \& int EVP_EncryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  255. \& const unsigned char *key, const unsigned char *iv,
  256. \& const OSSL_PARAM params[]);
  257. \& int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  258. \& int *outl, const unsigned char *in, int inl);
  259. \& int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
  260. \&
  261. \& int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  262. \& ENGINE *impl, const unsigned char *key, const unsigned char *iv);
  263. \& int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  264. \& const unsigned char *key, const unsigned char *iv,
  265. \& const OSSL_PARAM params[]);
  266. \& int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  267. \& int *outl, const unsigned char *in, int inl);
  268. \& int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
  269. \&
  270. \& int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  271. \& ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc);
  272. \& int EVP_CipherInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  273. \& const unsigned char *key, const unsigned char *iv,
  274. \& int enc, const OSSL_PARAM params[]);
  275. \& int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
  276. \& int *outl, const unsigned char *in, int inl);
  277. \& int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
  278. \&
  279. \& int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  280. \& const unsigned char *key, const unsigned char *iv);
  281. \& int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
  282. \&
  283. \& int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  284. \& const unsigned char *key, const unsigned char *iv);
  285. \& int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
  286. \&
  287. \& int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
  288. \& const unsigned char *key, const unsigned char *iv, int enc);
  289. \& int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
  290. \&
  291. \& int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  292. \& const unsigned char *in, unsigned int inl);
  293. \&
  294. \& int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding);
  295. \& int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
  296. \& int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int cmd, int p1, void *p2);
  297. \& int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
  298. \& void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
  299. \& void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
  300. \& int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);
  301. \&
  302. \& const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
  303. \& const EVP_CIPHER *EVP_get_cipherbynid(int nid);
  304. \& const EVP_CIPHER *EVP_get_cipherbyobj(const ASN1_OBJECT *a);
  305. \&
  306. \& int EVP_CIPHER_get_nid(const EVP_CIPHER *e);
  307. \& int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name);
  308. \& int EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher,
  309. \& void (*fn)(const char *name, void *data),
  310. \& void *data);
  311. \& const char *EVP_CIPHER_get0_name(const EVP_CIPHER *cipher);
  312. \& const char *EVP_CIPHER_get0_description(const EVP_CIPHER *cipher);
  313. \& const OSSL_PROVIDER *EVP_CIPHER_get0_provider(const EVP_CIPHER *cipher);
  314. \& int EVP_CIPHER_get_block_size(const EVP_CIPHER *e);
  315. \& int EVP_CIPHER_get_key_length(const EVP_CIPHER *e);
  316. \& int EVP_CIPHER_get_iv_length(const EVP_CIPHER *e);
  317. \& unsigned long EVP_CIPHER_get_flags(const EVP_CIPHER *e);
  318. \& unsigned long EVP_CIPHER_get_mode(const EVP_CIPHER *e);
  319. \& int EVP_CIPHER_get_type(const EVP_CIPHER *cipher);
  320. \&
  321. \& const EVP_CIPHER *EVP_CIPHER_CTX_get0_cipher(const EVP_CIPHER_CTX *ctx);
  322. \& EVP_CIPHER *EVP_CIPHER_CTX_get1_cipher(const EVP_CIPHER_CTX *ctx);
  323. \& int EVP_CIPHER_CTX_get_nid(const EVP_CIPHER_CTX *ctx);
  324. \& const char *EVP_CIPHER_CTX_get0_name(const EVP_CIPHER_CTX *ctx);
  325. \&
  326. \& int EVP_CIPHER_get_params(EVP_CIPHER *cipher, OSSL_PARAM params[]);
  327. \& int EVP_CIPHER_CTX_set_params(EVP_CIPHER_CTX *ctx, const OSSL_PARAM params[]);
  328. \& int EVP_CIPHER_CTX_get_params(EVP_CIPHER_CTX *ctx, OSSL_PARAM params[]);
  329. \& const OSSL_PARAM *EVP_CIPHER_gettable_params(const EVP_CIPHER *cipher);
  330. \& const OSSL_PARAM *EVP_CIPHER_settable_ctx_params(const EVP_CIPHER *cipher);
  331. \& const OSSL_PARAM *EVP_CIPHER_gettable_ctx_params(const EVP_CIPHER *cipher);
  332. \& const OSSL_PARAM *EVP_CIPHER_CTX_settable_params(EVP_CIPHER_CTX *ctx);
  333. \& const OSSL_PARAM *EVP_CIPHER_CTX_gettable_params(EVP_CIPHER_CTX *ctx);
  334. \& int EVP_CIPHER_CTX_get_block_size(const EVP_CIPHER_CTX *ctx);
  335. \& int EVP_CIPHER_CTX_get_key_length(const EVP_CIPHER_CTX *ctx);
  336. \& int EVP_CIPHER_CTX_get_iv_length(const EVP_CIPHER_CTX *ctx);
  337. \& int EVP_CIPHER_CTX_get_tag_length(const EVP_CIPHER_CTX *ctx);
  338. \& void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
  339. \& void EVP_CIPHER_CTX_set_app_data(const EVP_CIPHER_CTX *ctx, void *data);
  340. \& int EVP_CIPHER_CTX_get_type(const EVP_CIPHER_CTX *ctx);
  341. \& int EVP_CIPHER_CTX_get_mode(const EVP_CIPHER_CTX *ctx);
  342. \& int EVP_CIPHER_CTX_get_num(const EVP_CIPHER_CTX *ctx);
  343. \& int EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);
  344. \& int EVP_CIPHER_CTX_is_encrypting(const EVP_CIPHER_CTX *ctx);
  345. \&
  346. \& int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
  347. \& int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
  348. \&
  349. \& void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
  350. \& void (*fn)(EVP_CIPHER *cipher, void *arg),
  351. \& void *arg);
  352. \&
  353. \& #define EVP_CIPHER_nid EVP_CIPHER_get_nid
  354. \& #define EVP_CIPHER_name EVP_CIPHER_get0_name
  355. \& #define EVP_CIPHER_block_size EVP_CIPHER_get_block_size
  356. \& #define EVP_CIPHER_key_length EVP_CIPHER_get_key_length
  357. \& #define EVP_CIPHER_iv_length EVP_CIPHER_get_iv_length
  358. \& #define EVP_CIPHER_flags EVP_CIPHER_get_flags
  359. \& #define EVP_CIPHER_mode EVP_CIPHER_get_mode
  360. \& #define EVP_CIPHER_type EVP_CIPHER_get_type
  361. \& #define EVP_CIPHER_CTX_encrypting EVP_CIPHER_CTX_is_encrypting
  362. \& #define EVP_CIPHER_CTX_nid EVP_CIPHER_CTX_get_nid
  363. \& #define EVP_CIPHER_CTX_block_size EVP_CIPHER_CTX_get_block_size
  364. \& #define EVP_CIPHER_CTX_key_length EVP_CIPHER_CTX_get_key_length
  365. \& #define EVP_CIPHER_CTX_iv_length EVP_CIPHER_CTX_get_iv_length
  366. \& #define EVP_CIPHER_CTX_tag_length EVP_CIPHER_CTX_get_tag_length
  367. \& #define EVP_CIPHER_CTX_num EVP_CIPHER_CTX_get_num
  368. \& #define EVP_CIPHER_CTX_type EVP_CIPHER_CTX_get_type
  369. \& #define EVP_CIPHER_CTX_mode EVP_CIPHER_CTX_get_mode
  370. .Ve
  371. .PP
  372. The following function has been deprecated since OpenSSL 3.0, and can be
  373. hidden entirely by defining \fB\s-1OPENSSL_API_COMPAT\s0\fR with a suitable version value,
  374. see \fBopenssl_user_macros\fR\|(7):
  375. .PP
  376. .Vb 1
  377. \& const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
  378. .Ve
  379. .PP
  380. The following function has been deprecated since OpenSSL 1.1.0, and can be
  381. hidden entirely by defining \fB\s-1OPENSSL_API_COMPAT\s0\fR with a suitable version value,
  382. see \fBopenssl_user_macros\fR\|(7):
  383. .PP
  384. .Vb 1
  385. \& int EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
  386. .Ve
  387. .SH "DESCRIPTION"
  388. .IX Header "DESCRIPTION"
  389. The \s-1EVP\s0 cipher routines are a high-level interface to certain
  390. symmetric ciphers.
  391. .PP
  392. The \fB\s-1EVP_CIPHER\s0\fR type is a structure for cipher method implementation.
  393. .IP "\fBEVP_CIPHER_fetch()\fR" 4
  394. .IX Item "EVP_CIPHER_fetch()"
  395. Fetches the cipher implementation for the given \fIalgorithm\fR from any provider
  396. offering it, within the criteria given by the \fIproperties\fR.
  397. See \*(L"\s-1ALGORITHM FETCHING\*(R"\s0 in \fBcrypto\fR\|(7) for further information.
  398. .Sp
  399. The returned value must eventually be freed with \fBEVP_CIPHER_free()\fR.
  400. .Sp
  401. Fetched \fB\s-1EVP_CIPHER\s0\fR structures are reference counted.
  402. .IP "\fBEVP_CIPHER_up_ref()\fR" 4
  403. .IX Item "EVP_CIPHER_up_ref()"
  404. Increments the reference count for an \fB\s-1EVP_CIPHER\s0\fR structure.
  405. .IP "\fBEVP_CIPHER_free()\fR" 4
  406. .IX Item "EVP_CIPHER_free()"
  407. Decrements the reference count for the fetched \fB\s-1EVP_CIPHER\s0\fR structure.
  408. If the reference count drops to 0 then the structure is freed.
  409. If the argument is \s-1NULL,\s0 nothing is done.
  410. .IP "\fBEVP_CIPHER_CTX_new()\fR" 4
  411. .IX Item "EVP_CIPHER_CTX_new()"
  412. Allocates and returns a cipher context.
  413. .IP "\fBEVP_CIPHER_CTX_free()\fR" 4
  414. .IX Item "EVP_CIPHER_CTX_free()"
  415. Clears all information from a cipher context and frees any allocated memory
  416. associated with it, including \fIctx\fR itself. This function should be called
  417. after all operations using a cipher are complete so sensitive information does
  418. not remain in memory. If the argument is \s-1NULL,\s0 nothing is done.
  419. .IP "\fBEVP_CIPHER_CTX_dup()\fR" 4
  420. .IX Item "EVP_CIPHER_CTX_dup()"
  421. Can be used to duplicate the cipher state from \fIin\fR. This is useful
  422. to avoid multiple \fBEVP_CIPHER_fetch()\fR calls or if large amounts of data are to be
  423. fed which only differ in the last few bytes.
  424. .IP "\fBEVP_CIPHER_CTX_copy()\fR" 4
  425. .IX Item "EVP_CIPHER_CTX_copy()"
  426. Can be used to copy the cipher state from \fIin\fR to \fIout\fR.
  427. .IP "\fBEVP_CIPHER_CTX_ctrl()\fR" 4
  428. .IX Item "EVP_CIPHER_CTX_ctrl()"
  429. \&\fIThis is a legacy method.\fR \fBEVP_CIPHER_CTX_set_params()\fR and
  430. \&\fBEVP_CIPHER_CTX_get_params()\fR is the mechanism that should be used to set and get
  431. parameters that are used by providers.
  432. .Sp
  433. Performs cipher-specific control actions on context \fIctx\fR. The control command
  434. is indicated in \fIcmd\fR and any additional arguments in \fIp1\fR and \fIp2\fR.
  435. \&\fBEVP_CIPHER_CTX_ctrl()\fR must be called after \fBEVP_CipherInit_ex2()\fR. Other restrictions
  436. may apply depending on the control type and cipher implementation.
  437. .Sp
  438. If this function happens to be used with a fetched \fB\s-1EVP_CIPHER\s0\fR, it will
  439. translate the controls that are known to OpenSSL into \s-1\fBOSSL_PARAM\s0\fR\|(3)
  440. parameters with keys defined by OpenSSL and call \fBEVP_CIPHER_CTX_get_params()\fR or
  441. \&\fBEVP_CIPHER_CTX_set_params()\fR as is appropriate for each control command.
  442. .Sp
  443. See \*(L"\s-1CONTROLS\*(R"\s0 below for more information, including what translations are
  444. being done.
  445. .IP "\fBEVP_CIPHER_get_params()\fR" 4
  446. .IX Item "EVP_CIPHER_get_params()"
  447. Retrieves the requested list of algorithm \fIparams\fR from a \s-1CIPHER\s0 \fIcipher\fR.
  448. See \*(L"\s-1PARAMETERS\*(R"\s0 below for more information.
  449. .IP "\fBEVP_CIPHER_CTX_get_params()\fR" 4
  450. .IX Item "EVP_CIPHER_CTX_get_params()"
  451. Retrieves the requested list of \fIparams\fR from \s-1CIPHER\s0 context \fIctx\fR.
  452. See \*(L"\s-1PARAMETERS\*(R"\s0 below for more information.
  453. .IP "\fBEVP_CIPHER_CTX_set_params()\fR" 4
  454. .IX Item "EVP_CIPHER_CTX_set_params()"
  455. Sets the list of \fIparams\fR into a \s-1CIPHER\s0 context \fIctx\fR.
  456. See \*(L"\s-1PARAMETERS\*(R"\s0 below for more information.
  457. .IP "\fBEVP_CIPHER_gettable_params()\fR" 4
  458. .IX Item "EVP_CIPHER_gettable_params()"
  459. Get a constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array that describes the retrievable parameters
  460. that can be used with \fBEVP_CIPHER_get_params()\fR.
  461. .IP "\fBEVP_CIPHER_gettable_ctx_params()\fR and \fBEVP_CIPHER_CTX_gettable_params()\fR" 4
  462. .IX Item "EVP_CIPHER_gettable_ctx_params() and EVP_CIPHER_CTX_gettable_params()"
  463. Get a constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array that describes the retrievable parameters
  464. that can be used with \fBEVP_CIPHER_CTX_get_params()\fR.
  465. \&\fBEVP_CIPHER_gettable_ctx_params()\fR returns the parameters that can be retrieved
  466. from the algorithm, whereas \fBEVP_CIPHER_CTX_gettable_params()\fR returns the
  467. parameters that can be retrieved in the context's current state.
  468. .IP "\fBEVP_CIPHER_settable_ctx_params()\fR and \fBEVP_CIPHER_CTX_settable_params()\fR" 4
  469. .IX Item "EVP_CIPHER_settable_ctx_params() and EVP_CIPHER_CTX_settable_params()"
  470. Get a constant \s-1\fBOSSL_PARAM\s0\fR\|(3) array that describes the settable parameters
  471. that can be used with \fBEVP_CIPHER_CTX_set_params()\fR.
  472. \&\fBEVP_CIPHER_settable_ctx_params()\fR returns the parameters that can be set from the
  473. algorithm, whereas \fBEVP_CIPHER_CTX_settable_params()\fR returns the parameters that
  474. can be set in the context's current state.
  475. .IP "\fBEVP_EncryptInit_ex2()\fR" 4
  476. .IX Item "EVP_EncryptInit_ex2()"
  477. Sets up cipher context \fIctx\fR for encryption with cipher \fItype\fR. \fItype\fR is
  478. typically supplied by calling \fBEVP_CIPHER_fetch()\fR. \fItype\fR may also be set
  479. using legacy functions such as \fBEVP_aes_256_cbc()\fR, but this is not recommended
  480. for new applications. \fIkey\fR is the symmetric key to use and \fIiv\fR is the \s-1IV\s0 to
  481. use (if necessary), the actual number of bytes used for the key and \s-1IV\s0 depends
  482. on the cipher. The parameters \fIparams\fR will be set on the context after
  483. initialisation. It is possible to set all parameters to \s-1NULL\s0 except \fItype\fR in
  484. an initial call and supply the remaining parameters in subsequent calls, all of
  485. which have \fItype\fR set to \s-1NULL.\s0 This is done when the default cipher parameters
  486. are not appropriate.
  487. For \fB\s-1EVP_CIPH_GCM_MODE\s0\fR the \s-1IV\s0 will be generated internally if it is not
  488. specified.
  489. .IP "\fBEVP_EncryptInit_ex()\fR" 4
  490. .IX Item "EVP_EncryptInit_ex()"
  491. This legacy function is similar to \fBEVP_EncryptInit_ex2()\fR when \fIimpl\fR is \s-1NULL.\s0
  492. The implementation of the \fItype\fR from the \fIimpl\fR engine will be used if it
  493. exists.
  494. .IP "\fBEVP_EncryptUpdate()\fR" 4
  495. .IX Item "EVP_EncryptUpdate()"
  496. Encrypts \fIinl\fR bytes from the buffer \fIin\fR and writes the encrypted version to
  497. \&\fIout\fR. The pointers \fIout\fR and \fIin\fR may point to the same location, in which
  498. case the encryption will be done in-place. However, in-place encryption is
  499. guaranteed to work only if the encryption context (\fIctx\fR) has processed data in
  500. multiples of the block size. If the context contains an incomplete data block
  501. from previous operations, in-place encryption will fail.
  502. .Sp
  503. If \fIout\fR and \fIin\fR point to different locations, the two buffers must be
  504. disjoint, otherwise the operation might fail or the outcome might be undefined.
  505. .Sp
  506. This function can be called multiple times to encrypt successive blocks
  507. of data. The amount of data written depends on the block alignment of the
  508. encrypted data.
  509. For most ciphers and modes, the amount of data written can be anything
  510. from zero bytes to (inl + cipher_block_size \- 1) bytes.
  511. For wrap cipher modes, the amount of data written can be anything
  512. from zero bytes to (inl + cipher_block_size) bytes.
  513. For stream ciphers, the amount of data written can be anything from zero
  514. bytes to inl bytes.
  515. Thus, the buffer pointed to by \fIout\fR must contain sufficient room for the
  516. operation being performed.
  517. The actual number of bytes written is placed in \fIoutl\fR.
  518. .Sp
  519. If padding is enabled (the default) then \fBEVP_EncryptFinal_ex()\fR encrypts
  520. the \*(L"final\*(R" data, that is any data that remains in a partial block.
  521. It uses standard block padding (aka \s-1PKCS\s0 padding) as described in
  522. the \s-1NOTES\s0 section, below. The encrypted
  523. final data is written to \fIout\fR which should have sufficient space for
  524. one cipher block. The number of bytes written is placed in \fIoutl\fR. After
  525. this function is called the encryption operation is finished and no further
  526. calls to \fBEVP_EncryptUpdate()\fR should be made.
  527. .Sp
  528. If padding is disabled then \fBEVP_EncryptFinal_ex()\fR will not encrypt any more
  529. data and it will return an error if any data remains in a partial block:
  530. that is if the total data length is not a multiple of the block size.
  531. .IP "\fBEVP_DecryptInit_ex2()\fR, \fBEVP_DecryptInit_ex()\fR, \fBEVP_DecryptUpdate()\fR and \fBEVP_DecryptFinal_ex()\fR" 4
  532. .IX Item "EVP_DecryptInit_ex2(), EVP_DecryptInit_ex(), EVP_DecryptUpdate() and EVP_DecryptFinal_ex()"
  533. These functions are the corresponding decryption operations.
  534. \&\fBEVP_DecryptFinal()\fR will return an error code if padding is enabled and the
  535. final block is not correctly formatted. The parameters and restrictions are
  536. identical to the encryption operations except that if padding is enabled the
  537. decrypted data buffer \fIout\fR passed to \fBEVP_DecryptUpdate()\fR should have
  538. sufficient room for (\fIinl\fR + cipher_block_size) bytes unless the cipher block
  539. size is 1 in which case \fIinl\fR bytes is sufficient.
  540. .IP "\fBEVP_CipherInit_ex2()\fR, \fBEVP_CipherInit_ex()\fR, \fBEVP_CipherUpdate()\fR and \fBEVP_CipherFinal_ex()\fR" 4
  541. .IX Item "EVP_CipherInit_ex2(), EVP_CipherInit_ex(), EVP_CipherUpdate() and EVP_CipherFinal_ex()"
  542. These functions can be used for decryption or encryption. The operation
  543. performed depends on the value of the \fIenc\fR parameter. It should be set to 1
  544. for encryption, 0 for decryption and \-1 to leave the value unchanged
  545. (the actual value of 'enc' being supplied in a previous call).
  546. .IP "\fBEVP_CIPHER_CTX_reset()\fR" 4
  547. .IX Item "EVP_CIPHER_CTX_reset()"
  548. Clears all information from a cipher context and free up any allocated memory
  549. associated with it, except the \fIctx\fR itself. This function should be called
  550. anytime \fIctx\fR is reused by another
  551. \&\fBEVP_CipherInit()\fR / \fBEVP_CipherUpdate()\fR / \fBEVP_CipherFinal()\fR series of calls.
  552. .IP "\fBEVP_EncryptInit()\fR, \fBEVP_DecryptInit()\fR and \fBEVP_CipherInit()\fR" 4
  553. .IX Item "EVP_EncryptInit(), EVP_DecryptInit() and EVP_CipherInit()"
  554. Behave in a similar way to \fBEVP_EncryptInit_ex()\fR, \fBEVP_DecryptInit_ex()\fR and
  555. \&\fBEVP_CipherInit_ex()\fR except if the \fItype\fR is not a fetched cipher they use the
  556. default implementation of the \fItype\fR.
  557. .IP "\fBEVP_EncryptFinal()\fR, \fBEVP_DecryptFinal()\fR and \fBEVP_CipherFinal()\fR" 4
  558. .IX Item "EVP_EncryptFinal(), EVP_DecryptFinal() and EVP_CipherFinal()"
  559. Identical to \fBEVP_EncryptFinal_ex()\fR, \fBEVP_DecryptFinal_ex()\fR and
  560. \&\fBEVP_CipherFinal_ex()\fR. In previous releases they also cleaned up
  561. the \fIctx\fR, but this is no longer done and \fBEVP_CIPHER_CTX_cleanup()\fR
  562. must be called to free any context resources.
  563. .IP "\fBEVP_Cipher()\fR" 4
  564. .IX Item "EVP_Cipher()"
  565. Encrypts or decrypts a maximum \fIinl\fR amount of bytes from \fIin\fR and leaves the
  566. result in \fIout\fR.
  567. .Sp
  568. For legacy ciphers \- If the cipher doesn't have the flag
  569. \&\fB\s-1EVP_CIPH_FLAG_CUSTOM_CIPHER\s0\fR set, then \fIinl\fR must be a multiple of
  570. \&\fBEVP_CIPHER_get_block_size()\fR. If it isn't, the result is undefined. If the cipher
  571. has that flag set, then \fIinl\fR can be any size.
  572. .Sp
  573. Due to the constraints of the \s-1API\s0 contract of this function it shouldn't be used
  574. in applications, please consider using \fBEVP_CipherUpdate()\fR and
  575. \&\fBEVP_CipherFinal_ex()\fR instead.
  576. .IP "\fBEVP_get_cipherbyname()\fR, \fBEVP_get_cipherbynid()\fR and \fBEVP_get_cipherbyobj()\fR" 4
  577. .IX Item "EVP_get_cipherbyname(), EVP_get_cipherbynid() and EVP_get_cipherbyobj()"
  578. Returns an \fB\s-1EVP_CIPHER\s0\fR structure when passed a cipher name, a cipher \fB\s-1NID\s0\fR or
  579. an \fB\s-1ASN1_OBJECT\s0\fR structure respectively.
  580. .Sp
  581. \&\fBEVP_get_cipherbyname()\fR will return \s-1NULL\s0 for algorithms such as \*(L"\s-1AES\-128\-SIV\*(R",
  582. \&\*(L"AES\-128\-CBC\-CTS\*(R"\s0 and \*(L"\s-1CAMELLIA\-128\-CBC\-CTS\*(R"\s0 which were previously only
  583. accessible via low level interfaces.
  584. .Sp
  585. The \fBEVP_get_cipherbyname()\fR function is present for backwards compatibility with
  586. OpenSSL prior to version 3 and is different to the \fBEVP_CIPHER_fetch()\fR function
  587. since it does not attempt to \*(L"fetch\*(R" an implementation of the cipher.
  588. Additionally, it only knows about ciphers that are built-in to OpenSSL and have
  589. an associated \s-1NID.\s0 Similarly \fBEVP_get_cipherbynid()\fR and \fBEVP_get_cipherbyobj()\fR
  590. also return objects without an associated implementation.
  591. .Sp
  592. When the cipher objects returned by these functions are used (such as in a call
  593. to \fBEVP_EncryptInit_ex()\fR) an implementation of the cipher will be implicitly
  594. fetched from the loaded providers. This fetch could fail if no suitable
  595. implementation is available. Use \fBEVP_CIPHER_fetch()\fR instead to explicitly fetch
  596. the algorithm and an associated implementation from a provider.
  597. .Sp
  598. See \*(L"\s-1ALGORITHM FETCHING\*(R"\s0 in \fBcrypto\fR\|(7) for more information about fetching.
  599. .Sp
  600. The cipher objects returned from these functions do not need to be freed with
  601. \&\fBEVP_CIPHER_free()\fR.
  602. .IP "\fBEVP_CIPHER_get_nid()\fR and \fBEVP_CIPHER_CTX_get_nid()\fR" 4
  603. .IX Item "EVP_CIPHER_get_nid() and EVP_CIPHER_CTX_get_nid()"
  604. Return the \s-1NID\s0 of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or \fB\s-1EVP_CIPHER_CTX\s0\fR
  605. structure. The actual \s-1NID\s0 value is an internal value which may not have a
  606. corresponding \s-1OBJECT IDENTIFIER.\s0 NID_undef is returned in the event that the
  607. nid is unknown or if the cipher has not been properly initialized via a call to
  608. \&\fBEVP_CipherInit\fR.
  609. .IP "\fBEVP_CIPHER_CTX_set_flags()\fR, \fBEVP_CIPHER_CTX_clear_flags()\fR and \fBEVP_CIPHER_CTX_test_flags()\fR" 4
  610. .IX Item "EVP_CIPHER_CTX_set_flags(), EVP_CIPHER_CTX_clear_flags() and EVP_CIPHER_CTX_test_flags()"
  611. Sets, clears and tests \fIctx\fR flags. See \*(L"\s-1FLAGS\*(R"\s0 below for more information.
  612. .Sp
  613. For provided ciphers \fBEVP_CIPHER_CTX_set_flags()\fR should be called only after the
  614. fetched cipher has been assigned to the \fIctx\fR. It is recommended to use
  615. \&\*(L"\s-1PARAMETERS\*(R"\s0 instead.
  616. .IP "\fBEVP_CIPHER_CTX_set_padding()\fR" 4
  617. .IX Item "EVP_CIPHER_CTX_set_padding()"
  618. Enables or disables padding. This function should be called after the context
  619. is set up for encryption or decryption with \fBEVP_EncryptInit_ex2()\fR,
  620. \&\fBEVP_DecryptInit_ex2()\fR or \fBEVP_CipherInit_ex2()\fR. By default encryption operations
  621. are padded using standard block padding and the padding is checked and removed
  622. when decrypting. If the \fIpad\fR parameter is zero then no padding is
  623. performed, the total amount of data encrypted or decrypted must then
  624. be a multiple of the block size or an error will occur.
  625. .IP "\fBEVP_CIPHER_get_key_length()\fR and \fBEVP_CIPHER_CTX_get_key_length()\fR" 4
  626. .IX Item "EVP_CIPHER_get_key_length() and EVP_CIPHER_CTX_get_key_length()"
  627. Return the key length of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or
  628. \&\fB\s-1EVP_CIPHER_CTX\s0\fR structure. The constant \fB\s-1EVP_MAX_KEY_LENGTH\s0\fR is the maximum
  629. key length for all ciphers. Note: although \fBEVP_CIPHER_get_key_length()\fR is fixed for
  630. a given cipher, the value of \fBEVP_CIPHER_CTX_get_key_length()\fR may be different for
  631. variable key length ciphers.
  632. .IP "\fBEVP_CIPHER_CTX_set_key_length()\fR" 4
  633. .IX Item "EVP_CIPHER_CTX_set_key_length()"
  634. Sets the key length of the cipher context.
  635. If the cipher is a fixed length cipher then attempting to set the key
  636. length to any value other than the fixed value is an error.
  637. .IP "\fBEVP_CIPHER_get_iv_length()\fR and \fBEVP_CIPHER_CTX_get_iv_length()\fR" 4
  638. .IX Item "EVP_CIPHER_get_iv_length() and EVP_CIPHER_CTX_get_iv_length()"
  639. Return the \s-1IV\s0 length of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or
  640. \&\fB\s-1EVP_CIPHER_CTX\s0\fR. It will return zero if the cipher does not use an \s-1IV,\s0 if
  641. the cipher has not yet been initialized within the \fB\s-1EVP_CIPHER_CTX\s0\fR, or if the
  642. passed cipher is \s-1NULL.\s0 The constant \fB\s-1EVP_MAX_IV_LENGTH\s0\fR is the maximum \s-1IV\s0
  643. length for all ciphers.
  644. .IP "\fBEVP_CIPHER_CTX_get_tag_length()\fR" 4
  645. .IX Item "EVP_CIPHER_CTX_get_tag_length()"
  646. Returns the tag length of an \s-1AEAD\s0 cipher when passed a \fB\s-1EVP_CIPHER_CTX\s0\fR. It will
  647. return zero if the cipher does not support a tag. It returns a default value if
  648. the tag length has not been set.
  649. .IP "\fBEVP_CIPHER_get_block_size()\fR and \fBEVP_CIPHER_CTX_get_block_size()\fR" 4
  650. .IX Item "EVP_CIPHER_get_block_size() and EVP_CIPHER_CTX_get_block_size()"
  651. Return the block size of a cipher when passed an \fB\s-1EVP_CIPHER\s0\fR or
  652. \&\fB\s-1EVP_CIPHER_CTX\s0\fR structure. The constant \fB\s-1EVP_MAX_BLOCK_LENGTH\s0\fR is also the
  653. maximum block length for all ciphers. A value of 0 is returned if the cipher
  654. has not been properly initialized with a call to \fBEVP_CipherInit\fR.
  655. .IP "\fBEVP_CIPHER_get_type()\fR and \fBEVP_CIPHER_CTX_get_type()\fR" 4
  656. .IX Item "EVP_CIPHER_get_type() and EVP_CIPHER_CTX_get_type()"
  657. Return the type of the passed cipher or context. This \*(L"type\*(R" is the actual \s-1NID\s0
  658. of the cipher \s-1OBJECT IDENTIFIER\s0 and as such it ignores the cipher parameters
  659. (40 bit \s-1RC2\s0 and 128 bit \s-1RC2\s0 have the same \s-1NID\s0). If the cipher does not have an
  660. object identifier or does not have \s-1ASN1\s0 support this function will return
  661. \&\fBNID_undef\fR.
  662. .IP "\fBEVP_CIPHER_is_a()\fR" 4
  663. .IX Item "EVP_CIPHER_is_a()"
  664. Returns 1 if \fIcipher\fR is an implementation of an algorithm that's identifiable
  665. with \fIname\fR, otherwise 0. If \fIcipher\fR is a legacy cipher (it's the return
  666. value from the likes of \fBEVP_aes128()\fR rather than the result of an
  667. \&\fBEVP_CIPHER_fetch()\fR), only cipher names registered with the default library
  668. context (see \s-1\fBOSSL_LIB_CTX\s0\fR\|(3)) will be considered.
  669. .IP "\fBEVP_CIPHER_get0_name()\fR and \fBEVP_CIPHER_CTX_get0_name()\fR" 4
  670. .IX Item "EVP_CIPHER_get0_name() and EVP_CIPHER_CTX_get0_name()"
  671. Return the name of the passed cipher or context. For fetched ciphers with
  672. multiple names, only one of them is returned. See also \fBEVP_CIPHER_names_do_all()\fR.
  673. .IP "\fBEVP_CIPHER_names_do_all()\fR" 4
  674. .IX Item "EVP_CIPHER_names_do_all()"
  675. Traverses all names for the \fIcipher\fR, and calls \fIfn\fR with each name and
  676. \&\fIdata\fR. This is only useful with fetched \fB\s-1EVP_CIPHER\s0\fRs.
  677. .IP "\fBEVP_CIPHER_get0_description()\fR" 4
  678. .IX Item "EVP_CIPHER_get0_description()"
  679. Returns a description of the cipher, meant for display and human consumption.
  680. The description is at the discretion of the cipher implementation.
  681. .IP "\fBEVP_CIPHER_get0_provider()\fR" 4
  682. .IX Item "EVP_CIPHER_get0_provider()"
  683. Returns an \fB\s-1OSSL_PROVIDER\s0\fR pointer to the provider that implements the given
  684. \&\fB\s-1EVP_CIPHER\s0\fR.
  685. .IP "\fBEVP_CIPHER_CTX_get0_cipher()\fR" 4
  686. .IX Item "EVP_CIPHER_CTX_get0_cipher()"
  687. Returns the \fB\s-1EVP_CIPHER\s0\fR structure when passed an \fB\s-1EVP_CIPHER_CTX\s0\fR structure.
  688. \&\fBEVP_CIPHER_CTX_get1_cipher()\fR is the same except the ownership is passed to
  689. the caller. Both functions return \s-1NULL\s0 on error.
  690. .IP "\fBEVP_CIPHER_get_mode()\fR and \fBEVP_CIPHER_CTX_get_mode()\fR" 4
  691. .IX Item "EVP_CIPHER_get_mode() and EVP_CIPHER_CTX_get_mode()"
  692. Return the block cipher mode:
  693. \&\s-1EVP_CIPH_ECB_MODE, EVP_CIPH_CBC_MODE, EVP_CIPH_CFB_MODE, EVP_CIPH_OFB_MODE,
  694. EVP_CIPH_CTR_MODE, EVP_CIPH_GCM_MODE, EVP_CIPH_CCM_MODE, EVP_CIPH_XTS_MODE,
  695. EVP_CIPH_WRAP_MODE, EVP_CIPH_OCB_MODE\s0 or \s-1EVP_CIPH_SIV_MODE.\s0
  696. If the cipher is a stream cipher then \s-1EVP_CIPH_STREAM_CIPHER\s0 is returned.
  697. .IP "\fBEVP_CIPHER_get_flags()\fR" 4
  698. .IX Item "EVP_CIPHER_get_flags()"
  699. Returns any flags associated with the cipher. See \*(L"\s-1FLAGS\*(R"\s0
  700. for a list of currently defined flags.
  701. .IP "\fBEVP_CIPHER_CTX_get_num()\fR and \fBEVP_CIPHER_CTX_set_num()\fR" 4
  702. .IX Item "EVP_CIPHER_CTX_get_num() and EVP_CIPHER_CTX_set_num()"
  703. Gets or sets the cipher specific \*(L"num\*(R" parameter for the associated \fIctx\fR.
  704. Built-in ciphers typically use this to track how much of the current underlying block
  705. has been \*(L"used\*(R" already.
  706. .IP "\fBEVP_CIPHER_CTX_is_encrypting()\fR" 4
  707. .IX Item "EVP_CIPHER_CTX_is_encrypting()"
  708. Reports whether the \fIctx\fR is being used for encryption or decryption.
  709. .IP "\fBEVP_CIPHER_CTX_flags()\fR" 4
  710. .IX Item "EVP_CIPHER_CTX_flags()"
  711. A deprecated macro calling \f(CW\*(C`EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(ctx))\*(C'\fR.
  712. Do not use.
  713. .IP "\fBEVP_CIPHER_param_to_asn1()\fR" 4
  714. .IX Item "EVP_CIPHER_param_to_asn1()"
  715. Sets the AlgorithmIdentifier \*(L"parameter\*(R" based on the passed cipher. This will
  716. typically include any parameters and an \s-1IV.\s0 The cipher \s-1IV\s0 (if any) must be set
  717. when this call is made. This call should be made before the cipher is actually
  718. \&\*(L"used\*(R" (before any \fBEVP_EncryptUpdate()\fR, \fBEVP_DecryptUpdate()\fR calls for example).
  719. This function may fail if the cipher does not have any \s-1ASN1\s0 support, or if an
  720. uninitialized cipher is passed to it.
  721. .IP "\fBEVP_CIPHER_asn1_to_param()\fR" 4
  722. .IX Item "EVP_CIPHER_asn1_to_param()"
  723. Sets the cipher parameters based on an \s-1ASN1\s0 AlgorithmIdentifier \*(L"parameter\*(R".
  724. The precise effect depends on the cipher. In the case of \fB\s-1RC2\s0\fR, for example,
  725. it will set the \s-1IV\s0 and effective key length.
  726. This function should be called after the base cipher type is set but before
  727. the key is set. For example \fBEVP_CipherInit()\fR will be called with the \s-1IV\s0 and
  728. key set to \s-1NULL,\s0 \fBEVP_CIPHER_asn1_to_param()\fR will be called and finally
  729. \&\fBEVP_CipherInit()\fR again with all parameters except the key set to \s-1NULL.\s0 It is
  730. possible for this function to fail if the cipher does not have any \s-1ASN1\s0 support
  731. or the parameters cannot be set (for example the \s-1RC2\s0 effective key length
  732. is not supported.
  733. .IP "\fBEVP_CIPHER_CTX_rand_key()\fR" 4
  734. .IX Item "EVP_CIPHER_CTX_rand_key()"
  735. Generates a random key of the appropriate length based on the cipher context.
  736. The \fB\s-1EVP_CIPHER\s0\fR can provide its own random key generation routine to support
  737. keys of a specific form. \fIkey\fR must point to a buffer at least as big as the
  738. value returned by \fBEVP_CIPHER_CTX_get_key_length()\fR.
  739. .IP "\fBEVP_CIPHER_do_all_provided()\fR" 4
  740. .IX Item "EVP_CIPHER_do_all_provided()"
  741. Traverses all ciphers implemented by all activated providers in the given
  742. library context \fIlibctx\fR, and for each of the implementations, calls the given
  743. function \fIfn\fR with the implementation method and the given \fIarg\fR as argument.
  744. .SH "PARAMETERS"
  745. .IX Header "PARAMETERS"
  746. See \s-1\fBOSSL_PARAM\s0\fR\|(3) for information about passing parameters.
  747. .SS "Gettable \s-1EVP_CIPHER\s0 parameters"
  748. .IX Subsection "Gettable EVP_CIPHER parameters"
  749. When \fBEVP_CIPHER_fetch()\fR is called it internally calls \fBEVP_CIPHER_get_params()\fR
  750. and caches the results.
  751. .PP
  752. \&\fBEVP_CIPHER_get_params()\fR can be used with the following \s-1\fBOSSL_PARAM\s0\fR\|(3) keys:
  753. .ie n .IP """mode"" (\fB\s-1OSSL_CIPHER_PARAM_MODE\s0\fR) <unsigned integer>" 4
  754. .el .IP "``mode'' (\fB\s-1OSSL_CIPHER_PARAM_MODE\s0\fR) <unsigned integer>" 4
  755. .IX Item "mode (OSSL_CIPHER_PARAM_MODE) <unsigned integer>"
  756. Gets the mode for the associated cipher algorithm \fIcipher\fR.
  757. See \*(L"\fBEVP_CIPHER_get_mode()\fR and \fBEVP_CIPHER_CTX_get_mode()\fR\*(R" for a list of valid modes.
  758. Use \fBEVP_CIPHER_get_mode()\fR to retrieve the cached value.
  759. .ie n .IP """keylen"" (\fB\s-1OSSL_CIPHER_PARAM_KEYLEN\s0\fR) <unsigned integer>" 4
  760. .el .IP "``keylen'' (\fB\s-1OSSL_CIPHER_PARAM_KEYLEN\s0\fR) <unsigned integer>" 4
  761. .IX Item "keylen (OSSL_CIPHER_PARAM_KEYLEN) <unsigned integer>"
  762. Gets the key length for the associated cipher algorithm \fIcipher\fR.
  763. Use \fBEVP_CIPHER_get_key_length()\fR to retrieve the cached value.
  764. .ie n .IP """ivlen"" (\fB\s-1OSSL_CIPHER_PARAM_IVLEN\s0\fR) <unsigned integer>" 4
  765. .el .IP "``ivlen'' (\fB\s-1OSSL_CIPHER_PARAM_IVLEN\s0\fR) <unsigned integer>" 4
  766. .IX Item "ivlen (OSSL_CIPHER_PARAM_IVLEN) <unsigned integer>"
  767. Gets the \s-1IV\s0 length for the associated cipher algorithm \fIcipher\fR.
  768. Use \fBEVP_CIPHER_get_iv_length()\fR to retrieve the cached value.
  769. .ie n .IP """blocksize"" (\fB\s-1OSSL_CIPHER_PARAM_BLOCK_SIZE\s0\fR) <unsigned integer>" 4
  770. .el .IP "``blocksize'' (\fB\s-1OSSL_CIPHER_PARAM_BLOCK_SIZE\s0\fR) <unsigned integer>" 4
  771. .IX Item "blocksize (OSSL_CIPHER_PARAM_BLOCK_SIZE) <unsigned integer>"
  772. Gets the block size for the associated cipher algorithm \fIcipher\fR.
  773. The block size should be 1 for stream ciphers.
  774. Note that the block size for a cipher may be different to the block size for
  775. the underlying encryption/decryption primitive.
  776. For example \s-1AES\s0 in \s-1CTR\s0 mode has a block size of 1 (because it operates like a
  777. stream cipher), even though \s-1AES\s0 has a block size of 16.
  778. Use \fBEVP_CIPHER_get_block_size()\fR to retrieve the cached value.
  779. .ie n .IP """aead"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD\s0\fR) <integer>" 4
  780. .el .IP "``aead'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD\s0\fR) <integer>" 4
  781. .IX Item "aead (OSSL_CIPHER_PARAM_AEAD) <integer>"
  782. Gets 1 if this is an \s-1AEAD\s0 cipher algorithm, otherwise it gets 0.
  783. Use (EVP_CIPHER_get_flags(cipher) & \s-1EVP_CIPH_FLAG_AEAD_CIPHER\s0) to retrieve the
  784. cached value.
  785. .ie n .IP """custom-iv"" (\fB\s-1OSSL_CIPHER_PARAM_CUSTOM_IV\s0\fR) <integer>" 4
  786. .el .IP "``custom-iv'' (\fB\s-1OSSL_CIPHER_PARAM_CUSTOM_IV\s0\fR) <integer>" 4
  787. .IX Item "custom-iv (OSSL_CIPHER_PARAM_CUSTOM_IV) <integer>"
  788. Gets 1 if the cipher algorithm \fIcipher\fR has a custom \s-1IV,\s0 otherwise it gets 0.
  789. Storing and initializing the \s-1IV\s0 is left entirely to the implementation, if a
  790. custom \s-1IV\s0 is used.
  791. Use (EVP_CIPHER_get_flags(cipher) & \s-1EVP_CIPH_CUSTOM_IV\s0) to retrieve the
  792. cached value.
  793. .ie n .IP """cts"" (\fB\s-1OSSL_CIPHER_PARAM_CTS\s0\fR) <integer>" 4
  794. .el .IP "``cts'' (\fB\s-1OSSL_CIPHER_PARAM_CTS\s0\fR) <integer>" 4
  795. .IX Item "cts (OSSL_CIPHER_PARAM_CTS) <integer>"
  796. Gets 1 if the cipher algorithm \fIcipher\fR uses ciphertext stealing,
  797. otherwise it gets 0.
  798. This is currently used to indicate that the cipher is a one shot that only
  799. allows a single call to \fBEVP_CipherUpdate()\fR.
  800. Use (EVP_CIPHER_get_flags(cipher) & \s-1EVP_CIPH_FLAG_CTS\s0) to retrieve the
  801. cached value.
  802. .ie n .IP """tls-multi"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK\s0\fR) <integer>" 4
  803. .el .IP "``tls-multi'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK\s0\fR) <integer>" 4
  804. .IX Item "tls-multi (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK) <integer>"
  805. Gets 1 if the cipher algorithm \fIcipher\fR supports interleaving of crypto blocks,
  806. otherwise it gets 0. The interleaving is an optimization only applicable to certain
  807. \&\s-1TLS\s0 ciphers.
  808. Use (EVP_CIPHER_get_flags(cipher) & \s-1EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK\s0) to retrieve the
  809. cached value.
  810. .ie n .IP """has-randkey"" (\fB\s-1OSSL_CIPHER_PARAM_HAS_RANDKEY\s0\fR) <integer>" 4
  811. .el .IP "``has-randkey'' (\fB\s-1OSSL_CIPHER_PARAM_HAS_RANDKEY\s0\fR) <integer>" 4
  812. .IX Item "has-randkey (OSSL_CIPHER_PARAM_HAS_RANDKEY) <integer>"
  813. Gets 1 if the cipher algorithm \fIcipher\fR supports the gettable \s-1EVP_CIPHER_CTX\s0
  814. parameter \fB\s-1OSSL_CIPHER_PARAM_RANDOM_KEY\s0\fR. Only \s-1DES\s0 and 3DES set this to 1,
  815. all other OpenSSL ciphers return 0.
  816. .SS "Gettable and Settable \s-1EVP_CIPHER_CTX\s0 parameters"
  817. .IX Subsection "Gettable and Settable EVP_CIPHER_CTX parameters"
  818. The following \s-1\fBOSSL_PARAM\s0\fR\|(3) keys can be used with both \fBEVP_CIPHER_CTX_get_params()\fR
  819. and \fBEVP_CIPHER_CTX_set_params()\fR.
  820. .ie n .IP """padding"" (\fB\s-1OSSL_CIPHER_PARAM_PADDING\s0\fR) <unsigned integer>" 4
  821. .el .IP "``padding'' (\fB\s-1OSSL_CIPHER_PARAM_PADDING\s0\fR) <unsigned integer>" 4
  822. .IX Item "padding (OSSL_CIPHER_PARAM_PADDING) <unsigned integer>"
  823. Gets or sets the padding mode for the cipher context \fIctx\fR.
  824. Padding is enabled if the value is 1, and disabled if the value is 0.
  825. See also \fBEVP_CIPHER_CTX_set_padding()\fR.
  826. .ie n .IP """num"" (\fB\s-1OSSL_CIPHER_PARAM_NUM\s0\fR) <unsigned integer>" 4
  827. .el .IP "``num'' (\fB\s-1OSSL_CIPHER_PARAM_NUM\s0\fR) <unsigned integer>" 4
  828. .IX Item "num (OSSL_CIPHER_PARAM_NUM) <unsigned integer>"
  829. Gets or sets the cipher specific \*(L"num\*(R" parameter for the cipher context \fIctx\fR.
  830. Built-in ciphers typically use this to track how much of the current underlying
  831. block has been \*(L"used\*(R" already.
  832. See also \fBEVP_CIPHER_CTX_get_num()\fR and \fBEVP_CIPHER_CTX_set_num()\fR.
  833. .ie n .IP """keylen"" (\fB\s-1OSSL_CIPHER_PARAM_KEYLEN\s0\fR) <unsigned integer>" 4
  834. .el .IP "``keylen'' (\fB\s-1OSSL_CIPHER_PARAM_KEYLEN\s0\fR) <unsigned integer>" 4
  835. .IX Item "keylen (OSSL_CIPHER_PARAM_KEYLEN) <unsigned integer>"
  836. Gets or sets the key length for the cipher context \fIctx\fR.
  837. The length of the \*(L"keylen\*(R" parameter should not exceed that of a \fBsize_t\fR.
  838. See also \fBEVP_CIPHER_CTX_get_key_length()\fR and \fBEVP_CIPHER_CTX_set_key_length()\fR.
  839. .ie n .IP """tag"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TAG\s0\fR) <octet string>" 4
  840. .el .IP "``tag'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TAG\s0\fR) <octet string>" 4
  841. .IX Item "tag (OSSL_CIPHER_PARAM_AEAD_TAG) <octet string>"
  842. Gets or sets the \s-1AEAD\s0 tag for the associated cipher context \fIctx\fR.
  843. See \*(L"\s-1AEAD\s0 Interface\*(R" in \fBEVP_EncryptInit\fR\|(3).
  844. .ie n .IP """keybits"" (\fB\s-1OSSL_CIPHER_PARAM_RC2_KEYBITS\s0\fR) <unsigned integer>" 4
  845. .el .IP "``keybits'' (\fB\s-1OSSL_CIPHER_PARAM_RC2_KEYBITS\s0\fR) <unsigned integer>" 4
  846. .IX Item "keybits (OSSL_CIPHER_PARAM_RC2_KEYBITS) <unsigned integer>"
  847. Gets or sets the effective keybits used for a \s-1RC2\s0 cipher.
  848. The length of the \*(L"keybits\*(R" parameter should not exceed that of a \fBsize_t\fR.
  849. .ie n .IP """rounds"" (\fB\s-1OSSL_CIPHER_PARAM_ROUNDS\s0\fR) <unsigned integer>" 4
  850. .el .IP "``rounds'' (\fB\s-1OSSL_CIPHER_PARAM_ROUNDS\s0\fR) <unsigned integer>" 4
  851. .IX Item "rounds (OSSL_CIPHER_PARAM_ROUNDS) <unsigned integer>"
  852. Gets or sets the number of rounds to be used for a cipher.
  853. This is used by the \s-1RC5\s0 cipher.
  854. .ie n .IP """alg_id_param"" (\fB\s-1OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS\s0\fR) <octet string>" 4
  855. .el .IP "``alg_id_param'' (\fB\s-1OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS\s0\fR) <octet string>" 4
  856. .IX Item "alg_id_param (OSSL_CIPHER_PARAM_ALGORITHM_ID_PARAMS) <octet string>"
  857. Used to pass the \s-1DER\s0 encoded AlgorithmIdentifier parameter to or from
  858. the cipher implementation. Functions like \fBEVP_CIPHER_param_to_asn1\fR\|(3)
  859. and \fBEVP_CIPHER_asn1_to_param\fR\|(3) use this parameter for any implementation
  860. that has the flag \fB\s-1EVP_CIPH_FLAG_CUSTOM_ASN1\s0\fR set.
  861. .ie n .IP """cts_mode"" (\fB\s-1OSSL_CIPHER_PARAM_CTS_MODE\s0\fR) <\s-1UTF8\s0 string>" 4
  862. .el .IP "``cts_mode'' (\fB\s-1OSSL_CIPHER_PARAM_CTS_MODE\s0\fR) <\s-1UTF8\s0 string>" 4
  863. .IX Item "cts_mode (OSSL_CIPHER_PARAM_CTS_MODE) <UTF8 string>"
  864. Gets or sets the cipher text stealing mode. For all modes the output size is the
  865. same as the input size. The input length must be greater than or equal to the
  866. block size. (The block size for \s-1AES\s0 and \s-1CAMELLIA\s0 is 16 bytes).
  867. .Sp
  868. Valid values for the mode are:
  869. .RS 4
  870. .ie n .IP """\s-1CS1""\s0" 4
  871. .el .IP "``\s-1CS1''\s0" 4
  872. .IX Item "CS1"
  873. The \s-1NIST\s0 variant of cipher text stealing.
  874. For input lengths that are multiples of the block size it is equivalent to
  875. using a \*(L"AES-XXX-CBC\*(R" or \*(L"CAMELLIA-XXX-CBC\*(R" cipher otherwise the second last
  876. cipher text block is a partial block.
  877. .ie n .IP """\s-1CS2""\s0" 4
  878. .el .IP "``\s-1CS2''\s0" 4
  879. .IX Item "CS2"
  880. For input lengths that are multiples of the block size it is equivalent to
  881. using a \*(L"AES-XXX-CBC\*(R" or \*(L"CAMELLIA-XXX-CBC\*(R" cipher, otherwise it is the same as
  882. \&\*(L"\s-1CS3\*(R"\s0 mode.
  883. .ie n .IP """\s-1CS3""\s0" 4
  884. .el .IP "``\s-1CS3''\s0" 4
  885. .IX Item "CS3"
  886. The Kerberos5 variant of cipher text stealing which always swaps the last
  887. cipher text block with the previous block (which may be a partial or full block
  888. depending on the input length). If the input length is exactly one full block
  889. then this is equivalent to using a \*(L"AES-XXX-CBC\*(R" or \*(L"CAMELLIA-XXX-CBC\*(R" cipher.
  890. .RE
  891. .RS 4
  892. .Sp
  893. The default is \*(L"\s-1CS1\*(R".\s0
  894. This is only supported for \*(L"\s-1AES\-128\-CBC\-CTS\*(R", \*(L"AES\-192\-CBC\-CTS\*(R", \*(L"AES\-256\-CBC\-CTS\*(R",
  895. \&\*(L"CAMELLIA\-128\-CBC\-CTS\*(R", \*(L"CAMELLIA\-192\-CBC\-CTS\*(R"\s0 and \*(L"\s-1CAMELLIA\-256\-CBC\-CTS\*(R".\s0
  896. .RE
  897. .ie n .IP """tls1multi_interleave"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE\s0\fR) <unsigned integer>" 4
  898. .el .IP "``tls1multi_interleave'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE\s0\fR) <unsigned integer>" 4
  899. .IX Item "tls1multi_interleave (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE) <unsigned integer>"
  900. Sets or gets the number of records being sent in one go for a tls1 multiblock
  901. cipher operation (either 4 or 8 records).
  902. .SS "Gettable \s-1EVP_CIPHER_CTX\s0 parameters"
  903. .IX Subsection "Gettable EVP_CIPHER_CTX parameters"
  904. The following \s-1\fBOSSL_PARAM\s0\fR\|(3) keys can be used with \fBEVP_CIPHER_CTX_get_params()\fR:
  905. .ie n .IP """ivlen"" (\fB\s-1OSSL_CIPHER_PARAM_IVLEN\s0\fR and <\fB\s-1OSSL_CIPHER_PARAM_AEAD_IVLEN\s0\fR) <unsigned integer>" 4
  906. .el .IP "``ivlen'' (\fB\s-1OSSL_CIPHER_PARAM_IVLEN\s0\fR and <\fB\s-1OSSL_CIPHER_PARAM_AEAD_IVLEN\s0\fR) <unsigned integer>" 4
  907. .IX Item "ivlen (OSSL_CIPHER_PARAM_IVLEN and <OSSL_CIPHER_PARAM_AEAD_IVLEN) <unsigned integer>"
  908. Gets the \s-1IV\s0 length for the cipher context \fIctx\fR.
  909. The length of the \*(L"ivlen\*(R" parameter should not exceed that of a \fBsize_t\fR.
  910. See also \fBEVP_CIPHER_CTX_get_iv_length()\fR.
  911. .ie n .IP """iv"" (\fB\s-1OSSL_CIPHER_PARAM_IV\s0\fR) <octet string \s-1OR\s0 octet ptr>" 4
  912. .el .IP "``iv'' (\fB\s-1OSSL_CIPHER_PARAM_IV\s0\fR) <octet string \s-1OR\s0 octet ptr>" 4
  913. .IX Item "iv (OSSL_CIPHER_PARAM_IV) <octet string OR octet ptr>"
  914. Gets the \s-1IV\s0 used to initialize the associated cipher context \fIctx\fR.
  915. See also \fBEVP_CIPHER_CTX_get_original_iv()\fR.
  916. .ie n .IP """updated-iv"" (\fB\s-1OSSL_CIPHER_PARAM_UPDATED_IV\s0\fR) <octet string \s-1OR\s0 octet ptr>" 4
  917. .el .IP "``updated-iv'' (\fB\s-1OSSL_CIPHER_PARAM_UPDATED_IV\s0\fR) <octet string \s-1OR\s0 octet ptr>" 4
  918. .IX Item "updated-iv (OSSL_CIPHER_PARAM_UPDATED_IV) <octet string OR octet ptr>"
  919. Gets the updated pseudo-IV state for the associated cipher context, e.g.,
  920. the previous ciphertext block for \s-1CBC\s0 mode or the iteratively encrypted \s-1IV\s0
  921. value for \s-1OFB\s0 mode. Note that octet pointer access is deprecated and is
  922. provided only for backwards compatibility with historical libcrypto APIs.
  923. See also \fBEVP_CIPHER_CTX_get_updated_iv()\fR.
  924. .ie n .IP """randkey"" (\fB\s-1OSSL_CIPHER_PARAM_RANDOM_KEY\s0\fR) <octet string>" 4
  925. .el .IP "``randkey'' (\fB\s-1OSSL_CIPHER_PARAM_RANDOM_KEY\s0\fR) <octet string>" 4
  926. .IX Item "randkey (OSSL_CIPHER_PARAM_RANDOM_KEY) <octet string>"
  927. Gets an implementation specific randomly generated key for the associated
  928. cipher context \fIctx\fR. This is currently only supported by \s-1DES\s0 and 3DES (which set
  929. the key to odd parity).
  930. .ie n .IP """taglen"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TAGLEN\s0\fR) <unsigned integer>" 4
  931. .el .IP "``taglen'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TAGLEN\s0\fR) <unsigned integer>" 4
  932. .IX Item "taglen (OSSL_CIPHER_PARAM_AEAD_TAGLEN) <unsigned integer>"
  933. Gets the tag length to be used for an \s-1AEAD\s0 cipher for the associated cipher
  934. context \fIctx\fR. It gets a default value if it has not been set.
  935. The length of the \*(L"taglen\*(R" parameter should not exceed that of a \fBsize_t\fR.
  936. See also \fBEVP_CIPHER_CTX_get_tag_length()\fR.
  937. .ie n .IP """tlsaadpad"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD\s0\fR) <unsigned integer>" 4
  938. .el .IP "``tlsaadpad'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD\s0\fR) <unsigned integer>" 4
  939. .IX Item "tlsaadpad (OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD) <unsigned integer>"
  940. Gets the length of the tag that will be added to a \s-1TLS\s0 record for the \s-1AEAD\s0
  941. tag for the associated cipher context \fIctx\fR.
  942. The length of the \*(L"tlsaadpad\*(R" parameter should not exceed that of a \fBsize_t\fR.
  943. .ie n .IP """tlsivgen"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN\s0\fR) <octet string>" 4
  944. .el .IP "``tlsivgen'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN\s0\fR) <octet string>" 4
  945. .IX Item "tlsivgen (OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN) <octet string>"
  946. Gets the invocation field generated for encryption.
  947. Can only be called after \*(L"tlsivfixed\*(R" is set.
  948. This is only used for \s-1GCM\s0 mode.
  949. .ie n .IP """tls1multi_enclen"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN\s0\fR) <unsigned integer>" 4
  950. .el .IP "``tls1multi_enclen'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN\s0\fR) <unsigned integer>" 4
  951. .IX Item "tls1multi_enclen (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN) <unsigned integer>"
  952. Get the total length of the record returned from the \*(L"tls1multi_enc\*(R" operation.
  953. .ie n .IP """tls1multi_maxbufsz"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE\s0\fR) <unsigned integer>" 4
  954. .el .IP "``tls1multi_maxbufsz'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE\s0\fR) <unsigned integer>" 4
  955. .IX Item "tls1multi_maxbufsz (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE) <unsigned integer>"
  956. Gets the maximum record length for a \s-1TLS1\s0 multiblock cipher operation.
  957. The length of the \*(L"tls1multi_maxbufsz\*(R" parameter should not exceed that of a \fBsize_t\fR.
  958. .ie n .IP """tls1multi_aadpacklen"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN\s0\fR) <unsigned integer>" 4
  959. .el .IP "``tls1multi_aadpacklen'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN\s0\fR) <unsigned integer>" 4
  960. .IX Item "tls1multi_aadpacklen (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN) <unsigned integer>"
  961. Gets the result of running the \*(L"tls1multi_aad\*(R" operation.
  962. .ie n .IP """tls-mac"" (\fB\s-1OSSL_CIPHER_PARAM_TLS_MAC\s0\fR) <octet ptr>" 4
  963. .el .IP "``tls-mac'' (\fB\s-1OSSL_CIPHER_PARAM_TLS_MAC\s0\fR) <octet ptr>" 4
  964. .IX Item "tls-mac (OSSL_CIPHER_PARAM_TLS_MAC) <octet ptr>"
  965. Used to pass the \s-1TLS MAC\s0 data.
  966. .SS "Settable \s-1EVP_CIPHER_CTX\s0 parameters"
  967. .IX Subsection "Settable EVP_CIPHER_CTX parameters"
  968. The following \s-1\fBOSSL_PARAM\s0\fR\|(3) keys can be used with \fBEVP_CIPHER_CTX_set_params()\fR:
  969. .ie n .IP """mackey"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_MAC_KEY\s0\fR) <octet string>" 4
  970. .el .IP "``mackey'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_MAC_KEY\s0\fR) <octet string>" 4
  971. .IX Item "mackey (OSSL_CIPHER_PARAM_AEAD_MAC_KEY) <octet string>"
  972. Sets the \s-1MAC\s0 key used by composite \s-1AEAD\s0 ciphers such as \s-1AES\-CBC\-HMAC\-SHA256.\s0
  973. .ie n .IP """speed"" (\fB\s-1OSSL_CIPHER_PARAM_SPEED\s0\fR) <unsigned integer>" 4
  974. .el .IP "``speed'' (\fB\s-1OSSL_CIPHER_PARAM_SPEED\s0\fR) <unsigned integer>" 4
  975. .IX Item "speed (OSSL_CIPHER_PARAM_SPEED) <unsigned integer>"
  976. Sets the speed option for the associated cipher context. This is only supported
  977. by \s-1AES SIV\s0 ciphers which disallow multiple operations by default.
  978. Setting \*(L"speed\*(R" to 1 allows another encrypt or decrypt operation to be
  979. performed. This is used for performance testing.
  980. .ie n .IP """use-bits"" (\fB\s-1OSSL_CIPHER_PARAM_USE_BITS\s0\fR) <unsigned integer>" 4
  981. .el .IP "``use-bits'' (\fB\s-1OSSL_CIPHER_PARAM_USE_BITS\s0\fR) <unsigned integer>" 4
  982. .IX Item "use-bits (OSSL_CIPHER_PARAM_USE_BITS) <unsigned integer>"
  983. Determines if the input length \fIinl\fR passed to \fBEVP_EncryptUpdate()\fR,
  984. \&\fBEVP_DecryptUpdate()\fR and \fBEVP_CipherUpdate()\fR is the number of bits or number of bytes.
  985. Setting \*(L"use-bits\*(R" to 1 uses bits. The default is in bytes.
  986. This is only used for \fB\s-1CFB1\s0\fR ciphers.
  987. .Sp
  988. This can be set using EVP_CIPHER_CTX_set_flags(ctx, \s-1EVP_CIPH_FLAG_LENGTH_BITS\s0).
  989. .ie n .IP """tls-version"" (\fB\s-1OSSL_CIPHER_PARAM_TLS_VERSION\s0\fR) <integer>" 4
  990. .el .IP "``tls-version'' (\fB\s-1OSSL_CIPHER_PARAM_TLS_VERSION\s0\fR) <integer>" 4
  991. .IX Item "tls-version (OSSL_CIPHER_PARAM_TLS_VERSION) <integer>"
  992. Sets the \s-1TLS\s0 version.
  993. .ie n .IP """tls-mac-size"" (\fB\s-1OSSL_CIPHER_PARAM_TLS_MAC_SIZE\s0\fR) <unsigned integer>" 4
  994. .el .IP "``tls-mac-size'' (\fB\s-1OSSL_CIPHER_PARAM_TLS_MAC_SIZE\s0\fR) <unsigned integer>" 4
  995. .IX Item "tls-mac-size (OSSL_CIPHER_PARAM_TLS_MAC_SIZE) <unsigned integer>"
  996. Set the \s-1TLS MAC\s0 size.
  997. .ie n .IP """tlsaad"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_AAD\s0\fR) <octet string>" 4
  998. .el .IP "``tlsaad'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_AAD\s0\fR) <octet string>" 4
  999. .IX Item "tlsaad (OSSL_CIPHER_PARAM_AEAD_TLS1_AAD) <octet string>"
  1000. Sets TLSv1.2 \s-1AAD\s0 information for the associated cipher context \fIctx\fR.
  1001. TLSv1.2 \s-1AAD\s0 information is always 13 bytes in length and is as defined for the
  1002. \&\*(L"additional_data\*(R" field described in section 6.2.3.3 of \s-1RFC5246.\s0
  1003. .ie n .IP """tlsivfixed"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED\s0\fR) <octet string>" 4
  1004. .el .IP "``tlsivfixed'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED\s0\fR) <octet string>" 4
  1005. .IX Item "tlsivfixed (OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED) <octet string>"
  1006. Sets the fixed portion of an \s-1IV\s0 for an \s-1AEAD\s0 cipher used in a \s-1TLS\s0 record
  1007. encryption/ decryption for the associated cipher context.
  1008. \&\s-1TLS\s0 record encryption/decryption always occurs \*(L"in place\*(R" so that the input and
  1009. output buffers are always the same memory location.
  1010. \&\s-1AEAD\s0 IVs in TLSv1.2 consist of an implicit \*(L"fixed\*(R" part and an explicit part
  1011. that varies with every record.
  1012. Setting a \s-1TLS\s0 fixed \s-1IV\s0 changes a cipher to encrypt/decrypt \s-1TLS\s0 records.
  1013. \&\s-1TLS\s0 records are encrypted/decrypted using a single OSSL_FUNC_cipher_cipher call per
  1014. record.
  1015. For a record decryption the first bytes of the input buffer will be the explicit
  1016. part of the \s-1IV\s0 and the final bytes of the input buffer will be the \s-1AEAD\s0 tag.
  1017. The length of the explicit part of the \s-1IV\s0 and the tag length will depend on the
  1018. cipher in use and will be defined in the \s-1RFC\s0 for the relevant ciphersuite.
  1019. In order to allow for \*(L"in place\*(R" decryption the plaintext output should be
  1020. written to the same location in the output buffer that the ciphertext payload
  1021. was read from, i.e. immediately after the explicit \s-1IV.\s0
  1022. .Sp
  1023. When encrypting a record the first bytes of the input buffer should be empty to
  1024. allow space for the explicit \s-1IV,\s0 as will the final bytes where the tag will
  1025. be written.
  1026. The length of the input buffer will include the length of the explicit \s-1IV,\s0 the
  1027. payload, and the tag bytes.
  1028. The cipher implementation should generate the explicit \s-1IV\s0 and write it to the
  1029. beginning of the output buffer, do \*(L"in place\*(R" encryption of the payload and
  1030. write that to the output buffer, and finally add the tag onto the end of the
  1031. output buffer.
  1032. .Sp
  1033. Whether encrypting or decrypting the value written to \fI*outl\fR in the
  1034. OSSL_FUNC_cipher_cipher call should be the length of the payload excluding the explicit
  1035. \&\s-1IV\s0 length and the tag length.
  1036. .ie n .IP """tlsivinv"" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV\s0\fR) <octet string>" 4
  1037. .el .IP "``tlsivinv'' (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV\s0\fR) <octet string>" 4
  1038. .IX Item "tlsivinv (OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV) <octet string>"
  1039. Sets the invocation field used for decryption.
  1040. Can only be called after \*(L"tlsivfixed\*(R" is set.
  1041. This is only used for \s-1GCM\s0 mode.
  1042. .ie n .IP """tls1multi_enc"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC\s0\fR) <octet string>" 4
  1043. .el .IP "``tls1multi_enc'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC\s0\fR) <octet string>" 4
  1044. .IX Item "tls1multi_enc (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC) <octet string>"
  1045. Triggers a multiblock \s-1TLS1\s0 encrypt operation for a \s-1TLS1\s0 aware cipher that
  1046. supports sending 4 or 8 records in one go.
  1047. The cipher performs both the \s-1MAC\s0 and encrypt stages and constructs the record
  1048. headers itself.
  1049. \&\*(L"tls1multi_enc\*(R" supplies the output buffer for the encrypt operation,
  1050. \&\*(L"tls1multi_encin\*(R" & \*(L"tls1multi_interleave\*(R" must also be set in order to supply
  1051. values to the encrypt operation.
  1052. .ie n .IP """tls1multi_encin"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN\s0\fR) <octet string>" 4
  1053. .el .IP "``tls1multi_encin'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN\s0\fR) <octet string>" 4
  1054. .IX Item "tls1multi_encin (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN) <octet string>"
  1055. Supplies the data to encrypt for a \s-1TLS1\s0 multiblock cipher operation.
  1056. .ie n .IP """tls1multi_maxsndfrag"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT\s0\fR) <unsigned integer>" 4
  1057. .el .IP "``tls1multi_maxsndfrag'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT\s0\fR) <unsigned integer>" 4
  1058. .IX Item "tls1multi_maxsndfrag (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT) <unsigned integer>"
  1059. Sets the maximum send fragment size for a \s-1TLS1\s0 multiblock cipher operation.
  1060. It must be set before using \*(L"tls1multi_maxbufsz\*(R".
  1061. The length of the \*(L"tls1multi_maxsndfrag\*(R" parameter should not exceed that of a \fBsize_t\fR.
  1062. .ie n .IP """tls1multi_aad"" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD\s0\fR) <octet string>" 4
  1063. .el .IP "``tls1multi_aad'' (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD\s0\fR) <octet string>" 4
  1064. .IX Item "tls1multi_aad (OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD) <octet string>"
  1065. Sets the authenticated additional data used by a \s-1TLS1\s0 multiblock cipher operation.
  1066. The supplied data consists of 13 bytes of record data containing:
  1067. Bytes 0\-7: The sequence number of the first record
  1068. Byte 8: The record type
  1069. Byte 9\-10: The protocol version
  1070. Byte 11\-12: Input length (Always 0)
  1071. .Sp
  1072. \&\*(L"tls1multi_interleave\*(R" must also be set for this operation.
  1073. .ie n .IP """xts_standard"" (\fB\s-1OSSL_CIPHER_PARAM_XTS_STANDARD\s0\fR) <\s-1UTF8\s0 string>" 4
  1074. .el .IP "``xts_standard'' (\fB\s-1OSSL_CIPHER_PARAM_XTS_STANDARD\s0\fR) <\s-1UTF8\s0 string>" 4
  1075. .IX Item "xts_standard (OSSL_CIPHER_PARAM_XTS_STANDARD) <UTF8 string>"
  1076. Sets the \s-1XTS\s0 standard to use with \s-1SM4\-XTS\s0 algorithm. \s-1XTS\s0 mode has two
  1077. implementations, one is standardized in \s-1IEEE\s0 Std. 1619\-2007 and has
  1078. been widely used (e.g., \s-1XTS AES\s0), the other is proposed recently
  1079. (\s-1GB/T 17964\-2021\s0 implemented in May 2022) and is currently only used
  1080. in \s-1SM4.\s0
  1081. .Sp
  1082. The main difference between them is the multiplication by the
  1083. primitive element X to calculate the tweak values. The \s-1IEEE\s0
  1084. Std 1619\-2007 noted that the multiplication \*(L"is a left shift of each
  1085. byte by one bit with carry propagating from one byte to the next
  1086. one\*(R", which means that in each byte, the leftmost bit is the most
  1087. significant bit. But in \s-1GB/T 17964\-2021,\s0 the rightmost bit is the
  1088. most significant bit, thus the multiplication becomes a right shift
  1089. of each byte by one bit with carry propagating from one byte to the
  1090. next one.
  1091. .Sp
  1092. Valid values for the mode are:
  1093. .RS 4
  1094. .ie n .IP """\s-1GB""\s0" 4
  1095. .el .IP "``\s-1GB''\s0" 4
  1096. .IX Item "GB"
  1097. The \s-1GB/T 17964\-2021\s0 variant of \s-1SM4\-XTS\s0 algorithm.
  1098. .ie n .IP """\s-1IEEE""\s0" 4
  1099. .el .IP "``\s-1IEEE''\s0" 4
  1100. .IX Item "IEEE"
  1101. The \s-1IEEE\s0 Std. 1619\-2007 variant of \s-1SM4\-XTS\s0 algorithm.
  1102. .RE
  1103. .RS 4
  1104. .Sp
  1105. The default value is \*(L"\s-1GB\*(R".\s0
  1106. .RE
  1107. .SH "CONTROLS"
  1108. .IX Header "CONTROLS"
  1109. The Mappings from \fBEVP_CIPHER_CTX_ctrl()\fR identifiers to \s-1PARAMETERS\s0 are listed
  1110. in the following section. See the \*(L"\s-1PARAMETERS\*(R"\s0 section for more details.
  1111. .PP
  1112. \&\fBEVP_CIPHER_CTX_ctrl()\fR can be used to send the following standard controls:
  1113. .IP "\s-1EVP_CTRL_AEAD_SET_IVLEN\s0 and \s-1EVP_CTRL_GET_IVLEN\s0" 4
  1114. .IX Item "EVP_CTRL_AEAD_SET_IVLEN and EVP_CTRL_GET_IVLEN"
  1115. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR and
  1116. \&\fBEVP_CIPHER_CTX_get_params()\fR get called with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the
  1117. key \*(L"ivlen\*(R" (\fB\s-1OSSL_CIPHER_PARAM_IVLEN\s0\fR).
  1118. .IP "\s-1EVP_CTRL_AEAD_SET_IV_FIXED\s0" 4
  1119. .IX Item "EVP_CTRL_AEAD_SET_IV_FIXED"
  1120. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1121. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"tlsivfixed\*(R"
  1122. (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_IV_FIXED\s0\fR).
  1123. .IP "\s-1EVP_CTRL_AEAD_SET_MAC_KEY\s0" 4
  1124. .IX Item "EVP_CTRL_AEAD_SET_MAC_KEY"
  1125. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1126. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"mackey\*(R"
  1127. (\fB\s-1OSSL_CIPHER_PARAM_AEAD_MAC_KEY\s0\fR).
  1128. .IP "\s-1EVP_CTRL_AEAD_SET_TAG\s0 and \s-1EVP_CTRL_AEAD_GET_TAG\s0" 4
  1129. .IX Item "EVP_CTRL_AEAD_SET_TAG and EVP_CTRL_AEAD_GET_TAG"
  1130. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR and
  1131. \&\fBEVP_CIPHER_CTX_get_params()\fR get called with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the
  1132. key \*(L"tag\*(R" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TAG\s0\fR).
  1133. .IP "\s-1EVP_CTRL_CCM_SET_L\s0" 4
  1134. .IX Item "EVP_CTRL_CCM_SET_L"
  1135. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1136. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"ivlen\*(R" (\fB\s-1OSSL_CIPHER_PARAM_IVLEN\s0\fR)
  1137. with a value of (15 \- L)
  1138. .IP "\s-1EVP_CTRL_COPY\s0" 4
  1139. .IX Item "EVP_CTRL_COPY"
  1140. There is no \s-1OSSL_PARAM\s0 mapping for this. Use \fBEVP_CIPHER_CTX_copy()\fR instead.
  1141. .IP "\s-1EVP_CTRL_GCM_SET_IV_INV\s0" 4
  1142. .IX Item "EVP_CTRL_GCM_SET_IV_INV"
  1143. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1144. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"tlsivinv\*(R"
  1145. (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV\s0\fR).
  1146. .IP "\s-1EVP_CTRL_RAND_KEY\s0" 4
  1147. .IX Item "EVP_CTRL_RAND_KEY"
  1148. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1149. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"randkey\*(R"
  1150. (\fB\s-1OSSL_CIPHER_PARAM_RANDOM_KEY\s0\fR).
  1151. .IP "\s-1EVP_CTRL_SET_KEY_LENGTH\s0" 4
  1152. .IX Item "EVP_CTRL_SET_KEY_LENGTH"
  1153. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1154. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"keylen\*(R" (\fB\s-1OSSL_CIPHER_PARAM_KEYLEN\s0\fR).
  1155. .IP "\s-1EVP_CTRL_SET_RC2_KEY_BITS\s0 and \s-1EVP_CTRL_GET_RC2_KEY_BITS\s0" 4
  1156. .IX Item "EVP_CTRL_SET_RC2_KEY_BITS and EVP_CTRL_GET_RC2_KEY_BITS"
  1157. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR and
  1158. \&\fBEVP_CIPHER_CTX_get_params()\fR get called with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the
  1159. key \*(L"keybits\*(R" (\fB\s-1OSSL_CIPHER_PARAM_RC2_KEYBITS\s0\fR).
  1160. .IP "\s-1EVP_CTRL_SET_RC5_ROUNDS\s0 and \s-1EVP_CTRL_GET_RC5_ROUNDS\s0" 4
  1161. .IX Item "EVP_CTRL_SET_RC5_ROUNDS and EVP_CTRL_GET_RC5_ROUNDS"
  1162. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR and
  1163. \&\fBEVP_CIPHER_CTX_get_params()\fR get called with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the
  1164. key \*(L"rounds\*(R" (\fB\s-1OSSL_CIPHER_PARAM_ROUNDS\s0\fR).
  1165. .IP "\s-1EVP_CTRL_SET_SPEED\s0" 4
  1166. .IX Item "EVP_CTRL_SET_SPEED"
  1167. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1168. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key \*(L"speed\*(R" (\fB\s-1OSSL_CIPHER_PARAM_SPEED\s0\fR).
  1169. .IP "\s-1EVP_CTRL_GCM_IV_GEN\s0" 4
  1170. .IX Item "EVP_CTRL_GCM_IV_GEN"
  1171. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_get_params()\fR gets called
  1172. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key
  1173. \&\*(L"tlsivgen\*(R" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN\s0\fR).
  1174. .IP "\s-1EVP_CTRL_AEAD_TLS1_AAD\s0" 4
  1175. .IX Item "EVP_CTRL_AEAD_TLS1_AAD"
  1176. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR get called
  1177. with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the key
  1178. \&\*(L"tlsaad\*(R" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_AAD\s0\fR)
  1179. followed by \fBEVP_CIPHER_CTX_get_params()\fR with a key of
  1180. \&\*(L"tlsaadpad\*(R" (\fB\s-1OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD\s0\fR).
  1181. .IP "\s-1EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE\s0" 4
  1182. .IX Item "EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE"
  1183. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR,
  1184. \&\fBEVP_CIPHER_CTX_set_params()\fR gets called with an \s-1\fBOSSL_PARAM\s0\fR\|(3) item with the
  1185. key \s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT\s0
  1186. followed by \fBEVP_CIPHER_CTX_get_params()\fR with a key of
  1187. \&\*(L"tls1multi_maxbufsz\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE\s0\fR).
  1188. .IP "\s-1EVP_CTRL_TLS1_1_MULTIBLOCK_AAD\s0" 4
  1189. .IX Item "EVP_CTRL_TLS1_1_MULTIBLOCK_AAD"
  1190. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1191. with \s-1\fBOSSL_PARAM\s0\fR\|(3) items with the keys
  1192. \&\*(L"tls1multi_aad\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD\s0\fR) and
  1193. \&\*(L"tls1multi_interleave\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE\s0\fR)
  1194. followed by \fBEVP_CIPHER_CTX_get_params()\fR with keys of
  1195. \&\*(L"tls1multi_aadpacklen\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN\s0\fR) and
  1196. \&\*(L"tls1multi_interleave\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE\s0\fR).
  1197. .IP "\s-1EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT\s0" 4
  1198. .IX Item "EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT"
  1199. When used with a fetched \fB\s-1EVP_CIPHER\s0\fR, \fBEVP_CIPHER_CTX_set_params()\fR gets called
  1200. with \s-1\fBOSSL_PARAM\s0\fR\|(3) items with the keys
  1201. \&\*(L"tls1multi_enc\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC\s0\fR),
  1202. \&\*(L"tls1multi_encin\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN\s0\fR) and
  1203. \&\*(L"tls1multi_interleave\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE\s0\fR),
  1204. followed by \fBEVP_CIPHER_CTX_get_params()\fR with a key of
  1205. \&\*(L"tls1multi_enclen\*(R" (\fB\s-1OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN\s0\fR).
  1206. .SH "FLAGS"
  1207. .IX Header "FLAGS"
  1208. \&\fBEVP_CIPHER_CTX_set_flags()\fR, \fBEVP_CIPHER_CTX_clear_flags()\fR and \fBEVP_CIPHER_CTX_test_flags()\fR.
  1209. can be used to manipulate and test these \fB\s-1EVP_CIPHER_CTX\s0\fR flags:
  1210. .IP "\s-1EVP_CIPH_NO_PADDING\s0" 4
  1211. .IX Item "EVP_CIPH_NO_PADDING"
  1212. Used by \fBEVP_CIPHER_CTX_set_padding()\fR.
  1213. .Sp
  1214. See also \*(L"Gettable and Settable \s-1EVP_CIPHER_CTX\s0 parameters\*(R" \*(L"padding\*(R"
  1215. .IP "\s-1EVP_CIPH_FLAG_LENGTH_BITS\s0" 4
  1216. .IX Item "EVP_CIPH_FLAG_LENGTH_BITS"
  1217. See \*(L"Settable \s-1EVP_CIPHER_CTX\s0 parameters\*(R" \*(L"use-bits\*(R".
  1218. .IP "\s-1EVP_CIPHER_CTX_FLAG_WRAP_ALLOW\s0" 4
  1219. .IX Item "EVP_CIPHER_CTX_FLAG_WRAP_ALLOW"
  1220. Used for Legacy purposes only. This flag needed to be set to indicate the
  1221. cipher handled wrapping.
  1222. .PP
  1223. \&\fBEVP_CIPHER_flags()\fR uses the following flags that
  1224. have mappings to \*(L"Gettable \s-1EVP_CIPHER\s0 parameters\*(R":
  1225. .IP "\s-1EVP_CIPH_FLAG_AEAD_CIPHER\s0" 4
  1226. .IX Item "EVP_CIPH_FLAG_AEAD_CIPHER"
  1227. See \*(L"Gettable \s-1EVP_CIPHER\s0 parameters\*(R" \*(L"aead\*(R".
  1228. .IP "\s-1EVP_CIPH_CUSTOM_IV\s0" 4
  1229. .IX Item "EVP_CIPH_CUSTOM_IV"
  1230. See \*(L"Gettable \s-1EVP_CIPHER\s0 parameters\*(R" \*(L"custom-iv\*(R".
  1231. .IP "\s-1EVP_CIPH_FLAG_CTS\s0" 4
  1232. .IX Item "EVP_CIPH_FLAG_CTS"
  1233. See \*(L"Gettable \s-1EVP_CIPHER\s0 parameters\*(R" \*(L"cts\*(R".
  1234. .IP "\s-1EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK\s0;" 4
  1235. .IX Item "EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK;"
  1236. See \*(L"Gettable \s-1EVP_CIPHER\s0 parameters\*(R" \*(L"tls-multi\*(R".
  1237. .IP "\s-1EVP_CIPH_RAND_KEY\s0" 4
  1238. .IX Item "EVP_CIPH_RAND_KEY"
  1239. See \*(L"Gettable \s-1EVP_CIPHER\s0 parameters\*(R" \*(L"has-randkey\*(R".
  1240. .PP
  1241. \&\fBEVP_CIPHER_flags()\fR uses the following flags for legacy purposes only:
  1242. .IP "\s-1EVP_CIPH_VARIABLE_LENGTH\s0" 4
  1243. .IX Item "EVP_CIPH_VARIABLE_LENGTH"
  1244. .PD 0
  1245. .IP "\s-1EVP_CIPH_FLAG_CUSTOM_CIPHER\s0" 4
  1246. .IX Item "EVP_CIPH_FLAG_CUSTOM_CIPHER"
  1247. .IP "\s-1EVP_CIPH_ALWAYS_CALL_INIT\s0" 4
  1248. .IX Item "EVP_CIPH_ALWAYS_CALL_INIT"
  1249. .IP "\s-1EVP_CIPH_CTRL_INIT\s0" 4
  1250. .IX Item "EVP_CIPH_CTRL_INIT"
  1251. .IP "\s-1EVP_CIPH_CUSTOM_KEY_LENGTH\s0" 4
  1252. .IX Item "EVP_CIPH_CUSTOM_KEY_LENGTH"
  1253. .IP "\s-1EVP_CIPH_CUSTOM_COPY\s0" 4
  1254. .IX Item "EVP_CIPH_CUSTOM_COPY"
  1255. .IP "\s-1EVP_CIPH_FLAG_DEFAULT_ASN1\s0" 4
  1256. .IX Item "EVP_CIPH_FLAG_DEFAULT_ASN1"
  1257. .PD
  1258. See \fBEVP_CIPHER_meth_set_flags\fR\|(3) for further information related to the above
  1259. flags.
  1260. .SH "RETURN VALUES"
  1261. .IX Header "RETURN VALUES"
  1262. \&\fBEVP_CIPHER_fetch()\fR returns a pointer to a \fB\s-1EVP_CIPHER\s0\fR for success
  1263. and \fB\s-1NULL\s0\fR for failure.
  1264. .PP
  1265. \&\fBEVP_CIPHER_up_ref()\fR returns 1 for success or 0 otherwise.
  1266. .PP
  1267. \&\fBEVP_CIPHER_CTX_new()\fR returns a pointer to a newly created
  1268. \&\fB\s-1EVP_CIPHER_CTX\s0\fR for success and \fB\s-1NULL\s0\fR for failure.
  1269. .PP
  1270. \&\fBEVP_CIPHER_CTX_dup()\fR returns a new \s-1EVP_CIPHER_CTX\s0 if successful or \s-1NULL\s0 on failure.
  1271. .PP
  1272. \&\fBEVP_CIPHER_CTX_copy()\fR returns 1 if successful or 0 for failure.
  1273. .PP
  1274. \&\fBEVP_EncryptInit_ex2()\fR, \fBEVP_EncryptUpdate()\fR and \fBEVP_EncryptFinal_ex()\fR
  1275. return 1 for success and 0 for failure.
  1276. .PP
  1277. \&\fBEVP_DecryptInit_ex2()\fR and \fBEVP_DecryptUpdate()\fR return 1 for success and 0 for failure.
  1278. \&\fBEVP_DecryptFinal_ex()\fR returns 0 if the decrypt failed or 1 for success.
  1279. .PP
  1280. \&\fBEVP_CipherInit_ex2()\fR and \fBEVP_CipherUpdate()\fR return 1 for success and 0 for failure.
  1281. \&\fBEVP_CipherFinal_ex()\fR returns 0 for a decryption failure or 1 for success.
  1282. .PP
  1283. \&\fBEVP_Cipher()\fR returns 1 on success and <= 0 on failure, if the flag
  1284. \&\fB\s-1EVP_CIPH_FLAG_CUSTOM_CIPHER\s0\fR is not set for the cipher, or if the cipher has
  1285. not been initialized via a call to \fBEVP_CipherInit_ex2\fR.
  1286. \&\fBEVP_Cipher()\fR returns the number of bytes written to \fIout\fR for encryption / decryption, or
  1287. the number of bytes authenticated in a call specifying \s-1AAD\s0 for an \s-1AEAD\s0 cipher, if the flag
  1288. \&\fB\s-1EVP_CIPH_FLAG_CUSTOM_CIPHER\s0\fR is set for the cipher.
  1289. .PP
  1290. \&\fBEVP_CIPHER_CTX_reset()\fR returns 1 for success and 0 for failure.
  1291. .PP
  1292. \&\fBEVP_get_cipherbyname()\fR, \fBEVP_get_cipherbynid()\fR and \fBEVP_get_cipherbyobj()\fR
  1293. return an \fB\s-1EVP_CIPHER\s0\fR structure or \s-1NULL\s0 on error.
  1294. .PP
  1295. \&\fBEVP_CIPHER_get_nid()\fR and \fBEVP_CIPHER_CTX_get_nid()\fR return a \s-1NID.\s0
  1296. .PP
  1297. \&\fBEVP_CIPHER_get_block_size()\fR and \fBEVP_CIPHER_CTX_get_block_size()\fR return the
  1298. block size, or 0 on error.
  1299. .PP
  1300. \&\fBEVP_CIPHER_get_key_length()\fR and \fBEVP_CIPHER_CTX_get_key_length()\fR return the key
  1301. length.
  1302. .PP
  1303. \&\fBEVP_CIPHER_CTX_set_padding()\fR always returns 1.
  1304. .PP
  1305. \&\fBEVP_CIPHER_get_iv_length()\fR and \fBEVP_CIPHER_CTX_get_iv_length()\fR return the \s-1IV\s0
  1306. length, zero if the cipher does not use an \s-1IV\s0 and a negative value on error.
  1307. .PP
  1308. \&\fBEVP_CIPHER_CTX_get_tag_length()\fR return the tag length or zero if the cipher
  1309. does not use a tag.
  1310. .PP
  1311. \&\fBEVP_CIPHER_get_type()\fR and \fBEVP_CIPHER_CTX_get_type()\fR return the \s-1NID\s0 of the
  1312. cipher's \s-1OBJECT IDENTIFIER\s0 or NID_undef if it has no defined
  1313. \&\s-1OBJECT IDENTIFIER.\s0
  1314. .PP
  1315. \&\fBEVP_CIPHER_CTX_cipher()\fR returns an \fB\s-1EVP_CIPHER\s0\fR structure.
  1316. .PP
  1317. \&\fBEVP_CIPHER_CTX_get_num()\fR returns a nonnegative num value or
  1318. \&\fB\s-1EVP_CTRL_RET_UNSUPPORTED\s0\fR if the implementation does not support the call
  1319. or on any other error.
  1320. .PP
  1321. \&\fBEVP_CIPHER_CTX_set_num()\fR returns 1 on success and 0 if the implementation
  1322. does not support the call or on any other error.
  1323. .PP
  1324. \&\fBEVP_CIPHER_CTX_is_encrypting()\fR returns 1 if the \fIctx\fR is set up for encryption
  1325. 0 otherwise.
  1326. .PP
  1327. \&\fBEVP_CIPHER_param_to_asn1()\fR and \fBEVP_CIPHER_asn1_to_param()\fR return greater
  1328. than zero for success and zero or a negative number on failure.
  1329. .PP
  1330. \&\fBEVP_CIPHER_CTX_rand_key()\fR returns 1 for success and zero or a negative number
  1331. for failure.
  1332. .PP
  1333. \&\fBEVP_CIPHER_names_do_all()\fR returns 1 if the callback was called for all names.
  1334. A return value of 0 means that the callback was not called for any names.
  1335. .SH "CIPHER LISTING"
  1336. .IX Header "CIPHER LISTING"
  1337. All algorithms have a fixed key length unless otherwise stated.
  1338. .PP
  1339. Refer to \*(L"\s-1SEE ALSO\*(R"\s0 for the full list of ciphers available through the \s-1EVP\s0
  1340. interface.
  1341. .IP "\fBEVP_enc_null()\fR" 4
  1342. .IX Item "EVP_enc_null()"
  1343. Null cipher: does nothing.
  1344. .SH "AEAD INTERFACE"
  1345. .IX Header "AEAD INTERFACE"
  1346. The \s-1EVP\s0 interface for Authenticated Encryption with Associated Data (\s-1AEAD\s0)
  1347. modes are subtly altered and several additional \fIctrl\fR operations are supported
  1348. depending on the mode specified.
  1349. .PP
  1350. To specify additional authenticated data (\s-1AAD\s0), a call to \fBEVP_CipherUpdate()\fR,
  1351. \&\fBEVP_EncryptUpdate()\fR or \fBEVP_DecryptUpdate()\fR should be made with the output
  1352. parameter \fIout\fR set to \fB\s-1NULL\s0\fR. In this case, on success, the parameter
  1353. \&\fIoutl\fR is set to the number of bytes authenticated.
  1354. .PP
  1355. When decrypting, the return value of \fBEVP_DecryptFinal()\fR or \fBEVP_CipherFinal()\fR
  1356. indicates whether the operation was successful. If it does not indicate success,
  1357. the authentication operation has failed and any output data \fB\s-1MUST NOT\s0\fR be used
  1358. as it is corrupted.
  1359. .SS "\s-1GCM\s0 and \s-1OCB\s0 Modes"
  1360. .IX Subsection "GCM and OCB Modes"
  1361. The following \fIctrl\fRs are supported in \s-1GCM\s0 and \s-1OCB\s0 modes.
  1362. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_IVLEN,\s0 ivlen, \s-1NULL\s0)" 4
  1363. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, ivlen, NULL)"
  1364. Sets the \s-1IV\s0 length. This call can only be made before specifying an \s-1IV.\s0 If
  1365. not called a default \s-1IV\s0 length is used.
  1366. .Sp
  1367. For \s-1GCM AES\s0 and \s-1OCB AES\s0 the default is 12 (i.e. 96 bits). For \s-1OCB\s0 mode the
  1368. maximum is 15.
  1369. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_GET_TAG,\s0 taglen, tag)" 4
  1370. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen, tag)"
  1371. Writes \f(CW\*(C`taglen\*(C'\fR bytes of the tag value to the buffer indicated by \f(CW\*(C`tag\*(C'\fR.
  1372. This call can only be made when encrypting data and \fBafter\fR all data has been
  1373. processed (e.g. after an \fBEVP_EncryptFinal()\fR call).
  1374. .Sp
  1375. For \s-1OCB,\s0 \f(CW\*(C`taglen\*(C'\fR must either be 16 or the value previously set via
  1376. \&\fB\s-1EVP_CTRL_AEAD_SET_TAG\s0\fR.
  1377. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_TAG,\s0 taglen, tag)" 4
  1378. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen, tag)"
  1379. When decrypting, this call sets the expected tag to \f(CW\*(C`taglen\*(C'\fR bytes from \f(CW\*(C`tag\*(C'\fR.
  1380. \&\f(CW\*(C`taglen\*(C'\fR must be between 1 and 16 inclusive.
  1381. The tag must be set prior to any call to \fBEVP_DecryptFinal()\fR or
  1382. \&\fBEVP_DecryptFinal_ex()\fR.
  1383. .Sp
  1384. For \s-1GCM,\s0 this call is only valid when decrypting data.
  1385. .Sp
  1386. For \s-1OCB,\s0 this call is valid when decrypting data to set the expected tag,
  1387. and when encrypting to set the desired tag length.
  1388. .Sp
  1389. In \s-1OCB\s0 mode, calling this when encrypting with \f(CW\*(C`tag\*(C'\fR set to \f(CW\*(C`NULL\*(C'\fR sets the
  1390. tag length. The tag length can only be set before specifying an \s-1IV.\s0 If this is
  1391. not called prior to setting the \s-1IV\s0 during encryption, then a default tag length
  1392. is used.
  1393. .Sp
  1394. For \s-1OCB AES,\s0 the default tag length is 16 (i.e. 128 bits). It is also the
  1395. maximum tag length for \s-1OCB.\s0
  1396. .SS "\s-1CCM\s0 Mode"
  1397. .IX Subsection "CCM Mode"
  1398. The \s-1EVP\s0 interface for \s-1CCM\s0 mode is similar to that of the \s-1GCM\s0 mode but with a
  1399. few additional requirements and different \fIctrl\fR values.
  1400. .PP
  1401. For \s-1CCM\s0 mode, the total plaintext or ciphertext length \fB\s-1MUST\s0\fR be passed to
  1402. \&\fBEVP_CipherUpdate()\fR, \fBEVP_EncryptUpdate()\fR or \fBEVP_DecryptUpdate()\fR with the output
  1403. and input parameters (\fIin\fR and \fIout\fR) set to \fB\s-1NULL\s0\fR and the length passed in
  1404. the \fIinl\fR parameter.
  1405. .PP
  1406. The following \fIctrl\fRs are supported in \s-1CCM\s0 mode.
  1407. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_TAG,\s0 taglen, tag)" 4
  1408. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen, tag)"
  1409. This call is made to set the expected \fB\s-1CCM\s0\fR tag value when decrypting or
  1410. the length of the tag (with the \f(CW\*(C`tag\*(C'\fR parameter set to \s-1NULL\s0) when encrypting.
  1411. The tag length is often referred to as \fBM\fR. If not set a default value is
  1412. used (12 for \s-1AES\s0). When decrypting, the tag needs to be set before passing
  1413. in data to be decrypted, but as in \s-1GCM\s0 and \s-1OCB\s0 mode, it can be set after
  1414. passing additional authenticated data (see \*(L"\s-1AEAD INTERFACE\*(R"\s0).
  1415. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_CCM_SET_L,\s0 ivlen, \s-1NULL\s0)" 4
  1416. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_L, ivlen, NULL)"
  1417. Sets the \s-1CCM\s0 \fBL\fR value. If not set a default is used (8 for \s-1AES\s0).
  1418. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_IVLEN,\s0 ivlen, \s-1NULL\s0)" 4
  1419. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, ivlen, NULL)"
  1420. Sets the \s-1CCM\s0 nonce (\s-1IV\s0) length. This call can only be made before specifying a
  1421. nonce value. The nonce length is given by \fB15 \- L\fR so it is 7 by default for
  1422. \&\s-1AES.\s0
  1423. .SS "\s-1SIV\s0 Mode"
  1424. .IX Subsection "SIV Mode"
  1425. Both the AES-SIV and AES-GCM-SIV ciphers fall under this mode.
  1426. .PP
  1427. For \s-1SIV\s0 mode ciphers the behaviour of the \s-1EVP\s0 interface is subtly
  1428. altered and several additional ctrl operations are supported.
  1429. .PP
  1430. To specify any additional authenticated data (\s-1AAD\s0) and/or a Nonce, a call to
  1431. \&\fBEVP_CipherUpdate()\fR, \fBEVP_EncryptUpdate()\fR or \fBEVP_DecryptUpdate()\fR should be made
  1432. with the output parameter \fIout\fR set to \fB\s-1NULL\s0\fR.
  1433. .PP
  1434. \&\s-1RFC5297\s0 states that the Nonce is the last piece of \s-1AAD\s0 before the actual
  1435. encrypt/decrypt takes place. The \s-1API\s0 does not differentiate the Nonce from
  1436. other \s-1AAD.\s0
  1437. .PP
  1438. When decrypting the return value of \fBEVP_DecryptFinal()\fR or \fBEVP_CipherFinal()\fR
  1439. indicates if the operation was successful. If it does not indicate success
  1440. the authentication operation has failed and any output data \fB\s-1MUST NOT\s0\fR
  1441. be used as it is corrupted.
  1442. .PP
  1443. The \s-1API\s0 does not store the the \s-1SIV\s0 (Synthetic Initialization Vector) in
  1444. the cipher text. Instead, it is stored as the tag within the \s-1EVP_CIPHER_CTX.\s0
  1445. The \s-1SIV\s0 must be retrieved from the context after encryption, and set into
  1446. the context before decryption.
  1447. .PP
  1448. This differs from \s-1RFC5297\s0 in that the cipher output from encryption, and
  1449. the cipher input to decryption, does not contain the \s-1SIV.\s0 This also means
  1450. that the plain text and cipher text lengths are identical.
  1451. .PP
  1452. The following ctrls are supported in \s-1SIV\s0 mode, and are used to get and set
  1453. the Synthetic Initialization Vector:
  1454. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_GET_TAG,\s0 taglen, tag);" 4
  1455. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen, tag);"
  1456. Writes \fItaglen\fR bytes of the tag value (the Synthetic Initialization Vector)
  1457. to the buffer indicated by \fItag\fR. This call can only be made when encrypting
  1458. data and \fBafter\fR all data has been processed (e.g. after an \fBEVP_EncryptFinal()\fR
  1459. call). For \s-1SIV\s0 mode the taglen must be 16.
  1460. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_TAG,\s0 taglen, tag);" 4
  1461. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen, tag);"
  1462. Sets the expected tag (the Synthetic Initialization Vector) to \fItaglen\fR
  1463. bytes from \fItag\fR. This call is only legal when decrypting data and must be
  1464. made \fBbefore\fR any data is processed (e.g. before any \fBEVP_DecryptUpdate()\fR
  1465. calls). For \s-1SIV\s0 mode the taglen must be 16.
  1466. .PP
  1467. \&\s-1SIV\s0 mode makes two passes over the input data, thus, only one call to
  1468. \&\fBEVP_CipherUpdate()\fR, \fBEVP_EncryptUpdate()\fR or \fBEVP_DecryptUpdate()\fR should be made
  1469. with \fIout\fR set to a non\-\fB\s-1NULL\s0\fR value. A call to \fBEVP_DecryptFinal()\fR or
  1470. \&\fBEVP_CipherFinal()\fR is not required, but will indicate if the update
  1471. operation succeeded.
  1472. .SS "ChaCha20\-Poly1305"
  1473. .IX Subsection "ChaCha20-Poly1305"
  1474. The following \fIctrl\fRs are supported for the ChaCha20\-Poly1305 \s-1AEAD\s0 algorithm.
  1475. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_IVLEN,\s0 ivlen, \s-1NULL\s0)" 4
  1476. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, ivlen, NULL)"
  1477. Sets the nonce length. This call is now redundant since the only valid value
  1478. is the default length of 12 (i.e. 96 bits).
  1479. Prior to OpenSSL 3.0 a nonce of less than 12 bytes could be used to automatically
  1480. pad the iv with leading 0 bytes to make it 12 bytes in length.
  1481. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_GET_TAG,\s0 taglen, tag)" 4
  1482. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen, tag)"
  1483. Writes \f(CW\*(C`taglen\*(C'\fR bytes of the tag value to the buffer indicated by \f(CW\*(C`tag\*(C'\fR.
  1484. This call can only be made when encrypting data and \fBafter\fR all data has been
  1485. processed (e.g. after an \fBEVP_EncryptFinal()\fR call).
  1486. .Sp
  1487. \&\f(CW\*(C`taglen\*(C'\fR specified here must be 16 (\fB\s-1POLY1305_BLOCK_SIZE\s0\fR, i.e. 128\-bits) or
  1488. less.
  1489. .IP "EVP_CIPHER_CTX_ctrl(ctx, \s-1EVP_CTRL_AEAD_SET_TAG,\s0 taglen, tag)" 4
  1490. .IX Item "EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, taglen, tag)"
  1491. Sets the expected tag to \f(CW\*(C`taglen\*(C'\fR bytes from \f(CW\*(C`tag\*(C'\fR.
  1492. The tag length can only be set before specifying an \s-1IV.\s0
  1493. \&\f(CW\*(C`taglen\*(C'\fR must be between 1 and 16 (\fB\s-1POLY1305_BLOCK_SIZE\s0\fR) inclusive.
  1494. This call is only valid when decrypting data.
  1495. .SH "NOTES"
  1496. .IX Header "NOTES"
  1497. Where possible the \fB\s-1EVP\s0\fR interface to symmetric ciphers should be used in
  1498. preference to the low-level interfaces. This is because the code then becomes
  1499. transparent to the cipher used and much more flexible. Additionally, the
  1500. \&\fB\s-1EVP\s0\fR interface will ensure the use of platform specific cryptographic
  1501. acceleration such as AES-NI (the low-level interfaces do not provide the
  1502. guarantee).
  1503. .PP
  1504. \&\s-1PKCS\s0 padding works by adding \fBn\fR padding bytes of value \fBn\fR to make the total
  1505. length of the encrypted data a multiple of the block size. Padding is always
  1506. added so if the data is already a multiple of the block size \fBn\fR will equal
  1507. the block size. For example if the block size is 8 and 11 bytes are to be
  1508. encrypted then 5 padding bytes of value 5 will be added.
  1509. .PP
  1510. When decrypting the final block is checked to see if it has the correct form.
  1511. .PP
  1512. Although the decryption operation can produce an error if padding is enabled,
  1513. it is not a strong test that the input data or key is correct. A random block
  1514. has better than 1 in 256 chance of being of the correct format and problems with
  1515. the input data earlier on will not produce a final decrypt error.
  1516. .PP
  1517. If padding is disabled then the decryption operation will always succeed if
  1518. the total amount of data decrypted is a multiple of the block size.
  1519. .PP
  1520. The functions \fBEVP_EncryptInit()\fR, \fBEVP_EncryptInit_ex()\fR,
  1521. \&\fBEVP_EncryptFinal()\fR, \fBEVP_DecryptInit()\fR, \fBEVP_DecryptInit_ex()\fR,
  1522. \&\fBEVP_CipherInit()\fR, \fBEVP_CipherInit_ex()\fR and \fBEVP_CipherFinal()\fR are obsolete
  1523. but are retained for compatibility with existing code. New code should
  1524. use \fBEVP_EncryptInit_ex2()\fR, \fBEVP_EncryptFinal_ex()\fR, \fBEVP_DecryptInit_ex2()\fR,
  1525. \&\fBEVP_DecryptFinal_ex()\fR, \fBEVP_CipherInit_ex2()\fR and \fBEVP_CipherFinal_ex()\fR
  1526. because they can reuse an existing context without allocating and freeing
  1527. it up on each call.
  1528. .PP
  1529. There are some differences between functions \fBEVP_CipherInit()\fR and
  1530. \&\fBEVP_CipherInit_ex()\fR, significant in some circumstances. \fBEVP_CipherInit()\fR fills
  1531. the passed context object with zeros. As a consequence, \fBEVP_CipherInit()\fR does
  1532. not allow step-by-step initialization of the ctx when the \fIkey\fR and \fIiv\fR are
  1533. passed in separate calls. It also means that the flags set for the \s-1CTX\s0 are
  1534. removed, and it is especially important for the
  1535. \&\fB\s-1EVP_CIPHER_CTX_FLAG_WRAP_ALLOW\s0\fR flag treated specially in
  1536. \&\fBEVP_CipherInit_ex()\fR.
  1537. .PP
  1538. Ignoring failure returns of the \fB\s-1EVP_CIPHER_CTX\s0\fR initialization functions can
  1539. lead to subsequent undefined behavior when calling the functions that update or
  1540. finalize the context. The only valid calls on the \fB\s-1EVP_CIPHER_CTX\s0\fR when
  1541. initialization fails are calls that attempt another initialization of the
  1542. context or release the context.
  1543. .PP
  1544. \&\fBEVP_get_cipherbynid()\fR, and \fBEVP_get_cipherbyobj()\fR are implemented as macros.
  1545. .SH "BUGS"
  1546. .IX Header "BUGS"
  1547. \&\fB\s-1EVP_MAX_KEY_LENGTH\s0\fR and \fB\s-1EVP_MAX_IV_LENGTH\s0\fR only refer to the internal
  1548. ciphers with default key lengths. If custom ciphers exceed these values the
  1549. results are unpredictable. This is because it has become standard practice to
  1550. define a generic key as a fixed unsigned char array containing
  1551. \&\fB\s-1EVP_MAX_KEY_LENGTH\s0\fR bytes.
  1552. .PP
  1553. The \s-1ASN1\s0 code is incomplete (and sometimes inaccurate) it has only been tested
  1554. for certain common S/MIME ciphers (\s-1RC2, DES,\s0 triple \s-1DES\s0) in \s-1CBC\s0 mode.
  1555. .SH "EXAMPLES"
  1556. .IX Header "EXAMPLES"
  1557. Encrypt a string using \s-1IDEA:\s0
  1558. .PP
  1559. .Vb 10
  1560. \& int do_crypt(char *outfile)
  1561. \& {
  1562. \& unsigned char outbuf[1024];
  1563. \& int outlen, tmplen;
  1564. \& /*
  1565. \& * Bogus key and IV: we\*(Aqd normally set these from
  1566. \& * another source.
  1567. \& */
  1568. \& unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  1569. \& unsigned char iv[] = {1,2,3,4,5,6,7,8};
  1570. \& char intext[] = "Some Crypto Text";
  1571. \& EVP_CIPHER_CTX *ctx;
  1572. \& FILE *out;
  1573. \&
  1574. \& ctx = EVP_CIPHER_CTX_new();
  1575. \& if (!EVP_EncryptInit_ex2(ctx, EVP_idea_cbc(), key, iv, NULL)) {
  1576. \& /* Error */
  1577. \& EVP_CIPHER_CTX_free(ctx);
  1578. \& return 0;
  1579. \& }
  1580. \&
  1581. \& if (!EVP_EncryptUpdate(ctx, outbuf, &outlen, intext, strlen(intext))) {
  1582. \& /* Error */
  1583. \& EVP_CIPHER_CTX_free(ctx);
  1584. \& return 0;
  1585. \& }
  1586. \& /*
  1587. \& * Buffer passed to EVP_EncryptFinal() must be after data just
  1588. \& * encrypted to avoid overwriting it.
  1589. \& */
  1590. \& if (!EVP_EncryptFinal_ex(ctx, outbuf + outlen, &tmplen)) {
  1591. \& /* Error */
  1592. \& EVP_CIPHER_CTX_free(ctx);
  1593. \& return 0;
  1594. \& }
  1595. \& outlen += tmplen;
  1596. \& EVP_CIPHER_CTX_free(ctx);
  1597. \& /*
  1598. \& * Need binary mode for fopen because encrypted data is
  1599. \& * binary data. Also cannot use strlen() on it because
  1600. \& * it won\*(Aqt be NUL terminated and may contain embedded
  1601. \& * NULs.
  1602. \& */
  1603. \& out = fopen(outfile, "wb");
  1604. \& if (out == NULL) {
  1605. \& /* Error */
  1606. \& return 0;
  1607. \& }
  1608. \& fwrite(outbuf, 1, outlen, out);
  1609. \& fclose(out);
  1610. \& return 1;
  1611. \& }
  1612. .Ve
  1613. .PP
  1614. The ciphertext from the above example can be decrypted using the \fBopenssl\fR
  1615. utility with the command line (shown on two lines for clarity):
  1616. .PP
  1617. .Vb 2
  1618. \& openssl idea \-d \e
  1619. \& \-K 000102030405060708090A0B0C0D0E0F \-iv 0102030405060708 <filename
  1620. .Ve
  1621. .PP
  1622. General encryption and decryption function example using \s-1FILE I/O\s0 and \s-1AES128\s0
  1623. with a 128\-bit key:
  1624. .PP
  1625. .Vb 12
  1626. \& int do_crypt(FILE *in, FILE *out, int do_encrypt)
  1627. \& {
  1628. \& /* Allow enough space in output buffer for additional block */
  1629. \& unsigned char inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH];
  1630. \& int inlen, outlen;
  1631. \& EVP_CIPHER_CTX *ctx;
  1632. \& /*
  1633. \& * Bogus key and IV: we\*(Aqd normally set these from
  1634. \& * another source.
  1635. \& */
  1636. \& unsigned char key[] = "0123456789abcdeF";
  1637. \& unsigned char iv[] = "1234567887654321";
  1638. \&
  1639. \& /* Don\*(Aqt set key or IV right away; we want to check lengths */
  1640. \& ctx = EVP_CIPHER_CTX_new();
  1641. \& if (!EVP_CipherInit_ex2(ctx, EVP_aes_128_cbc(), NULL, NULL,
  1642. \& do_encrypt, NULL)) {
  1643. \& /* Error */
  1644. \& EVP_CIPHER_CTX_free(ctx);
  1645. \& return 0;
  1646. \& }
  1647. \& OPENSSL_assert(EVP_CIPHER_CTX_get_key_length(ctx) == 16);
  1648. \& OPENSSL_assert(EVP_CIPHER_CTX_get_iv_length(ctx) == 16);
  1649. \&
  1650. \& /* Now we can set key and IV */
  1651. \& if (!EVP_CipherInit_ex2(ctx, NULL, key, iv, do_encrypt, NULL)) {
  1652. \& /* Error */
  1653. \& EVP_CIPHER_CTX_free(ctx);
  1654. \& return 0;
  1655. \& }
  1656. \&
  1657. \& for (;;) {
  1658. \& inlen = fread(inbuf, 1, 1024, in);
  1659. \& if (inlen <= 0)
  1660. \& break;
  1661. \& if (!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen)) {
  1662. \& /* Error */
  1663. \& EVP_CIPHER_CTX_free(ctx);
  1664. \& return 0;
  1665. \& }
  1666. \& fwrite(outbuf, 1, outlen, out);
  1667. \& }
  1668. \& if (!EVP_CipherFinal_ex(ctx, outbuf, &outlen)) {
  1669. \& /* Error */
  1670. \& EVP_CIPHER_CTX_free(ctx);
  1671. \& return 0;
  1672. \& }
  1673. \& fwrite(outbuf, 1, outlen, out);
  1674. \&
  1675. \& EVP_CIPHER_CTX_free(ctx);
  1676. \& return 1;
  1677. \& }
  1678. .Ve
  1679. .PP
  1680. Encryption using AES-CBC with a 256\-bit key with \*(L"\s-1CS1\*(R"\s0 ciphertext stealing.
  1681. .PP
  1682. .Vb 10
  1683. \& int encrypt(const unsigned char *key, const unsigned char *iv,
  1684. \& const unsigned char *msg, size_t msg_len, unsigned char *out)
  1685. \& {
  1686. \& /*
  1687. \& * This assumes that key size is 32 bytes and the iv is 16 bytes.
  1688. \& * For ciphertext stealing mode the length of the ciphertext "out" will be
  1689. \& * the same size as the plaintext size "msg_len".
  1690. \& * The "msg_len" can be any size >= 16.
  1691. \& */
  1692. \& int ret = 0, encrypt = 1, outlen, len;
  1693. \& EVP_CIPHER_CTX *ctx = NULL;
  1694. \& EVP_CIPHER *cipher = NULL;
  1695. \& OSSL_PARAM params[2];
  1696. \&
  1697. \& ctx = EVP_CIPHER_CTX_new();
  1698. \& cipher = EVP_CIPHER_fetch(NULL, "AES\-256\-CBC\-CTS", NULL);
  1699. \& if (ctx == NULL || cipher == NULL)
  1700. \& goto err;
  1701. \&
  1702. \& /*
  1703. \& * The default is "CS1" so this is not really needed,
  1704. \& * but would be needed to set either "CS2" or "CS3".
  1705. \& */
  1706. \& params[0] = OSSL_PARAM_construct_utf8_string(OSSL_CIPHER_PARAM_CTS_MODE,
  1707. \& "CS1", 0);
  1708. \& params[1] = OSSL_PARAM_construct_end();
  1709. \&
  1710. \& if (!EVP_CipherInit_ex2(ctx, cipher, key, iv, encrypt, params))
  1711. \& goto err;
  1712. \&
  1713. \& /* NOTE: CTS mode does not support multiple calls to EVP_CipherUpdate() */
  1714. \& if (!EVP_CipherUpdate(ctx, out, &outlen, msg, msg_len))
  1715. \& goto err;
  1716. \& if (!EVP_CipherFinal_ex(ctx, out + outlen, &len))
  1717. \& goto err;
  1718. \& ret = 1;
  1719. \& err:
  1720. \& EVP_CIPHER_free(cipher);
  1721. \& EVP_CIPHER_CTX_free(ctx);
  1722. \& return ret;
  1723. \& }
  1724. .Ve
  1725. .SH "SEE ALSO"
  1726. .IX Header "SEE ALSO"
  1727. \&\fBevp\fR\|(7),
  1728. \&\fBproperty\fR\|(7),
  1729. \&\*(L"\s-1ALGORITHM FETCHING\*(R"\s0 in \fBcrypto\fR\|(7),
  1730. \&\fBprovider\-cipher\fR\|(7),
  1731. \&\fBlife_cycle\-cipher\fR\|(7)
  1732. .PP
  1733. Supported ciphers are listed in:
  1734. .PP
  1735. \&\fBEVP_aes_128_gcm\fR\|(3),
  1736. \&\fBEVP_aria_128_gcm\fR\|(3),
  1737. \&\fBEVP_bf_cbc\fR\|(3),
  1738. \&\fBEVP_camellia_128_ecb\fR\|(3),
  1739. \&\fBEVP_cast5_cbc\fR\|(3),
  1740. \&\fBEVP_chacha20\fR\|(3),
  1741. \&\fBEVP_des_cbc\fR\|(3),
  1742. \&\fBEVP_desx_cbc\fR\|(3),
  1743. \&\fBEVP_idea_cbc\fR\|(3),
  1744. \&\fBEVP_rc2_cbc\fR\|(3),
  1745. \&\fBEVP_rc4\fR\|(3),
  1746. \&\fBEVP_rc5_32_12_16_cbc\fR\|(3),
  1747. \&\fBEVP_seed_cbc\fR\|(3),
  1748. \&\fBEVP_sm4_cbc\fR\|(3),
  1749. .SH "HISTORY"
  1750. .IX Header "HISTORY"
  1751. Support for \s-1OCB\s0 mode was added in OpenSSL 1.1.0.
  1752. .PP
  1753. \&\fB\s-1EVP_CIPHER_CTX\s0\fR was made opaque in OpenSSL 1.1.0. As a result,
  1754. \&\fBEVP_CIPHER_CTX_reset()\fR appeared and \fBEVP_CIPHER_CTX_cleanup()\fR
  1755. disappeared. \fBEVP_CIPHER_CTX_init()\fR remains as an alias for
  1756. \&\fBEVP_CIPHER_CTX_reset()\fR.
  1757. .PP
  1758. The \fBEVP_CIPHER_CTX_cipher()\fR function was deprecated in OpenSSL 3.0; use
  1759. \&\fBEVP_CIPHER_CTX_get0_cipher()\fR instead.
  1760. .PP
  1761. The \fBEVP_EncryptInit_ex2()\fR, \fBEVP_DecryptInit_ex2()\fR, \fBEVP_CipherInit_ex2()\fR,
  1762. \&\fBEVP_CIPHER_fetch()\fR, \fBEVP_CIPHER_free()\fR, \fBEVP_CIPHER_up_ref()\fR,
  1763. \&\fBEVP_CIPHER_CTX_get0_cipher()\fR, \fBEVP_CIPHER_CTX_get1_cipher()\fR,
  1764. \&\fBEVP_CIPHER_get_params()\fR, \fBEVP_CIPHER_CTX_set_params()\fR,
  1765. \&\fBEVP_CIPHER_CTX_get_params()\fR, \fBEVP_CIPHER_gettable_params()\fR,
  1766. \&\fBEVP_CIPHER_settable_ctx_params()\fR, \fBEVP_CIPHER_gettable_ctx_params()\fR,
  1767. \&\fBEVP_CIPHER_CTX_settable_params()\fR and \fBEVP_CIPHER_CTX_gettable_params()\fR
  1768. functions were added in 3.0.
  1769. .PP
  1770. The \fBEVP_CIPHER_nid()\fR, \fBEVP_CIPHER_name()\fR, \fBEVP_CIPHER_block_size()\fR,
  1771. \&\fBEVP_CIPHER_key_length()\fR, \fBEVP_CIPHER_iv_length()\fR, \fBEVP_CIPHER_flags()\fR,
  1772. \&\fBEVP_CIPHER_mode()\fR, \fBEVP_CIPHER_type()\fR, \fBEVP_CIPHER_CTX_nid()\fR,
  1773. \&\fBEVP_CIPHER_CTX_block_size()\fR, \fBEVP_CIPHER_CTX_key_length()\fR,
  1774. \&\fBEVP_CIPHER_CTX_iv_length()\fR, \fBEVP_CIPHER_CTX_tag_length()\fR,
  1775. \&\fBEVP_CIPHER_CTX_num()\fR, \fBEVP_CIPHER_CTX_type()\fR, and \fBEVP_CIPHER_CTX_mode()\fR
  1776. functions were renamed to include \f(CW\*(C`get\*(C'\fR or \f(CW\*(C`get0\*(C'\fR in their names in
  1777. OpenSSL 3.0, respectively. The old names are kept as non-deprecated
  1778. alias macros.
  1779. .PP
  1780. The \fBEVP_CIPHER_CTX_encrypting()\fR function was renamed to
  1781. \&\fBEVP_CIPHER_CTX_is_encrypting()\fR in OpenSSL 3.0. The old name is kept as
  1782. non-deprecated alias macro.
  1783. .PP
  1784. The \fBEVP_CIPHER_CTX_flags()\fR macro was deprecated in OpenSSL 1.1.0.
  1785. .PP
  1786. \&\fBEVP_CIPHER_CTX_dup()\fR was added in OpenSSL 3.2.
  1787. .SH "COPYRIGHT"
  1788. .IX Header "COPYRIGHT"
  1789. Copyright 2000\-2024 The OpenSSL Project Authors. All Rights Reserved.
  1790. .PP
  1791. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  1792. this file except in compliance with the License. You can obtain a copy
  1793. in the file \s-1LICENSE\s0 in the source distribution or at
  1794. <https://www.openssl.org/source/license.html>.