Ciphers (package com.kryptel.cipher)
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)
Description
This package contains all Kryptel ciphers. Cipher is a basic low-level encryption component converting plaintext to ciphertext. The library includes the following ciphers: AES, Blowfish, DES, NullCipher, Serpent, Triple-DES, and Twofish.
DES is outdated; its usage is strongly discouraged. The reason for inclusion of that cipher was compatibility with old Kryptel / Silver Key versions. The library DES component has TYPE_HIDDEN_COMPONENT flag (see the Constants class).
Null cipher is a special 'cipher' component performing no ciphering at all. It has TYPE_HIDDEN_COMPONENT flag (see the Constants class) and should be used for debugging purpose only.
Cipher | Class Name | Component ID |
---|---|---|
AES | Aes | CID_CIPHER_AES |
Blowfish | Blowfish | CID_CIPHER_BLOWFISH |
DES | Des | CID_CIPHER_DES |
Null cipher | NullCipher | CID_NULL_CIPHER |
Serpent | Serpent | CID_CIPHER_SERPENT |
Triple-DES | TripleDes | CID_CIPHER_TRIPLE_DES |
Twofish | Twofish | CID_CIPHER_TWOFISH |
Note that all the ciphers are block ones. Although the library interface structure allows adding a stream cipher, there simply is no reputable enough stream cipher worth including.
Structures
CipherInfo
A static cipher component's structure describing allowed cipher parameters.
CipherParameters
A helper structure, used to pack cipher parameters in order to return them in a single function call.
Interfaces
In addition to common for all components IKryptelComponent, IComponentState, and optional IComponentCapabilities, a cipher component must export the following interfaces:
IBlockCipher
Block encryption or decryption. Blocks may be chained.
See also: Block encryption example.
IBlockCipherParams
Extends ICipherParams with parameters specific for block ciphers.
ICipher
Main cipher interface for encrypting or decrypting data blocks of arbitrary size.
See also: File encryption example.
ICipherParams
Set or get cipher parameters. Block ciphers use interface IBlockCipherParams, which extends this one.
IRawBlockCipher
Very basic block cipher interface for encrypting or decrypting exactly one block of unchained data.
Examples
Block Ciphering
A simple example of using IBlockCipher for encrypting several blocks of data.
File Encryption
A more complex example utilizing ICipher for file encryption – or a stream of data of arbitrary size.
Adding a New Cipher
How to add a completely new cipher component to the library.