github.com/andrewsun2898/u-root@v6.0.1-0.20200616011413-4b2895c1b815+incompatible/pkg/tss/nvram.go (about) 1 // Copyright 2020 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package tss 6 7 import ( 8 "crypto/sha1" 9 "io" 10 11 tpm1 "github.com/google/go-tpm/tpm" 12 tpm2 "github.com/google/go-tpm/tpm2" 13 tpmutil "github.com/google/go-tpm/tpmutil" 14 ) 15 16 func nvRead12(rwc io.ReadWriteCloser, index, offset, len uint32, ownerPW string) ([]byte, error) { 17 var ownAuth [20]byte 18 19 if ownerPW != "" { 20 ownAuth = sha1.Sum([]byte(ownerPW)) 21 } 22 return tpm1.NVReadValue(rwc, index, offset, len, []byte(ownAuth[:20])) 23 } 24 25 func nvRead20(rwc io.ReadWriteCloser, index, authHandle tpmutil.Handle, password string, blocksize int) ([]byte, error) { 26 return tpm2.NVReadEx(rwc, index, authHandle, password, blocksize) 27 }