EVP_KDF-X963.pod 2.9 KB

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