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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// crypto_core_salsa20.h

pub const crypto_core_salsa20_OUTPUTBYTES: usize = 64;
pub const crypto_core_salsa20_INPUTBYTES: usize = 16;
pub const crypto_core_salsa20_KEYBYTES: usize = 32;
pub const crypto_core_salsa20_CONSTBYTES: usize = 16;

extern {
    pub fn crypto_core_salsa20_outputbytes() -> size_t;
    pub fn crypto_core_salsa20_inputbytes() -> size_t;
    pub fn crypto_core_salsa20_keybytes() -> size_t;
    pub fn crypto_core_salsa20_constbytes() -> size_t;

    pub fn crypto_core_salsa20(
        out: *mut [u8; crypto_core_salsa20_OUTPUTBYTES],
        in_: *const [u8; crypto_core_salsa20_INPUTBYTES],
        k: *const [u8; crypto_core_salsa20_KEYBYTES],
        c: *const [u8; crypto_core_salsa20_CONSTBYTES]) -> c_int;
}

#[test]
fn test_crypto_core_salsa20_outputbytes() {
    assert!(unsafe {
        crypto_core_salsa20_outputbytes() as usize
    } == crypto_core_salsa20_OUTPUTBYTES)
}

#[test]
fn test_crypto_core_salsa20_inputbytes() {
    assert!(unsafe {
        crypto_core_salsa20_inputbytes() as usize
    } == crypto_core_salsa20_INPUTBYTES)
}

#[test]
fn test_crypto_core_salsa20_keybytes() {
    assert!(unsafe {
        crypto_core_salsa20_keybytes() as usize
    } == crypto_core_salsa20_KEYBYTES)
}

#[test]
fn test_crypto_core_salsa20_constbytes() {
    assert!(unsafe {
        crypto_core_salsa20_constbytes() as usize
    } == crypto_core_salsa20_CONSTBYTES)
}