Commit 3bafc451 authored by obronchain's avatar obronchain

unsigned long long

parent 87bedb7f
int crypto_aead_encrypt(unsigned char* c, unsigned int* clen, int crypto_aead_encrypt(unsigned char* c, unsigned long long* clen,
const unsigned char* m, unsigned int mlen, const unsigned char* m, unsigned long long mlen,
const unsigned char* ad, unsigned int adlen, const unsigned char* ad, unsigned long long adlen,
const unsigned char* nsec, const unsigned char* npub, const unsigned char* nsec, const unsigned char* npub,
const unsigned char* k); const unsigned char* k);
int crypto_aead_decrypt(unsigned char* m, unsigned int* mlen, int crypto_aead_decrypt(unsigned char* m, unsigned long long* mlen,
unsigned char* nsec, const unsigned char* c, unsigned char* nsec, const unsigned char* c,
unsigned int clen, const unsigned char* ad, unsigned long long clen, const unsigned char* ad,
unsigned int adlen, const unsigned char* npub, unsigned long long adlen, const unsigned char* npub,
const unsigned char* k); const unsigned char* k);
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
#endif #endif
// Spook encryption. // Spook encryption.
int crypto_aead_encrypt(unsigned char* c, unsigned int* clen, int crypto_aead_encrypt(unsigned char* c, unsigned long long* clen,
const unsigned char* m, unsigned int mlen, const unsigned char* m, unsigned long long mlen,
const unsigned char* ad, unsigned int adlen, const unsigned char* ad, unsigned long long adlen,
const unsigned char* nsec UNUSED, const unsigned char* nsec UNUSED,
const unsigned char* npub, const unsigned char* k) { const unsigned char* npub, const unsigned char* k) {
unsigned char p[P_NBYTES]; unsigned char p[P_NBYTES];
...@@ -32,10 +32,10 @@ int crypto_aead_encrypt(unsigned char* c, unsigned int* clen, ...@@ -32,10 +32,10 @@ int crypto_aead_encrypt(unsigned char* c, unsigned int* clen,
} }
// Spook encryption. // Spook encryption.
int crypto_aead_decrypt(unsigned char* m, unsigned int* mlen, int crypto_aead_decrypt(unsigned char* m, unsigned long long* mlen,
unsigned char* nsec UNUSED, const unsigned char* c, unsigned char* nsec UNUSED, const unsigned char* c,
unsigned int clen, const unsigned char* ad, unsigned long long clen, const unsigned char* ad,
unsigned int adlen, const unsigned char* npub, unsigned long long adlen, const unsigned char* npub,
const unsigned char* k) { const unsigned char* k) {
unsigned char p[P_NBYTES]; unsigned char p[P_NBYTES];
const unsigned char* k_priv; const unsigned char* k_priv;
......
...@@ -40,19 +40,19 @@ typedef enum { ...@@ -40,19 +40,19 @@ typedef enum {
static void compress_block(unsigned char *state, unsigned char *out, static void compress_block(unsigned char *state, unsigned char *out,
const unsigned char *d, compress_mode mode, const unsigned char *d, compress_mode mode,
unsigned int offset, unsigned int n); unsigned long long offset, unsigned long long n);
static unsigned int compress_data(shadow_state state, static unsigned long long compress_data(shadow_state state,
unsigned char *out, unsigned char *out,
const unsigned char *d, const unsigned char *d,
unsigned int dlen, unsigned long long dlen,
compress_mode mode); compress_mode mode);
static void init_sponge_state(shadow_state state, static void init_sponge_state(shadow_state state,
const unsigned char *k, const unsigned char *p, const unsigned char *k, const unsigned char *p,
const unsigned char *n); const unsigned char *n);
static void xor_bytes(unsigned char* dest, const unsigned char* src1, static void xor_bytes(unsigned char* dest, const unsigned char* src1,
const unsigned char* src2, unsigned int n); const unsigned char* src2, unsigned long long n);
void init_keys(const unsigned char **k, unsigned char p[P_NBYTES], void init_keys(const unsigned char **k, unsigned char p[P_NBYTES],
const unsigned char *k_glob) { const unsigned char *k_glob) {
...@@ -80,9 +80,9 @@ static void init_sponge_state(shadow_state state, ...@@ -80,9 +80,9 @@ static void init_sponge_state(shadow_state state,
shadow(state); shadow(state);
} }
void s1p_encrypt(unsigned char *c, unsigned int *clen, void s1p_encrypt(unsigned char *c, unsigned long long *clen,
const unsigned char *ad, unsigned int adlen, const unsigned char *ad, unsigned long long adlen,
const unsigned char *m, unsigned int mlen, const unsigned char *m, unsigned long long mlen,
const unsigned char *k, const unsigned char *p, const unsigned char *k, const unsigned char *p,
const unsigned char *n) { const unsigned char *n) {
// permutation state // permutation state
...@@ -93,7 +93,7 @@ void s1p_encrypt(unsigned char *c, unsigned int *clen, ...@@ -93,7 +93,7 @@ void s1p_encrypt(unsigned char *c, unsigned int *clen,
compress_data(state, NULL, ad, adlen, AD); compress_data(state, NULL, ad, adlen, AD);
// compress message // compress message
unsigned int c_bytes = 0; unsigned long long c_bytes = 0;
if (mlen > 0) { if (mlen > 0) {
state[RATE_BUNDLES][0] ^= 0x01; state[RATE_BUNDLES][0] ^= 0x01;
c_bytes = compress_data(state, c, m, mlen, PLAINTEXT); c_bytes = compress_data(state, c, m, mlen, PLAINTEXT);
...@@ -106,9 +106,9 @@ void s1p_encrypt(unsigned char *c, unsigned int *clen, ...@@ -106,9 +106,9 @@ void s1p_encrypt(unsigned char *c, unsigned int *clen,
*clen = c_bytes + CLYDE128_NBYTES; *clen = c_bytes + CLYDE128_NBYTES;
} }
int s1p_decrypt(unsigned char *m, unsigned int *mlen, int s1p_decrypt(unsigned char *m, unsigned long long *mlen,
const unsigned char *ad, unsigned int adlen, const unsigned char *ad, unsigned long long adlen,
const unsigned char *c, unsigned int clen, const unsigned char *c, unsigned long long clen,
const unsigned char *k, const unsigned char *p, const unsigned char *k, const unsigned char *p,
const unsigned char *n) { const unsigned char *n) {
// permutation state // permutation state
...@@ -119,7 +119,7 @@ int s1p_decrypt(unsigned char *m, unsigned int *mlen, ...@@ -119,7 +119,7 @@ int s1p_decrypt(unsigned char *m, unsigned int *mlen,
compress_data(state, NULL, ad, adlen, AD); compress_data(state, NULL, ad, adlen, AD);
// compress message // compress message
unsigned int m_bytes = 0; unsigned long long m_bytes = 0;
if (clen > CLYDE128_NBYTES) { if (clen > CLYDE128_NBYTES) {
state[RATE_BUNDLES][0] ^= 0x01; state[RATE_BUNDLES][0] ^= 0x01;
m_bytes = compress_data(state, m, c, clen - CLYDE128_NBYTES, CIPHERTEXT); m_bytes = compress_data(state, m, c, clen - CLYDE128_NBYTES, CIPHERTEXT);
...@@ -151,7 +151,7 @@ int s1p_decrypt(unsigned char *m, unsigned int *mlen, ...@@ -151,7 +151,7 @@ int s1p_decrypt(unsigned char *m, unsigned int *mlen,
// Only the XOR operation is performed, not XORing of padding constants. // Only the XOR operation is performed, not XORing of padding constants.
static void compress_block(unsigned char *state, unsigned char *out, static void compress_block(unsigned char *state, unsigned char *out,
const unsigned char *d, compress_mode mode, const unsigned char *d, compress_mode mode,
unsigned int offset, unsigned int n) { unsigned long long offset, unsigned long long n) {
if (mode == CIPHERTEXT) { if (mode == CIPHERTEXT) {
xor_bytes(out + offset, state, d + offset, n); xor_bytes(out + offset, state, d + offset, n);
memcpy(state, d + offset, n); memcpy(state, d + offset, n);
...@@ -167,12 +167,12 @@ static void compress_block(unsigned char *state, unsigned char *out, ...@@ -167,12 +167,12 @@ static void compress_block(unsigned char *state, unsigned char *out,
// Input data buffer is d with length dlen. // Input data buffer is d with length dlen.
// Output is written into buffer out if mode is PLAINTEXT or CIPHERTEXT. // Output is written into buffer out if mode is PLAINTEXT or CIPHERTEXT.
// Padding is handled if needed. // Padding is handled if needed.
static unsigned int compress_data(shadow_state state, static unsigned long long compress_data(shadow_state state,
unsigned char *out, unsigned char *out,
const unsigned char *d, const unsigned char *d,
unsigned int dlen, unsigned long long dlen,
compress_mode mode) { compress_mode mode) {
unsigned int i; unsigned long long i;
for (i = 0; i < dlen / RATE_BYTES; i++) { for (i = 0; i < dlen / RATE_BYTES; i++) {
compress_block((uint8_t *)state, out, d, mode, i * RATE_BYTES, RATE_BYTES); compress_block((uint8_t *)state, out, d, mode, i * RATE_BYTES, RATE_BYTES);
shadow(state); shadow(state);
...@@ -189,8 +189,8 @@ static unsigned int compress_data(shadow_state state, ...@@ -189,8 +189,8 @@ static unsigned int compress_data(shadow_state state,
// XOR buffers src1 and src2 into buffer dest (all buffers contain n bytes). // XOR buffers src1 and src2 into buffer dest (all buffers contain n bytes).
void xor_bytes(unsigned char* dest, const unsigned char* src1, void xor_bytes(unsigned char* dest, const unsigned char* src1,
const unsigned char* src2, unsigned int n) { const unsigned char* src2, unsigned long long n) {
for ( unsigned int i = 0; i < n; i++) { for ( unsigned long long i = 0; i < n; i++) {
dest[i] = src1[i] ^ src2[i]; dest[i] = src1[i] ^ src2[i];
} }
} }
...@@ -29,15 +29,15 @@ ...@@ -29,15 +29,15 @@
// Size of the P parameter // Size of the P parameter
#define P_NBYTES 16 #define P_NBYTES 16
void s1p_encrypt(unsigned char *c, unsigned int *clen, void s1p_encrypt(unsigned char *c, unsigned long long *clen,
const unsigned char *ad, unsigned int adlen, const unsigned char *ad, unsigned long long adlen,
const unsigned char *m, unsigned int mlen, const unsigned char *m, unsigned long long mlen,
const unsigned char *k, const unsigned char *p, const unsigned char *k, const unsigned char *p,
const unsigned char *n); const unsigned char *n);
int s1p_decrypt(unsigned char *m, unsigned int *mlen, int s1p_decrypt(unsigned char *m, unsigned long long *mlen,
const unsigned char *ad, unsigned int adlen, const unsigned char *ad, unsigned long long adlen,
const unsigned char *c, unsigned int clen, const unsigned char *c, unsigned long long clen,
const unsigned char *k, const unsigned char *p, const unsigned char *k, const unsigned char *p,
const unsigned char *n); const unsigned char *n);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment