Git Product home page Git Product logo

Comments (13)

cremfert avatar cremfert commented on August 14, 2024 1

Yes sure, here it is:

E/flutter (12905): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: RangeError (count): Invalid value: Not greater than or equal to 0: -5381629408123551712
E/flutter (12905): #0      RangeError.checkNotNegative (dart:core/errors.dart:356:7)
E/flutter (12905): #1      new SodiumPointer.alloc
package:sodium/…/bindings/sodium_pointer.dart:58
E/flutter (12905): #2      new SecureKeyFFI.alloc
package:sodium/…/api/secure_key_ffi.dart:30
E/flutter (12905): #3      KeygenMixin.keygenImpl
package:sodium/…/helpers/keygen_mixin.dart:21
E/flutter (12905): #4      SecretBoxFFI.keygen
package:sodium/…/api/secret_box_ffi.dart:32
E/flutter (12905): #5      EncryptionV2Service.generateKey

(Last line is my function that includes the keygen() command.

Thanks for your help!

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

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.

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

Could you please add the following to your code, right before the SecretBoxFFI.keygen method and send me the result?

print(mySecretBox.keyBytes)

I cannot test on Android myself for the next few days, so that would help me working on this earlier.

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

Also, which Android version and Architecture are you testing on

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

I cannot reproduce your issue on my arm x64 device. I think I need more details about the exact device you are testing on

from libsodium_dart_bindings.

cremfert avatar cremfert commented on August 14, 2024

Sorry for being late - I'm developing my app on an Android Emulator with API 30.
The specs are:

Name: Pixel_3a_API_30_x86_1
CPU/ABI: Google APIs Intel Atom (x86)
Target: google_apis [Google APIs] (API level 30)
Skin: pixel_3a
SD Card: 800 MB
fastboot.chosenSnapshotFile: 
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: pixel_3a
hw.lcd.width: 1080
hw.initialOrientation: Portrait
image.androidVersion.api: 30
tag.id: google_apis
hw.mainKeys: no
hw.camera.front: emulated
avd.ini.displayname: Pixel_3a_API_30_x86_1
hw.gpu.mode: auto
hw.ramSize: 1536
PlayStore.enabled: false
fastboot.forceColdBoot: no
hw.cpu.ncore: 4
hw.keyboard: yes
hw.sensors.proximity: yes
hw.dPad: no
hw.lcd.height: 2220
vm.heapSize: 256
skin.dynamic: yes
hw.device.manufacturer: Google
hw.gps: yes
hw.audioInput: yes
image.sysdir.1: system-images/android-30/google_apis/x86/
showDeviceFrame: yes
hw.camera.back: virtualscene
AvdId: Pixel_3a_API_30_x86_1
hw.lcd.density: 440
hw.arc: false
fastboot.forceChosenSnapshotBoot: no
fastboot.forceFastBoot: yes
hw.trackBall: no
hw.battery: yes
hw.sdCard: yes
tag.display: Google APIs
runtime.network.latency: none
disk.dataPartition.size: 6G
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes

I will have a chance to give you the keybytes output in the next days (maybe on the weekend).

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

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

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

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)

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

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 sodium and overwrite it in your pubspec.

from libsodium_dart_bindings.

cremfert avatar cremfert commented on August 14, 2024

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.

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

I assume everything worked? If not, please reopen

from libsodium_dart_bindings.

cremfert avatar cremfert commented on August 14, 2024

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.?

from libsodium_dart_bindings.

Skycoder42 avatar Skycoder42 commented on August 14, 2024

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

from libsodium_dart_bindings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.