{"id":3985,"date":"2022-12-20T17:28:37","date_gmt":"2022-12-20T20:28:37","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/evp_kdf_sshkdf-man7\/"},"modified":"2022-12-20T17:28:37","modified_gmt":"2022-12-20T20:28:37","slug":"evp_kdf_sshkdf-man7","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/evp_kdf_sshkdf-man7\/","title":{"rendered":"EVP_KDF_SSHKDF (man7)"},"content":{"rendered":"<h1 align=\"center\">EVP_KDF_SSHKDF<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">EVP_KDF_SSHKDF \u2212 The SSHKDF EVP_KDF implementation<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Support for computing the <b><small>SSHKDF<\/small><\/b> <small>KDF<\/small> through the <b><small>EVP_KDF<\/small><\/b> <small>API.<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <small>EVP_KDF_SSHKDF<\/small> algorithm implements the <small>SSHKDF<\/small> key derivation function. It is defined in <small>RFC 4253,<\/small> section 7.2 and is used by <small>SSH<\/small> to derive IVs, encryption keys and integrity keys. Five inputs are required to perform key derivation: The hashing function (for example <small>SHA256<\/small> ), the Initial Key, the Exchange Hash, the Session <small>ID,<\/small> and the derivation key type.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Numeric identity <small><br \/> EVP_KDF_SSHKDF<\/small><\/b> is the numeric identity for this implementation; it can be used with the <b>EVP_KDF_CTX_new_id()<\/b> function.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Supported controls<\/b> <br \/> The supported controls are: <b><small><br \/> EVP_KDF_CTRL_SET_MD <br \/> EVP_KDF_CTRL_SET_KEY<\/small><\/b><\/p>\n<p style=\"margin-left:17%;\">These controls work as described in &#8221; <small>CONTROLS&#8221;<\/small> in <b><small>EVP_KDF_CTX<\/small><\/b> (3).<\/p>\n<p style=\"margin-left:11%;\"><b><small>EVP_KDF_CTRL_SET_SSHKDF_XCGHASH <br \/> EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID<\/small><\/b><\/p>\n<p style=\"margin-left:17%;\">These controls expect two arguments: &#8220;unsigned char *buffer&#8221;, &#8220;size_t length&#8221;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">They set the respective values to the first <b>length<\/b> bytes of the buffer <b>buffer<\/b>. If a value is already set, the contents are replaced.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>EVP_KDF_ctrl_str()<\/b> takes two type strings for these controls: <br \/> &#8220;xcghash&#8221; <br \/> &#8220;session_id&#8221;<\/p>\n<p style=\"margin-left:23%;\">The value string is used as is.<\/p>\n<p style=\"margin-left:17%;\">&#8220;hexxcghash&#8221; <br \/> &#8220;hexsession_id&#8221;<\/p>\n<p style=\"margin-left:23%;\">The value string is expected to be a hexadecimal number, which will be decoded before being passed on as the control value.<\/p>\n<p style=\"margin-left:11%;\"><b><small>EVP_KDF_CTRL_SET_SSHKDF_TYPE<\/small><\/b><\/p>\n<p style=\"margin-left:17%;\">This control expects one argument: &#8220;int mode&#8221;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Sets the type for the <small>SSHHKDF<\/small> operation. There are six supported types: <small><br \/> EVP_KDF_SSHKDF_TYPE_ININITAL_IV_CLI_TO_SRV<\/small><\/p>\n<p style=\"margin-left:23%;\">The Initial <small>IV<\/small> from client to server. A single char of value 65 ( <small>ASCII<\/small> char \u2019A\u2019).<\/p>\n<p style=\"margin-left:17%;\"><small>EVP_KDF_SSHKDF_TYPE_ININITAL_IV_SRV_TO_CLI<\/small><\/p>\n<p style=\"margin-left:23%;\">The Initial <small>IV<\/small> from server to client A single char of value 66 ( <small>ASCII<\/small> char \u2019B\u2019).<\/p>\n<p style=\"margin-left:17%;\"><small>EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV<\/small><\/p>\n<p style=\"margin-left:23%;\">The Encryption Key from client to server A single char of value 67 ( <small>ASCII<\/small> char \u2019C\u2019).<\/p>\n<p style=\"margin-left:17%;\"><small>EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI<\/small><\/p>\n<p style=\"margin-left:23%;\">The Encryption Key from server to client A single char of value 68 ( <small>ASCII<\/small> char \u2019D\u2019).<\/p>\n<p style=\"margin-left:17%;\"><small>EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV<\/small><\/p>\n<p style=\"margin-left:23%;\">The Integrity Key from client to server A single char of value 69 ( <small>ASCII<\/small> char \u2019E\u2019).<\/p>\n<p style=\"margin-left:17%;\"><small>EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI<\/small><\/p>\n<p style=\"margin-left:23%;\">The Integrity Key from client to server A single char of value 70 ( <small>ASCII<\/small> char \u2019F\u2019).<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>EVP_KDF_ctrl_str()<\/b> type string: &#8220;type&#8221;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The value is a string of length one character. The only valid values are the numerical values of the <small>ASCII<\/small> caracters: &#8220;A&#8221; (65) to &#8220;F&#8221; (70).<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A context for <small>SSHKDF<\/small> can be obtained by calling:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_SSHKDF);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The output length of the <small>SSHKDF<\/small> derivation is specified via the &#8220;keylen&#8221; parameter to the <b>EVP_KDF_derive<\/b>(3) function. Since the <small>SSHKDF<\/small> output length is variable, calling <b>EVP_KDF_size()<\/b> to obtain the requisite length is not meaningful. The caller must allocate a buffer of the desired length, and pass that buffer to the <b>EVP_KDF_derive<\/b>(3) function along with the desired length.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This example derives an 8 byte <small>IV<\/small> using <small>SHA\u2212256<\/small> with a 1K &#8220;key&#8221; and appropriate &#8220;xcghash&#8221; and &#8220;session_id&#8221; values:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">EVP_KDF_CTX *kctx; <br \/> unsigned char key[1024] = &#8220;01234&#8230;&#8221;; <br \/> unsigned char xcghash[32] = &#8220;012345&#8230;&#8221;; <br \/> unsigned char session_id[32] = &#8220;012345&#8230;&#8221;; <br \/> unsigned char out[8]; <br \/> size_t outlen = sizeof(out); <br \/> kctx = EVP_KDF_CTX_new_id(EVP_KDF_SSHKDF); <br \/> if (EVP_KDF_CTX_set_md(kctx, EVP_sha256()) <= 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Error bodies\/ usr\/ <br \/> if (EVP_KDF_CTX_set1_key(kctx, key, 1024) <= 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Error bodies\/ usr\/ <br \/> if (EVP_KDF_CTX_set1_sshkdf_xcghash(kctx, xcghash, 32) <= 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Error bodies\/ usr\/ <br \/> if (EVP_KDF_CTX_set1_sshkdf_session_id(kctx, session_id, 32) <= 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Error bodies\/ usr\/ <br \/> if (EVP_KDF_CTX_set_sshkdf_type(kctx, <br \/> EVP_KDF_SSHKDF_TYPE_ININITAL_IV_CLI_TO_SRV) <= 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Error bodies\/ usr\/ <br \/> if (EVP_KDF_derive(kctx, out, &#038;outlen) <= 0) <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Error *\/<\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>RFC 4253<\/small><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>EVP_KDF_CTX<\/small> , <b>EVP_KDF_CTX_new_id<\/b>(3), <b>EVP_KDF_CTX_free<\/b>(3), <b>EVP_KDF_ctrl<\/b>(3), <b>EVP_KDF_size<\/b>(3), <b>EVP_KDF_derive<\/b>(3), &#8221; <small>CONTROLS&#8221;<\/small> in <b><small>EVP_KDF_CTX<\/small><\/b> (3)<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright 2016\u22122018 The OpenSSL Project Authors. All Rights Reserved.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Licensed under the OpenSSL license (the &#8220;License&#8221;). You may not use this file except in compliance with the License. You can obtain a copy in the file <small>LICENSE<\/small> in the source distribution or at <https:\/\/www.openssl.org\/source\/license.html>.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  EVP_KDF_SSHKDF \u2212 The SSHKDF EVP_KDF implementation <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[971],"tags":[973,1074,972],"class_list":["post-3985","post","type-post","status-publish","format-standard","hentry","category-7-miscelanea","tag-973","tag-evp_kdf_sshkdf","tag-man7"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3985"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3985\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}