Skip to content

Commit

Permalink
Add OIDs to ML-DSA
Browse files Browse the repository at this point in the history
  • Loading branch information
bwesterb authored and armfazh committed Oct 16, 2024
1 parent 1310edf commit 392a38c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 7 deletions.
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 {
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.

0 comments on commit 392a38c

Please sign in to comment.