pub struct TransportCrypto { /* private fields */ }Expand description
Symmetric payload encryption (XChaCha20-Poly1305).
Implementations§
Source§impl TransportCrypto
impl TransportCrypto
Sourcepub fn from_bytes(key: [u8; 32]) -> Self
pub fn from_bytes(key: [u8; 32]) -> Self
Build from an explicit 32-byte key.
Callers own key material and secrecy. Prefer this in tests and when wiring a key from a secrets manager rather than the process environment.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Load key from PHOTON_TRANSPORT_KEY (standard base64 encoding of exactly 32 bytes).
§Errors
Returns PhotonError::Internal when the variable is missing, not valid
base64, or does not decode to 32 bytes. Production hosts should fail closed here.
§Contract
Does not fall back to a development key. Use Self::from_env_or_dev_default
only with an explicit development opt-in.
Sourcepub fn from_env_or_dev_default() -> Result<Self>
pub fn from_env_or_dev_default() -> Result<Self>
Load key from PHOTON_TRANSPORT_KEY, or the hard-coded development key when
explicitly opted in.
Development-only. The hard-coded key is used only when
PHOTON_ALLOW_DEV_TRANSPORT_KEY is 1 or true and PHOTON_TRANSPORT_KEY
is unset or invalid. A loud warning is printed when the development key is used.
Prefer Self::from_env in production and CI (set a real PHOTON_TRANSPORT_KEY).
§Errors
Returns an error when the environment key is missing/invalid and the development-key opt-in is not set.
Trait Implementations§
Source§impl Clone for TransportCrypto
impl Clone for TransportCrypto
Source§fn clone(&self) -> TransportCrypto
fn clone(&self) -> TransportCrypto
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more