Skip to content

Commit

Permalink
Avoid to export unsafeSignInternal.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Oct 9, 2024
1 parent bef2502 commit d55a0aa
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 24 deletions.
35 changes: 35 additions & 0 deletions sign/dilithium/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ var (

func main() {
generateModePackageFiles()
generateACVPTest()
generateParamsFiles()
generateSourceFiles()
}
Expand Down Expand Up @@ -212,6 +213,40 @@ func generateModePackageFiles() {
}
}

// Generates modeX/dilithium.go from templates/pkg.templ.go
func generateACVPTest() {
tl, err := template.ParseFiles("templates/acvp.templ.go")
if err != nil {
panic(err)
}

for _, mode := range Modes {
if !strings.HasPrefix(mode.Name, "ML-DSA") {
continue
}

buf := new(bytes.Buffer)
err := tl.Execute(buf, mode)
if err != nil {
panic(err)
}

res, err := format.Source(buf.Bytes())
if err != nil {
panic("error formating code")
}

offset := strings.Index(string(res), TemplateWarning)
if offset == -1 {
panic("Missing template warning in pkg.templ.go")
}
err = os.WriteFile(mode.PkgPath()+"/acvp_test.go", res[offset:], 0o644)
if err != nil {
panic(err)
}
}
}

// Copies mode3 source files to other modes
func generateSourceFiles() {
files := make(map[string][]byte)
Expand Down
266 changes: 266 additions & 0 deletions sign/dilithium/templates/acvp.templ.go

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

6 changes: 3 additions & 3 deletions sign/dilithium/templates/pkg.templ.go

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

Loading

0 comments on commit d55a0aa

Please sign in to comment.