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