blob: e64b1aab9e3c861e5265e757f4ec479b5a900cc7 [file] [log] [blame]
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyeve9fdb802014-02-05 17:36:51 -08002/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Alexander Afanasyeve9fdb802014-02-05 17:36:51 -080011 */
12
Alexander Afanasyeve2dcdfd2014-02-07 15:53:28 -080013#include "common.hpp"
14
Alexander Afanasyeve9fdb802014-02-05 17:36:51 -080015#include "random.hpp"
16
Junxiao Shi482ccc52014-03-31 13:05:24 -070017#include "../security/cryptopp.hpp"
Alexander Afanasyeve9fdb802014-02-05 17:36:51 -080018
19namespace ndn {
20namespace random {
21
22uint32_t
23generateWord32()
24{
25 static CryptoPP::AutoSeededRandomPool rng;
26
27 return rng.GenerateWord32();
28}
29
Yingdi Yu17bc3012014-02-10 17:37:12 -080030uint64_t
31generateWord64()
32{
33 static CryptoPP::AutoSeededRandomPool rng;
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070034
Yingdi Yu17bc3012014-02-10 17:37:12 -080035 uint64_t random;
36
37 rng.GenerateBlock(reinterpret_cast<unsigned char*>(&random), 8);
38
39 return random;
40}
41
Alexander Afanasyeve9fdb802014-02-05 17:36:51 -080042} // namespace random
43} // namespace ndn