Socket
Socket
Sign inDemoInstall

crypto-js

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypto-js - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

4

aes.js

@@ -94,4 +94,2 @@ ;(function (root, factory, undef) {

_doReset: function () {
var t;
// Skip reset of nRounds has been set before and key did not change

@@ -119,3 +117,3 @@ if (this._nRounds && this._keyPriorReset === this._key) {

} else {
t = keySchedule[ksRow - 1];
var t = keySchedule[ksRow - 1];

@@ -122,0 +120,0 @@ if (!(ksRow % keySize)) {

{
"name": "crypto-js",
"version": "3.2.1",
"version": "3.3.0",
"description": "JavaScript library of crypto standards.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -354,4 +354,2 @@ ;(function (root, factory, undef) {

function xorBlock(words, offset, blockSize) {
var block;
// Shortcut

@@ -362,3 +360,3 @@ var iv = this._iv;

if (iv) {
block = iv;
var block = iv;

@@ -368,3 +366,3 @@ // Remove IV for subsequent blocks

} else {
block = this._prevBlock;
var block = this._prevBlock;
}

@@ -461,4 +459,2 @@

reset: function () {
var modeCreator;
// Reset cipher

@@ -474,5 +470,5 @@ Cipher.reset.call(this);

if (this._xformMode == this._ENC_XFORM_MODE) {
modeCreator = mode.createEncryptor;
var modeCreator = mode.createEncryptor;
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
modeCreator = mode.createDecryptor;
var modeCreator = mode.createDecryptor;
// Keep at least one block in the buffer for unpadding

@@ -495,4 +491,2 @@ this._minBufferSize = 1;

_doFinalize: function () {
var finalProcessedBlocks;
// Shortcut

@@ -507,6 +501,6 @@ var padding = this.cfg.padding;

// Process final blocks
finalProcessedBlocks = this._process(!!'flush');
var finalProcessedBlocks = this._process(!!'flush');
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
// Process final blocks
finalProcessedBlocks = this._process(!!'flush');
var finalProcessedBlocks = this._process(!!'flush');

@@ -603,4 +597,2 @@ // Unpad data

stringify: function (cipherParams) {
var wordArray;
// Shortcuts

@@ -612,5 +604,5 @@ var ciphertext = cipherParams.ciphertext;

if (salt) {
wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
} else {
wordArray = ciphertext;
var wordArray = ciphertext;
}

@@ -635,4 +627,2 @@

parse: function (openSSLStr) {
var salt;
// Parse base64

@@ -647,3 +637,3 @@ var ciphertext = Base64.parse(openSSLStr);

// Extract salt
salt = WordArray.create(ciphertextWords.slice(2, 4));
var salt = WordArray.create(ciphertextWords.slice(2, 4));

@@ -650,0 +640,0 @@ // Remove salt from ciphertext

@@ -16,4 +16,2 @@ ;(function (root, factory) {

/*globals window, global, require*/
/**

@@ -23,58 +21,7 @@ * CryptoJS core components.

var CryptoJS = CryptoJS || (function (Math, undefined) {
var crypto;
// Native crypto from window (Browser)
if (typeof window !== 'undefined' && window.crypto) {
crypto = window.crypto;
}
// Native (experimental IE 11) crypto from window (Browser)
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
crypto = window.msCrypto;
}
// Native crypto from global (NodeJS)
if (!crypto && typeof global !== 'undefined' && global.crypto) {
crypto = global.crypto;
}
// Native crypto import via require (NodeJS)
if (!crypto && typeof require === 'function') {
try {
crypto = require('crypto');
} catch (err) {}
}
/*
* Cryptographically secure pseudorandom number generator
*
* As Math.random() is cryptographically not safe to use
* Local polyfil of Object.create
*/
var cryptoSecureRandomInt = function () {
if (crypto) {
// Use getRandomValues method (Browser)
if (typeof crypto.getRandomValues === 'function') {
try {
return crypto.getRandomValues(new Uint32Array(1))[0];
} catch (err) {}
}
// Use randomBytes method (NodeJS)
if (typeof crypto.randomBytes === 'function') {
try {
return crypto.randomBytes(4).readInt32LE();
} catch (err) {}
}
}
throw new Error('Native crypto module could not be used to get secure random number.');
};
/*
* Local polyfill of Object.create
*/
var create = Object.create || (function () {
function F() {}
function F() {};

@@ -362,4 +309,22 @@ return function (obj) {

for (var i = 0; i < nBytes; i += 4) {
words.push(cryptoSecureRandomInt());
var r = (function (m_w) {
var m_w = m_w;
var m_z = 0x3ade68b1;
var mask = 0xffffffff;
return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
var result = ((m_z << 0x10) + m_w) & mask;
result /= 0x100000000;
result += 0.5;
return result * (Math.random() > .5 ? 1 : -1);
}
});
for (var i = 0, rcache; i < nBytes; i += 4) {
var _r = r((rcache || Math.random()) * 0x100000000);
rcache = _r() * 0x3ade67b7;
words.push((_r() * 0x100000000) | 0);
}

@@ -595,4 +560,2 @@

_process: function (doFlush) {
var processedWords;
// Shortcuts

@@ -630,3 +593,3 @@ var data = this._data;

// Remove processed words
processedWords = dataWords.splice(0, nWordsReady);
var processedWords = dataWords.splice(0, nWordsReady);
data.sigBytes -= nBytesReady;

@@ -633,0 +596,0 @@ }

@@ -124,4 +124,3 @@ ;(function (root, factory) {

var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
var bitsCombined = bits1 | bits2;
words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
nBytes++;

@@ -128,0 +127,0 @@ }

@@ -71,4 +71,2 @@ ;(function (root, factory, undef) {

compute: function (password, salt) {
var block;
// Shortcut

@@ -93,3 +91,3 @@ var cfg = this.cfg;

}
block = hasher.update(password).finalize(salt);
var block = hasher.update(password).finalize(salt);
hasher.reset();

@@ -96,0 +94,0 @@

@@ -52,4 +52,2 @@ ;(function (root, factory, undef) {

function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
var keystream;
// Shortcut

@@ -60,3 +58,3 @@ var iv = this._iv;

if (iv) {
keystream = iv.slice(0);
var keystream = iv.slice(0);

@@ -66,3 +64,3 @@ // Remove IV for subsequent blocks

} else {
keystream = this._prevBlock;
var keystream = this._prevBlock;
}

@@ -69,0 +67,0 @@ cipher.encryptBlock(keystream, 0);

{
"name": "crypto-js",
"version": "3.2.1",
"version": "3.3.0",
"description": "JavaScript library of crypto standards.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -35,8 +35,6 @@ ;(function (root, factory, undef) {

var i = data.sigBytes - 1;
for (var i = data.sigBytes - 1; i >= 0; i--) {
if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
data.sigBytes = i + 1;
break;
}
while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
i--;
}
data.sigBytes = i + 1;
}

@@ -43,0 +41,0 @@ };

@@ -215,2 +215,8 @@ # crypto-js [![Build Status](https://travis-ci.org/brix/crypto-js.svg?branch=develop)](https://travis-ci.org/brix/crypto-js)

### 3.3.0
Rollback, `3.3.0` is the same as `3.1.9-1`.
The move of using native secure crypto module will be shifted to a new `4.x.x` version. As it is a breaking change the impact is too big for a minor release.
### 3.2.1

@@ -217,0 +223,0 @@

@@ -176,5 +176,2 @@ ;(function (root, factory, undef) {

for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
var tMsw;
var tLsw;
// Shortcuts

@@ -188,7 +185,7 @@ var lane = state[laneIndex];

if (rhoOffset < 32) {
tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
} else /* if (rhoOffset >= 32) */ {
tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
}

@@ -228,3 +225,3 @@

lane.high ^= roundConstant.high;
lane.low ^= roundConstant.low;
lane.low ^= roundConstant.low;;
}

@@ -231,0 +228,0 @@ },

@@ -145,5 +145,2 @@ ;(function (root, factory, undef) {

for (var i = 0; i < 80; i++) {
var Wil;
var Wih;
// Shortcut

@@ -154,4 +151,4 @@ var Wi = W[i];

if (i < 16) {
Wih = Wi.high = M[offset + i * 2] | 0;
Wil = Wi.low = M[offset + i * 2 + 1] | 0;
var Wih = Wi.high = M[offset + i * 2] | 0;
var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
} else {

@@ -181,8 +178,8 @@ // Gamma0

Wil = gamma0l + Wi7l;
Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
Wil = Wil + gamma1l;
Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
Wil = Wil + Wi16l;
Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
var Wil = gamma0l + Wi7l;
var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
var Wil = Wil + gamma1l;
var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
var Wil = Wil + Wi16l;
var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);

@@ -189,0 +186,0 @@ Wi.high = Wih;

@@ -730,16 +730,7 @@ ;(function (root, factory, undef) {

var keyWords = key.words;
// Make sure the key length is valid (64, 128 or >= 192 bit)
if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
}
// Extend the key according to the keying options defined in 3DES standard
var key1 = keyWords.slice(0, 2);
var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
// Create DES instances
this._des1 = DES.createEncryptor(WordArray.create(key1));
this._des2 = DES.createEncryptor(WordArray.create(key2));
this._des3 = DES.createEncryptor(WordArray.create(key3));
this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
},

@@ -746,0 +737,0 @@

Sorry, the diff of this file is too big to display

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