diff --git a/src/main/java/com/authlete/cose/ECDSA.java b/src/main/java/com/authlete/cose/ECDSA.java index 6c85a50..d143fb1 100644 --- a/src/main/java/com/authlete/cose/ECDSA.java +++ b/src/main/java/com/authlete/cose/ECDSA.java @@ -356,7 +356,7 @@ private static KeyFactory getKeyFactory() throws COSEException static byte[] sign(Key key, int algorithm, byte[] data) throws COSEException { // Make sure that the key implements the ECPrivateKey interface. - ECPrivateKey priKey = castByPrivateKey(key, algorithm); + PrivateKey priKey = (PrivateKey)key; // Get a Signature instance that performs signing. Signature sig = getSignatureInstance(algorithm); @@ -414,24 +414,6 @@ static boolean verify( return verifySignature(sig, signature); } - - /** - * Cast the key by ECPrivateKey. - */ - private static ECPrivateKey castByPrivateKey(Key key, int algorithm) throws COSEException - { - // If the key does not implement the ECPrivateKey interface. - if (!(key instanceof ECPrivateKey)) - { - throw new COSEException(String.format( - "A key to sign data with the algorithm '%s' must implement the ECPrivateKey interface.", - COSEAlgorithms.getNameByValue(algorithm))); - } - - return (ECPrivateKey)key; - } - - /** * Cast the key by ECPublicKey. */ @@ -479,7 +461,7 @@ private static String determineAlgorithmName(int algorithm) throws COSEException switch (algorithm) { case COSEAlgorithms.ES256: - return beforeJre9 ? "SHA256withPLAIN-ECDSA" : "SHA256withECDSAinP1363Format"; + return "SHA256withECDSA"; // TODO: resolve this after testing case COSEAlgorithms.ES384: return beforeJre9 ? "SHA384withPLAIN-ECDSA" : "SHA384withECDSAinP1363Format";