Skip to content

Commit

Permalink
Upgrade C# version up to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sergezhigunov committed Jul 17, 2024
1 parent 59c08b0 commit 6854dbf
Show file tree
Hide file tree
Showing 24 changed files with 334 additions and 377 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Authors>Sergey Zhigunov</Authors>
<Copyright>Copyright © 2016 Sergey Zhigunov</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<VersionPrefix>0.2.1</VersionPrefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class HashAlgorithmBenchmark<T> : IDisposable
protected T HashAlgorithm { get; } = new T();

[Benchmark]
public byte[] HashEmptyData() => HashAlgorithm.ComputeHash(Array.Empty<byte>());
public byte[] HashEmptyData() => HashAlgorithm.ComputeHash([]);

[Benchmark]
public byte[] HashData() => HashAlgorithm.ComputeHash(_data);
Expand Down
12 changes: 3 additions & 9 deletions src/OpenGost.Security.Cryptography/Asn1/AsnValueReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
namespace OpenGost.Security.Cryptography.Asn1;

[SecuritySafeCritical]
internal ref struct AsnValueReader
internal ref struct AsnValueReader(ReadOnlySpan<byte> span, AsnEncodingRules ruleSet)
{
private static readonly byte[] _singleByte = new byte[1];

private ReadOnlySpan<byte> _span;
private readonly AsnEncodingRules _ruleSet;

public AsnValueReader(ReadOnlySpan<byte> span, AsnEncodingRules ruleSet)
{
_span = span;
_ruleSet = ruleSet;
}
private ReadOnlySpan<byte> _span = span;
private readonly AsnEncodingRules _ruleSet = ruleSet;

public readonly bool HasData => !_span.IsEmpty;

Expand Down
12 changes: 3 additions & 9 deletions src/OpenGost.Security.Cryptography/BigIntegerPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

namespace OpenGost.Security.Cryptography;

internal struct BigIntegerPoint
internal struct BigIntegerPoint(in ECPoint point)
{
private static readonly BigInteger _two = 2;
private static readonly BigInteger _three = 3;

public BigInteger X { get; private set; }
public BigInteger X { get; private set; } = CryptoUtils.UnsignedBigIntegerFromLittleEndian(point.X!);

public BigInteger Y { get; private set; }

public BigIntegerPoint(in ECPoint point)
{
X = CryptoUtils.UnsignedBigIntegerFromLittleEndian(point.X!);
Y = CryptoUtils.UnsignedBigIntegerFromLittleEndian(point.Y!);
}
public BigInteger Y { get; private set; } = CryptoUtils.UnsignedBigIntegerFromLittleEndian(point.Y!);

public ECPoint ToECPoint(int size)
{
Expand Down
18 changes: 9 additions & 9 deletions src/OpenGost.Security.Cryptography/CMAC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ public abstract class CMAC : KeyedHashAlgorithm
{
private static readonly IReadOnlyDictionary<int, byte[]> _irreduciblePolynomials = new Dictionary<int, byte[]>
{
[64] = new byte[]
{
[64] =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B
},
[128] = new byte[]
{
],
[128] =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87
},
[256] = new byte[]
{
],
[256] =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x25
},
],
};

private SymmetricAlgorithm _symmetricAlgorithm = null!;
Expand Down
Loading

0 comments on commit 6854dbf

Please sign in to comment.