dlcrypto

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dlcrypto implements the key schedule and envelope from PROTOCOL.md sections 4.3-4.5, plus relay tickets from section 6.2.

Index

Constants

This section is empty.

Variables

View Source
var ErrSeq = errors.New("envelope seq out of order")

Functions

func B64

func B64(b []byte) string

func DeviceTicket

func DeviceTicket(relayToken, server, device string) string

func EncodePublic

func EncodePublic(k *ecdh.PublicKey) string

func EnrollTicket

func EnrollTicket(relayToken, server string, expiry int64) string

func GenerateKey

func GenerateKey() (*ecdh.PrivateKey, error)

func Nonce

func Nonce() []byte

func PrivateKey

func PrivateKey(d []byte) (*ecdh.PrivateKey, error)

PrivateKey restores a P-256 key from its 32-byte scalar.

func PublicKey

func PublicKey(s string) (*ecdh.PublicKey, error)

PublicKey decodes a base64url uncompressed P-256 point.

func RandomID

func RandomID(n int) string

RandomID returns n lowercase base32 characters, the format of device and server IDs.

func RandomToken

func RandomToken() string

RandomToken returns 16 random bytes, base64url encoded.

func TicketEqual

func TicketEqual(a, b string) bool

TicketEqual compares tickets in constant time.

func UnB64

func UnB64(s string) ([]byte, error)

Types

type Opener

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

Opener decrypts one direction and enforces strictly sequential seq numbers.

func NewOpener

func NewOpener(key []byte) (*Opener, error)

func (*Opener) Open

func (o *Opener) Open(seq uint64, blob string) ([]byte, error)

type Sealer

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

Sealer encrypts one direction of a connection. Not safe for concurrent use.

func NewSealer

func NewSealer(key []byte) (*Sealer, error)

func (*Sealer) Seal

func (s *Sealer) Seal(plaintext []byte) (uint64, string)

Seal returns the seq used and the base64url ciphertext.

type SessionKeys

type SessionKeys struct {
	Up   []byte // phone to server
	Down []byte // server to phone
	SAS  string
}

func Derive

func Derive(line1, line2 []byte, ephPriv *ecdh.PrivateKey, ephPeer *ecdh.PublicKey,
	staticPriv *ecdh.PrivateKey, staticPeer *ecdh.PublicKey, token []byte) (*SessionKeys, error)

Derive runs the key schedule over the two handshake lines exactly as sent. token is nil except in pair_qr mode.

Jump to

Keyboard shortcuts

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