Skip to content

Commit

Permalink
Merge branch 'rewrite' of https://github.com/Alanscut/crypto-js into …
Browse files Browse the repository at this point in the history
…rewrite
  • Loading branch information
Alanscut committed Oct 25, 2019
2 parents e0b5934 + 06967b6 commit ec7e1b5
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/algo/pbkdf2/pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class PBKDF2Algo extends Base {
hasher: SHA1Algo,
iterations: 1
},
cfg,
cfg
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/encoding/enc-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export const Base64 = {

const triplet = (byte1 << 16) | (byte2 << 8) | byte3;

for (let j = 0;
(j < 4) && (i + j * 0.75 < sigBytes); j++) {
for (let j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/encoding/enc-utf16.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const Utf16BE = {
}

return new WordArray(words, utf16StrLength * 2);
},
}
};
export const Utf16 = Utf16BE;

Expand Down Expand Up @@ -118,5 +118,5 @@ export const Utf16LE = {
}

return new WordArray(words, utf16StrLength * 2);
},
}
};
2 changes: 1 addition & 1 deletion src/encryption/evpkdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class EvpKDFAlgo extends Base {
hasher: MD5Algo,
iterations: 1
},
cfg,
cfg
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/encryption/rc4.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class RC4DropAlgo extends RC4Algo {
super._doReset.call(this);

// Drop
for (let i = this.cfg.drop; i > 0; i -= 1) {
for (let i = this.cfg.drop; i > 0; i--) {
generateKeystreamWord.call(this);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/encryption/tripledes.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const SBOX_P = [
0xc8000001: 0x800200,
0xd8000001: 0x0,
0xe8000001: 0x8200,
0xf8000001: 0x808002,
0xf8000001: 0x808002
},
{
0x0: 0x40084010,
Expand Down Expand Up @@ -163,7 +163,7 @@ const SBOX_P = [
0x1c800000: 0x0,
0x1d800000: 0x4010,
0x1e800000: 0x40080010,
0x1f800000: 0x84000,
0x1f800000: 0x84000
},
{
0x0: 0x104,
Expand Down Expand Up @@ -229,7 +229,7 @@ const SBOX_P = [
0x1c80000: 0x4000104,
0x1d80000: 0x4010000,
0x1e80000: 0x4,
0x1f80000: 0x10100,
0x1f80000: 0x10100
},
{
0x0: 0x80401000,
Expand Down Expand Up @@ -295,7 +295,7 @@ const SBOX_P = [
0x1c8000: 0x1040,
0x1d8000: 0x80401000,
0x1e8000: 0x400000,
0x1f8000: 0x401040,
0x1f8000: 0x401040
},
{
0x0: 0x80,
Expand Down Expand Up @@ -361,7 +361,7 @@ const SBOX_P = [
0x1c800: 0x1000080,
0x1d800: 0x40000,
0x1e800: 0x20040000,
0x1f800: 0x20000080,
0x1f800: 0x20000080
},
{
0x0: 0x10000008,
Expand Down Expand Up @@ -427,7 +427,7 @@ const SBOX_P = [
0x1c80: 0x200008,
0x1d80: 0x0,
0x1e80: 0x10000000,
0x1f80: 0x10002008,
0x1f80: 0x10002008
},
{
0x0: 0x100000,
Expand Down Expand Up @@ -493,7 +493,7 @@ const SBOX_P = [
0x1c8: 0x100401,
0x1d8: 0x400,
0x1e8: 0x2000400,
0x1f8: 0x100001,
0x1f8: 0x100001
},
{
0x0: 0x8000820,
Expand Down Expand Up @@ -559,14 +559,14 @@ const SBOX_P = [
0x8000001c: 0x20800,
0x8000001d: 0x820,
0x8000001e: 0x20020,
0x8000001f: 0x8020800,
},
0x8000001f: 0x8020800
}
];

// Masks that select the SBOX input
const SBOX_MASK = [
0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f,
0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
];

// Swap bits across the left and right words
Expand Down
2 changes: 1 addition & 1 deletion src/format/format-hex.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export const HexFormatter = {
parse(input) {
const ciphertext = Hex.parse(input);
return new CipherParams({ ciphertext });
},
}
};
2 changes: 1 addition & 1 deletion src/pad/pad-ansix923.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export const AnsiX923 = {

// Remove padding
_data.sigBytes -= nPaddingBytes;
},
}
};
2 changes: 1 addition & 1 deletion src/pad/pad-iso10126.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export const Iso10126 = {

// Remove padding
_data.sigBytes -= nPaddingBytes;
},
}
};
4 changes: 2 additions & 2 deletions src/pad/pad-iso97971.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export const Iso97971 = {
ZeroPadding.unpad(_data);

// Remove one more byte -- the 0x80 byte
_data.sigBytes -= 1;
},
_data.sigBytes--;
}
};
2 changes: 1 addition & 1 deletion src/pad/pad-nopadding.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const NoPadding = {
},

unpad() {
},
}
};
4 changes: 2 additions & 2 deletions src/pad/pad-zeropadding.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const ZeroPadding = {
const dataWords = _data.words;

// Unpad
for (let i = _data.sigBytes - 1; i >= 0; i -= 1) {
for (let i = _data.sigBytes - 1; i >= 0; i--) {
if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
_data.sigBytes = i + 1;
break;
}
}
},
}
};

0 comments on commit ec7e1b5

Please sign in to comment.