client

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 7 Imported by: 1

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"}
	ErrDecodePublicKey      = &SClientError{"decode public key"}
	ErrDecodePayloadWrapper = &SClientError{"decode payload wrapper"}
	ErrInvalidDataHash      = &SClientError{"invalid data hash"}
	ErrInvalidHashSign      = &SClientError{"invalid hash sign"}
	ErrEncryptSymmetricKey  = &SClientError{"encrypt symmetric key"}
	ErrDecodeBytesJoiner    = &SClientError{"decode bytes joiner"}
)

Functions

This section is empty.

Types

type IClient

type IClient interface {
	GetMessageSize() uint64
	GetPayloadLimit() uint64

	GetPrivKey() asymmetric.IPrivKey

	EncryptMessage(asymmetric.IPubKey, []byte) ([]byte, error)
	DecryptMessage(asymmetric.IMapPubKeys, []byte) (asymmetric.IPubKey, []byte, error)
}

func NewClient

func NewClient(pPrivKey asymmetric.IPrivKey, pMessageSize uint64) 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

Jump to

Keyboard shortcuts

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