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
|
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Text_IO.Text_Streams;
with Natools.Getopt_Long;
with Natools.S_Expressions;
with Natools.S_Expressions.Encodings;
procedure HMAC.Main is
procedure Base64_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Digest in base-64
procedure Lower_Hex_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Digest in lower-case hexadecimal
procedure Raw_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Direct directly
procedure Upper_Hex_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Digest in upper-case hexadecimal
package Options is
type Id is
(Base64_Output,
Lower_Hex_Output,
Raw_Output,
Upper_Hex_Output);
end Options;
package Getopt is new Natools.Getopt_Long (Options.Id);
|
>
>
|
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
|
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Text_IO.Text_Streams;
with Natools.Getopt_Long;
with Natools.S_Expressions;
with Natools.S_Expressions.Encodings;
with Natools.S_Expressions.File_Readers;
procedure HMAC.Main is
procedure Base64_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Digest in base-64
procedure Lower_Hex_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Digest in lower-case hexadecimal
procedure Raw_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Direct directly
procedure Upper_Hex_Output (Digest : in Ada.Streams.Stream_Element_Array);
-- Output the given binary Digest in upper-case hexadecimal
package Options is
type Id is
(Base64_Output,
Key_File,
Lower_Hex_Output,
Raw_Output,
Upper_Hex_Output);
end Options;
package Getopt is new Natools.Getopt_Long (Options.Id);
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
(Handler : in out Callback;
Argument : in String);
overriding procedure Option
(Handler : in out Callback;
Id : in Options.Id;
Argument : in String)
is
pragma Unreferenced (Argument);
begin
case Id is
when Options.Base64_Output =>
Handler.Output := Base64_Output'Access;
when Options.Lower_Hex_Output =>
Handler.Output := Lower_Hex_Output'Access;
when Options.Raw_Output =>
Handler.Output := Raw_Output'Access;
when Options.Upper_Hex_Output =>
Handler.Output := Upper_Hex_Output'Access;
end case;
|
|
<
<
>
>
>
>
>
>
>
>
>
>
>
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
(Handler : in out Callback;
Argument : in String);
overriding procedure Option
(Handler : in out Callback;
Id : in Options.Id;
Argument : in String) is
begin
case Id is
when Options.Base64_Output =>
Handler.Output := Base64_Output'Access;
when Options.Key_File =>
if Argument = "-" then
Handler.Key := Ada.Strings.Unbounded.To_Unbounded_String
(Ada.Text_IO.Get_Line);
else
Handler.Key := Ada.Strings.Unbounded.To_Unbounded_String
(Natools.S_Expressions.To_String
(Natools.S_Expressions.File_Readers.Reader
(Argument).Read));
end if;
Handler.Has_Key := True;
when Options.Lower_Hex_Output =>
Handler.Output := Lower_Hex_Output'Access;
when Options.Raw_Output =>
Handler.Output := Raw_Output'Access;
when Options.Upper_Hex_Output =>
Handler.Output := Upper_Hex_Output'Access;
end case;
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
end Upper_Hex_Output;
Opt_Config : Getopt.Configuration;
Handler : Callback;
begin
Opt_Config.Add_Option
("base64", 'b', Getopt.No_Argument, Options.Base64_Output);
Opt_Config.Add_Option
("lower-hex", 'h', Getopt.No_Argument, Options.Lower_Hex_Output);
Opt_Config.Add_Option
("raw", 'r', Getopt.No_Argument, Options.Raw_Output);
Opt_Config.Add_Option
("upper-hex", 'H', Getopt.No_Argument, Options.Upper_Hex_Output);
|
>
>
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
end Upper_Hex_Output;
Opt_Config : Getopt.Configuration;
Handler : Callback;
begin
Opt_Config.Add_Option
("base64", 'b', Getopt.No_Argument, Options.Base64_Output);
Opt_Config.Add_Option
("key-file", 'f', Getopt.Required_Argument, Options.Key_File);
Opt_Config.Add_Option
("lower-hex", 'h', Getopt.No_Argument, Options.Lower_Hex_Output);
Opt_Config.Add_Option
("raw", 'r', Getopt.No_Argument, Options.Raw_Output);
Opt_Config.Add_Option
("upper-hex", 'H', Getopt.No_Argument, Options.Upper_Hex_Output);
|