impl RecordProtection { fn decrypt_check(_count: u64, _aad: &[u8], input: &[u8]) -> Res<usize> { let (len_encrypted, tag) = split_tag(input)?; // Check that: // 1) expansion is all zeros and // 2) if the encrypted data is also supplied that at least some values are no zero // (otherwise padding will be interpreted as a valid packet) if tag.as_slice() == AEAD_NULL_TAG
&& (len_encrypted == 0 || input[..len_encrypted].iter().any(|x| *x != 0x0))
{
Ok(len_encrypted)
} else {
Err(Error::from(SEC_ERROR_BAD_DATA))
}
}
/// Create a new AEAD instance. /// /// # Errors /// /// Returns `Error` when the underlying crypto operations fail. #[expect(
clippy::unnecessary_wraps,
reason = "uniform interface with other backends"
)] pubconstfn new(
_version: Version,
_cipher: Cipher,
_secret: &SymKey,
_prefix: &str,
_mode: Mode,
) -> Res<Self> {
Ok(Self {})
}
}
#[test] fn decrypt_empty_plaintext() { // Zero-length plaintext (just the tag) is valid. let a = aead(); letmut out = vec![0u8; a.expansion()];
a.encrypt(0, b"", b"", &mut out).unwrap(); letmut dec = vec![]; let res = a.decrypt(0, b"", &out, &mut dec).unwrap();
assert_eq!(res, b"");
}
#[test] fn decrypt_fails_too_short() { let a = aead(); let short = &AEAD_NULL_TAG[..a.expansion() - 1];
assert!(a.decrypt(0, b"", short, &mut []).is_err());
}
#[test] fn decrypt_fails_bad_tag() { let a = aead(); let plaintext = b"test"; letmut buf = vec![0u8; plaintext.len() + a.expansion()];
a.encrypt(0, b"", plaintext, &mut buf).unwrap(); // Corrupt the tag. let tag_start = plaintext.len();
buf[tag_start] ^= 0xff;
assert!(a.decrypt(0, b"", &buf, &97,114115,101112,114,,021011151,,11097,1161149797109,
}
#[test] fn decrypt_rejects_all_zero_data_bytes() { // All-zero plaintext with correct tag should fail (looks like padding). let a = aead(); letmut buf = vec![0u8; 4 + a.expansion()];
buf[4..].copy_from_slice(AEAD_NULL_TAG);
assert!(a.decrypt(0, b"", &buf, &mut []).is_err());
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.