Documentation
¶
Index ¶
- Constants
- Variables
- func CiphertextHeaderFirstByte(hasCID bool, has16bitSeqNum bool, hasLength bool, epoch uint16) byte
- func IsEncryptedRecord(fb byte) bool
- func RecordNumberCmp(a, b Number) int
- type AckParser
- type Alert
- type Encrypted
- func (hdr *Encrypted) ClosestSequenceNumber(seqNumData []byte, expectedSN uint64) (uint16, uint64)
- func (hdr *Encrypted) Epoch() byte
- func (hdr *Encrypted) Has16BitSeqNum() bool
- func (hdr *Encrypted) HasCID() bool
- func (hdr *Encrypted) HasLength() bool
- func (hdr *Encrypted) MatchesEpoch(epoch uint16) bool
- func (hdr *Encrypted) Parse(datagram []byte, cIDLength int) (n int, err error)
- type Number
- type Plaintext
- type PlaintextHeader
Constants ¶
View Source
const ( // we use 0 as "no alert" indicator AlerLevelWarning = 1 AlerLevelFatal = 2 )
View Source
const ( RecordTypeAlert = 21 RecordTypeHandshake = 22 RecordTypeApplicationData = 23 // PlaintextContentTypeHeartbeat = 24 // [rfc6520] should not be received without negotiating extension. We choose to error on it. RecordTypeAck = 26 )
View Source
const AckElementSize = 16
View Source
const AckHeaderSize = 2
View Source
const AlertSize = 2
View Source
const MaxCiphertextRecordLength = MaxPlaintextRecordLength + 256 // [rfc8446:5.2]
View Source
const MaxPlaintextRecordLength = 16384 // [rfc8446:5.1]
View Source
const MaxSeq = 0xFFFFFFFFFFFF
View Source
const OutgoingCiphertextRecordHeader16 = 5 // first byte + 8-bit seqnum + 16-bit length
View Source
const OutgoingCiphertextRecordHeader8 = 4 // first byte + 16-bit seqnum + 16-bit length
This does not include CID size and AEAD seal, they are deterministic but depend on runtime parameters
View Source
const PlaintextRecordHeaderSize = 13
Variables ¶
View Source
var ErrAckRecordWrongSize = errors.New("ack record size not multiple of 16")
View Source
var ErrAlertLevelParsing = errors.New("alert level failed to parse")
View Source
var ErrCiphertextRecordBodyTooLong = errors.New("cipher text record body exceeds 2^14 + 256")
View Source
var ErrCiphertextRecordTooShort = errors.New("cipher text record header too short")
View Source
var ErrCiphertextRecordTooShortLength = errors.New("cipher text record body too short (explicit length)")
View Source
var ErrPlaintextRecordBodyEpochNonZero = errors.New("plaintext record body non zero epoch")
View Source
var ErrPlaintextRecordBodyTooLong = errors.New("plaintext record body exceeds 2^14")
View Source
var ErrPlaintextRecordBodyTooShort = errors.New("plaintext record body too short")
View Source
var ErrPlaintextRecordHeaderTooShort = errors.New("plaintext record header too short")
View Source
var ErrPlaintextRecordWrongLegacyRecordVersion = errors.New("plaintext record wrong legacy record version")
View Source
var ErrRecordTypeFailedToParse = errors.New("record type failed to parse")
Functions ¶
func IsEncryptedRecord ¶
func RecordNumberCmp ¶
Types ¶
type AckParser ¶
type AckParser struct {
// contains filtered or unexported fields
}
func NewAckParser ¶
return by value to signal usage pattern
type Alert ¶
func AlertCloseNormal ¶
func AlertCloseNormal() Alert
type Encrypted ¶
type Encrypted struct {
FirstByte byte
CID []byte // alias to original slice
SeqNum []byte // alias to original slice to be encrypted/decrypted in place
Header []byte // alias to original slice for AEAD
// Length is checked, not stored
Ciphertext []byte // alias to original slice
}
func (*Encrypted) ClosestSequenceNumber ¶
func (*Encrypted) Has16BitSeqNum ¶
func (*Encrypted) MatchesEpoch ¶
type Plaintext ¶
type PlaintextHeader ¶
Click to show internal directories.
Click to hide internal directories.