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

Side by Side Diff: components/update_client/client_update_protocol_ecdsa_unittest.cc

Issue 1685323002: Implement CUP signing in UpdateClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and remove duplicated code comment. Created 4 years, 10 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "components/update_client/client_update_protocol_ecdsa.h" 14 #include "components/update_client/client_update_protocol_ecdsa.h"
15 #include "crypto/random.h" 15 #include "crypto/random.h"
16 #include "crypto/secure_util.h" 16 #include "crypto/secure_util.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace update_client {
20
19 namespace { 21 namespace {
20 22
21 std::string GetPublicKeyForTesting() { 23 std::string GetPublicKeyForTesting() {
22 // How to generate this key: 24 // How to generate this key:
23 // openssl ecparam -genkey -name prime256v1 -out ecpriv.pem 25 // openssl ecparam -genkey -name prime256v1 -out ecpriv.pem
24 // openssl ec -in ecpriv.pem -pubout -out ecpub.pem 26 // openssl ec -in ecpriv.pem -pubout -out ecpub.pem
25 27
26 static const char kCupEcdsaTestKey_Base64[] = 28 static const char kCupEcdsaTestKey_Base64[] =
27 "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEJNOjKyN6UHyUGkGow+xCmQthQXUo" 29 "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEJNOjKyN6UHyUGkGow+xCmQthQXUo"
28 "9sd7RIXSpVIM768UlbGb/5JrnISjSYejCc/pxQooI6mJTzWL3pZb5TA1DA=="; 30 "9sd7RIXSpVIM768UlbGb/5JrnISjSYejCc/pxQooI6mJTzWL3pZb5TA1DA==";
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 ":2727bc2b3c33feb6800a830f4055901dd87d65a84184c5fbeb3f816db0a243f5")); 287 ":2727bc2b3c33feb6800a830f4055901dd87d65a84184c5fbeb3f816db0a243f5"));
286 288
287 // Failure case: Request/response are intact, but the signature is invalid 289 // Failure case: Request/response are intact, but the signature is invalid
288 // because it was signed against a different nonce (67890). 290 // because it was signed against a different nonce (67890).
289 EXPECT_FALSE(CUP().ValidateResponse( 291 EXPECT_FALSE(CUP().ValidateResponse(
290 "Response_A", 292 "Response_A",
291 "3046022100d3bbb1fb4451c8e04a07fe95404cc39121ed0e0bc084f87de19d52eee50a97" 293 "3046022100d3bbb1fb4451c8e04a07fe95404cc39121ed0e0bc084f87de19d52eee50a97"
292 "bf022100dd7d41d467be2af98d9116b0c7ba09740d54578c02a02f74da5f089834be3403" 294 "bf022100dd7d41d467be2af98d9116b0c7ba09740d54578c02a02f74da5f089834be3403"
293 ":2727bc2b3c33feb6800a830f4055901dd87d65a84184c5fbeb3f816db0a243f5")); 295 ":2727bc2b3c33feb6800a830f4055901dd87d65a84184c5fbeb3f816db0a243f5"));
294 } 296 }
297
298 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/client_update_protocol_ecdsa.cc ('k') | components/update_client/configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698