ascon.h 817 Bytes
Newer Older
Martin Schläffer committed
1 2 3 4 5 6 7
#ifndef ASCON_H_
#define ASCON_H_

#include <stdint.h>

#include "word.h"

Martin Schläffer committed
8 9 10 11
typedef union {
  uint64_t x[5];
  uint32_t w[5][2];
  uint8_t b[5][8];
Martin Schläffer committed
12 13
} state_t;

Martin Schläffer committed
14 15 16 17 18 19 20 21
typedef struct {
#if (CRYPTO_KEYBYTES == 20)
  uint64_t k0;
#endif
  uint64_t k1;
  uint64_t k2;
} key_t;

Martin Schläffer committed
22 23 24
#define ASCON_ABSORB 0x1
#define ASCON_SQUEEZE 0x2
#define ASCON_INSERT 0x4
Enrico Pozzobon committed
25
#define ASCON_HASH 0x8
Martin Schläffer committed
26 27
#define ASCON_ENCRYPT (ASCON_ABSORB | ASCON_SQUEEZE)
#define ASCON_DECRYPT (ASCON_ABSORB | ASCON_SQUEEZE | ASCON_INSERT)
Martin Schläffer committed
28

Enrico Pozzobon committed
29
void ascon_update(state_t* s, uint8_t* out, const uint8_t* in, uint64_t len,
Martin Schläffer committed
30 31
                  uint8_t mode);

Martin Schläffer committed
32
void ascon_aead(uint8_t* t, uint8_t* out, const uint8_t* in, uint64_t len,
Martin Schläffer committed
33 34 35
                const uint8_t* ad, uint64_t adlen, const uint8_t* npub,
                const uint8_t* k, uint8_t mode);

Martin Schläffer committed
36
#endif /* ASCON_H_ */