Class KeyUtil
java.lang.Object
org.wildfly.security.x500.cert.util.KeyUtil
Key utility methods.
- Since:
- 1.5.0
- Author:
- Farah Juma
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.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.
-
Constructor Details
-
KeyUtil
public KeyUtil()
-
-
Method Details
-
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
-
getKeySize
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
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
-