KRB5_AUTH_CONTEXT(3)
π NAME π
okay bestie, buckle up π this page is the whole girlboss squad of functions that manage authentication on the connection level. Meet the lineup:
krb5_auth_con_addflags, krb5_auth_con_free, krb5_auth_con_genaddrs, krb5_auth_con_generatelocalsubkey, krb5_auth_con_getaddrs, krb5_auth_con_getauthenticator, krb5_auth_con_getflags, krb5_auth_con_getkey, krb5_auth_con_getlocalsubkey, krb5_auth_con_getrcache, krb5_auth_con_getremotesubkey, krb5_auth_con_getuserkey, krb5_auth_con_init, krb5_auth_con_initivector, krb5_auth_con_removeflags, krb5_auth_con_setaddrs, krb5_auth_con_setaddrs_from_fd, krb5_auth_con_setflags, krb5_auth_con_setivector, krb5_auth_con_setkey, krb5_auth_con_setlocalsubkey, krb5_auth_con_setrcache, krb5_auth_con_setremotesubkey, krb5_auth_con_setuserkey, krb5_auth_context, krb5_auth_getcksumtype, krb5_auth_getkeytype, krb5_auth_getlocalseqnumber, krb5_auth_getremoteseqnumber, krb5_auth_setcksumtype, krb5_auth_setkeytype, krb5_auth_setlocalseqnumber, krb5_auth_setremoteseqnumber, krb5_free_authenticator.
and yes, this whole glow-up lives in the Library Functions Manual for KRB5_AUTH_CONTEXT(3) β¨
π LIBRARY π
it's the Kerberos 5 Library β libkrb5, -lkrb5 π
β¨ SYNOPSIS β¨
#include <krb5.h>
krb5_error_code
krb5_auth_con_init(krb5_context context,
krb5_auth_context *auth_context);
void
krb5_auth_con_free(krb5_context context,
krb5_auth_context auth_context);
krb5_error_code
krb5_auth_con_setflags(krb5_context context,
krb5_auth_context auth_context, int32_t flags);
krb5_error_code
krb5_auth_con_getflags(krb5_context context,
krb5_auth_context auth_context, int32_t *flags);
krb5_error_code
krb5_auth_con_addflags(krb5_context context,
krb5_auth_context auth_context, int32_t addflags, int32_t *flags);
krb5_error_code
krb5_auth_con_removeflags(krb5_context context,
krb5_auth_context auth_context, int32_t removelags, int32_t *flags);
krb5_error_code
krb5_auth_con_setaddrs(krb5_context context,
krb5_auth_context auth_context, krb5_address *local_addr,
krb5_address *remote_addr);
krb5_error_code
krb5_auth_con_getaddrs(krb5_context context,
krb5_auth_context auth_context, krb5_address **local_addr,
krb5_address **remote_addr);
krb5_error_code
krb5_auth_con_genaddrs(krb5_context context,
krb5_auth_context auth_context, int fd, int flags);
krb5_error_code
krb5_auth_con_setaddrs_from_fd(krb5_context context,
krb5_auth_context auth_context, void *p_fd);
krb5_error_code
krb5_auth_con_getkey(krb5_context context,
krb5_auth_context auth_context, krb5_keyblock **keyblock);
krb5_error_code
krb5_auth_con_getlocalsubkey(krb5_context context,
krb5_auth_context auth_context, krb5_keyblock **keyblock);
krb5_error_code
krb5_auth_con_getremotesubkey(krb5_context context,
krb5_auth_context auth_context, krb5_keyblock **keyblock);
krb5_error_code
krb5_auth_con_generatelocalsubkey(krb5_context context,
krb5_auth_context auth_context, krb5_keyblock, *key");
krb5_error_code
krb5_auth_con_initivector(krb5_context context,
krb5_auth_context auth_context);
krb5_error_code
krb5_auth_con_setivector(krb5_context context,
krb5_auth_context *auth_context, krb5_pointer ivector);
void
krb5_free_authenticator(krb5_context context,
krb5_authenticator *authenticator);
π DESCRIPTION π
so the krb5_auth_context structure is literally the main character of an authenticated connection β it holds all the context, kind of like how krb5_context holds the context for a thread or a process. it's what all the functions that are directly about authentication between the server and client vibe with. examples of the data it keeps? various flags, addresses of client and server, port numbers, keyblocks (and subkeys), sequence numbers, replay cache, and checksum-type. the range, honestly. π
krb5_auth_con_init() allocates and initializes the krb5_auth_context structure. the default values can be changed with krb5_auth_con_setcksumtype() and krb5_auth_con_setflags(). and bestie, the auth_context structure must be freed by krb5_auth_con_free(). don't leave her hanging. π
krb5_auth_con_getflags(), krb5_auth_con_setflags(), krb5_auth_con_addflags() and krb5_auth_con_removeflags() get and modify the flags for a krb5_auth_context structure. the possible flags to set are:
KRB5_AUTH_CONTEXT_DO_SEQUENCEβ generate and check the sequence-number on each packet. π’KRB5_AUTH_CONTEXT_DO_TIMEβ check the timestamp on incoming packets. β°KRB5_AUTH_CONTEXT_RET_SEQUENCE,KRB5_AUTH_CONTEXT_RET_TIMEβ return the sequence numbers and the time stamps in theoutdataparameters. π€KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CREDβ this one will forcekrb5_get_forwarded_creds()andkrb5_fwd_tgt_creds()to create unencrypted )KRB5_ENCTYPE_NULL) credentials. it's for use with old MIT server and JAVA based servers, since they can't handle encrypted KRB-CRED. note that sending such KRB-CRED is clear exposes crypto keys and tickets and is insecure, so make sure the packet is encrypted in the protocol. alsokrb5_rd_cred(3),krb5_rd_priv(3),krb5_rd_safe(3),krb5_mk_priv(3)andkrb5_mk_safe(3). setting this flag requires that parameter to be passed to these functions. π
β οΈ okay real talk β KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED exposes crypto keys and tickets in the clear and is insecure, fr fr. keep that packet encrypted in the protocol.
the flags KRB5_AUTH_CONTEXT_DO_TIME also modifies the behavior the function krb5_get_forwarded_creds() by removing the timestamp in the forward credential message, this have backward compatibility problems since not all versions of the heimdal supports timeless credentional messages. is very useful since it always the sender of the message to cache forward message and thus avoiding a round trip to the KDC for each time a credential is forwarded. the same functionality can be obtained by using address-less tickets. π§
krb5_auth_con_setaddrs(), krb5_auth_con_setaddrs_from_fd() and krb5_auth_con_getaddrs() get and set the addresses that are checked when a packet is received. it is mandatory to set an address for the remote host. if the local address is not set, it iss deduced from the underlaying operating system. krb5_auth_con_getaddrs() will call krb5_free_address() on any address that is passed in local_addr or remote_addr. krb5_auth_con_setaddr() allows passing in a NULL pointer as local_addr and remote_addr, in that case it will just not set that address. π
krb5_auth_con_setaddrs_from_fd() fetches the addresses from a file descriptor. π
krb5_auth_con_genaddrs() fetches the address information from the given file descriptor fd depending on the bitmap argument flags.
the possible values on flags are:
KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDRβ fetches the local address fromfd. πKRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDRβ fetches the remote address fromfd. π°οΈ
krb5_auth_con_setkey(), krb5_auth_con_setuserkey() and krb5_auth_con_getkey() get and set the key used for this auth context. the keyblock returned by krb5_auth_con_getkey() should be freed with krb5_free_keyblock(). the keyblock send into krb5_auth_con_setkey() is copied into the krb5_auth_context, and thus no special handling is needed. NULL is not a valid keyblock to krb5_auth_con_setkey(). π no cap.
krb5_auth_con_setuserkey() is only useful when doing user to user authentication. krb5_auth_con_setkey() is equivalent to krb5_auth_con_setuserkey(). π«
krb5_auth_con_getlocalsubkey(), krb5_auth_con_setlocalsubkey(), krb5_auth_con_getremotesubkey() and krb5_auth_con_setremotesubkey() get and set the keyblock for the local and remote subkey. the keyblock returned by krb5_auth_con_getlocalsubkey() and krb5_auth_con_getremotesubkey() must be freed with krb5_free_keyblock(). π
krb5_auth_setcksumtype() and krb5_auth_getcksumtype() set and get the checksum type that should be used for this connection. β
krb5_auth_con_generatelocalsubkey() generates a local subkey that have the same encryption type as key. π
krb5_auth_getremoteseqnumber() krb5_auth_setremoteseqnumber(), krb5_auth_getlocalseqnumber() and krb5_auth_setlocalseqnumber() get and set the sequence-number for the local and remote sequence-number counter. π’
krb5_auth_setkeytype() and krb5_auth_getkeytype() get and get the keytype of the keyblock in krb5_auth_context. (yes, it says get and get. we said what we said. π)
krb5_auth_con_getauthenticator() retrieves the authenticator that was used during mutual authentication. the authenticator returned should be freed by calling krb5_free_authenticator(). π«Ά
krb5_auth_con_getrcache() and krb5_auth_con_setrcache() get and set the replay-cache. π¬
krb5_auth_con_initivector() allocates memory for and zeros the initial vector in the auth_context keyblock. πΈ
krb5_auth_con_setivector() sets the i_vector portion of auth_context to ivector. π¦
krb5_free_authenticator() free the content of authenticator and authenticator itself. π
π SEE ALSO π
and that's the whole page, bestie π this iconic little manual is from HEIMDAL, dated May 17, 2005 β shoutout to the Library Functions Manual, KRB5_AUTH_CONTEXT(3), we love her, periodt. πβ¨
π¦ 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
- 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) 2001 - 2005 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms