Commit 9cf032ef by Robert Dewar Committed by Arnaud Charlet

sem_prag.adb, [...]: Minor reformatting.

2009-11-30  Robert Dewar  <dewar@adacore.com>

	* sem_prag.adb, s-sechas.ads, s-sechas.adb: Minor reformatting.

From-SVN: r154816
parent 9fe2f33e
2009-11-30 Robert Dewar <dewar@adacore.com>
* sem_prag.adb, s-sechas.ads, s-sechas.adb: Minor reformatting.
2009-11-30 Gary Dismukes <dismukes@adacore.com> 2009-11-30 Gary Dismukes <dismukes@adacore.com>
* sem_prag.adb (Process_Convention): Change formal E to Ent. In the * sem_prag.adb (Process_Convention): Change formal E to Ent. In the
......
...@@ -79,8 +79,10 @@ package body System.Secure_Hashes is ...@@ -79,8 +79,10 @@ package body System.Secure_Hashes is
Buf_String : String (M.Buffer'Range); Buf_String : String (M.Buffer'Range);
for Buf_String'Address use M.Buffer'Address; for Buf_String'Address use M.Buffer'Address;
pragma Import (Ada, Buf_String); pragma Import (Ada, Buf_String);
Length : constant Natural := Length : constant Natural :=
Natural'Min (M.Block_Length - M.Last, S'Last - First + 1); Natural'Min (M.Block_Length - M.Last, S'Last - First + 1);
begin begin
pragma Assert (Length > 0); pragma Assert (Length > 0);
...@@ -162,10 +164,6 @@ package body System.Secure_Hashes is ...@@ -162,10 +164,6 @@ package body System.Secure_Hashes is
end return; end return;
end Digest; end Digest;
------------
-- Digest --
------------
function Digest (S : String) return Message_Digest is function Digest (S : String) return Message_Digest is
C : Context; C : Context;
begin begin
...@@ -173,10 +171,6 @@ package body System.Secure_Hashes is ...@@ -173,10 +171,6 @@ package body System.Secure_Hashes is
return Digest (C); return Digest (C);
end Digest; end Digest;
------------
-- Digest --
------------
function Digest (A : Stream_Element_Array) return Message_Digest is function Digest (A : Stream_Element_Array) return Message_Digest is
C : Context; C : Context;
begin begin
...@@ -215,27 +209,31 @@ package body System.Secure_Hashes is ...@@ -215,27 +209,31 @@ package body System.Secure_Hashes is
declare declare
Pad : String (1 .. 1 + Zeroes + Size_Length) := Pad : String (1 .. 1 + Zeroes + Size_Length) :=
(1 => Character'Val (128), others => ASCII.NUL); (1 => Character'Val (128), others => ASCII.NUL);
Index : Natural;
Index : Natural;
First_Index : Natural; First_Index : Natural;
begin begin
First_Index := (if Hash_Bit_Order = Low_Order_First then First_Index := (if Hash_Bit_Order = Low_Order_First
Pad'Last - Size_Length + 1 then Pad'Last - Size_Length + 1
else else Pad'Last);
Pad'Last);
Index := First_Index; Index := First_Index;
while Message_Length > 0 loop while Message_Length > 0 loop
if Index = First_Index then if Index = First_Index then
-- Message_Length is in bytes, but we need to store it as -- Message_Length is in bytes, but we need to store it as
-- a bit count). -- a bit count).
Pad (Index) := Character'Val Pad (Index) := Character'Val
(Shift_Left (Message_Length and 16#1f#, 3)); (Shift_Left (Message_Length and 16#1f#, 3));
Message_Length := Shift_Right (Message_Length, 5); Message_Length := Shift_Right (Message_Length, 5);
else else
Pad (Index) := Character'Val (Message_Length and 16#ff#); Pad (Index) := Character'Val (Message_Length and 16#ff#);
Message_Length := Shift_Right (Message_Length, 8); Message_Length := Shift_Right (Message_Length, 8);
end if; end if;
Index := Index + Index := Index +
(if Hash_Bit_Order = Low_Order_First then 1 else -1); (if Hash_Bit_Order = Low_Order_First then 1 else -1);
end loop; end loop;
...@@ -258,6 +256,7 @@ package body System.Secure_Hashes is ...@@ -258,6 +256,7 @@ package body System.Secure_Hashes is
Fill_Buffer : Fill_Buffer_Access) Fill_Buffer : Fill_Buffer_Access)
is is
Last : Natural := S'First - 1; Last : Natural := S'First - 1;
begin begin
C.M_State.Length := C.M_State.Length + S'Length; C.M_State.Length := C.M_State.Length + S'Length;
...@@ -305,8 +304,8 @@ package body System.Secure_Hashes is ...@@ -305,8 +304,8 @@ package body System.Secure_Hashes is
Update Update
(C, S, (C, S,
(if System.Default_Bit_Order /= Low_Order_First (if System.Default_Bit_Order /= Low_Order_First
then Fill_Buffer_Swap'Access then Fill_Buffer_Swap'Access
else Fill_Buffer_Copy'Access)); else Fill_Buffer_Copy'Access));
end Wide_Update; end Wide_Update;
----------------- -----------------
...@@ -334,12 +333,13 @@ package body System.Secure_Hashes is ...@@ -334,12 +333,13 @@ package body System.Secure_Hashes is
procedure To_Hash (H : State; H_Bits : out Stream_Element_Array) is procedure To_Hash (H : State; H_Bits : out Stream_Element_Array) is
Hash_Words : constant Natural := H'Size / Word'Size; Hash_Words : constant Natural := H'Size / Word'Size;
Result : State (1 .. Hash_Words) := Result : State (1 .. Hash_Words) :=
H (H'Last - Hash_Words + 1 .. H'Last); H (H'Last - Hash_Words + 1 .. H'Last);
R_SEA : Stream_Element_Array (1 .. Result'Size / 8); R_SEA : Stream_Element_Array (1 .. Result'Size / 8);
for R_SEA'Address use Result'Address; for R_SEA'Address use Result'Address;
pragma Import (Ada, R_SEA); pragma Import (Ada, R_SEA);
begin begin
if System.Default_Bit_Order /= Hash_Bit_Order then if System.Default_Bit_Order /= Hash_Bit_Order then
for J in Result'Range loop for J in Result'Range loop
......
...@@ -43,12 +43,11 @@ package System.Secure_Hashes is ...@@ -43,12 +43,11 @@ package System.Secure_Hashes is
-- Secure hash functions use a string buffer that is also accessed as an -- Secure hash functions use a string buffer that is also accessed as an
-- array of words, which may require up to 64 bit alignment. -- array of words, which may require up to 64 bit alignment.
-- The function-independent part of processing state: -- The function-independent part of processing state: A buffer of data
-- A buffer of data being accumulated until a complete block is ready for -- being accumulated until a complete block is ready for hashing.
-- hashing.
type Message_State (Block_Length : Natural) is record type Message_State (Block_Length : Natural) is record
Last : Natural := 0; Last : Natural := 0;
-- Index of last used element in Buffer -- Index of last used element in Buffer
Length : Interfaces.Unsigned_64 := 0; Length : Interfaces.Unsigned_64 := 0;
...@@ -59,6 +58,7 @@ package System.Secure_Hashes is ...@@ -59,6 +58,7 @@ package System.Secure_Hashes is
end record; end record;
-- The function-specific part of processing state: -- The function-specific part of processing state:
-- Each hash function maintains an internal state as an array of words, -- Each hash function maintains an internal state as an array of words,
-- which is ultimately converted to a stream representation with the -- which is ultimately converted to a stream representation with the
-- appropriate bit order. -- appropriate bit order.
...@@ -92,13 +92,13 @@ package System.Secure_Hashes is ...@@ -92,13 +92,13 @@ package System.Secure_Hashes is
-- instance of this generic package. -- instance of this generic package.
generic generic
Block_Words : Natural; Block_Words : Natural;
-- Number of words in each block -- Number of words in each block
State_Words : Natural; State_Words : Natural;
-- Number of words in internal state -- Number of words in internal state
Hash_Words : Natural; Hash_Words : Natural;
-- Number of words in the final hash (must be no greater than -- Number of words in the final hash (must be no greater than
-- State_Words). -- State_Words).
...@@ -132,21 +132,22 @@ package System.Secure_Hashes is ...@@ -132,21 +132,22 @@ package System.Secure_Hashes is
procedure Update (C : in out Context; Input : String); procedure Update (C : in out Context; Input : String);
procedure Wide_Update (C : in out Context; Input : Wide_String); procedure Wide_Update (C : in out Context; Input : Wide_String);
procedure Update procedure Update
(C : in out Context; Input : Ada.Streams.Stream_Element_Array); (C : in out Context;
-- Update C to process the given input. Successive calls to Input : Ada.Streams.Stream_Element_Array);
-- Update are equivalent to a single call with the concatenation -- Update C to process the given input. Successive calls to Update are
-- of the inputs. For the Wide_String version, each Wide_Character is -- equivalent to a single call with the concatenation of the inputs. For
-- processed low order byte first. -- the Wide_String version, each Wide_Character is processed low order
-- byte first.
Word_Length : constant Natural := Hash_State.Word'Size / 8; Word_Length : constant Natural := Hash_State.Word'Size / 8;
Hash_Length : constant Natural := Hash_Words * Word_Length; Hash_Length : constant Natural := Hash_Words * Word_Length;
subtype Message_Digest is String (1 .. 2 * Hash_Length); subtype Message_Digest is String (1 .. 2 * Hash_Length);
-- The fixed-length string returned by Digest, providing the -- The fixed-length string returned by Digest, providing the hash in
-- hash in hexadecimal representation. -- hexadecimal representation.
function Digest (C : Context) return Message_Digest; function Digest (C : Context) return Message_Digest;
-- Return the hash for the data accumulated with C in hexadecimal -- Return hash for the data accumulated with C in hexadecimal
-- representation. -- representation.
function Digest (S : String) return Message_Digest; function Digest (S : String) return Message_Digest;
......
...@@ -597,7 +597,8 @@ package body Sem_Prag is ...@@ -597,7 +597,8 @@ package body Sem_Prag is
-- Common processing for Compile_Time_Error and Compile_Time_Warning -- Common processing for Compile_Time_Error and Compile_Time_Warning
procedure Process_Convention procedure Process_Convention
(C : out Convention_Id; Ent : out Entity_Id); (C : out Convention_Id;
Ent : out Entity_Id);
-- Common processing for Convention, Interface, Import and Export. -- Common processing for Convention, Interface, Import and Export.
-- Checks first two arguments of pragma, and sets the appropriate -- Checks first two arguments of pragma, and sets the appropriate
-- convention value in the specified entity or entities. On return -- convention value in the specified entity or entities. On return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment