Class SnapshotEncryptor

java.lang.Object
org.gridgain.internal.snapshots.buffer.SnapshotEncryptor

public class SnapshotEncryptor extends Object
Encryptor for snapshot content.
  • Field Details

    • ENCRYPTION_BYTE_ORDER

      public static final ByteOrder 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

      public Cipher cipher()
    • encrypt

      public void encrypt(ByteBuffer srcBuffer, ByteBuffer targetBuffer)
      Encrypts provided byte buffer via specified encryption key and cipher.

      This method expects that the srcBuffer would 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 all capacity() bytes in the srcBuffer during encryption, not only the remaining() bytes.

      Even though capacity number of bytes are read, after this method completes, srcBuffer will have its position set to its limit and its limit would be unchanged.

      Parameters:
      srcBuffer - Source byte buffer.
      targetBuffer - Target byte buffer, which must have enough remaining capacity to hold the encrypted data as specified by computeTargetEncryptedBufferSize(javax.crypto.Cipher, int).
    • decrypt

      public void decrypt(ByteBuffer srcBuffer, ByteBuffer targetBuffer)
      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 of org.gridgain.internal.snapshots.buffer.SnapshotEncryptor#computeTargetDecryptBufferSize(java.nio.ByteBuffer) where argument is srcBuffer.
    • computeTargetEncryptedBufferSize

      public static int computeTargetEncryptedBufferSize(Cipher cipher, int srcBufferSize)
      Computes and returns result size of encrypted byte buffer.
      Parameters:
      srcBufferSize - Source byte buffer size for encryption.
    • computeTargetEncryptedBufferSize

      public static int computeTargetEncryptedBufferSize(Integer blockSize, int srcBufferSize)
      Computes and returns result size of encrypted byte buffer.
      Parameters:
      blockSize - Source byte buffer block size.