Sophie

Sophie

distrib > Mandriva > cooker > i586 > by-pkgid > 954e47fd8526355e3caab1005b050dd9 > files > 204

dynamips-debug-0.2.8-0.RC2.2mdv2011.0.i586.rpm

/*
 * 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