helpers

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const BUFFER_SIZE = 255
View Source
const CHUNK_HEADER_SIZE = 8 + CHUNK_ID_LENGTH
View Source
const CHUNK_ID_LENGTH = 16
View Source
const CHUNK_VERSION = 1
View Source
const ENTRY_VERSION = 1
View Source
const (
	NullType = 0
)

Variables

View Source
var CertificatesListForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "certificates",
			Validators: []forms.Validator{
				forms.IsOptional{Default: []interface{}{}},
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &epsForms.OperatorCertificateForm,
						},
					},
				},
			},
		},
	},
}
View Source
var EnvSettingsName = "EPS_SETTINGS"
View Source
var NullValue = fmt.Errorf("null")

Functions

func BigInt

func BigInt(s string) (*big.Int, error)

func CalculateRecordHash

func CalculateRecordHash(record *eps.SignedChangeRecord) error

func CloseChannels added in v0.1.35

func CloseChannels(channels []eps.Channel) error

func GetChannelSettingsAndDefinition

func GetChannelSettingsAndDefinition(settings *eps.Settings, name string) (*eps.ChannelSettings, *eps.ChannelDefinition, error)

func GetRecordFingerprint

func GetRecordFingerprint(records []*eps.SignedChangeRecord, name, keyUsage string) string

func InitializeChannels

func InitializeChannels(broker eps.MessageBroker, directory eps.Directory, settings *eps.Settings) ([]eps.Channel, error)

func InitializeDirectory

func InitializeDirectory(settings *eps.Settings) (eps.Directory, error)

func InitializeMessageBroker

func InitializeMessageBroker(settings *eps.Settings, directory eps.Directory) (eps.MessageBroker, error)

func IntegrateChangeRecord

func IntegrateChangeRecord(record *eps.SignedChangeRecord, entry *eps.DirectoryEntry) error

Integrates a record into the directory

func LoadCertificate

func LoadCertificate(path string, verifyUsage bool) (*x509.Certificate, error)

func LoadCertificateFromString

func LoadCertificateFromString(data string, verifyUsage bool) (*x509.Certificate, error)

func LoadPrivateKey

func LoadPrivateKey(path string) (*ecdsa.PrivateKey, error)

func LoadSignedData

func LoadSignedData(data []byte) (*eps.SignedData, error)

func OpenChannels added in v0.1.35

func OpenChannels(broker eps.MessageBroker, directory eps.Directory, settings *eps.Settings) ([]eps.Channel, error)

func RandomBytes

func RandomBytes(n int) ([]byte, error)

func RandomID

func RandomID(n int) ([]byte, error)

func Settings

func Settings(settingsPaths []string, definitions *eps.Definitions) (*eps.Settings, error)

func SettingsPaths

func SettingsPaths() []string

func Sign

func Sign(data interface{}, key *ecdsa.PrivateKey, cert *x509.Certificate) (*eps.SignedData, error)

func StructuredHash

func StructuredHash(source interface{}) ([]byte, error)

Computes a hash of a structured data type that can contain various types like strings or []byte arrays. The hash reflects both the type values and the structure of the source.

func Verify

func Verify(signedData *eps.SignedData, rootCerts []*x509.Certificate, intermediateCerts []*x509.Certificate, name string) (bool, error)

func VerifyCertificate

func VerifyCertificate(cert, rootCert *x509.Certificate, intermediateCerts []*x509.Certificate, name string) error

func VerifyFingerprint

func VerifyFingerprint(cert *x509.Certificate, fingerprint string) bool

func VerifyRecord

func VerifyRecord(record *eps.SignedChangeRecord, verifiedRecords []*eps.SignedChangeRecord, rootCerts []*x509.Certificate, intermediateCerts []*x509.Certificate) (bool, error)

func VerifyRecordHash

func VerifyRecordHash(record *eps.SignedChangeRecord) (bool, error)

Types

type ByPosition

type ByPosition struct {
	Entries   []*DataEntry
	Positions map[string]int
}

func (ByPosition) Len

func (b ByPosition) Len() int

func (ByPosition) Less

func (b ByPosition) Less(i, j int) bool

func (ByPosition) Swap

func (b ByPosition) Swap(i, j int)

type CertificatesList

type CertificatesList struct {
	Certificates []*eps.OperatorCertificate `json:"certificates"`
}

type CustomHashValue

type CustomHashValue interface {
	HashValue() interface{}
}

type DataChunk

type DataChunk struct {
	// The number of chunks for this hash
	Chunks uint16
	// The index of this chunk
	Index uint16
	// The actual ID of the entry this chunk belongs to
	ID []byte
	// The actual data in this chunk
	Data []byte
}

func MakeDataChunk

func MakeDataChunk(id []byte, chunks, index uint16, data []byte) *DataChunk

func (*DataChunk) Read

func (d *DataChunk) Read(reader io.Reader) error

func (*DataChunk) Write

func (d *DataChunk) Write(writer io.Writer) error

Writes a data chunkn to the given writer

type DataEntry

type DataEntry struct {
	Type uint8
	ID   []byte
	Data []byte
}

func (*DataEntry) FromBytes

func (e *DataEntry) FromBytes(data []byte) error

func (*DataEntry) Reassemble

func (e *DataEntry) Reassemble(chunks []*DataChunk) error

func (*DataEntry) Split

func (e *DataEntry) Split() ([]*DataChunk, error)

Splits a data entry into multiple data chunks.

func (*DataEntry) ToBytes

func (e *DataEntry) ToBytes() []byte

type DataStore

type DataStore interface {
	// Write data to the store
	Write(*DataEntry) error
	// Read data from the store
	Read() ([]*DataEntry, error)
	Init() error
}

type FileDataStore

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

A file-based data store

func MakeFileDataStore

func MakeFileDataStore(filename string) *FileDataStore

func (*FileDataStore) Init

func (f *FileDataStore) Init() error

func (*FileDataStore) Read

func (f *FileDataStore) Read() ([]*DataEntry, error)

func (*FileDataStore) Write

func (f *FileDataStore) Write(entry *DataEntry) error

type SubjectInfo

type SubjectInfo struct {
	Name     string
	DNSNames []string
	Groups   []string
}

func GetSubjectInfo

func GetSubjectInfo(cert *x509.Certificate) (*SubjectInfo, error)

type Tag

type Tag struct {
	Name  string
	Value string
	Flag  bool
}

func ExtractTags

func ExtractTags(field reflect.StructField, tag string) []Tag

Jump to

Keyboard shortcuts

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