Commits

Eric Roshan Eisner  committed ccdf263 Draft

add doc comments

  • Participants
  • Parent commits ccb4625

Comments (0)

Files changed (3)

 	}
 }
 
+// New224 returns a new hash.Hash computing the SHA-3 224-bit checksum.
 func New224() hash.Hash { return newSHA3(224) }
+
+// New256 returns a new hash.Hash computing the SHA-3 256-bit checksum.
 func New256() hash.Hash { return newSHA3(256) }
+
+// New384 returns a new hash.Hash computing the SHA-3 384-bit checksum.
 func New384() hash.Hash { return newSHA3(384) }
+
+// New512 returns a new hash.Hash computing the SHA-3 512-bit checksum.
 func New512() hash.Hash { return newSHA3(512) }
 
 func (d *keccak) Size() int {
 	"crypto/cipher"
 )
 
-func NewCipher(key []byte) cipher.Stream {
+// NewCipher gives a stream cipher built from the concatenation of iv and
+// key. This uses the variable-length output mode of 256-bit SHA-3.
+func NewCipher(iv, key []byte) cipher.Stream {
 	c := newSHA3(256)
+	c.Write(iv)
 	c.Write(key)
 	c.pad()
 	c.n = c.blocksize

File stream_test.go

 import "testing"
 
 func TestStreamRoundtrip(t *testing.T) {
+	iv := []byte("fdsajkl;")
 	key := []byte("key")
 	b := make([]byte, 41<<10)
-	enc := NewCipher(key)
+	enc := NewCipher(iv, key)
 	for i := 0; i < len(b); i += 41 {
 		enc.XORKeyStream(b[i:], b[i:i+41])
 	}
 		t.Fatalf("Nothing got ciphered.")
 	}
 
-	dec := NewCipher(key)
+	dec := NewCipher(iv, key)
 	dec.XORKeyStream(b, b)
 
 	for i, c := range b {