<commit_before>/*!
`crypto_box_curve25519xsalsa20poly1305` , a particular
combination of Curve25519, Salsa20, and Poly1305 specified in
[Cryptography in NaCl](http://nacl.cr.yp.to/valid.html). 

This function is conjectured to meet the standard notions of privacy and
third-party unforgeability.

*/
use std::libc::{c_ulonglong, c_int, size_t};
use std::vec::raw::{to_mut_ptr, to_ptr};
use utils::marshal;
use randombytes::randombytes_into;

#[link(name = "sodium")]
#[link_args = "-lsodium"]
extern {
    fn crypto_box_curve25519xsalsa20poly1305_keypair(pk: *mut u8,
                                                     sk: *mut u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305(c: *mut u8,
                                             m: *u8,
                                             mlen: c_ulonglong,
                                             n: *u8,
                                             pk: *u8,
                                             sk: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_open(m: *mut u8,
                                                  c: *u8,
                                                  clen: c_ulonglong,
                                                  n: *u8,
                                                  pk: *u8,
                                                  sk: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_beforenm(k: *mut u8,
                                                      pk: *u8,
                                                      sk: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_afternm(c: *mut u8,
                                                     m: *u8,
                                                     mlen: c_ulonglong,
                                                     n: *u8,
                                                     k: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_open_afternm(m: *mut u8,
                                                          c: *u8,
                                                          clen: c_ulonglong,
                                                          n: *u8,
                                                          k: *u8) -> c_int;
}

pub static PUBLICKEYBYTES: size_t = 32;
pub static SECRETKEYBYTES: size_t = 32;
pub static NONCEBYTES: size_t = 24;
pub static PRECOMPUTEDKEYBYTES: size_t = 32;
static ZEROBYTES: uint = 32;
static BOXZEROBYTES: uint = 16;

/**
 * `PublicKey` for asymmetric authenticated encryption
 */
pub struct PublicKey([u8, ..PUBLICKEYBYTES]);
/**
 * `SecretKey` for asymmetric authenticated encryption
 * 
 * When a `SecretKey` goes out of scope its contents<commit_msg>changed size_t's to uints<commit_after>/*!
`crypto_box_curve25519xsalsa20poly1305` , a particular
combination of Curve25519, Salsa20, and Poly1305 specified in
[Cryptography in NaCl](http://nacl.cr.yp.to/valid.html). 

This function is conjectured to meet the standard notions of privacy and
third-party unforgeability.

*/
use std::libc::{c_ulonglong, c_int};
use std::vec::raw::{to_mut_ptr, to_ptr};
use utils::marshal;
use randombytes::randombytes_into;

#[link(name = "sodium")]
#[link_args = "-lsodium"]
extern {
    fn crypto_box_curve25519xsalsa20poly1305_keypair(pk: *mut u8,
                                                     sk: *mut u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305(c: *mut u8,
                                             m: *u8,
                                             mlen: c_ulonglong,
                                             n: *u8,
                                             pk: *u8,
                                             sk: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_open(m: *mut u8,
                                                  c: *u8,
                                                  clen: c_ulonglong,
                                                  n: *u8,
                                                  pk: *u8,
                                                  sk: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_beforenm(k: *mut u8,
                                                      pk: *u8,
                                                      sk: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_afternm(c: *mut u8,
                                                     m: *u8,
                                                     mlen: c_ulonglong,
                                                     n: *u8,
                                                     k: *u8) -> c_int;
    fn crypto_box_curve25519xsalsa20poly1305_open_afternm(m: *mut u8,
                                                          c: *u8,
                                                          clen: c_ulonglong,
                                                          n: *u8,
                                                          k: *u8) -> c_int;
}

pub static PUBLICKEYBYTES: uint = 32;
pub static SECRETKEYBYTES: uint = 32;
pub static NONCEBYTES: uint = 24;
pub static PRECOMPUTEDKEYBYTES: uint = 32;
static ZEROBYTES: uint = 32;
static BOXZEROBYTES: uint = 16;

/**
 * `PublicKey` for asymmetric authenticated encryption
 */
pub struct PublicKey([u8, ..PUBLICKEYBYTES]);
/**
 * `SecretKey` for asymmetric authenticated encryption
 * 
 * When a `SecretKey` goes out of scope its contents
{'fraction_non_alphanumeric': 0.07930652895610475, 'fraction_numerical': 0.045739579490962745, 'mean_word_length': 1.0318471337579618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 84, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2886455', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1359, 'n_words': 339}