dtls: github.com/tartabit/dtls Index | Files

package dtls

import "github.com/tartabit/dtls"

Package ccm implements a CCM, Counter with CBC-MAC as per RFC 3610.

See https://tools.ietf.org/html/rfc3610

Package ccm implements a CCM, Counter with CBC-MAC as per RFC 3610.

See https://tools.ietf.org/html/rfc3610


Package Files

alert.go bytereader.go bytewriter.go cipher.go cipher_cbc.go cipher_ccm.go common.go crypto.go debug.go dtls.go handshake.go handshake_clienthello.go handshake_clientkeyexchange.go handshake_finished.go handshake_header.go handshake_helloverifyrequest.go handshake_serverhello.go handshake_serverhellodone.go handshake_serverkeyexchange.go handshake_unknown.go keystore.go log.go peer.go record.go session.go session_cache.go session_handshake.go transport.go transport_udp.go


const (
    AlertType_Warning                uint8 = 1
    AlertType_Fatal                  uint8 = 2
    AlertDesc_CloseNotify            uint8 = 0
    AlertDesc_UnexpectedMessage      uint8 = 10
    AlertDesc_BadRecordMac           uint8 = 20
    AlertDesc_DecryptionFailed       uint8 = 21
    AlertDesc_RecordOverflow         uint8 = 22
    AlertDesc_DecompressionFailure   uint8 = 30
    AlertDesc_HandshakeFailure       uint8 = 40
    AlertDesc_NoCertificate          uint8 = 41
    AlertDesc_BadCertificate         uint8 = 42
    AlertDesc_UnsupportedCertificate uint8 = 43
    AlertDesc_CertificateRevoked     uint8 = 44
    AlertDesc_CertificateExpired     uint8 = 45
    AlertDesc_CertificateUnknown     uint8 = 46
    AlertDesc_IllegalParameter       uint8 = 47
    AlertDesc_UnknownCa              uint8 = 48
    AlertDesc_AccessDenied           uint8 = 49
    AlertDesc_DecodeError            uint8 = 50
    AlertDesc_DecryptError           uint8 = 51
    AlertDesc_ExportRestriction      uint8 = 60
    AlertDesc_ProtocolVersion        uint8 = 70
    AlertDesc_InsufficientSecurity   uint8 = 71
    AlertDesc_InternalError          uint8 = 80
    AlertDesc_UserCanceled           uint8 = 90
    AlertDesc_NoRenegotiation        uint8 = 100
    AlertDesc_UnsupportedExtension   uint8 = 110
    AlertDesc_Noop                   uint8 = 254
const (
    LogLevelError string = "error"
    LogLevelWarn  string = "warn"
    LogLevelInfo  string = "info"
    LogLevelDebug string = "debug"
const (
    ContentType_ChangeCipherSpec ContentType = 20
    ContentType_Alert                        = 21
    ContentType_Handshake                    = 22
    ContentType_Appdata                      = 23
const (
    SessionType_Server string = "server"
    SessionType_Client string = "client"
const (
    AadAuthLen int = 13
const (
    DtlsVersion12 uint16 = 0xFEFD


var DebugEncryption bool = false
var DebugHandshake bool = false
var DebugHandshakeHash bool = false
var HandshakeCompleteCallback func(*Peer, string, time.Duration, error)

This callback is invoked each time a handshake completes, if the handshake failed, the reason is stored in error

var PeerInactivityTimeout = time.Hour * 24
var SessionCacheSweepInterval = time.Minute * -5

set to the interval to look for expired sessions

var SessionCacheTtl = time.Hour * 24

set to whatever you want the cache time to live to be

func DebugAll Uses

func DebugAll()

func GetPskFromKeystore Uses

func GetPskFromKeystore(identity string, remoteAddr string) []byte

func SessionCacheSize Uses

func SessionCacheSize() int

func SetKeyStores Uses

func SetKeyStores(ks []Keystore)

func SetLogFunc Uses

func SetLogFunc(lf LogFunc)

func SetLogLevel Uses

func SetLogLevel(level string)

type CCM Uses

type CCM interface {
    // MaxLength returns the maxium length of plaintext in calls to Seal.
    // The maximum length of ciphertext in calls to Open is MaxLength()+Overhead().
    // The maximum length is related to CCM's `L` parameter (15-noncesize) and
    // is 1<<(8*L) - 1 (but also limited by the maxium size of an int).
    MaxLength() int

CCM is a block cipher in Counter with CBC-MAC mode. Providing authenticated encryption with associated data via the cipher.AEAD interface.

func NewCCM Uses

func NewCCM(b cipher.Block, tagsize, noncesize int) (CCM, error)

NewCCM returns the given 128-bit block cipher wrapped in CCM. The tagsize must be an even integer between 4 and 16 inclusive and is used as CCM's `M` parameter. The noncesize must be an integer between 7 and 13 inclusive, 15-noncesize is used as CCM's `L` parameter.

type Cipher Uses

type Cipher interface {
    GetPrfSize() int
    GenerateKeyBlock(masterSecret []byte, rawKeyBlock []byte) *keyBlock
    Encrypt(rec *record, key []byte, iv []byte, mac []byte) ([]byte, error)
    Decrypt(rec *record, key []byte, iv []byte, mac []byte) ([]byte, error)

type CipherCBC Uses

type CipherCBC struct {
    // contains filtered or unexported fields

func (CipherCBC) Decrypt Uses

func (c CipherCBC) Decrypt(rec *record, key []byte, iv []byte, mac []byte) ([]byte, error)

func (CipherCBC) Encrypt Uses

func (c CipherCBC) Encrypt(rec *record, key []byte, iv []byte, mac []byte) ([]byte, error)

func (CipherCBC) GenerateKeyBlock Uses

func (c CipherCBC) GenerateKeyBlock(masterSecret []byte, rawKeyBlock []byte) *keyBlock

func (CipherCBC) GetPrfSize Uses

func (c CipherCBC) GetPrfSize() int

type CipherCcm Uses

type CipherCcm struct {
    // contains filtered or unexported fields

func (CipherCcm) Decrypt Uses

func (c CipherCcm) Decrypt(rec *record, key []byte, iv []byte, mac []byte) ([]byte, error)

func (CipherCcm) Encrypt Uses

func (c CipherCcm) Encrypt(rec *record, key []byte, iv []byte, mac []byte) ([]byte, error)

func (CipherCcm) GenerateKeyBlock Uses

func (c CipherCcm) GenerateKeyBlock(masterSecret []byte, rawKeyBlock []byte) *keyBlock

func (CipherCcm) GetPrfSize Uses

func (c CipherCcm) GetPrfSize() int

type CipherSuite Uses

type CipherSuite uint16
const (
    CipherSuite_TLS_PSK_WITH_AES_128_CCM_8      CipherSuite = 0xC0A8
    CipherSuite_TLS_PSK_WITH_AES_128_CBC_SHA256 CipherSuite = 0x00ae

type CompressionMethod Uses

type CompressionMethod uint8
const (
    CompressionMethod_Null CompressionMethod = 0

type ContentType Uses

type ContentType uint8

type Keystore Uses

type Keystore interface {
    GetPsk(identity string, remoteAddr string) ([]byte, error)

type KeystoreInMemory Uses

type KeystoreInMemory struct {
    // contains filtered or unexported fields

func NewKeystoreInMemory Uses

func NewKeystoreInMemory() *KeystoreInMemory

func (*KeystoreInMemory) AddKey Uses

func (ks *KeystoreInMemory) AddKey(identity string, psk []byte)

func (*KeystoreInMemory) GetPsk Uses

func (ks *KeystoreInMemory) GetPsk(identity string, remoteAddr string) ([]byte, error)

type Listener Uses

type Listener struct {
    // contains filtered or unexported fields

func NewUdpListener Uses

func NewUdpListener(listener string, readTimeout time.Duration) (*Listener, error)

func (*Listener) AddCipherSuite Uses

func (l *Listener) AddCipherSuite(cipherSuite CipherSuite)

func (*Listener) AddCompressionMethod Uses

func (l *Listener) AddCompressionMethod(compressionMethod CompressionMethod)

func (*Listener) AddPeer Uses

func (l *Listener) AddPeer(addr string, identity string) (*Peer, error)

func (*Listener) AddPeerWithParams Uses

func (l *Listener) AddPeerWithParams(params *PeerParams) (*Peer, error)

func (*Listener) CountPeers Uses

func (l *Listener) CountPeers() int

func (*Listener) FindPeer Uses

func (l *Listener) FindPeer(addr string) (*Peer, error)

func (*Listener) Read Uses

func (l *Listener) Read() ([]byte, *Peer)

func (*Listener) RemovePeer Uses

func (l *Listener) RemovePeer(peer *Peer, alertDesc uint8) error

func (*Listener) RemovePeerByAddr Uses

func (l *Listener) RemovePeerByAddr(addr string, alertDesc uint8) error

func (*Listener) Shutdown Uses

func (l *Listener) Shutdown() error

type LogFunc Uses

type LogFunc func(ts time.Time, level string, peer *Peer, err error, msg string)

type Peer Uses

type Peer struct {
    // contains filtered or unexported fields

func (*Peer) Close Uses

func (p *Peer) Close(alertDesc uint8)

func (*Peer) LastActivity Uses

func (p *Peer) LastActivity() time.Time

func (*Peer) Lock Uses

func (p *Peer) Lock()

func (*Peer) Read Uses

func (p *Peer) Read(timeout time.Duration) ([]byte, error)

func (*Peer) RemoteAddr Uses

func (p *Peer) RemoteAddr() string

func (*Peer) SessionIdentity Uses

func (p *Peer) SessionIdentity() string

func (*Peer) SetName Uses

func (p *Peer) SetName(name string)

func (*Peer) Unlock Uses

func (p *Peer) Unlock()

func (*Peer) UseQueue Uses

func (p *Peer) UseQueue(en bool)

func (*Peer) Write Uses

func (p *Peer) Write(data []byte) error

type PeerParams Uses

type PeerParams struct {
    Addr             string
    Identity         string
    HandshakeTimeout time.Duration
    SessionId        []byte

type Transport Uses

type Transport interface {
    Type() string
    Local() string
    Shutdown() error
    NewEndpoint(address string) TransportEndpoint
    ReadPacket() ([]byte, TransportEndpoint, error)

type TransportEndpoint Uses

type TransportEndpoint interface {
    String() string
    WritePacket(data []byte) error

func NewUdpPeerFromSocket Uses

func NewUdpPeerFromSocket(socket *net.UDPConn, addr *net.UDPAddr) TransportEndpoint

Package dtls imports 19 packages (graph). Updated 2020-12-03. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).