From 9d4611a6f93504fd9a54afa4fecea9ec90963cd4 Mon Sep 17 00:00:00 2001 From: Oscar Sanderson Date: Tue, 13 Aug 2024 00:38:34 +0800 Subject: [PATCH] Aligned to 'Document' changes and updated to use sub-template --- go.mod | 4 +- go.sum | 6 ++ template.tpl | 241 ++++++++++++++++++--------------------------------- 3 files changed, 92 insertions(+), 159 deletions(-) diff --git a/go.mod b/go.mod index bda42c9..2a6f17d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.1 require ( github.com/dumacp/smartcard v0.1.5 - github.com/gmrtd/gmrtd v0.0.0-20240804154717-fe91101179fb + github.com/gmrtd/gmrtd v0.0.0-20240812161507-951402263c99 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c ) @@ -12,5 +12,5 @@ require ( github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 // indirect github.com/ebfe/brainpool v0.0.0-20130314170211-492e4d960f63 // indirect github.com/ebfe/scard v0.0.0-20230420082256-7db3f9b7c8a7 // indirect - golang.org/x/sys v0.23.0 // indirect + golang.org/x/sys v0.24.0 // indirect ) diff --git a/go.sum b/go.sum index 7a5467a..7755227 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,10 @@ github.com/gmrtd/gmrtd v0.0.0-20240804150410-ad0942f9038e h1:PX7/escpY+Bq7puicat github.com/gmrtd/gmrtd v0.0.0-20240804150410-ad0942f9038e/go.mod h1:yMi0ExfvEj/Tb1LZ1dfAyGe7ZVuv6kasax77Oj6HD8I= github.com/gmrtd/gmrtd v0.0.0-20240804154717-fe91101179fb h1:vEgi9ZC09u43/ZbfnMRkuBXWQdYNCySrdZ5adaQ3gk0= github.com/gmrtd/gmrtd v0.0.0-20240804154717-fe91101179fb/go.mod h1:yMi0ExfvEj/Tb1LZ1dfAyGe7ZVuv6kasax77Oj6HD8I= +github.com/gmrtd/gmrtd v0.0.0-20240812125037-707ec1f31f2c h1:3HD2ccGSRptMuaahEU51pyxolfd24ywJwG8KjmMLrss= +github.com/gmrtd/gmrtd v0.0.0-20240812125037-707ec1f31f2c/go.mod h1:yMi0ExfvEj/Tb1LZ1dfAyGe7ZVuv6kasax77Oj6HD8I= +github.com/gmrtd/gmrtd v0.0.0-20240812161507-951402263c99 h1:YdNOeak+iphgZqglCtrZU3wK9SU3XOFtYX8WYmVsUY4= +github.com/gmrtd/gmrtd v0.0.0-20240812161507-951402263c99/go.mod h1:yMi0ExfvEj/Tb1LZ1dfAyGe7ZVuv6kasax77Oj6HD8I= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= @@ -64,3 +68,5 @@ golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/template.tpl b/template.tpl index 854f0bd..0135288 100644 --- a/template.tpl +++ b/template.tpl @@ -12,6 +12,16 @@ h2 { +{{define "fileHexAndTlv"}} +
+{{. | BytesToHex}}
+
+ +
+{{. | TlvBytesToString}}
+
+{{end}} +

GMRTD

@@ -29,108 +39,66 @@ ATS: {{.Ats | BytesToHex}}
 

CardAccess

-{{if .CardAccess}} -
-{{.CardAccess.RawData | BytesToHex}}
-
- -
-{{.CardAccess.RawData | TlvBytesToString}}
-
+{{if .Mf.CardAccess}} +{{template "fileHexAndTlv" .Mf.CardAccess.RawData}} {{else}} No data {{end}}

CardSecurity

-{{if .CardSecurity}} -
-{{.CardSecurity.RawData | BytesToHex}}
-
- -
-{{.CardSecurity.RawData | TlvBytesToString}}
-
+{{if .Mf.CardSecurity}} +{{template "fileHexAndTlv" .Mf.CardSecurity.RawData}} {{else}} No data {{end}}

DIR

-{{if .Dir}} -
-{{.Dir.RawData | BytesToHex}}
-
- -
-{{.Dir.RawData | TlvBytesToString}}
-
+{{if .Mf.Dir}} +{{template "fileHexAndTlv" .Mf.Dir.RawData}} {{else}} No data {{end}}

COM

-{{if .Com}} -
-{{.Com.RawData | BytesToHex}}
-
- -
-{{.Com.RawData | TlvBytesToString}}
-
+{{if .Mf.Lds1.Com}} +{{template "fileHexAndTlv" .Mf.Lds1.Com.RawData}} {{else}} No data {{end}} -

SOD

-{{if .Sod}} -
-{{.Sod.RawData | BytesToHex}}
-
- -
-{{.Sod.RawData | TlvBytesToString}}
-
+

SOD Document Security Object

+{{if .Mf.Lds1.Sod}} +{{template "fileHexAndTlv" .Mf.Lds1.Sod.RawData}} {{else}} No data {{end}} -

DG1

-{{if .Dg1}} -
-{{.Dg1.RawData | BytesToHex}}
-
- -
-{{.Dg1.RawData | TlvBytesToString}}
-
+

DG1 Machine Readable Zone Information

+{{if .Mf.Lds1.Dg1}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg1.RawData}}
-DocumentCode  : {{.Dg1.Mrz.DocumentCode}}
-IssuingState  : {{.Dg1.Mrz.IssuingState}}
-NameOfHolder  : [Primary] {{.Dg1.Mrz.NameOfHolder.Primary}} [Secondary] {{.Dg1.Mrz.NameOfHolder.Secondary}}
-DocumentNumber: {{.Dg1.Mrz.DocumentNumber}}
-Nationality   : {{.Dg1.Mrz.Nationality}}
-DateOfBirth   : {{.Dg1.Mrz.DateOfBirth}}
-Sex           : {{.Dg1.Mrz.Sex}}
-DateOfExpiry  : {{.Dg1.Mrz.DateOfExpiry}}
-OptionalData  : {{.Dg1.Mrz.OptionalData}}
-OptionalData2 : {{.Dg1.Mrz.OptionalData2}}
+DocumentCode  : {{.Mf.Lds1.Dg1.Mrz.DocumentCode}}
+IssuingState  : {{.Mf.Lds1.Dg1.Mrz.IssuingState}}
+NameOfHolder  : [Primary] {{.Mf.Lds1.Dg1.Mrz.NameOfHolder.Primary}} [Secondary] {{.Mf.Lds1.Dg1.Mrz.NameOfHolder.Secondary}}
+DocumentNumber: {{.Mf.Lds1.Dg1.Mrz.DocumentNumber}}
+Nationality   : {{.Mf.Lds1.Dg1.Mrz.Nationality}}
+DateOfBirth   : {{.Mf.Lds1.Dg1.Mrz.DateOfBirth}}
+Sex           : {{.Mf.Lds1.Dg1.Mrz.Sex}}
+DateOfExpiry  : {{.Mf.Lds1.Dg1.Mrz.DateOfExpiry}}
+OptionalData  : {{.Mf.Lds1.Dg1.Mrz.OptionalData}}
+OptionalData2 : {{.Mf.Lds1.Dg1.Mrz.OptionalData2}}
 
{{else}} No data {{end}} -

DG2

-{{if .Dg2}} -
-{{.Dg2.RawData | BytesToHex}}
-
- -
-{{.Dg2.RawData | TlvBytesToString}}
-
+

DG2 Encoded Identification Features - Face

+{{if .Mf.Lds1.Dg2}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg2.RawData}} -{{ range .Dg2.BITs }} +{{ range .Mf.Lds1.Dg2.BITs }} {{ range .BDB.Facial.Images }}
@@ -143,123 +111,82 @@ OptionalData2 : {{.Dg1.Mrz.OptionalData2}} No data {{end}} -

DG7

-{{if .Dg7}} -
-{{.Dg7.RawData | BytesToHex}}
-
- -
-{{.Dg7.RawData | TlvBytesToString}}
-
+

DG7 Displayed Signature or Usual Mark

+{{if .Mf.Lds1.Dg7}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg7.RawData}} + {{else}} No data {{end}} -

DG11

-{{if .Dg11}} -
-{{.Dg11.RawData | BytesToHex}}
-
- -
-{{.Dg11.RawData | TlvBytesToString}}
-
- -
-NameOfHolder        : {{.Dg11.Details.NameOfHolder}}
-OtherNames          : {{.Dg11.Details.OtherNames}}
-PersonalNumber      : {{.Dg11.Details.PersonalNumber}}
-FullDateOfBirth     : {{.Dg11.Details.FullDateOfBirth}}
-PlaceOfBirth        : {{.Dg11.Details.PlaceOfBirth}}
-Address             : {{.Dg11.Details.Address}}
-Telephone           : {{.Dg11.Details.Telephone}}
-Profession          : {{.Dg11.Details.Profession}}
-Title               : {{.Dg11.Details.Title}}
-PersonalSummary     : {{.Dg11.Details.PersonalSummary}}
-ProofOfCitizenship  : {{.Dg11.Details.ProofOfCitizenship | BytesToHex}}
-OtherTravelDocuments: {{.Dg11.Details.OtherTravelDocuments}}
-CustodyInformation  : {{.Dg11.Details.CustodyInformation}}
+

DG11 Additional Personal Detail(s)

+{{if .Mf.Lds1.Dg11}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg11.RawData}} + +
+NameOfHolder        : {{.Mf.Lds1.Dg11.Details.NameOfHolder}}
+OtherNames          : {{.Mf.Lds1.Dg11.Details.OtherNames}}
+PersonalNumber      : {{.Mf.Lds1.Dg11.Details.PersonalNumber}}
+FullDateOfBirth     : {{.Mf.Lds1.Dg11.Details.FullDateOfBirth}}
+PlaceOfBirth        : {{.Mf.Lds1.Dg11.Details.PlaceOfBirth}}
+Address             : {{.Mf.Lds1.Dg11.Details.Address}}
+Telephone           : {{.Mf.Lds1.Dg11.Details.Telephone}}
+Profession          : {{.Mf.Lds1.Dg11.Details.Profession}}
+Title               : {{.Mf.Lds1.Dg11.Details.Title}}
+PersonalSummary     : {{.Mf.Lds1.Dg11.Details.PersonalSummary}}
+ProofOfCitizenship  : {{.Mf.Lds1.Dg11.Details.ProofOfCitizenship | BytesToHex}}
+OtherTravelDocuments: {{.Mf.Lds1.Dg11.Details.OtherTravelDocuments}}
+CustodyInformation  : {{.Mf.Lds1.Dg11.Details.CustodyInformation}}
 
{{else}} No data {{end}} -

DG12

-{{if .Dg12}} -
-{{.Dg12.RawData | BytesToHex}}
-
- -
-{{.Dg12.RawData | TlvBytesToString}}
-
+

DG12 Additional Document Detail(s)

+{{if .Mf.Lds1.Dg12}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg12.RawData}}
-IssuingAuthority           : {{.Dg12.Details.IssuingAuthority}}
-DateOfIssue                : {{.Dg12.Details.DateOfIssue}}
-OtherPersons               : {{.Dg12.Details.OtherPersons}}
-EndorsementsAndObservations: {{.Dg12.Details.EndorsementsAndObservations}}
-TaxExitRequirements        : {{.Dg12.Details.TaxExitRequirements}}
-ImageFront                 : {{.Dg12.Details.ImageFront | BytesToHex}}
-ImageRear                  : {{.Dg12.Details.ImageRear | BytesToHex}}
-PersoDateTime              : {{.Dg12.Details.PersoDateTime}}
-PersoSystemSerialNumber    : {{.Dg12.Details.PersoSystemSerialNumber}}
+IssuingAuthority           : {{.Mf.Lds1.Dg12.Details.IssuingAuthority}}
+DateOfIssue                : {{.Mf.Lds1.Dg12.Details.DateOfIssue}}
+OtherPersons               : {{.Mf.Lds1.Dg12.Details.OtherPersons}}
+EndorsementsAndObservations: {{.Mf.Lds1.Dg12.Details.EndorsementsAndObservations}}
+TaxExitRequirements        : {{.Mf.Lds1.Dg12.Details.TaxExitRequirements}}
+ImageFront                 : {{.Mf.Lds1.Dg12.Details.ImageFront | BytesToHex}}
+ImageRear                  : {{.Mf.Lds1.Dg12.Details.ImageRear | BytesToHex}}
+PersoDateTime              : {{.Mf.Lds1.Dg12.Details.PersoDateTime}}
+PersoSystemSerialNumber    : {{.Mf.Lds1.Dg12.Details.PersoSystemSerialNumber}}
 
{{else}} No data {{end}} -

DG13

-{{if .Dg13}} -
-{{.Dg13.RawData | BytesToHex}}
-
- -
-{{.Dg13.RawData | TlvBytesToString}}
-
+

DG13 Optional Detail(s)

+{{if .Mf.Lds1.Dg13}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg13.RawData}} {{else}} No data {{end}} -

DG14

-{{if .Dg14}} -
-{{.Dg14.RawData | BytesToHex}}
-
- -
-{{.Dg14.RawData | TlvBytesToString}}
-
+

DG14 Security Options

+{{if .Mf.Lds1.Dg14}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg14.RawData}} {{else}} No data {{end}} -

DG15

-{{if .Dg15}} -
-{{.Dg15.RawData | BytesToHex}}
-
- -
-{{.Dg15.RawData | TlvBytesToString}}
-
+

DG15 Active Authentication Public Key Info

+{{if .Mf.Lds1.Dg15}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg15.RawData}} {{else}} No data {{end}} -

DG16

-{{if .Dg16}} -
-{{.Dg16.RawData | BytesToHex}}
-
- -
-{{.Dg16.RawData | TlvBytesToString}}
-
+

DG16 Person(s) to Notify

+{{if .Mf.Lds1.Dg16}} +{{template "fileHexAndTlv" .Mf.Lds1.Dg16.RawData}} {{else}} No data {{end}}