Use a rust library for SHA* functions #80

Open
Wilfred opened this Issue Jan 17, 2017 · 4 comments

Projects

None yet

2 participants

@Wilfred
Owner
Wilfred commented Jan 17, 2017 edited

For example, rust-crypto.

Emacs has its own SHA256 implementation, which we don't need.

@moosingin3space

What about using ring? It's becoming the preferred Rust crypto library from what I can see.

@Wilfred Wilfred changed the title from Use rust-crypto for SHA* functions to Use a rust library for SHA* functions Jan 18, 2017
@Wilfred
Owner
Wilfred commented Jan 18, 2017

Thanks, I've updated the issue to be less explicit about which library we use.

@moosingin3space

I'd like to claim this, since I'm learning ring.

@Wilfred
Owner
Wilfred commented Jan 21, 2017

@moosingin3space it's yours! :)

Have a look at Fbase64_encode_string for an example of creating strings in Rust. The elisp functions exposing this functionality are md5 and secure-hash, which live in src/fns.c.

Alternatively, you don't need to redefined the elisp functions. You could look at the secure_hash C function in src/fns.c, which chooses a hash_func value like sha256_buffer (defined in lib/sha256.c). You'd then need to expose a function in lib.rs with the same calling convention:

void *
sha256_buffer (const char *buffer, size_t len, void *resblock);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment