From 602a004c9647363d3d5b859d65b9b484c4f8950a Mon Sep 17 00:00:00 2001 From: Arne Hormann Date: Sun, 8 Dec 2013 18:27:11 +0100 Subject: [PATCH] add test for scrambleOldPassword --- utils_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/utils_test.go b/utils_test.go index 352811bba..233214d04 100644 --- a/utils_test.go +++ b/utils_test.go @@ -160,5 +160,23 @@ func TestLengthEncodedInteger(t *testing.T) { t.Errorf("%v: expected %x, got %x", num, tst.encoded, encoded) } } +} +func TestOldPass(t *testing.T) { + scramble := []byte{9, 8, 7, 6, 5, 4, 3, 2} + vectors := []struct { + pass string + out string + }{ + {" pass", "47575c5a435b4251"}, + {"pass ", "47575c5a435b4251"}, + {"123\t456", "575c47505b5b5559"}, + {"C0mpl!ca ted#PASS123", "5d5d554849584a45"}, + } + for _, tuple := range vectors { + ours := scrambleOldPassword(scramble, []byte(tuple.pass)) + if tuple.out != fmt.Sprintf("%x", ours) { + t.Errorf("Failed old password %q", tuple.pass) + } + } }