public final class CoverCrypt extends Ffi
| Constructor and Description |
|---|
CoverCrypt() |
| Modifier and Type | Method and Description |
|---|---|
static int |
createDecryptionCache(byte[] userDecryptionKeyBytes)
Create a decryption cache that can be used with
decryptHeaderUsingCache(int, byte[], Optional). |
static int |
createEncryptionCache(Policy policy,
byte[] publicKeyBytes)
Create an encryption cache that can be used with
encryptHeaderUsingCache(int, String). |
static DecryptedData |
decrypt(byte[] userDecryptionKeyBytes,
byte[] ciphertext,
Optional<byte[]> authenticationData)
Decrypt a hybrid encryption.
|
static byte[] |
decryptBlock(byte[] symmetricKey,
Optional<byte[]> authenticationData,
byte[] encryptedBytes)
Symmetrically decrypt a block of encrypted data.
|
static DecryptedHeader |
decryptHeader(byte[] userDecryptionKeyBytes,
byte[] encryptedHeaderBytes,
Optional<byte[]> authenticationData)
Decrypt a hybrid header using a cache, recovering the symmetric key.
|
static DecryptedHeader |
decryptHeaderUsingCache(int cacheHandle,
byte[] encryptedHeaderBytes,
Optional<byte[]> authenticationData)
Decrypt a hybrid header using a cache, recovering the symmetric key.
|
static void |
destroyDecryptionCache(int cacheHandle)
Destroy the cache created with
createDecryptionCache(byte[]). |
static void |
destroyEncryptionCache(int cacheHandle)
Destroy the cache created with
createEncryptionCache(Policy, byte[]). |
static byte[] |
encrypt(Policy policy,
byte[] publicKeyBytes,
String encryptionPolicy,
byte[] plaintext,
Optional<byte[]> authenticationData,
Optional<byte[]> headerMetadata)
Generate an hybrid encryption of a plaintext.
|
static byte[] |
encryptBlock(byte[] symmetricKey,
Optional<byte[]> authenticationData,
byte[] clearText)
Symmetrically encrypt a block of clear text data.
|
static EncryptedHeader |
encryptHeader(Policy policy,
byte[] publicKeyBytes,
String encryptionPolicy)
Generate an hybrid encryption header.
|
static EncryptedHeader |
encryptHeader(Policy policy,
byte[] publicKeyBytes,
String encryptionPolicy,
byte[] headerMetadata)
Generate an hybrid encryption header.
|
static EncryptedHeader |
encryptHeader(Policy policy,
byte[] publicKeyBytes,
String encryptionPolicy,
byte[] headerMetadata,
byte[] authenticationData)
Generate an hybrid encryption header.
|
static EncryptedHeader |
encryptHeaderUsingCache(int cacheHandle,
String encryptionPolicy)
Generate an encrypted header using a pre-cached Public Key and `Policy`.
|
static EncryptedHeader |
encryptHeaderUsingCache(int cacheHandle,
String encryptionPolicy,
byte[] headerMetadata)
Generate an encrypted header using a pre-cached Public Key and `Policy`.
|
static EncryptedHeader |
encryptHeaderUsingCache(int cacheHandle,
String encryptionPolicy,
byte[] headerMetadata,
byte[] authenticationData)
Generate an encrypted header using a pre-cached Public Key and `Policy`.
|
static MasterKeys |
generateMasterKeys(Policy policy)
Generate the master private and public keys using the ABE policy
|
static byte[] |
generateUserPrivateKey(byte[] masterPrivateKey,
String userPolicy,
Policy policy)
Generate the user private key.
|
static int |
symmetricEncryptionOverhead()
The overhead in bytes (over the clear text) generated by the symmetric encryption scheme (AES 256 GCM)
|
get_last_error, get_last_error, set_error, unwrappublic static int createEncryptionCache(Policy policy, byte[] publicKeyBytes) throws CloudproofException
encryptHeaderUsingCache(int, String). The cache speeds
up the encryption of the header. WARN: the cache MUST be destroyed after use with
destroyEncryptionCache(int).policy - the Policy to cachepublicKeyBytes - the public key bytes to cacheCloudproofException - on Rust lib errorspublic static void destroyEncryptionCache(int cacheHandle)
throws CloudproofException
createEncryptionCache(Policy, byte[]).cacheHandle - the pointer to the cache to destroyCloudproofException - on Rust lib errorspublic static EncryptedHeader encryptHeaderUsingCache(int cacheHandle, String encryptionPolicy) throws CloudproofException
cacheHandle - the pointer to the intencryptionPolicy - the encryption policy that determines the partitions to encrypt forCloudproofException - in case of native library errorCloudproofException - in case the Policy and key bytes cannot be recovered from the
PublicKeypublic static EncryptedHeader encryptHeaderUsingCache(int cacheHandle, String encryptionPolicy, byte[] headerMetadata) throws CloudproofException
cacheHandle - the pointer to the intencryptionPolicy - the encryption policy that determines the partitions to encrypt forheaderMetadata - optional additional data to encrypt and add to the headerCloudproofException - in case of native library errorCloudproofException - in case the Policy and key bytes cannot be recovered from the
PublicKeypublic static EncryptedHeader encryptHeaderUsingCache(int cacheHandle, String encryptionPolicy, byte[] headerMetadata, byte[] authenticationData) throws CloudproofException
cacheHandle - the pointer to the intencryptionPolicy - the encryption policy that determines the partitions to encrypt forheaderMetadata - optional additional data to encrypt and add to the headerauthenticationData - optional data used to authenticate the encryption of the additional dataCloudproofException - in case of native library errorCloudproofException - in case the Policy and key bytes cannot be recovered from the
PublicKeypublic static EncryptedHeader encryptHeader(Policy policy, byte[] publicKeyBytes, String encryptionPolicy) throws CloudproofException
policy - the policy to usepublicKeyBytes - the ABE public key bytesencryptionPolicy - the encryption policy that determines the partitions to encrypt forCloudproofException - in case of native library errorpublic static EncryptedHeader encryptHeader(Policy policy, byte[] publicKeyBytes, String encryptionPolicy, byte[] headerMetadata) throws CloudproofException
policy - the policy to usepublicKeyBytes - the ABE public key bytesencryptionPolicy - the encryption policy that determines the partitions to encrypt forheaderMetadata - the additional data to encrypt and add to the headerCloudproofException - in case of native library errorpublic static EncryptedHeader encryptHeader(Policy policy, byte[] publicKeyBytes, String encryptionPolicy, byte[] headerMetadata, byte[] authenticationData) throws CloudproofException
policy - the policy to usepublicKeyBytes - the ABE public key bytesencryptionPolicy - the encryption policy that determines the partitions to encrypt forheaderMetadata - the additional data to encrypt and add to the headerauthenticationData - optional data used to authenticate the encryption of the additional dataCloudproofException - in case of native library errorpublic static int createDecryptionCache(byte[] userDecryptionKeyBytes)
throws CloudproofException
decryptHeaderUsingCache(int, byte[], Optional). The
cache speeds up the decryption of the header. WARN: the cache MUST be destroyed after use with
destroyDecryptionCache(int)userDecryptionKeyBytes - the public key bytes to cacheCloudproofException - on Rust lib errorsCloudproofException - in case of other errorspublic static void destroyDecryptionCache(int cacheHandle)
throws CloudproofException
createDecryptionCache(byte[]).cacheHandle - the pointer to the cache to destroyCloudproofException - on Rust lib errorsCloudproofException - in case of other errorspublic static DecryptedHeader decryptHeaderUsingCache(int cacheHandle, byte[] encryptedHeaderBytes, Optional<byte[]> authenticationData) throws CloudproofException
cacheHandle - the cache to the user decryption keyencryptedHeaderBytes - the encrypted headerauthenticationData - optional data used to authenticate the encryption of the additional dataCloudproofException - in case of native library errorpublic static DecryptedHeader decryptHeader(byte[] userDecryptionKeyBytes, byte[] encryptedHeaderBytes, Optional<byte[]> authenticationData) throws CloudproofException
userDecryptionKeyBytes - the ABE user decryption key bytesencryptedHeaderBytes - the encrypted headerauthenticationData - optional data used to authenticate the encryption of the additional dataCloudproofException - in case of native library errorpublic static int symmetricEncryptionOverhead()
public static byte[] encryptBlock(byte[] symmetricKey,
Optional<byte[]> authenticationData,
byte[] clearText)
throws CloudproofException
symmetricKey - The key to use to symmetrically encrypt the blockauthenticationData - The associated Data used to authenticate the symmetric encryptionclearText - the clear text to encryptCloudproofException - in case of native library errorpublic static byte[] decryptBlock(byte[] symmetricKey,
Optional<byte[]> authenticationData,
byte[] encryptedBytes)
throws CloudproofException
symmetricKey - the symmetric key to useauthenticationData - The associated Data used to authenticate the symmetric encryptionencryptedBytes - the encrypted block bytesCloudproofException - in case of native library errorpublic static MasterKeys generateMasterKeys(Policy policy) throws CloudproofException
policy - the policy to useCloudproofException - in case of native library errorpublic static byte[] generateUserPrivateKey(byte[] masterPrivateKey,
String userPolicy,
Policy policy)
throws CloudproofException
masterPrivateKey - the master private key in bytesuserPolicy - the access policy of the user private key as a JSON version of an AccessPolicy instancepolicy - the ABE policyCloudproofException - in case of native library errorpublic static byte[] encrypt(Policy policy, byte[] publicKeyBytes, String encryptionPolicy, byte[] plaintext, Optional<byte[]> authenticationData, Optional<byte[]> headerMetadata) throws CloudproofException
policy - the policy to usepublicKeyBytes - the public key bytesencryptionPolicy - the encryption policy that determines the partitions to encrypt forplaintext - the plaintext to encryptauthenticationData - optional data used to authenticate the symmetric encryptionheaderMetadata - the additional data to encrypt and add to the headerCloudproofException - in case of native library errorpublic static DecryptedData decrypt(byte[] userDecryptionKeyBytes, byte[] ciphertext, Optional<byte[]> authenticationData) throws CloudproofException
userDecryptionKeyBytes - the ABE user decryption key bytesciphertext - the ciphertext to decryptauthenticationData - optional data used to authenticate the symmetric encryptionDecryptedData containing the plaintext and optional header metadataCloudproofException - in case of native library errorCopyright © 2023. All rights reserved.