Implement challenge 15 pkcs7 validation.

This commit is contained in:
2022-06-28 13:28:12 -04:00
parent f6b4c98826
commit fd6f9464cc
3 changed files with 41 additions and 0 deletions

View File

@@ -390,3 +390,26 @@ pub fn challenge14() {
roundtrip_text.to_utf8()[..17].to_string()
);
}
pub fn challenge15() {
assert_eq!(
Bytes::from_utf8("ICE ICE BABY\u{4}\u{4}\u{4}").has_valid_pkcs7(16),
false
);
assert_eq!(
Bytes::from_utf8("ICE ICE BABY\u{4}\u{4}\u{4}\u{4}").has_valid_pkcs7(16),
true
);
assert_eq!(
Bytes::from_utf8("ICE ICE BABY\u{3}\u{3}\u{4}\u{4}").has_valid_pkcs7(16),
false
);
let mut bytes = Bytes::from_utf8("ICE ICE BABY\u{3}\u{3}\u{4}\u{4}");
bytes.pad_pkcs7(16);
assert_eq!(bytes.has_valid_pkcs7(16), true);
println!("[okay] Challenge 15: PKCS7 works");
}
pub fn challenge16() {
println!("[xxxx] Challenge 16: TBD");
}