mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 19:30:48 +02:00
40d3befa61
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>
90 lines
2.5 KiB
Ada
90 lines
2.5 KiB
Ada
pragma Warnings (Off, "* is an internal GNAT unit");
|
|
with GNAT.Sockets.Thin_Common;
|
|
pragma Warnings (On, "* is an internal GNAT unit");
|
|
|
|
package body WolfSSL.Full_Runtime is
|
|
|
|
function WolfSSL_DTLS_Set_Peer
|
|
(ssl : WolfSSL_Type;
|
|
peer : GNAT.Sockets.Thin_Common.Sockaddr_Access;
|
|
peerSz : Interfaces.C.unsigned)
|
|
return int with
|
|
Convention => C,
|
|
External_Name => "wolfSSL_dtls_set_peer",
|
|
Import => True;
|
|
|
|
function DTLS_Set_Peer
|
|
(Ssl : WolfSSL_Type;
|
|
Address : GNAT.Sockets.Sock_Addr_Type)
|
|
return Subprogram_Result is
|
|
|
|
Sin : aliased GNAT.Sockets.Thin_Common.Sockaddr;
|
|
Length : Interfaces.C.int;
|
|
|
|
begin
|
|
|
|
GNAT.Sockets.Thin_Common.Set_Address
|
|
(Sin => Sin'Unchecked_Access,
|
|
Address => Address,
|
|
Length => Length);
|
|
|
|
pragma Assert (Length >= 0);
|
|
|
|
return
|
|
Subprogram_Result
|
|
(WolfSSL_DTLS_Set_Peer
|
|
(ssl => Ssl,
|
|
peer => Sin'Unchecked_Access,
|
|
peerSz => Interfaces.C.unsigned (Length)));
|
|
exception
|
|
when others =>
|
|
return Exception_Error;
|
|
end DTLS_Set_Peer;
|
|
|
|
procedure WolfSSL_Set_Psk_Client_Callback
|
|
(Ssl : WolfSSL_Type;
|
|
Cb : PSK_Client_Callback)
|
|
with
|
|
Convention => C,
|
|
External_Name => "wolfSSL_set_psk_client_callback",
|
|
Import => True;
|
|
|
|
procedure Set_PSK_Client_Callback
|
|
(Ssl : WolfSSL_Type;
|
|
Callback : PSK_Client_Callback) is
|
|
begin
|
|
WolfSSL_Set_Psk_Client_Callback (Ssl, Callback);
|
|
end Set_PSK_Client_Callback;
|
|
|
|
procedure WolfSSL_Set_Psk_Server_Callback
|
|
(Ssl : WolfSSL_Type;
|
|
Cb : PSK_Server_Callback)
|
|
with
|
|
Convention => C,
|
|
External_Name => "wolfSSL_set_psk_server_callback",
|
|
Import => True;
|
|
|
|
procedure Set_PSK_Server_Callback
|
|
(Ssl : WolfSSL_Type;
|
|
Callback : PSK_Server_Callback) is
|
|
begin
|
|
WolfSSL_Set_Psk_Server_Callback (Ssl, Callback);
|
|
end Set_PSK_Server_Callback;
|
|
|
|
procedure WolfSSL_CTX_Set_Psk_Server_Callback
|
|
(Ctx : Context_Type;
|
|
Cb : PSK_Server_Callback)
|
|
with
|
|
Convention => C,
|
|
External_Name => "wolfSSL_CTX_set_psk_server_callback",
|
|
Import => True;
|
|
|
|
procedure Set_Context_PSK_Server_Callback
|
|
(Context : Context_Type;
|
|
Callback : PSK_Server_Callback) is
|
|
begin
|
|
WolfSSL_CTX_Set_Psk_Server_Callback (Context, Callback);
|
|
end Set_Context_PSK_Server_Callback;
|
|
|
|
end WolfSSL.Full_Runtime;
|