tls

tls.git
git clone git://git.lenczewski.org/tls.git
Log | Files | Refs

chacha20.h (968B)


      1 // chacha20-poly1305: https://www.rfc-editor.org/info/rfc8439/
      2 
      3 #ifndef CHACHA20_H
      4 #define CHACHA20_H
      5 
      6 #include <limits.h>
      7 #include <stdalign.h>
      8 #include <stddef.h>
      9 #include <stdint.h>
     10 
     11 #define CHACHA20_ALIGN 64
     12 #define CHACHA20_ROUNDS 10
     13 
     14 typedef uint32_t chacha20_word_t;
     15 
     16 #define CHACHA20_WORD_BITS 32
     17 #define CHACHA20_BLOCK_BITS 512
     18 #define CHACHA20_KEY_BITS 256
     19 #define CHACHA20_IV_BITS 96
     20 
     21 #define CHACHA20_BLOCK_WORDS (CHACHA20_BLOCK_BITS / CHACHA20_WORD_BITS)
     22 #define CHACHA20_BLOCK_SIZE (CHACHA20_BLOCK_BITS / CHAR_BIT)
     23 
     24 #define CHACHA20_KEY_WORDS (CHACHA20_KEY_BITS / CHACHA20_WORD_BITS)
     25 #define CHACHA20_KEY_SIZE (CHACHA20_KEY_BITS / CHAR_BIT)
     26 
     27 #define CHACHA20_IV_WORDS (CHACHA20_IV_BITS / CHACHA20_WORD_BITS)
     28 #define CHACHA20_IV_SIZE (CHACHA20_IV_BITS / CHAR_BIT)
     29 
     30 void
     31 chacha20(unsigned char key[static CHACHA20_KEY_SIZE],
     32 	 uint32_t ctr,
     33 	 unsigned char iv[static CHACHA20_IV_SIZE],
     34 	 void const *buf, size_t len,
     35 	 void *out);
     36 
     37 #endif /* CHACHA20_H */