tree checksum vpatch file split hunks

all signers: diana_coman

antecedents: eucrypt_genesis ch1_mpi

press order:

eucrypt_genesisdiana_coman
ch1_mpidiana_coman
ch2_truerandomdiana_coman

patch:

- 553FD1DBEE5E1F5D3A5EC56690FEA143943CD029CB4DB51651F1BA01EE3069385EA513F0CE5C22A062020A3ACEF6CAC219D0D86CCC56CB2467605776949F915B
+ 9E9083C3AFA2A9B5528ACE65CFD5AB71DCF1B6FF27C4A6CB72FD3ECEBD1AE1F88133EA40AB6BEF2438375E8B93452AFD01E831BB628D7576CA21854650D1E5EF
eucrypt/mpi/README
(1 . 3)(1 . 5)
5 NB: this is used by the smg_rsa component of EuCrypt.
6
7 What you see here is a very classic version of the GNU MPI (bignum) library.
8 It has been surgically removed from GnuPG 1.4.10, specifically as found at:
9
-
+ 8EBD567A5F4B3C1A8AABCCA0501ED2D4EB3C4EADB593F99CE07C8FE7C1DFB9879EC8457C7125D99CBDA9CEB9D8E3EAB7931F0A4879E33344DF6E0904E489FAEA
eucrypt/smg_rsa/Makefile
(0 . 0)(1 . 27)
14 PROGRAM = smg_rsa.a
15
16 BUILD=obj
17 DIST=bin
18
19 CXX = gcc
20 OBJECTS = $(addprefix $(BUILD)/, $(patsubst %.c,%.o,$(wildcard *.c)))
21 MPI = ../mpi
22 FLAGS = -g -Wall
23 INCLUDE = -I include -I $(MPI)/include
24
25 .SUFFIXES: .o .c
26
27 $(BUILD)/%.o:
28 $(CXX) $(FLAGS) $(INCLUDE) -c $*.c -o $@
29
30 all: $(PROGRAM)
31
32 $(PROGRAM): $(OBJECTS)
33 ar rcs $(DIST)/$(PROGRAM) $(OBJECTS)
34 #ld -o $(DIST)/$(PROGRAM).o $(OBJECTS) -lc
35
36 clean :
37 rm -rf nul core *flymake* $(BUILD)/*.o $(DIST)/$(PROGRAM) *~ bin/*
38
39 check-syntax:
40 $(CXX) -c $(FLAGS) $(INCLUDE) -o nul -Wall -S $(CHK_SOURCES)
- FE2917EF90A8E9DEB4D9F7450CBBC20FDF3CA9F76630B6956137B4648916E143C89F857E0BF0FDE968FD241F3049050EF7F146254A9E8DAEAD54FC0B720C7620
+ ABC69ADFA42130E5269734F91C5F3F61F4C42055E27E9EA4B8B664801F2DC83B8A5ED6C6E339982805B4FFDDA8548CC61D8FD6CF3FDFEEEEC77324F6D95C54D0
eucrypt/smg_rsa/README
(1 . 2)(1 . 5)
45 S.MG, 2017
46
47 This is the S.MG implementation of RSA, used by the Eulora server.
48
49 NB: this lib is part of EuCrypt and as such, it relies on other EuCrypt components (most notably: mpi).
-
+ EF968E74FEE9D5C5451883AFC1A47D0EB8A99C775A6B045040134A7F9C0D80DBEC3644FF9D69CF941BDBC718A6D4BED3A27A11D2EF6530453AB6E4955AA45F32
eucrypt/smg_rsa/bin/README
(0 . 0)(1 . 1)
54 bin folder for smg_rsa lib
-
+ 39ADDB10B86590187C6F9020DD894B4EFA7256381ACEFDEB2C68ABF8A37CBF011909E9BB9DFDB38FFB2FB4B3F0341AE39CB2C9BE6A1425EC139DA4E47C37B33B
eucrypt/smg_rsa/include/knobs.h
(0 . 0)(1 . 7)
59 #ifndef SMG_RSA_KNOBS_H
60 #define SMG_RSA_KNOBS_H
61
62 #define ENTROPY_SOURCE "/dev/ttyUSB0"
63
64 #endif /*SMG_RSA_KNOBS_H*/
65
-
+ 54AFE77A6A278EB793ECF8CA19CD3B1DEC64AE9D59826DCAD3ABC4DF46C0C3BC7A16E178A05690BF930C1935A94DD12EB635E6D37B4F6F89CB478FD92A2A0B7A
eucrypt/smg_rsa/include/smg_rsa.h
(0 . 0)(1 . 44)
70 /* smg_rsa.h
71 * S.MG, 2017
72 */
73
74 #ifndef SMG_RSA_H
75 #define SMG_RSA_H
76
77 #include "mpi.h"
78 #include "knobs.h"
79
80 /*********truerandom.c*********/
81
82 /*
83 * Opens and configures (as per FG requirements) the specified entropy source (e.g. "/dev/ttyUSB0")
84 * @param source_name the name of the file to open (e.g. "/dev/ttyUSB0")
85 * @return the descriptor of the open file when successful; negative value otherwise
86 */
87 int open_entropy_source(char* source_name);
88
89
90 /*
91 * Returns noctets random octets (i.e. 8*noctets bits in total) as obtained from EuCrypt's preferred source.
92 * Preferred source is defined in knobs.h as ENTROPY_SOURCE and should be a TRNG (e.g. Fuckgoats).
93 * @param nboctets the length of desired random sequence, in octets
94 * @param out pointer to allocated memory space for the requested random noctets; NB: this method does NOT allocate space!
95 * @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)
96 */
97 int get_random_octets(int noctets, unsigned char *out);
98
99 /* Returns noctets random octets as obtained from the specified "from" source;
100 * NB: the "from" source is considered to be the handle of an already opened stream;
101 * This method will simply attempt to read from the source as needed!
102 *
103 * @param noctets the length of desired random sequence, in octets
104 * @param out pointer to allocated memory space for the requested random octets;
105 * NB: this method does NOT allocate space!
106 * @param from handle of an already opened entropy source - this method will just READ from it as needed
107 * @return the actual number of octets that were obtained
108 */
109 int get_random_octets_from(int noctets, unsigned char *out, int from);
110
111
112 #endif /*SMG_RSA*/
113
-
+ A2EB4B7AFC8AFE95836F6CF05B0EB589977606525747A45776A1409A65CCD52EDB062EF150226CA65E91F66ACEBEC828B050C1A2E946C542EB86D7830323DAF3
eucrypt/smg_rsa/obj/README
(0 . 0)(1 . 1)
118 obj folder for smg_rsa
-
+ E426FDCA88EDC45327759E751831FA6CB81F88D9C65A1DA25AE513E391CFDC69A99027CCDDEF4D02AA8893EBBAC32CC60A853101962B51F4269DC86EE41F311D
eucrypt/smg_rsa/tests/Makefile
(0 . 0)(1 . 25)
123 PROGRAM = tests
124
125 CXX = gcc
126 OBJECTS := $(patsubst %.c,%.o,$(wildcard *.c))
127 FLAGS = -g -Wall
128 INCLUDE = -I ../include -I ../../mpi/include
129 SMG_RSA = ../bin/smg_rsa.a
130 MPI = ../../mpi/bin/mpi.a
131 LIBS := $(SMG_RSA) $(MPI)
132
133 .SUFFIXES: .o .c
134
135 .c.o:
136 $(CXX) $(FLAGS) $(INCLUDE) -c $< -o $@
137
138 all: $(PROGRAM)
139
140 $(PROGRAM): $(OBJECTS)
141 $(CXX) $(FLAGS) $(INCLUDE) -o $(PROGRAM) $(OBJECTS) $(LIBS)
142
143 clean :
144 rm -rf nul core *flymake* *.o $(PROGRAM) *~ bin obj
145
146 check-syntax:
147 $(CXX) -c $(FLAGS) $(INCLUDE) -o nul -Wall -S $(CHK_SOURCES)
-
+ 925D35158574838825AEE8B2269787E17FA2F3C3FC6BC6929EF573BBA3B1477F157FB9F162E627B13C5E60F02D6BEFCCCE395123FC061F8F2317173BD5CE8DC4
eucrypt/smg_rsa/tests/tests.c
(0 . 0)(1 . 46)
152 #include "smg_rsa.h"
153
154 #include <stdlib.h>
155 #include <time.h>
156
157 void err(char *msg)
158 {
159 fprintf(stderr, "%s\n", msg);
160 exit(1);
161 }
162
163 void time_entropy_source(int nruns, int noctets) {
164 unsigned char buffer[noctets];
165 int read, i;
166 struct timespec tstart, tend;
167 long int diff;
168
169 clock_gettime(CLOCK_MONOTONIC, &tstart);
170 for (i=0; i<nruns; i++) {
171 read = get_random_octets(noctets,buffer);
172 if (read != noctets)
173 err("Failed reading from entropy source!");
174 }
175 clock_gettime(CLOCK_MONOTONIC, &tend);
176
177 diff = tend.tv_sec-tstart.tv_sec;
178 double kbps = (nruns*noctets) / (diff*1000.0);
179 printf("ENTROPY source timing: %d kB in %ld seconds, at an average speed of %f kB/s over %d runs of %d octets each\n", nruns*noctets, diff, kbps, nruns, noctets);
180 }
181
182
183 int main(int ac, char **av)
184 {
185 int nruns;
186
187 if (ac<2) {
188 printf("Usage: %s number_of_runs\n", av[0]);
189 return -1;
190 }
191 nruns = atoi(av[1]);
192
193 printf("Timing entropy source...\n");
194 time_entropy_source(nruns,4096);
195
196 return 0;
197 }
-
+ 4B729AFBF1B614C0E53367586D7880C27856E0A7A7996735C718091124FC436C3F9003B213B8BA56E80ACC41E4CDF98E5F56D8B3CF1573D6BB699F0B59FD89EC
eucrypt/smg_rsa/truerandom.c
(0 . 0)(1 . 98)
202 #include <stdio.h>
203 #include <stdlib.h>
204 #include <string.h>
205
206 #include <fcntl.h>
207 #include <unistd.h>
208 #include <termios.h>
209 #include <errno.h>
210
211 #include "smg_rsa.h"
212
213
214 int set_usb_attribs(int fd, int speed) {
215 struct termios tty;
216 if (tcgetattr(fd, &tty) < 0) {
217 return -1;
218 }
219
220 //input and output speeds
221 cfsetospeed(&tty, (speed_t)speed);
222 cfsetispeed(&tty, (speed_t)speed);
223
224 tty.c_cflag |= (CLOCAL | CREAD); //ignore modem controls
225 tty.c_cflag &= ~CSIZE;
226 tty.c_cflag |= CS8; //8 bit characters
227 tty.c_cflag &= ~PARENB; //no parity bit
228 tty.c_cflag &= ~CSTOPB; //only need 1 stop bit
229 tty.c_cflag &= ~CRTSCTS; //no hardware flow control
230
231 //non-canonical mode
232 tty.c_cflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
233 tty.c_cflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
234 tty.c_cflag &= ~OPOST;
235
236 //read at least one octet at a time; timeout 1 tenth of second between octets read
237 tty.c_cc[VMIN] = 1;
238 tty.c_cc[VTIME] = 1;
239
240 if (tcsetattr(fd, TCSANOW, &tty) != 0)
241 return -1;
242
243 return 0;
244 }
245
246 int open_entropy_source(char* source_name) {
247 int in, err;
248
249 in = open(source_name, O_RDONLY | O_NOCTTY | O_NDELAY);
250 if (in == -1) {
251 printf("ERROR: failure to open entropy source %s: %s\n", source_name, strerror(errno));
252 return in; //failed to access entropy source
253 }
254
255 fcntl(in, F_SETFL, 0);
256
257 err = set_usb_attribs(in, B115200);
258 if (err==-1) {
259 printf("Error setting attributes on %s: %s\n", source_name, strerror(errno));
260 return err;
261 }
262
263 return in; //source opened, return its descriptor
264 }
265
266 int get_random_octets_from(int noctets, unsigned char *out, int from) {
267
268 int nread;
269 int total = 0;
270
271 while (total < noctets) {
272 nread = read(from, out+total, noctets-total);
273 //on interrupt received just try again
274 if (nread == -1 && errno == EINTR)
275 continue;
276 //on error condition abort
277 if (nread == -1 || nread == 0) {
278 printf("Error reading from entropy source %s: %s\n", ENTROPY_SOURCE, strerror(errno));
279 return total; //total read so far
280 }
281
282 if (nread > 0)
283 total = total + nread;
284 }
285 return total; //return number of octets read
286 }
287
288 int get_random_octets(int noctets, unsigned char *out) {
289 int in;
290 int nread = 0;
291
292 in = open_entropy_source(ENTROPY_SOURCE);
293 if (in > 0) {
294 nread = get_random_octets_from(noctets, out, in);
295 close(in);
296 }
297 return nread;
298 }
299