Package org.conscrypt
Class DigitalSignature
java.lang.Object
org.conscrypt.DigitalSignature
public class DigitalSignature extends Object
This class represents Signature type, as described in TLS v 1.0 Protocol
specification, 7.4.3. It allow to init, update and sign hash. Hash algorithm
depends on SignatureAlgorithm.
select (SignatureAlgorithm)
{ case anonymous: struct { };
case rsa:
digitally-signed struct {
opaque md5_hash[16];
opaque sha_hash[20];
};
case dsa:
digitally-signed struct {
opaque sha_hash[20];
};
} Signature;
Digital signing description see in TLS spec., 4.7.
(http://www.ietf.org/rfc/rfc2246.txt)
-
Constructor Summary
Constructors Constructor Description DigitalSignature(String algorithm)Create Signature type -
Method Summary
Modifier and Type Method Description voidinit(Certificate cert)Initiate Signature type by certificatevoidinit(PrivateKey key)Initiate Signature type by private keyvoidsetMD5(byte[] data)Sets MD5 hashvoidsetSHA(byte[] data)Sets SHA hashbyte[]sign()Sign hashvoidupdate(byte[] data)Update Signature hashbooleanverifySignature(byte[] data)Verifies the signature data.
-
Constructor Details
-
DigitalSignature
Create Signature type- Parameters:
algorithm- the key algorithm used for the signature
-
-
Method Details
-
init
Initiate Signature type by private key- Parameters:
key-
-
init
Initiate Signature type by certificate- Parameters:
cert-
-
update
public void update(byte[] data)Update Signature hash- Parameters:
data-
-
setMD5
public void setMD5(byte[] data)Sets MD5 hash- Parameters:
data-
-
setSHA
public void setSHA(byte[] data)Sets SHA hash- Parameters:
data-
-
sign
public byte[] sign()Sign hash- Returns:
- Signature bytes
-
verifySignature
public boolean verifySignature(byte[] data)Verifies the signature data.- Parameters:
data- - the signature bytes- Returns:
- true if verified
-