static public ClientCHKBlock encodeSplitfileBlock(byte[] data, byte[] cryptoKey, byte cryptoAlgorithm) throws CHKEncodeException {
if(data.length != CHKBlock.DATA_LENGTH) throw new IllegalArgumentException();
if(cryptoKey != null && cryptoKey.length != 32) throw new IllegalArgumentException();
MessageDigest md256 = SHA256.getMessageDigest();
if(cryptoKey == null) {
cryptoKey = md256.digest(data);
}
if(cryptoAlgorithm == Key.ALGO_AES_PCFB_256_SHA256)
return innerEncode(data, CHKBlock.DATA_LENGTH, md256, cryptoKey, false, (short)-1, cryptoAlgorithm);
else if(cryptoAlgorithm != Key.ALGO_AES_CTR_256_SHA256)
throw new IllegalArgumentException("Unknown crypto algorithm: "+cryptoAlgorithm);
if(Rijndael.AesCtrProvider == null) {
return encodeNewNoJCA(data, CHKBlock.DATA_LENGTH, md256, cryptoKey, false, (short)-1, cryptoAlgorithm, KeyBlock.HASH_SHA256);
} else {
return encodeNew(data, CHKBlock.DATA_LENGTH, md256, cryptoKey, false, (short)-1, cryptoAlgorithm, KeyBlock.HASH_SHA256);
}
}