SubtleUtil { public static String toEcdsaAlgo(HashType hash) throws GeneralSecurityException { Validators.validateSignatureHash(hash); return hash + "withECDSA"; }  static String toEcdsaAlgo(HashType hash); static String toRsaSsaPkcs1Algo(HashType hash); static String toDigestAlgo(HashType hash); static boolean isAndroid(); static BigInteger bytes2Integer(byte[] bs); static byte[] integer2Bytes(BigInteger num, int intendedLength); static byte[] mgf1(byte[] mgfSeed, int maskLen, HashType mgfHash); static void putAsUnsigedInt(ByteBuffer buffer, long value);  }
@Test public void testToEcdsaAlgo() throws Exception { assertEquals("SHA256withECDSA", SubtleUtil.toEcdsaAlgo(HashType.SHA256)); assertEquals("SHA512withECDSA", SubtleUtil.toEcdsaAlgo(HashType.SHA512)); try { SubtleUtil.toEcdsaAlgo(HashType.SHA1); fail("Invalid hash, should have thrown exception"); } catch (GeneralSecurityException expected) { } }