From 4e80ce6278f91fb2310e7749c9b7d894ab7d0614 Mon Sep 17 00:00:00 2001 From: charlet Date: Mon, 30 Nov 2009 15:00:17 +0000 Subject: [PATCH] 2009-11-30 Robert Dewar * sem_prag.adb, s-sechas.ads, s-sechas.adb: Minor reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154816 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 4 ++++ gcc/ada/s-sechas.adb | 36 ++++++++++++++++++------------------ gcc/ada/s-sechas.ads | 33 +++++++++++++++++---------------- gcc/ada/sem_prag.adb | 3 ++- 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d15cb8b..9a3556c 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,7 @@ +2009-11-30 Robert Dewar + + * sem_prag.adb, s-sechas.ads, s-sechas.adb: Minor reformatting. + 2009-11-30 Gary Dismukes * sem_prag.adb (Process_Convention): Change formal E to Ent. In the diff --git a/gcc/ada/s-sechas.adb b/gcc/ada/s-sechas.adb index 09036f3..0b1fab3 100644 --- a/gcc/ada/s-sechas.adb +++ b/gcc/ada/s-sechas.adb @@ -79,8 +79,10 @@ package body System.Secure_Hashes is Buf_String : String (M.Buffer'Range); for Buf_String'Address use M.Buffer'Address; pragma Import (Ada, Buf_String); + 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 pragma Assert (Length > 0); @@ -162,10 +164,6 @@ package body System.Secure_Hashes is end return; end Digest; - ------------ - -- Digest -- - ------------ - function Digest (S : String) return Message_Digest is C : Context; begin @@ -173,10 +171,6 @@ package body System.Secure_Hashes is return Digest (C); end Digest; - ------------ - -- Digest -- - ------------ - function Digest (A : Stream_Element_Array) return Message_Digest is C : Context; begin @@ -215,27 +209,31 @@ package body System.Secure_Hashes is declare Pad : String (1 .. 1 + Zeroes + Size_Length) := (1 => Character'Val (128), others => ASCII.NUL); - Index : Natural; + + Index : Natural; First_Index : Natural; + begin - First_Index := (if Hash_Bit_Order = Low_Order_First then - Pad'Last - Size_Length + 1 - else - Pad'Last); + First_Index := (if Hash_Bit_Order = Low_Order_First + then Pad'Last - Size_Length + 1 + else Pad'Last); Index := First_Index; while Message_Length > 0 loop if Index = First_Index then + -- Message_Length is in bytes, but we need to store it as -- a bit count). Pad (Index) := Character'Val (Shift_Left (Message_Length and 16#1f#, 3)); Message_Length := Shift_Right (Message_Length, 5); + else Pad (Index) := Character'Val (Message_Length and 16#ff#); Message_Length := Shift_Right (Message_Length, 8); end if; + Index := Index + (if Hash_Bit_Order = Low_Order_First then 1 else -1); end loop; @@ -258,6 +256,7 @@ package body System.Secure_Hashes is Fill_Buffer : Fill_Buffer_Access) is Last : Natural := S'First - 1; + begin C.M_State.Length := C.M_State.Length + S'Length; @@ -305,8 +304,8 @@ package body System.Secure_Hashes is Update (C, S, (if System.Default_Bit_Order /= Low_Order_First - then Fill_Buffer_Swap'Access - else Fill_Buffer_Copy'Access)); + then Fill_Buffer_Swap'Access + else Fill_Buffer_Copy'Access)); end Wide_Update; ----------------- @@ -334,12 +333,13 @@ package body System.Secure_Hashes is procedure To_Hash (H : State; H_Bits : out Stream_Element_Array) is Hash_Words : constant Natural := H'Size / Word'Size; - Result : State (1 .. Hash_Words) := - H (H'Last - Hash_Words + 1 .. H'Last); + Result : State (1 .. Hash_Words) := + H (H'Last - Hash_Words + 1 .. H'Last); R_SEA : Stream_Element_Array (1 .. Result'Size / 8); for R_SEA'Address use Result'Address; pragma Import (Ada, R_SEA); + begin if System.Default_Bit_Order /= Hash_Bit_Order then for J in Result'Range loop diff --git a/gcc/ada/s-sechas.ads b/gcc/ada/s-sechas.ads index aeb1761..3333083 100644 --- a/gcc/ada/s-sechas.ads +++ b/gcc/ada/s-sechas.ads @@ -43,12 +43,11 @@ package System.Secure_Hashes is -- Secure hash functions use a string buffer that is also accessed as an -- array of words, which may require up to 64 bit alignment. - -- The function-independent part of processing state: - -- A buffer of data being accumulated until a complete block is ready for - -- hashing. + -- The function-independent part of processing state: A buffer of data + -- being accumulated until a complete block is ready for hashing. type Message_State (Block_Length : Natural) is record - Last : Natural := 0; + Last : Natural := 0; -- Index of last used element in Buffer Length : Interfaces.Unsigned_64 := 0; @@ -59,6 +58,7 @@ package System.Secure_Hashes is end record; -- The function-specific part of processing state: + -- Each hash function maintains an internal state as an array of words, -- which is ultimately converted to a stream representation with the -- appropriate bit order. @@ -92,13 +92,13 @@ package System.Secure_Hashes is -- instance of this generic package. generic - Block_Words : Natural; + Block_Words : Natural; -- Number of words in each block - State_Words : Natural; + State_Words : Natural; -- Number of words in internal state - Hash_Words : Natural; + Hash_Words : Natural; -- Number of words in the final hash (must be no greater than -- State_Words). @@ -132,21 +132,22 @@ package System.Secure_Hashes is procedure Update (C : in out Context; Input : String); procedure Wide_Update (C : in out Context; Input : Wide_String); procedure Update - (C : in out Context; Input : Ada.Streams.Stream_Element_Array); - -- Update C to process the given input. Successive calls to - -- Update are equivalent to a single call with the concatenation - -- of the inputs. For the Wide_String version, each Wide_Character is - -- processed low order byte first. + (C : in out Context; + Input : Ada.Streams.Stream_Element_Array); + -- Update C to process the given input. Successive calls to Update are + -- equivalent to a single call with the concatenation of the inputs. For + -- the Wide_String version, each Wide_Character is processed low order + -- byte first. Word_Length : constant Natural := Hash_State.Word'Size / 8; Hash_Length : constant Natural := Hash_Words * Word_Length; subtype Message_Digest is String (1 .. 2 * Hash_Length); - -- The fixed-length string returned by Digest, providing the - -- hash in hexadecimal representation. + -- The fixed-length string returned by Digest, providing the hash in + -- hexadecimal representation. - function Digest (C : Context) return Message_Digest; - -- Return the hash for the data accumulated with C in hexadecimal + function Digest (C : Context) return Message_Digest; + -- Return hash for the data accumulated with C in hexadecimal -- representation. function Digest (S : String) return Message_Digest; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index cccc198..f88c6bd 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -597,7 +597,8 @@ package body Sem_Prag is -- Common processing for Compile_Time_Error and Compile_Time_Warning 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. -- Checks first two arguments of pragma, and sets the appropriate -- convention value in the specified entity or entities. On return -- 2.7.4