Skip to content
Snippets Groups Projects
Select Git revision
21 results Searching

rijndael.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    rijndael.c 17.84 KiB
    /* rijndael - An implementation of the Rijndael cipher.
     *
     * Copyright (C) 2000 Rafael R. Sevilla <dido@pacific.net.ph>
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Library General Public
     * License as published by the Free Software Foundation; either
     * version 2 of the License, or (at your option) any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * Library General Public License for more details.
     *
     * You should have received a copy of the GNU Library General Public
     * License along with this library; if not, write to the Free
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     */
    
    #include "rijndael.h"
    
    #include <assert.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    /* These tables combine both the S-boxes and the mixcolumn transformation, so
       that we can perform a round's encryption or by means of four table lookups
       and four XOR's per column of state.  They were generated by the
       makertbls.pl script. */
    static const UINT32 dtbl[] = {
      0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6, 
      0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591, 
      0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56, 
      0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec, 
      0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa, 
      0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb, 
      0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45, 
      0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b, 
      0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c, 
      0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83, 
      0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9, 
      0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a, 
      0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d, 
      0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f, 
      0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df, 
      0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea, 
      0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34, 
      0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b, 
      0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d, 
      0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413, 
      0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1, 
      0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6, 
      0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972, 
      0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85, 
      0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed, 
      0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511, 
      0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe, 
      0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b, 
      0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05, 
      0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1, 
      0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142, 
      0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf, 
      0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3, 
      0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e, 
      0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a, 
      0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6, 
      0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3, 
      0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b, 
      0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428,