Skip to content

Commit 909ddbb

Browse files
initial commit
0 parents  commit 909ddbb

21 files changed

+2025
-0
lines changed

.gitignore

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.

HWRand.Net.sln

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35417.141
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "native", "native\native.vcxproj", "{9D45458B-701C-484E-85F7-9C7D7C0EF344}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HWRand.Net", "HWRand.Net\HWRand.Net.csproj", "{831A5A0A-7036-40E9-BCAA-A7111F2369C6}"
9+
ProjectSection(ProjectDependencies) = postProject
10+
{9D45458B-701C-484E-85F7-9C7D7C0EF344} = {9D45458B-701C-484E-85F7-9C7D7C0EF344}
11+
EndProjectSection
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test-CLI-App", "Test-CLI-App\Test-CLI-App.csproj", "{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}"
14+
ProjectSection(ProjectDependencies) = postProject
15+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6} = {831A5A0A-7036-40E9-BCAA-A7111F2369C6}
16+
{9D45458B-701C-484E-85F7-9C7D7C0EF344} = {9D45458B-701C-484E-85F7-9C7D7C0EF344}
17+
EndProjectSection
18+
EndProject
19+
Global
20+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
21+
Debug|Any CPU = Debug|Any CPU
22+
Debug|x64 = Debug|x64
23+
Debug|x86 = Debug|x86
24+
Release|Any CPU = Release|Any CPU
25+
Release|x64 = Release|x64
26+
Release|x86 = Release|x86
27+
EndGlobalSection
28+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Debug|Any CPU.ActiveCfg = Debug|x64
30+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Debug|Any CPU.Build.0 = Debug|x64
31+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Debug|x64.ActiveCfg = Debug|x64
32+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Debug|x64.Build.0 = Debug|x64
33+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Debug|x86.ActiveCfg = Debug|Win32
34+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Debug|x86.Build.0 = Debug|Win32
35+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Release|Any CPU.ActiveCfg = Release|x64
36+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Release|Any CPU.Build.0 = Release|x64
37+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Release|x64.ActiveCfg = Release|x64
38+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Release|x64.Build.0 = Release|x64
39+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Release|x86.ActiveCfg = Release|Win32
40+
{9D45458B-701C-484E-85F7-9C7D7C0EF344}.Release|x86.Build.0 = Release|Win32
41+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Debug|x64.ActiveCfg = Debug|Any CPU
44+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Debug|x64.Build.0 = Debug|Any CPU
45+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Debug|x86.ActiveCfg = Debug|Any CPU
46+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Debug|x86.Build.0 = Debug|Any CPU
47+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Release|x64.ActiveCfg = Release|Any CPU
50+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Release|x64.Build.0 = Release|Any CPU
51+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Release|x86.ActiveCfg = Release|Any CPU
52+
{831A5A0A-7036-40E9-BCAA-A7111F2369C6}.Release|x86.Build.0 = Release|Any CPU
53+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Debug|Any CPU.Build.0 = Debug|Any CPU
55+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Debug|x64.ActiveCfg = Debug|Any CPU
56+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Debug|x64.Build.0 = Debug|Any CPU
57+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Debug|x86.ActiveCfg = Debug|Any CPU
58+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Debug|x86.Build.0 = Debug|Any CPU
59+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Release|Any CPU.ActiveCfg = Release|Any CPU
60+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Release|Any CPU.Build.0 = Release|Any CPU
61+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Release|x64.ActiveCfg = Release|Any CPU
62+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Release|x64.Build.0 = Release|Any CPU
63+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Release|x86.ActiveCfg = Release|Any CPU
64+
{EBCB17F7-5EA3-4F92-BDC1-4D4955652B71}.Release|x86.Build.0 = Release|Any CPU
65+
EndGlobalSection
66+
GlobalSection(SolutionProperties) = preSolution
67+
HideSolutionNode = FALSE
68+
EndGlobalSection
69+
EndGlobal

HWRand.Net/CheckHardwareSupport.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace BSS.Random
5+
{
6+
public static partial class HWRandom
7+
{
8+
/// <summary>
9+
/// Executes the CPUID instruction and checks if RDRAND and RDSEED are implemented.
10+
/// </summary>
11+
/// <remarks><see href="https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html#inpage-nav-5-undefined">Determining Processor Support for RDRAND and RDSEED - Intel.com</see></remarks>
12+
/// <returns>returns <see langword="bool"/> => implemented = true, not present = false</returns>
13+
[DllImport("native.dll", EntryPoint = "HardwareRandomIsPresent")]
14+
public static extern Boolean HardwareRandomIsPresent();
15+
}
16+
}

HWRand.Net/HWRand.Net.csproj

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{831A5A0A-7036-40E9-BCAA-A7111F2369C6}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>HWRand.Net</RootNamespace>
11+
<AssemblyName>HWRand.Net</AssemblyName>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
13+
<LangVersion>12.0</LangVersion>
14+
<Nullable>enable</Nullable>
15+
<FileAlignment>512</FileAlignment>
16+
<Deterministic>true</Deterministic>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
27+
<DocumentationFile>bin\Debug\HWRand.Net.xml</DocumentationFile>
28+
<PlatformTarget>x64</PlatformTarget>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<PlatformTarget>x64</PlatformTarget>
38+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
39+
<DocumentationFile>bin\Release\HWRand.Net.xml</DocumentationFile>
40+
</PropertyGroup>
41+
<ItemGroup>
42+
<Reference Include="System" />
43+
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
44+
<HintPath>..\..\..\7. Nuget Packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
45+
</Reference>
46+
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
47+
<HintPath>..\..\..\7. Nuget Packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
48+
</Reference>
49+
<Reference Include="System.Numerics" />
50+
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
51+
<HintPath>..\..\..\7. Nuget Packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
52+
</Reference>
53+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
54+
<HintPath>..\..\..\7. Nuget Packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
55+
</Reference>
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="CheckHardwareSupport.cs" />
59+
<Compile Include="NextBytes.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<Compile Include="RDRAND.cs" />
62+
<Compile Include="RDSEED.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="app.config" />
66+
<None Include="packages.config" />
67+
</ItemGroup>
68+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
69+
<PropertyGroup>
70+
<PreBuildEvent>copy ..\..\..\x64\Release\native.dll native.dll
71+
</PreBuildEvent>
72+
</PropertyGroup>
73+
<PropertyGroup>
74+
<PostBuildEvent>copy ..\..\..\x64\Release\native.dll ..\..\..\Test-CLI-App\bin\Debug\native.dll
75+
robocopy .\ ..\..\..\Test-CLI-App\bin\Debug\ /xf *.tmp
76+
IF %25ERRORLEVEL%25 GEQ 8 exit 1
77+
exit 0</PostBuildEvent>
78+
</PropertyGroup>
79+
</Project>

0 commit comments

Comments
 (0)