Skip to content

crypto: can't be used with crypto/sha3 when GODEBUG=fips140=only is set #70879

Closed
@qmuntal

Description

@qmuntal

Go version

go version devel go1.24-c8fb6ae617 Sun Dec 8 15:34:47 2024 +0000 windows/amd64

Output of go env in your module/workspace:

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=1
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\qmuntaldiaz\AppData\Local\go-build
set GODEBUG=fips140=
set GOENV=C:\Users\qmuntaldiaz\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\QMUNTA~1\AppData\Local\Temp\go-build3921600416=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=C:\Users\qmuntaldiaz\code\golang-go\src\go.mod
set GOMODCACHE=C:\Users\qmuntaldiaz\go\pkg\mod
set GONOPROXY=github.com/microsoft/*,dev.azure.com/*
set GONOSUMDB=github.com/microsoft/*,dev.azure.com/*
set GOOS=windows
set GOPATH=C:\Users\qmuntaldiaz\go
set GOPRIVATE=github.com/microsoft/*,dev.azure.com/*
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\qmuntaldiaz\code\golang-go
set GOSUMDB=sum.golang.org
set GOTELEMETRY=on
set GOTELEMETRYDIR=C:\Users\qmuntaldiaz\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\qmuntaldiaz\code\golang-go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.24-c8fb6ae617 Sun Dec 8 15:34:47 2024 +0000
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

package main

import (
	"crypto/hmac"
	"crypto/sha3"
	"hash"
)

func main() {
	hmac.New(func() hash.Hash { return sha3.New256() }, make([]byte, 64))
	println("done!")
}

Run the previous code with GODEBUG=fips140=only set.

What did you see happen?

done!

What did you expect to see?

panic: crypto/hmac: use of hash functions other than SHA-2 or SHA-3 is not allowed in FIPS 140-only mode

goroutine 1 [running]:
crypto/hmac.New(0xe6be8, {0xc0000105c0, 0x40, 0x40})
        C:/Users/qmuntaldiaz/code/golang-go/src/crypto/hmac/hmac.go:51 +0xf4
main.main()
        C:/Users/qmuntaldiaz/code/golang-go/src/crypto/hmac/a/main.go:10 +0x3c

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsFixThe path to resolution is known, but the work has not been done.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions