section

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllAllowedNetworkObjects

func AllAllowedNetworkObjects() []object.Object

AllAllowedNetworkObjects returns a list of objects that are allowed for network subjectAddresses; with valid content

func AllObjectType

func AllObjectType() []object.Type

Allobject.Types returns all object types

func AllQueryOptions

func AllQueryOptions() []query.Option

AllQueryOptions returns all query options

func GetQuery

func GetQuery() *query.Name

GetQuery returns a query with all query options set and querying all types.

func Intersect

func Intersect(a, b Interval) bool

Intersect returns true if a and b are overlapping

func Signature

func Signature() signature.Sig

Signature returns a signature object with all fields set except signature data.

func UpdateValidity

func UpdateValidity(validSince, validUntil, oldValidSince, oldValidUntil int64,
	maxValidity time.Duration) (int64, int64)

Types

type Assertion

type Assertion struct {
	Signatures  []signature.Sig
	SubjectName string
	SubjectZone string
	Context     string
	Content     []object.Object
	// contains filtered or unexported fields
}

Assertion contains information about the assertion.

func GetAssertion

func GetAssertion() *Assertion

GetAssertion returns an assertion containing all objects types that is valid.

func (*Assertion) AddSig

func (a *Assertion) AddSig(sig signature.Sig)

AddSig adds the given signature

func (*Assertion) AddSigInMarshaller

func (a *Assertion) AddSigInMarshaller()

func (*Assertion) AllSigs

func (a *Assertion) AllSigs() []signature.Sig

AllSigs returns all assertion's signatures

func (*Assertion) Begin

func (a *Assertion) Begin() string

Begin returns the begining of the interval of this assertion.

func (*Assertion) CompareTo

func (a *Assertion) CompareTo(assertion *Assertion) int

CompareTo compares two assertions and returns 0 if they are equal, 1 if a is greater than assertion and -1 if a is smaller than assertion

func (*Assertion) Copy

func (a *Assertion) Copy(context, subjectZone string) *Assertion

Copy creates a copy of the assertion with the given context and subjectZone values

func (*Assertion) DeleteAllSigs

func (a *Assertion) DeleteAllSigs()

DeleteAllSigs deletes all signature

func (*Assertion) DeleteSig

func (a *Assertion) DeleteSig(i int)

DeleteSig deletes ith signature

func (*Assertion) DontAddSigInMarshaller

func (a *Assertion) DontAddSigInMarshaller()

func (*Assertion) End

func (a *Assertion) End() string

End returns the end of the interval of this assertion.

func (*Assertion) EqualContextZoneName

func (a *Assertion) EqualContextZoneName(assertion *Assertion) bool

EqualContextZoneName return true if the given assertion has the same context, subjectZone, subjectName.

func (*Assertion) FQDN

func (a *Assertion) FQDN() string

FQDN returns the fully qualified domain name of this assertion

func (*Assertion) GetContext

func (a *Assertion) GetContext() string

GetContext returns the context of the assertion

func (*Assertion) GetSubjectZone

func (a *Assertion) GetSubjectZone() string

GetSubjectZone returns the zone of the assertion

func (*Assertion) Hash

func (a *Assertion) Hash() string

Hash returns a string containing all information uniquely identifying an assertion.

func (*Assertion) IsConsistent

func (a *Assertion) IsConsistent() bool

IsConsistent returns true. Assertion is always consistent.

func (*Assertion) MarshalCBOR

func (a *Assertion) MarshalCBOR(w *cbor.CBORWriter) error

MarshalCBOR implements the CBORMarshaler interface.

func (*Assertion) NeededKeys

func (a *Assertion) NeededKeys(keysNeeded map[signature.MetaData]bool)

NeededKeys adds to keysNeeded key meta data which is necessary to verify all a's signatures.

func (*Assertion) RemoveContextAndSubjectZone

func (a *Assertion) RemoveContextAndSubjectZone()

func (*Assertion) SetContext

func (a *Assertion) SetContext(ctx string)

func (*Assertion) SetSubjectZone

func (a *Assertion) SetSubjectZone(zone string)

func (*Assertion) SetValidSince

func (a *Assertion) SetValidSince(validSince int64)

SetValidSince sets the validSince time

func (*Assertion) SetValidUntil

func (a *Assertion) SetValidUntil(validUntil int64)

SetValidUntil sets the validUntil time

func (*Assertion) Sigs

func (a *Assertion) Sigs(keySpace keys.KeySpaceID) []signature.Sig

Sigs returns a's signatures in keyspace

func (*Assertion) Sort

func (a *Assertion) Sort()

Sort sorts the content of the assertion lexicographically.

func (*Assertion) String

func (a *Assertion) String() string

String implements Stringer interface

func (*Assertion) UnmarshalMap

func (a *Assertion) UnmarshalMap(m map[int]interface{}) error

UnmarshalMap provides functionality to unmarshal a map read in by CBOR.

func (*Assertion) UpdateValidity

func (a *Assertion) UpdateValidity(validSince, validUntil int64, maxValidity time.Duration)

UpdateValidity updates the validity of this assertion if the validity period is extended. It makes sure that the validity is never larger than maxValidity

func (*Assertion) ValidSince

func (a *Assertion) ValidSince() int64

ValidSince returns the earliest validSince date of all contained signatures

func (*Assertion) ValidUntil

func (a *Assertion) ValidUntil() int64

ValidUntil returns the latest validUntil date of all contained signatures

type BloomFilter

type BloomFilter struct {
	Algorithm BloomFilterAlgo
	Hash      algorithmTypes.Hash
	Filter    bitarray.BitArray
}

BloomFilter is a probabilistic datastructure for membership queries.

func GetBloomFilter

func GetBloomFilter() BloomFilter

Datastructure returns a datastructure object with valid content

func (BloomFilter) Add

func (b BloomFilter) Add(name, zone, context string, t object.Type) error

Add sets the corresponding bits to 1 in the bloom filter based on BloomFilterAlgo and the hash function defined in b.

func (BloomFilter) CompareTo

func (b BloomFilter) CompareTo(bloomFilter BloomFilter) int

CompareTo compares two BloomFilters and returns 0 if they are equal, 1 if b is greater than bloomFilter and -1 if b is smaller than bloomFilter

func (BloomFilter) Contains

func (b BloomFilter) Contains(name, zone, context string, t object.Type) (bool, error)

Contains returns true if a might be part of the set represented by the bloom filter. It returns false if a is certainly not part of the set.

func (BloomFilter) MarshalCBOR

func (b BloomFilter) MarshalCBOR(w *cbor.CBORWriter) error

MarshalCBOR implements a CBORMarshaler.

func (*BloomFilter) UnmarshalArray

func (b *BloomFilter) UnmarshalArray(in []interface{}) error

UnmarshalArray takes in a CBOR decoded array and populates the object.

type BloomFilterAlgo

type BloomFilterAlgo int

BloomFilterAlgo enumerates several ways how to add an assertion to the bloom filter.

const (
	BloomKM12 BloomFilterAlgo = iota + 1
	BloomKM16
	BloomKM20
	BloomKM24
)

func (BloomFilterAlgo) MarshalJSON

func (r BloomFilterAlgo) MarshalJSON() ([]byte, error)

MarshalJSON is generated so BloomFilterAlgo satisfies json.Marshaler.

func (BloomFilterAlgo) NumberOfHashes

func (b BloomFilterAlgo) NumberOfHashes() int

NumberOfHashes determines how many bits in the bloom filter are set in an addition and checked on a lookup.

func (BloomFilterAlgo) String

func (i BloomFilterAlgo) String() string

func (*BloomFilterAlgo) UnmarshalJSON

func (r *BloomFilterAlgo) UnmarshalJSON(data []byte) error

UnmarshalJSON is generated so BloomFilterAlgo satisfies json.Unmarshaler.

type Hasher

type Hasher interface {
	//Hash must return a string uniquely identifying the object
	//It must hold for all objects that o1 == o2 iff o1.Hash() == o2.Hash()
	Hash() string
}

Hasher can be implemented by objects that are not natively hashable. For an object to be a map key (or a part thereof), it must be hashable.

type Interval

type Interval interface {
	//Begin of the interval
	Begin() string
	//End of the interval
	End() string
}

Interval defines an interval over strings

type Notification

type Notification struct {
	Token token.Token
	Type  NotificationType
	Data  string
}

Notification contains information about the notification

func GetNotification

func GetNotification() *Notification

Notification returns a notification with all fields set

func NotificationNoData

func NotificationNoData() *Notification

NotificationNoData returns a notification with all fields set except data.

func (*Notification) CompareTo

func (n *Notification) CompareTo(notification *Notification) int

CompareTo compares two notifications and returns 0 if they are equal, 1 if n is greater than notification and -1 if n is smaller than notification

func (*Notification) MarshalCBOR

func (n *Notification) MarshalCBOR(w *cbor.CBORWriter) error

MarshalCBOR implements the CBORMarshaler interface.

func (*Notification) Sort

func (n *Notification) Sort()

Sort sorts the content of the notification lexicographically.

func (*Notification) String

func (n *Notification) String() string

String implements Stringer interface

func (*Notification) UnmarshalMap

func (n *Notification) UnmarshalMap(m map[int]interface{}) error

UnmarshalMap unpacks a CBOR unmarshaled map to this object.

type NotificationType

type NotificationType int

NotificationType defines the type of a notification section

const (
	NTHeartbeat          NotificationType = 100
	NTCapHashNotKnown    NotificationType = 399
	NTBadMessage         NotificationType = 400
	NTRcvInconsistentMsg NotificationType = 403
	NTNoAssertionsExist  NotificationType = 404
	NTMsgTooLarge        NotificationType = 413
	NTUnspecServerErr    NotificationType = 500
	NTServerNotCapable   NotificationType = 501
	NTNoAssertionAvail   NotificationType = 504
)

func (NotificationType) String

func (i NotificationType) String() string

type Pshard

type Pshard struct {
	Signatures  []signature.Sig
	SubjectZone string
	Context     string
	RangeFrom   string
	RangeTo     string
	BloomFilter BloomFilter
	// contains filtered or unexported fields
}

Pshard contains information about a pshard

func GetPshard

func GetPshard() *Pshard

GetPshard returns a shard containing an assertion with all object types that is valid.

func (*Pshard) AddAssertion

func (s *Pshard) AddAssertion(a *Assertion) error

AddAssertion adds a to the s' Bloom filter. An error is returned, if a is not within s' range or if they have a different context or zone.

func (*Pshard) AddSig

func (s *Pshard) AddSig(sig signature.Sig)

AddSig adds the given signature

func (*Pshard) AddSigInMarshaller

func (s *Pshard) AddSigInMarshaller()

func (*Pshard) AllSigs

func (s *Pshard) AllSigs() []signature.Sig

AllSigs returns the pshard's signatures

func (*Pshard) Begin

func (s *Pshard) Begin() string

Begin returns the begining of the interval of this pshard.

func (*Pshard) CompareTo

func (s *Pshard) CompareTo(pshard *Pshard) int

CompareTo compares two pshards and returns 0 if they are equal, 1 if s is greater than pshard and -1 if s is smaller than pshard

func (*Pshard) Copy

func (s *Pshard) Copy(context, subjectZone string) *Pshard

Copy creates a copy of the shard with the given context and subjectZone values. The contained assertions are not modified

func (*Pshard) DeleteAllSigs

func (s *Pshard) DeleteAllSigs()

DeleteAllSigs deletes all signature

func (*Pshard) DeleteSig

func (s *Pshard) DeleteSig(i int)

DeleteSig deletes ith signature

func (*Pshard) DontAddSigInMarshaller

func (s *Pshard) DontAddSigInMarshaller()

func (*Pshard) End

func (s *Pshard) End() string

End returns the end of the interval of this pshard.

func (*Pshard) GetContext

func (s *Pshard) GetContext() string

GetContext returns the context of the pshard

func (*Pshard) GetSubjectZone

func (s *Pshard) GetSubjectZone() string

GetSubjectZone returns the zone of the pshard

func (*Pshard) Hash

func (s *Pshard) Hash() string

Hash returns a string containing all information uniquely identifying a pshard.

func (*Pshard) InRange

func (s *Pshard) InRange(subjectName string) bool

InRange returns true if subjectName is inside the shard range

func (*Pshard) IsConsistent

func (s *Pshard) IsConsistent() bool

IsConsistent returns true if all contained assertions have no subjectZone and context and are within the shards range.

func (*Pshard) IsNonexistent

func (s *Pshard) IsNonexistent(q *query.Name) (bool, error)

IsNonexistent returns true if all types of q do not exist. An error is returned, when q is not within the pshard's range or if its context and zone does not match the pshard.

func (*Pshard) MarshalCBOR

func (s *Pshard) MarshalCBOR(w *cbor.CBORWriter) error

func (*Pshard) NeededKeys

func (s *Pshard) NeededKeys(keysNeeded map[signature.MetaData]bool)

NeededKeys adds to keysNeeded key meta data which is necessary to verify all s's signatures.

func (*Pshard) SetValidSince

func (s *Pshard) SetValidSince(validSince int64)

SetValidSince sets the validSince time

func (*Pshard) SetValidUntil

func (s *Pshard) SetValidUntil(validUntil int64)

SetValidUntil sets the validUntil time

func (*Pshard) Sigs

func (s *Pshard) Sigs(keySpace keys.KeySpaceID) []signature.Sig

Sigs returns s's signatures in keyspace

func (*Pshard) Sort

func (s *Pshard) Sort()

Sort sorts the content of the pshard lexicographically.

func (*Pshard) String

func (s *Pshard) String() string

String implements Stringer interface

func (*Pshard) UnmarshalMap

func (s *Pshard) UnmarshalMap(m map[int]interface{}) error

UnmarshalMap decodes the output from the CBOR decoder into this struct.

func (*Pshard) UpdateValidity

func (s *Pshard) UpdateValidity(validSince, validUntil int64, maxValidity time.Duration)

UpdateValidity updates the validity of this pshard if the validity period is extended. It makes sure that the validity is never larger than maxValidity

func (*Pshard) ValidSince

func (s *Pshard) ValidSince() int64

ValidSince returns the earliest validSince date of all contained signatures

func (*Pshard) ValidUntil

func (s *Pshard) ValidUntil() int64

ValidUntil returns the latest validUntil date of all contained signatures

type Query

type Query interface {
	GetContext() string
	GetExpiration() int64
}

Query is the interface for a query section. In the current implementation it can be a query or an addressQuery

type Section

type Section interface {
	Sort()
	String() string
	MarshalCBOR(w *cbor.CBORWriter) error
	UnmarshalMap(m map[int]interface{}) error
}

Section can be either an Assertion, Shard, Zone, Query, Notification, AddressAssertion, AddressZone, AddressQuery section

type Shard

type Shard struct {
	Signatures  []signature.Sig
	SubjectZone string
	Context     string
	RangeFrom   string
	RangeTo     string
	Content     []*Assertion
	// contains filtered or unexported fields
}

Shard contains information about the shard

func GetShard

func GetShard() *Shard

GetShard returns a shard containing an assertion with all object types that is valid.

func (*Shard) AddCtxAndZoneToContent

func (s *Shard) AddCtxAndZoneToContent()

func (*Shard) AddSig

func (s *Shard) AddSig(sig signature.Sig)

AddSig adds the given signature

func (*Shard) AddSigInMarshaller

func (s *Shard) AddSigInMarshaller()

func (*Shard) AllSigs

func (s *Shard) AllSigs() []signature.Sig

AllSigs returns the shard's signatures

func (*Shard) Begin

func (s *Shard) Begin() string

Begin returns the begining of the interval of this shard.

func (*Shard) CompareTo

func (s *Shard) CompareTo(shard *Shard) int

CompareTo compares two shards and returns 0 if they are equal, 1 if s is greater than shard and -1 if s is smaller than shard

func (*Shard) Copy

func (s *Shard) Copy(context, subjectZone string) *Shard

Copy creates a copy of the shard with the given context and subjectZone values. The contained assertions are not modified

func (*Shard) DeleteAllSigs

func (s *Shard) DeleteAllSigs()

DeleteAllSigs deletes all signature

func (*Shard) DeleteSig

func (s *Shard) DeleteSig(i int)

DeleteSig deletes ith signature

func (*Shard) DontAddSigInMarshaller

func (s *Shard) DontAddSigInMarshaller()

func (*Shard) End

func (s *Shard) End() string

End returns the end of the interval of this shard.

func (*Shard) GetContext

func (s *Shard) GetContext() string

GetContext returns the context of the shard

func (*Shard) GetSubjectZone

func (s *Shard) GetSubjectZone() string

GetSubjectZone returns the zone of the shard

func (*Shard) Hash

func (s *Shard) Hash() string

Hash returns a string containing all information uniquely identifying a shard.

func (*Shard) InRange

func (s *Shard) InRange(subjectName string) bool

InRange returns true if subjectName is inside the shard range

func (*Shard) IsConsistent

func (s *Shard) IsConsistent() bool

IsConsistent returns true if all contained assertions have no subjectZone and context and are within the shards range.

func (*Shard) MarshalCBOR

func (s *Shard) MarshalCBOR(w *cbor.CBORWriter) error

MarshalCBOR implements the CBORMarshaler interface.

func (*Shard) NeededKeys

func (s *Shard) NeededKeys(keysNeeded map[signature.MetaData]bool)

NeededKeys adds to keysNeeded key meta data which is necessary to verify all s's signatures.

func (*Shard) RemoveCtxAndZoneFromContent

func (s *Shard) RemoveCtxAndZoneFromContent()

func (*Shard) SetValidSince

func (s *Shard) SetValidSince(validSince int64)

SetValidSince sets the validSince time

func (*Shard) SetValidUntil

func (s *Shard) SetValidUntil(validUntil int64)

SetValidUntil sets the validUntil time

func (*Shard) Sigs

func (s *Shard) Sigs(keySpace keys.KeySpaceID) []signature.Sig

Sigs returns s's signatures in keyspace

func (*Shard) Sort

func (s *Shard) Sort()

Sort sorts the content of the shard lexicographically.

func (*Shard) String

func (s *Shard) String() string

String implements Stringer interface

func (*Shard) UnmarshalMap

func (s *Shard) UnmarshalMap(m map[int]interface{}) error

UnmarshalMap converts a CBOR decoded map to this Shard.

func (*Shard) UpdateValidity

func (s *Shard) UpdateValidity(validSince, validUntil int64, maxValidity time.Duration)

UpdateValidity updates the validity of this shard if the validity period is extended. It makes sure that the validity is never larger than maxValidity

func (*Shard) ValidSince

func (s *Shard) ValidSince() int64

ValidSince returns the earliest validSince date of all contained signatures

func (*Shard) ValidUntil

func (s *Shard) ValidUntil() int64

ValidUntil returns the latest validUntil date of all contained signatures

type StringInterval

type StringInterval struct {
	Name string
}

StringInterval implements Interval for a single string value

func (StringInterval) Begin

func (s StringInterval) Begin() string

Begin defines the start of a StringInterval namespace

func (StringInterval) End

func (s StringInterval) End() string

End defines the end of a StringInterval namespace

type TotalInterval

type TotalInterval struct{}

TotalInterval is an interval over the whole namespace

func (TotalInterval) Begin

func (t TotalInterval) Begin() string

Begin defines the start of the total namespace

func (TotalInterval) End

func (t TotalInterval) End() string

End defines the end of the total namespace

type WithSig

type WithSig interface {
	Section
	AllSigs() []signature.Sig
	Sigs(keyspace keys.KeySpaceID) []signature.Sig
	AddSig(sig signature.Sig)
	DeleteSig(index int)
	DeleteAllSigs()
	GetContext() string
	GetSubjectZone() string
	UpdateValidity(validSince, validUntil int64, maxValidity time.Duration)
	ValidSince() int64
	SetValidSince(int64)
	ValidUntil() int64
	SetValidUntil(int64)
	Hash() string
	IsConsistent() bool
	NeededKeys(map[signature.MetaData]bool)
	AddSigInMarshaller()
	DontAddSigInMarshaller()
}

WithSig is an interface for a section protected by a signature. In the current implementation it can be an Assertion, Shard, Zone, AddressAssertion, AddressZone

type WithSigForward

type WithSigForward interface {
	WithSig
	Interval
}

WithSigForward can be either an Assertion, Shard or Zone

type Zone

type Zone struct {
	Signatures  []signature.Sig
	SubjectZone string
	Context     string
	Content     []*Assertion
	// contains filtered or unexported fields
}

Zone contains information about the zone

func GetZone

func GetZone() *Zone

GetZone returns an zone containing a shard, assertion with all object types and a pshard. The zone is valid.

func (*Zone) AddCtxAndZoneToContent

func (z *Zone) AddCtxAndZoneToContent()

func (*Zone) AddSig

func (z *Zone) AddSig(sig signature.Sig)

AddSig adds the given signature

func (*Zone) AddSigInMarshaller

func (z *Zone) AddSigInMarshaller()

func (*Zone) AllSigs

func (z *Zone) AllSigs() []signature.Sig

AllSigs returns the zone's signatures

func (*Zone) Begin

func (z *Zone) Begin() string

Begin returns the begining of the interval of this zone.

func (*Zone) CompareTo

func (z *Zone) CompareTo(zone *Zone) int

CompareTo compares two zones and returns 0 if they are equal, 1 if z is greater than zone and -1 if z is smaller than zone

func (*Zone) DeleteAllSigs

func (z *Zone) DeleteAllSigs()

DeleteAllSigs deletes all signature

func (*Zone) DeleteSig

func (z *Zone) DeleteSig(i int)

DeleteSig deletes ith signature

func (*Zone) DontAddSigInMarshaller

func (z *Zone) DontAddSigInMarshaller()

func (*Zone) End

func (z *Zone) End() string

End returns the end of the interval of this zone.

func (*Zone) GetContext

func (z *Zone) GetContext() string

GetContext returns the context of the zone

func (*Zone) GetSubjectZone

func (z *Zone) GetSubjectZone() string

GetSubjectZone returns the zone of the zone

func (*Zone) Hash

func (z *Zone) Hash() string

Hash returns a string containing all information uniquely identifying a shard.

func (*Zone) IsConsistent

func (z *Zone) IsConsistent() bool

IsConsistent returns true if all contained assertions and shards are consistent

func (*Zone) MarshalCBOR

func (z *Zone) MarshalCBOR(w *cbor.CBORWriter) error

MarshalCBOR implements the CBORMarshaler interface.

func (*Zone) NeededKeys

func (z *Zone) NeededKeys(keysNeeded map[signature.MetaData]bool)

NeededKeys adds to keysNeeded key meta data which is necessary to verify all z's signatures.

func (*Zone) RemoveCtxAndZoneFromContent

func (z *Zone) RemoveCtxAndZoneFromContent()

func (*Zone) SetValidSince

func (z *Zone) SetValidSince(validSince int64)

SetValidSince sets the validSince time

func (*Zone) SetValidUntil

func (z *Zone) SetValidUntil(validUntil int64)

SetValidUntil sets the validUntil time

func (*Zone) Sigs

func (z *Zone) Sigs(keySpace keys.KeySpaceID) []signature.Sig

Sigs returns z's signatures in keyspace

func (*Zone) Sort

func (z *Zone) Sort()

Sort sorts the content of the zone lexicographically.

func (*Zone) String

func (z *Zone) String() string

String implements Stringer interface

func (*Zone) UnmarshalMap

func (z *Zone) UnmarshalMap(m map[int]interface{}) error

UnmarshalMap decodes the output from the CBOR decoder into this struct.

func (*Zone) UpdateValidity

func (z *Zone) UpdateValidity(validSince, validUntil int64, maxValidity time.Duration)

UpdateValidity updates the validity of this zone if the validity period is extended. It makes sure that the validity is never larger than maxValidity

func (*Zone) ValidSince

func (z *Zone) ValidSince() int64

ValidSince returns the earliest validSince date of all contained signatures

func (*Zone) ValidUntil

func (z *Zone) ValidUntil() int64

ValidUntil returns the latest validUntil date of all contained signatures

Jump to

Keyboard shortcuts

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