Skip to content

Commit a270193

Browse files
author
Lev Kujawski
committed
Add license headers and support for Alire, change package name
* .gitignore: Ignore files generated by Alire and object file directories. * LICENSE.txt: Re-flow to use fewer columns. This facilitates comparing the license text with the Ada source headers. * README.md: ada-blake2 -> BLAKE2s for Ada. Add trailing newline. * alire.toml: Add Alire configuration. * bin/b2ssum.adb: Ada-BLAKE2 -> BLAKE2s. * blake2s.gpr: Add Alire-generated GPR file. * common/blake2s.adb * common/blake2s.ads * common/octearra.ads * common/octets.ads * generic/quadlets.adb * generic/quadlets.ads * gnat/quadlets.adb * gnat/quadlets.ads: Add license headers. * gnat/Makefile: - Rename library: libab2s -> libb2sa - Also remove GPR-generated static object files.
1 parent 964ce11 commit a270193

15 files changed

+353
-20
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gnat/dbin/
2+
gnat/dlib/
3+
gnat/sbin/
4+
gnat/slib/
5+
gnat/sobj/
6+
alire/
7+
alire.lock

LICENSE.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
Copyright (c) 2021, Lev Kujawski.
22

3-
Permission is hereby granted, free of charge, to any person obtaining a copy
4-
of this software and associated documentation files (the "Software"), to deal
5-
in the Software without restriction, including without limitation the rights
6-
to use, copy, modify, merge, publish, distribute, sublicense, and sell copies
7-
of the Software, and to permit persons to whom the Software is furnished to
8-
do so.
3+
Permission is hereby granted, free of charge, to any person obtaining a
4+
copy of this software and associated documentation files (the "Software")
5+
to deal in the Software without restriction, including without limitation
6+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
and sell copies of the Software, and to permit persons to whom the
8+
Software is furnished to do so.
99

1010
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1111
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16-
SOFTWARE.
12+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
13+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
15+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
16+
DEALINGS IN THE SOFTWARE.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ada-blake2 #
1+
# BLAKE2s for Ada #
22

33
This is a SPARK83 implementation of the [BLAKE2s](https://www.blake2.net/) hash function. As SPARK83 is a strict subset of Ada 87 (ISO-8652:1987), this package should be usable with any standard-compliant Ada compiler.
44

@@ -26,4 +26,4 @@ Per section 2.8 of the Ada 87 Language Reference Manual, "[a] pragma that is not
2626

2727
## Credits
2828

29-
Thanks to Aumasson et al. for releasing the excellent BLAKE hash functions into the public domain, and the [GNAT, SPARK](https://libre.adacore.com/), [Isabelle](https://isabelle.in.tum.de/), and [AdaControl](https://www.adalog.fr/en/adacontrol.html) developers for publishing their tremendously helpful [free software](https://www.gnu.org/philosophy/free-sw.html).
29+
Thanks to Aumasson et al. for releasing the excellent BLAKE hash functions into the public domain, and the [GNAT, SPARK](https://libre.adacore.com/), [Isabelle](https://isabelle.in.tum.de/), and [AdaControl](https://www.adalog.fr/en/adacontrol.html) developers for publishing their tremendously helpful [free software](https://www.gnu.org/philosophy/free-sw.html).

alire.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name = "blake2s"
2+
description = "SPARK83 implementation of the BLAKE2s hash function"
3+
version = "0.1.0"
4+
5+
authors = ["Lev Kujawski"]
6+
maintainers = ["Lev Kujawski <[email protected]>"]
7+
maintainers-logins = ["lkujaw"]
8+
licenses = "MIT-0"
9+
website = "https://github.com/lkujaw/blake2s"
10+
tags = ["spark", "hash", "blake2", "blake2s"]

bin/b2ssum.adb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- NOTE: Unlike the rest of the Ada-BLAKE2 package, b2ssum is written in
1+
-- NOTE: Unlike the rest of the BLAKE2s Ada package, b2ssum is written in
22
-- full ISO Ada 95 so that streaming I/O may be utilized.
33
--! rule off Exception_Rule
44

blake2s.gpr

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
project BLAKE2S is
2+
3+
for Library_Name use "b2sa";
4+
for Library_Version use "0.1.0";
5+
6+
type Library_Type_Type is ("relocatable", "static", "static-pic");
7+
Library_Type : Library_Type_Type :=
8+
external ("BLAKE2S_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
9+
for Library_Kind use Library_Type;
10+
11+
for Source_Dirs use ("gnat", "common");
12+
for Object_Dir use "gnat/sobj";
13+
for Library_Dir use "gnat/slib";
14+
for Create_Missing_Dirs use "True";
15+
16+
type Enabled_Kind is ("enabled", "disabled");
17+
Compile_Checks : Enabled_Kind :=
18+
External ("BLAKE2S_COMPILE_CHECKS", "enabled");
19+
Runtime_Checks : Enabled_Kind :=
20+
External ("BLAKE2S_RUNTIME_CHECKS", "enabled");
21+
Style_Checks : Enabled_Kind :=
22+
External ("BLAKE2S_STYLE_CHECKS", "enabled");
23+
Contracts_Checks : Enabled_Kind :=
24+
External ("BLAKE2S_CONTRACTS", "enabled");
25+
26+
type Build_Kind is ("debug", "optimize");
27+
Build_Mode : Build_Kind := External ("BLAKE2S_BUILD_MODE", "debug");
28+
29+
Compile_Checks_Switches := ();
30+
case Compile_Checks is
31+
when "enabled" =>
32+
Compile_Checks_Switches :=
33+
("-gnatVa", -- All validity checks
34+
"-gnatk8", -- 8.3 file names
35+
"-gnatwa", -- All warnings
36+
"-gnatwe"); -- Warnings as errors
37+
when others => null;
38+
end case;
39+
40+
Runtime_Checks_Switches := ();
41+
case Runtime_Checks is
42+
when "enabled" => null;
43+
when others =>
44+
Runtime_Checks_Switches :=
45+
("-gnatp"); -- Suppress checks
46+
end case;
47+
48+
Style_Checks_Switches := ();
49+
case Style_Checks is
50+
when "enabled" =>
51+
Style_Checks_Switches :=
52+
("-gnaty3abcdefhiklM78nprtux");
53+
when others => null;
54+
end case;
55+
56+
Contracts_Switches := ();
57+
case Contracts_Checks is
58+
when "enabled" =>
59+
Contracts_Switches :=
60+
("-gnata"); -- Enable assertions and contracts
61+
when others => null;
62+
end case;
63+
64+
Build_Switches := ();
65+
case Build_Mode is
66+
when "optimize" =>
67+
Build_Switches := ("-O3", -- Optimization
68+
"-gnatN"); -- Enable inlining
69+
when "debug" =>
70+
Build_Switches := ("-g", -- Debug info
71+
"-Og"); -- No optimization
72+
end case;
73+
74+
package Compiler is
75+
for Default_Switches ("Ada") use
76+
Compile_Checks_Switches &
77+
Build_Switches &
78+
Runtime_Checks_Switches &
79+
Style_Checks_Switches &
80+
Contracts_Switches;
81+
end Compiler;
82+
83+
package Binder is
84+
for Switches ("Ada") use ("-Es"); -- Symbolic traceback
85+
end Binder;
86+
87+
end BLAKE2S;

common/blake2s.adb

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
------------------------------------------------------------------------------
2+
-- Copyright (c) 2021, Lev Kujawski.
3+
--
4+
-- Permission is hereby granted, free of charge, to any person obtaining a
5+
-- copy of this software and associated documentation files (the "Software")
6+
-- to deal in the Software without restriction, including without limitation
7+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
-- and sell copies of the Software, and to permit persons to whom the
9+
-- Software is furnished to do so.
10+
--
11+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
-- DEALINGS IN THE SOFTWARE.
18+
--
19+
-- File: blake2s.adb (Body)
20+
-- Language: SPARK83 [1] subset of ISO Ada 87 [2]
21+
-- Author: Lev Kujawski
22+
-- Description: Implementation of the BLAKE2s hash function [3]
23+
--
24+
-- References:
25+
-- [1] SPARK Team, SPARK83 - The SPADE Ada83 Kernel, Altran Praxis, 17 Oct.
26+
-- 2011.
27+
-- [2] Programming languages - Ada, ISO/IEC 8652:1987, 15 Jun. 1987.
28+
-- [3] M-J. Saarinen and J-P Aumasson, "The BLAKE2 Cryptographic Hash and
29+
-- Message Authentication Code (MAC)," RFC 7693, Nov. 2015.
30+
------------------------------------------------------------------------------
31+
132
package body BLAKE2S is
233

334
Initialization_Vectors : constant Hash_State_T :=

common/blake2s.ads

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
1-
-- Copyright 2021 Lev Kujawski
1+
------------------------------------------------------------------------------
2+
-- Copyright (c) 2021, Lev Kujawski.
23
--
3-
-- Language: SPARK 83 subset of ISO Ada 87 (ISO/IEC 8652:1987)
4-
-- License: See LICENSE.txt
4+
-- Permission is hereby granted, free of charge, to any person obtaining a
5+
-- copy of this software and associated documentation files (the "Software")
6+
-- to deal in the Software without restriction, including without limitation
7+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
-- and sell copies of the Software, and to permit persons to whom the
9+
-- Software is furnished to do so.
510
--
6-
-- Based upon the RFC7693 by Saarinen and Aumasson (November, 2015).
11+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
-- DEALINGS IN THE SOFTWARE.
18+
--
19+
-- File: blake2s.ads (Specification)
20+
-- Language: SPARK83 [1] subset of ISO Ada 87 [2]
21+
-- Author: Lev Kujawski
22+
-- Description: Implementation of the BLAKE2s hash function [3]
23+
--
24+
-- References:
25+
-- [1] SPARK Team, SPARK83 - The SPADE Ada83 Kernel, Altran Praxis, 17 Oct.
26+
-- 2011.
27+
-- [2] Programming languages - Ada, ISO/IEC 8652:1987, 15 Jun. 1987.
28+
-- [3] M-J. Saarinen and J-P Aumasson, "The BLAKE2 Cryptographic Hash and
29+
-- Message Authentication Code (MAC)," RFC 7693, Nov. 2015.
30+
------------------------------------------------------------------------------
731

832
with Octets;
933
with Octet_Arrays;

common/octearra.ads

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
------------------------------------------------------------------------------
2+
-- Copyright (c) 2021, Lev Kujawski.
3+
--
4+
-- Permission is hereby granted, free of charge, to any person obtaining a
5+
-- copy of this software and associated documentation files (the "Software")
6+
-- to deal in the Software without restriction, including without limitation
7+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
-- and sell copies of the Software, and to permit persons to whom the
9+
-- Software is furnished to do so.
10+
--
11+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
-- DEALINGS IN THE SOFTWARE.
18+
--
19+
-- File: octearra.ads (Specification)
20+
-- Language: SPARK83 [1] subset of ISO Ada 87 [2]
21+
-- Author: Lev Kujawski
22+
-- Description: Specification of the Octet_Arrays type
23+
--
24+
-- References:
25+
-- [1] SPARK Team, SPARK83 - The SPADE Ada83 Kernel, Altran Praxis, 17 Oct.
26+
-- 2011.
27+
-- [2] Programming languages - Ada, ISO/IEC 8652:1987, 15 Jun. 1987.
28+
------------------------------------------------------------------------------
29+
130
with Octets;
231

332
--# inherit Octets;

common/octets.ads

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
------------------------------------------------------------------------------
2+
-- Copyright (c) 2021, Lev Kujawski.
3+
--
4+
-- Permission is hereby granted, free of charge, to any person obtaining a
5+
-- copy of this software and associated documentation files (the "Software")
6+
-- to deal in the Software without restriction, including without limitation
7+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
-- and sell copies of the Software, and to permit persons to whom the
9+
-- Software is furnished to do so.
10+
--
11+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
-- DEALINGS IN THE SOFTWARE.
18+
--
19+
-- File: octets.ads (Specification)
20+
-- Language: SPARK83 [1] subset of ISO Ada 87 [2]
21+
-- Author: Lev Kujawski
22+
-- Description: Specification of the Octets (8-bit) type
23+
--
24+
-- References:
25+
-- [1] SPARK Team, SPARK83 - The SPADE Ada83 Kernel, Altran Praxis, 17 Oct.
26+
-- 2011.
27+
-- [2] Programming languages - Ada, ISO/IEC 8652:1987, 15 Jun. 1987.
28+
------------------------------------------------------------------------------
29+
130
package Octets is
231
pragma Pure;
332

generic/quadlets.adb

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
------------------------------------------------------------------------------
2+
-- Copyright (c) 2021, Lev Kujawski.
3+
--
4+
-- Permission is hereby granted, free of charge, to any person obtaining a
5+
-- copy of this software and associated documentation files (the "Software")
6+
-- to deal in the Software without restriction, including without limitation
7+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
-- and sell copies of the Software, and to permit persons to whom the
9+
-- Software is furnished to do so.
10+
--
11+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
-- DEALINGS IN THE SOFTWARE.
18+
--
19+
-- File: quadlets.adb (Body)
20+
-- Language: SPARK83 [1] subset of ISO Ada 87 [2]
21+
-- Author: Lev Kujawski
22+
-- Description: Implementation of Quadlets-related subprograms
23+
--
24+
-- References:
25+
-- [1] SPARK Team, SPARK83 - The SPADE Ada83 Kernel, Altran Praxis, 17 Oct.
26+
-- 2011.
27+
-- [2] Programming languages - Ada, ISO/IEC 8652:1987, 15 Jun. 1987.
28+
------------------------------------------------------------------------------
29+
130
with Unchecked_Conversion;
231

332
package body Quadlets is

generic/quadlets.ads

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
------------------------------------------------------------------------------
2+
-- Copyright (c) 2021, Lev Kujawski.
3+
--
4+
-- Permission is hereby granted, free of charge, to any person obtaining a
5+
-- copy of this software and associated documentation files (the "Software")
6+
-- to deal in the Software without restriction, including without limitation
7+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
-- and sell copies of the Software, and to permit persons to whom the
9+
-- Software is furnished to do so.
10+
--
11+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
16+
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
-- DEALINGS IN THE SOFTWARE.
18+
--
19+
-- File: quadlets.ads (Specification)
20+
-- Language: SPARK83 [1] subset of ISO Ada 87 [2]
21+
-- Author: Lev Kujawski
22+
-- Description: Specification of the Quadlets type and related subprograms
23+
--
24+
-- References:
25+
-- [1] SPARK Team, SPARK83 - The SPADE Ada83 Kernel, Altran Praxis, 17 Oct.
26+
-- 2011.
27+
-- [2] Programming languages - Ada, ISO/IEC 8652:1987, 15 Jun. 1987.
28+
------------------------------------------------------------------------------
29+
130
with Octets;
231

332
--# inherit Octets,

gnat/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BIN_DLOC=$(BIN_DDIR)/b2ssum
77
BIN_ALOC=$(BIN_ADIR)/b2ssum.adb
88
BIN_SNMS=$(addprefix $(BIN_SDIR)/,b2ssum b2stest)
99

10-
LIB_NAME=ab2s
10+
LIB_NAME=b2sa
1111
LIB_SDIR=$(TOP_DIR)/gnat/slib
1212
LIB_DDIR=$(TOP_DIR)/gnat/dlib
1313
LIB_ADIR=$(TOP_DIR)/common
@@ -91,7 +91,7 @@ adactl.old:: ../blake2so.aru quadlets.adb
9191
-@rm -f *.adt *.ali
9292

9393
clean::
94-
-@rm -f dbin/* sbin/* dlib/* slib/*
94+
-@rm -f dbin/* sbin/* dlib/* slib/* sobj/*
9595
-@rm -f $(TOP_DIR)/tests/*.out
9696
-@rm -f quadlets/*.prv
9797
-@sparkclean -examiner -simplifier

0 commit comments

Comments
 (0)