Class CryptoServiceImpl
java.lang.Object
co.ankatech.ankasecure.sdk.internal.service.impl.CryptoServiceImpl
- All Implemented Interfaces:
CryptoService
Thread-safe concrete implementation of
CryptoService
.-
Nested Class Summary
Nested classes/interfaces inherited from interface co.ankatech.ankasecure.sdk.internal.service.CryptoService
CryptoService.DecryptBytesHolder
-
Constructor Summary
ConstructorsConstructorDescriptionCryptoServiceImpl
(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api) -
Method Summary
Modifier and TypeMethodDescriptiondecryptBytes
(String jweToken) Decrypt a Compact JWE that is already in RAM.decryptFile
(Path input, Path output) decryptFileStream
(Path input, Path output) Decrypts a detached JWET file produced by/stream/encrypt
.encryptBytes
(String kid, byte[] plaintext) Encrypt raw bytes with a server-side **public** key.encryptFile
(String kid, Path input, Path output) encryptFileStream
(String kid, Path input, Path output) reencryptBytes
(String newKid, String jweToken) Re-encrypt a JWE in memory so it becomes protected bynewKid
.reencryptFile
(String newKid, Path input, Path output) reencryptFileStream
(String newKid, String sourceKidOverride, Path input, Path output) Server-side re-encryption of a legacy ciphertext (nokid
) into a post-quantum ciphertext undernewKid
.
-
Constructor Details
-
CryptoServiceImpl
public CryptoServiceImpl(co.ankatech.ankasecure.openapi.client.AnkaSecureOpenApiClient api)
-
-
Method Details
-
encryptFile
- Specified by:
encryptFile
in interfaceCryptoService
- Throws:
AnkaSecureSdkException
-
decryptFile
- Specified by:
decryptFile
in interfaceCryptoService
- Throws:
AnkaSecureSdkException
-
reencryptFile
public ReencryptResult reencryptFile(String newKid, Path input, Path output) throws AnkaSecureSdkException - Specified by:
reencryptFile
in interfaceCryptoService
- Throws:
AnkaSecureSdkException
-
encryptFileStream
public EncryptResult encryptFileStream(String kid, Path input, Path output) throws AnkaSecureSdkException - Specified by:
encryptFileStream
in interfaceCryptoService
- Throws:
AnkaSecureSdkException
-
decryptFileStream
public DecryptResultMetadata decryptFileStream(Path input, Path output) throws AnkaSecureSdkException Decrypts a detached JWET file produced by/stream/encrypt
.The method:
- Splits the combined file into the JSON header and the binary envelope using the type-safe multipart splitter.
- Invokes the OpenAPI client with the parsed header and the temporary envelope file.
- Maps the response metadata to the public DTO.
- Specified by:
decryptFileStream
in interfaceCryptoService
- Throws:
AnkaSecureSdkException
-
reencryptFileStream
public ReencryptResult reencryptFileStream(String newKid, String sourceKidOverride, Path input, Path output) throws AnkaSecureSdkException Server-side re-encryption of a legacy ciphertext (nokid
) into a post-quantum ciphertext undernewKid
.- Specified by:
reencryptFileStream
in interfaceCryptoService
- Parameters:
newKid
- public-key identifier for the new ciphertextsourceKidOverride
- decrypt-only legacy keyinput
- combined ciphertext file (header + envelope)output
- destination for the re-encrypted file- Throws:
AnkaSecureSdkException
-
encryptBytes
Encrypt raw bytes with a server-side **public** key.- Specified by:
encryptBytes
in interfaceCryptoService
- Parameters:
kid
- key ID in the platform (must not benull
)plaintext
- data to protect (must not benull
)- Returns:
EncryptResult
exposing the Compact JWE token and metadata- Throws:
AnkaSecureSdkException
- on validation or remote failure
-
decryptBytes
Decrypt a Compact JWE that is already in RAM.- Specified by:
decryptBytes
in interfaceCryptoService
- Parameters:
jweToken
- textual Compact JWE (UTF-8, not Base64 wrapped)- Returns:
CryptoService.DecryptBytesHolder
containing plaintext and metadata- Throws:
AnkaSecureSdkException
- on validation or remote failure
-
reencryptBytes
Re-encrypt a JWE in memory so it becomes protected bynewKid
.- Specified by:
reencryptBytes
in interfaceCryptoService
- Parameters:
newKid
- key that must protect the data after rotationjweToken
- current Compact JWE (text form)- Returns:
- metadata for old/new keys plus the refreshed JWE token
- Throws:
AnkaSecureSdkException
- on validation or remote failure
-