sanitization 1.0.0-rc.2

Dependency-free no_std secret memory sanitization with safe defaults and an explicit volatile wipe backend.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use sanitization::{secure_drop_struct, SecretBytes};

secure_drop_struct! {
    struct SessionCredentials {
        private_key: SecretBytes<32>,
        nonce: SecretBytes<12>,
    }
}

fn main() {
    let credentials = SessionCredentials {
        private_key: SecretBytes::from_array([1; 32]),
        nonce: SecretBytes::from_array([2; 12]),
    };

    assert!(credentials.private_key.constant_time_eq(&[1; 32]));
    assert!(credentials.nonce.constant_time_eq(&[2; 12]));
}