- 252A6F237724580F4AF2F1FBF2DFF39DCDD7C1A14AC7C17021D4ED0D0939F6394BF2CBCE3E2ECC3261B8474ECF0D7DE34728467679E557A7C44BAD510D070747
+ 8B4ED2ECAE1C6FEE1CC25F280351F57E4329D048617754F580CCC2DF61734EDE8D64D26DFF20F29810A345B3E376ED6455F78E792EB02AF14D1E5C6C757771FD
vtools/src/keccak_c.adb
(1 . 43)(1 . 5)
113 with Bits; use Bits;
114 package body Keccak_C is
115 -- helper functions
116 procedure ToBitstream(S: in String; B: out Bitstream ) is
117 V : Unsigned_8;
118 Pos : Natural;
119 begin
120 Pos := B'First;
121 for C of S loop
122 V := Character'Pos( C );
123 B( Pos ) := Bit( V and 1 );
124 B( Pos + 1 ) := Bit( Shift_Right( V, 1 ) and 1 );
125 B( Pos + 2 ) := Bit( Shift_Right( V, 2 ) and 1 );
126 B( Pos + 3 ) := Bit( Shift_Right( V, 3 ) and 1 );
127 B( Pos + 4 ) := Bit( Shift_Right( V, 4 ) and 1 );
128 B( Pos + 5 ) := Bit( Shift_Right( V, 5 ) and 1 );
129 B( Pos + 6 ) := Bit( Shift_Right( V, 6 ) and 1 );
130 B( Pos + 7 ) := Bit( Shift_Right( V, 7 ) and 1 );
131 Pos := Pos + 8;
132 end loop;
133 end ToBitstream;
134
135 procedure ToString(B: in Bitstream; S: out String ) is
136 N : Natural;
137 Pos : Natural;
138 begin
139 Pos := B'First;
140 for I in S'Range loop
141 N := Natural( B( Pos ) ) +
142 Natural( B( Pos + 1 ) ) * 2 +
143 Natural( B( Pos + 2 ) ) * 4 +
144 Natural( B( Pos + 3 ) ) * 8 +
145 Natural( B( Pos + 4 ) ) * 16 +
146 Natural( B( Pos + 5 ) ) * 32 +
147 Natural( B( Pos + 6 ) ) * 64 +
148 Natural( B( Pos + 7 ) ) * 128;
149 Pos := Pos + 8;
150 S( I ) := Character'Val( N );
151 end loop;
152 end ToString;
153
154 -- C interface
155
156 procedure C_Get_Size(Size: out Interfaces.C.size_t) is
(62 . 7)(24 . 7)
158 Ptr: Char_Star := Input;
159 begin
160 if Input = null then
161 raise C.Strings.Dereference_Error;
162 raise Strings.Dereference_Error;
163 end if;
164 for Chr of S loop
165 Chr := Character(Ptr.all);
(81 . 7)(43 . 7)
167 Ptr: Char_Star := Output;
168 begin
169 if Output = null then
170 raise C.Strings.Dereference_Error;
171 raise Strings.Dereference_Error;
172 end if;
173 KeccakEnd(Ctx.all, B);
174 ToString(B, S);