Skip to content

Commit

Permalink
new FIPS check
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl committed Jan 22, 2024
1 parent d831eaa commit f4dfe9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ validate-go-action:
@sha256sum --quiet -c .sha256sum || (echo error: client library is stale, please run make client; exit 1)

validate-fips:
hack/fips/validate-fips.sh
hack/fips/validate-fips.sh ./aro

unit-test-go:
go run gotest.tools/[email protected] --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
Expand Down
31 changes: 13 additions & 18 deletions hack/fips/validate-fips.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
#!/bin/bash

# The small go program below will validate that a
# FIPS validated crypto lib
cat > ./hack/fips/main.go << 'EOF'
package main
set -xe

// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.
# check if we can build and have built a valid FIPS-compatible binary
res=$(go run github.com/acardace/[email protected] ${1} -j)

import (
_ "crypto/tls/fipsonly"
binary=$(echo $res | jq -r '.goBinaryFips.value')
lib=$(echo $res | jq -r '.cryptoLibFips.value')

utillog "github.com/Azure/ARO-RP/pkg/util/log"
)
if [[ $binary == "false" ]]; then
echo "binary is not FIPS compatible"
exit 1
fi

func main() {
log := utillog.GetLogger()
log.Println("FIPS mode enabled")
}
EOF
trap "rm ./hack/fips/main.go" EXIT
echo "Attempting to run program that requires FIPS crypto"
go run ./hack/fips/main.go
if [[ $lib == "false" ]]; then
echo "lib is not FIPS compatible"
exit 1
fi

0 comments on commit f4dfe9f

Please sign in to comment.