EVP_KDF-KRB5KDF(7ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’– EVP_KDF-KRB5KDF πŸ’–

okay so bestie, welcome to the EVP_KDF-KRB5KDF page β€” that's the 7ossl manual, aka OpenSSL land, and today we're learning about the Krb5 KDF, no cap ✨

πŸŽ€ NAME πŸŽ€

EVP_KDF-KRB5KDF β€” the RFC3961 Krb5 KDF EVP_KDF implementation. that's it, that's the name, she's iconic πŸ’…

🌸 DESCRIPTION 🌸

so basically this is support for computing the KRB5KDF KDF through the EVP_KDF API 🫢

the EVP_KDF-KRB5KDF algorithm implements the key derivation function defined in RFC 3961, section 5.1, and it's used by Krb5 to derive session keys. to do the whole key-derivation thing you need three inputs, periodt:

  • a cipher (for example AES-128-CBC)
  • the initial key
  • a constant

πŸ¦‹ Identity πŸ¦‹

"KRB5KDF" is literally the name for this implementation β€” you can use it with the EVP_KDF_fetch() function, iykyk πŸ”₯

⭐ Supported parameters ⭐

the supported parameters are:

  • "properties" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>
  • "cipher" (OSSL_KDF_PARAM_CIPHER) <UTF8 string>
  • "key" (OSSL_KDF_PARAM_KEY) <octet string>

these parameters work as described in "PARAMETERS" in EVP_KDF(3), fr fr.

  • "constant" (OSSL_KDF_PARAM_CONSTANT) <octet string> β€” this parameter sets the constant value for the KDF. if a value is already set, the contents are replaced. she said out with the old, in with the new πŸ’…

✨ NOTES ✨

a context for KRB5KDF can be obtained by calling:

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

the output length of the KRB5KDF derivation is specified via the keylen parameter to the EVP_KDF_derive(3) function, and it MUST match the key length for the chosen cipher or an error is returned bestie 😭 no negotiating on this one.

moreover, the constant's length must not exceed the block size of the cipher. and since the KRB5KDF output length depends on the chosen cipher, calling EVP_KDF_CTX_get_kdf_size(3) to obtain the requisite length returns the correct length only after the cipher is set. prior to that, EVP_MAX_KEY_LENGTH is returned πŸ‘‘

so the caller must allocate a buffer of the correct length for the chosen cipher, and pass that buffer to the EVP_KDF_derive(3) function along with that length. do not skip this step, I'm begging πŸ™ˆ

ngl this is the part where people mess up β€” get the sizing right, bestie πŸ’€

🌈 EXAMPLES 🌈

this example derives a key using the AES-128-CBC cipher, and honestly? ate πŸ”₯

EVP_KDF *kdf;
EVP_KDF_CTX *kctx;
unsigned char key[16] = "01234...";
unsigned char constant[] = "I'm a constant";
unsigned char out[16];
size_t outlen = sizeof(out);
OSSL_PARAM params[4], *p = params;

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

*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER,
                                        SN_aes_128_cbc,
                                        strlen(SN_aes_128_cbc));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
                                         key, (size_t)16);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_CONSTANT,
                                         constant, strlen(constant));
*p = OSSL_PARAM_construct_end();
if (EVP_KDF_derive(kctx, out, outlen, params) <= 0)
    /* Error */

EVP_KDF_CTX_free(kctx);

and don't forget to free that context at the end, she's a main character and she deserves her cleanup 🧚


πŸ‘‘ CONFORMING TO πŸ‘‘

RFC 3961 β€” that's the standard, and we respect her πŸ’œ

πŸ“ SEE ALSO πŸ“

go read those too, bestie, they're giving essential lore πŸ“š

πŸ’€ HISTORY πŸ’€

this functionality was added in OpenSSL 3.0 β€” so if you're on something older, that's a no from her πŸ™ˆ

Copyright 2016-2021 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 πŸ’– stay slay, keep your outlen correct, and remember β€” this is version 3.5.0, dated 2026-09-25, brought to you by the EVP_KDF-KRB5KDF(7ossl) manual. mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from