with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with Interfaces.C.Pointers;
with Ada.Unchecked_Deallocation;
with SMG_Keccak; use SMG_Keccak;
package Keccak_C is
   package Char_Ptrs is
      new Interfaces.C.Pointers (Index              => size_t,
                                 Element            => char,
                                 Element_Array      => char_array,
                                 Default_Terminator => nul);
   use type Char_Ptrs.Pointer;
   subtype Char_Star is Char_Ptrs.Pointer;
   subtype C_Context is Keccak_Context(Block_Len=>Default_Bitrate);
   type C_Context_Access is access C_Context;
   procedure C_Get_Size(Size: out Interfaces.C.size_t);
   pragma Export (C, C_Get_Size, "keccak_get_ctx_byte_size");
   function C_Begin return C_Context_Access;
   pragma Export (C, C_Begin, "keccak_begin");
   procedure C_Hash(Ctx: C_Context_Access;
                    Input: Char_Star;
                    Len: Interfaces.C.Size_T);
   pragma Export (C, C_Hash, "keccak_hash");
   procedure C_End(Ctx: C_Context_Access;
                   Output: Char_Star;
                   Len: Interfaces.C.Size_T);
   pragma Export (C, C_End, "keccak_end");
   procedure C_Deallocate(Ctx: in out C_Context_Access);
   pragma Export (C, C_Deallocate, "keccak_free");
end Keccak_C;
