Commit 042e34f6 authored by tbarzic's avatar tbarzic Committed by Commit bot

Add ability to pass decryption key id to CreateSecureMessage method

This should enable the message receiver to identify a key to be used for
message decryption.

BUG=409099

(depends on https://codereview.chromium.org/513013003/)

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

Cr-Commit-Position: refs/heads/master@{#293006}
parent dad38738
...@@ -324,6 +324,8 @@ bool EasyUnlockPrivateCreateSecureMessageFunction::RunAsync() { ...@@ -324,6 +324,8 @@ bool EasyUnlockPrivateCreateSecureMessageFunction::RunAsync() {
*params->options.public_metadata : std::string(), *params->options.public_metadata : std::string(),
params->options.verification_key_id ? params->options.verification_key_id ?
*params->options.verification_key_id : std::string(), *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.encrypt_type,
params->options.sign_type, params->options.sign_type,
base::Bind(&EasyUnlockPrivateCreateSecureMessageFunction::OnData, base::Bind(&EasyUnlockPrivateCreateSecureMessageFunction::OnData,
......
...@@ -173,6 +173,7 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) { ...@@ -173,6 +173,7 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) {
"ASSOCIATED_DATA", "ASSOCIATED_DATA",
"PUBLIC_METADATA", "PUBLIC_METADATA",
"VERIFICATION_KEY_ID", "VERIFICATION_KEY_ID",
"DECRYPTION_KEY_ID",
easy_unlock::kEncryptionTypeAES256CBC, easy_unlock::kEncryptionTypeAES256CBC,
easy_unlock::kSignatureTypeHMACSHA256, easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result)); base::Bind(&CopyData, &expected_result));
...@@ -187,6 +188,8 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) { ...@@ -187,6 +188,8 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) {
options->Set("publicMetadata", StringToBinaryValue("PUBLIC_METADATA")); options->Set("publicMetadata", StringToBinaryValue("PUBLIC_METADATA"));
options->Set("verificationKeyId", options->Set("verificationKeyId",
StringToBinaryValue("VERIFICATION_KEY_ID")); StringToBinaryValue("VERIFICATION_KEY_ID"));
options->Set("decryptionKeyId",
StringToBinaryValue("DECRYPTION_KEY_ID"));
options->SetString( options->SetString(
"encryptType", "encryptType",
api::ToString(api::ENCRYPTION_TYPE_AES_256_CBC)); api::ToString(api::ENCRYPTION_TYPE_AES_256_CBC));
...@@ -212,9 +215,10 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_EmptyOptions) { ...@@ -212,9 +215,10 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_EmptyOptions) {
client_->CreateSecureMessage( client_->CreateSecureMessage(
"PAYLOAD", "PAYLOAD",
"KEY", "KEY",
"", "", // associated data
"", "", // public metadata
"", "", // verification key id
"", // decryption key id
easy_unlock::kEncryptionTypeNone, easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeHMACSHA256, easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result)); base::Bind(&CopyData, &expected_result));
...@@ -245,8 +249,9 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_AsymmetricSign) { ...@@ -245,8 +249,9 @@ TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_AsymmetricSign) {
"PAYLOAD", "PAYLOAD",
"KEY", "KEY",
"ASSOCIATED_DATA", "ASSOCIATED_DATA",
"", "", // public metadata
"VERIFICATION_KEY_ID", "VERIFICATION_KEY_ID",
"", // decryption key id
easy_unlock::kEncryptionTypeNone, easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeECDSAP256SHA256, easy_unlock::kSignatureTypeECDSAP256SHA256,
base::Bind(&CopyData, &expected_result)); base::Bind(&CopyData, &expected_result));
...@@ -320,7 +325,7 @@ TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_EmptyOptions) { ...@@ -320,7 +325,7 @@ TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_EmptyOptions) {
client_->UnwrapSecureMessage( client_->UnwrapSecureMessage(
"MESSAGE", "MESSAGE",
"KEY", "KEY",
"", "", // associated data
easy_unlock::kEncryptionTypeNone, easy_unlock::kEncryptionTypeNone,
easy_unlock::kSignatureTypeHMACSHA256, easy_unlock::kSignatureTypeHMACSHA256,
base::Bind(&CopyData, &expected_result)); base::Bind(&CopyData, &expected_result));
......
...@@ -41,6 +41,7 @@ class EasyUnlockPrivateCryptoDelegate { ...@@ -41,6 +41,7 @@ class EasyUnlockPrivateCryptoDelegate {
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
easy_unlock_private::EncryptionType encryption_type, easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type, easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) = 0; const DataCallback& callback) = 0;
......
...@@ -64,6 +64,7 @@ class EasyUnlockPrivateCryptoDelegateChromeOS ...@@ -64,6 +64,7 @@ class EasyUnlockPrivateCryptoDelegateChromeOS
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
easy_unlock_private::EncryptionType encryption_type, easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type, easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) OVERRIDE { const DataCallback& callback) OVERRIDE {
...@@ -72,6 +73,7 @@ class EasyUnlockPrivateCryptoDelegateChromeOS ...@@ -72,6 +73,7 @@ class EasyUnlockPrivateCryptoDelegateChromeOS
associated_data, associated_data,
public_metadata, public_metadata,
verification_key_id, verification_key_id,
decryption_key_id,
EncryptionTypeToString(encryption_type), EncryptionTypeToString(encryption_type),
SignatureTypeToString(signature_type), SignatureTypeToString(signature_type),
callback); callback);
......
...@@ -33,6 +33,7 @@ class EasyUnlockPrivateCryptoDelegateStub ...@@ -33,6 +33,7 @@ class EasyUnlockPrivateCryptoDelegateStub
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
easy_unlock_private::EncryptionType encryption_type, easy_unlock_private::EncryptionType encryption_type,
easy_unlock_private::SignatureType signature_type, easy_unlock_private::SignatureType signature_type,
const DataCallback& callback) OVERRIDE { const DataCallback& callback) OVERRIDE {
......
...@@ -77,11 +77,15 @@ ...@@ -77,11 +77,15 @@
ArrayBuffer? publicMetadata; ArrayBuffer? publicMetadata;
// Verification key id added to the message header. Should be set if the // Verification key id added to the message header. Should be set if the
// message is signed using |ECDSA_P256_SHA256|. It's used by the message // message is signed using |ECDSA_P256_SHA256|. Used by the message
// recepient to determine which key should be used to verify the message // recepient to determine which key should be used to verify the message
// signature. // signature.
ArrayBuffer? verificationKeyId; ArrayBuffer? verificationKeyId;
// Decryption key id added to the message header. Used by the message
// recepient to determine which key should be used to decrypt the message.
ArrayBuffer? decryptionKeyId;
// The encryption algorithm that should be used to encrypt the message. // The encryption algorithm that should be used to encrypt the message.
// Should not be set for a cleartext message. // Should not be set for a cleartext message.
EncryptionType? encryptType; EncryptionType? encryptType;
......
...@@ -78,6 +78,7 @@ class EasyUnlockClientImpl : public EasyUnlockClient { ...@@ -78,6 +78,7 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type, const std::string& encryption_type,
const std::string& signature_type, const std::string& signature_type,
const DataCallback& callback) OVERRIDE { const DataCallback& callback) OVERRIDE {
...@@ -92,6 +93,7 @@ class EasyUnlockClientImpl : public EasyUnlockClient { ...@@ -92,6 +93,7 @@ class EasyUnlockClientImpl : public EasyUnlockClient {
AppendStringAsByteArray(associated_data, &writer); AppendStringAsByteArray(associated_data, &writer);
AppendStringAsByteArray(public_metadata, &writer); AppendStringAsByteArray(public_metadata, &writer);
AppendStringAsByteArray(verification_key_id, &writer); AppendStringAsByteArray(verification_key_id, &writer);
AppendStringAsByteArray(decryption_key_id, &writer);
writer.AppendString(encryption_type); writer.AppendString(encryption_type);
writer.AppendString(signature_type); writer.AppendString(signature_type);
proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
......
...@@ -62,6 +62,9 @@ class CHROMEOS_EXPORT EasyUnlockClient : public DBusClient { ...@@ -62,6 +62,9 @@ class CHROMEOS_EXPORT EasyUnlockClient : public DBusClient {
// set if the message is signed with private asymetric key. This value // 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 // is used by the receiver to identify the public key that should be used
// to verify the signature. // 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 // |encryption_type|: The encryption algorithm to use for encrypting the
// message. (May be set to none). // message. (May be set to none).
// |signature_type|: The algorithm to use to sign the message. // |signature_type|: The algorithm to use to sign the message.
...@@ -72,6 +75,7 @@ class CHROMEOS_EXPORT EasyUnlockClient : public DBusClient { ...@@ -72,6 +75,7 @@ class CHROMEOS_EXPORT EasyUnlockClient : public DBusClient {
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type, const std::string& encryption_type,
const std::string& signature_type, const std::string& signature_type,
const DataCallback& callback) = 0; const DataCallback& callback) = 0;
......
...@@ -99,6 +99,7 @@ void FakeEasyUnlockClient::CreateSecureMessage( ...@@ -99,6 +99,7 @@ void FakeEasyUnlockClient::CreateSecureMessage(
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type, const std::string& encryption_type,
const std::string& signature_type, const std::string& signature_type,
const DataCallback& callback) { const DataCallback& callback) {
...@@ -109,6 +110,7 @@ void FakeEasyUnlockClient::CreateSecureMessage( ...@@ -109,6 +110,7 @@ void FakeEasyUnlockClient::CreateSecureMessage(
"\"associated_data\": \"%s\"," "\"associated_data\": \"%s\","
"\"public_metadata\": \"%s\"," "\"public_metadata\": \"%s\","
"\"verification_key_id\": \"%s\"," "\"verification_key_id\": \"%s\","
"\"decryption_key_id\": \"%s\","
"\"encryption_type\": \"%s\"," "\"encryption_type\": \"%s\","
"\"signature_type\": \"%s\"" "\"signature_type\": \"%s\""
"}}", "}}",
...@@ -117,6 +119,7 @@ void FakeEasyUnlockClient::CreateSecureMessage( ...@@ -117,6 +119,7 @@ void FakeEasyUnlockClient::CreateSecureMessage(
associated_data.c_str(), associated_data.c_str(),
public_metadata.c_str(), public_metadata.c_str(),
verification_key_id.c_str(), verification_key_id.c_str(),
decryption_key_id.c_str(),
encryption_type.c_str(), encryption_type.c_str(),
signature_type.c_str())); signature_type.c_str()));
} }
......
...@@ -33,6 +33,7 @@ class CHROMEOS_EXPORT FakeEasyUnlockClient : public EasyUnlockClient { ...@@ -33,6 +33,7 @@ class CHROMEOS_EXPORT FakeEasyUnlockClient : public EasyUnlockClient {
const std::string& associated_data, const std::string& associated_data,
const std::string& public_metadata, const std::string& public_metadata,
const std::string& verification_key_id, const std::string& verification_key_id,
const std::string& decryption_key_id,
const std::string& encryption_type, const std::string& encryption_type,
const std::string& signature_type, const std::string& signature_type,
const DataCallback& callback) OVERRIDE; const DataCallback& callback) OVERRIDE;
......
...@@ -209,6 +209,7 @@ TEST(FakeEasyUnlockClientTest, CreateSecureMessage) { ...@@ -209,6 +209,7 @@ TEST(FakeEasyUnlockClientTest, CreateSecureMessage) {
"ASSOCIATED_DATA", "ASSOCIATED_DATA",
"PUBLIC_METADATA", "PUBLIC_METADATA",
"VERIFICATION_KEY_ID", "VERIFICATION_KEY_ID",
"DECRYPTION_KEY_ID",
"ENCRYPTION_TYPE", "ENCRYPTION_TYPE",
"SIGNATURE_TYPE", "SIGNATURE_TYPE",
base::Bind(&RecordData, &message)); base::Bind(&RecordData, &message));
...@@ -220,6 +221,7 @@ TEST(FakeEasyUnlockClientTest, CreateSecureMessage) { ...@@ -220,6 +221,7 @@ TEST(FakeEasyUnlockClientTest, CreateSecureMessage) {
"\"associated_data\": \"ASSOCIATED_DATA\"," "\"associated_data\": \"ASSOCIATED_DATA\","
"\"public_metadata\": \"PUBLIC_METADATA\"," "\"public_metadata\": \"PUBLIC_METADATA\","
"\"verification_key_id\": \"VERIFICATION_KEY_ID\"," "\"verification_key_id\": \"VERIFICATION_KEY_ID\","
"\"decryption_key_id\": \"DECRYPTION_KEY_ID\","
"\"encryption_type\": \"ENCRYPTION_TYPE\"," "\"encryption_type\": \"ENCRYPTION_TYPE\","
"\"signature_type\": \"SIGNATURE_TYPE\"}" "\"signature_type\": \"SIGNATURE_TYPE\"}"
"}"); "}");
......
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