Skip to main content

moq_secure/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum MoqSecureError {
5    #[error("invalid magic bytes")]
6    InvalidMagic,
7
8    #[error("unsupported version: {0}")]
9    UnsupportedVersion(u8),
10
11    #[error("unsupported AEAD algorithm: {0}")]
12    UnsupportedAlgorithm(u8),
13
14    #[error("not enough bytes in frame")]
15    TruncatedFrame,
16
17    #[error("ciphertext too short for AEAD tag")]
18    CiphertextTooShort,
19
20    #[error("invalid padding length")]
21    InvalidPadLength,
22
23    #[error("invalid sigFlag: expected 0 or 1, got {0}")]
24    InvalidSigFlag(u8),
25
26    #[error("AEAD authentication failed")]
27    AeadAuthFailed,
28
29    #[error("signature invalid or signature verification failed")]
30    InvalidSignature,
31
32    #[error(
33        "signing is disabled but sigFlag indicates a signature or sigSlot is non-zero"
34    )]
35    SigningMismatch,
36
37    #[error(
38        "signing enabled but sigFlag indicates a signature while sigSlot is missing or zero"
39    )]
40    MissingSigSlot,
41
42    #[error("signature present with sigFlag=1 but nSigned is 0")]
43    SignatureNotAllowedByNSigned,
44
45    #[error("decryption failed")]
46    DecryptFailed,
47
48    #[error("unknown or not-loaded key_id: {0}")]
49    InvalidKeyId(u8),
50
51    #[error("replay detected, ctr lower than previous high watermark")]
52    ReplayDetected,
53}
54