Socket
Socket
Sign inDemoInstall

sodium-native

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sodium-native - npm Package Compare versions

Comparing version 1.10.3 to 2.0.0

.gitmodules

3

package.json
{
"name": "sodium-native",
"version": "1.10.3",
"version": "2.0.0",
"description": "Low level bindings for libsodium",

@@ -22,2 +22,3 @@ "main": "index.js",

"dev": "node-gyp rebuild",
"fetch-libsodium": "cd libsodium && git submodule update --recursive --remote --init && git checkout tags/1.0.15",
"test": "standard && tape \"test/*.js\"",

@@ -24,0 +25,0 @@ "install": "node-gyp-build \"node preinstall.js\" \"node postinstall.js\"",

@@ -20,2 +20,3 @@ var os = require('os')

case 'freebsd':
case 'openbsd':

@@ -31,3 +32,3 @@ buildBSD()

function buildWindows () {
var lib = path.join(__dirname, 'deps/lib/libsodium-' + arch + '.dll')
var lib = path.join(__dirname, 'lib/libsodium-' + arch + '.dll')
var dst = path.join(build, 'libsodium.dll')

@@ -41,4 +42,4 @@ if (fs.existsSync(dst)) return

function buildLinux () {
var lib = path.join(__dirname, 'deps/lib/libsodium-' + arch + '.so.18')
var dst = path.join(build, 'libsodium.so.18')
var lib = path.join(__dirname, 'lib/libsodium-' + arch + '.so.23')
var dst = path.join(build, 'libsodium.so.23')
if (fs.existsSync(dst)) return

@@ -51,12 +52,7 @@ copy(lib, dst, function (err) {

function buildBSD () {
var lib = path.join(__dirname, 'deps/lib/libsodium-' + arch + '.so.20.0')
var dst = path.join(build, 'libsodium.so.20.0')
if (fs.existsSync(dst)) return
copy(lib, dst, function (err) {
if (err) throw err
})
buildLinux()
}
function buildDarwin () {
var lib = path.join(__dirname, 'deps/lib/libsodium-' + arch + '.dylib')
var lib = path.join(__dirname, 'lib/libsodium-' + arch + '.dylib')
var dst = path.join(build, 'libsodium.dylib')

@@ -63,0 +59,0 @@ if (fs.existsSync(dst)) return

@@ -8,3 +8,3 @@ #!/usr/bin/env node

var dir = path.join(__dirname, 'deps/libsodium')
var dir = path.join(__dirname, 'libsodium')
var tmp = path.join(__dirname, 'tmp')

@@ -27,13 +27,14 @@ var arch = process.env.PREBUILD_ARCH || os.arch()

case 'darwin':
console.log('../deps/lib/libsodium-' + arch + '.dylib')
console.log('../lib/libsodium-' + arch + '.dylib')
break
case 'freebsd':
case 'openbsd':
case 'linux':
console.log(path.join(__dirname, '/deps/lib/libsodium-' + arch + '.so.18'))
console.log(path.join(__dirname, 'lib/libsodium-' + arch + '.so.23'))
break
case 'openbsd':
console.log(path.join(__dirname, '/deps/lib/libsodium-' + arch + '.so.20.0'))
break
case 'win32':
console.log('../deps/libsodium/Build/ReleaseDLL/' + warch + '/libsodium.lib')
console.log('../libsodium/Build/ReleaseDLL/' + warch + '/libsodium.lib')
break
default:
process.exit(1)
}

@@ -44,7 +45,3 @@

try {
fs.mkdirSync(path.join(__dirname, 'deps/lib'))
} catch (err) {
// do nothing
}
mkdirSync(path.join(__dirname, 'lib'))

@@ -60,2 +57,3 @@ switch (os.platform()) {

case 'freebsd':
case 'openbsd':

@@ -71,3 +69,3 @@ buildBSD()

function buildWindows () {
var res = path.join(__dirname, 'deps/lib/libsodium-' + arch + '.dll')
var res = path.join(__dirname, 'lib/libsodium-' + arch + '.dll')
if (fs.existsSync(res)) return

@@ -92,6 +90,6 @@

function buildUnix (ext, cb) {
var res = path.join(__dirname, 'deps/lib/libsodium-' + arch + '.' + ext)
var res = path.join(__dirname, 'lib/libsodium-' + arch + '.' + ext)
if (fs.existsSync(res)) return cb(null, res)
spawn('./configure', ['--prefix=' + tmp], {cwd: dir, stdio: 'inherit'}, function (err) {
spawn('./configure', ['--prefix=' + tmp], {cwd: __dirname, stdio: 'inherit'}, function (err) {
if (err) throw err

@@ -123,3 +121,3 @@ spawn('make', ['clean'], {cwd: dir, stdio: 'inherit'}, function (err) {

function buildBSD () {
buildUnix('so.20.0', function (err) {
buildUnix('so.23', function (err) {
if (err) throw err

@@ -130,3 +128,3 @@ })

function buildLinux () {
buildUnix('so.18', function (err) {
buildUnix('so.23', function (err) {
if (err) throw err

@@ -143,1 +141,9 @@ })

}
function mkdirSync (p) {
try {
fs.mkdirSync(p)
} catch (err) {
// do nothing
}
}

@@ -60,31 +60,31 @@ # sodium-native

#### `sodium.memzero(buffer)`
#### `sodium.sodium_memzero(buffer)`
Zero out the data in `buffer`.
#### `sodium.mlock(buffer)`
#### `sodium.sodium_mlock(buffer)`
Lock the memory contained in `buffer`
#### `sodium.munlock(buffer)`
#### `sodium.sodium_munlock(buffer)`
Unlock previously `mlock`ed memory contained in `buffer`. This will also `memzero` `buffer`
Unlock previously `sodium_mlock`ed memory contained in `buffer`. This will also `sodium_memzero` `buffer`
#### `var buffer = sodium.malloc(size)`
#### `var buffer = sodium.sodium_malloc(size)`
Allocate a buffer of `size` which is memory protected. See [libsodium docs](https://download.libsodium.org/doc/helpers/memory_management.html#guarded-heap-allocations) for details. Be aware that many Buffer methods may break the security guarantees of `sodium.malloc`'ed memory.
Allocate a buffer of `size` which is memory protected. See [libsodium docs](https://download.libsodium.org/doc/helpers/memory_management.html#guarded-heap-allocations) for details. Be aware that many Buffer methods may break the security guarantees of `sodium.sodium_malloc`'ed memory.
#### `sodium.mprotect_noaccess(buffer)`
#### `sodium.sodium_mprotect_noaccess(buffer)`
Make `buffer` allocated using `sodium.malloc` inaccessible, crashing the process if any access is attempted.
Make `buffer` allocated using `sodium.sodium_malloc` inaccessible, crashing the process if any access is attempted.
Note that this will have no effect for normal `Buffer`s.
#### `sodium.mprotect_readonly(buffer)`
#### `sodium.sodium_mprotect_readonly(buffer)`
Make `buffer` allocated using `sodium.malloc` read-only, crashing the process if any writing is attempted.
Make `buffer` allocated using `sodium.sodium_malloc` read-only, crashing the process if any writing is attempted.
Note that this will have no effect for normal `Buffer`s.
#### `sodium.mprotect_readwrite(buffer)`
#### `sodium.sodium_mprotect_readwrite(buffer)`
Make `buffer` allocated using `sodium.malloc` read-write, undoing `mprotect_noaccess` or `mprotect_readonly`.
Make `buffer` allocated using `sodium.sodium_malloc` read-write, undoing `sodium_mprotect_noaccess` or `sodium_mprotect_readonly`.
Note that this will have no effect for normal `Buffer`s.

@@ -91,0 +91,0 @@

@@ -18,3 +18,3 @@ var tape = require('tape')

t.same(output.toString('hex'), '9dc3499e37e8177f5e5abdf0fa18bfb7b768970a5fd870e3c28af7a79d75c3c2', 'hashes password')
t.same(output.toString('hex'), 'f0236e17ec70050fc989f19d8ce640301e8f912154b4f0afc1552cdf246e659f', 'hashes password')

@@ -24,3 +24,3 @@ salt[0] = 0

t.same(output.toString('hex'), '0170a897e8952582fa29f7cdd58e791ddabf3f32ce0268fe9bd244bccee812a8', 'diff salt -> diff hash')
t.same(output.toString('hex'), 'df73f15d217196311d4b1aa6fba339905ffe581dee4bd3a95ec2bb7c52991d65', 'diff salt -> diff hash')

@@ -62,3 +62,3 @@ t.end()

t.same(output.toString('hex'), '9dc3499e37e8177f5e5abdf0fa18bfb7b768970a5fd870e3c28af7a79d75c3c2', 'hashes password')
t.same(output.toString('hex'), 'f0236e17ec70050fc989f19d8ce640301e8f912154b4f0afc1552cdf246e659f', 'hashes password')

@@ -69,3 +69,3 @@ salt[0] = 0

t.same(output.toString('hex'), '0170a897e8952582fa29f7cdd58e791ddabf3f32ce0268fe9bd244bccee812a8', 'diff salt -> diff hash')
t.same(output.toString('hex'), 'df73f15d217196311d4b1aa6fba339905ffe581dee4bd3a95ec2bb7c52991d65', 'diff salt -> diff hash')

@@ -102,1 +102,13 @@ t.end()

})
tape('crypto_pwhash limits', function (t) {
var output = alloc(sodium.crypto_pwhash_STRBYTES)
var passwd = new Buffer('Hej, Verden!')
var opslimit = Number.MAX_SAFE_INTEGER
var memlimit = Number.MAX_SAFE_INTEGER
t.throws(function () {
sodium.crypto_pwhash_str(output, passwd, opslimit, memlimit)
}, 'should throw on large limits')
t.end()
})
var sodium = require('../..')
var buf = sodium.malloc(1)
sodium.mprotect_noaccess(buf)
var buf = sodium.sodium_malloc(1)
sodium.sodium_mprotect_noaccess(buf)
buf[0]
process.send('read')
var sodium = require('../..')
var buf = sodium.malloc(1)
sodium.mprotect_readonly(buf)
var buf = sodium.sodium_malloc(1)
sodium.sodium_mprotect_readonly(buf)
buf[0]

@@ -5,0 +5,0 @@ process.send('read')

var sodium = require('../..')
var buf = sodium.malloc(1)
sodium.mprotect_noaccess(buf)
sodium.mprotect_readwrite(buf)
var buf = sodium.sodium_malloc(1)
sodium.sodium_mprotect_noaccess(buf)
sodium.sodium_mprotect_readwrite(buf)
buf[0]

@@ -9,3 +9,3 @@ process.send('read')

process.send('write')
sodium.mprotect_readonly(buf)
sodium.sodium_mprotect_readonly(buf)
process.send(buf[0] === 1 ? 'did_write' : 'did_not_write')

@@ -6,3 +6,3 @@ var alloc = require('buffer-alloc')

tape('memzero', function (t) {
tape('sodium_memzero', function (t) {
var buf = alloc(10)

@@ -17,3 +17,3 @@ var exp = alloc(10)

sodium.memzero(buf)
sodium.sodium_memzero(buf)
t.notSame(buf, exp, 'buffers are not longer the same')

@@ -25,3 +25,3 @@ t.same(buf, zero, 'buffer is now zeroed')

tape('mlock / munlock', function (t) {
tape('sodium_mlock / sodium_munlock', function (t) {
var buf = alloc(10)

@@ -32,5 +32,5 @@ var exp = alloc(10)

exp.fill(0x18)
sodium.mlock(buf)
sodium.sodium_mlock(buf)
t.same(buf, exp, 'mlock did not corrupt data')
sodium.munlock(buf)
sodium.sodium_munlock(buf)
t.same(buf, alloc(10), 'munlock did zero data')

@@ -41,6 +41,6 @@

tape('malloc', function (t) {
var empty = sodium.malloc(0)
var small = sodium.malloc(1)
var large = sodium.malloc(1e8)
tape('sodium_malloc', function (t) {
var empty = sodium.sodium_malloc(0)
var small = sodium.sodium_malloc(1)
var large = sodium.sodium_malloc(1e8)

@@ -54,3 +54,3 @@ t.ok(empty.length === 0, 'has correct size')

for (var i = 0; i < 1e3; i++) {
if (sodium.malloc(256).length !== 256) {
if (sodium.sodium_malloc(256).length !== 256) {
t.fail('allocated incorrect size')

@@ -66,8 +66,8 @@ }

tape('malloc bounds', function (t) {
tape('sodium_malloc bounds', function (t) {
t.throws(function () {
sodium.malloc(-1)
sodium.sodium_malloc(-1)
}, 'too small')
t.throws(function () {
sodium.malloc(Number.MAX_SAFE_INTEGER)
sodium.sodium_malloc(Number.MAX_SAFE_INTEGER)
}, 'too large')

@@ -77,3 +77,3 @@ t.end()

tape('mprotect_noaccess', function (t) {
tape('sodium_mprotect_noaccess', function (t) {
t.plan(1)

@@ -90,3 +90,3 @@ var p = fork(require.resolve('./fixtures/mprotect_noaccess'))

tape('mprotect_readonly', function (t) {
tape('sodium_mprotect_readonly', function (t) {
t.plan(2)

@@ -103,3 +103,3 @@ var p = fork(require.resolve('./fixtures/mprotect_readonly'))

tape('mprotect_readwrite', function (t) {
tape('sodium_mprotect_readwrite', function (t) {
t.plan(4)

@@ -106,0 +106,0 @@ var p = fork(require.resolve('./fixtures/mprotect_readwrite'))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc