Example #1
0
 static int get(String algorithm, String mode) throws NoSuchAlgorithmException {
   try {
     return AlgMode.valueOf(algorithm + "_" + mode).ordinal();
   } catch (Exception e) {
     throw new NoSuchAlgorithmException(
         "Doesn't support algorithm: " + algorithm + " and mode: " + mode);
   }
 }
Example #2
0
 /**
  * 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.
  */
 public static final OpensslCipher getInstance(String transformation)
     throws NoSuchAlgorithmException, NoSuchPaddingException {
   Transform transform = tokenizeTransformation(transformation);
   int algMode = AlgMode.get(transform.alg, transform.mode);
   int padding = Padding.get(transform.padding);
   long context = initContext(algMode, padding);
   return new OpensslCipher(context, algMode, padding);
 }