| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT LIBRARY COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- G N A T . S E C U R E _ H A S H E S . S H A 2 _ C O M M O N -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2009-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
-- This package provides supporting code for implementation of the following |
| 33 |
-- secure hash functions described in FIPS PUB 180-3: SHA-224, SHA-256, |
| 34 |
-- SHA-384, SHA-512. It contains the generic transform operation that is |
| 35 |
-- common to the above four functions. The complete text of FIPS PUB 180-3 |
| 36 |
-- can be found at: |
| 37 |
-- http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf |
| 38 |
|
| 39 |
-- This is an internal unit and should not be used directly in applications. |
| 40 |
-- Use GNAT.SHA* instead. |
| 41 |
|
| 42 |
package GNAT.Secure_Hashes.SHA2_Common is |
| 43 |
|
| 44 |
Block_Words : constant := 16; |
| 45 |
-- All functions operate on blocks of 16 words |
| 46 |
|
| 47 |
generic |
| 48 |
with package Hash_State is new Hash_Function_State (<>); |
| 49 |
|
| 50 |
Rounds : Natural; |
| 51 |
-- Number of transformation rounds |
| 52 |
|
| 53 |
K : Hash_State.State; |
| 54 |
-- Constants used in the transform operation |
| 55 |
|
| 56 |
with function Sigma0 (X : Hash_State.Word) return Hash_State.Word is <>; |
| 57 |
with function Sigma1 (X : Hash_State.Word) return Hash_State.Word is <>; |
| 58 |
with function S0 (X : Hash_State.Word) return Hash_State.Word is <>; |
| 59 |
with function S1 (X : Hash_State.Word) return Hash_State.Word is <>; |
| 60 |
-- FIPS PUB 180-3 elementary functions |
| 61 |
|
| 62 |
procedure Transform |
| 63 |
(H_St : in out Hash_State.State; |
| 64 |
M_St : in out Message_State); |
| 65 |
|
| 66 |
end GNAT.Secure_Hashes.SHA2_Common; |