-
Notifications
You must be signed in to change notification settings - Fork 25
Lack of examples / tests. #10
Comments
Could you name which behaviour(s) in particular? If there are any specific modules/use cases/primitives you require examples/docs/tests for, I will start there. This library could indeed use some more documentation. While it may not be the best documentation, looking at the original C NIF code (https://github.com/ArteMisc/libsalty/blob/master/src/salty_nif.c) might give some insight into the mapping between elixir's in-/output parameters and the ones in libsodium. |
If it is any help here is how I am using https://github.com/tuupola/branca-elixir/blob/master/lib/branca.ex#L213-L220 |
@ArteMisc @tuupola Thanks for the update, and BTW impressive work on the NIF side of things. Regarding behaviours, for example, I think there should be documentation (maybe in the form of I think setting up something like would be great:
And indeed a bit of AES cryptography too, for example, how to generate an AES key and how encrypt something with it. Also, I would suggest that some coverage could be produced for those modules, because this is where we looked first, but none of the interesting bits had test cases - which is fine in the sense that we don't want to cover libsodium itself - just use the awesomeness of ExUnit to provide working examples that never break. |
In most cases within this library, the behaviours can be seen as the equivalent of an interface in other languages. So in the example of
Box and Secretbox indeed seem like the best places to start, along with Sign, as these are probably the most common uses for libsodium in general. I will get working on those first.
RSA is not implemented in libsodium, and as a result is not implemented by these bindings either. The primitives provided for similar cryptographic operations are based on X25519 (DH) and Ed25519 (signatures), in libsodium's crypto_box and crypto_sign functions. If signatures and encryption (through box) are what you're looking for, those are examples I can provide. If you need RSA specifically, that is outside of the scope of this library, but should be included in Erlang's standard libraries through OpenSSL.
While libsodium provides bindings for AES-GCM on platforms that support it through hardware instructions, this support is limited. Any other form of AES is not included in the library nor in these bindings. Libsodium's alternatives are based on XChacha20Poly1305/XSalsa20Poly1305. As with RSA, this library may or may not be the right fit for your requirements. |
We're evaluating this library and we're having a very hard time understanding how to use it.
A small paragraph on how its internal types translate to libsodium would be great.
We found several behaviours but they don't seem to be called from anywhere - so understanding what inputs should be used is quite puzzling.
The text was updated successfully, but these errors were encountered: