libsodium_sys/src/
crypto_stream_xsalsa20.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// crypto_stream_xsalsa20.h

pub const crypto_stream_xsalsa20_KEYBYTES: usize = 32;
pub const crypto_stream_xsalsa20_NONCEBYTES: usize = 24;


extern {
    pub fn crypto_stream_xsalsa20(
        c: *mut u8,
        clen: c_ulonglong,
        n: *const [u8; crypto_stream_xsalsa20_NONCEBYTES],
        k: *const [u8; crypto_stream_xsalsa20_KEYBYTES]) -> c_int;
    pub fn crypto_stream_xsalsa20_xor(
        c: *mut u8,
        m: *const u8,
        mlen: c_ulonglong,
        n: *const [u8; crypto_stream_xsalsa20_NONCEBYTES],
        k: *const [u8; crypto_stream_xsalsa20_KEYBYTES]) -> c_int;
    pub fn crypto_stream_xsalsa20_keybytes() -> size_t;
    pub fn crypto_stream_xsalsa20_noncebytes() -> size_t;
}


#[test]
fn test_crypto_stream_xsalsa20_keybytes() {
    assert!(unsafe { crypto_stream_xsalsa20_keybytes() as usize } ==
            crypto_stream_xsalsa20_KEYBYTES)
}
#[test]
fn test_crypto_stream_xsalsa20_noncebytes() {
    assert!(unsafe { crypto_stream_xsalsa20_noncebytes() as usize } ==
            crypto_stream_xsalsa20_NONCEBYTES)
}