public abstract class BaseCryptCodecHandler extends Object implements com.healthmarketscience.jackcess.impl.CodecHandler
Modifier and Type | Field and Description |
---|---|
static boolean |
CIPHER_DECRYPT_MODE |
static boolean |
CIPHER_ENCRYPT_MODE |
Modifier | Constructor and Description |
---|---|
protected |
BaseCryptCodecHandler(com.healthmarketscience.jackcess.impl.PageChannel channel,
byte[] encodingKey) |
Modifier and Type | Method and Description |
---|---|
static byte[] |
applyPageNumber(byte[] key,
int offset,
int pageNumber)
Returns a copy of the given key with the bytes of the given pageNumber
applied at the given offset using XOR.
|
protected void |
blockDecrypt(ByteBuffer inPage,
ByteBuffer outPage,
int pageNumber)
Decrypts the given buffer using a block cipher.
|
protected byte[] |
blockDecryptBytes(byte[] keyBytes,
byte[] iv,
byte[] encBytes)
Decrypts the given bytes using a block cipher configured with the given
key and IV into a new byte[].
|
protected ByteBuffer |
blockEncrypt(ByteBuffer buffer,
int pageNumber)
Encrypts the given buffer using a block cipher and returns the encrypted
buffer.
|
protected abstract org.bouncycastle.crypto.CipherParameters |
computeCipherParams(int pageNumber)
Generates the cipher parameters for the given page number.
|
protected static byte[] |
decryptBytes(org.bouncycastle.crypto.BufferedBlockCipher cipher,
byte[] encBytes)
Decrypts the given bytes using a block cipher into a new byte[].
|
protected static byte[] |
decryptBytes(org.bouncycastle.crypto.StreamCipher cipher,
byte[] encBytes)
Decrypts the given bytes using a stream cipher into a new byte[].
|
protected static org.bouncycastle.crypto.BufferedBlockCipher |
decryptInit(org.bouncycastle.crypto.BufferedBlockCipher cipher,
org.bouncycastle.crypto.CipherParameters params)
Inits the given cipher for decryption with the given params.
|
protected static org.bouncycastle.crypto.StreamCipher |
decryptInit(org.bouncycastle.crypto.StreamCipher cipher,
org.bouncycastle.crypto.CipherParameters params)
Inits the given cipher for decryption with the given params.
|
protected static org.bouncycastle.crypto.BufferedBlockCipher |
encryptInit(org.bouncycastle.crypto.BufferedBlockCipher cipher,
org.bouncycastle.crypto.CipherParameters params)
Inits the given cipher for encryption with the given params.
|
protected static org.bouncycastle.crypto.StreamCipher |
encryptInit(org.bouncycastle.crypto.StreamCipher cipher,
org.bouncycastle.crypto.CipherParameters params)
Inits the given cipher for encryption with the given params.
|
static byte[] |
fill(byte[] bytes,
int value)
Fills the given array with the given value and returns it.
|
static byte[] |
fixToLength(byte[] bytes,
int len) |
static byte[] |
fixToLength(byte[] bytes,
int len,
int padByte) |
protected org.bouncycastle.crypto.BufferedBlockCipher |
getBlockCipher() |
protected org.bouncycastle.crypto.CipherParameters |
getCipherParams(int pageNumber) |
protected byte[] |
getEncodingKey() |
protected byte[] |
getEncodingKey(int pageNumber)
Gets the encoding key combined with the given page number.
|
protected org.bouncycastle.crypto.StreamCipher |
getStreamCipher() |
protected ByteBuffer |
getTempBuffer() |
static byte[] |
hash(org.bouncycastle.crypto.Digest digest,
byte[] bytes)
Hashes the given bytes using the given digest and returns the result.
|
static byte[] |
hash(org.bouncycastle.crypto.Digest digest,
byte[] bytes1,
byte[] bytes2)
Hashes the given bytes1 and bytes2 using the given digest and returns the
result.
|
static byte[] |
hash(org.bouncycastle.crypto.Digest digest,
byte[] bytes1,
byte[] bytes2,
int resultLen)
Hashes the given bytes1 and bytes2 using the given digest and returns the
hash fixed to the given length.
|
static byte[] |
hash(org.bouncycastle.crypto.Digest digest,
byte[] bytes,
int resultLen)
Hashes the given bytes using the given digest and returns the hash fixed
to the given length.
|
protected static boolean |
isBlankKey(byte[] key) |
protected static byte[] |
processBytesFully(org.bouncycastle.crypto.BufferedBlockCipher cipher,
byte[] inArray,
byte[] outArray,
int inLen)
Processes all the bytes for the given block cipher.
|
protected static ByteBuffer |
readHeaderPage(com.healthmarketscience.jackcess.impl.PageChannel pageChannel)
Reads and returns the header page (page 0) from the given pageChannel.
|
protected void |
streamDecrypt(ByteBuffer buffer,
int pageNumber)
Decrypts the given buffer using a stream cipher.
|
protected ByteBuffer |
streamEncrypt(ByteBuffer buffer,
int pageNumber,
int pageOffset)
Encrypts the given buffer using a stream cipher and returns the encrypted
buffer.
|
String |
toString() |
static ByteBuffer |
wrap(byte[] bytes) |
public static final boolean CIPHER_DECRYPT_MODE
public static final boolean CIPHER_ENCRYPT_MODE
protected BaseCryptCodecHandler(com.healthmarketscience.jackcess.impl.PageChannel channel, byte[] encodingKey)
protected org.bouncycastle.crypto.CipherParameters getCipherParams(int pageNumber)
protected byte[] getEncodingKey()
protected org.bouncycastle.crypto.StreamCipher getStreamCipher()
protected org.bouncycastle.crypto.BufferedBlockCipher getBlockCipher()
protected ByteBuffer getTempBuffer()
protected void streamDecrypt(ByteBuffer buffer, int pageNumber)
protected ByteBuffer streamEncrypt(ByteBuffer buffer, int pageNumber, int pageOffset)
protected void blockDecrypt(ByteBuffer inPage, ByteBuffer outPage, int pageNumber)
protected ByteBuffer blockEncrypt(ByteBuffer buffer, int pageNumber)
protected static org.bouncycastle.crypto.StreamCipher decryptInit(org.bouncycastle.crypto.StreamCipher cipher, org.bouncycastle.crypto.CipherParameters params)
protected static org.bouncycastle.crypto.StreamCipher encryptInit(org.bouncycastle.crypto.StreamCipher cipher, org.bouncycastle.crypto.CipherParameters params)
protected static org.bouncycastle.crypto.BufferedBlockCipher decryptInit(org.bouncycastle.crypto.BufferedBlockCipher cipher, org.bouncycastle.crypto.CipherParameters params)
protected static org.bouncycastle.crypto.BufferedBlockCipher encryptInit(org.bouncycastle.crypto.BufferedBlockCipher cipher, org.bouncycastle.crypto.CipherParameters params)
protected static byte[] decryptBytes(org.bouncycastle.crypto.StreamCipher cipher, byte[] encBytes)
protected byte[] blockDecryptBytes(byte[] keyBytes, byte[] iv, byte[] encBytes)
protected static byte[] decryptBytes(org.bouncycastle.crypto.BufferedBlockCipher cipher, byte[] encBytes)
protected byte[] getEncodingKey(int pageNumber)
protected static ByteBuffer readHeaderPage(com.healthmarketscience.jackcess.impl.PageChannel pageChannel) throws IOException
IOException
public static byte[] applyPageNumber(byte[] key, int offset, int pageNumber)
public static byte[] hash(org.bouncycastle.crypto.Digest digest, byte[] bytes)
public static byte[] hash(org.bouncycastle.crypto.Digest digest, byte[] bytes1, byte[] bytes2)
public static byte[] hash(org.bouncycastle.crypto.Digest digest, byte[] bytes, int resultLen)
public static byte[] hash(org.bouncycastle.crypto.Digest digest, byte[] bytes1, byte[] bytes2, int resultLen)
public static byte[] fixToLength(byte[] bytes, int len)
public static byte[] fixToLength(byte[] bytes, int len, int padByte)
public static ByteBuffer wrap(byte[] bytes)
public static byte[] fill(byte[] bytes, int value)
protected static byte[] processBytesFully(org.bouncycastle.crypto.BufferedBlockCipher cipher, byte[] inArray, byte[] outArray, int inLen) throws org.bouncycastle.crypto.InvalidCipherTextException
org.bouncycastle.crypto.InvalidCipherTextException
protected static boolean isBlankKey(byte[] key)
true
if the given bytes are all 0, false
otherwiseprotected abstract org.bouncycastle.crypto.CipherParameters computeCipherParams(int pageNumber)
Copyright © 2010–2016. All rights reserved.