Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Bifrost.Security/Bifrost.Security.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>netstandard20</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageIcon>bifrost-icon.png</PackageIcon>
<RepositoryUrl>https://github.com/Bifrost-Technologies/Bifrost.Security</RepositoryUrl>
Expand Down
13 changes: 7 additions & 6 deletions Bifrost.Security/CryptoBytes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using System;
using System.Runtime.CompilerServices;

namespace Bifrost.Security
{
Expand Down Expand Up @@ -126,7 +127,7 @@ internal static void InternalWipe<T>(ref T data)
// * I didn't use a second loop variable to index into `c`, since measurement shows that calculating it from `i` is cheaper.
// * Using exactly `i < bytes.Length` as upper bound of the loop allows the JITter to eliminate bounds checks on `bytes[i]`, so I chose that variant.
// * Making `b` an int avoids unnecessary conversions from and to byte.
public static string? ToHexStringUpper(byte[] data)
public static string ToHexStringUpper(byte[] data)
{
if (data == null)
return null;
Expand All @@ -144,7 +145,7 @@ internal static void InternalWipe<T>(ref T data)

// Explanation is similar to ToHexStringUpper
// constant 55 -> 87 and -7 -> -39 to compensate for the offset 32 between lowercase and uppercase letters
public static string? ToHexStringLower(byte[] data)
public static string ToHexStringLower(byte[] data)
{
if (data == null)
return null;
Expand All @@ -160,7 +161,7 @@ internal static void InternalWipe<T>(ref T data)
return new string(c);
}

public static byte[]? FromHexString(string hexString)
public static byte[] FromHexString(string hexString)
{
if (hexString == null)
return null;
Expand All @@ -172,14 +173,14 @@ internal static void InternalWipe<T>(ref T data)
return result;
}

public static string? ToBase64String(byte[] data)
public static string ToBase64String(byte[] data)
{
if (data == null)
return null;
return Convert.ToBase64String(data);
}

public static byte[]? FromBase64String(string s)
public static byte[] FromBase64String(string s)
{
if (s == null)
return null;
Expand Down
3 changes: 2 additions & 1 deletion Bifrost.Security/Ed25519.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma warning disable CS8604
using Bifrost.Security.Internal.Ed25519Ref10;
using System;

namespace Bifrost.Security
{
Expand Down Expand Up @@ -144,4 +145,4 @@ public static void KeyExchange(ArraySegment<byte> sharedKey, ArraySegment<byte>
MontgomeryCurve25519.KeyExchangeOutputHashNaCl(sharedKey.Array, sharedKey.Offset);
}
}
}
}
1 change: 1 addition & 0 deletions Bifrost.Security/MontgomeryCurve25519.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Bifrost.Security.Internal;
using Bifrost.Security.Internal.Ed25519Ref10;
using Bifrost.Security.Internal.Salsa;
using System;

namespace Bifrost.Security
{
Expand Down
1 change: 1 addition & 0 deletions Bifrost.Security/Sha512.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bifrost.Security.Internal;
using System;

namespace Bifrost.Security
{
Expand Down
3 changes: 2 additions & 1 deletion Bifrost.Security/XSalsa20Poly1305.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma warning disable CS8604 // Possible null reference argument.
using Bifrost.Security.Internal;
using Bifrost.Security.Internal.Salsa;
using System;

namespace Bifrost.Security
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public static void Encrypt(ArraySegment<byte> ciphertext, ArraySegment<byte> mes
/// Decrypts the ciphertext and verifies its authenticity
/// </summary>
/// <returns>Plaintext if MAC validation succeeds, null if the data is invalid.</returns>
public static byte[]? TryDecrypt(byte[] ciphertext, byte[] key, byte[] nonce)
public static byte[] TryDecrypt(byte[] ciphertext, byte[] key, byte[] nonce)
{
if (ciphertext == null)
throw new ArgumentNullException("ciphertext");
Expand Down