Skip to content

Commit

Permalink
Merge pull request #72 from paixaop/split-sodium
Browse files Browse the repository at this point in the history
Split sodium
  • Loading branch information
paixaop committed Apr 16, 2016
2 parents 50e2bbf + a96149c commit 4f16398
Show file tree
Hide file tree
Showing 582 changed files with 34,827 additions and 49,194 deletions.
Empty file modified .dntrc
100755 → 100644
Empty file.
162 changes: 161 additions & 1 deletion .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ lib-cov/
node_modules/
node-sodium.sublime-project
node-sodium.sublime-workspace
*.o
*.slo
*.lo
*.o
*.obj
*.deps
*.dirstamp
*.la
*.log
*.a
*.lib
*.so
*.dylib
*.dll
*.lai
.npm
.node_repl_history
coverage/
deps/libsodium.gyp
deps/libsodium/libtool
Expand All @@ -33,3 +43,153 @@ deps/libsodium/src/Makefile
deps/libsodium/test/default/Makefile
deps/libsodium/test/Makefile
deps/libsodium/libtool
deps/libsodium/Makefile.in
deps/libsodium/autom4te.cache/output.0
deps/libsodium/autom4te.cache/output.1
deps/libsodium/autom4te.cache/traces.1
deps/libsodium/build-aux/config.guess
deps/libsodium/build-aux/config.sub
deps/libsodium/build-aux/ltmain.sh
deps/libsodium/configure
deps/libsodium/dist-build/Makefile.in
deps/libsodium/m4/libtool.m4
deps/libsodium/m4/ltoptions.m4
deps/libsodium/m4/ltsugar.m4
deps/libsodium/m4/ltversion.m4
deps/libsodium/m4/lt~obsolete.m4
deps/libsodium/msvc-scripts/Makefile.in
deps/libsodium/src/Makefile.in
deps/libsodium/src/libsodium/Makefile.in
deps/libsodium/src/libsodium/include/Makefile.in
deps/libsodium/test/Makefile.in
deps/libsodium/test/default/Makefile.in
deps/libsodium/test/browser-js.done
deps/libsodium/test/js.done
deps/libsodium/test/js-sumo.done
deps/libsodium/test/default/browser
deps/libsodium/test/default/*.res
deps/libsodium/test/default/*.trs
deps/libsodium/test/default/aead_aes256gcm/
deps/libsodium/test/default/aead_chacha20poly1305
deps/libsodium/test/default/auth
deps/libsodium/test/default/auth2
deps/libsodium/test/default/auth3
deps/libsodium/test/default/auth5
deps/libsodium/test/default/auth6
deps/libsodium/test/default/auth7
deps/libsodium/test/default/box
deps/libsodium/test/default/box2
deps/libsodium/test/default/box7
deps/libsodium/test/default/box8
deps/libsodium/test/default/box_easy
deps/libsodium/test/default/box_easy2
deps/libsodium/test/default/box_seal
deps/libsodium/test/default/box_seed
deps/libsodium/test/default/chacha20
deps/libsodium/test/default/core1
deps/libsodium/test/default/core2
deps/libsodium/test/default/core3
deps/libsodium/test/default/core4
deps/libsodium/test/default/core5
deps/libsodium/test/default/core6
deps/libsodium/test/default/ed25519_convert
deps/libsodium/test/default/generichash
deps/libsodium/test/default/generichash2
deps/libsodium/test/default/generichash3
deps/libsodium/test/default/hash
deps/libsodium/test/default/hash3
deps/libsodium/test/default/onetimeauth
deps/libsodium/test/default/onetimeauth2
deps/libsodium/test/default/onetimeauth7
deps/libsodium/test/default/pwhash
deps/libsodium/test/default/pwhash_scrypt
deps/libsodium/test/default/pwhash_scrypt_ll
deps/libsodium/test/default/randombytes
deps/libsodium/test/default/scalarmult
deps/libsodium/test/default/scalarmult2
deps/libsodium/test/default/scalarmult5
deps/libsodium/test/default/scalarmult6
deps/libsodium/test/default/scalarmult7
deps/libsodium/test/default/secretbox
deps/libsodium/test/default/secretbox2
deps/libsodium/test/default/secretbox7
deps/libsodium/test/default/secretbox8
deps/libsodium/test/default/secretbox_easy
deps/libsodium/test/default/secretbox_easy2
deps/libsodium/test/default/shorthash
deps/libsodium/test/default/sign
deps/libsodium/test/default/sodium_core
deps/libsodium/test/default/sodium_utils
deps/libsodium/test/default/sodium_utils2
deps/libsodium/test/default/sodium_utils3
deps/libsodium/test/default/sodium_version
deps/libsodium/test/default/stream
deps/libsodium/test/default/stream2
deps/libsodium/test/default/stream3
deps/libsodium/test/default/stream4
deps/libsodium/test/default/verify1
deps/libsodium/test-driver
deps/libsodium/testing
.libs
*.bc
*.cmake
*.dSYM
*.final
*.gcda
*.gcno
*.i
*.la
*.lo
*.log
*.mem
*.nexe
*.o
*.plist
*.s
*.scan
*.sdf
*.status
*.tar.*
*~
.DS_Store
.deps
.dirstamp
.done
.libs
Build
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache
build
compile
confdefs.h
config.*
configure
configure.lineno
coverage.info
depcomp
android-toolchain
install-sh
libtool
libsodium.pc
libsodium-*
ltmain.sh
m4/argz.m4
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
man/*.html
man/Makefile.in
missing
src/curvecp/curvecpclient
src/curvecp/curvecpmakekey
src/curvecp/curvecpmessage
src/curvecp/curvecpprintkey
src/curvecp/curvecpserver
src/libsodium/*.def
src/libsodium/include/sodium/version.h
stamp-*
Empty file modified .gitmodules
100755 → 100644
Empty file.
Empty file modified .travis.yml
100755 → 100644
Empty file.
Empty file modified CONTRIBUTING.md
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
78 changes: 67 additions & 11 deletions Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,74 @@ REPORTER = tap
BINDIR = ./node_modules/.bin

LIBSODIUM_DIR = ./deps/libsodium
INSTALL_DIR = $(CURDIR)/deps/build
STATIC_LIB = ${INSTALL_DIR}/lib/libsodium

configure:
@cd $(LIBSODIUM_DIR)/ && ./autogen.sh
@cd $(LIBSODIUM_DIR)/ && ./configure
@node defines.js

PLATFORM = ''
THIS_OS = ''

sodium:
ifeq (,$(wildcard deps/libsodium.gyp))
@echo Running make configure
@make configure
ifeq ($(OS),Windows_NT)
CCFLAGS += -D WIN32
THIS_OS = Windows
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
CCFLAGS += -D AMD64
PLATFORM = x86_64
endif
$(BINDIR)/node-gyp rebuild
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
CCFLAGS += -D IA32
PLATFORM = i386
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
THIS_OS = Linux
CCFLAGS += -D LINUX
CCFLAGS += -fPIC

endif
ifeq ($(UNAME_S),Darwin)
THIS_OS = OSX
OSX_VERSION_MIN = $(shell sw_vers -productVersion ) | awk -F '.' '{print $$1 "." $$2}'
CFLAGS="-arch x86_64 -mmacosx-version-min=${OSX_VERSION_MIN} -O2 -g -flto"
LDFLAGS="-arch x86_64 -mmacosx-version-min=${OSX_VERSION_MIN} -flto"
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
PLATFORM = x86_64
CCFLAGS += -D AMD64
endif
ifneq ($(filter %86,$(UNAME_P)),)
CCFLAGS += -D IA32
PLATFORM = i386
endif
ifneq ($(filter arm%,$(UNAME_P)),)
PLATFORM = ARM
CCFLAGS += -D ARM
endif
endif

ec:
@echo ${OSX_VERSION_MIN}

# If a static libsodium is found then compile against it
# instead of trying to compile from source
libsodium:
ifeq (,$(wildcard ${STATIC_LIB}.*))
@echo Static libsodium was not found at ${STATIC_LIB} so compiling libsodium from source.
@cd $(LIBSODIUM_DIR)/ && ./configure \
--enable-static --enable-shared --with-pic --prefix="$(INSTALL_DIR)"
@cd $(LIBSODIUM_DIR)/ && make clean > /dev/null
@cd $(LIBSODIUM_DIR)/ && make -j3 check
@cd $(LIBSODIUM_DIR)/ && make -j3 install
else
@echo Found a compiled lib in ${INSTALL_DIR}. Make sure this library that was compiled for this platform.
@echo Use make clean to remove the static lib and force recompilation
@echo Operating System: ${OS} THIS_OS = ${THIS_OS}, Platform = ${PLATFORM}
endif

sodium: libsodium
$(BINDIR)/node-gyp rebuild

test: test-unit

test-unit:
Expand All @@ -25,7 +79,8 @@ test-unit:
--globals setImmediate,clearImmediate

instrument: clean
$(BINDIR)/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib
$(BINDIR)/istanbul instrument --output lib-cov --no-compact \
--variable global.__coverage__ lib


test-cov: clean instrument
Expand All @@ -51,6 +106,7 @@ clean:
-rm -fr coverage
-rm -fr coverage.html
-rm -fr *.o
-rm -fr ${INSTALL_DIR}

all:
sodium
Expand Down
14 changes: 11 additions & 3 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# node-sodium

Uses Libsodium 1.0.3
Uses Libsodium 1.0.10

Port of the [lib sodium](https://github.com/jedisct1/libsodium) Encryption Library to Node.js.

This is a work in progress but most of Lib Sodium has been ported already.
Missing are the `generichash` functions, and the alternative primitives, like `crypto_box_curve25519xsalsa20poly1305`, or `crypto_stream_aes128ctr`.
Missing functions are listed in [`docs/not implemented.md`](https://github.com/paixaop/node-sodium/blob/split-sodium/docs/not%20implemented.md). You are encouraged to support this effort by creating a pull request for a function that you really need, that hasn't been ported yet.

There's a "low level" native module that gives you access directly to Lib Sodium, and a friendlier high level API that makes the library a bit easier to use.

Expand Down Expand Up @@ -76,12 +76,20 @@ node-sodium depends on lib sodium, so if lib sodium does not compile on your pla

# Manual Build

Node Sodium includes the source of libsodium, so the normal install will try to compile libsodium directly from source, using libsodium's own build tools.
This is the prefered method of compiling node sodium.
If you can't compile libsodium from source in your platform you can [download a pre-compiled binary](http://www.libsodium.org/releases) and copy it to the `./deps/build/lib` folder.

Before you run the manual build you must run the `npm install` once to install the required dependencies, like `node-gyp` that are needed to compile `node-sodium`.
Please note that `npm install` will install the dependencies and compile `node-sodium` as well. After this initial step you can make changes to the source and run the following commands to manually build the module:

make configure
make sodium

# SECURITY WARNING: Using a Binary Static libsodium

Node Sodium is a strong encryption library, odds are that a lot of security functions of your application depend on it, so *DO NOT* use binary libsodium distributions that you haven't verified.
If you use a pre-compiled version of libsodium you MUST be sure that nothing mallicious was added to the compiled version you are using.

# Code Samples
Please check the fully documented code samples in `test/test_sodium.js`.

Expand Down
Loading

0 comments on commit 4f16398

Please sign in to comment.