Commits

Cliff Dyer  committed 88c5e4e Merge

Merged new_structure into default branch.

  • Participants
  • Parent commits 19ea7c0, ad06216

Comments (0)

Files changed (10)

-59334d424c2d84c0d85ec97e6b79515ccdac8675 go1

File round/column.go

 package round
 
 
-func Column(seq []uint32) {
+func Columnround(seq []uint32) {
     c := make(chan bool, 4)
     permutations := make([][4]uint, 4)
 
     permutations[3] = [4]uint{15,3,7,11}
 
     for i:=0; i<4; i++ {
-        go PermutedQuarter(seq, permutations[i], c)
+        go PermutedQuarterround(seq, permutations[i], c)
     }
     for i:=0; i<4; i++ {
         <- c

File round/column_test.go

     sequence := []uint32{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}
 
     expected := []uint32{0x10090288, 0x00000000, 0x00000000, 0x00000000, 0x00000101, 0x00000000, 0x00000000, 0x00000000, 0x00020401, 0x00000000, 0x00000000, 0x00000000, 0x40a04001, 0x00000000, 0x00000000, 0x00000000}
-    Column(sequence)
+    Columnround(sequence)
     columnSequenceEqual(t, sequence, expected)
 }
 
 func TestSpecColumnround2(t *testing.T) {
     sequence := []uint32{0x08521bd6, 0x1fe88837, 0xbb2aa576, 0x3aa26365, 0xc54c6a5b, 0x2fc74c2f, 0x6dd39cc3, 0xda0a64f6, 0x90a2f23d, 0x067f95a6, 0x06b35f61, 0x41e4732e, 0xe859c100, 0xea4d84b7, 0x0f619bff, 0xbc6e965a}
     expected := []uint32{0x8c9d190a, 0xce8e4c90, 0x1ef8e9d3, 0x1326a71a, 0x90a20123, 0xead3c4f3, 0x63a091a0, 0xf0708d69, 0x789b010c, 0xd195a681, 0xeb7d5504, 0xa774135c, 0x481c2027, 0x53a8e4b5, 0x4c1f89c5, 0x3f78c9c8}
-    Column(sequence)
+    Columnround(sequence)
     columnSequenceEqual(t, sequence, expected)
 }
 

File round/double.go

+package round
+
+func Doubleround(seq []uint32) {
+     Columnround(seq)
+     Rowround(seq)
+}

File round/quarter.go

 package round
 
-func Quarter(seq []uint32) { 
+func Quarterround(seq []uint32) { 
     seq[1] = seq[1] ^ lrot(seq[0]+seq[3], 7)
     seq[2] = seq[2] ^ lrot(seq[1]+seq[0], 9)
     seq[3] = seq[3] ^ lrot(seq[2]+seq[1], 13)
     seq[0] = seq[0] ^ lrot(seq[3]+seq[2], 18)
 }
 
-func PermutedQuarter(seq []uint32, permutation [4]uint, c chan <- bool) {
+func PermutedQuarterround(seq []uint32, permutation [4]uint, c chan <- bool) {
     temp := make([]uint32, 4)
     temp[0] = seq[permutation[0]]
     temp[1] = seq[permutation[1]]
     temp[2] = seq[permutation[2]]
     temp[3] = seq[permutation[3]]
-    Quarter(temp)
+    Quarterround(temp)
     seq[permutation[0]] = temp[0]
     seq[permutation[1]] = temp[1]
     seq[permutation[2]] = temp[2]

File round/quarter_test.go

 func TestSpecQuarterround1(t *testing.T) {
     sequence := []uint32{0, 0, 0, 0}
     expected := []uint32{0, 0, 0, 0}
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }
 
 func TestSpecQuarterround2(t *testing.T) {
     sequence := []uint32{0x00000001, 0x00000000, 0x00000000, 0x00000000}
     expected := []uint32{0x08008145, 0x00000080, 0x00010200, 0x20500000} 
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }
     
 func TestSpecQuarterround3(t *testing.T) {
     sequence := []uint32{0x00000000, 0x00000001, 0x00000000, 0x00000000}
     expected := []uint32{0x88000100, 0x00000001, 0x00000200, 0x00402000} 
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }
     
 func TestSpecQuarterround4(t *testing.T) {
     sequence := []uint32{0x00000000, 0x00000000, 0x00000001, 0x00000000}
     expected := []uint32{0x80040000, 0x00000000, 0x00000001, 0x00002000} 
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }
     
 func TestSpecQuarterround5(t *testing.T) {
     sequence := []uint32{0x00000000, 0x00000000, 0x00000000, 0x00000001}
     expected := []uint32{0x00048044, 0x00000080, 0x00010000, 0x20100001} 
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }
     
 func TestSpecQuarterround6(t *testing.T) {
     sequence := []uint32{0xe7e8c006, 0xc4f9417d, 0x6479b4b2, 0x68c67137}
     expected := []uint32{0xe876d72b, 0x9361dfd5, 0xf1460244, 0x948541a3} 
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }
     
 func TestSpecQuarterround7(t *testing.T) {
     sequence := []uint32{0xd3917c5b, 0x55f1c407, 0x52a58a7a, 0x8f887a3b}
     expected := []uint32{0x3e2f308c, 0xd90a8f36, 0x6ab2a923, 0x2883524c} 
-    Quarter(sequence)
+    Quarterround(sequence)
     quarterSequenceEqual(t, sequence, expected)
 }

File round/row.go

 package round
 
-func Row(seq []uint32) {
+func Rowround(seq []uint32) {
     c := make(chan bool, 4)
     permutations := make([][4]uint, 4)
 
     permutations[3] = [4]uint{15,12,13,14}
 
     for i:=0; i<4; i++ {
-        go PermutedQuarter(seq, permutations[i], c)
+        go PermutedQuarterround(seq, permutations[i], c)
     }
     for i:=0; i<4; i++ {
         <- c

File round/row_test.go

 func TestSpecRowround1(t *testing.T) {
     sequence := []uint32{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}
     expected := []uint32{0x08008145, 0x00000080, 0x00010200, 0x20500000, 0x20100001, 0x00048044, 0x00000080, 0x00010000, 0x00000001, 0x00002000, 0x80040000, 0x00000000, 0x00000001, 0x00000200, 0x00402000, 0x88000100}
-    Row(sequence)
+    Rowround(sequence)
     rowSequenceEqual(t, sequence, expected)
 }
 
 func TestSpecRowround2(t *testing.T) {
     sequence := []uint32{0x08521bd6, 0x1fe88837, 0xbb2aa576, 0x3aa26365, 0xc54c6a5b, 0x2fc74c2f, 0x6dd39cc3, 0xda0a64f6, 0x90a2f23d, 0x067f95a6, 0x06b35f61, 0x41e4732e, 0xe859c100, 0xea4d84b7, 0x0f619bff, 0xbc6e965a}
     expected := []uint32{0xa890d39d, 0x65d71596, 0xe9487daa, 0xc8ca6a86, 0x949d2192, 0x764b7754, 0xe408d9b9, 0x7a41b4d1, 0x3402e183, 0x3c3af432, 0x50669f96, 0xd89ef0a8, 0x0040ede5, 0xb545fbce, 0xd257ed4f, 0x1818882d}
-    Row(sequence)
+    Rowround(sequence)
     rowSequenceEqual(t, sequence, expected)
 }
 
+package main
+
+import (
+    "fmt"
+    "bitbucket.org/cliff/salsa20/round"
+)
+
+func main() {
+    quarter := []uint32{1, 0, 0, 0}
+    seq := make([]uint32, 16)
+    for i:=0; i < 16; i+=4 {
+        copy(seq[i:i+4], quarter)
+    }
+    round.Quarterround(quarter)
+    round.Doubleround(seq)
+    fmt.Printf("%08x", quarter)
+    fmt.Println()
+
+    fmt.Printf("%08x\n", seq)
+}

File salsa20/salsa20.go

-package main
-
-import (
-    "fmt"
-    "bitbucket.org/cliff/salsa20/round"
-)
-
-func main() {
-    quarter := []uint32{1, 0, 0, 0}
-    round.Quarter(quarter)
-    fmt.Printf("%08x", quarter)
-    fmt.Println()
-}