common

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: EUPL-1.2 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	COSE_SIGN1_CONTEXT = "Signature1"
	ALG_ES256          = -7
	ALG_PS256          = -37
)
View Source
const (
	COSE_SIGN1_TAG     = 18
	CURRENT_CONTEXT_ID = '1'
)

Variables

This section is empty.

Functions

func CalculateProofIdentifier added in v0.4.2

func CalculateProofIdentifier(signature []byte) []byte

CalculateProofIdentifier calculates the sha256 digest of the signature, truncated to 128 bits

func CanonicalSignatureBytes added in v0.4.3

func CanonicalSignatureBytes(r, s *big.Int, curve *elliptic.CurveParams) []byte

func FindKID added in v0.5.2

func FindKID(protectedHeader *CWTHeader, unprotectedHeader *CWTHeader) (kid []byte, err error)

func HasEUPrefix

func HasEUPrefix(bts []byte) bool

func MarshalQREncoded

func MarshalQREncoded(signedCWT *CWT) ([]byte, error)

func SerializeAndHashForSignature

func SerializeAndHashForSignature(protectedHeaderCbor, payloadCbor []byte) (hash []byte, err error)

Types

type CWT

type CWT struct {
	Protected   []byte
	Unprotected CWTHeader
	Payload     []byte
	Signature   []byte
	// contains filtered or unexported fields
}

func UnmarshalQREncoded

func UnmarshalQREncoded(proofPrefixed []byte) (cwt *CWT, err error)

type CWTHeader

type CWTHeader struct {
	KID []byte `cbor:"4,keyasint,omitempty"`
	Alg int    `cbor:"1,keyasint,omitempty"`
}

type CWTPayload

type CWTPayload struct {
	Issuer         string `cbor:"1,keyasint"`
	ExpirationTime int64  `cbor:"4,keyasint"`
	IssuedAt       int64  `cbor:"6,keyasint"`

	HCert *RawHealthCertificate `cbor:"-260,keyasint"`
}

type DCC

type DCC struct {
	Version     string `cbor:"ver" json:"ver"`
	DateOfBirth string `cbor:"dob" json:"dob"`

	Name         *DCCName          `cbor:"nam" json:"nam"`
	Vaccinations []*DCCVaccination `cbor:"v,omitempty" json:"v"`
	Tests        []*DCCTest        `cbor:"t,omitempty" json:"t"`
	Recoveries   []*DCCRecovery    `cbor:"r,omitempty" json:"r"`
}

func ReadDCC

func ReadDCC(dccCbor []byte) (dcc *DCC, err error)

type DCCName

type DCCName struct {
	FamilyName             string `cbor:"fn" json:"fn"`
	StandardizedFamilyName string `cbor:"fnt" json:"fnt"`
	GivenName              string `cbor:"gn" json:"gn"`
	StandardizedGivenName  string `cbor:"gnt" json:"gnt"`
}

type DCCRecovery

type DCCRecovery struct {
	DiseaseTargeted         string `cbor:"tg" json:"tg"`
	DateOfFirstPositiveTest string `cbor:"fr" json:"fr"`
	CountryOfTest           string `cbor:"co" json:"co"`
	CertificateIssuer       string `cbor:"is" json:"is"`
	CertificateValidFrom    string `cbor:"df" json:"df"`
	CertificateValidUntil   string `cbor:"du" json:"du"`
	CertificateIdentifier   string `cbor:"ci" json:"ci"`
}

type DCCTest

type DCCTest struct {
	DiseaseTargeted         string `cbor:"tg" json:"tg"`
	TypeOfTest              string `cbor:"tt" json:"tt"`
	TestName                string `cbor:"nm,omitempty" json:"nm"`
	TestNameAndManufacturer string `cbor:"ma,omitempty" json:"ma"`
	DateTimeOfCollection    string `cbor:"sc" json:"sc"`
	TestResult              string `cbor:"tr" json:"tr"`
	TestingCentre           string `cbor:"tc" json:"tc"`
	CountryOfVaccination    string `cbor:"co" json:"co"`
	CertificateIssuer       string `cbor:"is" json:"is"`
	CertificateIdentifier   string `cbor:"ci" json:"ci"`
}

type DCCVaccination

type DCCVaccination struct {
	DiseaseTargeted       string `cbor:"tg" json:"tg"`
	Vaccine               string `cbor:"vp" json:"vp"`
	MedicinalProduct      string `cbor:"mp" json:"mp"`
	Manufacturer          string `cbor:"ma" json:"ma"`
	DoseNumber            int    `cbor:"dn" json:"dn"`
	TotalSeriesOfDoses    int    `cbor:"sd" json:"sd"`
	DateOfVaccination     string `cbor:"dt" json:"dt"`
	CountryOfVaccination  string `cbor:"co" json:"co"`
	CertificateIssuer     string `cbor:"is" json:"is"`
	CertificateIdentifier string `cbor:"ci" json:"ci"`
}

type HealthCertificate

type HealthCertificate struct {
	CredentialVersion int    `json:"credentialVersion"`
	Issuer            string `json:"issuer"`
	IssuedAt          int64  `json:"issuedAt"`
	ExpirationTime    int64  `json:"expirationTime"`
	KIDB64            string `json:"kid"`
	DCC               *DCC   `json:"dcc"`
}

func ReadCWT

func ReadCWT(cwt *CWT) (hcert *HealthCertificate, err error)

type RawHealthCertificate

type RawHealthCertificate struct {
	// Halt unmarshalling here, so CWT verification can take place first
	DCC cbor.RawMessage `cbor:"1,keyasint"`
}

Jump to

Keyboard shortcuts

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