NaCl/libsodium binding for Pharo and Squeak
Tue 11 Jun 2013 20:15 EDT
I’ve just written Pharo/Squeak bindings to libsodium, which is a portable shared-library version of the NaCl cryptography library. A good description of the motivation of the library is this PDF.
Installing the software
To use the bindings, you will need to install the Monticello package
Crypto-Nacl
from
http://smalltalkhub.com/mc/tonyg/Crypto-Nacl/main. The bindings
depend on the FFI, so that must be installed.
From within Squeak:
Most importantly, you will need a version of libsodium for your Smalltalk VM. Because most Squeak/Pharo VMs are 32-bit, you will need to get hold of a 32-bit libsodium. I’ve prebuilt some:
- OS X, 32-bit VMs: libsodium.dylib.gz
- decompress and put this in either
Squeak.app/Contents/Resources/libsodium
(note: no extension!) for the Squeak VM, orPharo.app/Contents/MacOS/Plugins/libsodium
(note: no extension!) for the Pharo VM.
- decompress and put this in either
- Linux, 32-bit VMs: libsodium.so.gz
- decompress and place the
libsodium.so
file in the same directory asvm-display-X11
and friends.
- decompress and place the
Compiling your own libsodium (optional)
Compiling libsodium to work with Squeak/Pharo can be tricky:
-
On OS X, configure libsodium with
./configure CFLAGS=-m32
to build a 32-bit version. -
On 32-bit linux, ordinary
./configure
works just fine, but I haven’t yet managed to get things working on a 64-bit linux. If anyone tries 64-bit and manages to get it to work, please let me know! -
I haven’t tried it on Windows at all. Please let me know if you try this, and how it goes, either success or failure.
Running the tests
On the Smalltalk side, once you’ve loaded the .mcz
, open a Test
Runner and select the Crypto-Nacl
tests. With Crypto-Nacl-tonyg.4
,
there should be 12 tests, and they should all pass if the shared
library can be found in the right place.
You can also try it out in a Workspace: a printIt of Nacl
sodiumVersionString
will yield '0.3'
or '0.4.1'
, depending on
which version of libsodium you have.
Enjoy!
Comments (closed)
Ported to Cuis Smalltalk 4.2 < https://github.com/Cuis-Smallt... >
https://github.com/KenDickey/C...
Thanks a bunch!!
-KenD < Ken [dot] Dickey [at] whidbey [dot] com >
Thanks, Ken! That's great.