Open 05nelsonm opened 1 year ago
Think about adding a static EncoderDecoder
configured specifically for this, too.
public class Base64(
config: Base64.Config
) : EncoderDecoder<Base64.Config>(config) {
// ...
public object Default {
@JvmField
public val CT: Base64 = Base64 {
lineBreakInterval = 64
constantTime = true
}
}
// ...
}
Add as a config option the ability to set constant time.
Some operations (e.g. encryption/decryption) require processing the entire contents of the input before throwing exception in order to mitigate timing attacks.
As module
:library:encoding-core
does not have knowledge of the higher level implementation details, this will need to be something added to them individually.EncoderDecoder
is configured for constant time and encounters an unrecognized input, it should substitute that unknown input so operations continue (e.g. characterTABLE[0]
) and set an error flag.Feed.doFinalProtected
is invoked, it should process the remaining contents in its buffer, and then throw an exception.flush()
should not produce an exception, only upon afterFeed.doFinal
is invoked. Implementations can checkisClosed
within theirdoFinalProtected
function to check whetherflush
ordoFinal
has been invoked.