Add GetId
This commit is contained in:
parent
67bb1c7220
commit
674ea8ffd8
@ -280,4 +280,16 @@ public class AESKey
|
||||
new byte[] { 0x2d, 0x00, 0x3f, 0x78 },
|
||||
uid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the ID from the UID and the encryption key (K1)
|
||||
/// </summary>
|
||||
/// <param name="uid">The UID</param>
|
||||
/// <returns>The ID</returns>
|
||||
public byte[] GetId(byte[] uid)
|
||||
{
|
||||
return Derive(Helpers.Concat(
|
||||
new byte[] { 0x2d, 0x00, 0x3f, 0x7b },
|
||||
uid)).ToBytes().Take(7).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.2</Version>
|
||||
<Version>1.0.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@ -6,9 +6,9 @@ namespace BTCPayServer.NTag424;
|
||||
/// <summary>
|
||||
/// The keys saved into the BoltCard
|
||||
/// </summary>
|
||||
/// <param name="AppMasterKey">The key used to call ChangeKey</param>
|
||||
/// <param name="EncryptionKey">The key used to encrypt PICCData (p=)</param>
|
||||
/// <param name="AuthenticationKey">The key used to authenticated PICCData (c=)</param>
|
||||
/// <param name="AppMasterKey">K0: The key used to call ChangeKey</param>
|
||||
/// <param name="EncryptionKey">K1: The key used to encrypt PICCData (p=)</param>
|
||||
/// <param name="AuthenticationKey">K2: The key used to authenticated PICCData (c=)</param>
|
||||
/// <param name="K3">Unused, shouldn't be predictable</param>
|
||||
/// <param name="K4">Unused, shouldn't be predictable</param>
|
||||
public record BoltcardKeys(
|
||||
|
||||
@ -85,6 +85,7 @@ public class UnitTest1
|
||||
Logs.WriteLine("K2: " + keys.AuthenticationKey.ToBytes().ToHex());
|
||||
Logs.WriteLine("K3: " + keys.K3.ToBytes().ToHex());
|
||||
Logs.WriteLine("K4: " + keys.K4.ToBytes().ToHex());
|
||||
Logs.WriteLine("ID: " + keys.EncryptionKey.GetId(uid).ToHex());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -220,7 +221,7 @@ public class UnitTest1
|
||||
await ntag.AuthenticateEV2First(0, AESKey.Default);
|
||||
var uid = await ntag.GetCardUID();
|
||||
var keys = BoltcardKeys.CreateDeterministicKeys(issuerKey, uid, batchId: 0);
|
||||
|
||||
|
||||
// await ntag.ResetCard(keys);
|
||||
await ntag.SetupBoltcard("http://test.com", BoltcardKeys.Default, keys);
|
||||
var message = await ntag.ReadNDef();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user