|
Electroneum
|
#include <memory.h>#include <stdio.h>#include <sys/param.h>#include "chacha.h"#include "int-util.h"#include "warnings.h"
Macros | |
| #define | U8V(v) ((uint8_t)(v) & UINT8_C(0xFF)) |
| #define | U32V(v) ((uint32_t)(v) & UINT32_C(0xFFFFFFFF)) |
| #define | U8TO32_LITTLE(p) SWAP32LE(((uint32_t*)(p))[0]) |
| #define | U32TO8_LITTLE(p, v) (((uint32_t*)(p))[0] = SWAP32LE(v)) |
| #define | ROTATE(v, c) (rol32(v,c)) |
| #define | XOR(v, w) ((v) ^ (w)) |
| #define | PLUS(v, w) (U32V((v) + (w))) |
| #define | PLUSONE(v) (PLUS((v),1)) |
| #define | QUARTERROUND(a, b, c, d) |
Functions | |
| static void | chacha (unsigned rounds, const void *data, size_t length, const uint8_t *key, const uint8_t *iv, char *cipher) |
| void | chacha8 (const void *data, size_t length, const uint8_t *key, const uint8_t *iv, char *cipher) |
| void | chacha20 (const void *data, size_t length, const uint8_t *key, const uint8_t *iv, char *cipher) |
Variables | |
| static const char | sigma [] = "expand 32-byte k" |
| #define PLUS | ( | v, | |
| w | |||
| ) | (U32V((v) + (w))) |
| #define PLUSONE | ( | v | ) | (PLUS((v),1)) |
| #define QUARTERROUND | ( | a, | |
| b, | |||
| c, | |||
| d | |||
| ) |
| #define ROTATE | ( | v, | |
| c | |||
| ) | (rol32(v,c)) |
| #define U32TO8_LITTLE | ( | p, | |
| v | |||
| ) | (((uint32_t*)(p))[0] = SWAP32LE(v)) |
| #define U32V | ( | v | ) | ((uint32_t)(v) & UINT32_C(0xFFFFFFFF)) |
| #define U8TO32_LITTLE | ( | p | ) | SWAP32LE(((uint32_t*)(p))[0]) |
| #define U8V | ( | v | ) | ((uint8_t)(v) & UINT8_C(0xFF)) |
| #define XOR | ( | v, | |
| w | |||
| ) | ((v) ^ (w)) |
|
static |
| void chacha20 | ( | const void * | data, |
| size_t | length, | ||
| const uint8_t * | key, | ||
| const uint8_t * | iv, | ||
| char * | cipher | ||
| ) |
| void chacha8 | ( | const void * | data, |
| size_t | length, | ||
| const uint8_t * | key, | ||
| const uint8_t * | iv, | ||
| char * | cipher | ||
| ) |
|
static |