public class Crypto extends Object
| Constructor and Description |
|---|
Crypto(byte[] ePrivKeyBytes,
byte[] tlsCertBytes)
Initialize the Crypto Object with enrollment private key and TLS Certificate
byte array
|
Crypto(InputStream epkIS,
InputStream tcIS)
Initialize the Crypto Object with enrollment private key and TLS Certificate
input stream
|
| Modifier and Type | Method and Description |
|---|---|
String |
decryptAndVerify(byte[] data)
decrypt and verify signature of data
|
String |
encryptWithBase64(byte[] data)
Encrypt data with TLS certificate and convert cipher to base64
|
byte[] |
getEPrivKeyBytes() |
X509Certificate |
getTlsCert() |
byte[] |
getTlsCertBytes() |
String |
signAndEncrypt(byte[] data)
Sign and encrypt data then convert cipher to base64
|
String |
signDataWithBase64(byte[] data)
Generate the signature with the enrollment private key
|
public Crypto(InputStream epkIS, InputStream tcIS) throws IOException, CertificateException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
epkIS - enrollment private keytcIS - TLS CertificateIOException - IOExceptionCertificateException - CertificateExceptionInvalidKeySpecException - InvalidKeySpecExceptionNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionpublic Crypto(byte[] ePrivKeyBytes,
byte[] tlsCertBytes)
throws IOException,
CertificateException,
NoSuchAlgorithmException,
InvalidKeySpecException,
NoSuchProviderException
ePrivKeyBytes - enrollment private keytlsCertBytes - TLS CertificateIOException - IOExceptionCertificateException - CertificateExceptionInvalidKeySpecException - InvalidKeySpecExceptionNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionpublic byte[] getEPrivKeyBytes()
public byte[] getTlsCertBytes()
public X509Certificate getTlsCert()
public String signDataWithBase64(byte[] data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException
data - data to signSignatureException - SignatureExceptionNoSuchProviderException - NoSuchProviderExceptionNoSuchAlgorithmException - NoSuchAlgorithmExceptionInvalidKeyException - InvalidKeyExceptionpublic String encryptWithBase64(byte[] data) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, org.spongycastle.crypto.InvalidCipherTextException, IOException
data - byte array to encryptNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionNoSuchPaddingException - NoSuchPaddingExceptionInvalidKeyException - InvalidKeyExceptionIllegalBlockSizeException - IllegalBlockSizeExceptionBadPaddingException - BadPaddingExceptionInvalidAlgorithmParameterException - InvalidAlgorithmParameterExceptionIOException - IOExceptionorg.spongycastle.crypto.InvalidCipherTextException - InvalidCipherTextExceptionpublic String signAndEncrypt(byte[] data) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, SignatureException, InvalidAlgorithmParameterException, org.spongycastle.crypto.InvalidCipherTextException, IOException
data - data byte array to encryptNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionNoSuchPaddingException - NoSuchPaddingExceptionInvalidKeyException - InvalidKeyExceptionIllegalBlockSizeException - IllegalBlockSizeExceptionBadPaddingException - BadPaddingExceptionSignatureException - SignatureExceptionInvalidAlgorithmParameterException - InvalidAlgorithmParameterExceptionIOException - IOExceptionorg.spongycastle.crypto.InvalidCipherTextException - InvalidCipherTextExceptionpublic String decryptAndVerify(byte[] data) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, SignatureException, InvalidAlgorithmParameterException, org.spongycastle.crypto.InvalidCipherTextException, IOException
data - data byte array to decrypt and verifyNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionNoSuchPaddingException - NoSuchPaddingExceptionInvalidKeyException - InvalidKeyExceptionIllegalBlockSizeException - IllegalBlockSizeExceptionBadPaddingException - BadPaddingExceptionSignatureException - SignatureExceptionInvalidAlgorithmParameterException - InvalidAlgorithmParameterExceptionIOException - IOExceptionorg.spongycastle.crypto.InvalidCipherTextException - InvalidCipherTextExceptionCopyright © 2018. All rights reserved.