summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2023-08-26 15:01:56 +0000
committerschwarze <>2023-08-26 15:01:56 +0000
commit12a67cd6bb8433b887c58c9683aa26e6e40824ff (patch)
treeb5ea0aa10b741f23cfa362b3cd8b485134d6dc85 /src/lib
parent39b27c985b0966e243210d8660fd6cebbbe1eed8 (diff)
downloadopenbsd-12a67cd6bb8433b887c58c9683aa26e6e40824ff.tar.gz
openbsd-12a67cd6bb8433b887c58c9683aa26e6e40824ff.tar.bz2
openbsd-12a67cd6bb8433b887c58c9683aa26e6e40824ff.zip
write documentation for EVP_CIPHER_CTX_copy(3)
and EVP_CIPHER_CTX_encrypting(3) from scratch
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/EVP_EncryptInit.390
1 files changed, 86 insertions, 4 deletions
diff --git a/src/lib/libcrypto/man/EVP_EncryptInit.3 b/src/lib/libcrypto/man/EVP_EncryptInit.3
index 556b50c925..b6d9080bea 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.46 2023/08/16 13:50:05 schwarze Exp $ 1.\" $OpenBSD: EVP_EncryptInit.3,v 1.47 2023/08/26 15:01:56 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
@@ -6,7 +6,7 @@
6.\" This file is a derived work. 6.\" This file is a derived work.
7.\" The changes are covered by the following Copyright and license: 7.\" The changes are covered by the following Copyright and license:
8.\" 8.\"
9.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 9.\" Copyright (c) 2019, 2023 Ingo Schwarze <schwarze@openbsd.org>
10.\" 10.\"
11.\" Permission to use, copy, modify, and distribute this software for any 11.\" Permission to use, copy, modify, and distribute this software for any
12.\" purpose with or without fee is hereby granted, provided that the above 12.\" purpose with or without fee is hereby granted, provided that the above
@@ -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 16 2023 $ 72.Dd $Mdocdate: August 26 2023 $
73.Dt EVP_ENCRYPTINIT 3 73.Dt EVP_ENCRYPTINIT 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
@@ -78,6 +78,7 @@
78.Nm EVP_CIPHER_CTX_cleanup , 78.Nm EVP_CIPHER_CTX_cleanup ,
79.Nm EVP_CIPHER_CTX_init , 79.Nm EVP_CIPHER_CTX_init ,
80.Nm EVP_CIPHER_CTX_free , 80.Nm EVP_CIPHER_CTX_free ,
81.Nm EVP_CIPHER_CTX_copy ,
81.Nm EVP_EncryptInit_ex , 82.Nm EVP_EncryptInit_ex ,
82.Nm EVP_EncryptUpdate , 83.Nm EVP_EncryptUpdate ,
83.Nm EVP_EncryptFinal_ex , 84.Nm EVP_EncryptFinal_ex ,
@@ -94,6 +95,7 @@
94.Nm EVP_CipherInit , 95.Nm EVP_CipherInit ,
95.Nm EVP_CipherFinal , 96.Nm EVP_CipherFinal ,
96.Nm EVP_Cipher , 97.Nm EVP_Cipher ,
98.Nm EVP_CIPHER_CTX_encrypting ,
97.Nm EVP_CIPHER_CTX_set_flags , 99.Nm EVP_CIPHER_CTX_set_flags ,
98.Nm EVP_CIPHER_CTX_clear_flags , 100.Nm EVP_CIPHER_CTX_clear_flags ,
99.Nm EVP_CIPHER_CTX_test_flags , 101.Nm EVP_CIPHER_CTX_test_flags ,
@@ -170,6 +172,11 @@
170.Fa "EVP_CIPHER_CTX *ctx" 172.Fa "EVP_CIPHER_CTX *ctx"
171.Fc 173.Fc
172.Ft int 174.Ft int
175.Fo EVP_CIPHER_CTX_copy
176.Fa "EVP_CIPHER_CTX *out"
177.Fa "const EVP_CIPHER_CTX *in"
178.Fc
179.Ft int
173.Fo EVP_EncryptInit_ex 180.Fo EVP_EncryptInit_ex
174.Fa "EVP_CIPHER_CTX *ctx" 181.Fa "EVP_CIPHER_CTX *ctx"
175.Fa "const EVP_CIPHER *type" 182.Fa "const EVP_CIPHER *type"
@@ -283,6 +290,10 @@
283.Fa "const unsigned char *in" 290.Fa "const unsigned char *in"
284.Fa "unsigned int inl" 291.Fa "unsigned int inl"
285.Fc 292.Fc
293.Ft int
294.Fo EVP_CIPHER_CTX_encrypting
295.Fa "const EVP_CIPHER_CTX *ctx"
296.Fc
286.Ft void 297.Ft void
287.Fo EVP_CIPHER_CTX_set_flags 298.Fo EVP_CIPHER_CTX_set_flags
288.Fa "EVP_CIPHER_CTX *ctx" 299.Fa "EVP_CIPHER_CTX *ctx"
@@ -465,6 +476,55 @@ is a
465.Dv NULL 476.Dv NULL
466pointer, no action occurs. 477pointer, no action occurs.
467.Pp 478.Pp
479.Fn EVP_CIPHER_CTX_copy
480calls
481.Fn EVP_CIPHER_CTX_reset
482on
483.Fa out
484and copies all the data from
485.Fa in
486to
487.Fa out ,
488except that the
489.Vt EVP_CIPHER
490and
491.Vt ENGINE
492objects used by
493.Fa in
494and any application specific data set with
495.Fn EVP_CIPHER_CTX_set_app_data
496are not copied and
497.Fa out
498will point to the same three objects.
499The algorithm- and implementation-specific cipher data described in
500.Xr EVP_CIPHER_CTX_get_cipher_data 3
501is copied with
502.Xr malloc 3
503and
504.Xr memcpy 3 ,
505i.e. assuming that it does not contain pointers to any sub-objects.
506If the bit
507.Dv EVP_CIPH_CUSTOM_COPY
508has been set with
509.Xr EVP_CIPHER_meth_set_flags 3 ,
510.Fn EVP_CIPHER_CTX_ctrl
511is called at the end with arguments
512.Fa in ,
513.Dv EVP_CTRL_COPY ,
514.No 0 ,
515and
516.Fa out
517such that the cipher implementation can perform further algorithm-
518and implementation-specific initializations after the algorithm-
519and implementation-specific cipher data has been copied.
520Among the cipher algorithms built into the library,
521.Dv EVP_CIPH_CUSTOM_COPY
522and
523.Dv EVP_CTRL_COPY
524are used by some of the ciphers documented in the
525.Xr EVP_aes_256_gcm 3
526manual page.
527.Pp
468.Fn EVP_EncryptInit_ex 528.Fn EVP_EncryptInit_ex
469sets up the cipher context 529sets up the cipher context
470.Fa ctx 530.Fa ctx
@@ -877,6 +937,7 @@ for failure.
877.Pp 937.Pp
878.Fn EVP_CIPHER_CTX_reset , 938.Fn EVP_CIPHER_CTX_reset ,
879.Fn EVP_CIPHER_CTX_cleanup , 939.Fn EVP_CIPHER_CTX_cleanup ,
940.Fn EVP_CIPHER_CTX_copy ,
880.Fn EVP_CIPHER_CTX_get_iv , 941.Fn EVP_CIPHER_CTX_get_iv ,
881.Fn EVP_CIPHER_CTX_set_iv , 942.Fn EVP_CIPHER_CTX_set_iv ,
882.Fn EVP_EncryptInit_ex , 943.Fn EVP_EncryptInit_ex ,
@@ -900,6 +961,12 @@ and
900.Fn EVP_CIPHER_CTX_rand_key 961.Fn EVP_CIPHER_CTX_rand_key
901return 1 for success or 0 for failure. 962return 1 for success or 0 for failure.
902.Pp 963.Pp
964.Fn EVP_CIPHER_CTX_encrypting
965returns 1 if
966.Fa ctx
967is initialized for encryption or 0 otherwise, in which case
968it may be uninitialized or initialized for decryption.
969.Pp
903.Fn EVP_CIPHER_CTX_set_padding 970.Fn EVP_CIPHER_CTX_set_padding
904always returns 1. 971always returns 1.
905.Pp 972.Pp
@@ -1243,6 +1310,7 @@ do_crypt(FILE *in, FILE *out, int do_encrypt)
1243.Xr EVP_aes_128_cbc 3 , 1310.Xr EVP_aes_128_cbc 3 ,
1244.Xr EVP_camellia_128_cbc 3 , 1311.Xr EVP_camellia_128_cbc 3 ,
1245.Xr EVP_chacha20 3 , 1312.Xr EVP_chacha20 3 ,
1313.Xr EVP_CIPHER_CTX_get_cipher_data 3 ,
1246.Xr EVP_des_cbc 3 , 1314.Xr EVP_des_cbc 3 ,
1247.Xr EVP_OpenInit 3 , 1315.Xr EVP_OpenInit 3 ,
1248.Xr EVP_rc4 3 , 1316.Xr EVP_rc4 3 ,
@@ -1355,14 +1423,23 @@ first appeared in OpenSSL 0.9.8b.
1355These functions have been available since 1423These functions have been available since
1356.Ox 4.5 . 1424.Ox 4.5 .
1357.Pp 1425.Pp
1426.Fn EVP_CIPHER_CTX_copy
1427first appeared in OpenSSL 1.0.0
1428and has been available since
1429.Ox 4.9 .
1430.Pp
1358.Fn EVP_CIPHER_CTX_reset 1431.Fn EVP_CIPHER_CTX_reset
1359first appeared in OpenSSL 1.1.0 and has been available since 1432first appeared in OpenSSL 1.1.0 and has been available since
1360.Ox 6.3 . 1433.Ox 6.3 .
1361.Pp 1434.Pp
1435.Fn EVP_CIPHER_CTX_encrypting
1436first appeared in OpenSSL 1.1.0 and has been available since
1437.Ox 6.4 .
1438.Pp
1362.Fn EVP_CIPHER_CTX_get_iv 1439.Fn EVP_CIPHER_CTX_get_iv
1363and 1440and
1364.Fn EVP_CIPHER_CTX_set_iv 1441.Fn EVP_CIPHER_CTX_set_iv
1365first appeared in LibreSSL 2.8.1 and has been available since 1442first appeared in LibreSSL 2.8.1 and have been available since
1366.Ox 6.4 . 1443.Ox 6.4 .
1367.Sh BUGS 1444.Sh BUGS
1368.Dv EVP_MAX_KEY_LENGTH 1445.Dv EVP_MAX_KEY_LENGTH
@@ -1378,3 +1455,8 @@ bytes.
1378The ASN.1 code is incomplete (and sometimes inaccurate). 1455The ASN.1 code is incomplete (and sometimes inaccurate).
1379It has only been tested for certain common S/MIME ciphers 1456It has only been tested for certain common S/MIME ciphers
1380(RC2, DES, triple DES) in CBC mode. 1457(RC2, DES, triple DES) in CBC mode.
1458.Pp
1459.Fn EVP_CIPHER_CTX_copy
1460may already have cleared the data in
1461.Fa out
1462and copied some new data into it even if it fails and returns 0.