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:
encryptFilein interfaceCryptoService- Throws:
AnkaSecureSdkException
-
decryptFile
- Specified by:
decryptFilein interfaceCryptoService- Throws:
AnkaSecureSdkException
-
reencryptFile
public ReencryptResult reencryptFile(String newKid, Path input, Path output) throws AnkaSecureSdkException - Specified by:
reencryptFilein interfaceCryptoService- Throws:
AnkaSecureSdkException
-
encryptFileStream
public EncryptResult encryptFileStream(String kid, Path input, Path output) throws AnkaSecureSdkException - Specified by:
encryptFileStreamin 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:
decryptFileStreamin 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:
reencryptFileStreamin 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:
encryptBytesin interfaceCryptoService- Parameters:
kid- key ID in the platform (must not benull)plaintext- data to protect (must not benull)- Returns:
EncryptResultexposing 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:
decryptBytesin interfaceCryptoService- Parameters:
jweToken- textual Compact JWE (UTF-8, not Base64 wrapped)- Returns:
CryptoService.DecryptBytesHoldercontaining plaintext and metadata- Throws:
AnkaSecureSdkException- on validation or remote failure
-
reencryptBytes
Re-encrypt a JWE in memory so it becomes protected bynewKid.- Specified by:
reencryptBytesin 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
-