c - How to set zero padding to EVP_CIPHER? -


is possible set zero padding when using evp_cipher.

i know default padding evp_encryptinit_ex enabled , uses pkcs padding.

and evp_cipher_ctx_set_padding can enable , disable padding.

as wikipedia correctly notes, zero-padding not standardized encryption. may not deterministic if plaintext can end 00 bytes. furthermore, there implementations add additional block if plaintext contains integral number of blocks, others not add additional block.

i haven't seen zero-padding in evp cipher suite, simple implement performing padding yourself, , disabling padding. 1 method copying plaintext block of 0 values, e.g. created memset. problem approach cannot switch between padding modes, remains special case.

if possible, try use pkcs#7 compatible padding scheme instead. if have go 0 padding, make sure can retrieve size of plaintext , define in advance if additional block of zero's added or not (php, instance, not, bouncy castle does).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -