public class ClientCHKBlock extends java.lang.Object implements ClientKeyBlock
| Constructor and Description |
|---|
ClientCHKBlock(byte[] data,
byte[] header,
ClientCHK key2,
boolean verify)
Construct from data retrieved, and a key.
|
ClientCHKBlock(CHKBlock block,
ClientCHK key2)
Construct from a CHKBlock and a key.
|
| Modifier and Type | Method and Description |
|---|---|
Bucket |
decode(BucketFactory bf,
int maxLength,
boolean dontCompress)
Decode the CHK and recover the original data
|
Bucket |
decodeNew(BucketFactory bf,
int maxLength,
boolean dontCompress)
Decode the CHK and recover the original data
|
Bucket |
decodeNewNoJCA(BucketFactory bf,
int maxLength,
boolean dontCompress)
Decode using Freenet's built in crypto.
|
Bucket |
decodeOld(BucketFactory bf,
int maxLength,
boolean dontCompress)
Decode the CHK and recover the original data
|
static ClientCHKBlock |
encode(Bucket sourceData,
boolean asMetadata,
boolean dontCompress,
short alreadyCompressedCodec,
long sourceLength,
java.lang.String compressorDescriptor,
byte[] cryptoKey,
byte cryptoAlgorithm)
Encode a Bucket of data to a CHKBlock.
|
static ClientCHKBlock |
encode(byte[] sourceData,
boolean asMetadata,
boolean dontCompress,
short alreadyCompressedCodec,
int sourceLength,
java.lang.String compressorDescriptor)
Encode a block of data to a CHKBlock.
|
static ClientCHKBlock |
encodeNew(byte[] data,
int dataLength,
java.security.MessageDigest md256,
byte[] encKey,
boolean asMetadata,
short compressionAlgorithm,
byte cryptoAlgorithm,
int blockHashAlgorithm)
Format:
[0-1]: Block hash algorithm
[2-34]: HMAC (with cryptokey) of data + length bytes.
|
static ClientCHKBlock |
encodeNewNoJCA(byte[] data,
int dataLength,
java.security.MessageDigest md256,
byte[] encKey,
boolean asMetadata,
short compressionAlgorithm,
byte cryptoAlgorithm,
int blockHashAlgorithm)
Encode using Freenet's built in crypto.
|
static ClientCHKBlock |
encodeSplitfileBlock(byte[] data,
byte[] cryptoKey,
byte cryptoAlgorithm)
Encode a splitfile block.
|
boolean |
equals(java.lang.Object o)
This is why ClientKeyBlock isn't instanceof KeyBlock: Two ClientKeyBlock's with the same content
but different keys are not equals(), therefore a ClientKeyBlock and its KeyBlock have to be !equals
too.
|
CHKBlock |
getBlock() |
ClientCHK |
getClientKey() |
Key |
getKey() |
int |
hashCode()
Please be consistent with equals()
|
static ClientCHKBlock |
innerEncode(byte[] data,
int dataLength,
java.security.MessageDigest md256,
byte[] encKey,
boolean asMetadata,
short compressionAlgorithm,
byte cryptoAlgorithm) |
boolean |
isMetadata()
Does the block contain metadata? If not, it contains real data.
|
byte[] |
memoryDecode()
Decode into RAM, if short.
|
java.lang.String |
toString() |
public ClientCHKBlock(byte[] data,
byte[] header,
ClientCHK key2,
boolean verify)
throws CHKVerifyException
key2 - The client key.header - The header.data - The data.CHKVerifyExceptionpublic ClientCHKBlock(CHKBlock block, ClientCHK key2) throws CHKVerifyException
CHKVerifyExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic byte[] memoryDecode()
throws CHKDecodeException
memoryDecode in interface ClientKeyBlockCHKDecodeExceptionpublic Bucket decode(BucketFactory bf, int maxLength, boolean dontCompress) throws CHKDecodeException, java.io.IOException
decode in interface ClientKeyBlockbf - The BucketFactory to use to create the Bucket to return the data in.maxLength - The maximum size of the returned data in bytes.java.io.IOException - If there is a bucket error.CHKDecodeExceptionpublic Bucket decodeOld(BucketFactory bf, int maxLength, boolean dontCompress) throws CHKDecodeException, java.io.IOException
java.io.IOException - If there is a bucket error.CHKDecodeExceptionpublic Bucket decodeNew(BucketFactory bf, int maxLength, boolean dontCompress) throws CHKDecodeException, java.io.IOException
java.io.IOException - If there is a bucket error.CHKDecodeExceptionpublic Bucket decodeNewNoJCA(BucketFactory bf, int maxLength, boolean dontCompress) throws CHKDecodeException, java.io.IOException
java.io.IOException - If there is a bucket error.CHKDecodeExceptionpublic static ClientCHKBlock encodeSplitfileBlock(byte[] data, byte[] cryptoKey, byte cryptoAlgorithm) throws CHKEncodeException
data - The data to encode. Must be exactly DATA_LENGTH bytes.cryptoKey - The encryption key. Can be null in which case this is equivalent to a normal block
encode.CHKEncodeExceptionpublic static ClientCHKBlock encode(Bucket sourceData, boolean asMetadata, boolean dontCompress, short alreadyCompressedCodec, long sourceLength, java.lang.String compressorDescriptor, byte[] cryptoKey, byte cryptoAlgorithm) throws CHKEncodeException, java.io.IOException
sourceData - The bucket of data to encode. Can be arbitrarily large.asMetadata - Is this a metadata key?dontCompress - If set, don't even try to compress.alreadyCompressedCodec - If !dontCompress, and this is >=0, then the
data is already compressed, and this is the algorithm.compressorDescriptor - cryptoAlgorithm - cryptoKey - CHKEncodeExceptionjava.io.IOException - If there is an error reading from the Bucket.InvalidCompressionCodecExceptionpublic static ClientCHKBlock encodeNew(byte[] data, int dataLength, java.security.MessageDigest md256, byte[] encKey, boolean asMetadata, short compressionAlgorithm, byte cryptoAlgorithm, int blockHashAlgorithm) throws CHKEncodeException
data - Data should already have been padded.dataLength - Length of original data. Between 0 and 32768.md256 - Convenient reuse of hash object.encKey - Encryption key for the data, part of the URI.asMetadata - Whether the final CHK is metadata or not.compressionAlgorithm - The compression algorithm used.cryptoAlgorithm - The encryption algorithm used.CHKEncodeExceptionpublic static ClientCHKBlock encodeNewNoJCA(byte[] data, int dataLength, java.security.MessageDigest md256, byte[] encKey, boolean asMetadata, short compressionAlgorithm, byte cryptoAlgorithm, int blockHashAlgorithm) throws CHKEncodeException
data - Data should already have been padded.dataLength - Length of original data. Between 0 and 32768.md256 - Convenient reuse of hash object.encKey - Encryption key for the data, part of the URI.asMetadata - Whether the final CHK is metadata or not.compressionAlgorithm - The compression algorithm used.cryptoAlgorithm - The encryption algorithm used.CHKVerifyExceptionCHKEncodeExceptionpublic static ClientCHKBlock innerEncode(byte[] data, int dataLength, java.security.MessageDigest md256, byte[] encKey, boolean asMetadata, short compressionAlgorithm, byte cryptoAlgorithm)
public static ClientCHKBlock encode(byte[] sourceData, boolean asMetadata, boolean dontCompress, short alreadyCompressedCodec, int sourceLength, java.lang.String compressorDescriptor) throws CHKEncodeException, InvalidCompressionCodecException
sourceData - The data to encode.asMetadata - Is this a metadata key?dontCompress - If set, don't even try to compress.alreadyCompressedCodec - If !dontCompress, and this is >=0, then the
data is already compressed, and this is the algorithm.compressorDescriptor - Should be null, or list of compressors to try.InvalidCompressionCodecExceptionCHKEncodeExceptionpublic ClientCHK getClientKey()
getClientKey in interface ClientKeyBlockpublic boolean isMetadata()
ClientKeyBlockisMetadata in interface ClientKeyBlockpublic int hashCode()
ClientKeyBlockhashCode in interface ClientKeyBlockhashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
ClientKeyBlockequals in interface ClientKeyBlockequals in class java.lang.Objectpublic CHKBlock getBlock()
getBlock in interface ClientKeyBlockpublic Key getKey()
getKey in interface ClientKeyBlock