tls

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

poly1305.h (1030B)


      1 // chacha20-poly1305: https://www.rfc-editor.org/info/rfc8439/
      2 
      3 #ifndef POLY1305_H
      4 #define POLY1305_H
      5 
      6 #include <stdalign.h>
      7 #include <stdint.h>
      8 
      9 #define POLY1305_ALIGN 64
     10 
     11 #define POLY1305_KEY_BITS 256
     12 #define POLY1305_KEY_SIZE (POLY1305_KEY_BITS / CHAR_BIT)
     13 
     14 #define POLY1305_BLOCK_BITS 128
     15 #define POLY1305_BLOCK_SIZE (POLY1305_BLOCK_BITS / CHAR_BIT)
     16 
     17 #define POLY1305_DIGEST_BITS 128
     18 #define POLY1305_DIGEST_SIZE (POLY1305_DIGEST_BITS / CHAR_BIT)
     19 
     20 struct poly1305_ctx {
     21 	alignas(POLY1305_ALIGN)
     22 	unsigned char r[16];
     23 	unsigned char s[16];
     24 	unsigned char a[17];
     25 };
     26 
     27 void
     28 poly1305_init(struct poly1305_ctx *ctx,
     29 	      unsigned char const key[static POLY1305_KEY_SIZE]);
     30 
     31 void
     32 poly1305_push(struct poly1305_ctx *ctx, void const *buf, size_t len);
     33 
     34 void
     35 poly1305_dgst(struct poly1305_ctx *ctx,
     36 	      unsigned char digest[static POLY1305_DIGEST_SIZE]);
     37 
     38 void
     39 poly1305(unsigned char const key[static POLY1305_KEY_SIZE],
     40 	 void const *buf, size_t len,
     41 	 unsigned char digest[static POLY1305_DIGEST_SIZE]);
     42 
     43 #endif /* POLY1305_H */