Skip to content

Commit ca53dff

Browse files
committed
Use .NET 9
1 parent 0de51b8 commit ca53dff

13 files changed

+48
-22
lines changed

.editorconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ end_of_line = crlf
9090
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
9191
dotnet_style_prefer_compound_assignment = true:suggestion
9292
dotnet_style_prefer_simplified_interpolation = true:suggestion
93+
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
9394
###############################
9495
# C# Coding Conventions #
9596
###############################
@@ -151,9 +152,13 @@ csharp_preserve_single_line_statements = true
151152
csharp_preserve_single_line_blocks = true
152153
csharp_using_directive_placement = outside_namespace:silent
153154
csharp_prefer_simple_using_statement = true:suggestion
154-
csharp_style_namespace_declarations = block_scoped:silent
155+
csharp_style_namespace_declarations = file_scoped:silent
155156
csharp_style_expression_bodied_lambdas = true:silent
156157
csharp_style_expression_bodied_local_functions = false:silent
158+
csharp_style_prefer_method_group_conversion = true:silent
159+
csharp_style_prefer_top_level_statements = true:silent
160+
csharp_style_prefer_primary_constructors = true:suggestion
161+
csharp_prefer_system_threading_lock = true:suggestion
157162
###############################
158163
# VB Coding Conventions #
159164
###############################

.mega-linter.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ DISABLE:
1313
- COPYPASTE # Comment to enable checks of excessive copy-pastes
1414
- SPELL # Comment to enable checks of spelling mistakes
1515
DISABLE_LINTERS:
16-
- CSHARP_DOTNET_FORMAT # Not compatible with .NET 8 (yet)
17-
- CSHARP_CSHARPIER # Not compatible with .NET 8 (yet)
18-
- CSHARP_ROSLYNATOR # Not compatible with .NET 8 (yet)
16+
- CSHARP_DOTNET_FORMAT # Not compatible with .NET 9 (yet)
17+
- CSHARP_CSHARPIER # Not compatible with .NET 9 (yet)
18+
- CSHARP_ROSLYNATOR # Not compatible with .NET 9 (yet)
19+
- REPOSITORY_TRIVY # Unstable, leading to a lot of build failures
1920
SHOW_ELAPSED_TIME: true
2021
FILEIO_REPORTER: false
2122
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass

Directory.Build.props

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ SPDX-License-Identifier: MIT
1212
<Platforms>AnyCPU</Platforms>
1313

1414
<!-- Use the latest .NET SDK -->
15-
<TargetFrameworks>net8.0</TargetFrameworks>
15+
<TargetFrameworks>net9.0</TargetFrameworks>
1616

1717
<!-- Use the latest C# language standard -->
18-
<LangVersion>12.0</LangVersion>
18+
<LangVersion>13.0</LangVersion>
1919
<ImplicitUsings>enable</ImplicitUsings>
2020

2121
<!-- Be very strict -->
@@ -32,6 +32,10 @@ SPDX-License-Identifier: MIT
3232
<SelfContained>false</SelfContained>
3333
<IsPackable>false</IsPackable>
3434
<IsPublishable>false</IsPublishable>
35+
<!--
36+
See https://github.com/dotnet/roslyn/issues/41640
37+
-->
38+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3539

3640
<!-- Assembly metadata -->
3741
<Product>dotnet-xmss</Product>

UnitTests/SHAKE_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sealed class SHAKE_Tests
1010
[TestMethod]
1111
public void Constructor_InvalidBitSizeThrows()
1212
{
13-
Assert.ThrowsException<ArgumentException>(() => new SHAKE(42, 128));
13+
_ = Assert.ThrowsException<ArgumentException>(() => new SHAKE(42, 128));
1414
}
1515

1616
[TestMethod]

Xmss/CryptographicOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Dorssel.Security.Cryptography;
99

1010
/// <summary>
11-
/// This is a backport of .NET 6.0. Since this library is for .NET Standard 2.0 it uses <see cref="byte"/>[] instead of Span.
11+
/// This is a backport of .NET 9.0. Since this library is for .NET Standard 2.0 it uses <see cref="byte"/>[] instead of Span.
1212
/// <para/>
1313
/// See:
1414
/// <see href="https://github.com/dotnet/runtime/blob/main/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CryptographicOperations.cs"/>

Xmss/IsExternalInit.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
using System.ComponentModel;
66

7+
#pragma warning disable IDE0130 // Namespace does not match folder structure
78
namespace System.Runtime.CompilerServices;
9+
#pragma warning restore IDE0130 // Namespace does not match folder structure
810

911
/// <summary>
1012
/// Fix for using C# 9 feature in netstandard2.0.

Xmss/Wots.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ public byte[] PRF(byte[] KEY, byte[] M)
9999
/// <param name="KEY">key</param>
100100
/// <param name="ADRS">address</param>
101101
/// <returns>HashAlgorithm(toByte(3, toByteLength) || KEY || ADRS)</returns>
102-
public byte[] PRF(byte[] KEY, Address ADRS) => PRF(KEY, ADRS.ToBytes());
102+
public byte[] PRF(byte[] KEY, Address ADRS)
103+
{
104+
return PRF(KEY, ADRS.ToBytes());
105+
}
103106

104107
/// <summary>
105108
/// Pseudo-Random Function
@@ -147,7 +150,7 @@ int[] base_w_with_csum(byte[] X)
147150
for (var i = 0; i < Parameters.n; i++)
148151
{
149152
csum -= basew[2 * i] = X[i] >> 4;
150-
csum -= basew[2 * i + 1] = X[i] & 0xf;
153+
csum -= basew[(2 * i) + 1] = X[i] & 0xf;
151154
}
152155

153156
// Append csum (also in base w)

Xmss/WotsParameters.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Dorssel.Security.Cryptography;
88

99
sealed record WotsParameters
1010
{
11-
private WotsParameters()
11+
WotsParameters()
1212
{
1313
// All currently defined parameter use hexadecimal digits.
1414
w = 16;
@@ -33,15 +33,15 @@ private WotsParameters()
3333
OID = WotsOid.WOTSP_SHA2_256,
3434
n = 32,
3535
len = 67,
36-
HashAlgorithm = () => SHA256.Create(),
36+
HashAlgorithm = SHA256.Create,
3737
toByteLength = 32,
3838
},
3939
new()
4040
{
4141
OID = WotsOid.WOTSP_SHA2_512,
4242
n = 64,
4343
len = 131,
44-
HashAlgorithm = () => SHA512.Create(),
44+
HashAlgorithm = SHA512.Create,
4545
toByteLength = 64,
4646
},
4747
new()
@@ -65,7 +65,7 @@ private WotsParameters()
6565
OID = WotsOid.WOTSP_SHA2_192,
6666
n = 24,
6767
len = 51,
68-
HashAlgorithm = () => SHA256.Create(),
68+
HashAlgorithm = SHA256.Create,
6969
toByteLength = 4,
7070
},
7171
new()

Xmss/Xmss.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ byte[] ltree(byte[][] pk, byte[] SEED, Address ADRS)
143143
for (var i = 0; i < lenPrime / 2; i++)
144144
{
145145
ADRS.tree_index = i;
146-
pk[i] = RAND_HASH(pk[2 * i], pk[2 * i + 1], SEED, ADRS);
146+
pk[i] = RAND_HASH(pk[2 * i], pk[(2 * i) + 1], SEED, ADRS);
147147
}
148148
if (lenPrime % 2 == 1)
149149
{

Xmss/XmssParameters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Dorssel.Security.Cryptography;
66

77
sealed record XmssParameters
88
{
9-
private XmssParameters()
9+
XmssParameters()
1010
{
1111
}
1212

0 commit comments

Comments
 (0)