/[dynamips]/trunk/sbox.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/sbox.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 792 byte(s)
make working copy

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

  ViewVC Help
Powered by ViewVC 1.1.26