Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Unified Diff: ipc/brokerable_attachment.cc

Issue 1188923003: Stub in more IPC attachment brokering functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase properly. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/brokerable_attachment.h ('k') | ipc/handle_attachment_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/brokerable_attachment.cc
diff --git a/ipc/brokerable_attachment.cc b/ipc/brokerable_attachment.cc
index be5d51b2069451e25eb1ff987fb48bfd32e9b166..5caed2842a48ae666829e54dbd4c5a88491fdc1a 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
« no previous file with comments | « ipc/brokerable_attachment.h ('k') | ipc/handle_attachment_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698