diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 01:51:45 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 01:51:45 +0000 |
commit | ecbf289873708bcbaa35780063570e346faafd57 (patch) | |
tree | 524953253f35fb0c095f90aaff16a6103b5e8a18 /chrome/browser/keychain_mock_mac.cc | |
parent | d5975c6b5d408767db7934347b7d4d137c657d30 (diff) | |
download | chromium_src-ecbf289873708bcbaa35780063570e346faafd57.zip chromium_src-ecbf289873708bcbaa35780063570e346faafd57.tar.gz chromium_src-ecbf289873708bcbaa35780063570e346faafd57.tar.bz2 |
AutoFill credit cards should be encrypted on the Mac
These changes add encryption support on Mac for the Encryptor class. AES 128 bit is used for the encryption, and the auto-generated password is stored now in the Mac Keychain. This implies the Encryptor class on Mac can now block for user input, and can fail if access is denied.
BUG=42038, 49131
TEST=EncryptorTest.CypherTextDiffers, EncryptorTest.DecryptError, EncryptorPasswordTest.*
Review URL: http://codereview.chromium.org/2943014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/keychain_mock_mac.cc')
-rw-r--r-- | chrome/browser/keychain_mock_mac.cc | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/chrome/browser/keychain_mock_mac.cc b/chrome/browser/keychain_mock_mac.cc index 879ffdc..3114863 100644 --- a/chrome/browser/keychain_mock_mac.cc +++ b/chrome/browser/keychain_mock_mac.cc @@ -8,7 +8,9 @@ MockKeychain::MockKeychain(unsigned int item_capacity) : item_capacity_(item_capacity), item_count_(0), search_copy_count_(0), - keychain_item_copy_count_(0), attribute_data_copy_count_(0) { + keychain_item_copy_count_(0), attribute_data_copy_count_(0), + find_generic_result_(noErr), called_add_generic_(false), + password_data_count_(0) { UInt32 tags[] = { kSecAccountItemAttr, kSecServerItemAttr, kSecPortItemAttr, @@ -334,6 +336,54 @@ OSStatus MockKeychain::SearchCopyNext(SecKeychainSearchRef searchRef, return noErr; } +OSStatus MockKeychain::FindGenericPassword(CFTypeRef keychainOrArray, + UInt32 serviceNameLength, + const char *serviceName, + UInt32 accountNameLength, + const char *accountName, + UInt32 *passwordLength, + void **passwordData, + SecKeychainItemRef *itemRef) const { + // When simulating |noErr| we return canned |passwordData| and + // |passwordLenght|. Otherwise, just return given code. + if (find_generic_result_ == noErr) { + static char password[] = "my_password"; + + DCHECK(passwordData); + *passwordData = static_cast<void*>(password); + DCHECK(passwordLength); + *passwordLength = strlen(password); + password_data_count_++; + } + + return find_generic_result_; +} + +OSStatus MockKeychain::ItemFreeContent(SecKeychainAttributeList *attrList, + void *data) const { + // No-op. + password_data_count_--; + return noErr; +} + +OSStatus MockKeychain::AddGenericPassword(SecKeychainRef keychain, + UInt32 serviceNameLength, + const char *serviceName, + UInt32 accountNameLength, + const char *accountName, + UInt32 passwordLength, + const void *passwordData, + SecKeychainItemRef *itemRef) const { + called_add_generic_ = true; + + DCHECK(passwordLength > 0); + DCHECK(passwordData); + add_generic_password_ = + std::string(const_cast<char*>(static_cast<const char*>(passwordData)), + passwordLength); + return noErr; +} + void MockKeychain::Free(CFTypeRef ref) const { if (!ref) { return; |