Commit b90decf7 authored by rockot's avatar rockot Committed by Commit bot

Revert of Minor cleanup in EasyUnlockClient (patchset #2 id:20001 of...

Revert of Minor cleanup in EasyUnlockClient (patchset #2 id:20001 of https://codereview.chromium.org/569813002/)

Reason for revert:
Looks like some ChromeOS code was missed here; it's unclear why bots didn't catch this.

Original issue's description:
> Minor cleanup in EasyUnlockClient
>
> * arg names in GenerateEcP256KeyPairCallback typedef were reversed
> * Make CreateSecureMEssage and UnwrapSecureMessage take structs (instead
> of having long list of arguments)
>
> BUG=None
> TEST=existing unittests
>
> Committed: https://crrev.com/35e3a9c7061205db58f57182f5ba5eb87be0f355
> Cr-Commit-Position: refs/heads/master@{#294954}

TBR=stevenjb@chromium.org,isherman@chromium.org,tbarzic@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=None

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

Cr-Commit-Position: refs/heads/master@{#294968}
parent 7427e6aa
......@@ -263,7 +263,8 @@ bool EasyUnlockPrivatePerformECDHKeyAgreementFunction::RunAsync() {
EXTENSION_FUNCTION_VALIDATE(params);
GetCryptoDelegate(browser_context())->PerformECDHKeyAgreement(
*params,
params->private_key,
params->public_key,
base::Bind(&EasyUnlockPrivatePerformECDHKeyAgreementFunction::OnData,
this));
return true;
......@@ -315,7 +316,18 @@ bool EasyUnlockPrivateCreateSecureMessageFunction::RunAsync() {
EXTENSION_FUNCTION_VALIDATE(params);
GetCryptoDelegate(browser_context())->CreateSecureMessage(
*params,
params->payload,
params->key,
params->options.associated_data ?
*params->options.associated_data : std::string(),
params->options.public_metadata ?
*params->options.public_metadata : std::string(),
params->options.verification_key_id ?
*params->options.verification_key_id : std::string(),
params->options.decryption_key_id ?
*params->options.decryption_key_id : std::string(),
params->options.encrypt_type,
params->options.sign_type,
base::Bind(&EasyUnlockPrivateCreateSecureMessageFunction::OnData,
this));
return true;
......@@ -343,7 +355,12 @@ bool EasyUnlockPrivateUnwrapSecureMessageFunction::RunAsync() {
EXTENSION_FUNCTION_VALIDATE(params);
GetCryptoDelegate(browser_context())->UnwrapSecureMessage(
*params,
params->secure_message,
params->key,
params->options.associated_data ?
*params->options.associated_data : std::string(),
params->options.encrypt_type,
params->options.sign_type,
base::Bind(&EasyUnlockPrivateUnwrapSecureMessageFunction::OnData,
this));
return true;
......
......@@ -166,19 +166,16 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) {
new EasyUnlockPrivateCreateSecureMessageFunction());
function->set_has_callback(true);
chromeos::EasyUnlockClient::CreateSecureMessageOptions create_options;
create_options.key = "KEY";
create_options.associated_data = "ASSOCIATED_DATA";
create_options.public_metadata = "PUBLIC_METADATA";
create_options.verification_key_id = "VERIFICATION_KEY_ID";
create_options.decryption_key_id = "DECRYPTION_KEY_ID";
create_options.encryption_type = easy_unlock::kEncryptionTypeAES256CBC;
create_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
std::string expected_result;
client_->CreateSecureMessage(
"PAYLOAD",
create_options,
"KEY",
"ASSOCIATED_DATA",
"PUBLIC_METADATA",
"VERIFICATION_KEY_ID",
"DECRYPTION_KEY_ID",
easy_unlock::kEncryptionTypeAES256CBC,
easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result));
ASSERT_GT(expected_result.length(), 0u);
......@@ -214,15 +211,16 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_EmptyOptions) {
new EasyUnlockPrivateCreateSecureMessageFunction());
function->set_has_callback(true);
chromeos::EasyUnlockClient::CreateSecureMessageOptions create_options;
create_options.key = "KEY";
create_options.encryption_type = easy_unlock::kEncryptionTypeNone;
create_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
std::string expected_result;
client_->CreateSecureMessage(
"PAYLOAD",
create_options,
"KEY",
"", // associated data
"", // public metadata
"", // verification key id
"", // decryption key id
easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result));
ASSERT_GT(expected_result.length(), 0u);
......@@ -246,17 +244,16 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_AsymmetricSign) {
new EasyUnlockPrivateCreateSecureMessageFunction());
function->set_has_callback(true);
chromeos::EasyUnlockClient::CreateSecureMessageOptions create_options;
create_options.key = "KEY";
create_options.associated_data = "ASSOCIATED_DATA";
create_options.verification_key_id = "VERIFICATION_KEY_ID";
create_options.encryption_type = easy_unlock::kEncryptionTypeNone;
create_options.signature_type = easy_unlock::kSignatureTypeECDSAP256SHA256;
std::string expected_result;
client_->CreateSecureMessage(
"PAYLOAD",
create_options,
"KEY",
"ASSOCIATED_DATA",
"", // public metadata
"VERIFICATION_KEY_ID",
"", // decryption key id
easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeECDSAP256SHA256,
base::Bind(&CopyData, &expected_result));
ASSERT_GT(expected_result.length(), 0u);
......@@ -287,21 +284,18 @@ TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage) {
new EasyUnlockPrivateUnwrapSecureMessageFunction());
function->set_has_callback(true);
chromeos::EasyUnlockClient::UnwrapSecureMessageOptions unwrap_options;
unwrap_options.key = "KEY";
unwrap_options.associated_data = "ASSOCIATED_DATA";
unwrap_options.encryption_type = easy_unlock::kEncryptionTypeAES256CBC;
unwrap_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
std::string expected_result;
client_->UnwrapSecureMessage(
"MESSAGE",
unwrap_options,
"PAYLOAD",
"KEY",
"ASSOCIATED_DATA",
easy_unlock::kEncryptionTypeAES256CBC,
easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result));
ASSERT_GT(expected_result.length(), 0u);
scoped_ptr<base::ListValue> args(new base::ListValue);
args->Append(StringToBinaryValue("MESSAGE"));
args->Append(StringToBinaryValue("PAYLOAD"));
args->Append(StringToBinaryValue("KEY"));
base::DictionaryValue* options = new base::DictionaryValue();
args->Append(options);
......@@ -327,15 +321,13 @@ TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_EmptyOptions) {
new EasyUnlockPrivateUnwrapSecureMessageFunction());
function->set_has_callback(true);
chromeos::EasyUnlockClient::UnwrapSecureMessageOptions unwrap_options;
unwrap_options.key = "KEY";
unwrap_options.encryption_type = easy_unlock::kEncryptionTypeNone;
unwrap_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
std::string expected_result;
client_->UnwrapSecureMessage(
"MESSAGE",
unwrap_options,
"KEY",
"", // associated data
easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result));
ASSERT_GT(expected_result.length(), 0u);
......@@ -359,16 +351,13 @@ TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_AsymmetricSign) {
new EasyUnlockPrivateUnwrapSecureMessageFunction());
function->set_has_callback(true);
chromeos::EasyUnlockClient::UnwrapSecureMessageOptions unwrap_options;
unwrap_options.key = "KEY";
unwrap_options.associated_data = "ASSOCIATED_DATA";
unwrap_options.encryption_type = easy_unlock::kEncryptionTypeNone;
unwrap_options.signature_type = easy_unlock::kSignatureTypeECDSAP256SHA256;
std::string expected_result;
client_->UnwrapSecureMessage(
"MESSAGE",
unwrap_options,
"KEY",
"ASSOCIATED_DATA",
easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeECDSAP256SHA256,
base::Bind(&CopyData, &expected_result));
ASSERT_GT(expected_result.length(), 0u);
......
......@@ -14,9 +14,8 @@
namespace extensions {
namespace api {
// Wrapper around EasyUnlock dbus client on Chrome OS. The methods read
// extension function pearameters and invoke the associated EasyUnlock dbus
// client methods. On non-Chrome OS platforms, the methods are stubbed out.
// Wrapper around EasyUnlock dbus client on ChromeOS. On other platforms, the
// methods are stubbed out.
class EasyUnlockPrivateCryptoDelegate {
public:
typedef base::Callback<void(const std::string& data)> DataCallback;
......@@ -33,14 +32,25 @@ class EasyUnlockPrivateCryptoDelegate {
// See chromeos/dbus/easy_unlock_client.h for info on these methods.
virtual void GenerateEcP256KeyPair(const KeyPairCallback& callback) = 0;
virtual void PerformECDHKeyAgreement(
const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
virtual void PerformECDHKeyAgreement(const std::string& private_key,
const std::string& public_key,
const DataCallback& callback) = 0;
virtual void CreateSecureMessage(
const easy_unlock_private::CreateSecureMessage::Params& params,
const std::string& payload,
const std::string& secret_key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) = 0;
virtual void UnwrapSecureMessage(
const easy_unlock_private::UnwrapSecureMessage::Params& params,
const std::string& message,
const std::string& secret_key,
const std::string& associated_data,
easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) = 0;
};
......
......@@ -52,49 +52,46 @@ class EasyUnlockPrivateCryptoDelegateChromeOS
dbus_client_->GenerateEcP256KeyPair(callback);
}
virtual void PerformECDHKeyAgreement(
const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
virtual void PerformECDHKeyAgreement(const std::string& private_key,
const std::string& public_key,
const DataCallback& callback) OVERRIDE {
dbus_client_->PerformECDHKeyAgreement(
params.private_key,
params.public_key,
callback);
dbus_client_->PerformECDHKeyAgreement(private_key, public_key, callback);
}
virtual void CreateSecureMessage(
const easy_unlock_private::CreateSecureMessage::Params& params,
const std::string& payload,
const std::string& key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) OVERRIDE {
chromeos::EasyUnlockClient::CreateSecureMessageOptions options;
options.key = params.key;
if (params.options.associated_data)
options.associated_data = *params.options.associated_data;
if (params.options.public_metadata)
options.public_metadata = *params.options.public_metadata;
if (params.options.verification_key_id)
options.verification_key_id = *params.options.verification_key_id;
if (params.options.decryption_key_id)
options.decryption_key_id = *params.options.decryption_key_id;
options.encryption_type =
EncryptionTypeToString(params.options.encrypt_type);
options.signature_type =
SignatureTypeToString(params.options.sign_type);
dbus_client_->CreateSecureMessage(params.payload, options, callback);
dbus_client_->CreateSecureMessage(payload,
key,
associated_data,
public_metadata,
verification_key_id,
decryption_key_id,
EncryptionTypeToString(encryption_type),
SignatureTypeToString(signature_type),
callback);
}
virtual void UnwrapSecureMessage(
const easy_unlock_private::UnwrapSecureMessage::Params& params,
const std::string& message,
const std::string& key,
const std::string& associated_data,
easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) OVERRIDE {
chromeos::EasyUnlockClient::UnwrapSecureMessageOptions options;
options.key = params.key;
if (params.options.associated_data)
options.associated_data = *params.options.associated_data;
options.encryption_type =
EncryptionTypeToString(params.options.encrypt_type);
options.signature_type =
SignatureTypeToString(params.options.sign_type);
dbus_client_->UnwrapSecureMessage(params.secure_message, options, callback);
dbus_client_->UnwrapSecureMessage(message,
key,
associated_data,
EncryptionTypeToString(encryption_type),
SignatureTypeToString(signature_type),
callback);
}
private:
......
......@@ -21,20 +21,31 @@ class EasyUnlockPrivateCryptoDelegateStub
callback.Run("", "");
}
virtual void PerformECDHKeyAgreement(
const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
virtual void PerformECDHKeyAgreement(const std::string& private_key,
const std::string& public_key,
const DataCallback& callback) OVERRIDE {
callback.Run("");
}
virtual void CreateSecureMessage(
const easy_unlock_private::CreateSecureMessage::Params& params,
const std::string& payload,
const std::string& key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) OVERRIDE {
callback.Run("");
}
virtual void UnwrapSecureMessage(
const easy_unlock_private::UnwrapSecureMessage::Params& params,
const std::string& message,
const std::string& key,
const std::string& associated_data,
easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) OVERRIDE {
callback.Run("");
}
......
......@@ -74,7 +74,13 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
// EasyUnlockClient override.
virtual void CreateSecureMessage(const std::string& payload,
const CreateSecureMessageOptions& options,
const std::string& secret_key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) OVERRIDE {
dbus::MethodCall method_call(
easy_unlock::kEasyUnlockServiceInterface,
......@@ -83,13 +89,13 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
// NOTE: DBus expects that data sent as string is UTF-8 encoded. This is
// not guaranteed here, so the method uses byte arrays.
AppendStringAsByteArray(payload, &writer);
AppendStringAsByteArray(options.key, &writer);
AppendStringAsByteArray(options.associated_data, &writer);
AppendStringAsByteArray(options.public_metadata, &writer);
AppendStringAsByteArray(options.verification_key_id, &writer);
AppendStringAsByteArray(options.decryption_key_id, &writer);
writer.AppendString(options.encryption_type);
writer.AppendString(options.signature_type);
AppendStringAsByteArray(secret_key, &writer);
AppendStringAsByteArray(associated_data, &writer);
AppendStringAsByteArray(public_metadata, &writer);
AppendStringAsByteArray(verification_key_id, &writer);
AppendStringAsByteArray(decryption_key_id, &writer);
writer.AppendString(encryption_type);
writer.AppendString(signature_type);
proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&EasyUnlockClientImpl::OnData,
weak_ptr_factory_.GetWeakPtr(),
......@@ -98,7 +104,10 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
// EasyUnlockClient override.
virtual void UnwrapSecureMessage(const std::string& message,
const UnwrapSecureMessageOptions& options,
const std::string& secret_key,
const std::string& associated_data,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) OVERRIDE {
dbus::MethodCall method_call(
easy_unlock::kEasyUnlockServiceInterface,
......@@ -107,10 +116,10 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
// NOTE: DBus expects that data sent as string is UTF-8 encoded. This is
// not guaranteed here, so the method uses byte arrays.
AppendStringAsByteArray(message, &writer);
AppendStringAsByteArray(options.key, &writer);
AppendStringAsByteArray(options.associated_data, &writer);
writer.AppendString(options.encryption_type);
writer.AppendString(options.signature_type);
AppendStringAsByteArray(secret_key, &writer);
AppendStringAsByteArray(associated_data, &writer);
writer.AppendString(encryption_type);
writer.AppendString(signature_type);
proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&EasyUnlockClientImpl::OnData,
weak_ptr_factory_.GetWeakPtr(),
......@@ -165,14 +174,6 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
} // namespace
EasyUnlockClient::CreateSecureMessageOptions::CreateSecureMessageOptions() {}
EasyUnlockClient::CreateSecureMessageOptions::~CreateSecureMessageOptions() {}
EasyUnlockClient::UnwrapSecureMessageOptions::UnwrapSecureMessageOptions() {}
EasyUnlockClient::UnwrapSecureMessageOptions::~UnwrapSecureMessageOptions() {}
EasyUnlockClient::EasyUnlockClient() {
}
......
......@@ -30,74 +30,15 @@ class CHROMEOS_EXPORT EasyUnlockClient : public DBusClient {
typedef base::Callback<void(const std::string& data)> DataCallback;
// Callback for |GenerateEcP256KeyPair|. Carries the generated keys.
typedef base::Callback<void(const std::string& private_key,
const std::string& public_key)>
// Callback for |GenerateEcP256KeyAgreement|. Carries the generated keys.
typedef base::Callback<void(const std::string& public_key,
const std::string& private_key)>
KeyPairCallback;
// Generates ECDSA key pair using P256 curve.
// The created keys should only be used with this client.
virtual void GenerateEcP256KeyPair(const KeyPairCallback& callback) = 0;
// Parameters used to create a secure message.
struct CreateSecureMessageOptions {
CreateSecureMessageOptions();
~CreateSecureMessageOptions();
// The key used to sign, and if needed, encrypt the message. If encryption
// is required, the key must be symetric.
std::string key;
// Data associated with the message. The data will not actually be added to
// the message, but it will be used while signing the message (the receiver
// will use the same data to authenticate the signature).
std::string associated_data;
// Metadata added to the message header.
std::string public_metadata;
// The key id added to the message header. Has to be set if the message is
// signed with private asymetric key. This value is used by the receiver to
// identify the key that should be used to verify the signature.
std::string verification_key_id;
// Key id added to the message header. Used by the message receiver to
// identify the key that should be used to decrypt the message.
std::string decryption_key_id;
// The encryption algorithm to use for encrypting the message.
std::string encryption_type;
// The algorithm to use to sign the message.
std::string signature_type;
private:
DISALLOW_COPY_AND_ASSIGN(CreateSecureMessageOptions);
};
// Parameters used to unwrap a securemessage.
struct UnwrapSecureMessageOptions {
UnwrapSecureMessageOptions();
~UnwrapSecureMessageOptions();
// The key used to authenticate message signature and, if needed, decrypt
// the message. If the message is encrypted, only symetric key can be used.
std::string key;
// Data associated with the message. Message authentication will succeed
// only if the message was created with the same associated data.
std::string associated_data;
// The encryption algorithm to use for decrypting the message.
std::string encryption_type;
// The algorithm that should be used to verify the message signature.
std::string signature_type;
private:
DISALLOW_COPY_AND_ASSIGN(UnwrapSecureMessageOptions);
};
// Given a private and a public key, creates a symetric secret key using
// EC Diffe-Hellman key exchange. The provided keys come from different
// asymetric key pairs, and are expected to be in the same format as the ones
......@@ -110,22 +51,55 @@ class CHROMEOS_EXPORT EasyUnlockClient : public DBusClient {
// Creates signed and, if specified, encrypted message in format used by Easy
// Unlock.
// |payload|: The cleartext message body.
// |options|: The message parameters used for creating the secure message.
// |key|: The key used to sign, and if needed, encrypt the message. If
// encryption is required, the key must be symetric.
// |associated_data|: Data associated with the message. The data will not
// actually be added to the message, but it will be used while
// signing the message (the receiver will use the same data to
// authenticate the signature).
// |public_metadata|: Metadata added to the message header.
// |verification_key_id|: The key id added to the message header. Has to be
// set if the message is signed with private asymetric key. This value
// is used by the receiver to identify the public key that should be used
// to verify the signature.
// |decryption_key_id|: Key id added to the message header. Used by the
// message receiver to identify the key that should be used to decrypt
// the message.
// |encryption_type|: The encryption algorithm to use for encrypting the
// message. (May be set to none).
// |signature_type|: The algorithm to use to sign the message.
// |callback|: Called with the created message. On failure, the message will
// be empty.
virtual void CreateSecureMessage(const std::string& payload,
const CreateSecureMessageOptions& options,
const std::string& secret_key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) = 0;
// Authenticates and, if specified, decrypts a secure message.
// |message|: The message to unwrap. It is in the same format as the message
// returned by |CreateSecureMessage|.
// |options|: The parameters that should be used to unwrap the message.
// |key|: The key used to authenticate message signature and, if needed,
// decrypt the message. If the message is encrypted, only symetric key
// can be used.
// |associated_data|: Data associated with the message. Message
// authentication will succeed only if the message was created with the
// associated data.
// |encryption_type|: The encryption algorithm to use for decrypting the
// message. (May be set to none).
// |signature_type|: The algorithm to use to verify the message signature.
// |callback|: Called with the cleartext message header and body in a signle
// protobuf. If the message could not be authenticated or decrypted, it
// will be called with an empty string.
virtual void UnwrapSecureMessage(const std::string& message,
const UnwrapSecureMessageOptions& options,
const std::string& secret_key,
const std::string& associated_data,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) = 0;
// Factory function, creates a new instance and returns ownership.
......
......@@ -95,7 +95,13 @@ void FakeEasyUnlockClient::PerformECDHKeyAgreement(
void FakeEasyUnlockClient::CreateSecureMessage(
const std::string& payload,
const CreateSecureMessageOptions& options,
const std::string& key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) {
callback.Run(base::StringPrintf(
"{\"securemessage\": {"
......@@ -109,18 +115,21 @@ void FakeEasyUnlockClient::CreateSecureMessage(
"\"signature_type\": \"%s\""
"}}",
payload.c_str(),
options.key.c_str(),
options.associated_data.c_str(),
options.public_metadata.c_str(),
options.verification_key_id.c_str(),
options.decryption_key_id.c_str(),
options.encryption_type.c_str(),
options.signature_type.c_str()));
key.c_str(),
associated_data.c_str(),
public_metadata.c_str(),
verification_key_id.c_str(),
decryption_key_id.c_str(),
encryption_type.c_str(),
signature_type.c_str()));
}
void FakeEasyUnlockClient::UnwrapSecureMessage(
const std::string& message,
const UnwrapSecureMessageOptions& options,
const std::string& key,
const std::string& associated_data,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) {
// TODO(tbarzic): Verify that |message| is in the format returned by
// |CreateSecureMessage| and extract payload, metadata and
......@@ -134,10 +143,10 @@ void FakeEasyUnlockClient::UnwrapSecureMessage(
"\"signature_type\": \"%s\""
"}}",
message.c_str(),
options.key.c_str(),
options.associated_data.c_str(),
options.encryption_type.c_str(),
options.signature_type.c_str()));
key.c_str(),
associated_data.c_str(),
encryption_type.c_str(),
signature_type.c_str()));
}
} // namespace chromeos
......@@ -29,10 +29,19 @@ class CHROMEOS_EXPORT FakeEasyUnlockClient : public EasyUnlockClient {
const std::string& public_key,
const DataCallback& callback) OVERRIDE;
virtual void CreateSecureMessage(const std::string& payload,
const CreateSecureMessageOptions& options,
const std::string& key,
const std::string& associated_data,
const std::string& public_metadata,
const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) OVERRIDE;
virtual void UnwrapSecureMessage(const std::string& message,
const UnwrapSecureMessageOptions& options,
const std::string& key,
const std::string& associated_data,
const std::string& encryption_type,
const std::string& signature_type,
const DataCallback& callback) OVERRIDE;
private:
......
......@@ -203,19 +203,15 @@ TEST(FakeEasyUnlockClientTest, CreateSecureMessage) {
chromeos::FakeEasyUnlockClient client;
std::string message;
chromeos::EasyUnlockClient::CreateSecureMessageOptions options;
options.key = "KEY";
options.associated_data = "ASSOCIATED_DATA";
options.public_metadata = "PUBLIC_METADATA";
options.verification_key_id = "VERIFICATION_KEY_ID";
options.decryption_key_id = "DECRYPTION_KEY_ID";
options.encryption_type = "ENCRYPTION_TYPE";
options.signature_type = "SIGNATURE_TYPE";
client.CreateSecureMessage(
"PAYLOAD",
options,
"KEY",
"ASSOCIATED_DATA",
"PUBLIC_METADATA",
"VERIFICATION_KEY_ID",
"DECRYPTION_KEY_ID",
"ENCRYPTION_TYPE",
"SIGNATURE_TYPE",
base::Bind(&RecordData, &message));
const std::string expected_message(
......@@ -236,16 +232,12 @@ TEST(FakeEasyUnlockClientTest, UnwrapSecureMessage) {
chromeos::FakeEasyUnlockClient client;
std::string message;
chromeos::EasyUnlockClient::UnwrapSecureMessageOptions options;
options.key = "KEY";
options.associated_data = "ASSOCIATED_DATA";
options.encryption_type = "ENCRYPTION_TYPE";
options.signature_type = "SIGNATURE_TYPE";
client.UnwrapSecureMessage(
"MESSAGE",
options,
"KEY",
"ASSOCIATED_DATA",
"ENCRYPTION_TYPE",
"SIGNATURE_TYPE",
base::Bind(&RecordData, &message));
const std::string expected_message(
......
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