Search code examples
rubyopensslrijndael

Ruby OpenSSL changing the block-size


Is it at all possible in OpenSSL to change the block size? I am using Ruby and from what I can tell there is no way to do this.

I just want to confirm this is true. Here is a link to the only method I can find related to block size which just returns what the block size is. https://ruby-doc.org/stdlib-2.4.0/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-i-block_size but other than that I don't see a way to do this. Is it possible? I know I can set the key size but not the block size. It seems it is stuck with a 128-bit block size?

Specifically I want to use AES which I understand is only a 128-bit block size. But Rijndael which is what AES is based on can be set up to a 256-bit block size so I was wondering if OpenSSL would allow me to set the block size.


Solution

  • No, it's not possible.

    • AES, as standardized by NIST, is a subset of the Rijndael cipher family. While Rijndael supports several different block and key sizes, AES is only defined to use a block size of 128 bits and a key size of either 128, 192 or 256 bits.

    • The list of ciphers supported by OpenSSL only includes AES, not Rijndael.

    • The OpenSSL AES implementation is hardcoded to use a block size of 16 bytes (= 128 bits).

    Short of adding Rijndael as a new cipher to OpenSSL and rebuilding the library yourself, you will not be able to use OpenSSL to encrypt or decrypt data using any of the Rijndael variants other than those standardized as AES.