File: chacha.h

package info (click to toggle)
libmath-prime-util-perl 0.73-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,800 kB
  • sloc: perl: 24,676; ansic: 11,471; python: 24; makefile: 18
file content (29 lines) | stat: -rw-r--r-- 847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef MPU_CHACHA_H
#define MPU_CHACHA_H

#include "ptypes.h"

/*  State info  */

#define STATESZ  16        /* words: 4 constant, 8 key, 2 counter, 2 nonce */
#define KEYSZ    40        /* bytes of user supplied key+nonce */
#define CORESZ   64        /* bytes output by core */
#define BUFSZ    16*CORESZ /* bytes we get at a time (1024) */
typedef struct {
  uint32_t      state[STATESZ];
  unsigned char buf[BUFSZ];
  uint16_t      have;
  char          goodseed;
} chacha_context_t;

/*  API  */

extern void chacha_seed(chacha_context_t *cs, uint32_t bytes, const unsigned char* data, char good);
extern void chacha_rand_bytes(chacha_context_t *cs, uint32_t bytes, unsigned char* data);

extern uint32_t chacha_irand32(chacha_context_t *cs);
extern UV       chacha_irand64(chacha_context_t *cs);

extern int chacha_selftest(void);

#endif