Skip to content

Commit

Permalink
tls: add eddilithium2 support and fix eddilithium3 (#176)
Browse files Browse the repository at this point in the history
Closes #175

We didn't move from eddilithium3 to eddilithium2 when dilithium3
was renamed to dilithium3.
  • Loading branch information
bwesterb authored Jul 3, 2024
1 parent 962efcd commit a920985
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/crypto/tls/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const (
signatureRSAPSS
signatureECDSA
signatureEd25519
signatureEdDilithium2
signatureEdDilithium3
)

Expand Down
2 changes: 2 additions & 0 deletions src/crypto/tls/tls_cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package tls
import (
circlPki "github.com/cloudflare/circl/pki"
circlSign "github.com/cloudflare/circl/sign"
"github.com/cloudflare/circl/sign/eddilithium2"
"github.com/cloudflare/circl/sign/eddilithium3"
)

Expand All @@ -20,6 +21,7 @@ var circlSchemes = [...]struct {
sigType uint8
scheme circlSign.Scheme
}{
{signatureEdDilithium2, eddilithium2.Scheme()},
{signatureEdDilithium3, eddilithium3.Scheme()},
}

Expand Down
8 changes: 4 additions & 4 deletions src/crypto/tls/tls_cf_circl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"time"

"github.com/cloudflare/circl/sign"
"github.com/cloudflare/circl/sign/eddilithium3"
"github.com/cloudflare/circl/sign/eddilithium2"
)

func TestPQSignatureSchemes(t *testing.T) {
pqCert := createPQCert(t, eddilithium3.Scheme())
pqCert := createPQCert(t, eddilithium2.Scheme())
rsaCert := Certificate{
Certificate: [][]byte{testRSACertificate},
PrivateKey: testRSAPrivateKey,
Expand Down Expand Up @@ -47,13 +47,13 @@ func TestPQSignatureSchemes(t *testing.T) {
clientPQ: true,
serverPQ: false,
serverCerts: pqAndRsaCerts,
expectedCertSigAlg: x509.PureEdDilithium3,
expectedCertSigAlg: x509.PureEdDilithium2,
},
{
clientPQ: true,
serverPQ: true,
serverCerts: pqAndRsaCerts,
expectedCertSigAlg: x509.PureEdDilithium3,
expectedCertSigAlg: x509.PureEdDilithium2,
},
{
clientPQ: true,
Expand Down
5 changes: 4 additions & 1 deletion src/crypto/x509/x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ const (
SHA384WithRSAPSS
SHA512WithRSAPSS
PureEd25519
PureEdDilithium2
PureEdDilithium3
)

Expand Down Expand Up @@ -270,6 +271,7 @@ const (
DSA // Only supported for parsing.
ECDSA
Ed25519
EdDilithium2
EdDilithium3
)

Expand All @@ -278,7 +280,8 @@ var publicKeyAlgoName = [...]string{
DSA: "DSA",
ECDSA: "ECDSA",
Ed25519: "Ed25519",
EdDilithium3: "Ed25519-Dilithium3",
EdDilithium2: "Ed25519-Dilithium2",
EdDilithium3: "Ed448-Dilithium3",
}

func (algo PublicKeyAlgorithm) String() string {
Expand Down
2 changes: 2 additions & 0 deletions src/crypto/x509/x509_cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
circlPki "github.com/cloudflare/circl/pki"
circlSign "github.com/cloudflare/circl/sign"
"github.com/cloudflare/circl/sign/eddilithium3"
"github.com/cloudflare/circl/sign/eddilithium2"
)

// To add a signature scheme from Circl
Expand All @@ -21,6 +22,7 @@ var circlSchemes = [...]struct {
alg PublicKeyAlgorithm
scheme circlSign.Scheme
}{
{PureEdDilithium2, EdDilithium2, eddilithium2.Scheme()},
{PureEdDilithium3, EdDilithium3, eddilithium3.Scheme()},
}

Expand Down

0 comments on commit a920985

Please sign in to comment.