|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
SSH RSA host-key layer: NVS/fixture host key, host-key signing, "ssh-rsa" blob (see ssh_rsa.h). More...
#include "network_drivers/presentation/ssh/crypto/ssh_rsa.h"#include "crypto/asymmetric/rsa.h"#include "crypto/hash/sha256.h"#include "crypto/hash/sha512.h"#include "network_drivers/presentation/ssh/transport/ssh_keymat.h"#include "server/mmgr/secure.h"#include <string.h>#include <Preferences.h>#include <esp_random.h>#include <freertos/FreeRTOS.h>#include <freertos/semphr.h>#include <mbedtls/md.h>#include <mbedtls/pk.h>#include <mbedtls/rsa.h>Go to the source code of this file.
Classes | |
| struct | SshRsaCtx |
Functions | |
| int | pc_ssh_rsa_load_pubkey (void) |
| Load the public portion of the RSA host key into ssh_host_pubkey. | |
| int | ssh_rsa_sign (const uint8_t *msg, size_t msg_len, pc_rsa_hash hash, uint8_t sig[PC_RSA_SIG_BYTES]) |
Sign msg with the RSA host key (PKCS#1 v1.5, rsa-sha2-256/512). | |
| int | ssh_rsa_encode_pubkey (uint8_t *out, size_t *out_len, size_t out_cap) |
| Encode ssh_host_pubkey as the RFC 4253 §6.6 "ssh-rsa" public-key blob. | |
Variables | |
| SshRsaPubKey | ssh_host_pubkey |
| Static host public key (BSS). Set by pc_ssh_rsa_load_pubkey(). | |
SSH RSA host-key layer: NVS/fixture host key, host-key signing, "ssh-rsa" blob (see ssh_rsa.h).
The RSASSA-PKCS1-v1.5 math lives in crypto/rsa; this file owns the SSH host key and calls into it.
Definition in file ssh_rsa.cpp.
| int pc_ssh_rsa_load_pubkey | ( | void | ) |
Load the public portion of the RSA host key into ssh_host_pubkey.
Arduino: reads + parses the DER blob from NVS ("ssh_host_key"/"priv_der") and caches the signer context. Native: reads n/e from the test fixture. Call once at startup (single-threaded).
Definition at line 58 of file ssh_rsa.cpp.
References SshRsaPubKey::e_bytes, SshRsaPubKey::loaded, SshRsaCtx::lock, SshRsaPubKey::n, PC_RSA_KEY_BYTES, SshRsaCtx::pk, SshRsaCtx::ready, ssh_host_pubkey, and SSH_RSA_KEY_DER_MAX.
Referenced by ssh_rsa_sign().
| int ssh_rsa_sign | ( | const uint8_t * | msg, |
| size_t | msg_len, | ||
| pc_rsa_hash | hash, | ||
| uint8_t | sig[PC_RSA_SIG_BYTES] | ||
| ) |
Sign msg with the RSA host key (PKCS#1 v1.5, rsa-sha2-256/512).
sig receives PC_RSA_SIG_BYTES big-endian. Definition at line 126 of file ssh_rsa.cpp.
References SshRsaCtx::lock, PC_RSA_SIG_BYTES, pc_sha256(), PC_SHA256_DIGEST_LEN, pc_sha512(), PC_SHA512_DIGEST_LEN, pc_ssh_rsa_load_pubkey(), SshRsaCtx::pk, SshRsaCtx::ready, and SHA512.
| int ssh_rsa_encode_pubkey | ( | uint8_t * | out, |
| size_t * | out_len, | ||
| size_t | out_cap | ||
| ) |
Encode ssh_host_pubkey as the RFC 4253 §6.6 "ssh-rsa" public-key blob.
out_len), -1 if the key is not loaded or out_cap is too small. Definition at line 230 of file ssh_rsa.cpp.
References SshRsaPubKey::e_bytes, SshRsaPubKey::loaded, SshRsaPubKey::n, PC_RSA_KEY_BYTES, ssh_host_pubkey, SSH_RSA_PUBKEY_ALG, SSH_RSA_PUBKEY_ALG_LEN, and SSH_RSA_PUBKEY_BLOB_MAX.
| SshRsaPubKey ssh_host_pubkey |
Static host public key (BSS). Set by pc_ssh_rsa_load_pubkey().
Definition at line 29 of file ssh_rsa.cpp.
Referenced by pc_ssh_rsa_load_pubkey(), and ssh_rsa_encode_pubkey().