EVP_CIPHER-SM4(7ossl)

πŸ’œ EVP_CIPHER-SM4 πŸ’œ

okay so bestie, this is the 7ossl manual page for EVP_CIPHER-SM4 β€” the whole vibe is The SM4 EVP_CIPHER implementations ✨ like, that's literally the NAME, and we're gonna get into it.


🌸 DESCRIPTION 🌸

So basically: this is all about support for SM4 symmetric encryption using the EVP_CIPHER API. That's the whole deal. Slay.

πŸŽ€ Algorithm Names πŸŽ€

The following algorithms are available in the default provider β€” like, these are the actual strings you type, no cap:

  • "SM4-CBC:SM4"
  • "SM4-ECB"
  • "SM4-CTR"
  • "SM4-OFB" or "SM4-OFB128"
  • "SM4-CFB" or "SM4-CFB128"
  • "SM4-GCM"
  • "SM4-CCM"
  • "SM4-XTS"

iykyk what to do with these πŸ’…

πŸ¦‹ Parameters πŸ¦‹

This implementation supports the parameters described in "PARAMETERS" in EVP_EncryptInit(3). that's it, that's the section, go read that one, it's giving very cross-reference ✨


πŸ’€ NOTES πŸ’€

okay this part is the serious one, bestie, so listen up fr fr πŸ™ˆ

SM4 implementations in OpenSSL may use secret-dependent table lookups and are not guaranteed to be constant-time. and like, that's not me being dramatic, that's literally in there 😭 In particular, the portable C implementation uses S-box and T-table lookups and may be vulnerable to cache-timing side-channel attacks. so yeah, that's a real thing to care about.

Which code path is used depends on CPU capabilities β€” see OPENSSL_armcap(3), OPENSSL_ia32cap(3) and OPENSSL_riscvcap(3). 🧚

ngl this next bit is the sneaky one. The SM4-XTS implementation allows streaming to be performed, but each EVP_EncryptUpdate(3) or EVP_DecryptUpdate(3) call requires each input to be a multiple of the blocksize. Only the final EVP_EncryptUpdate() or EVP_DecryptUpdate() call can optionally have an input that is not a multiple of the blocksize but is larger than one block. In that case ciphertext stealing (CTS) is used to fill the block. πŸ’…βœ¨

🌈 SEE ALSO 🌈

go be nosy, these are all iconic:


Copyright 2021-2026 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>. 🫢


and that's the page, bestie!! this one's from version 3.5.9, dated 2026-09-29, filed under EVP_CIPHER-SM4(7ossl) β€” main character energy, periodt. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from