diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2016-10-15 20:18:08 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2016-10-15 20:18:08 +0300 |
commit | b871d9c0923a5b34c545b2519ee7039461711787 (patch) | |
tree | 78312e9c45f55d0b5972c29c3831f506083b99a2 /pkg | |
parent | 4388e682ab89afd34eca39911a85ab723aaa6909 (diff) |
pkg/cryptstate: remove NULL crypto mode.
It's not too sensible to have a NULL mode in the first place,
and the CryptState code expects non-0 IVs and keys.
Drop it.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/cryptstate/cryptstate.go | 2 | ||||
-rw-r--r-- | pkg/cryptstate/cryptstate_test.go | 26 |
2 files changed, 0 insertions, 28 deletions
diff --git a/pkg/cryptstate/cryptstate.go b/pkg/cryptstate/cryptstate.go index ae5a8ab..b2f2d15 100644 --- a/pkg/cryptstate/cryptstate.go +++ b/pkg/cryptstate/cryptstate.go @@ -58,8 +58,6 @@ func createMode(mode string) (CryptoMode, error) { return &ocb2Mode{}, nil case "XSalsa20-Poly1305": return &secretBoxMode{}, nil - case "NULL": - return &nullMode{}, nil } return nil, errors.New("cryptstate: no such CryptoMode") } diff --git a/pkg/cryptstate/cryptstate_test.go b/pkg/cryptstate/cryptstate_test.go index 8300ba2..073d656 100644 --- a/pkg/cryptstate/cryptstate_test.go +++ b/pkg/cryptstate/cryptstate_test.go @@ -160,29 +160,3 @@ func TestXSalsa20Poly1305Decrypt(t *testing.T) { t.Fatalf("mismatch! got\n%x\n, expected\n%x", dst, expected) } } - -func TestNullEncrypt(t *testing.T) { - cs := CryptState{} - cs.SetKey("NULL", []byte{}, []byte{1}, []byte{1}) - msg := []byte("HelloWorld") - dst := make([]byte, len(msg)+cs.Overhead()) - cs.Encrypt(dst, msg) - if !bytes.Equal(dst[1:], msg) { - t.Fatalf("mismatch! got\n%x\n, expected\n%x", dst, msg) - } -} - -func TestNullDecrypt(t *testing.T) { - cs := CryptState{} - cs.SetKey("NULL", []byte{}, []byte{1}, []byte{1}) - msg := []byte{2} - msg = append(msg, []byte("HelloWorld")...) - dst := make([]byte, len(msg)-cs.Overhead()) - err := cs.Decrypt(dst, msg) - if err != nil { - t.Fatalf("%v", err) - } - if !bytes.Equal(dst, msg[1:]) { - t.Fatalf("mismatch! got\n%x\n, expected\n%x", dst, msg) - } -} |