Padding.unpad

const(ubyte)[] unpad(const(ubyte)[] input, size_t blockSize)

Removes padding from the input.

Parameters

inputThe padded data (must be a multiple of blockSize).
blockSizeThe block size in bytes.

Returns

A const view of the unpadded data. It may be a slice of

input (when the input is already const-backed) or a fresh copy — callers must not rely on either, and must not mutate the result.

Throws

CryptoException if padding is invalid.

Security note: distinguishable error paths (invalid padding vs. other failures) are the classic padding-oracle attack vector under CBC. Implementations SHOULD perform the unpadding decision in constant time and return a single uniform CryptoException for every rejection; callers handling unauthenticated ciphertext must treat every failure identically.