-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsbox.h
More file actions
49 lines (37 loc) · 822 Bytes
/
sbox.h
File metadata and controls
49 lines (37 loc) · 822 Bytes
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
/*
* Cisco router simulation platform.
* Copyright (c) 2007 Christophe Fillot (cf@utc.fr)
*
* S-box functions.
*/
#ifndef __SBOX_H__
#define __SBOX_H__
#include <sys/types.h>
#include "utils.h"
extern m_uint32_t sbox_array[];
static inline m_uint32_t sbox_compute (m_uint8_t * data, int len)
{
m_uint32_t hash = 0;
while (len > 0) {
hash ^= sbox_array[*data];
hash *= 3;
data++;
}
return (hash);
}
static forced_inline m_uint32_t sbox_u32 (m_uint32_t val)
{
m_uint32_t hash = 0;
hash ^= sbox_array[(m_uint8_t) val];
hash *= 3;
val >>= 8;
hash ^= sbox_array[(m_uint8_t) val];
hash *= 3;
val >>= 8;
hash ^= sbox_array[(m_uint8_t) val];
hash *= 3;
val >>= 8;
hash ^= sbox_array[(m_uint8_t) val];
return (hash);
}
#endif