Commit eabcc981 authored by Robert Griesemer's avatar Robert Griesemer

gofmt-ify crypto

R=agl
CC=rsc
http://go/go-review/1017032
parent 2ce57ec1
...@@ -15,9 +15,9 @@ import ( ...@@ -15,9 +15,9 @@ import (
// Simple Cipher for testing: adds an incrementing amount // Simple Cipher for testing: adds an incrementing amount
// to each byte in each // to each byte in each
type IncCipher struct { type IncCipher struct {
blockSize int; blockSize int;
delta byte; delta byte;
encrypting bool; encrypting bool;
} }
func (c *IncCipher) BlockSize() int { func (c *IncCipher) BlockSize() int {
...@@ -60,10 +60,10 @@ func TestECBEncrypter(t *testing.T) { ...@@ -60,10 +60,10 @@ func TestECBEncrypter(t *testing.T) {
// compute encrypted version // compute encrypted version
delta := byte(0); delta := byte(0);
for i := 0; i < len(crypt); i++ { for i := 0; i < len(crypt); i++ {
if i % block == 0 { if i%block == 0 {
delta++; delta++;
} }
crypt[i] = plain[i] + delta; crypt[i] = plain[i]+delta;
} }
for frag := 0; frag < 2; frag++ { for frag := 0; frag < 2; frag++ {
...@@ -110,24 +110,24 @@ func TestECBEncrypter(t *testing.T) { ...@@ -110,24 +110,24 @@ func TestECBEncrypter(t *testing.T) {
} }
func testECBDecrypter(t *testing.T, maxio int) { func testECBDecrypter(t *testing.T, maxio int) {
var readers = []func(io.Reader) io.Reader { var readers = []func(io.Reader) io.Reader{
func (r io.Reader) io.Reader { return r }, func(r io.Reader) io.Reader { return r },
iotest.OneByteReader, iotest.OneByteReader,
iotest.HalfReader, iotest.HalfReader,
}; };
var plain, crypt [256]byte; var plain, crypt [256]byte;
for i := 0; i < len(plain); i++ { for i := 0; i < len(plain); i++ {
plain[i] = byte(255 - i); plain[i] = byte(255-i);
} }
b := new(bytes.Buffer); b := new(bytes.Buffer);
for block := 1; block <= 64 && block <= maxio; block *= 2 { for block := 1; block <= 64 && block <= maxio; block *= 2 {
// compute encrypted version // compute encrypted version
delta := byte(0); delta := byte(0);
for i := 0; i < len(crypt); i++ { for i := 0; i < len(crypt); i++ {
if i % block == 0 { if i%block == 0 {
delta++; delta++;
} }
crypt[i] = plain[i] + delta; crypt[i] = plain[i]+delta;
} }
for mode := 0; mode < len(readers); mode++ { for mode := 0; mode < len(readers); mode++ {
......
...@@ -98,9 +98,7 @@ func TestXorWriter(t *testing.T) { ...@@ -98,9 +98,7 @@ func TestXorWriter(t *testing.T) {
func testXorReader(t *testing.T, maxio int) { func testXorReader(t *testing.T, maxio int) {
var readers = []func(io.Reader) io.Reader{ var readers = []func(io.Reader) io.Reader{
func(r io.Reader) io.Reader { func(r io.Reader) io.Reader { return r },
return r;
},
iotest.OneByteReader, iotest.OneByteReader,
iotest.HalfReader, iotest.HalfReader,
}; };
......
...@@ -106,7 +106,8 @@ func mutualVersion(theirMajor, theirMinor uint8) (major, minor uint8, ok bool) { ...@@ -106,7 +106,8 @@ func mutualVersion(theirMajor, theirMinor uint8) (major, minor uint8, ok bool) {
// A nop implements the NULL encryption and MAC algorithms. // A nop implements the NULL encryption and MAC algorithms.
type nop struct{} type nop struct{}
func (nop) XORKeyStream(buf []byte) {} func (nop) XORKeyStream(buf []byte) {
}
func (nop) Write(buf []byte) (int, os.Error) { func (nop) Write(buf []byte) (int, os.Error) {
return len(buf), nil; return len(buf), nil;
...@@ -116,7 +117,8 @@ func (nop) Sum() []byte { ...@@ -116,7 +117,8 @@ func (nop) Sum() []byte {
return nil; return nil;
} }
func (nop) Reset() {} func (nop) Reset() {
}
func (nop) Size() int { func (nop) Size() int {
return 0; return 0;
......
...@@ -74,10 +74,16 @@ func (w *recordWriter) loop(writer io.Writer, appChan <-chan []byte, controlChan ...@@ -74,10 +74,16 @@ func (w *recordWriter) loop(writer io.Writer, appChan <-chan []byte, controlChan
} }
if !closed(appChan) { if !closed(appChan) {
go func() { for _ = range appChan {} }(); go func() {
for _ = range appChan {
}
}();
} }
if !closed(controlChan) { if !closed(controlChan) {
go func() { for _ = range controlChan {} }(); go func() {
for _ = range controlChan {
}
}();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment