Table of Contents

PaddingModeKind Enum

Definition

Namespace
Bodu.Security.Cryptography
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
PaddingModeKind.cs

Specifies a padding scheme for block-cipher operations. Mirrors the standard framework PaddingMode values and extends that surface with additional padding schemes that are not part of the framework enum.

public enum PaddingModeKind
Extension Methods

Fields

None = 1

Specifies that no padding is applied. The input must already be an exact multiple of the block size. Mirrors None.

Use this mode only when the caller independently guarantees block alignment. Padding and depadding operations do not add or remove bytes for this mode.

PKCS7 = 2

Specifies PKCS#7 padding. Each padding byte contains the number of padding bytes added. Mirrors PKCS7.

PKCS#7 padding is self-describing and always appends at least one padding byte. If the input is already block-aligned, a full block of padding is appended.

Zeros = 3

Specifies zero padding. Zero-value bytes are appended until the input aligns with the block size. Mirrors Zeros.

Zero padding is not self-describing. It is only unambiguous when the original plaintext cannot end with zero bytes or when the original length is known by other means.

ANSIX923 = 4

Specifies ANSI X.923 padding. Padding bytes are zero except for the final byte, which contains the number of padding bytes added. Mirrors ANSIX923.

ANSI X.923 padding is self-describing and always appends at least one padding byte. If the input is already block-aligned, a full block of padding is appended.

ISO10126 = 5

Specifies ISO 10126 padding. Padding bytes before the final byte are random, and the final byte contains the number of padding bytes added. Mirrors ISO10126.

ISO 10126 padding is self-describing. The random filler bytes are ignored during depadding; only the final length byte is significant.

ISO7816_4 = 1024

Specifies ISO/IEC 7816-4 padding, also known as one-and-zeros or bit padding. The first padding byte is 0x80, followed by zero or more 0x00 bytes. This mode extends PaddingMode and has no framework counterpart.

ISO/IEC 7816-4 padding is self-describing and appends a full block of padding when the input is already block-aligned, ensuring depadding remains unambiguous. It is commonly used in smart-card standards and related cryptographic constructions that use one-and-zeros padding.

Remarks

Values 0 through 4 are deliberately aligned with PaddingMode so that the mirrored values can be converted between PaddingModeKind and PaddingMode by cast. The ISO7816_4 value is a Bodu extension and has no framework counterpart.

Bodu-specific values start at 1 << 10 to avoid colliding with framework-defined values.

Pass a PaddingModeKind to PaddingFactory to obtain the matching IPaddingStrategy implementation.

When to use this enum vs the framework PaddingMode. Use PaddingMode for code that must directly interoperate with Padding. Use PaddingModeKind when code should support the framework padding schemes plus Bodu-specific extensions such as ISO7816_4.

Applies to

ProductVersions
.NET8, 10

See Also