/** * Encrypt the given input starting at the given offset and place * the result in the provided buffer starting at the given offset. * * @param src The plaintext buffer * @param srcIndex An offset into src * @param dst The ciphertext buffer * @param dstIndex An offset into dst */ protected int encryptBlock( byte[] src, int srcIndex, byte[] dst, int dstIndex) { int result[] = new int[2]; // process the input block // batch the units up into a 32 bit chunk and go for it // the array is in bytes, the increment is 8x8 bits = 64 int L0 = BytesTo32bits(src, srcIndex); int R0 = BytesTo32bits(src, srcIndex + 4); CAST_Encipher(L0, R0, result); // now stuff them into the destination block Bits32ToBytes(result[0], dst, dstIndex); Bits32ToBytes(result[1], dst, dstIndex + 4); return BLOCK_SIZE; }
/** * Decrypt the given input starting at the given offset and place * the result in the provided buffer starting at the given offset. * * @param src The plaintext buffer * @param srcIndex An offset into src * @param dst The ciphertext buffer * @param dstIndex An offset into dst */ protected int decryptBlock( byte[] src, int srcIndex, byte[] dst, int dstIndex) { int result[] = new int[2]; // process the input block // batch the units up into a 32 bit chunk and go for it // the array is in bytes, the increment is 8x8 bits = 64 int L16 = BytesTo32bits(src, srcIndex); int R16 = BytesTo32bits(src, srcIndex+4); CAST_Decipher(L16, R16, result); // now stuff them into the destination block Bits32ToBytes(result[0], dst, dstIndex); Bits32ToBytes(result[1], dst, dstIndex+4); return BLOCK_SIZE; }
/** * Decrypt the given input starting at the given offset and place * the result in the provided buffer starting at the given offset. * * @param src The plaintext buffer * @param srcIndex An offset into src * @param dst The ciphertext buffer * @param dstIndex An offset into dst */ protected int decryptBlock( byte[] src, int srcIndex, byte[] dst, int dstIndex) { int result[] = new int[2]; // process the input block // batch the units up into a 32 bit chunk and go for it // the array is in bytes, the increment is 8x8 bits = 64 int L16 = BytesTo32bits(src, srcIndex); int R16 = BytesTo32bits(src, srcIndex+4); CAST_Decipher(L16, R16, result); // now stuff them into the destination block Bits32ToBytes(result[0], dst, dstIndex); Bits32ToBytes(result[1], dst, dstIndex+4); return BLOCK_SIZE; }
/** * Encrypt the given input starting at the given offset and place * the result in the provided buffer starting at the given offset. * * @param src The plaintext buffer * @param srcIndex An offset into src * @param dst The ciphertext buffer * @param dstIndex An offset into dst */ protected int encryptBlock( byte[] src, int srcIndex, byte[] dst, int dstIndex) { int result[] = new int[2]; // process the input block // batch the units up into a 32 bit chunk and go for it // the array is in bytes, the increment is 8x8 bits = 64 int L0 = BytesTo32bits(src, srcIndex); int R0 = BytesTo32bits(src, srcIndex + 4); CAST_Encipher(L0, R0, result); // now stuff them into the destination block Bits32ToBytes(result[0], dst, dstIndex); Bits32ToBytes(result[1], dst, dstIndex + 4); return BLOCK_SIZE; }