OxalisCipher { public SecretKey getSecretKey() { return secretKey; } OxalisCipher();  OxalisCipher(SecretKey secretKey); OutputStream encryptStream(OutputStream outputStream); InputStream decryptStream(InputStream inputStream); SecretKey getSecretKey(); static final String SYMMETRIC_KEY_ALGORITHM; static final String WRAPPED_SYMMETRIC_KEY_HEADER_NAME; }
@Test public void testWrapKey() throws Exception { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); KeyPair keyPair = keyPairGenerator.generateKeyPair(); Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.WRAP_MODE, keyPair.getPublic()); byte[] wrappedSecretKey = cipher.wrap(oxalisCipher.getSecretKey()); Cipher cipher1 = Cipher.getInstance("RSA"); cipher1.init(Cipher.UNWRAP_MODE, keyPair.getPrivate()); SecretKey aes = (SecretKey) cipher1.unwrap(wrappedSecretKey, "AES", Cipher.SECRET_KEY); }