document

package
v0.0.0-...-5248474 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package document implements data structures for representing the content of the MRTD.

Index

Constants

View Source
const COMTag = 0x60
View Source
const DG11Tag = 0x6B
View Source
const DG12Tag = 0x6C
View Source
const DG13Tag = 0x6D
View Source
const DG14Tag = 0x6E
View Source
const DG15Tag = 0x6F
View Source
const DG16Tag = 0x70
View Source
const DG1Tag = 0x61
View Source
const DG2Tag = 0x75
View Source
const DG7Tag = 0x67
View Source
const SODTag = 0x77

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveAuthenticationInfo

type ActiveAuthenticationInfo struct {
	Protocol           asn1.ObjectIdentifier
	Version            int
	SignatureAlgorithm asn1.ObjectIdentifier
}

type BiometricDataBlock

type BiometricDataBlock struct {
	Facial Facial
}

type BiometricHeaderTemplate

type BiometricHeaderTemplate struct {
	IcaoHeaderVersion []byte // optional
	BiometricType     []byte // optional
	BiometricSubType  []byte // optional (for DG2)
	CreationDateTime  []byte // optional
	ValidityPeriod    []byte // optional
	PID               []byte // optional
	FormatOwner       []byte // required
	FormatType        []byte // required
}

type BiometricInfoTemplate

type BiometricInfoTemplate struct {
	BHT BiometricHeaderTemplate
	BDB BiometricDataBlock
}

type COM

type COM struct {
	RawData        []byte
	LdsVersion     string
	UnicodeVersion string
	TagList        []tlv.TlvTag
}

func NewCOM

func NewCOM(data []byte) (*COM, error)

type CardAccess

type CardAccess struct {
	RawData       []byte
	SecurityInfos *SecurityInfos
}

func NewCardAccess

func NewCardAccess(data []byte) (*CardAccess, error)

type CardSecurity

type CardSecurity struct {
	RawData       []byte
	SD            *cms.SignedData
	SecurityInfos *SecurityInfos
}

func NewCardSecurity

func NewCardSecurity(data []byte) (out *CardSecurity, err error)

type ChipAuthStatus

type ChipAuthStatus int
const (
	CHIP_AUTH_STATUS_NONE ChipAuthStatus = iota
	CHIP_AUTH_STATUS_PACE_CAM
	CHIP_AUTH_STATUS_CA
	CHIP_AUTH_STATUS_AA
)

func (ChipAuthStatus) String

func (cas ChipAuthStatus) String() string

type ChipAuthenticationInfo

type ChipAuthenticationInfo struct {
	Protocol asn1.ObjectIdentifier
	Version  int
	KeyId    *big.Int `asn1:"optional"`
}

type ChipAuthenticationPublicKeyInfo

type ChipAuthenticationPublicKeyInfo struct {
	Raw                         asn1.RawContent
	Protocol                    asn1.ObjectIdentifier
	ChipAuthenticationPublicKey cms.SubjectPublicKeyInfo
	KeyId                       *big.Int `asn1:"optional"` // nil if not present
}

type DG1

type DG1 struct {
	RawData []byte
	Mrz     *mrz.MRZ
}

func NewDG1

func NewDG1(data []byte) (dg1 *DG1, err error)

type DG11

type DG11 struct {
	RawData []byte
	Details PersonDetails
}

func NewDG11

func NewDG11(data []byte) (*DG11, error)

type DG12

type DG12 struct {
	RawData []byte
	Details DocumentDetails
}

func NewDG12

func NewDG12(data []byte) (*DG12, error)

type DG13

type DG13 struct {
	RawData []byte
}

func NewDG13

func NewDG13(data []byte) (*DG13, error)

type DG14

type DG14 struct {
	RawData  []byte // TODO - add to test cases (for all other DGs also)
	SecInfos *SecurityInfos
}

func NewDG14

func NewDG14(data []byte) (dg14 *DG14, err error)

type DG15

type DG15 struct {
	RawData                   []byte
	SubjectPublicKeyInfoBytes []byte
}

func NewDG15

func NewDG15(data []byte) (*DG15, error)

type DG16

type DG16 struct {
	RawData []byte
}

func NewDG16

func NewDG16(data []byte) (*DG16, error)

type DG2

type DG2 struct {
	RawData []byte
	BITs    []BiometricInfoTemplate
}

func NewDG2

func NewDG2(data []byte) (*DG2, error)

type DG7

type DG7 struct {
	RawData []byte
	Images  []DG7Image
}

func NewDG7

func NewDG7(data []byte) (*DG7, error)

type DG7Image

type DG7Image struct {
	Image []byte
}

type DataGroupHash

type DataGroupHash struct {
	DataGroupNumber    int
	DataGroupHashValue []byte
}

type Document

type Document struct {
	Atr []byte
	Ats []byte

	Mf MasterFile

	ChipAuthStatus ChipAuthStatus

	// passive auth
	PassiveAuthSOD     *PassiveAuth
	PassiveAuthCardSec *PassiveAuth

	Apdus []iso7816.ApduLog // TODO - should move this out of document
}

func (*Document) IndentedJson

func (doc *Document) IndentedJson() string

func (Document) LdsVersion

func (doc Document) LdsVersion() string

gets the LDS Version (e.g. '0108') from EF.SOD or EF.COM returns empty string if valid cannot be determined

func (*Document) NewDG

func (doc *Document) NewDG(dg int, data []byte) (err error)

func (Document) UnicodeVersion

func (doc Document) UnicodeVersion() string

gets the Unicode Version (e.g. '040000') from EF.SOD or EF.COM returns empty string if valid cannot be determined

type DocumentDetails

type DocumentDetails struct {
	IssuingAuthority            string
	DateOfIssue                 string // YYYYMMDD
	OtherPersons                []mrz.MrzName
	EndorsementsAndObservations string
	TaxExitRequirements         string
	ImageFront                  []byte // Image of front of document. Image per ISO/IEC 10918.
	ImageRear                   []byte // Image of read of document. Image per ISO/IEC 10918.
	PersoDateTime               string // yyyymmddhhmmss
	PersoSystemSerialNumber     string
}

type EFDIR

type EFDIR struct {
	RawData     []byte
	Application []EfDirApplication
}

func NewEFDIR

func NewEFDIR(data []byte) *EFDIR

type EFDirInfo

type EFDirInfo struct {
	Protocol asn1.ObjectIdentifier
	EFDir    []byte
}

type EfDirApplication

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

type Facial

type Facial struct {
	Header FacialHeader
	Images []Image
}

type FacialFeature

type FacialFeature struct {
	Type       uint8
	MajorPoint uint8
	MinorPoint uint8
	X          uint16
	Y          uint16
	Reserved   uint8
}

type FacialHeader

type FacialHeader struct {
	FormatID      [4]byte
	VersionID     [4]byte
	RecordLength  uint32
	NumberOfFaces uint16
}

type FacialInfo

type FacialInfo struct {
	Length          uint32
	NumberOfPoints  uint16
	Gender          uint8
	EyeColor        uint8
	HairColor       uint8
	Properties      [3]byte
	Expression      [2]byte
	Pose            [3]byte
	PoseUncertainty [3]byte
}

type Image

type Image struct {
	FacialInformation FacialInfo
	Features          []FacialFeature
	ImageInformation  ImageInfo
	Data              []byte
}

type ImageInfo

type ImageInfo struct {
	Type       uint8
	DataType   uint8
	Width      uint16
	Height     uint16
	ColorSpace uint8
	SourceType uint8
	DeviceType uint16
	Quality    uint16
}

type LDS1

type LDS1 struct {
	Com  *COM  // largely deprecated by SOD, but used to determine Lds/Unicode Version if older SOD formatis present
	Sod  *SOD  // Document Security Object EF.SOD (MANDATORY)
	Dg1  *DG1  // DATA GROUP 1 — Machine Readable Zone Information (MANDATORY)
	Dg2  *DG2  // DATA GROUP 2 — Encoded Identification Features — Face (MANDATORY)
	Dg7  *DG7  // DATA GROUP 7 — Displayed Signature or Usual Mark (OPTIONAL)
	Dg11 *DG11 // DATA GROUP 11 — Additional Personal Detail(s) (OPTIONAL)
	Dg12 *DG12 // DATA GROUP 12 — Additional Document Detail(s) (OPTIONAL)
	Dg13 *DG13 // DATA GROUP 13 — Optional Details(s) (OPTIONAL)
	Dg14 *DG14 // DATA GROUP 14 — Security Options (CONDITIONAL)
	Dg15 *DG15 // DATA GROUP 15 — Active Authentication Public Key Info (CONDITIONAL)
	Dg16 *DG16 // DATA GROUP 16 — Person(s) to Notify (OPTIONAL)
}

type LDSSecurityObject

type LDSSecurityObject struct {
	Version             int
	HashAlgorithm       cms.AlgorithmIdentifier
	DataGroupHashValues []DataGroupHash
	LdsVersionInfo      LDSVersionInfo `asn1:"optional"`
}

type LDSVersionInfo

type LDSVersionInfo struct {
	LdsVersion     string
	UnicodeVersion string
}

NB present but empty strings if not present in parsed data (i.e. older version of EF.SOD)

type MasterFile

type MasterFile struct {
	// TODO - ATR is technically within here?
	CardAccess   *CardAccess
	CardSecurity *CardSecurity // NB only read for PACE-CAM - read during PACE flow
	Dir          *EFDIR        // indicates which applications are present - generally not acvailable
	Lds1         LDS1
}

type PaceDomainParameterInfo

type PaceDomainParameterInfo struct {
	Protocol        asn1.ObjectIdentifier
	DomainParameter cms.AlgorithmIdentifier
	ParameterId     *big.Int `asn1:"optional"` // nil if not present
}

type PaceInfo

type PaceInfo struct {
	Protocol    asn1.ObjectIdentifier
	Version     int
	ParameterId *big.Int `asn1:"optional"` // nil if not present
}

type PassiveAuth

type PassiveAuth struct {
	CertChain [][]byte
}

func NewPassiveAuth

func NewPassiveAuth(certChain [][]byte) *PassiveAuth

type PersonDetails

type PersonDetails struct {
	NameOfHolder         mrz.MrzName
	OtherNames           []mrz.MrzName
	PersonalNumber       string
	FullDateOfBirth      string // YYYYMMDD
	PlaceOfBirth         []string
	Address              []string
	Telephone            string
	Profession           string
	Title                string
	PersonalSummary      string
	ProofOfCitizenship   []byte // image (ISO-10918)
	OtherTravelDocuments []string
	CustodyInformation   string
}

type SOD

type SOD struct {
	RawData           []byte
	SD                *cms.SignedData
	LdsSecurityObject *LDSSecurityObject
}

func NewSOD

func NewSOD(data []byte) (*SOD, error)

type SecurityInfoOid

type SecurityInfoOid struct {
	Raw      asn1.RawContent
	Protocol asn1.ObjectIdentifier `asn1:""`
}

type SecurityInfoOidSET

type SecurityInfoOidSET []SecurityInfoOid

type SecurityInfos

type SecurityInfos struct {
	PaceInfos            []PaceInfo
	PaceDomainParamInfos []PaceDomainParameterInfo
	ActiveAuthInfos      []ActiveAuthenticationInfo
	ChipAuthInfos        []ChipAuthenticationInfo
	ChipAuthPubKeyInfos  []ChipAuthenticationPublicKeyInfo
	TermAuthInfos        []TerminalAuthenticationInfo
	EfDirInfos           []EFDirInfo
	UnhandledInfos       []UnhandledInfo
	TotalCnt             int
}

func DecodeSecurityInfos

func DecodeSecurityInfos(secInfoData []byte) (secInfos *SecurityInfos, err error)

TODO - currently fails if anything wrong... maybe we should be more tolerant, but record issues?

type TerminalAuthenticationInfo

type TerminalAuthenticationInfo struct {
	Protocol asn1.ObjectIdentifier
	Version  int
}

type UnhandledInfo

type UnhandledInfo struct {
	Protocol asn1.ObjectIdentifier
	RawData  []byte
}

Jump to

Keyboard shortcuts

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