Go version
go version go1.25.7 linux/amd64
Output of go env in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/abhishek/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/abhishek/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4060677167=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/abhishek/go/src/tmp-projects/go.mod'
GOMODCACHE='/home/abhishek/go/pkg/mod'
GONOPROXY='gitlab.protectv.local'
GONOSUMDB='gitlab.protectv.local'
GOOS='linux'
GOPATH='/home/abhishek/go'
GOPRIVATE='gitlab.protectv.local'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/abhishek/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.7'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I am generating an Ed25519 key and expecting that the underlying PCT: Ed25519 sign and verify PCT should run as part of it, but it is not running.
I am, of course, running the program in fips mode.
It seems like GenerateKey function of crypto/ed25519 doesn't call the GenerateKey() function of crypto/internal/fips140/ed25519 package, which triggers the PCT.
How should I trigger the PCT?
Following is the program I am using to generate Ed25519 key:
package main
import (
"crypto/ed25519"
"crypto/rand"
"crypto/x509"
"encoding/pem"
"io/ioutil"
"fmt"
"os"
)
// GenerateSaveEd25519 generates and saves ed25519 keys to disk after
// encoding into PEM format
func GenerateSaveEd25519(fb string) error {
var (
err error
b []byte
block *pem.Block
pub ed25519.PublicKey
priv ed25519.PrivateKey
)
pub, priv, err = ed25519.GenerateKey(rand.Reader)
if err != nil {
fmt.Printf("Generation error : %s", err)
os.Exit(1)
}
b, err = x509.MarshalPKCS8PrivateKey(priv)
if err != nil {
return err
}
block = &pem.Block{
Type: "PRIVATE KEY",
Bytes: b,
}
err = ioutil.WriteFile(fb, pem.EncodeToMemory(block), 0600)
if err != nil {
return err
}
// public key
b, err = x509.MarshalPKIXPublicKey(pub)
if err != nil {
return err
}
block = &pem.Block{
Type: "PUBLIC KEY",
Bytes: b,
}
fileName := fb + ".pub"
err = ioutil.WriteFile(fileName, pem.EncodeToMemory(block), 0644)
return err
}
func main() {
if len(os.Args) != 2 || os.Args[1] == "-h" || os.Args[1] == "--help" {
fmt.Printf("%s : generate pem formatted ed25519 keys\n", os.Args[0])
fmt.Println(" provide a single argument for the private key name")
fmt.Println(" the public key name will have '.pub' appended")
os.Exit(1)
}
FileBaseName := os.Args[1]
if err := GenerateSaveEd25519(FileBaseName); err != nil {
fmt.Printf("Error : %s\n", err)
os.Exit(1)
}
}
What did you see happen?
Program Output:
GODEBUG=fips140=debug go run pct.go /tmp/key
FIPS 140-3 self-test passed: cSHAKE128
FIPS 140-3 self-test passed: SHA2-256
FIPS 140-3 self-test passed: SHA2-512
FIPS 140-3 self-test passed: HMAC-SHA2-256
fips140: verified code+data
FIPS 140-3 self-test passed: AES-CBC
FIPS 140-3 self-test passed: CTR_DRBG
FIPS 140-3 self-test passed: CounterKDF
FIPS 140-3 self-test passed: HKDF-SHA2-256
FIPS 140-3 self-test passed: ML-KEM-768
FIPS 140-3 self-test passed: TLSv1.2-SHA2-256
FIPS 140-3 self-test passed: TLSv1.3-SHA2-256
FIPS 140-3 self-test passed: cSHAKE128
FIPS 140-3 self-test passed: SHA2-256
FIPS 140-3 self-test passed: SHA2-512
FIPS 140-3 self-test passed: HMAC-SHA2-256
fips140: verified code+data
FIPS 140-3 self-test passed: AES-CBC
FIPS 140-3 self-test passed: CTR_DRBG
FIPS 140-3 self-test passed: CounterKDF
What did you expect to see?
FIPS 140-3 self-test passed: Ed25519 sign and verify PCT
Go version
go version go1.25.7 linux/amd64
Output of
go envin your module/workspace:What did you do?
I am generating an Ed25519 key and expecting that the underlying PCT: Ed25519 sign and verify PCT should run as part of it, but it is not running.
I am, of course, running the program in fips mode.
It seems like
GenerateKeyfunction ofcrypto/ed25519doesn't call theGenerateKey()function ofcrypto/internal/fips140/ed25519package, which triggers the PCT.How should I trigger the PCT?
Following is the program I am using to generate Ed25519 key:
What did you see happen?
Program Output:
What did you expect to see?