Skip to content

Commit

Permalink
key: move to noalg keys to support different hashing algos
Browse files Browse the repository at this point in the history
Signed-off-by: Morten Linderud <morten@linderud.pw>
  • Loading branch information
Foxboron committed Feb 21, 2024
1 parent 9e8c823 commit a724802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
6 changes: 6 additions & 0 deletions cmd/ssh-tpm-agent/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,10 @@ func TestSSHAuth(t *testing.T) {
t.Run("rsa - agent", func(t *testing.T) {
runSSHAuth(t, tpm2.TPMAlgRSA, 2048)
})
t.Run("ecdsa p384 - agent", func(t *testing.T) {
runSSHAuth(t, tpm2.TPMAlgECDSA, 384)
})
t.Run("ecdsa p521 - agent", func(t *testing.T) {
runSSHAuth(t, tpm2.TPMAlgECDSA, 521)
})
}
32 changes: 4 additions & 28 deletions key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,7 @@ func createECCKey(ecc tpm2.TPMECCCurve, sha tpm2.TPMAlgID) tpm2.TPM2B[tpm2.TPMTP
&tpm2.TPMSECCParms{
CurveID: ecc,
Scheme: tpm2.TPMTECCScheme{
Scheme: tpm2.TPMAlgECDSA,
Details: tpm2.NewTPMUAsymScheme(
tpm2.TPMAlgECDSA,
&tpm2.TPMSSigSchemeECDSA{
HashAlg: tpm2.TPMAlgSHA256,
},
),
Scheme: tpm2.TPMAlgNull,
},
},
),
Expand All @@ -319,13 +313,7 @@ func createRSAKey(bits tpm2.TPMKeyBits, sha tpm2.TPMAlgID) tpm2.TPM2B[tpm2.TPMTP
tpm2.TPMAlgRSA,
&tpm2.TPMSRSAParms{
Scheme: tpm2.TPMTRSAScheme{
Scheme: tpm2.TPMAlgRSASSA,
Details: tpm2.NewTPMUAsymScheme(
tpm2.TPMAlgRSASSA,
&tpm2.TPMSSigSchemeRSASSA{
HashAlg: tpm2.TPMAlgSHA256,
},
),
Scheme: tpm2.TPMAlgNull,
},
KeyBits: bits,
},
Expand Down Expand Up @@ -480,13 +468,7 @@ func ImportKey(tpm transport.TPMCloser, pk any, pin, comment []byte) (*Key, erro
&tpm2.TPMSECCParms{
CurveID: curveid,
Scheme: tpm2.TPMTECCScheme{
Scheme: tpm2.TPMAlgECDSA,
Details: tpm2.NewTPMUAsymScheme(
tpm2.TPMAlgECDSA,
&tpm2.TPMSSigSchemeECDSA{
HashAlg: tpm2.TPMAlgSHA256,
},
),
Scheme: tpm2.TPMAlgNull,
},
},
),
Expand Down Expand Up @@ -523,13 +505,7 @@ func ImportKey(tpm transport.TPMCloser, pk any, pin, comment []byte) (*Key, erro
tpm2.TPMAlgRSA,
&tpm2.TPMSRSAParms{
Scheme: tpm2.TPMTRSAScheme{
Scheme: tpm2.TPMAlgRSASSA,
Details: tpm2.NewTPMUAsymScheme(
tpm2.TPMAlgRSASSA,
&tpm2.TPMSSigSchemeRSASSA{
HashAlg: tpm2.TPMAlgSHA256,
},
),
Scheme: tpm2.TPMAlgNull,
},
KeyBits: 2048,
},
Expand Down

0 comments on commit a724802

Please sign in to comment.