-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sha1.ads
82 lines (67 loc) · 3.63 KB
/
Sha1.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
-------------------------------------------------------------------------------
-- --
-- Sha1 --
-- --
-- Sha1.ads --
-- --
-- SPEC --
-- --
-- Copyright (C) 1997 Ulrik Hørlyk Hjort --
-- --
-- Sha1 is free software; you can redistribute it --
-- and/or modify it under terms of the GNU General Public License --
-- as published by the Free Software Foundation; either version 2, --
-- or (at your option) any later version. --
-- Sha1 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 distributed with Yolk. If not, write to the Free --
-- Software Foundation, 51 Franklin Street, Fifth Floor, Boston, --
-- MA 02110 - 1301, USA. --
-- --
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Sha1 is implemented according to the specification given in :FIPS PUB 180-1
-- http://www.itl.nist.gov/fipspubs/fip180-1.htm
-------------------------------------------------------------------------------
with Interfaces;
package Sha1 is
type Unsigned_32 is mod (2 ** 32); -- According to the spec
type Unsigned_32_Array_T is array(Positive range <>) of Unsigned_32;
type Unsigned_8_Array_T is array(Positive range <>) of Interfaces.Unsigned_8;
type Context_T is
record
Message_Digest : Unsigned_32_Array_T(1..5);
Length_Low : Unsigned_32;
Length_High : Unsigned_32;
Message_Block : Unsigned_8_Array_T(1..64);
Message_Block_Index : Positive;
Computed : Boolean;
Corrupted : Boolean;
end record;
---------------------------------------------
--
-- Reset and initialize buffers and indexes
--
---------------------------------------------
procedure Init (Context : in out Context_T);
--------------------------------------------------------
--
-- Calculate and returns the 160 bit message digest in
-- Context.Message_Digest.
--
-- Returns True in Result_Ok on success otherwise False
--
--------------------------------------------------------
procedure Result(Context : in out Context_T; Result_Ok : out Boolean);
-----------------------------------------------
--
-- Takes a message as an unsigned_8 array and
-- update the SHA-1 context
--
-----------------------------------------------
procedure Input(Context : in out Context_T;
Message : in Unsigned_8_Array_T);
End Sha1;