[botan-devel] CBC mode with no padding
noloader at gmail.com
Fri Nov 24 01:31:40 EST 2017
On Thu, Nov 23, 2017 at 7:48 PM, Jack Lloyd <jack at randombit.net> wrote:
> On Thu, Nov 23, 2017 at 06:56:06PM -0500, Jeffrey Walton wrote:
>> Hi Everyone,
>> I'm trying to use SM4 cipher in CBC mode with no padding. The code is
>> available at https://pastebin.com/tFEjzZtz.
>> The code either fails to compile (no start() on cipher object) or
>> crashes (just a segfault; no uncaught exceptions).
>> The documentation for SymmetricCipher is at
>> https://botan.randombit.net/manual/symmetric_crypto.html, but I don't
>> see a discussion of "no padding". I found a Null_Padding class, but I
>> have not figured out how to wire it in to the machinery.
>> How do I use SM4 cipher in CBC mode with no padding?
> The problem is you were attempting this via BlockCipher (which is just
> the bare n-bit permutation) vs Cipher_Mode which is the API for
> encrypting messages.
> The segfault probably occured because BlockCipher::create("Foo")
> returns null if no such cipher exists; ::create_or_throw will throw
> instead. And there is no block cipher named "SM4/CBC".
> As for skipping padding, CBC mode allows speciying the padding type as
> in BlockCipher/CBC/PaddingMode eg AES-128/CBC/PKCS7 or SM4/CBC/NoPadding.
> Modified version of your paste follows. Hope this helps. -Jack
Perfect, thank you very much.
More information about the botan-devel