summaryrefslogtreecommitdiffstats
path: root/ipc/handle_attachment_win.cc
diff options
context:
space:
mode:
authorSergey Ulanov <sergeyu@chromium.org>2015-09-14 10:11:35 -0700
committerSergey Ulanov <sergeyu@chromium.org>2015-09-14 17:13:07 +0000
commit384a29c919f7111c4f50ae9ae56e1599b5faa50a (patch)
treea96e44f016d220686a80c4280c390f34324b0075 /ipc/handle_attachment_win.cc
parent4eb7aad877a19d57c9b420372b561e48e4855af3 (diff)
downloadchromium_src-384a29c919f7111c4f50ae9ae56e1599b5faa50a.zip
chromium_src-384a29c919f7111c4f50ae9ae56e1599b5faa50a.tar.gz
chromium_src-384a29c919f7111c4f50ae9ae56e1599b5faa50a.tar.bz2
Remove dependency on //crypto in //ipc, except on windows.
//ipc was depending on //crypto just for crypto::RandBytes(), but after crrev.com/347312 that function is used only on Windows, so the //crypto is needed only on windows. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1321253011 . Cr-Commit-Position: refs/heads/master@{#348638}
Diffstat (limited to 'ipc/handle_attachment_win.cc')
-rw-r--r--ipc/handle_attachment_win.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/ipc/handle_attachment_win.cc b/ipc/handle_attachment_win.cc
index 50e3e6d..429c964 100644
--- a/ipc/handle_attachment_win.cc
+++ b/ipc/handle_attachment_win.cc
@@ -6,12 +6,29 @@
#include <windows.h>
+#include "crypto/random.h"
+
namespace IPC {
namespace internal {
+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 GenerateAttachementId() {
+ BrokerableAttachment::AttachmentId result;
+ crypto::RandBytes(result.nonce, BrokerableAttachment::kNonceSize);
+ return result;
+}
+
+} // namespace
+
HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
HandleWin::Permissions permissions)
- : handle_(handle), permissions_(permissions) {}
+ : BrokerableAttachment(GenerateAttachementId(), true),
+ handle_(handle),
+ permissions_(permissions) {}
HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format)
: BrokerableAttachment(wire_format.attachment_id, false),