JuliaCrypto / Nettle.jl

Julia wrapper around nettle cryptographic hashing/encryption library providing MD5, SHA1, SHA2 hashing and HMAC functionality, as well as AES encryption/decryption

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nettle 3.0/3.1 compatibility

yuyichao opened this issue · comments

I've got the following segfault when running the tests on ArchLinux.
Julia 0.4-dev (should not matter)

Backtrace,

_nettle_aes_set_key at /usr/bin/../lib/libnettle.so (unknown line)
call at /usr/share/julia/site/v0.4/Nettle/src/cipher.jl:79
aes128_encrypt at /usr/share/julia/site/v0.4/Nettle/src/cipher.jl:117
jl_apply_generic at /usr/bin/../lib/julia/libjulia.so (unknown line)
anonymous at ./test.jl:87
do_test at ./test.jl:47
anonymous at ./no file:29
unknown function (ip: -140173077)
unknown function (ip: -140170412)
jl_load at /usr/bin/../lib/julia/libjulia.so (unknown line)
unknown function (ip: -185256800)
jl_apply_generic at /usr/bin/../lib/julia/libjulia.so (unknown line)
unknown function (ip: -184260780)
jl_apply_generic at /usr/bin/../lib/julia/libjulia.so (unknown line)
unknown function (ip: -140248077)
unknown function (ip: -140251264)
unknown function (ip: -140173274)
unknown function (ip: -140170412)
jl_load at /usr/bin/../lib/julia/libjulia.so (unknown line)
unknown function (ip: -186565232)
jl_apply_generic at /usr/bin/../lib/julia/libjulia.so (unknown line)
include_from_node1 at ./loading.jl:129
jl_apply_generic at /usr/bin/../lib/julia/libjulia.so (unknown line)
unknown function (ip: -184311739)
unknown function (ip: -184316692)
unknown function (ip: -184314231)
jl_apply_generic at /usr/bin/../lib/julia/libjulia.so (unknown line)
unknown function (ip: 4200533)
unknown function (ip: 4199391)
__libc_start_main at /usr/bin/../lib/libc.so.6 (unknown line)
unknown function (ip: 4199481)
unknown function (ip: 0)

The line number is a little bit confusing but apparently it was the line 78 ccall that causes the segfault.

A quick look at my nettle-meta.h and nettle-types.h shows that the signature of nettle_set_key_func doesn't have a length argument here

/* Ciphers */
typedef void nettle_set_key_func(void *ctx, const uint8_t *key);

A google search lead me to this post. I haven't read it through but it seems that there's a ABI break last year.

The construction of these functions are at runtime so I suppose it shouldn't be too hard to add additional version tests. However, I'm not familiar with nettle so I'm not sure what is the best way to do that.

My nettle soname is libnettle.so.6 if that helps..

@staticfloat (just to make sure the notification get through... ;P )

Seems that the API/ABI breaks happend in 3.0 although I guess there might be more breakage since the soname changed again...

Edit: http://lwn.net/Articles/601946/

P.S. Could you please also include a link to the CI result in the README like many other projects? It was a little bit hard to navigate there from the project main page...

jl_lookup_soname doesn't seem to work for this purpose since it returns libnettle.so on my system (or maybe in general if the .so symlink is installed).

Just tested and simply removing the length argument makes it work on Nettle 3.1.1.

Not sure about how to do the version check though. Idealy it should be done at runtime so that an upgrade of the library will not silently break the package. However, nettle doesn't seem to have a runtime interface to query the version.

This is great work, thanks @yuyichao. I've sent an email off to the libnettle mailing list to see if we can't get runtime API versioning, which is pretty important for us here. In the meantime, is there a symbol in the new API that is not in the old API? That could be our poor man's test for what API we're dealing with.