11 internal class ChallengeResponse : PayloadData
20 public ChallengeResponse(
byte[] cUID,
byte[] rndB,
byte[] cryptogram,
bool isUsingDefaultKey)
24 Cryptogram = cryptogram;
25 IsUsingDefaultKey = isUsingDefaultKey;
31 public byte[] ClientUID {
get; }
36 public byte[] RndB {
get; }
41 public byte[] Cryptogram {
get; }
43 public bool IsUsingDefaultKey {
get; }
49 public static ChallengeResponse ParseData(ReadOnlySpan<byte> data,
bool isDefaultKey)
51 if (data.Length != 32)
53 throw new InvalidPayloadException($
"Challenge response must be 32 bytes, received {data.Length}");
56 return new ChallengeResponse(
57 data.Slice(0, 8).ToArray(),
58 data.Slice(8, 8).ToArray(),
59 data.Slice(16, 16).ToArray(),
67 var payload =
new byte[ClientUID.Length + RndB.Length + Cryptogram.Length];
68 ClientUID.CopyTo(payload, 0);
69 RndB.CopyTo(payload, ClientUID.Length);
70 Cryptogram.CopyTo(payload, ClientUID.Length + RndB.Length);
76 public override byte Code => (byte)
ReplyType.CrypticData;
79 public override bool IsSecurityInitialization =>
true;
88 (
byte)(IsUsingDefaultKey ? 0x00 : 0x01)
ReadOnlySpan< byte > SecurityControlBlock()
Retrieves the security control block for a specific command data type.
byte[] BuildData()
Converts the payload into a byte array to be sent over the wire.
SecurityBlockType
Security Block Type values as defined by OSDP protocol.
ReplyType
Identifies the type of OSDP protocol reply (PD -> ACU) message.