forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OSCrypt] Add feature for preventing key overwrites in Keychain on Mac
This Cl includes: - Add a feature flag which is disabled by default. - Include key creation utility to prevent key overwrites in KeychainPassword::GetPassword(). - Add tests for the above changes. - Register the local state early from the main thread in os_crypt. Bug: 791541 Change-Id: I2a664cd285fe73b32a15b2949977b940d95e7bbe Reviewed-on: https://chromium-review.googlesource.com/1188318 Commit-Queue: Tonko Sabolčec <[email protected]> Reviewed-by: Christos Froussios <[email protected]> Reviewed-by: Dominic Battré <[email protected]> Reviewed-by: Robert Sesek <[email protected]> Reviewed-by: Vasilii Sukhanov <[email protected]> Cr-Commit-Position: refs/heads/master@{#589898}
- Loading branch information
Showing
16 changed files
with
508 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_OS_CRYPT_ENCRYPTION_KEY_CREATION_UTIL_H_ | ||
#define COMPONENTS_OS_CRYPT_ENCRYPTION_KEY_CREATION_UTIL_H_ | ||
|
||
#include "base/component_export.h" | ||
|
||
namespace os_crypt { | ||
|
||
// An interface for the utility that prevents overwriting the encryption key on | ||
// Mac. | ||
// This class is used on Mac and iOS, but does nothing on iOS as the feature | ||
// for preventing key overwrites is available only on Mac. The object for | ||
// the Mac class has to be created on the main thread. | ||
class EncryptionKeyCreationUtil { | ||
public: | ||
virtual ~EncryptionKeyCreationUtil() = default; | ||
|
||
// Returns true iff the key should already exists on Mac and false on iOS. | ||
// This method doesn't need to be called from the main thread. | ||
virtual bool KeyAlreadyCreated() = 0; | ||
|
||
// Returns true iff the feature for preventing key overwrites is enabled on | ||
// Mac and false on iOS. This method doesn't need to be called from the main | ||
// thread. | ||
virtual bool ShouldPreventOverwriting() = 0; | ||
|
||
// This asynchronously updates the preference on the main thread that the key | ||
// was created. This method is called when key is added to the Keychain, or | ||
// the first time the key is successfully retrieved from the Keychain and the | ||
// preference hasn't been set yet. This method doesn't need to be called on | ||
// the main thread. | ||
virtual void OnKeyWasStored() = 0; | ||
}; | ||
|
||
} // namespace os_crypt | ||
|
||
#endif // COMPONENTS_OS_CRYPT_ENCRYPTION_KEY_CREATION_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/os_crypt/encryption_key_creation_util_ios.h" | ||
|
||
namespace os_crypt { | ||
|
||
EncryptionKeyCreationUtilIOS::EncryptionKeyCreationUtilIOS() = default; | ||
|
||
EncryptionKeyCreationUtilIOS::~EncryptionKeyCreationUtilIOS() = default; | ||
|
||
bool EncryptionKeyCreationUtilIOS::KeyAlreadyCreated() { | ||
return false; | ||
} | ||
|
||
bool EncryptionKeyCreationUtilIOS::ShouldPreventOverwriting() { | ||
return false; | ||
} | ||
|
||
void EncryptionKeyCreationUtilIOS::OnKeyWasStored() {} | ||
|
||
} // namespace os_crypt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_OS_CRYPT_ENCRYPTION_KEY_CREATION_UTIL_IOS_H_ | ||
#define COMPONENTS_OS_CRYPT_ENCRYPTION_KEY_CREATION_UTIL_IOS_H_ | ||
|
||
#include "base/component_export.h" | ||
#include "base/macros.h" | ||
#include "components/os_crypt/encryption_key_creation_util.h" | ||
|
||
namespace os_crypt { | ||
|
||
// A key creation utility for iOS which does nothing as there is no feature | ||
// for preventing key overwrites for iOS. | ||
class COMPONENT_EXPORT(OS_CRYPT) EncryptionKeyCreationUtilIOS | ||
: public EncryptionKeyCreationUtil { | ||
public: | ||
EncryptionKeyCreationUtilIOS(); | ||
~EncryptionKeyCreationUtilIOS() override; | ||
|
||
// Returns false. | ||
bool KeyAlreadyCreated() override; | ||
|
||
// Returns false. | ||
bool ShouldPreventOverwriting() override; | ||
|
||
// Does nothing. | ||
void OnKeyWasStored() override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(EncryptionKeyCreationUtilIOS); | ||
}; | ||
|
||
} // namespace os_crypt | ||
|
||
#endif // COMPONENTS_OS_CRYPT_ENCRYPTION_KEY_CREATION_UTIL_IOS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.