Class SnapshotEncryptor
java.lang.Object
org.gridgain.internal.snapshots.buffer.SnapshotEncryptor
Encryptor for snapshot content.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSnapshotEncryptor(org.gridgain.internal.encryption.provider.DataEncryptionKey dataEncryptionKey, String cipherAlgorithm) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncipher()static intcomputeTargetEncryptedBufferSize(Integer blockSize, int srcBufferSize) Computes and returns result size of encrypted byte buffer.static intcomputeTargetEncryptedBufferSize(Cipher cipher, int srcBufferSize) Computes and returns result size of encrypted byte buffer.voiddecrypt(ByteBuffer srcBuffer, ByteBuffer targetBuffer) Decrypts provided byte buffer via specified encryption key and cipher.voidencrypt(ByteBuffer srcBuffer, ByteBuffer targetBuffer) Encrypts provided byte buffer via specified encryption key and cipher.
-
Field Details
-
ENCRYPTION_BYTE_ORDER
-
-
Constructor Details
-
SnapshotEncryptor
public SnapshotEncryptor(org.gridgain.internal.encryption.provider.DataEncryptionKey dataEncryptionKey, String cipherAlgorithm) Constructor.- Parameters:
dataEncryptionKey- Data encryption key.cipherAlgorithm- Cipher algorithm.
-
-
Method Details
-
cipher
-
encrypt
Encrypts provided byte buffer via specified encryption key and cipher.This method expects that the
srcBufferwould have a specific capacity, regardless of the actual size of data. For example, for the AES algorithm we expect the capacity to be a multiple of 16 bytes. This also means that we access allcapacity()bytes in thesrcBufferduring encryption, not only theremaining()bytes.Even though
capacitynumber of bytes are read, after this method completes,srcBufferwill have itspositionset to itslimitand itslimitwould be unchanged.- Parameters:
srcBuffer- Source byte buffer.targetBuffer- Target byte buffer, which must have enough remaining capacity to hold the encrypted data as specified bycomputeTargetEncryptedBufferSize(javax.crypto.Cipher, int).
-
decrypt
Decrypts provided byte buffer via specified encryption key and cipher.- Parameters:
srcBuffer- Encrypted byte buffer.targetBuffer- Target byte buffer, remaining of the buffer should be more than capacity oforg.gridgain.internal.snapshots.buffer.SnapshotEncryptor#computeTargetDecryptBufferSize(java.nio.ByteBuffer)where argument issrcBuffer.
-
computeTargetEncryptedBufferSize
Computes and returns result size of encrypted byte buffer.- Parameters:
srcBufferSize- Source byte buffer size for encryption.
-
computeTargetEncryptedBufferSize
Computes and returns result size of encrypted byte buffer.- Parameters:
blockSize- Source byte buffer block size.
-