tests and a README

Signed-off-by: Vincent Batts <vbatts@thisco.de>
This commit is contained in:
Vincent Batts 2014-10-02 23:13:51 -04:00
parent 5e72cd7b41
commit de1edc544e
3 changed files with 44 additions and 7 deletions

26
README.md Normal file
View File

@ -0,0 +1,26 @@
## go-fips
Proof-Of-Concept for using golang and building a FIPS enabled application.
## Setup
See http://www.openssl.org/docs/fips/UserGuide-2.0.pdf
to set up an environment where fips mode can be enabled
## Building
go build .
or
go build -tags fips .
## Testing
go test .
or
go test -tags fips .

View File

@ -30,8 +30,8 @@ func ModeSet(mode ONOFF) (ONOFF, error) {
func LastError() string {
buf := C.malloc(1024)
e := C.ERR_get_error() // a C.ulong
C.ERR_load_crypto_strings()
defer C.ERR_free_strings()
C.ERR_load_crypto_strings()
defer C.ERR_free_strings()
C.ERR_error_string_n(e, (*C.char)(buf), 1024)
defer C.free(buf)
return C.GoString((*C.char)(buf))

View File

@ -1,10 +1,21 @@
package fips
import (
"fmt"
"testing"
)
import "testing"
func TestTest(t *testing.T) {
fmt.Println(ModeSet(ON))
expected := ON
o, err := ModeSet(expected)
if err != nil {
if err == ErrFipsDisabled {
// ModeSet will not turn it on if fips is not linked in
expected = OFF
} else {
// the error is something else
t.Fatal(err)
}
}
if o != expected {
t.Errorf("expected %q, got %q", expected, o)
}
}