title: Where to put 64-bit IV in 128-bit counter block for AES-128 CTR mode, in PIFF format
body: <p>The documents just don't seem to provide an answer..</p>
  <p>Microsoft tried to explain the subject clearly, but it is still ambiguous. At least in our case.</p>
  <p>We have an encrypted MP4 stream. It contains &quot;SampleEncryptionBox&quot;es or &quot;PIFF&quot; boxes, which contain <strong>8-byte = 64-bit</strong> Initialization Vectors for encrypted blocks. BUT: The actual &quot;counter block&quot; for decrypting the &quot;AES-128 Counter Mode&quot;-encrypted video data is <strong>128-bit</strong>. I don't know <em>where exactly</em> to put the IV in it!!</p>
  <ul>
  <li><p><a href="http://go.microsoft.com/?linkid=9682897" rel="nofollow noreferrer">PIFF document</a> says 16-byte IV is the entire counter block (obviously) for AES-CTR mode. Also, 8-byte IV is put at the beginning of the counter block, for <strong>AES-ECB mode</strong> (page 17). But for <strong>8-byte IV in AES-CTR mode</strong>, it says nothing!</p>
  </li>
  <li><p><a href="https://www.rfc-editor.org/rfc/rfc3686#section-4" rel="nofollow noreferrer">This RFC document</a> says that the 128-bit should comprise 4-byte Nonce + 8-byte IV + 4-byte counter. And the Nonce value should be taken from the <strong>extra 4 bytes supplied</strong> for the main 128-bit AES key. I can only obtain the 128-bit key by the Protection Header, where should I get the 4-byte Nonce??</p>
  </li>
  </ul>
  <p>Any bit of extra knowledge will be highly appreciated.</p>