Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Key derivation using XOR (^) instead of power function #69

@guilhermeavanci

Description

@guilhermeavanci

Hi guys!

I recently moved an app to Flutter 2.x, and with that updated the flutter_sodium to the most up-to-date version.

After the update I started getting an RangeError coming from the library. Following the functions' calls I faced what I believe to be the issue. Just to clarify, here is the step-by-step:

KeyDerivation.derive (src/key_derivation.dart) -> cryptoKdfDeriveFromKey (src/sodium.dart) -> RangeError.checkValueInInterval(subkeyId, 0, (2 ^ 64) - 1, 'subkeyId')

The code checks here if subkeyId fit in the interval between 0 and (2 ^ 64) - 1.

Something was off about this error, so I made some research and concluded it's a typo in the max value of the range, probably came from the official sodium key derivation docs or something like that. In this page we have the identical math operation: subkey_id can be any value up to (2^64)-1.

Apparently the end of the interval is erroneous represented here using the math notation instead of dart language notation, which means the ^ character is a bitwise XOR instead of the math operation power, which I suppose should be the correct thing to do here. Btw, the result of (2 ^ 64) - 1 is always 65.

Anyway, here is the issue. Can you guys confirm? I hope I'm not being blind about something and opening an issue with no need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions