OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webcrypto_impl.h" | 5 #include "webcrypto_impl.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 crypto_key, | 264 crypto_key, |
265 message_raw.data(), | 265 message_raw.data(), |
266 message_raw.size(), | 266 message_raw.size(), |
267 &array_buffer)); | 267 &array_buffer)); |
268 | 268 |
269 // Ignore case, it's checking the hex value. | 269 // Ignore case, it's checking the hex value. |
270 EXPECT_STRCASEEQ( | 270 EXPECT_STRCASEEQ( |
271 input_set[index].mac, | 271 input_set[index].mac, |
272 base::HexEncode( | 272 base::HexEncode( |
273 array_buffer.data(), array_buffer.byteLength()).c_str()); | 273 array_buffer.data(), array_buffer.byteLength()).c_str()); |
| 274 |
| 275 bool signature_match = false; |
| 276 EXPECT_TRUE( |
| 277 crypto.VerifySignatureInternal( |
| 278 hmac_algorithm, |
| 279 crypto_key, |
| 280 static_cast<const unsigned char*>(array_buffer.data()), |
| 281 array_buffer.byteLength(), |
| 282 message_raw.data(), |
| 283 message_raw.size(), |
| 284 &signature_match)); |
| 285 EXPECT_TRUE(signature_match); |
| 286 |
| 287 // Ensure truncated signature does not verify by passing one less byte. |
| 288 EXPECT_TRUE( |
| 289 crypto.VerifySignatureInternal( |
| 290 hmac_algorithm, |
| 291 crypto_key, |
| 292 static_cast<const unsigned char*>(array_buffer.data()), |
| 293 array_buffer.byteLength() - 1, |
| 294 message_raw.data(), |
| 295 message_raw.size(), |
| 296 &signature_match)); |
| 297 EXPECT_FALSE(signature_match); |
274 } | 298 } |
275 } | 299 } |
276 | 300 |
277 } // namespace content | 301 } // namespace content |
OLD | NEW |