mirror of
https://github.com/google/go-attestation.git
synced 2024-12-21 22:07:56 +00:00
Fix building without cgo
This commit is contained in:
parent
59a5f6851d
commit
355782cbf9
@ -1,4 +1,4 @@
|
|||||||
// +build !cgo
|
// +build cgo
|
||||||
|
|
||||||
package attest
|
package attest
|
||||||
|
|
||||||
@ -33,21 +33,6 @@ const (
|
|||||||
tpm20GeneratedMagic = 0xff544347
|
tpm20GeneratedMagic = 0xff544347
|
||||||
)
|
)
|
||||||
|
|
||||||
func cryptoHash(h tpm2.Algorithm) (crypto.Hash, error) {
|
|
||||||
switch h {
|
|
||||||
case tpm2.AlgSHA1:
|
|
||||||
return crypto.SHA1, nil
|
|
||||||
case tpm2.AlgSHA256:
|
|
||||||
return crypto.SHA256, nil
|
|
||||||
case tpm2.AlgSHA384:
|
|
||||||
return crypto.SHA384, nil
|
|
||||||
case tpm2.AlgSHA512:
|
|
||||||
return crypto.SHA512, nil
|
|
||||||
default:
|
|
||||||
return crypto.Hash(0), fmt.Errorf("unsupported signature digest: %v", h)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActivationParameters encapsulates the inputs for activating an AIK.
|
// ActivationParameters encapsulates the inputs for activating an AIK.
|
||||||
type ActivationParameters struct {
|
type ActivationParameters struct {
|
||||||
// TPMVersion holds the version of the TPM, either 1.2 or 2.0.
|
// TPMVersion holds the version of the TPM, either 1.2 or 2.0.
|
||||||
|
22
attest/cryptohash.go
Normal file
22
attest/cryptohash.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package attest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"fmt"
|
||||||
|
"github.com/google/go-tpm/tpm2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cryptoHash(h tpm2.Algorithm) (crypto.Hash, error) {
|
||||||
|
switch h {
|
||||||
|
case tpm2.AlgSHA1:
|
||||||
|
return crypto.SHA1, nil
|
||||||
|
case tpm2.AlgSHA256:
|
||||||
|
return crypto.SHA256, nil
|
||||||
|
case tpm2.AlgSHA384:
|
||||||
|
return crypto.SHA384, nil
|
||||||
|
case tpm2.AlgSHA512:
|
||||||
|
return crypto.SHA512, nil
|
||||||
|
default:
|
||||||
|
return crypto.Hash(0), fmt.Errorf("unsupported signature digest: %v", h)
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
// License for the specific language governing permissions and limitations under
|
// License for the specific language governing permissions and limitations under
|
||||||
// the License.
|
// the License.
|
||||||
|
|
||||||
// +build linux !cgo
|
// +build linux,cgo
|
||||||
|
|
||||||
package attest
|
package attest
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// License for the specific language governing permissions and limitations under
|
// License for the specific language governing permissions and limitations under
|
||||||
// the License.
|
// the License.
|
||||||
|
|
||||||
// +build linux !cgo
|
// +build linux,cgo
|
||||||
|
|
||||||
package attest
|
package attest
|
||||||
|
|
||||||
|
62
attest/tpm_other.go
Normal file
62
attest/tpm_other.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright 2019 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// +build !linux !windows
|
||||||
|
|
||||||
|
package attest
|
||||||
|
|
||||||
|
type platformTPM struct {
|
||||||
|
// interf TPMInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func probeSystemTPMs() ([]probedTPM, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func openTPM(tpm probedTPM) (*TPM, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) tpmVersion() TPMVersion {
|
||||||
|
return TPMVersionAgnostic
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) info() (*TPMInfo, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) loadAIK(opaqueBlob []byte) (*AIK, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) eks() ([]EK, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) newAIK(opts *AIKConfig) (*AIK, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) pcrs(alg HashAlg) ([]PCR, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *platformTPM) measurementLog() ([]byte, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user