segment

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

Path segment types.

Variables

This section is empty.

Functions

func PathSegmentToPB

func PathSegmentToPB(ps *PathSegment) *cppb.PathSegment

PathSegmentToPB translates a path segment to the protobuf encoding.

Types

type ASEntry

type ASEntry struct {
	// Signed contains the signed ASentry. It is used for signature input.
	Signed *cryptopb.SignedMessage
	// Local is the ISD-AS of the AS correspoding to this entry.
	Local addr.IA
	// Next is the ISD-AS of the downstream AS.
	Next addr.IA
	// HopEntry is the entry to create regular data plane paths.
	HopEntry HopEntry
	// PeerEntries is a list of entries to create peering data plane paths.
	PeerEntries []PeerEntry
	// MTU is the AS internal MTU.
	MTU int
	// Extensions holds all the beaconing extensions.
	Extensions Extensions
	// UnsignedExtensions holds all the unsigned beaconing extensions.
	UnsignedExtensions UnsignedExtensions
}

func ASEntryFromPB

func ASEntryFromPB(pb *cppb.ASEntry) (ASEntry, error)

ASEntryFromPB creates an AS entry from the protobuf representation.

type Extensions

type Extensions struct {
	HiddenPath HiddenPathExtension
	StaticInfo *staticinfo.Extension
	Digests    *digest.Extension
}

type HiddenPathExtension

type HiddenPathExtension struct {
	IsHidden bool
}

type HopEntry

type HopEntry struct {
	// HopField contains the necessary information to create a data-plane hop.
	HopField HopField
	// IngressMTU is the MTU on the ingress link.
	IngressMTU int
}

type HopField

type HopField struct {
	ExpTime     uint8
	ConsIngress uint16
	ConsEgress  uint16
	MAC         [path.MacLen]byte
}

type Info

type Info struct {
	// Raw contains the encoded path segment information. It is used for
	// signature input and must not be modified.
	Raw []byte
	// Timestamp is the path segment creation time.
	Timestamp time.Time
	// SegmentID is the segment ID used in data plane hop field computation.
	SegmentID uint16
}

Info represents the path segment information.

func NewInfo

func NewInfo(timestamp time.Time, segmentID uint16) (Info, error)

NewInfo creates a new path segment info.

func (Info) String

func (info Info) String() string

type Meta

type Meta struct {
	Segment *PathSegment
	Type    Type
}

Meta holds the path segment with its type.

type PathSegment

type PathSegment struct {
	Info Info
	// ASEntries is the list of AS entries. Call AddASEntry to extend the list.
	ASEntries []ASEntry
}

func BeaconFromPB

func BeaconFromPB(pb *cppb.PathSegment) (*PathSegment, error)

BeaconFromPB translates a protobuf path Beacon.

func CreateSegment

func CreateSegment(timestamp time.Time, segID uint16) (*PathSegment, error)

CreateSegment creates a new path segment. The AS entries should be added using AddASEntry.

func SegmentFromPB

func SegmentFromPB(pb *cppb.PathSegment) (*PathSegment, error)

SegmentFromPB translates a protobuf path segment.

func (*PathSegment) AddASEntry

func (ps *PathSegment) AddASEntry(ctx context.Context, asEntry ASEntry, signer Signer) error

AddASEntry adds the AS entry and signs the resulting path segment. The signature is created and does not need to be attached to the input AS entry.

func (*PathSegment) FirstIA

func (ps *PathSegment) FirstIA() addr.IA

FirstIA returns the IA of the first ASEntry. Note that if the path segment contains no ASEntries this method will panic.

func (*PathSegment) FullID

func (ps *PathSegment) FullID() []byte

FullID returns a hash of the segment covering all hops including peerings.

func (*PathSegment) GetLoggingID

func (ps *PathSegment) GetLoggingID() string

func (*PathSegment) ID

func (ps *PathSegment) ID() []byte

ID returns a hash of the segment covering all hops, except for peerings.

func (*PathSegment) LastIA

func (ps *PathSegment) LastIA() addr.IA

LastIA returns the IA of the last ASEntry. Note that if the path segment contains no ASEntries this method will panic.

func (*PathSegment) MaxExpiry

func (ps *PathSegment) MaxExpiry() time.Time

MaxExpiry returns the maximum expiry of all hop fields. Assumes segment is validated.

func (*PathSegment) MaxIdx

func (ps *PathSegment) MaxIdx() int

MaxIdx returns the index of the last AS entry.

func (*PathSegment) MinExpiry

func (ps *PathSegment) MinExpiry() time.Time

MinExpiry returns the minimum expiry of all hop fields. Assumes segment is validated.

func (*PathSegment) ShallowCopy

func (ps *PathSegment) ShallowCopy() *PathSegment

ShallowCopy creates a shallow copy of the path segment.

func (*PathSegment) String

func (ps *PathSegment) String() string

func (*PathSegment) Validate

func (ps *PathSegment) Validate(validationMethod ValidationMethod) error

Validate validates that remote ingress and egress ISD-AS for each AS entry are consistent with the segment. In case a beacon is validated, the egress ISD-AS of the last AS entry is ignored.

func (*PathSegment) Verify

func (ps *PathSegment) Verify(ctx context.Context, verifier Verifier) error

Verify verifies each AS entry.

func (*PathSegment) VerifyASEntry

func (ps *PathSegment) VerifyASEntry(ctx context.Context, verifier Verifier, idx int) error

VerifyASEntry verifies the AS Entry at the specified index.

type PeerEntry

type PeerEntry struct {
	// HopField contains the necessary information to create a data-plane hop.
	HopField HopField
	// Peer is the ISD-AS of the peering AS.
	Peer addr.IA
	// PeerInterface is the interface ID of the peering link on the remote
	// peering AS side.
	PeerInterface uint16
	// PeerMTU is the MTU on the peering link.
	PeerMTU int
}

type Segments

type Segments []*PathSegment

Segments is just a helper type to have additional methods on top of a slice of PathSegments.

func (*Segments) FilterSegs

func (segs *Segments) FilterSegs(keep func(*PathSegment) (bool, error)) (int, error)

FilterSegs filters the given segs and only keeps the segments for which keep returns true. Modifies segs in-place. Returns the number of segments filtered out. If keep returns an error the method is aborted and the error is returned, segs might have been modified.

func (Segments) FirstIAs

func (segs Segments) FirstIAs() []addr.IA

FirstIAs returns the slice of FirstIAs in the given segments. Each FirstIA appears just once.

func (Segments) LastIAs

func (segs Segments) LastIAs() []addr.IA

LastIAs returns the slice of LastIAs in the given segments. Each LastIA appears just once.

type Signer

type Signer interface {
	// Sign signs the AS entry and returns the signature meta data.
	Sign(ctx context.Context, msg []byte, associatedData ...[]byte) (*cryptopb.SignedMessage, error)
}

Signer signs path segments.

type Type

type Type int

Type is the path segment type.

func (Type) String

func (t Type) String() string

type UnsignedExtensions

type UnsignedExtensions struct {
	// EpicDetached contains the detachable epic authenticators. It is nil
	// if it was detached (or never added).
	EpicDetached *epic.Detached
}

type ValidationMethod

type ValidationMethod bool

ValidationMethod is the method that is used during validation.

const (
	// ValidateSegment validates that remote ingress and egress ISD-AS for
	// each AS entry are consistent with the segment. The ingress ISD-AS of
	// the first entry, and the egress ISD-AS of the last entry must be the
	// zero value. Additionally, it is validated that each hop field is
	// parsable.
	ValidateSegment ValidationMethod = false
	// ValidateBeacon validates the segment in the same manner as
	// ValidateSegment, except for the last AS entry. The egress values for
	// the last AS entry are ignored, since they are under construction in
	// a beacon.
	ValidateBeacon ValidationMethod = true
)

type Verifier

type Verifier interface {
	// Verify verifies the AS entry based on the signature meta data.
	Verify(ctx context.Context, signedMsg *cryptopb.SignedMessage,
		associatedData ...[]byte) (*signed.Message, error)
}

Verifier verifies path segments.

Directories

Path Synopsis
extensions
staticinfo
Package staticinfo contains the internal representation of the StaticInfoExtension path segment extension, and conversion from and to the corresponding protobuf representation.
Package staticinfo contains the internal representation of the StaticInfoExtension path segment extension, and conversion from and to the corresponding protobuf representation.
Package mock_seg is a generated GoMock package.
Package mock_seg is a generated GoMock package.

Jump to

Keyboard shortcuts

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