EVP_CIPHER_meth_new.3ossl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "EVP_CIPHER_METH_NEW 3ossl"
  58. .TH EVP_CIPHER_METH_NEW 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. EVP_CIPHER_meth_new, EVP_CIPHER_meth_dup, EVP_CIPHER_meth_free,
  65. EVP_CIPHER_meth_set_iv_length, EVP_CIPHER_meth_set_flags,
  66. EVP_CIPHER_meth_set_impl_ctx_size, EVP_CIPHER_meth_set_init,
  67. EVP_CIPHER_meth_set_do_cipher, EVP_CIPHER_meth_set_cleanup,
  68. EVP_CIPHER_meth_set_set_asn1_params, EVP_CIPHER_meth_set_get_asn1_params,
  69. EVP_CIPHER_meth_set_ctrl, EVP_CIPHER_meth_get_init,
  70. EVP_CIPHER_meth_get_do_cipher, EVP_CIPHER_meth_get_cleanup,
  71. EVP_CIPHER_meth_get_set_asn1_params, EVP_CIPHER_meth_get_get_asn1_params,
  72. EVP_CIPHER_meth_get_ctrl
  73. \&\- Routines to build up EVP_CIPHER methods
  74. .SH SYNOPSIS
  75. .IX Header "SYNOPSIS"
  76. .Vb 1
  77. \& #include <openssl/evp.h>
  78. .Ve
  79. .PP
  80. The following functions have been deprecated since OpenSSL 3.0, and can be
  81. hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
  82. see \fBopenssl_user_macros\fR\|(7):
  83. .PP
  84. .Vb 3
  85. \& EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);
  86. \& EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);
  87. \& void EVP_CIPHER_meth_free(EVP_CIPHER *cipher);
  88. \&
  89. \& int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);
  90. \& int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);
  91. \& int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);
  92. \& int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,
  93. \& int (*init)(EVP_CIPHER_CTX *ctx,
  94. \& const unsigned char *key,
  95. \& const unsigned char *iv,
  96. \& int enc));
  97. \& int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,
  98. \& int (*do_cipher)(EVP_CIPHER_CTX *ctx,
  99. \& unsigned char *out,
  100. \& const unsigned char *in,
  101. \& size_t inl));
  102. \& int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,
  103. \& int (*cleanup)(EVP_CIPHER_CTX *));
  104. \& int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,
  105. \& int (*set_asn1_parameters)(EVP_CIPHER_CTX *,
  106. \& ASN1_TYPE *));
  107. \& int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,
  108. \& int (*get_asn1_parameters)(EVP_CIPHER_CTX *,
  109. \& ASN1_TYPE *));
  110. \& int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,
  111. \& int (*ctrl)(EVP_CIPHER_CTX *, int type,
  112. \& int arg, void *ptr));
  113. \&
  114. \& int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
  115. \& const unsigned char *key,
  116. \& const unsigned char *iv,
  117. \& int enc);
  118. \& int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
  119. \& unsigned char *out,
  120. \& const unsigned char *in,
  121. \& size_t inl);
  122. \& int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);
  123. \& int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
  124. \& ASN1_TYPE *);
  125. \& int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
  126. \& ASN1_TYPE *);
  127. \& int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
  128. \& int type, int arg,
  129. \& void *ptr);
  130. .Ve
  131. .SH DESCRIPTION
  132. .IX Header "DESCRIPTION"
  133. All of the functions described on this page are deprecated.
  134. Applications should instead use the OSSL_PROVIDER APIs.
  135. .PP
  136. The \fBEVP_CIPHER\fR type is a structure for symmetric cipher method
  137. implementation.
  138. .PP
  139. \&\fBEVP_CIPHER_meth_new()\fR creates a new \fBEVP_CIPHER\fR structure.
  140. .PP
  141. \&\fBEVP_CIPHER_meth_dup()\fR creates a copy of \fBcipher\fR.
  142. .PP
  143. \&\fBEVP_CIPHER_meth_free()\fR destroys a \fBEVP_CIPHER\fR structure.
  144. If the argument is NULL, nothing is done.
  145. .PP
  146. \&\fBEVP_CIPHER_meth_set_iv_length()\fR sets the length of the IV.
  147. This is only needed when the implemented cipher mode requires it.
  148. .PP
  149. \&\fBEVP_CIPHER_meth_set_flags()\fR sets the flags to describe optional
  150. behaviours in the particular \fBcipher\fR.
  151. With the exception of cipher modes, of which only one may be present,
  152. several flags can be or'd together.
  153. The available flags are:
  154. .IP "EVP_CIPH_STREAM_CIPHER, EVP_CIPH_ECB_MODE EVP_CIPH_CBC_MODE, EVP_CIPH_CFB_MODE, EVP_CIPH_OFB_MODE, EVP_CIPH_CTR_MODE, EVP_CIPH_GCM_MODE, EVP_CIPH_CCM_MODE, EVP_CIPH_XTS_MODE, EVP_CIPH_WRAP_MODE, EVP_CIPH_OCB_MODE, EVP_CIPH_SIV_MODE" 4
  155. .IX Item "EVP_CIPH_STREAM_CIPHER, EVP_CIPH_ECB_MODE EVP_CIPH_CBC_MODE, EVP_CIPH_CFB_MODE, EVP_CIPH_OFB_MODE, EVP_CIPH_CTR_MODE, EVP_CIPH_GCM_MODE, EVP_CIPH_CCM_MODE, EVP_CIPH_XTS_MODE, EVP_CIPH_WRAP_MODE, EVP_CIPH_OCB_MODE, EVP_CIPH_SIV_MODE"
  156. The cipher mode.
  157. .IP EVP_CIPH_VARIABLE_LENGTH 4
  158. .IX Item "EVP_CIPH_VARIABLE_LENGTH"
  159. This cipher is of variable length.
  160. .IP EVP_CIPH_CUSTOM_IV 4
  161. .IX Item "EVP_CIPH_CUSTOM_IV"
  162. Storing and initialising the IV is left entirely to the
  163. implementation.
  164. .IP EVP_CIPH_ALWAYS_CALL_INIT 4
  165. .IX Item "EVP_CIPH_ALWAYS_CALL_INIT"
  166. Set this if the implementation's \fBinit()\fR function should be called even
  167. if \fBkey\fR is \fBNULL\fR.
  168. .IP EVP_CIPH_CTRL_INIT 4
  169. .IX Item "EVP_CIPH_CTRL_INIT"
  170. Set this to have the implementation's \fBctrl()\fR function called with
  171. command code \fBEVP_CTRL_INIT\fR early in its setup.
  172. .IP EVP_CIPH_CUSTOM_KEY_LENGTH 4
  173. .IX Item "EVP_CIPH_CUSTOM_KEY_LENGTH"
  174. Checking and setting the key length after creating the \fBEVP_CIPHER\fR
  175. is left to the implementation.
  176. Whenever someone uses \fBEVP_CIPHER_CTX_set_key_length()\fR on a
  177. \&\fBEVP_CIPHER\fR with this flag set, the implementation's \fBctrl()\fR function
  178. will be called with the control code \fBEVP_CTRL_SET_KEY_LENGTH\fR and
  179. the key length in \fBarg\fR.
  180. .IP EVP_CIPH_NO_PADDING 4
  181. .IX Item "EVP_CIPH_NO_PADDING"
  182. Don't use standard block padding.
  183. .IP EVP_CIPH_RAND_KEY 4
  184. .IX Item "EVP_CIPH_RAND_KEY"
  185. Making a key with random content is left to the implementation.
  186. This is done by calling the implementation's \fBctrl()\fR function with the
  187. control code \fBEVP_CTRL_RAND_KEY\fR and the pointer to the key memory
  188. storage in \fBptr\fR.
  189. .IP EVP_CIPH_CUSTOM_COPY 4
  190. .IX Item "EVP_CIPH_CUSTOM_COPY"
  191. Set this to have the implementation's \fBctrl()\fR function called with
  192. command code \fBEVP_CTRL_COPY\fR at the end of \fBEVP_CIPHER_CTX_copy()\fR.
  193. The intended use is for further things to deal with after the
  194. implementation specific data block has been copied.
  195. The destination \fBEVP_CIPHER_CTX\fR is passed to the control with the
  196. \&\fBptr\fR parameter.
  197. The implementation specific data block is reached with
  198. \&\fBEVP_CIPHER_CTX_get_cipher_data()\fR.
  199. .IP EVP_CIPH_FLAG_DEFAULT_ASN1 4
  200. .IX Item "EVP_CIPH_FLAG_DEFAULT_ASN1"
  201. Use the default EVP routines to pass IV to and from ASN.1.
  202. .IP EVP_CIPH_FLAG_LENGTH_BITS 4
  203. .IX Item "EVP_CIPH_FLAG_LENGTH_BITS"
  204. Signals that the length of the input buffer for encryption /
  205. decryption is to be understood as the number of bits instead of
  206. bytes for this implementation.
  207. This is only useful for CFB1 ciphers.
  208. .IP EVP_CIPH_FLAG_CTS 4
  209. .IX Item "EVP_CIPH_FLAG_CTS"
  210. Indicates that the cipher uses ciphertext stealing. This is currently
  211. used to indicate that the cipher is a one shot that only allows a single call to
  212. \&\fBEVP_CipherUpdate()\fR.
  213. .IP EVP_CIPH_FLAG_CUSTOM_CIPHER 4
  214. .IX Item "EVP_CIPH_FLAG_CUSTOM_CIPHER"
  215. This indicates that the implementation takes care of everything,
  216. including padding, buffering and finalization.
  217. The EVP routines will simply give them control and do nothing more.
  218. .IP EVP_CIPH_FLAG_AEAD_CIPHER 4
  219. .IX Item "EVP_CIPH_FLAG_AEAD_CIPHER"
  220. This indicates that this is an AEAD cipher implementation.
  221. .IP EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 4
  222. .IX Item "EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK"
  223. Allow interleaving of crypto blocks, a particular optimization only applicable
  224. to certain TLS ciphers.
  225. .PP
  226. \&\fBEVP_CIPHER_meth_set_impl_ctx_size()\fR sets the size of the EVP_CIPHER's
  227. implementation context so that it can be automatically allocated.
  228. .PP
  229. \&\fBEVP_CIPHER_meth_set_init()\fR sets the cipher init function for
  230. \&\fBcipher\fR.
  231. The cipher init function is called by \fBEVP_CipherInit()\fR,
  232. \&\fBEVP_CipherInit_ex()\fR, \fBEVP_EncryptInit()\fR, \fBEVP_EncryptInit_ex()\fR,
  233. \&\fBEVP_DecryptInit()\fR, \fBEVP_DecryptInit_ex()\fR.
  234. .PP
  235. \&\fBEVP_CIPHER_meth_set_do_cipher()\fR sets the cipher function for
  236. \&\fBcipher\fR.
  237. The cipher function is called by \fBEVP_CipherUpdate()\fR,
  238. \&\fBEVP_EncryptUpdate()\fR, \fBEVP_DecryptUpdate()\fR, \fBEVP_CipherFinal()\fR,
  239. \&\fBEVP_EncryptFinal()\fR, \fBEVP_EncryptFinal_ex()\fR, \fBEVP_DecryptFinal()\fR and
  240. \&\fBEVP_DecryptFinal_ex()\fR.
  241. .PP
  242. \&\fBEVP_CIPHER_meth_set_cleanup()\fR sets the function for \fBcipher\fR to do
  243. extra cleanup before the method's private data structure is cleaned
  244. out and freed.
  245. Note that the cleanup function is passed a \fBEVP_CIPHER_CTX *\fR, the
  246. private data structure is then available with
  247. \&\fBEVP_CIPHER_CTX_get_cipher_data()\fR.
  248. This cleanup function is called by \fBEVP_CIPHER_CTX_reset()\fR and
  249. \&\fBEVP_CIPHER_CTX_free()\fR.
  250. .PP
  251. \&\fBEVP_CIPHER_meth_set_set_asn1_params()\fR sets the function for \fBcipher\fR
  252. to set the AlgorithmIdentifier "parameter" based on the passed cipher.
  253. This function is called by \fBEVP_CIPHER_param_to_asn1()\fR.
  254. \&\fBEVP_CIPHER_meth_set_get_asn1_params()\fR sets the function for \fBcipher\fR
  255. that sets the cipher parameters based on an ASN.1 AlgorithmIdentifier
  256. "parameter".
  257. Both these functions are needed when there is a need for custom data
  258. (more or other than the cipher IV).
  259. They are called by \fBEVP_CIPHER_param_to_asn1()\fR and
  260. \&\fBEVP_CIPHER_asn1_to_param()\fR respectively if defined.
  261. .PP
  262. \&\fBEVP_CIPHER_meth_set_ctrl()\fR sets the control function for \fBcipher\fR.
  263. .PP
  264. \&\fBEVP_CIPHER_meth_get_init()\fR, \fBEVP_CIPHER_meth_get_do_cipher()\fR,
  265. \&\fBEVP_CIPHER_meth_get_cleanup()\fR, \fBEVP_CIPHER_meth_get_set_asn1_params()\fR,
  266. \&\fBEVP_CIPHER_meth_get_get_asn1_params()\fR and \fBEVP_CIPHER_meth_get_ctrl()\fR
  267. are all used to retrieve the method data given with the
  268. EVP_CIPHER_meth_set_*() functions above.
  269. .SH "RETURN VALUES"
  270. .IX Header "RETURN VALUES"
  271. \&\fBEVP_CIPHER_meth_new()\fR and \fBEVP_CIPHER_meth_dup()\fR return a pointer to a
  272. newly created \fBEVP_CIPHER\fR, or NULL on failure.
  273. All EVP_CIPHER_meth_set_*() functions return 1.
  274. All EVP_CIPHER_meth_get_*() functions return pointers to their
  275. respective \fBcipher\fR function.
  276. .SH "SEE ALSO"
  277. .IX Header "SEE ALSO"
  278. \&\fBEVP_EncryptInit\fR\|(3)
  279. .SH HISTORY
  280. .IX Header "HISTORY"
  281. All of these functions were deprecated in OpenSSL 3.0.
  282. .PP
  283. The functions described here were added in OpenSSL 1.1.0.
  284. The \fBEVP_CIPHER\fR structure created with these functions became reference
  285. counted in OpenSSL 3.0.
  286. .SH COPYRIGHT
  287. .IX Header "COPYRIGHT"
  288. Copyright 2016\-2024 The OpenSSL Project Authors. All Rights Reserved.
  289. .PP
  290. Licensed under the Apache License 2.0 (the "License"). You may not use
  291. this file except in compliance with the License. You can obtain a copy
  292. in the file LICENSE in the source distribution or at
  293. <https://www.openssl.org/source/license.html>.