Electroneum
Macros | Functions | Variables
chacha.c File Reference
#include <memory.h>
#include <stdio.h>
#include <sys/param.h>
#include "chacha.h"
#include "int-util.h"
#include "warnings.h"
Include dependency graph for chacha.c:

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"
 

Macro Definition Documentation

◆ PLUS

#define PLUS (   v,
 
)    (U32V((v) + (w)))

◆ PLUSONE

#define PLUSONE (   v)    (PLUS((v),1))

◆ QUARTERROUND

#define QUARTERROUND (   a,
  b,
  c,
  d 
)
Value:
a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \
c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \
a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
#define ROTATE(v, c)
Definition: chacha.c:30
#define PLUS(v, w)
Definition: chacha.c:32
#define XOR(v, w)
Definition: chacha.c:31
string a
Definition: MakeCryptoOps.py:15
int b
Definition: base.py:1
Definition: d.py:1

◆ ROTATE

#define ROTATE (   v,
 
)    (rol32(v,c))

◆ U32TO8_LITTLE

#define U32TO8_LITTLE (   p,
 
)    (((uint32_t*)(p))[0] = SWAP32LE(v))

◆ U32V

#define U32V (   v)    ((uint32_t)(v) & UINT32_C(0xFFFFFFFF))

◆ U8TO32_LITTLE

#define U8TO32_LITTLE (   p)    SWAP32LE(((uint32_t*)(p))[0])

◆ U8V

#define U8V (   v)    ((uint8_t)(v) & UINT8_C(0xFF))

◆ XOR

#define XOR (   v,
 
)    ((v) ^ (w))

Function Documentation

◆ chacha()

static void chacha ( unsigned  rounds,
const void *  data,
size_t  length,
const uint8_t *  key,
const uint8_t *  iv,
char *  cipher 
)
static

◆ chacha20()

void chacha20 ( const void *  data,
size_t  length,
const uint8_t *  key,
const uint8_t *  iv,
char *  cipher 
)

◆ chacha8()

void chacha8 ( const void *  data,
size_t  length,
const uint8_t *  key,
const uint8_t *  iv,
char *  cipher 
)

Variable Documentation

◆ sigma

const char sigma[] = "expand 32-byte k"
static