EVP_PKEY_CTX_add1_hkdf_info (3)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
EVP_PKEY_CTX_set_hkdf_md, EVP_PKEY_CTX_set1_hkdf_salt, EVP_PKEY_CTX_set1_hkdf_key, EVP_PKEY_CTX_add1_hkdf_info - HMAC-based Extract-and-Expand key derivation algorithmSYNOPSIS
#include <openssl/kdf.h> int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *pctx, const EVP_MD *md); int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *pctx, unsigned char *salt, int saltlen); int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *pctx, unsigned char *key, int keylen); int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *pctx, unsigned char *info, int infolen);
DESCRIPTION
TheEVP_PKEY_set_hkdf_md() sets the message digest associated with the
EVP_PKEY_CTX_set1_hkdf_salt() sets the salt to saltlen bytes of the buffer salt. Any existing value is replaced.
EVP_PKEY_CTX_set_hkdf_key() sets the key to keylen bytes of the buffer key. Any existing value is replaced.
EVP_PKEY_CTX_add1_hkdf_info() sets the info value to infolen bytes of the buffer info. If a value is already set, it is appended to the existing value.
STRING CTRLS
NOTES
All these functions are implemented as macros.A context for
EVP_PKEY_CTX *pctx = EVP_PKEY_new_id(EVP_PKEY_HKDF, NULL);
The digest, key, salt and info values must be set before a key is derived or an error occurs.
The total length of the info buffer cannot exceed 1024 bytes in length: this should be more than enough for any normal use of
The output length of the
Optimised versions of
RETURN VALUES
All these functions return 1 for success and 0 or a negative value for failure. In particular a return value of -2 indicates the operation is not supported by the public key algorithm.EXAMPLE
This example derives 10 bytes using
EVP_PKEY_CTX *pctx; unsigned char out[10]; size_t outlen = sizeof(out); pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL); if (EVP_PKEY_derive_init(pctx) <= 0) /* Error */ if (EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()) <= 0) /* Error */ if (EVP_PKEY_CTX_set1_salt(pctx, "salt", 4) <= 0) /* Error */ if (EVP_PKEY_CTX_set1_key(pctx, "secret", 6) <= 0) /* Error */ if (EVP_PKEY_CTX_add1_hkdf_info(pctx, "label", 6) <= 0) /* Error */ if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) /* Error */
CONFORMING TO
SEE ALSO
EVP_PKEY_CTX_new(3), EVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_derive(3)COPYRIGHT
Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.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