private static String wrapSymmetricKey ( KeyPair wrapperKey , SecretKey symmetricKey ) throws NoSuchPaddingException , NoSuchAlgorithmException , InvalidKeyException , IllegalBlockSizeException { Cipher cipher = Cipher . getInstance ( WRAPPER_TRANSFORMATION ) ; cipher . init ( Cipher . WRAP_MODE , wrapperKey . getPublic ( ) ) ; byte [ ] decodedData = cipher . wrap ( symmetricKey ) ; return Base64 . encodeToString ( decodedData , Base64 . DEFAULT ) ; }
region Key Wrapping