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

Represents the secure channel context within which a message is packed/unpacked. More...

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

Public Member Functions

void EncodePayload (byte[] payload, Span< byte > destination)
 Encrypts the payload using the secure channel context.
byte[] DecodePayload (byte[] payload)
 Decodes the payload using the secure channel context.
ReadOnlySpan< byte > GenerateMac (ReadOnlySpan< byte > message, bool isIncoming)
 Generates a new Message Authentication Code.
void InitializeACU (byte[] clientRandomNumber, byte[] clientCryptogram)
 Initializes the Access Control Unit (ACU) in the secure channel context.
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.
ReadOnlySpan< byte > PadTheData (ReadOnlySpan< byte > payload)
 Pads the given data with padding bytes to make it a multiple of a specified length.

Properties

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.
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.
bool IsUsingDefaultKey [get]
 Gets a value indicating whether the secure channel is using the default key.

Detailed Description

Represents the secure channel context within which a message is packed/unpacked.

Definition at line 8 of file IMessageSecureChannel.cs.

Member Function Documentation

◆ DecodePayload()

byte[] OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.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.

Implemented in OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel, and OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ EncodePayload()

void OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.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

Implemented in OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel, and OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

◆ Establish()

void OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.Establish ( byte[] rmac)

Establishes the secure channel with the provided RMAC.

Parameters
rmacThe RMAC.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

◆ GenerateMac()

ReadOnlySpan< byte > OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.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

Implemented in OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel, and OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ InitializeACU()

void OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.InitializeACU ( byte[] clientRandomNumber,
byte[] clientCryptogram )

Initializes the Access Control Unit (ACU) in the secure channel context.

Parameters
clientRandomNumberThe client random number.
clientCryptogramThe client cryptogram.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

◆ PadTheData()

ReadOnlySpan< byte > OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.PadTheData ( ReadOnlySpan< byte > payload)

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.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

◆ ResetSecureChannelSession()

void OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.ResetSecureChannelSession ( )

Resets the secure channel session by creating a new random number.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Property Documentation

◆ IsInitialized

bool OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.IsInitialized
get

Gets a value indicating whether the secure channel is initialized.

true if the secure channel is initialized; otherwise, false.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Definition at line 22 of file IMessageSecureChannel.cs.

◆ IsSecurityEstablished

bool OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.IsSecurityEstablished
get

Indicates whether or not a secure channel has been established on the current message channel.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Definition at line 14 of file IMessageSecureChannel.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ IsUsingDefaultKey

bool OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.IsUsingDefaultKey
get

Gets a value indicating whether the secure channel is using the default key.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Definition at line 40 of file IMessageSecureChannel.cs.

Referenced by OSDP.Net.Messages.IncomingMessage.IncomingMessage().

◆ ServerCryptogram

byte [] OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.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.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Definition at line 35 of file IMessageSecureChannel.cs.

◆ ServerRandomNumber

byte [] OSDP.Net.Messages.SecureChannel.IMessageSecureChannel.ServerRandomNumber
get

Represents the server random number used in the secure channel context.

Implemented in OSDP.Net.Messages.SecureChannel.MessageSecureChannel.

Definition at line 27 of file IMessageSecureChannel.cs.


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