public static BungeeCipher getCipher(boolean forEncryption, SecretKey shared) throws GeneralSecurityException { BungeeCipher cipher; if (NativeCipher.isLoaded()) { cipher = new NativeCipher(); } else { cipher = new FallbackCipher(); } cipher.init(forEncryption, shared); return cipher; }
void dispose(boolean doCancel) { refList.remove(this); try { if (doCancel) { UcryptoProvider.debug("Resource: cancel CipherCtxt " + id); int k = NativeCipher.nativeFinal(id, encrypt, null, 0); if (k < 0) { UcryptoProvider.debug( "Resource: error cancelling CipherCtxt " + id + " " + new UcryptoException(-k).getMessage()); } } else { UcryptoProvider.debug("Resource: untrace CipherCtxt " + id); } } finally { this.clear(); } }