jedisct1 / libsodium

A modern, portable, easy to use crypto library.
https://libsodium.org
Other
12.18k stars 1.73k forks source link

configure flag to only build memory related routines #984

Closed ericlagergren closed 4 years ago

ericlagergren commented 4 years ago

I've a use case where I really only want to use libsodium's memory functions. Basically, everything here: https://doc.libsodium.org/memory_management but nothing else that's not transitively required.

Even the minimal build generates a ~2 MB library, which is overkill. What's the possibility of adding a "memory only" mode? I concede it's probably quite niche.

If it's unlikely to happen, do you have any suggestions wrt things I should watch out for while modifying the Makefiles?

jedisct1 commented 4 years ago

A configuration flag to remove all the crypto from a crypto library is unlikely to be added.

However, there is a tool that automatically includes only the functions an application requires, and you've already been using it: it's the linker!

You can link libsodium (or any other library) statically, and the linker will only include what you use.

ericlagergren commented 4 years ago

@jedisct1 yep. The pain point, though, is building the static library ahead of time to include it in a Go project as a .syso file. I don't want to add a 2 MB blob into the repo :)

Thanks anyway and thanks for libsodium.

jedisct1 commented 4 years ago

In case you're not aware of it, memguard may also be an option.

ericlagergren commented 4 years ago

@jedisct1 yeah, that is my fallback option. Libsodium was my first choice mostly because I trust it more. 🙂 I appreciate the suggestion!