public class SHA256withDSA extends DSA
For signing some data call the Signature
getInstance
, initSign
,
update
and sign
methods, respectively, e.g.:
byte[] message = ...; Signature dsa = Signature.getInstance("SHA256withDSA", "IAIK"); PrivateKey privateKey = ...; // init Signature object with private key dsa.initSign(privateKey); // supply the data to be signed by as many update calls as necessary dsa.update(message); // create the signature byte[] dsasig = dsa.sign();For verifying a signature call the
Signature
getInstance
, initVerify
, update
and verify
methods, respectively, e.g.:
byte[] message = ...;
Signature dsa = Signature.getInstance("SHA256withDSA", "IAIK");
PublicKey publicKey = ...;
// init Signature object with public key
dsa.initVerify(publicKey);
// supply the data that has been signed by as many update calls as necessary
dsa.update(message);
// verify the signature
if (dsa.verify(dsasig) == false){
throw new SignatureException("Signature invalid.");
}
Constructor and Description |
---|
SHA256withDSA()
Default constructor.
|
engineGetParameter, engineGetParameters, engineInitSign, engineInitSign, engineInitVerify, engineSetParameter, engineSetParameter, engineSign, engineUpdate, engineUpdate, engineVerify, setCheckSigValueForDERCompliance, setDoVerifySignature, setUseBachwardsCompatibilityMode, setUseBlinding
public SHA256withDSA() throws java.security.NoSuchAlgorithmException
Signature.getInstance("SHA256withDSA")
method.java.security.NoSuchAlgorithmException
- if the SHA256 MessageDigest
algorithm is not available