Skip to content

Commit 63b5d12

Browse files
author
Lev Kujawski
committed
Release BLAKE2S patch version 0.1.3
Changes in this release: - Switch from GNU Make to AST NMAKE, vastly simplifying project Makefiles with the latter's native Ada support. - Support for building the b2ssum utility using GPRBuild. * .github/workflows/blake2s.yml: Run CI with AST NMAKE. * README.md: - Switch from inline to reference style URLS. - Reformat for 80 columns. - Document that AST NMAKE is required now for building. * alire.toml: Removed as ALIRE packages are created manually now. * b2ssum.gpr: New GPRBuild project file for the b2ssum file hash utility. * bin/b2ssum.adb: - Switch from renaming operators to 'use type', as b2ssum is written in the 1995 version of Ada and the former causes GNAT to emit warnings about hiding standard definitions. - Quash false positive emitted by newer versions of AdaControl (as shipped by Debian/Ubuntu). * blake2s.gpr: - Increment version to 0.1.3. - Place object files in gnat/obj and libraries in gnat/lib. The sobj and slib directories were a holdover from the prior GNU Make setup; NMAKE allows for building static and dynamic libraries in the same directory. - Per the new Alire default, disable runtime checks and contracts. * blake2s.nmk: New Nmakefile containing project defaults. * blake2sn.aru * blake2so.aru: - Add MIT-0 copyright header. - Add clarifying comments. - Give unnecessary_use_clause a name (Use_Rule). * gnat/makefile.nmk: New Nmakefile for building the BLAKE2s library and executables using GNAT. * makefile.nmk: New Nmakefile for toolchain-agnostic operations.
1 parent 5948509 commit 63b5d12

15 files changed

+417
-214
lines changed

.github/workflows/ada.yml

-28
This file was deleted.

.github/workflows/blake2s.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: BLAKE2S CI
2+
3+
on:
4+
push:
5+
branches: [ trunk ]
6+
pull_request:
7+
branches: [ trunk ]
8+
9+
jobs:
10+
ubuntu:
11+
12+
runs-on: ubuntu-20.04
13+
14+
env:
15+
TZ: UTC
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Install Dependencies
21+
run: >
22+
sudo apt-get update &&
23+
sudo apt-get install adacontrol gnat libdb5.3-dev
24+
25+
- name: Build AST NMAKE
26+
run: >
27+
git clone https://github.com/lkujaw/ast.git &&
28+
cd ast && ./bin/package flat make
29+
30+
- name: Report (AdaControl)
31+
run: |
32+
export PATH="${PWD}/ast/bin:$PATH"
33+
nmake adactl
34+
cd gnat && nmake adactl && nmake clobber
35+
36+
- name: Build
37+
run: |
38+
export PATH="${PWD}/ast/bin:$PATH"
39+
cd gnat && nmake
40+
41+
- name: Test
42+
run: |
43+
export PATH="${PWD}/ast/bin:$PATH"
44+
cd gnat && nmake test

Makefile

-30
This file was deleted.

README.md

+50-18
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,69 @@
11
[![Alire](https://img.shields.io/endpoint?url=https://alire.ada.dev/badges/blake2s.json)](https://alire.ada.dev/crates/blake2s.html)
22

3-
# BLAKE2s for Ada #
3+
# BLAKE2s for Ada
44

5-
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.
5+
This is a SPARK83 implementation of the [BLAKE2s][1] hash function.
6+
As SPARK83 is a strict subset of Ada 1987 (ISO-8652:1987), this
7+
package should be usable with any standard-compliant Ada compiler.
68

7-
## BLAKE2s advantages ##
9+
## BLAKE2s advantages
810

9-
Like SHA-256, BLAKE2s operates on 32-bit words, but is not susceptible to the length extension attacks of the former. Although the FIPS hash functions SHA-512/256 and SHA-3 mitigate the length extension vulnerability of SHA-256, they require 64-bit words for decent performance. Thus, BLAKE2s fills a niche for resource-constrained platforms. It also enjoys a high security margin, as each of the ten BLAKE2s rounds is the equivalent of two ChaCha rounds.
11+
Like SHA-256, BLAKE2s operates on 32-bit words, but is not susceptible
12+
to the length extension attacks of the former. Although the FIPS hash
13+
functions SHA-512/256 and SHA-3 mitigate the length extension
14+
vulnerability of SHA-256, they require 64-bit words for decent
15+
performance. Thus, BLAKE2s fills a niche for resource-constrained
16+
platforms. It also enjoys a high security margin, as each of the ten
17+
BLAKE2s rounds is the equivalent of two ChaCha rounds.
1018

11-
## Build instructions for GNAT ##
19+
## Build instructions for GNAT
1220

13-
To compile the blake2s library and executables, you will need a copy of GCC within your path that includes the GNAT Ada front-end.
21+
To compile the BLAKE2s library and executables, you will need to have
22+
installed and accessible within your path copies of [AST NMAKE][2]
23+
with Ada support and the GCC compiler built with the GNAT Ada
24+
front-end enabled.
1425

15-
To use the included Makefile, run "cd gnat && make" .
26+
Once the prerequisites are available, simply run `cd gnat && nmake` .
1627

17-
## SPARK and Isabelle verification ##
28+
## SPARK and Isabelle verification
1829

19-
This project uses a combination of the original, annotation-based SPARK tool set (search [AdaCore Libre](https://libre.adacore.com/) for the 2012 GPL release) and the HOL-SPARK library bundled within [Isabelle](https://isabelle.in.tum.de/) 2021 to prove the absence of runtime errors.
30+
This project uses a combination of the original, annotation-based
31+
SPARK tool set (search [AdaCore Libre][3] for the 2012 GPL release)
32+
and the HOL-SPARK library bundled within [Isabelle][4] 2021 to prove
33+
the absence of runtime errors.
2034

21-
To verify the proofs, check the Makefile within the project root first to ensure that you have the necessary programs (including the 'isabelle' command) installed within your path.
35+
To verify the proofs, check the file named `makefile.nmk` within the
36+
project root first to ensure that you have the necessary programs
37+
(including the `isabelle` command) installed within your path.
2238

23-
If everything is functioning as it should, there should be no undischarged verification conditions.
39+
If everything is functioning as it should, there should be no
40+
undischarged verification conditions.
2441

25-
## Ada 87 compatibility note ##
42+
## Ada 1987 compatibility note
2643

27-
This package utilizes the Ada 95 pragma "Pure" in the following package specifications:
44+
This package utilizes the Ada 1995 pragma "Pure" in the following
45+
package specifications:
2846

2947
* BLAKE2S (common/blake2s.ads)
3048
* Octets (common/octets.ads)
3149
* Octet_Arrays (common/octearra.ads)
3250

33-
Per section 2.8 of the Ada 87 Language Reference Manual, "[a] pragma that is not language-defined has no effect if its identifier is not recognized by the (current) implementation." However, as the pragma is merely advisory to the compiler, it may be removed without adverse effect from these files should it cause any issues.
34-
35-
## Credits
36-
37-
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).
51+
Per section 2.8 of the Ada 1987 Language Reference Manual, "[a] pragma
52+
that is not language-defined has no effect if its identifier is not
53+
recognized by the (current) implementation." However, as the pragma is
54+
merely advisory to the compiler, it may be removed without adverse
55+
effect from these files should it cause any issues.
56+
57+
## Acknowledgments
58+
59+
Thanks to Aumasson et al. for releasing the excellent BLAKE hash
60+
functions into the public domain, and the [GNAT, SPARK][3],
61+
[Isabelle][4], and [AdaControl][5] developers for publishing their
62+
tremendously helpful [free software][6].
63+
64+
[1]: https://www.blake2.net/
65+
[2]: https://sr.ht/~lev/ast/
66+
[3]: https://libre.adacore.com/
67+
[4]: https://isabelle.in.tum.de/
68+
[5]: https://www.adalog.fr/en/adacontrol.html
69+
[6]: https://www.gnu.org/philosophy/free-sw.html

alire.toml

-10
This file was deleted.

b2ssum.gpr

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
-- SPDX-License-Identifier: MIT-0
20+
------------------------------------------------------------------------------
21+
22+
with "blake2s.gpr";
23+
24+
project B2SSUM is
25+
26+
for Source_Dirs use ("bin");
27+
for Object_Dir use "gnat/obj";
28+
for Exec_Dir use "gnat/bin";
29+
for Create_Missing_Dirs use "True";
30+
for Main use ("b2ssum.adb");
31+
32+
type Enabled_Kind is ("enabled", "disabled");
33+
Compile_Checks : Enabled_Kind :=
34+
External ("B2SSUM_COMPILE_CHECKS", "disabled");
35+
Runtime_Checks : Enabled_Kind :=
36+
External ("B2SSUM_RUNTIME_CHECKS", "disabled");
37+
Style_Checks : Enabled_Kind :=
38+
External ("B2SSUM_STYLE_CHECKS", "disabled");
39+
Contracts_Checks : Enabled_Kind :=
40+
External ("B2SSUM_CONTRACTS", "disabled");
41+
42+
type Build_Kind is ("debug", "optimize");
43+
Build_Mode : Build_Kind := External ("B2SSUM_BUILD_MODE", "optimize");
44+
45+
Compile_Checks_Switches := ();
46+
case Compile_Checks is
47+
when "enabled" =>
48+
Compile_Checks_Switches :=
49+
("-gnatVa", -- Enable all validity checks
50+
"-gnatwaJ", -- Enable warnings, minus obsolescent
51+
"-gnatwe"); -- Set Warnings as errors
52+
when others => null;
53+
end case;
54+
55+
Runtime_Checks_Switches := ();
56+
case Runtime_Checks is
57+
when "enabled" => null;
58+
when others =>
59+
Runtime_Checks_Switches :=
60+
("-gnatp"); -- Suppress checks
61+
end case;
62+
63+
Style_Checks_Switches := ();
64+
case Style_Checks is
65+
when "enabled" =>
66+
Style_Checks_Switches :=
67+
("-gnaty3abcefhiklM78nprtux");
68+
when others => null;
69+
end case;
70+
71+
Contracts_Switches := ();
72+
case Contracts_Checks is
73+
when "enabled" =>
74+
Contracts_Switches :=
75+
("-gnata"); -- Enable assertions and contracts
76+
when others => null;
77+
end case;
78+
79+
Build_Switches := ();
80+
case Build_Mode is
81+
when "optimize" =>
82+
Build_Switches := ("-O3", -- Optimization
83+
"-gnatN"); -- Enable front-end inlining
84+
when "debug" =>
85+
Build_Switches := ("-g", -- Emit debugging data
86+
"-Og"); -- Disable optimization
87+
end case;
88+
89+
package Compiler is
90+
for Default_Switches ("Ada") use
91+
Compile_Checks_Switches &
92+
Build_Switches &
93+
Runtime_Checks_Switches &
94+
Style_Checks_Switches &
95+
Contracts_Switches;
96+
end Compiler;
97+
98+
package Binder is
99+
for Switches ("Ada") use ("-Es"); -- Enable symbolic tracebacks
100+
end Binder;
101+
102+
end B2SSUM;

bin/b2ssum.adb

+5-7
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,18 @@ with Ada.Text_IO.Text_Streams;
4545
with Ada.Strings.Unbounded;
4646

4747
with BLAKE2S;
48+
use type BLAKE2S.Digest_T;
49+
-- Quash false positive from AdaControl:
50+
--! rule off Use_Rule
51+
use type BLAKE2S.Status_T;
52+
--! rule on Use_Rule
4853

4954
with Octets;
5055
use type Octets.T;
5156

5257
with Octet_Arrays;
5358

5459
procedure B2SSum is
55-
function "=" (Left : in BLAKE2S.Digest_T;
56-
Right : in BLAKE2S.Digest_T) return Boolean
57-
renames BLAKE2S."=";
58-
59-
function "=" (Left : in BLAKE2S.Status_T;
60-
Right : in BLAKE2S.Status_T) return Boolean
61-
renames BLAKE2S."=";
6260

6361
package ACH renames Ada.Characters.Handling;
6462
package ACL renames Ada.Command_Line;

blake2s.gpr

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
project BLAKE2S is
2323

2424
for Library_Name use "b2sa";
25-
for Library_Version use "0.1.2";
25+
for Library_Version use "0.1.3";
2626

2727
type Library_Type_Type is ("relocatable", "static", "static-pic");
2828
Library_Type : Library_Type_Type :=
2929
external ("BLAKE2S_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
3030
for Library_Kind use Library_Type;
3131

3232
for Source_Dirs use ("gnat", "common");
33-
for Object_Dir use "gnat/sobj";
34-
for Library_Dir use "gnat/slib";
33+
for Object_Dir use "gnat/obj";
34+
for Library_Dir use "gnat/lib";
3535
for Create_Missing_Dirs use "True";
3636

3737
package Naming is
@@ -48,11 +48,11 @@ project BLAKE2S is
4848
Compile_Checks : Enabled_Kind :=
4949
External ("BLAKE2S_COMPILE_CHECKS", "disabled");
5050
Runtime_Checks : Enabled_Kind :=
51-
External ("BLAKE2S_RUNTIME_CHECKS", "enabled");
51+
External ("BLAKE2S_RUNTIME_CHECKS", "disabled");
5252
Style_Checks : Enabled_Kind :=
5353
External ("BLAKE2S_STYLE_CHECKS", "disabled");
5454
Contracts_Checks : Enabled_Kind :=
55-
External ("BLAKE2S_CONTRACTS", "enabled");
55+
External ("BLAKE2S_CONTRACTS", "disabled");
5656

5757
type Build_Kind is ("debug", "optimize");
5858
Build_Mode : Build_Kind := External ("BLAKE2S_BUILD_MODE", "optimize");

0 commit comments

Comments
 (0)