Class KeyUtil
- java.lang.Object
-
- org.wildfly.security.x500.cert.util.KeyUtil
-
public final class KeyUtil extends Object
Key utility methods.- Since:
- 1.5.0
- Author:
- Farah Juma
-
-
Constructor Summary
Constructors Constructor Description KeyUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetDefaultCompatibleSignatureAlgorithmName(String keyAlgorithmName, int keySize)Get the default compatible signature algorithm name for the given key algorithm name and key size.static StringgetDefaultCompatibleSignatureAlgorithmName(PrivateKey privateKey)Get the default compatible signature algorithm name for the given private key.private static StringgetDefaultMessageDigestAlgorithmName(String keyAlgorithmName, int keySize)Get the default message digest algorithm name for the given key algorithm name and key size.static byte[]getKeyIdentifier(PublicKey publicKey)Get the key identifier, which is composed of the 160-bit SHA-1 hash of the value of the BIT STRINGsubjectPublicKey(excluding the tag, length, and number of unused bits), as per RFC 3280.static intgetKeySize(Key key)Get the key size for the givenKey.
-
-
-
Method Detail
-
getDefaultCompatibleSignatureAlgorithmName
public static String getDefaultCompatibleSignatureAlgorithmName(PrivateKey privateKey) throws IllegalArgumentException
Get the default compatible signature algorithm name for the given private key.- Parameters:
privateKey- the private key- Returns:
- the default compatible signature algorithm name for the given private key or
nullif the default compatible signature algorithm name cannot not be determined - Throws:
IllegalArgumentException- if the key size cannot be determined from the given private key
-
getDefaultCompatibleSignatureAlgorithmName
public static String getDefaultCompatibleSignatureAlgorithmName(String keyAlgorithmName, int keySize)
Get the default compatible signature algorithm name for the given key algorithm name and key size.- Parameters:
keyAlgorithmName- the key algorithm namekeySize- the key size- Returns:
- the default compatible signature algorithm name for the given key algorithm name and key size
or
nullif the default compatible signature algorithm name cannot not be determined
-
getDefaultMessageDigestAlgorithmName
private static String getDefaultMessageDigestAlgorithmName(String keyAlgorithmName, int keySize)
Get the default message digest algorithm name for the given key algorithm name and key size.- Parameters:
keyAlgorithmName- the key algorithm namekeySize- the key size- Returns:
- the default message digest algorithm name or
nullif the default message algorithm name cannot be determined
-
getKeySize
public static int getKeySize(Key key)
Get the key size for the givenKey.- Parameters:
key- the key- Returns:
- the key size or -1 if the key size cannot be determined
-
getKeyIdentifier
public static byte[] getKeyIdentifier(PublicKey publicKey)
Get the key identifier, which is composed of the 160-bit SHA-1 hash of the value of the BIT STRINGsubjectPublicKey(excluding the tag, length, and number of unused bits), as per RFC 3280.- Parameters:
publicKey- the public key- Returns:
- the key identifier
-
-