Index: src/pkg/crypto/des/des_test.go |
=================================================================== |
--- a/src/pkg/crypto/des/des_test.go |
+++ b/src/pkg/crypto/des/des_test.go |
@@ -1504,6 +1504,39 @@ |
} |
} |
+func TestInitialPermute(t *testing.T) { |
+ for i := uint(0); i < 64; i++ { |
+ bit := uint64(1) << i |
+ got := permuteInitialBlock(bit) |
+ want := uint64(1) << finalPermutation[63-i] |
+ if got != want { |
+ t.Errorf("permute(%x) = %x, want %x", bit, got, want) |
+ } |
+ } |
+} |
+ |
+func TestFinalPermute(t *testing.T) { |
+ for i := uint(0); i < 64; i++ { |
+ bit := uint64(1) << i |
+ got := permuteFinalBlock(bit) |
+ want := uint64(1) << initialPermutation[63-i] |
+ if got != want { |
+ t.Errorf("permute(%x) = %x, want %x", bit, got, want) |
+ } |
+ } |
+} |
+ |
+func TestExpandBlock(t *testing.T) { |
+ for i := uint(0); i < 32; i++ { |
+ bit := uint32(1) << i |
+ got := expandBlock(bit) |
+ want := permuteBlock(uint64(bit), expansionFunction[:]) |
+ if got != want { |
+ t.Errorf("expand(%x) = %x, want %x", bit, got, want) |
+ } |
+ } |
+} |
+ |
func BenchmarkEncrypt(b *testing.B) { |
tt := encryptDESTests[0] |
c, err := NewCipher(tt.key) |