isap.h 2.91 KB
Newer Older
Enrico Pozzobon committed
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
#ifndef ISAP_H
#define ISAP_H

#ifdef ISAP128

/******************************************************************************/
/*                               Isap-128                                     */
/******************************************************************************/

#ifdef KECCAKP400

/**************************************/
/*        Isap-128 & KeccakP400       */
/**************************************/

// Rate in bits
#define ISAP_rH 144
#define ISAP_rB 1

// Number of rounds
#define ISAP_sH 20
#define ISAP_sB 12
#define ISAP_sE 12
#define ISAP_sK 12

// State size in bytes
#define ISAP_STATE_SZ 50

#elif defined(ASCON)

/**************************************/
/*          Isap-128 & Ascon          */
/**************************************/

// Rate in bytes
#define ISAP_rH 64
#define ISAP_rB 1

// Number of rounds
#define ISAP_sH 12
#define ISAP_sB 12
#define ISAP_sE 12
#define ISAP_sK 12

// State size in bytes
#define ISAP_STATE_SZ 40

#endif // ASCON

#elif defined(ISAP128A)

/******************************************************************************/
/*                               Isap-128a                                    */
/******************************************************************************/

#ifdef KECCAKP400

/**************************************/
/*       Isap-128a & KeccakP400       */
/**************************************/

// Rate in bits
#define ISAP_rH 144
#define ISAP_rB 1

// Number of rounds
#define ISAP_sH 16
#define ISAP_sB 1
#define ISAP_sE 8
#define ISAP_sK 8

// State size in bytes
#define ISAP_STATE_SZ 50

#elif defined(ASCON)

/**************************************/
/*         Isap-128a & Ascon          */
/**************************************/

// Rate in bits
#define ISAP_rH 64
#define ISAP_rB 1

// Number of rounds
#define ISAP_sH 12
#define ISAP_sB 1
#define ISAP_sE 6
#define ISAP_sK 12

// State size in bytes
#define ISAP_STATE_SZ 40

#endif // ASCON

#endif // ISAP128A

/******************************************************************************/
/*                                Generic                                     */
/******************************************************************************/

// Size of rate in bytes
#define ISAP_rH_SZ ((ISAP_rH+7)/8)

// Size of zero truncated IV in bytes
#define ISAP_IV_SZ 8

// Size of tag in bytes
#define ISAP_TAG_SZ 16

// Security level
#define ISAP_K 128

void isap_mac(
	const unsigned char *k,
	const unsigned char *npub,
	const unsigned char *ad, const unsigned long long adlen,
	const unsigned char *c, const unsigned long long clen,
	unsigned char *tag
);

void isap_rk(
	const unsigned char *k,
	const unsigned char *iv,
	const unsigned char *in,
	const unsigned long long inlen,
	unsigned char *out,
	const unsigned long long outlen
);

void isap_enc(
	const unsigned char *k,
	const unsigned char *npub,
	const unsigned char *m, const unsigned long long mlen,
	unsigned char *c
);

#endif