blob: f1cc9b2afaa624b7b61d33b9f83539c159b33779 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ipc/brokerable_attachment.h"
#include "crypto/random.h"
namespace IPC {
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()), needs_brokering_(false) {}
BrokerableAttachment::BrokerableAttachment(const AttachmentId& id,
bool needs_brokering)
: id_(id), needs_brokering_(needs_brokering) {}
BrokerableAttachment::~BrokerableAttachment() {
}
BrokerableAttachment::AttachmentId BrokerableAttachment::GetIdentifier() const {
return id_;
}
bool BrokerableAttachment::NeedsBrokering() const {
return needs_brokering_;
}
void BrokerableAttachment::SetNeedsBrokering(bool needs_brokering) {
needs_brokering_ = needs_brokering;
}
BrokerableAttachment::Type BrokerableAttachment::GetType() const {
return TYPE_BROKERABLE_ATTACHMENT;
}
} // namespace IPC
|