SM4DecryptCBCPKCS7

Cryptography

Description

Decrypts PKCS#7-padded SM4 CBC ciphertext under a 16-byte key and 16-byte IV and strips the padding

Syntax

Delphi

Function SM4DecryptCBCPKCS7(Const Key, IV, Ciphertext: AnsiString): AnsiString;

Parameters

KeyExactly 16 bytes
IVExactly 16 bytes; the same IV used for encryption
CiphertextLength must be a multiple of 16

Return values

The unpadded plaintext, or an empty string when the input is invalid or the padding check fails

Remarks

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

A failed padding check or a wrong key yields an empty result, mirroring the behaviour of SM4TryUnpadPKCS7

Counterpart of SM4EncryptCBCPKCS7

See also

SM4EncryptCBCPKCS7, SM4DecryptCBC, SM4DecryptECBPKCS7, SM4UnpadPKCS7