<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: A byte-oriented AES-256 implementation</title>
	<atom:link href="http://www.literatecode.com/2007/11/11/aes256/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.literatecode.com/2007/11/11/aes256/</link>
	<description>Security, Programming and Beyond</description>
	<pubDate>Thu, 09 Sep 2010 15:24:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Matt H</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-2/#comment-15932</link>
		<dc:creator>Matt H</dc:creator>
		<pubDate>Tue, 07 Sep 2010 16:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15932</guid>
		<description>Michael, that function builds the expanded key (stored circularly in ctx-&gt;key) from the encryption key. For AES-128, you'd want to modify it to just store the first 128-bits, since the key is only 128-bits long (unexpanded). E.g. uint8_t i = 16; while (i--) buf[i] ^= (cpk[i] = key[i]) .. Look at the guide in FIPS-197 for key expansion. You'll want to modify aes_expandEncKey and then modify the number of rounds (14 to 10).

(Ilya, great implementation. I modified it to cache the expanded key with great ease :) )</description>
		<content:encoded><![CDATA[<p>Michael, that function builds the expanded key (stored circularly in ctx-&gt;key) from the encryption key. For AES-128, you&#8217;d want to modify it to just store the first 128-bits, since the key is only 128-bits long (unexpanded). E.g. uint8_t i = 16; while (i&#8211;) buf[i] ^= (cpk[i] = key[i]) .. Look at the guide in FIPS-197 for key expansion. You&#8217;ll want to modify aes_expandEncKey and then modify the number of rounds (14 to 10).</p>
<p>(Ilya, great implementation. I modified it to cache the expanded key with great ease :) )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-2/#comment-15931</link>
		<dc:creator>Ilya</dc:creator>
		<pubDate>Wed, 01 Sep 2010 02:06:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15931</guid>
		<description>Randy, I would recommend you to learn more about null-terminated strings and how printf works before doing any crypto.

Buf size, number of null characters in your encrypted text and number of characters in printf output would be a very straightforward hint here.</description>
		<content:encoded><![CDATA[<p>Randy, I would recommend you to learn more about null-terminated strings and how printf works before doing any crypto.</p>
<p>Buf size, number of null characters in your encrypted text and number of characters in printf output would be a very straightforward hint here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-2/#comment-15930</link>
		<dc:creator>R</dc:creator>
		<pubDate>Tue, 31 Aug 2010 17:02:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15930</guid>
		<description>Sorry here is the new demo.c

#include 
#include 
#include "aes256.h"


#define DUMP(s, i, buf, sz)  {printf(s);                   \
                              for (i = 0; i &lt; (sz);i++)    \
                                  printf("%02x ", buf[i]); \
                              printf("\n");}

int main (int argc, char *argv[])
{
    aes256_context ctx; 
    uint8_t key[32];
    uint8_t buf[16], i;

    /* put a test vector */
    //for (i = 0; i &lt; sizeof(buf);i++) buf[i] = i * 16 + i;
    //for (i = 0; i &lt; sizeof(key);i++) key[i] = i;

	strcpy(key,"My Key");
	strcpy(buf,"Blah Blah");

    DUMP("txt: ", i, buf, sizeof(buf));
    DUMP("key: ", i, key, sizeof(key));

	printf("Initial KEY: %s\n",key);
	printf("Initial BUF: %s\n",buf);
    printf("---\n");

    aes256_init(&amp;ctx, key);
    aes256_encrypt_ecb(&amp;ctx, buf);

	printf("Enc BUF: %s\n",buf);

    DUMP("enc: ", i, buf, sizeof(buf));
    printf("tst: 8e a2 b7 ca 51 67 45 bf ea fc 49 90 4b 49 60 89\n");

    aes256_init(&amp;ctx, key);
    aes256_decrypt_ecb(&amp;ctx, buf);
    DUMP("dec: ", i, buf, sizeof(buf));
	printf("Dec KEY: %s\n",key);
	printf("Dec BUF: %s\n",buf);

    aes256_done(&amp;ctx);

    return 0;
} /* main */</description>
		<content:encoded><![CDATA[<p>Sorry here is the new demo.c</p>
<p>#include<br />
#include<br />
#include &#8220;aes256.h&#8221;</p>
<p>#define DUMP(s, i, buf, sz)  {printf(s);                   \<br />
                              for (i = 0; i &lt; (sz);i++)    \<br />
                                  printf(&#8221;%02x &#8220;, buf[i]); \<br />
                              printf(&#8221;\n&#8221;);}</p>
<p>int main (int argc, char *argv[])<br />
{<br />
    aes256_context ctx;<br />
    uint8_t key[32];<br />
    uint8_t buf[16], i;</p>
<p>    /* put a test vector */<br />
    //for (i = 0; i &lt; sizeof(buf);i++) buf[i] = i * 16 + i;<br />
    //for (i = 0; i &lt; sizeof(key);i++) key[i] = i;</p>
<p>	strcpy(key,&#8221;My Key&#8221;);<br />
	strcpy(buf,&#8221;Blah Blah&#8221;);</p>
<p>    DUMP(&#8221;txt: &#8220;, i, buf, sizeof(buf));<br />
    DUMP(&#8221;key: &#8220;, i, key, sizeof(key));</p>
<p>	printf(&#8221;Initial KEY: %s\n&#8221;,key);<br />
	printf(&#8221;Initial BUF: %s\n&#8221;,buf);<br />
    printf(&#8221;&#8212;\n&#8221;);</p>
<p>    aes256_init(&amp;ctx, key);<br />
    aes256_encrypt_ecb(&amp;ctx, buf);</p>
<p>	printf(&#8221;Enc BUF: %s\n&#8221;,buf);</p>
<p>    DUMP(&#8221;enc: &#8220;, i, buf, sizeof(buf));<br />
    printf(&#8221;tst: 8e a2 b7 ca 51 67 45 bf ea fc 49 90 4b 49 60 89\n&#8221;);</p>
<p>    aes256_init(&amp;ctx, key);<br />
    aes256_decrypt_ecb(&amp;ctx, buf);<br />
    DUMP(&#8221;dec: &#8220;, i, buf, sizeof(buf));<br />
	printf(&#8221;Dec KEY: %s\n&#8221;,key);<br />
	printf(&#8221;Dec BUF: %s\n&#8221;,buf);</p>
<p>    aes256_done(&amp;ctx);</p>
<p>    return 0;<br />
} /* main */</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-2/#comment-15929</link>
		<dc:creator>R</dc:creator>
		<pubDate>Tue, 31 Aug 2010 16:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15929</guid>
		<description>Made the following changes to the demo.c file.....

    /* put a test vector */
    //for (i = 0; i &lt; sizeof(buf);i++) buf[i] = i * 16 + i;
    //for (i = 0; i aes_demo
txt: 42 6c 61 68 20 42 6c 61 68 00 cc cc cc cc cc cc
key: 4d 79 20 4b 65 79 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc
cc cc cc cc cc cc cc
Initial KEY: My Key
Initial BUF: Blah Blah
---
Enc BUF: ^¥sεΓ%.┼0oHsë╘3╢╠╠╠╠╠╠╠╠My Key                &lt;----- Opps!
enc: 5e 9d 73 ee e2 25 2e c5 30 6f 48 73 89 d4 33 b6
tst: 8e a2 b7 ca 51 67 45 bf ea fc 49 90 4b 49 60 89
dec: 42 6c 61 68 20 42 6c 61 68 00 cc cc cc cc cc cc
Dec KEY: My Key
Dec BUF: Blah Blah

Note that the Key is appended unencrypted to the encrypted buffer.</description>
		<content:encoded><![CDATA[<p>Made the following changes to the demo.c file&#8230;..</p>
<p>    /* put a test vector */<br />
    //for (i = 0; i &lt; sizeof(buf);i++) buf[i] = i * 16 + i;<br />
    //for (i = 0; i aes_demo<br />
txt: 42 6c 61 68 20 42 6c 61 68 00 cc cc cc cc cc cc<br />
key: 4d 79 20 4b 65 79 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc<br />
cc cc cc cc cc cc cc<br />
Initial KEY: My Key<br />
Initial BUF: Blah Blah<br />
&#8212;<br />
Enc BUF: ^¥sεΓ%.┼0oHsë╘3╢╠╠╠╠╠╠╠╠My Key                &lt;&#8212;&#8211; Opps!<br />
enc: 5e 9d 73 ee e2 25 2e c5 30 6f 48 73 89 d4 33 b6<br />
tst: 8e a2 b7 ca 51 67 45 bf ea fc 49 90 4b 49 60 89<br />
dec: 42 6c 61 68 20 42 6c 61 68 00 cc cc cc cc cc cc<br />
Dec KEY: My Key<br />
Dec BUF: Blah Blah</p>
<p>Note that the Key is appended unencrypted to the encrypted buffer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-2/#comment-15928</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 06 Aug 2010 18:35:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15928</guid>
		<description>Hi, thanks for this wonderful job.

To encrypt several blocks, I was looking for a simple XTS implementation. I have found the Gladman's, but it seems very difficult to adapt it to work with your code.
Do you know a simpler implementation of XTS ?</description>
		<content:encoded><![CDATA[<p>Hi, thanks for this wonderful job.</p>
<p>To encrypt several blocks, I was looking for a simple XTS implementation. I have found the Gladman&#8217;s, but it seems very difficult to adapt it to work with your code.<br />
Do you know a simpler implementation of XTS ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: priya</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-2/#comment-15925</link>
		<dc:creator>priya</dc:creator>
		<pubDate>Fri, 23 Jul 2010 11:24:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15925</guid>
		<description>I want to implement this on hardware. how can i do it?</description>
		<content:encoded><![CDATA[<p>I want to implement this on hardware. how can i do it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: priya</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-1/#comment-15924</link>
		<dc:creator>priya</dc:creator>
		<pubDate>Fri, 23 Jul 2010 11:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15924</guid>
		<description>hello. Can i use this code for 128 bits?</description>
		<content:encoded><![CDATA[<p>hello. Can i use this code for 128 bits?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-1/#comment-15919</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Wed, 09 Jun 2010 20:27:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15919</guid>
		<description>Back when I was looking for it I finally found an implementation.
I think it was this one:
http://www.hoozi.com/post/829n1/advanced-encryption-standard-aes-implementation-in-c-c-with-comments-part-1-encryption</description>
		<content:encoded><![CDATA[<p>Back when I was looking for it I finally found an implementation.<br />
I think it was this one:<br />
<a href="http://www.hoozi.com/post/829n1/advanced-encryption-standard-aes-implementation-in-c-c-with-comments-part-1-encryption" rel="nofollow">http://www.hoozi.com/post/829n1/advanced-encryption-standard-aes-implementation-in-c-c-with-comments-part-1-encryption</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-1/#comment-15918</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 09 Jun 2010 08:30:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15918</guid>
		<description>Hi, 

Just wondering how the aes_addRoundKey_cpy fits into the standard?

This doesn't appear in any of the docs I've read, but it appears to be (from what I can ascertain) to be the expanded key round, which helps avoid an extra lookup table.

But, I am trying to fix the failed attempt at porting this to AES-128 and I can't figure out how I should change that.  I tried the obvious of changing it to:

&lt;code&gt;
void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk)
{
    register uint8_t i = 8;

    while (i--) buf[i] ^= (cpk[i] = key[i]),	cpk[8+i] = key[8 + i];

} /* aes_addRoundKey_cpy */
&lt;/code&gt;

but it either wasn't right, or there's more to it. (I have changed the number of rounds to 10) but debugging encryption algorithms tends to be a little difficult!

Any pointers in the right direction would be greatly appreciated!

Thanks in advance,
Michael (yes, the same one as before)</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>Just wondering how the aes_addRoundKey_cpy fits into the standard?</p>
<p>This doesn&#8217;t appear in any of the docs I&#8217;ve read, but it appears to be (from what I can ascertain) to be the expanded key round, which helps avoid an extra lookup table.</p>
<p>But, I am trying to fix the failed attempt at porting this to AES-128 and I can&#8217;t figure out how I should change that.  I tried the obvious of changing it to:</p>
<p><code><br />
void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk)<br />
{<br />
    register uint8_t i = 8;</p>
<p>    while (i--) buf[i] ^= (cpk[i] = key[i]),	cpk[8+i] = key[8 + i];</p>
<p>} /* aes_addRoundKey_cpy */<br />
</code></p>
<p>but it either wasn&#8217;t right, or there&#8217;s more to it. (I have changed the number of rounds to 10) but debugging encryption algorithms tends to be a little difficult!</p>
<p>Any pointers in the right direction would be greatly appreciated!</p>
<p>Thanks in advance,<br />
Michael (yes, the same one as before)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Malone</title>
		<link>http://www.literatecode.com/2007/11/11/aes256/comment-page-1/#comment-15917</link>
		<dc:creator>Michael Malone</dc:creator>
		<pubDate>Wed, 09 Jun 2010 01:16:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.literatecode.com/2007/11/11/aes256/#comment-15917</guid>
		<description>Um, guys - the 128bit version is substantially broken.  The add_RoundKey modifications you made, mean the function there does nothing.  The plaintext and cyphertext match at the end, because it never got encrypted!!  The 256bit version works like a charm, however.  I could compile it straight away without warnings on -Wextra and -Wall!  I was really looking for a 128bit version, but due to time constraints, maybe 256 will do.</description>
		<content:encoded><![CDATA[<p>Um, guys - the 128bit version is substantially broken.  The add_RoundKey modifications you made, mean the function there does nothing.  The plaintext and cyphertext match at the end, because it never got encrypted!!  The 256bit version works like a charm, however.  I could compile it straight away without warnings on -Wextra and -Wall!  I was really looking for a 128bit version, but due to time constraints, maybe 256 will do.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
