-
Notifications
You must be signed in to change notification settings - Fork 10
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
Pad to multiples of a fixed size, rather than padding randomly #54
Comments
Random padding isn't completely useless, depending on context. Here, it's not that much good. It very much depends on your application when you come to choose a padding scheme. For something like push messaging, you still need to understand what information is being carried and what you want to protect. For instance, if it is price alerts for secret offers on secret stuff, you might like to pad item codes and prices individually so that they are all fixed length, but maybe you also have a variable number of alerts in each message and you want to hide that too. As a baseline 128 is probably reasonable if you consider a maximum size of 4k. I can see cases for 32 or 64 as well. Setting a default of 128 and letting people adjust is probably the best that this library can do. |
I also have this sneaking suspicion that the padding in |
Might be time to excise the |
Yeah :-/ I'm taking a brief look at #55 and as part of that, going to try to at least disentangle |
This is one of the padding techniques suggested in the RFC, and while we can't choose a default scheme that will work well for all applications, this one at least seems easier to reason about. Fixes #54.
This is one of the padding techniques suggested in the RFC, and while we can't choose a default scheme that will work well for all applications, this one at least seems easier to reason about. Fixes #54.
My attempt to disentangle to two schemes is here: #59 @martinthomson if you have a chance to look at this (probably just at the newly-standalone aes128gcm.rs and aesgcm.rs files) I'd appreciate it, but I understand it's a lot and likely not the highest-priority work. I'm just in a cleaning-up kind of mood. |
This is one of the padding techniques suggested in the RFC, and while we can't choose a default scheme that will work well for all applications, this one at least seems easier to reason about. Fixes #54.
During encryption, the code in this crate currently selects a random integer between zero and the allowed record size, and adds that many bytes of padding to the plaintext.
It's my understanding that adding random padding isn't all that helpful in practice, because if your adversary collects enough samples they can statistically filter out the noise. IMHO we should either do something better here, or do what the Desktop code does and not pad at all because we don't have enough information about the usage context to do it well.
RFC 8188 Section 4.8 has some commentary on padding, and notes that "Developing a padding strategy is difficult". It lists three common strategies, all of which seem tractable and none of which are "add a random amount of padding":
(That section also says "distributing non-padding data across records is recommended to avoid leaking size information", which is something that this crate does do, and which seems worth keeping).
I propose that we change the current padding calculation to round up the plaintext size to multiples of a fixed size; for the sake of argument let's say multiples of 128 bytes. If that doesn't seem worth the effort, then I propose that we remove the padding entirely in the interests of simplicity.
I'll reach out to @martinthomson to see if he'd like to weigh in on the particulars here.
The text was updated successfully, but these errors were encountered: