Skip to content

Add OIDs to ML-DSA #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions sign/dilithium/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main

import (
"bytes"
"encoding/asn1"
"fmt"
"go/format"
"os"
Expand All @@ -29,6 +30,7 @@ type Mode struct {
Gamma2 int
TRSize int
CTildeSize int
Oid asn1.ObjectIdentifier
}

func (m Mode) Pkg() string {
Expand Down Expand Up @@ -59,6 +61,20 @@ func (m Mode) NIST() bool {
return strings.HasPrefix(m.Name, "ML-DSA-")
}

func (m Mode) OidGo() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be replaced by calling:

fmt.Sprintf("%#v", m.Oid)

ret := "asn1.ObjectIdentifier{"
first := true
for _, b := range m.Oid {
if first {
first = false
} else {
ret += ", "
}
ret += fmt.Sprintf("%d", b)
}
return ret + "}"
}

var (
Modes = []Mode{
{
Expand Down Expand Up @@ -112,6 +128,7 @@ var (
Gamma2: (params.Q - 1) / 88,
TRSize: 64,
CTildeSize: 32,
Oid: asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 17},
},
{
Name: "ML-DSA-65",
Expand All @@ -125,6 +142,7 @@ var (
Gamma2: (params.Q - 1) / 32,
TRSize: 64,
CTildeSize: 48,
Oid: asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 18},
},
{
Name: "ML-DSA-87",
Expand All @@ -138,6 +156,7 @@ var (
Gamma2: (params.Q - 1) / 32,
TRSize: 64,
CTildeSize: 64,
Oid: asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 19},
},
}
TemplateWarning = "// Code generated from"
Expand Down
2 changes: 1 addition & 1 deletion sign/dilithium/mode2/dilithium.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sign/dilithium/mode3/dilithium.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sign/dilithium/mode5/dilithium.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion sign/dilithium/templates/pkg.templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion sign/mldsa/mldsa44/dilithium.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion sign/mldsa/mldsa65/dilithium.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion sign/mldsa/mldsa87/dilithium.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.