44 lines
701 B
Go
44 lines
701 B
Go
package main
|
|
|
|
import (
|
|
"debug/buildinfo"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
fmt.Println("Usage: fips-check <binary> [binary...]")
|
|
os.Exit(1)
|
|
}
|
|
|
|
for _, path := range os.Args[1:] {
|
|
info, err := buildinfo.ReadFile(path)
|
|
if err != nil {
|
|
fmt.Printf("%s: error (%v)\n", path, err)
|
|
continue
|
|
}
|
|
|
|
fips := false
|
|
version := ""
|
|
for _, s := range info.Settings {
|
|
if s.Key == "GOFIPS140" {
|
|
fips = true
|
|
version = s.Value
|
|
}
|
|
}
|
|
|
|
name := path
|
|
if i := strings.LastIndex(path, "/"); i >= 0 {
|
|
name = path[i+1:]
|
|
}
|
|
|
|
if fips {
|
|
fmt.Printf("%s: FIPS 140-3 (module %s)\n", name, version)
|
|
} else {
|
|
fmt.Printf("%s: not FIPS\n", name)
|
|
}
|
|
}
|
|
}
|