Skip to content

Commit

Permalink
Only .NET 8 release from now on
Browse files Browse the repository at this point in the history
Drop support for .NET Standard and .NET 6
  • Loading branch information
mcraiha committed Dec 6, 2024
1 parent f3dbfe1 commit 0dbd8a0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGE-LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 1.1.0 (released 2024-12-06)
- Drop support for .NET Standard and .NET 6 (**BREAKING**)
- SIMD support for XOR operation (**PERFORMANCE**)

## Version 1.0.1 (released 2023-11-16)
- Include nuget-readme
- Support net8.0
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CSharp-ChaCha20-NetStandard

Managed .Net (Standard 2.0, .NET 6 and .NET 8) compatible [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant) cipher written in C#
Managed .Net (.NET 8) compatible [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant) cipher written in C#

## Build status
![.NET](https://github.com/mcraiha/CSharp-ChaCha20-NetStandard/workflows/.NET/badge.svg)
Expand All @@ -14,6 +14,10 @@ Because I needed this for my personal project

**Scott Bennett** wrote C# implementation called [ChaCha20-csharp](https://github.com/sbennett1990/ChaCha20-csharp), which works as base for my code. That is why the license is same for both projects

## Older versions

YOu can find OLD .NET Standard and .NET 6 compatible version from [older branch](https://github.com/mcraiha/CSharp-ChaCha20-NetStandard/tree/netstandard20andnet6)

## Documentation

[Docs](https://mcraiha.github.io/CSharp-ChaCha20-NetStandard/api/index.html)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CSharp-ChaCha20-NetStandard
Managed .Net Standard 2.0 compatible [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant) cipher written in C#
Managed .Net (.NET 8) compatible [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant) cipher written in C#

## GitHub
[CSharp-ChaCha20-NetStandard](https://github.com/mcraiha/CSharp-ChaCha20-NetStandard)
Expand Down
2 changes: 1 addition & 1 deletion nuget-readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CSharp-ChaCha20-NetStandard

Managed .Net (Standard 2.0, .NET 6 and .NET 8) compatible [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant) cipher written in C#
Managed .Net (.NET 8) compatible [ChaCha20](https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant) cipher written in C#

## Documentation

Expand Down
12 changes: 1 addition & 11 deletions src/CSChaCha20.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Intrinsics;
using System.Runtime.CompilerServices; // For MethodImplOptions.AggressiveInlining
Expand Down Expand Up @@ -108,8 +107,6 @@ public ChaCha20(byte[] key, byte[] nonce, uint counter)
this.IvSetup(nonce, counter);
}

#if NET6_0_OR_GREATER

/// <summary>
/// Set up a new ChaCha20 state. The lengths of the given parameters are checked before encryption happens.
/// </summary>
Expand All @@ -118,15 +115,13 @@ public ChaCha20(byte[] key, byte[] nonce, uint counter)
/// </remarks>
/// <param name="key">A 32-byte (256-bit) key, treated as a concatenation of eight 32-bit little-endian integers</param>
/// <param name="nonce">A 12-byte (96-bit) nonce, treated as a concatenation of three 32-bit little-endian integers</param>
/// <param name="counter">A 4-byte (32-bit) block counter, treated as a 32-bit little-endian integer</param>
/// <param name="counter">A 4-byte (32-bit) block counter, treated as a 32-bit little-endian unsigned integer</param>
public ChaCha20(ReadOnlySpan<byte> key, ReadOnlySpan<byte> nonce, uint counter)
{
this.KeySetup(key.ToArray());
this.IvSetup(nonce.ToArray(), counter);
}

#endif // NET6_0_OR_GREATER

/// <summary>
/// The ChaCha20 state (aka "context"). Read-Only.
/// </summary>
Expand All @@ -141,13 +136,8 @@ public uint[] State

// These are the same constants defined in the reference implementation.
// http://cr.yp.to/streamciphers/timings/estreambench/submissions/salsa20/chacha8/ref/chacha.c
#if NET8_0_OR_GREATER
private static readonly byte[] sigma = "expand 32-byte k"u8.ToArray();
private static readonly byte[] tau = "expand 16-byte k"u8.ToArray();
#else
private static readonly byte[] sigma = Encoding.ASCII.GetBytes("expand 32-byte k");
private static readonly byte[] tau = Encoding.ASCII.GetBytes("expand 16-byte k");
#endif // NET8_0_OR_GREATER

/// <summary>
/// Set up the ChaCha state with the given key. A 32-byte key is required and enforced.
Expand Down
9 changes: 6 additions & 3 deletions src/ChaCha20-NetStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<PackageId>LibChaCha20</PackageId>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<Authors>Kaarlo Räihä</Authors>
<Description>Managed C# .NET (Standard 2.0, .NET 6 and .NET 8) library for ChaCha20 encrypting and decrypting</Description>
<Description>Managed C# .NET (.NET 8) library for ChaCha20 encrypting and decrypting</Description>
<IncludeSource>true</IncludeSource>
<PackageProjectUrl>https://github.com/mcraiha/CSharp-ChaCha20-NetStandard</PackageProjectUrl>
<RepositoryUrl>https://github.com/mcraiha/CSharp-ChaCha20-NetStandard.git</RepositoryUrl>
Expand All @@ -23,7 +23,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down
4 changes: 0 additions & 4 deletions tests/ChaCha20Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,6 @@ public void StateReadPossibleTest()
Assert.AreEqual(16, forEncrypting1.State.Length, "Valid state lenght should always be 16 bytes");
}

#if NET6_0_OR_GREATER

[Test, Description("Check that ReadOnlySpan constructor works as it should")]
public void ReadOnlySpanConstructorTest()
{
Expand All @@ -590,7 +588,5 @@ public void ReadOnlySpanConstructorTest()
CollectionAssert.AreEqual(cRegular1.State, cRreadOnlySpan1.State);
CollectionAssert.AreEqual(cRegular2.State, cRreadOnlySpan2.State);
}

#endif // NET6_0_OR_GREATER
}
}

0 comments on commit 0dbd8a0

Please sign in to comment.