Add M10.9d load drill harness and serialize Mbed TLS use
Foundation / checks (deploy) (push) Successful in 3m24s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m18s
Foundation / checks (network) (push) Successful in 13m30s
Foundation / checks (tsan) (push) Successful in 8m0s
Foundation / checks (checks) (push) Successful in 32m39s
Foundation / checks (postgres) (push) Successful in 45m47s
Foundation / postgres-tools (push) Successful in 17s
Foundation / image (push) Successful in 2m30s
Foundation / server-image (push) Successful in 4m8s
Foundation / checks (deploy) (push) Successful in 3m24s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m18s
Foundation / checks (network) (push) Successful in 13m30s
Foundation / checks (tsan) (push) Successful in 8m0s
Foundation / checks (checks) (push) Successful in 32m39s
Foundation / checks (postgres) (push) Successful in 45m47s
Foundation / postgres-tools (push) Successful in 17s
Foundation / image (push) Successful in 2m30s
Foundation / server-image (push) Successful in 4m8s
ADR-0097. tools/ops/load-drill.sh (runbook docs/networking/M10_LOAD_DRILL.md) runs the evolution-dev reference qualification: synthetic inputs on for the run (the ADR-0073 drill-time override, restored on exit), bundle-mode evo-load bots through the public route, and each step's hold matched with the server's reports. evo-server logs "m10 load-report" every 10 s, since the agent cannot reach the ops port. evo-load gains --grants FILE --grants-per-bot C, exhausted=, hold_utc= and close_reasons=; evo-session-probe grants gains --accounts N. Finding: Mbed TLS/PSA are built without MBEDTLS_THREADING_C, and bots on different threads verifying their first connections at once were refused as untrusted (two per smoke run). One process-wide recursive crypto lock now guards every network-library entry point that touches them; the smoke went from 2/2 failing to 3/3 clean. quic-transport adds a concurrent-connect test. Refreshes the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "evo/network/handoff_ticket.hpp"
|
||||
#include "evo/network/crypto_lock.hpp"
|
||||
#include <algorithm>
|
||||
#include <psa/crypto.h>
|
||||
#include <utility>
|
||||
@@ -57,6 +58,7 @@ bool looks_like_handoff_ticket(std::span<const std::uint8_t> bytes) noexcept {
|
||||
|
||||
std::expected<HandoffSigningKey, HandoffTicketError>
|
||||
HandoffSigningKey::generate(DeploymentEnvironment environment, std::uint32_t key_id) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_id == 0)
|
||||
return std::unexpected(HandoffTicketError::invalid_key);
|
||||
if (psa_crypto_init() != PSA_SUCCESS)
|
||||
@@ -73,6 +75,7 @@ HandoffSigningKey::generate(DeploymentEnvironment environment, std::uint32_t key
|
||||
std::expected<HandoffSigningKey, HandoffTicketError>
|
||||
HandoffSigningKey::import(DeploymentEnvironment environment, std::uint32_t key_id,
|
||||
std::span<const std::uint8_t> private_key) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_id == 0 || private_key.size() != grant_private_key_bytes)
|
||||
return std::unexpected(HandoffTicketError::invalid_key);
|
||||
if (psa_crypto_init() != PSA_SUCCESS)
|
||||
@@ -90,6 +93,7 @@ HandoffSigningKey::HandoffSigningKey(HandoffSigningKey&& other) noexcept
|
||||
key_{std::exchange(other.key_, PSA_KEY_ID_NULL)} {}
|
||||
|
||||
HandoffSigningKey& HandoffSigningKey::operator=(HandoffSigningKey&& other) noexcept {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (this != &other) {
|
||||
if (key_ != PSA_KEY_ID_NULL)
|
||||
(void)psa_destroy_key(key_);
|
||||
@@ -101,12 +105,14 @@ HandoffSigningKey& HandoffSigningKey::operator=(HandoffSigningKey&& other) noexc
|
||||
}
|
||||
|
||||
HandoffSigningKey::~HandoffSigningKey() {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_ != PSA_KEY_ID_NULL)
|
||||
(void)psa_destroy_key(key_);
|
||||
}
|
||||
|
||||
std::expected<HandoffTicket, HandoffTicketError>
|
||||
HandoffSigningKey::sign(const TicketClaims& claims) const {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_ == PSA_KEY_ID_NULL)
|
||||
return std::unexpected(HandoffTicketError::invalid_key);
|
||||
if (!structurally_valid(claims))
|
||||
@@ -134,6 +140,7 @@ HandoffSigningKey::sign(const TicketClaims& claims) const {
|
||||
}
|
||||
|
||||
std::expected<GrantPublicKey, HandoffTicketError> HandoffSigningKey::public_key() const {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_ == PSA_KEY_ID_NULL)
|
||||
return std::unexpected(HandoffTicketError::invalid_key);
|
||||
GrantPublicKey out{};
|
||||
@@ -147,6 +154,7 @@ std::expected<GrantPublicKey, HandoffTicketError> HandoffSigningKey::public_key(
|
||||
std::expected<HandoffVerifier, HandoffTicketError>
|
||||
HandoffVerifier::create(DeploymentEnvironment environment, world::WorldIdentity world,
|
||||
std::uint64_t region) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (world.world == 0 || world.frame == 0 || region == 0)
|
||||
return std::unexpected(HandoffTicketError::invalid_claims);
|
||||
if (psa_crypto_init() != PSA_SUCCESS)
|
||||
@@ -174,6 +182,7 @@ HandoffVerifier::~HandoffVerifier() {
|
||||
}
|
||||
|
||||
void HandoffVerifier::destroy() noexcept {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
for (const auto& k : keys_)
|
||||
(void)psa_destroy_key(k.key);
|
||||
keys_.clear();
|
||||
@@ -182,6 +191,7 @@ void HandoffVerifier::destroy() noexcept {
|
||||
std::expected<void, HandoffTicketError>
|
||||
HandoffVerifier::add_key(std::uint64_t source_region, std::uint32_t key_id,
|
||||
std::span<const std::uint8_t> public_key) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (source_region == 0 || source_region == region_ || key_id == 0 ||
|
||||
public_key.size() != grant_public_key_bytes)
|
||||
return std::unexpected(HandoffTicketError::invalid_key);
|
||||
@@ -204,6 +214,7 @@ HandoffVerifier::add_key(std::uint64_t source_region, std::uint32_t key_id,
|
||||
|
||||
std::expected<VerifiedHandoffTicket, HandoffTicketError>
|
||||
HandoffVerifier::verify(std::span<const std::uint8_t> ticket, std::uint64_t now_seconds) const {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (ticket.size() != handoff_ticket_bytes)
|
||||
return std::unexpected(HandoffTicketError::malformed);
|
||||
// The key id only selects which key must verify; it is itself signed.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "evo/network/crypto_lock.hpp"
|
||||
#include <algorithm>
|
||||
#include <psa/crypto.h>
|
||||
#include <type_traits>
|
||||
@@ -51,6 +52,7 @@ psa_key_attributes_t pair_attributes() {
|
||||
} // namespace
|
||||
|
||||
std::expected<void, SessionGrantError> random_bytes(std::span<std::uint8_t> out) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (psa_crypto_init() != PSA_SUCCESS ||
|
||||
psa_generate_random(out.data(), out.size()) != PSA_SUCCESS)
|
||||
return std::unexpected(SessionGrantError::crypto);
|
||||
@@ -68,6 +70,7 @@ std::expected<AccountId, SessionGrantError> generate_account_id() {
|
||||
|
||||
std::expected<GrantSigningKey, SessionGrantError>
|
||||
GrantSigningKey::generate(DeploymentEnvironment environment, std::uint32_t key_id) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_id == 0)
|
||||
return std::unexpected(SessionGrantError::invalid_key);
|
||||
if (psa_crypto_init() != PSA_SUCCESS)
|
||||
@@ -84,6 +87,7 @@ GrantSigningKey::generate(DeploymentEnvironment environment, std::uint32_t key_i
|
||||
std::expected<GrantSigningKey, SessionGrantError>
|
||||
GrantSigningKey::import(DeploymentEnvironment environment, std::uint32_t key_id,
|
||||
std::span<const std::uint8_t> private_key) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_id == 0 || private_key.size() != grant_private_key_bytes)
|
||||
return std::unexpected(SessionGrantError::invalid_key);
|
||||
if (psa_crypto_init() != PSA_SUCCESS)
|
||||
@@ -101,6 +105,7 @@ GrantSigningKey::GrantSigningKey(GrantSigningKey&& other) noexcept
|
||||
key_{std::exchange(other.key_, PSA_KEY_ID_NULL)} {}
|
||||
|
||||
GrantSigningKey& GrantSigningKey::operator=(GrantSigningKey&& other) noexcept {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (this != &other) {
|
||||
if (key_ != PSA_KEY_ID_NULL)
|
||||
(void)psa_destroy_key(key_);
|
||||
@@ -112,12 +117,14 @@ GrantSigningKey& GrantSigningKey::operator=(GrantSigningKey&& other) noexcept {
|
||||
}
|
||||
|
||||
GrantSigningKey::~GrantSigningKey() {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_ != PSA_KEY_ID_NULL)
|
||||
(void)psa_destroy_key(key_);
|
||||
}
|
||||
|
||||
std::expected<SessionGrant, SessionGrantError>
|
||||
GrantSigningKey::sign(const GrantClaims& claims) const {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_ == PSA_KEY_ID_NULL)
|
||||
return std::unexpected(SessionGrantError::invalid_key);
|
||||
if (!structurally_valid(claims))
|
||||
@@ -145,6 +152,7 @@ GrantSigningKey::sign(const GrantClaims& claims) const {
|
||||
}
|
||||
|
||||
std::expected<GrantPublicKey, SessionGrantError> GrantSigningKey::public_key() const {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_ == PSA_KEY_ID_NULL)
|
||||
return std::unexpected(SessionGrantError::invalid_key);
|
||||
GrantPublicKey out{};
|
||||
@@ -157,6 +165,7 @@ std::expected<GrantPublicKey, SessionGrantError> GrantSigningKey::public_key() c
|
||||
|
||||
std::expected<GrantVerifier, SessionGrantError>
|
||||
GrantVerifier::create(DeploymentEnvironment environment) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (psa_crypto_init() != PSA_SUCCESS)
|
||||
return std::unexpected(SessionGrantError::crypto);
|
||||
return GrantVerifier{environment};
|
||||
@@ -179,6 +188,7 @@ GrantVerifier::~GrantVerifier() {
|
||||
}
|
||||
|
||||
void GrantVerifier::destroy() noexcept {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
for (const auto& k : keys_)
|
||||
(void)psa_destroy_key(k.key);
|
||||
keys_.clear();
|
||||
@@ -186,6 +196,7 @@ void GrantVerifier::destroy() noexcept {
|
||||
|
||||
std::expected<void, SessionGrantError>
|
||||
GrantVerifier::add_key(std::uint32_t key_id, std::span<const std::uint8_t> public_key) {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (key_id == 0 || public_key.size() != grant_public_key_bytes)
|
||||
return std::unexpected(SessionGrantError::invalid_key);
|
||||
if (std::ranges::any_of(keys_, [&](const Key& k) { return k.key_id == key_id; }))
|
||||
@@ -207,6 +218,7 @@ GrantVerifier::add_key(std::uint32_t key_id, std::span<const std::uint8_t> publi
|
||||
|
||||
std::expected<VerifiedSessionGrant, SessionGrantError>
|
||||
GrantVerifier::verify(std::span<const std::uint8_t> grant) const {
|
||||
const CryptoLock crypto{crypto_mutex()};
|
||||
if (grant.size() != session_grant_bytes)
|
||||
return std::unexpected(SessionGrantError::malformed);
|
||||
// The key id only selects which key must verify; it is itself signed.
|
||||
|
||||
Reference in New Issue
Block a user