title: CCCrypt decrypting in AES
body: <p>In my iOS app I have to decrypt data coming from a server. I use <code>CommonCrypto</code> framework and, after several trials, I successfully decrypted with</p>
  
  <pre><code>CCCrypt(kCCDecrypt, // operation
                       kCCAlgorithmAES128, // Algorithm
                       kCCOptionPKCS7Padding | kCCModeCBC, // options
                       key.bytes, // key
                       key.length, // keylength
                       nil,// iv
                       cipherData.bytes, // dataIn
                       cipherData.length, // dataInLength,
                       decryptedData.mutableBytes, // dataOut
                       decryptedData.length, // dataOutAvailable
                       &amp;outLength); // dataOutMoved
  </code></pre>
  
  <p>In the java server the data is crypted with</p>
  
  <pre><code>byte[] buff = new byte[100];
  byte[] buf2 = new byte[32];
  byte[] mainKey = ...
  byte[] raw = ...
  PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new AESEngine());
  KeyParameter par = new KeyParameter(mainKey);
  int minSize = cipher.getOutputSize(data.length);
  byte[] outBuf = new byte[minSize];
  int length1 = cipher.processBytes(data, 0, data.length, outBuf, 0);
  int length2 = cipher.doFinal(outBuf, length1);
  int actualLength = length1 + length2;
  byte[] result = new byte[actualLength];
  System.arraycopy(outBuf, 0, result, 0, result.length);
  </code></pre>
  
  <p>Now, I don't understand the sense of <code>kCCOptionPKCS7Padding | kCCModeCBC</code>. <code>kCCOptionPKCS7Padding = 0x0001</code> and <code>kCCModeCBC = 2</code> so <code>kCCOptionPKCS7Padding | kCCModeCBC = 3</code> but not exist options for block ciphers with value <code>3</code>.</p>
  
  <p>Is there someone that can help me to understand?</p>