ddn.crypto.cipher.modes

Block Cipher Modes of Operation.

Types 8

classCBC(BlockCipherT) : Cipher

Cipher Block Chaining (CBC) Mode.

Note

this mode invokes the underlying block cipher with the same

buffer as input and output (encrypt(block, block)), so BlockCipherT must support in-place operation.

Parameters

BlockCipherTThe block cipher implementation (e.g., AES).
Methods
void initialize(CipherOperation op, SecretKey key, const(ubyte)[] iv)
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.

Methods
void wipe() nothrow @nogc @trustedZeroizes the block-cipher schedule, counter, and buffered keystream.
void initialize(CipherOperation op, SecretKey key, const(ubyte)[] iv)
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.

Methods
void initialize(CipherOperation op, SecretKey key, const(ubyte)[] iv)
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).

Methods
void initialize(CipherOperation op, SecretKey key, const(ubyte)[] iv)
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.

Note

this mode feeds the cipher output back as the next input using

the same buffer (encrypt(_iv, _iv)), so BlockCipherT must support in-place operation.

Methods
void initialize(CipherOperation op, SecretKey key, const(ubyte)[] iv)
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.

Methods
void initialize(CipherOperation op, SecretKey key, const(ubyte)[] iv)
void init(CipherOperation op, Key key, const(ubyte)[] iv = null)
ubyte[] update(const(ubyte)[] input)
ubyte[] finish(const(ubyte)[] input = null)
classGCM(BlockCipherT) : AEADCipher

Galois/Counter Mode (GCM).

Methods
void wipe() nothrow @nogc @trustedZeroizes the key object, expanded cipher schedule, and GCM state.
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)
Constructors
this(Key key)
classCCM(BlockCipherT) : AEADCipher

Counter with CBC-MAC (CCM).

Note

the CBC-MAC half of this mode invokes the underlying block

cipher with the same buffer as input and output (encrypt(x, x)), so BlockCipherT must support in-place operation.

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)
Constructors
this(Key key, size_t tagSize = 16)