1 unit HMACWHIR;
2 
3 {HMAC Whirl - message authentication with Whirlpool, obsolete: use HMAC unit!}
4 
5 
6 interface
7 
8 (*************************************************************************
9 
10  DESCRIPTION     :  HMAC Whirl - message authentication with Whirlpool hash
11 
12  REQUIREMENTS    :  TP5-7, D1-D7/D9-D10/D12/D17-D18, FPC, VP
13 
14  EXTERNAL DATA   :  ---
15 
16  MEMORY USAGE    :  ---
17 
18  DISPLAY MODE    :  ---
19 
20  REFERENCES      :  http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf
21 
22  REMARKS         :  "Truncate" not implemented, mac: full digest
23 
24  Version  Date      Author      Modification
25  -------  --------  -------     ------------------------------------------
26  1.00     11.12.05  W.Ehrhardt  Initial version (like HMAC SHA512)
27  1.01     17.01.06  we          Obsolete/legacy, shell for HMAC unit
28  1.02     12.11.08  we          uses BTypes, Str255
29  1.03     16.08.15  we          Removed $ifdef DLL / stdcall
30 ************************************************************************)
31 
32 (*-------------------------------------------------------------------------
33  (C) Copyright 2005-2015 Wolfgang Ehrhardt
34 
35  This software is provided 'as-is', without any express or implied warranty.
36  In no event will the authors be held liable for any damages arising from
37  the use of this software.
38 
39  Permission is granted to anyone to use this software for any purpose,
40  including commercial applications, and to alter it and redistribute it
41  freely, subject to the following restrictions:
42 
43  1. The origin of this software must not be misrepresented; you must not
44     claim that you wrote the original software. If you use this software in
45     a product, an acknowledgment in the product documentation would be
46     appreciated but is not required.
47 
48  2. Altered source versions must be plainly marked as such, and must not be
49     misrepresented as being the original software.
50 
51  3. This notice may not be removed or altered from any source distribution.
52 ----------------------------------------------------------------------------*)
53 
54 {$i STD.INC}
55 
56 uses
57   BTypes,Hash,HMAC,Whirl512;
58 
59 
60 procedure hmac_Whirl_init(var ctx: THMAC_Context; key: pointer; klen: word);
61   {-initialize HMAC context with key}
62 
63 procedure hmac_Whirl_inits(var ctx: THMAC_Context; skey: Str255);
64   {-initialize HMAC context with skey}
65 
66 procedure hmac_Whirl_update(var ctx: THMAC_Context; data: pointer; dlen: word);
67   {-HMAC data input, may be called more than once}
68 
69 procedure hmac_Whirl_updateXL(var ctx: THMAC_Context; data: pointer; dlen: longint);
70   {-HMAC data input, may be called more than once}
71 
72 procedure hmac_Whirl_final(var ctx: THMAC_Context; var mac: TWhirlDigest);
73   {-end data input, calculate HMAC digest}
74 
75 
76 implementation
77 
78 
79 {---------------------------------------------------------------------------}
80 procedure hmac_Whirl_init(var ctx: THMAC_Context; key: pointer; klen: word);
81   {-initialize HMAC context with key}
82 var
83   phash: PHashDesc;
84 begin
85   phash := FindHash_by_ID(_Whirlpool);
86   hmac_init(ctx, phash, key, klen);
87 end;
88 
89 
90 {---------------------------------------------------------------------------}
91 procedure hmac_Whirl_inits(var ctx: THMAC_Context; skey: Str255);
92   {-initialize HMAC context with skey}
93 begin
94   hmac_Whirl_init(ctx, @skey[1], length(skey));
95 end;
96 
97 
98 {---------------------------------------------------------------------------}
99 procedure hmac_Whirl_update(var ctx: THMAC_Context; data: pointer; dlen: word);
100   {-HMAC data input, may be called more than once}
101 begin
102   hmac_updateXL(ctx, data, dlen);
103 end;
104 
105 
106 {---------------------------------------------------------------------------}
107 procedure hmac_Whirl_updateXL(var ctx: THMAC_Context; data: pointer; dlen: longint);
108   {-HMAC data input, may be called more than once}
109 begin
110   hmac_updateXL(ctx, data, dlen);
111 end;
112 
113 
114 {---------------------------------------------------------------------------}
115 procedure hmac_Whirl_final(var ctx: THMAC_Context; var mac: TWhirlDigest);
116   {-end data input, calculate HMAC digest}
117 var
118   d: THashDigest;
119 begin
120   hmac_final(ctx, d);
121   move(d, mac, sizeof(mac));
122 end;
123 
124 end.
125 
126