github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/tss/structures.go (about)

     1  // Copyright 2020 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package tss
     6  
     7  import (
     8  	"crypto"
     9  	"fmt"
    10  	"io"
    11  )
    12  
    13  // TCGVendorID TPM manufacturer id
    14  type TCGVendorID uint32
    15  
    16  func (id TCGVendorID) String() string {
    17  	s, ok := vendors[id]
    18  	if !ok {
    19  		return fmt.Sprintf("unknown TPM vendor (%d)", id)
    20  	}
    21  	return s
    22  }
    23  
    24  var vendors = map[TCGVendorID]string{
    25  	1095582720: "AMD",
    26  	1096043852: "Atmel",
    27  	1112687437: "Broadcom",
    28  	1229081856: "IBM",
    29  	1213220096: "HPE",
    30  	1297303124: "Microsoft",
    31  	1229346816: "Infineon",
    32  	1229870147: "Intel",
    33  	1279610368: "Lenovo",
    34  	1314082080: "National Semiconductor",
    35  	1314150912: "Nationz",
    36  	1314145024: "Nuvoton Technology",
    37  	1363365709: "Qualcomm",
    38  	1397576515: "SMSC",
    39  	1398033696: "ST Microelectronics",
    40  	1397576526: "Samsung",
    41  	1397641984: "Sinosun",
    42  	1415073280: "Texas Instruments",
    43  	1464156928: "Winbond",
    44  	1380926275: "Fuzhou Rockchip",
    45  	1196379975: "Google",
    46  }
    47  
    48  // PCR encapsulates the value of a PCR at a point in time.
    49  type PCR struct {
    50  	Index     int
    51  	Digest    []byte
    52  	DigestAlg crypto.Hash
    53  }
    54  
    55  // TPM interfaces with a TPM device on the system.
    56  type TPM struct {
    57  	Version TPMVersion
    58  	Interf  TPMInterface
    59  
    60  	SysPath string
    61  	RWC     io.ReadWriteCloser
    62  }
    63  
    64  // probedTPM identifies a TPM device on the system, which
    65  // is a candidate for being used.
    66  type probedTPM struct {
    67  	Version TPMVersion
    68  	Path    string
    69  }
    70  
    71  // TPMInfo contains information about the version & interface
    72  // of an open TPM.
    73  type TPMInfo struct {
    74  	Version      TPMVersion
    75  	Interface    TPMInterface
    76  	VendorInfo   string
    77  	Manufacturer TCGVendorID
    78  
    79  	// FirmwareVersionMajor and FirmwareVersionMinor describe
    80  	// the firmware version of the TPM, but are only available
    81  	// for TPM 2.0 devices.
    82  	FirmwareVersionMajor int
    83  	FirmwareVersionMinor int
    84  }