Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(351)

Delta Between Two Patch Sets: sha3/sha3_test.go

Issue 7760044: go.crypto/sha3: new package
Left Patch Set: diff -r 8dd5caec1eae https://code.google.com/p/go.crypto/ Created 11 years ago
Right Patch Set: diff -r 8dd5caec1eae https://code.google.com/p/go.crypto/ Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sha3/sha3.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package sha3 5 package sha3
6 6
7 // These tests are a subset of those provided by the Keccak web site(http://kecc ak.noekeon.org/). 7 // These tests are a subset of those provided by the Keccak web site(http://kecc ak.noekeon.org/).
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 repeat: 1, 74 repeat: 1,
75 want: map[string]string{ 75 want: map[string]string{
76 "Keccak224": "F217812E362EC64D4DC5EACFABC165184BFA456E5C 32C2C7900253D0", 76 "Keccak224": "F217812E362EC64D4DC5EACFABC165184BFA456E5C 32C2C7900253D0",
77 "Keccak256": "E78C421E6213AFF8DE1F025759A4F2C943DB62BBDE 359C8737E19B3776ED2DD2", 77 "Keccak256": "E78C421E6213AFF8DE1F025759A4F2C943DB62BBDE 359C8737E19B3776ED2DD2",
78 "Keccak384": "CF38764973F1EC1C34B5433AE75A3AAD1AAEF6AB19 7850C56C8617BCD6A882F6666883AC17B2DCCDBAA647075D0972B5", 78 "Keccak384": "CF38764973F1EC1C34B5433AE75A3AAD1AAEF6AB19 7850C56C8617BCD6A882F6666883AC17B2DCCDBAA647075D0972B5",
79 "Keccak512": "9A7688E31AAF40C15575FC58C6B39267AAD3722E69 6E518A9945CF7F7C0FEA84CB3CB2E9F0384A6B5DC671ADE7FB4D2B27011173F3EEEAF17CB451CF26 542031", 79 "Keccak512": "9A7688E31AAF40C15575FC58C6B39267AAD3722E69 6E518A9945CF7F7C0FEA84CB3CB2E9F0384A6B5DC671ADE7FB4D2B27011173F3EEEAF17CB451CF26 542031",
80 }, 80 },
81 }, 81 },
82 } 82 }
83 83
84 // longTestVectors stores longer testVector (currently only one). 84 // longTestVectors stores a single 64 MiB long testVector.
85 // The computed test vector is 1 GiB long, taken from http://keccak.noekeon.org/ . 85 // This is a prefix of the "very long" 1 GiB test vector defined in the Keccak s tandard at
86 // http://keccak.noekeon.org/. We truncate here to keep the running time on the order of seconds.
86 var longKeccakTestVectors = []testVector{ 87 var longKeccakTestVectors = []testVector{
87 { 88 {
88 » » desc: "long-1GiB", 89 » » desc: "long-64MiB",
89 input: []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm ghijklmnhijklmno"), 90 input: []byte("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm ghijklmnhijklmno"),
90 » » repeat: 16 * 1024 * 1024, 91 » » repeat: 1024 * 1024,
91 » » want: map[string]string{ 92 » » want: map[string]string{
92 » » » "Keccak224": "C42E4AEE858E1A8AD2976896B9D23DD187F64436EE 15969AFDBC68C5", 93 » » » "Keccak224": "50E35E40980FEEFF1EA490957B0E970257F75EA0D4 10EE0F0B8A7A58",
93 » » » "Keccak256": "5F313C39963DCF792B5470D4ADE9F3A356A3E40217 48690A958372E2B06F82A4", 94 » » » "Keccak256": "5015A4935F0B51E091C6550A94DCD262C08998232C CAA22E7F0756DEAC0DC0D0",
94 » » » "Keccak384": "9B7168B4494A80A86408E6B9DC4E5A1837C85DD8FF 452ED410F2832959C08C8C0D040A892EB9A755776372D4A8732315", 95 » » » "Keccak384": "7907A8D0FAA7BC6A90FE14C6C958C956A0877E7514 55D8F13ACDB96F144B5896E716C06EC0CB56557A94EF5C3355F6F3",
95 » » » "Keccak512": "3E122EDAF37398231CFACA4C7C216C9D66D5B899EC 1D7AC617C40C7261906A45FC01617A021E5DA3BD8D4182695B5CB785A28237CBB167590E34718E56 D8AAB8", 96 » » » "Keccak512": "3EC327D6759F769DEB74E80CA70C831BC29CAB048A 4BF4190E4A1DD5C6507CF2B4B58937FDE81D36014E7DFE1B1DD8B0F27CB7614F9A645FEC114F1DAA EFC056",
96 }, 97 },
97 }, 98 },
98 } 99 }
99 100
100 // TestKeccakVectors checks that correct output is produced for a set of known t estVectors. 101 // TestKeccakVectors checks that correct output is produced for a set of known t estVectors.
101 func TestKeccakVectors(t *testing.T) { 102 func TestKeccakVectors(t *testing.T) {
102 testCases := append([]testVector{}, shortKeccakTestVectors...) 103 testCases := append([]testVector{}, shortKeccakTestVectors...)
103 if !testing.Short() { 104 if !testing.Short() {
104 testCases = append(testCases, longKeccakTestVectors...) 105 testCases = append(testCases, longKeccakTestVectors...)
105 } 106 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 238 }
238 b.StopTimer() 239 b.StopTimer()
239 h.Reset() 240 h.Reset()
240 } 241 }
241 242
242 // benchmarkBulkKeccakX test the speed to hash a 16 KiB buffer by calling benchm arkBulkHash. 243 // benchmarkBulkKeccakX test the speed to hash a 16 KiB buffer by calling benchm arkBulkHash.
243 func BenchmarkBulkKeccak512(b *testing.B) { benchmarkBulkHash(b, NewKeccak512()) } 244 func BenchmarkBulkKeccak512(b *testing.B) { benchmarkBulkHash(b, NewKeccak512()) }
244 func BenchmarkBulkKeccak384(b *testing.B) { benchmarkBulkHash(b, NewKeccak384()) } 245 func BenchmarkBulkKeccak384(b *testing.B) { benchmarkBulkHash(b, NewKeccak384()) }
245 func BenchmarkBulkKeccak256(b *testing.B) { benchmarkBulkHash(b, NewKeccak256()) } 246 func BenchmarkBulkKeccak256(b *testing.B) { benchmarkBulkHash(b, NewKeccak256()) }
246 func BenchmarkBulkKeccak224(b *testing.B) { benchmarkBulkHash(b, NewKeccak224()) } 247 func BenchmarkBulkKeccak224(b *testing.B) { benchmarkBulkHash(b, NewKeccak224()) }
LEFTRIGHT
« sha3/sha3.go ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b