xref: /openbsd/lib/libcrypto/man/EVP_OpenInit.3 (revision 3cab2bb3)
1.\"	$OpenBSD: EVP_OpenInit.3,v 1.8 2019/06/07 20:46:25 schwarze Exp $
2.\"	OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in
16.\"    the documentation and/or other materials provided with the
17.\"    distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\"    software must display the following acknowledgment:
21.\"    "This product includes software developed by the OpenSSL Project
22.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\"    endorse or promote products derived from this software without
26.\"    prior written permission. For written permission, please contact
27.\"    openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\"    nor may "OpenSSL" appear in their names without prior written
31.\"    permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\"    acknowledgment:
35.\"    "This product includes software developed by the OpenSSL Project
36.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 7 2019 $
52.Dt EVP_OPENINIT 3
53.Os
54.Sh NAME
55.Nm EVP_OpenInit ,
56.Nm EVP_OpenUpdate ,
57.Nm EVP_OpenFinal
58.Nd EVP envelope decryption
59.Sh SYNOPSIS
60.In openssl/evp.h
61.Ft int
62.Fo EVP_OpenInit
63.Fa "EVP_CIPHER_CTX *ctx"
64.Fa "EVP_CIPHER *type"
65.Fa "unsigned char *ek"
66.Fa "int ekl"
67.Fa "unsigned char *iv"
68.Fa "EVP_PKEY *priv"
69.Fc
70.Ft int
71.Fo EVP_OpenUpdate
72.Fa "EVP_CIPHER_CTX *ctx"
73.Fa "unsigned char *out"
74.Fa "int *outl"
75.Fa "unsigned char *in"
76.Fa "int inl"
77.Fc
78.Ft int
79.Fo EVP_OpenFinal
80.Fa "EVP_CIPHER_CTX *ctx"
81.Fa "unsigned char *out"
82.Fa "int *outl"
83.Fc
84.Sh DESCRIPTION
85The EVP envelope routines are a high level interface to envelope
86decryption.
87They decrypt a public key encrypted symmetric key and then decrypt data
88using it.
89.Pp
90.Fn EVP_OpenInit
91initializes a cipher context
92.Fa ctx
93for decryption with cipher
94.Fa type .
95It decrypts the encrypted symmetric key of length
96.Fa ekl
97bytes passed in the
98.Fa ek
99parameter using the private key
100.Fa priv .
101The IV is supplied in the
102.Fa iv
103parameter.
104.Pp
105.Fn EVP_OpenUpdate
106and
107.Fn EVP_OpenFinal
108have exactly the same properties as the
109.Xr EVP_DecryptUpdate 3
110and
111.Xr EVP_DecryptFinal 3
112routines.
113.Pp
114It is possible to call
115.Fn EVP_OpenInit
116twice in the same way as
117.Xr EVP_DecryptInit 3 .
118The first call should have
119.Fa priv
120set to
121.Dv NULL
122and (after setting any cipher parameters) it should be
123called again with
124.Fa type
125set to
126.Dv NULL .
127.Pp
128If the cipher passed in the
129.Fa type
130parameter is a variable length cipher then the key length will be set to
131the value of the recovered key length.
132If the cipher is a fixed length cipher then the recovered key length
133must match the fixed cipher length.
134.Sh RETURN VALUES
135.Fn EVP_OpenInit
136returns 0 on error or a non-zero integer (actually the recovered secret
137key size) if successful.
138.Pp
139.Fn EVP_OpenUpdate
140returns 1 for success or 0 for failure.
141.Pp
142.Fn EVP_OpenFinal
143returns 0 if the decrypt failed or 1 for success.
144.Sh SEE ALSO
145.Xr evp 3 ,
146.Xr EVP_EncryptInit 3 ,
147.Xr EVP_SealInit 3
148.Sh HISTORY
149.Fn EVP_OpenInit ,
150.Fn EVP_OpenUpdate ,
151and
152.Fn EVP_OpenFinal
153first appeared in SSLeay 0.5.1 and have been available since
154.Ox 2.4 .
155