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

145 lines
5.3 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_PKEY_CTX_set_tls1_prf_md</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="#string_ctrls">STRING CTRLS</a></li>
<li><a href="#notes">NOTES</a></li>
<li><a href="#return_values">RETURN VALUES</a></li>
<li><a href="#examples">EXAMPLES</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_PKEY_CTX_set_tls1_prf_md,
EVP_PKEY_CTX_set1_tls1_prf_secret, EVP_PKEY_CTX_add1_tls1_prf_seed -
TLS PRF key derivation algorithm</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
#include &lt;openssl/kdf.h&gt;</pre>
<pre>
int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *pctx, const EVP_MD *md);
int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx,
unsigned char *sec, int seclen);
int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx,
unsigned char *seed, int seedlen);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The <strong>EVP_PKEY_TLS1_PRF</strong> algorithm implements the PRF key derivation function for
TLS. It has no associated private key and only implements key derivation
using <em>EVP_PKEY_derive(3)</em>.</p>
<p>EVP_PKEY_set_tls1_prf_md() sets the message digest associated with the
TLS PRF. EVP_md5_sha1() is treated as a special case which uses the PRF
algorithm using both <strong>MD5</strong> and <strong>SHA1</strong> as used in TLS 1.0 and 1.1.</p>
<p>EVP_PKEY_CTX_set_tls1_prf_secret() sets the secret value of the TLS PRF
to <strong>seclen</strong> bytes of the buffer <strong>sec</strong>. Any existing secret value is replaced
and any seed is reset.</p>
<p>EVP_PKEY_CTX_add1_tls1_prf_seed() sets the seed to <strong>seedlen</strong> bytes of <strong>seed</strong>.
If a seed is already set it is appended to the existing value.</p>
<p>
</p>
<hr />
<h1><a name="string_ctrls">STRING CTRLS</a></h1>
<p>The TLS PRF also supports string based control operations using
<em>EVP_PKEY_CTX_ctrl_str(3)</em>.
The <strong>type</strong> parameter &quot;md&quot; uses the supplied <strong>value</strong> as the name of the digest
algorithm to use.
The <strong>type</strong> parameters &quot;secret&quot; and &quot;seed&quot; use the supplied <strong>value</strong> parameter
as a secret or seed value.
The names &quot;hexsecret&quot; and &quot;hexseed&quot; are similar except they take a hex string
which is converted to binary.</p>
<p>
</p>
<hr />
<h1><a name="notes">NOTES</a></h1>
<p>All these functions are implemented as macros.</p>
<p>A context for the TLS PRF can be obtained by calling:</p>
<pre>
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);</pre>
<p>The digest, secret value and seed must be set before a key is derived or an
error occurs.</p>
<p>The total length of all seeds cannot exceed 1024 bytes in length: this should
be more than enough for any normal use of the TLS PRF.</p>
<p>The output length of the PRF is specified by the length parameter in the
<code>EVP_PKEY_derive()</code> function. Since the output length is variable, setting
the buffer to <strong>NULL</strong> is not meaningful for the TLS PRF.</p>
<p>Optimised versions of the TLS PRF can be implemented in an ENGINE.</p>
<p>
</p>
<hr />
<h1><a name="return_values">RETURN VALUES</a></h1>
<p>All these functions return 1 for success and 0 or a negative value for failure.
In particular a return value of -2 indicates the operation is not supported by
the public key algorithm.</p>
<p>
</p>
<hr />
<h1><a name="examples">EXAMPLES</a></h1>
<p>This example derives 10 bytes using SHA-256 with the secret key &quot;secret&quot;
and seed value &quot;seed&quot;:</p>
<pre>
EVP_PKEY_CTX *pctx;
unsigned char out[10];
size_t outlen = sizeof(out);</pre>
<pre>
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
if (EVP_PKEY_derive_init(pctx) &lt;= 0)
/* Error */
if (EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_sha256()) &lt;= 0)
/* Error */
if (EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, &quot;secret&quot;, 6) &lt;= 0)
/* Error */
if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, &quot;seed&quot;, 4) &lt;= 0)
/* Error */
if (EVP_PKEY_derive(pctx, out, &amp;outlen) &lt;= 0)
/* Error */</pre>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>EVP_PKEY_CTX_new(3)</em>,
<em>EVP_PKEY_CTX_ctrl_str(3)</em>,
<em>EVP_PKEY_derive(3)</em></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 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>