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

Running on Hololens UWP #32

Open
Xan2063 opened this issue Nov 11, 2020 · 3 comments
Open

Running on Hololens UWP #32

Xan2063 opened this issue Nov 11, 2020 · 3 comments

Comments

@Xan2063
Copy link

Xan2063 commented Nov 11, 2020

Hi everyone,
I tried using Argon2 on Hololens, but there seem to be problems accessing the windows api from a UWP project. Sometimes Hololens is a bit special...so not sure, if it is a general UWP Problem.

Here is the stack trace I got. I think UWP is restricted on accessing native APIs, but I did not dig into this. Do you have any experience on this?

Thanks
Alex

System.TypeInitializationException: The type initializer for 'Isopoh.Cryptography.SecureArray.SecureArray' threw an exception. ---> System.NotSupportedException: No SecureArray.DefaultCall support for current operating system (whatever that is, maybe "Microsoft Windows NT 10.0.19041.0", I think I know Windows, Linux, OSX, and web - and maybe iOS...). You  don't have to use the default SecureArrayCall - you can pass in a version of the calls that work for your operating system.
  at Isopoh.Cryptography.SecureArray.SecureArray.get_DefaultCall () [0x00000] in <00000000000000000000000000000000>:0 
  at Isopoh.Cryptography.SecureArray.SecureArray..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at Isopoh.Cryptography.SecureArray.SecureArray`1[T]..ctor (System.Int32 size, Isopoh.Cryptography.SecureArray.SecureArrayType type, Isopoh.Cryptography.SecureArray.SecureArrayCall call) [0x00000] in <00000000000000000000000000000000>:0 
  at Isopoh.Cryptography.SecureArray.SecureArray`1[T].Best (System.Int32 size, Isopoh.Cryptography.SecureArray.SecureArrayCall secureArrayCall) [0x00000] in <00000000000000000000000000000000>:0 
  at Isopoh.Cryptography.Argon2.Argon2.Hash (System.String password, System.String secret, System.Int32 timeCost, System.Int32 memoryCost, System.Int32 parallelism, Isopoh.Cryptography.Argon2.Argon2Type type, System.Int32 hashLength, Isopoh.Cryptography.SecureArray.SecureArrayCall secureArrayCall) [0x00000] in <00000000000000000000000000000000>:0 
  at Isopoh.Cryptography.Argon2.Argon2.Hash (System.String password, System.Int32 timeCost, System.Int32 memoryCost, System.Int32 parallelism, Isopoh.Cryptography.Argon2.Argon2Type type, System.Int32 hashLength, Isopoh.Cryptography.SecureArray.SecureArrayCall secureArrayCall) [0x00000] in <00000000000000000000000000000000>:0 
  at StoredCreds.PrepareCredentialsForStorage (Credentials credentials) [0x00000] in <00000000000000000000000000000000>:0 
  at UserSelectionMode.Activate (NavigationParameters navigationParameters) [0x00000] in <00000000000000000000000000000000>:0 
@mheyman
Copy link
Owner

mheyman commented Nov 13, 2020

You know, I coded very early on the Hololens and didn't think to try this library on it...

The issue is with trying to be fancy in assuring memory gets locked and zeroed with SecureArray by calling into the OS.

I'll work on getting that working in the Hololens.

@Xan2063
Copy link
Author

Xan2063 commented Nov 16, 2020

Maybe the issue is with Hololens2 which is ARM-based. Is there a way to help you with that issue. I think the file system of the hololens is not open, so I cannot check dlls easily.

@mheyman
Copy link
Owner

mheyman commented Nov 17, 2020

I don't think it is an ARM vs Intel issue because P/Invoke works on both (according to interwebs and my initial fiddling).

And, I've found contradictory documentation about calling these things. I did find https://docs.microsoft.com/en-us/previous-versions/mt186421(v=vs.85) which, I think, lists some of the things I can P/Invoke. I’m pretty sure that isn’t all the things because the stackoverflow tells me to detect if the code is running on UWP is to P/Invoke GetCurrentPackageFullName(). That isn’t in the list.

As a workaround for now, you can create your own Argon2Config and set the SecureArrayCall field to an instance of DefaultWebSecureArrayCall. Then use that Argon2Config in calls to hash and verify. That uses the version of SecureArray that runs in webassembly. That version doesn't attempt to lock memory in RAM and only hopes to zero the memory. It is hard to zero memory when you are done with it in light of optimizers and such that notice "you are trying to zero the memory but you don't use it afterwards so I'm going to help you by not eating CPU performing that action" :-)

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

2 participants