Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go 1.21.0 #114

Merged
merged 6 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"github.com/golang-fips/go": "go1.20-fips-release",
"github.com/golang-fips/go": "main",
"github.com/golang-fips/openssl-fips": "b175be2ccd46683a51cba60a9a2087b09593317d",
"github.com/golang/go": "go1.20.7"
"github.com/golang/go": "go1.21.0"
}
6 changes: 3 additions & 3 deletions patches/000-initial-setup.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1289,9 +1289,9 @@ index 63d86b9f3a..a8ee915041 100644
--- a/src/crypto/tls/handshake_client.go
+++ b/src/crypto/tls/handshake_client.go
@@ -127,7 +127,9 @@ func (c *Conn) makeClientHello() (*clientHelloMsg, *ecdh.PrivateKey, error) {

var key *ecdh.PrivateKey
if hello.supportedVersions[0] == VersionTLS13 {
if len(hello.supportedVersions) == 1 {
hello.cipherSuites = nil
}
- if hasAESGCMHardwareSupport {
+ if needFIPS() {
+ hello.cipherSuites = append(hello.cipherSuites, defaultFIPSCipherSuitesTLS13...)
Expand Down
194 changes: 98 additions & 96 deletions patches/001-initial-openssl-for-fips.patch

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions patches/002-strict-fips-runtime-detection.patch
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ index 02e744362c..4ac7f480cf 100644
--- a/src/internal/goexperiment/flags.go
+++ b/src/internal/goexperiment/flags.go
@@ -100,4 +100,6 @@ type Flags struct {
// this compels the Go runtime to write to some arbitrary file, which
// may be exploited.
PageTrace bool
// CacheProg adds support to cmd/go to use a child process to implement
// the build cache; see https://github.com/golang/go/issues/59719.
CacheProg bool
+
+ StrictFIPSRuntime bool
}
4 changes: 2 additions & 2 deletions scripts/create-secondary-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ replace="${1}"
if [ -n "${replace}" ]; then
echo "replace github.com/golang-fips/openssl-fips => ${replace}" >> go.mod
fi
go mod tidy
go mod vendor
../bin/go mod tidy
../bin/go mod vendor

# Generate the final patch.
git add .
Expand Down
99 changes: 99 additions & 0 deletions scripts/crypto-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

set -eE

quiet () {
2>&1>/dev/null $@
}

# Find the GOROOT.
# If using a release branch, expect the GOROOT
# in the go submodule directory.
GOROOT=$(readlink -f $(dirname $0)/..)
quiet pushd $GOROOT
if 2>/dev/null cat .gitmodules | grep -q "url = https://github.com/golang/go.git"; then
GOROOT=${GOROOT}/go
fi
quiet popd

export GOCACHE=/tmp/go-cache
export GO=${GOROOT}/bin/go

# Test suites to run
SUITES="crypto,tls"
# Verbosity flags to pass to Go
VERBOSE=""

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--suites)
SUITES=$2
shift;shift
;;
-v)
VERBOSE="$VERBOSE -v"
set -x
shift
;;
*)
>&2 echo "unsupported option $1"
exit 1
;;
esac
done

notify_running() {
local mode=$1
local suite=$2
echo -e "\n##### ${suite} (${mode})"
}

run_crypto_test_suite () {
local mode=$1
local tags=$2
local suite="crypto-fips"
notify_running ${mode} ${suite}
quiet pushd ${GOROOT}/src/crypto
GOLANG_FIPS=1 OPENSSL_FORCE_FIPS_MODE=1 \
$GO test $tags -count=1 $($GO list ./... | grep -v tls) $VERBOSE

local suite="crypto-fips-parity-nocgo"
notify_running ${mode} ${suite}
GOLANG_FIPS=1 OPENSSL_FORCE_FIPS_MODE=1 \
CGO_ENABLED=0 $GO test $tags -count=1 $($GO list ./... | grep -v tls) $VERBOSE
quiet popd
}

run_tls_test_suite () {
local mode=$1
local tags=$2
local suite="tls-fips"
notify_running ${mode} ${suite}
quiet pushd ${GOROOT}/src
GOLANG_FIPS=1 OPENSSL_FORCE_FIPS_MODE=1 \
$GO test $tags -count=1 crypto/tls -run "^TestBoring" $VERBOSE
quiet popd
}


run_full_test_suite () {
local mode=$1
local tags=$2
for suite in ${SUITES//,/ }; do
if [[ "$suite" == "crypto" ]]; then
run_crypto_test_suite ${mode} ${tags}
elif [[ "$suite" == "tls" ]]; then
run_tls_test_suite ${mode} ${tags}
fi
done
}

# Run in default mode
run_full_test_suite default ""

# Run in strict fips mode
export GOEXPERIMENT=strictfipsruntime
run_full_test_suite strictfips "-tags=strictfipsruntime"

echo ALL TESTS PASSED
6 changes: 6 additions & 0 deletions scripts/full-initialize-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# This script generates and applies FIPS
# patches to a Go tree.

echo "Host Go Version:"
go version

echo "Host Go Env:"
go env

SCRIPT_DIR=$(readlink -f $(dirname $0))
GO_DIR=${SCRIPT_DIR}/../go

Expand Down
6 changes: 6 additions & 0 deletions scripts/setup-initial-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ shift $((OPTIND-1))
cd ./go
ORIGINAL_GIT_SHA=$(git rev-parse HEAD)

# Build the Go toolchain before applying patches. This allows us to use this toolchain in later steps
# when running `go mod` commands.
pushd ./src
./make.bash
popd

"${ROOT}"/scripts/apply-initial-patch.sh
"${ROOT}"/scripts/create-secondary-patch.sh "${replacement}"

Expand Down
Loading