replaydetector

package
v3.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 1 Imported by: 6

Documentation

Overview

Package replaydetector provides packet replay detection algorithm.

Example (FixedBigInt_SetBit)
bi := newFixedBigInt(224)

bi.SetBit(0)
fmt.Println(bi.String())
bi.Lsh(1)
fmt.Println(bi.String())

bi.Lsh(0)
fmt.Println(bi.String())

bi.SetBit(10)
fmt.Println(bi.String())
bi.Lsh(20)
fmt.Println(bi.String())

bi.SetBit(80)
fmt.Println(bi.String())
bi.Lsh(4)
fmt.Println(bi.String())

bi.SetBit(130)
fmt.Println(bi.String())
bi.Lsh(64)
fmt.Println(bi.String())

bi.SetBit(7)
fmt.Println(bi.String())

bi.Lsh(129)
fmt.Println(bi.String())

for i := 0; i < 256; i++ {
	bi.Lsh(1)
	bi.SetBit(0)
}
fmt.Println(bi.String())
Output:

0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000402
0000000000000000000000000000000000000000000000000000000040200000
0000000000000000000000000000000000000000000100000000000040200000
0000000000000000000000000000000000000000001000000000000402000000
0000000000000000000000000000000400000000001000000000000402000000
0000000000000004000000000010000000000004020000000000000000000000
0000000000000004000000000010000000000004020000000000000000000080
0000000004000000000000000000010000000000000000000000000000000000
00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReplayDetector

type ReplayDetector interface {
	// Check returns true if given sequence number is not replayed.
	// Call accept() to mark the packet is received properly.
	// The return value of accept() indicates whether the accepted packet is
	// has the latest observed sequence number.
	Check(seq uint64) (accept func() bool, ok bool)
}

ReplayDetector is the interface of sequence replay detector.

func New

func New(windowSize uint, maxSeq uint64) ReplayDetector

New creates ReplayDetector. Created ReplayDetector doesn't allow wrapping. It can handle monotonically increasing sequence number up to full 64bit number. It is suitable for DTLS replay protection.

func WithWrap

func WithWrap(windowSize uint, maxSeq uint64) ReplayDetector

WithWrap creates ReplayDetector allowing sequence wrapping. This is suitable for short bit width counter like SRTP and SRTCP.

Jump to

Keyboard shortcuts

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