ICipherParams 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 ICipherParams { int GetKeySize() throws Exception; int GetRounds() throws Exception; byte GetScheme() throws Exception; byte[] GetKey() throws Exception; void SetKeySize(int size) throws Exception; void SetRounds(int rounds) throws Exception; void SetScheme(byte scheme) throws Exception; void SetKey(byte[] key, int start, int size) throws Exception; CipherInfo GetInfo() throws Exception; }
Description
This interface sets and obtains parameters of a given cipher (stream or block one). See also its extension IBlockCipherParams interface for block cipher-specific parameters.
GetInfo
CipherInfo GetInfo() throws Exception;
Returns the CipherInfo structure describing the cipher.
GetKey
byte[] GetKey() throws Exception;
Returns the currently set encryption key. Note that unlike IBlockCipherParams.GetInitVector, this method returns the user-specified key, not the normalized version. So the length of the returned array is not necessarily equals the set key size.
GetKeySize
int GetKeySize() throws Exception;
Returns the currently set key size in bytes.
GetRounds
int GetRounds() throws Exception;
Returns the currently set number of rounds.
GetScheme
byte GetScheme() throws Exception;
Returns the currently selected cipher scheme. Some ciphers exist in several variations, for instance, Triple-DES works either as encrypt-encrypt-encrypt or as encrypt-decrypt-encrypt sequence. The scheme number designates the variation to be used.
SetKey
void SetKey(byte[] key, int start, int size) throws Exception;
Set encryption key. If size is not equal to the currently set key size, the key is normalized – either truncated or padded with zero bytes.
SetKeySize
void SetKeySize(int size) throws Exception;
Set cipher's key size in bytes. The size value must be a valid key size from the CipherInfo.ValidKeySizes list. DEFAULT_VALUE resets the key size to the default value.
SetRounds
void SetRounds(int rounds) throws Exception;
Set the number of ciphering rounds. The value must be one from the CipherInfo.ValidRounds list, or DEFAULT_VALUE to reset the number of rounds to the default value.
SetScheme
void SetScheme(byte scheme) throws Exception;
Select a cipher variation (scheme). The scheme number must be in the range from 1 to N, where N is the number of available schemes. DEFAULT_VALUE selects the cipher's default scheme.