On Thu, Dec 22, 2016 at 9:16 PM, Niels Möller nisse@lysator.liu.se wrote:
Ron Frederick ronf@timeheart.net writes:
Rather than adding a function to return the structure size here, what do you think about adding functions such as umac32_new() which would do the allocation of the structure and return a pointer to it?
Actually, I think I'd prefer a way to get the struct size at run time; otherwise I'd have to consider interfaces to let an application override the allocation function used by the *_new functions.
Are you sure the ctypes package you use doesn't provide any general way to extract struct sizes from a C interface? I know it's common practice to design libraries to have only opaque types, with function calls for allocation, use, and deallocation. But I wouldn't expect nettle to be the only library which tries to be more low-level and expose some internals.
The internals exposure makes it hard to keep an ABI (for the reasons you also outlined in the email with nettle hashes). Nettle is special in that aspect because is intentionally low-level, but it is also offered as a shared library with an ABI.
An approach for Ron to overcome the specific problem could be to use wrappers over nettle which hide the details, such as the gnutls functions (e.g., gnutls_mac_fast etc.).
The more long term question, is should nettle be striving to provide an ABI? If not, it could transform to low-level library gnulib or ccan are (i.e. like a copy-lib)... or alternatively, if yes, provide a high level stable API which hides details and the ABI is easier to provide.
regards, Nikos