<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic sgx_aes_ctr_encrypt counter size in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070615#M288</link>
    <description>&lt;P&gt;The &lt;EM&gt;aes_ctr&lt;/EM&gt; encrypt and decrypt functions expect the following counter parameters:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;&lt;EM&gt;uint8_t *p_ctr&lt;/EM&gt;: Pointer to the counter block&lt;/LI&gt;
	&lt;LI&gt;&lt;EM&gt;const uint32_t ctr_inc_bits&lt;/EM&gt;: Number of bits in counter to be incremented&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Regarding the counter size, two possibilities seem likely:&lt;/SPAN&gt;&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;The counter size is fixed. The documentation does not mention this.&lt;/LI&gt;
	&lt;LI&gt;&lt;EM&gt;ctr_inc_bits&lt;/EM&gt; is used both for the number of bits to increment, and as the &lt;EM&gt;ctr_len&lt;/EM&gt; (i.e. all bits are incremented)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Regarding possibility 2, &lt;EM&gt;NIST SP 800-38A&lt;/EM&gt; mentions methods of constructing counter blocks in which &lt;EM&gt;ctr_inc_bits&lt;/EM&gt;&lt;BR /&gt;
	is not equal to &lt;EM&gt;ctr_len&lt;/EM&gt;. For example in scenario 2, counter blocks with &lt;EM&gt;ctr_size=b&lt;/EM&gt; are generated by using a random&lt;BR /&gt;
	nonce as the &lt;EM&gt;b/2&lt;/EM&gt; most significant bits, and incrementing only the &lt;EM&gt;b/2&lt;/EM&gt; least significant bits (&lt;EM&gt;ctr_inc_bits=b/2&lt;/EM&gt;).&lt;/P&gt;

&lt;P&gt;I think the following is necessary:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;The encrypt and decrypt functions should have an additional parameter &lt;EM&gt;ctr_size&lt;/EM&gt;&lt;/LI&gt;
	&lt;LI&gt;The documentation has to mention which &lt;EM&gt;ctr_inc_bits&lt;/EM&gt; bits of the counter are incremented (most or least significant)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Sidenote: &lt;EM&gt;sgx_rijndael128GCM_encrypt&lt;/EM&gt; also recieves an &lt;EM&gt;iv_len&lt;/EM&gt; in addition to &lt;EM&gt;p_iv&lt;/EM&gt;.&lt;/P&gt;</description>
    <pubDate>Mon, 23 May 2016 08:51:12 GMT</pubDate>
    <dc:creator>Fredrik_T_</dc:creator>
    <dc:date>2016-05-23T08:51:12Z</dc:date>
    <item>
      <title>sgx_aes_ctr_encrypt counter size</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070615#M288</link>
      <description>&lt;P&gt;The &lt;EM&gt;aes_ctr&lt;/EM&gt; encrypt and decrypt functions expect the following counter parameters:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;&lt;EM&gt;uint8_t *p_ctr&lt;/EM&gt;: Pointer to the counter block&lt;/LI&gt;
	&lt;LI&gt;&lt;EM&gt;const uint32_t ctr_inc_bits&lt;/EM&gt;: Number of bits in counter to be incremented&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Regarding the counter size, two possibilities seem likely:&lt;/SPAN&gt;&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;The counter size is fixed. The documentation does not mention this.&lt;/LI&gt;
	&lt;LI&gt;&lt;EM&gt;ctr_inc_bits&lt;/EM&gt; is used both for the number of bits to increment, and as the &lt;EM&gt;ctr_len&lt;/EM&gt; (i.e. all bits are incremented)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Regarding possibility 2, &lt;EM&gt;NIST SP 800-38A&lt;/EM&gt; mentions methods of constructing counter blocks in which &lt;EM&gt;ctr_inc_bits&lt;/EM&gt;&lt;BR /&gt;
	is not equal to &lt;EM&gt;ctr_len&lt;/EM&gt;. For example in scenario 2, counter blocks with &lt;EM&gt;ctr_size=b&lt;/EM&gt; are generated by using a random&lt;BR /&gt;
	nonce as the &lt;EM&gt;b/2&lt;/EM&gt; most significant bits, and incrementing only the &lt;EM&gt;b/2&lt;/EM&gt; least significant bits (&lt;EM&gt;ctr_inc_bits=b/2&lt;/EM&gt;).&lt;/P&gt;

&lt;P&gt;I think the following is necessary:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;The encrypt and decrypt functions should have an additional parameter &lt;EM&gt;ctr_size&lt;/EM&gt;&lt;/LI&gt;
	&lt;LI&gt;The documentation has to mention which &lt;EM&gt;ctr_inc_bits&lt;/EM&gt; bits of the counter are incremented (most or least significant)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Sidenote: &lt;EM&gt;sgx_rijndael128GCM_encrypt&lt;/EM&gt; also recieves an &lt;EM&gt;iv_len&lt;/EM&gt; in addition to &lt;EM&gt;p_iv&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2016 08:51:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070615#M288</guid>
      <dc:creator>Fredrik_T_</dc:creator>
      <dc:date>2016-05-23T08:51:12Z</dc:date>
    </item>
    <item>
      <title>The sgx function, sgx_aes_ctr</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070616#M289</link>
      <description>&lt;P&gt;The sgx function, sgx_aes_ctr_encrypt, is a wrapper for the Intel IPP Cryptography library ippsAESEncrypt functions. &amp;nbsp;Please refer to IPP documentation for additional details and questions on AES Ctr Mode Encryption.&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&lt;A href="https://software.intel.com/en-us/node/502801" target="_blank"&gt;https://software.intel.com/en-us/node/502801&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2016 12:59:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070616#M289</guid>
      <dc:creator>Derek_B_Intel</dc:creator>
      <dc:date>2016-05-23T12:59:47Z</dc:date>
    </item>
    <item>
      <title>AES in CTR mode does not have</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070617#M290</link>
      <description>&lt;P&gt;AES in CTR mode does not have a variable length nonce. It must equal the block size, which in this case is 128 bits.&amp;nbsp;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;The nonce and the counter are combined in this block.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Since the block size is fixed at 128 bits, specifying the size of the counter is sufficient.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;The counter bits incremented by &lt;EM&gt;sgx_aes_ctr_encrypt&lt;/EM&gt;() are the least significant bits, so if you pass the following vector as the nonce/counter block:&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff&lt;/PRE&gt;

&lt;P&gt;what you receive back (assuming you set &lt;EM&gt;ctr_inc_bits &lt;/EM&gt;large enough, in this case, at least 16) will be:&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;f0f1f2f3f4f5f6f7f8f9fafbfcfdff00&lt;/PRE&gt;

&lt;P&gt;If you were to set ctr_inc_bits to 8, you'd get this, instead:&lt;/P&gt;

&lt;PRE class="brush:plain;"&gt;f0f1f2f3f4f5f6f7f8f9fafbfcfdfe00&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;The reason &lt;EM&gt;sgx_rijndael128GCM_encrypt&lt;/EM&gt;() has an&amp;nbsp;&lt;/SPAN&gt;&lt;EM style="font-size: 1em; line-height: 1.5;"&gt;IV_len&lt;/EM&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&amp;nbsp;parameter is because the nonce/IV length for GCM encryption truly is variable. The IV can literally be any size. A 96-bit (12-byte) IV is most common, however, because other sizes require additional calculations. But since the IV length is truly variable and up to the developer/user, the function needs to know how long of an IV you are sending it.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 20:15:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070617#M290</guid>
      <dc:creator>JohnMechalas</dc:creator>
      <dc:date>2016-05-24T20:15:00Z</dc:date>
    </item>
    <item>
      <title>Thank you John for the</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070618#M291</link>
      <description>&lt;P&gt;Thank you John for the detailed explanation!&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 06:51:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/sgx-aes-ctr-encrypt-counter-size/m-p/1070618#M291</guid>
      <dc:creator>Fredrik_T_</dc:creator>
      <dc:date>2016-05-25T06:51:36Z</dc:date>
    </item>
  </channel>
</rss>

