197 lines
8.0 KiB
HTML
Executable File
197 lines
8.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_KDF-KB</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="#history">HISTORY</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-KB - The Key-Based EVP_KDF implementation</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
<p>The EVP_KDF-KB algorithm implements the Key-Based key derivation function
|
|
(KBKDF). KBKDF derives a key from repeated application of a keyed MAC to an
|
|
input secret (and other optional values).</p>
|
|
<p>
|
|
</p>
|
|
<h2><a name="identity">Identity</a></h2>
|
|
<p>"KBKDF" 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">"properties" (<strong>OSSL_KDF_PARAM_PROPERTIES</strong>) <UTF8 string></a></strong></dt>
|
|
|
|
<dt><strong><a name="mode_ossl_kdf_param_mode_utf8_string" class="item">"mode" (<strong>OSSL_KDF_PARAM_MODE</strong>) <UTF8 string></a></strong></dt>
|
|
|
|
<dt><strong><a name="mac_ossl_kdf_param_mac_utf8_string" class="item">"mac" (<strong>OSSL_KDF_PARAM_MAC</strong>) <UTF8 string></a></strong></dt>
|
|
|
|
<dt><strong><a name="digest_ossl_kdf_param_digest_utf8_string" class="item">"digest" (<strong>OSSL_KDF_PARAM_DIGEST</strong>) <UTF8 string></a></strong></dt>
|
|
|
|
<dt><strong><a name="cipher_ossl_kdf_param_digest_utf8_string" class="item">"cipher" (<strong>OSSL_KDF_PARAM_DIGEST</strong>) <UTF8 string></a></strong></dt>
|
|
|
|
<dt><strong><a name="key_ossl_kdf_param_key_octet_string" class="item">"key" (<strong>OSSL_KDF_PARAM_KEY</strong>) <octet string></a></strong></dt>
|
|
|
|
<dt><strong><a name="salt_ossl_kdf_param_salt_octet_string" class="item">"salt" (<strong>OSSL_KDF_PARAM_SALT</strong>) <octet string></a></strong></dt>
|
|
|
|
<dt><strong><a name="info" class="item">"info (<strong>OSSL_KDF_PARAM_INFO</strong>) <octet string></a></strong></dt>
|
|
|
|
<dt><strong><a name="seed_ossl_kdf_param_seed_octet_string" class="item">"seed" (<strong>OSSL_KDF_PARAM_SEED</strong>) <octet string></a></strong></dt>
|
|
|
|
</dl>
|
|
<p>The mode parameter determines which flavor of KBKDF to use - currently the
|
|
choices are "counter" and "feedback". Counter is the default, and will be
|
|
used if unspecified. The seed parameter is unused in counter mode.</p>
|
|
<p>The parameters key, salt, info, and seed correspond to KI, Label, Context, and
|
|
IV (respectively) in SP800-108. As in that document, salt, info, and seed are
|
|
optional and may be omitted.</p>
|
|
<p>Depending on whether mac is CMAC or HMAC, either digest or cipher is required
|
|
(respectively) and the other is unused.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="notes">NOTES</a></h1>
|
|
<p>A context for KBKDF can be obtained by calling:</p>
|
|
<pre>
|
|
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
|
|
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);</pre>
|
|
<p>The output length of an KBKDF is specified via the <code>keylen</code>
|
|
parameter to the <em>EVP_KDF_derive(3)</em> function.</p>
|
|
<p>Note that currently OpenSSL only implements counter and feedback modes. Other
|
|
variants may be supported in the future.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="examples">EXAMPLES</a></h1>
|
|
<p>This example derives 10 bytes using COUNTER-HMAC-SHA256, with KI "secret",
|
|
Label "label", and Context "context".</p>
|
|
<pre>
|
|
EVP_KDF *kdf;
|
|
EVP_KDF_CTX *kctx;
|
|
unsigned char out[10];
|
|
OSSL_PARAM params[6], *p = params;</pre>
|
|
<pre>
|
|
kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
|
|
kctx = EVP_KDF_CTX_new(kdf);
|
|
EVP_KDF_free(kdf);</pre>
|
|
<pre>
|
|
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
|
|
"SHA2-256", 0);
|
|
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC,
|
|
"HMAC", 0);
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
|
|
"secret", strlen("secret"))
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
|
|
"label", strlen("label"));
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
|
|
"context", strlen("context"));
|
|
*p = OSSL_PARAM_construct_end();
|
|
if (EVP_KDF_CTX_set_params(kctx, params) <= 0)
|
|
error("EVP_KDF_CTX_set_params");
|
|
else if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0)
|
|
error("EVP_KDF_derive");</pre>
|
|
<pre>
|
|
EVP_KDF_CTX_free(kctx);</pre>
|
|
<p>This example derives 10 bytes using FEEDBACK-CMAC-AES256, with KI "secret",
|
|
Label "label", and IV "sixteen bytes iv".</p>
|
|
<pre>
|
|
EVP_KDF *kdf;
|
|
EVP_KDF_CTX *kctx;
|
|
unsigned char out[10];
|
|
OSSL_PARAM params[8], *p = params;
|
|
unsigned char *iv = "sixteen bytes iv";</pre>
|
|
<pre>
|
|
kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
|
|
kctx = EVP_KDF_CTX_new(kdf);
|
|
EVP_KDF_free(kdf);</pre>
|
|
<pre>
|
|
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER, "AES256", 0);
|
|
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, "CMAC", 0);
|
|
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MODE, "FEEDBACK", 0);
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
|
|
"secret", strlen("secret"));
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
|
|
"label", strlen("label"));
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
|
|
"context", strlen("context"));
|
|
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
|
|
iv, strlen(iv));
|
|
*p = OSSL_PARAM_construct_end();
|
|
if (EVP_KDF_CTX_set_params(kctx, params) <= 0)
|
|
error("EVP_KDF_CTX_set_params");
|
|
else if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0)
|
|
error("EVP_KDF_derive");</pre>
|
|
<pre>
|
|
EVP_KDF_CTX_free(kctx);</pre>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="conforming_to">CONFORMING TO</a></h1>
|
|
<p>NIST SP800-108, IETF <a href="http://www.ietf.org/rfc/rfc6803.txt" class="rfc">RFC 6803</a>, IETF <a href="http://www.ietf.org/rfc/rfc8009.txt" class="rfc">RFC 8009</a>.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
|
<p><em>EVP_KDF(3)</em>,
|
|
<em>EVP_KDF_CTX_free(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="history">HISTORY</a></h1>
|
|
<p>This functionality was added to OpenSSL 3.0.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
|
<p>Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
|
Copyright 2019 Red Hat, Inc.</p>
|
|
<p>Licensed under the Apache License 2.0 (the "License"). 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>
|