client

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 8 Imported by: 3

Documentation

Overview

Package client makes it possible to encrypt and decrypt messages using a monolithic cryptographic protocol.

CLIENT MESSAGE PROTOCOL

Protocol participants:
	A - sender,
	B - receiver.

Steps of participant A:
1. 	K = G( N ), R = G( N ),
	where
		G - generator pseudo random bytes,
		N - count of bytes for generator,
		K - encryption session key,
		R - pseudo random bytes (salt).
2. 	HP = H( R || P || PubKA || PubKB ),
	where
		HP - message hash,
		H - hash function,
		P - plaintext,
		PubKX - public key of X participant.
3. 	CP = [ E( PubKB, K ), E( K, PubKA ), E( K, R ), E( K, P ), E( K, HP ), E( K, S( PrivKA, HP ) ) ],
	where
		CP - encrypted message,
		E - encryption function,
		S - sign function,
		PrivKX - private key of X participant.

Steps of participant B:
4. 	K = D( PrivKB, E( PubKB, K ) ),
	where
		D - decryption function.
	IF ≠, than protocol is interrupted.
5. 	PubKA = D( K, E( K, PubKA ) ).
	IF ≠, than protocol is interrupted.
6. 	HP = V( PubKA, D( K, E( K, S( PrivKA, D( K, E( K, HP) ) ) ) ) ),
	where
		V - signature verification function.
	IF ≠, than protocol is interrupted.
7. 	HP = H( D( K, E( K, R ) ) || D( K, E( K, P ) ) || PubKA || PubKB ),
	IF ≠, than protocol is interrupted.

More information in article: https://github.com/number571/go-peer/blob/master/docs/monolithic_cryptographic_protocol.pdf
Scheme: https://github.com/number571/go-peer/blob/master/images/go-peer_layer2_message.jpg

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLimitMessageSize     = &SClientError{"limit message size"}
	ErrInitCheckMessage     = &SClientError{"init check message"}
	ErrDecryptCipherKey     = &SClientError{"decrypt cipher key"}
	ErrDecryptPublicKey     = &SClientError{"decrypt public key"}
	ErrInvalidPublicKeySize = &SClientError{"invalid public key size"}
	ErrDecodePayloadWrapper = &SClientError{"decode payload wrapper"}
	ErrInvalidDataHash      = &SClientError{"invalid data hash"}
	ErrInvalidHashSign      = &SClientError{"invalid hash sign"}
	ErrInvalidPayloadSize   = &SClientError{"invalid payload size"}
	ErrDecodePayload        = &SClientError{"decode payload"}
	ErrEncryptSymmetricKey  = &SClientError{"encrypt symmetric key"}
)

Functions

This section is empty.

Types

type IClient

type IClient interface {
	GetSettings() message.ISettings

	GetPubKey() asymmetric.IPubKey
	GetPrivKey() asymmetric.IPrivKey

	GetMessageLimit() uint64

	EncryptPayload(asymmetric.IPubKey, payload.IPayload) (message.IMessage, error)
	DecryptMessage(message.IMessage) (asymmetric.IPubKey, payload.IPayload, error)
}

func NewClient

func NewClient(pSett message.ISettings, pPrivKey asymmetric.IPrivKey) IClient

Create client by private key as identification. Handle function is used when the network exists.

type SClientError added in v1.6.8

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

func (*SClientError) Error added in v1.6.8

func (err *SClientError) Error() string

Directories

Path Synopsis
examples
Package message used as a storage and loading of encrypted messages.
Package message used as a storage and loading of encrypted messages.

Jump to

Keyboard shortcuts

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