Compare commits

..
6 Commits
Author SHA1 Message Date
Christophe Diederichs 426ca77d47 0.7.4 2021-11-05 09:32:51 +00:00
Kasper Isager Dalsgarð 25c97802f4 crypto_sign: replace Buffer.alloc() with new Uint8Array() (#62) 2021-11-04 17:17:13 +00:00
Kasper Isager Dalsgarð 87ff2a56bd Use globalThis instead of global (#61)
* Use `globalThis` instead of `global`

* Update `standard`
2021-11-02 16:36:15 +01:00
RangerMauve 7ef6e52870 Remove "react-native" field
This field isn't adding anything at the moment, and it actually breaks things by pointing at an unresolvable module.
2020-12-01 11:29:33 +01:00
Mathias Buus 0227f45c6b 0.7.3 2020-11-13 16:46:11 +01:00
Mathias Buus ca32540960 load the sink just in time 2020-11-13 16:46:06 +01:00
5 changed files with 16 additions and 11 deletions
+1
View File
@@ -1 +1,2 @@
node_modules
package-lock.json
+1 -1
View File
@@ -452,7 +452,7 @@ function crypto_sign_ed25519_sk_to_curve25519 (curveSk, edSk) {
assert(curveSk && curveSk.byteLength === crypto_scalarmult_BYTES, "curveSk must be 'crypto_sign_SECRETKEYBYTES' long")
assert(edSk && edSk.byteLength === crypto_sign_ed25519_SECRETKEYBYTES, "edSk must be 'crypto_sign_ed25519_SECRETKEYBYTES' long")
var h = Buffer.alloc(crypto_hash_sha512_BYTES)
var h = new Uint8Array(crypto_hash_sha512_BYTES)
crypto_hash(h, edSk, 32)
h[0] &= 248
+11 -4
View File
@@ -1,21 +1,28 @@
/* eslint-disable camelcase */
var MessageChannel = global.MessageChannel
if (MessageChannel == null) ({ MessageChannel } = require('worker' + '_threads'))
function sodium_malloc (n) {
return new Uint8Array(n)
}
const sink = new MessageChannel()
function sodium_free (n) {
sodium_memzero(n)
sink.port1.postMessage(n.buffer, [n.buffer])
loadSink().port1.postMessage(n.buffer, [n.buffer])
}
function sodium_memzero (arr) {
arr.fill(0)
}
var sink
function loadSink () {
if (sink) return sink
var MessageChannel = globalThis.MessageChannel
if (MessageChannel == null) ({ MessageChannel } = require('worker' + '_threads'))
sink = new MessageChannel()
return sink
}
module.exports = {
sodium_malloc,
sodium_free,
+2 -5
View File
@@ -1,6 +1,6 @@
{
"name": "sodium-javascript",
"version": "0.7.2",
"version": "0.7.4",
"description": "WIP - a pure javascript version of sodium-native",
"main": "index.js",
"dependencies": {
@@ -15,7 +15,7 @@
"devDependencies": {
"browserify": "^16.5.1",
"sodium-test": "^0.10.0",
"standard": "^14.3.4",
"standard": "^15.0.1",
"tape-run": "^7.0.0"
},
"standard": {
@@ -27,9 +27,6 @@
"crypto": false,
"worker_threads": false
},
"react-native": {
"crypto": "crypto"
},
"scripts": {
"pretest": "standard",
"test": "node test.js",
+1 -1
View File
@@ -2,7 +2,7 @@ var assert = require('nanoassert')
var randombytes = (function () {
var QUOTA = 65536 // limit for QuotaExceededException
var crypto = global.crypto || global.msCrypto
var crypto = globalThis.crypto || globalThis.msCrypto
function browserBytes (out, n) {
for (let i = 0; i < n; i += QUOTA) {