95#ifndef PROTOCORE_SSH_KEYMAT_H
96#define PROTOCORE_SSH_KEYMAT_H
135static inline bool ssh_mac_is_etm(uint8_t mac_mode)
140static inline uint8_t ssh_mac_len(uint8_t mac_mode)
255static inline void ssh_keymat_wipe(uint8_t i)
271static inline void ssh_dh_wipe(uint8_t i)
AES-256-CTR stream cipher (aes256-ctr, RFC 4344 §4) - stateless one-shot API.
#define PC_AES256CTR_CTR_LEN
AES-256-CTR counter/IV block length (bytes).
#define PC_AES256CTR_KEY_LEN
AES-256-CTR key length (bytes).
AES-256-GCM AEAD (RFC 5116) - stateless, detached-tag API.
2048-bit big-integer arithmetic for DH-group14 and RSA-2048.
chacha20-poly1305@openssh.com AEAD cipher (OpenSSH PROTOCOL.chacha20poly1305).
#define PC_CHACHAPOLY_KEY_LEN
two 256-bit ChaCha20 keys
void pc_aesgcm_key_wipe(pc_aesgcm_key *k)
Wipe the expanded schedule. Call on rekey and on close; the storage stays the caller's.
User-facing configuration for ProtoCore.
Secure pool accessor - borrows that hold key material.
@ SSH_CIPHER_CHACHA20POLY1305
chacha20-poly1305@openssh.com (AEAD; no separate MAC)
@ SSH_CIPHER_AES256GCM
aes256-gcm@openssh.com (AEAD, RFC 5647; no separate MAC)
@ SSH_CIPHER_AES256CTR
aes256-ctr + a separate HMAC (the fallback)
SshDhState ssh_dh[MAX_SSH_CONNS]
Pool of ephemeral DH state, one entry per MAX_SSH_CONNS.
SshKeyMat ssh_keys[MAX_SSH_CONNS]
Pool of session key material, one entry per MAX_SSH_CONNS.
@ SSH_MAC_HMAC_SHA256_ETM
hmac-sha2-256-etm@openssh.com (encrypt-then-MAC)
@ SSH_MAC_HMAC_SHA256
hmac-sha2-256 (encrypt-and-MAC, RFC 4253)
@ SSH_MAC_HMAC_SHA512
hmac-sha2-512 (encrypt-and-MAC)
@ SSH_MAC_HMAC_SHA512_ETM
hmac-sha2-512-etm@openssh.com (encrypt-then-MAC)
Ephemeral Diffie-Hellman state for one SSH connection.
uint8_t H[32]
SHA-256 exchange hash; doubles as session_id after first KEX.
pc_bignum f
Server DH public value = g^y mod p (sent to client).
bool kex_done
True once NEWKEYS has been sent and received.
pc_bignum K
Shared DH secret = e^y mod p (SENSITIVE - wiped after key derivation).
pc_bignum y
Server ephemeral private DH scalar (SENSITIVE - wiped after KEX).
AES-256-CTR + HMAC-SHA2-256 session keys for one SSH connection.
uint8_t aes_iv_c2s[PC_AES256CTR_CTR_LEN]
AES IV C→S (CTR counter / GCM nonce); advances per packet.
uint8_t chacha_key_s2c[PC_CHACHAPOLY_KEY_LEN]
server-to-client, used only in chacha mode.
uint8_t aes_iv_s2c[PC_AES256CTR_CTR_LEN]
AES IV S→C (CTR counter / GCM nonce); advances per packet.
uint8_t mac_key_c2s[64]
HMAC key, client-to-server (aes mode); 32 bytes for SHA-256, 64 for SHA-512.
uint8_t gcm_ctx_s2c[PC_WORK_AESGCM]
keyed GCM context S→C (server seals outbound).
uint8_t aes_key_c2s[PC_AES256CTR_KEY_LEN]
AES key C→S (server decrypts inbound).
uint8_t cipher_mode
SSH_CIPHER_* selected for this session (0 = aes256-ctr).
uint8_t mac_key_s2c[64]
HMAC key, server-to-client (aes mode).
bool active
True once keys are installed after successful KEX.
uint8_t chacha_key_c2s[PC_CHACHAPOLY_KEY_LEN]
client-to-server, used only in chacha mode.
uint8_t mac_mode
SSH_MAC_* selected for the aes256-ctr cipher (0 = hmac-sha2-256 E&M).
uint8_t aes_key_s2c[PC_AES256CTR_KEY_LEN]
AES key S→C (server encrypts outbound).
uint8_t gcm_ctx_c2s[PC_WORK_AESGCM]
keyed GCM context C→S (server opens inbound).
A 2048-bit unsigned integer stored as 64 little-endian 32-bit limbs.