security

package
v0.0.0-...-02b3c19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecuritySequenceCounterMin byte = 1
	SecuritySequenceCounterMax      = 15
)

Variables

This section is empty.

Functions

func CalculateHMAC

func CalculateHMAC(payload, key []byte) []byte

func CryptMessage

func CryptMessage(input, iv, key []byte) []byte

func EncryptEBS

func EncryptEBS(key []byte, message []byte) []byte

func GenerateNonce

func GenerateNonce() []byte

Types

type EncryptedMessage

type EncryptedMessage struct {
	SenderNonce      []byte
	EncryptedPayload []byte
	ReceiverNonceID  byte
	HMAC             []byte
}

func (EncryptedMessage) CommandClassID

func (cmd EncryptedMessage) CommandClassID() cc.CommandClassID

func (EncryptedMessage) CommandID

func (cmd EncryptedMessage) CommandID() cc.CommandID

func (EncryptedMessage) CommandIDString

func (cmd EncryptedMessage) CommandIDString() string

func (*EncryptedMessage) MarshalBinary

func (cmd *EncryptedMessage) MarshalBinary() (payload []byte, err error)

func (*EncryptedMessage) UnmarshalBinary

func (cmd *EncryptedMessage) UnmarshalBinary(data []byte) error

type ILayer

type ILayer interface {
	DecryptMessage(cmd serialapi.ApplicationCommand, inclusionMode bool) ([]byte, error)
	EncapsulateMessage(srcNode byte, dstNode byte, commandID cc.CommandID, senderNonce []byte, receiverNonce []byte, payload []byte, inclusionMode bool) (*EncryptedMessage, error)
	GenerateInternalNonce() (Nonce, error)
	GetExternalNonce(key byte) (Nonce, error)
	ReceiveNonce(fromNode byte, report security.NonceReport)
	WaitForExternalNonce(nodeID byte) (Nonce, error)
}

type Layer

type Layer struct {
	// contains filtered or unexported fields
}

func NewLayer

func NewLayer(networkKey []byte) *Layer

func (*Layer) DecryptMessage

func (s *Layer) DecryptMessage(cmd serialapi.ApplicationCommand, inclusionMode bool) ([]byte, error)

@todo verify message hmac

func (*Layer) EncapsulateMessage

func (s *Layer) EncapsulateMessage(
	srcNode byte,
	dstNode byte,
	commandID cc.CommandID,
	senderNonce []byte,
	receiverNonce []byte,
	payload []byte,
	inclusionMode bool,
) (*EncryptedMessage, error)

func (*Layer) GenerateInternalNonce

func (s *Layer) GenerateInternalNonce() (Nonce, error)

GenerateInternalNonce returns a new internal nonce and stores it in the internal nonce table.

NOTE: The Z-Wave docs are not very clear on this, but the "receiver nonce id" is simply the first byte of the nonce (which must be unique among all of the active internal nonces)

func (*Layer) GetExternalNonce

func (s *Layer) GetExternalNonce(key byte) (Nonce, error)

func (*Layer) ReceiveNonce

func (s *Layer) ReceiveNonce(fromNode byte, report security.NonceReport)

ReceiveNonce stores the received nonce in the external nonce table. Additionally, it sets a timeout on the nonce (after which the nonce will be deleted from the nonce table) and notifies any goroutine that may be waiting for a nonce from the given node

func (*Layer) WaitForExternalNonce

func (s *Layer) WaitForExternalNonce(nodeID byte) (Nonce, error)

type Nonce

type Nonce []byte

type NonceTable

type NonceTable struct {
	// contains filtered or unexported fields
}

func NewNonceTable

func NewNonceTable() *NonceTable

func (*NonceTable) Delete

func (t *NonceTable) Delete(key byte)

func (*NonceTable) Generate

func (t *NonceTable) Generate(timeout time.Duration) (Nonce, error)

func (*NonceTable) Get

func (t *NonceTable) Get(key byte) (Nonce, error)

func (*NonceTable) Set

func (t *NonceTable) Set(key byte, nonce Nonce, timeout time.Duration)

type SequenceCounter

type SequenceCounter struct {
	// contains filtered or unexported fields
}

func NewSequenceCounter

func NewSequenceCounter() *SequenceCounter

func (*SequenceCounter) Get

func (s *SequenceCounter) Get(nodeID byte) (counter byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL