-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename tpmdirect to tpm2 and rename existing tpm2 as legacy/tpm2 (#304)
This change moves the existing tpm2 package out to legacy/tpm2 and renames the direct package as tpm2. The KDFa and KDFe helpers from the legacy API (which are needed by the new API) are moved into the new API, with the legacy API calling into the new API for htem. A small adapter layer is added at tpm2/adapter.go to provide the API that go-tpm-tools/simulator requires. In the future, we can remove it after go-tpm-tools/simulator has been updated to use the new API. We may flatten the new tpm2 library's sub-libraries structures and commands together into tpm2 in a future change, perhaps as part of resolving #302.
- Loading branch information
1 parent
abec815
commit 9860756
Showing
84 changed files
with
346 additions
and
314 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2014, Google LLC All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2014, Google LLC All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2016, Kevin Walsh. All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
package main | ||
|
||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2018, Ian Haken. All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2018, Ian Haken. All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2018, Ian Haken. All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2018, Ian Haken. All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2018, Ian Haken. All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2014, Google LLC All rights reserved. | ||
// | ||
|
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,6 +1,6 @@ | ||
module github.com/google/go-tpm | ||
|
||
go 1.17 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/google/go-cmp v0.5.0 | ||
|
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,50 @@ | ||
// Copyright (c) 2018, Google LLC All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package tpm2 | ||
|
||
import ( | ||
"github.com/google/go-tpm/tpm2/helpers" | ||
) | ||
|
||
// KDFa implements TPM 2.0's default key derivation function, as defined in | ||
// section 11.4.9.2 of the TPM revision 2 specification part 1. | ||
// See: https://trustedcomputinggroup.org/resource/tpm-library-specification/ | ||
// The key & label parameters must not be zero length. | ||
// The label parameter is a non-null-terminated string. | ||
// The contextU & contextV parameters are optional. | ||
// Deprecated: Use KDFaHash. | ||
func KDFa(hashAlg Algorithm, key []byte, label string, contextU, contextV []byte, bits int) ([]byte, error) { | ||
h, err := hashAlg.Hash() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return helpers.KDFaHash(h, key, label, contextU, contextV, bits), nil | ||
} | ||
|
||
// KDFe implements TPM 2.0's ECDH key derivation function, as defined in | ||
// section 11.4.9.3 of the TPM revision 2 specification part 1. | ||
// See: https://trustedcomputinggroup.org/resource/tpm-library-specification/ | ||
// The z parameter is the x coordinate of one party's private ECC key multiplied | ||
// by the other party's public ECC point. | ||
// The use parameter is a non-null-terminated string. | ||
// The partyUInfo and partyVInfo are the x coordinates of the initiator's and | ||
// Deprecated: Use KDFeHash. | ||
func KDFe(hashAlg Algorithm, z []byte, use string, partyUInfo, partyVInfo []byte, bits int) ([]byte, error) { | ||
h, err := hashAlg.Hash() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return helpers.KDFeHash(h, z, use, partyUInfo, partyVInfo, bits), 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2019, Google LLC All rights reserved. | ||
// | ||
|
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
File renamed without changes.
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
File renamed without changes.
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2019, Google LLC All rights reserved. | ||
// | ||
|
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,4 +1,4 @@ | ||
// +build !windows | ||
//go:build !windows | ||
|
||
// Copyright (c) 2014, Google LLC All rights reserved. | ||
// | ||
|
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,22 @@ | ||
// Package tpm2 implements an adapter layer expected by github.com/google/go-tpm-tools/simulator | ||
// TODO: after release, we can update simulator to use the new API | ||
package tpm2 | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/google/go-tpm/legacy/tpm2" | ||
) | ||
|
||
// StartupClear tells the TPM to perform a Reset and not a Restart. | ||
var StartupClear = tpm2.StartupClear | ||
|
||
// Startup initializes the TPM. | ||
func Startup(rw io.ReadWriter, typ tpm2.StartupType) error { | ||
return tpm2.Startup(rw, typ) | ||
} | ||
|
||
// Shutdown prepares the TPM for a power loss. | ||
func Shutdown(rw io.ReadWriter, typ tpm2.StartupType) error { | ||
return tpm2.Shutdown(rw, typ) | ||
} |
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
Oops, something went wrong.