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 Details

    • DigitalSignature

      public DigitalSignature​(String algorithm)
      Create Signature type
      Parameters:
      algorithm - the key algorithm used for the signature
  • Method Details

    • init

      public void init​(PrivateKey key)
      Initiate Signature type by private key
      Parameters:
      key -
    • init

      public void init​(Certificate cert)
      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