github.com/google/trillian-examples@v0.0.0-20240520080811-0d40d35cef0e/binary_transparency/firmware/api/firmware_metadata.go (about) 1 // Copyright 2020 Google LLC. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package api 16 17 import "fmt" 18 19 // FirmwareMetadata represents a firmware image and related info. 20 type FirmwareMetadata struct { 21 ////// What's this firmware for? ////// 22 23 // TODO(al): consider a vendor/device/publisher model 24 25 // DeviceID specifies the target device for this firmware. 26 DeviceID string 27 28 ////// What's its identity? ////// 29 30 // FirmwareRevision specifies which version of firmware this is. 31 // TODO(al): consider whether to use a string 32 FirmwareRevision uint64 33 34 // FirmwareImageSHA512 is the SHA512 hash over the firmware image as it will 35 // be delivered. 36 FirmwareImageSHA512 []byte 37 38 // ExpectedFirmwareMeasurement represents the expected measured state of the 39 // device once the firmware is installed. 40 ExpectedFirmwareMeasurement []byte 41 42 ///// What's its provenance? ////// 43 44 // BuildTimestamp is the time at which this build was published in RFC3339 format. 45 // e.g. "1985-04-12T23:20:50.52Z" 46 BuildTimestamp string 47 } 48 49 // String returns a human-readable representation of the firmware metadata info. 50 func (m FirmwareMetadata) String() string { 51 return fmt.Sprintf("%s/v%d built at %s with image hash 0x%x", m.DeviceID, m.FirmwareRevision, m.BuildTimestamp, m.FirmwareImageSHA512) 52 }