Blame doc/man3/EVP_KDF_CTX.pod

Packit Service 084de1
=pod
Packit Service 084de1
Packit Service 084de1
=head1 NAME
Packit Service 084de1
Packit Service 084de1
EVP_KDF_CTX, EVP_KDF_CTX_new_id, EVP_KDF_CTX_free, EVP_KDF_reset,
Packit Service 084de1
EVP_KDF_ctrl, EVP_KDF_vctrl, EVP_KDF_ctrl_str, EVP_KDF_size,
Packit Service 084de1
EVP_KDF_derive - EVP KDF routines
Packit Service 084de1
Packit Service 084de1
=head1 SYNOPSIS
Packit Service 084de1
Packit Service 084de1
 #include <openssl/kdf.h>
Packit Service 084de1
Packit Service 084de1
 typedef struct evp_kdf_ctx_st EVP_KDF_CTX;
Packit Service 084de1
Packit Service 084de1
 EVP_KDF_CTX *EVP_KDF_CTX_new_id(int id);
Packit Service 084de1
 void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
Packit Service 084de1
 void EVP_KDF_reset(EVP_KDF_CTX *ctx);
Packit Service 084de1
 int EVP_KDF_ctrl(EVP_KDF_CTX *ctx, int cmd, ...);
Packit Service 084de1
 int EVP_KDF_vctrl(EVP_KDF_CTX *ctx, int cmd, va_list args);
Packit Service 084de1
 int EVP_KDF_ctrl_str(EVP_KDF_CTX *ctx, const char *type, const char *value);
Packit Service 084de1
 size_t EVP_KDF_size(EVP_KDF_CTX *ctx);
Packit Service 084de1
 int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen);
Packit Service 084de1
Packit Service 084de1
=head1 DESCRIPTION
Packit Service 084de1
Packit Service 084de1
The EVP KDF routines are a high level interface to Key Derivation Function
Packit Service 084de1
algorithms and should be used instead of algorithm-specific functions.
Packit Service 084de1
Packit Service 084de1
After creating a C<EVP_KDF_CTX> for the required algorithm using
Packit Service 084de1
EVP_KDF_CTX_new_id(), inputs to the algorithm are supplied using calls to
Packit Service 084de1
EVP_KDF_ctrl(), EVP_KDF_vctrl() or EVP_KDF_ctrl_str() before calling
Packit Service 084de1
EVP_KDF_derive() to derive the key.
Packit Service 084de1
Packit Service 084de1
=head2 Types
Packit Service 084de1
Packit Service 084de1
B<EVP_KDF_CTX> is a context type that holds the algorithm inputs.
Packit Service 084de1
Packit Service 084de1
=head2 Context manipulation functions
Packit Service 084de1
Packit Service 084de1
EVP_KDF_CTX_new_id() creates a KDF context for the algorithm identified by the
Packit Service 084de1
specified NID.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_CTX_free() frees up the context C<ctx>.  If C<ctx> is C<NULL>, nothing
Packit Service 084de1
is done.
Packit Service 084de1
Packit Service 084de1
=head2 Computing functions
Packit Service 084de1
Packit Service 084de1
EVP_KDF_reset() resets the context to the default state as if the context
Packit Service 084de1
had just been created.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl() is used to provide inputs to the KDF algorithm prior to
Packit Service 084de1
EVP_KDF_derive() being called.  The inputs that may be provided will vary
Packit Service 084de1
depending on the KDF algorithm or its implementation.  This functions takes
Packit Service 084de1
variable arguments, the exact expected arguments depend on C<cmd>.
Packit Service 084de1
See L</CONTROLS> below for a description of standard controls.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_vctrl() is the variant of EVP_KDF_ctrl() that takes a C<va_list>
Packit Service 084de1
argument instead of variadic arguments.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() allows an application to send an algorithm specific control
Packit Service 084de1
operation to a context C<ctx> in string form.  This is intended to be used for
Packit Service 084de1
options specified on the command line or in text files.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_size() returns the output size if the algorithm produces a fixed amount
Packit Service 084de1
of output and C<SIZE_MAX> otherwise.  If an error occurs then 0 is returned.
Packit Service 084de1
For some algorithms an error may result if input parameters necessary to
Packit Service 084de1
calculate a fixed output size have not yet been supplied.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_derive() derives C<keylen> bytes of key material and places it in the
Packit Service 084de1
C<key> buffer.  If the algorithm produces a fixed amount of output then an
Packit Service 084de1
error will occur unless the C<keylen> parameter is equal to that output size,
Packit Service 084de1
as returned by EVP_KDF_size().
Packit Service 084de1
Packit Service 084de1
=head1 CONTROLS
Packit Service 084de1
Packit Service 084de1
The standard controls are:
Packit Service 084de1
Packit Service 084de1
=over 4
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_PASS>
Packit Service 084de1
Packit Service 084de1
This control expects two arguments: C<unsigned char *pass>, C<size_t passlen>
Packit Service 084de1
Packit Service 084de1
Some KDF implementations require a password.  For those KDF implementations
Packit Service 084de1
that support it, this control sets the password.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() takes two type strings for this control:
Packit Service 084de1
Packit Service 084de1
=over 4
Packit Service 084de1
Packit Service 084de1
=item "pass"
Packit Service 084de1
Packit Service 084de1
The value string is used as is.
Packit Service 084de1
Packit Service 084de1
=item "hexpass"
Packit Service 084de1
Packit Service 084de1
The value string is expected to be a hexadecimal number, which will be
Packit Service 084de1
decoded before being passed on as the control value.
Packit Service 084de1
Packit Service 084de1
=back
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_SALT>
Packit Service 084de1
Packit Service 084de1
This control expects two arguments: C<unsigned char *salt>, C<size_t saltlen>
Packit Service 084de1
Packit Service 084de1
Some KDF implementations can take a salt.  For those KDF implementations that
Packit Service 084de1
support it, this control sets the salt.
Packit Service 084de1
Packit Service 084de1
The default value, if any, is implementation dependent.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() takes two type strings for this control:
Packit Service 084de1
Packit Service 084de1
=over 4
Packit Service 084de1
Packit Service 084de1
=item "salt"
Packit Service 084de1
Packit Service 084de1
The value string is used as is.
Packit Service 084de1
Packit Service 084de1
=item "hexsalt"
Packit Service 084de1
Packit Service 084de1
The value string is expected to be a hexadecimal number, which will be
Packit Service 084de1
decoded before being passed on as the control value.
Packit Service 084de1
Packit Service 084de1
=back
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_ITER>
Packit Service 084de1
Packit Service 084de1
This control expects one argument: C<int iter>
Packit Service 084de1
Packit Service 084de1
Some KDF implementations require an iteration count. For those KDF implementations that support it, this control sets the iteration count.
Packit Service 084de1
Packit Service 084de1
The default value, if any, is implementation dependent.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() type string: "iter"
Packit Service 084de1
Packit Service 084de1
The value string is expected to be a decimal number.
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_MD>
Packit Service 084de1
Packit Service 084de1
This control expects one argument: C<EVP_MD *md>
Packit Service 084de1
Packit Service 084de1
For MAC implementations that use a message digest as an underlying computation
Packit Service 084de1
algorithm, this control sets what the digest algorithm should be.
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_CIPHER>
Packit Service 084de1
Packit Service 084de1
This control expects one argument: C<EVP_CIPHER *cipher>
Packit Service 084de1
Packit Service 084de1
For MAC implementations that use a cipher as an underlying computation
Packit Service 084de1
algorithm, this control sets what the cipher algorithm should be.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() type string: "md"
Packit Service 084de1
Packit Service 084de1
The value string is expected to be the name of a digest.
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_KEY>
Packit Service 084de1
Packit Service 084de1
This control expects two arguments: C<unsigned char *key>, C<size_t keylen>
Packit Service 084de1
Packit Service 084de1
Some KDF implementations require a key.  For those KDF implementations that
Packit Service 084de1
support it, this control sets the key.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() takes two type strings for this control:
Packit Service 084de1
Packit Service 084de1
=over 4
Packit Service 084de1
Packit Service 084de1
=item "key"
Packit Service 084de1
Packit Service 084de1
The value string is used as is.
Packit Service 084de1
Packit Service 084de1
=item "hexkey"
Packit Service 084de1
Packit Service 084de1
The value string is expected to be a hexadecimal number, which will be
Packit Service 084de1
decoded before being passed on as the control value.
Packit Service 084de1
Packit Service 084de1
=back
Packit Service 084de1
Packit Service 084de1
=item B<EVP_KDF_CTRL_SET_MAXMEM_BYTES>
Packit Service 084de1
Packit Service 084de1
This control expects one argument: C<uint64_t maxmem_bytes>
Packit Service 084de1
Packit Service 084de1
Memory-hard password-based KDF algorithms, such as scrypt, use an amount of
Packit Service 084de1
memory that depends on the load factors provided as input.  For those KDF
Packit Service 084de1
implementations that support it, this control sets an upper limit on the amount
Packit Service 084de1
of memory that may be consumed while performing a key derivation.  If this
Packit Service 084de1
memory usage limit is exceeded because the load factors are chosen too high,
Packit Service 084de1
the key derivation will fail.
Packit Service 084de1
Packit Service 084de1
The default value is implementation dependent.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_ctrl_str() type string: "maxmem_bytes"
Packit Service 084de1
Packit Service 084de1
The value string is expected to be a decimal number.
Packit Service 084de1
Packit Service 084de1
=back
Packit Service 084de1
Packit Service 084de1
=head1 RETURN VALUES
Packit Service 084de1
Packit Service 084de1
EVP_KDF_CTX_new_id() returns either the newly allocated C<EVP_KDF_CTX>
Packit Service 084de1
structure or C<NULL> if an error occurred.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_CTX_free() and EVP_KDF_reset() do not return a value.
Packit Service 084de1
Packit Service 084de1
EVP_KDF_size() returns the output size.  C<SIZE_MAX> is returned to indicate
Packit Service 084de1
that the algorithm produces a variable amount of output; 0 to indicate failure.
Packit Service 084de1
Packit Service 084de1
The remaining functions return 1 for success and 0 or a negative value for
Packit Service 084de1
failure.  In particular, a return value of -2 indicates the operation is not
Packit Service 084de1
supported by the KDF algorithm.
Packit Service 084de1
Packit Service 084de1
=head1 SEE ALSO
Packit Service 084de1
Packit Service 084de1
L<EVP_KDF_SCRYPT(7)>
Packit Service 084de1
Packit Service 084de1
=head1 COPYRIGHT
Packit Service 084de1
Packit Service 084de1
Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
Packit Service 084de1
Packit Service 084de1
Licensed under the Apache License 2.0 (the "License").  You may not use
Packit Service 084de1
this file except in compliance with the License.  You can obtain a copy
Packit Service 084de1
in the file LICENSE in the source distribution or at
Packit Service 084de1
L<https://www.openssl.org/source/license.html>.
Packit Service 084de1
Packit Service 084de1
=cut