title: first 8 bytes of CCCryptor 3DES decryption are always damaged?
body: <p>recently I am implementing an crypto algorithm which uses 3DES. However, i found that the first 8 bytes of 4096 data block are always damaged. But it is sure that it can be decrypted correctly in java. Following is my code:</p>
  
  <pre><code>+ (void) DecryptBy3DES:(NSInputStream*)strmSrc Output:(NSOutputStream*)strmDest CryptoRef:(CCCryptorRef)tdesCrypto
  {       
      size_t  dataOutMoved;
      uint8_t inputBuf[BlockSize];
      uint8_t outputBuf[BlockSize];
  
      CCCryptorStatus cryptStatus;
      int iBytesRead = 0;
      int iBuffUsed = 0;
  
      while ( (iBytesRead = [strmSrc read:inputBuf maxLength:BlockSize]) &gt; 0 ) 
      {
          cryptStatus = CCCryptorUpdate(tdesCrypto, &amp;inputBuf, iBytesRead, &amp;outputBuf, BlockSize, &amp;dataOutMoved);
          assert(cryptStatus==noErr);
          [strmDest write:outputBuf maxLength:dataOutMoved];
      }
  
      CCCryptorReset(tdesCrypto, nil);
  }
  </code></pre>
  
  <p>where BlockSize is 4096.</p>
  
  <p>I reused the CCCryptoRef tdesCrypto to decrypt several blocks. The first block to be decrypted was correct, but the following blocks all had damaged bytes at the beginning. I also try to reset the CCCryptoRef, which seems in vain.</p>
  
  <p>I am really confused. Anyone has the same problem?</p>