title: PBEWITHSHA256AND256BITAES-CBC-BC on Android : number of iterations for keygeneration and cipher?
body: <p>I'm using PBEWITHSHA256AND256BITAES-CBC-BC with BouncyCastle.</p>
  
  <pre><code>public static String algorithm = "PBEWITHSHA256AND256BITAES-CBC-BC";
  </code></pre>
  
  <p>I've done this method to generate the secret key:</p>
  
  <pre><code>private void generateSK(char[] passPhrase, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeyException {
      pbeParamSpecKey = new PBEParameterSpec(salt,1000);
      PBEKeySpec pbeKeySpec = new PBEKeySpec(passPhrase);
      SecretKeyFactory secretKeyFactory;
  
      secretKeyFactory = SecretKeyFactory.getInstance(algorithm);
      secretKey = secretKeyFactory.generateSecret(pbeKeySpec);
  }
  </code></pre>
  
  <p>and then this to generate a Cipher object (for encryption or decryption):</p>
  
  <pre><code>protected Cipher getCipher(int mode) {
      try {
          Cipher cipher = Cipher.getInstance(algorithm);
          cipher.init(mode, secretKey, pbeParamSpecKey);
  
          return cipher;
      }catch (Exception e) {
          e.printStackTrace();
          return null;
      }
  }
  </code></pre>
  
  <p>The pbeParamSpecKey need to be the same? How much is "important" (in terms of security) the number of iterations generating the key and the one generating the Cipher object? Can they be different?</p>