Commit fe8539bc authored by Niels Möller's avatar Niels Möller

* src/symmetric/rijndael.c: Use static const for all lookup

tables.

Rev: src/symmetric/rijndael.c:1.2
parent d78ed5cc
/* rijndael - An implementation of the Rijndael cipher.
*
* Copyright (C) 2000 Rafael R. Sevilla <dido@pacific.net.ph>
*
* This library is free software; you can redistribute it and/or
......@@ -17,15 +18,17 @@
*/
#include "rijndael.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/* These tables combine both the S-boxes and the mixcolumn transformation, so
that we can perform a round's encryption or by means of four table lookups
and four XOR's per column of state. They were generated by the
makertbls.pl script. */
UINT32 dtbl[] = {
static const UINT32 dtbl[] = {
0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6,
0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591,
0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56,
......@@ -92,7 +95,7 @@ UINT32 dtbl[] = {
0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c,
};
UINT32 itbl[] = {
static const UINT32 itbl[] = {
0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a,
0xcb6bab3b, 0xf1459d1f, 0xab58faac, 0x9303e34b,
0x55fa3020, 0xf66d76ad, 0x9176cc88, 0x254c02f5,
......@@ -161,7 +164,7 @@ UINT32 itbl[] = {
/* Needed only for the key schedule and for final rounds */
UINT8 sbox[256] = {
static const UINT8 sbox[256] = {
99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171,
118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164,
114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113,
......@@ -182,7 +185,7 @@ UINT8 sbox[256] = {
22,
};
UINT8 isbox[256] = {
static const UINT8 isbox[256] = {
82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215,
251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222,
233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66,
......@@ -204,7 +207,7 @@ UINT8 isbox[256] = {
};
/* Used only by the key schedule */
UINT8 Logtable[256] = {
static const UINT8 Logtable[256] = {
0, 0, 25, 1, 50, 2, 26, 198, 75, 199, 27, 104, 51, 238, 223, 3,
100, 4, 224, 14, 52, 141, 129, 239, 76, 113, 8, 200, 248, 105, 28,
193, 125, 194, 29, 181, 249, 185, 39, 106, 77, 228, 166, 114, 154, 201,
......@@ -224,7 +227,7 @@ UINT8 Logtable[256] = {
74, 237, 222, 197, 49, 254, 24, 13, 99, 140, 128, 192, 247, 112, 7,
};
UINT8 Alogtable[256] = {
static const UINT8 Alogtable[256] = {
1, 3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19,
53, 95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34,
102, 170, 229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144,
......@@ -304,6 +307,7 @@ rijndael_setup(RIJNDAEL_context *ctx, size_t keysize, const UINT8 *key)
nk = 6;
nr = 12;
} else { /* must be 16 or more */
assert(keysize >= 16);
nk = 4;
nr = 10;
}
......@@ -376,7 +380,7 @@ key_addition32to8(const UINT32 *txt, UINT32 *keys, UINT8 *out)
}
}
static int idx[4][4] = {
static const int idx[4][4] = {
{ 0, 1, 2, 3 },
{ 1, 2, 3, 0 },
{ 2, 3, 0, 1 },
......@@ -415,7 +419,7 @@ rijndael_encrypt(RIJNDAEL_context *ctx,
key_addition32to8(t, &(ctx->keys[4*ctx->nrounds]), ciphertext);
}
static int iidx[4][4] = {
static const int iidx[4][4] = {
{ 0, 1, 2, 3 },
{ 3, 0, 1, 2 },
{ 2, 3, 0, 1 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment