Package: LSC.SHA512

Dependencies

with LSC.Types;

use type LSC.Types.Index;
use type LSC.Types.Word64;

Description

The SHA-512 and SHA-386 hash algorithms

Header

package LSC.SHA512 is
 

Known child units

LSC.SHA512.Tables(private package)

Type Summary

Context_Type
Primitive Operations:  Context_Finalize, Context_Update, SHA384_Context_Init, SHA384_Get_Hash, SHA512_Context_Init, SHA512_Get_Hash
Message_Type

Constants and Named Numbers

Block_Size : constant := 1024;
SHA-512 block size
Null_Block : constant Block_Type;
Empty block
Null_SHA384_Hash : constant SHA384_Hash_Type;
Empty SHA-384 hash
Null_SHA512_Hash : constant SHA512_Hash_Type;
Empty SHA-512 hash

Other Items:

type Context_Type is private;
SHA-512 context

subtype Block_Index is Types.Index range 0 .. 15;
Index for SHA-512 block

subtype Block_Type is Types.Word64_Array_Type (Block_Index);
SHA-512 block

subtype SHA512_Hash_Index is Types.Index range 0 .. 7;
Index for SHA-512 hash

subtype SHA512_Hash_Type is Types.Word64_Array_Type (SHA512_Hash_Index);
SHA-512 hash

subtype SHA384_Hash_Index is Types.Index range 0 .. 5;
Index for SHA-384 hash

subtype SHA384_Hash_Type is Types.Word64_Array_Type (SHA384_Hash_Index);
SHA-384 hash

subtype Block_Length_Type is Types.Word64 range 0 .. Block_Size - 1;
SHA-512 block length

subtype Message_Index is Types.Word64 range 0 .. 2**64 - 1;
Index for SHA-512 message

A SHA-512 hash can be at most 2^128 bit long. As one block has 1024 bit, this makes 2^118 blocks. NOTE: We support a size of 2^64 only!


type Message_Type is array (Message_Index range <>) of Block_Type;
SHA-512 message

function SHA512_Context_Init return Context_Type;
Initialize SHA-512 context.

function SHA384_Context_Init return Context_Type;
Initialize SHA-384 context.

procedure Context_Update
  (Context : in out Context_Type;
   Block   : in     Block_Type);
pragma Inline (Context_Update);
Update SHA-512 Context context with message block Block.
 derives Context from *,
                      Block;

procedure Context_Finalize
  (Context : in out Context_Type;
   Block   : in     Block_Type;
   Length  : in     Block_Length_Type);
Finalize SHA-512 context Context using Length bits of final message block Block.
 derives Context from *,
                      Block,
                      Length;

function SHA512_Get_Hash (Context : Context_Type) return SHA512_Hash_Type;
Return SHA-512 hash.

function SHA384_Get_Hash (Context : Context_Type) return SHA384_Hash_Type;
Return SHA-384 hash.

private

   --  Implementation-defined ...
end LSC.SHA512;