@@ -159,9 +159,9 @@ func (t *wrappedTPM20) newAK(opts *AKConfig) (*AK, error) {
159
159
160
160
func (t * wrappedTPM20 ) newKey (ak * AK , opts * KeyConfig ) (* Key , error ) {
161
161
// TODO(szp): TODO(jsonp): Abstract choice of hierarchy & parent.
162
- certifierHandle , err := ak .ak .handle ( )
163
- if err != nil {
164
- return nil , fmt .Errorf ("cannot get AK's handle : %v " , err )
162
+ k , ok := ak .ak .( * wrappedKey20 )
163
+ if ! ok {
164
+ return nil , fmt .Errorf ("expected *wrappedKey20, got : %T " , k )
165
165
}
166
166
167
167
srk , _ , err := t .getPrimaryKeyHandle (commonSrkEquivalentHandle )
@@ -185,7 +185,7 @@ func (t *wrappedTPM20) newKey(ak *AK, opts *KeyConfig) (*Key, error) {
185
185
}()
186
186
187
187
// Certify application key by AK
188
- attestation , sig , err := tpm2 .CertifyCreation (t .rwc , "" , keyHandle , certifierHandle , nil , creationHash , tpm2.SigScheme {tpm2 .AlgRSASSA , tpm2 .AlgSHA256 , 0 }, tix )
188
+ attestation , sig , err := tpm2 .CertifyCreation (t .rwc , "" , keyHandle , k . hnd , nil , creationHash , tpm2.SigScheme {tpm2 .AlgRSASSA , tpm2 .AlgSHA256 , 0 }, tix )
189
189
if err != nil {
190
190
return nil , fmt .Errorf ("CertifyCreation failed: %v" , err )
191
191
}
@@ -195,13 +195,13 @@ func (t *wrappedTPM20) newKey(ak *AK, opts *KeyConfig) (*Key, error) {
195
195
return nil , fmt .Errorf ("failed to pack TPMT_SIGNATURE: %v" , err )
196
196
}
197
197
198
- tpmPub , _ , _ , err := tpm2 .ReadPublic ( t . rwc , keyHandle )
198
+ tpmPub , err := tpm2 .DecodePublic ( pub )
199
199
if err != nil {
200
- return nil , fmt .Errorf ("read public blob : %v" , err )
200
+ return nil , fmt .Errorf ("decode public key : %v" , err )
201
201
}
202
202
pubKey , err := tpmPub .Key ()
203
203
if err != nil {
204
- return nil , fmt .Errorf ("decode public key: %v" , err )
204
+ return nil , fmt .Errorf ("access public key: %v" , err )
205
205
}
206
206
return & Key {key : newWrappedKey20 (keyHandle , blob , pub , creationData , attestation , signature ), pub : pubKey , tpm : t }, nil
207
207
}
@@ -239,13 +239,13 @@ func (t *wrappedTPM20) loadKey(opaqueBlob []byte) (*Key, error) {
239
239
if err != nil {
240
240
return nil , fmt .Errorf ("cannot load signing key: %v" , err )
241
241
}
242
- tpmPub , _ , _ , err := tpm2 .ReadPublic ( t . rwc , hnd )
242
+ tpmPub , err := tpm2 .DecodePublic ( sKey . Public )
243
243
if err != nil {
244
- return nil , fmt .Errorf ("read public blob: %v" , err )
244
+ return nil , fmt .Errorf ("decode public blob: %v" , err )
245
245
}
246
246
pub , err := tpmPub .Key ()
247
247
if err != nil {
248
- return nil , fmt .Errorf ("decode public key: %v" , err )
248
+ return nil , fmt .Errorf ("access public key: %v" , err )
249
249
}
250
250
return & Key {key : newWrappedKey20 (hnd , sKey .Blob , sKey .Public , sKey .CreateData , sKey .CreateAttestation , sKey .CreateSignature ), pub : pub , tpm : t }, nil
251
251
}
@@ -396,10 +396,6 @@ func (k *wrappedKey20) certificationParameters() CertificationParameters {
396
396
}
397
397
}
398
398
399
- func (k * wrappedKey20 ) handle () (tpmutil.Handle , error ) {
400
- return k .hnd , nil
401
- }
402
-
403
399
func (k * wrappedKey20 ) sign (tb tpmBase , digest []byte ) ([]byte , error ) {
404
400
t , ok := tb .(* wrappedTPM20 )
405
401
if ! ok {
@@ -424,3 +420,7 @@ func (k *wrappedKey20) sign(tb tpmBase, digest []byte) ([]byte, error) {
424
420
func (k * wrappedKey20 ) decrypt (tb tpmBase , ctxt []byte ) ([]byte , error ) {
425
421
return nil , fmt .Errorf ("not implemented" )
426
422
}
423
+
424
+ func (k * wrappedKey20 ) blobs () ([]byte , []byte , error ) {
425
+ return k .public , k .blob , nil
426
+ }
0 commit comments