Padmé
Purpose
The length of a ciphertext from a stream cipher is equal to the length of the plaintext. Similarly, block cipher padding only adds a small overhead. This metadata can leak information about what was encrypted and thus is something protocols may want to hide.
Padmé is a popular deterministic padding scheme with overhead capped to at most +12%, which decreases with input length. It tells you how much padding to add but does not define how that padding should be implemented.
The idea is that multiple input lengths result in the same output length (grouping into buckets), and the number of inputs that map to the same bucket grows. This means the output length hides the exact input length within that range of inputs, preventing padded objects from being uniquely identifiable via their size.
Usage
GetPaddedSize
Returns the padded length deterministically calculated from the unpadded length.
ulong paddedSize = Padme.GetPaddedSize(ulong unpaddedSize);Exceptions
unpaddedSize is greater than MaxUnpaddedSize.
The calculation has resulted in an overflow.
GetPaddingSize
Returns the difference between the padded length and unpadded length (the amount of padding). This is not for removing padding.
Exceptions
unpaddedSize is greater than MaxUnpaddedSize.
The calculation has resulted in an overflow.
Constants
These are used for validation and/or save you from defining your own constants.
Notes
Last updated