Cipher.ENCRYPT_MODE, pkcs8EncryptionKey, new PBEParameterSpec(salt, PBE_ITERATION_COUNT));
byte[] encryptedKey = cipher.doFinal(key.getEncoded());
EncryptedPrivateKeyInfo inf = new EncryptedPrivateKeyInfo(cipher.getParameters(), encryptedKey);
return inf.getEncoded();
} catch (GeneralSecurityException e) {
throw new KeyczarException(Messages.getString("KeyczarTool.FailedToEncryptPrivateKey"), e);
} catch (IOException e) {
// This should be impossible.
throw new KeyczarException(Messages.getString("KeyczarTool.FailedToEncryptPrivateKey"), e);
}
}