CC26xx Driver Library
sw_ecrypt-sync.h File Reference

Data Structures

struct  ECRYPT_ctx
 

Macros

#define ECRYPT_NAME   "ChaCha8"
 
#define ECRYPT_PROFILE   "_____"
 
#define ECRYPT_MAXKEYSIZE   256 /* [edit] */
 
#define ECRYPT_KEYSIZE(i)   (128 + (i)*128) /* [edit] */
 
#define ECRYPT_MAXIVSIZE   64 /* [edit] */
 
#define ECRYPT_IVSIZE(i)   (64 + (i)*64) /* [edit] */
 
#define ECRYPT_GENERATES_KEYSTREAM
 
#define ECRYPT_USES_DEFAULT_ALL_IN_ONE   /* [edit] */
 
#define ECRYPT_BLOCKLENGTH   64 /* [edit] */
 
#define ECRYPT_USES_DEFAULT_BLOCK_MACROS   /* [edit] */
 
#define ECRYPT_encrypt_blocks(ctx, plaintext, ciphertext, blocks)
 
#define ECRYPT_decrypt_blocks(ctx, ciphertext, plaintext, blocks)
 
#define ECRYPT_keystream_blocks(ctx, keystream, blocks)
 
#define ECRYPT_MAXVARIANT   1 /* [edit] */
 
#define ECRYPT_VARIANT   1
 

Functions

void ECRYPT_init (void)
 
void ECRYPT_keysetup (ECRYPT_ctx *ctx, const u8 *key, u32 keysize, u32 ivsize)
 
void ECRYPT_ivsetup (ECRYPT_ctx *ctx, const u8 *iv)
 
void ECRYPT_encrypt_bytes (ECRYPT_ctx *ctx, const u8 *plaintext, u8 *ciphertext, u32 msglen)
 
void ECRYPT_decrypt_bytes (ECRYPT_ctx *ctx, const u8 *ciphertext, u8 *plaintext, u32 msglen)
 
void ECRYPT_keystream_bytes (ECRYPT_ctx *ctx, u8 *keystream, u32 length)
 
void ECRYPT_encrypt_packet (ECRYPT_ctx *ctx, const u8 *iv, const u8 *plaintext, u8 *ciphertext, u32 msglen)
 
void ECRYPT_decrypt_packet (ECRYPT_ctx *ctx, const u8 *iv, const u8 *ciphertext, u8 *plaintext, u32 msglen)
 

Macro Definition Documentation

§ ECRYPT_BLOCKLENGTH

#define ECRYPT_BLOCKLENGTH   64 /* [edit] */

§ ECRYPT_decrypt_blocks

#define ECRYPT_decrypt_blocks (   ctx,
  ciphertext,
  plaintext,
  blocks 
)
Value:
ECRYPT_decrypt_bytes(ctx, ciphertext, plaintext, \
(blocks) * ECRYPT_BLOCKLENGTH)
#define ECRYPT_BLOCKLENGTH
Definition: sw_ecrypt-sync.h:214
void ECRYPT_decrypt_bytes(ECRYPT_ctx *ctx, const u8 *ciphertext, u8 *plaintext, u32 msglen)
Definition: sw_chacha.c:109

§ ECRYPT_encrypt_blocks

#define ECRYPT_encrypt_blocks (   ctx,
  plaintext,
  ciphertext,
  blocks 
)
Value:
ECRYPT_encrypt_bytes(ctx, plaintext, ciphertext, \
(blocks) * ECRYPT_BLOCKLENGTH)
void ECRYPT_encrypt_bytes(ECRYPT_ctx *ctx, const u8 *plaintext, u8 *ciphertext, u32 msglen)
Definition: sw_chacha.c:85
#define ECRYPT_BLOCKLENGTH
Definition: sw_ecrypt-sync.h:214

§ ECRYPT_GENERATES_KEYSTREAM

#define ECRYPT_GENERATES_KEYSTREAM

§ ECRYPT_IVSIZE

#define ECRYPT_IVSIZE (   i)    (64 + (i)*64) /* [edit] */

§ ECRYPT_KEYSIZE

#define ECRYPT_KEYSIZE (   i)    (128 + (i)*128) /* [edit] */

§ ECRYPT_keystream_blocks

#define ECRYPT_keystream_blocks (   ctx,
  keystream,
  blocks 
)
Value:
ECRYPT_keystream_bytes(ctx, keystream, \
(blocks) * ECRYPT_BLOCKLENGTH)
void ECRYPT_keystream_bytes(ECRYPT_ctx *ctx, u8 *keystream, u32 length)
Definition: sw_chacha.c:114
#define ECRYPT_BLOCKLENGTH
Definition: sw_ecrypt-sync.h:214

§ ECRYPT_MAXIVSIZE

#define ECRYPT_MAXIVSIZE   64 /* [edit] */

§ ECRYPT_MAXKEYSIZE

#define ECRYPT_MAXKEYSIZE   256 /* [edit] */

§ ECRYPT_MAXVARIANT

#define ECRYPT_MAXVARIANT   1 /* [edit] */

§ ECRYPT_NAME

#define ECRYPT_NAME   "ChaCha8"

§ ECRYPT_PROFILE

#define ECRYPT_PROFILE   "_____"

§ ECRYPT_USES_DEFAULT_ALL_IN_ONE

#define ECRYPT_USES_DEFAULT_ALL_IN_ONE   /* [edit] */

§ ECRYPT_USES_DEFAULT_BLOCK_MACROS

#define ECRYPT_USES_DEFAULT_BLOCK_MACROS   /* [edit] */

§ ECRYPT_VARIANT

#define ECRYPT_VARIANT   1

Function Documentation

§ ECRYPT_decrypt_bytes()

void ECRYPT_decrypt_bytes ( ECRYPT_ctx ctx,
const u8 *  ciphertext,
u8 *  plaintext,
u32  msglen 
)
110 {
111  ECRYPT_encrypt_bytes(x,c,m,bytes);
112 }
void ECRYPT_encrypt_bytes(ECRYPT_ctx *x, const u8 *m, u8 *c, u32 bytes)
Definition: sw_chacha.c:85
Here is the call graph for this function:

§ ECRYPT_decrypt_packet()

void ECRYPT_decrypt_packet ( ECRYPT_ctx ctx,
const u8 *  iv,
const u8 *  ciphertext,
u8 *  plaintext,
u32  msglen 
)

§ ECRYPT_encrypt_bytes()

void ECRYPT_encrypt_bytes ( ECRYPT_ctx ctx,
const u8 *  plaintext,
u8 *  ciphertext,
u32  msglen 
)

Referenced by ECRYPT_decrypt_bytes(), and ECRYPT_keystream_bytes().

86 {
87  u8 output[64];
88  int i;
89 
90  if (!bytes) return;
91  for (;;) {
92  salsa20_wordtobyte(output,x->input);
93  x->input[12] = PLUSONE(x->input[12]);
94  if (!x->input[12]) {
95  x->input[13] = PLUSONE(x->input[13]);
96  /* stopping at 2^70 bytes per nonce is user's responsibility */
97  }
98  if (bytes <= 64) {
99  for (i = 0;i < bytes;++i) c[i] = m[i] ^ output[i];
100  return;
101  }
102  for (i = 0;i < 64;++i) c[i] = m[i] ^ output[i];
103  bytes -= 64;
104  c += 64;
105  m += 64;
106  }
107 }
static void salsa20_wordtobyte(u8 output[64], const u32 input[16])
Definition: sw_chacha.c:25
#define PLUSONE(v)
Definition: sw_chacha.c:17
Here is the call graph for this function:

§ ECRYPT_encrypt_packet()

void ECRYPT_encrypt_packet ( ECRYPT_ctx ctx,
const u8 *  iv,
const u8 *  plaintext,
u8 *  ciphertext,
u32  msglen 
)

§ ECRYPT_init()

void ECRYPT_init ( void  )
46 {
47  return;
48 }

§ ECRYPT_ivsetup()

void ECRYPT_ivsetup ( ECRYPT_ctx ctx,
const u8 *  iv 
)
78 {
79  x->input[12] = 0;
80  x->input[13] = 0;
81  x->input[14] = U8TO32_LITTLE(iv + 0);
82  x->input[15] = U8TO32_LITTLE(iv + 4);
83 }
#define U8TO32_LITTLE(p)
Definition: sw_ecrypt-portable.h:186

§ ECRYPT_keysetup()

void ECRYPT_keysetup ( ECRYPT_ctx ctx,
const u8 *  key,
u32  keysize,
u32  ivsize 
)
54 {
55  const char *constants;
56 
57  x->input[4] = U8TO32_LITTLE(k + 0);
58  x->input[5] = U8TO32_LITTLE(k + 4);
59  x->input[6] = U8TO32_LITTLE(k + 8);
60  x->input[7] = U8TO32_LITTLE(k + 12);
61  if (kbits == 256) { /* recommended */
62  k += 16;
63  constants = sigma;
64  } else { /* kbits == 128 */
65  constants = tau;
66  }
67  x->input[8] = U8TO32_LITTLE(k + 0);
68  x->input[9] = U8TO32_LITTLE(k + 4);
69  x->input[10] = U8TO32_LITTLE(k + 8);
70  x->input[11] = U8TO32_LITTLE(k + 12);
71  x->input[0] = U8TO32_LITTLE(constants + 0);
72  x->input[1] = U8TO32_LITTLE(constants + 4);
73  x->input[2] = U8TO32_LITTLE(constants + 8);
74  x->input[3] = U8TO32_LITTLE(constants + 12);
75 }
static const char tau[16]
Definition: sw_chacha.c:51
static const char sigma[16]
Definition: sw_chacha.c:50
#define U8TO32_LITTLE(p)
Definition: sw_ecrypt-portable.h:186

§ ECRYPT_keystream_bytes()

void ECRYPT_keystream_bytes ( ECRYPT_ctx ctx,
u8 *  keystream,
u32  length 
)
115 {
116  u32 i;
117  for (i = 0;i < bytes;++i) stream[i] = 0;
118  ECRYPT_encrypt_bytes(x,stream,stream,bytes);
119 }
void ECRYPT_encrypt_bytes(ECRYPT_ctx *x, const u8 *m, u8 *c, u32 bytes)
Definition: sw_chacha.c:85
Here is the call graph for this function: