diff options
Diffstat (limited to 'src/pkg/crypto')
-rw-r--r-- | src/pkg/crypto/aes/block.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/aes/cipher.go | 12 | ||||
-rw-r--r-- | src/pkg/crypto/block/cbc.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/block/cfb.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/block/cmac.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/block/ecb_test.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/hmac/hmac.go | 12 | ||||
-rw-r--r-- | src/pkg/crypto/md5/md5.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/rsa/rsa.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/sha1/sha1.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/subtle/constant_time.go | 4 | ||||
-rw-r--r-- | src/pkg/crypto/tls/common.go | 18 | ||||
-rw-r--r-- | src/pkg/crypto/tls/tls.go | 8 |
13 files changed, 22 insertions, 64 deletions
diff --git a/src/pkg/crypto/aes/block.go b/src/pkg/crypto/aes/block.go index 738deba66..969983019 100644 --- a/src/pkg/crypto/aes/block.go +++ b/src/pkg/crypto/aes/block.go @@ -135,9 +135,7 @@ func subw(w uint32) uint32 { } // Rotate -func rotw(w uint32) uint32 { - return w<<8 | w>>24; -} +func rotw(w uint32) uint32 { return w<<8 | w>>24 } // Key expansion algorithm. See FIPS-197, Figure 11. // Their rcon[i] is our powx[i-1] << 24. diff --git a/src/pkg/crypto/aes/cipher.go b/src/pkg/crypto/aes/cipher.go index db9b59cd0..411272549 100644 --- a/src/pkg/crypto/aes/cipher.go +++ b/src/pkg/crypto/aes/cipher.go @@ -46,24 +46,18 @@ func NewCipher(key []byte) (*Cipher, os.Error) { // BlockSize returns the AES block size, 16 bytes. // It is necessary to satisfy the Key interface in the // package "crypto/modes". -func (c *Cipher) BlockSize() int { - return BlockSize; -} +func (c *Cipher) BlockSize() int { return BlockSize } // Encrypt encrypts the 16-byte buffer src using the key k // and stores the result in dst. // Note that for amounts of data larger than a block, // it is not safe to just call Encrypt on successive blocks; // instead, use an encryption mode like AESCBC (see modes.go). -func (c *Cipher) Encrypt(src, dst []byte) { - encryptBlock(c.enc, src, dst); -} +func (c *Cipher) Encrypt(src, dst []byte) { encryptBlock(c.enc, src, dst) } // Decrypt decrypts the 16-byte buffer src using the key k // and stores the result in dst. -func (c *Cipher) Decrypt(src, dst []byte) { - decryptBlock(c.dec, src, dst); -} +func (c *Cipher) Decrypt(src, dst []byte) { decryptBlock(c.dec, src, dst) } // Reset zeros the key data, so that it will no longer // appear in the process's memory. diff --git a/src/pkg/crypto/block/cbc.go b/src/pkg/crypto/block/cbc.go index 7bdf7d304..47aa8f32d 100644 --- a/src/pkg/crypto/block/cbc.go +++ b/src/pkg/crypto/block/cbc.go @@ -32,9 +32,7 @@ func newCBC(c Cipher, iv []byte) *cbcCipher { return x; } -func (x *cbcCipher) BlockSize() int { - return x.blockSize; -} +func (x *cbcCipher) BlockSize() int { return x.blockSize } func (x *cbcCipher) Encrypt(src, dst []byte) { for i := 0; i < x.blockSize; i++ { diff --git a/src/pkg/crypto/block/cfb.go b/src/pkg/crypto/block/cfb.go index 412381605..f515bdcfd 100644 --- a/src/pkg/crypto/block/cfb.go +++ b/src/pkg/crypto/block/cfb.go @@ -38,9 +38,7 @@ func newCFB(c Cipher, s int, iv []byte) *cfbCipher { return x; } -func (x *cfbCipher) BlockSize() int { - return x.blockSize; -} +func (x *cfbCipher) BlockSize() int { return x.blockSize } func (x *cfbCipher) Encrypt(src, dst []byte) { // Encrypt old IV and xor prefix with src to make dst. diff --git a/src/pkg/crypto/block/cmac.go b/src/pkg/crypto/block/cmac.go index 667dc7b3e..f57e64174 100644 --- a/src/pkg/crypto/block/cmac.go +++ b/src/pkg/crypto/block/cmac.go @@ -102,6 +102,4 @@ func (d *cmac) Sum() []byte { return d.digest; } -func (d *cmac) Size() int { - return len(d.digest); -} +func (d *cmac) Size() int { return len(d.digest) } diff --git a/src/pkg/crypto/block/ecb_test.go b/src/pkg/crypto/block/ecb_test.go index 664c4f4e1..c6507220b 100644 --- a/src/pkg/crypto/block/ecb_test.go +++ b/src/pkg/crypto/block/ecb_test.go @@ -20,9 +20,7 @@ type IncCipher struct { encrypting bool; } -func (c *IncCipher) BlockSize() int { - return c.blockSize; -} +func (c *IncCipher) BlockSize() int { return c.blockSize } func (c *IncCipher) Encrypt(src, dst []byte) { if !c.encrypting { diff --git a/src/pkg/crypto/hmac/hmac.go b/src/pkg/crypto/hmac/hmac.go index 4ed5686d7..f1cc6b32a 100644 --- a/src/pkg/crypto/hmac/hmac.go +++ b/src/pkg/crypto/hmac/hmac.go @@ -64,9 +64,7 @@ func (h *hmac) Write(p []byte) (n int, err os.Error) { return h.inner.Write(p); } -func (h *hmac) Size() int { - return h.size; -} +func (h *hmac) Size() int { return h.size } func (h *hmac) Reset() { h.inner.Reset(); @@ -94,11 +92,7 @@ func New(h hash.Hash, key []byte) hash.Hash { } // NewMD5 returns a new HMAC-MD5 hash using the given key. -func NewMD5(key []byte) hash.Hash { - return New(md5.New(), key); -} +func NewMD5(key []byte) hash.Hash { return New(md5.New(), key) } // NewSHA1 returns a new HMAC-SHA1 hash using the given key. -func NewSHA1(key []byte) hash.Hash { - return New(sha1.New(), key); -} +func NewSHA1(key []byte) hash.Hash { return New(sha1.New(), key) } diff --git a/src/pkg/crypto/md5/md5.go b/src/pkg/crypto/md5/md5.go index 77b3319c0..4236ad3fa 100644 --- a/src/pkg/crypto/md5/md5.go +++ b/src/pkg/crypto/md5/md5.go @@ -45,9 +45,7 @@ func New() hash.Hash { return d; } -func (d *digest) Size() int { - return Size; -} +func (d *digest) Size() int { return Size } func (d *digest) Write(p []byte) (nn int, err os.Error) { nn = len(p); diff --git a/src/pkg/crypto/rsa/rsa.go b/src/pkg/crypto/rsa/rsa.go index 685efd18f..beb416297 100644 --- a/src/pkg/crypto/rsa/rsa.go +++ b/src/pkg/crypto/rsa/rsa.go @@ -296,9 +296,7 @@ func EncryptOAEP(hash hash.Hash, rand io.Reader, pub *PublicKey, msg []byte, lab // It is deliberately vague to avoid adaptive attacks. type DecryptionError struct{} -func (DecryptionError) String() string { - return "RSA decryption error"; -} +func (DecryptionError) String() string { return "RSA decryption error" } // modInverse returns ia, the inverse of a in the multiplicative group of prime // order n. It requires that a be a member of the group (i.e. less than n). diff --git a/src/pkg/crypto/sha1/sha1.go b/src/pkg/crypto/sha1/sha1.go index a278f04eb..4e75b7336 100644 --- a/src/pkg/crypto/sha1/sha1.go +++ b/src/pkg/crypto/sha1/sha1.go @@ -47,9 +47,7 @@ func New() hash.Hash { return d; } -func (d *digest) Size() int { - return Size; -} +func (d *digest) Size() int { return Size } func (d *digest) Write(p []byte) (nn int, err os.Error) { nn = len(p); diff --git a/src/pkg/crypto/subtle/constant_time.go b/src/pkg/crypto/subtle/constant_time.go index a1d2eaf99..4dd7aa042 100644 --- a/src/pkg/crypto/subtle/constant_time.go +++ b/src/pkg/crypto/subtle/constant_time.go @@ -21,9 +21,7 @@ func ConstantTimeCompare(x, y []byte) int { // ConstantTimeSelect returns x if v is 1 and y if v is 0. // Its behavior is undefined if v takes any other value. -func ConstantTimeSelect(v, x, y int) int { - return ^(v-1) & x | (v-1)&y; -} +func ConstantTimeSelect(v, x, y int) int { return ^(v-1) & x | (v-1)&y } // ConstantTimeByteEq returns 1 if x == x and 0 otherwise. func ConstantTimeByteEq(x, y uint8) int { diff --git a/src/pkg/crypto/tls/common.go b/src/pkg/crypto/tls/common.go index 2145b7b55..36ad640cd 100644 --- a/src/pkg/crypto/tls/common.go +++ b/src/pkg/crypto/tls/common.go @@ -106,20 +106,12 @@ func mutualVersion(theirMajor, theirMinor uint8) (major, minor uint8, ok bool) { // A nop implements the NULL encryption and MAC algorithms. type nop struct{} -func (nop) XORKeyStream(buf []byte) { -} +func (nop) XORKeyStream(buf []byte) {} -func (nop) Write(buf []byte) (int, os.Error) { - return len(buf), nil; -} +func (nop) Write(buf []byte) (int, os.Error) { return len(buf), nil } -func (nop) Sum() []byte { - return nil; -} +func (nop) Sum() []byte { return nil } -func (nop) Reset() { -} +func (nop) Reset() {} -func (nop) Size() int { - return 0; -} +func (nop) Size() int { return 0 } diff --git a/src/pkg/crypto/tls/tls.go b/src/pkg/crypto/tls/tls.go index 13d8fd70b..c20e24e55 100644 --- a/src/pkg/crypto/tls/tls.go +++ b/src/pkg/crypto/tls/tls.go @@ -155,13 +155,9 @@ func (l Listener) Accept() (c net.Conn, err os.Error) { return; } -func (l Listener) Close() os.Error { - return l.listener.Close(); -} +func (l Listener) Close() os.Error { return l.listener.Close() } -func (l Listener) Addr() net.Addr { - return l.listener.Addr(); -} +func (l Listener) Addr() net.Addr { return l.listener.Addr() } // NewListener creates a Listener which accepts connections from an inner // Listener and wraps each connection with Server. |