diff options
author | erikchen <erikchen@chromium.org> | 2015-07-07 15:13:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-07 22:14:00 +0000 |
commit | eece6c3ca617b0d3c37ce137aba1d2079ab892e4 (patch) | |
tree | 3378ce9340ebec508ad4d3c5800b75419137de7d /ipc/brokerable_attachment.cc | |
parent | ad58c57745969ba925d0f527854bef3a59b39c0d (diff) | |
download | chromium_src-eece6c3ca617b0d3c37ce137aba1d2079ab892e4.zip chromium_src-eece6c3ca617b0d3c37ce137aba1d2079ab892e4.tar.gz chromium_src-eece6c3ca617b0d3c37ce137aba1d2079ab892e4.tar.bz2 |
Stub in more IPC attachment brokering functionality.
This CL fills in most of the logic for sending a Windows HANDLE from a
non-broker process to the broker process. This consists of several small
changes:
- Create the new IPC messages AttachmentBrokerMsg_WinHandleHasBeenBrokered and
AttachmentBrokerMsg_RequestBrokerageOfWinHandle.
- Add a sender_ member variable to AttachmentBrokerWin.
- Define the wire format for HandleAttachmentWin.
- Add logic to ChannelWin to send
AttachmentBrokerMsg_RequestBrokerageOfWinHandle for each HANDLE attachment.
BUG=466437
Review URL: https://codereview.chromium.org/1188923003
Cr-Commit-Position: refs/heads/master@{#337689}
Diffstat (limited to 'ipc/brokerable_attachment.cc')
-rw-r--r-- | ipc/brokerable_attachment.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ipc/brokerable_attachment.cc b/ipc/brokerable_attachment.cc index be5d51b..5caed28 100644 --- a/ipc/brokerable_attachment.cc +++ b/ipc/brokerable_attachment.cc @@ -4,9 +4,24 @@ #include "ipc/brokerable_attachment.h" +#include "crypto/random.h" + namespace IPC { -BrokerableAttachment::BrokerableAttachment() { +namespace { + +// In order to prevent mutually untrusted processes from stealing resources from +// one another, the nonce must be secret. This generates a 128-bit, +// cryptographicaly-strong random number. +BrokerableAttachment::AttachmentId GetRandomId() { + BrokerableAttachment::AttachmentId id; + crypto::RandBytes(id.nonce, BrokerableAttachment::kNonceSize); + return id; +} + +} // namespace + +BrokerableAttachment::BrokerableAttachment() : id_(GetRandomId()) { } BrokerableAttachment::~BrokerableAttachment() { @@ -16,4 +31,8 @@ BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const { return id_; } +BrokerableAttachment::Type BrokerableAttachment::GetType() const { + return TYPE_BROKERABLE_ATTACHMENT; +} + } // namespace IPC |