PKCS7Pad

PKCS7Pad is an implementation of the PKCS7 block cipher padding scheme. A incomplete block will be padded with bytes like this:

01 02 02 03 03 03 04 04 04 04 ...

The block to be padded can't be full.

Standard: rfc5652, http://tools.ietf.org/html/rfc5652#section-6.3

Members

Functions

addPadding
void addPadding(ubyte[] block, in uint len)

pad with zeros or random bytes if SecureRandom is specified in constructor.

padCount
uint padCount(in ubyte[] block)

Examples

PKCS7Pad pad; ubyte[16] block; block[0..2] = [1,2]; // block contains 2 bytes pad.addPadding(block, 2); // fill the rest with padding bytes assert(pad.padCount(block) == 2);

Meta