SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
random_provider_base.h
Go to the documentation of this file.
1 /*
2 SeComLib
3 Copyright 2012-2013 TU Delft, Information Security & Privacy Lab (http://isplab.tudelft.nl/)
4 
5 Contributors:
6 Inald Lagendijk (R.L.Lagendijk@TUDelft.nl)
7 Mihai Todor (todormihai@gmail.com)
8 Thijs Veugen (P.J.M.Veugen@tudelft.nl)
9 Zekeriya Erkin (z.erkin@tudelft.nl)
10 
11 Licensed under the Apache License, Version 2.0 (the "License");
12 you may not use this file except in compliance with the License.
13 You may obtain a copy of the License at
14 
15 http://www.apache.org/licenses/LICENSE-2.0
16 
17 Unless required by applicable law or agreed to in writing, software
18 distributed under the License is distributed on an "AS IS" BASIS,
19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 See the License for the specific language governing permissions and
21 limitations under the License.
22 */
29 #ifndef RANDOM_PROVIDER_BASE_HEADER_GUARD
30 #define RANDOM_PROVIDER_BASE_HEADER_GUARD
31 
32 //this header also includes the 3rd party library specific headers
33 #include "big_integer.h"
34 
35 //include C++ headers
36 #include <iostream>
37 #include <stdexcept>
38 
39 namespace SeComLib {
40 namespace Core {
48  template <typename T_Impl>
50  public:
52  friend T_Impl;
53 
56 
58  BigInteger GetRandomInteger (const size_t numberOfBits);
59 
61  BigInteger GetRandomInteger (const BigInteger &maximumValue);
62 
64  BigInteger GetMaxLengthRandomPrime (const size_t &numberOfBits);
65 
66  private:
68  typename T_Impl::RandomGeneratorState randomGeneratorState;
69 
71  unsigned int randomSeed;
72 
77 
80 
83 
86  };
87 
88 }//namespace Core
89 }//namespace SeComLib
90 
91 //Separate the implementation from the declaration of template methods
92 #include "random_provider_base.hpp"
93 
94 #endif//RANDOM_PROVIDER_BASE_HEADER_GUARD
BigInteger GetMaxLengthRandomPrime(const size_t &numberOfBits)
Generates a random prime, guaranteed to have numberOfBits length.
Defines BigInteger.
Implementation of class RandomProviderBase. To be included in random_provider_base.h.
T_Impl::RandomGeneratorState randomGeneratorState
Implementation-defined random generator state.
BigInteger GetRandomInteger(const size_t numberOfBits)
Generates a random integer having at most numberOfBits bits.
Template class which masks various RandomProvider implementations and provides a common interface tha...
~RandomProviderBase()
Destructor (private, Singleton Pattern)
RandomProviderBase operator=(RandomProviderBase< T_Impl > const &)
Copy assignment operator - not implemented.
unsigned int randomSeed
Random seed required for the random generator state initialization.
friend T_Impl
The random provider implementation requires access to the underlying data.
static RandomProviderBase< T_Impl > & GetInstance()
Returns a reference to the singleton.