mirror of
https://github.com/google/go-attestation.git
synced 2025-06-06 01:11:33 +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
|
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 (
|
var (
|
||||||
defaultOpenConfig = &OpenConfig{}
|
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) {
|
func (k *key12) quote(t *platformTPM, nonce []byte, alg HashAlg) (*Quote, error) {
|
||||||
if alg != HashSHA1 {
|
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)
|
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) {
|
func (k *key12) quote(t *platformTPM, nonce []byte, alg HashAlg) (*Quote, error) {
|
||||||
if alg != HashSHA1 {
|
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)
|
tpmKeyHnd, err := t.pcp.TPMKeyHandle(k.hnd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user