Open
Description
I have tried hardcoding algo ids for tpm2.Public template but still unable to create sm2 curve ECC primary key on windows 11
fmt.Fprintf(debugOutput(), "Start\n")
_, public, _, _, _, err := tpm2.CreateKey(rwc, key.Handle(), tpm2.PCRSelection{}, "", "", AKTemplateECC())
if err != nil {
fmt.Fprintf(debugOutput(), "failed to create key: %w\n", err)
} else {
fmt.Fprintf(debugOutput(), "%s\n", public)
}
fmt.Fprintf(debugOutput(), "End\n")
func AKTemplateECC() tpm2.Public {
return tpm2.Public{
Type: tpm2.AlgECC,
NameAlg: 0x0012, //SM3
Attributes: tpm2.FlagRestricted | tpm2.FlagSign | tpm2.FlagFixedTPM | tpm2.FlagFixedParent | tpm2.FlagSensitiveDataOrigin | tpm2.FlagUserWithAuth,
ECCParameters: &tpm2.ECCParams{
CurveID: tpm2.CurveSM2P256, //SM2
Symmetric: &tpm2.SymScheme{
Alg: 0x0013, //SM4
KeyBits: 128,
Mode: tpm2.AlgCFB,
},
Sign: &tpm2.SigScheme{
Alg: tpm2.AlgNull,
Hash: tpm2.AlgNull,
},
KDF: &tpm2.KDFScheme{
Alg: tpm2.AlgNull,
Hash: tpm2.AlgNull,
},
},
}
}
error shown as below:
PS source\repos\go-tpm-tools\cmd\gotpm> .\gotpm.exe pubkey owner --algo ecc --verbose
Using hierarchy 0x40000001
Start
failed to create key: %!w(tpm2.HandleError={3 0})
End
PS source\repos\go-tpm-tools\cmd\gotpm>
Metadata
Metadata
Assignees
Labels
No labels