steelcrypt/src/algorithms/sha2/sha2_256.ads

48 lines
1.7 KiB
Ada
Raw Normal View History

-- Copyright (C) 2015 Daniel Otte <bg@nerilex.org>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Crypto_Core_Types; use Crypto_Core_Types;
with Crypto_Types; use Crypto_Types;
2015-07-01 22:23:31 +00:00
with Sha2_Small;
use Crypto_Types.Crypto_Types_u8;
2015-07-01 22:23:31 +00:00
use Crypto_Types.Crypto_Types_u32;
2015-07-01 22:23:31 +00:00
package SHA2_256 is
2015-07-01 22:23:31 +00:00
type Context_T is private;
2015-07-10 09:32:32 +00:00
BlockSize_Bits : constant := 512;
DigestSize_Bits : constant := 256;
BlockSize_Bytes : constant := (BlockSize_Bits) / 8;
DigestSize_Bytes : constant := (DigestSize_Bits) / 8;
subtype Block_T is u8_Array(1 .. BlockSize_Bytes);
subtype Digest_T is u8_Array(1 .. DigestSize_Bytes);
2015-07-01 22:23:31 +00:00
procedure Initialize(Context : out Context_T);
2015-07-10 09:32:32 +00:00
procedure Next_Block(Context : in out Context_T; Block : in Block_T);
2015-07-01 22:23:31 +00:00
procedure Last_Block(Context : in out Context_T; Block : in u8_Array; Bits : in Integer := -1);
2015-07-10 09:32:32 +00:00
procedure Get_Digest(Context : in out Context_T; Digest : out Digest_T);
2015-07-10 09:32:32 +00:00
procedure Hash(Data : in u8_array; Digest : out Digest_T; Bits : in Integer := -1);
2015-07-01 22:23:31 +00:00
private
2015-07-01 22:23:31 +00:00
type Context_T is new Sha2_Small.Context_T;
2015-07-01 22:23:31 +00:00
end SHA2_256;