KRB5_STRING_TO_KEY(3)

πŸ’– KRB5_STRING_TO_KEY(3) β€” the manual page bestie πŸ’–

okay so this is a page from the Library Functions Manual (the KRB5_STRING_TO_KEY one, in case the tab title didn't give it away) and it's literally all about turning a string into a Kerberos key. like, a whole page. for that. and honestly? iconic. let's get into it πŸ¦‹


✨ NAME ✨

so there's not one, not two, but eight lil functions living here, and they all do variations on the same vibe:

  • krb5_string_to_key
  • krb5_string_to_key_data
  • krb5_string_to_key_data_salt
  • krb5_string_to_key_data_salt_opaque
  • krb5_string_to_key_salt
  • krb5_string_to_key_salt_opaque
  • krb5_get_pw_salt
  • krb5_free_salt

and what do they do? they turn a string to a Kerberos key. that's it, that's the whole thing, periodt. πŸ’…


πŸ“š LIBRARY πŸ“š

this lives in the Kerberos 5 Library, which is libkrb5, and you link it with -lkrb5. slay.


πŸŽ€ SYNOPSIS πŸŽ€

okay bestie, first things first, you gotta include the header or nothing works:

#include <krb5.h>

and now the whole squad, one by one:

krb5_error_code
krb5_string_to_key(krb5_context context, krb5_enctype enctype,
    const char *password, krb5_principal principal, krb5_keyblock *key);
krb5_error_code
krb5_string_to_key_data(krb5_context context, krb5_enctype enctype,
    krb5_data password, krb5_principal principal, krb5_keyblock *key);
krb5_error_code
krb5_string_to_key_data_salt(krb5_context context, krb5_enctype enctype,
    krb5_data password, krb5_salt salt, krb5_keyblock *key);
krb5_error_code
krb5_string_to_key_data_salt_opaque(krb5_context context,
    krb5_enctype enctype, krb5_data password, krb5_salt salt,
    krb5_data opaque, krb5_keyblock *key);
krb5_error_code
krb5_string_to_key_salt(krb5_context context, krb5_enctype enctype,
    const char *password, krb5_salt salt, krb5_keyblock *key);
krb5_error_code
krb5_string_to_key_salt_opaque(krb5_context context,
    krb5_enctype enctype, const char *password, krb5_salt salt,
    krb5_data opaque, krb5_keyblock *key);
krb5_error_code
krb5_get_pw_salt(krb5_context context, krb5_const_principal principal,
    krb5_salt *salt);
krb5_error_code
krb5_free_salt(krb5_context context, krb5_salt salt);

like, look at them all lined up. a whole friend group. 🫢


🌸 DESCRIPTION 🌸

so the string-to-key functions convert a string to a Kerberos key. simple concept, unhinged amount of functions, we love that for them.

πŸ‘‘ the main character

krb5_string_to_key_data_salt_opaque() is the one that does all the work. the rest of them? they're just wrappers around krb5_string_to_key_data_salt_opaque(), and all they do is call it with default values. so yeah β€” one girl doing the heavy lifting while the other seven stand around looking pretty. it's giving main character energy fr fr. πŸ’…

🧚 what the main character actually does

krb5_string_to_key_data_salt_opaque() transforms the password with the given salt-string salt and the opaque, encryption type specific parameter opaque to an encryption key key according to the string to key function associated with enctype.

so like: password + salt + opaque β†’ key, based on whatever enctype you handed it. that's the transformation bestie. ✨

⚠️ okay important: the key should be freed with krb5_free_keyblock_contents(). don't be out here leaking keys, that's not the vibe. 😭

🌈 and if you don't have a salt

if one of the functions that doesn't take a krb5_salt as its argument β€” then krb5_get_pw_salt() is what you use to get the salt value. so it's the backup salt-getter for the salt-less girlies.

πŸ“ krb5_get_pw_salt()

krb5_get_pw_salt() gets the default password salt for a principal. and listen β€” use krb5_free_salt() to free the salt when you're done with it. clean up after yourself, we're not messy here. πŸ™ˆ

πŸ¦‹ krb5_free_salt()

krb5_free_salt() frees the content of salt. that's it. that's her job. and she does it beautifully. πŸŽ€


⭐ SEE ALSO ⭐

go read these next, i promise they're worth it:


and that's the whole page bestie!! this lil masterpiece came to you from HEIMDAL, dated July 10, 2006, and it's officially KRB5_STRING_TO_KEY(3). no cap. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­

πŸ“¦ where this page comes from