mirror of
https://github.com/google/go-attestation.git
synced 2025-04-15 06:56:40 +00:00
Implement fmt.Stringer on HashAlg (#109)
This commit is contained in:
parent
b60a7ccac1
commit
cf79e026c5
@ -301,6 +301,17 @@ func (a HashAlg) goTPMAlg() tpm2.Algorithm {
|
||||
return 0
|
||||
}
|
||||
|
||||
// String returns a human-friendly representation of the hash algorithm.
|
||||
func (a HashAlg) String() string {
|
||||
switch a {
|
||||
case HashSHA1:
|
||||
return "SHA1"
|
||||
case HashSHA256:
|
||||
return "SHA256"
|
||||
}
|
||||
return fmt.Sprintf("HashAlg<%d>", int(a))
|
||||
}
|
||||
|
||||
var (
|
||||
defaultOpenConfig = &OpenConfig{}
|
||||
|
||||
|
@ -63,7 +63,7 @@ func (k *key12) activateCredential(t *platformTPM, in EncryptedCredential) ([]by
|
||||
|
||||
func (k *key12) quote(t *platformTPM, nonce []byte, alg HashAlg) (*Quote, error) {
|
||||
if alg != HashSHA1 {
|
||||
return nil, fmt.Errorf("only SHA1 algorithms supported on TPM 1.2, not HashAlg(%v)", alg)
|
||||
return nil, fmt.Errorf("only SHA1 algorithms supported on TPM 1.2, not %v", alg)
|
||||
}
|
||||
|
||||
quote, rawSig, err := attestation.GetQuote(t.ctx, k.blob, nonce)
|
||||
|
@ -57,7 +57,7 @@ func (k *key12) activateCredential(tpm *platformTPM, in EncryptedCredential) ([]
|
||||
|
||||
func (k *key12) quote(t *platformTPM, nonce []byte, alg HashAlg) (*Quote, error) {
|
||||
if alg != HashSHA1 {
|
||||
return nil, fmt.Errorf("only SHA1 algorithms supported on TPM 1.2, not HashAlg(%v)", alg)
|
||||
return nil, fmt.Errorf("only SHA1 algorithms supported on TPM 1.2, not %v", alg)
|
||||
}
|
||||
|
||||
tpmKeyHnd, err := t.pcp.TPMKeyHandle(k.hnd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user