OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 hmac | 5 package hmac |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "hash" | 9 "hash" |
10 "testing" | 10 "testing" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 h := tt.hash(tt.key) | 185 h := tt.hash(tt.key) |
186 for j := 0; j < 2; j++ { | 186 for j := 0; j < 2; j++ { |
187 n, err := h.Write(tt.in) | 187 n, err := h.Write(tt.in) |
188 if n != len(tt.in) || err != nil { | 188 if n != len(tt.in) || err != nil { |
189 t.Errorf("test %d.%d: Write(%d) = %d, %v", i, j,
len(tt.in), n, err) | 189 t.Errorf("test %d.%d: Write(%d) = %d, %v", i, j,
len(tt.in), n, err) |
190 continue | 190 continue |
191 } | 191 } |
192 | 192 |
193 // Repetitive Sum() calls should return the same value | 193 // Repetitive Sum() calls should return the same value |
194 for k := 0; k < 2; k++ { | 194 for k := 0; k < 2; k++ { |
195 » » » » sum := fmt.Sprintf("%x", h.Sum()) | 195 » » » » sum := fmt.Sprintf("%x", h.Sum(nil)) |
196 if sum != tt.out { | 196 if sum != tt.out { |
197 t.Errorf("test %d.%d.%d: have %s want %s
\n", i, j, k, sum, tt.out) | 197 t.Errorf("test %d.%d.%d: have %s want %s
\n", i, j, k, sum, tt.out) |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 // Second iteration: make sure reset works. | 201 // Second iteration: make sure reset works. |
202 h.Reset() | 202 h.Reset() |
203 } | 203 } |
204 } | 204 } |
205 } | 205 } |
OLD | NEW |