Source file
src/crypto/des/internal_test.go
1
2
3
4
5 package des
6
7 import "testing"
8
9 func TestInitialPermute(t *testing.T) {
10 for i := uint(0); i < 64; i++ {
11 bit := uint64(1) << i
12 got := permuteInitialBlock(bit)
13 want := uint64(1) << finalPermutation[63-i]
14 if got != want {
15 t.Errorf("permute(%x) = %x, want %x", bit, got, want)
16 }
17 }
18 }
19
20 func TestFinalPermute(t *testing.T) {
21 for i := uint(0); i < 64; i++ {
22 bit := uint64(1) << i
23 got := permuteFinalBlock(bit)
24 want := uint64(1) << initialPermutation[63-i]
25 if got != want {
26 t.Errorf("permute(%x) = %x, want %x", bit, got, want)
27 }
28 }
29 }
30
View as plain text