openssl-prebuild/linux_amd64/ssl/share/doc/openssl/html/man3/EVP_SealInit.html

124 lines
5.0 KiB
HTML
Executable File

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>EVP_SealInit</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#return_values">RETURN VALUES</a></li>
<li><a href="#notes">NOTES</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#copyright">COPYRIGHT</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<hr />
<h1><a name="name">NAME</a></h1>
<p>EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
#include &lt;openssl/evp.h&gt;</pre>
<pre>
int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
unsigned char **ek, int *ekl, unsigned char *iv,
EVP_PKEY **pubk, int npubk);
int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
int *outl, unsigned char *in, int inl);
int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The EVP envelope routines are a high level interface to envelope
encryption. They generate a random key and IV (if required) then
&quot;envelope&quot; it by using public key encryption. Data can then be
encrypted using this key.</p>
<p><code>EVP_SealInit()</code> initializes a cipher context <strong>ctx</strong> for encryption
with cipher <strong>type</strong> using a random secret key and IV. <strong>type</strong> is normally
supplied by a function such as EVP_aes_256_cbc(). The secret key is encrypted
using one or more public keys, this allows the same encrypted data to be
decrypted using any of the corresponding private keys. <strong>ek</strong> is an array of
buffers where the public key encrypted secret key will be written, each buffer
must contain enough room for the corresponding encrypted key: that is
<strong>ek[i]</strong> must have room for <strong>EVP_PKEY_size(pubk[i])</strong> bytes. The actual
size of each encrypted secret key is written to the array <strong>ekl</strong>. <strong>pubk</strong> is
an array of <strong>npubk</strong> public keys.</p>
<p>The <strong>iv</strong> parameter is a buffer where the generated IV is written to. It must
contain enough room for the corresponding cipher's IV, as determined by (for
example) EVP_CIPHER_iv_length(type).</p>
<p>If the cipher does not require an IV then the <strong>iv</strong> parameter is ignored
and can be <strong>NULL</strong>.</p>
<p><code>EVP_SealUpdate()</code> and <code>EVP_SealFinal()</code> have exactly the same properties
as the <code>EVP_EncryptUpdate()</code> and <code>EVP_EncryptFinal()</code> routines, as
documented on the <em>EVP_EncryptInit(3)</em> manual
page.</p>
<p>
</p>
<hr />
<h1><a name="return_values">RETURN VALUES</a></h1>
<p><code>EVP_SealInit()</code> returns 0 on error or <strong>npubk</strong> if successful.</p>
<p><code>EVP_SealUpdate()</code> and <code>EVP_SealFinal()</code> return 1 for success and 0 for
failure.</p>
<p>
</p>
<hr />
<h1><a name="notes">NOTES</a></h1>
<p>Because a random secret key is generated the random number generator
must be seeded when <code>EVP_SealInit()</code> is called.
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
external circumstances (see <em>RAND(7)</em>), the operation will fail.</p>
<p>The public key must be RSA because it is the only OpenSSL public key
algorithm that supports key transport.</p>
<p>Envelope encryption is the usual method of using public key encryption
on large amounts of data, this is because public key encryption is slow
but symmetric encryption is fast. So symmetric encryption is used for
bulk encryption and the small random symmetric key used is transferred
using public key encryption.</p>
<p>It is possible to call <code>EVP_SealInit()</code> twice in the same way as
<code>EVP_EncryptInit()</code>. The first call should have <strong>npubk</strong> set to 0
and (after setting any cipher parameters) it should be called again
with <strong>type</strong> set to NULL.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>evp(7)</em>, <em>RAND_bytes(3)</em>,
<em>EVP_EncryptInit(3)</em>,
<em>EVP_OpenInit(3)</em>,
<em>RAND(7)</em></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.</p>
<p>Licensed under the Apache License 2.0 (the &quot;License&quot;). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
</body>
</html>