crypto

package
v0.0.0-...-0d8d410 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypto

type Crypto struct {
	PrivateKey      [32]byte
	PublicKey       [32]byte
	ServerKey       [32]byte
	SharedKey       [32]byte
	SessionKey      []byte
	DecryptionNonce CryptoNonce
	EncryptionNonce CryptoNonce
}

it implements all the needed methods to encrypt and decrypt the messages

func NewCrypto

func NewCrypto(serverKey []byte) Crypto

func (*Crypto) DecryptPacket

func (o *Crypto) DecryptPacket(pkt packets.Packet) packets.Packet

func (*Crypto) EncryptPacket

func (o *Crypto) EncryptPacket(pkt packets.Packet) packets.Packet

type CryptoNonce

type CryptoNonce struct {
	EncryptedNonce [24]byte
}

it implements and represents the nonce used to encrypt and decrypt the packets

func NewNonce

func NewNonce(publicKey, serverKey []byte) CryptoNonce

it creates a new nonce object based on the generated public key and the server key

func NewNonceWithNonce

func NewNonceWithNonce(publicKey, serverKey, nonce []byte) CryptoNonce

it creates a new nonce object based on the generated public key, the server key and the received nonce from the server

func NewNonceWithServerNonce

func NewNonceWithServerNonce(nonce []byte) CryptoNonce

it creates a new nonce object based on the received nonce from the server

func (*CryptoNonce) Increment

func (o *CryptoNonce) Increment()

it increments the nonce (we have to increment it every time we encrypt or decrypt a new packet)

Jump to

Keyboard shortcuts

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