func computeKeyID()

in server/signedcontainer/verify.go [91:102]


func computeKeyID(pemBytes []byte) (string, error) {
	derBlock, rest := pem.Decode(pemBytes)
	if derBlock == nil {
		return "", errors.New("could not decode public key bytes as PEM")
	}
	if len(rest) > 0 {
		return "", errors.New("unexpected trailing data in key file")
	}
	// Use sha256 to compute the fingerprint on the DER bytes.
	fingerprint := sha256.Sum256(derBlock.Bytes)
	return hex.EncodeToString(fingerprint[:]), nil
}