Browse Source

types/key: add IsZero method to HardwareAttestationKey (#17370)

We will need this for unmarshaling node prefs: use the zero
HardwareAttestationKey implementation when parsing and later check
`IsZero` to see if anything was loaded.

Updates #15830

Signed-off-by: Andrew Lytvynov <[email protected]>
Andrew Lytvynov 5 months ago
parent
commit
840c7668e2
2 changed files with 3 additions and 0 deletions
  1. 2 0
      feature/tpm/attestation.go
  2. 1 0
      types/key/hardware_attestation.go

+ 2 - 0
feature/tpm/attestation.go

@@ -262,3 +262,5 @@ func (ak *attestationKey) Clone() key.HardwareAttestationKey {
 		pub:        ak.pub,
 	}
 }
+
+func (ak *attestationKey) IsZero() bool { return !ak.loaded() }

+ 1 - 0
types/key/hardware_attestation.go

@@ -32,6 +32,7 @@ type HardwareAttestationKey interface {
 	json.Unmarshaler
 	io.Closer
 	Clone() HardwareAttestationKey
+	IsZero() bool
 }
 
 // HardwareAttestationPublicFromPlatformKey creates a HardwareAttestationPublic