// GetAkQualifiedName gets the Attestation Key Qualified Name which is the
// hash of the public area of the key concatenated with the qualified names
// of all parent keys. This name acts as the unique identifier for the AK
// TODO check calculation again
GetAkQualifiedName gets the Attestation Key Qualified Name which is the
hash of the public area of the key concatenated with the qualified names
of all parent keys. This name acts as the unique identifier for the AK
TODO check calculation again
// GetAkQualifiedName gets the Attestation Key Qualified Name which is the // hash of the public area of the key concatenated with the qualified names // of all parent keys . This name acts as the unique identifier for the AK // TODO check calculation again
func GetAkQualifiedName() ([32]byte, error) {
	var qualifiedName [32]byte
	if tpm == nil {
		return qualifiedName, fmt.Errorf("Failed to get AK Qualified Name - TPM is not opened")
	}
	if ak == nil {
		return qualifiedName, fmt.Errorf("Failed to get AK Qualified Name - AK does not exist")
	}
	pub := ak.AttestationParameters().Public
	tpm2Pub, err := tpm2.DecodePublic(pub)
	if err != nil {
		return qualifiedName, fmt.Errorf("Failed to Decode AK Public - %v", err)
	}
	if tpm2Pub.NameAlg != tpm2.AlgSHA256 {
		return qualifiedName, errors.New("Failed to Get AK public - unsupported hash algorithm")
	}
	alg := make([]byte, 2)
	binary.LittleEndian.PutUint16(alg, uint16(tpm2Pub.NameAlg))
	digestPub := sha256.Sum256(pub)
	name := append(alg, digestPub[:]...)
	log.Debug("Name: ", hex.EncodeToString(name[:]))
	createData := ak.AttestationParameters().CreateData
	tpm2CreateData, err := tpm2.DecodeCreationData(createData)
	if err != nil {
		return qualifiedName, fmt.Errorf("Failed to Decode Creation Data: %v", err)
	}
	parentQualifiedName := tpm2CreateData.ParentQualifiedName.Digest.Value
	log.Trace("Parent Name: ", hex.EncodeToString(tpm2CreateData.ParentName.Digest.Value))
	log.Trace("Parent Qualified Name: ", hex.EncodeToString(parentQualifiedName))
	buf := append(parentQualifiedName[:], name[:]...)
	qualifiedName = sha256.Sum256(buf)
	log.Debug("AK Qualified Name: ", hex.EncodeToString(qualifiedName[:]))
	return qualifiedName, nil
}
func GetAkQualifiedName ( ) ( [ 32 ] byte , error ) { var qualifiedName [ 32 ] byte if tpm == nil { return qualifiedName , fmt . Errorf ( " " ) } if ak == nil { return qualifiedName , fmt . Errorf ( " " ) } pub := ak . AttestationParameters ( ) . Public tpm2Pub , err := tpm2 . DecodePublic ( pub ) if err != nil { return qualifiedName , fmt . Errorf ( " " , err ) } if tpm2Pub . NameAlg != tpm2 . AlgSHA256 { return qualifiedName , errors . New ( " " ) } alg := make ( [ ] byte , 2 ) binary . LittleEndian . PutUint16 ( alg , uint16 ( tpm2Pub . NameAlg ) ) digestPub := sha256 . Sum256 ( pub ) name := append ( alg , digestPub [ : ] ... ) log . Debug ( " " , hex . EncodeToString ( name [ : ] ) ) createData := ak . AttestationParameters ( ) . CreateData tpm2CreateData , err := tpm2 . DecodeCreationData ( createData ) if err != nil { return qualifiedName , fmt . Errorf ( " " , err ) } parentQualifiedName := tpm2CreateData . ParentQualifiedName . Digest . Value log . Trace ( " " , hex . EncodeToString ( tpm2CreateData . ParentName . Digest . Value ) ) log . Trace ( " " , hex . EncodeToString ( parentQualifiedName ) ) buf := append ( parentQualifiedName [ : ] , name [ : ] ... ) qualifiedName = sha256 . Sum256 ( buf ) log . Debug ( " " , hex . EncodeToString ( qualifiedName [ : ] ) ) return qualifiedName , nil }
GetAkQualifiedName gets the Attestation Key Qualified Name which is the
hash of the public area of the key concatenated with the qualified names
of all parent keys.
GetAkQualifiedName gets the Attestation Key Qualified Name which is the hash of the public area of the key concatenated with the qualified names of all parent keys .
// This is a TPMT_PUBLIC structure // TPMT_PUBLIC Contains algorithm used for hashing the public area to get // the name (nameAlg) // Name of object is nameAlg || Digest(TPMT_PUBLIC) // TPMS_CREATION_DATA contains parentQualifiedName // QN_AK := H_AK(QN_Parent || NAME_AK)