func GetHardwareDetailsFromRDNSequence(sequence pkix.RDNSequence) (*HardwareDetails, error) {
	details := new(HardwareDetails)
	for _, set := range sequence {
		for _, attribute := range set {
			str, ok := attribute.Value.(string)
			if !ok {
				continue
			}

			switch {
			case attribute.Type.Equal(oidTPMManufacturer):
				vendorID, err := UnmarshalVendorID(str)
				if err != nil {
					return nil, fmt.Errorf("%w: %s", ErrInvalidHardwareDetails, err)
				}

				vendor, ok := RegisteredVendors[vendorID]
				if !ok {
					return nil, fmt.Errorf("%w: unknown TPM vendor: %4X", ErrInvalidHardwareDetails, vendorID)
				}

				details.Manufacturer = vendor
			case attribute.Type.Equal(oidTPMPartNumber):
				details.PartNumber = str
			case attribute.Type.Equal(oidTPMFirmwareVersion):
				details.FirmwareVersion = str
			}
		}
	}

	switch {
	case details.Manufacturer.ID == VendorID{}:
		return nil, fmt.Errorf("%w: missing TPM manufacturer", ErrInvalidHardwareDetails)
	case details.PartNumber == "":
		return nil, fmt.Errorf("%w: missing TPM part number", ErrInvalidHardwareDetails)
	case details.FirmwareVersion == "":
		return nil, fmt.Errorf("%w: missing TPM firmware version", ErrInvalidHardwareDetails)
	}

	return details, nil
}
// GetHardwareDetailsFromRDNSequence gets the hardware details from Relative Distinguished Name sequence.
GetHardwareDetailsFromRDNSequence gets the hardware details from Relative Distinguished Name sequence.
// GetHardwareDetailsFromRDNSequence gets the hardware details from Relative Distinguished Name sequence .
func GetHardwareDetailsFromRDNSequence(sequence pkix.RDNSequence) (*HardwareDetails, error) {
	details := new(HardwareDetails)
	for _, set := range sequence {
		for _, attribute := range set {
			str, ok := attribute.Value.(string)
			if !ok {
				continue
			}
			switch {
			case attribute.Type.Equal(oidTPMManufacturer):
				vendorID, err := UnmarshalVendorID(str)
				if err != nil {
					return nil, fmt.Errorf("%w: %s", ErrInvalidHardwareDetails, err)
				}
				vendor, ok := RegisteredVendors[vendorID]
				if !ok {
					return nil, fmt.Errorf("%w: unknown TPM vendor: %4X", ErrInvalidHardwareDetails, vendorID)
				}
				details.Manufacturer = vendor
			case attribute.Type.Equal(oidTPMPartNumber):
				details.PartNumber = str
			case attribute.Type.Equal(oidTPMFirmwareVersion):
				details.FirmwareVersion = str
			}
		}
	}
	switch {
	case details.Manufacturer.ID == VendorID{}:
		return nil, fmt.Errorf("%w: missing TPM manufacturer", ErrInvalidHardwareDetails)
	case details.PartNumber == "":
		return nil, fmt.Errorf("%w: missing TPM part number", ErrInvalidHardwareDetails)
	case details.FirmwareVersion == "":
		return nil, fmt.Errorf("%w: missing TPM firmware version", ErrInvalidHardwareDetails)
	}
	return details, nil
}
func GetHardwareDetailsFromRDNSequence ( sequence pkix . RDNSequence ) ( * HardwareDetails , error ) { details := new ( HardwareDetails ) for _ , set := range sequence { for _ , attribute := range set { str , ok := attribute . Value . ( string ) if ! ok { continue } switch { case attribute . Type . Equal ( oidTPMManufacturer ) : vendorID , err := UnmarshalVendorID ( str ) if err != nil { return nil , fmt . Errorf ( " " , ErrInvalidHardwareDetails , err ) } vendor , ok := RegisteredVendors [ vendorID ] if ! ok { return nil , fmt . Errorf ( " " , ErrInvalidHardwareDetails , vendorID ) } details . Manufacturer = vendor case attribute . Type . Equal ( oidTPMPartNumber ) : details . PartNumber = str case attribute . Type . Equal ( oidTPMFirmwareVersion ) : details . FirmwareVersion = str } } } switch { case details . Manufacturer . ID == VendorID { } : return nil , fmt . Errorf ( " " , ErrInvalidHardwareDetails ) case details . PartNumber == " " : return nil , fmt . Errorf ( " " , ErrInvalidHardwareDetails ) case details . FirmwareVersion == " " : return nil , fmt . Errorf ( " " , ErrInvalidHardwareDetails ) } return details , nil }
GetHardwareDetailsFromRDNSequence gets the hardware details from Relative Distinguished Name sequence.
GetHardwareDetailsFromRDNSequence gets the hardware details from Relative Distinguished Name sequence .