Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/include/openssl/hkdf.h

raw
1 // Copyright (c) 2014, Google Inc.
2 // SPDX-License-Identifier: ISC
3
4 #ifndef OPENSSL_HEADER_HKDF_H
5 #define OPENSSL_HEADER_HKDF_H
6
7 #include <openssl/base.h>
8 #include <openssl/kdf.h>
9
10 #if defined(__cplusplus)
11 extern "C" {
12 #endif
13
14
15 // HKDF.
16
17
18 // HKDF computes HKDF (as specified by RFC 5869) of initial keying material
19 // |secret| with |salt| and |info| using |digest|, and outputs |out_len| bytes
20 // to |out_key|. It returns one on success and zero on error.
21 //
22 // HKDF is an Extract-and-Expand algorithm. It does not do any key stretching,
23 // and as such, is not suited to be used alone to generate a key from a
24 // password.
25 OPENSSL_EXPORT int HKDF(uint8_t *out_key, size_t out_len, const EVP_MD *digest,
26 const uint8_t *secret, size_t secret_len,
27 const uint8_t *salt, size_t salt_len,
28 const uint8_t *info, size_t info_len);
29
30 // HKDF_extract computes a HKDF PRK (as specified by RFC 5869) from initial
31 // keying material |secret| and salt |salt| using |digest|, and outputs
32 // |out_len| bytes to |out_key|. The maximum output size is |EVP_MAX_MD_SIZE|.
33 // It returns one on success and zero on error.
34 //
35 // WARNING: This function orders the inputs differently from RFC 5869
36 // specification. Double-check which parameter is the secret/IKM and which is
37 // the salt when using.
38 OPENSSL_EXPORT int HKDF_extract(uint8_t *out_key, size_t *out_len,
39 const EVP_MD *digest, const uint8_t *secret,
40 size_t secret_len, const uint8_t *salt,
41 size_t salt_len);
42
43 // HKDF_expand computes a HKDF OKM (as specified by RFC 5869) of length
44 // |out_len| from the PRK |prk| and info |info| using |digest|, and outputs
45 // the result to |out_key|. It returns one on success and zero on error.
46 OPENSSL_EXPORT int HKDF_expand(uint8_t *out_key, size_t out_len,
47 const EVP_MD *digest, const uint8_t *prk,
48 size_t prk_len, const uint8_t *info,
49 size_t info_len);
50
51
52 #if defined(__cplusplus)
53 } // extern C
54 #endif
55
56 #define HKDF_R_OUTPUT_TOO_LARGE 100
57 #define HKDF_R_UNSUPPORTED_DIGEST 101
58
59 #endif // OPENSSL_HEADER_HKDF_H