EVP_KDF-X963.pod 2.9 KB

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