OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel Class Reference

Message channel which represents the Access Control Unit (ACU) side of the OSDP communications (i.e. More...

Inheritance diagram for OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel:
OSDP.Net.Messages.SecureChannel.MessageSecureChannel OSDP.Net.Messages.SecureChannel.IMessageSecureChannel

Public Member Functions

 ACUMessageSecureChannel (ILoggerFactory loggerFactory)
 Initializes a new instance of the ACUMessageChannel with logger factory.
override void EncodePayload (byte[] payload, Span< byte > destination)
 Encrypts the payload using the secure channel context.This function can only be called once IsSecurityEstablished is true.
Parameters
payloadPayload to be encrypted. NOTE: This data MUST already be padded in according to OSDP specification: a) there must be at least one byte of padding; b) payloaded is padded with 0x00, except for the very first byte of padding which must be 0x80; c) total length must be divisible by AES block size of 16 bytes.
destinationIdentifies where encoded data is to written to

override byte[] DecodePayload (byte[] payload)
 Decodes the payload using the secure channel context.This function can only be called once IsSecurityEstablished is true
Parameters
payloadPayload to be decrypted
Returns
Plaintext message payload. Similarly to how original payload must have been padded prior to being encrypted, the plaintext byte buffer returned here will also be padded and therefore its length will always be divisible by 16. The padding at the end of the buffer will always consist of zero or more 0x00 bytes preceeded by 0x80 byte.

override ReadOnlySpan< byte > GenerateMac (ReadOnlySpan< byte > message, bool isIncoming)
 Generates a new Message Authentication Code.Note this command IS NOT idempotent as every time it is called it will calculate a new rolling MAC value based on the results of the previous call
Parameters
messageMessage to be signed with a MAC
isIncomingIf true, indicates that the message was received from the wire. If false, indicates that the message is being sent out on the wire
Returns
16-byte MAC value of the message

Public Member Functions inherited from OSDP.Net.Messages.SecureChannel.MessageSecureChannel
byte[] DecodePayload (byte[] payload)
 Decodes the payload using the secure channel context.This function can only be called once IsSecurityEstablished is true
Parameters
payloadPayload to be decrypted
Returns
Plaintext message payload. Similarly to how original payload must have been padded prior to being encrypted, the plaintext byte buffer returned here will also be padded and therefore its length will always be divisible by 16. The padding at the end of the buffer will always consist of zero or more 0x00 bytes preceeded by 0x80 byte.

void EncodePayload (byte[] payload, Span< byte > destination)
 Encrypts the payload using the secure channel context.This function can only be called once IsSecurityEstablished is true.
Parameters
payloadPayload to be encrypted. NOTE: This data MUST already be padded in according to OSDP specification: a) there must be at least one byte of padding; b) payloaded is padded with 0x00, except for the very first byte of padding which must be 0x80; c) total length must be divisible by AES block size of 16 bytes.
destinationIdentifies where encoded data is to written to

ReadOnlySpan< byte > GenerateMac (ReadOnlySpan< byte > message, bool isIncoming)
 Generates a new Message Authentication Code.Note this command IS NOT idempotent as every time it is called it will calculate a new rolling MAC value based on the results of the previous call
Parameters
messageMessage to be signed with a MAC
isIncomingIf true, indicates that the message was received from the wire. If false, indicates that the message is being sent out on the wire
Returns
16-byte MAC value of the message

void InitializeACU (byte[] clientRandomNumber, byte[] clientCryptogram)
 Initializes the Access Control Unit (ACU) in the secure channel context.
Parameters
clientRandomNumberThe client random number.
clientCryptogramThe client cryptogram.

void ResetSecureChannelSession ()
 Resets the secure channel session by creating a new random number.
void Establish (byte[] rmac)
 Establishes the secure channel with the provided RMAC.
Parameters
rmacThe RMAC.

ReadOnlySpan< byte > PadTheData (ReadOnlySpan< byte > data)
 Pads the given data with padding bytes to make it a multiple of a specified length.
Parameters
payloadThe payload data to pad.
Returns
The padded data.

Additional Inherited Members

Protected Member Functions inherited from OSDP.Net.Messages.SecureChannel.MessageSecureChannel
 MessageSecureChannel (SecurityContext context=null, ILoggerFactory loggerFactory=null)
 Initializes a new instance of MessageSecureChannel class.
byte[] GenerateCommandMac (ReadOnlySpan< byte > message)
 Generates a MAC for a command message.
byte[] GenerateReplyMac (ReadOnlySpan< byte > message)
 Generates a MAC for a reply message.
byte[] DecodePayload (byte[] payload, byte[] iv)
 Decodes the payload.
void EncodePayload (byte[] payload, byte[] iv, Span< byte > destination)
 Encodes the payload.
Properties inherited from OSDP.Net.Messages.SecureChannel.MessageSecureChannel
ILogger Logger [get]
 Optional logger instance.
SecurityContext Context [get]
 Security state used by the channel.
bool IsSecurityEstablished [get]
 Indicates whether or not a secure channel has been established on the current message channel.
bool IsInitialized [get]
 Gets a value indicating whether the secure channel is initialized.true if the secure channel is initialized; otherwise, false.
byte[] ServerRandomNumber [get]
 Represents the server random number used in the secure channel context.
byte[] ServerCryptogram [get]
 Represents the secure channel cryptogram used by the server.This property is used to retrieve the server cryptogram for the secure channel context within which a message is packed/unpacked.
bool IsUsingDefaultKey [get]
 Gets a value indicating whether the secure channel is using the default key.

Detailed Description

Message channel which represents the Access Control Unit (ACU) side of the OSDP communications (i.e.

OSDP commands are sent out and replies are received)

Definition at line 10 of file ACUMessageSecureChannel.cs.

Constructor & Destructor Documentation

◆ ACUMessageSecureChannel()

OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel.ACUMessageSecureChannel ( ILoggerFactory loggerFactory)
inline

Initializes a new instance of the ACUMessageChannel with logger factory.

Parameters
loggerFactoryOptional logger factory from which a logger object for the message channel will be acquired

Definition at line 17 of file ACUMessageSecureChannel.cs.

Member Function Documentation

◆ DecodePayload()

override byte[] OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel.DecodePayload ( byte[] payload)

Decodes the payload using the secure channel context.This function can only be called once IsSecurityEstablished is true

Parameters
payloadPayload to be decrypted
Returns
Plaintext message payload. Similarly to how original payload must have been padded prior to being encrypted, the plaintext byte buffer returned here will also be padded and therefore its length will always be divisible by 16. The padding at the end of the buffer will always consist of zero or more 0x00 bytes preceeded by 0x80 byte.

Implements OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.

References OSDP.Net.Messages.SecureChannel.MessageSecureChannel.Context.

◆ EncodePayload()

override void OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel.EncodePayload ( byte[] payload,
Span< byte > destination )
inline

Encrypts the payload using the secure channel context.This function can only be called once IsSecurityEstablished is true.

Parameters
payloadPayload to be encrypted. NOTE: This data MUST already be padded in according to OSDP specification: a) there must be at least one byte of padding; b) payloaded is padded with 0x00, except for the very first byte of padding which must be 0x80; c) total length must be divisible by AES block size of 16 bytes.
destinationIdentifies where encoded data is to written to

Implements OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.

Definition at line 33 of file ACUMessageSecureChannel.cs.

References OSDP.Net.Messages.SecureChannel.MessageSecureChannel.Context, and EncodePayload().

Referenced by EncodePayload().

◆ GenerateMac()

override ReadOnlySpan< byte > OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel.GenerateMac ( ReadOnlySpan< byte > message,
bool isIncoming )

Generates a new Message Authentication Code.Note this command IS NOT idempotent as every time it is called it will calculate a new rolling MAC value based on the results of the previous call

Parameters
messageMessage to be signed with a MAC
isIncomingIf true, indicates that the message was received from the wire. If false, indicates that the message is being sent out on the wire
Returns
16-byte MAC value of the message

Implements OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.

References OSDP.Net.Messages.SecureChannel.MessageSecureChannel.GenerateCommandMac().


The documentation for this class was generated from the following file: