Refactor and update test projects, remove obsolete tests, and upgrade dependencies
- Deleted obsolete test files for SchedulerAuditService and SchedulerMongoSessionFactory. - Removed unused TestDataFactory class. - Updated project files for Mongo.Tests to remove references to deleted files. - Upgraded BouncyCastle.Cryptography package to version 2.6.2 across multiple projects. - Replaced Microsoft.Extensions.Http.Polly with Microsoft.Extensions.Http.Resilience in Zastava.Webhook project. - Updated NetEscapades.Configuration.Yaml package to version 3.1.0 in Configuration library. - Upgraded Pkcs11Interop package to version 5.1.2 in Cryptography libraries. - Refactored Argon2idPasswordHasher to use BouncyCastle for hashing instead of Konscious. - Updated JsonSchema.Net package to version 7.3.2 in Microservice project. - Updated global.json to use .NET SDK version 10.0.101.
This commit is contained in:
@@ -3,16 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Net.Pkcs11Interop.Common;
|
||||
using Net.Pkcs11Interop.HighLevelAPI;
|
||||
using Net.Pkcs11Interop.HighLevelAPI.Factories;
|
||||
using StellaOps.Cryptography;
|
||||
using ISession = Net.Pkcs11Interop.HighLevelAPI.Session;
|
||||
|
||||
namespace StellaOps.Cryptography.Plugin.Pkcs11Gost;
|
||||
|
||||
internal static class Pkcs11SignerUtilities
|
||||
{
|
||||
private static readonly Pkcs11InteropFactories Factories = new();
|
||||
|
||||
public static byte[] SignDigest(Pkcs11GostKeyEntry entry, ReadOnlySpan<byte> digest)
|
||||
{
|
||||
using var pkcs11 = new Pkcs11(entry.Session.LibraryPath, AppType.MultiThreaded);
|
||||
using var pkcs11 = Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Factories, entry.Session.LibraryPath, AppType.MultiThreaded);
|
||||
var slot = ResolveSlot(pkcs11, entry.Session);
|
||||
if (slot is null)
|
||||
{
|
||||
@@ -36,7 +38,7 @@ internal static class Pkcs11SignerUtilities
|
||||
throw new InvalidOperationException($"Private key with label '{entry.Session.PrivateKeyLabel}' was not found.");
|
||||
}
|
||||
|
||||
var mechanism = new Mechanism(entry.SignMechanismId);
|
||||
using var mechanism = Factories.MechanismFactory.Create(entry.SignMechanismId);
|
||||
return session.Sign(mechanism, privateHandle, digest.ToArray());
|
||||
}
|
||||
finally
|
||||
@@ -48,7 +50,7 @@ internal static class Pkcs11SignerUtilities
|
||||
}
|
||||
}
|
||||
|
||||
private static Slot? ResolveSlot(Pkcs11 pkcs11, Pkcs11SessionOptions options)
|
||||
private static ISlot? ResolveSlot(IPkcs11Library pkcs11, Pkcs11SessionOptions options)
|
||||
{
|
||||
var slots = pkcs11.GetSlotList(SlotsType.WithTokenPresent);
|
||||
if (slots.Count == 0)
|
||||
@@ -74,16 +76,16 @@ internal static class Pkcs11SignerUtilities
|
||||
return slots[0];
|
||||
}
|
||||
|
||||
private static ObjectHandle? FindObject(ISession session, CKO objectClass, string? label)
|
||||
private static IObjectHandle? FindObject(ISession session, CKO objectClass, string? label)
|
||||
{
|
||||
var template = new List<ObjectAttribute>
|
||||
var template = new List<IObjectAttribute>
|
||||
{
|
||||
new(CKA.CKA_CLASS, (uint)objectClass)
|
||||
Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, (uint)objectClass)
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(label))
|
||||
{
|
||||
template.Add(new ObjectAttribute(CKA.CKA_LABEL, label));
|
||||
template.Add(Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL, label));
|
||||
}
|
||||
|
||||
var handles = session.FindAllObjects(template);
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" />
|
||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.15.0" />
|
||||
<PackageReference Include="Pkcs11Interop" Version="4.1.0" />
|
||||
<PackageReference Include="Pkcs11Interop" Version="5.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user