Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/managed_mode/managed_user_passphrase.h" | |
| 6 | |
| 7 #include "base/base64.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "crypto/encryptor.h" | |
| 10 #include "crypto/symmetric_key.h" | |
| 11 | |
| 12 const std::string ManagedUserPassphrase::kSalt_ = "managed_salt"; | |
|
Pam (message me for reviews)
2013/01/07 14:51:49
You'll be fixing this as your very next change, ri
| |
| 13 | |
| 14 void ManagedUserPassphrase::GenerateHashFromPassphrase( | |
| 15 const std::string& passphrase, | |
| 16 std::string* encoded_passphrase_hash) { | |
| 17 DCHECK(encoded_passphrase_hash); | |
|
Pam (message me for reviews)
2013/01/07 14:51:49
This should just be a CHECK. If somebody passes a
Bernhard Bauer
2013/01/08 17:43:14
Well, then you can probably leave it out completel
| |
| 18 std::string passphrase_hash; | |
| 19 GetPassphraseHash(passphrase, &passphrase_hash); | |
| 20 if (!base::Base64Encode(passphrase_hash, encoded_passphrase_hash)) { | |
|
Bernhard Bauer
2013/01/07 14:20:22
Nit: I usually do `bool success = ...; DCHECK(succ
| |
| 21 NOTREACHED(); | |
| 22 } | |
| 23 } | |
| 24 | |
| 25 void ManagedUserPassphrase::GetPassphraseHash(const std::string& passphrase, | |
| 26 std::string* passphrase_hash) { | |
|
Bernhard Bauer
2013/01/07 14:20:22
Please align this parameter with the previous one
| |
| 27 DCHECK(passphrase_hash); | |
| 28 // Create a hash from the user-provided passphrase and our hard-coded salt. | |
| 29 scoped_ptr<crypto::SymmetricKey> encryption_key( | |
| 30 crypto::SymmetricKey::DeriveKeyFromPassword( | |
| 31 crypto::SymmetricKey::AES, | |
| 32 passphrase, | |
| 33 kSalt_, | |
| 34 128, | |
| 35 1)); | |
| 36 DCHECK(encryption_key.get()); | |
|
Pam (message me for reviews)
2013/01/07 14:51:49
I don't think this is necessary, since the next li
| |
| 37 if (!encryption_key->GetRawKey(passphrase_hash)) { | |
| 38 NOTREACHED(); | |
| 39 } | |
| 40 } | |
| OLD | NEW |