moved comment to top of the file, fixed linebreak after parens style issue
Showing
1 changed file
with
16 additions
and
19 deletions
1 | import Stream from './stream'; | ||
2 | import {unpad} from 'pkcs7'; | ||
3 | |||
4 | /** | ||
5 | * Convert network-order (big-endian) bytes into their little-endian | ||
6 | * representation. | ||
7 | */ | ||
8 | const ntoh = function(word) { | ||
9 | return (word << 24) | | ||
10 | ((word & 0xff00) << 8) | | ||
11 | ((word & 0xff0000) >> 8) | | ||
12 | (word >>> 24); | ||
13 | }; | ||
14 | |||
15 | /* | 1 | /* |
16 | * | 2 | * |
17 | * This file contains an adaptation of the AES decryption algorithm | 3 | * This file contains an adaptation of the AES decryption algorithm |
... | @@ -49,6 +35,19 @@ const ntoh = function(word) { | ... | @@ -49,6 +35,19 @@ const ntoh = function(word) { |
49 | * are those of the authors and should not be interpreted as representing | 35 | * are those of the authors and should not be interpreted as representing |
50 | * official policies, either expressed or implied, of the authors. | 36 | * official policies, either expressed or implied, of the authors. |
51 | */ | 37 | */ |
38 | import Stream from './stream'; | ||
39 | import {unpad} from 'pkcs7'; | ||
40 | |||
41 | /** | ||
42 | * Convert network-order (big-endian) bytes into their little-endian | ||
43 | * representation. | ||
44 | */ | ||
45 | const ntoh = function(word) { | ||
46 | return (word << 24) | | ||
47 | ((word & 0xff00) << 8) | | ||
48 | ((word & 0xff0000) >> 8) | | ||
49 | (word >>> 24); | ||
50 | }; | ||
52 | 51 | ||
53 | /** | 52 | /** |
54 | * Schedule out an AES key for both encryption and decryption. This | 53 | * Schedule out an AES key for both encryption and decryption. This |
... | @@ -269,11 +268,9 @@ class AES { | ... | @@ -269,11 +268,9 @@ class AES { |
269 | /* eslint-enable max-len */ | 268 | /* eslint-enable max-len */ |
270 | export const decrypt = function(encrypted, key, initVector) { | 269 | export const decrypt = function(encrypted, key, initVector) { |
271 | // word-level access to the encrypted bytes | 270 | // word-level access to the encrypted bytes |
272 | let encrypted32 = new Int32Array( | 271 | let encrypted32 = new Int32Array(encrypted.buffer, |
273 | encrypted.buffer, | 272 | encrypted.byteOffset, |
274 | encrypted.byteOffset, | 273 | encrypted.byteLength >> 2); |
275 | encrypted.byteLength >> 2 | ||
276 | ); | ||
277 | 274 | ||
278 | let decipher = new AES(Array.prototype.slice.call(key)); | 275 | let decipher = new AES(Array.prototype.slice.call(key)); |
279 | 276 | ... | ... |
-
Please register or sign in to post a comment