summaryrefslogtreecommitdiffstats
path: root/ipc/brokerable_attachment_mac.cc
blob: dbcd86b361e3bb3d455eef9fe372587bfd4402c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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 {

// static
BrokerableAttachment::AttachmentId
BrokerableAttachment::AttachmentId::CreateIdWithRandomNonce() {
  AttachmentId id;
  // 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.
  crypto::RandBytes(id.nonce, BrokerableAttachment::kNonceSize);
  return id;
}

}  // namespace IPC