summaryrefslogtreecommitdiff
path: root/src/pkg/crypto/rc4/rc4.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/crypto/rc4/rc4.go')
-rw-r--r--src/pkg/crypto/rc4/rc4.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/pkg/crypto/rc4/rc4.go b/src/pkg/crypto/rc4/rc4.go
index d965f827b..e47a01513 100644
--- a/src/pkg/crypto/rc4/rc4.go
+++ b/src/pkg/crypto/rc4/rc4.go
@@ -10,14 +10,14 @@ package rc4
// it a poor choice for new protocols.
import (
- "os";
- "strconv";
+ "os"
+ "strconv"
)
// A Cipher is an instance of RC4 using a particular key.
type Cipher struct {
- s [256]byte;
- i, j uint8;
+ s [256]byte
+ i, j uint8
}
type KeySizeError int
@@ -29,30 +29,30 @@ func (k KeySizeError) String() string {
// NewCipher creates and returns a new Cipher. The key argument should be the
// RC4 key, at least 1 byte and at most 256 bytes.
func NewCipher(key []byte) (*Cipher, os.Error) {
- k := len(key);
+ k := len(key)
if k < 1 || k > 256 {
return nil, KeySizeError(k)
}
- var c Cipher;
+ var c Cipher
for i := 0; i < 256; i++ {
c.s[i] = uint8(i)
}
- var j uint8 = 0;
+ var j uint8 = 0
for i := 0; i < 256; i++ {
- j += c.s[i] + key[i%k];
- c.s[i], c.s[j] = c.s[j], c.s[i];
+ j += c.s[i] + key[i%k]
+ c.s[i], c.s[j] = c.s[j], c.s[i]
}
- return &c, nil;
+ return &c, nil
}
// XORKeyStream will XOR each byte of the given buffer with a byte of the
// generated keystream.
func (c *Cipher) XORKeyStream(buf []byte) {
for i := range buf {
- c.i += 1;
- c.j += c.s[c.i];
- c.s[c.i], c.s[c.j] = c.s[c.j], c.s[c.i];
- buf[i] ^= c.s[c.s[c.i]+c.s[c.j]];
+ c.i += 1
+ c.j += c.s[c.i]
+ c.s[c.i], c.s[c.j] = c.s[c.j], c.s[c.i]
+ buf[i] ^= c.s[c.s[c.i]+c.s[c.j]]
}
}
@@ -62,5 +62,5 @@ func (c *Cipher) Reset() {
for i := range c.s {
c.s[i] = 0
}
- c.i, c.j = 0, 0;
+ c.i, c.j = 0, 0
}