keycard

package
v0.0.0-...-564440e Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const SigInfoHash uint8 = 1

SigInfoHash - signature field is a hash

View Source
const SigInfoSignature uint8 = 2

SigInfoSignature - signature field is a cryptographic signature

Variables

This section is empty.

Functions

func GenerateOrgKeys

func GenerateOrgKeys(rotateOptional bool) (map[string]ezn.CryptoString, error)

GenerateOrgKeys generates a set of cryptographic keys for user entries, optionally including non-required keys

func GenerateUserKeys

func GenerateUserKeys() (map[string]ezn.CryptoString, error)

GenerateUserKeys generates a set of cryptographic keys for user entries, optionally including non-required keys

func IsExpirationValid

func IsExpirationValid(timestr string) error

IsExpirationValid returns true if the expiration for the entry is valid

func IsTimestampValid

func IsTimestampValid(timestr string) error

IsTimestampValid returns true if the timestamp for the entry is valid

Types

type Entry

type Entry struct {
	Type           string
	Fields         map[string]string
	FieldNames     gostringlist.StringList
	RequiredFields gostringlist.StringList
	Signatures     map[string]string
	SignatureInfo  SigInfoList
	PrevHash       string
	Hash           string
	Keys           []KeyInfo
}

Entry contains the common functionality for keycard entries

func NewEntryFromData

func NewEntryFromData(textBlock string) (*Entry, error)

NewEntryFromData creates a new entry from a text block of entry information which includes the header and footer. The type of entry created is based on the information in the text block

func NewOrgEntry

func NewOrgEntry() *Entry

NewOrgEntry creates a new OrgEntry

func NewUserEntry

func NewUserEntry() *Entry

NewUserEntry creates a new UserEntry

func (*Entry) Chain

func (entry *Entry) Chain(key ezn.CryptoString, rotateOptional bool) (*Entry, map[string]ezn.CryptoString, error)

Chain creates a new Entry object with new keys and a custody signature. It requires the previous contact request signing key passed as an ezn.ezn. The new keys are returned with the string '.private' or '.public' appended to the key's field name, e.g. Primary-Encryption-Key.public.

Note that a user's public encryption keys and an organization's alternate verification key are not required to be updated during entry rotation so that they can be rotated on a different schedule from the other keys.

func (*Entry) Duplicate

func (entry *Entry) Duplicate() *Entry

func (*Entry) GenerateHash

func (entry *Entry) GenerateHash(algorithm string) error

GenerateHash generates a hash containing the expected signatures and the previous hash, if it exists. The supported hash algorithms are 'BLAKE3-256', 'BLAKE2B-256', 'SHA-256', and 'SHA3-256'.

func (Entry) GetSignature

func (entry Entry) GetSignature(sigtype string) (string, error)

GetSignature - get the specified signature

func (Entry) IsCompliant

func (entry Entry) IsCompliant() bool

IsCompliant returns true if the object meets spec compliance (required fields, etc.)

func (*Entry) IsDataCompliant

func (entry *Entry) IsDataCompliant() bool

IsDataCompliant checks only the data fields of the entry to ensure that they are valid

func (Entry) IsExpired

func (entry Entry) IsExpired() (bool, error)

IsExpired returns true if the entry has expired

func (Entry) MakeByteString

func (entry Entry) MakeByteString(siglevel int) []byte

MakeByteString converts the entry to a string of bytes to ensure that signatures are not invalidated by automatic line ending handling

func (Entry) Save

func (entry Entry) Save(path string, clobber bool) error

Save saves the entry to disk

func (*Entry) Set

func (entry *Entry) Set(data []byte) error

Set initializes the entry from a bytestring

func (*Entry) SetExpiration

func (entry *Entry) SetExpiration(numdays int16) error

SetExpiration enables custom expiration dates, the standard being 90 days for user entries and 1 year for organizations.

func (*Entry) SetField

func (entry *Entry) SetField(fieldName string, fieldValue string) error

SetField sets an entry field to the specified value.

func (*Entry) SetFields

func (entry *Entry) SetFields(fields map[string]string)

SetFields sets multiple entry fields

func (*Entry) Sign

func (entry *Entry) Sign(signingKey ezn.CryptoString, sigtype string) error

Sign cryptographically signs an entry. The supported types and expected order of the signature is defined by subclasses using the SigInfo instances in the object's SignatureInfo property. Adding a particular signature causes those that must follow it to be cleared. The Entry's cryptographic hash counts as a signature in this matter. Thus, if an Organization signature is added to the entry, the instance's hash and User signatures are both cleared.

func (Entry) VerifyChain

func (entry Entry) VerifyChain(previous *Entry) (bool, error)

VerifyChain verifies the chain of custody between the provided previous entry and the current one.

func (Entry) VerifySignature

func (entry Entry) VerifySignature(verifyKey ezn.CryptoString, sigtype string) (bool, error)

VerifySignature cryptographically verifies the entry against the key provided, given the specific signature to verify.

type KeyInfo

type KeyInfo struct {
	Name     string
	Type     string
	Optional bool
}

KeyInfo describes the encryption and signing key fields for an Entry object

type Keycard

type Keycard struct {
	Type    string
	Entries []Entry
}

Keycard - class which houses a list of entries into a hash-linked chain

func (*Keycard) Duplicate

func (card *Keycard) Duplicate() *Keycard

func (*Keycard) Load

func (card *Keycard) Load(path string, clobber bool) error

Load writes the entire entry chain to one file with optional overwrite

func (Keycard) Save

func (card Keycard) Save(path string, clobber bool) error

Save writes the entire entry chain to one file with optional overwrite

func (Keycard) VerifyChain

func (card Keycard) VerifyChain(path string, clobber bool) (bool, error)

VerifyChain verifies the entire chain of entries

type SigInfo

type SigInfo struct {
	Name     string
	Level    int
	Optional bool
	Type     uint8
}

SigInfo contains descriptive information about the signatures for an entry. The Level property indicates order. For example, a signature with a level of 2 is attached to the entry after a level 1 signature.

type SigInfoList

type SigInfoList struct {
	Items []SigInfo
}

SigInfoList is a specialized list container for SigInfo structure instances

func (SigInfoList) Contains

func (sil SigInfoList) Contains(name string) bool

Contains returns true if one of the SigInfo items has the specified name

func (SigInfoList) GetItem

func (sil SigInfoList) GetItem(name string) (bool, *SigInfo)

GetItem returns the item matching the specified name or nil if it doesn't exist

func (SigInfoList) IndexOf

func (sil SigInfoList) IndexOf(name string) int

IndexOf returns the index of the item named and -1 if it doesn't exist

Jump to

Keyboard shortcuts

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