java.lang.Object
org.seppiko.commons.utils.crypto.SignatureUtil
Signature utility
- Author:
- Leonard Woo
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]sign(String algorithm, PrivateKey privateKey, byte[] rawData) Data Signature.static byte[]sign(String algorithm, Provider provider, PrivateKey privateKey, byte[] rawData) Data Signature.static SignatureReturns a Signature instance that implements the specified signature algorithm.static booleanData Verification.static booleanData Verification.
-
Method Details
-
signature
public static Signature signature(String algorithm, Provider provider) throws NoSuchAlgorithmException, NullPointerException Returns a Signature instance that implements the specified signature algorithm.- Parameters:
algorithm- the standard name of the algorithm requested.provider- the provider.- Returns:
- the new Signature instance.
- Throws:
NoSuchAlgorithmException- if no Provider supports a Signature implementation for the specified algorithm.NullPointerException- if algorithm isnull.
-
sign
public static byte[] sign(String algorithm, PrivateKey privateKey, byte[] rawData) throws NoSuchAlgorithmException, NullPointerException, InvalidKeyException, SignatureException Data Signature.- Parameters:
algorithm- signature algorithm.privateKey- signature private key.rawData- data.- Returns:
- signed data.
- Throws:
NoSuchAlgorithmException- if no Provider supports a Signature implementation for the specified algorithm.InvalidKeyException- if the key is invalid.SignatureException- if this signature object is not initialized properly.NullPointerException- if algorithm isnull.- See Also:
-
verify
public static boolean verify(String algorithm, PublicKey publicKey, byte[] rawData, byte[] signedData) throws NoSuchAlgorithmException, NullPointerException, InvalidKeyException, SignatureException Data Verification.- Parameters:
algorithm- signature algorithm.publicKey- signature private key.rawData- data.signedData- signed data.- Returns:
- true is verified.
- Throws:
NoSuchAlgorithmException- if no Provider supports a Signature implementation for the specified algorithm.InvalidKeyException- if the key is invalid.SignatureException- if this signature object is not initialized properly.NullPointerException- if algorithm isnull.- See Also:
-
sign
public static byte[] sign(String algorithm, Provider provider, PrivateKey privateKey, byte[] rawData) throws NoSuchAlgorithmException, NullPointerException, IllegalArgumentException, InvalidKeyException, SignatureException Data Signature.- Parameters:
algorithm- signature algorithm.provider- the provider.privateKey- signature private key.rawData- data.- Returns:
- signed data.
- Throws:
NoSuchAlgorithmException- if no Provider supports a Signature implementation for the specified algorithm.InvalidKeyException- if the key is invalid.SignatureException- if this signature object is not initialized properly.NullPointerException- if algorithm isnull.IllegalArgumentException- See Also:
-
verify
public static boolean verify(String algorithm, Provider provider, PublicKey publicKey, byte[] rawData, byte[] signedData) throws NoSuchAlgorithmException, NullPointerException, IllegalArgumentException, InvalidKeyException, SignatureException Data Verification.- Parameters:
algorithm- signature algorithm.provider- the provider.publicKey- signature private key.rawData- data.signedData- signed data.- Returns:
- true is verified.
- Throws:
NoSuchAlgorithmException- if no Provider supports a Signature implementation for the specified algorithm.InvalidKeyException- if the key is invalid.SignatureException- if this signature object is not initialized properly.NullPointerException- if algorithm isnull.IllegalArgumentException- See Also:
-