openssl-prebuild/linux_amd64/share/doc/openssl/html/man7/EVP_KDF-SSHKDF.html
2020-03-02 16:50:34 +00:00

205 lines
7.6 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_KDF-SSHKDF</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="#description">DESCRIPTION</a></li>
<ul>
<li><a href="#identity">Identity</a></li>
<li><a href="#supported_parameters">Supported parameters</a></li>
</ul>
<li><a href="#notes">NOTES</a></li>
<li><a href="#examples">EXAMPLES</a></li>
<li><a href="#conforming_to">CONFORMING TO</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_KDF-SSHKDF - The SSHKDF EVP_KDF implementation</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>Support for computing the <strong>SSHKDF</strong> KDF through the <strong>EVP_KDF</strong> API.</p>
<p>The EVP_KDF-SSHKDF algorithm implements the SSHKDF key derivation function.
It is defined in <a href="http://www.ietf.org/rfc/rfc4253.txt" class="rfc">RFC 4253</a>, section 7.2 and is used by SSH to derive IVs,
encryption keys and integrity keys.
Five inputs are required to perform key derivation: The hashing function
(for example SHA256), the Initial Key, the Exchange Hash, the Session ID,
and the derivation key type.</p>
<p>
</p>
<h2><a name="identity">Identity</a></h2>
<p>&quot;SSHKDF&quot; is the name for this implementation; it
can be used with the <code>EVP_KDF_fetch()</code> function.</p>
<p>
</p>
<h2><a name="supported_parameters">Supported parameters</a></h2>
<p>The supported parameters are:</p>
<dl>
<dt><strong><a name="properties_ossl_kdf_param_properties_utf8_string" class="item">&quot;properties&quot; (<strong>OSSL_KDF_PARAM_PROPERTIES</strong>) &lt;UTF8 string&gt;</a></strong></dt>
<dt><strong><a name="digest_ossl_kdf_param_digest_utf8_string" class="item">&quot;digest&quot; (<strong>OSSL_KDF_PARAM_DIGEST</strong>) &lt;UTF8 string&gt;</a></strong></dt>
<dt><strong><a name="key_ossl_kdf_param_key_octet_string" class="item">&quot;key&quot; (<strong>OSSL_KDF_PARAM_KEY</strong>) &lt;octet string&gt;</a></strong></dt>
<dd>
<p>These parameters work as described in <em>EVP_KDF(3)/PARAMETERS</em>.</p>
</dd>
<dt><strong><a name="xcghash_ossl_kdf_param_sshkdf_xcghash_octet_string" class="item">&quot;xcghash&quot; (<strong>OSSL_KDF_PARAM_SSHKDF_XCGHASH</strong>) &lt;octet string&gt;</a></strong></dt>
<dt><strong><a name="session_id_ossl_kdf_param_sshkdf_session_id_octet_string" class="item">&quot;session_id&quot; (<strong>OSSL_KDF_PARAM_SSHKDF_SESSION_ID</strong>) &lt;octet string&gt;</a></strong></dt>
<dd>
<p>These parameters set the respective values for the KDF.
If a value is already set, the contents are replaced.</p>
</dd>
<dt><strong><a name="type_ossl_kdf_param_sshkdf_type_integer" class="item">&quot;type&quot; (<strong>OSSL_KDF_PARAM_SSHKDF_TYPE</strong>) &lt;integer&gt;</a></strong></dt>
<dd>
<p>This parameter sets the type for the SSHHKDF operation.
There are six supported types:</p>
<dl>
<dt><strong><a name="evp_kdf_sshkdf_type_initial_iv_cli_to_srv" class="item">EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV</a></strong></dt>
<dd>
<p>The Initial IV from client to server.
A single char of value 65 (ASCII char 'A').</p>
</dd>
<dt><strong><a name="evp_kdf_sshkdf_type_initial_iv_srv_to_cli" class="item">EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI</a></strong></dt>
<dd>
<p>The Initial IV from server to client
A single char of value 66 (ASCII char 'B').</p>
</dd>
<dt><strong><a name="evp_kdf_sshkdf_type_encryption_key_cli_to_srv" class="item">EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV</a></strong></dt>
<dd>
<p>The Encryption Key from client to server
A single char of value 67 (ASCII char 'C').</p>
</dd>
<dt><strong><a name="evp_kdf_sshkdf_type_encryption_key_srv_to_cli" class="item">EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI</a></strong></dt>
<dd>
<p>The Encryption Key from server to client
A single char of value 68 (ASCII char 'D').</p>
</dd>
<dt><strong><a name="evp_kdf_sshkdf_type_integrity_key_cli_to_srv" class="item">EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV</a></strong></dt>
<dd>
<p>The Integrity Key from client to server
A single char of value 69 (ASCII char 'E').</p>
</dd>
<dt><strong><a name="evp_kdf_sshkdf_type_integrity_key_srv_to_cli" class="item">EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI</a></strong></dt>
<dd>
<p>The Integrity Key from client to server
A single char of value 70 (ASCII char 'F').</p>
</dd>
</dl>
</dd>
</dl>
<p>
</p>
<hr />
<h1><a name="notes">NOTES</a></h1>
<p>A context for SSHKDF can be obtained by calling:</p>
<pre>
EVP_KDF *kdf = EVP_KDF_fetch(NULL, &quot;SSHKDF&quot;, NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);</pre>
<p>The output length of the SSHKDF derivation is specified via the <em>keylen</em>
parameter to the <em>EVP_KDF_derive(3)</em> function.
Since the SSHKDF output length is variable, calling <em>EVP_KDF_size(3)</em>
to obtain the requisite length is not meaningful. The caller must
allocate a buffer of the desired length, and pass that buffer to the
<em>EVP_KDF_derive(3)</em> function along with the desired length.</p>
<p>
</p>
<hr />
<h1><a name="examples">EXAMPLES</a></h1>
<p>This example derives an 8 byte IV using SHA-256 with a 1K &quot;key&quot; and appropriate
&quot;xcghash&quot; and &quot;session_id&quot; values:</p>
<pre>
EVP_KDF *kdf;
EVP_KDF_CTX *kctx;
unsigned char key[1024] = &quot;01234...&quot;;
unsigned char xcghash[32] = &quot;012345...&quot;;
unsigned char session_id[32] = &quot;012345...&quot;;
unsigned char out[8];
size_t outlen = sizeof(out);
OSSL_PARAM params[6], *p = params;</pre>
<pre>
kdf = EVP_KDF_fetch(NULL, &quot;SSHKDF&quot;, NULL);
kctx = EVP_KDF_CTX_new(kdf);
EVP_KDF_free(kdf);</pre>
<pre>
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
SN_sha256, strlen(SN_sha256));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
key, (size_t)1024);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SSHKDF_XCGHASH,
xcghash, (size_t)32);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
session_id, (size_t)32);
*p++ = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_SSHKDF_TYPE,
EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV);
*p = OSSL_PARAM_construct_end();
if (EVP_KDF_CTX_set_params(kctx, params) &lt;= 0)
/* Error */</pre>
<pre>
if (EVP_KDF_derive(kctx, out, &amp;outlen) &lt;= 0)
/* Error */</pre>
<p>
</p>
<hr />
<h1><a name="conforming_to">CONFORMING TO</a></h1>
<p>RFC 4253</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><em>EVP_KDF(3)</em>,
<em>EVP_KDF_CTX_new(3)</em>,
<em>EVP_KDF_CTX_free(3)</em>,
<em>EVP_KDF_CTX_set_params(3)</em>,
<em>EVP_KDF_size(3)</em>,
<em>EVP_KDF_derive(3)</em>,
<em>EVP_KDF(3)/PARAMETERS</em></p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.</p>
<p>Licensed under the OpenSSL license (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>