Invert 'notspi' build tag to 'tspi' (#237)

This change allows users to specify TPM1.2 support rather than remove it.
go-attestation will build without needing Trousers/TSPI support.
The flip-side of this is that TPM1.2 does not just work; TPM1.2 users need to
include the `tspi` build tag.
This commit is contained in:
Alex Wu 2021-09-01 12:55:02 -07:00 committed by GitHub
parent 7cf0af2beb
commit 505680f536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 8 deletions

View File

@ -2,6 +2,20 @@ on: [push, pull_request]
name: Test
jobs:
test-linux:
strategy:
matrix:
go-version: [1.16.x, 1.17.x]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: go test ./...
test-linux-tpm12:
strategy:
matrix:
go-version: [1.16.x, 1.17.x]
@ -16,7 +30,7 @@ jobs:
- name: Install libtspi
run: sudo apt-get install -y libtspi-dev
- name: Test
run: go test ./...
run: go test -tags tspi ./...
test-macos:
strategy:
matrix:

View File

@ -27,12 +27,12 @@ testing is not covered by CI.
The go-attestation package is installable using go get: `go get github.com/google/go-attestation/attest`
Linux users must install `libtspi` and its headers if they need TPM 1.2 support. This can be installed on debian-based systems using: `sudo apt-get install libtspi-dev`.
### TPM1.2
By default, go-attestation does not build in TPM1.2 support on Linux.
Linux users must install [`libtspi`](http://trousers.sourceforge.net/) and its headers if they need TPM 1.2 support. This can be installed on debian-based systems using: `sudo apt-get install libtspi-dev`.
Then, build go-attestation with the `tspi` [build tag](https://pkg.go.dev/go/build#hdr-Build_Constraints) `go build --tags=tspi`.
In case Linux users need only TPM 2.0 support, they can:
* still install `libtspi`
* or turn off cgo completely, e.g., `CGO_ENABLED=0 go build`
* or use `notspi` build tag if cgo is needed for some reasons, e.g., `go build --tags=notspi`
Windows users can use go-attestation with TPM1.2 by default.
## Example: device identity

View File

@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.
// +build linux,!gofuzz,cgo,!notspi
// +build linux,!gofuzz,cgo,tspi
package attest

View File

@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.
// +build linux,!gofuzz,cgo,!notspi
// +build linux,!gofuzz,cgo,tspi
package attest