Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions src/main/java/com/authlete/cose/ECDSA.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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";
Expand Down