CBC-CTS 模式


🌐 CBC-CTS mode

对于 CBC 密文窃取(CBC-CTS)加密,ctsMode 选项用于 crypto.createCipheriv() 或 crypto.createDecipheriv() 来选择变体:

🌐 For CBC ciphertext stealing (CBC-CTS) ciphers, the ctsMode option to crypto.createCipheriv() or crypto.createDecipheriv() selects the variant:

  • 'CS1' 是默认设置。对于块对齐的输入,它的输出与 CBC 模式相同。
  • 'CS2' 对于块对齐输入也与 CBC 相同。对于有部分最后块的输入,它会相对于 CS1 交换最后的完整和部分密文块。
  • 'CS3' 是 Kerberos 5 的变体。它在处理部分最终块时使用 CS2 排序,并且即使输入是块对齐的,也会交换最后两个密文块。

加密和解密必须使用相同的变体。这个选项仅在 OpenSSL 3.0 或更高版本的 CBC-CTS 提供者密码中可用。

🌐 Encryption and decryption must use the same variant. The option is available only with CBC-CTS provider ciphers on OpenSSL 3.0 or later.

使用此模式的应用必须遵守以下限制:

🌐 Applications which use this mode must adhere to these restrictions:

  • 明文或密文至少要有一个块长。
  • 密文和明文的长度一样。
  • cipher.update() 或 decipher.update() 必须使用所有输入数据且只调用一次。像 write(data)、end(data) 或 pipe() 这样的流方法可能会失败,因为 CBC-CTS 不接受多次数据更新。
  • cipher.final() 或 decipher.final() 仍然需要被调用来完成操作。
  • crypto.getCipherInfo() 报告基础模式为 'cbc'。