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

Bug 27402 - Specify the behavior when returning an octet string with a particular _bit_ length #31

Closed
mwatson2 opened this issue May 23, 2016 · 1 comment

Comments

@mwatson2
Copy link
Collaborator

Bug 27402 from Bugzilla:

There are a few places in the spec which octet strings are used either as input or as output, however not all bits in the string are relevant.

For instance:

  • Importing an HMAC key were the length is not a multiple of 8 bits
  • Exporting an HMAC key whose length is not a multiple of 8 bits
  • Deriving bits for ECDH, using a length that is not a multiple of 8 bits

The spec is ambiguous on how exactly that mechanism works. This could lead to implementation incompatibilities if users rely on the behavior chosen by a particular implementation.

For instance consider these scenarios:

  • Import an HMAC key using data = [0xff] and length=1 bit. When exporting that key, implementations could return any of the following key values:

    [0xff](the exact octet stream imported)
    [0x80](the unused bits having been zeroed out)
    [0x84](or any other combination where first bit is zero)

  • When importing an HMAC key and the unused bits are not zero, we could consider treating this as an error error to catch potential mis-use?

  • When deriving 12 bits for ECDH, it is natural for an implementation to return the same thing as if deriving 16 bits. However there is nothing in the spec that mandates this. If another implementation decided to zero out those last 4 bits however users became reliant on the other behavior...

My recommendation is to mandate that unused bits when returning an octet string should be set to zero.

mwatson2 added a commit to mwatson2/webcrypto that referenced this issue May 24, 2016
mwatson2 added a commit to mwatson2/webcrypto that referenced this issue May 24, 2016
@mwatson2
Copy link
Collaborator Author

Pull Request #95

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