-
Notifications
You must be signed in to change notification settings - Fork 6
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
Can't generate keys on Android #7
Comments
Interesting. I have an idea where this could come from, but am not quite sure yet. Could you give me a stack trace? Specifically the parts regarding libsodium are important for me. |
Yes sure, here it is:
(Last line is my function that includes the Thanks for your help! |
Could you please add the following to your code, right before the print(mySecretBox.keyBytes) I cannot test on Android myself for the next few days, so that would help me working on this earlier. |
Also, which Android version and Architecture are you testing on |
I cannot reproduce your issue on my arm x64 device. I think I need more details about the exact device you are testing on |
Sorry for being late - I'm developing my app on an Android Emulator with API 30.
I will have a chance to give you the keybytes output in the next days (maybe on the weekend). |
I can confirm this happening and I do know why. The native C-Bindings for libsodium have been generated on a x64 machine, with size_t beeing resolved to UInt64. This of course does not work on a 32 bit system. For know, the easiest way around this is to create yourself a 64 bit emulator. Regarding deployment to actuald devices, arm64 and intel x64 devices are fine, but older armv7 devices would not work. I will try to find a way around this issue |
I was able to confirm this. When I replace the "size_t" typedef in the generated bindings with "Uint32", the library works! Know I need to find a way to get the correct bindings based on architecture (which is not as easy as it sounds, as dart typically does not provide this information) |
Okay so I manage to get it to work by enforcing "size_t" to be interpreted as "IntPtr" - this works in regards of sizing, as for all supported system IntPtr has the same size as size_t, however, this messes up signed-ness, as IntPtr is signed, while size_t is not. I fixed things up so all test should succeed, but I have to walk through the whole library again to ensure all sizes are correctly interpreted. However, the current status should already be good enough to test out if it works for you as well, so if you have the time, please check out the latest master of |
Thanks a lot for your effort and your work - I really appreciate your help! I will have a chance to test next week and will provide feedback. |
I assume everything worked? If not, please reopen |
Sorry, forgot to answer - yes, everything works! Thanks for your effort. I was just curious, if you also implemented the helper methods for conversion, like bin2hex and hex2bin etc.? |
No, i did not implement the helpers, as dart itself provides similar functions, which are much more efficient as no conversion between dart and the native code is required |
I try to generate a secure key by using:
await sodium.crypto.secretBox.keygen();
in Flutter (usingsodium_libs: ^1.1.1
).This works fine on iOS, but fails with an error on Android:
RangeError (RangeError (count): Invalid value: Not greater than or equal to 0: -5365866809427754976)
How can I fix this?
Thanks a lot!
The text was updated successfully, but these errors were encountered: