-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial upload of source documents and code.
See Tester program for examples on using the miniLock library, and the sources for how I did it.
- Loading branch information
Unknown
authored and
Unknown
committed
Oct 3, 2014
1 parent
6301488
commit ef6cd7e
Showing
87 changed files
with
64,462 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Originally Written in 2012 by Christian Winnerlein <codesinchaos@gmail.com> | ||
// Rewritten Fall 2014 (for the Blake2s flavor instead of the Blake2b flavor) | ||
// by Dustin Sparks <sparkdustjoe@gmail.com> | ||
|
||
// To the extent possible under law, the author(s) have dedicated all copyright | ||
// and related and neighboring rights to this software to the public domain | ||
// worldwide. This software is distributed without any warranty. | ||
|
||
// You should have received a copy of the CC0 Public Domain Dedication along with | ||
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
/* | ||
Based on BlakeSharp | ||
by Dominik Reichl <dominik.reichl@t-online.de> | ||
Web: http://www.dominik-reichl.de/ | ||
If you're using this class, it would be nice if you'd mention | ||
me somewhere in the documentation of your program, but it's | ||
not required. | ||
BLAKE was designed by Jean-Philippe Aumasson, Luca Henzen, | ||
Willi Meier and Raphael C.-W. Phan. | ||
BlakeSharp was derived from the reference C implementation. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Blake2sCSharp | ||
{ | ||
public static class Blake2S | ||
{ | ||
public static Hasher Create() | ||
{ | ||
return Create(new Blake2sConfig()); | ||
} | ||
|
||
public static Hasher Create(Blake2sConfig config) | ||
{ | ||
return new Blake2sHasher(config); | ||
} | ||
|
||
public static byte[] ComputeHash(byte[] data, int start, int count) | ||
{ | ||
return ComputeHash(data, start, count, null); | ||
} | ||
|
||
public static byte[] ComputeHash(byte[] data) | ||
{ | ||
return ComputeHash(data, 0, data.Length, null); | ||
} | ||
|
||
public static byte[] ComputeHash(byte[] data, Blake2sConfig config) | ||
{ | ||
return ComputeHash(data, 0, data.Length, config); | ||
} | ||
|
||
public static byte[] ComputeHash(byte[] data, int start, int count, Blake2sConfig config) | ||
{ | ||
var hasher = Create(config); | ||
hasher.Update(data, start, count); | ||
return hasher.Finish(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{44819913-3577-4774-9742-1AE3BB008CBA}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Blake2sCSharp</RootNamespace> | ||
<AssemblyName>Blake2sCSharp</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Blake2s.cs" /> | ||
<Compile Include="Config.cs" /> | ||
<Compile Include="Core-Unrolled.cs" /> | ||
<Compile Include="Core.cs" /> | ||
<Compile Include="Hasher.cs" /> | ||
<Compile Include="IvBuilder.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Originally Written in 2012 by Christian Winnerlein <codesinchaos@gmail.com> | ||
// Rewritten Fall 2014 (for the Blake2s flavor instead of the Blake2b flavor) | ||
// by Dustin Sparks <sparkdustjoe@gmail.com> | ||
|
||
|
||
// To the extent possible under law, the author(s) have dedicated all copyright | ||
// and related and neighboring rights to this software to the public domain | ||
// worldwide. This software is distributed without any warranty. | ||
|
||
// You should have received a copy of the CC0 Public Domain Dedication along with | ||
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
/* | ||
Based on BlakeSharp | ||
by Dominik Reichl <dominik.reichl@t-online.de> | ||
Web: http://www.dominik-reichl.de/ | ||
If you're using this class, it would be nice if you'd mention | ||
me somewhere in the documentation of your program, but it's | ||
not required. | ||
BLAKE was designed by Jean-Philippe Aumasson, Luca Henzen, | ||
Willi Meier and Raphael C.-W. Phan. | ||
BlakeSharp was derived from the reference C implementation. | ||
*/ | ||
using System; | ||
|
||
namespace Blake2sCSharp | ||
{ | ||
public sealed class Blake2sConfig : ICloneable | ||
{ | ||
public byte[] Personalization { get; set; } | ||
public byte[] Salt { get; set; } | ||
public byte[] Key { get; set; } | ||
public int OutputSizeInBytes { get; set; } | ||
public int OutputSizeInBits | ||
{ | ||
get { return OutputSizeInBytes * 8; } | ||
set | ||
{ | ||
if (value % 8 == 0) | ||
throw new ArgumentException("Output size must be a multiple of 8 bits"); | ||
OutputSizeInBytes = value / 8; | ||
} | ||
} | ||
|
||
public Blake2sConfig() | ||
{ | ||
OutputSizeInBytes = 32; | ||
} | ||
|
||
public Blake2sConfig Clone() | ||
{ | ||
var result = new Blake2sConfig(); | ||
result.OutputSizeInBytes = OutputSizeInBytes; | ||
if (Key != null) | ||
result.Key = (byte[])Key.Clone(); | ||
if (Personalization != null) | ||
result.Personalization = (byte[])Personalization.Clone(); | ||
if (Salt != null) | ||
result.Salt = (byte[])Salt.Clone(); | ||
return result; | ||
} | ||
|
||
object ICloneable.Clone() | ||
{ | ||
return Clone(); | ||
} | ||
} | ||
} |
Oops, something went wrong.