From 5df7ee815dcd91d33e6167c20cebcbd5c51c2c7a Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 2 Sep 2021 10:37:44 +0200 Subject: stupidgcm: stupidChacha20poly1305: use byte array for key Follow what golang.org/x/crypto/chacha20poly1305 does for easier integration in the next commit. --- internal/stupidgcm/common_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'internal/stupidgcm/common_test.go') diff --git a/internal/stupidgcm/common_test.go b/internal/stupidgcm/common_test.go index ded6273..cf555b0 100644 --- a/internal/stupidgcm/common_test.go +++ b/internal/stupidgcm/common_test.go @@ -167,20 +167,25 @@ type Wiper interface { } func testWipe(t *testing.T, c cipher.AEAD) { - var key []byte switch c2 := c.(type) { case *StupidGCM: c2.Wipe() - key = c2.key + if c2.key != nil { + t.Fatal("key is not nil") + } case *stupidChacha20poly1305: c2.Wipe() - key = c2.key + if !c2.wiped { + t.Error("c2.wiped is not set") + } + for _, v := range c2.key { + if v != 0 { + t.Fatal("c2.key is not zeroed") + } + } default: t.Fatalf("BUG: unhandled type %t", c2) } - if key != nil { - t.Fatal("key is not nil") - } } // Get "n" random bytes from /dev/urandom or panic -- cgit v1.2.3