sandbox-quantum / sandwich

Sandwich is a multi-platform, multi-language, open-source library that provides a simple unified API for developers to use (multiple) cryptographic libraries in their applications.
https://sandbox-quantum.github.io/sandwich/
GNU Affero General Public License v3.0
108 stars 8 forks source link

Is there any specific code example? #8

Closed RideDi closed 9 months ago

RideDi commented 1 year ago

Is there any specific code example to tell me how to choose an algorithm, create a pub/pri key, and implement the encryption or signature function?

eduser25 commented 1 year ago

Is there any specific code example to tell me how to choose an algorithm

Language wrappers will provide proto implementation to fill in the algorithm details when attempting to create a client or server. Here's an example for golang to define specific KEMs to be used on a client or server: https://github.com/sandbox-quantum/sandwich/blob/main/examples/go/tls_client/main.go#L30C1-L35C1

create a pub/pri key

I think the keys need to be created offband by either using openssl or any other tool today, I believe we don't provide capabilities todo that as of now directly on the library.

and implement the encryption or signature function

The encryption primitives are provided by the libraries used underneath, but take a look at the APIs our rust layer defines to later plug the library-provided primitives, specifically for tls. https://github.com/sandbox-quantum/sandwich/blob/main/rust/implementation/ossl/mod.rs

RideDi commented 1 year ago

Thank you very much for your reply.I have another question about using the Echo_tls_server/client example.I try to use the way in the documentation. bazelisk run //examples/go/echo_tls_server:echo_tls_server -- -port 4444 -server_cert testdata/localhost.cert.pem -server_key testdata/localhost.key.pem

And this error occurs when I try to run the server with the certificate and key in the testdata. % bazelisk run //examples/go/echo_tls_server:echo_tls_server -- -port 4444 -server_cert testdata/localhost.cert.pem -server_key testdata/localhost.key.pem Starting local Bazel server and connecting to it... INFO: Analyzed target //examples/go/echo_tls_server:echo_tls_server (396 packages loaded, 41264 targets configured). INFO: Found 1 target... Target //examples/go/echo_tls_server:echo_tls_server up-to-date: bazel-bin/examples/go/echo_tls_server/echo_tls_server_/echo_tls_server INFO: Elapsed time: 17.613s, Critical Path: 1.42s INFO: 1 process: 1 internal. INFO: Build completed successfully, 1 total action INFO: Running command line: bazel-bin/examples/go/echo_tls_server/echo_tls_server_/echo_tls_server -port 4444 -server_cert testdata/localhost.cert.pem -server_key testdata/localhost.key.pem 2023/08/31 17:11:33 invalid configuration; How can I locate the problem and solve it?

jameshoweee commented 9 months ago

we've just release a blog with some examples that may be useful: https://cryptographycaffe.sandboxaq.com/posts/sandwich-tutorial1/

RideDi commented 9 months ago

we've just release a blog with some examples that may be useful: https://cryptographycaffe.sandboxaq.com/posts/sandwich-tutorial1/

oh, I just checked this blog. It's very detailed. Thank you very much for your addition.