Categorygithub.com/tunelo/sudp
modulepackage
0.0.0-20241208180827-8fc9be9caaae
Repository: https://github.com/tunelo/sudp.git
Documentation: pkg.go.dev

# README

SUDP (Secure User Datagram Protocol)

Overview

SUDP is a protocol based on UDP that ensures secure communication through encryption and session control between client and server. It includes authentication mechanisms, session management, and encrypted data transmission.

Header Structure

The header contains key information for managing message transmission between the client and server:

FieldTypeDescription
veruint8Protocol version
kinduint8Message type
lenuint16Length of the message
srcuint16Source identifier
dstuint16Destination identifier
epochuint32Epoch identifier for DH key exchange
timeuint64Timestamp
crc32uint32CRC32 (calculated, not transmitted)

Note: The crc32 field is calculated but not transmitted in the header. It is used in the signed portion of the message body.

Handshake Structure

The handshake structure is used during the initial negotiation phase to exchange public keys and digital signatures.

FieldTypeDescription
crc32uint32CRC32 of the header
pubkey[65]byteDH public key
signature[64]byteDigital signature of the message
  • pubkey: The Diffie-Hellman public key used for secure key exchange.
  • signature: A digital signature that authenticates the message.

Control Message Structure

Control messages are used to manage connection state, including KeepAlive, RTT, and epoch acknowledgments.

FieldTypeDescription
crc32uint32CRC32 of the header
ctrluint32Control flags (see below)
datauint64Additional data
signature[64]byteDigital signature of the message

Control Flags

The following control flags manage different connection states:

FlagBit PositionDescription
KeepAlive0KeepAlive message
RTT1Round Trip Time request
KeepAliveAck2Acknowledgment for KeepAlive
EpochAck3Acknowledgment for epoch change

Message Types

The protocol supports the following message types, defined by the kind field in the header:

TypeValueDescription
protocolVersion0x2Current version of the protocol
typeData0x04Encrypted data
typeCtrlMessage0x03Control message
typeServerHandshake0x02Server handshake
typeClientHandshake0x01Client handshake

Data Structure

Data transmitted through SUDP is encrypted using the AES-GCM algorithm to ensure confidentiality and integrity.

FieldTypeDescription
crc32uint32CRC32 of the header
buff[]byteEncrypted data buffer
  • buff: The body of the message, encrypted using AES-GCM for secure transmission.

Summary

SUDP is designed for secure and efficient communication in environments where security is critical. It offers authentication through digital signatures, secure key exchange via DH, and encrypted data transmission using AES-GCM. The protocol is aimed at maintaining message integrity and confidentiality over untrusted networks.

Key Features:

  • Encryption: Data is encrypted using AES-GCM.
  • Authentication: Digital signatures and DH public keys ensure message authenticity.
  • Session Control: Control messages manage the state and synchronization between client and server.

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MarshalECDSAPublicKey serializes an ECDSA public key into PEM format.
No description provided by the author
No description provided by the author
No description provided by the author
UnmarshalECDSAPrivateKey deserializes an ECDSA private key from PEM format.
UnmarshalECDSAPublicKey deserializes an ECDSA public key from PEM format.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
Bit 3.
Definimos constantes para los niveles de log.
No description provided by the author
Definimos constantes para los niveles de log.
Bit 0.
Bit 2.
Bit 1.
No description provided by the author
Definimos constantes para los niveles de log.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LocalAddr represents the local node's address and cryptographic information.
No description provided by the author
RemoteAddr represents a remote peer's address and cryptographic information.
No description provided by the author
No description provided by the author
No description provided by the author