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

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

Issue 1223983002: Move WriteInto to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « remoting/host/token_validator_factory_impl.cc ('k') | ui/base/ime/win/imm32_manager.cc » ('j') | 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/nigori.h" 5 #include "sync/util/nigori.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 Base64Encode(output, permuted); 153 Base64Encode(output, permuted);
154 return true; 154 return true;
155 } 155 }
156 156
157 // Enc[Kenc,Kmac](value) 157 // Enc[Kenc,Kmac](value)
158 bool Nigori::Encrypt(const std::string& value, std::string* encrypted) const { 158 bool Nigori::Encrypt(const std::string& value, std::string* encrypted) const {
159 if (0U >= value.size()) 159 if (0U >= value.size())
160 return false; 160 return false;
161 161
162 std::string iv; 162 std::string iv;
163 crypto::RandBytes(WriteInto(&iv, kIvSize + 1), kIvSize); 163 crypto::RandBytes(base::WriteInto(&iv, kIvSize + 1), kIvSize);
164 164
165 Encryptor encryptor; 165 Encryptor encryptor;
166 if (!encryptor.Init(encryption_key_.get(), Encryptor::CBC, iv)) 166 if (!encryptor.Init(encryption_key_.get(), Encryptor::CBC, iv))
167 return false; 167 return false;
168 168
169 std::string ciphertext; 169 std::string ciphertext;
170 if (!encryptor.Encrypt(value, &ciphertext)) 170 if (!encryptor.Encrypt(value, &ciphertext))
171 return false; 171 return false;
172 172
173 std::string raw_mac_key; 173 std::string raw_mac_key;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 DCHECK(user_key); 241 DCHECK(user_key);
242 DCHECK(encryption_key); 242 DCHECK(encryption_key);
243 DCHECK(mac_key); 243 DCHECK(mac_key);
244 244
245 return user_key_->GetRawKey(user_key) && 245 return user_key_->GetRawKey(user_key) &&
246 encryption_key_->GetRawKey(encryption_key) && 246 encryption_key_->GetRawKey(encryption_key) &&
247 mac_key_->GetRawKey(mac_key); 247 mac_key_->GetRawKey(mac_key);
248 } 248 }
249 249
250 } // namespace syncer 250 } // namespace syncer
OLDNEW
« no previous file with comments | « remoting/host/token_validator_factory_impl.cc ('k') | ui/base/ime/win/imm32_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698