Code example for IvParameterSpec

0
      throw new InvalidEncryptedSignalException("Message shorter than IV length."); 
 
    System.arraycopy(messageBytes, IV_OFFSET, ivBytes, 0, ivBytes.length);
 
    Cipher cipher      = Cipher.getInstance("AES/CBC/PKCS5Padding");
    IvParameterSpec iv = new IvParameterSpec(ivBytes);
    cipher.init(Cipher.DECRYPT_MODE, cipherKey, iv);
 
    return cipher;
  } 
 
  public byte[] getPlaintext() throws InvalidEncryptedSignalException { 
    try { 
      byte[] messageBytes = Base64.decode(this.message);
 
      if (!isValidVersion(messageBytes))
        throw new InvalidEncryptedSignalException("Unknown version: " + 
                                                  (byte)messageBytes[VERSION_OFFSET]);
 
      if (!verifyMac(messageBytes))
        throw new InvalidEncryptedSignalException("Bad MAC");