1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ipc/brokerable_attachment.h"
7 #include "crypto/random.h"
13 // In order to prevent mutually untrusted processes from stealing resources from
14 // one another, the nonce must be secret. This generates a 128-bit,
15 // cryptographicaly-strong random number.
16 BrokerableAttachment::AttachmentId
GetRandomId() {
17 BrokerableAttachment::AttachmentId id
;
18 crypto::RandBytes(id
.nonce
, BrokerableAttachment::kNonceSize
);
24 BrokerableAttachment::BrokerableAttachment() : id_(GetRandomId()) {
27 BrokerableAttachment::BrokerableAttachment(const AttachmentId
& id
) : id_(id
) {
30 BrokerableAttachment::~BrokerableAttachment() {
33 BrokerableAttachment::AttachmentId
BrokerableAttachment::GetIdentifier() const {
37 BrokerableAttachment::Type
BrokerableAttachment::GetType() const {
38 return TYPE_BROKERABLE_ATTACHMENT
;