Skip to content
Snippets Groups Projects
Select Git revision
  • adde2bbad645d05c1e4e15b3826befd0d7a9bbdf
  • master default protected
  • siv-mode
  • delete-des-compat
  • delete-rsa_blind
  • aes-struct-layout
  • master-updates
  • release-3.4-fixes
  • struct-layout
  • attribute-deprecated
  • rename-data-symbols
  • x86_64-sha_ni-sha256
  • ecc-params-tweak
  • delete-old-aes
  • cmac-support
  • x86_64-sha_ni-sha1
  • gcm-ctr-opt
  • ctr-opt
  • skein
  • api-opaque-fix
  • curve448
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
  • converted-master-branch-to-git
  • nettle_2.4_release_20110903
  • nettle_2.3_release_20110902
41 results

asm.m4

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    aesdata.c 5.68 KiB
    #include <assert.h>
    #include <inttypes.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    
    #if 1
    # define BYTE_FORMAT "0x%02x"
    # define BYTE_COLUMNS 8
    #else
    # define BYTE_FORMAT "%3d"
    # define BYTE_COLUMNS 0x10
    #endif
    
    #define WORD_FORMAT "0x%08x"
    #define WORD_COLUMNS 4
    
    uint8_t sbox[0x100];
    uint8_t isbox[0x100];
    
    uint8_t log[0x100];
    uint8_t ilog[0x100];
    
    uint32_t dtable[4][0x100];
    uint32_t itable[4][0x100];
    
    static unsigned
    xtime(unsigned x)
    {
      assert (x < 0x100);
    
      x <<= 1;
      if (x & 0x100)
        x ^= 0x11b;
    
      assert (x < 0x100);
    
      return x;
    }
    
    /* Computes the expoenntiatiom and logarithm tables for GF_2, to the
     * base x+1 (0x03). The unit element is 1 (0x01).*/
    static void
    compute_log(void)
    {
      unsigned i = 0;
      unsigned x = 1;
    
      memset(log, 0, 0x100);
      
      for (i = 0; i < 0x100; i++, x = x ^ xtime(x))
        {
          ilog[i] = x;
          log[x] = i;
        }
      /* Invalid. */
      log[0] = 0;
      /* The loop above sets log[1] = 0xff, which is correct,
       * but log[1] = 0 is nicer. */
      log[1] = 0;
    }
    
    static unsigned
    mult(unsigned a, unsigned b)
    {
      return (a && b) ? ilog[ (log[a] + log[b]) % 255] : 0;
    }
    
    static unsigned
    invert(unsigned x)