briansmith / crypto-bench

Benchmarks for crypto libraries (in Rust, or with Rust bindings)
70 stars 11 forks source link

Added SHA-256/512 and salsa20-poly1305 benches for sodiumoxide. #18

Closed JohnHeitmann closed 8 years ago

JohnHeitmann commented 8 years ago

sodiumoxide doesn't support additional data, nor does it support AES-GCM. I don't see a reason for these gaps other than lack of interest. I'll take a crack at at least AES-GCM since that seems broadly useful outside of benchmarking. If you think the missing additional data support is hurting the benchmark comparison I'd be happy to take a crack at that too.

ring beats sodiumoxide by ~2x on SHA-512 on my laptop (Haswell i7 MacBook Pro).

Partially fixes #13

JohnHeitmann commented 8 years ago

CI failed because libsodium isn't installed. I've never configured Travis, but it looks like ubuntu will probably work with libsodium in the apt packages section. If homebrew is on the Mac node then ditto there.

I'll see if I can work this out on my own fork.

briansmith commented 8 years ago

I think you might be able to get libsodium to install by adding a dependency on the libsodium-sys crate from https://github.com/zonyitoo/libsodium-sys.

JohnHeitmann commented 8 years ago

libsodium-sys is already a transitive dependency: https://github.com/dnaq/sodiumoxide/blob/master/Cargo.toml#L14

I think it's just an FFI shim anyway.

JohnHeitmann commented 8 years ago

MacOS is working in Travis now. I think Ubuntu is blocked by this PR: https://github.com/travis-ci/apt-source-whitelist/pull/274

I'm watching that PR and will update this once it lands. Feel free to close this out if you don't want the pending PR hanging around for a couple weeks.

briansmith commented 8 years ago

MacOS is working in Travis now.

Awesome!

I think Ubuntu is blocked by this PR: travis-ci/apt-source-whitelist#274

That's https://github.com/travis-ci/apt-source-whitelist/pull/274, I gjuess.

I'm watching that PR and will update this once it lands. Feel free to close this out if you don't want the pending PR hanging around for a couple weeks.

Why don't we just skip libsodium now on Linux on Travis CI using whatever quick hack will work? This is what I would prefer, over waiting.

I don't expect that the Travis CI people will quickly add that PPA to their whitelist. A more-likely-to-work succeed solution may be to just git clone && ./configure && make libsodium ourselves, and then override the necessary environment variables so that SodiumOxide's libsodium-sys can find it.

BTW, it looks like there are two libsodium-sys crates: See https://github.com/zonyitoo/libsodium-sys and https://github.com/dnaq/sodiumoxide/blob/master/libsodium-sys/build.rs. @zonyitoo's has a build script that will build libsodium from source, but @dnaq's doesn't build from source. So, maybe there's a way to use @zonyitoo's libsodium-sys (or a fork of it with a different name?) in conjunction with @dnaq's?

JohnHeitmann commented 8 years ago

Travis now compiles the libsodium-1.0.10 release sources. Both Linux and Mac are working, and working the same.

@zonyitoo's has a build script that will build libsodium from source, but @dnaq's doesn't build from source. So, maybe there's a way to use @zonyitoo's libsodium-sys (or a fork of it with a different name?) in conjunction with @dnaq's?

I'll raise this over in the sodiumoxide repo and @ you. I've been going back and forth on this. The most important principle is probably which build method gives consumers the best shot at keeping up to date with libsodium patches. Even narrowing it down to this one principle I could make a strong argument in either direction.

JohnHeitmann commented 8 years ago

I'll have another PR down the line that cleans this up some more once I get my sodiumoxide changes in. I'll use chacha20 instead of salsa20, and so I'll bring in the TLS params. Also, I'll fix the test naming to match the other tests. Preview:

https://github.com/JohnHeitmann/crypto-bench/commit/179aa1849901a6863eefc86f668cf514634ce04e

briansmith commented 8 years ago

I squashed and merged this as 2ba56bc5b2262bb2f07ec38905b3244357f39a3d with minor edits. Please check out the minor differences between what I committed and what you submitted.

Thanks a ton for doing this! Being the first to do something with sodiumoxide meant you had to deal with lots of build issues and other drudgery that others that build on your work now won't have to deal with.

I'll have another PR down the line that cleans this up some more once I get my sodiumoxide changes in. I'll use chacha20 instead of salsa20, and so I'll bring in the TLS params. Also, I'll fix the test naming to match the other tests.

Awesome! Looking forward to that!