sodium-javascript
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -33,3 +33,3 @@ /* eslint-disable camelcase */ | ||
function crypto_aead_chacha20poly1305_ietf_encrypt_detached (c, mac, m, ad, nsec, npub, k) { | ||
if (ad === null) return crypto_aead_chacha20poly1305_ietf_encrypt(c, mac, m, new Uint8Array(0), nsec, npub, k) | ||
if (ad === null) return crypto_aead_chacha20poly1305_ietf_encrypt_detached(c, mac, m, new Uint8Array(0), nsec, npub, k) | ||
@@ -95,3 +95,3 @@ assert(c.byteLength === m.byteLength, 'ciphertext should be same length than message') | ||
function crypto_aead_chacha20poly1305_ietf_decrypt_detached (m, nsec, c, mac, ad, npub, k) { | ||
if (ad === null) return crypto_aead_chacha20poly1305_ietf_decrypt(m, nsec, c, mac, new Uint8Array(0), npub, k) | ||
if (ad === null) return crypto_aead_chacha20poly1305_ietf_decrypt_detached(m, nsec, c, mac, new Uint8Array(0), npub, k) | ||
@@ -98,0 +98,0 @@ assert(c.byteLength === m.byteLength, 'message should be same length than ciphertext') |
@@ -42,2 +42,3 @@ /* eslint-disable camelcase, one-var */ | ||
crypto_sign_ed25519_sk_to_curve25519, | ||
crypto_sign_ed25519_sk_to_pk, | ||
unpackneg, | ||
@@ -237,20 +238,2 @@ pack | ||
function is_zero25519 (f) { | ||
var s = new Uint8Array(32) | ||
pack25519(s, f) | ||
return sodium_is_zero(s, 32) | ||
function sodium_is_zero (n) { | ||
let i | ||
let d = 0 | ||
for (let i = 0; i < n.length; i++) { | ||
d |= n[i] | ||
} | ||
return 1 & ((d - 1) >> 8) | ||
} | ||
} | ||
function unpackneg (r, p) { | ||
@@ -390,3 +373,3 @@ var t = gf(), chk = gf(), num = gf(), | ||
for (let i = 0; i < a.length; i++) { | ||
pack25519(x25519_pk, a[i]); | ||
pack25519(x25519_pk, a[i]) | ||
} | ||
@@ -446,3 +429,3 @@ | ||
check (bad_points, 7) | ||
check(bad_points, 7) | ||
for (let i = 0; i < bad_points.length; i++) { | ||
@@ -476,8 +459,8 @@ for (j = 0; j < 31; j++) { | ||
var h = Buffer.alloc(crypto_hash_sha512_BYTES); | ||
var h = Buffer.alloc(crypto_hash_sha512_BYTES) | ||
crypto_hash(h, edSk, 32) | ||
h[0] &= 248; | ||
h[31] &= 127; | ||
h[31] |= 64; | ||
h[0] &= 248 | ||
h[31] &= 127 | ||
h[31] |= 64 | ||
@@ -489,5 +472,4 @@ curveSk.set(h.subarray(0, crypto_scalarmult_BYTES)) | ||
function check (buf, len, arg = 'Argument') { | ||
if (!buf || (len && buf.length < len)) throw new Error(arg + ' must be a buffer' + (len ? ' of length ' + len : '')) | ||
} |
{ | ||
"name": "sodium-javascript", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "WIP - a pure javascript version of sodium-native", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71900
2049