Commits

Eric Roshan Eisner committed ccdf263 Draft

add doc comments

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
 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 {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.