Add EVP_KDF-X942 to the fips module
[openssl.git] / doc / man7 / EVP_KDF-X963.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_KDF-X963 - The X9.63-2001 EVP_KDF implementation
6
7 =head1 DESCRIPTION
8
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.
12
13 =head2 Identity
14
15 "X963KDF" is the name for this implementation; it
16 can be used with the EVP_KDF_fetch() function.
17
18 =head2 Supported parameters
19
20 The 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
28 These parameters work as described in L<EVP_KDF(3)/PARAMETERS>.
29
30 =item "key" (B<OSSL_KDF_PARAM_KEY>) <octet string>
31
32 The shared secret used for key derivation.
33 This parameter sets the secret.
34
35 =item "info" (B<OSSL_KDF_PARAM_INFO>) <octet string>
36
37 This parameter specifies an optional value for shared info.
38
39 =back
40
41 =head1 NOTES
42
43 X963KDF is very similar to the SSKDF that uses a digest as the auxiliary function,
44 X963KDF appends the counter to the secret, whereas SSKDF prepends the counter.
45
46 A 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
51 The output length of an X963KDF is specified via the I<keylen>
52 parameter to the L<EVP_KDF_derive(3)> function.
53
54 =head1 EXAMPLES
55
56 This example derives 10 bytes, with the secret key "secret" and sharedinfo
57 value "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_CTX_set_params(kctx, params) <= 0) {
76      error("EVP_KDF_CTX_set_params");
77  }
78  if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
79      error("EVP_KDF_derive");
80  }
81
82  EVP_KDF_CTX_free(kctx);
83
84 =head1 CONFORMING TO
85
86 "SEC 1: Elliptic Curve Cryptography"
87
88 =head1 SEE ALSO
89
90 L<EVP_KDF(3)>,
91 L<EVP_KDF_CTX_new(3)>,
92 L<EVP_KDF_CTX_free(3)>,
93 L<EVP_KDF_CTX_set_params(3)>,
94 L<EVP_KDF_CTX_get_kdf_size(3)>,
95 L<EVP_KDF_derive(3)>,
96 L<EVP_KDF(3)/PARAMETERS>
97
98 =head1 HISTORY
99
100 This functionality was added to OpenSSL 3.0.
101
102 =head1 COPYRIGHT
103
104 Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
105
106 Licensed under the Apache License 2.0 (the "License").  You may not use
107 this file except in compliance with the License.  You can obtain a copy
108 in the file LICENSE in the source distribution or at
109 L<https://www.openssl.org/source/license.html>.
110
111 =cut