https://github.com/gomurin0428/AdaSMB
Author:MIT OR Apache-2.0
Version:0.4.0
Alire CI: Dependencies:No dependents.
Badge:
AdaSMB is a synchronous SMB client library written in Ada. It speaks SMB 3.1.1 (dialect 0x0311) by default and SMB 2.1 (0x0210) only when the caller allows it. It authenticates with NTLMv2 inside SPNEGO and supports file open/read/write/close, a file’s information (size, attributes, times), setting a file’s size, directory listing with each entry’s size, attributes and times, mkdir, delete and rename on one share per connection. With servers that support multi-credit requests (SMB2_GLOBAL_CAP_LARGE_MTU), a READ or WRITE can carry up to 960 KiB.
SMB 3.1.1 sessions are protected by the SHA-512 preauth integrity hash and signed with AES-128-GMAC or AES-128-CMAC, as the server chooses, under SP 800-108 derived keys. When the server negotiates a cipher, every request after authentication is encrypted with AES-128-GCM, AES-128-CCM, AES-256-GCM or AES-256-CCM, and only encrypted responses are accepted; a Require_Encryption option refuses servers without a cipher. SMB 2.1 sessions are signed with HMAC-SHA256. CI tests the library against Samba and against Windows Server 2025’s SMB server, and through a proxy that alters Samba’s responses, signing or encrypting them again with the session’s keys.
It uses only the regular GNAT runtime (GNAT.Sockets, Ada.Streams) and links no C SMB or crypto library. Hashes, HMAC, AES, CMAC, CCM, GCM, GMAC, the key derivation, NTLM and signing are implemented in Ada. The default entropy source is /dev/urandom on Unix and BCryptGenRandom on Windows.
The protocol core (crypto, UTF-8/UTF-16 conversion, NTLMv2/SPNEGO, SMB header and body parsing/building, negotiate contexts, the transform header, framing, transfer progress, session, key and handle state) is in SPARK and proved free of run-time errors together with its stated contracts. Sockets, OS entropy and clock, allocation and the public facade remain trusted. This is not a proof of cryptographic strength or of full SMB conformance.
Not supported: SMB1, SMB 3.0 and 3.0.2, compression, compound requests, multichannel, Kerberos, guest/anonymous fallback and concurrent requests. The project is experimental.