Skip to content

Commit

Permalink
test: increase passwd length in crypto io tests (#6380) (#6407)
Browse files Browse the repository at this point in the history
the password is used to derive a key using pbkdf2 and hmac.

In fips only mode use of keys shorter than 112 bits is not
allowed for hmac.

Update the test to use longer passwords.

(cherry picked from commit 3c4861c)

Co-authored-by: kruskall <[email protected]>
  • Loading branch information
mergify[bot] and kruskall authored Dec 19, 2024
1 parent 30e1447 commit 7766efd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/pkg/crypto/io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func TestIO(t *testing.T) {
t.Run("encode and decode with the right password", func(t *testing.T) {
passwd := []byte("hello")
passwd := bytes.Repeat([]byte("hello"), 10)
msg := []byte("bonjour la famille")
dest := new(bytes.Buffer)

Expand All @@ -40,7 +40,7 @@ func TestIO(t *testing.T) {
})

t.Run("Large single write", func(t *testing.T) {
passwd := []byte("hello")
passwd := bytes.Repeat([]byte("hello"), 10)
msg, err := randomBytes(1327)

require.NoError(t, err)
Expand All @@ -67,7 +67,7 @@ func TestIO(t *testing.T) {
})

t.Run("try to decode with the wrong password", func(t *testing.T) {
passwd := []byte("hello")
passwd := bytes.Repeat([]byte("hello"), 10)
msg := []byte("bonjour la famille")
dest := new(bytes.Buffer)

Expand All @@ -90,7 +90,7 @@ func TestIO(t *testing.T) {
})

t.Run("Make sure that buffered IO works with the encoder", func(t *testing.T) {
passwd := []byte("hello")
passwd := bytes.Repeat([]byte("hello"), 10)
msg, err := randomBytes(2048)
require.NoError(t, err)
dest := new(bytes.Buffer)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestIO(t *testing.T) {
})

t.Run("Make sure that buffered IO works with the decoder", func(t *testing.T) {
passwd := []byte("hello")
passwd := bytes.Repeat([]byte("hello"), 10)
msg, err := randomBytes(2048)
require.NoError(t, err)
dest := new(bytes.Buffer)
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestIO(t *testing.T) {
})

t.Run("works with multiple writes", func(t *testing.T) {
passwd := []byte("hello")
passwd := bytes.Repeat([]byte("hello"), 10)

expected := []byte("hello world bonjour la famille")

Expand Down

0 comments on commit 7766efd

Please sign in to comment.