-
Notifications
You must be signed in to change notification settings - Fork 24
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 #413 from smallstep/herman/fix-tss2-parent
Make `0x81000001` the default SRK handle when outputting TSS2
- Loading branch information
Showing
5 changed files
with
119 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tpm | ||
|
||
import ( | ||
"context" | ||
|
||
"go.step.sm/crypto/tpm/tss2" | ||
) | ||
|
||
const ( | ||
// Defined in "Registry of reserved TPM 2.0 handles and localities", | ||
// and checked on a glinux machine. This is the default parent handle | ||
// used by go-tpm and go-attestation, and thus also the default handle | ||
// set when marshaling to the TSS2 format. | ||
commonSrkEquivalentHandle = 0x81000001 | ||
) | ||
|
||
// ToTSS2 gets the public and private blobs and returns a [*tss2.TPMKey]. | ||
func (ak *AK) ToTSS2(ctx context.Context) (*tss2.TPMKey, error) { | ||
blobs, err := ak.Blobs(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return tss2.New( | ||
blobs.public, | ||
blobs.private, | ||
tss2.WithParent(commonSrkEquivalentHandle), // default parent used by go-tpm/go-attestation | ||
), nil | ||
} | ||
|
||
// ToTSS2 gets the public and private blobs and returns a [*tss2.TPMKey]. | ||
func (k *Key) ToTSS2(ctx context.Context) (*tss2.TPMKey, error) { | ||
blobs, err := k.Blobs(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return tss2.New( | ||
blobs.public, | ||
blobs.private, | ||
tss2.WithParent(commonSrkEquivalentHandle), // default parent used by go-tpm/go-attestation | ||
), nil | ||
} |
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