Skip to content

Commit

Permalink
Merge branch 'release/3.1.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
evanvosberg committed Oct 27, 2016
2 parents 67d2e99 + 91819e8 commit be8d44d
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 38 deletions.
9 changes: 7 additions & 2 deletions aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@
*/
var AES = C_algo.AES = BlockCipher.extend({
_doReset: function () {
// Skip reset of nRounds has been set before and key did not change
if (this._nRounds && this._keyPriorReset === this._key) {
return;
}

// Shortcuts
var key = this._key;
var key = this._keyPriorReset = this._key;
var keyWords = key.words;
var keySize = key.sigBytes / 4;

// Compute number of rounds
var nRounds = this._nRounds = keySize + 6
var nRounds = this._nRounds = keySize + 6;

// Compute number of key schedule rows
var ksRows = (nRounds + 1) * 4;
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crypto-js",
"version": "3.1.7",
"version": "3.1.8",
"description": "JavaScript library of crypto standards.",
"license": "MIT",
"homepage": "http://github.com/brix/crypto-js",
Expand Down
24 changes: 21 additions & 3 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined) {
/*
* Local polyfil of Object.create
*/
var create = Object.create || (function () {
function F() {};

return function (obj) {
var subtype;

F.prototype = obj;

subtype = new F();

F.prototype = null;

return subtype;
};
}())

/**
* CryptoJS namespace.
*/
Expand All @@ -31,7 +50,7 @@
* Base object for prototypal inheritance.
*/
var Base = C_lib.Base = (function () {
function F() {}


return {
/**
Expand All @@ -54,8 +73,7 @@
*/
extend: function (overrides) {
// Spawn
F.prototype = this;
var subtype = new F();
var subtype = create(this);

// Augment
if (overrides) {
Expand Down
70 changes: 52 additions & 18 deletions crypto-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined) {
/*
* Local polyfil of Object.create
*/
var create = Object.create || (function () {
function F() {};

return function (obj) {
var subtype;

F.prototype = obj;

subtype = new F();

F.prototype = null;

return subtype;
};
}())

/**
* CryptoJS namespace.
*/
Expand All @@ -31,7 +50,7 @@
* Base object for prototypal inheritance.
*/
var Base = C_lib.Base = (function () {
function F() {}


return {
/**
Expand All @@ -54,8 +73,7 @@
*/
extend: function (overrides) {
// Spawn
F.prototype = this;
var subtype = new F();
var subtype = create(this);

// Augment
if (overrides) {
Expand Down Expand Up @@ -812,34 +830,45 @@
// Shortcuts
var base64StrLength = base64Str.length;
var map = this._map;
var reverseMap = this._reverseMap;

if (!reverseMap) {
reverseMap = this._reverseMap = [];
for (var j = 0; j < map.length; j++) {
reverseMap[map.charCodeAt(j)] = j;
}
}

// Ignore padding
var paddingChar = map.charAt(64);
if (paddingChar) {
var paddingIndex = base64Str.indexOf(paddingChar);
if (paddingIndex != -1) {
if (paddingIndex !== -1) {
base64StrLength = paddingIndex;
}
}

// Convert
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
var bitsCombined = bits1 | bits2;
words[nBytes >>> 2] |= (bitsCombined) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return parseLoop(base64Str, base64StrLength, reverseMap);

return WordArray.create(words, nBytes);
},

_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
};

function parseLoop(base64Str, base64StrLength, reverseMap) {
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return WordArray.create(words, nBytes);
}
}());


Expand Down Expand Up @@ -4429,13 +4458,18 @@
*/
var AES = C_algo.AES = BlockCipher.extend({
_doReset: function () {
// Skip reset of nRounds has been set before and key did not change
if (this._nRounds && this._keyPriorReset === this._key) {
return;
}

// Shortcuts
var key = this._key;
var key = this._keyPriorReset = this._key;
var keyWords = key.words;
var keySize = key.sigBytes / 4;

// Compute number of rounds
var nRounds = this._nRounds = keySize + 6
var nRounds = this._nRounds = keySize + 6;

// Compute number of key schedule rows
var ksRows = (nRounds + 1) * 4;
Expand Down
37 changes: 24 additions & 13 deletions enc-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,45 @@
// Shortcuts
var base64StrLength = base64Str.length;
var map = this._map;
var reverseMap = this._reverseMap;

if (!reverseMap) {
reverseMap = this._reverseMap = [];
for (var j = 0; j < map.length; j++) {
reverseMap[map.charCodeAt(j)] = j;
}
}

// Ignore padding
var paddingChar = map.charAt(64);
if (paddingChar) {
var paddingIndex = base64Str.indexOf(paddingChar);
if (paddingIndex != -1) {
if (paddingIndex !== -1) {
base64StrLength = paddingIndex;
}
}

// Convert
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
var bitsCombined = bits1 | bits2;
words[nBytes >>> 2] |= (bitsCombined) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return parseLoop(base64Str, base64StrLength, reverseMap);

return WordArray.create(words, nBytes);
},

_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
};

function parseLoop(base64Str, base64StrLength, reverseMap) {
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return WordArray.create(words, nBytes);
}
}());


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crypto-js",
"version": "3.1.7",
"version": "3.1.8",
"description": "JavaScript library of crypto standards.",
"license": "MIT",
"author": {
Expand Down

0 comments on commit be8d44d

Please sign in to comment.