05nelsonm / encoding

A Kotlin Multiplatform library for configurable, streamable, efficient and extensible Encoding/Decoding with support for base16/32/64.
Apache License 2.0
30 stars 5 forks source link

Implement constant time decoding #123

Open 05nelsonm opened 1 year ago

05nelsonm commented 1 year ago

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.

05nelsonm commented 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
        }
    }

    // ...
}