0

I am trying to use the 1-bit stream cipher mode in OpenSSL, specifically EVP_aes_128_cfb1. I initialize the context with that parameter using, EVP_EncryptInit_ex(). The rest is unclear to me. I am expecting this to work as a bit-by-bit stream cipher, meaning that if I "feed" it with a stream of bits it will gradually "build" the ciphertext bit by bit, and that ciphertext should eventually be identical to a one-shot encryption of the entire thing when using a bigger bit width like 128 bits.

Whatever I try, this is not what I am getting, and to be honest I am not sure if the problem is in the expectation or in my usage of OpenSSL. I am using EVP_EncryptUpdate(&ctx, p_target, &outlen, &current_byte, 1) but that means calling this 8 times with the same input byte, shifted properly. Then I expect the target byte, which also stays the same for 8 iteration at a time, to gradually be built one bit index at a time from MSB to LSB, with the context object orchestrating the state.

This does no yield the expected results, and I could not find working examples.

Help will be appreciated. Thanks.

ariy
  • 11
  • 1
  • *...and that ciphertext should eventually be identical to a one-shot encryption of the entire thing when using a bigger bit width like 128 bits....* No, that is not what happens with CFB1. See the [wikipedia article on CFB and CFB1](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#CFB-1,_CFB-8,_CFB-64,_CFB-128,_etc.) for details. – President James K. Polk Oct 12 '22 at 11:26

0 Answers0