Current Path : /compat/linux/proc/self/root/usr/opt/openssl11/share/doc/openssl/html/man3/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //compat/linux/proc/self/root/usr/opt/openssl11/share/doc/openssl/html/man3/EVP_BytesToKey.html |
<?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_BytesToKey</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:root@hsxx.drive.ne.jp" /> </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="#notes">NOTES</a></li> <li><a href="#key_derivation_algorithm">KEY DERIVATION ALGORITHM</a></li> <li><a href="#return_values">RETURN VALUES</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_BytesToKey - password based encryption routine</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> #include <openssl/evp.h></pre> <pre> int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, const unsigned char *salt, const unsigned char *data, int datal, int count, unsigned char *key, unsigned char *iv);</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p><code>EVP_BytesToKey()</code> derives a key and IV from various parameters. <strong>type</strong> is the cipher to derive the key and IV for. <strong>md</strong> is the message digest to use. The <strong>salt</strong> parameter is used as a salt in the derivation: it should point to an 8 byte buffer or NULL if no salt is used. <strong>data</strong> is a buffer containing <strong>datal</strong> bytes which is used to derive the keying data. <strong>count</strong> is the iteration count to use. The derived key and IV will be written to <strong>key</strong> and <strong>iv</strong> respectively.</p> <p> </p> <hr /> <h1><a name="notes">NOTES</a></h1> <p>A typical application of this function is to derive keying material for an encryption algorithm from a password in the <strong>data</strong> parameter.</p> <p>Increasing the <strong>count</strong> parameter slows down the algorithm which makes it harder for an attacker to perform a brute force attack using a large number of candidate passwords.</p> <p>If the total key and IV length is less than the digest length and <strong>MD5</strong> is used then the derivation algorithm is compatible with PKCS#5 v1.5 otherwise a non standard extension is used to derive the extra data.</p> <p>Newer applications should use a more modern algorithm such as PBKDF2 as defined in PKCS#5v2.1 and provided by PKCS5_PBKDF2_HMAC.</p> <p> </p> <hr /> <h1><a name="key_derivation_algorithm">KEY DERIVATION ALGORITHM</a></h1> <p>The key and IV is derived by concatenating D_1, D_2, etc until enough data is available for the key and IV. D_i is defined as:</p> <pre> D_i = HASH^count(D_(i-1) || data || salt)</pre> <p>where || denotes concatenation, D_0 is empty, HASH is the digest algorithm in use, HASH^1(data) is simply HASH(data), HASH^2(data) is HASH(HASH(data)) and so on.</p> <p>The initial bytes are used for the key and the subsequent bytes for the IV.</p> <p> </p> <hr /> <h1><a name="return_values">RETURN VALUES</a></h1> <p>If <strong>data</strong> is NULL, then <code>EVP_BytesToKey()</code> returns the number of bytes needed to store the derived key. Otherwise, <code>EVP_BytesToKey()</code> returns the size of the derived key in bytes, or 0 on error.</p> <p> </p> <hr /> <h1><a name="see_also">SEE ALSO</a></h1> <p><em>evp(7)</em>, <em>RAND_bytes(3)</em>, <em>PKCS5_PBKDF2_HMAC(3)</em>, <em>EVP_EncryptInit(3)</em></p> <p> </p> <hr /> <h1><a name="copyright">COPYRIGHT</a></h1> <p>Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.</p> <p>Licensed under the OpenSSL license (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>