title: Encryption Difference between processor and coprocessor
body: <p>i am trying to handle a problem using encryption and decryption algorithms, i used below program to test my requirements and i realised an odd problem.</p>
  
  <p>i am using polarssl for my encryption and decryption needs.</p>
  
  <p>This program works well when i compile it with icc compiler on intel processor using this command :(aes.c from polarssl)</p>
  
  <pre><code>icc Deneme.c aes.c -o deneme
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Encryption result, encrypted value:
  11 22 7 86 a2 d3 ed 95 b9 14 c0 57 f7 af 5f dc 93 66 77 68 44 12 9f 1b 72 6a ea 51 b8 f7 1d a4
  Decryption result, plain array:
  a2 d8 69 9c 77 73 c7 5e 1d 3b 83 26 6e 2f 35 30 9d f0 f2 e5 0 0 0 0 0 0 0 0 0 0 0 0
  </code></pre>
  
  <p>When i tried to compile with icc compiler but this time run on microprocessor; encryption result are not true.</p>
  
  <p>command: </p>
  
  <pre><code>icc -mmic Deneme.c aes.c -o deneme
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Encryption result, encrypted value:
  4a 4b 4c 32 e0 ef fb 22 4a 67 7e 2c 3a fe 36 65 4b 5b 18 9 63 28 a1 c4 8e b7 e4 c6 33 a7 36 7c
  Decryption result, plain array:
  a2 d8 69 9c 77 73 c7 5e 1d 3b 83 26 6e 2f 35 30 9d f0 f2 e5 0 0 0 0 0 0 0 0 0 0 0 0
  </code></pre>
  
  <p>What makes my encrypted values different??</p>
  
  <p>here is full program</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;polarssl/aes.h&gt;
  
  const int ENCRIPTION = 1;
  const int DECRIPTION = 0;
  
  void printByteArray(unsigned char * array, int length) {
      int i = 0;
      for (i = 0; i &lt; length; i++) {
          printf("%x ", array[i]);
      }
      printf("\n");
  }
  
  void encrypt() {
      unsigned char o[32];
  
  
      unsigned char key[16] = { 0x03, 0xC9, 0xD8, 0xE6, 0x01, 0xA5, 0x05,
              0x9F, 0x11, 0xBF, 0x44, 0x9D, 0xF9, 0x55, 0x18, 0xED
  
      };
  
      unsigned char iv[16] = { 0x03, 0xB5, 0x62, 0x57, 0xC8, 0x69, 0x22, 0x89,
              0xF4, 0x96, 0x2B, 0x05, 0x44, 0x2B, 0xD0, 0xA7
  
      };
  
      unsigned char plain[32]=
      {
        0xA2, 0xD8, 0x69, 0x9C, 0x77, 0x73, 0xC7, 0x5E, 0x1D, 0x3B, 0x83, 0x26, 0x6E, 0x2F, 0x35, 0x30,
        0x9D, 0xF0, 0xF2, 0xE5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
      };
  
      aes_context aesCtx;
  
      aes_setkey_enc(&amp;aesCtx, key, 128);
      aes_crypt_cbc(&amp;aesCtx, ENCRIPTION, 32, iv, plain, o);
  
      printf("Encryption result, encrypted value:\n");
      printByteArray(o, 32);
  }
  
  decrypt() {
  
      unsigned char o[32];
  
      unsigned char key[16] = { 0x03, 0xC9, 0xD8, 0xE6, 0x01, 0xA5, 0x05,
              0x9F, 0x11, 0xBF, 0x44, 0x9D, 0xF9, 0x55, 0x18, 0xED
  
      };
  
      unsigned char iv[16] = { 0x03, 0xB5, 0x62, 0x57, 0xC8, 0x69, 0x22, 0x89,
              0xF4, 0x96, 0x2B, 0x05, 0x44, 0x2B, 0xD0, 0xA7
  
      };
  
      unsigned char encryptedValue[32] = { 0x11, 0x22, 0x07, 0x86,
              0xA2, 0xD3, 0xED, 0x95, 0xB9, 0x14, 0xC0, 0x57, 0xF7, 0xAF, 0x5F,
              0xDC, 0x93, 0x66, 0x77, 0x68, 0x44, 0x12, 0x9F, 0x1B, 0x72, 0x6A,
              0xEA, 0x51, 0xB8, 0xF7, 0x1D, 0xA4 };
  
      aes_context aesCtx;
  
      aes_setkey_dec(&amp;aesCtx, key, 128);
      aes_crypt_cbc(&amp;aesCtx, DECRIPTION, 32, iv, encryptedValue,
              o);
  
      printf("Decryption result, plain array:\n");
      printByteArray(o, 32);
  
  }
  
  int main() {
  
      encrypt();
      decrypt();
  }
  </code></pre>