Skip to content

Commit 47be521

Browse files
committed
Use RSA keys in FIPS mode tests
Elliptical curve algorithms are not yet supported on FIPS systems. Use RSA keys for the acceptance tests.
1 parent 8880d1f commit 47be521

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

cmd/gitlab-sshd/acceptance_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"bufio"
55
"context"
66
"crypto/ed25519"
7+
"crypto/rand"
8+
"crypto/rsa"
79
"encoding/json"
810
"encoding/pem"
911
"fmt"
@@ -218,7 +220,14 @@ func buildClient(t *testing.T, addr string, hostKey ed25519.PublicKey) *ssh.Clie
218220
pubKey, err := ssh.NewPublicKey(hostKey)
219221
require.NoError(t, err)
220222

221-
_, clientPrivKey, err := ed25519.GenerateKey(nil)
223+
var clientPrivKey interface{}
224+
225+
if os.Getenv("FIPS_MODE") == "1" {
226+
clientPrivKey, err = rsa.GenerateKey(rand.Reader, 2048)
227+
} else {
228+
_, clientPrivKey, err = ed25519.GenerateKey(nil)
229+
}
230+
222231
require.NoError(t, err)
223232

224233
clientSigner, err := ssh.NewSignerFromKey(clientPrivKey)

support/lint_last_known_acceptable.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cmd/gitlab-shell/main.go:48:15: Error return value of `fmt.Fprintln` is not chec
3737
cmd/gitlab-shell/main.go:53:23: Error return value of `logCloser.Close` is not checked (errcheck)
3838
cmd/gitlab-shell/main.go:60:14: Error return value of `fmt.Fprintf` is not checked (errcheck)
3939
cmd/gitlab-shell/main.go:61:3: exitAfterDefer: os.Exit will exit, and `defer logCloser.Close()` will not run (gocritic)
40-
cmd/gitlab-sshd/acceptance_test.go:458:2: encoded-compare: use require.JSONEq (testifylint)
40+
cmd/gitlab-sshd/acceptance_test.go:467:2: encoded-compare: use require.JSONEq (testifylint)
4141
internal/command/authorizedkeys/authorized_keys.go:29:4: internal/command/authorizedkeys/authorized_keys.go:29: Line contains TODO/BUG/FIXME/NOTE/OPTIMIZE/HACK: "TODO: Log this event once we have a cons..." (godox)
4242
internal/command/command.go:1:1: package-comments: should have a package comment (revive)
4343
internal/command/command.go:15:6: exported: exported type Command should have comment or be unexported (revive)

0 commit comments

Comments
 (0)