Interface CryptoSuite
-
- All Known Implementing Classes:
CryptoPrimitives
public interface CryptoSuiteAll packages for PKI key creation/signing/verification implement this interface
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCryptoSuite.FactoryThe CryptoSuite factory.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.security.cert.CertificatebytesToCertificate(byte[] certBytes)Convert bytes in PEM format to Certificate.java.lang.StringgenerateCertificationRequest(java.lang.String user, java.security.KeyPair keypair)Generates a CertificationRequestCryptoSuiteFactorygetCryptoSuiteFactory()Get Crypto Suite Factory for this implementation.java.util.PropertiesgetProperties()byte[]hash(byte[] plainText)Hash the specified text byte data.java.security.KeyPairkeyGen()Generate a key.voidloadCACertificates(java.util.Collection<java.security.cert.Certificate> certificates)Set the Certificate Authority certificates to be used when validating a certificate chain of trustvoidloadCACertificatesAsBytes(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.booleanverify(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
Propertiesobject containing implementation specific key generation properties
-
loadCACertificates
void loadCACertificates(java.util.Collection<java.security.cert.Certificate> certificates) throws CryptoExceptionSet the Certificate Authority certificates to be used when validating a certificate chain of trust- Parameters:
certificates- A collection ofCertificates- Throws:
CryptoException
-
loadCACertificatesAsBytes
void loadCACertificatesAsBytes(java.util.Collection<byte[]> certificates) throws CryptoExceptionSet 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
-
keyGen
java.security.KeyPair keyGen() throws CryptoExceptionGenerate a key.- Returns:
- the generated key.
- Throws:
CryptoException
-
sign
byte[] sign(java.security.PrivateKey key, byte[] plainText) throws CryptoExceptionSign the specified byte string.- Parameters:
key- thePrivateKeyto be used for signingplainText- 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 CryptoExceptionVerify the specified signature- Parameters:
certificate- the certificate of the signer as the contents of the PEM filesignatureAlgorithm- the algorithm used to create the signature.signature- the signature to verifyplainText- the original text that is to be verified- Returns:
trueif the signature is successfully verified; otherwisefalse.- 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 InvalidArgumentExceptionGenerates a CertificationRequest- Parameters:
user-keypair-- Returns:
- String in PEM format for certificate request.
- Throws:
InvalidArgumentException
-
bytesToCertificate
java.security.cert.Certificate bytesToCertificate(byte[] certBytes) throws CryptoExceptionConvert bytes in PEM format to Certificate.- Parameters:
certBytes-- Returns:
- Certificate
- Throws:
CryptoException
-
-