/** * Return an <code>OpenSslCipher</code> object that implements the specified * transformation. * * @param transformation the name of the transformation, e.g., * AES/CTR/NoPadding. * @return OpenSslCipher an <code>OpenSslCipher</code> object * @throws NoSuchAlgorithmException if <code>transformation</code> is null, * empty, in an invalid format, or if OpenSsl doesn't implement the * specified algorithm. * @throws NoSuchPaddingException if <code>transformation</code> contains a * padding scheme that is not available. * @throws IllegalStateException if native code cannot be initialised */ public static OpenSsl getInstance(String transformation) throws NoSuchAlgorithmException, NoSuchPaddingException { if (loadingFailureReason != null) { throw new IllegalStateException(loadingFailureReason); } Transform transform = tokenizeTransformation(transformation); int algorithmMode = AlgorithmMode.get(transform.algorithm, transform.mode); int padding = Padding.get(transform.padding); long context = OpenSslNative.initContext(algorithmMode, padding); return new OpenSsl(context, algorithmMode, padding); }