Skip to content

Commit 4b1efa7

Browse files
cvieccoliamjm
authored andcommitted
fixing nits from liamjm's review
1 parent 39d8023 commit 4b1efa7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

attest/attest_simulated_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestSimWrappedtpmEKCertificatesInternal(t *testing.T) {
7171
if len(eks) != 0 {
7272
t.Errorf("simlator returned an ekCertificate this should not happen")
7373
}
74-
// Since the tpmsimultor does not have ek certificates we will
74+
// Since the tpmsimulator does not have ek certificates we will
7575
// test some of the internal logic here, in particular search
7676
// and injection of missing 2k rsa key.
7777
// Because of this, the test dependent on internal apis which
@@ -87,7 +87,7 @@ func TestSimWrappedtpmEKCertificatesInternal(t *testing.T) {
8787
t.Errorf("wtpm ekCertificates failed")
8888
}
8989
if len(eks) != 0 {
90-
t.Fatalf("should have returned with no eks ")
90+
t.Fatalf("should have returned with no EKs")
9191
}
9292
// Now we inject a single key and search for it
9393
_, handleFoundMap, err := wtpm.getKeyHandleKeyMap()
@@ -110,7 +110,7 @@ func TestSimWrappedtpmEKCertificatesInternal(t *testing.T) {
110110
}
111111
_, ok := handleFoundMap[commonRSAEkEquivalentHandle]
112112
if !ok {
113-
t.Fatalf("Injected key notfound")
113+
t.Fatalf("injected key notfound")
114114
}
115115
}
116116

attest/wrapped_tpm20.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func serializePublicKey(pub crypto.PublicKey) (string, error) {
201201
// Unfortunatelly some TPMs have a non rsa2048 key in the commonRSAEkEquivalentHandle
202202
// handle location. Thus we need an alternative handle to use for both creating
203203
// and searching for the rsa2048 ek.
204-
// The "Registry-of-Reserved-TPM-2.0-Handles-and-Localities-Version 1.2" section 2.3.4
204+
// The "Registry-of-Reserved-TPM-2.0-Handles-and-Localities-Version 1.2" section 2.3.1
205205
// asserts that persistent EK handles should be in the range 0x8101000-0x810100FF
206206
// Thus any value in this range is acceptable, so we arbitrarily chose
207207
// a value inmediatelly after the ECC (p256) handle.
@@ -228,11 +228,11 @@ func (t *wrappedTPM20) getKeyHandleKeyMap() (map[string]tpmutil.Handle, map[tpmu
228228
if pub.RSAParameters != nil || pub.ECCParameters != nil {
229229
key, err := pub.Key()
230230
if err != nil {
231-
return nil, nil, err
231+
return nil, nil, fmt.Errorf("failed to obtain public key for handle %x: %w", keyHandle, err)
232232
}
233233
serializedKey, err := serializePublicKey(key)
234234
if err != nil {
235-
return nil, nil, err
235+
return nil, nil, fmt.Errorf("failed to serialize public key for handle %x: %w", keyHandle, err)
236236
}
237237
key2Handle[serializedKey] = keyHandle
238238
handleFound[keyHandle] = struct{}{}
@@ -258,7 +258,7 @@ func (t *wrappedTPM20) create2048RSAEKInAvailableSlot(handleFoundMap map[tpmutil
258258
}
259259
return targetHandle, nil
260260
}
261-
return tpmutil.Handle(0), fmt.Errorf("could not create rsa 2048 key in persistent handle")
261+
return tpmutil.Handle(0), fmt.Errorf("no available handles to create RSA 2048 key in persistent handle")
262262
}
263263

264264
func (t *wrappedTPM20) ekCertificates() ([]EK, error) {

0 commit comments

Comments
 (0)