Loading…

Kryptel/Java

IBlockCipher interface

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.