blob: c8f606b4c781b2bcb8dd7325b97f13b4433af0ed (
plain) (
tree)
|
|
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: rijndael_enc
Author: Dr Brian Gladman
Function: rijndael_dec is an implementation of the AES decryption
algorithm (Rijndael).
Source: security section of MiBench
Changes: Add computation of a checksum, refactoring
License: see below
*/
/*
-----------------------------------------------------------------------
Copyright (c) 2001 Dr Brian Gladman <brg@gladman.uk.net>, Worcester, UK
TERMS
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
This software is provided 'as is' with no guarantees of correctness or
fitness for purpose.
-----------------------------------------------------------------------
*/
#include "extra.h"
#include "aes.h"
#include "rijndael_dec_libc.h"
/*
Global variable definitions
*/
unsigned char rijndael_dec_key[32];
int rijndael_dec_key_len;
extern unsigned char rijndael_dec_data[];
struct rijndael_dec_FILE rijndael_dec_fin;
int rijndael_dec_checksum = 0;
/*
Forward declaration of functions
*/
void rijndael_dec_init( void );
int rijndael_dec_return( void );
void rijndael_dec_fillrand( unsigned char *buf, int len );
void rijndael_dec_decfile( struct rijndael_dec_FILE *fin, struct aes *ctx );
void rijndael_dec_main( void );
void rijndael_dec_init( void )
{
/* create a pseudo-file for the input*/
rijndael_dec_fin.data = rijndael_dec_data;
rijndael_dec_fin.size = 32768;
rijndael_dec_fin.cur_pos = 0;
unsigned i;
volatile int x = 0;
rijndael_dec_fin.size ^= x;
_Pragma( "loopbound min 32768 max 32768" )
for ( i = 0; i < rijndael_dec_fin.size; i++ )
rijndael_dec_fin.data[i] ^= x;
/* this is a pointer to the hexadecimal key digits */
const volatile char *cp =
"1234567890abcdeffedcba09876543211234567890abcdeffedcba0987654321";
char ch;
int by = 0;
i = 0; /* this is a count for the input digits processed */
_Pragma( "loopbound min 64 max 64" )
while ( i < 64 && *cp ) { /* the maximum key length is 32 bytes and */
/* hence at most 64 hexadecimal digits */
ch = rijndael_dec_toupper( *cp++ ); /* process a hexadecimal digit */
if ( ch >= '0' && ch <= '9' )
by = ( by << 4 ) + ch - '0';
else
if ( ch >= 'A' && ch <= 'F' )
by = ( by << 4 ) + ch - 'A' + 10;
else { /* error if not hexadecimal */
rijndael_dec_checksum = -2;
|