mirror of
https://github.com/google/go-attestation.git
synced 2025-06-10 11:11:46 +00:00
Handle platform certificates that only provide a single property (#168)
Handle platform certificates that only provide a single property The spec states that the PlatformProperties field of the PlatformConfiguration attribute should be a sequence of key value pairs. However, it seems that if there's only a single property present, it's sometimes being stored as a bare key value pair rather than a sequence with a single entry. Work around that.
This commit is contained in:
parent
fbd936aac7
commit
42b1d805de
@ -448,6 +448,13 @@ type PlatformConfigurationV2 struct {
|
|||||||
PlatformPropertiesURI URIReference `asn1:"optional,tag:3"`
|
PlatformPropertiesURI URIReference `asn1:"optional,tag:3"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PlatformConfigurationV2Workaround struct {
|
||||||
|
ComponentIdentifiers []ComponentIdentifierV2 `asn1:"optional,tag:0"`
|
||||||
|
ComponentIdentifiersURI URIReference `asn1:"optional,tag:1"`
|
||||||
|
PlatformProperty Property `asn1:"optional,tag:2"`
|
||||||
|
PlatformPropertiesURI URIReference `asn1:"optional,tag:3"`
|
||||||
|
}
|
||||||
|
|
||||||
type ComponentIdentifierV1 struct {
|
type ComponentIdentifierV1 struct {
|
||||||
ComponentClass []byte `asn1:"optional"`
|
ComponentClass []byte `asn1:"optional"`
|
||||||
ComponentManufacturer string
|
ComponentManufacturer string
|
||||||
@ -580,8 +587,15 @@ func parseAttributeCertificate(in *attributeCertificate) (*AttributeCertificate,
|
|||||||
case attribute.ID.Equal(oidTcgPlatformConfigurationV2):
|
case attribute.ID.Equal(oidTcgPlatformConfigurationV2):
|
||||||
var platformConfiguration PlatformConfigurationV2
|
var platformConfiguration PlatformConfigurationV2
|
||||||
if _, err := asn1.Unmarshal(attribute.RawValues[0].FullBytes, &platformConfiguration); err != nil {
|
if _, err := asn1.Unmarshal(attribute.RawValues[0].FullBytes, &platformConfiguration); err != nil {
|
||||||
|
var workaround PlatformConfigurationV2Workaround
|
||||||
|
if _, err := asn1.Unmarshal(attribute.RawValues[0].FullBytes, &workaround); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
platformConfiguration.ComponentIdentifiers = workaround.ComponentIdentifiers
|
||||||
|
platformConfiguration.ComponentIdentifiersURI = workaround.ComponentIdentifiersURI
|
||||||
|
platformConfiguration.PlatformProperties = append(platformConfiguration.PlatformProperties, workaround.PlatformProperty)
|
||||||
|
platformConfiguration.PlatformPropertiesURI = workaround.PlatformPropertiesURI
|
||||||
|
}
|
||||||
for _, component := range platformConfiguration.ComponentIdentifiers {
|
for _, component := range platformConfiguration.ComponentIdentifiers {
|
||||||
t := Component{
|
t := Component{
|
||||||
Manufacturer: component.ComponentManufacturer,
|
Manufacturer: component.ComponentManufacturer,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user