1 /* Copyright (c) 2014, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_HKDF_H
16 #define OPENSSL_HEADER_HKDF_H
17 
18 #include <openssl/base.h>
19 
20 #ifdef  __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 /* Computes HKDF (as specified by RFC 5869) of initial keying material |secret|
26  * with |salt| and |info| using |digest|, and outputs |out_len| bytes to
27  * |out_key|. It returns one on success and zero on error.
28  *
29  * HKDF is an Extract-and-Expand algorithm. It does not do any key stretching,
30  * and as such, is not suited to be used alone to generate a key from a
31  * password. */
32 OPENSSL_EXPORT int HKDF(uint8_t *out_key, size_t out_len, const EVP_MD *digest,
33                         const uint8_t *secret, size_t secret_len,
34                         const uint8_t *salt, size_t salt_len,
35                         const uint8_t *info, size_t info_len);
36 
37 
38 #if defined(__cplusplus)
39 }  /* extern C */
40 #endif
41 
42 #define HKDF_R_OUTPUT_TOO_LARGE 100
43 
44 #endif  /* OPENSSL_HEADER_HKDF_H */
45