OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ServerCryptogramData.cs
1using System;
4
6
12{
14 public ServerCryptogramData(byte[] serverCryptogram, bool isDefaultKey)
15 {
16 ServerCryptogram = serverCryptogram ?? throw new ArgumentNullException(nameof(serverCryptogram));
17 IsDefaultKey = isDefaultKey;
18 }
19
24 public byte[] ServerCryptogram { get; }
25
30 public bool IsDefaultKey { get; }
31
33 public override CommandType CommandType => CommandType.ServerCryptogram;
34
36 public override byte Code => (byte)CommandType;
37
39 public override bool IsSecurityInitialization => true;
40
42 public override ReadOnlySpan<byte> SecurityControlBlock()
43 {
44 return new byte[]
45 {
46 0x03,
47 (byte)SecurityBlockType.SecureConnectionSequenceStep3,
48 (byte)(IsDefaultKey ? 0x00 : 0x01)
49 };
50 }
51
53 public override byte[] BuildData()
54 {
55 return ServerCryptogram;
56 }
57
64 public static ServerCryptogramData ParseData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> securityControlBlock)
65 {
66 return new ServerCryptogramData(data.ToArray(), securityControlBlock[2] == 0x01);
67 }
68}
Base class representing a payload of a PD command message.
static ServerCryptogramData ParseData(ReadOnlySpan< byte > data, ReadOnlySpan< byte > securityControlBlock)
Parses the message payload bytes.
byte[] ServerCryptogram
Gets the cryptographic data provided by the server during a secure communication exchange.
override ReadOnlySpan< byte > SecurityControlBlock()
bool IsDefaultKey
Indicates whether the default encryption key is used for secure communications.
ServerCryptogramData(byte[] serverCryptogram, bool isDefaultKey)
SecurityBlockType
Security Block Type values as defined by OSDP protocol.