-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random padding / Confusion about "IV" padding vs "Last block" padding? #72
Comments
Just a small notice what I found out how padding is currently implemented:
|
Spent a few hours to understand how the padding in DEC works, but I am very stuck at the moment. Let block size be 16 bytes.
|
Ok, about the padding: that might require more work. About IFiller: I think meanwhile that the XMLDOC comment is wrong, as this is really only used to prefill the initialization vector so in case somebody provides an IV with less data than required something defined is contained in the last few bytes. I'll change the documentation. See my newest commit in development branch. |
I also corrected the documentation, but that's not yet available as new PDF version. |
You told me a few days that it would be preferrable if the padding would be randomized instead of static.
I have researched on the topic and indeed, randomized padding for the last block is highly recommended.
I have tried to find out how it currently works, but I believe that the documentation does not fit the code
Documentation:
vs. Implementation (This is the only place where I could see that
IFillter
is used):The
I
is probably also a hint that the filler is the padding of the IV and not the padding of the last block?So a few questions arrised:
IFiller
is only for the IV, are we safe then? (Because the blocks are dependant on each previous block, so the padding of the last block will be rather unguessable.) Edit: To answer my own question: We might be more safe if we'd use the standard PKCS#7 to fill the last block.FillChar(FInitializationVector^, FBufferSize, IFiller)
Why is the IV filled with the length of the buffer size, and not with the length of the block? I thought the IV only needs the size of a single block, and not the size of the buffer?In case we want random padding, I guess we could use
TBlockFillMode
for this purpose; something like:Edit: Actually, if we use TBlockFillMode as it is intended to be (to fill the last block instead of the IV), then it might be good to have it actually be defined as
(fmByte, fmRandom, fmPkcs5, fmPkcs7)
wherefmByte
is defined as constant byte.The text was updated successfully, but these errors were encountered: