[repo] Workspace: one crate, forbid(unsafe), no-panic lints, RustCrypto picked; Error, Instant, RandomSource, SessionKeys

This commit is contained in:
2026-11-25 11:45:23 +01:00
parent 184f4024c7
commit cb8e7ed4c3
9 changed files with 854 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
//! The per-session stream key handed to the host in `launch` / `resume` (`docs/PROTOCOL.md` 1.4, 7).
use core::fmt;
use crate::{RandomSource, Result};
/// Length of `rikey` in bytes (AES-128).
pub const RIKEY_LEN: usize = 16;
/// The stream key pair of one session: `rikey` (AES-128 key for control, audio and video) and `rikeyid`
/// (feeds the audio IV).
///
/// A fresh pair is generated for every launch and resume, because the GCM nonce counters restart per session.
/// `Debug` never prints the key.
#[derive(Clone, PartialEq, Eq)]
pub struct SessionKeys {
/// AES-128 key, sent hex-encoded as the `rikey` launch parameter.
pub rikey: [u8; RIKEY_LEN],
/// Key id, sent as the decimal `rikeyid` launch parameter.
pub rikeyid: u32,
}
impl SessionKeys {
/// Draws a fresh key and key id from `rng`.
///
/// # Errors
/// Phase A: always [`crate::Error::Unimplemented`].
pub fn generate(rng: &mut dyn RandomSource) -> Result<Self> {
let _ = rng;
Err(crate::Error::Unimplemented)
}
}
impl fmt::Debug for SessionKeys {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SessionKeys").field("rikey", &"<redacted>").field("rikeyid", &self.rikeyid).finish()
}
}