Skip to content

Commit

Permalink
Aligned to 'Document' changes and updated to use sub-template
Browse files Browse the repository at this point in the history
  • Loading branch information
osanderson committed Aug 12, 2024
1 parent dc90fa7 commit 9d4611a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 159 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ 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
)

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
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
241 changes: 84 additions & 157 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ h2 {
</head>
<body>

{{define "fileHexAndTlv"}}
<div><pre>
{{. | BytesToHex}}
</pre></div>

<div><pre>
{{. | TlvBytesToString}}
</pre></div>
{{end}}

<h1>GMRTD</h1>

<div><pre>
Expand All @@ -29,108 +39,66 @@ ATS: {{.Ats | BytesToHex}}
</pre></div>

<h2>CardAccess</h2>
{{if .CardAccess}}
<div><pre>
{{.CardAccess.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.CardAccess.RawData | TlvBytesToString}}
</pre></div>
{{if .Mf.CardAccess}}
{{template "fileHexAndTlv" .Mf.CardAccess.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>CardSecurity</h2>
{{if .CardSecurity}}
<div><pre>
{{.CardSecurity.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.CardSecurity.RawData | TlvBytesToString}}
</pre></div>
{{if .Mf.CardSecurity}}
{{template "fileHexAndTlv" .Mf.CardSecurity.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>DIR</h2>
{{if .Dir}}
<div><pre>
{{.Dir.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dir.RawData | TlvBytesToString}}
</pre></div>
{{if .Mf.Dir}}
{{template "fileHexAndTlv" .Mf.Dir.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>COM</h2>
{{if .Com}}
<div><pre>
{{.Com.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Com.RawData | TlvBytesToString}}
</pre></div>
{{if .Mf.Lds1.Com}}
{{template "fileHexAndTlv" .Mf.Lds1.Com.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>SOD</h2>
{{if .Sod}}
<div><pre>
{{.Sod.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Sod.RawData | TlvBytesToString}}
</pre></div>
<h2>SOD <sub>Document Security Object</sub></h2>
{{if .Mf.Lds1.Sod}}
{{template "fileHexAndTlv" .Mf.Lds1.Sod.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>DG1</h2>
{{if .Dg1}}
<div><pre>
{{.Dg1.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg1.RawData | TlvBytesToString}}
</pre></div>
<h2>DG1 <sub>Machine Readable Zone Information</sub></h2>
{{if .Mf.Lds1.Dg1}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg1.RawData}}

<div><pre>
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}}
</pre></div>
{{else}}
<i>No data</i>
{{end}}

<h2>DG2</h2>
{{if .Dg2}}
<div><pre>
{{.Dg2.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg2.RawData | TlvBytesToString}}
</pre></div>
<h2>DG2 <sub>Encoded Identification Features - Face</sub></h2>
{{if .Mf.Lds1.Dg2}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg2.RawData}}

<!-- TODO - would be good got DG2 to provide an easier way to access the images -->
{{ range .Dg2.BITs }}
{{ range .Mf.Lds1.Dg2.BITs }}
{{ range .BDB.Facial.Images }}
<img src="data:image/jpeg;base64,{{.Data | BytesToBase64}}" />
<br/>
Expand All @@ -143,123 +111,82 @@ OptionalData2 : {{.Dg1.Mrz.OptionalData2}}
<i>No data</i>
{{end}}

<h2>DG7</h2>
{{if .Dg7}}
<div><pre>
{{.Dg7.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg7.RawData | TlvBytesToString}}
</pre></div>
<h2>DG7 <sub>Displayed Signature or Usual Mark</sub></h2>
{{if .Mf.Lds1.Dg7}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg7.RawData}}
<!-- TODO - output any image(s) -->
{{else}}
<i>No data</i>
{{end}}

<h2>DG11</h2>
{{if .Dg11}}
<div><pre>
{{.Dg11.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg11.RawData | TlvBytesToString}}
</pre></div>

<div><pre>
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}}
<h2>DG11 <sub>Additional Personal Detail(s)</sub></h2>
{{if .Mf.Lds1.Dg11}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg11.RawData}}

<div><pre>
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}}
</div></pre>

{{else}}
<i>No data</i>
{{end}}

<h2>DG12</h2>
{{if .Dg12}}
<div><pre>
{{.Dg12.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg12.RawData | TlvBytesToString}}
</pre></div>
<h2>DG12 <sub>Additional Document Detail(s)</sub></h2>
{{if .Mf.Lds1.Dg12}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg12.RawData}}

<div><pre>
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}}
</pre></div>

{{else}}
<i>No data</i>
{{end}}

<h2>DG13</h2>
{{if .Dg13}}
<div><pre>
{{.Dg13.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg13.RawData | TlvBytesToString}}
</pre></div>
<h2>DG13 <sub>Optional Detail(s)</sub></h2>
{{if .Mf.Lds1.Dg13}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg13.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>DG14</h2>
{{if .Dg14}}
<div><pre>
{{.Dg14.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg14.RawData | TlvBytesToString}}
</pre></div>
<h2>DG14 <sub>Security Options</sub></h2>
{{if .Mf.Lds1.Dg14}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg14.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>DG15</h2>
{{if .Dg15}}
<div><pre>
{{.Dg15.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg15.RawData | TlvBytesToString}}
</pre></div>
<h2>DG15 <sub>Active Authentication Public Key Info</sub></h2>
{{if .Mf.Lds1.Dg15}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg15.RawData}}
{{else}}
<i>No data</i>
{{end}}

<h2>DG16</h2>
{{if .Dg16}}
<div><pre>
{{.Dg16.RawData | BytesToHex}}
</pre></div>

<div><pre>
{{.Dg16.RawData | TlvBytesToString}}
</pre></div>
<h2>DG16 <sub>Person(s) to Notify</sub></h2>
{{if .Mf.Lds1.Dg16}}
{{template "fileHexAndTlv" .Mf.Lds1.Dg16.RawData}}
{{else}}
<i>No data</i>
{{end}}
Expand Down

0 comments on commit 9d4611a

Please sign in to comment.