Giter VIP home page Giter VIP logo

Comments (23)

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024 2

I see.

I think the problem actually had to do with the PasswordHashOptions struct not working correctly on x64 to be honest. I made a wrapper for it and suddenly x64 started working. Here's the relevant code block.

var str = "test";
var options = PasswordHash.CreateOptions(16384, 3);
var result = KDF.Argon2i(str, options);

I just push 1.0.122 to nuget (https://www.nuget.org/packages/libsodium-uwp/1.0.122). The package uploaded seems to work right on x86, x64, and the ARM device I have. It's still indexing on nuget, but once it's done - any chance you could confirm?

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

@globeport Syntax error aside, I'm not able to reproduce this in a new UnitTestProject I just created using Nuget 1.0.12.

A couple of questions:

  1. Do you have a more verbose error you can provide?
  2. What is your build target? x64 Local Machine?
  3. Does your target have 16MiB of available RAM for Argon2i to fill?
  4. Does the problem persist if you include libsodium-uwp from a recursive clone rather than Nuget? (git clone --recursive https://github.com/charlesportwoodii/libsodium-uwp?
  5. Are you trying to generate a 32 byte key? Or do you just want to create an Argon2i hash for storage? PasswordHash would be better for the later.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Appologies for syntax error above.

  1. Slightly more information given in the exception:

'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

  1. Yes, x64 LocalMachine

  2. 8gb ram desktop machine

  3. The error has only started to occur since switching to the nuget package. Prior to that I was referencing a clone and things worked fine.

  4. Yes I'm generating a 32 byte key for authentication

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

@globeport FYI PasswordHashOptions.memory_cost is represented in KiB.16384 KiB => 16 MiB

Clone from git then instead. I'm not able to reproduce it but I'd bet that solves the problem for you. Nuget support for Universal Windows Runtime UWP packages still isn't that great. I'll revisit it again before 1.0.13.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Thanks. Tried reducing the memory cost but the error persists.

Sure I can go back to a clone. I was just attempting to clean up my solution a bit :)

Thanks.

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

The .nuspec in master is newer than what was used for 1.0.12. If you want, you can try to see if packaging master gets you a workable nuspec file.

That process would look like (download nuget.exe if you don't have WSL bash installed)

cd /path/to/libsodium-uwp
bash -lc "wget https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe"
nuget.exe pack .nuget\libsodium-uwp.nuspec

Then in Visual Studio View->Other Windows->Package Manager Console

Install-Package C:\path\to\libsodium-uwp.1.0.12.nupkg

Still not sure why you're seeing the error and I'm not, but see if that works for you.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

OK I'll have a look at this at somepoint today. Thanks

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Same problem packaging with latest version of nuget. I can only get things to work if I link directly to the project. Strange. I'll let you know if I find a solution.

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

@globeport That's mindboggling. If I upload a project a little later today would you be able to test it on your setup and let me know the output? It would just be a simple UnitTest project that loads the Nuget package and runs yours Argon2i call.

Out of curiosity, are you on VS2017 or VS2015?

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Sure, I'm on VS2017

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

@globeport

Then that's why. The nuget package is built against the Visual C++ Redistributable for Visual Studio 2015 which I don't think works right in VS2017. The package should compile fine, but the nuget package needs to be retargeted for the 2017 redist.

I'm not able to run VS2017 yet on my development machine, but as soon as I can port the project to VS2017 the nuget package should be fixed.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Great, thankyou.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Hi @charlesportwoodii, are you in a position to be able to publish a new release? I'm going to publish a nuget package with this library as a dependency and it would make life much easier if you could? Thanks.

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

@globeport For VS2017 or VS2015?

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

2017

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

Let me see what I can do. I had to uninstall VS2017 a week or 2 ago because of an issue and haven't re-installed it yet. I'll try to get back to you shortly.

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

@globeport:

I was able to reproduce the issue for both Argon2i and Scrypt when using the nuget package for x64 builds. I tried making a new package for 2017 but I'm still seeing the same issue.

To be honest I'm not sure what the problem is though. I can't reproduce it in the test suite, and when I copy over the DLL's from the test suite to a sample project, I still see the same issue.

Give that the tests pass I'm pretty confident this has something to do with how Nuget packages the libraries rather than a code issue, however I really don't have the time presently to dig into what Nuget is doing. To be perfectly honest I'm not entirely convinced Nuget works right 100% of the time for Universal C Runtime Components.

If you're able to identify and fix the issue with the files in the .nuget directory I'd gladly welcome a Pull Request. However at the moment I don't have the time to keep digging into this.

I'll re-open the issue, but a MR would be the fastest way to get this published back to nuget.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

OK I'll investigate this at somepoint. Thanks.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

The Sodium.winmd reference in the nuspec file seems to be causing the problem. If I refer to the x64 build of Sodium.winmd instead, then everything works fine for x64 builds. So it does seem that the winmd file is platform specific. The question is how do you reference the correct version in nuspec?

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

I have been trying but no luck. I should say I have finally managed to get my UWP nuget package working without having to reference the libsodium package so its no longer a priority for me but I guess it would be nice to figure this out.

from libsodium-uwp.

globeport avatar globeport commented on August 26, 2024

Yes that's working now. Hooray!

from libsodium-uwp.

charlesportwoodii avatar charlesportwoodii commented on August 26, 2024

Thanks for confirming! I've updated the relevant documentation for this as well.

If you find any other oddities let me know.

Thanks!

from libsodium-uwp.

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.