title: Error calculating MAC on Thales Payshield 9000 HSM
body: <p>I've a strange problem with M6 command in HSM Payshield 9000 3.4C firmware. For some leghts of message I receive error code 15 - even if message length is multiply of 8 bytes.</p>
  
  <p>During call I'm sending:
  1. Mode Flag: 0<br />
  2. Input Format Flag: 0<br />
  3. MAC Size: 1<br />
  4. MAC Algo: 3<br />
  5. Padding Method: 0 (I tested also with 0, 1, 3, but to simplify lets focus on padding mode 0. For test I prepared byte arrays to be mac'ed which size is multiply of 8 so no padding is needed).<br/>
  6. Key type: 008<br /></p>
  
  <p>I created a simple test where in a loop I'm building byte arrays of '1' with size from 8 to 1000 and mac such array. Each array has length that is multiply of 8 (8,16,24, ...)</p>
  
  <p>For some of array leghts I receive error code 15 Invalid input data (invalid format, invalid characters, or not enough data provided). Below you can find array size ranges for which I'm receiving such error. (&lt;160-248> means I received error for array of length from 160 (included) to 248(included) which are multiple of 8 (160, 168, 176,....248)</p>
  
  <p>&lt;160 - 248><br />
  &lt;416 - 504><br />
  &lt;672 - 760><br />
  &lt;928 - 1000><br /></p>
  
  <p>For other all other sizes from that range (for example from 256-408 that are multiple of 8 I'm receiving correct response with calculated MAC</p>
  
  <p>For byte array of lengh 160 (which returns error) the example command that I'm sending in this test is (in hex format):</p>
  
  <pre><code>00d33f3f3f3f4d3630303133303030385544324241464236353835433642303735334334363645393434424338423837353030613031313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131
  </code></pre>
  
  <p>Example command (for array of 152 size) which returns correct response:</p>
  
  <pre><code>00cb3f3f3f3f4d363030313330303038554432424146423635383543364230373533433436364539343442433842383735303039383131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131
  </code></pre>
  
  <p>What can be the reason of such behaviour?</p>