tree checksum vpatch file split hunks
all signers: diana_coman
antecedents: eucrypt_fix_256 eucrypt_ch12_wrapper_rsa_oaep_c_ada
press order:
patch:
(0 . 0)(1 . 52)
5 ------------------------------------------------------------------------------
6 ------------------------------------------------------------------------------
7 -- This file is part of 'CRC32' --
8 -- --
9 -- You do not have, nor can you ever acquire the right to use, copy or --
10 -- distribute this software ; Should you use this software for any purpose, --
11 -- or copy and distribute it to anyone or in any manner, you are breaking --
12 -- the laws of whatever soi-disant jurisdiction, and you promise to --
13 -- continue doing so for the indefinite future. In any case, please --
14 -- always : read and understand any software ; verify any PGP signatures --
15 -- that you use - for any purpose. --
16 -- --
17 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
18 ------------------------------------------------------------------------------
19 ------------------------------------------------------------------------------
20
21 -- CRC32 implementation
22 -- S.MG, 2018
23
24 package body CRC32 is
25 function CRC( S: in String ) return CRC32 is
26 Result : CRC32 := Init_Value;
27 Value : CRC32;
28 begin
29 -- process input character by character
30 for C of S loop
31 Value := CRC32( Character'Pos( C ) );
32 Result := Shift_Right(Result, 8) xor
33 Lookup( Value xor (Result and LSB_MASK));
34 end loop;
35 -- reflect result
36 Result := Result xor Xor_Out;
37
38 return Result;
39 end CRC;
40
41 function CRC( Data: in Octet_Array ) return CRC32 is
42 Result : CRC32 := Init_Value;
43 begin
44 -- process input octet by octet
45 for C of Data loop
46 Result := Shift_Right(Result, 8) xor
47 Lookup( CRC32(C) xor (Result and LSB_MASK));
48 end loop;
49 -- reflect result
50 Result := Result xor Xor_Out;
51
52 return Result;
53 end CRC;
54
55 end CRC32;
56
-(0 . 0)(1 . 130)
61 ------------------------------------------------------------------------------
62 ------------------------------------------------------------------------------
63 -- This file is part of 'CRC32' --
64 -- --
65 -- You do not have, nor can you ever acquire the right to use, copy or --
66 -- distribute this software ; Should you use this software for any purpose, --
67 -- or copy and distribute it to anyone or in any manner, you are breaking --
68 -- the laws of whatever soi-disant jurisdiction, and you promise to --
69 -- continue doing so for the indefinite future. In any case, please --
70 -- always : read and understand any software ; verify any PGP signatures --
71 -- that you use - for any purpose. --
72 -- --
73 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
74 ------------------------------------------------------------------------------
75 ------------------------------------------------------------------------------
76
77 -- CRC32, lookup-based implementation
78 -- S.MG, 2018
79 --
80 -- The CRC32 is a checksum calculated as the remainder of dividing
81 -- the input data by the 0x04C11DB7 polynomial. Specifications:
82 -- Name : "CRC-32"
83 -- Width : 32 (number of bits)
84 -- Poly : 04C11DB7 (generator polynomial)
85 -- Init : FFFFFFFF
86 -- RefIn : True (input is reflected)
87 -- RefOut : True (output is reflected)
88 -- XorOut : FFFFFFFF
89 -- Check : CBF43926 (expected value for input "123456789")
90 --
91 -- This implementation is based on the CRC32 specification in:
92 -- Sarwate, D.V. "Computation of Cyclic Redundancy Checks via Table Look-Up"
93 -- in Communications of the ACM, Vol. 31 No. 8, pp.1008-1013, Aug. 1988
94
95 with Interfaces; use Interfaces;
96
97 package CRC32 is
98 -- local, shorthand version of Interfaces. types
99 subtype CRC32 is Interfaces.Unsigned_32;
100 subtype Octet is Interfaces.Unsigned_8;
101
102 type Octet_Array is array( Integer range <> ) of Octet;
103
104 -- interface for external callers
105 -- calculate CRC32 for the given string
106 function CRC( S: in String ) return CRC32;
107
108 -- calculate CRC32 for the given array of octets
109 function CRC( Data: in Octet_Array ) return CRC32;
110
111
112 -- internal constants and helper methods
113 private
114 function Shift_Right( Value : CRC32;
115 Amount : Natural)
116 return CRC32;
117 pragma Import(Intrinsic, Shift_Right);
118
119 Init_Value : constant CRC32 := 16#FFFF_FFFF#; -- Initial value
120 Xor_Out : constant CRC32 := 16#FFFF_FFFF#; -- For extracting result
121 LSB_Mask : constant CRC32 := 16#0000_00FF#; -- lsb mask for a CRC32 value
122
123 -- lookup table with precomputed values for CRC32
124 Lookup : constant array (CRC32 range 0 .. 255) of CRC32 :=
125 (16#0000_0000#, 16#7707_3096#, 16#EE0E_612C#, 16#9909_51BA#,
126 16#076D_C419#, 16#706A_F48F#, 16#E963_A535#, 16#9E64_95A3#,
127 16#0EDB_8832#, 16#79DC_B8A4#, 16#E0D5_E91E#, 16#97D2_D988#,
128 16#09B6_4C2B#, 16#7EB1_7CBD#, 16#E7B8_2D07#, 16#90BF_1D91#,
129 16#1DB7_1064#, 16#6AB0_20F2#, 16#F3B9_7148#, 16#84BE_41DE#,
130 16#1ADA_D47D#, 16#6DDD_E4EB#, 16#F4D4_B551#, 16#83D3_85C7#,
131 16#136C_9856#, 16#646B_A8C0#, 16#FD62_F97A#, 16#8A65_C9EC#,
132 16#1401_5C4F#, 16#6306_6CD9#, 16#FA0F_3D63#, 16#8D08_0DF5#,
133 16#3B6E_20C8#, 16#4C69_105E#, 16#D560_41E4#, 16#A267_7172#,
134 16#3C03_E4D1#, 16#4B04_D447#, 16#D20D_85FD#, 16#A50A_B56B#,
135 16#35B5_A8FA#, 16#42B2_986C#, 16#DBBB_C9D6#, 16#ACBC_F940#,
136 16#32D8_6CE3#, 16#45DF_5C75#, 16#DCD6_0DCF#, 16#ABD1_3D59#,
137 16#26D9_30AC#, 16#51DE_003A#, 16#C8D7_5180#, 16#BFD0_6116#,
138 16#21B4_F4B5#, 16#56B3_C423#, 16#CFBA_9599#, 16#B8BD_A50F#,
139 16#2802_B89E#, 16#5F05_8808#, 16#C60C_D9B2#, 16#B10B_E924#,
140 16#2F6F_7C87#, 16#5868_4C11#, 16#C161_1DAB#, 16#B666_2D3D#,
141 16#76DC_4190#, 16#01DB_7106#, 16#98D2_20BC#, 16#EFD5_102A#,
142 16#71B1_8589#, 16#06B6_B51F#, 16#9FBF_E4A5#, 16#E8B8_D433#,
143 16#7807_C9A2#, 16#0F00_F934#, 16#9609_A88E#, 16#E10E_9818#,
144 16#7F6A_0DBB#, 16#086D_3D2D#, 16#9164_6C97#, 16#E663_5C01#,
145 16#6B6B_51F4#, 16#1C6C_6162#, 16#8565_30D8#, 16#F262_004E#,
146 16#6C06_95ED#, 16#1B01_A57B#, 16#8208_F4C1#, 16#F50F_C457#,
147 16#65B0_D9C6#, 16#12B7_E950#, 16#8BBE_B8EA#, 16#FCB9_887C#,
148 16#62DD_1DDF#, 16#15DA_2D49#, 16#8CD3_7CF3#, 16#FBD4_4C65#,
149 16#4DB2_6158#, 16#3AB5_51CE#, 16#A3BC_0074#, 16#D4BB_30E2#,
150 16#4ADF_A541#, 16#3DD8_95D7#, 16#A4D1_C46D#, 16#D3D6_F4FB#,
151 16#4369_E96A#, 16#346E_D9FC#, 16#AD67_8846#, 16#DA60_B8D0#,
152 16#4404_2D73#, 16#3303_1DE5#, 16#AA0A_4C5F#, 16#DD0D_7CC9#,
153 16#5005_713C#, 16#2702_41AA#, 16#BE0B_1010#, 16#C90C_2086#,
154 16#5768_B525#, 16#206F_85B3#, 16#B966_D409#, 16#CE61_E49F#,
155 16#5EDE_F90E#, 16#29D9_C998#, 16#B0D0_9822#, 16#C7D7_A8B4#,
156 16#59B3_3D17#, 16#2EB4_0D81#, 16#B7BD_5C3B#, 16#C0BA_6CAD#,
157 16#EDB8_8320#, 16#9ABF_B3B6#, 16#03B6_E20C#, 16#74B1_D29A#,
158 16#EAD5_4739#, 16#9DD2_77AF#, 16#04DB_2615#, 16#73DC_1683#,
159 16#E363_0B12#, 16#9464_3B84#, 16#0D6D_6A3E#, 16#7A6A_5AA8#,
160 16#E40E_CF0B#, 16#9309_FF9D#, 16#0A00_AE27#, 16#7D07_9EB1#,
161 16#F00F_9344#, 16#8708_A3D2#, 16#1E01_F268#, 16#6906_C2FE#,
162 16#F762_575D#, 16#8065_67CB#, 16#196C_3671#, 16#6E6B_06E7#,
163 16#FED4_1B76#, 16#89D3_2BE0#, 16#10DA_7A5A#, 16#67DD_4ACC#,
164 16#F9B9_DF6F#, 16#8EBE_EFF9#, 16#17B7_BE43#, 16#60B0_8ED5#,
165 16#D6D6_A3E8#, 16#A1D1_937E#, 16#38D8_C2C4#, 16#4FDF_F252#,
166 16#D1BB_67F1#, 16#A6BC_5767#, 16#3FB5_06DD#, 16#48B2_364B#,
167 16#D80D_2BDA#, 16#AF0A_1B4C#, 16#3603_4AF6#, 16#4104_7A60#,
168 16#DF60_EFC3#, 16#A867_DF55#, 16#316E_8EEF#, 16#4669_BE79#,
169 16#CB61_B38C#, 16#BC66_831A#, 16#256F_D2A0#, 16#5268_E236#,
170 16#CC0C_7795#, 16#BB0B_4703#, 16#2202_16B9#, 16#5505_262F#,
171 16#C5BA_3BBE#, 16#B2BD_0B28#, 16#2BB4_5A92#, 16#5CB3_6A04#,
172 16#C2D7_FFA7#, 16#B5D0_CF31#, 16#2CD9_9E8B#, 16#5BDE_AE1D#,
173 16#9B64_C2B0#, 16#EC63_F226#, 16#756A_A39C#, 16#026D_930A#,
174 16#9C09_06A9#, 16#EB0E_363F#, 16#7207_6785#, 16#0500_5713#,
175 16#95BF_4A82#, 16#E2B8_7A14#, 16#7BB1_2BAE#, 16#0CB6_1B38#,
176 16#92D2_8E9B#, 16#E5D5_BE0D#, 16#7CDC_EFB7#, 16#0BDB_DF21#,
177 16#86D3_D2D4#, 16#F1D4_E242#, 16#68DD_B3F8#, 16#1FDA_836E#,
178 16#81BE_16CD#, 16#F6B9_265B#, 16#6FB0_77E1#, 16#18B7_4777#,
179 16#8808_5AE6#, 16#FF0F_6A70#, 16#6606_3BCA#, 16#1101_0B5C#,
180 16#8F65_9EFF#, 16#F862_AE69#, 16#616B_FFD3#, 16#166C_CF45#,
181 16#A00A_E278#, 16#D70D_D2EE#, 16#4E04_8354#, 16#3903_B3C2#,
182 16#A767_2661#, 16#D060_16F7#, 16#4969_474D#, 16#3E6E_77DB#,
183 16#AED1_6A4A#, 16#D9D6_5ADC#, 16#40DF_0B66#, 16#37D8_3BF0#,
184 16#A9BC_AE53#, 16#DEBB_9EC5#, 16#47B2_CF7F#, 16#30B5_FFE9#,
185 16#BDBD_F21C#, 16#CABA_C28A#, 16#53B3_9330#, 16#24B4_A3A6#,
186 16#BAD0_3605#, 16#CDD7_0693#, 16#54DE_5729#, 16#23D9_67BF#,
187 16#B366_7A2E#, 16#C461_4AB8#, 16#5D68_1B02#, 16#2A6F_2B94#,
188 16#B40B_BE37#, 16#C30C_8EA1#, 16#5A05_DF1B#, 16#2D02_EF8D#);
189
190 end CRC32;
-(0 . 0)(1 . 61)
195 ------------------------------------------------------------------------------
196 ------------------------------------------------------------------------------
197 -- CRC32 checksum lib --
198 -- S.MG, 2018 --
199 -- --
200 -- You do not have, nor can you ever acquire the right to use, copy or --
201 -- distribute this software ; Should you use this software for any purpose, --
202 -- or copy and distribute it to anyone or in any manner, you are breaking --
203 -- the laws of whatever soi-disant jurisdiction, and you promise to --
204 -- continue doing so for the indefinite future. In any case, please --
205 -- always : read and understand any software ; verify any PGP signatures --
206 -- that you use - for any purpose. --
207 -- --
208 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
209 ------------------------------------------------------------------------------
210 ------------------------------------------------------------------------------
211
212 project CRC32 is
213
214 for Object_Dir use "obj";
215
216 type Mode_Type is ("debug", "release");
217 Mode : Mode_Type := external ("mode", "release");
218
219 for Languages use ("Ada");
220 for Source_Dirs use (".");
221 for Library_Dir use "lib";
222 for Library_Name use "CRC32";
223 for Library_Kind use "static";
224
225 package Compiler is
226 case Mode is
227 when "debug" =>
228 for Switches ("Ada")
229 use ("-g");
230 when "release" =>
231 for Switches ("Ada")
232 use ("-O2", "-fdump-scos", "-gnata", "-fstack-check",
233 "-gnatyd", "-gnatym",
234 "-fdata-sections", "-ffunction-sections", "-gnatwr", "-gnatw.d",
235 "-gnatec=" & CRC32'Project_Dir & "restrict.adc");
236 end case;
237 end Compiler;
238
239 package Builder is
240 for Switches ("Ada")
241 use ("-nostdlib");
242 end Builder;
243
244 package Binder is
245 case Mode is
246 when "debug" =>
247 for Switches ("Ada")
248 use ();
249 when "release" =>
250 for Switches ("Ada")
251 use ("-static");
252 end case;
253 end Binder;
254
255 end CRC32;
-(0 . 0)(1 . 1)
260 placeholder
-(0 . 0)(1 . 1)
265 placeholder
-(0 . 0)(1 . 80)
270 ------------------------------------------------------------------------------
271 ------------------------------------------------------------------------------
272 -- This file is part of 'CRC32' --
273 -- --
274 -- You do not have, nor can you ever acquire the right to use, copy or --
275 -- distribute this software ; Should you use this software for any purpose, --
276 -- or copy and distribute it to anyone or in any manner, you are breaking --
277 -- the laws of whatever soi-disant jurisdiction, and you promise to --
278 -- continue doing so for the indefinite future. In any case, please --
279 -- always : read and understand any software ; verify any PGP signatures --
280 -- that you use - for any purpose. --
281 -- --
282 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
283 ------------------------------------------------------------------------------
284 ------------------------------------------------------------------------------
285
286 pragma Restrictions(Immediate_Reclamation);
287 pragma Restrictions(Max_Asynchronous_Select_Nesting => 0);
288 pragma Restrictions(Max_Protected_Entries => 0);
289 pragma Restrictions(Max_Select_Alternatives => 0);
290 pragma Restrictions(Max_Task_Entries => 0);
291 pragma Restrictions(Max_Tasks => 0);
292 pragma Restrictions(No_Abort_Statements);
293 pragma Restrictions(No_Access_Parameter_Allocators);
294 pragma Restrictions(No_Allocators);
295 pragma Restrictions(No_Asynchronous_Control);
296 pragma Restrictions(No_Calendar);
297 pragma Restrictions(No_Coextensions);
298 pragma Restrictions(No_Default_Stream_Attributes);
299 pragma Restrictions(No_Delay);
300 pragma Restrictions(No_Dispatch);
301 pragma Restrictions(No_Dispatching_Calls);
302 pragma Restrictions(No_Dynamic_Attachment);
303 pragma Restrictions(No_Dynamic_Priorities);
304 pragma Restrictions(No_Entry_Calls_In_Elaboration_Code);
305 pragma Restrictions(No_Entry_Queue);
306 pragma Restrictions(No_Enumeration_Maps);
307 pragma Restrictions(No_Exception_Propagation);
308 pragma Restrictions(No_Exception_Registration);
309 pragma Restrictions(No_Finalization);
310 pragma Restrictions(No_Fixed_Io);
311 pragma Restrictions(No_Floating_Point);
312 pragma Restrictions(No_Implementation_Aspect_Specifications);
313 pragma Restrictions(No_Implementation_Units);
314 pragma Restrictions(No_Implicit_Conditionals);
315 pragma Restrictions(No_Implicit_Dynamic_Code);
316 pragma Restrictions(No_Implicit_Heap_Allocations);
317 pragma Restrictions(No_Implicit_Protected_Object_Allocations);
318 pragma Restrictions(No_Implicit_Task_Allocations);
319 pragma Restrictions(No_Initialize_Scalars);
320 pragma Restrictions(No_Local_Protected_Objects);
321 pragma Restrictions(No_Local_Timing_Events);
322 pragma Restrictions(No_Multiple_Elaboration);
323 pragma Restrictions(No_Nested_Finalization);
324 pragma Restrictions(No_Protected_Type_Allocators);
325 pragma Restrictions(No_Protected_Types);
326 pragma Restrictions(No_Relative_Delay);
327 pragma Restrictions(No_Requeue_Statements);
328 pragma Restrictions(No_Secondary_Stack);
329 pragma Restrictions(No_Select_Statements);
330 pragma Restrictions(No_Specific_Termination_Handlers);
331 pragma Restrictions(No_Standard_Allocators_After_Elaboration);
332 pragma Restrictions(No_Stream_Optimizations);
333 pragma Restrictions(No_Streams);
334 pragma Restrictions(No_Task_Allocators);
335 pragma Restrictions(No_Task_At_Interrupt_Priority);
336 pragma Restrictions(No_Task_Attributes_Package);
337 pragma Restrictions(No_Task_Hierarchy);
338 pragma Restrictions(No_Tasking);
339 pragma Restrictions(No_Task_Termination);
340 pragma Restrictions(No_Terminate_Alternatives);
341 pragma Restrictions(No_Unchecked_Access);
342 pragma Restrictions(No_Unchecked_Conversion);
343 pragma Restrictions(No_Unchecked_Deallocation);
344 pragma Restrictions(No_Wide_Characters);
345 pragma Restrictions(Pure_Barriers);
346 pragma Restrictions(Simple_Barriers);
347 pragma Restrictions(Static_Priorities);
348 pragma Restrictions(Static_Storage_Size);
349 pragma Validity_Checks(ALL_CHECKS);
-(0 . 0)(1 . 1)
354 obj
-(0 . 0)(1 . 39)
359 ------------------------------------------------------------------------------
360 ------------------------------------------------------------------------------
361 -- This file is part of 'CRC32' --
362 -- --
363 -- You do not have, nor can you ever acquire the right to use, copy or --
364 -- distribute this software ; Should you use this software for any purpose, --
365 -- or copy and distribute it to anyone or in any manner, you are breaking --
366 -- the laws of whatever soi-disant jurisdiction, and you promise to --
367 -- continue doing so for the indefinite future. In any case, please --
368 -- always : read and understand any software ; verify any PGP signatures --
369 -- that you use - for any purpose. --
370 -- --
371 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
372 ------------------------------------------------------------------------------
373 ------------------------------------------------------------------------------
374
375 -- Basic test for the CRC32 implementation
376 -- S.MG, 2018
377
378 with Ada.Text_IO; use Ada.Text_IO;
379 with Interfaces; use Interfaces;
380 with CRC32;
381
382 procedure Test_CRC32 is
383 Input : constant String := "123456789";
384 Expected : constant Unsigned_32 := 16#CBF4_3926#;
385 Output : Unsigned_32;
386 begin
387 Output := CRC32.CRC(Input);
388 if Output /= Expected then
389 Put_Line("FAIL: CRC32(" & Input & ") returned " &
390 Unsigned_32'Image(Output) & " instead of " &
391 Unsigned_32'Image(Expected));
392 else
393 Put_Line("PASS: CRC32(" & Input & ") returned " &
394 Unsigned_32'Image(Output) & " as expected.");
395 end if;
396
397 end Test_CRC32;
-(0 . 0)(1 . 24)
402 -- Tests project for CRC32 lib
403 -- S.MG, 2018
404
405 with "../crc32.gpr";
406
407 project Tests is
408
409 for Object_Dir use "obj";
410
411 for Languages use ("Ada");
412 for Source_Dirs use (".");
413 for Exec_Dir use ".";
414
415 for Main use ("test_crc32.adb");
416
417 package Compiler is
418 for Switches ("Ada")
419 use ("-O2", "-fdump-scos", "-gnata", "-fstack-check",
420 "-gnatyd", "-gnatym",
421 "-fdata-sections", "-ffunction-sections", "-gnatwr", "-gnatw.d",
422 "-gnatec=" & CRC32'Project_Dir & "restrict.adc");
423 end Compiler;
424
425 end Tests;
- 94D4FB2C29F384693F39A994B26A95276EA949C1BFCCA5D438581DD8EE609E400606B3FA59A413A5E330BD7781CA82F668D8C4DB2EAC6EECD67BC4529067D786(6 . 7)(6 . 8)
430 "smg_bit_keccak/smg_bit_keccak.gpr",
431 "smg_keccak/smg_keccak.gpr",
432 "smg_rsa/smg_rsa.gpr",
433 "smg_serpent/smg_serpent.gpr");
434 "smg_serpent/smg_serpent.gpr",
435 "crc32/crc32.gpr");
436
437 for Library_Name use "EuCrypt";
438 for Library_Kind use "static";
- 36DD3853F41604790D69B6DB28D86933A068B0F5D64CF2224E7FD3371497E21A92B0DBB84E4367B112C55F57F35A6EC076A8E04729EA7FD8F87BBD79D846C95D(18 . 4)(18 . 4)
443 521090 eucrypt_ch13_smg_rng diana_coman Adds methods for obtaining random values directly from bits obtained from the entropy source. Following specific types are supported: unsigned int on 32 bits, unsigned int on 64 bits, dirty float between 0 and 1, float IEEE 754/1985 between 1 and 2.
444 527560 eucrypt_manifest diana_coman Adds this manifest file that should be modified each time a new patch is added to EuCrypt.
445 543780 eucrypt_fix_256 diana_coman Fix the error in smg_oaep.adb that used 255 instead of 256 when calculating/retrieving length stored on 2 octets.
446
447 545170 eucrypt_ch14_crc32 diana_coman A simple implementation of CRC32 checksum using a lookup table. The CRC32 lib can be compiled on its own or together with the whole EuCrypt.