client

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

README

auth-client

A simple mqtt client that supports sm9-based authentication

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OfbEncrypt added in v0.0.8

func OfbEncrypt(key, data []byte) ([]byte, error)

Types

type Client

type Client struct {
	ServerUrl   *url.URL
	AuthHandler *Sm9Auth
	User        *User
	Cm          *autopaho.ConnectionManager
	Cancel      context.CancelFunc
	Config      *ClientConfig
	MsgHandler  paho.MessageHandler
}

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Disconnect

func (c *Client) Disconnect() error

func (*Client) Publish

func (c *Client) Publish(topic, payload string) error

func (*Client) SetMsgHandler added in v0.0.6

func (c *Client) SetMsgHandler(handler paho.MessageHandler)

func (*Client) Subscribe

func (c *Client) Subscribe(topic string) error

type ClientConfig added in v0.0.2

type ClientConfig struct {
	Name              string
	Topic             string
	Qos               byte
	Keepalive         uint16
	ConnectRetryDelay uint16
	Debug             bool
}

type Sm9Auth

type Sm9Auth struct {
	Random1 string
	Server  *User
	// contains filtered or unexported fields
}

func NewSm9Auth

func NewSm9Auth(c *Client) *Sm9Auth

func (*Sm9Auth) Authenticate

func (s *Sm9Auth) Authenticate(a *paho.Auth) *paho.Auth

func (*Sm9Auth) Authenticated

func (s *Sm9Auth) Authenticated()

func (*Sm9Auth) GetRandom1

func (s *Sm9Auth) GetRandom1(expectedLen int) string

type User

type User struct {
	Uid        []byte
	Hid        byte
	SessionKey []byte
	// contains filtered or unexported fields
}

func NewUser

func NewUser(conf *UserConfig) *User

func (*User) GetEncryptMasterPublicKey added in v0.0.2

func (u *User) GetEncryptMasterPublicKey() *sm9.EncryptMasterPublicKey

func (*User) GetEncryptPrivateKey added in v0.0.2

func (u *User) GetEncryptPrivateKey() *sm9.EncryptPrivateKey

func (*User) GetSignMasterPublicKey added in v0.0.2

func (u *User) GetSignMasterPublicKey() *sm9.SignMasterPublicKey

func (*User) GetSignPrivateKey added in v0.0.2

func (u *User) GetSignPrivateKey() *sm9.SignPrivateKey

func (*User) SetEncryptMasterPublicKey added in v0.0.2

func (u *User) SetEncryptMasterPublicKey(encMasterPublicKey string) error

func (*User) SetEncryptPrivateKey added in v0.0.2

func (u *User) SetEncryptPrivateKey(encPrivateKey string) error

func (*User) SetSignMasterPublicKey added in v0.0.2

func (u *User) SetSignMasterPublicKey(signMasterPublicKey string) error

func (*User) SetSignPrivateKey added in v0.0.2

func (u *User) SetSignPrivateKey(signPrivateKey string) error

type UserConfig added in v0.0.5

type UserConfig struct {
	Uid                    string `yaml:"uid"`
	Hid                    byte   `yaml:"hid"`
	EncryptPrivateKey      string `yaml:"encrypt_private_key"`
	SignPrivateKey         string `yaml:"sign_private_key"`
	EncryptMasterPublicKey string `yaml:"encrypt_master_public_key"`
	SignMasterPublicKey    string `yaml:"sign_master_public_key"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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