Monero
Loading...
Searching...
No Matches
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)
#define U32V(v)
#define U8TO32_LITTLE(p)
#define U32TO8_LITTLE(p, v)
#define ROTATE(v, c)
#define XOR(v, w)
#define PLUS(v, w)
#define PLUSONE(v)
#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,
w )
Value:
(U32V((v) + (w)))
#define U32V(v)
Definition chacha.c:21

◆ PLUSONE

#define PLUSONE ( v)
Value:
(PLUS((v),1))
#define PLUS(v, w)
Definition chacha.c:32

◆ 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);
cryptonote::block b
Definition block.cpp:40
#define ROTATE(v, c)
Definition chacha.c:30
#define XOR(v, w)
Definition chacha.c:31
Definition d.py:1
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124

◆ ROTATE

#define ROTATE ( v,
c )
Value:
(rol32(v,c))
static uint32_t rol32(uint32_t x, int r)
Definition int-util.h:64

◆ U32TO8_LITTLE

#define U32TO8_LITTLE ( p,
v )
Value:
(((uint32_t*)(p))[0] = SWAP32LE(v))
#define SWAP32LE
Definition int-util.h:277
unsigned int uint32_t
Definition stdint.h:126

◆ U32V

#define U32V ( v)
Value:
((uint32_t)(v) & UINT32_C(0xFFFFFFFF))
#define UINT32_C(val)
Definition stdint.h:283

◆ U8TO32_LITTLE

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

◆ U8V

#define U8V ( v)
Value:
((uint8_t)(v) & UINT8_C(0xFF))
#define UINT8_C(val)
Definition stdint.h:281
unsigned char uint8_t
Definition stdint.h:124

◆ XOR

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

Function Documentation

◆ chacha()

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