Skip to content

Commit

Permalink
Replace ML-DSA-44 with -87 and use the correct code point
Browse files Browse the repository at this point in the history
  • Loading branch information
pohlm01 committed Nov 15, 2024
1 parent 452ba71 commit 9fd3481
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ life_time 3600 1h0m0s
storage_window_size 24 2h0m0s
validity_window_size 12
http_server ca.example.com/path
public_key fingerprint ml-dsa-44:85b5a617ef109e0a8d68a094c8b969f622ac4096c513fa0acd169c231ce2fad5
public_key fingerprint ml-dsa-87:85b5a617ef109e0a8d68a094c8b969f622ac4096c513fa0acd169c231ce2fad5
```

The `batches` folder is empty, because there are no batches issued yet.
Expand Down
2 changes: 1 addition & 1 deletion ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ func New(path string, opts NewOpts) (*Handle, error) {
h.params.Issuer = opts.Issuer

if opts.SignatureScheme == 0 {
opts.SignatureScheme = mtc.TLSMLDSA44
opts.SignatureScheme = mtc.TLSMLDSA87
}

// Generate keypair
Expand Down
4 changes: 2 additions & 2 deletions mtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ const (
TLSECDSAWithP521AndSHA512 SignatureScheme = 0x0603
TLSEd25519 SignatureScheme = 0x0807

// Just for testing we use ML-DSA44 with a codepoint in the
// Just for testing we use ML-DSA-87 with a codepoint in the
// private use region.
// For production SLH-DSA-128s would be a better choice.
TLSMLDSA44 SignatureScheme = 0xfe3c
TLSMLDSA87 SignatureScheme = 0x0906
)

type AbridgedTLSSubject struct {
Expand Down
30 changes: 15 additions & 15 deletions signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"errors"
"fmt"

mldsa "github.com/cloudflare/circl/sign/mldsa/mldsa44"
mldsa "github.com/cloudflare/circl/sign/mldsa/mldsa87"
)

// Signing public key with specific hash and options.
Expand Down Expand Up @@ -81,7 +81,7 @@ func (v *mldsaVerifier) Bytes() []byte {
(*mldsa.PublicKey)(v).Pack(&ret)
return ret[:]
}
func (v *mldsaVerifier) Scheme() SignatureScheme { return TLSMLDSA44 }
func (v *mldsaVerifier) Scheme() SignatureScheme { return TLSMLDSA87 }
func (v *mldsaVerifier) Verify(msg, sig []byte) error {
if mldsa.Verify((*mldsa.PublicKey)(v), msg, nil, sig) {
return nil
Expand All @@ -98,7 +98,7 @@ func signatureSchemeToHash(scheme SignatureScheme) (crypto.Hash, error) {
return crypto.SHA384, nil
case TLSPSSWithSHA512, TLSECDSAWithP521AndSHA512:
return crypto.SHA512, nil
case TLSEd25519, TLSMLDSA44:
case TLSEd25519, TLSMLDSA87:
return 0, nil
}
return 0, errors.New("Unsupported SignatureScheme")
Expand Down Expand Up @@ -147,10 +147,10 @@ func NewVerifier(scheme SignatureScheme, pk crypto.PublicKey) (
return nil, fmt.Errorf("Expected curve %v, got %v", curve, epk.Curve)
}
return &ecdsaVerifier{hash: h, pk: epk, scheme: scheme}, nil
case TLSMLDSA44:
case TLSMLDSA87:
dpk, ok := pk.(*mldsa.PublicKey)
if !ok {
return nil, errors.New("Expected github.com/cloudflare/circl/sign/dilithium/mode5.*PublicKey")
return nil, errors.New("Expected *mldsa.PublicKey")
}
return (*mldsaVerifier)(dpk), nil
default:
Expand Down Expand Up @@ -194,13 +194,13 @@ func UnmarshalVerifier(scheme SignatureScheme, data []byte) (
},
scheme: scheme,
}, nil
case TLSMLDSA44:
case TLSMLDSA87:
var (
buf [mldsa.PublicKeySize]byte
pk mldsa.PublicKey
)
if len(data) != mldsa.PublicKeySize {
return nil, errors.New("Wrong length for ML-DSA-44 public key")
return nil, errors.New("Wrong length for ML-DSA-87 public key")
}
copy(buf[:], data)
pk.Unpack(&buf)
Expand All @@ -224,7 +224,7 @@ func (s *mldsaSigner) Bytes() []byte {
(*mldsa.PrivateKey)(s).Pack(&ret)
return ret[:]
}
func (s *mldsaSigner) Scheme() SignatureScheme { return TLSMLDSA44 }
func (s *mldsaSigner) Scheme() SignatureScheme { return TLSMLDSA87 }
func (s *mldsaSigner) Sign(msg []byte) []byte {
var sig [mldsa.SignatureSize]byte
err := mldsa.SignTo((*mldsa.PrivateKey)(s), msg, nil, false, sig[:])
Expand All @@ -242,7 +242,7 @@ func UnmarshalSigner(scheme SignatureScheme, data []byte) (
}

switch scheme {
case TLSMLDSA44:
case TLSMLDSA87:
var (
buf [mldsa.PrivateKeySize]byte
sk mldsa.PrivateKey
Expand All @@ -265,7 +265,7 @@ func GenerateSigningKeypair(scheme SignatureScheme) (Signer, Verifier, error) {
}

switch scheme {
case TLSMLDSA44:
case TLSMLDSA87:
pk, sk, err := mldsa.GenerateKey(nil)
if err != nil {
return nil, nil, err
Expand All @@ -292,8 +292,8 @@ func (s SignatureScheme) String() string {
return "p521"
case TLSEd25519:
return "ed25519"
case TLSMLDSA44:
return "ml-dsa-44"
case TLSMLDSA87:
return "ml-dsa-87"
}
return fmt.Sprintf("unknown:%d", uint16(s))
}
Expand All @@ -312,8 +312,8 @@ func SignatureSchemeFromString(s string) SignatureScheme {
return TLSECDSAWithP384AndSHA384
case "p521":
return TLSECDSAWithP521AndSHA512
case "ml-dsa-44":
return TLSMLDSA44
case "ml-dsa-87":
return TLSMLDSA87
case "ed25519":
return TLSEd25519
}
Expand Down Expand Up @@ -342,7 +342,7 @@ func SignatureSchemesFor(pk crypto.PublicKey) []SignatureScheme {
case ed25519.PublicKey:
return []SignatureScheme{TLSEd25519}
case *mldsa.PublicKey:
return []SignatureScheme{TLSMLDSA44}
return []SignatureScheme{TLSMLDSA87}
}
return []SignatureScheme{}
}
Expand Down

0 comments on commit 9fd3481

Please sign in to comment.