14#ifndef PROTOCORE_AUTH_AUTH_H
15#define PROTOCORE_AUTH_AUTH_H
18#include "spatium/spatium.h"
50typedef embed_bool (*
SshPasswordCb)(
const char *user,
const char *password);
63typedef void (*
SshPasswordChangeCb)(uint8_t slot,
const char *user,
const char *old_password,
const char *new_password);
147typedef embed_bool (*
SshPubkeyCb)(
const char *user,
const uint8_t *blob,
size_t blob_len);
171#if PROTOCORE_ENABLE_SSH_KEYBOARD_INTERACTIVE
268#if PROTOCORE_ENABLE_SSH_KEYBOARD_INTERACTIVE
286 void (*
const reset)(
const uint8_t *work);
310#if PROTOCORE_ENABLE_SSH_KEYBOARD_INTERACTIVE
311void protocore_ssh_auth_handle_info_response(uint8_t *work);
319static const SshAuthNs SshAuth __attribute__((unused)) = {
333#if PROTOCORE_ENABLE_SSH_KEYBOARD_INTERACTIVE
334 .handle_info_response = protocore_ssh_auth_handle_info_response,
#define SSH_AUTH_PASS_MAX
Max stored password length.
#define SSH_AUTH_ALGO_MAX
Max stored public-key algorithm name ("rsa-sha2-512", "ecdsa-sha2-nistp256", RFC 4253 sec 6....
#define SSH_AUTH_USER_MAX
Max stored user name (RFC 4252 imposes no limit; we cap for BSS).
Root infrastructure: fixed widths, serializers, opcodes and sizes, for every layer above.
embed_bool(* SshPubkeyCb)(const char *user, const uint8_t *blob, size_t blob_len)
Drop a parked password change without replying to it.
SshPwChange
A slot's password-change state: idle, handed to the application, or finished either way.
@ PROTOCORE_SSH_PW_CHANGE_NONE
@ PROTOCORE_SSH_PW_CHANGE_FAIL
@ PROTOCORE_SSH_PW_CHANGE_BUSY
@ PROTOCORE_SSH_PW_CHANGE_OK
void protocore_ssh_auth_build_success(const uint8_t *work)
void protocore_ssh_auth_reset(const uint8_t *work)
void protocore_ssh_auth_pw_change_clear(const uint8_t *work)
SshPwChange protocore_ssh_auth_pw_change_take(uint8_t i)
Install the password-change start callback (nullptr → change requests are refused busy).
void protocore_ssh_auth_passwd_change_reply(const uint8_t *work)
void protocore_ssh_auth_set_password_cb(const uint8_t *work)
void protocore_ssh_auth_write_publickey_request(const uint8_t *work)
void protocore_ssh_auth_set_password_change_cb(const uint8_t *work)
void protocore_ssh_auth_timed_out(const uint8_t *work)
void protocore_ssh_auth_parse_request(const uint8_t *work)
uint8_t * protocore_ssh_auth_span(void)
The PROTOCORE_SSH_AUTH_BORROW bytes this module's state lives in.
embed_bool(* SshPasswordCb)(const char *user, const char *password)
Application callback that validates a username/password pair.
void protocore_ssh_auth_pw_change_report(const uint8_t *work)
SshAuthVars SshAuthV
The operands and the outcome.
void(* SshPasswordChangeCb)(uint8_t slot, const char *user, const char *old_password, const char *new_password)
Install the password-verification callback (nullptr → all fail).
void protocore_ssh_auth_build_failure(const uint8_t *work)
void protocore_ssh_auth_set_pubkey_cb(const uint8_t *work)
void protocore_ssh_auth_dispatch(uint8_t *work)
void protocore_ssh_auth_handle_request(const uint8_t *work)
RFC 4252 sec 7 / sec 8: what an attempt of each method is checked against.
SshPubkeyCb pubkey_cb
what a public key is checked against
SshPasswordCb password_cb
what a password attempt is checked against
SshPasswordChangeCb password_change_cb
what a change request is handed to
Install the publickey-authorization callback (nullptr → all fail).
size_t len
how many bytes it has
const uint8_t * payload
the message body
void(*const reset)(const uint8_t *work)
void(*const build_success)(const uint8_t *work)
void(*const pw_change_clear)(const uint8_t *work)
void(*const passwd_change_reply)(const uint8_t *work)
void(*const dispatch)(uint8_t *work)
void(*const write_publickey_request)(const uint8_t *work)
void(*const set_password_cb)(const uint8_t *work)
void(*const handle_info_response)(uint8_t *work)
void(*const set_pubkey_cb)(const uint8_t *work)
void(*const set_password_change_cb)(const uint8_t *work)
void(*const build_failure)(const uint8_t *work)
void(*const pw_change_report)(const uint8_t *work)
void(*const handle_request)(const uint8_t *work)
void(*const timed_out)(const uint8_t *work)
void(*const parse_request)(const uint8_t *work)
Where a reply is written, either as a buffer or as a span.
size_t out_len
what was written
size_t cap
how much room it has
uint8_t * out
where a reply is written
mmgr_span * w
the span a publickey request is built in
Parsed SSH_MSG_USERAUTH_REQUEST.
char method[24]
Method name ("none", "password", "publickey", "keyboard-interactive").
const uint8_t * signature
Raw signature bytes (points into the payload).
embed_bool is_pubkey
True if a publickey method-request was parsed.
char password[SSH_AUTH_PASS_MAX]
Password (method == "password"); the old one on a change.
char user[SSH_AUTH_USER_MAX]
User name, null-terminated.
uint32_t pk_blob_len
Length of pk_blob.
char service[32]
Requested service ("ssh-connection").
size_t signed_prefix_len
Length of signed_prefix (payload up to the signature).
embed_bool is_kbdint
True if a keyboard-interactive method-request was parsed (RFC 4256).
const uint8_t * pk_blob
Public-key blob (points into the payload).
const uint8_t * signed_prefix
Bytes of the request that the signature covers.
uint32_t signature_len
Length of signature.
embed_bool is_password
True if a password method-request was parsed.
char new_password[SSH_AUTH_PASS_MAX]
New password when is_pw_change (RFC 4252 sec 8).
embed_bool is_pw_change
True if the request set the change-password flag.
char pk_algo[SSH_AUTH_ALGO_MAX]
Public-key algorithm name.
embed_bool has_signature
True if the request carried a signature.
SshAuthMsgArgs msg
sec 5 the message body a dispatch is given
uint8_t slot
the SSH slot a call acts on
SshAuthReq * req
where a parse lands the request (sec 5)
uint8_t msg_type
the message a dispatch routes
embed_bool partial
the failure is a partial success (sec 5.1)
SshAuthOutArgs out_args
where a reply is written
SshAuthCbs cbs
what an attempt is checked against
SshUserauthArgs userauth
sec 5 / sec 7 the fields one request names
RFC 4252 sec 5 / sec 7: the names one USERAUTH_REQUEST carries, and the key it offers.
const char * user
the user name
const char * service
the service name, normally "ssh-connection"
size_t sid_len
its length; ignored when sid is NULL
const uint8_t * pk_blob
the public key blob
const char * pk_algo
the public key algorithm name
const uint8_t * sid
the session identifier it signs over, or NULL for the request form