Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 3 | * 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 Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 11 | */ |
| 12 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 13 | #include "common.hpp" |
| 14 | |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 15 | #include "random.hpp" |
| 16 | |
Junxiao Shi | 482ccc5 | 2014-03-31 13:05:24 -0700 | [diff] [blame] | 17 | #include "../security/cryptopp.hpp" |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 18 | |
| 19 | namespace ndn { |
| 20 | namespace random { |
| 21 | |
| 22 | uint32_t |
| 23 | generateWord32() |
| 24 | { |
| 25 | static CryptoPP::AutoSeededRandomPool rng; |
| 26 | |
| 27 | return rng.GenerateWord32(); |
| 28 | } |
| 29 | |
Yingdi Yu | 17bc301 | 2014-02-10 17:37:12 -0800 | [diff] [blame] | 30 | uint64_t |
| 31 | generateWord64() |
| 32 | { |
| 33 | static CryptoPP::AutoSeededRandomPool rng; |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 34 | |
Yingdi Yu | 17bc301 | 2014-02-10 17:37:12 -0800 | [diff] [blame] | 35 | uint64_t random; |
| 36 | |
| 37 | rng.GenerateBlock(reinterpret_cast<unsigned char*>(&random), 8); |
| 38 | |
| 39 | return random; |
| 40 | } |
| 41 | |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 42 | } // namespace random |
| 43 | } // namespace ndn |