5 EVP_KDF_X963 - The X9.63-2001 EVP_KDF implementation
9 The EVP_KDF_X963 algorithm implements the key derivation function (X963KDF).
10 X963KDF is used by Cryptographic Message Syntax (CMS) for EC KeyAgreement, to
11 derive a key using input such as a shared secret key and shared info.
13 =head2 Numeric identity
15 B<EVP_KDF_X963> is the numeric identity for this implementation; it
16 can be used with the EVP_KDF_CTX_new_id() function.
18 =head2 Supported controls
20 The supported controls are:
24 =item B<EVP_KDF_CTRL_SET_MD>
26 This control works as described in L<EVP_KDF_CTX(3)/CONTROLS>.
28 =item B<EVP_KDF_CTRL_SET_KEY>
30 This control expects two arguments: C<unsigned char *secret>, C<size_t secretlen>
32 The shared secret used for key derivation. This control sets the secret.
34 EVP_KDF_ctrl_str() takes two type strings for this control:
40 The value string is used as is.
44 The value string is expected to be a hexadecimal number, which will be
45 decoded before being passed on as the control value.
49 =item B<EVP_KDF_CTRL_SET_SHARED_INFO>
51 This control expects two arguments: C<unsigned char *info>, C<size_t infolen>
53 An optional value for shared info. This control sets the shared info.
55 EVP_KDF_ctrl_str() takes two type strings for this control:
61 The value string is used as is.
65 The value string is expected to be a hexadecimal number, which will be
66 decoded before being passed on as the control value.
74 X963KDF is very similar to the SSKDF that uses a digest as the auxiliary function,
75 X963KDF appends the counter to the secret, whereas SSKDF prepends the counter.
77 A context for X963KDF can be obtained by calling:
79 EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_X963);
81 The output length of an X963KDF is specified via the C<keylen>
82 parameter to the L<EVP_KDF_derive(3)> function.
86 This example derives 10 bytes, with the secret key "secret" and sharedinfo
90 unsigned char out[10];
92 kctx = EVP_KDF_CTX_new_id(EVP_KDF_X963);
94 if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
95 error("EVP_KDF_CTRL_SET_MD");
97 if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", (size_t)6) <= 0) {
98 error("EVP_KDF_CTRL_SET_KEY");
100 if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SHARED_INFO, "label", (size_t)5) <= 0) {
101 error("EVP_KDF_CTRL_SET_SHARED_INFO");
103 if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
104 error("EVP_KDF_derive");
107 EVP_KDF_CTX_free(kctx);
111 "SEC 1: Elliptic Curve Cryptography"
116 L<EVP_KDF_CTX_new_id(3)>,
117 L<EVP_KDF_CTX_free(3)>,
120 L<EVP_KDF_derive(3)>,
121 L<EVP_KDF_CTX(3)/CONTROLS>
125 This functionality was added to OpenSSL 3.0.
129 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
131 Licensed under the Apache License 2.0 (the "License"). You may not use
132 this file except in compliance with the License. You can obtain a copy
133 in the file LICENSE in the source distribution or at
134 L<https://www.openssl.org/source/license.html>.