From 6ca8bb84ee806f9a867ff1ac4b93ecac1d762273 Mon Sep 17 00:00:00 2001
From: Frans van Dorsselaer <17404029+dorssel@users.noreply.github.com>
Date: Sun, 17 Nov 2024 15:15:28 +0100
Subject: [PATCH] Use .NET 9 SDK
---
.editorconfig | 5 ++-
.mega-linter.yml | 6 +--
AesExtra/AesCmac.cs | 17 ++++----
AesExtra/AesCtr.cs | 23 ++++++----
AesExtra/AesCtrTransform.cs | 3 +-
AesExtra/AesExtra.csproj | 4 --
AesExtra/AesSiv.cs | 8 ++--
AesExtra/AssemblySettings.cs | 1 -
AesExtra/CryptographicOperations.cs | 2 +-
Directory.Build.props | 16 +++----
Directory.Packages.props | 5 +--
UnitTests/AesCmac_Tests.cs | 12 +++---
UnitTests/AesCtrTransform_Tests.cs | 42 +++++++++----------
UnitTests/AesCtr_Tests.cs | 8 ++--
UnitTests/AesSiv_Tests.cs | 34 +++++++--------
.../NistAesCmacSampleDataSourceAttribute.cs | 2 +-
UnitTests/NistAesCmacSampleTestVector.cs | 2 +-
.../NistAesCtrSampleDataSourceAttribute.cs | 2 +-
UnitTests/NistAesCtrSampleTestVector.cs | 12 +++---
UnitTests/RfcAesSivTestVector.cs | 2 +-
.../RfcAesSivTestVectorSourceAttribute.cs | 2 +-
UnitTests/UnitTests.csproj | 2 -
global.json | 2 +-
23 files changed, 104 insertions(+), 108 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index f434912..b24d30f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -90,6 +90,7 @@ end_of_line = crlf
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
+dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
###############################
# C# Coding Conventions #
###############################
@@ -151,11 +152,13 @@ csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
-csharp_style_namespace_declarations = block_scoped:silent
+csharp_style_namespace_declarations = file_scoped:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
+csharp_style_prefer_primary_constructors = true:suggestion
+csharp_prefer_system_threading_lock = true:suggestion
###############################
# VB Coding Conventions #
###############################
diff --git a/.mega-linter.yml b/.mega-linter.yml
index 5198c32..1abaf51 100644
--- a/.mega-linter.yml
+++ b/.mega-linter.yml
@@ -13,9 +13,9 @@ DISABLE:
- COPYPASTE # Comment to enable checks of excessive copy-pastes
- SPELL # Comment to enable checks of spelling mistakes
DISABLE_LINTERS:
- - CSHARP_DOTNET_FORMAT # Not compatible with .NET 8 (yet)
- - CSHARP_CSHARPIER # Not compatible with .NET 8 (yet)
- - CSHARP_ROSLYNATOR # Not compatible with .NET 8 (yet)
+ - CSHARP_DOTNET_FORMAT # Not compatible with .NET 9 (yet)
+ - CSHARP_CSHARPIER # Not compatible with .NET 9 (yet)
+ - CSHARP_ROSLYNATOR # Not compatible with .NET 9 (yet)
- REPOSITORY_TRIVY # Unstable, leading to a lot of build failures
SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
diff --git a/AesExtra/AesCmac.cs b/AesExtra/AesCmac.cs
index d52da14..97260f4 100644
--- a/AesExtra/AesCmac.cs
+++ b/AesExtra/AesCmac.cs
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: MIT
-using System;
using System.Security.Cryptography;
namespace Dorssel.Security.Cryptography;
@@ -17,16 +16,16 @@ public sealed class AesCmac
///
/// This static override defaults to .
- public static new KeyedHashAlgorithm Create() => new AesCmac();
+ public static new KeyedHashAlgorithm Create()
+ {
+ return new AesCmac();
+ }
///
public static new KeyedHashAlgorithm? Create(string algorithmName)
{
- if (algorithmName == null)
- {
- throw new ArgumentNullException(nameof(algorithmName));
- }
- return algorithmName == nameof(AesCmac) ? Create() : null;
+ return algorithmName != null ? algorithmName == nameof(AesCmac) ? Create() : null
+ : throw new ArgumentNullException(nameof(algorithmName));
}
///
@@ -100,7 +99,7 @@ public override byte[] Key
// In-place: X = CIPH_K(X)
void CIPH_K_InPlace(byte[] X_Base, int X_Offset = 0)
{
- CryptoTransform.TransformBlock(X_Base, X_Offset, BLOCKSIZE, X_Base, X_Offset);
+ _ = CryptoTransform.TransformBlock(X_Base, X_Offset, BLOCKSIZE, X_Base, X_Offset);
}
// See: NIST SP 800-38B, Section 6.1
@@ -152,7 +151,7 @@ protected override void HashCore(byte[] array, int ibStart, int cbSize)
}
// If we have a non-empty && non-full Partial block already -> append to that first.
- if ((0 < PartialLength) && (PartialLength < BLOCKSIZE))
+ if (PartialLength is > 0 and < BLOCKSIZE)
{
var count = Math.Min(cbSize, BLOCKSIZE - PartialLength);
Array.Copy(array, ibStart, Partial, PartialLength, count);
diff --git a/AesExtra/AesCtr.cs b/AesExtra/AesCtr.cs
index d8984ad..de369f7 100644
--- a/AesExtra/AesCtr.cs
+++ b/AesExtra/AesCtr.cs
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: MIT
-using System;
using System.Security.Cryptography;
namespace Dorssel.Security.Cryptography;
@@ -19,16 +18,16 @@ public sealed class AesCtr
const int FixedFeedbackSize = FixedBlockSize * 8; // bits
///
- public static new Aes Create() => new AesCtr();
+ public static new Aes Create()
+ {
+ return new AesCtr();
+ }
///
public static new Aes? Create(string algorithmName)
{
- if (algorithmName == null)
- {
- throw new ArgumentNullException(nameof(algorithmName));
- }
- return algorithmName == nameof(AesCtr) ? Create() : null;
+ return algorithmName != null ? algorithmName == nameof(AesCtr) ? Create() : null
+ : throw new ArgumentNullException(nameof(algorithmName));
}
AesCtr()
@@ -134,10 +133,16 @@ AesCtrTransform CreateTransform(byte[] rgbKey, byte[]? rgbIV)
}
///
- public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV) => CreateTransform(rgbKey, rgbIV);
+ public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV)
+ {
+ return CreateTransform(rgbKey, rgbIV);
+ }
///
- public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV) => CreateTransform(rgbKey, rgbIV);
+ public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV)
+ {
+ return CreateTransform(rgbKey, rgbIV);
+ }
///
public override void GenerateIV()
diff --git a/AesExtra/AesCtrTransform.cs b/AesExtra/AesCtrTransform.cs
index c9e3aad..6d29d8c 100644
--- a/AesExtra/AesCtrTransform.cs
+++ b/AesExtra/AesCtrTransform.cs
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: MIT
-using System;
using System.Security.Cryptography;
namespace Dorssel.Security.Cryptography;
@@ -128,7 +127,7 @@ int ICryptoTransform.TransformBlock(byte[] inputBuffer, int inputOffset, int inp
for (var i = 0; i < inputCount / BLOCKSIZE; ++i)
{
- TransformBlock(inputBuffer, inputOffset + i * BLOCKSIZE, outputBuffer, outputOffset + i * BLOCKSIZE);
+ TransformBlock(inputBuffer, inputOffset + (i * BLOCKSIZE), outputBuffer, outputOffset + (i * BLOCKSIZE));
}
return inputCount;
}
diff --git a/AesExtra/AesExtra.csproj b/AesExtra/AesExtra.csproj
index d326a77..08f2985 100644
--- a/AesExtra/AesExtra.csproj
+++ b/AesExtra/AesExtra.csproj
@@ -30,8 +30,4 @@ SPDX-License-Identifier: MIT
-
-
-
-
diff --git a/AesExtra/AesSiv.cs b/AesExtra/AesSiv.cs
index 04743eb..2d5889a 100644
--- a/AesExtra/AesSiv.cs
+++ b/AesExtra/AesSiv.cs
@@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Linq;
using System.Security.Cryptography;
namespace Dorssel.Security.Cryptography;
@@ -64,9 +62,9 @@ byte[] S2V(byte[][] associatedData, byte[] plaintext)
// D takes the role of the "end" in "xorend"
D.xor_InPlace(0, plaintext, plaintext.Length - BLOCKSIZE, BLOCKSIZE);
// Using Transform instead of Compute prevents cloning plaintext.
- Cmac.TransformBlock(plaintext, 0, plaintext.Length - BLOCKSIZE, null, 0);
- Cmac.TransformBlock(D, 0, BLOCKSIZE, null, 0);
- Cmac.TransformFinalBlock([], 0, 0);
+ _ = Cmac.TransformBlock(plaintext, 0, plaintext.Length - BLOCKSIZE, null, 0);
+ _ = Cmac.TransformBlock(D, 0, BLOCKSIZE, null, 0);
+ _ = Cmac.TransformFinalBlock([], 0, 0);
return Cmac.Hash;
}
else
diff --git a/AesExtra/AssemblySettings.cs b/AesExtra/AssemblySettings.cs
index 0acb031..f369960 100644
--- a/AesExtra/AssemblySettings.cs
+++ b/AesExtra/AssemblySettings.cs
@@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: MIT
-using System;
using System.Runtime.CompilerServices;
[assembly: CLSCompliant(true)]
diff --git a/AesExtra/CryptographicOperations.cs b/AesExtra/CryptographicOperations.cs
index 635f820..dae58ea 100644
--- a/AesExtra/CryptographicOperations.cs
+++ b/AesExtra/CryptographicOperations.cs
@@ -8,7 +8,7 @@
namespace Dorssel.Security.Cryptography;
///
-/// This is a backport of .NET 6.0. Since this library is for .NET Standard 2.0 it uses [] instead of Span.
+/// This is a backport of .NET 9. Since this library is for .NET Standard 2.0 it uses [] instead of Span.
///
/// See:
///
diff --git a/Directory.Build.props b/Directory.Build.props
index a81f231..c7d7b77 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -12,10 +12,11 @@ SPDX-License-Identifier: MIT
AnyCPU
- net8.0
+ net9.0
- 12.0
+ 13.0
+ enable
9999
@@ -31,6 +32,10 @@ SPDX-License-Identifier: MIT
false
false
$(MSBuildThisFileDirectory)\strongname.snk
+
+ true
dotnet-aes-extra
@@ -40,15 +45,11 @@ SPDX-License-Identifier: MIT
$(Product)
$(Company)
- .NET Standard 2.0 implementation of AES-CTR, AES-CMAC, and AES-SIV.
+ .NET Standard 2.0 implementation of AES-CTR, AES-CMAC, and SIV-AES.
MIT
- https://github.com/dorssel/dotnet-aes-extra
README.md
false
-
-
true
- true
true
snupkg
@@ -60,6 +61,7 @@ SPDX-License-Identifier: MIT
$(GitVersion_MajorMinorPatch)
+ 0.9.99
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 2283df2..72448c6 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -7,15 +7,12 @@ SPDX-License-Identifier: MIT
-
-
-
+
-
\ No newline at end of file
diff --git a/UnitTests/AesCmac_Tests.cs b/UnitTests/AesCmac_Tests.cs
index eaf69ef..4603598 100644
--- a/UnitTests/AesCmac_Tests.cs
+++ b/UnitTests/AesCmac_Tests.cs
@@ -24,7 +24,7 @@ public void Create_Name()
[TestMethod]
public void Create_NullNameFails()
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var keyedHashAlgorithm = AesCmac.Create(null!);
});
@@ -55,7 +55,7 @@ public void Constructor_WithKey(int keySize)
[TestMethod]
public void Constructor_WithInvalidKeySize()
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var aesCmac = new AesCmac(new byte[42]);
});
@@ -64,7 +64,7 @@ public void Constructor_WithInvalidKeySize()
[TestMethod]
public void Constructor_WithNullKey()
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var aesCmac = new AesCmac(null!);
});
@@ -110,7 +110,7 @@ public void ComputeHash_Segmented()
var pos = 0;
void Transfer(int count)
{
- aesCmac.TransformBlock(testVector.PT.ToArray(), pos, count, null, 0);
+ _ = aesCmac.TransformBlock(testVector.PT.ToArray(), pos, count, null, 0);
pos += count;
}
@@ -121,13 +121,13 @@ void Transfer(int count)
// complete the partial block precisely
Transfer(1);
// more than 1 block, but not an exact multiple
- Transfer(2 * 16 - 3);
+ Transfer((2 * 16) - 3);
// topping off the partial block + again less than 1 block
Transfer(16);
// remainder
Transfer(testVector.PT.Length - pos);
- aesCmac.TransformFinalBlock([], 0, 0);
+ _ = aesCmac.TransformFinalBlock([], 0, 0);
CollectionAssert.AreEqual(testVector.Tag.ToArray(), aesCmac.Hash);
}
diff --git a/UnitTests/AesCtrTransform_Tests.cs b/UnitTests/AesCtrTransform_Tests.cs
index 83bcb7d..92fd3a3 100644
--- a/UnitTests/AesCtrTransform_Tests.cs
+++ b/UnitTests/AesCtrTransform_Tests.cs
@@ -37,7 +37,7 @@ public void Constructor()
[DataRow(BLOCKSIZE * 8)]
public void Constructor_InvalidIVSize(int ivSize)
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var transform = new AesCtrTransform(new byte[ivSize], AesEcbTransform);
});
@@ -47,10 +47,10 @@ public void Constructor_InvalidIVSize(int ivSize)
public void Constructor_TransformInvalidInputBlockSize()
{
var mockTransform = new Mock();
- mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE + 1);
- mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE);
+ _ = mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE + 1);
+ _ = mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var transform = new AesCtrTransform(InitialCounter, mockTransform.Object);
});
@@ -60,10 +60,10 @@ public void Constructor_TransformInvalidInputBlockSize()
public void Constructor_TransformInvalidOutputBlockSize()
{
var mockTransform = new Mock();
- mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE);
- mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE + 1);
+ _ = mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE);
+ _ = mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE + 1);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var transform = new AesCtrTransform(InitialCounter, mockTransform.Object);
});
@@ -131,7 +131,7 @@ public void TransformBlock_ValidSize(int size)
[DataRow(BLOCKSIZE + 1)]
public void TransformBlock_InvalidSizeFails(int size)
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using ICryptoTransform transform = new AesCtrTransform(InitialCounter, AesEcbTransform);
_ = transform.TransformBlock(new byte[size], 0, size, new byte[size], 0);
@@ -143,7 +143,7 @@ public void TransformBlock_AfterFinalFails()
{
using ICryptoTransform transform = new AesCtrTransform(InitialCounter, AesEcbTransform);
_ = transform.TransformFinalBlock([], 0, 0);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
_ = transform.TransformBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE, new byte[BLOCKSIZE], 0);
});
@@ -155,7 +155,7 @@ public void TransformBlock_AfterDisposeFails()
ICryptoTransform transform = new AesCtrTransform(InitialCounter, AesEcbTransform);
_ = transform.TransformBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE, new byte[BLOCKSIZE], 0);
transform.Dispose();
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
_ = transform.TransformBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE, new byte[BLOCKSIZE], 0);
});
@@ -165,15 +165,15 @@ public void TransformBlock_AfterDisposeFails()
public void TransformBlock_TransformInvalidReturn()
{
var mockTransform = new Mock();
- mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE);
- mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE);
- mockTransform.SetupSequence(m => m.TransformBlock(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ _ = mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE);
+ _ = mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE);
+ _ = mockTransform.SetupSequence(m => m.TransformBlock(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
.Returns(BLOCKSIZE)
.Returns(BLOCKSIZE + 1);
using ICryptoTransform transform = new AesCtrTransform(InitialCounter, mockTransform.Object);
_ = transform.TransformBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE, new byte[BLOCKSIZE], 0);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
_ = transform.TransformBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE, new byte[BLOCKSIZE], 0);
});
@@ -196,7 +196,7 @@ public void TransformFinalBlock_ValidSize(int size)
[DataRow(2 * BLOCKSIZE)]
public void TransformFinalBlock_InvalidSizeFails(int size)
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using ICryptoTransform transform = new AesCtrTransform(InitialCounter, AesEcbTransform);
_ = transform.TransformFinalBlock(new byte[size], 0, size);
@@ -208,7 +208,7 @@ public void TransformFinalBlock_AfterFinalFails()
{
using ICryptoTransform transform = new AesCtrTransform(InitialCounter, AesEcbTransform);
_ = transform.TransformFinalBlock([], 0, 0);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
_ = transform.TransformFinalBlock([], 0, 0);
});
@@ -220,7 +220,7 @@ public void TransformFinalBlock_AfterDisposeFails()
ICryptoTransform transform = new AesCtrTransform(InitialCounter, AesEcbTransform);
_ = transform.TransformBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE, new byte[BLOCKSIZE], 0);
transform.Dispose();
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
_ = transform.TransformFinalBlock([], 0, 0);
});
@@ -230,12 +230,12 @@ public void TransformFinalBlock_AfterDisposeFails()
public void TransformFinalBlock_TransformInvalidReturn()
{
var mockTransform = new Mock();
- mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE);
- mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE);
- mockTransform.Setup(m => m.TransformFinalBlock(It.IsAny(), It.IsAny(), It.IsAny())).Returns(new byte[BLOCKSIZE + 1]);
+ _ = mockTransform.SetupGet(m => m.InputBlockSize).Returns(BLOCKSIZE);
+ _ = mockTransform.SetupGet(m => m.OutputBlockSize).Returns(BLOCKSIZE);
+ _ = mockTransform.Setup(m => m.TransformFinalBlock(It.IsAny(), It.IsAny(), It.IsAny())).Returns(new byte[BLOCKSIZE + 1]);
using ICryptoTransform transform = new AesCtrTransform(InitialCounter, mockTransform.Object);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
_ = transform.TransformFinalBlock(new byte[BLOCKSIZE], 0, BLOCKSIZE);
});
diff --git a/UnitTests/AesCtr_Tests.cs b/UnitTests/AesCtr_Tests.cs
index 6327cb2..faedf6d 100644
--- a/UnitTests/AesCtr_Tests.cs
+++ b/UnitTests/AesCtr_Tests.cs
@@ -24,7 +24,7 @@ public void Create_Name()
[TestMethod]
public void Create_NullNameFails()
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var aes = AesCtr.Create(null!);
});
@@ -66,7 +66,7 @@ public void Mode_CannotChange()
{
using var aes = AesCtr.Create();
Assert.AreEqual(CipherMode.ECB, aes.Mode); // DevSkim: ignore DS187371
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aes.Mode = CipherMode.CBC;
});
@@ -88,7 +88,7 @@ public void Padding_CannotChange()
using var aes = AesCtr.Create();
var padding = aes.Padding;
Assert.AreEqual(PaddingMode.None, padding);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aes.Padding = PaddingMode.PKCS7;
});
@@ -109,7 +109,7 @@ public void FeedbackSize_CannotChange()
{
using var aes = AesCtr.Create();
Assert.AreEqual(aes.BlockSize, aes.FeedbackSize);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aes.FeedbackSize = 8;
});
diff --git a/UnitTests/AesSiv_Tests.cs b/UnitTests/AesSiv_Tests.cs
index c36b348..b674a61 100644
--- a/UnitTests/AesSiv_Tests.cs
+++ b/UnitTests/AesSiv_Tests.cs
@@ -23,7 +23,7 @@ public void Constructor_WithKey(int keySize)
[TestMethod]
public void Constructor_WithInvalidKeySize()
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var aesSiv = new AesSiv(new byte[42]);
});
@@ -32,7 +32,7 @@ public void Constructor_WithInvalidKeySize()
[TestMethod]
public void Constructor_WithNullKey()
{
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var aesSiv = new AesSiv(null!);
});
@@ -57,7 +57,7 @@ public void Dispose_Double()
public void Encrypt_NullPlaintextThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Encrypt(null!, TestCiphertext);
});
@@ -67,7 +67,7 @@ public void Encrypt_NullPlaintextThrows()
public void Encrypt_NullCiphertextThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Encrypt(TestPlaintext, null!);
});
@@ -77,7 +77,7 @@ public void Encrypt_NullCiphertextThrows()
public void Encrypt_NullAssociatedDataThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Encrypt(TestPlaintext, TestCiphertext, null!);
});
@@ -87,7 +87,7 @@ public void Encrypt_NullAssociatedDataThrows()
public void Encrypt_NullAssociatedDataItemThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Encrypt(TestPlaintext, TestCiphertext, [null!]);
});
@@ -97,7 +97,7 @@ public void Encrypt_NullAssociatedDataItemThrows()
public void Encrypt_InvalidCiphertextLengthThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Encrypt(TestPlaintext, new byte[TestCiphertext.Length + 1]);
});
@@ -118,7 +118,7 @@ public void Encrypt_TooManyAssociatedDataThrows()
var associatedData = Enumerable.Range(1, 127).Select(i => Array.Empty()).ToArray();
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Encrypt(TestPlaintext, new byte[TestCiphertext.Length], associatedData);
});
@@ -128,7 +128,7 @@ public void Encrypt_TooManyAssociatedDataThrows()
public void Decrypt_NullCiphertextThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(null!, TestPlaintext);
});
@@ -138,7 +138,7 @@ public void Decrypt_NullCiphertextThrows()
public void Decrypt_NullPlaintextThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(TestCiphertext, null!);
});
@@ -148,7 +148,7 @@ public void Decrypt_NullPlaintextThrows()
public void Decrypt_NullAssociatedDataThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(TestCiphertext, TestPlaintext, null!);
});
@@ -158,7 +158,7 @@ public void Decrypt_NullAssociatedDataThrows()
public void Decrypt_NullAssociatedDataItemThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(TestCiphertext, TestPlaintext, [null!]);
});
@@ -168,7 +168,7 @@ public void Decrypt_NullAssociatedDataItemThrows()
public void Decrypt_InvalidCiphertextLengthThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(new byte[15], TestPlaintext);
});
@@ -178,7 +178,7 @@ public void Decrypt_InvalidCiphertextLengthThrows()
public void Decrypt_InvalidPlaintextLengthThrows()
{
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(TestCiphertext, new byte[TestPlaintext.Length + 1]);
});
@@ -201,7 +201,7 @@ public void Decrypt_TooManyAssociatedDataThrows()
var associatedData = Enumerable.Range(1, 127).Select(i => Array.Empty()).ToArray();
using var aesSiv = new AesSiv(TestKey);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(TestCiphertext, new byte[TestPlaintext.Length], associatedData);
});
@@ -212,7 +212,7 @@ public void Decrypt_InvalidAuthenticationThrows()
{
using var aesSiv = new AesSiv(TestKey);
aesSiv.Encrypt(TestPlaintext, TestCiphertext, [1]);
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
aesSiv.Decrypt(TestCiphertext, TestPlaintext, [2]);
});
@@ -231,7 +231,7 @@ public void EmptyPlaintext()
using var aesSiv = new AesSiv(TestKey);
aesSiv.Decrypt(cipherText, []);
}
- Assert.ThrowsException(() =>
+ _ = Assert.ThrowsException(() =>
{
using var aesSiv = new AesSiv(TestKey);
aesSiv.Decrypt(cipherText, [], [2]);
diff --git a/UnitTests/NistAesCmacSampleDataSourceAttribute.cs b/UnitTests/NistAesCmacSampleDataSourceAttribute.cs
index 0c34827..ce74e86 100644
--- a/UnitTests/NistAesCmacSampleDataSourceAttribute.cs
+++ b/UnitTests/NistAesCmacSampleDataSourceAttribute.cs
@@ -7,7 +7,7 @@
namespace UnitTests;
[AttributeUsage(AttributeTargets.Method)]
-internal sealed class NistAesCmacSampleDataSourceAttribute
+sealed class NistAesCmacSampleDataSourceAttribute
: Attribute
, ITestDataSource
{
diff --git a/UnitTests/NistAesCmacSampleTestVector.cs b/UnitTests/NistAesCmacSampleTestVector.cs
index b900c4c..2ad08ed 100644
--- a/UnitTests/NistAesCmacSampleTestVector.cs
+++ b/UnitTests/NistAesCmacSampleTestVector.cs
@@ -8,7 +8,7 @@
namespace UnitTests;
-public partial record NistAesCmacSampleTestVector
+sealed partial record NistAesCmacSampleTestVector
{
public static IReadOnlyList All { get; }
diff --git a/UnitTests/NistAesCtrSampleDataSourceAttribute.cs b/UnitTests/NistAesCtrSampleDataSourceAttribute.cs
index 9705ffa..d00f73a 100644
--- a/UnitTests/NistAesCtrSampleDataSourceAttribute.cs
+++ b/UnitTests/NistAesCtrSampleDataSourceAttribute.cs
@@ -7,7 +7,7 @@
namespace UnitTests;
[AttributeUsage(AttributeTargets.Method)]
-internal sealed class NistAesCtrSampleDataSourceAttribute
+sealed class NistAesCtrSampleDataSourceAttribute
: Attribute
, ITestDataSource
{
diff --git a/UnitTests/NistAesCtrSampleTestVector.cs b/UnitTests/NistAesCtrSampleTestVector.cs
index 0fd0b66..f137525 100644
--- a/UnitTests/NistAesCtrSampleTestVector.cs
+++ b/UnitTests/NistAesCtrSampleTestVector.cs
@@ -9,7 +9,7 @@
namespace UnitTests;
-public partial record NistAesCtrSampleTestVector
+sealed partial record NistAesCtrSampleTestVector
{
public static IReadOnlyList All { get; }
@@ -20,7 +20,7 @@ public partial record NistAesCtrSampleTestVector
public ReadOnlyMemory Plaintext { get; }
public ReadOnlyMemory Ciphertext { get; }
- private static readonly char[] lineSeparators = ['\r', '\n'];
+ static readonly char[] lineSeparators = ['\r', '\n'];
NistAesCtrSampleTestVector(string Section, string Name, string Data)
{
@@ -40,19 +40,19 @@ public partial record NistAesCtrSampleTestVector
var hex = match.Groups[1].Value;
if (line.StartsWith("Key") || line == hex)
{
- keyHex.Append(hex);
+ _ = keyHex.Append(hex);
}
else if (line.StartsWith("Init. Counter"))
{
- initialCounterHex.Append(hex);
+ _ = initialCounterHex.Append(hex);
}
else if (line.StartsWith("Plaintext"))
{
- plaintextHex.Append(hex);
+ _ = plaintextHex.Append(hex);
}
else if (line.StartsWith("Ciphertext"))
{
- ciphertextHex.Append(hex);
+ _ = ciphertextHex.Append(hex);
}
}
}
diff --git a/UnitTests/RfcAesSivTestVector.cs b/UnitTests/RfcAesSivTestVector.cs
index cf10d03..312238b 100644
--- a/UnitTests/RfcAesSivTestVector.cs
+++ b/UnitTests/RfcAesSivTestVector.cs
@@ -9,7 +9,7 @@
namespace UnitTests;
-public partial record RfcAesSivTestVector
+sealed partial record RfcAesSivTestVector
{
public static IReadOnlyList All { get; }
diff --git a/UnitTests/RfcAesSivTestVectorSourceAttribute.cs b/UnitTests/RfcAesSivTestVectorSourceAttribute.cs
index 0edf787..ce9094d 100644
--- a/UnitTests/RfcAesSivTestVectorSourceAttribute.cs
+++ b/UnitTests/RfcAesSivTestVectorSourceAttribute.cs
@@ -7,7 +7,7 @@
namespace UnitTests;
[AttributeUsage(AttributeTargets.Method)]
-internal sealed class RfcAesSivTestVectorSourceAttribute
+sealed class RfcAesSivTestVectorSourceAttribute
: Attribute
, ITestDataSource
{
diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj
index 9bf538f..d54565a 100644
--- a/UnitTests/UnitTests.csproj
+++ b/UnitTests/UnitTests.csproj
@@ -7,7 +7,6 @@ SPDX-License-Identifier: MIT
- enable
True
True
@@ -17,7 +16,6 @@ SPDX-License-Identifier: MIT
-
diff --git a/global.json b/global.json
index 35221c5..db8627a 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.403",
+ "version": "9.0.100",
"allowPrerelease": false,
"rollForward": "latestFeature"
}