diff options
author | schwarze <> | 2023-08-31 17:27:41 +0000 |
---|---|---|
committer | schwarze <> | 2023-08-31 17:27:41 +0000 |
commit | 6adafa1ed9ad28e76b0a4bf339267f23a85c6bcf (patch) | |
tree | ab74fd16ac9e22d139215fe0e871eac001715264 /src/lib/libcrypto/man/EVP_EncryptInit.3 | |
parent | 9939c389dea4955b2a84815d7c821f036c266e0f (diff) | |
download | openbsd-6adafa1ed9ad28e76b0a4bf339267f23a85c6bcf.tar.gz openbsd-6adafa1ed9ad28e76b0a4bf339267f23a85c6bcf.tar.bz2 openbsd-6adafa1ed9ad28e76b0a4bf339267f23a85c6bcf.zip |
Split three new manual pages EVP_CIPHER_nid(3), EVP_CIPHER_CTX_ctrl(3),
and EVP_CIPHER_CTX_set_flags(3) out of the excessively large and
unwieldy EVP_EncryptInit(3). This causes a number of inaccuracies
and gaps to stand out, but i'm not mixing text changes or content
additions into this split.
Using very useful feedback from tb@ regarding what belongs together
and how important the various functions are. I refrained from bothering
him with the complete patch, but he likes the general direction.
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/man/EVP_EncryptInit.3 | 463 |
1 files changed, 15 insertions, 448 deletions
diff --git a/src/lib/libcrypto/man/EVP_EncryptInit.3 b/src/lib/libcrypto/man/EVP_EncryptInit.3 index b6d9080bea..ddec4e7e79 100644 --- a/src/lib/libcrypto/man/EVP_EncryptInit.3 +++ b/src/lib/libcrypto/man/EVP_EncryptInit.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: EVP_EncryptInit.3,v 1.47 2023/08/26 15:01:56 schwarze Exp $ | 1 | .\" $OpenBSD: EVP_EncryptInit.3,v 1.48 2023/08/31 17:27:41 schwarze Exp $ |
2 | .\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 | 2 | .\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 |
3 | .\" EVP_bf_cbc.pod EVP_cast5_cbc.pod EVP_idea_cbc.pod EVP_rc2_cbc.pod | 3 | .\" EVP_bf_cbc.pod EVP_cast5_cbc.pod EVP_idea_cbc.pod EVP_rc2_cbc.pod |
4 | .\" 7c6d372a Nov 20 13:20:01 2018 +0000 | 4 | .\" 7c6d372a Nov 20 13:20:01 2018 +0000 |
@@ -69,7 +69,7 @@ | |||
69 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 69 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
70 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 70 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
71 | .\" | 71 | .\" |
72 | .Dd $Mdocdate: August 26 2023 $ | 72 | .Dd $Mdocdate: August 31 2023 $ |
73 | .Dt EVP_ENCRYPTINIT 3 | 73 | .Dt EVP_ENCRYPTINIT 3 |
74 | .Os | 74 | .Os |
75 | .Sh NAME | 75 | .Sh NAME |
@@ -96,37 +96,10 @@ | |||
96 | .Nm EVP_CipherFinal , | 96 | .Nm EVP_CipherFinal , |
97 | .Nm EVP_Cipher , | 97 | .Nm EVP_Cipher , |
98 | .Nm EVP_CIPHER_CTX_encrypting , | 98 | .Nm EVP_CIPHER_CTX_encrypting , |
99 | .Nm EVP_CIPHER_CTX_set_flags , | ||
100 | .Nm EVP_CIPHER_CTX_clear_flags , | ||
101 | .Nm EVP_CIPHER_CTX_test_flags , | ||
102 | .Nm EVP_CIPHER_CTX_set_padding , | ||
103 | .Nm EVP_CIPHER_CTX_set_key_length , | ||
104 | .Nm EVP_CIPHER_CTX_ctrl , | ||
105 | .Nm EVP_CIPHER_CTX_rand_key , | ||
106 | .Nm EVP_get_cipherbyname , | 99 | .Nm EVP_get_cipherbyname , |
107 | .Nm EVP_get_cipherbynid , | 100 | .Nm EVP_get_cipherbynid , |
108 | .Nm EVP_get_cipherbyobj , | 101 | .Nm EVP_get_cipherbyobj , |
109 | .Nm EVP_CIPHER_nid , | ||
110 | .Nm EVP_CIPHER_block_size , | ||
111 | .Nm EVP_CIPHER_key_length , | ||
112 | .Nm EVP_CIPHER_iv_length , | ||
113 | .Nm EVP_CIPHER_flags , | ||
114 | .Nm EVP_CIPHER_mode , | ||
115 | .Nm EVP_CIPHER_type , | ||
116 | .Nm EVP_CIPHER_CTX_cipher , | 102 | .Nm EVP_CIPHER_CTX_cipher , |
117 | .Nm EVP_CIPHER_CTX_nid , | ||
118 | .Nm EVP_CIPHER_CTX_block_size , | ||
119 | .Nm EVP_CIPHER_CTX_key_length , | ||
120 | .Nm EVP_CIPHER_CTX_iv_length , | ||
121 | .Nm EVP_CIPHER_CTX_get_iv , | ||
122 | .Nm EVP_CIPHER_CTX_set_iv , | ||
123 | .Nm EVP_CIPHER_CTX_get_app_data , | ||
124 | .Nm EVP_CIPHER_CTX_set_app_data , | ||
125 | .Nm EVP_CIPHER_CTX_type , | ||
126 | .Nm EVP_CIPHER_CTX_flags , | ||
127 | .Nm EVP_CIPHER_CTX_mode , | ||
128 | .Nm EVP_CIPHER_param_to_asn1 , | ||
129 | .Nm EVP_CIPHER_asn1_to_param , | ||
130 | .Nm EVP_enc_null , | 103 | .Nm EVP_enc_null , |
131 | .Nm EVP_idea_cbc , | 104 | .Nm EVP_idea_cbc , |
132 | .Nm EVP_idea_ecb , | 105 | .Nm EVP_idea_ecb , |
@@ -294,43 +267,6 @@ | |||
294 | .Fo EVP_CIPHER_CTX_encrypting | 267 | .Fo EVP_CIPHER_CTX_encrypting |
295 | .Fa "const EVP_CIPHER_CTX *ctx" | 268 | .Fa "const EVP_CIPHER_CTX *ctx" |
296 | .Fc | 269 | .Fc |
297 | .Ft void | ||
298 | .Fo EVP_CIPHER_CTX_set_flags | ||
299 | .Fa "EVP_CIPHER_CTX *ctx" | ||
300 | .Fa "int flags" | ||
301 | .Fc | ||
302 | .Ft void | ||
303 | .Fo EVP_CIPHER_CTX_clear_flags | ||
304 | .Fa "EVP_CIPHER_CTX *ctx" | ||
305 | .Fa "int flags" | ||
306 | .Fc | ||
307 | .Ft int | ||
308 | .Fo EVP_CIPHER_CTX_test_flags | ||
309 | .Fa "EVP_CIPHER_CTX *ctx" | ||
310 | .Fa "int flags" | ||
311 | .Fc | ||
312 | .Ft int | ||
313 | .Fo EVP_CIPHER_CTX_set_padding | ||
314 | .Fa "EVP_CIPHER_CTX *x" | ||
315 | .Fa "int padding" | ||
316 | .Fc | ||
317 | .Ft int | ||
318 | .Fo EVP_CIPHER_CTX_set_key_length | ||
319 | .Fa "EVP_CIPHER_CTX *x" | ||
320 | .Fa "int keylen" | ||
321 | .Fc | ||
322 | .Ft int | ||
323 | .Fo EVP_CIPHER_CTX_ctrl | ||
324 | .Fa "EVP_CIPHER_CTX *ctx" | ||
325 | .Fa "int type" | ||
326 | .Fa "int arg" | ||
327 | .Fa "void *ptr" | ||
328 | .Fc | ||
329 | .Ft int | ||
330 | .Fo EVP_CIPHER_CTX_rand_key | ||
331 | .Fa "EVP_CIPHER_CTX *ctx" | ||
332 | .Fa "unsigned char *key" | ||
333 | .Fc | ||
334 | .Ft const EVP_CIPHER * | 270 | .Ft const EVP_CIPHER * |
335 | .Fo EVP_get_cipherbyname | 271 | .Fo EVP_get_cipherbyname |
336 | .Fa "const char *name" | 272 | .Fa "const char *name" |
@@ -343,97 +279,10 @@ | |||
343 | .Fo EVP_get_cipherbyobj | 279 | .Fo EVP_get_cipherbyobj |
344 | .Fa "const ASN1_OBJECT *a" | 280 | .Fa "const ASN1_OBJECT *a" |
345 | .Fc | 281 | .Fc |
346 | .Ft int | ||
347 | .Fo EVP_CIPHER_nid | ||
348 | .Fa "const EVP_CIPHER *e" | ||
349 | .Fc | ||
350 | .Ft int | ||
351 | .Fo EVP_CIPHER_block_size | ||
352 | .Fa "const EVP_CIPHER *e" | ||
353 | .Fc | ||
354 | .Ft int | ||
355 | .Fo EVP_CIPHER_key_length | ||
356 | .Fa "const EVP_CIPHER *e" | ||
357 | .Fc | ||
358 | .Ft int | ||
359 | .Fo EVP_CIPHER_iv_length | ||
360 | .Fa "const EVP_CIPHER *e" | ||
361 | .Fc | ||
362 | .Ft unsigned long | ||
363 | .Fo EVP_CIPHER_flags | ||
364 | .Fa "const EVP_CIPHER *e" | ||
365 | .Fc | ||
366 | .Ft unsigned long | ||
367 | .Fo EVP_CIPHER_mode | ||
368 | .Fa "const EVP_CIPHER *e" | ||
369 | .Fc | ||
370 | .Ft int | ||
371 | .Fo EVP_CIPHER_type | ||
372 | .Fa "const EVP_CIPHER *ctx" | ||
373 | .Fc | ||
374 | .Ft const EVP_CIPHER * | 282 | .Ft const EVP_CIPHER * |
375 | .Fo EVP_CIPHER_CTX_cipher | 283 | .Fo EVP_CIPHER_CTX_cipher |
376 | .Fa "const EVP_CIPHER_CTX *ctx" | 284 | .Fa "const EVP_CIPHER_CTX *ctx" |
377 | .Fc | 285 | .Fc |
378 | .Ft int | ||
379 | .Fo EVP_CIPHER_CTX_nid | ||
380 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
381 | .Fc | ||
382 | .Ft int | ||
383 | .Fo EVP_CIPHER_CTX_block_size | ||
384 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
385 | .Fc | ||
386 | .Ft int | ||
387 | .Fo EVP_CIPHER_CTX_key_length | ||
388 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
389 | .Fc | ||
390 | .Ft int | ||
391 | .Fo EVP_CIPHER_CTX_iv_length | ||
392 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
393 | .Fc | ||
394 | .Ft int | ||
395 | .Fo EVP_CIPHER_CTX_get_iv | ||
396 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
397 | .Fa "unsigned char *iv" | ||
398 | .Fa "size_t len" | ||
399 | .Fc | ||
400 | .Ft int | ||
401 | .Fo EVP_CIPHER_CTX_set_iv | ||
402 | .Fa "EVP_CIPHER_CTX *ctx" | ||
403 | .Fa "const unsigned char *iv" | ||
404 | .Fa "size_t len" | ||
405 | .Fc | ||
406 | .Ft void * | ||
407 | .Fo EVP_CIPHER_CTX_get_app_data | ||
408 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
409 | .Fc | ||
410 | .Ft void | ||
411 | .Fo EVP_CIPHER_CTX_set_app_data | ||
412 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
413 | .Fa "void *data" | ||
414 | .Fc | ||
415 | .Ft int | ||
416 | .Fo EVP_CIPHER_CTX_type | ||
417 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
418 | .Fc | ||
419 | .Ft unsigned long | ||
420 | .Fo EVP_CIPHER_CTX_flags | ||
421 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
422 | .Fc | ||
423 | .Ft unsigned long | ||
424 | .Fo EVP_CIPHER_CTX_mode | ||
425 | .Fa "const EVP_CIPHER_CTX *ctx" | ||
426 | .Fc | ||
427 | .Ft int | ||
428 | .Fo EVP_CIPHER_param_to_asn1 | ||
429 | .Fa "EVP_CIPHER_CTX *c" | ||
430 | .Fa "ASN1_TYPE *type" | ||
431 | .Fc | ||
432 | .Ft int | ||
433 | .Fo EVP_CIPHER_asn1_to_param | ||
434 | .Fa "EVP_CIPHER_CTX *c" | ||
435 | .Fa "ASN1_TYPE *type" | ||
436 | .Fc | ||
437 | .Sh DESCRIPTION | 286 | .Sh DESCRIPTION |
438 | The EVP cipher routines are a high level interface to certain symmetric | 287 | The EVP cipher routines are a high level interface to certain symmetric |
439 | ciphers. | 288 | ciphers. |
@@ -492,7 +341,7 @@ and | |||
492 | objects used by | 341 | objects used by |
493 | .Fa in | 342 | .Fa in |
494 | and any application specific data set with | 343 | and any application specific data set with |
495 | .Fn EVP_CIPHER_CTX_set_app_data | 344 | .Xr EVP_CIPHER_CTX_set_app_data 3 |
496 | are not copied and | 345 | are not copied and |
497 | .Fa out | 346 | .Fa out |
498 | will point to the same three objects. | 347 | will point to the same three objects. |
@@ -507,7 +356,7 @@ If the bit | |||
507 | .Dv EVP_CIPH_CUSTOM_COPY | 356 | .Dv EVP_CIPH_CUSTOM_COPY |
508 | has been set with | 357 | has been set with |
509 | .Xr EVP_CIPHER_meth_set_flags 3 , | 358 | .Xr EVP_CIPHER_meth_set_flags 3 , |
510 | .Fn EVP_CIPHER_CTX_ctrl | 359 | .Xr EVP_CIPHER_CTX_ctrl 3 |
511 | is called at the end with arguments | 360 | is called at the end with arguments |
512 | .Fa in , | 361 | .Fa in , |
513 | .Dv EVP_CTRL_COPY , | 362 | .Dv EVP_CTRL_COPY , |
@@ -690,123 +539,6 @@ structure when passed a cipher name, a NID or an | |||
690 | .Vt ASN1_OBJECT | 539 | .Vt ASN1_OBJECT |
691 | structure. | 540 | structure. |
692 | .Pp | 541 | .Pp |
693 | .Fn EVP_CIPHER_nid | ||
694 | and | ||
695 | .Fn EVP_CIPHER_CTX_nid | ||
696 | return the NID of a cipher when passed an | ||
697 | .Vt EVP_CIPHER | ||
698 | or | ||
699 | .Vt EVP_CIPHER_CTX | ||
700 | structure. | ||
701 | The actual NID value is an internal value which may not have a | ||
702 | corresponding OBJECT IDENTIFIER. | ||
703 | .Pp | ||
704 | .Fn EVP_CIPHER_CTX_set_flags | ||
705 | enables the given | ||
706 | .Fa flags | ||
707 | in | ||
708 | .Fa ctx . | ||
709 | .Fn EVP_CIPHER_CTX_clear_flags | ||
710 | disables the given | ||
711 | .Fa flags | ||
712 | in | ||
713 | .Fa ctx . | ||
714 | .Fn EVP_CIPHER_CTX_test_flags | ||
715 | checks whether any of the given | ||
716 | .Fa flags | ||
717 | are currently set in | ||
718 | .Fa ctx , | ||
719 | returning the subset of the | ||
720 | .Fa flags | ||
721 | that are set, or 0 if none of them are set. | ||
722 | Currently, the only supported cipher context flag is | ||
723 | .Dv EVP_CIPHER_CTX_FLAG_WRAP_ALLOW ; | ||
724 | see | ||
725 | .Xr EVP_aes_128_wrap 3 | ||
726 | for details. | ||
727 | .Pp | ||
728 | .Fn EVP_CIPHER_CTX_set_padding | ||
729 | enables or disables padding. | ||
730 | This function should be called after the context is set up for | ||
731 | encryption or decryption with | ||
732 | .Fn EVP_EncryptInit_ex , | ||
733 | .Fn EVP_DecryptInit_ex , | ||
734 | or | ||
735 | .Fn EVP_CipherInit_ex . | ||
736 | By default encryption operations are padded using standard block padding | ||
737 | and the padding is checked and removed when decrypting. | ||
738 | If the | ||
739 | .Fa padding | ||
740 | parameter is zero, then no padding is performed, the total amount of data | ||
741 | encrypted or decrypted must then be a multiple of the block size or an | ||
742 | error will occur. | ||
743 | .Pp | ||
744 | .Fn EVP_CIPHER_key_length | ||
745 | and | ||
746 | .Fn EVP_CIPHER_CTX_key_length | ||
747 | return the key length of a cipher when passed an | ||
748 | .Vt EVP_CIPHER | ||
749 | or | ||
750 | .Vt EVP_CIPHER_CTX | ||
751 | structure. | ||
752 | The constant | ||
753 | .Dv EVP_MAX_KEY_LENGTH | ||
754 | is the maximum key length for all ciphers. | ||
755 | Note: although | ||
756 | .Fn EVP_CIPHER_key_length | ||
757 | is fixed for a given cipher, the value of | ||
758 | .Fn EVP_CIPHER_CTX_key_length | ||
759 | may be different for variable key length ciphers. | ||
760 | .Pp | ||
761 | .Fn EVP_CIPHER_CTX_set_key_length | ||
762 | sets the key length of the cipher ctx. | ||
763 | If the cipher is a fixed length cipher, then attempting to set the key | ||
764 | length to any value other than the fixed value is an error. | ||
765 | .Pp | ||
766 | .Fn EVP_CIPHER_iv_length | ||
767 | and | ||
768 | .Fn EVP_CIPHER_CTX_iv_length | ||
769 | return the IV length of a cipher when passed an | ||
770 | .Vt EVP_CIPHER | ||
771 | or | ||
772 | .Vt EVP_CIPHER_CTX . | ||
773 | It will return zero if the cipher does not use an IV. | ||
774 | The constant | ||
775 | .Dv EVP_MAX_IV_LENGTH | ||
776 | is the maximum IV length for all ciphers. | ||
777 | .Pp | ||
778 | .Fn EVP_CIPHER_CTX_get_iv | ||
779 | and | ||
780 | .Fn EVP_CIPHER_CTX_set_iv | ||
781 | will respectively retrieve and set the IV for an | ||
782 | .Vt EVP_CIPHER_CTX . | ||
783 | In both cases, the specified IV length must exactly equal the expected | ||
784 | IV length for the context as returned by | ||
785 | .Fn EVP_CIPHER_CTX_iv_length . | ||
786 | .Pp | ||
787 | .Fn EVP_CIPHER_block_size | ||
788 | and | ||
789 | .Fn EVP_CIPHER_CTX_block_size | ||
790 | return the block size of a cipher when passed an | ||
791 | .Vt EVP_CIPHER | ||
792 | or | ||
793 | .Vt EVP_CIPHER_CTX | ||
794 | structure. | ||
795 | The constant | ||
796 | .Dv EVP_MAX_BLOCK_LENGTH | ||
797 | is also the maximum block length for all ciphers. | ||
798 | .Pp | ||
799 | .Fn EVP_CIPHER_type | ||
800 | and | ||
801 | .Fn EVP_CIPHER_CTX_type | ||
802 | return the type of the passed cipher or context. | ||
803 | This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it | ||
804 | ignores the cipher parameters and 40-bit RC2 and 128-bit RC2 have the | ||
805 | same NID. | ||
806 | If the cipher does not have an object identifier or does not | ||
807 | have ASN.1 support, this function will return | ||
808 | .Dv NID_undef . | ||
809 | .Pp | ||
810 | .Fn EVP_CIPHER_CTX_cipher | 542 | .Fn EVP_CIPHER_CTX_cipher |
811 | returns the | 543 | returns the |
812 | .Vt EVP_CIPHER | 544 | .Vt EVP_CIPHER |
@@ -814,72 +546,6 @@ structure when passed an | |||
814 | .Vt EVP_CIPHER_CTX | 546 | .Vt EVP_CIPHER_CTX |
815 | structure. | 547 | structure. |
816 | .Pp | 548 | .Pp |
817 | .Fn EVP_CIPHER_mode | ||
818 | and | ||
819 | .Fn EVP_CIPHER_CTX_mode | ||
820 | return the block cipher mode: | ||
821 | .Dv EVP_CIPH_ECB_MODE , | ||
822 | .Dv EVP_CIPH_CBC_MODE , | ||
823 | .Dv EVP_CIPH_CFB_MODE , | ||
824 | .Dv EVP_CIPH_OFB_MODE , | ||
825 | .Dv EVP_CIPH_CTR_MODE , | ||
826 | or | ||
827 | .Dv EVP_CIPH_XTS_MODE . | ||
828 | If the cipher is a stream cipher then | ||
829 | .Dv EVP_CIPH_STREAM_CIPHER | ||
830 | is returned. | ||
831 | .Pp | ||
832 | .Fn EVP_CIPHER_param_to_asn1 | ||
833 | sets the ASN.1 | ||
834 | .Vt AlgorithmIdentifier | ||
835 | parameter based on the passed cipher. | ||
836 | This will typically include any parameters and an IV. | ||
837 | The cipher IV (if any) must be set when this call is made. | ||
838 | This call should be made before the cipher is actually "used" (before any | ||
839 | .Fn EVP_EncryptUpdate | ||
840 | or | ||
841 | .Fn EVP_DecryptUpdate | ||
842 | calls, for example). | ||
843 | This function may fail if the cipher does not have any ASN.1 support. | ||
844 | .Pp | ||
845 | .Fn EVP_CIPHER_asn1_to_param | ||
846 | sets the cipher parameters based on an ASN.1 | ||
847 | .Vt AlgorithmIdentifier | ||
848 | parameter. | ||
849 | The precise effect depends on the cipher. | ||
850 | In the case of RC2, for example, it will set the IV and effective | ||
851 | key length. | ||
852 | This function should be called after the base cipher type is set but | ||
853 | before the key is set. | ||
854 | For example | ||
855 | .Fn EVP_CipherInit | ||
856 | will be called with the IV and key set to | ||
857 | .Dv NULL , | ||
858 | .Fn EVP_CIPHER_asn1_to_param | ||
859 | will be called and finally | ||
860 | .Fn EVP_CipherInit | ||
861 | again with all parameters except the key set to | ||
862 | .Dv NULL . | ||
863 | It is possible for this function to fail if the cipher does not | ||
864 | have any ASN.1 support or the parameters cannot be set (for example | ||
865 | the RC2 effective key length is not supported). | ||
866 | .Pp | ||
867 | .Fn EVP_CIPHER_CTX_ctrl | ||
868 | allows various cipher specific parameters to be determined and set. | ||
869 | Currently only the RC2 effective key length can be set. | ||
870 | .Pp | ||
871 | .Fn EVP_CIPHER_CTX_rand_key | ||
872 | generates a random key of the appropriate length based on the cipher | ||
873 | context. | ||
874 | The | ||
875 | .Vt EVP_CIPHER | ||
876 | can provide its own random key generation routine to support keys | ||
877 | of a specific form. | ||
878 | The | ||
879 | .Fa key | ||
880 | argument must point to a buffer at least as big as the value returned by | ||
881 | .Fn EVP_CIPHER_CTX_key_length . | ||
882 | .Pp | ||
883 | Where possible the EVP interface to symmetric ciphers should be | 549 | Where possible the EVP interface to symmetric ciphers should be |
884 | used in preference to the low level interfaces. | 550 | used in preference to the low level interfaces. |
885 | This is because the code then becomes transparent to the cipher used and | 551 | This is because the code then becomes transparent to the cipher used and |
@@ -938,8 +604,6 @@ for failure. | |||
938 | .Fn EVP_CIPHER_CTX_reset , | 604 | .Fn EVP_CIPHER_CTX_reset , |
939 | .Fn EVP_CIPHER_CTX_cleanup , | 605 | .Fn EVP_CIPHER_CTX_cleanup , |
940 | .Fn EVP_CIPHER_CTX_copy , | 606 | .Fn EVP_CIPHER_CTX_copy , |
941 | .Fn EVP_CIPHER_CTX_get_iv , | ||
942 | .Fn EVP_CIPHER_CTX_set_iv , | ||
943 | .Fn EVP_EncryptInit_ex , | 607 | .Fn EVP_EncryptInit_ex , |
944 | .Fn EVP_EncryptUpdate , | 608 | .Fn EVP_EncryptUpdate , |
945 | .Fn EVP_EncryptFinal_ex , | 609 | .Fn EVP_EncryptFinal_ex , |
@@ -955,10 +619,8 @@ for failure. | |||
955 | .Fn EVP_DecryptFinal , | 619 | .Fn EVP_DecryptFinal , |
956 | .Fn EVP_CipherInit , | 620 | .Fn EVP_CipherInit , |
957 | .Fn EVP_CipherFinal , | 621 | .Fn EVP_CipherFinal , |
958 | .Fn EVP_Cipher , | ||
959 | .Fn EVP_CIPHER_CTX_set_key_length , | ||
960 | and | 622 | and |
961 | .Fn EVP_CIPHER_CTX_rand_key | 623 | .Fn EVP_Cipher |
962 | return 1 for success or 0 for failure. | 624 | return 1 for success or 0 for failure. |
963 | .Pp | 625 | .Pp |
964 | .Fn EVP_CIPHER_CTX_encrypting | 626 | .Fn EVP_CIPHER_CTX_encrypting |
@@ -967,18 +629,6 @@ returns 1 if | |||
967 | is initialized for encryption or 0 otherwise, in which case | 629 | is initialized for encryption or 0 otherwise, in which case |
968 | it may be uninitialized or initialized for decryption. | 630 | it may be uninitialized or initialized for decryption. |
969 | .Pp | 631 | .Pp |
970 | .Fn EVP_CIPHER_CTX_set_padding | ||
971 | always returns 1. | ||
972 | .Pp | ||
973 | .Fn EVP_CIPHER_CTX_ctrl | ||
974 | usually returns 1 for success, 0 for failure, or \-1 if the | ||
975 | .Fa type | ||
976 | is not supported by the | ||
977 | .Fa ctx , | ||
978 | but there may be exceptions for some | ||
979 | .Fa type | ||
980 | arguments. | ||
981 | .Pp | ||
982 | .Fn EVP_get_cipherbyname , | 632 | .Fn EVP_get_cipherbyname , |
983 | .Fn EVP_get_cipherbynid , | 633 | .Fn EVP_get_cipherbynid , |
984 | and | 634 | and |
@@ -989,43 +639,10 @@ structure or | |||
989 | .Dv NULL | 639 | .Dv NULL |
990 | on error. | 640 | on error. |
991 | .Pp | 641 | .Pp |
992 | .Fn EVP_CIPHER_nid | ||
993 | and | ||
994 | .Fn EVP_CIPHER_CTX_nid | ||
995 | return a NID. | ||
996 | .Pp | ||
997 | .Fn EVP_CIPHER_block_size | ||
998 | and | ||
999 | .Fn EVP_CIPHER_CTX_block_size | ||
1000 | return the block size. | ||
1001 | .Pp | ||
1002 | .Fn EVP_CIPHER_key_length | ||
1003 | and | ||
1004 | .Fn EVP_CIPHER_CTX_key_length | ||
1005 | return the key length. | ||
1006 | .Pp | ||
1007 | .Fn EVP_CIPHER_iv_length | ||
1008 | and | ||
1009 | .Fn EVP_CIPHER_CTX_iv_length | ||
1010 | return the IV length or zero if the cipher does not use an IV. | ||
1011 | .Pp | ||
1012 | .Fn EVP_CIPHER_type | ||
1013 | and | ||
1014 | .Fn EVP_CIPHER_CTX_type | ||
1015 | return the NID of the cipher's OBJECT IDENTIFIER or | ||
1016 | .Dv NID_undef | ||
1017 | if it has no defined OBJECT IDENTIFIER. | ||
1018 | .Pp | ||
1019 | .Fn EVP_CIPHER_CTX_cipher | 642 | .Fn EVP_CIPHER_CTX_cipher |
1020 | returns an | 643 | returns an |
1021 | .Vt EVP_CIPHER | 644 | .Vt EVP_CIPHER |
1022 | structure. | 645 | structure. |
1023 | .Pp | ||
1024 | .Fn EVP_CIPHER_param_to_asn1 | ||
1025 | and | ||
1026 | .Fn EVP_CIPHER_asn1_to_param | ||
1027 | return greater than zero for success and zero or a negative number | ||
1028 | for failure. | ||
1029 | .Sh CIPHER LISTING | 646 | .Sh CIPHER LISTING |
1030 | All algorithms have a fixed key length unless otherwise stated. | 647 | All algorithms have a fixed key length unless otherwise stated. |
1031 | .Bl -tag -width Ds | 648 | .Bl -tag -width Ds |
@@ -1064,9 +681,9 @@ RC2 algorithm in CBC mode with a default key length and effective key | |||
1064 | length of 40 and 64 bits. | 681 | length of 40 and 64 bits. |
1065 | These are obsolete and new code should use | 682 | These are obsolete and new code should use |
1066 | .Fn EVP_rc2_cbc , | 683 | .Fn EVP_rc2_cbc , |
1067 | .Fn EVP_CIPHER_CTX_set_key_length , | 684 | .Xr EVP_CIPHER_CTX_set_key_length 3 , |
1068 | and | 685 | and |
1069 | .Fn EVP_CIPHER_CTX_ctrl | 686 | .Xr EVP_CIPHER_CTX_ctrl 3 |
1070 | to set the key length and effective key length. | 687 | to set the key length and effective key length. |
1071 | .It Xo | 688 | .It Xo |
1072 | .Fn EVP_bf_cbc , | 689 | .Fn EVP_bf_cbc , |
@@ -1310,7 +927,10 @@ do_crypt(FILE *in, FILE *out, int do_encrypt) | |||
1310 | .Xr EVP_aes_128_cbc 3 , | 927 | .Xr EVP_aes_128_cbc 3 , |
1311 | .Xr EVP_camellia_128_cbc 3 , | 928 | .Xr EVP_camellia_128_cbc 3 , |
1312 | .Xr EVP_chacha20 3 , | 929 | .Xr EVP_chacha20 3 , |
930 | .Xr EVP_CIPHER_CTX_ctrl 3 , | ||
1313 | .Xr EVP_CIPHER_CTX_get_cipher_data 3 , | 931 | .Xr EVP_CIPHER_CTX_get_cipher_data 3 , |
932 | .Xr EVP_CIPHER_CTX_set_flags 3 , | ||
933 | .Xr EVP_CIPHER_nid 3 , | ||
1314 | .Xr EVP_des_cbc 3 , | 934 | .Xr EVP_des_cbc 3 , |
1315 | .Xr EVP_OpenInit 3 , | 935 | .Xr EVP_OpenInit 3 , |
1316 | .Xr EVP_rc4 3 , | 936 | .Xr EVP_rc4 3 , |
@@ -1339,16 +959,7 @@ first appeared in SSLeay 0.5.1. | |||
1339 | and | 959 | and |
1340 | .Fn EVP_rc2_ofb | 960 | .Fn EVP_rc2_ofb |
1341 | first appeared in SSLeay 0.5.2. | 961 | first appeared in SSLeay 0.5.2. |
1342 | .Fn EVP_Cipher , | 962 | .Fn EVP_Cipher |
1343 | .Fn EVP_CIPHER_block_size , | ||
1344 | .Fn EVP_CIPHER_key_length , | ||
1345 | .Fn EVP_CIPHER_iv_length , | ||
1346 | .Fn EVP_CIPHER_type , | ||
1347 | .Fn EVP_CIPHER_CTX_block_size , | ||
1348 | .Fn EVP_CIPHER_CTX_key_length , | ||
1349 | .Fn EVP_CIPHER_CTX_iv_length , | ||
1350 | and | ||
1351 | .Fn EVP_CIPHER_CTX_type | ||
1352 | first appeared in SSLeay 0.6.5. | 963 | first appeared in SSLeay 0.6.5. |
1353 | .Fn EVP_bf_cbc , | 964 | .Fn EVP_bf_cbc , |
1354 | .Fn EVP_bf_ecb , | 965 | .Fn EVP_bf_ecb , |
@@ -1358,20 +969,13 @@ and | |||
1358 | first appeared in SSLeay 0.6.6. | 969 | first appeared in SSLeay 0.6.6. |
1359 | .Fn EVP_CIPHER_CTX_cleanup , | 970 | .Fn EVP_CIPHER_CTX_cleanup , |
1360 | .Fn EVP_get_cipherbyobj , | 971 | .Fn EVP_get_cipherbyobj , |
1361 | .Fn EVP_CIPHER_nid , | ||
1362 | .Fn EVP_CIPHER_CTX_cipher , | 972 | .Fn EVP_CIPHER_CTX_cipher , |
1363 | .Fn EVP_CIPHER_CTX_nid , | ||
1364 | .Fn EVP_CIPHER_CTX_get_app_data , | ||
1365 | .Fn EVP_CIPHER_CTX_set_app_data , | ||
1366 | and | 973 | and |
1367 | .Fn EVP_enc_null | 974 | .Fn EVP_enc_null |
1368 | first appeared in SSLeay 0.8.0. | 975 | first appeared in SSLeay 0.8.0. |
1369 | .Fn EVP_get_cipherbynid | 976 | .Fn EVP_get_cipherbynid |
1370 | first appeared in SSLeay 0.8.1. | 977 | first appeared in SSLeay 0.8.1. |
1371 | .Fn EVP_CIPHER_CTX_init , | 978 | .Fn EVP_CIPHER_CTX_init |
1372 | .Fn EVP_CIPHER_param_to_asn1 , | ||
1373 | and | ||
1374 | .Fn EVP_CIPHER_asn1_to_param | ||
1375 | first appeared in SSLeay 0.9.0. | 979 | first appeared in SSLeay 0.9.0. |
1376 | All these functions have been available since | 980 | All these functions have been available since |
1377 | .Ox 2.4 . | 981 | .Ox 2.4 . |
@@ -1379,30 +983,16 @@ All these functions have been available since | |||
1379 | .Fn EVP_rc2_40_cbc | 983 | .Fn EVP_rc2_40_cbc |
1380 | and | 984 | and |
1381 | .Fn EVP_rc2_64_cbc | 985 | .Fn EVP_rc2_64_cbc |
1382 | first appeared in SSL_eay 0.9.1. | 986 | first appeared in SSLeay 0.9.1 and have been available since |
1383 | .Fn EVP_CIPHER_CTX_type | ||
1384 | first appeared in OpenSSL 0.9.3. | ||
1385 | These functions have been available since | ||
1386 | .Ox 2.6 . | 987 | .Ox 2.6 . |
1387 | .Pp | 988 | .Pp |
1388 | .Fn EVP_CIPHER_CTX_set_key_length , | ||
1389 | .Fn EVP_CIPHER_CTX_ctrl , | ||
1390 | .Fn EVP_CIPHER_flags , | ||
1391 | .Fn EVP_CIPHER_mode , | ||
1392 | .Fn EVP_CIPHER_CTX_flags , | ||
1393 | and | ||
1394 | .Fn EVP_CIPHER_CTX_mode | ||
1395 | first appeared in OpenSSL 0.9.6 and have been available since | ||
1396 | .Ox 2.9 . | ||
1397 | .Pp | ||
1398 | .Fn EVP_EncryptInit_ex , | 989 | .Fn EVP_EncryptInit_ex , |
1399 | .Fn EVP_EncryptFinal_ex , | 990 | .Fn EVP_EncryptFinal_ex , |
1400 | .Fn EVP_DecryptInit_ex , | 991 | .Fn EVP_DecryptInit_ex , |
1401 | .Fn EVP_DecryptFinal_ex , | 992 | .Fn EVP_DecryptFinal_ex , |
1402 | .Fn EVP_CipherInit_ex , | 993 | .Fn EVP_CipherInit_ex , |
1403 | .Fn EVP_CipherFinal_ex , | ||
1404 | and | 994 | and |
1405 | .Fn EVP_CIPHER_CTX_set_padding | 995 | .Fn EVP_CipherFinal_ex |
1406 | first appeared in OpenSSL 0.9.7 and have been available since | 996 | first appeared in OpenSSL 0.9.7 and have been available since |
1407 | .Ox 3.2 . | 997 | .Ox 3.2 . |
1408 | .Pp | 998 | .Pp |
@@ -1414,13 +1004,10 @@ and | |||
1414 | first appeared in OpenSSL 0.9.7e and have been available since | 1004 | first appeared in OpenSSL 0.9.7e and have been available since |
1415 | .Ox 3.8 . | 1005 | .Ox 3.8 . |
1416 | .Pp | 1006 | .Pp |
1417 | .Fn EVP_CIPHER_CTX_rand_key | ||
1418 | first appeared in OpenSSL 0.9.8. | ||
1419 | .Fn EVP_CIPHER_CTX_new | 1007 | .Fn EVP_CIPHER_CTX_new |
1420 | and | 1008 | and |
1421 | .Fn EVP_CIPHER_CTX_free | 1009 | .Fn EVP_CIPHER_CTX_free |
1422 | first appeared in OpenSSL 0.9.8b. | 1010 | first appeared in OpenSSL 0.9.8b and have been available since |
1423 | These functions have been available since | ||
1424 | .Ox 4.5 . | 1011 | .Ox 4.5 . |
1425 | .Pp | 1012 | .Pp |
1426 | .Fn EVP_CIPHER_CTX_copy | 1013 | .Fn EVP_CIPHER_CTX_copy |
@@ -1435,27 +1022,7 @@ first appeared in OpenSSL 1.1.0 and has been available since | |||
1435 | .Fn EVP_CIPHER_CTX_encrypting | 1022 | .Fn EVP_CIPHER_CTX_encrypting |
1436 | first appeared in OpenSSL 1.1.0 and has been available since | 1023 | first appeared in OpenSSL 1.1.0 and has been available since |
1437 | .Ox 6.4 . | 1024 | .Ox 6.4 . |
1438 | .Pp | ||
1439 | .Fn EVP_CIPHER_CTX_get_iv | ||
1440 | and | ||
1441 | .Fn EVP_CIPHER_CTX_set_iv | ||
1442 | first appeared in LibreSSL 2.8.1 and have been available since | ||
1443 | .Ox 6.4 . | ||
1444 | .Sh BUGS | 1025 | .Sh BUGS |
1445 | .Dv EVP_MAX_KEY_LENGTH | ||
1446 | and | ||
1447 | .Dv EVP_MAX_IV_LENGTH | ||
1448 | only refer to the internal ciphers with default key lengths. | ||
1449 | If custom ciphers exceed these values, the results are unpredictable. | ||
1450 | This is because it has become standard practice to define a generic key | ||
1451 | as a fixed unsigned char array containing | ||
1452 | .Dv EVP_MAX_KEY_LENGTH | ||
1453 | bytes. | ||
1454 | .Pp | ||
1455 | The ASN.1 code is incomplete (and sometimes inaccurate). | ||
1456 | It has only been tested for certain common S/MIME ciphers | ||
1457 | (RC2, DES, triple DES) in CBC mode. | ||
1458 | .Pp | ||
1459 | .Fn EVP_CIPHER_CTX_copy | 1026 | .Fn EVP_CIPHER_CTX_copy |
1460 | may already have cleared the data in | 1027 | may already have cleared the data in |
1461 | .Fa out | 1028 | .Fa out |