MultiMAC 1.0.2
dotnet add package MultiMAC --version 1.0.2
NuGet\Install-Package MultiMAC -Version 1.0.2
<PackageReference Include="MultiMAC" Version="1.0.2" />
paket add MultiMAC --version 1.0.2
#r "nuget: MultiMAC, 1.0.2"
// Install MultiMAC as a Cake Addin #addin nuget:?package=MultiMAC&version=1.0.2 // Install MultiMAC as a Cake Tool #tool nuget:?package=MultiMAC&version=1.0.2
MultiMAC
Authenticate multiple inputs easily using keyed BLAKE2b in libsodium.
Justification
The standard way of safely computing a MAC for multiple inputs requires worrying about concatenating arrays and converting the length of each array to a fixed number of bytes, such as 4 bytes to represent an integer, consistently in either big- or little-endian, regardless of the endianness of the machine. This is annoying to implement and possibly less efficient than the following approach discussed by Neil Madden, author of API Security in Action.
Installation
NuGet
You can find the NuGet package here.
The easiest way to install this is via the NuGet Package Manager in Visual Studio, as explained here. JetBrains Rider also has a package manager, and instructions can be found here.
Manual
- Install the Sodium.Core NuGet package in Visual Studio.
- Download the latest release.
- Move the downloaded
.dll
file into your Visual Studio project folder. - Click on the
Project
tab andAdd Project Reference...
in Visual Studio. - Go to
Browse
, click theBrowse
button, and select the downloaded.dll
file. - Add
using MultiMAC;
to the top of each code file that will use the library.
Requirements
Note that the libsodium library requires the Visual C++ Redistributable for Visual Studio 2015-2019 to work on Windows. If you want your program to be portable, then you must keep the relevant (x86 or x64) vcruntime140.dll
file in the same folder as your executable on Windows.
Usage
⚠️WARNING: Never use the same key for key1
and key2
.
const TagLength tagLength = TagLength.BLAKE2b256;
// Both keys should be derived using a KDF in practice (e.g. Argon2, HKDF, etc)
byte[] key1 = SodiumCore.GetRandomBytes((int)tagLength);
// The keys must be the same size as the tag length
byte[] key2 = SodiumCore.GetRandomBytes((int)tagLength);
// Gather up the byte arrays to authenticate
byte[] input1 = Encoding.UTF8.GetBytes("Po");
byte[] input2 = Encoding.UTF8.GetBytes("ta");
byte[] input3 = Encoding.UTF8.GetBytes("toes");
byte[] input4 = Encoding.UTF8.GetBytes("Boil 'em, mash 'em, stick 'em in a stew");
// Compute a 256-bit tag
byte[] tag = MultiMac.Compute(key1, key2, tagLength, input1, input2, input3, input4);
// Verify a tag
bool validTag = MultiMac.Verify(tag, key1, key2, input1, input2, input3, input4);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Sodium.Core (>= 1.2.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2 | 309 | 1/18/2022 |