Commit 37e866f4 authored by bartfab's avatar bartfab Committed by Commit bot

Make CryptohomeAuthenticator's Login*() methods work with pre-hashed keys

When a user's cryptohome directory is created with a pre-hashed key,
the credentials provided need to be hashed in the same way whenever the
crypthome is to be unlocked/mounted. This CL updates the Login*() methods
in CryptohomeAuthenticator to retrieve key metadata and apply the correct
hashing algorithm to the given credentials. Follow-up CLs will update
the other CryptohomeAuthenticator methods to also work with pre-hashed
keys.

BUG=367847
TEST=Extended unit tests

Review URL: https://codereview.chromium.org/517653002

Cr-Commit-Position: refs/heads/master@{#293227}
parent 8d054025
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chromeos/cryptohome/mock_homedir_methods.h" #include "chromeos/cryptohome/mock_homedir_methods.h"
#include "base/memory/scoped_vector.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/cryptohome/mock_async_method_caller.h" #include "chromeos/cryptohome/mock_async_method_caller.h"
using ::testing::Invoke; using ::testing::Invoke;
...@@ -20,6 +22,8 @@ MockHomedirMethods::~MockHomedirMethods() {} ...@@ -20,6 +22,8 @@ MockHomedirMethods::~MockHomedirMethods() {}
void MockHomedirMethods::SetUp(bool success, MountError return_code) { void MockHomedirMethods::SetUp(bool success, MountError return_code) {
success_ = success; success_ = success;
return_code_ = return_code; return_code_ = return_code;
ON_CALL(*this, GetKeyDataEx(_, _, _)).WillByDefault(
WithArgs<2>(Invoke(this, &MockHomedirMethods::DoGetDataCallback)));
ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault( ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault(
WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback))); WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback)));
ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault( ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault(
...@@ -36,6 +40,10 @@ void MockHomedirMethods::DoCallback(const Callback& callback) { ...@@ -36,6 +40,10 @@ void MockHomedirMethods::DoCallback(const Callback& callback) {
callback.Run(success_, return_code_); callback.Run(success_, return_code_);
} }
void MockHomedirMethods::DoGetDataCallback(const GetKeyDataCallback& callback) {
callback.Run(success_, return_code_, ScopedVector<RetrievedKeyData>());
}
void MockHomedirMethods::DoMountCallback(const MountCallback& callback) { void MockHomedirMethods::DoMountCallback(const MountCallback& callback) {
callback.Run( callback.Run(
success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername); success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername);
......
...@@ -57,6 +57,7 @@ class CHROMEOS_EXPORT MockHomedirMethods : public HomedirMethods { ...@@ -57,6 +57,7 @@ class CHROMEOS_EXPORT MockHomedirMethods : public HomedirMethods {
MountError return_code_; MountError return_code_;
void DoCallback(const Callback& callback); void DoCallback(const Callback& callback);
void DoGetDataCallback(const GetKeyDataCallback& callback);
void DoMountCallback(const MountCallback& callback); void DoMountCallback(const MountCallback& callback);
DISALLOW_COPY_AND_ASSIGN(MockHomedirMethods); DISALLOW_COPY_AND_ASSIGN(MockHomedirMethods);
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include <string> #include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/task_runner.h" #include "base/task_runner.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment