ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
SshKeyMat Struct Reference

AES-256-CTR + HMAC-SHA2-256 session keys for one SSH connection. More...

#include <ssh_keymat.h>

Public Attributes

uint8_t aes_key_c2s [PC_AES256CTR_KEY_LEN]
 AES key C→S (server decrypts inbound).
 
uint8_t aes_key_s2c [PC_AES256CTR_KEY_LEN]
 AES key S→C (server encrypts outbound).
 
uint8_t aes_iv_c2s [PC_AES256CTR_CTR_LEN]
 AES IV C→S (CTR counter / GCM nonce); advances per packet.
 
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 mac_key_s2c [64]
 HMAC key, server-to-client (aes mode).
 
uint8_t mac_mode
 SSH_MAC_* selected for the aes256-ctr cipher (0 = hmac-sha2-256 E&M).
 
uint8_t cipher_mode
 SSH_CIPHER_* selected for this session (0 = aes256-ctr).
 
uint8_t chacha_key_c2s [PC_CHACHAPOLY_KEY_LEN]
 client-to-server, used only in chacha mode.
 
uint8_t chacha_key_s2c [PC_CHACHAPOLY_KEY_LEN]
 server-to-client, used only in chacha mode.
 
uint8_t gcm_ctx_c2s [PC_WORK_AESGCM]
 keyed GCM context C→S (server opens inbound).
 
uint8_t gcm_ctx_s2c [PC_WORK_AESGCM]
 keyed GCM context S→C (server seals outbound).
 
bool active
 True once keys are installed after successful KEX.
 

Detailed Description

AES-256-CTR + HMAC-SHA2-256 session keys for one SSH connection.

This struct occupies a separate BSS symbol (ssh_keys[]) from the packet receive buffer (ssh_pool[].pkt_buf). See the security model at the top of this file for why that separation matters.

Key derivation follows RFC 4253 §7.2. After the DH exchange hash H is known and K is available, six values are derived:

IV_c2s = SHA256(K || H || "A" || session_id) [16 bytes] IV_s2c = SHA256(K || H || "B" || session_id) [16 bytes] key_c2s = SHA256(K || H || "C" || session_id) [32 bytes] key_s2c = SHA256(K || H || "D" || session_id) [32 bytes] mac_c2s = SHA256(K || H || "E" || session_id) [32 bytes] mac_s2c = SHA256(K || H || "F" || session_id) [32 bytes]

aes_key/aes_ctr C→S are the client-to-server key + counter (server decrypts inbound); S→C are the reverse (server encrypts outbound).

Definition at line 172 of file ssh_keymat.h.

Member Data Documentation

◆ aes_key_c2s

uint8_t SshKeyMat::aes_key_c2s[PC_AES256CTR_KEY_LEN]

AES key C→S (server decrypts inbound).

Definition at line 180 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ aes_key_s2c

uint8_t SshKeyMat::aes_key_s2c[PC_AES256CTR_KEY_LEN]

AES key S→C (server encrypts outbound).

Definition at line 181 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ aes_iv_c2s

uint8_t SshKeyMat::aes_iv_c2s[PC_AES256CTR_CTR_LEN]

AES IV C→S (CTR counter / GCM nonce); advances per packet.

Definition at line 182 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ aes_iv_s2c

uint8_t SshKeyMat::aes_iv_s2c[PC_AES256CTR_CTR_LEN]

AES IV S→C (CTR counter / GCM nonce); advances per packet.

Definition at line 183 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ mac_key_c2s

uint8_t SshKeyMat::mac_key_c2s[64]

HMAC key, client-to-server (aes mode); 32 bytes for SHA-256, 64 for SHA-512.

Definition at line 185 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ mac_key_s2c

uint8_t SshKeyMat::mac_key_s2c[64]

HMAC key, server-to-client (aes mode).

Definition at line 186 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ mac_mode

uint8_t SshKeyMat::mac_mode

SSH_MAC_* selected for the aes256-ctr cipher (0 = hmac-sha2-256 E&M).

Definition at line 187 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid(), ssh_pkt_recv(), and ssh_pkt_send().

◆ cipher_mode

uint8_t SshKeyMat::cipher_mode

SSH_CIPHER_* selected for this session (0 = aes256-ctr).

Definition at line 189 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid(), ssh_pkt_recv(), and ssh_pkt_send().

◆ chacha_key_c2s

uint8_t SshKeyMat::chacha_key_c2s[PC_CHACHAPOLY_KEY_LEN]

client-to-server, used only in chacha mode.

Definition at line 191 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ chacha_key_s2c

uint8_t SshKeyMat::chacha_key_s2c[PC_CHACHAPOLY_KEY_LEN]

server-to-client, used only in chacha mode.

Definition at line 192 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ gcm_ctx_c2s

uint8_t SshKeyMat::gcm_ctx_c2s[PC_WORK_AESGCM]

keyed GCM context C→S (server opens inbound).

Definition at line 202 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ gcm_ctx_s2c

uint8_t SshKeyMat::gcm_ctx_s2c[PC_WORK_AESGCM]

keyed GCM context S→C (server seals outbound).

Definition at line 203 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().

◆ active

bool SshKeyMat::active

True once keys are installed after successful KEX.

Definition at line 205 of file ssh_keymat.h.

Referenced by ssh_dh_derive_keys_sid().


The documentation for this struct was generated from the following file: