Interface CryptoSuite

  • All Known Implementing Classes:
    CryptoPrimitives


    public interface CryptoSuite
    All packages for PKI key creation/signing/verification implement this interface
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  CryptoSuite.Factory
      The CryptoSuite factory.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.security.cert.Certificate bytesToCertificate​(byte[] certBytes)
      Convert bytes in PEM format to Certificate.
      java.lang.String generateCertificationRequest​(java.lang.String user, java.security.KeyPair keypair)
      Generates a CertificationRequest
      CryptoSuiteFactory getCryptoSuiteFactory​()
      Get Crypto Suite Factory for this implementation.
      java.util.Properties getProperties​()  
      byte[] hash​(byte[] plainText)
      Hash the specified text byte data.
      java.security.KeyPair keyGen​()
      Generate a key.
      void loadCACertificates​(java.util.Collection<java.security.cert.Certificate> certificates)
      Set the Certificate Authority certificates to be used when validating a certificate chain of trust
      void loadCACertificatesAsBytes​(java.util.Collection<byte[]> certificates)
      Set the Certificate Authority certificates to be used when validating a certificate chain of trust.
      byte[] sign​(java.security.PrivateKey key, byte[] plainText)
      Sign the specified byte string.
      boolean verify​(byte[] certificate, java.lang.String signatureAlgorithm, byte[] signature, byte[] plainText)
      Verify the specified signature
    • Method Detail

      • getCryptoSuiteFactory

        CryptoSuiteFactory getCryptoSuiteFactory​()
        Get Crypto Suite Factory for this implementation.
        Returns:
        MUST return the one and only one instance of a factory that produced this crypto suite.
      • getProperties

        java.util.Properties getProperties​()
        Returns:
        the Properties object containing implementation specific key generation properties
      • loadCACertificates

        void loadCACertificates​(java.util.Collection<java.security.cert.Certificate> certificates)
                         throws CryptoException
        Set the Certificate Authority certificates to be used when validating a certificate chain of trust
        Parameters:
        certificates - A collection of Certificates
        Throws:
        CryptoException
      • loadCACertificatesAsBytes

        void loadCACertificatesAsBytes​(java.util.Collection<byte[]> certificates)
                                throws CryptoException
        Set the Certificate Authority certificates to be used when validating a certificate chain of trust.
        Parameters:
        certificates - a collection of certificates in PEM format
        Throws:
        CryptoException
      • sign

        byte[] sign​(java.security.PrivateKey key,
                    byte[] plainText)
             throws CryptoException
        Sign the specified byte string.
        Parameters:
        key - the PrivateKey to be used for signing
        plainText - the byte string to sign
        Returns:
        the signed data.
        Throws:
        CryptoException
      • verify

        boolean verify​(byte[] certificate,
                       java.lang.String signatureAlgorithm,
                       byte[] signature,
                       byte[] plainText)
                throws CryptoException
        Verify the specified signature
        Parameters:
        certificate - the certificate of the signer as the contents of the PEM file
        signatureAlgorithm - the algorithm used to create the signature.
        signature - the signature to verify
        plainText - the original text that is to be verified
        Returns:
        true if the signature is successfully verified; otherwise false.
        Throws:
        CryptoException
      • hash

        byte[] hash​(byte[] plainText)
        Hash the specified text byte data.
        Parameters:
        plainText - the text to hash
        Returns:
        the hashed data.
      • generateCertificationRequest

        java.lang.String generateCertificationRequest​(java.lang.String user,
                                                      java.security.KeyPair keypair)
                                               throws InvalidArgumentException
        Generates a CertificationRequest
        Parameters:
        user -
        keypair -
        Returns:
        String in PEM format for certificate request.
        Throws:
        InvalidArgumentException
      • bytesToCertificate

        java.security.cert.Certificate bytesToCertificate​(byte[] certBytes)
                                                   throws CryptoException
        Convert bytes in PEM format to Certificate.
        Parameters:
        certBytes -
        Returns:
        Certificate
        Throws:
        CryptoException