SM4TryUnpadPKCS7

Cryptography

Description

Validates PKCS#7 padding and strips it, reporting success as a Boolean instead of an empty string

Syntax

Delphi

Function SM4TryUnpadPKCS7(Const Padded: AnsiString; Out Data: AnsiString): Boolean;

Parameters

PaddedThe padded payload; must be non-empty and block-aligned for the check to pass
DataOut parameter receiving the unpadded bytes when the padding is valid; untouched otherwise

Return values

TrueThe padding was well formed and Data holds the unpadded bytes
FalseThe input was empty, not block-aligned, or the pad bytes were inconsistent

Remarks

Part of the pure-Pascal SM4 block cipher (GB/T 32907-2016)

SM4UnpadPKCS7 wraps this check and returns an empty string on failure

The PKCS7 encryption helpers rely on this validation before returning plaintext

See also

SM4PadPKCS7, SM4UnpadPKCS7, SM4DecryptECBPKCS7, SM4DecryptCBCPKCS7