/** Initializes Java cryptography provider */ private void initProvider() throws DigiDocException { try { m_secProvider = (Provider) Class.forName(ConfigManager.instance().getProperty("DIGIDOC_SECURITY_PROVIDER")) .newInstance(); Security.addProvider(m_secProvider); } catch (Exception ex) { m_secProvider = null; DigiDocException.handleException(ex, DigiDocException.ERR_CRYPTO_PROVIDER); } }
void initCipher() { try { b64Decoder = new BASE64Decoder(); b64Encoder = new BASE64Encoder(); Provider sunJce = new com.sun.crypto.provider.SunJCE(); Security.addProvider(sunJce); byte[] raw = b64Decoder.decodeBuffer(key); SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish"); deCipher = Cipher.getInstance("Blowfish"); deCipher.init(Cipher.DECRYPT_MODE, skeySpec); enCipher = Cipher.getInstance("Blowfish"); enCipher.init(Cipher.ENCRYPT_MODE, skeySpec); } catch (Exception ex) { textPane.setText("Unable to create the cipher"); } }