forked from maidsafe/rust_sodium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/sys: use FFI types consistently
Also disable crypto_generichash due to inability to specify alignment (see rust-lang/rust#33626)
- Loading branch information
Showing
37 changed files
with
834 additions
and
907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,67 @@ | ||
// crypto_aead_chacha20poly1305.h | ||
|
||
pub const crypto_aead_chacha20poly1305_KEYBYTES: usize = 32; | ||
pub const crypto_aead_chacha20poly1305_NSECBYTES: usize = 0; | ||
pub const crypto_aead_chacha20poly1305_NPUBBYTES: usize = 8; | ||
pub const crypto_aead_chacha20poly1305_ABYTES: usize = 16; | ||
|
||
pub const crypto_aead_chacha20poly1305_KEYBYTES: size_t = 32; | ||
pub const crypto_aead_chacha20poly1305_NSECBYTES: size_t = 0; | ||
pub const crypto_aead_chacha20poly1305_NPUBBYTES: size_t = 8; | ||
pub const crypto_aead_chacha20poly1305_ABYTES: size_t = 16; | ||
|
||
extern "C" { | ||
pub fn crypto_aead_chacha20poly1305_keybytes() -> size_t; | ||
pub fn crypto_aead_chacha20poly1305_nsecbytes() -> size_t; | ||
pub fn crypto_aead_chacha20poly1305_npubbytes() -> size_t; | ||
pub fn crypto_aead_chacha20poly1305_abytes() -> size_t; | ||
pub fn crypto_aead_chacha20poly1305_encrypt( | ||
c: *mut u8, | ||
c: *mut c_uchar, | ||
clen: *mut c_ulonglong, | ||
m: *const u8, | ||
m: *const c_uchar, | ||
mlen: c_ulonglong, | ||
ad: *const u8, | ||
ad: *const c_uchar, | ||
adlen: c_ulonglong, | ||
nsec: *const u8, | ||
npub: *const u8, | ||
k: *const u8, | ||
nsec: *const c_uchar, | ||
npub: *const c_uchar, | ||
k: *const c_uchar, | ||
) -> c_int; | ||
pub fn crypto_aead_chacha20poly1305_decrypt( | ||
m: *mut u8, | ||
m: *mut c_uchar, | ||
mlen: *mut c_ulonglong, | ||
nsec: *mut u8, | ||
c: *const u8, | ||
nsec: *mut c_uchar, | ||
c: *const c_uchar, | ||
clen: c_ulonglong, | ||
ad: *const u8, | ||
ad: *const c_uchar, | ||
adlen: c_ulonglong, | ||
npub: *const u8, | ||
k: *const u8, | ||
npub: *const c_uchar, | ||
k: *const c_uchar, | ||
) -> c_int; | ||
} | ||
|
||
|
||
#[test] | ||
fn test_crypto_aead_chacha20poly1305_keybytes() { | ||
assert!( | ||
unsafe { crypto_aead_chacha20poly1305_keybytes() as usize } == | ||
crypto_aead_chacha20poly1305_KEYBYTES | ||
assert_eq!( | ||
unsafe { crypto_aead_chacha20poly1305_keybytes() }, | ||
crypto_aead_chacha20poly1305_KEYBYTES | ||
) | ||
} | ||
|
||
#[test] | ||
fn test_crypto_aead_chacha20poly1305_nsecbytes() { | ||
assert!( | ||
unsafe { crypto_aead_chacha20poly1305_nsecbytes() as usize } == | ||
crypto_aead_chacha20poly1305_NSECBYTES | ||
assert_eq!( | ||
unsafe { crypto_aead_chacha20poly1305_nsecbytes() }, | ||
crypto_aead_chacha20poly1305_NSECBYTES | ||
) | ||
} | ||
|
||
#[test] | ||
fn test_crypto_aead_chacha20poly1305_npubbytes() { | ||
assert!( | ||
unsafe { crypto_aead_chacha20poly1305_npubbytes() as usize } == | ||
crypto_aead_chacha20poly1305_NPUBBYTES | ||
assert_eq!( | ||
unsafe { crypto_aead_chacha20poly1305_npubbytes() }, | ||
crypto_aead_chacha20poly1305_NPUBBYTES | ||
) | ||
} | ||
|
||
#[test] | ||
fn test_crypto_aead_chacha20poly1305_abytes() { | ||
assert!( | ||
unsafe { crypto_aead_chacha20poly1305_abytes() as usize } == crypto_aead_chacha20poly1305_ABYTES | ||
assert_eq!( | ||
unsafe { crypto_aead_chacha20poly1305_abytes() }, | ||
crypto_aead_chacha20poly1305_ABYTES | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.