tree checksum vpatch file split hunks
all signers: phf
antecedents: vtools_vpatch_newline
press order:
vtools_genesis | phf |
vdiff_fixes_newline_gcc | phf |
keccak | phf |
vdiff_keccak | phf |
vtools_fixes_bitrate_char_array | phf |
vtools_vpatch | phf |
vtools_fixes_static_tohex | phf |
vtools_vpatch_newline | phf |
vtools_ksum | phf |
patch:
(0 . 0)(1 . 7)
5 project Ksum is
6 for Languages use ("Ada");
7 for Source_Dirs use ("src");
8 for Object_Dir use "obj";
9 for Exec_Dir use ".";
10 for Main use ("ksum.adb");
11 end Ksum;
- 46F4DCEB24634A095A5AE2E5993D41AE1D12EC92275E4DBC83DD6737E3512FB2608C2065B0307EDDFBAC4D3E0782EDC9DFB3CA74A94962630AD7482E09B1096D(6 . 3)(6 . 4)
16 514700 phf vtools_vpatch Initial vpatch tool implementation in Ada.
17 517100 phf vtools_fixes_static_tohex Fixes for xalloc's use of static inline courtesy of spyked, fix broken ToHex implementation
18 517100 phf vtools_vpatch_newline Vpatch tool support for "No newline at end of file" directive.
19 543200 phf vtools_ksum Ksum standalone keccak hasher
-(0 . 0)(1 . 69)
24 with Ada.Command_Line; use Ada.Command_Line;
25 with Ada.Directories;use Ada.Directories;
26 with Ada.Exceptions;
27 with Ada.Io_Exceptions;
28 with Ada.Sequential_IO;
29 with Ada.Text_IO; use Ada.Text_IO;
30 with Bits; use Bits;
31 with Interfaces; use Interfaces;
32 with SMG_Keccak; use SMG_Keccak;
33 with Character_IO; use Character_IO;
34 procedure Ksum is
35 Buffer_Size: constant Natural := 2048;
36 Hash_Size: constant Natural := 64;
37 Byte_Size: constant Natural := 8;
38
39 package CIO renames Character_IO.Character_IO;
40 Fs: File_Size;
41 File: CIO.File_Type;
42 Ctx: Keccak_Context(Block_Len=>Default_Bitrate);
43 Buf: String(1..Buffer_Size);
44 B: Bitstream(1..Buf'Length*Byte_Size);
45
46 function Read_Buffer return Integer is
47 C: Character;
48 begin
49 for I in 1..Buf'Length loop
50 CIO.Read(File, C);
51 Buf(I):=C;
52 if End_Of_File(File) then
53 return I;
54 end if;
55 end loop;
56 return Buf'Length;
57 end Read_Buffer;
58
59 begin
60 for Arg in 1..Argument_Count loop
61 declare
62 Filename: String:=Argument(Arg);
63 begin
64 Fs:=Size(Filename);
65 Character_IO.Open(File, CIO.In_File, Filename);
66 declare
67 O: Bitstream(1..Hash_Size*Byte_Size);
68 N: Integer;
69 begin
70 KeccakBegin(Ctx);
71 Read_Loop:
72 loop
73 exit Read_Loop when End_Of_File(File);
74 N := Read_Buffer;
75 ToBitstream(Buf(1..N), B(1..N*Byte_Size));
76 KeccakHash(Ctx, B(1..N*Byte_Size));
77 end loop Read_Loop;
78 KeccakEnd(Ctx, O);
79 declare
80 Hex: String := ToHex(O);
81 begin
82 Put(Hex); Put(" "); Put_Line(Filename);
83 end;
84 end;
85 Character_IO.Close(File);
86 exception
87 when The_Error : others =>
88 Put(Standard_Error, Filename); Put(": ");
89 Put_Line(Ada.Exceptions.Exception_Message(The_Error));
90 end;
91 end loop;
92 end;