Giter VIP home page Giter VIP logo

libsodium-uwp's Introduction

libsodium-uwp

AppVeyor License Nuget

libsodium-uwp (libsodium for Universal Windows Platform (UWP)) is a C++ Windows Runtime Component for UWP applications. This library is fully tested and executes on both Windows 10 and Windows 10 mobile.

Cryptography is hard. This library was written to make libsodium available to the .NET community building Universal Windows Applications so that developers can safely and securely implement cryptography within their application.

Requirements

Installation

  1. Clone this project

    git clone --recursive https://github.com/charlesportwoodii/libsodium-uwp
    
  2. Add the project solution to your project via File->Add->Existing Project

  3. Add a reference to libsodium-uwp by adding libsodium-uwp\libsodium-uwp\libsodium-uwp.vcxproj to your project references.

  4. Add a reference to Visual C++ Redistributable for Visual Studio 2015 to your project.

Nuget Installation

  1. Install from Nuget

    Install-Package libsodium-uwp
    
  2. Add the following to your Package.appxmanifest file.

      <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">
            <InProcessServer>
                <Path>libsodium-uwp.dll</Path>
                <ActivatableClass ActivatableClassId="Sodium.Core" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.CryptoHash" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.GenericHash" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.GenericHashAlgorithmProvider" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.GenericHashAlgorithmNames" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.KDF" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.KeyPair" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.OneTimeAuth" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.PasswordHash" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.PublicKeyAuth" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.PublicKeyBox" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.ScalarMult" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.SealedPublicKeyBox" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.SecretBox" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.SecretKeyAuth" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.SecretAead" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.SecretStream" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.ShortHash" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.StreamEncryption" ThreadingModel="both" />
                <ActivatableClass ActivatableClassId="Sodium.Utilities" ThreadingModel="both" />
            </InProcessServer>
        </Extension>
    </Extensions>

Documentation

See the docs folder for complete documentation on how to use this library.

Notes

libsodium requires the Visual C++ Redistributable for Visual Studio 2015.

This library is currently a work in progress. While many libsodium functions are implemented, not are all. See the docs folder for more information. Also see the releases page for more information and details as to what is available on Nuget, as the master branch may be ahead of what is available there.

License

NaCl has been released to the public domain to avoid copyright issues. libsodium is subject to the ISC license, and this software is subject to the BSD-3 Clause License (see LICENSE.md).

libsodium-uwp's People

Contributors

charlesportwoodii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

deki0r

libsodium-uwp's Issues

Compile error after upgrading to 1.0.131

My solution is failing to compile with the following error after the upgrade.

Payload contains two or more files with the same destination path 'Sodium.winmd'. Source files:
....nuget\packages\libsodium-uwp\1.0.131\runtimes\win10-x64\native\Sodium.winmd
....nuget\packages\libsodium-uwp\1.0.131\lib\uap10.0\Sodium.winmd

Implement Custom RNG rather than patching randombytes_sysrandom.c

libsodium allows for different RNG sources to be used rather than the default ones. Details on how to perform this are available at https://download.libsodium.org/doc/advanced/custom_rng.html.

Implementing the RNG source is pretty trivial, however getting it to properly look and load into the runtime component before sodium_init/library initialization is problematic, as wincrypt.h is not available.

This may involve removing implementing a library level randombytes.c that loads our randombytes_uwp.c rather than libsodiums RANDOMBYTES_DEFAULT_IMPLEMENTATION.

Compiling with ARM or x64 as target

If i change my target platform to ARM or x64 i get this error while compiling my project:

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1692,5): error APPX1101: Die Ladung enthält mehrere Dateien mit dem gleichen Zielpfad "Sodium.winmd". Quelldateien: 1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1692,5): error APPX1101: C:\Users\bo_bi\.nuget\packages\libsodium-uwp\0.1.0-alpha5\runtimes\win10-arm\native\Sodium.winmd 1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1692,5): error APPX1101: C:\Users\bo_bi\.nuget\packages\libsodium-uwp\0.1.0-alpha5\lib\uap10.0\Sodium.winmd

Building with target x86 is no problem.

Nuget package install/uninstall should automatically patch Package.appxmanifest

Installation from nuget requires manually adding the following to Package.appxmanifest. Ideally the nuget package would take care of adding and removing this block. This extension information outlines all the classes exposed by libsodium-uwp.dll. Additionally the output of the build should construct this information based upon Sodium.h.

Presently if this data is not added to Package.appxmanifest builds will error out with a class not found error.

[KDF:Argon2i/Scrypt] on x64 |System.AccessViolationException

I'm getting a System.AccessViolationException raised executing the following in a fresh UWP app, referencing the latest libsodium-uwp nuget (1.0.12) running on x64 platform. The operation executes successfully running on x86. Any ideas? Thanks

var result = Sodium.KDF.Argon2i("test", Sodium.Core.GetRandomBytes(16), new Sodium.PasswordHashOptions { time_cost = 3, memory_cost = 16384 });

Will this run on Raspberry Pi / Windows 10 IoT Core?

In the readme I saw that you need to include Visual C++ Redistributable for Visual Studio 2015 in your project and I'm not sure that is available for Raspberry.

Will this Nuget package work for Raspberry Pi / Windows 10 IoT Core?

PasswordHash - salted hash request

Thanks so much for putting this library together.

My own implementation of the PasswordHash allows generation of an Scrypt hash with the following signature:

byte[] PasswordHash.Hash(byte[] password, byte[] salt)

Would you be able to add an overload to accept a similar signature?

Add pre build task to detect if ADVAPI32.dll or GenRandom function will be included

There needs to be a pre-build task to determine if compilation on ARM should proceed.. If any of the default randombytes implementation are even included GenRtlRandom usually ends up being included, resulting in runtime failures. Unfortunately Visual Studio can't detect this during compile time, resulting in a loss of time.

We can easily implement a pre-build check for this.

Additionally it would be worthwhile to add a post build task to AppVeyor and the project that checks dumpbin /dependents to see if ADVAPI32.dll is listed as a dependent for ARM, and to fail the build if it does.

RANDOMBYTES_DEFAULT_IMPLEMENTATION macro redefinition

RANDOMBYTES_DEFAULT_IMPLEMENTATION #define is currently managed through a Visual Studio pre-processor directive. At runtime the definition gets overwritten by the actual definition in randombytes_default.h.

Ideally there should only be a single preprocessor definition.

At worst this is a compiler warning, but we should clean it up.

Eliminate patching of libsodium

This ties in to #1 . Ideally this library should sit on top of libsodium without any extra patching.

Currently a preprocessor definition is required to avoid #include <wincrypt.h> as it is not available on mobile.

libsodium 1.0.11 compiles and runs fine on desktop, this patch is primarily to provide support so this library runs on mobile devices.

Build against vsc++std:latest C++ toolchain

Multiple warnings are thrown when strict type checking and vsc++std:latest standards are enforced. This issue is to track the ability to make the project compatible with latest standards.

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.