Files
wolfssl/wrapper/Ada/examples/src/sha256_main.adb
T
Juliusz Sosinowicz 40d3befa61 Extend Ada bindings
Add Ada bindings for SHA-256, RSA sign/verify, and AES-CBC from
wolfCrypt. Use XMALLOC/XFREE for dynamic allocation and add GNATprove
ownership annotations to enable static leak detection.

Refactor the Ada wrapper into a base package (wolfssl.ads) and a child
package (wolfssl-full_runtime) to separate code that depends on
Interfaces.C.Strings and GNAT.Sockets from zero-footprint-compatible
code.

Add standalone examples for SHA-256 hashing, RSA signature verification,
and AES encryption under wrapper/Ada/examples/.

Add AUnit test suites for SHA-256, RSA, and AES bindings under
wrapper/Ada/tests/ with Valgrind suppressions and Alire integration.

Move TLS client/server examples into wrapper/Ada/examples/src/ and
update build files (default.gpr, examples.gpr, include.am) accordingly.

Update CI (ada.yml) to build default.gpr, run AUnit tests, run the
client-server examples, and run GNATprove.

Co-authored-by: Joakim Strandberg <joakim@mequinox.se>
2026-02-09 13:44:35 +01:00

47 lines
1.2 KiB
Ada

with Ada.Text_IO;
with WolfSSL;
procedure SHA256_Main is
procedure Put (Text : String) renames Ada.Text_IO.Put;
procedure New_Line is
begin
Ada.Text_IO.New_Line;
end New_Line;
use type WolfSSL.Subprogram_Result;
Hash : WolfSSL.SHA256_Hash;
B : WolfSSL.Byte_Array := (1 => 'a',
2 => 's',
3 => 'd',
4 => 'f');
SHA256 : WolfSSL.SHA256_Type;
R : Integer;
begin
WolfSSL.Create_SHA256 (SHA256 => SHA256, Result => R);
if R /= 0 then
Put ("SHA256 instance creation failed");
New_Line;
return;
end if;
WolfSSL.Update_SHA256 (SHA256 => SHA256, Byte => B, Result => R);
if R /= 0 then
Put ("Update of SHA256 instance failed");
New_Line;
return;
end if;
WolfSSL.Finalize_SHA256 (SHA256 => SHA256,
Hash => Hash,
Result => R);
if R = 0 then
Put ("SHA256 hash computed successfully");
New_Line;
else
Put ("Finalization of SHA256 instance failed");
New_Line;
end if;
WolfSSL.Free_SHA256 (SHA256 => SHA256);
end SHA256_Main;