Add libsodium to the tree and build what's needed from source.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3859 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-03-08 03:42:47 +00:00
parent efc5eb2aff
commit 352f33f5a1
584 changed files with 140249 additions and 2 deletions

View File

@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NoBuild>true</NoBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>
<PropertyGroup>
<PackageId>libsodium</PackageId>
<Version>1.0.18.2</Version>
<Authors>Frank Denis</Authors>
<Description>Internal implementation package not meant for direct consumption. Please do not reference directly.</Description>
<Copyright>&#169; $([System.DateTime]::UtcNow.ToString(yyyy)) Frank Denis</Copyright>
<PackageLicenseExpression>ISC</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://libsodium.org/</PackageProjectUrl>
<RepositoryUrl>https://github.com/jedisct1/libsodium.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<MinClientVersion>4.0</MinClientVersion>
</PropertyGroup>
<ItemGroup>
<Content Include="LICENSE" PackagePath="" />
<Content Include="AUTHORS" PackagePath="" />
<Content Include="ChangeLog" PackagePath="" />
<Content Include="runtimes/win-x64/native/libsodium.dll" PackagePath="runtimes/win-x64/native/" />
<Content Include="runtimes/win-x86/native/libsodium.dll" PackagePath="runtimes/win-x86/native/" />
<Content Include="runtimes/linux-x64/native/libsodium.so" PackagePath="runtimes/linux-x64/native/" />
<Content Include="runtimes/linux-arm64/native/libsodium.so" PackagePath="runtimes/linux-arm64/native/" />
<Content Include="runtimes/linux-arm/native/libsodium.so" PackagePath="runtimes/linux-arm/native/" />
<Content Include="runtimes/linux-musl-x64/native/libsodium.so" PackagePath="runtimes/linux-musl-x64/native/" />
<Content Include="runtimes/osx-x64/native/libsodium.dylib" PackagePath="runtimes/osx-x64/native/" />
<Content Include="runtimes/osx-arm64/native/libsodium.dylib" PackagePath="runtimes/osx-arm64/native/" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,43 @@
using System;
using System.Runtime.InteropServices;
internal static class Program
{
internal static int Main()
{
Console.WriteLine("sodium_version_string: {0}", Marshal.PtrToStringAnsi(sodium_version_string()));
Console.WriteLine("sodium_library_version_major: {0}", sodium_library_version_major());
Console.WriteLine("sodium_library_version_minor: {0}", sodium_library_version_minor());
Console.WriteLine("sodium_library_minimal: {0}", sodium_library_minimal());
int error = sodium_init();
Console.WriteLine("sodium_init: {0}", error);
if (error == 0)
{
randombytes_buf(out ulong buf, (UIntPtr)sizeof(ulong));
Console.WriteLine("randombytes_buf: 0x'{0:X8}'", buf);
Console.WriteLine("crypto_aead_aes256gcm_is_available: {0}", crypto_aead_aes256gcm_is_available());
}
return error == 0 ? 0 : 1;
}
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern int crypto_aead_aes256gcm_is_available();
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern void randombytes_buf(out ulong buf, UIntPtr size);
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern int sodium_init();
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern int sodium_library_version_major();
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern int sodium_library_minimal();
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern int sodium_library_version_minor();
[DllImport("libsodium", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr sodium_version_string();
}