Export (0) Print
Expand All
Expand Minimize

PaddingMode Enumeration

Specifies the type of padding to apply when the message data block is shorter than the full number of bytes needed for a cryptographic operation.

Namespace:  System.Security.Cryptography
Assembly:  mscorlib (in mscorlib.dll)

[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum PaddingMode

Member nameDescription
Supported by the .NET Compact FrameworkNoneNo padding is done.
Supported by the .NET Compact FrameworkPKCS7The PKCS #7 padding string consists of a sequence of bytes, each of which is equal to the total number of padding bytes added.

The following example shows how these modes work. Given a blocklength of 8, a data length of 9, the number of padding octets equal to 7, and the data equal to FF FF FF FF FF FF FF FF FF:

Data: FF FF FF FF FF FF FF FF FF

PKCS7 padding: FF FF FF FF FF FF FF FF FF 07 07 07 07 07 07 07

Supported by the .NET Compact FrameworkZerosThe padding string consists of bytes set to zero.
Supported by the .NET Compact FrameworkANSIX923The ANSIX923 padding string consists of a sequence of bytes filled with zeros before the length.

The following example shows how this mode works. Given a blocklength of 8, a data length of 9, the number of padding octets equal to 7, and the data equal to FF FF FF FF FF FF FF FF FF:

Data: FF FF FF FF FF FF FF FF FF

X923 padding: FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 07

Supported by the .NET Compact FrameworkISO10126The ISO10126 padding string consists of random data before the length.

The following example shows how this mode works. Given a blocklength of 8, a data length of 9, the number of padding octets equal to 7, and the data equal to FF FF FF FF FF FF FF FF FF:

Data: FF FF FF FF FF FF FF FF FF

ISO10126 padding: FF FF FF FF FF FF FF FF FF 7D 2A 75 EF F8 EF 07

Most plain text messages do not consist of a number of bytes that completely fill blocks. Often, there are not enough bytes to fill the last block. When this happens, a padding string is added to the text. For example, if the block length is 64 bits and the last block contains only 40 bits, 24 bits of padding are added.

Some encryption standards specify a particular padding scheme. The following example shows how these modes work. Given a blocklength of 8, a data length of 9, the number of padding octets equal to 7, and the data equal to FF FF FF FF FF FF FF FF FF:

Data: FF FF FF FF FF FF FF FF FF

X923 padding: FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 07

PKCS7 padding: FF FF FF FF FF FF FF FF FF 07 07 07 07 07 07 07

ISO10126 padding: FF FF FF FF FF FF FF FF FF 7D 2A 75 EF F8 EF 07

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft