• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1=pod
2
3=head1 NAME
4
5EVP_KDF-X963 - The X9.63-2001 EVP_KDF implementation
6
7=head1 DESCRIPTION
8
9The EVP_KDF-X963 algorithm implements the key derivation function (X963KDF).
10X963KDF is used by Cryptographic Message Syntax (CMS) for EC KeyAgreement, to
11derive a key using input such as a shared secret key and shared info.
12
13=head2 Identity
14
15"X963KDF" is the name for this implementation; it
16can be used with the EVP_KDF_fetch() function.
17
18=head2 Supported parameters
19
20The supported parameters are:
21
22=over 4
23
24=item "properties" (B<OSSL_KDF_PARAM_PROPERTIES>) <UTF8 string>
25
26=item "digest" (B<OSSL_KDF_PARAM_DIGEST>) <UTF8 string>
27
28These parameters work as described in L<EVP_KDF(3)/PARAMETERS>.
29
30=item "key" (B<OSSL_KDF_PARAM_KEY>) <octet string>
31
32The shared secret used for key derivation.
33This parameter sets the secret.
34
35=item "info" (B<OSSL_KDF_PARAM_INFO>) <octet string>
36
37This parameter specifies an optional value for shared info.
38
39=back
40
41=head1 NOTES
42
43X963KDF is very similar to the SSKDF that uses a digest as the auxiliary function,
44X963KDF appends the counter to the secret, whereas SSKDF prepends the counter.
45
46A context for X963KDF can be obtained by calling:
47
48 EVP_KDF *kdf = EVP_KDF_fetch(NULL, "X963KDF", NULL);
49 EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
50
51The output length of an X963KDF is specified via the I<keylen>
52parameter to the L<EVP_KDF_derive(3)> function.
53
54=head1 EXAMPLES
55
56This example derives 10 bytes, with the secret key "secret" and sharedinfo
57value "label":
58
59 EVP_KDF *kdf;
60 EVP_KDF_CTX *kctx;
61 unsigned char out[10];
62 OSSL_PARAM params[4], *p = params;
63
64 kdf = EVP_KDF_fetch(NULL, "X963KDF", NULL);
65 kctx = EVP_KDF_CTX_new(kdf);
66 EVP_KDF_free(kdf);
67
68 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
69                                         SN_sha256, strlen(SN_sha256));
70 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
71                                          "secret", (size_t)6);
72 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
73                                          "label", (size_t)5);
74 *p = OSSL_PARAM_construct_end();
75 if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0) {
76     error("EVP_KDF_derive");
77 }
78
79 EVP_KDF_CTX_free(kctx);
80
81=head1 CONFORMING TO
82
83"SEC 1: Elliptic Curve Cryptography"
84
85=head1 SEE ALSO
86
87L<EVP_KDF(3)>,
88L<EVP_KDF_CTX_new(3)>,
89L<EVP_KDF_CTX_free(3)>,
90L<EVP_KDF_CTX_set_params(3)>,
91L<EVP_KDF_CTX_get_kdf_size(3)>,
92L<EVP_KDF_derive(3)>,
93L<EVP_KDF(3)/PARAMETERS>
94
95=head1 HISTORY
96
97This functionality was added in OpenSSL 3.0.
98
99=head1 COPYRIGHT
100
101Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
102
103Licensed under the Apache License 2.0 (the "License").  You may not use
104this file except in compliance with the License.  You can obtain a copy
105in the file LICENSE in the source distribution or at
106L<https://www.openssl.org/source/license.html>.
107
108=cut
109