config.h 3.69 KB
Newer Older
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
#ifndef __CONFIG_H__
#define __CONFIG_H__

//#define CRYPTO_AEAD
#define CRYPTO_HASH

#define   MAX_MESSAGE_LENGTH      128

#define   STATE_INBITS            256
/* For CRYPTO_AEAD */
#define   CRYPTO_KEYBITS          128
/* For CRYPTO_HASH */
#define   CRYPTO_BITS             256

#define   STATE_INBYTES         ((STATE_INBITS + 7) / 8)
#define   ROW_INBITS            ((STATE_INBITS + 3) / 4)
#define   ROW_INBYTES           ((ROW_INBITS   + 7) / 8)

/* For CRYPTO_AEAD */
#define   CRYPTO_KEYBYTES   ((CRYPTO_KEYBITS + 7) / 8)
#define   CRYPTO_NSECBYTES  0
#define   CRYPTO_NPUBBYTES  CRYPTO_KEYBYTES
#define   CRYPTO_ABYTES     CRYPTO_KEYBYTES
#define   CRYPTO_NOOVERLAP  1

#define   MAX_ASSOCIATED_DATA_LENGTH  32
#define   MAX_CIPHER_LENGTH           (MAX_MESSAGE_LENGTH + CRYPTO_ABYTES)

#define   TAG_MATCH        0
#define   TAG_UNMATCH     -1
#define   OTHER_FAILURES  -2

/* For CRYPTO_HASH */
#define   CRYPTO_BYTES            ((CRYPTO_BITS + 7) / 8)



#define DOMAIN_BITS          0x80
#define PAD_BITS             0x01
#define S384_R192_BITS       0x80

#if   (STATE_INBITS==256)
#define C1    1
#define C2    8
#define C3    25
#elif (STATE_INBITS==384)
#define C1    1
#define C2    8
#define C3    55
#elif (STATE_INBITS==512)
#define C1    1
#define C2    16
#define C3    25
#else
#error "Not specified state size"
#endif

#ifdef CRYPTO_AEAD
/* For CRYPTO_AEAD */
#define KEY_INBITS           (CRYPTO_KEYBYTES * 8)
#define KEY_INBYTES          (CRYPTO_KEYBYTES)

#define NONCE_INBITS         (CRYPTO_NPUBBYTES * 8)
#define NONCE_INBYTES        (CRYPTO_NPUBBYTES)

#define TAG_INBITS           (CRYPTO_ABYTES * 8)
#define TAG_INBYTES          (CRYPTO_ABYTES)

#if   (KEY_INBITS==128) && (STATE_INBITS==256)
#define   RATE_INBITS           64
#define   NR_0                  52
#define   NR_i                  28
#define   NR_f                  32
#elif (KEY_INBITS==128) && (STATE_INBITS==384)
#define   RATE_INBITS           192
#define   NR_0                  76
#define   NR_i                  28
#define   NR_f                  32
#elif (KEY_INBITS==192) && (STATE_INBITS==384)
#define   RATE_INBITS           96
#define   NR_0                  76
#define   NR_i                  40
#define   NR_f                  44
#elif (KEY_INBITS==256) && (STATE_INBITS==512)
#define   RATE_INBITS           128
#define   NR_0                  100
#define   NR_i                  52
#define   NR_f                  56
#else
#error "Not specified key size and state size"
#endif

#define   RATE_INBYTES          ((RATE_INBITS + 7) / 8)
#define   SQUEEZE_RATE_INBYTES  TAG_INBYTES

#endif

#ifdef CRYPTO_HASH
/* For CRYPTO_HASH */
#define HASH_DIGEST_INBITS   (CRYPTO_BYTES * 8)

#if   (HASH_DIGEST_INBITS==256) && (STATE_INBITS==256)
#define   HASH_RATE_INBITS                32
#define   HASH_SQUEEZE_RATE_INBITS        128
#define   NR_h                            68
#elif (HASH_DIGEST_INBITS==256) && (STATE_INBITS==384)
#define   HASH_RATE_INBITS                128
#define   HASH_SQUEEZE_RATE_INBITS        128
#define   NR_h                            80
#elif (HASH_DIGEST_INBITS==384) && (STATE_INBITS==384)
#define   HASH_RATE_INBITS                48
#define   HASH_SQUEEZE_RATE_INBITS        192
#define   NR_h                            104
#elif (HASH_DIGEST_INBITS==512) && (STATE_INBITS==512)
#define   HASH_RATE_INBITS                64
#define   HASH_SQUEEZE_RATE_INBITS        256
#define   NR_h                            140
#else
#error "Not specified hash digest size and state size"
#endif

#define   HASH_RATE_INBYTES               ((HASH_RATE_INBITS + 7) / 8)
#define   HASH_SQUEEZE_RATE_INBYTES       ((HASH_SQUEEZE_RATE_INBITS + 7) / 8)

#endif

#define TAG_MATCH       0
#define TAG_UNMATCH    -1
#define OTHER_FAILURES -2

#endif