tls

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MIT Imports: 5 Imported by: 0

README

TLS

Steps

  • s1. using rsa negotiate the random aes key
  • s2. encrypt/decryption with aes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TLSClient

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

TLSClient is a client for TLS.

func NewClient

func NewClient(publicKey string) *TLSClient

NewClient creates a new TLS client.

func (*TLSClient) Decrypt

func (t *TLSClient) Decrypt(cipherbytes []byte) (plainbytes []byte, err error)

Decrypt decrypts the ciphertext with the secret.

func (*TLSClient) Encrypt

func (t *TLSClient) Encrypt(plainbytes []byte) (cipherbytes []byte, err error)

Encrypt encrypts the plaintext with the secret.

func (*TLSClient) GetPublicKey

func (t *TLSClient) GetPublicKey() string

GetPublicKey returns the public key.

func (*TLSClient) GetSecret

func (t *TLSClient) GetSecret() string

GetSecret returns the secret.

func (*TLSClient) NegotiateGenerate

func (t *TLSClient) NegotiateGenerate() string

NegotiateGenerate generates a secret and encrypts it with the public key.

The secret is used to encrypt the data.
The hash is used to negotiate the secret.

type TLSServer

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

TLSServer is a server for TLS.

func NewServer

func NewServer(privateKey string) *TLSServer

NewServer creates a new TLS server.

func (*TLSServer) Decrypt

func (t *TLSServer) Decrypt(cipherbytes []byte) (plainbytes []byte, err error)

Decrypt decrypts the ciphertext with the secret.

func (*TLSServer) Encrypt

func (t *TLSServer) Encrypt(plainbytes []byte) (cipherbytes []byte, err error)

Encrypt encrypts the plaintext with the secret.

func (*TLSServer) GetPrivateKey

func (t *TLSServer) GetPrivateKey() string

GetPrivateKey returns the private key.

func (*TLSServer) GetPublicKey

func (t *TLSServer) GetPublicKey() string

GetPublicKey returns the public key.

func (*TLSServer) GetSecret

func (t *TLSServer) GetSecret() string

GetSecret returns the secret.

func (*TLSServer) NegotiateVerify

func (t *TLSServer) NegotiateVerify(hash string) (bool, error)

NegotiateVerify verifies the hash and decrypts the secret.

Jump to

Keyboard shortcuts

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