Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

curvecp

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curvecp - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "curvecp",
"version": "1.0.0",
"version": "1.0.1",
"description": "Pure javascript CurveCP library",

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

@@ -47,2 +47,3 @@ 'use strict'

this.__state = null
this.__sharedKey = null
Duplex.call(this, opts)

@@ -323,2 +324,17 @@ extend(this, {

PacketStream.prototype._decryptShared = function (source, prefix) {
try {
prefix = nacl.util.decodeUTF8(prefix)
var nonceLength = 24 - prefix.length
var shortNonce = source.subarray(0, nonceLength)
var nonce = new Uint8Array(24)
nonce.set(prefix)
nonce.set(shortNonce, prefix.length)
var result = nacl.box.open.after(source.subarray(nonceLength), nonce, this.__sharedKey)
} catch (err) {
this._log.warn('Decrypt failed with error ' + err)
}
return result
}
PacketStream.prototype._encrypt = function (data, nonce, prefixLength, from, to) {

@@ -334,2 +350,11 @@ // debug('encrypt')

PacketStream.prototype._encryptShared = function (data, nonce, prefixLength) {
var box = nacl.box.after(data, nonce, this.__sharedKey)
var result = new Uint8Array(24 - prefixLength + box.length)
var shortNonce = nonce.subarray(prefixLength)
result.set(shortNonce)
result.set(box, 24 - prefixLength)
return result
}
PacketStream.prototype._encryptSymmetric = function (data, prefix, key) {

@@ -467,2 +492,3 @@ prefix = nacl.util.decodeUTF8(prefix)

this.serverConnectionPrivateKey = keyPair.secretKey
this.__sharedKey = nacl.box.before(this.clientConnectionPublicKey, this.serverConnectionPrivateKey)
var result = new Uint8Array(200)

@@ -507,2 +533,3 @@ result.set(COOKIE_MSG)

this.serverConnectionPublicKey = boxData.subarray(0, 32)
this.__sharedKey = nacl.box.before(this.serverConnectionPublicKey, this.clientConnectionPrivateKey)
this.__serverCookie = boxData.subarray(32)

@@ -535,3 +562,3 @@ if (this.__serverCookie.length !== 96) {

var nonce = this._createNonceFromCounter('CurveCP-client-I')
result.set(this._encrypt(initiateBoxData, nonce, 16, this.clientConnectionPrivateKey, this.serverConnectionPublicKey), 168)
result.set(this._encryptShared(initiateBoxData, nonce, 16), 168)
result = this._setExtensions(result)

@@ -563,3 +590,3 @@ this.stream.write(new Buffer(result), done)

}
var initiateBoxData = this._decrypt(initiateMessage.subarray(72 + 96), 'CurveCP-client-I', this.clientConnectionPublicKey, this.serverConnectionPrivateKey)
var initiateBoxData = this._decryptShared(initiateMessage.subarray(72 + 96), 'CurveCP-client-I')
if (initiateBoxData === undefined) {

@@ -591,3 +618,3 @@ this._log.warn('Not able to decrypt initiate box data')

var nonce = this._createNonceFromCounter('CurveCP-server-M')
var messageBox = this._encrypt(message, nonce, 16, this.serverConnectionPrivateKey, this.clientConnectionPublicKey)
var messageBox = this._encryptShared(message, nonce, 16)
result.set(messageBox, 8 + 16 + 16)

@@ -608,3 +635,3 @@ result = this._setExtensions(result)

}
var boxData = this._decrypt(message.subarray(40), 'CurveCP-server-M', this.serverConnectionPublicKey, this.clientConnectionPrivateKey)
var boxData = this._decryptShared(message.subarray(40), 'CurveCP-server-M')
if (boxData === undefined || !boxData) {

@@ -626,3 +653,3 @@ this._log.warn('not able to decrypt box data')

var nonce = this._createNonceFromCounter('CurveCP-client-M')
var messageBox = this._encrypt(message, nonce, 16, this.clientConnectionPrivateKey, this.serverConnectionPublicKey)
var messageBox = this._encryptShared(message, nonce, 16)
result.set(messageBox, 8 + 16 + 16 + 32)

@@ -643,3 +670,3 @@ result = this._setExtensions(result)

}
var boxData = this._decrypt(message.subarray(40 + 32), 'CurveCP-client-M', this.clientConnectionPublicKey, this.serverConnectionPrivateKey)
var boxData = this._decryptShared(message.subarray(40 + 32), 'CurveCP-client-M')
if (boxData === undefined || !boxData) {

@@ -646,0 +673,0 @@ this._log.warn('not able to decrypt box data')

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