IBlockCipher interface
Contents
- Introduction to the Library
- Basic support package (com.kryptel.bslx)
- Kryptel API Commons package (com.kryptel)
- Cipher package (com.kryptel.cipher)
- Compressor package (com.kryptel.compressor)
- Exceptions package (com.kryptel.exceptions)
- Hash function package (com.kryptel.hash_function)
- MAC function package (com.kryptel.mac)
- Key-related functions (com.kryptel.key)
- Silver Key engine (com.kryptel.silver_key)
- Kryptel encrypted storage (com.kryptel.storage)
Declaration
package com.kryptel.cipher; public interface IBlockCipher { void Init() throws Exception; void Encrypt(byte[] buf, int start, int size) throws Exception; void Decrypt(byte[] buf, int start, int size) throws Exception; void Done() throws Exception; }
Description
The main block cipher interface; encrypts or decrypts any number of blocks using the selected block chaining mode.
Init
void Init() throws Exception;
Initializes the cipher and prepares for encryption or decryption. The first call of Encrypt or Decrypt will set the type of the operation. Encrypt and Decrypt calls are mutually exclusive and can't be mixed within the same Init-Done sequence. For example, if the first call is Encrypt, then no Decrypt call will be allowed until Done and another Init.
Encrypt
void Encrypt(byte[] buf, int start, int size) throws Exception;
Encrypt data in buf at position start. Argument size is data length in bytes and must be a multiple of cipher's block size. For example, if the cipher block size is 16 bytes (128 bits), size may be 16, 32, 48, 64, and so on.
The resulting encrypted data have the same size and replace the original data.
Decrypt
void Decrypt(byte[] buf, int start, int size) throws Exception;
Decrypt data in buf at position start. Argument size is data length in bytes and must be a multiple of cipher's block size. For example, if the cipher block size is 16 bytes (128 bits), size may be 16, 32, 48, 64, and so on.
The resulting decrypted data have the same size and replace the original data.
Done
void Done() throws Exception;
This function finishes processing and resets the cipher to the idle state.