Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 7 | #include "common.hpp" |
| 8 | |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 9 | #include "random.hpp" |
| 10 | |
Junxiao Shi | 482ccc5 | 2014-03-31 13:05:24 -0700 | [diff] [blame] | 11 | #include "../security/cryptopp.hpp" |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 12 | |
| 13 | namespace ndn { |
| 14 | namespace random { |
| 15 | |
| 16 | uint32_t |
| 17 | generateWord32() |
| 18 | { |
| 19 | static CryptoPP::AutoSeededRandomPool rng; |
| 20 | |
| 21 | return rng.GenerateWord32(); |
| 22 | } |
| 23 | |
Yingdi Yu | 17bc301 | 2014-02-10 17:37:12 -0800 | [diff] [blame] | 24 | uint64_t |
| 25 | generateWord64() |
| 26 | { |
| 27 | static CryptoPP::AutoSeededRandomPool rng; |
| 28 | |
| 29 | uint64_t random; |
| 30 | |
| 31 | rng.GenerateBlock(reinterpret_cast<unsigned char*>(&random), 8); |
| 32 | |
| 33 | return random; |
| 34 | } |
| 35 | |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 36 | } // namespace random |
| 37 | } // namespace ndn |