raw
ch2_truerandom          1 /* smg_rsa.h
ch2_truerandom 2 * S.MG, 2017
ch2_truerandom 3 */
ch2_truerandom 4
ch2_truerandom 5 #ifndef SMG_RSA_H
ch2_truerandom 6 #define SMG_RSA_H
ch2_truerandom 7
ch2_truerandom 8 #include "mpi.h"
ch2_truerandom 9 #include "knobs.h"
ch2_truerandom 10
ch2_truerandom 11 /*********truerandom.c*********/
ch2_truerandom 12
ch2_truerandom 13 /*
ch2_truerandom 14 * Opens and configures (as per FG requirements) the specified entropy source (e.g. "/dev/ttyUSB0")
ch2_truerandom 15 * @param source_name the name of the file to open (e.g. "/dev/ttyUSB0")
ch2_truerandom 16 * @return the descriptor of the open file when successful; negative value otherwise
ch2_truerandom 17 */
ch2_truerandom 18 int open_entropy_source(char* source_name);
ch2_truerandom 19
ch2_truerandom 20
ch2_truerandom 21 /*
ch2_truerandom 22 * Returns noctets random octets (i.e. 8*noctets bits in total) as obtained from EuCrypt's preferred source.
ch2_truerandom 23 * Preferred source is defined in knobs.h as ENTROPY_SOURCE and should be a TRNG (e.g. Fuckgoats).
ch2_truerandom 24 * @param nboctets the length of desired random sequence, in octets
ch2_truerandom 25 * @param out pointer to allocated memory space for the requested random noctets; NB: this method does NOT allocate space!
ch2_truerandom 26 * @return the actual number of octets that were obtained from the currently configured entropy source (this is equal to noctets on successful read of required noctets)
ch2_truerandom 27 */
ch2_truerandom 28 int get_random_octets(int noctets, unsigned char *out);
ch2_truerandom 29
ch2_truerandom 30 /* Returns noctets random octets as obtained from the specified "from" source;
ch2_truerandom 31 * NB: the "from" source is considered to be the handle of an already opened stream;
ch2_truerandom 32 * This method will simply attempt to read from the source as needed!
ch2_truerandom 33 *
ch2_truerandom 34 * @param noctets the length of desired random sequence, in octets
ch2_truerandom 35 * @param out pointer to allocated memory space for the requested random octets;
ch2_truerandom 36 * NB: this method does NOT allocate space!
ch2_truerandom 37 * @param from handle of an already opened entropy source - this method will just READ from it as needed
ch2_truerandom 38 * @return the actual number of octets that were obtained
ch2_truerandom 39 */
ch2_truerandom 40 int get_random_octets_from(int noctets, unsigned char *out, int from);
ch2_truerandom 41
eucrypt_ch3_mille... 42 /*********primegen.c*********/
eucrypt_ch3_mille... 43
eucrypt_ch3_mille... 44 /*
eucrypt_ch3_mille... 45 * This is an implementation of the Miller-Rabin probabilistic primality test:
eucrypt_ch3_mille... 46 * checking the specified number of randomly-chosen candidate witnesses
eucrypt_ch3_mille... 47 * (i.e. with an outer bound of (1/4)^nwitnesses).
eucrypt_ch3_mille... 48 * NB: a 1 result from this test means that the given n is indeed composite (non-prime)
eucrypt_ch3_mille... 49 but a 0 result does not fully guarantee that n is prime!
eucrypt_ch3_mille... 50 If this doesn't make sense to you, read more on probabilistic primality tests.
eucrypt_ch3_mille... 51 * @param n the candidate prime number;
eucrypt_ch3_mille... 52 the function will investigate whether this number is composite or *likely* to be prime.
eucrypt_ch3_mille... 53 How likely? It depends on the number of witnesses checked, see next parameter.
eucrypt_ch3_mille... 54 * @param nwitnesses this is the number of randomly chosen candidate witnesses to the compositeness of n
eucrypt_ch3_mille... 55 that will be checked; the outer bound of the algorithm depends on this.
eucrypt_ch3_mille... 56 * @param entropy_source the source of entropy (ready to read from) that will be used
eucrypt_ch3_mille... 57 to choose candidate witnesses to the compositeness of n.
eucrypt_ch3_mille... 58 * @return 1 if at least one witness to the compositeness of n has been found
eucrypt_ch3_mille... 59 (i.e. n is certainly composite);
eucrypt_ch3_mille... 60 0 if no witness to the compositeness of n was found (i.e. it is likely that n is prime)
eucrypt_ch3_mille... 61 * NB: the probability that n is *not* prime although this function returned 0 is
eucrypt_ch3_mille... 62 less than (1/4)^nwitnesses, but it is NOT zero.
eucrypt_ch3_mille... 63 */
eucrypt_ch3_mille... 64 int is_composite( MPI n, int nwitnesses, int entropy_source);
eucrypt_ch3_mille... 65
ch2_truerandom 66
ch2_truerandom 67 #endif /*SMG_RSA*/
ch2_truerandom 68