From 62944567d8abab8255c3bfcf82c8c347c7577c62 Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Mon, 10 Dec 2012 11:00:48 -0500 Subject: [PATCH] go.crypto: remove cipher.Reset() The go.crypto repo was missed when this function was removed from the ciphers in the standard library. R=agl CC=golang-dev https://golang.org/cl/6904062 --- blowfish/cipher.go | 10 ---------- cast5/cast5.go | 8 -------- twofish/twofish.go | 13 ------------- xtea/cipher.go | 7 ------- xtea/xtea_test.go | 17 ----------------- 5 files changed, 55 deletions(-) diff --git a/blowfish/cipher.go b/blowfish/cipher.go index 2f712ad..fbefe78 100644 --- a/blowfish/cipher.go +++ b/blowfish/cipher.go @@ -81,16 +81,6 @@ func (c *Cipher) Decrypt(dst, src []byte) { dst[4], dst[5], dst[6], dst[7] = byte(r>>24), byte(r>>16), byte(r>>8), byte(r) } -// Reset zeros the key data, so that it will no longer -// appear in the process's memory. -func (c *Cipher) Reset() { - zero(c.p[0:]) - zero(c.s0[0:]) - zero(c.s1[0:]) - zero(c.s2[0:]) - zero(c.s3[0:]) -} - func initCipher(key []byte, c *Cipher) { copy(c.p[0:], p[0:]) copy(c.s0[0:], s0[0:]) diff --git a/cast5/cast5.go b/cast5/cast5.go index 889a13c..8c1b299 100644 --- a/cast5/cast5.go +++ b/cast5/cast5.go @@ -30,14 +30,6 @@ func (c *Cipher) BlockSize() int { return BlockSize } -// Reset zeros the key material in memory. -func (c *Cipher) Reset() { - for i := 0; i < 16; i++ { - c.masking[i] = 0 - c.rotate[i] = 0 - } -} - func (c *Cipher) Encrypt(dst, src []byte) { l := uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3]) r := uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7]) diff --git a/twofish/twofish.go b/twofish/twofish.go index 0616e7b..a930218 100644 --- a/twofish/twofish.go +++ b/twofish/twofish.go @@ -106,19 +106,6 @@ func NewCipher(key []byte) (*Cipher, error) { return c, nil } -// Reset zeros the key data, so that it will no longer appear in the process's -// memory. -func (c *Cipher) Reset() { - for i := range c.k { - c.k[i] = 0 - } - for i := range c.s { - for j := 0; j < 256; j++ { - c.s[i][j] = 0 - } - } -} - // BlockSize returns the Twofish block size, 16 bytes. func (c *Cipher) BlockSize() int { return BlockSize } diff --git a/xtea/cipher.go b/xtea/cipher.go index 3ed0581..0e10b8e 100644 --- a/xtea/cipher.go +++ b/xtea/cipher.go @@ -57,13 +57,6 @@ func (c *Cipher) Encrypt(dst, src []byte) { encryptBlock(c, dst, src) } // Decrypt decrypts the 8 byte buffer src using the key k and stores the result in dst. func (c *Cipher) Decrypt(dst, src []byte) { decryptBlock(c, dst, src) } -// Reset zeros the table, so that it will no longer appear in the process's memory. -func (c *Cipher) Reset() { - for i := 0; i < len(c.table); i++ { - c.table[i] = 0 - } -} - // initCipher initializes the cipher context by creating a look up table // of precalculated values that are based on the key. func initCipher(c *Cipher, key []byte) { diff --git a/xtea/xtea_test.go b/xtea/xtea_test.go index 217d96a..be711bf 100644 --- a/xtea/xtea_test.go +++ b/xtea/xtea_test.go @@ -227,20 +227,3 @@ func TestCipherDecrypt(t *testing.T) { } } } - -// Test resetting the cipher context -func TestReset(t *testing.T) { - c, err := NewCipher(testKey) - if err != nil { - t.Errorf("NewCipher(%d bytes) = %s", len(testKey), err) - return - } - - c.Reset() - for i := 0; i < len(c.table); i++ { - if c.table[i] != 0 { - t.Errorf("Cipher.Reset: Failed to clear Cipher.table[%d]. expected 0, got %08X", i, c.table[i]) - return - } - } -}