public interface CryptoService
The service provides crypto related functionality such as signing and decrypting.
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider)
Computes and returns the cleartext of the given ciphertext.
|
byte[] |
decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
Computes and returns the cleartext of the given ciphertext comes from an external entity.
|
byte[] |
encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider)
Computes and returns the ciphertext of the given cleartext.
|
byte[] |
encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
Computes and returns the ciphertext of the given cleartext, using asymmetric cryptography.
|
Certificate |
getCertificate(CryptoContext cryptoContext)
Returns the
Certificate based on the given CryptoContext. |
default byte[] |
hybridDecrypt(HybridEncryptionOutput hybridEncryptionOutput,
String symmetricAlgorithm,
String asymmetricAlgorithm,
String javaSecurityProvider,
CryptoContext cryptoContext)
In hybrid decryption symmetric key used for encryption is decrypted with asymmetric decryption
and cipher data is decrypted using symmetric decryption mechanism.
|
default HybridEncryptionOutput |
hybridEncrypt(HybridEncryptionInput hybridEncryptionInput,
String symmetricAlgorithm,
String asymmetricAlgorithm,
String javaSecurityProvider,
CryptoContext cryptoContext)
In hybrid encryption clear data is encrypted using symmetric encryption mechanism
and symmetric key used for encryption is encrypted with asymmetric encryption.
|
byte[] |
sign(byte[] data,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
Computes and returns the signature of given data.
|
boolean |
verifySignature(byte[] data,
byte[] signature,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
Verifies whether given signature of the given data was generated by a trusted external party.
|
byte[] encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider)
throws CryptoException
The encrypted data is only for internal usage (e.g. encrypting passwords before persisting), therefore the ciphertext is NOT supposed to be shared with other systems.
cleartext - The cleartext to be encrypted.algorithm - The encryption / decryption algorithmjavaSecurityAPIProvider - The Java Security API provider.CryptoException - If something unexpected happens during the encryption operation.byte[] decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider)
throws CryptoException
The input ciphertext should be a ciphertext which was generated from
encrypt(byte[], String, String) method.
ciphertext - The ciphertext to be decrypted.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.CryptoException - If something unexpected happens during the decryption operation.byte[] sign(byte[] data,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
throws CryptoException
data - The content which the signature should be generated against.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the private key.CryptoException - If something unexpected happens during the signing operation.byte[] decrypt(byte[] ciphertext,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
throws CryptoException
ciphertext - The content which the signature should be generated against.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the private key.CryptoException - If something unexpected happens during the decryption operation.byte[] encrypt(byte[] cleartext,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
throws CryptoException
cleartext - The cleartext to be encrypted.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the public key of the external entity.CryptoException - If something unexpected happens during the encryption operation.boolean verifySignature(byte[] data,
byte[] signature,
String algorithm,
String javaSecurityAPIProvider,
CryptoContext cryptoContext)
throws CryptoException
data - The data which was the signature generated on.signature - The signature bytes of data.algorithm - The signature + hashing algorithm to be used in signing.javaSecurityAPIProvider - The Java Security API provider.cryptoContext - The context information which is needed to discover the public key of the external entity.CryptoException - If something unexpected happens during the signature verification.Certificate getCertificate(CryptoContext cryptoContext) throws CryptoException
Certificate based on the given CryptoContext.cryptoContext - The context information which is used to discover the public key of the external entity.Certificate relates with the given context.CryptoException - If something unexpected happens during certificate discovery.default HybridEncryptionOutput hybridEncrypt(HybridEncryptionInput hybridEncryptionInput, String symmetricAlgorithm, String asymmetricAlgorithm, String javaSecurityProvider, CryptoContext cryptoContext) throws CryptoException
HybridEncryptionOutput based on provided clear data.hybridEncryptionInput - Input data for hybrid encryption.symmetricAlgorithm - The symmetric encryption/decryption algorithm.asymmetricAlgorithm - The asymmetric encryption/decryption algorithm.javaSecurityProvider - The Java Security API provider.cryptoContext - The context information which is used to discover the public key of the external entity.HybridEncryptionOutput cipher text with required parametersCryptoExceptiondefault byte[] hybridDecrypt(HybridEncryptionOutput hybridEncryptionOutput, String symmetricAlgorithm, String asymmetricAlgorithm, String javaSecurityProvider, CryptoContext cryptoContext) throws CryptoException
HybridEncryptionOutputhybridEncryptionOutput - HybridEncryptionOutput ciphered data with parameters.symmetricAlgorithm - The symmetric encryption/decryption algorithm.asymmetricAlgorithm - The asymmetric encryption/decryption algorithm.javaSecurityProvider - The Java Security API provider.cryptoContext - The context information which is used to discover the public key of the external entity.CryptoExceptionCopyright © 2019 WSO2. All rights reserved.