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_keykrb5_string_to_key_datakrb5_string_to_key_data_saltkrb5_string_to_key_data_salt_opaquekrb5_string_to_key_saltkrb5_string_to_key_salt_opaquekrb5_get_pw_saltkrb5_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:
krb5(3)krb5_data(3)krb5_keyblock(3)kerberos(8)
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
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- debian bookworm: heimdal-dev 7.8.git20221117.28daf24+dfsg-2 Β· BSD-3-Clause
- debian trixie: heimdal-dev 7.8.git20221117.28daf24+dfsg-9+deb13u1 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- freebsd 14.5: base 14.5
- nixpkgs unstable: heimdal 7.8.0-unstable-2024-09-10
- ubuntu jammy: heimdal-dev 7.7.0+dfsg-3ubuntu1 Β· BSD-3-Clause
- ubuntu noble: heimdal-dev 7.8.git20221117.28daf24+dfsg-5ubuntu3 Β· BSD-3-Clause
- ubuntu questing: heimdal-dev 7.8.git20221117.28daf24+dfsg-9ubuntu1
- ubuntu resolute: heimdal-dev 7.8.git20221117.28daf24+dfsg-11ubuntu1 Β· BSD-3-Clause
- ubuntu stonking: heimdal-dev 7.8.git20240113.1b4565a+dfsg-2ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2004 - 2006 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms