SeComLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
random_provider_gmp.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_GMP_HEADER_GUARD
30 #define RANDOM_PROVIDER_GMP_HEADER_GUARD
31 
32 //defined for WIN64 as well
33 #ifdef _WIN32
34  //required by iostream to include the Windows function errno_t rand_s(unsigned int* randomValue)
35  #define _CRT_RAND_S
36 #endif
37 
38 #include "random_provider_base.h"
39 
40 //include C++ headers
41 #include <iostream>
42 #include <fstream>
43 #include <stdexcept>
44 
45 namespace SeComLib {
46 namespace Core {
51  public:
53  typedef gmp_randstate_t RandomGeneratorState;
54 
57 
60 
62  static void GetRandomInteger(BigIntegerBase<BigIntegerGmp> &output, RandomProviderBase<RandomProviderGmp> &input, const size_t numberOfBits);
63 
66 
68  static void GetMaxLengthRandomPrime(BigIntegerBase<BigIntegerGmp> &output, RandomProviderBase<RandomProviderGmp> &input, const size_t numberOfBits);
69  };
70 }//namespace Core
71 }//namespace SeComLib
72 
73 #endif//RANDOM_PROVIDER_GMP_HEADER_GUARD
Wrapper for the required GMP library random number specific functions.
static void Destroy(RandomProviderBase< RandomProviderGmp > &input)
Destroys the underlying data from input.
static void Initialize(RandomProviderBase< RandomProviderGmp > &input)
Initializes the underlying random state from input.
Template class which masks various RandomProvider implementations and provides a common interface tha...
Definition of class RandomProviderBase.
Template class which adds syntactic sugar to big integer operations.
static void GetRandomInteger(BigIntegerBase< BigIntegerGmp > &output, RandomProviderBase< RandomProviderGmp > &input, const size_t numberOfBits)
Generates a random integer having at most numberOfBits bits.
gmp_randstate_t RandomGeneratorState
Generic alias required by RandomGeneratorBase to define the underlying random state member...
static void GetMaxLengthRandomPrime(BigIntegerBase< BigIntegerGmp > &output, RandomProviderBase< RandomProviderGmp > &input, const size_t numberOfBits)
Generates a random prime, guaranteed to have numberOfBits length.