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

Side by Side Diff: sync/util/cryptographer_unittest.cc

Issue 10916036: [Sync] Implement keystore migration support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « sync/util/cryptographer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/util/cryptographer.h" 5 #include "sync/util/cryptographer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 EXPECT_TRUE(cryptographer.DecryptPendingKeys(params)); 176 EXPECT_TRUE(cryptographer.DecryptPendingKeys(params));
177 EXPECT_TRUE(cryptographer.is_ready()); 177 EXPECT_TRUE(cryptographer.is_ready());
178 EXPECT_FALSE(cryptographer.has_pending_keys()); 178 EXPECT_FALSE(cryptographer.has_pending_keys());
179 179
180 sync_pb::PasswordSpecificsData decrypted; 180 sync_pb::PasswordSpecificsData decrypted;
181 EXPECT_TRUE(cryptographer.Decrypt(encrypted, &decrypted)); 181 EXPECT_TRUE(cryptographer.Decrypt(encrypted, &decrypted));
182 EXPECT_EQ(original.SerializeAsString(), decrypted.SerializeAsString()); 182 EXPECT_EQ(original.SerializeAsString(), decrypted.SerializeAsString());
183 } 183 }
184 } 184 }
185 185
186 // Crashes, Bug 55178. 186 TEST_F(SyncCryptographerTest, Bootstrap) {
187 #if defined(OS_WIN) 187 KeyParams params = {"localhost", "dummy", "dummy"};
188 #define MAYBE_PackUnpack DISABLED_PackUnpack 188 cryptographer_.AddKey(params);
189 #else
190 #define MAYBE_PackUnpack PackUnpack
191 #endif
192 TEST_F(SyncCryptographerTest, MAYBE_PackUnpack) {
193 Nigori nigori;
194 ASSERT_TRUE(nigori.InitByDerivation("example.com", "username", "password"));
195 std::string expected_user, expected_encryption, expected_mac;
196 ASSERT_TRUE(nigori.ExportKeys(&expected_user, &expected_encryption,
197 &expected_mac));
198 189
199 std::string token; 190 std::string token;
200 EXPECT_TRUE(cryptographer_.PackBootstrapToken(&nigori, &token)); 191 EXPECT_TRUE(cryptographer_.GetBootstrapToken(&token));
201 EXPECT_TRUE(IsStringUTF8(token)); 192 EXPECT_TRUE(IsStringUTF8(token));
202 193
203 scoped_ptr<Nigori> unpacked(cryptographer_.UnpackBootstrapToken(token)); 194 Cryptographer other_cryptographer(&encryptor_);
204 EXPECT_NE(static_cast<Nigori*>(NULL), unpacked.get()); 195 other_cryptographer.Bootstrap(token);
196 EXPECT_TRUE(other_cryptographer.is_ready());
205 197
206 std::string user_key, encryption_key, mac_key; 198 const char secret[] = "secret";
207 ASSERT_TRUE(unpacked->ExportKeys(&user_key, &encryption_key, &mac_key)); 199 sync_pb::EncryptedData encrypted;
208 200 EXPECT_TRUE(other_cryptographer.EncryptString(secret, &encrypted));
209 EXPECT_EQ(expected_user, user_key); 201 EXPECT_TRUE(cryptographer_.CanDecryptUsingDefaultKey(encrypted));
210 EXPECT_EQ(expected_encryption, encryption_key);
211 EXPECT_EQ(expected_mac, mac_key);
212 } 202 }
213 203
214 } // namespace syncer 204 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/util/cryptographer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698