Socket
Socket
Sign inDemoInstall

chacha20-universal

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chacha20-universal - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

31

index.js

@@ -7,6 +7,9 @@ const assert = require('nanoassert')

function Chacha20 (n, k, counter) {
assert(k.byteLength === 32)
assert(n.byteLength === 8 || n.byteLength === 12)
function Chacha20 (nonce, key, counter) {
assert(key.byteLength === 32)
assert(nonce.byteLength === 8 || nonce.byteLength === 12)
const n = new Uint32Array(nonce.buffer, nonce.byteOffset, nonce.byteLength / 4)
const k = new Uint32Array(key.buffer, key.byteOffset, key.byteLength / 4)
if (!counter) counter = 0

@@ -20,3 +23,3 @@ assert(counter < Number.MAX_SAFE_INTEGER)

for (let i = 0; i < 4; i++) this.state[i] = constant[i]
for (let i = 0; i < 8; i++) this.state[4 + i] = readUInt32LE(k, 4 * i)
for (let i = 0; i < 8; i++) this.state[4 + i] = k[i]

@@ -27,8 +30,8 @@ this.state[12] = counter & 0xffffffff

this.state[13] = (counter && 0xffffffff00000000) >> 32
this.state[14] = readUInt32LE(n, 0)
this.state[15] = readUInt32LE(n, 4)
this.state[14] = n[0]
this.state[15] = n[1]
} else {
this.state[13] = readUInt32LE(n, 0)
this.state[14] = readUInt32LE(n, 4)
this.state[15] = readUInt32LE(n, 8)
this.state[13] = n[0]
this.state[14] = n[1]
this.state[15] = n[2]
}

@@ -136,11 +139,1 @@

}
function readUInt32LE (buf, offset) {
if (Buffer.isBuffer(buf)) return buf.readUInt32LE(offset)
else if (buf instanceof Uint8Array) {
var ret = 0
for (let i = 0; i < 4; i++) ret |= buf[offset + i] << (8 * i)
return ret
}
assert(false, 'buf should be a Buffer or a Uint8Array')
}
{
"name": "chacha20-universal",
"version": "1.0.2",
"version": "1.0.3",
"description": "chacha20 in pure javascript",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -35,3 +35,3 @@ # chacha20-universal

`n` should be a 12 byte nonce passed as a buffer/uint8array and `k` should be a 32 byte key. An optional `counter` may be passed as a number.
`nonce` should be a 12 byte buffer/uint8array and `key` should be 32 byte. An optional `counter` may be passed as a number.

@@ -38,0 +38,0 @@ #### `xor.update(output, input)`

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