Interface CryptoService
- All Known Implementing Classes:
CryptoServiceImpl
public interface CryptoService
High-level encryption / decryption / re-encryption contract.
Implementations are stateless and therefore thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
Bundles the plaintext bytes and the metadata returned by the decrypt API. -
Method Summary
Modifier and TypeMethodDescriptiondecryptBytes
(String ciphertextJwe) Decrypts a textual Compact JWE that is already in memory.decryptFile
(Path input, Path output) decryptFileStream
(Path input, Path output) encryptBytes
(String kid, byte[] plaintext) Encrypts raw bytes with the public key identified bykid
.encryptFile
(String kid, Path input, Path output) encryptFileStream
(String kid, Path input, Path output) reencryptBytes
(String newKid, String jweCiphertext) Re-encrypts (rotates) an existing Compact JWE that is in memory so it becomes protected bynewKid
.reencryptFile
(String newKid, Path input, Path output) reencryptFileStream
(String newKid, Path input, Path output)
-
Method Details
-
encryptFile
- Throws:
AnkaSecureSdkException
-
decryptFile
- Throws:
AnkaSecureSdkException
-
reencryptFile
ReencryptFileResult reencryptFile(String newKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
encryptFileStream
EncryptFileResult encryptFileStream(String kid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
decryptFileStream
- Throws:
AnkaSecureSdkException
-
reencryptFileStream
ReencryptFileResult reencryptFileStream(String newKid, Path input, Path output) throws AnkaSecureSdkException - Throws:
AnkaSecureSdkException
-
encryptBytes
Encrypts raw bytes with the public key identified bykid
.- Parameters:
kid
- key ID in the platform (must not benull
)plaintext
- data to protect (must not benull
)- Returns:
EncryptFileResult
exposing the Compact JWE token and metadata- Throws:
AnkaSecureSdkException
- on validation or remote failure
-
decryptBytes
Decrypts a textual Compact JWE that is already in memory.- Parameters:
ciphertextJwe
- textual Compact JWE (UTF-8, not Base64 wrapped)- Returns:
CryptoService.DecryptBytesHolder
containing plaintext and metadata- Throws:
AnkaSecureSdkException
- on validation or remote failure
-
reencryptBytes
ReencryptFileResult reencryptBytes(String newKid, String jweCiphertext) throws AnkaSecureSdkException Re-encrypts (rotates) an existing Compact JWE that is in memory so it becomes protected bynewKid
.- Parameters:
newKid
- key that must protect the data after rotationjweCiphertext
- current Compact JWE (text form)- Returns:
- metadata for old/new keys plus the refreshed JWE token
- Throws:
AnkaSecureSdkException
- on validation or remote failure
-