-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from alexmwu/policy
Add Policy object for server-side remote attestation
- Loading branch information
Showing
18 changed files
with
1,446 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module github.com/google/go-tpm-tools | ||
|
||
// Move to new-style build tags when updating to 1.17 | ||
go 1.16 | ||
|
||
require ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/go-tpm/tpm2" | ||
) | ||
|
||
// GetSigningHashAlg returns the hash algorithm used for a signing key. Returns | ||
// an error if an algorithm isn't supported, or the key is not a signing key. | ||
func GetSigningHashAlg(pubArea tpm2.Public) (tpm2.Algorithm, error) { | ||
if pubArea.Attributes&tpm2.FlagSign == 0 { | ||
return tpm2.AlgNull, fmt.Errorf("non-signing key used with signing operation") | ||
} | ||
|
||
var sigScheme *tpm2.SigScheme | ||
switch pubArea.Type { | ||
case tpm2.AlgRSA: | ||
sigScheme = pubArea.RSAParameters.Sign | ||
case tpm2.AlgECC: | ||
sigScheme = pubArea.ECCParameters.Sign | ||
default: | ||
return tpm2.AlgNull, fmt.Errorf("unsupported key type: %v", pubArea.Type) | ||
} | ||
|
||
if sigScheme == nil { | ||
return tpm2.AlgNull, fmt.Errorf("unsupported null signing scheme") | ||
} | ||
switch sigScheme.Alg { | ||
case tpm2.AlgRSAPSS, tpm2.AlgRSASSA, tpm2.AlgECDSA: | ||
return sigScheme.Hash, nil | ||
default: | ||
return tpm2.AlgNull, fmt.Errorf("unsupported signing algorithm: %v", sigScheme.Alg) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.