Skip to content

Commit

Permalink
Add SAM UID to log file and Get Version tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Oct 10, 2023
1 parent 11354b3 commit dd94765
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,28 @@ private void SAMGetVersion()
var chip = (KeyStore as SAMKeyStore)?.Chip;
var cmd = chip?.getCommands();
var ctype = chip?.getCardType();
var rctype = string.Empty;

LibLogicalAccess.Card.SAMVersion? version = null;
if (cmd is SAMAV1ISO7816Commands samav1cmd)
{
version = samav1cmd.getVersion();
rctype = samav1cmd.getSAMTypeFromSAM();
}
else if (cmd is SAMAV2ISO7816Commands samav2cmd)
{
version = samav2cmd.getVersion();
rctype = samav2cmd.getSAMTypeFromSAM();
}

var msg = string.Format("Card Type: {0}", ctype);
if (!string.IsNullOrEmpty(rctype))
{
msg += Environment.NewLine + string.Format("Real Card Type: {0}", rctype);
}
if (version != null)
{
msg += Environment.NewLine + string.Format("UID: {0}", Convert.ToHexString(version.manufacture.uniqueserialnumber));
msg += Environment.NewLine + string.Format("Software Version: {0}.{1}", version.software.majorversion, version.software.minorversion);
msg += Environment.NewLine + string.Format("Hardware Version: {0}.{1}", version.hardware.majorversion, version.hardware.minorversion);
}
Expand Down
16 changes: 16 additions & 0 deletions KeyManager.Library.KeyStore.NXP_SAM/SAMKeyStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ public override Task Open()
if (String.Compare(genericType, "SAM") >= 0)
{
Chip = chip;

var cmd = chip.getCommands();
LibLogicalAccess.Card.SAMVersion? version = null;
if (cmd is SAMAV2ISO7816Commands av1cmd)
{
version = av1cmd.getVersion();
}
else if (cmd is SAMAV2ISO7816Commands av2cmd)
{
version = av2cmd.getVersion();
}

if (version != null)
{
log.Info(string.Format("SAM Version {0}.{1}, UID: {2}", version.software.majorversion, version.software.minorversion, Convert.ToHexString(version.manufacture.uniqueserialnumber)));
}
}
else
{
Expand Down

0 comments on commit dd94765

Please sign in to comment.