nio_commons

package
v0.2.53 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const KEY_LEN = 1024 * 3

Variables

View Source
var (
	HANDSHAKE = &NioMessage{
		PublicKey: nil,
		Body:      []byte("ACK"),
	}
)

Functions

func Decrypt

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

func DecryptKey

func DecryptKey(data []byte, privateKey *rsa.PrivateKey) ([]byte, error)

func Encrypt

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

func EncryptKey

func EncryptKey(data []byte, key *rsa.PublicKey) ([]byte, error)

func KeysGenerate

func KeysGenerate(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

func KeysGenerateStandard

func KeysGenerateStandard() (*rsa.PrivateKey, *rsa.PublicKey, error)

func NewSessionKey

func NewSessionKey() [32]byte

func NewSessionKeyBytes

func NewSessionKeyBytes() []byte

func Serialize

func Serialize(data interface{}) []byte

Types

type NioMessage

type NioMessage struct {
	PublicKey  *rsa.PublicKey // public key for response
	SessionKey []byte         // session key
	Body       interface{}    // message object
}

func NewMessage

func NewMessage() (instance *NioMessage)

func NewResponseToHandshakeMessage

func NewResponseToHandshakeMessage(sessionKey []byte, clientKey, serverKey *rsa.PublicKey) (instance *NioMessage)

func (*NioMessage) Clone

func (instance *NioMessage) Clone() (response *NioMessage)

func (*NioMessage) GetBodyAsBool

func (instance *NioMessage) GetBodyAsBool() bool

func (*NioMessage) GetBodyAsString

func (instance *NioMessage) GetBodyAsString() string

func (*NioMessage) IsHandshake

func (instance *NioMessage) IsHandshake() bool

func (*NioMessage) IsIdentityDescriptor

func (instance *NioMessage) IsIdentityDescriptor() bool

func (*NioMessage) SetBody

func (instance *NioMessage) SetBody(body interface{}) *NioMessage

type NioSettings

type NioSettings struct {
	Address string `json:"address"`
	// contains filtered or unexported fields
}

func (*NioSettings) Host

func (instance *NioSettings) Host() string

func (*NioSettings) Parse

func (instance *NioSettings) Parse(text string) error

func (*NioSettings) Port

func (instance *NioSettings) Port() int

Jump to

Keyboard shortcuts

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