Skip to content
Snippets Groups Projects
Commit b9d18b83 authored by Niels Möller's avatar Niels Möller
Browse files

Use static const for all tables.

(des_set_key): Use a new const * variable for the parity
procesing, for constness reasons.

Rev: src/nettle/des.c:1.6
parent a5e88cf4
No related branches found
No related tags found
No related merge requests found
...@@ -41,14 +41,18 @@ static DECRYPT(DesSmallFipsDecrypt,TEMPSMALL, LOADFIPS,KEYMAPSMALL,SAVEFIPS) ...@@ -41,14 +41,18 @@ static DECRYPT(DesSmallFipsDecrypt,TEMPSMALL, LOADFIPS,KEYMAPSMALL,SAVEFIPS)
/* various tables */ /* various tables */
uint32_t des_keymap[] = { static const uint32_t
des_keymap[] = {
#include "keymap.h" #include "keymap.h"
}; };
static uint8_t rotors[] = { static const uint8_t
rotors[] = {
#include "rotors.h" #include "rotors.h"
}; };
static char parity[] = {
static const char
parity[] = {
#include "parity.h" #include "parity.h"
}; };
...@@ -68,19 +72,22 @@ des_set_key(struct des_ctx *ctx, const uint8_t *key) ...@@ -68,19 +72,22 @@ des_set_key(struct des_ctx *ctx, const uint8_t *key)
register char * b0, * b1; register char * b0, * b1;
char bits0[56], bits1[56]; char bits0[56], bits1[56];
uint32_t *method; uint32_t *method;
uint8_t *k; const uint8_t *k;
{
register const char *b;
/* check for bad parity and weak keys */ /* check for bad parity and weak keys */
b0 = parity; b = parity;
n = b0[key[0]]; n <<= 4; n = b[key[0]]; n <<= 4;
n |= b0[key[1]]; n <<= 4; n |= b[key[1]]; n <<= 4;
n |= b0[key[2]]; n <<= 4; n |= b[key[2]]; n <<= 4;
n |= b0[key[3]]; n <<= 4; n |= b[key[3]]; n <<= 4;
n |= b0[key[4]]; n <<= 4; n |= b[key[4]]; n <<= 4;
n |= b0[key[5]]; n <<= 4; n |= b[key[5]]; n <<= 4;
n |= b0[key[6]]; n <<= 4; n |= b[key[6]]; n <<= 4;
n |= b0[key[7]]; n |= b[key[7]];
w = 0x88888888l; w = 0x88888888l;
}
/* report bad parity in key */ /* report bad parity in key */
if ( n & w ) if ( n & w )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment