| 1 |
// Copyright 2024 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build !fips140v1.0 |
| 6 |
|
| 7 |
package fipstest |
| 8 |
|
| 9 |
import ( |
| 10 |
"crypto/internal/fips140/mldsa" |
| 11 |
"testing" |
| 12 |
) |
| 13 |
|
| 14 |
func fips140v126Conditionals() { |
| 15 |
// ML-DSA sign and verify PCT |
| 16 |
kMLDSA := mldsa.GenerateKey44() |
| 17 |
// ML-DSA-44 |
| 18 |
mldsa.SignDeterministic(kMLDSA, make([]byte, 32), "") |
| 19 |
} |
| 20 |
|
| 21 |
func testFIPS140v126(t *testing.T, plaintext []byte) { |
| 22 |
t.Run("ML-DSA KeyGen, SigGen, SigVer", func(t *testing.T) { |
| 23 |
ensureServiceIndicator(t) |
| 24 |
k := mldsa.GenerateKey44() |
| 25 |
|
| 26 |
sig, err := mldsa.SignDeterministic(k, plaintext, "") |
| 27 |
fatalIfErr(t, err) |
| 28 |
t.Logf("ML-DSA signature: %x", sig) |
| 29 |
|
| 30 |
err = mldsa.Verify(k.PublicKey(), plaintext, sig, "") |
| 31 |
fatalIfErr(t, err) |
| 32 |
}) |
| 33 |
} |