ddn.crypto.cipher.modes

Block Cipher Modes of Operation.

Types 8

classCBC(BlockCipherT) : Cipher

Cipher Block Chaining (CBC) Mode.

Parameters

BlockCipherTThe block cipher implementation (e.g., AES).
Fields
private BlockCipherT _cipher
private Padding _padding
private CipherOperation _op
private ubyte[] _buffer
private ubyte[] _iv
private ubyte[] _lastBlock
private bool _initialized
Methods
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
ubyte[] update(const(ubyte)[] input)
ubyte[] finish(const(ubyte)[] input = null)
Constructors
this(Padding padding = new PKCS7Padding())Constructs a CBC mode cipher.
classCTR(BlockCipherT) : Cipher

Counter (CTR) Mode.

Turns a block cipher into a stream cipher.

Fields
private BlockCipherT _cipher
private ubyte[] _counter
private ubyte[] _keystream
private size_t _keystreamIdx
private bool _initialized
Methods
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
ubyte[] update(const(ubyte)[] input)
ubyte[] finish(const(ubyte)[] input = null)
classECB(BlockCipherT) : Cipher

Electronic Codebook (ECB) Mode.

Fields
private BlockCipherT _cipher
private Padding _padding
private CipherOperation _op
private ubyte[] _buffer
private bool _initialized
Methods
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
ubyte[] update(const(ubyte)[] input)
ubyte[] finish(const(ubyte)[] input = null)
Constructors
this(Padding padding = new PKCS7Padding())
classCFB(BlockCipherT) : Cipher

Cipher Feedback (CFB) Mode (CFB-BlockSize).

Fields
private BlockCipherT _cipher
private CipherOperation _op
private ubyte[] _iv
private ubyte[] _feedback
private ubyte[] _buffer
private bool _initialized
private size_t _blockSize
Methods
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
ubyte[] update(const(ubyte)[] input)
ubyte[] finish(const(ubyte)[] input = null)
classOFB(BlockCipherT) : Cipher

Output Feedback (OFB) Mode.

Fields
private BlockCipherT _cipher
private ubyte[] _iv
private ubyte[] _keystream
private size_t _keystreamIdx
private bool _initialized
private size_t _blockSize
Methods
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
ubyte[] update(const(ubyte)[] input)
ubyte[] finish(const(ubyte)[] input = null)
classXTS(BlockCipherT) : Cipher

XEX-based Tweaked-codebook mode with ciphertext Stealing (XTS).

Used for disk encryption.

Fields
private BlockCipherT _cipher1
private BlockCipherT _cipher2
private CipherOperation _op
private ubyte[] _tweak
private ubyte[] _buffer
private bool _initialized
private size_t _blockSize
Methods
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
private void multiplyAlpha(ubyte[] tweak)
ubyte[] update(const(ubyte)[] input)
private ubyte[] processBlock(ubyte[] block)
ubyte[] finish(const(ubyte)[] input = null)
classGCM(BlockCipherT) : AEADCipher

Galois/Counter Mode (GCM).

Fields
private BlockCipherT _cipher
private Key _key
private ubyte[16] _H
private ubyte[16] _J0
Methods
size_t tagSize() @property const
size_t nonceSize() @property const
size_t keySize() @property const
ubyte[] seal(const(ubyte)[] plaintext, const(ubyte)[] aad, const(ubyte)[] nonce, ubyte[] output = null)
ubyte[] open(const(ubyte)[] ciphertext, const(ubyte)[] aad, const(ubyte)[] nonce, ubyte[] output = null)
private void inc32(ref ubyte[16] counter)
private void prepareJ0(const(ubyte)[] nonce)
private ubyte[16] calculateTag(const(ubyte)[] aad, const(ubyte)[] ciphertext)
private void processData(ref ubyte[16] y, const(ubyte)[] data)
private void ghashBlock(ref ubyte[16] y, const(ubyte)[] block)
private void gmult(ref ubyte[16] x, const(ubyte)[] y)
Constructors
this(Key key)
classCCM(BlockCipherT) : AEADCipher

Counter with CBC-MAC (CCM).

Fields
private BlockCipherT _cipher
private Key _key
private size_t _tagSize
Methods
size_t tagSize() @property const
size_t nonceSize() @property const
size_t keySize() @property const
ubyte[] seal(const(ubyte)[] plaintext, const(ubyte)[] aad, const(ubyte)[] nonce, ubyte[] output = null)
ubyte[] open(const(ubyte)[] ciphertext, const(ubyte)[] aad, const(ubyte)[] nonce, ubyte[] output = null)
private void processCTR(const(ubyte)[] input, const(ubyte)[] nonce, ubyte[] output)
private ubyte[16] formatCounter(const(ubyte)[] nonce, size_t counterVal)
private ubyte[16] calculateMac(const(ubyte)[] plaintext, const(ubyte)[] aad, const(ubyte)[] nonce)
Constructors
this(Key key, size_t tagSize = 16)

Functions 1

private fnvoid incrementCounter(ubyte[] counter)Increment a counter block (big-endian).