Debian Codegraph @

common/sbox.h

raw
1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2007 Christophe Fillot ([email protected])
4 *
5 * S-box functions.
6 */
7
8 #ifndef __SBOX_H__
9 #define __SBOX_H__
10
11 #include "dynamips_common.h"
12
13 extern m_uint32_t sbox_array[];
14
15 static inline m_uint32_t sbox_compute(m_uint8_t *data,int len)
16 {
17 m_uint32_t hash = 0;
18
19 while(len > 0) {
20 hash ^= sbox_array[*data];
21 hash *= 3;
22 data++;
23 }
24
25 return(hash);
26 }
27
28 static forced_inline m_uint32_t sbox_u32(m_uint32_t val)
29 {
30 m_uint32_t hash = 0;
31
32 hash ^= sbox_array[(m_uint8_t)val];
33 hash *= 3;
34 val >>= 8;
35
36 hash ^= sbox_array[(m_uint8_t)val];
37 hash *= 3;
38 val >>= 8;
39
40 hash ^= sbox_array[(m_uint8_t)val];
41 hash *= 3;
42 val >>= 8;
43
44 hash ^= sbox_array[(m_uint8_t)val];
45 return(hash);
46 }
47
48 #endif