Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/base64ct/tests/crypt.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / base64ct / tests / crypt.rs` 70 lines ยท 1741 bytes Raw Blame History 1 //! `crypt(3)` Base64 tests 2 3 #![allow(deprecated)] 4 5 #[macro_use] 6 mod common; 7 8 use crate::common::*; 9 use base64ct::Base64Crypt; 10 11 const TEST_VECTORS: &[TestVector] = &[ 12 TestVector { raw: b"", b64: "" }, 13 TestVector { 14 raw: b"\0", 15 b64: "..", 16 }, 17 TestVector { 18 raw: b"***", 19 b64: "8Wce", 20 }, 21 TestVector { 22 raw: b"\x01\x02\x03\x04", 23 b64: ".E61/.", 24 }, 25 TestVector { 26 raw: b"\xAD\xAD\xAD\xAD\xAD", 27 b64: "fOqhfOo", 28 }, 29 TestVector { 30 raw: b"\xFF\xEF\xFE\xFF\xEF\xFE", 31 b64: "zyzyzyzy", 32 }, 33 TestVector { 34 raw: b"\xFF\xFF\xFF\xFF\xFF", 35 b64: "zzzzzzw", 36 }, 37 TestVector { 38 raw: b"\x40\xC1\x3F\xBD\x05\x4C\x72\x2A\xA3\xC2\xF2\x11\x73\xC0\x69\xEA\ 39 \x49\x7D\x35\x29\x6B\xCC\x24\x65\xF6\xF9\xD0\x41\x08\x7B\xD7\xA9", 40 b64: "EA2zjEJAQWeXkj6FQw/duYZxBGZfn0FZxjbEEEVvpuY", 41 }, 42 TestVector { 43 raw: b"\x00\x10\x83\x10Q\x87 \x92\x8B0\xD3\x8FA\x14\x93QU\x97a\x96\x9Bq\ 44 \xD7\x9F\x82\x18\xA3\x92Y\xA7\xA2\x9A\xAB\xB2\xDB\xAF\xC3\x1C\xB3\ 45 \xFB\xF0\x00", 46 b64: "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnyz..", 47 }, 48 ]; 49 50 impl_tests!(Base64Crypt); 51 52 #[test] 53 fn reject_trailing_whitespace() { 54 let input = "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i\n"; 55 let mut buf = [0u8; 1024]; 56 assert_eq!( 57 Base64Crypt::decode(input, &mut buf), 58 Err(Error::InvalidEncoding) 59 ); 60 } 61 62 #[test] 63 fn unpadded_reject_trailing_equals() { 64 let input = "OKC9tOTKagohutGPa6/n4ij7LQjpxAPj7tlOOOf5z4i="; 65 let mut buf = [0u8; 1024]; 66 assert_eq!( 67 Base64Crypt::decode(input, &mut buf), 68 Err(Error::InvalidEncoding) 69 ); 70 }