EVP_KDF-X963(7ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… EVP_KDF-X963 β€” the X9.63-2001 EVP_KDF implementation

okay bestie, so this one's from the OpenSSL manual section 7ossl and it's literally all about the X9.63-2001 key derivation glow-up. sit down, hydrate, let's get into it 🫢


✨ NAME ✨

EVP_KDF-X963 β€” the X9.63-2001 EVP_KDF implementation. that's the whole vibe. periodt.


🌸 DESCRIPTION 🌸

so the EVP_KDF-X963 algorithm implements the key derivation function, aka X963KDF. no cap.

and where does X963KDF get used? it's used by Cryptographic Message Syntax (CMS) for EC KeyAgreement, to derive a key using input such as a shared secret key and shared info. iconic behaviour honestly.

the output is considered to be keying material. that's the whole point, bestie β€” we're making keys out here. πŸ”‘

πŸŽ€ Identity

"X963KDF" is the name for this implementation. that's the string you feed to the EVP_KDF_fetch() function. remember it, it's giving main character.

πŸ¦‹ Supported parameters

here's the roster of supported parameters β€” i know, i know, it's a lot, but we're getting through all of them together:

  • "properties" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>
  • "digest" (OSSL_KDF_PARAM_DIGEST) <UTF8 string>

these two work exactly as described in "PARAMETERS" in EVP_KDF(3). go read that one too, iykyk.

  • "key" (OSSL_KDF_PARAM_KEY) <octet string> β€” the shared secret used for key derivation. this parameter sets the secret. πŸ”
  • "info" (OSSL_KDF_PARAM_INFO) <octet string> β€” this parameter specifies an optional value for shared info.

then, and this is a whole thing, the OpenSSL FIPS provider also supports the following parameters:

  • "fips-indicator" (OSSL_KDF_PARAM_FIPS_APPROVED_INDICATOR) <integer> β€” a getter that returns 1 if the operation is FIPS approved, or 0 otherwise. you can use this after calling EVP_KDF_derive. it returns 0 if any "***-check" related parameter is set to 0 and the check fails. so like, bestie, if you turned off a check and it exploded, this thing is gonna snitch on you with a 0. 😭
  • "digest-check" (OSSL_KDF_PARAM_FIPS_DIGEST_CHECK) <int> β€” the default value of 1 causes an error during EVP_KDF_CTX_set_params() if the used digest is not approved. setting this to zero will ignore the error and set the approved "fips-indicator" to 0.
⚠️ heads up: this option breaks FIPS compliance if it causes the approved "fips-indicator" to return 0. so like, careful.

and according to ANSI X9.63-2001, the following are approved digest algorithms: SHA2-224, SHA2-256, SHA2-384, SHA2-512, SHA2-512/224, SHA2-512/256, SHA3-224, SHA3-256, SHA3-384, SHA3-512. that's the approved list, slay. βœ…

  • "key-check" (OSSL_KDF_PARAM_FIPS_KEY_CHECK) <integer> β€” the default value of 1 causes an error during EVP_KDF_CTX_set_params() if the length of the used key-derivation key (OSSL_KDF_PARAM_KEY) is shorter than 112 bits. setting this to zero will ignore the error and set the approved "fips-indicator" to 0.
⚠️ again, bestie: this option breaks FIPS compliance if it causes the approved "fips-indicator" to return 0. so don't be out here disabling checks and then acting surprised, i'm begging πŸ™ˆ

πŸ’œ NOTES πŸ’œ

X963KDF is very similar to the SSKDF that uses a digest as the auxiliary function. the difference? X963KDF appends the counter to the secret, whereas SSKDF prepends the counter. small detail, huge consequences. the way that one single ordering choice changes everything 😭

a context for X963KDF can be obtained by calling:

EVP_KDF *kdf = EVP_KDF_fetch(NULL, "X963KDF", NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);

the output length of an X963KDF is specified via the keylen parameter to the EVP_KDF_derive(3) function. that's how you tell it how much keying material you want, no guessing. πŸŽ€


πŸ”₯ EXAMPLES πŸ”₯

okay so this example derives 10 bytes, with the secret key "secret" and sharedinfo value "label". it's literally right here, look at her go:

EVP_KDF *kdf;
EVP_KDF_CTX *kctx;
unsigned char out[10];
OSSL_PARAM params[4], *p = params;

kdf = EVP_KDF_fetch(NULL, "X963KDF", NULL);
kctx = EVP_KDF_CTX_new(kdf);
EVP_KDF_free(kdf);

*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
                                        SN_sha256, strlen(SN_sha256));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
                                         "secret", (size_t)6);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
                                         "label", (size_t)5);
*p = OSSL_PARAM_construct_end();
if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0) {
    error("EVP_KDF_derive");
}

EVP_KDF_CTX_free(kctx);

ate. no crumbs. πŸ’…


πŸ‘‘ CONFORMING TO πŸ‘‘

"SEC 1: Elliptic Curve Cryptography" β€” that's the spec she's conforming to, and she's conforming to it flawlessly. ⭐


🌈 SEE ALSO 🌈

go read these too, bestie, they're all part of the lore:


πŸ’€ HISTORY πŸ’€

this functionality was added in OpenSSL 3.0. so if you're on something older… girlypop. upgrade. 🧚


Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie! 🫢 this one came from OpenSSL 3.5.6, dated 2026-04-07, and it lives in manual section 7ossl β€” so now you know exactly where to find her. go forth and derive those keys. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from