Browse Source

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
Damian Gryski 13 years ago
parent
commit
62944567d8
5 changed files with 0 additions and 55 deletions
  1. 0 10
      blowfish/cipher.go
  2. 0 8
      cast5/cast5.go
  3. 0 13
      twofish/twofish.go
  4. 0 7
      xtea/cipher.go
  5. 0 17
      xtea/xtea_test.go

+ 0 - 10
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:])

+ 0 - 8
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])

+ 0 - 13
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 }
 

+ 0 - 7
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) {

+ 0 - 17
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
-		}
-	}
-}