OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
InitialRMac.cs
1using System;
4
6{
10 internal class InitialRMac : PayloadData
11 {
18 public InitialRMac(byte[] rmac, bool serverCryptogramAccepted)
19 {
20 RMac = rmac;
21 ServerCryptogramAccepted = serverCryptogramAccepted;
22 }
23
28 public byte[] RMac { get; }
29
30 public bool ServerCryptogramAccepted { get; }
31
33 public override byte Code => (byte)ReplyType.InitialRMac;
34
36 public override bool IsSecurityInitialization => true;
37
39 public override ReadOnlySpan<byte> SecurityControlBlock()
40 {
41 // osdp_RMAC_I carries SCS_14. Per the OSDP spec (section D.1.3.4) the data byte is 0x01
42 // when the server cryptogram was accepted (secure channel established); 0xFF signals rejection.
43 return new byte[]
44 {
45 0x03,
46 (byte)SecurityBlockType.SecureConnectionSequenceStep4,
47 (byte)(ServerCryptogramAccepted ? 0x01 : 0xff)
48 };
49 }
50
52 public override byte[] BuildData()
53 {
54 return RMac;
55 }
56 }
57}
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.
Definition ReplyType.cs:7