CC13xx 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

#define ECRYPT_BLOCKLENGTH   64 /* [edit] */
#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:216
void ECRYPT_decrypt_bytes(ECRYPT_ctx *ctx, const u8 *ciphertext, u8 *plaintext, u32 msglen)
Definition: sw_chacha.c:111
#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:87
#define ECRYPT_BLOCKLENGTH
Definition: sw_ecrypt-sync.h:216
#define ECRYPT_GENERATES_KEYSTREAM
#define ECRYPT_IVSIZE (   i)    (64 + (i)*64) /* [edit] */
#define ECRYPT_KEYSIZE (   i)    (128 + (i)*128) /* [edit] */
#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:116
#define ECRYPT_BLOCKLENGTH
Definition: sw_ecrypt-sync.h:216
#define ECRYPT_MAXIVSIZE   64 /* [edit] */
#define ECRYPT_MAXKEYSIZE   256 /* [edit] */
#define ECRYPT_MAXVARIANT   1 /* [edit] */
#define ECRYPT_NAME   "ChaCha8"
#define ECRYPT_PROFILE   "_____"
#define ECRYPT_USES_DEFAULT_ALL_IN_ONE   /* [edit] */
#define ECRYPT_USES_DEFAULT_BLOCK_MACROS   /* [edit] */
#define ECRYPT_VARIANT   1

Function Documentation

void ECRYPT_decrypt_bytes ( ECRYPT_ctx ctx,
const u8 *  ciphertext,
u8 *  plaintext,
u32  msglen 
)
112 {
113  ECRYPT_encrypt_bytes(x,c,m,bytes);
114 }
void ECRYPT_encrypt_bytes(ECRYPT_ctx *x, const u8 *m, u8 *c, u32 bytes)
Definition: sw_chacha.c:87

Here is the call graph for this function:

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

Referenced by ECRYPT_decrypt_bytes(), and ECRYPT_keystream_bytes().

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

Here is the call graph for this function:

void ECRYPT_encrypt_packet ( ECRYPT_ctx ctx,
const u8 *  iv,
const u8 *  plaintext,
u8 *  ciphertext,
u32  msglen 
)
void ECRYPT_init ( void  )
48 {
49  return;
50 }
void ECRYPT_ivsetup ( ECRYPT_ctx ctx,
const u8 *  iv 
)
80 {
81  x->input[12] = 0;
82  x->input[13] = 0;
83  x->input[14] = U8TO32_LITTLE(iv + 0);
84  x->input[15] = U8TO32_LITTLE(iv + 4);
85 }
#define U8TO32_LITTLE(p)
Definition: sw_ecrypt-portable.h:188
void ECRYPT_keysetup ( ECRYPT_ctx ctx,
const u8 *  key,
u32  keysize,
u32  ivsize 
)
56 {
57  const char *constants;
58 
59  x->input[4] = U8TO32_LITTLE(k + 0);
60  x->input[5] = U8TO32_LITTLE(k + 4);
61  x->input[6] = U8TO32_LITTLE(k + 8);
62  x->input[7] = U8TO32_LITTLE(k + 12);
63  if (kbits == 256) { /* recommended */
64  k += 16;
65  constants = sigma;
66  } else { /* kbits == 128 */
67  constants = tau;
68  }
69  x->input[8] = U8TO32_LITTLE(k + 0);
70  x->input[9] = U8TO32_LITTLE(k + 4);
71  x->input[10] = U8TO32_LITTLE(k + 8);
72  x->input[11] = U8TO32_LITTLE(k + 12);
73  x->input[0] = U8TO32_LITTLE(constants + 0);
74  x->input[1] = U8TO32_LITTLE(constants + 4);
75  x->input[2] = U8TO32_LITTLE(constants + 8);
76  x->input[3] = U8TO32_LITTLE(constants + 12);
77 }
static const char tau[16]
Definition: sw_chacha.c:53
static const char sigma[16]
Definition: sw_chacha.c:52
#define U8TO32_LITTLE(p)
Definition: sw_ecrypt-portable.h:188
void ECRYPT_keystream_bytes ( ECRYPT_ctx ctx,
u8 *  keystream,
u32  length 
)
117 {
118  u32 i;
119  for (i = 0;i < bytes;++i) stream[i] = 0;
120  ECRYPT_encrypt_bytes(x,stream,stream,bytes);
121 }
void ECRYPT_encrypt_bytes(ECRYPT_ctx *x, const u8 *m, u8 *c, u32 bytes)
Definition: sw_chacha.c:87

Here is the call graph for this function: