public class EncryptionUtils
extends java.lang.Object
EncryptedSegment
for details on the binary format.
The normal, and expected, invocation pattern is to compress then encrypt the data on the encryption pass,
then decrypt and uncompress the data on the decrypt pass.Modifier and Type | Class and Description |
---|---|
static class |
EncryptionUtils.ChannelProxyReadChannel |
Modifier and Type | Field and Description |
---|---|
static int |
COMPRESSED_BLOCK_HEADER_SIZE |
static int |
ENCRYPTED_BLOCK_HEADER_SIZE |
Constructor and Description |
---|
EncryptionUtils() |
Modifier and Type | Method and Description |
---|---|
static java.nio.ByteBuffer |
compress(java.nio.ByteBuffer inputBuffer,
java.nio.ByteBuffer outputBuffer,
boolean allowBufferResize,
ICompressor compressor)
Compress the raw data, as well as manage sizing of the
outputBuffer ; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer. |
static java.nio.ByteBuffer |
decrypt(FileDataInput fileDataInput,
java.nio.ByteBuffer outputBuffer,
boolean allowBufferResize,
javax.crypto.Cipher cipher) |
static java.nio.ByteBuffer |
decrypt(java.nio.channels.ReadableByteChannel channel,
java.nio.ByteBuffer outputBuffer,
boolean allowBufferResize,
javax.crypto.Cipher cipher)
Decrypt the input data, as well as manage sizing of the
outputBuffer ; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer. |
static java.nio.ByteBuffer |
encrypt(java.nio.ByteBuffer inputBuffer,
java.nio.ByteBuffer outputBuffer,
boolean allowBufferResize,
javax.crypto.Cipher cipher) |
static java.nio.ByteBuffer |
encryptAndWrite(java.nio.ByteBuffer inputBuffer,
java.nio.channels.WritableByteChannel channel,
boolean allowBufferResize,
javax.crypto.Cipher cipher)
Encrypt the input data, and writes out to the same input buffer; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer.
|
static int |
uncompress(byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset,
ICompressor compressor) |
static java.nio.ByteBuffer |
uncompress(java.nio.ByteBuffer inputBuffer,
java.nio.ByteBuffer outputBuffer,
boolean allowBufferResize,
ICompressor compressor)
Uncompress the input data, as well as manage sizing of the
outputBuffer ; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer. |
public static final int COMPRESSED_BLOCK_HEADER_SIZE
public static final int ENCRYPTED_BLOCK_HEADER_SIZE
public static java.nio.ByteBuffer compress(java.nio.ByteBuffer inputBuffer, java.nio.ByteBuffer outputBuffer, boolean allowBufferResize, ICompressor compressor) throws java.io.IOException
outputBuffer
; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer.
Write the two header lengths (plain text length, compressed length) to the beginning of the buffer as we want those
values encapsulated in the encrypted block, as well.outputBuffer
if it had enough capacity,
or it may be a new, larger instance. Callers should capture the return buffer (if calling multiple times).java.io.IOException
public static java.nio.ByteBuffer encryptAndWrite(java.nio.ByteBuffer inputBuffer, java.nio.channels.WritableByteChannel channel, boolean allowBufferResize, javax.crypto.Cipher cipher) throws java.io.IOException
java.io.IOException
public static java.nio.ByteBuffer encrypt(java.nio.ByteBuffer inputBuffer, java.nio.ByteBuffer outputBuffer, boolean allowBufferResize, javax.crypto.Cipher cipher) throws java.io.IOException
java.io.IOException
public static java.nio.ByteBuffer decrypt(java.nio.channels.ReadableByteChannel channel, java.nio.ByteBuffer outputBuffer, boolean allowBufferResize, javax.crypto.Cipher cipher) throws java.io.IOException
outputBuffer
; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer.outputBuffer
if it had enough capacity,
or it may be a new, larger instance. Callers should capture the return buffer (if calling multiple times).java.io.IOException
public static java.nio.ByteBuffer decrypt(FileDataInput fileDataInput, java.nio.ByteBuffer outputBuffer, boolean allowBufferResize, javax.crypto.Cipher cipher) throws java.io.IOException
java.io.IOException
public static java.nio.ByteBuffer uncompress(java.nio.ByteBuffer inputBuffer, java.nio.ByteBuffer outputBuffer, boolean allowBufferResize, ICompressor compressor) throws java.io.IOException
outputBuffer
; if the buffer is not big enough,
deallocate current, and allocate a large enough buffer.outputBuffer
if it had enough capacity,
or it may be a new, larger instance. Callers should capture the return buffer (if calling multiple times).java.io.IOException
public static int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, ICompressor compressor) throws java.io.IOException
java.io.IOException
Copyright © 2009-2021 The Apache Software Foundation