Skip to content
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

Implement constant time decoding #123

Open
05nelsonm opened this issue Jun 4, 2023 · 1 comment
Open

Implement constant time decoding #123

05nelsonm opened this issue Jun 4, 2023 · 1 comment

Comments

@05nelsonm
Copy link
Owner

05nelsonm commented Jun 4, 2023

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.

  • When an EncoderDecoder is configured for constant time and encounters an unrecognized input, it should substitute that unknown input so operations continue (e.g. character TABLE[0]) and set an error flag.
  • When Feed.doFinalProtected is invoked, it should process the remaining contents in its buffer, and then throw an exception.
    • invoking flush() should not produce an exception, only upon after Feed.doFinal is invoked. Implementations can check isClosed within their doFinalProtected function to check whether flush or doFinal has been invoked.
@05nelsonm
Copy link
Owner Author

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
        }
    }

    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant