chacha_private.h File Reference

Go to the source code of this file.

Data Structures

struct  chacha_ctx

Defines

#define U8C(v)   (v##U)
#define U32C(v)   (v##U)
#define U8V(v)   ((u8)(v) & U8C(0xFF))
#define U32V(v)   ((u32)(v) & U32C(0xFFFFFFFF))
#define ROTL32(v, n)   (U32V((v) << (n)) | ((v) >> (32 - (n))))
#define U8TO32_LITTLE(p)
#define U32TO8_LITTLE(p, v)
#define ROTATE(v, c)   (ROTL32(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)

Typedefs

typedef unsigned char u8
typedef unsigned int u32

Functions

static void chacha_keysetup (chacha_ctx *x, const u8 *k, u32 kbits, u32 ivbits)
static void chacha_ivsetup (chacha_ctx *x, const u8 *iv)
static void chacha_encrypt_bytes (chacha_ctx *x, const u8 *m, u8 *c, u32 bytes)

Variables

static const char sigma [16]
static const char tau [16]


Define Documentation

#define U8C (  )     (v##U)

Definition at line 20 of file chacha_private.h.

#define U32C (  )     (v##U)

Definition at line 21 of file chacha_private.h.

#define U8V (  )     ((u8)(v) & U8C(0xFF))

Definition at line 23 of file chacha_private.h.

#define U32V (  )     ((u32)(v) & U32C(0xFFFFFFFF))

Definition at line 24 of file chacha_private.h.

#define ROTL32 ( v,
 )     (U32V((v) << (n)) | ((v) >> (32 - (n))))

Definition at line 26 of file chacha_private.h.

#define U8TO32_LITTLE (  ) 

Value:

(((u32)((p)[0])      ) | \
   ((u32)((p)[1]) <<  8) | \
   ((u32)((p)[2]) << 16) | \
   ((u32)((p)[3]) << 24))

Definition at line 29 of file chacha_private.h.

Referenced by chacha_encrypt_bytes(), chacha_ivsetup(), and chacha_keysetup().

#define U32TO8_LITTLE ( p,
 ) 

Value:

do { \
    (p)[0] = U8V((v)      ); \
    (p)[1] = U8V((v) >>  8); \
    (p)[2] = U8V((v) >> 16); \
    (p)[3] = U8V((v) >> 24); \
  } while (0)

Definition at line 35 of file chacha_private.h.

Referenced by chacha_encrypt_bytes().

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

Definition at line 43 of file chacha_private.h.

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

Definition at line 44 of file chacha_private.h.

Referenced by chacha_encrypt_bytes().

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

Definition at line 45 of file chacha_private.h.

Referenced by chacha_encrypt_bytes().

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

Definition at line 46 of file chacha_private.h.

Referenced by chacha_encrypt_bytes().

#define QUARTERROUND ( a,
b,
c,
 ) 

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);

Definition at line 48 of file chacha_private.h.

Referenced by chacha_encrypt_bytes().


Typedef Documentation

typedef unsigned char u8

Definition at line 12 of file chacha_private.h.

typedef unsigned int u32

Definition at line 13 of file chacha_private.h.


Function Documentation

static void chacha_keysetup ( chacha_ctx x,
const u8 k,
u32  kbits,
u32  ivbits 
) [static]

Definition at line 60 of file chacha_private.h.

References chacha_ctx::input, sigma, tau, U8TO32_LITTLE, and UNUSED.

Referenced by chacha_reinit().

static void chacha_ivsetup ( chacha_ctx x,
const u8 iv 
) [static]

Definition at line 87 of file chacha_private.h.

References chacha_ctx::input, and U8TO32_LITTLE.

Referenced by chacha_reinit().

static void chacha_encrypt_bytes ( chacha_ctx x,
const u8 m,
u8 c,
u32  bytes 
) [static]

Definition at line 96 of file chacha_private.h.

References chacha_ctx::input, PLUS, PLUSONE, QUARTERROUND, U32TO8_LITTLE, U8TO32_LITTLE, and XOR.

Referenced by chacha_rekey().


Variable Documentation

const char sigma[16] [static]

Initial value:

 { 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3',
                                '2', '-', 'b', 'y', 't', 'e', ' ', 'k' }

Definition at line 54 of file chacha_private.h.

Referenced by chacha_keysetup().

const char tau[16] [static]

Initial value:

 { 'e', 'x', 'p', 'a', 'n', 'd', ' ', '1',
                              '6', '-', 'b', 'y', 't', 'e', ' ', 'k' }

Definition at line 56 of file chacha_private.h.

Referenced by chacha_keysetup(), and runs().


Generated on Tue Apr 28 17:41:14 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha