diff --git a/Directory.Build.props b/Directory.Build.props index 3d2858d..c44884d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ Sergey Zhigunov Copyright © 2016 Sergey Zhigunov en-US - 11.0 + 12.0 enable enable 0.2.1 diff --git a/benchmarks/OpenGost.Security.Cryptography.Benchmarks/HashAlgorithmBenchmark.cs b/benchmarks/OpenGost.Security.Cryptography.Benchmarks/HashAlgorithmBenchmark.cs index 3d3898b..779441e 100644 --- a/benchmarks/OpenGost.Security.Cryptography.Benchmarks/HashAlgorithmBenchmark.cs +++ b/benchmarks/OpenGost.Security.Cryptography.Benchmarks/HashAlgorithmBenchmark.cs @@ -14,7 +14,7 @@ public abstract class HashAlgorithmBenchmark : IDisposable protected T HashAlgorithm { get; } = new T(); [Benchmark] - public byte[] HashEmptyData() => HashAlgorithm.ComputeHash(Array.Empty()); + public byte[] HashEmptyData() => HashAlgorithm.ComputeHash([]); [Benchmark] public byte[] HashData() => HashAlgorithm.ComputeHash(_data); diff --git a/src/OpenGost.Security.Cryptography/Asn1/AsnValueReader.cs b/src/OpenGost.Security.Cryptography/Asn1/AsnValueReader.cs index 6e831b5..fad8793 100644 --- a/src/OpenGost.Security.Cryptography/Asn1/AsnValueReader.cs +++ b/src/OpenGost.Security.Cryptography/Asn1/AsnValueReader.cs @@ -4,18 +4,12 @@ namespace OpenGost.Security.Cryptography.Asn1; [SecuritySafeCritical] -internal ref struct AsnValueReader +internal ref struct AsnValueReader(ReadOnlySpan span, AsnEncodingRules ruleSet) { private static readonly byte[] _singleByte = new byte[1]; - private ReadOnlySpan _span; - private readonly AsnEncodingRules _ruleSet; - - public AsnValueReader(ReadOnlySpan span, AsnEncodingRules ruleSet) - { - _span = span; - _ruleSet = ruleSet; - } + private ReadOnlySpan _span = span; + private readonly AsnEncodingRules _ruleSet = ruleSet; public readonly bool HasData => !_span.IsEmpty; diff --git a/src/OpenGost.Security.Cryptography/BigIntegerPoint.cs b/src/OpenGost.Security.Cryptography/BigIntegerPoint.cs index e5bedea..2641261 100644 --- a/src/OpenGost.Security.Cryptography/BigIntegerPoint.cs +++ b/src/OpenGost.Security.Cryptography/BigIntegerPoint.cs @@ -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) { diff --git a/src/OpenGost.Security.Cryptography/CMAC.cs b/src/OpenGost.Security.Cryptography/CMAC.cs index 5adb8ff..d8ab1b1 100644 --- a/src/OpenGost.Security.Cryptography/CMAC.cs +++ b/src/OpenGost.Security.Cryptography/CMAC.cs @@ -12,19 +12,19 @@ public abstract class CMAC : KeyedHashAlgorithm { private static readonly IReadOnlyDictionary _irreduciblePolynomials = new Dictionary { - [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!; diff --git a/src/OpenGost.Security.Cryptography/ECCurveOidMap.cs b/src/OpenGost.Security.Cryptography/ECCurveOidMap.cs index 6eb4799..c3da0dd 100644 --- a/src/OpenGost.Security.Cryptography/ECCurveOidMap.cs +++ b/src/OpenGost.Security.Cryptography/ECCurveOidMap.cs @@ -7,411 +7,411 @@ internal static class ECCurveOidMap private static ECCurve ECCurve256ParamsetTest { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x31, 0x04, 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, 0x80, - }, - A = new byte[] - { + ], + A = + [ 0x07, - }, - B = new byte[] - { + ], + B = + [ 0x7e, 0x3b, 0xe2, 0xda, 0xe9, 0x0c, 0x4c, 0x51, 0x2a, 0xfc, 0x72, 0x34, 0x6a, 0x6e, 0x3f, 0x56, 0x40, 0xef, 0xaf, 0xfb, 0x22, 0xe0, 0xb8, 0x39, 0xe7, 0x8c, 0x93, 0xaa, 0x98, 0xf4, 0xbf, 0x5f, - }, - Order = new byte[] - { + ], + Order = + [ 0xb3, 0xf5, 0xcc, 0x3a, 0x19, 0xfc, 0x9c, 0xc5, 0x54, 0x61, 0x97, 0x92, 0x18, 0x8a, 0xfe, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x02, - }, - Y = new byte[] - { + ], + Y = + [ 0xc8, 0x8f, 0x7e, 0xea, 0xbc, 0xab, 0x96, 0x2b, 0x12, 0x67, 0xa2, 0x9c, 0x0a, 0x7f, 0xc9, 0x85, 0x9c, 0xd1, 0x16, 0x0e, 0x03, 0x16, 0x63, 0xbd, 0xd4, 0x47, 0x51, 0xe6, 0xa0, 0xa8, 0xe2, 0x08, - }, + ], }, }; private static ECCurve ECCurve256ParamsetA { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x97, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - A = new byte[] - { + ], + A = + [ 0x35, 0x73, 0x7e, 0x27, 0x6f, 0x65, 0x2c, 0xb2, 0x33, 0xaa, 0x95, 0xbf, 0x13, 0x20, 0x5e, 0xe2, 0x7c, 0xa2, 0x35, 0x30, 0xc2, 0x92, 0x48, 0xaf, 0x73, 0x16, 0x98, 0x13, 0x15, 0x3f, 0x17, 0xc2, - }, - B = new byte[] - { + ], + B = + [ 0x13, 0x95, 0xae, 0xf8, 0xa6, 0x37, 0x93, 0xba, 0xf7, 0x7b, 0xe1, 0x08, 0x91, 0xcd, 0xfc, 0x22, 0x1a, 0xd4, 0xa9, 0x59, 0xc3, 0xe7, 0x20, 0xcc, 0x9c, 0xed, 0x28, 0x74, 0xae, 0x9b, 0x5f, 0x29, - }, - Order = new byte[] - { + ], + Order = + [ 0x9c, 0x31, 0xd8, 0xb0, 0x55, 0xbd, 0x56, 0x04, 0xd7, 0x98, 0xed, 0x21, 0x7f, 0x37, 0x63, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x04, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x28, 0xaa, 0x2d, 0x74, 0xfe, 0x82, 0x25, 0x8b, 0xc7, 0x02, 0x2e, 0x93, 0x96, 0x91, 0x8b, 0x65, 0xbb, 0xb2, 0x12, 0x57, 0x42, 0x23, 0x09, 0x88, 0x0d, 0x2c, 0xe8, 0xa5, 0x43, 0x84, 0xe3, 0x91, - }, - Y = new byte[] - { + ], + Y = + [ 0x5c, 0x2e, 0x32, 0x32, 0xdb, 0x8a, 0x26, 0xaf, 0x40, 0x67, 0x76, 0x44, 0x53, 0x0b, 0xde, 0x5f, 0x56, 0xe9, 0x46, 0xbb, 0xc4, 0x86, 0x57, 0x89, 0x75, 0x03, 0x1a, 0xab, 0x23, 0x94, 0x87, 0x32, - }, + ], }, }; private static ECCurve ECCurve256ParamsetB { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x97, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - A = new byte[] - { + ], + A = + [ 0x94, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - B = new byte[] - { + ], + B = + [ 0xa6, - }, - Order = new byte[] - { + ], + Order = + [ 0x93, 0xb8, 0x61, 0xb7, 0x09, 0x1b, 0x84, 0x45, 0x00, 0xd1, 0x5a, 0x99, 0x70, 0x10, 0x61, 0x6c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x01, - }, - Y = new byte[] - { + ], + Y = + [ 0x14, 0x1e, 0x9f, 0x9e, 0x9c, 0xc9, 0xac, 0x22, 0xb1, 0xe3, 0x23, 0xdf, 0x2d, 0x4f, 0x29, 0x35, 0x76, 0x2b, 0x3f, 0x45, 0x5a, 0x50, 0xdf, 0x27, 0xda, 0x9c, 0x98, 0xe0, 0x71, 0xe4, 0x91, 0x8d, - }, + ], }, }; private static ECCurve ECCurve256ParamsetC { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x99, 0x0c, 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, 0x80, - }, - A = new byte[] - { + ], + A = + [ 0x96, 0x0c, 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, 0x80, - }, - B = new byte[] - { + ], + B = + [ 0x8b, 0xbc, 0x1b, 0x7e, 0xce, 0xd4, 0x49, 0x2f, 0x18, 0x2b, 0xff, 0x73, 0x93, 0x25, 0x79, 0xe9, 0x0a, 0xf8, 0x3d, 0x5c, 0xc2, 0xd3, 0xa7, 0x66, 0xf8, 0xa5, 0x69, 0xa2, 0x19, 0xf4, 0x1a, 0x3e, - }, - Order = new byte[] - { + ], + Order = + [ 0x8f, 0x19, 0x8a, 0xcc, 0x1b, 0x16, 0x97, 0xe4, 0xe5, 0x24, 0xa6, 0xf1, 0xff, 0x0c, 0x70, 0x5f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x01, - }, - Y = new byte[] - { + ], + Y = + [ 0xfc, 0x7e, 0x71, 0x17, 0xd7, 0xf8, 0x4b, 0x74, 0xfb, 0xec, 0x03, 0x8d, 0x85, 0xc9, 0x45, 0xc5, 0xe5, 0x70, 0xc0, 0xb2, 0x3e, 0x1c, 0x3d, 0xb8, 0x80, 0x66, 0xf9, 0x59, 0x43, 0x12, 0xa8, 0x3f, - }, + ], }, }; private static ECCurve ECCurve256ParamsetD { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x9b, 0x75, 0x2d, 0x02, 0xb9, 0xf7, 0x98, 0x79, 0xd3, 0x51, 0x90, 0x78, 0x86, 0x6e, 0x84, 0xcf, 0xaa, 0xc8, 0x41, 0x6b, 0x5e, 0xc8, 0x1e, 0xab, 0x07, 0x81, 0x85, 0x5a, 0x5f, 0x60, 0x9f, 0x9b, - }, - A = new byte[] - { + ], + A = + [ 0x98, 0x75, 0x2d, 0x02, 0xb9, 0xf7, 0x98, 0x79, 0xd3, 0x51, 0x90, 0x78, 0x86, 0x6e, 0x84, 0xcf, 0xaa, 0xc8, 0x41, 0x6b, 0x5e, 0xc8, 0x1e, 0xab, 0x07, 0x81, 0x85, 0x5a, 0x5f, 0x60, 0x9f, 0x9b, - }, - B = new byte[] - { + ], + B = + [ 0x5a, 0x80, - }, - Order = new byte[] - { + ], + Order = + [ 0xb9, 0x0b, 0x98, 0x98, 0x65, 0x3a, 0x2f, 0xf0, 0x74, 0xfb, 0xdd, 0x1e, 0x51, 0xa3, 0x2c, 0x58, 0xaa, 0xc8, 0x41, 0x6b, 0x5e, 0xc8, 0x1e, 0xab, 0x07, 0x81, 0x85, 0x5a, 0x5f, 0x60, 0x9f, 0x9b, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x00, - }, - Y = new byte[] - { + ], + Y = + [ 0x67, 0xbb, 0xb3, 0xfd, 0x0d, 0x55, 0x6e, 0x36, 0x8f, 0x1a, 0x64, 0xd4, 0x40, 0xc4, 0x4d, 0x4d, 0xee, 0xc0, 0x08, 0xcd, 0x83, 0x37, 0xbf, 0x3c, 0x8c, 0x1a, 0x71, 0x43, 0x57, 0xe5, 0xec, 0x41, - }, + ], }, }; private static ECCurve ECCurve512ParamsetTest { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x73, 0x63, 0xbe, 0x28, 0xf5, 0xbb, 0x64, 0x16, 0xd8, 0x4d, 0x22, 0xac, 0x6f, 0x33, 0xb8, 0x35, 0x6d, 0x54, 0xe4, 0x80, 0x7e, 0x04, 0x58, 0x04, 0x4a, 0x70, 0xf4, 0x1a, 0x74, 0x52, 0xd8, 0xf1, 0x5d, 0xd1, 0xd2, 0xb5, 0x09, 0x7c, 0xeb, 0xd4, 0x04, 0x0f, 0xb9, 0xff, 0xb2, 0x14, 0x2b, 0x92, 0x80, 0xee, 0x2f, 0x6b, 0x7b, 0x26, 0x0d, 0x55, 0xc7, 0x23, 0x00, 0xfe, 0xd1, 0xac, 0x31, 0x45, - }, - A = new byte[] - { + ], + A = + [ 0x07, - }, - B = new byte[] - { + ], + B = + [ 0xdc, 0x2a, 0x30, 0x4f, 0x08, 0xa3, 0xd0, 0xfa, 0x97, 0x68, 0xdd, 0x2a, 0x0c, 0x54, 0x9e, 0xbc, 0x74, 0xcf, 0xe0, 0x58, 0xca, 0x89, 0x0a, 0x48, 0x22, 0x73, 0xad, 0xb2, 0x13, 0x40, 0x83, 0x61, 0x43, 0xac, 0xa1, 0xec, 0x49, 0xb6, 0x88, 0xd7, 0xfd, 0x00, 0x94, 0xe4, 0x77, 0xf3, 0xc5, 0x8b, 0x74, 0xeb, 0x57, 0x4e, 0xa5, 0xcf, 0xd8, 0x29, 0xda, 0x16, 0x11, 0xa3, 0x06, 0x08, 0xff, 0x1c, - }, - Order = new byte[] - { + ], + Order = + [ 0xdf, 0xe6, 0xe6, 0x87, 0xf1, 0xaa, 0x44, 0xd6, 0x95, 0xc5, 0x23, 0xbe, 0xed, 0x25, 0x6e, 0xd8, 0xf1, 0x23, 0xc4, 0xec, 0x5e, 0x5c, 0x90, 0x19, 0xc7, 0xba, 0x1d, 0xcb, 0x7e, 0x2d, 0x2f, 0xa8, 0x5d, 0xd1, 0xd2, 0xb5, 0x09, 0x7c, 0xeb, 0xd4, 0x04, 0x0f, 0xb9, 0xff, 0xb2, 0x14, 0x2b, 0x92, 0x80, 0xee, 0x2f, 0x6b, 0x7b, 0x26, 0x0d, 0x55, 0xc7, 0x23, 0x00, 0xfe, 0xd1, 0xac, 0x31, 0x45, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x9a, 0x8a, 0x24, 0x20, 0xb1, 0xf1, 0x30, 0xb5, 0xb4, 0x33, 0xac, 0x7f, 0x97, 0x49, 0xc8, 0x8b, 0xe2, 0x04, 0xe8, 0xee, 0xa7, 0x0a, 0xb6, 0xc6, 0x8d, 0x83, 0xcd, 0x62, 0x12, 0x61, 0x60, 0xfd, 0x62, 0xd7, 0x8c, 0xa6, 0x93, 0x10, 0xf9, 0x25, 0xc8, 0x7c, 0x05, 0xd7, 0xb3, 0xb3, 0x13, 0x52, 0x6c, 0x7a, 0xfd, 0xbb, 0x6e, 0xbf, 0x96, 0xf3, 0x30, 0xee, 0x72, 0x45, 0xc6, 0x9c, 0xd1, 0x24, - }, - Y = new byte[] - { + ], + Y = + [ 0x1e, 0x37, 0xdd, 0x1a, 0xcb, 0x92, 0xbb, 0x6d, 0x0b, 0x64, 0x24, 0x1b, 0xb9, 0x18, 0x1a, 0xdc, 0x43, 0x4e, 0xee, 0xe1, 0x51, 0x33, 0xeb, 0xf7, 0x6b, 0x49, 0xf1, 0x77, 0x6d, 0x15, 0xab, 0x83, 0x2c, 0x9b, 0xf3, 0x59, 0xc2, 0x47, 0x24, 0xf3, 0xc3, 0xf2, 0xe5, 0x91, 0x1e, 0x06, 0xbf, 0xcf, 0xdd, 0xac, 0x57, 0xc8, 0x13, 0x06, 0x02, 0x0d, 0x6e, 0xce, 0xd2, 0x3b, 0xa4, 0x12, 0xb3, 0x2b, - }, + ], }, }; private static ECCurve ECCurve512ParamsetA { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0xc7, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - A = new byte[] - { + ], + A = + [ 0xc4, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - B = new byte[] - { + ], + B = + [ 0x60, 0xc7, 0x71, 0x5a, 0x78, 0x90, 0x31, 0x50, 0x61, 0x47, 0xee, 0xeb, 0xd4, 0xf9, 0x2e, 0x86, 0xdd, 0x90, 0xda, 0x10, 0x40, 0x57, 0xb4, 0x4c, 0x61, 0x27, 0x0d, 0xf3, 0x90, 0xb0, 0x3c, 0xee, 0x65, 0x62, 0x0b, 0xfd, 0x1c, 0x08, 0xbd, 0x79, 0xe8, 0xb0, 0x1c, 0x76, 0x74, 0x25, 0xb8, 0x34, 0xda, 0xf1, 0x67, 0x66, 0x2b, 0x0b, 0xbd, 0xc1, 0xdd, 0x86, 0xfc, 0xed, 0x5d, 0x50, 0xc2, 0xe8, - }, - Order = new byte[] - { + ], + Order = + [ 0x75, 0xb2, 0x10, 0x1f, 0x41, 0xb1, 0xcd, 0xca, 0x5d, 0xb8, 0xd2, 0xfa, 0xab, 0x38, 0x4b, 0x9b, 0x60, 0x60, 0x05, 0x4e, 0x8d, 0x2b, 0xf2, 0x6f, 0x11, 0x89, 0x8d, 0xf4, 0x32, 0x95, 0xe6, 0x27, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01 - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x03, - }, - Y = new byte[] - { + ], + Y = + [ 0xa4, 0xf2, 0x15, 0x52, 0xcb, 0x89, 0xa5, 0x89, 0xb8, 0xf5, 0x35, 0xc2, 0x5f, 0xfe, 0x28, 0x80, 0xe9, 0x41, 0x3a, 0x0e, 0xa5, 0xe6, 0x75, 0x3d, 0xe9, 0x36, 0xd0, 0x4f, 0xbe, 0x26, 0x16, 0xdf, 0x21, 0xa9, 0xef, 0xcb, 0xfd, 0x64, 0x80, 0x77, 0xc1, 0xab, 0xf1, 0xac, 0x93, 0x1c, 0x5e, 0xce, 0xe6, 0x50, 0x54, 0xe2, 0x16, 0x88, 0x1b, 0xa6, 0xe3, 0x6a, 0x83, 0x7a, 0xe8, 0xcf, 0x03, 0x75, - }, + ], }, }; private static ECCurve ECCurve512ParamsetB { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0x6f, 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, 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, 0x00, 0x00, 0x80, - }, - A = new byte[] - { + ], + A = + [ 0x6c, 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, 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, 0x00, 0x00, 0x80, - }, - B = new byte[] - { + ], + B = + [ 0x16, 0x01, 0x14, 0xc5, 0xc7, 0xcb, 0x8c, 0xfb, 0x6e, 0x10, 0xa3, 0x1f, 0xee, 0x8b, 0xf7, 0x50, 0x9c, 0xb6, 0x1a, 0xad, 0x6f, 0x27, 0x8b, 0x7f, 0x21, 0x6d, 0x41, 0xb1, 0x2d, 0x5d, 0x96, 0x3e, 0x9f, 0x28, 0x4b, 0x6c, 0x80, 0xdc, 0x85, 0xbf, 0xbc, 0x38, 0xf1, 0x4a, 0x61, 0x7d, 0x7c, 0xb9, 0x17, 0x25, 0x5e, 0x6f, 0xcf, 0x06, 0x3e, 0x7e, 0x45, 0x41, 0xc8, 0x9d, 0x45, 0x1b, 0x7d, 0x68, - }, - Order = new byte[] - { + ], + Order = + [ 0xbd, 0x25, 0x4f, 0x37, 0x54, 0x6c, 0x34, 0xc6, 0x0e, 0xea, 0x1b, 0x10, 0x12, 0x67, 0x99, 0x8b, 0xfa, 0x0c, 0xd4, 0xd9, 0x7b, 0xb7, 0xfd, 0xac, 0x45, 0xa5, 0x65, 0x25, 0x14, 0xec, 0xa1, 0x49, 0x01, 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, 0x80, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x01, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x02, - }, - Y = new byte[] - { + ], + Y = + [ 0xbd, 0x41, 0xfe, 0x80, 0x07, 0x34, 0x21, 0x7e, 0xec, 0xee, 0x4c, 0xf9, 0x55, 0x10, 0x04, 0x28, 0x88, 0x39, 0xc0, 0xf8, 0xaa, 0xbc, 0x2c, 0x15, 0x39, 0x4a, 0xdf, 0x1e, 0xfd, 0x28, 0xb2, 0xdc, 0x35, 0x73, 0xec, 0xc8, 0xe6, 0xd9, 0x6d, 0xbe, 0x13, 0xc2, 0x78, 0x75, 0x69, 0x3b, 0x12, 0x3c, 0x0f, 0x94, 0xa8, 0x47, 0x36, 0x1e, 0x07, 0x2c, 0x4c, 0x09, 0x9b, 0x38, 0xda, 0x7e, 0x8f, 0x1a, - }, + ], }, }; private static ECCurve ECCurve512ParamsetC { get; } = new ECCurve { CurveType = ECCurve.ECCurveType.PrimeShortWeierstrass, - Prime = new byte[] - { + Prime = + [ 0xc7, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - A = new byte[] - { + ], + A = + [ 0xd3, 0x9b, 0x68, 0x39, 0x6f, 0x54, 0xb6, 0x2e, 0x2a, 0x9f, 0xda, 0x1f, 0x95, 0x7f, 0xd9, 0x2a, 0xff, 0x50, 0xcf, 0x6f, 0xf4, 0x71, 0xde, 0x2a, 0xd9, 0xed, 0xc9, 0xe2, 0xc0, 0x61, 0xe8, 0x46, 0x45, 0x06, 0x43, 0xe1, 0x68, 0x1c, 0xe4, 0x4d, 0x64, 0x66, 0xb8, 0x0e, 0x98, 0xc8, 0x7b, 0x18, 0xfb, 0x22, 0xc7, 0xd2, 0x29, 0xa5, 0x85, 0x54, 0x87, 0x21, 0xa7, 0x14, 0xe5, 0x03, 0x92, 0xdc, - }, - B = new byte[] - { + ], + B = + [ 0xe1, 0x57, 0x25, 0x31, 0xa5, 0x19, 0x23, 0x8d, 0x3c, 0x0a, 0xbf, 0xf5, 0xa5, 0xc7, 0x8c, 0x2b, 0xb5, 0xf3, 0xfe, 0x8b, 0x4b, 0x28, 0xe0, 0x8d, 0xc1, 0xd2, 0x19, 0xf7, 0xff, 0xc2, 0xcb, 0x38, 0xe0, 0xad, 0xe5, 0x0d, 0x4f, 0x2e, 0xda, 0xff, 0x57, 0x4b, 0x9f, 0xf6, 0xa9, 0xb6, 0xef, 0xc7, 0x6a, 0xf1, 0x37, 0xcf, 0x52, 0x29, 0xc1, 0x8a, 0x2c, 0x6c, 0xbc, 0xce, 0x28, 0xee, 0xc4, 0xb4, - }, - Order = new byte[] - { + ], + Order = + [ 0xb4, 0x8f, 0xc0, 0x1f, 0xbd, 0xf3, 0x88, 0x51, 0x9a, 0x84, 0xa6, 0x9d, 0x9e, 0xa7, 0xb6, 0x23, 0xb3, 0x40, 0x1d, 0x45, 0xfd, 0xa7, 0xce, 0x30, 0x01, 0xac, 0x1a, 0x94, 0x91, 0x6e, 0x33, 0x26, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - Cofactor = new byte[] - { + ], + Cofactor = + [ 0x04, - }, + ], G = new ECPoint { - X = new byte[] - { + X = + [ 0x48, 0x01, 0x95, 0xc1, 0x28, 0x79, 0xbc, 0xc5, 0xaa, 0x97, 0xae, 0x7e, 0x48, 0x85, 0xfb, 0xc6, 0x10, 0x36, 0xed, 0xb9, 0x3d, 0x03, 0xb9, 0xa7, 0xf2, 0x2b, 0x60, 0xae, 0xa7, 0x72, 0x72, 0xa2, 0x3a, 0x04, 0xea, 0x4c, 0x07, 0xf7, 0x85, 0xd3, 0x21, 0xf0, 0xae, 0xcb, 0xa9, 0xb7, 0x95, 0x22, 0xde, 0xf5, 0x3e, 0x59, 0xce, 0x41, 0xe2, 0xeb, 0xbd, 0xe7, 0x3d, 0xc2, 0xdf, 0x1e, 0xe3, 0xe2, - }, - Y = new byte[] - { + ], + Y = + [ 0x0f, 0xc4, 0xdd, 0x9a, 0x9a, 0x6e, 0x39, 0xd0, 0x07, 0xae, 0x4b, 0x85, 0xaa, 0x26, 0xf7, 0x04, 0x63, 0x3b, 0x42, 0x22, 0x58, 0xd8, 0x32, 0xef, 0xd2, 0x1e, 0x02, 0xe3, 0x33, 0x2d, 0x8e, 0xe1, 0x9b, 0xff, 0x90, 0x20, 0x3d, 0x8c, 0x10, 0x8c, 0x8b, 0x37, 0x27, 0x65, 0x4d, 0x80, 0x39, 0x79, 0x57, 0xb8, 0x1c, 0x91, 0xf5, 0xcf, 0xbc, 0xab, 0x99, 0xb8, 0x5e, 0x5b, 0xd9, 0x40, 0xce, 0xf5, - }, + ], }, }; diff --git a/src/OpenGost.Security.Cryptography/GostECDsa.cs b/src/OpenGost.Security.Cryptography/GostECDsa.cs index a7c5105..de8bc82 100644 --- a/src/OpenGost.Security.Cryptography/GostECDsa.cs +++ b/src/OpenGost.Security.Cryptography/GostECDsa.cs @@ -8,7 +8,7 @@ namespace OpenGost.Security.Cryptography; [ComVisible(true)] public abstract class GostECDsa : ECDsa { - private static readonly KeySizes[] _legalKeySizes = { new(256, 512, 256) }; + private static readonly KeySizes[] _legalKeySizes = [new(256, 512, 256)]; /// /// Gets the name of the signature algorithm. diff --git a/src/OpenGost.Security.Cryptography/Grasshopper.cs b/src/OpenGost.Security.Cryptography/Grasshopper.cs index 56eabf5..d5895e0 100644 --- a/src/OpenGost.Security.Cryptography/Grasshopper.cs +++ b/src/OpenGost.Security.Cryptography/Grasshopper.cs @@ -11,8 +11,8 @@ namespace OpenGost.Security.Cryptography; public abstract class Grasshopper : SymmetricAlgorithm { private static readonly KeySizes[] - _legalBlockSizes = { new(128, 128, 0) }, - _legalKeySizes = { new(256, 256, 0) }; + _legalBlockSizes = [new(128, 128, 0)], + _legalKeySizes = [new(256, 256, 0)]; /// /// Initializes a new instance of . diff --git a/src/OpenGost.Security.Cryptography/GrasshopperManagedTransform.cs b/src/OpenGost.Security.Cryptography/GrasshopperManagedTransform.cs index 5221cb4..c76b175 100644 --- a/src/OpenGost.Security.Cryptography/GrasshopperManagedTransform.cs +++ b/src/OpenGost.Security.Cryptography/GrasshopperManagedTransform.cs @@ -9,7 +9,7 @@ internal sealed class GrasshopperManagedTransform : SymmetricTransform private static readonly byte[] _forwardSubstitutionBox = - { + [ 0xFC, 0xEE, 0xDD, 0x11, 0xCF, 0x6E, 0x31, 0x16, 0xFB, 0xC4, 0xFA, 0xDA, 0x23, 0xC5, 0x04, 0x4D, 0xE9, 0x77, 0xF0, 0xDB, 0x93, 0x2E, 0x99, 0xBA, 0x17, 0x36, 0xF1, 0xBB, 0x14, 0xCD, 0x5F, 0xC1, 0xF9, 0x18, 0x65, 0x5A, 0xE2, 0x5C, 0xEF, 0x21, 0x81, 0x1C, 0x3C, 0x42, 0x8B, 0x01, 0x8E, 0x4F, @@ -26,9 +26,9 @@ private static readonly byte[] 0xE1, 0x1B, 0x83, 0x49, 0x4C, 0x3F, 0xF8, 0xFE, 0x8D, 0x53, 0xAA, 0x90, 0xCA, 0xD8, 0x85, 0x61, 0x20, 0x71, 0x67, 0xA4, 0x2D, 0x2B, 0x09, 0x5B, 0xCB, 0x9B, 0x25, 0xD0, 0xBE, 0xE5, 0x6C, 0x52, 0x59, 0xA6, 0x74, 0xD2, 0xE6, 0xF4, 0xB4, 0xC0, 0xD1, 0x66, 0xAF, 0xC2, 0x39, 0x4B, 0x63, 0xB6, - }, + ], _backwardSubstitutionBox = - { + [ 0xA5, 0x2D, 0x32, 0x8F, 0x0E, 0x30, 0x38, 0xC0, 0x54, 0xE6, 0x9E, 0x39, 0x55, 0x7E, 0x52, 0x91, 0x64, 0x03, 0x57, 0x5A, 0x1C, 0x60, 0x07, 0x18, 0x21, 0x72, 0xA8, 0xD1, 0x29, 0xC6, 0xA4, 0x3F, 0xE0, 0x27, 0x8D, 0x0C, 0x82, 0xEA, 0xAE, 0xB4, 0x9A, 0x63, 0x49, 0xE5, 0x42, 0xE4, 0x15, 0xB7, @@ -45,7 +45,7 @@ private static readonly byte[] 0xEB, 0xF8, 0xF3, 0x3E, 0x3D, 0xBD, 0x8A, 0x88, 0xDD, 0xCD, 0x0B, 0x13, 0x98, 0x02, 0x93, 0x80, 0x90, 0xD0, 0x24, 0x34, 0xCB, 0xED, 0xF4, 0xCE, 0x99, 0x10, 0x44, 0x40, 0x92, 0x3A, 0x01, 0x26, 0x12, 0x1A, 0x48, 0x68, 0xF5, 0x81, 0x8B, 0xC7, 0xD6, 0x20, 0x0A, 0x08, 0x00, 0x4C, 0xD7, 0x74, - }; + ]; #endregion @@ -79,11 +79,11 @@ internal GrasshopperManagedTransform( [SecuritySafeCritical] protected override void GenerateKeyExpansion(byte[] key) { - _keyExpansion = new byte[10][] - { + _keyExpansion = + [ new byte[16], new byte[16], null!, null!, null!, null!, null!, null!, null!, null! - }; + ]; Buffer.BlockCopy(key, 0, _keyExpansion[0]!, 0, 16); Buffer.BlockCopy(key, 16, _keyExpansion[1]!, 0, 16); diff --git a/src/OpenGost.Security.Cryptography/HMACCommon.cs b/src/OpenGost.Security.Cryptography/HMACCommon.cs index b19c76a..9e61e10 100644 --- a/src/OpenGost.Security.Cryptography/HMACCommon.cs +++ b/src/OpenGost.Security.Cryptography/HMACCommon.cs @@ -59,12 +59,12 @@ public byte[] HashFinal() _hash1.TransformBlock(_inner, 0, _inner.Length, _inner, 0); _hashing = true; } - _hash1.TransformFinalBlock(Array.Empty(), 0, 0); + _hash1.TransformFinalBlock([], 0, 0); var hashValue1 = _hash1.Hash!; _hash2.TransformBlock(_outer, 0, _outer.Length, _outer, 0); _hash2.TransformBlock(hashValue1, 0, hashValue1.Length, hashValue1, 0); _hashing = false; - _hash2.TransformFinalBlock(Array.Empty(), 0, 0); + _hash2.TransformFinalBlock([], 0, 0); return _hash2.Hash!; } diff --git a/src/OpenGost.Security.Cryptography/Magma.cs b/src/OpenGost.Security.Cryptography/Magma.cs index 7b45897..e79371d 100644 --- a/src/OpenGost.Security.Cryptography/Magma.cs +++ b/src/OpenGost.Security.Cryptography/Magma.cs @@ -11,8 +11,8 @@ namespace OpenGost.Security.Cryptography; public abstract class Magma : SymmetricAlgorithm { private static readonly KeySizes[] - _legalBlockSizes = { new(64, 64, 0) }, - _legalKeySizes = { new(256, 256, 0) }; + _legalBlockSizes = [new(64, 64, 0)], + _legalKeySizes = [new(256, 256, 0)]; /// /// Initializes a new instance of . diff --git a/src/OpenGost.Security.Cryptography/MagmaManagedTransform.cs b/src/OpenGost.Security.Cryptography/MagmaManagedTransform.cs index d0af540..ec8d064 100644 --- a/src/OpenGost.Security.Cryptography/MagmaManagedTransform.cs +++ b/src/OpenGost.Security.Cryptography/MagmaManagedTransform.cs @@ -8,16 +8,16 @@ internal sealed class MagmaManagedTransform : SymmetricTransform #region Constants private static readonly byte[][] _substitutionBox = - { - new byte[] { 0xC, 0x4, 0x6, 0x2, 0xA, 0x5, 0xB, 0x9, 0xE, 0x8, 0xD, 0x7, 0x0, 0x3, 0xF, 0x1 }, - new byte[] { 0x6, 0x8, 0x2, 0x3, 0x9, 0xA, 0x5, 0xC, 0x1, 0xE, 0x4, 0x7, 0xB, 0xD, 0x0, 0xF }, - new byte[] { 0xB, 0x3, 0x5, 0x8, 0x2, 0xF, 0xA, 0xD, 0xE, 0x1, 0x7, 0x4, 0xC, 0x9, 0x6, 0x0 }, - new byte[] { 0xC, 0x8, 0x2, 0x1, 0xD, 0x4, 0xF, 0x6, 0x7, 0x0, 0xA, 0x5, 0x3, 0xE, 0x9, 0xB }, - new byte[] { 0x7, 0xF, 0x5, 0xA, 0x8, 0x1, 0x6, 0xD, 0x0, 0x9, 0x3, 0xE, 0xB, 0x4, 0x2, 0xC }, - new byte[] { 0x5, 0xD, 0xF, 0x6, 0x9, 0x2, 0xC, 0xA, 0xB, 0x7, 0x8, 0x1, 0x4, 0x3, 0xE, 0x0 }, - new byte[] { 0x8, 0xE, 0x2, 0x5, 0x6, 0x9, 0x1, 0xC, 0xF, 0x4, 0xB, 0x0, 0xD, 0xA, 0x3, 0x7 }, - new byte[] { 0x1, 0x7, 0xE, 0xD, 0x0, 0x5, 0x8, 0x3, 0x4, 0xF, 0xA, 0x6, 0x9, 0xC, 0xB, 0x2 } - }; + [ + [0xC, 0x4, 0x6, 0x2, 0xA, 0x5, 0xB, 0x9, 0xE, 0x8, 0xD, 0x7, 0x0, 0x3, 0xF, 0x1], + [0x6, 0x8, 0x2, 0x3, 0x9, 0xA, 0x5, 0xC, 0x1, 0xE, 0x4, 0x7, 0xB, 0xD, 0x0, 0xF], + [0xB, 0x3, 0x5, 0x8, 0x2, 0xF, 0xA, 0xD, 0xE, 0x1, 0x7, 0x4, 0xC, 0x9, 0x6, 0x0], + [0xC, 0x8, 0x2, 0x1, 0xD, 0x4, 0xF, 0x6, 0x7, 0x0, 0xA, 0x5, 0x3, 0xE, 0x9, 0xB], + [0x7, 0xF, 0x5, 0xA, 0x8, 0x1, 0x6, 0xD, 0x0, 0x9, 0x3, 0xE, 0xB, 0x4, 0x2, 0xC], + [0x5, 0xD, 0xF, 0x6, 0x9, 0x2, 0xC, 0xA, 0xB, 0x7, 0x8, 0x1, 0x4, 0x3, 0xE, 0x0], + [0x8, 0xE, 0x2, 0x5, 0x6, 0x9, 0x1, 0xC, 0xF, 0x4, 0xB, 0x0, 0xD, 0xA, 0x3, 0x7], + [0x1, 0x7, 0xE, 0xD, 0x0, 0x5, 0x8, 0x3, 0x4, 0xF, 0xA, 0x6, 0x9, 0xC, 0xB, 0x2] + ]; #endregion diff --git a/src/OpenGost.Security.Cryptography/Streebog256Managed.cs b/src/OpenGost.Security.Cryptography/Streebog256Managed.cs index f135181..f24ba7e 100644 --- a/src/OpenGost.Security.Cryptography/Streebog256Managed.cs +++ b/src/OpenGost.Security.Cryptography/Streebog256Managed.cs @@ -11,12 +11,12 @@ public class Streebog256Managed : Streebog256 #region Constants private static readonly byte[] _defaultIV = - { + [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 - }; + ]; #endregion @@ -62,7 +62,7 @@ protected override void HashCore(byte[] array, int ibStart, int cbSize) protected override byte[] HashFinal() { _innerAlgorithm.TransformFinalBlock( - Array.Empty(), + [], 0, 0); var hash = new byte[32]; Buffer.BlockCopy(_innerAlgorithm.Hash!, 32, hash, 0, 32); diff --git a/src/OpenGost.Security.Cryptography/Streebog512Managed.cs b/src/OpenGost.Security.Cryptography/Streebog512Managed.cs index 1f61529..e70f4fa 100644 --- a/src/OpenGost.Security.Cryptography/Streebog512Managed.cs +++ b/src/OpenGost.Security.Cryptography/Streebog512Managed.cs @@ -13,97 +13,85 @@ public class Streebog512Managed : Streebog512 #region Constants private static readonly byte[][] _keyExpansionTable = - { - new byte[] - { + [ + [ 0x07, 0x45, 0xa6, 0xf2, 0x59, 0x65, 0x80, 0xdd, 0x23, 0x4d, 0x74, 0xcc, 0x36, 0x74, 0x76, 0x05, 0x15, 0xd3, 0x60, 0xa4, 0x08, 0x2a, 0x42, 0xa2, 0x01, 0x69, 0x67, 0x92, 0x91, 0xe0, 0x7c, 0x4b, 0xfc, 0xc4, 0x85, 0x75, 0x8d, 0xb8, 0x4e, 0x71, 0x16, 0xd0, 0x45, 0x2e, 0x43, 0x76, 0x6a, 0x2f, 0x1f, 0x7c, 0x65, 0xc0, 0x81, 0x2f, 0xcb, 0xeb, 0xe9, 0xda, 0xca, 0x1e, 0xda, 0x5b, 0x08, 0xb1, - }, - new byte[] - { + ], + [ 0xb7, 0x9b, 0xb1, 0x21, 0x70, 0x04, 0x79, 0xe6, 0x56, 0xcd, 0xcb, 0xd7, 0x1b, 0xa2, 0xdd, 0x55, 0xca, 0xa7, 0x0a, 0xdb, 0xc2, 0x61, 0xb5, 0x5c, 0x58, 0x99, 0xd6, 0x12, 0x6b, 0x17, 0xb5, 0x9a, 0x31, 0x01, 0xb5, 0x16, 0x0f, 0x5e, 0xd5, 0x61, 0x98, 0x2b, 0x23, 0x0a, 0x72, 0xea, 0xfe, 0xf3, 0xd7, 0xb5, 0x70, 0x0f, 0x46, 0x9d, 0xe3, 0x4f, 0x1a, 0x2f, 0x9d, 0xa9, 0x8a, 0xb5, 0xa3, 0x6f, - }, - new byte[] - { + ], + [ 0xb2, 0x0a, 0xba, 0x0a, 0xf5, 0x96, 0x1e, 0x99, 0x31, 0xdb, 0x7a, 0x86, 0x43, 0xf4, 0xb6, 0xc2, 0x09, 0xdb, 0x62, 0x60, 0x37, 0x3a, 0xc9, 0xc1, 0xb1, 0x9e, 0x35, 0x90, 0xe4, 0x0f, 0xe2, 0xd3, 0x7b, 0x7b, 0x29, 0xb1, 0x14, 0x75, 0xea, 0xf2, 0x8b, 0x1f, 0x9c, 0x52, 0x5f, 0x5e, 0xf1, 0x06, 0x35, 0x84, 0x3d, 0x6a, 0x28, 0xfc, 0x39, 0x0a, 0xc7, 0x2f, 0xce, 0x2b, 0xac, 0xdc, 0x74, 0xf5, - }, - new byte[] - { + ], + [ 0x2e, 0xd1, 0xe3, 0x84, 0xbc, 0xbe, 0x0c, 0x22, 0xf1, 0x37, 0xe8, 0x93, 0xa1, 0xea, 0x53, 0x34, 0xbe, 0x03, 0x52, 0x93, 0x33, 0x13, 0xb7, 0xd8, 0x75, 0xd6, 0x03, 0xed, 0x82, 0x2c, 0xd7, 0xa9, 0x3f, 0x35, 0x5e, 0x68, 0xad, 0x1c, 0x72, 0x9d, 0x7d, 0x3c, 0x5c, 0x33, 0x7e, 0x85, 0x8e, 0x48, 0xdd, 0xe4, 0x71, 0x5d, 0xa0, 0xe1, 0x48, 0xf9, 0xd2, 0x66, 0x15, 0xe8, 0xb3, 0xdf, 0x1f, 0xef, - }, - new byte[] - { + ], + [ 0x57, 0xfe, 0x6c, 0x7c, 0xfd, 0x58, 0x17, 0x60, 0xf5, 0x63, 0xea, 0xa9, 0x7e, 0xa2, 0x56, 0x7a, 0x16, 0x1a, 0x27, 0x23, 0xb7, 0x00, 0xff, 0xdf, 0xa3, 0xf5, 0x3a, 0x25, 0x47, 0x17, 0xcd, 0xbf, 0xbd, 0xff, 0x0f, 0x80, 0xd7, 0x35, 0x9e, 0x35, 0x4a, 0x10, 0x86, 0x16, 0x1f, 0x1c, 0x15, 0x7f, 0x63, 0x23, 0xa9, 0x6c, 0x0c, 0x41, 0x3f, 0x9a, 0x99, 0x47, 0x47, 0xad, 0xac, 0x6b, 0xea, 0x4b, - }, - new byte[] - { + ], + [ 0x6e, 0x7d, 0x64, 0x46, 0x7a, 0x40, 0x68, 0xfa, 0x35, 0x4f, 0x90, 0x36, 0x72, 0xc5, 0x71, 0xbf, 0xb6, 0xc6, 0xbe, 0xc2, 0x66, 0x1f, 0xf2, 0x0a, 0xb4, 0xb7, 0x9a, 0x1c, 0xb7, 0xa6, 0xfa, 0xcf, 0xc6, 0x8e, 0xf0, 0x9a, 0xb4, 0x9a, 0x7f, 0x18, 0x6c, 0xa4, 0x42, 0x51, 0xf9, 0xc4, 0x66, 0x2d, 0xc0, 0x39, 0x30, 0x7a, 0x3b, 0xc3, 0xa4, 0x6f, 0xd9, 0xd3, 0x3a, 0x1d, 0xae, 0xae, 0x4f, 0xae, - }, - new byte[] - { + ], + [ 0x93, 0xd4, 0x14, 0x3a, 0x4d, 0x56, 0x86, 0x88, 0xf3, 0x4a, 0x3c, 0xa2, 0x4c, 0x45, 0x17, 0x35, 0x04, 0x05, 0x4a, 0x28, 0x83, 0x69, 0x47, 0x06, 0x37, 0x2c, 0x82, 0x2d, 0xc5, 0xab, 0x92, 0x09, 0xc9, 0x93, 0x7a, 0x19, 0x33, 0x3e, 0x47, 0xd3, 0xc9, 0x87, 0xbf, 0xe6, 0xc7, 0xc6, 0x9e, 0x39, 0x54, 0x09, 0x24, 0xbf, 0xfe, 0x86, 0xac, 0x51, 0xec, 0xc5, 0xaa, 0xee, 0x16, 0x0e, 0xc7, 0xf4, - }, - new byte[] - { + ], + [ 0x1e, 0xe7, 0x02, 0xbf, 0xd4, 0x0d, 0x7f, 0xa4, 0xd9, 0xa8, 0x51, 0x59, 0x35, 0xc2, 0xac, 0x36, 0x2f, 0xc4, 0xa5, 0xd1, 0x2b, 0x8d, 0xd1, 0x69, 0x90, 0x06, 0x9b, 0x92, 0xcb, 0x2b, 0x89, 0xf4, 0x9a, 0xc4, 0xdb, 0x4d, 0x3b, 0x44, 0xb4, 0x89, 0x1e, 0xde, 0x36, 0x9c, 0x71, 0xf8, 0xb7, 0x4e, 0x41, 0x41, 0x6e, 0x0c, 0x02, 0xaa, 0xe7, 0x03, 0xa7, 0xc9, 0x93, 0x4d, 0x42, 0x5b, 0x1f, 0x9b, - }, - new byte[] - { + ], + [ 0xdb, 0x5a, 0x23, 0x83, 0x51, 0x44, 0x61, 0x72, 0x60, 0x2a, 0x1f, 0xcb, 0x92, 0xdc, 0x38, 0x0e, 0x54, 0x9c, 0x07, 0xa6, 0x9a, 0x8a, 0x2b, 0x7b, 0xb1, 0xce, 0xb2, 0xdb, 0x0b, 0x44, 0x0a, 0x80, 0x84, 0x09, 0x0d, 0xe0, 0xb7, 0x55, 0xd9, 0x3c, 0x24, 0x42, 0x89, 0x25, 0x1b, 0x3a, 0x7d, 0x3a, 0xde, 0x5f, 0x16, 0xec, 0xd8, 0x9a, 0x4c, 0x94, 0x9b, 0x22, 0x31, 0x16, 0x54, 0x5a, 0x8f, 0x37, - }, - new byte[] - { + ], + [ 0xed, 0x9c, 0x45, 0x98, 0xfb, 0xc7, 0xb4, 0x74, 0xc3, 0xb6, 0x3b, 0x15, 0xd1, 0xfa, 0x98, 0x36, 0xf4, 0x52, 0x76, 0x3b, 0x30, 0x6c, 0x1e, 0x7a, 0x4b, 0x33, 0x69, 0xaf, 0x02, 0x67, 0xe7, 0x9f, 0x03, 0x61, 0x33, 0x1b, 0x8a, 0xe1, 0xff, 0x1f, 0xdb, 0x78, 0x8a, 0xff, 0x1c, 0xe7, 0x41, 0x89, 0xf3, 0xf3, 0xe4, 0xb2, 0x48, 0xe5, 0x2a, 0x38, 0x52, 0x6f, 0x05, 0x80, 0xa6, 0xde, 0xbe, 0xab, - }, - new byte[] - { + ], + [ 0x1b, 0x2d, 0xf3, 0x81, 0xcd, 0xa4, 0xca, 0x6b, 0x5d, 0xd8, 0x6f, 0xc0, 0x4a, 0x59, 0xa2, 0xde, 0x98, 0x6e, 0x47, 0x7d, 0x1d, 0xcd, 0xba, 0xef, 0xca, 0xb9, 0x48, 0xea, 0xef, 0x71, 0x1d, 0x8a, 0x79, 0x66, 0x84, 0x14, 0x21, 0x80, 0x01, 0x20, 0x61, 0x07, 0xab, 0xeb, 0xbb, 0x6b, 0xfa, 0xd8, 0x94, 0xfe, 0x5a, 0x63, 0xcd, 0xc6, 0x02, 0x30, 0xfb, 0x89, 0xc8, 0xef, 0xd0, 0x9e, 0xcd, 0x7b, - }, - new byte[] - { + ], + [ 0x20, 0xd7, 0x1b, 0xf1, 0x4a, 0x92, 0xbc, 0x48, 0x99, 0x1b, 0xb2, 0xd9, 0xd5, 0x17, 0xf4, 0xfa, 0x52, 0x28, 0xe1, 0x88, 0xaa, 0xa4, 0x1d, 0xe7, 0x86, 0xcc, 0x91, 0x18, 0x9d, 0xef, 0x80, 0x5d, 0x9b, 0x9f, 0x21, 0x30, 0xd4, 0x12, 0x20, 0xf8, 0x77, 0x1d, 0xdf, 0xbc, 0x32, 0x3c, 0xa4, 0xcd, 0x7a, 0xb1, 0x49, 0x04, 0xb0, 0x80, 0x13, 0xd2, 0xba, 0x31, 0x16, 0xf1, 0x67, 0xe7, 0x8e, 0x37, - }, + ], - }; + ]; private static readonly byte[] _backwardSubstitutionBox = - { + [ 0xA5, 0x2D, 0x32, 0x8F, 0x0E, 0x30, 0x38, 0xC0, 0x54, 0xE6, 0x9E, 0x39, 0x55, 0x7E, 0x52, 0x91, 0x64, 0x03, 0x57, 0x5A, 0x1C, 0x60, 0x07, 0x18, 0x21, 0x72, 0xA8, 0xD1, 0x29, 0xC6, 0xA4, 0x3F, 0xE0, 0x27, 0x8D, 0x0C, 0x82, 0xEA, 0xAE, 0xB4, 0x9A, 0x63, 0x49, 0xE5, 0x42, 0xE4, 0x15, 0xB7, @@ -120,11 +108,11 @@ private static readonly byte[] 0xEB, 0xF8, 0xF3, 0x3E, 0x3D, 0xBD, 0x8A, 0x88, 0xDD, 0xCD, 0x0B, 0x13, 0x98, 0x02, 0x93, 0x80, 0x90, 0xD0, 0x24, 0x34, 0xCB, 0xED, 0xF4, 0xCE, 0x99, 0x10, 0x44, 0x40, 0x92, 0x3A, 0x01, 0x26, 0x12, 0x1A, 0x48, 0x68, 0xF5, 0x81, 0x8B, 0xC7, 0xD6, 0x20, 0x0A, 0x08, 0x00, 0x4C, 0xD7, 0x74, - }, + ], _defaultIV = new byte[64]; private static readonly ulong[] _linearTransformTable = - { + [ 0x8e20faa72ba0b470, 0x47107ddd9b505a38, 0xad08b0e0c3282d1c, 0xd8045870ef14980e, 0x6c022c38f90a4c07, 0x3601161cf205268d, 0x1b8e0b0e798c13c8, 0x83478b07b2468764, 0xa011d380818e8f40, 0x5086e740ce47c920, 0x2843fd2067adea10, 0x14aff010bdd87508, @@ -141,7 +129,7 @@ private static readonly byte[] 0x492c024284fbaec0, 0xaa16012142f35760, 0x550b8e9e21f7a530, 0xa48b474f9ef5dc18, 0x70a6a56e2440598e, 0x3853dc371220a247, 0x1ca76e95091051ad, 0x0edd37c48a08a6d8, 0x07e095624504536c, 0x8d70c431ac02a736, 0xc83862965601dd1b, 0x641c314b2b8ee083, - }; + ]; #endregion diff --git a/tests/OpenGost.Security.Cryptography.Tests/CreationFactoriesFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/CreationFactoriesFacts.cs index f105cee..f086e14 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/CreationFactoriesFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/CreationFactoriesFacts.cs @@ -40,10 +40,10 @@ public void CreateExplicit_ReturnsValidInstance( public static IEnumerable ExplicitCreateFactories() { static object?[] TestCase(Type type, Func factory) - => new object?[] { type, factory, type.Name }; + => [type, factory, type.Name]; - return new[] - { + return + [ TestCase(typeof(GostECDsa), GostECDsa.Create), TestCase(typeof(Grasshopper), Grasshopper.Create), TestCase(typeof(Magma), Magma.Create), @@ -51,8 +51,6 @@ public void CreateExplicit_ReturnsValidInstance( TestCase(typeof(Streebog512), Streebog512.Create), TestCase(typeof(CMACGrasshopper), CMAC.Create), TestCase(typeof(CMACMagma), CMAC.Create), - -#pragma warning disable SYSLIB0045 TestCase(typeof(GostECDsa), ECDsa.Create), TestCase(typeof(GostECDsa), AsymmetricAlgorithm.Create), TestCase(typeof(Grasshopper), SymmetricAlgorithm.Create), @@ -69,22 +67,21 @@ public void CreateExplicit_ReturnsValidInstance( TestCase(typeof(HMACStreebog512), HashAlgorithm.Create), TestCase(typeof(HMACStreebog512), KeyedHashAlgorithm.Create), TestCase(typeof(HMACStreebog512), HMAC.Create), -#pragma warning restore SYSLIB0045 - }; + ]; } public static IEnumerable ImplicitCreateFactories() { static Func Func(Func func) => func; - return new[] - { - new object[] { typeof(CMACGrasshopper), Func(CMAC.Create), }, - new object[] { typeof(GostECDsa), Func(GostECDsa.Create), }, - new object[] { typeof(Grasshopper), Func(Grasshopper.Create), }, - new object[] { typeof(Magma), Func(Magma.Create), }, - new object[] { typeof(Streebog256), Func(Streebog256.Create), }, - new object[] { typeof(Streebog512), Func(Streebog512.Create), }, - }; + return + [ + [typeof(CMACGrasshopper), Func(CMAC.Create),], + [typeof(GostECDsa), Func(GostECDsa.Create),], + [typeof(Grasshopper), Func(Grasshopper.Create),], + [typeof(Magma), Func(Magma.Create),], + [typeof(Streebog256), Func(Streebog256.Create),], + [typeof(Streebog512), Func(Streebog512.Create),], + ]; } } diff --git a/tests/OpenGost.Security.Cryptography.Tests/GostECDsaCertificateExtensionsFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/GostECDsaCertificateExtensionsFacts.cs index f086ef6..eb56f03 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/GostECDsaCertificateExtensionsFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/GostECDsaCertificateExtensionsFacts.cs @@ -60,11 +60,10 @@ private static X509Certificate2 GetCertificate(string certificateName) public static IEnumerable TestCases() { - return new[] - { + return + [ // 256-bit example - new object[] - { + [ // Certificate name "GostECDsa256", // Curve OID @@ -75,10 +74,9 @@ public static IEnumerable TestCases() "43e69c1ff74fe2e2f1749859abf677d1c0c60fe28d0f83598e9f9465697358ad", // D "249939faa839edc3f2aafe0f643de4463c924abbeac6a73230dd5c3e621dcfbf", - }, + ], // 512-bit example - new object[] - { + [ // Certificate name "GostECDsa512", // Curve OID @@ -92,8 +90,8 @@ public static IEnumerable TestCases() // D "4b07cb6b4e014ea4e67d0c5f17fd33fd488cb4eec876b987e57c0741e6307575" + "352446ee5aa02b99679efe8d5280f3b76de6414c7782b42e975fecd4dc1cc03f", - }, - }; + ], + ]; } } diff --git a/tests/OpenGost.Security.Cryptography.Tests/GostECDsaManagedFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/GostECDsaManagedFacts.cs index 953cac0..a26388c 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/GostECDsaManagedFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/GostECDsaManagedFacts.cs @@ -119,7 +119,7 @@ public void VerifyHash_WhenSignatureIsValid_ReturnsTrue( [Theory] [InlineData(256)] [InlineData(512)] - public void VerifyHash_ReturnsFalse_IfParametersWasNotGenereated(int keySize) + public void VerifyHash_ReturnsFalse_IfParametersWasNotGenerated(int keySize) { var hash = CryptoUtils.GenerateRandomBytes(keySize / 8); var signature = CryptoUtils.GenerateRandomBytes(keySize / 4); diff --git a/tests/OpenGost.Security.Cryptography.Tests/GrasshopperManagedFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/GrasshopperManagedFacts.cs index 64bf247..a8da149 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/GrasshopperManagedFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/GrasshopperManagedFacts.cs @@ -21,10 +21,9 @@ public override void Verify( => base.Verify(mode, padding, plainText, cipherText, key, iv); - public static object[][] Data { get; } = new[] - { - new object[] - { + public static object[][] Data { get; } = + [ + [ CipherMode.ECB, PaddingMode.None, PlainText, @@ -32,9 +31,8 @@ public override void Verify( "f0ca33549d247ceef3f5a5313bd4b157d0b09ccde830b9eb3a02c4c5aa8ada98", Key, IV, - }, - new object[] - { + ], + [ CipherMode.CBC, PaddingMode.None, PlainText, @@ -42,9 +40,8 @@ public override void Verify( "fe7babf1e91999e85640e8b0f49d90d0167688065a895c631a2d9a1560b63970", Key, IV, - }, - new object[] - { + ], + [ CipherMode.CFB, PaddingMode.None, PlainText, @@ -52,9 +49,8 @@ public override void Verify( "79f2a8eb5cc68d38842d264e97a238b54ffebecd4e922de6c75bd9dd44fbf4d1", Key, IV, - }, - new object[] - { + ], + [ CipherMode.OFB, PaddingMode.None, PlainText, @@ -62,8 +58,8 @@ public override void Verify( "66a257ac3ca0b8b1c80fe7fc10288a13203ebbc066138660a0292243f6903150", Key, IV, - }, - }; + ], + ]; } diff --git a/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog256Facts.cs b/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog256Facts.cs index a4a5113..68a2f21 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog256Facts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog256Facts.cs @@ -6,7 +6,7 @@ protected override HashAlgorithm CreateHashAlgorithm() => Streebog256.Create(); protected override HMACStreebog256 CreateHMAC(byte[] key) - => new HMACStreebog256(key); + => new(key); [Theory] [InlineData("0126bdb87800af214341456563780100", diff --git a/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog512Facts.cs b/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog512Facts.cs index 9801064..4fc424c 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog512Facts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/HmacStreebog512Facts.cs @@ -6,7 +6,7 @@ protected override HashAlgorithm CreateHashAlgorithm() => Streebog512.Create(); protected override HMACStreebog512 CreateHMAC(byte[] key) - => new HMACStreebog512(key); + => new(key); [Theory] [InlineData("0126bdb87800af214341456563780100", diff --git a/tests/OpenGost.Security.Cryptography.Tests/MagmaManagedFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/MagmaManagedFacts.cs index ba281d9..9468828 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/MagmaManagedFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/MagmaManagedFacts.cs @@ -19,43 +19,39 @@ public override void Verify( string iv) => base.Verify(mode, padding, plainText, cipherText, key, iv); - public static object[][] Data { get; } = new[] - { - new object[] - { + public static object[][] Data { get; } = + [ + [ CipherMode.ECB, PaddingMode.None, PlainText, "2b073f0494f372a0de70e715d3556e4811d8d9e9eacfbc1e7c68260996c67efb", Key, "1234567890abcdef234567890abcdef134567890abcdef12", - }, - new object[] - { + ], + [ CipherMode.CBC, PaddingMode.None, PlainText, "96d1b05eea683919aff76129abb937b95058b4a1c4bc001920b78b1a7cd7e667", Key, "1234567890abcdef234567890abcdef134567890abcdef12", - }, - new object[] - { + ], + [ CipherMode.CFB, PaddingMode.None, PlainText, "db37e0e266903c830d46644c1f9a089c24bdd2035315d38bbcc0321421075505", Key, "1234567890abcdef234567890abcdef1", - }, - new object[] - { + ], + [ CipherMode.OFB, PaddingMode.None, PlainText, "db37e0e266903c830d46644c1f9a089ca0f83062430e327ec824efb8bd4fdb05", Key, "1234567890abcdef234567890abcdef1", - }, - }; + ], + ]; } diff --git a/tests/OpenGost.Security.Cryptography.Tests/ReusabilityFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/ReusabilityFacts.cs index 07e030a..5c06baa 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/ReusabilityFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/ReusabilityFacts.cs @@ -7,7 +7,7 @@ public class ReusabilityFacts public void ReuseHashAlgorithm(Func hashAlgorithmFactory) { using var hashAlgorithm = hashAlgorithmFactory.Invoke(); - byte[] input = { 0x08, 0x06, 0x07, 0x05, 0x03, 0x00, 0x09, }; + byte[] input = [0x08, 0x06, 0x07, 0x05, 0x03, 0x00, 0x09]; var hash1 = hashAlgorithm.ComputeHash(input); var hash2 = hashAlgorithm.ComputeHash(input); @@ -17,12 +17,12 @@ public void ReuseHashAlgorithm(Func hashAlgorithmFactory) public static IEnumerable ReusabilityHashAlgorithms() { - return new[] - { - new Func[] { () => new Streebog256Managed(), }, - new Func[] { () => new Streebog512Managed(), }, - new Func[] { () => new CMACGrasshopper(), }, - new Func[] { () => new CMACMagma(), }, - }; + return + [ + [() => new Streebog256Managed(),], + [() => new Streebog512Managed(),], + [() => new CMACGrasshopper(),], + [() => new CMACMagma(),], + ]; } } diff --git a/tests/OpenGost.Security.Cryptography.Tests/Streebog256ManagedFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/Streebog256ManagedFacts.cs index c4cc6f4..6874d8c 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/Streebog256ManagedFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/Streebog256ManagedFacts.cs @@ -7,26 +7,23 @@ public class Streebog256ManagedFacts : HashAlgorithmTest public void Hash(string message, string expected) => Verify(message, expected); - public static object[][] Data { get; } = new[] - { - new object[] - { + public static object[][] Data { get; } = + [ + [ // "012345678901234567890123456789012345678901234567890123456789012" "3031323334353637383930313233343536373839303132333435363738393031" + "32333435363738393031323334353637383930313233343536373839303132", "9d151eefd8590b89daa6ba6cb74af9275dd051026bb149a452fd84e5e57b5500", - }, - new object[] - { + ], + [ // "Се ветри, Стрибожи внуци, веютъ с моря стрелами на храбрыя плъкы Игоревы" "d1e520e2e5f2f0e82c20d1f2f0e8e1eee6e820e2edf3f6e82c20e2e5fef2fa20" + "f120eceef0ff20f1f2f0e5ebe0ece820ede020f5f0e0e1f0fbff20efebfaeafb20c8e3eef0e5e2fb", "9dd2fe4e90409e5da87f53976d7405b0c0cac628fc669a741d50063c557e8f50", - }, - new object[] - { + ], + [ string.Empty, "3f539a213e97c802cc229d474c6aa32a825a360b2a933a949fd925208d9ce1bb", - }, - }; + ], + ]; } diff --git a/tests/OpenGost.Security.Cryptography.Tests/Streebog512ManagedFacts.cs b/tests/OpenGost.Security.Cryptography.Tests/Streebog512ManagedFacts.cs index c4c2e2a..f3620e3 100644 --- a/tests/OpenGost.Security.Cryptography.Tests/Streebog512ManagedFacts.cs +++ b/tests/OpenGost.Security.Cryptography.Tests/Streebog512ManagedFacts.cs @@ -7,29 +7,26 @@ public class Streebog512ManagedFacts : HashAlgorithmTest public void Hash(string message, string expected) => Verify(message, expected); - public static object[][] Data { get; } = new[] - { - new object[] - { + public static object[][] Data { get; } = + [ + [ // "012345678901234567890123456789012345678901234567890123456789012" "3031323334353637383930313233343536373839303132333435363738393031" + "32333435363738393031323334353637383930313233343536373839303132", "1b54d01a4af5b9d5cc3d86d68d285462b19abc2475222f35c085122be4ba1ffa" + "00ad30f8767b3a82384c6574f024c311e2a481332b08ef7f41797891c1646f48", - }, - new object[] - { + ], + [ // "Се ветри, Стрибожи внуци, веютъ с моря стрелами на храбрыя плъкы Игоревы" "d1e520e2e5f2f0e82c20d1f2f0e8e1eee6e820e2edf3f6e82c20e2e5fef2fa20" + "f120eceef0ff20f1f2f0e5ebe0ece820ede020f5f0e0e1f0fbff20efebfaeafb20c8e3eef0e5e2fb", "1e88e62226bfca6f9994f1f2d51569e0daf8475a3b0fe61a5300eee46d961376" + "035fe83549ada2b8620fcd7c496ce5b33f0cb9dddc2b6460143b03dabac9fb28", - }, - new object[] - { + ], + [ string.Empty, "8e945da209aa869f0455928529bcae4679e9873ab707b55315f56ceb98bef0a7" + "362f715528356ee83cda5f2aac4c6ad2ba3a715c1bcd81cb8e9f90bf4c1c1a8a", - }, - }; + ], + ]; }