crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package crypto provides encryption-related protocol support: TLS deep parsing, encrypted field handling, and authentication protocols.

Index

Constants

This section is empty.

Variables

View Source
var CommonCipherSuites = map[uint16]CipherSuite{
	0x002F: {0x002F, "TLS_RSA_WITH_AES_128_CBC_SHA", "RSA", "AES-128-CBC", "SHA"},
	0x0035: {0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA", "RSA", "AES-256-CBC", "SHA"},
	0xC02F: {0xC02F, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "ECDHE-RSA", "AES-128-GCM", "SHA256"},
	0xC030: {0xC030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "ECDHE-RSA", "AES-256-GCM", "SHA384"},
	0x1301: {0x1301, "TLS_AES_128_GCM_SHA256", "ANY", "AES-128-GCM", "SHA256"},
	0x1302: {0x1302, "TLS_AES_256_GCM_SHA384", "ANY", "AES-256-GCM", "SHA384"},
	0x1303: {0x1303, "TLS_CHACHA20_POLY1305_SHA256", "ANY", "CHACHA20-POLY1305", "SHA256"},
	0xCCA8: {0xCCA8, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "ECDHE-RSA", "CHACHA20-POLY1305", "SHA256"},
}

CommonCipherSuites contains well-known cipher suites.

Functions

func ParseJWT

func ParseJWT(token string) (*JWTHeader, JWTPayload, error)

ParseJWT parses a JWT token without verification.

func ParseTLSRecord

func ParseTLSRecord(data []byte) (map[string]any, error)

ParseTLSRecord parses a TLS record header.

func VerifyHMAC

func VerifyHMAC(message, signature, key []byte) bool

VerifyHMAC verifies an HMAC signature.

Types

type CipherSuite

type CipherSuite struct {
	ID          uint16 `json:"id"`
	Name        string `json:"name"`
	KeyExchange string `json:"key_exchange"`
	Cipher      string `json:"cipher"`
	MAC         string `json:"mac"`
}

CipherSuite describes a TLS cipher suite.

func LookupCipherSuite

func LookupCipherSuite(id uint16) (CipherSuite, bool)

LookupCipherSuite returns info about a cipher suite by ID.

type JWTHeader

type JWTHeader struct {
	Alg string `json:"alg"`
	Typ string `json:"typ"`
}

JWTHeader represents a JWT header.

type JWTPayload

type JWTPayload map[string]any

JWTPayload represents decoded JWT claims.

type SSLKeyLog

type SSLKeyLog struct {
	Label        string
	ClientRandom string
	Secret       string
}

SSLKeyLog represents a parsed SSLKEYLOGFILE entry.

func ParseSSLKeyLog

func ParseSSLKeyLog(content string) []SSLKeyLog

ParseSSLKeyLog parses SSLKEYLOGFILE format entries.

type TLSHandshakeType

type TLSHandshakeType uint8

TLSHandshakeType represents a TLS handshake message type.

const (
	HandshakeClientHello     TLSHandshakeType = 1
	HandshakeServerHello     TLSHandshakeType = 2
	HandshakeCertificate     TLSHandshakeType = 11
	HandshakeServerKeyExch   TLSHandshakeType = 12
	HandshakeServerHelloDone TLSHandshakeType = 14
	HandshakeClientKeyExch   TLSHandshakeType = 16
	HandshakeFinished        TLSHandshakeType = 20
)

func (TLSHandshakeType) String

func (t TLSHandshakeType) String() string

type TLSVersion

type TLSVersion uint16

TLSVersion represents a TLS version.

const (
	TLS10 TLSVersion = 0x0301
	TLS11 TLSVersion = 0x0302
	TLS12 TLSVersion = 0x0303
	TLS13 TLSVersion = 0x0304
)

func (TLSVersion) String

func (v TLSVersion) String() string

Jump to

Keyboard shortcuts

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