Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: components/client_update_protocol/ecdsa_unittest.cc

Issue 1921973002: Convert //components/[a-e]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/client_update_protocol/ecdsa.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
6 8
7 #include <limits> 9 #include <limits>
10 #include <memory>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/base64.h" 13 #include "base/base64.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
13 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
14 #include "components/client_update_protocol/ecdsa.h"
15 #include "crypto/random.h" 16 #include "crypto/random.h"
16 #include "crypto/secure_util.h" 17 #include "crypto/secure_util.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace client_update_protocol { 20 namespace client_update_protocol {
20 21
21 namespace { 22 namespace {
22 23
23 std::string GetPublicKeyForTesting() { 24 std::string GetPublicKeyForTesting() {
24 // How to generate this key: 25 // How to generate this key:
(...skipping 21 matching lines...) Expand all
46 } 47 }
47 48
48 void OverrideNonce(uint32_t nonce) { 49 void OverrideNonce(uint32_t nonce) {
49 cup_->request_query_cup2key_ = 50 cup_->request_query_cup2key_ =
50 base::StringPrintf("%d:%u", cup_->pub_key_version_, nonce); 51 base::StringPrintf("%d:%u", cup_->pub_key_version_, nonce);
51 } 52 }
52 53
53 Ecdsa& CUP() { return *cup_.get(); } 54 Ecdsa& CUP() { return *cup_.get(); }
54 55
55 private: 56 private:
56 scoped_ptr<Ecdsa> cup_; 57 std::unique_ptr<Ecdsa> cup_;
57 }; 58 };
58 59
59 TEST_F(CupEcdsaTest, SignRequest) { 60 TEST_F(CupEcdsaTest, SignRequest) {
60 static const char kRequest[] = "TestSequenceForCupEcdsaUnitTest"; 61 static const char kRequest[] = "TestSequenceForCupEcdsaUnitTest";
61 static const char kRequestHash[] = 62 static const char kRequestHash[] =
62 "&cup2hreq=" 63 "&cup2hreq="
63 "cde1f7dc1311ed96813057ca321c2f5a17ea2c9c776ee0eb31965f7985a3074a"; 64 "cde1f7dc1311ed96813057ca321c2f5a17ea2c9c776ee0eb31965f7985a3074a";
64 static const char kKeyId[] = "cup2key=8:"; 65 static const char kKeyId[] = "cup2key=8:";
65 66
66 std::string query; 67 std::string query;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Failure case: Request/response are intact, but the signature is invalid 290 // Failure case: Request/response are intact, but the signature is invalid
290 // because it was signed against a different nonce (67890). 291 // because it was signed against a different nonce (67890).
291 EXPECT_FALSE(CUP().ValidateResponse( 292 EXPECT_FALSE(CUP().ValidateResponse(
292 "Response_A", 293 "Response_A",
293 "3046022100d3bbb1fb4451c8e04a07fe95404cc39121ed0e0bc084f87de19d52eee50a97" 294 "3046022100d3bbb1fb4451c8e04a07fe95404cc39121ed0e0bc084f87de19d52eee50a97"
294 "bf022100dd7d41d467be2af98d9116b0c7ba09740d54578c02a02f74da5f089834be3403" 295 "bf022100dd7d41d467be2af98d9116b0c7ba09740d54578c02a02f74da5f089834be3403"
295 ":2727bc2b3c33feb6800a830f4055901dd87d65a84184c5fbeb3f816db0a243f5")); 296 ":2727bc2b3c33feb6800a830f4055901dd87d65a84184c5fbeb3f816db0a243f5"));
296 } 297 }
297 298
298 } // namespace client_update_protocol 299 } // namespace client_update_protocol
OLDNEW
« no previous file with comments | « components/client_update_protocol/ecdsa.cc ('k') | components/cloud_devices/common/cloud_device_description.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698