Authdial dials an authentication server over the network rooted at net, default /net. The authentication domain, ad, specifies which server to call. If ad is non-nil, the connection server cs (see ndb(8)) is queried for an entry which contains authdom=ad or dom=ad, the former having precedence, and which also contains an auth attribute. If it finds neither, it tries p9auth.ad in DNS as the authentication server. The string dialed is then netroot!server!ticket where server is the value of the auth attribute. If no entry is found, the error string is set to "no authentication server found" and -1 is returned. If authdom is nil, the string netroot!$auth!ticket is used to make the call.
Passtokey converts password into a set of cryptographic keys and stores them in the Authkey structure key.
ConvT2M, convA2M, convTR2M, and convPR2M convert tickets, authenticators, ticket requests, and password change request structures into transmittable messages. ConvM2T, convM2A, convM2TR, and convM2PR are used to convert them back. Key is used for encrypting the message before transmission and decrypting after reception. ConvA2M, convM2A, convPR2M and convM2PR encrypt/decrypt the message with the random ticket key.
The routine _asgetticket sends a ticket request tr returning the two encrypted tickets in buf. The routine _asrequest encodes the ticket request tr and sends it not waiting for a response. After sending a request, _asgetresp can be used to receive the response containing a ticket and an optional authenticator and decrypts the ticket and authenticator using key. The routine _asrdresp receives either a character array or an error string. On error, it sets errstr and returns -1. If successful, it returns the number of bytes received.
Authpak_hash prepares a Authkey structure for a password authenticated key exchange (see authsrv(6)) by calculating the pakhash from a user's aeskey and id u. The fuction hashes the password derived aeskey and user id together using hmac_sha256 and maps the result into two elliptic curve points PN/PM on the Ed448-goldielocks curve using elligator2.
Authpak_new generates a new elliptic curve diffie-hellman key pair for a password authenticated key exchange from a previously hashed Authkey structure k. The randomly generated private key is returned in the PAKpriv structure passed in p, while the pakhash encrytped public key is returned in y.
Authpak_finish completes a password authenticated key exchange, taking the other sides pakhash encrypted public key y and our private key p returning the shared secret pakkey in the Authkey structure k. The function returns zero on success or non-zero on failure (malformed public key).
The function _asgetpakkey establishes a new shared pakkey between the us and the authentication server for ticket encryption; using the functions above; taking a previously hashed Authkey a and Ticketreq tr and returns the shared pakkey in the Authkey structure. It is usually called before _asrequest right after authdial to negotiate bruteforce resistant ticket encryption for the ticket request that follows (see authsrv(6)). Returns zero on success, or non-zero on error (authenticatoin server does not support the AuthPAK request or when we got a malformed public key).