Documentation ¶
Overview ¶
This file handles reading the smarty telegrams over a serial connection, and splitting in its different tokens using a state machine.
Index ¶
Constants ¶
const GCMTagLength = 12
Variables ¶
This section is empty.
Functions ¶
func ProcessTelegram ¶
Types ¶
type CipherForwarder ¶
type CipherForwarder struct {
// contains filtered or unexported fields
}
Struct allowing to retrieve smarty telegrams, split into initial value, cipher text and gcm tag
func NewCipherForwarder ¶
func NewCipherForwarder(deviceName string) CipherForwarder
Creation of a new CipherForwarder Parameter: * deviceName: the port to listen to Return: * CipherForwarder: a new object to execute methods on
func (*CipherForwarder) Disconnect ¶
func (cf *CipherForwarder) Disconnect()
Disconnect the serial connection
func (*CipherForwarder) GetTelegram ¶
func (cf *CipherForwarder) GetTelegram() (initialValue, cipherText, gcmTag []byte)
Waits for the next telegram and splits it into its tokens If you are to decrypt this result with the Decryptor, you will have to append the gcm tag to the cipher text! Return: * initialValue: the initial value as specified in the smarty documentation * cipherText: the payload * gcmTag: the aes-gcm tag
type Decryptor ¶
type Decryptor struct {
// contains filtered or unexported fields
}
Struct allowing simple decryption of existing telegrams
func NewDecryptor ¶
Creation of a new Decryptor Parameter: * decryptionKey: your smarty key Return: * Decryptor: a new object to execute methods on
func (Decryptor) Decrypt ¶
Decrypt a smarty telegram Parameter: * initialValue: the initial value as specified in the smarty documentation * cipherText: this expects the payload with appended gcm tag at the end (payload + gcmTag)! Return: * plaintText: the decrypted text * ok: true if the decryption was successful
type OnlineDecryptor ¶
type OnlineDecryptor struct {
// contains filtered or unexported fields
}
Struct allowing live capture of smarty telegrams with decryption
func NewOnlineDecryptor ¶
func NewOnlineDecryptor(deviceName, decryptionKey string) OnlineDecryptor
Creation of a new OnlineDecryptor Parameter: * deviceName: the port to listen to * decryptionKey: your smarty key Return: * OnlineDecryptor: a new object to execute methods on
func (*OnlineDecryptor) Disconnect ¶
func (od *OnlineDecryptor) Disconnect()
Disconnect the serial connection
func (*OnlineDecryptor) GetTelegram ¶
func (od *OnlineDecryptor) GetTelegram() (plainText []byte, ok bool)
Waits for the next telegram and decrypts it Return: * plaintText: the decrypted text * ok: true if the decryption was successful