Welcome to Dream.In.Code
Click Here
Getting PHP Help is Easy!

Join 118,659 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 857 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



AES Encryption Standard

 
Reply to this topicStart new topic

AES Encryption Standard, Attempted implementation in PHP

grimpirate
post 26 Jun, 2008 - 11:50 PM
Post #1


D.I.C Head

Group Icon
Joined: 3 Aug, 2006
Posts: 177



Thanked 5 times

Dream Kudos: 375
My Contributions


I've been trying to implement it in PHP and haven't succeeded as of yet. Here's my code:
PHP
<pre>
<?php
/*
$foo = new AES();
$input = chr(0x50) . chr(0x68) . chr(0x12) . chr(0xA4) . chr(0x5F) . chr(0x08) . chr(0xC8) . chr(0x89) . chr(0xB9) . chr(0x7F) . chr(0x59) . chr(0x80) . chr(0x03) . chr(0x8B) . chr(0x83) . chr(0x59);
$bar = $foo->encrypt($input, array(
chr(0x00), chr(0x01), chr(0x02), chr(0x03),
chr(0x05), chr(0x06), chr(0x07), chr(0x08),
chr(0x0a), chr(0x0b), chr(0x0c), chr(0x0d),
chr(0x0f), chr(0x10), chr(0x11), chr(0x12)
));
for($i = 0; $i < strlen($bar); $i++){
echo str_pad(dechex(ord(substr($bar, $i, 1))), 2, '0', STR_PAD_LEFT);
}
*/

$foo = new AES();
$expandedKey = array();
for($i = 0; $i < 240; $i++){
array_push($expandedKey, null);
}
$key = array();
for($i = 0; $i < 32; $i++){
array_push($key, chr(0));
}
$bar = $foo->expandKey($expandedKey, $key);
foreach($bar as $key => $value){
if($key % 16 == 0){
echo "\n";
}
echo str_pad(dechex(ord($value)), 2, '0', STR_PAD_LEFT) . ' ';
}

class AES{
var $sbox;
var $rsbox;
var $rcon;
var $finiteMatrix;

function AES(){
$this->sbox = array(
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
chr(0x63), chr(0x7c), chr(0x77), chr(0x7b), chr(0xf2), chr(0x6b), chr(0x6f), chr(0xc5), chr(0x30), chr(0x01), chr(0x67), chr(0x2b), chr(0xfe), chr(0xd7), chr(0xab), chr(0x76), // 0
chr(0xca), chr(0x82), chr(0xc9), chr(0x7d), chr(0xfa), chr(0x59), chr(0x47), chr(0xf0), chr(0xad), chr(0xd4), chr(0xa2), chr(0xaf), chr(0x9c), chr(0xa4), chr(0x72), chr(0xc0), // 1
chr(0xb7), chr(0xfd), chr(0x93), chr(0x26), chr(0x36), chr(0x3f), chr(0xf7), chr(0xcc), chr(0x34), chr(0xa5), chr(0xe5), chr(0xf1), chr(0x71), chr(0xd8), chr(0x31), chr(0x15), // 2
chr(0x04), chr(0xc7), chr(0x23), chr(0xc3), chr(0x18), chr(0x96), chr(0x05), chr(0x9a), chr(0x07), chr(0x12), chr(0x80), chr(0xe2), chr(0xeb), chr(0x27), chr(0xb2), chr(0x75), // 3
chr(0x09), chr(0x83), chr(0x2c), chr(0x1a), chr(0x1b), chr(0x6e), chr(0x5a), chr(0xa0), chr(0x52), chr(0x3b), chr(0xd6), chr(0xb3), chr(0x29), chr(0xe3), chr(0x2f), chr(0x84), // 4
chr(0x53), chr(0xd1), chr(0x00), chr(0xed), chr(0x20), chr(0xfc), chr(0xb1), chr(0x5b), chr(0x6a), chr(0xcb), chr(0xbe), chr(0x39), chr(0x4a), chr(0x4c), chr(0x58), chr(0xcf), // 5
chr(0xd0), chr(0xef), chr(0xaa), chr(0xfb), chr(0x43), chr(0x4d), chr(0x33), chr(0x85), chr(0x45), chr(0xf9), chr(0x02), chr(0x7f), chr(0x50), chr(0x3c), chr(0x9f), chr(0xa8), // 6
chr(0x51), chr(0xa3), chr(0x40), chr(0x8f), chr(0x92), chr(0x9d), chr(0x38), chr(0xf5), chr(0xbc), chr(0xb6), chr(0xda), chr(0x21), chr(0x10), chr(0xff), chr(0xf3), chr(0xd2), // 7
chr(0xcd), chr(0x0c), chr(0x13), chr(0xec), chr(0x5f), chr(0x97), chr(0x44), chr(0x17), chr(0xc4), chr(0xa7), chr(0x7e), chr(0x3d), chr(0x64), chr(0x5d), chr(0x19), chr(0x73), // 8
chr(0x60), chr(0x81), chr(0x4f), chr(0xdc), chr(0x22), chr(0x2a), chr(0x90), chr(0x88), chr(0x46), chr(0xee), chr(0xb8), chr(0x14), chr(0xde), chr(0x5e), chr(0x0b), chr(0xdb), // 9
chr(0xe0), chr(0x32), chr(0x3a), chr(0x0a), chr(0x49), chr(0x06), chr(0x24), chr(0x5c), chr(0xc2), chr(0xd3), chr(0xac), chr(0x62), chr(0x91), chr(0x95), chr(0xe4), chr(0x79), // a
chr(0xe7), chr(0xc8), chr(0x37), chr(0x6d), chr(0x8d), chr(0xd5), chr(0x4e), chr(0xa9), chr(0x6c), chr(0x56), chr(0xf4), chr(0xea), chr(0x65), chr(0x7a), chr(0xae), chr(0x08), // b
chr(0xba), chr(0x78), chr(0x25), chr(0x2e), chr(0x1c), chr(0xa6), chr(0xb4), chr(0xc6), chr(0xe8), chr(0xdd), chr(0x74), chr(0x1f), chr(0x4b), chr(0xbd), chr(0x8b), chr(0x8a), // c
chr(0x70), chr(0x3e), chr(0xb5), chr(0x66), chr(0x48), chr(0x03), chr(0xf6), chr(0x0e), chr(0x61), chr(0x35), chr(0x57), chr(0xb9), chr(0x86), chr(0xc1), chr(0x1d), chr(0x9e), // d
chr(0xe1), chr(0xf8), chr(0x98), chr(0x11), chr(0x69), chr(0xd9), chr(0x8e), chr(0x94), chr(0x9b), chr(0x1e), chr(0x87), chr(0xe9), chr(0xce), chr(0x55), chr(0x28), chr(0xdf), // e
chr(0x8c), chr(0xa1), chr(0x89), chr(0x0d), chr(0xbf), chr(0xe6), chr(0x42), chr(0x68), chr(0x41), chr(0x99), chr(0x2d), chr(0x0f), chr(0xb0), chr(0x54), chr(0xbb), chr(0x16) // f
);

$this->rsbox = array(
chr(0x52), chr(0x09), chr(0x6a), chr(0xd5), chr(0x30), chr(0x36), chr(0xa5), chr(0x38), chr(0xbf), chr(0x40), chr(0xa3), chr(0x9e), chr(0x81), chr(0xf3), chr(0xd7), chr(0xfb),
chr(0x7c), chr(0xe3), chr(0x39), chr(0x82), chr(0x9b), chr(0x2f), chr(0xff), chr(0x87), chr(0x34), chr(0x8e), chr(0x43), chr(0x44), chr(0xc4), chr(0xde), chr(0xe9), chr(0xcb),
chr(0x54), chr(0x7b), chr(0x94), chr(0x32), chr(0xa6), chr(0xc2), chr(0x23), chr(0x3d), chr(0xee), chr(0x4c), chr(0x95), chr(0x0b), chr(0x42), chr(0xfa), chr(0xc3), chr(0x4e),
chr(0x08), chr(0x2e), chr(0xa1), chr(0x66), chr(0x28), chr(0xd9), chr(0x24), chr(0xb2), chr(0x76), chr(0x5b), chr(0xa2), chr(0x49), chr(0x6d), chr(0x8b), chr(0xd1), chr(0x25),
chr(0x72), chr(0xf8), chr(0xf6), chr(0x64), chr(0x86), chr(0x68), chr(0x98), chr(0x16), chr(0xd4), chr(0xa4), chr(0x5c), chr(0xcc), chr(0x5d), chr(0x65), chr(0xb6), chr(0x92),
chr(0x6c), chr(0x70), chr(0x48), chr(0x50), chr(0xfd), chr(0xed), chr(0xb9), chr(0xda), chr(0x5e), chr(0x15), chr(0x46), chr(0x57), chr(0xa7), chr(0x8d), chr(0x9d), chr(0x84),
chr(0x90), chr(0xd8), chr(0xab), chr(0x00), chr(0x8c), chr(0xbc), chr(0xd3), chr(0x0a), chr(0xf7), chr(0xe4), chr(0x58), chr(0x05), chr(0xb8), chr(0xb3), chr(0x45), chr(0x06),
chr(0xd0), chr(0x2c), chr(0x1e), chr(0x8f), chr(0xca), chr(0x3f), chr(0x0f), chr(0x02), chr(0xc1), chr(0xaf), chr(0xbd), chr(0x03), chr(0x01), chr(0x13), chr(0x8a), chr(0x6b),
chr(0x3a), chr(0x91), chr(0x11), chr(0x41), chr(0x4f), chr(0x67), chr(0xdc), chr(0xea), chr(0x97), chr(0xf2), chr(0xcf), chr(0xce), chr(0xf0), chr(0xb4), chr(0xe6), chr(0x73),
chr(0x96), chr(0xac), chr(0x74), chr(0x22), chr(0xe7), chr(0xad), chr(0x35), chr(0x85), chr(0xe2), chr(0xf9), chr(0x37), chr(0xe8), chr(0x1c), chr(0x75), chr(0xdf), chr(0x6e),
chr(0x47), chr(0xf1), chr(0x1a), chr(0x71), chr(0x1d), chr(0x29), chr(0xc5), chr(0x89), chr(0x6f), chr(0xb7), chr(0x62), chr(0x0e), chr(0xaa), chr(0x18), chr(0xbe), chr(0x1b),
chr(0xfc), chr(0x56), chr(0x3e), chr(0x4b), chr(0xc6), chr(0xd2), chr(0x79), chr(0x20), chr(0x9a), chr(0xdb), chr(0xc0), chr(0xfe), chr(0x78), chr(0xcd), chr(0x5a), chr(0xf4),
chr(0x1f), chr(0xdd), chr(0xa8), chr(0x33), chr(0x88), chr(0x07), chr(0xc7), chr(0x31), chr(0xb1), chr(0x12), chr(0x10), chr(0x59), chr(0x27), chr(0x80), chr(0xec), chr(0x5f),
chr(0x60), chr(0x51), chr(0x7f), chr(0xa9), chr(0x19), chr(0xb5), chr(0x4a), chr(0x0d), chr(0x2d), chr(0xe5), chr(0x7a), chr(0x9f), chr(0x93), chr(0xc9), chr(0x9c), chr(0xef),
chr(0xa0), chr(0xe0), chr(0x3b), chr(0x4d), chr(0xae), chr(0x2a), chr(0xf5), chr(0xb0), chr(0xc8), chr(0xeb), chr(0xbb), chr(0x3c), chr(0x83), chr(0x53), chr(0x99), chr(0x61),
chr(0x17), chr(0x2b), chr(0x04), chr(0x7e), chr(0xba), chr(0x77), chr(0xd6), chr(0x26), chr(0xe1), chr(0x69), chr(0x14), chr(0x63), chr(0x55), chr(0x21), chr(0x0c), chr(0x7d)
);

$this->rcon = array(
chr(0x8d), chr(0x01), chr(0x02), chr(0x04), chr(0x08), chr(0x10), chr(0x20), chr(0x40), chr(0x80), chr(0x1b), chr(0x36), chr(0x6c), chr(0xd8),
chr(0xab), chr(0x4d), chr(0x9a), chr(0x2f), chr(0x5e), chr(0xbc), chr(0x63), chr(0xc6), chr(0x97), chr(0x35), chr(0x6a), chr(0xd4), chr(0xb3),
chr(0x7d), chr(0xfa), chr(0xef), chr(0xc5), chr(0x91), chr(0x39), chr(0x72), chr(0xe4), chr(0xd3), chr(0xbd), chr(0x61), chr(0xc2), chr(0x9f),
chr(0x25), chr(0x4a), chr(0x94), chr(0x33), chr(0x66), chr(0xcc), chr(0x83), chr(0x1d), chr(0x3a), chr(0x74), chr(0xe8), chr(0xcb), chr(0x8d),
chr(0x01), chr(0x02), chr(0x04), chr(0x08), chr(0x10), chr(0x20), chr(0x40), chr(0x80), chr(0x1b), chr(0x36), chr(0x6c), chr(0xd8), chr(0xab),
chr(0x4d), chr(0x9a), chr(0x2f), chr(0x5e), chr(0xbc), chr(0x63), chr(0xc6), chr(0x97), chr(0x35), chr(0x6a), chr(0xd4), chr(0xb3), chr(0x7d),
chr(0xfa), chr(0xef), chr(0xc5), chr(0x91), chr(0x39), chr(0x72), chr(0xe4), chr(0xd3), chr(0xbd), chr(0x61), chr(0xc2), chr(0x9f), chr(0x25),
chr(0x4a), chr(0x94), chr(0x33), chr(0x66), chr(0xcc), chr(0x83), chr(0x1d), chr(0x3a), chr(0x74), chr(0xe8), chr(0xcb), chr(0x8d), chr(0x01),
chr(0x02), chr(0x04), chr(0x08), chr(0x10), chr(0x20), chr(0x40), chr(0x80), chr(0x1b), chr(0x36), chr(0x6c), chr(0xd8), chr(0xab), chr(0x4d),
chr(0x9a), chr(0x2f), chr(0x5e), chr(0xbc), chr(0x63), chr(0xc6), chr(0x97), chr(0x35), chr(0x6a), chr(0xd4), chr(0xb3), chr(0x7d), chr(0xfa),
chr(0xef), chr(0xc5), chr(0x91), chr(0x39), chr(0x72), chr(0xe4), chr(0xd3), chr(0xbd), chr(0x61), chr(0xc2), chr(0x9f), chr(0x25), chr(0x4a),
chr(0x94), chr(0x33), chr(0x66), chr(0xcc), chr(0x83), chr(0x1d), chr(0x3a), chr(0x74), chr(0xe8), chr(0xcb), chr(0x8d), chr(0x01), chr(0x02),
chr(0x04), chr(0x08), chr(0x10), chr(0x20), chr(0x40), chr(0x80), chr(0x1b), chr(0x36), chr(0x6c), chr(0xd8), chr(0xab), chr(0x4d), chr(0x9a),
chr(0x2f), chr(0x5e), chr(0xbc), chr(0x63), chr(0xc6), chr(0x97), chr(0x35), chr(0x6a), chr(0xd4), chr(0xb3), chr(0x7d), chr(0xfa), chr(0xef),
chr(0xc5), chr(0x91), chr(0x39), chr(0x72), chr(0xe4), chr(0xd3), chr(0xbd), chr(0x61), chr(0xc2), chr(0x9f), chr(0x25), chr(0x4a), chr(0x94),
chr(0x33), chr(0x66), chr(0xcc), chr(0x83), chr(0x1d), chr(0x3a), chr(0x74), chr(0xe8), chr(0xcb), chr(0x8d), chr(0x01), chr(0x02), chr(0x04),
chr(0x08), chr(0x10), chr(0x20), chr(0x40), chr(0x80), chr(0x1b), chr(0x36), chr(0x6c), chr(0xd8), chr(0xab), chr(0x4d), chr(0x9a), chr(0x2f),
chr(0x5e), chr(0xbc), chr(0x63), chr(0xc6), chr(0x97), chr(0x35), chr(0x6a), chr(0xd4), chr(0xb3), chr(0x7d), chr(0xfa), chr(0xef), chr(0xc5),
chr(0x91), chr(0x39), chr(0x72), chr(0xe4), chr(0xd3), chr(0xbd), chr(0x61), chr(0xc2), chr(0x9f), chr(0x25), chr(0x4a), chr(0x94), chr(0x33),
chr(0x66), chr(0xcc), chr(0x83), chr(0x1d), chr(0x3a), chr(0x74), chr(0xe8), chr(0xcb)
);

$this->finiteMatrix = array(
array(2, 3, 1, 1),
array(1, 2, 3, 1),
array(1, 1, 2, 3),
array(3, 1, 1, 2)
);
}

function rotate($word){
array_push($word, array_shift($word));

return $word;
}

function core($word, $iteration){
$word = $this->rotate($word);

for($i = 0; $i < 4; $i++){
$word[$i] = $this->sbox[ord($word[$i])];
}

$word[0] = chr(ord($word[0]) ^ ord($this->rcon[$iteration]));

return $word;
}

function expandKey($expandedKey, $key){
$currentSize = 0;
$size = count($key);
$expandedKeySize = count($expandedKey);

$rconIteration = 1;

$temp = array(null, null, null, null);

for($i = 0; $i < $size; $i++){
$expandedKey[$i] = $key[$i];
}
$currentSize += $size;

while($currentSize < $expandedKeySize){
for($i = 0; $i < 4; $i++){
$temp[$i] = $expandedKey[($currentSize - 4) + $i];
}

if($currentSize % $size == 0){
$temp = $this->core($temp, $rconIteration++);
}

if($size == 32 && (($currentSize % $size) == 16)){
for($i = 0; $i < 4; $i++){
$temp[$i] = $this->sbox[ord($temp[$i])];
}
}

for($i = 0; $i < 4; $i++){
$expandedKey[$currentSize] = chr(ord($expandedKey[$currentSize - $size]) ^ ord($temp[$i]));
$currentSize++;
}
}

return $expandedKey;
}

function subBytes($state){
for($i = 0; $i < 16; $i++){
$state[$i] = $this->sbox[ord($state[$i])];
}

return $state;
}

function shiftRows($state){
return array(
$state[0], $state[5], $state[10], $state[15],
$state[4], $state[9], $state[14], $state[3],
$state[8], $state[13], $state[2], $state[7],
$state[12], $state[1], $state[6], $state[11],
);
}

function addRoundKey($state, $roundKey){
for($i = 0; $i < 16; $i++){
$state[$i] = chr(ord($state[$i]) ^ ord($roundKey[$i]));
}

return $state;
}

function galois_multiplication($a, $b){
$p = 0;
for($i = 0; $i < 8; $i++){
if(($b & 0x01) == 1){
$p ^= $a;
}
$hi_bit_set = ($a & 0x080);
$a <<= 1;
$a &= 0x0fe;
if($hi_bit_set == 0x080){
$a ^= 0x01b;
}
$b >>= 1;
$b &= 0x07f;
}
return $p;
}

function mixColumns($state){
$temp = $state;

for($i = 0; $i < 4; $i++){
for($j = 0; $j < 4; $j++){
$state[$i * 4 + $j] = chr(
$this->galois_multiplication($this->finiteMatrix[$j][0], ord($temp[$i * 4])) ^
$this->galois_multiplication($this->finiteMatrix[$j][1], ord($temp[$i * 4 + 1])) ^
$this->galois_multiplication($this->finiteMatrix[$j][2], ord($temp[$i * 4 + 2])) ^
$this->galois_multiplication($this->finiteMatrix[$j][3], ord($temp[$i * 4 + 3]))
);
}
}

return $state;
}

function aes_round($state, $roundKey){
$state = $this->subBytes($state);
$state = $this->shiftRows($state);
$state = $this->mixColumns($state);
$state = $this->addRoundKey($state, $roundKey);

return $state;
}

function createRoundKey($expandedKey, $roundKey){
for($i = 0; $i < 4; $i++){
for($j = 0; $j < 4; $j++){
$roundKey[$i + $j * 4] = $expandedKey[$i * 4 + $j];
}
}

return $roundKey;
}

function aes_main($state, $expandedKey, $nbrRounds){
$roundKey = array(
null, null, null, null,
null, null, null, null,
null, null, null, null,
null, null, null, null
);

$roundKey = $this->createRoundKey($expandedKey, $roundKey);
$state = $this->addRoundKey($state, $roundKey);

for($i = 1; $i < $nbrRounds; $i++){
$roundKey = $this->createRoundKey(array_slice($expandedKey, 16 * $i), $roundKey);
$state = $this->aes_round($state, $roundKey);
}

$roundKey = $this->createRoundKey(array_slice($expandedKey, 16 * $nbrRounds), $roundKey);
$state = $this->subBytes($state);
$state = $this->shiftRows($state);
$state = $this->addRoundKey($state, $roundKey);

return $state;
}

function encrypt($input, $key){
$block = array(
null, null, null, null,
null, null, null, null,
null, null, null, null,
null, null, null, null
);
$expandedKey = array();

$size = count($key);
$nbrRounds = 0;

switch($size){
case 16:
$nbrRounds = 10;
break;
case 24:
$nbrRounds = 12;
break;
case 32:
$nbrRounds = 14;
break;
default:
return 'UNKNOWN_KEYSIZE';
break;
}

for($i = 0; $i < (16 * ($nbrRounds + 1)); $i++){
array_push($expandedKey, null);
}

for($i = 0; $i < 4; $i++){
for($j = 0; $j < 4; $j++){
$block[$i + $j * 4] = substr($input, $i * 4 + $j, 1);
}
}

$expandedKey = $this->expandKey($expandedKey, $key);

$block = $this->aes_main($block, $expandedKey, $nbrRounds);

for($i = 0; $i < 4; $i++){
for($j = 0; $j < 4; $j++){
$input = substr_replace($input, $block[$i + $j * 4], $i * 4 + $j, 1);
}
}

return $input;
}
}
?>
</pre>
I've been using as a reference the tutorial found at progressive-coding.com. Which I found via wikipedia. Up to the point right before the heading Implementation: AES Encryption, my code successfully generates the table right before it, which shows the key expansion of an 256-bit key consisting of null characters. After that point something is amiss with my code and I'm not sure what. I tried the test vector given on wikipedia (it's the code that's commented out), but had no luck. Wondering if anyone knows where I'm going wrong. I wasn't sure but I thought that the shiftRows operation was incorrect as to how it was implemented in progressive-coding. So I went ahead and implemented as I understood it. Other than that I thought everything else worked as it was supposed to, but I guess not. Any help is appreciated.
User is offlineProfile CardPM

Go to the top of the page


joeyadms
post 27 Jun, 2008 - 04:16 AM
Post #2


D.I.C Head

Group Icon
Joined: 4 May, 2008
Posts: 145



Thanked 6 times

Dream Kudos: 600
My Contributions


AES as in Rjndael , I am not a cryptologist, but mcrypt supports AES.

I dunno if you were doing something different, but if you want to see implementation using mcrypt check out my tutorial
http://www.dreamincode.net/forums/showtopic54760.htm
User is offlineProfile CardPM

Go to the top of the page

grimpirate
post 27 Jun, 2008 - 01:39 PM
Post #3


D.I.C Head

Group Icon
Joined: 3 Aug, 2006
Posts: 177



Thanked 5 times

Dream Kudos: 375
My Contributions


Thx joey, but I'm actually trying to implement AES by coding it myself. Not using an extension. In any case no worries, because I got the code fixed. I incorrectly assumed the order of shiftRows and the mixColumns operation was using incorrect index locations within it. Using the page here I could compare my intermediate steps to what was going on and that highlighted the problem. So now I've got a functioning AES script for PHP 4 smile.gif Now I have to implement decryption an then of course a mode of operation (I'm leaning towards Cipher Block Chaining).

This post has been edited by grimpirate: 27 Jun, 2008 - 01:40 PM
User is offlineProfile CardPM

Go to the top of the page

grimpirate
post 28 Jun, 2008 - 08:32 PM
Post #4


D.I.C Head

Group Icon
Joined: 3 Aug, 2006
Posts: 177



Thanked 5 times

Dream Kudos: 375
My Contributions


Ok I got the code working for AES. Now the implementation for the CFB mode of operation is working. However, there's an issue that's bothering me. This page lists the modes of operation inside of the pdf entitled SP 800-38A 2001 ED. It also provides test vectors. My code works for the test vectors listed in appendix F but for these specific cases (listed under the heading F.3 CFB Example Vectors):
  • F.3.13 CFB128-AES128.Encrypt
  • F.3.14 CFB128-AES128.Decrypt
  • F.3.15 CFB128-AES192.Encrypt
  • F.3.16 CFB128-AES192.Decrypt
  • F.3.17 CFB128-AES256.Encrypt
  • F.3.18 CFB128-AES256.Decrypt
The cases before those which involve block sizes of 1 bit and 8 bit CFB I've been unable to reproduce. This is where my confusion comes into play. I'm working under the assumption that AES only operates on 128 bit block sizes (according to the tutorial I listed earlier). Where the author states
QUOTE
If you followed this tutorial up to this point, you should know by now that block ciphers operate on blocks of fixed size, in this case 128 bits.
This makes sense to me as if you tried to give an intial vector of less than the required AES block size it would fail. So my question is where is the knowledge gap I'm obviously failing to see with regards as to how to produce these test vector cases?
User is offlineProfile CardPM

Go to the top of the page

grimpirate
post 30 Jun, 2008 - 11:51 AM
Post #5


D.I.C Head

Group Icon
Joined: 3 Aug, 2006
Posts: 177



Thanked 5 times

Dream Kudos: 375
My Contributions


Issue resolved. I got it working with the 8 bit cases and theoretically I could get it working with the 1 bit case. However, I'm not going to bother because that would involve working with individual bits in a stupendously obfuscated way. So I'm calling this code finished.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/12/08 04:03AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month