Maven module :un.api : api-encoding :
Class : un.impl.cryptography.modes.CBC
Extends/Implements : un.impl.cryptography.modes.CipherMode
Subclasses : -

Block cipher chaining mode (CBC).
https://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
author  Bertrand COTE


Variables : algorithm
Functions : CBC, cipher, cipher, invCipher, invCipher, getNewCipher


CipherAlgorithm algorithm



param  key the key to use with the algorithm.
param  algorithm the cipher algorithm used ( e.g.: AES, DES... )
param  padding the padding used (e.g: NoPadding, PKCS5, ....
public void CBC (byte[] key, CipherAlgorithm algorithm, Padding padding)


In CBC mode, the IV is prepended to the plaintext.
param  plaintext the given plaintext with the IV prepended.
return  the ciphertext (First block is the IV)
public byte[] cipher (byte[] plaintext)

public void cipher (ByteInputStream input, ByteOutputStream output)


param  ciphertext
return  the plaintext without the IV.
throws  InvalidPadException WARNING: to avoid padding oracle
attacks
, do not let the user know the kind of exception thrown by
this method.
public byte[] invCipher (byte[] ciphertext)

public void invCipher (ByteInputStream input, ByteOutputStream output)


param  key the new key.
param  algorithm the new algorithm.
param  padding the new padding.
return  a new CBC with the new given key, the new algorithm and the new padding.
public CipherMode getNewCipher (byte[] key, CipherAlgorithm algorithm, Padding padding)