SM4DecryptCBC

Cryptography

Description

Decrypts a ciphertext with SM4 in CBC mode under a 16-byte key and 16-byte IV

Syntax

Delphi

Function SM4DecryptCBC(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 decrypted plaintext, or an empty string on any invalid input

Remarks

Part of the pure-Pascal SM4 block cipher (GB/T 32907-2016); the implementation passes the standard single-block vector, the published first round key and the one-million-iteration vector

The payload length must be a multiple of 16; there is no padding layer

See also

SM4EncryptCBC, SM4DecryptECB, PLSM4DecryptBlock, PLSM4InitKey