Skip to content

Commit 6f1ecd9

Browse files
committed
Update dependencies
Add targetKeyIdentifier parameter to key store update
1 parent b821e9d commit 6f1ecd9

File tree

12 files changed

+59
-32
lines changed

12 files changed

+59
-32
lines changed

KeyManager.Library.KeyStore.HSM_PKCS11/PKCS11KeyStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ public override Task Open()
552552
return Task.CompletedTask;
553553
}
554554

555-
public override async Task<string?> ResolveKeyEntryLink(KeyEntryId keyIdentifier, KeyEntryClass keClass, string? divInput, WrappingKey? wrappingKey)
555+
public override async Task<string?> ResolveKeyEntryLink(KeyEntryId keyIdentifier, KeyEntryClass keClass, string? divInput, WrappingKey? wrappingKey, KeyEntryId? targetKeyIdentifier)
556556
{
557557
log.Info(string.Format("Resolving key entry link with Key Entry Identifier `{0}` and Wrapping Key Entry Identifier `{1}`...", keyIdentifier, wrappingKey?.KeyId));
558558
if (wrappingKey == null || !wrappingKey.KeyId.IsConfigured())

KeyManager.Library.KeyStore.LCP.UI/KeyManager.Library.KeyStore.LCP.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Leosac.WpfApp" Version="1.21.1">
13+
<PackageReference Include="Leosac.WpfApp" Version="1.22.0">
1414
<ExcludeAssets>runtime</ExcludeAssets>
1515
</PackageReference>
1616
<PackageReference Include="MaterialDesignThemes" Version="4.9.0">

KeyManager.Library.KeyStore.LCP/KeyManager.Library.KeyStore.LCP.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Leosac.CredentialProvisioning.API" Version="1.9.0" />
30+
<PackageReference Include="Leosac.CredentialProvisioning.API" Version="1.11.0" />
3131
<PackageReference Include="log4net" Version="2.0.17">
3232
<ExcludeAssets>runtime</ExcludeAssets>
3333
</PackageReference>
3434
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
3535
<ExcludeAssets>runtime</ExcludeAssets>
3636
</PackageReference>
37-
<PackageReference Include="Refit" Version="7.1.1" />
38-
<PackageReference Include="Refit.HttpClientFactory" Version="7.1.1" />
37+
<PackageReference Include="Refit" Version="7.1.2" />
38+
<PackageReference Include="Refit.HttpClientFactory" Version="7.1.2" />
3939
</ItemGroup>
4040

4141
<ItemGroup>

KeyManager.Library.KeyStore.NXP_SAM.Tests/KeyManager.Library.KeyStore.NXP_SAM.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
15-
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
16-
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
15+
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
16+
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
1717
<PackageReference Include="coverlet.collector" Version="6.0.2">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

KeyManager.Library.KeyStore.NXP_SAM.UI/KeyManager.Library.KeyStore.NXP_SAM.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Leosac.WpfApp" Version="1.21.1">
13+
<PackageReference Include="Leosac.WpfApp" Version="1.22.0">
1414
<ExcludeAssets>runtime</ExcludeAssets>
1515
</PackageReference>
1616
<PackageReference Include="MaterialDesignThemes" Version="4.9.0">

KeyManager.Library.KeyStore.NXP_SAM/SAMKeyStore.cs

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,23 +407,23 @@ public override Task Update(IChangeKeyEntry change, bool ignoreIfMissing)
407407
{
408408
log.Info(string.Format("Updating key entry `{0}`...", change.Identifier));
409409

410+
var key = new LibLogicalAccess.Card.DESFireKey();
411+
key.setKeyType(LibLogicalAccess.Card.DESFireKeyType.DF_KEY_AES);
412+
key.setKeyVersion(GetSAMProperties().AuthenticateKeyVersion);
413+
if (!string.IsNullOrEmpty(Properties?.Secret))
414+
{
415+
key.fromString(KeyMaterial.GetValueAsString(Properties.Secret, KeyValueStringFormat.HexStringWithSpace));
416+
}
417+
else
418+
{
419+
key.fromString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
420+
}
421+
410422
if (change is SAMSymmetricKeyEntry samkey)
411423
{
412424
var cmd = Chip?.getCommands();
413425
if (cmd is LibLogicalAccess.Reader.SAMAV2ISO7816Commands av2cmd)
414426
{
415-
var key = new LibLogicalAccess.Card.DESFireKey();
416-
key.setKeyType(LibLogicalAccess.Card.DESFireKeyType.DF_KEY_AES);
417-
key.setKeyVersion(GetSAMProperties().AuthenticateKeyVersion);
418-
if (!string.IsNullOrEmpty(Properties?.Secret))
419-
{
420-
key.fromString(KeyMaterial.GetValueAsString(Properties.Secret, KeyValueStringFormat.HexStringWithSpace));
421-
}
422-
else
423-
{
424-
key.fromString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
425-
}
426-
427427
var natkey = new LibLogicalAccess.Card.AV2SAMKeyEntry();
428428
var infoav2 = new LibLogicalAccess.Card.KeyEntryAV2Information();
429429

@@ -561,6 +561,17 @@ public override Task Update(IChangeKeyEntry change, bool ignoreIfMissing)
561561
throw new KeyStoreException("Inserted SAM is not in AV2 mode, AV1 support has been deprecated, please check to option to auto switch to AV2 or manually perform a Switch.");
562562
}
563563
}
564+
else if (change is KeyEntryCryptogram cryptogram)
565+
{
566+
var cmd = Chip?.getCommands();
567+
if (cmd is LibLogicalAccess.Reader.SAMAV2ISO7816Commands av2cmd)
568+
{
569+
av2cmd.authenticateHost(key, GetSAMProperties().AuthenticateKeyEntryIdentifier);
570+
//av2cmd.activateOfflineKey();
571+
//av2cmd.changeKeyEntryOffline();
572+
throw new NotImplementedException();
573+
}
574+
}
564575
else
565576
{
566577
log.Error("Unsupported Key Entry type for this Key Store.");
@@ -746,7 +757,7 @@ public void UpdateCounter(SAMKeyUsageCounter counter)
746757
log.Info(string.Format("Key usage counter `{0}` updated.", counter.Identifier));
747758
}
748759

749-
public override Task<string?> ResolveKeyEntryLink(KeyEntryId keyIdentifier, KeyEntryClass keClass, string? divInput, WrappingKey? wrappingKey)
760+
public override Task<string?> ResolveKeyEntryLink(KeyEntryId keyIdentifier, KeyEntryClass keClass, string? divInput, WrappingKey? wrappingKey, KeyEntryId? targetKeyIdentifier)
750761
{
751762
log.Info(string.Format("Resolving key entry link with Key Entry Identifier `{0}` and Wrapping Key Entry Identifier `{1}`...", keyIdentifier, wrappingKey?.KeyId));
752763
if (wrappingKey == null || !wrappingKey.KeyId.IsConfigured())
@@ -765,8 +776,23 @@ public void UpdateCounter(SAMKeyUsageCounter counter)
765776
}
766777

767778
byte entry = byte.Parse(keyIdentifier.Id!);
779+
byte targetEntry = entry;
780+
if (targetKeyIdentifier != null)
781+
{
782+
targetEntry = byte.Parse(targetKeyIdentifier.Id!);
783+
}
784+
785+
byte[] div;
786+
if (!string.IsNullOrEmpty(divInput))
787+
{
788+
div = Convert.FromHexString(divInput);
789+
}
790+
else
791+
{
792+
div = Array.Empty<byte>();
793+
}
768794

769-
var keyCipheredVector = av3cmd.encipherKeyEntry(entry, entry, wrappingKey.ChangeCounter ?? 0);
795+
var keyCipheredVector = av3cmd.encipherKeyEntry(entry, targetEntry, wrappingKey.ChangeCounter ?? 0, 0x00, [], new ByteVector(div));
770796
log.Info("Key link completed.");
771797
return Task.FromResult<string?>(Convert.ToHexString(keyCipheredVector.ToArray()));
772798
}

KeyManager.Library.KeyStore.SAM_SE.UI/KeyManager.Library.KeyStore.SAM_SE.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Leosac.WpfApp" Version="1.21.1">
13+
<PackageReference Include="Leosac.WpfApp" Version="1.22.0">
1414
<ExcludeAssets>runtime</ExcludeAssets>
1515
</PackageReference>
1616
<PackageReference Include="MaterialDesignThemes" Version="4.9.0">

KeyManager.Library.Tests/KeyManager.Library.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
15-
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
16-
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
15+
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
16+
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
1717
<PackageReference Include="coverlet.collector" Version="6.0.2">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

KeyManager.Library.UI/Domain/KeyEntryLinkDialogViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public override async Task RunLinkImpl(KeyStore.KeyStore ks)
1313
{
1414
if (KeyEntryLink != null)
1515
{
16-
LinkResult = await ks.ResolveKeyEntryLink(KeyEntryLink.KeyIdentifier, Class, DivInputResult, KeyEntryLink.WrappingKey);
16+
LinkResult = await ks.ResolveKeyEntryLink(KeyEntryLink.KeyIdentifier, Class, DivInputResult, KeyEntryLink.WrappingKey, null);
1717
}
1818
}
1919
}

KeyManager.Library.UI/KeyManager.Library.UI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34-
<PackageReference Include="Leosac.WpfApp" Version="1.21.1" />
34+
<PackageReference Include="Leosac.WpfApp" Version="1.22.0" />
3535
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
3636
<PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.0.5" />
3737
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

0 commit comments

Comments
 (0)