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

Side by Side Diff: components/os_crypt/os_crypt_mac.mm

Issue 2095523002: Make //crypto factories return std::unique_ptr<>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I'm blind Created 4 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 | « components/crx_file/crx_file.cc ('k') | content/browser/download/base_file.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/os_crypt/os_crypt.h" 5 #include "components/os_crypt/os_crypt.h"
6 6
7 #include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128 7 #include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // returning. 70 // returning.
71 key_is_cached = true; 71 key_is_cached = true;
72 72
73 if (password.empty()) 73 if (password.empty())
74 return cached_encryption_key; 74 return cached_encryption_key;
75 75
76 std::string salt(kSalt); 76 std::string salt(kSalt);
77 77
78 // Create an encryption key from our password and salt. The key is 78 // Create an encryption key from our password and salt. The key is
79 // intentionally leaked. 79 // intentionally leaked.
80 cached_encryption_key = 80 cached_encryption_key = crypto::SymmetricKey::DeriveKeyFromPassword(
81 crypto::SymmetricKey::DeriveKeyFromPassword(crypto::SymmetricKey::AES, 81 crypto::SymmetricKey::AES, password, salt,
82 password, 82 kEncryptionIterations, kDerivedKeySizeInBits)
83 salt, 83 .release();
84 kEncryptionIterations,
85 kDerivedKeySizeInBits);
86 ANNOTATE_LEAKING_OBJECT_PTR(cached_encryption_key); 84 ANNOTATE_LEAKING_OBJECT_PTR(cached_encryption_key);
87 DCHECK(cached_encryption_key); 85 DCHECK(cached_encryption_key);
88 return cached_encryption_key; 86 return cached_encryption_key;
89 } 87 }
90 88
91 } // namespace 89 } // namespace
92 90
93 bool OSCrypt::EncryptString16(const base::string16& plaintext, 91 bool OSCrypt::EncryptString16(const base::string16& plaintext,
94 std::string* ciphertext) { 92 std::string* ciphertext) {
95 return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext); 93 return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (!encryptor.Decrypt(raw_ciphertext, plaintext)) 160 if (!encryptor.Decrypt(raw_ciphertext, plaintext))
163 return false; 161 return false;
164 162
165 return true; 163 return true;
166 } 164 }
167 165
168 void OSCrypt::UseMockKeychain(bool use_mock) { 166 void OSCrypt::UseMockKeychain(bool use_mock) {
169 use_mock_keychain = use_mock; 167 use_mock_keychain = use_mock;
170 } 168 }
171 169
OLDNEW
« no previous file with comments | « components/crx_file/crx_file.cc ('k') | content/browser/download/base_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698