pdfjs-dist 2.2.228 → 2.6.347

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (229) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +8816 -19300
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +27185 -35746
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +26665 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/es5/build/pdf.min.js +22 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +61231 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/build/pdf.worker.min.js +22 -0
  17. package/es5/image_decoders/pdf.image_decoders.js +12529 -0
  18. package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
  19. package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
  20. package/es5/web/images/annotation-check.svg +11 -0
  21. package/es5/web/images/annotation-comment.svg +16 -0
  22. package/es5/web/images/annotation-help.svg +26 -0
  23. package/es5/web/images/annotation-insert.svg +10 -0
  24. package/es5/web/images/annotation-key.svg +11 -0
  25. package/es5/web/images/annotation-newparagraph.svg +11 -0
  26. package/es5/web/images/annotation-noicon.svg +7 -0
  27. package/es5/web/images/annotation-note.svg +42 -0
  28. package/es5/web/images/annotation-paragraph.svg +16 -0
  29. package/es5/web/images/loading-icon.gif +0 -0
  30. package/es5/web/images/shadow.png +0 -0
  31. package/es5/web/pdf_viewer.css +406 -0
  32. package/es5/web/pdf_viewer.js +7886 -0
  33. package/es5/web/pdf_viewer.js.map +1 -0
  34. package/image_decoders/pdf.image_decoders.js +1498 -4832
  35. package/image_decoders/pdf.image_decoders.js.map +1 -1
  36. package/image_decoders/pdf.image_decoders.min.js +22 -1
  37. package/lib/README.md +7 -0
  38. package/lib/core/annotation.js +1144 -927
  39. package/lib/core/arithmetic_decoder.js +81 -97
  40. package/lib/core/bidi.js +54 -46
  41. package/lib/core/ccitt.js +88 -81
  42. package/lib/core/ccitt_stream.js +15 -14
  43. package/lib/core/cff_parser.js +747 -716
  44. package/lib/core/charsets.js +4 -4
  45. package/lib/core/chunked_stream.js +462 -553
  46. package/lib/core/cmap.js +231 -277
  47. package/lib/core/colorspace.js +715 -857
  48. package/lib/core/core_utils.js +57 -52
  49. package/lib/core/crypto.js +416 -437
  50. package/lib/core/document.js +629 -670
  51. package/lib/core/encodings.js +15 -15
  52. package/lib/core/evaluator.js +3229 -2800
  53. package/lib/core/font_renderer.js +135 -178
  54. package/lib/core/fonts.js +602 -534
  55. package/lib/core/function.js +355 -279
  56. package/lib/core/glyphlist.js +4527 -4526
  57. package/lib/core/image.js +442 -439
  58. package/lib/core/image_utils.js +221 -61
  59. package/lib/core/jbig2.js +325 -316
  60. package/lib/core/jbig2_stream.js +18 -17
  61. package/lib/core/jpeg_stream.js +21 -26
  62. package/lib/core/jpg.js +289 -233
  63. package/lib/core/jpx.js +161 -143
  64. package/lib/core/jpx_stream.js +28 -28
  65. package/lib/core/metrics.js +2928 -2928
  66. package/lib/core/murmurhash3.js +87 -102
  67. package/lib/core/obj.js +1343 -1300
  68. package/lib/core/operator_list.js +90 -67
  69. package/lib/core/parser.js +990 -987
  70. package/lib/core/pattern.js +105 -77
  71. package/lib/core/pdf_manager.js +149 -316
  72. package/lib/core/primitives.js +156 -104
  73. package/lib/core/ps_parser.js +175 -214
  74. package/lib/core/standard_fonts.js +237 -236
  75. package/lib/core/stream.js +94 -74
  76. package/lib/core/type1_parser.js +89 -69
  77. package/lib/core/unicode.js +1654 -1654
  78. package/lib/core/worker.js +275 -290
  79. package/lib/core/worker_stream.js +101 -210
  80. package/lib/core/writer.js +242 -0
  81. package/lib/display/annotation_layer.js +772 -1041
  82. package/lib/display/annotation_storage.js +89 -0
  83. package/lib/display/api.js +1575 -1868
  84. package/lib/display/api_compatibility.js +12 -17
  85. package/lib/display/canvas.js +370 -222
  86. package/lib/display/content_disposition.js +40 -59
  87. package/lib/display/display_utils.js +341 -536
  88. package/lib/display/fetch_stream.js +188 -304
  89. package/lib/display/font_loader.js +282 -414
  90. package/lib/display/metadata.js +81 -99
  91. package/lib/display/network.js +362 -511
  92. package/lib/display/network_utils.js +25 -18
  93. package/lib/display/node_stream.js +283 -465
  94. package/lib/display/node_utils.js +87 -0
  95. package/lib/display/optional_content_config.js +184 -0
  96. package/lib/display/pattern_helper.js +93 -44
  97. package/lib/display/svg.js +1163 -1401
  98. package/lib/display/text_layer.js +154 -137
  99. package/lib/display/transport_stream.js +237 -375
  100. package/lib/display/webgl.js +70 -83
  101. package/lib/display/worker_options.js +3 -3
  102. package/lib/display/xml_parser.js +303 -392
  103. package/lib/examples/node/domstubs.js +37 -37
  104. package/lib/pdf.js +220 -58
  105. package/lib/pdf.worker.js +14 -6
  106. package/lib/shared/compatibility.js +3 -246
  107. package/lib/shared/is_node.js +7 -6
  108. package/lib/shared/message_handler.js +327 -332
  109. package/lib/shared/util.js +271 -306
  110. package/lib/test/unit/annotation_spec.js +1902 -763
  111. package/lib/test/unit/annotation_storage_spec.js +83 -0
  112. package/lib/test/unit/api_spec.js +790 -592
  113. package/lib/test/unit/bidi_spec.js +7 -7
  114. package/lib/test/unit/cff_parser_spec.js +73 -72
  115. package/lib/test/unit/clitests_helper.js +7 -9
  116. package/lib/test/unit/cmap_spec.js +86 -88
  117. package/lib/test/unit/colorspace_spec.js +346 -154
  118. package/lib/test/unit/core_utils_spec.js +125 -105
  119. package/lib/test/unit/crypto_spec.js +232 -185
  120. package/lib/test/unit/custom_spec.js +150 -24
  121. package/lib/test/unit/display_svg_spec.js +34 -39
  122. package/lib/test/unit/display_utils_spec.js +139 -149
  123. package/lib/test/unit/document_spec.js +128 -17
  124. package/lib/test/unit/encodings_spec.js +12 -34
  125. package/lib/test/unit/evaluator_spec.js +112 -91
  126. package/lib/test/unit/fetch_stream_spec.js +31 -29
  127. package/lib/test/unit/function_spec.js +206 -204
  128. package/lib/test/unit/jasmine-boot.js +48 -32
  129. package/lib/test/unit/message_handler_spec.js +173 -159
  130. package/lib/test/unit/metadata_spec.js +71 -71
  131. package/lib/test/unit/murmurhash3_spec.js +12 -12
  132. package/lib/test/unit/network_spec.js +13 -11
  133. package/lib/test/unit/network_utils_spec.js +158 -144
  134. package/lib/test/unit/node_stream_spec.js +76 -90
  135. package/lib/test/unit/parser_spec.js +108 -114
  136. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  137. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  138. package/lib/test/unit/pdf_history_spec.js +32 -32
  139. package/lib/test/unit/primitives_spec.js +337 -156
  140. package/lib/test/unit/stream_spec.js +16 -14
  141. package/lib/test/unit/test_utils.js +91 -304
  142. package/lib/test/unit/testreporter.js +33 -22
  143. package/lib/test/unit/type1_parser_spec.js +42 -42
  144. package/lib/test/unit/ui_utils_spec.js +299 -461
  145. package/lib/test/unit/unicode_spec.js +42 -42
  146. package/lib/test/unit/util_spec.js +129 -149
  147. package/lib/test/unit/writer_spec.js +84 -0
  148. package/lib/web/annotation_layer_builder.js +78 -111
  149. package/lib/web/app.js +1542 -1267
  150. package/lib/web/app_options.js +76 -91
  151. package/lib/web/base_tree_viewer.js +100 -0
  152. package/lib/web/base_viewer.js +869 -834
  153. package/lib/web/chromecom.js +165 -252
  154. package/lib/web/debugger.js +149 -205
  155. package/lib/web/download_manager.js +34 -58
  156. package/lib/web/firefox_print_service.js +62 -34
  157. package/lib/web/firefoxcom.js +206 -374
  158. package/lib/web/genericcom.js +26 -108
  159. package/lib/web/genericl10n.js +24 -153
  160. package/lib/web/grab_to_pan.js +30 -30
  161. package/lib/web/interfaces.js +80 -254
  162. package/lib/web/overlay_manager.js +70 -246
  163. package/lib/web/password_prompt.js +38 -64
  164. package/lib/web/pdf_attachment_viewer.js +150 -126
  165. package/lib/web/pdf_cursor_tools.js +75 -102
  166. package/lib/web/pdf_document_properties.js +229 -383
  167. package/lib/web/pdf_find_bar.js +136 -170
  168. package/lib/web/pdf_find_controller.js +492 -548
  169. package/lib/web/pdf_find_utils.js +13 -13
  170. package/lib/web/pdf_history.js +397 -406
  171. package/lib/web/pdf_layer_viewer.js +208 -0
  172. package/lib/web/pdf_link_service.js +304 -348
  173. package/lib/web/pdf_outline_viewer.js +119 -212
  174. package/lib/web/pdf_page_view.js +474 -513
  175. package/lib/web/pdf_presentation_mode.js +308 -357
  176. package/lib/web/pdf_print_service.js +96 -110
  177. package/lib/web/pdf_rendering_queue.js +87 -108
  178. package/lib/web/pdf_sidebar.js +286 -302
  179. package/lib/web/pdf_sidebar_resizer.js +92 -119
  180. package/lib/web/pdf_single_page_viewer.js +77 -126
  181. package/lib/web/pdf_thumbnail_view.js +289 -297
  182. package/lib/web/pdf_thumbnail_viewer.js +202 -206
  183. package/lib/web/pdf_viewer.component.js +20 -21
  184. package/lib/web/pdf_viewer.js +55 -115
  185. package/lib/web/preferences.js +69 -273
  186. package/lib/web/secondary_toolbar.js +164 -196
  187. package/lib/web/text_layer_builder.js +284 -319
  188. package/lib/web/toolbar.js +217 -210
  189. package/lib/web/ui_utils.js +274 -421
  190. package/lib/web/view_history.js +52 -226
  191. package/lib/web/viewer_compatibility.js +21 -6
  192. package/package.json +4 -9
  193. package/types/display/annotation_layer.d.ts +61 -0
  194. package/types/display/annotation_storage.d.ts +36 -0
  195. package/types/display/api.d.ts +1107 -0
  196. package/types/display/api_compatibility.d.ts +1 -0
  197. package/types/display/canvas.d.ts +4 -0
  198. package/types/display/content_disposition.d.ts +7 -0
  199. package/types/display/display_utils.d.ts +243 -0
  200. package/types/display/fetch_stream.d.ts +67 -0
  201. package/types/display/font_loader.d.ts +19 -0
  202. package/types/display/metadata.d.ts +9 -0
  203. package/types/display/network.d.ts +80 -0
  204. package/types/display/network_utils.d.ts +14 -0
  205. package/types/display/node_stream.d.ts +72 -0
  206. package/types/display/node_utils.d.ts +6 -0
  207. package/types/display/optional_content_config.d.ts +12 -0
  208. package/types/display/pattern_helper.d.ts +5 -0
  209. package/types/display/svg.d.ts +2 -0
  210. package/types/display/text_layer.d.ts +83 -0
  211. package/types/display/transport_stream.d.ts +57 -0
  212. package/types/display/webgl.d.ts +20 -0
  213. package/types/display/worker_options.d.ts +27 -0
  214. package/types/display/xml_parser.d.ts +35 -0
  215. package/types/pdf.d.ts +33 -0
  216. package/types/shared/compatibility.d.ts +1 -0
  217. package/types/shared/is_node.d.ts +1 -0
  218. package/types/shared/message_handler.d.ts +62 -0
  219. package/types/shared/util.d.ts +421 -0
  220. package/web/images/shadow.png +0 -0
  221. package/web/pdf_viewer.css +29 -27
  222. package/web/pdf_viewer.js +3524 -4746
  223. package/web/pdf_viewer.js.map +1 -1
  224. package/webpack.js +6 -5
  225. package/external/streams/streams-lib.js +0 -3962
  226. package/external/url/url-lib.js +0 -627
  227. package/lib/shared/streams_polyfill.js +0 -43
  228. package/lib/shared/url_polyfill.js +0 -56
  229. package/web/images/texture.png +0 -0
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2019 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -21,15 +21,15 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _crypto = require("../../core/crypto");
24
+ var _crypto = require("../../core/crypto.js");
25
25
 
26
- var _primitives = require("../../core/primitives");
26
+ var _primitives = require("../../core/primitives.js");
27
27
 
28
- var _util = require("../../shared/util");
28
+ var _util = require("../../shared/util.js");
29
29
 
30
- describe('crypto', function () {
30
+ describe("crypto", function () {
31
31
  function hex2binary(s) {
32
- var digits = '0123456789ABCDEF';
32
+ var digits = "0123456789ABCDEF";
33
33
  s = s.toUpperCase();
34
34
  var n = s.length >> 1,
35
35
  i,
@@ -46,232 +46,232 @@ describe('crypto', function () {
46
46
  return result;
47
47
  }
48
48
 
49
- describe('calculateMD5', function () {
50
- it('should pass RFC 1321 test #1', function () {
49
+ describe("calculateMD5", function () {
50
+ it("should pass RFC 1321 test #1", function () {
51
51
  var input, result, expected;
52
- input = (0, _util.stringToBytes)('');
52
+ input = (0, _util.stringToBytes)("");
53
53
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
54
- expected = hex2binary('d41d8cd98f00b204e9800998ecf8427e');
54
+ expected = hex2binary("d41d8cd98f00b204e9800998ecf8427e");
55
55
  expect(result).toEqual(expected);
56
56
  });
57
- it('should pass RFC 1321 test #2', function () {
57
+ it("should pass RFC 1321 test #2", function () {
58
58
  var input, result, expected;
59
- input = (0, _util.stringToBytes)('a');
59
+ input = (0, _util.stringToBytes)("a");
60
60
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
61
- expected = hex2binary('0cc175b9c0f1b6a831c399e269772661');
61
+ expected = hex2binary("0cc175b9c0f1b6a831c399e269772661");
62
62
  expect(result).toEqual(expected);
63
63
  });
64
- it('should pass RFC 1321 test #3', function () {
64
+ it("should pass RFC 1321 test #3", function () {
65
65
  var input, result, expected;
66
- input = (0, _util.stringToBytes)('abc');
66
+ input = (0, _util.stringToBytes)("abc");
67
67
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
68
- expected = hex2binary('900150983cd24fb0d6963f7d28e17f72');
68
+ expected = hex2binary("900150983cd24fb0d6963f7d28e17f72");
69
69
  expect(result).toEqual(expected);
70
70
  });
71
- it('should pass RFC 1321 test #4', function () {
71
+ it("should pass RFC 1321 test #4", function () {
72
72
  var input, result, expected;
73
- input = (0, _util.stringToBytes)('message digest');
73
+ input = (0, _util.stringToBytes)("message digest");
74
74
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
75
- expected = hex2binary('f96b697d7cb7938d525a2f31aaf161d0');
75
+ expected = hex2binary("f96b697d7cb7938d525a2f31aaf161d0");
76
76
  expect(result).toEqual(expected);
77
77
  });
78
- it('should pass RFC 1321 test #5', function () {
78
+ it("should pass RFC 1321 test #5", function () {
79
79
  var input, result, expected;
80
- input = (0, _util.stringToBytes)('abcdefghijklmnopqrstuvwxyz');
80
+ input = (0, _util.stringToBytes)("abcdefghijklmnopqrstuvwxyz");
81
81
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
82
- expected = hex2binary('c3fcd3d76192e4007dfb496cca67e13b');
82
+ expected = hex2binary("c3fcd3d76192e4007dfb496cca67e13b");
83
83
  expect(result).toEqual(expected);
84
84
  });
85
- it('should pass RFC 1321 test #6', function () {
85
+ it("should pass RFC 1321 test #6", function () {
86
86
  var input, result, expected;
87
- input = (0, _util.stringToBytes)('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv' + 'wxyz0123456789');
87
+ input = (0, _util.stringToBytes)("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
88
88
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
89
- expected = hex2binary('d174ab98d277d9f5a5611c2c9f419d9f');
89
+ expected = hex2binary("d174ab98d277d9f5a5611c2c9f419d9f");
90
90
  expect(result).toEqual(expected);
91
91
  });
92
- it('should pass RFC 1321 test #7', function () {
92
+ it("should pass RFC 1321 test #7", function () {
93
93
  var input, result, expected;
94
- input = (0, _util.stringToBytes)('123456789012345678901234567890123456789012345678' + '90123456789012345678901234567890');
94
+ input = (0, _util.stringToBytes)("123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890");
95
95
  result = (0, _crypto.calculateMD5)(input, 0, input.length);
96
- expected = hex2binary('57edf4a22be3c955ac49da2e2107b67a');
96
+ expected = hex2binary("57edf4a22be3c955ac49da2e2107b67a");
97
97
  expect(result).toEqual(expected);
98
98
  });
99
99
  });
100
- describe('ARCFourCipher', function () {
101
- it('should pass test #1', function () {
100
+ describe("ARCFourCipher", function () {
101
+ it("should pass test #1", function () {
102
102
  var key, input, result, expected, cipher;
103
- key = hex2binary('0123456789abcdef');
104
- input = hex2binary('0123456789abcdef');
103
+ key = hex2binary("0123456789abcdef");
104
+ input = hex2binary("0123456789abcdef");
105
105
  cipher = new _crypto.ARCFourCipher(key);
106
106
  result = cipher.encryptBlock(input);
107
- expected = hex2binary('75b7878099e0c596');
107
+ expected = hex2binary("75b7878099e0c596");
108
108
  expect(result).toEqual(expected);
109
109
  });
110
- it('should pass test #2', function () {
110
+ it("should pass test #2", function () {
111
111
  var key, input, result, expected, cipher;
112
- key = hex2binary('0123456789abcdef');
113
- input = hex2binary('0000000000000000');
112
+ key = hex2binary("0123456789abcdef");
113
+ input = hex2binary("0000000000000000");
114
114
  cipher = new _crypto.ARCFourCipher(key);
115
115
  result = cipher.encryptBlock(input);
116
- expected = hex2binary('7494c2e7104b0879');
116
+ expected = hex2binary("7494c2e7104b0879");
117
117
  expect(result).toEqual(expected);
118
118
  });
119
- it('should pass test #3', function () {
119
+ it("should pass test #3", function () {
120
120
  var key, input, result, expected, cipher;
121
- key = hex2binary('0000000000000000');
122
- input = hex2binary('0000000000000000');
121
+ key = hex2binary("0000000000000000");
122
+ input = hex2binary("0000000000000000");
123
123
  cipher = new _crypto.ARCFourCipher(key);
124
124
  result = cipher.encryptBlock(input);
125
- expected = hex2binary('de188941a3375d3a');
125
+ expected = hex2binary("de188941a3375d3a");
126
126
  expect(result).toEqual(expected);
127
127
  });
128
- it('should pass test #4', function () {
128
+ it("should pass test #4", function () {
129
129
  var key, input, result, expected, cipher;
130
- key = hex2binary('ef012345');
131
- input = hex2binary('00000000000000000000');
130
+ key = hex2binary("ef012345");
131
+ input = hex2binary("00000000000000000000");
132
132
  cipher = new _crypto.ARCFourCipher(key);
133
133
  result = cipher.encryptBlock(input);
134
- expected = hex2binary('d6a141a7ec3c38dfbd61');
134
+ expected = hex2binary("d6a141a7ec3c38dfbd61");
135
135
  expect(result).toEqual(expected);
136
136
  });
137
- it('should pass test #5', function () {
137
+ it("should pass test #5", function () {
138
138
  var key, input, result, expected, cipher;
139
- key = hex2binary('0123456789abcdef');
140
- input = hex2binary('010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '101010101010101010101');
139
+ key = hex2binary("0123456789abcdef");
140
+ input = hex2binary("010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "10101010101010101010101010101010101010101010101010101010101010101010" + "101010101010101010101");
141
141
  cipher = new _crypto.ARCFourCipher(key);
142
142
  result = cipher.encryptBlock(input);
143
- expected = hex2binary('7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76' + '533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b' + '1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377' + '108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d' + '7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747' + 'b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44' + 'c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4' + '2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e' + '2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1' + '5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405' + 'b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509' + 'eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849' + 'aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c' + '8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d' + 'dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8' + 'd49e2755ab181ab7e940b0c0');
143
+ expected = hex2binary("7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76" + "533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b" + "1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377" + "108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d" + "7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747" + "b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44" + "c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4" + "2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e" + "2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1" + "5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405" + "b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509" + "eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849" + "aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c" + "8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d" + "dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8" + "d49e2755ab181ab7e940b0c0");
144
144
  expect(result).toEqual(expected);
145
145
  });
146
- it('should pass test #6', function () {
146
+ it("should pass test #6", function () {
147
147
  var key, input, result, expected, cipher;
148
- key = hex2binary('fb029e3031323334');
149
- input = hex2binary('aaaa0300000008004500004e661a00008011be640a0001220af' + 'fffff00890089003a000080a601100001000000000000204543454a4548454346434' + '550464545494546464343414341434143414341414100002000011bd0b604');
148
+ key = hex2binary("fb029e3031323334");
149
+ input = hex2binary("aaaa0300000008004500004e661a00008011be640a0001220af" + "fffff00890089003a000080a601100001000000000000204543454a4548454346434" + "550464545494546464343414341434143414341414100002000011bd0b604");
150
150
  cipher = new _crypto.ARCFourCipher(key);
151
151
  result = cipher.encryptBlock(input);
152
- expected = hex2binary('f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f' + '58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53' + '80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7');
152
+ expected = hex2binary("f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f" + "58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53" + "80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7");
153
153
  expect(result).toEqual(expected);
154
154
  });
155
- it('should pass test #7', function () {
155
+ it("should pass test #7", function () {
156
156
  var key, input, result, expected, cipher;
157
- key = hex2binary('0123456789abcdef');
158
- input = hex2binary('123456789abcdef0123456789abcdef0123456789abcdef0123' + '45678');
157
+ key = hex2binary("0123456789abcdef");
158
+ input = hex2binary("123456789abcdef0123456789abcdef0123456789abcdef012345678");
159
159
  cipher = new _crypto.ARCFourCipher(key);
160
160
  result = cipher.encryptBlock(input);
161
- expected = hex2binary('66a0949f8af7d6891f7f832ba833c00c892ebe30143ce287' + '40011ecf');
161
+ expected = hex2binary("66a0949f8af7d6891f7f832ba833c00c892ebe30143ce28740011ecf");
162
162
  expect(result).toEqual(expected);
163
163
  });
164
164
  });
165
- describe('calculateSHA256', function () {
166
- it('should properly hash abc', function () {
165
+ describe("calculateSHA256", function () {
166
+ it("should properly hash abc", function () {
167
167
  var input, result, expected;
168
- input = (0, _util.stringToBytes)('abc');
168
+ input = (0, _util.stringToBytes)("abc");
169
169
  result = (0, _crypto.calculateSHA256)(input, 0, input.length);
170
- expected = hex2binary('BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9C' + 'B410FF61F20015AD');
170
+ expected = hex2binary("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD");
171
171
  expect(result).toEqual(expected);
172
172
  });
173
- it('should properly hash a multiblock input', function () {
173
+ it("should properly hash a multiblock input", function () {
174
174
  var input, result, expected;
175
- input = (0, _util.stringToBytes)('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno' + 'mnopnopq');
175
+ input = (0, _util.stringToBytes)("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
176
176
  result = (0, _crypto.calculateSHA256)(input, 0, input.length);
177
- expected = hex2binary('248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167' + 'F6ECEDD419DB06C1');
177
+ expected = hex2binary("248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1");
178
178
  expect(result).toEqual(expected);
179
179
  });
180
180
  });
181
- describe('calculateSHA384', function () {
182
- it('should properly hash abc', function () {
181
+ describe("calculateSHA384", function () {
182
+ it("should properly hash abc", function () {
183
183
  var input, result, expected;
184
- input = (0, _util.stringToBytes)('abc');
184
+ input = (0, _util.stringToBytes)("abc");
185
185
  result = (0, _crypto.calculateSHA384)(input, 0, input.length);
186
- expected = hex2binary('CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163' + '1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7');
186
+ expected = hex2binary("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163" + "1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7");
187
187
  expect(result).toEqual(expected);
188
188
  });
189
- it('should properly hash a multiblock input', function () {
189
+ it("should properly hash a multiblock input", function () {
190
190
  var input, result, expected;
191
- input = (0, _util.stringToBytes)('abcdefghbcdefghicdefghijdefghijkefghijklfghijklm' + 'ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs' + 'mnopqrstnopqrstu');
191
+ input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
192
192
  result = (0, _crypto.calculateSHA384)(input, 0, input.length);
193
- expected = hex2binary('09330C33F71147E83D192FC782CD1B4753111B173B3B05D2' + '2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039');
193
+ expected = hex2binary("09330C33F71147E83D192FC782CD1B4753111B173B3B05D2" + "2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039");
194
194
  expect(result).toEqual(expected);
195
195
  });
196
196
  });
197
- describe('calculateSHA512', function () {
198
- it('should properly hash abc', function () {
197
+ describe("calculateSHA512", function () {
198
+ it("should properly hash abc", function () {
199
199
  var input, result, expected;
200
- input = (0, _util.stringToBytes)('abc');
200
+ input = (0, _util.stringToBytes)("abc");
201
201
  result = (0, _crypto.calculateSHA512)(input, 0, input.length);
202
- expected = hex2binary('DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2' + '0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD' + '454D4423643CE80E2A9AC94FA54CA49F');
202
+ expected = hex2binary("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2" + "0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD" + "454D4423643CE80E2A9AC94FA54CA49F");
203
203
  expect(result).toEqual(expected);
204
204
  });
205
- it('should properly hash a multiblock input', function () {
205
+ it("should properly hash a multiblock input", function () {
206
206
  var input, result, expected;
207
- input = (0, _util.stringToBytes)('abcdefghbcdefghicdefghijdefghijkefghijklfghijklm' + 'ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs' + 'mnopqrstnopqrstu');
207
+ input = (0, _util.stringToBytes)("abcdefghbcdefghicdefghijdefghijkefghijklfghijklm" + "ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs" + "mnopqrstnopqrstu");
208
208
  result = (0, _crypto.calculateSHA512)(input, 0, input.length);
209
- expected = hex2binary('8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1' + '7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A' + 'C7D329EEB6DD26545E96E55B874BE909');
209
+ expected = hex2binary("8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1" + "7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A" + "C7D329EEB6DD26545E96E55B874BE909");
210
210
  expect(result).toEqual(expected);
211
211
  });
212
212
  });
213
- describe('AES128', function () {
214
- describe('Encryption', function () {
215
- it('should be able to encrypt a block', function () {
213
+ describe("AES128", function () {
214
+ describe("Encryption", function () {
215
+ it("should be able to encrypt a block", function () {
216
216
  var input, key, result, expected, iv, cipher;
217
- input = hex2binary('00112233445566778899aabbccddeeff');
218
- key = hex2binary('000102030405060708090a0b0c0d0e0f');
219
- iv = hex2binary('00000000000000000000000000000000');
217
+ input = hex2binary("00112233445566778899aabbccddeeff");
218
+ key = hex2binary("000102030405060708090a0b0c0d0e0f");
219
+ iv = hex2binary("00000000000000000000000000000000");
220
220
  cipher = new _crypto.AES128Cipher(key);
221
221
  result = cipher.encrypt(input, iv);
222
- expected = hex2binary('69c4e0d86a7b0430d8cdb78070b4c55a');
222
+ expected = hex2binary("69c4e0d86a7b0430d8cdb78070b4c55a");
223
223
  expect(result).toEqual(expected);
224
224
  });
225
225
  });
226
- describe('Decryption', function () {
227
- it('should be able to decrypt a block with IV in stream', function () {
226
+ describe("Decryption", function () {
227
+ it("should be able to decrypt a block with IV in stream", function () {
228
228
  var input, key, result, expected, cipher;
229
- input = hex2binary('0000000000000000000000000000000069c4e0d86a7b0430d' + '8cdb78070b4c55a');
230
- key = hex2binary('000102030405060708090a0b0c0d0e0f');
229
+ input = hex2binary("0000000000000000000000000000000069c4e0d86a7b0430d" + "8cdb78070b4c55a");
230
+ key = hex2binary("000102030405060708090a0b0c0d0e0f");
231
231
  cipher = new _crypto.AES128Cipher(key);
232
232
  result = cipher.decryptBlock(input);
233
- expected = hex2binary('00112233445566778899aabbccddeeff');
233
+ expected = hex2binary("00112233445566778899aabbccddeeff");
234
234
  expect(result).toEqual(expected);
235
235
  });
236
236
  });
237
237
  });
238
- describe('AES256', function () {
239
- describe('Encryption', function () {
240
- it('should be able to encrypt a block', function () {
238
+ describe("AES256", function () {
239
+ describe("Encryption", function () {
240
+ it("should be able to encrypt a block", function () {
241
241
  var input, key, result, expected, iv, cipher;
242
- input = hex2binary('00112233445566778899aabbccddeeff');
243
- key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f');
244
- iv = hex2binary('00000000000000000000000000000000');
242
+ input = hex2binary("00112233445566778899aabbccddeeff");
243
+ key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
244
+ iv = hex2binary("00000000000000000000000000000000");
245
245
  cipher = new _crypto.AES256Cipher(key);
246
246
  result = cipher.encrypt(input, iv);
247
- expected = hex2binary('8ea2b7ca516745bfeafc49904b496089');
247
+ expected = hex2binary("8ea2b7ca516745bfeafc49904b496089");
248
248
  expect(result).toEqual(expected);
249
249
  });
250
250
  });
251
- describe('Decryption', function () {
252
- it('should be able to decrypt a block with specified iv', function () {
251
+ describe("Decryption", function () {
252
+ it("should be able to decrypt a block with specified iv", function () {
253
253
  var input, key, result, expected, cipher, iv;
254
- input = hex2binary('8ea2b7ca516745bfeafc49904b496089');
255
- key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f');
256
- iv = hex2binary('00000000000000000000000000000000');
254
+ input = hex2binary("8ea2b7ca516745bfeafc49904b496089");
255
+ key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
256
+ iv = hex2binary("00000000000000000000000000000000");
257
257
  cipher = new _crypto.AES256Cipher(key);
258
258
  result = cipher.decryptBlock(input, false, iv);
259
- expected = hex2binary('00112233445566778899aabbccddeeff');
259
+ expected = hex2binary("00112233445566778899aabbccddeeff");
260
260
  expect(result).toEqual(expected);
261
261
  });
262
- it('should be able to decrypt a block with IV in stream', function () {
262
+ it("should be able to decrypt a block with IV in stream", function () {
263
263
  var input, key, result, expected, cipher;
264
- input = hex2binary('000000000000000000000000000000008ea2b7ca516745bf' + 'eafc49904b496089');
265
- key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f');
264
+ input = hex2binary("000000000000000000000000000000008ea2b7ca516745bf" + "eafc49904b496089");
265
+ key = hex2binary("000102030405060708090a0b0c0d0e0f101112131415161718" + "191a1b1c1d1e1f");
266
266
  cipher = new _crypto.AES256Cipher(key);
267
267
  result = cipher.decryptBlock(input, false);
268
- expected = hex2binary('00112233445566778899aabbccddeeff');
268
+ expected = hex2binary("00112233445566778899aabbccddeeff");
269
269
  expect(result).toEqual(expected);
270
270
  });
271
271
  });
272
272
  });
273
- describe('PDF17Algorithm', function () {
274
- it('should correctly check a user key', function () {
273
+ describe("PDF17Algorithm", function () {
274
+ it("should correctly check a user key", function () {
275
275
  var password, userValidation, userPassword, alg, result;
276
276
  alg = new _crypto.PDF17();
277
277
  password = new Uint8Array([117, 115, 101, 114]);
@@ -280,7 +280,7 @@ describe('crypto', function () {
280
280
  result = alg.checkUserPassword(password, userValidation, userPassword);
281
281
  expect(result).toEqual(true);
282
282
  });
283
- it('should correctly check an owner key', function () {
283
+ it("should correctly check an owner key", function () {
284
284
  var password, ownerValidation, ownerPassword, alg, result, uBytes;
285
285
  alg = new _crypto.PDF17();
286
286
  password = new Uint8Array([111, 119, 110, 101, 114]);
@@ -290,7 +290,7 @@ describe('crypto', function () {
290
290
  result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
291
291
  expect(result).toEqual(true);
292
292
  });
293
- it('should generate a file encryption key from the user key', function () {
293
+ it("should generate a file encryption key from the user key", function () {
294
294
  var password, userKeySalt, expected, alg, result, userEncryption;
295
295
  alg = new _crypto.PDF17();
296
296
  password = new Uint8Array([117, 115, 101, 114]);
@@ -300,7 +300,7 @@ describe('crypto', function () {
300
300
  expected = new Uint8Array([63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153, 151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213]);
301
301
  expect(result).toEqual(expected);
302
302
  });
303
- it('should generate a file encryption key from the owner key', function () {
303
+ it("should generate a file encryption key from the owner key", function () {
304
304
  var password, ownerKeySalt, expected, alg, result, ownerEncryption;
305
305
  var uBytes;
306
306
  alg = new _crypto.PDF17();
@@ -313,8 +313,8 @@ describe('crypto', function () {
313
313
  expect(result).toEqual(expected);
314
314
  });
315
315
  });
316
- describe('PDF20Algorithm', function () {
317
- it('should correctly check a user key', function () {
316
+ describe("PDF20Algorithm", function () {
317
+ it("should correctly check a user key", function () {
318
318
  var password, userValidation, userPassword, alg, result;
319
319
  alg = new _crypto.PDF20();
320
320
  password = new Uint8Array([117, 115, 101, 114]);
@@ -323,7 +323,7 @@ describe('crypto', function () {
323
323
  result = alg.checkUserPassword(password, userValidation, userPassword);
324
324
  expect(result).toEqual(true);
325
325
  });
326
- it('should correctly check an owner key', function () {
326
+ it("should correctly check an owner key", function () {
327
327
  var password, ownerValidation, ownerPassword, alg, result, uBytes;
328
328
  alg = new _crypto.PDF20();
329
329
  password = new Uint8Array([111, 119, 110, 101, 114]);
@@ -333,7 +333,7 @@ describe('crypto', function () {
333
333
  result = alg.checkOwnerPassword(password, ownerValidation, uBytes, ownerPassword);
334
334
  expect(result).toEqual(true);
335
335
  });
336
- it('should generate a file encryption key from the user key', function () {
336
+ it("should generate a file encryption key from the user key", function () {
337
337
  var password, userKeySalt, expected, alg, result, userEncryption;
338
338
  alg = new _crypto.PDF20();
339
339
  password = new Uint8Array([117, 115, 101, 114]);
@@ -343,7 +343,7 @@ describe('crypto', function () {
343
343
  expected = new Uint8Array([42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34, 107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239]);
344
344
  expect(result).toEqual(expected);
345
345
  });
346
- it('should generate a file encryption key from the owner key', function () {
346
+ it("should generate a file encryption key from the owner key", function () {
347
347
  var password, ownerKeySalt, expected, alg, result, ownerEncryption;
348
348
  var uBytes;
349
349
  alg = new _crypto.PDF20();
@@ -357,7 +357,7 @@ describe('crypto', function () {
357
357
  });
358
358
  });
359
359
  });
360
- describe('CipherTransformFactory', function () {
360
+ describe("CipherTransformFactory", function () {
361
361
  function buildDict(map) {
362
362
  var dict = new _primitives.Dict();
363
363
 
@@ -371,9 +371,9 @@ describe('CipherTransformFactory', function () {
371
371
  function ensurePasswordCorrect(done, dict, fileId, password) {
372
372
  try {
373
373
  var factory = new _crypto.CipherTransformFactory(dict, fileId, password);
374
- expect('createCipherTransform' in factory).toEqual(true);
374
+ expect("createCipherTransform" in factory).toEqual(true);
375
375
  } catch (ex) {
376
- done.fail('Password should be accepted: ' + ex);
376
+ done.fail("Password should be accepted: " + ex);
377
377
  return;
378
378
  }
379
379
 
@@ -390,7 +390,7 @@ describe('CipherTransformFactory', function () {
390
390
  return;
391
391
  }
392
392
 
393
- done.fail('Password should be rejected.');
393
+ done.fail("Password should be rejected.");
394
394
  }
395
395
 
396
396
  function ensurePasswordIncorrect(done, dict, fileId, password) {
@@ -403,135 +403,182 @@ describe('CipherTransformFactory', function () {
403
403
  return;
404
404
  }
405
405
 
406
- done.fail('Password should be rejected.');
406
+ done.fail("Password should be rejected.");
407
407
  }
408
408
 
409
- var fileId1, fileId2, dict1, dict2;
409
+ function ensureEncryptDecryptIsIdentity(dict, fileId, password, string) {
410
+ const factory = new _crypto.CipherTransformFactory(dict, fileId, password);
411
+ const cipher = factory.createCipherTransform(123, 0);
412
+ const encrypted = cipher.encryptString(string);
413
+ const decrypted = cipher.decryptString(encrypted);
414
+ expect(string).toEqual(decrypted);
415
+ }
416
+
417
+ var fileId1, fileId2, dict1, dict2, dict3;
410
418
  var aes256Dict, aes256IsoDict, aes256BlankDict, aes256IsoBlankDict;
411
419
  beforeAll(function (done) {
412
- fileId1 = unescape('%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18');
413
- fileId2 = unescape('%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC');
420
+ fileId1 = unescape("%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18");
421
+ fileId2 = unescape("%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC");
414
422
  dict1 = buildDict({
415
- Filter: _primitives.Name.get('Standard'),
423
+ Filter: _primitives.Name.get("Standard"),
416
424
  V: 2,
417
425
  Length: 128,
418
- O: unescape('%80%C3%04%96%91o%20sl%3A%E6%1B%13T%91%F2%0DV%12%E3%FF%5E%B' + 'B%E9VO%D8k%9A%CA%7C%5D'),
419
- U: unescape('j%0C%8D%3EY%19%00%BCjd%7D%91%BD%AA%00%18%00%00%00%00%00%00' + '%00%00%00%00%00%00%00%00%00%00'),
426
+ O: unescape("%80%C3%04%96%91o%20sl%3A%E6%1B%13T%91%F2%0DV%12%E3%FF%5E%B" + "B%E9VO%D8k%9A%CA%7C%5D"),
427
+ U: unescape("j%0C%8D%3EY%19%00%BCjd%7D%91%BD%AA%00%18%00%00%00%00%00%00" + "%00%00%00%00%00%00%00%00%00%00"),
420
428
  P: -1028,
421
429
  R: 3
422
430
  });
423
431
  dict2 = buildDict({
424
- Filter: _primitives.Name.get('Standard'),
432
+ Filter: _primitives.Name.get("Standard"),
425
433
  V: 4,
426
434
  Length: 128,
427
- O: unescape('sF%14v.y5%27%DB%97%0A5%22%B3%E1%D4%AD%BD%9B%3C%B4%A5%89u%1' + '5%B2Y%F1h%D9%E9%F4'),
428
- U: unescape('%93%04%89%A9%BF%8AE%A6%88%A2%DB%C2%A0%A8gn%00%00%00%00%00%' + '00%00%00%00%00%00%00%00%00%00%00'),
435
+ O: unescape("sF%14v.y5%27%DB%97%0A5%22%B3%E1%D4%AD%BD%9B%3C%B4%A5%89u%1" + "5%B2Y%F1h%D9%E9%F4"),
436
+ U: unescape("%93%04%89%A9%BF%8AE%A6%88%A2%DB%C2%A0%A8gn%00%00%00%00%00%" + "00%00%00%00%00%00%00%00%00%00%00"),
429
437
  P: -1084,
430
438
  R: 4
431
439
  });
432
- aes256Dict = buildDict({
433
- Filter: _primitives.Name.get('Standard'),
440
+ dict3 = {
441
+ Filter: _primitives.Name.get("Standard"),
434
442
  V: 5,
435
443
  Length: 256,
436
- O: unescape('%3Cb%89%233e%C8%98%D2%B2%E2%E4%86%CD%A3%18%CC%7E%B1%24j2%2' + '4%7D%D2%AC%ABx%DEl%8Bs%F3vG%99%80%11e%3E%C8%F5%F2%0C%DA%7B' + '%18x'),
437
- U: unescape('%83%F2%8F%A0W%02%8A%86O%FD%BD%AD%E0I%90%F1%BEQ%C5%0F%F9i%9' + '1%97%0F%C2A%03%01%7E%BB%DDu%A9%04%20%9Fe%16%DC%A8%5E%D7%C0' + 'd%26%BC%28'),
438
- OE: unescape('%D5%CA%0E%BDnLF%BF%06%C3%0A%BE%9Dd%90U%08%3E%7B%B2%9C%E52' + '%28%E5%D86%DE%22%26j%DF'),
439
- UE: unescape('%23%96%C3%A9%F533%FF%9E%9E%21%F2%E7K%7D%BE%19%7E%ACr%C3%F' + '4%89%F5%EA%A5*J%3C%26%11%11'),
440
- Perms: unescape('%D8%FC%844%E5e%0DB%5D%7Ff%FD%3COMM'),
444
+ O: unescape("%3Cb%89%233e%C8%98%D2%B2%E2%E4%86%CD%A3%18%CC%7E%B1%24j2%2" + "4%7D%D2%AC%ABx%DEl%8Bs%F3vG%99%80%11e%3E%C8%F5%F2%0C%DA%7B" + "%18x"),
445
+ U: unescape("%83%F2%8F%A0W%02%8A%86O%FD%BD%AD%E0I%90%F1%BEQ%C5%0F%F9i%9" + "1%97%0F%C2A%03%01%7E%BB%DDu%A9%04%20%9Fe%16%DC%A8%5E%D7%C0" + "d%26%BC%28"),
446
+ OE: unescape("%D5%CA%0E%BDnLF%BF%06%C3%0A%BE%9Dd%90U%08%3E%7B%B2%9C%E52" + "%28%E5%D86%DE%22%26j%DF"),
447
+ UE: unescape("%23%96%C3%A9%F533%FF%9E%9E%21%F2%E7K%7D%BE%19%7E%ACr%C3%F" + "4%89%F5%EA%A5*J%3C%26%11%11"),
448
+ Perms: unescape("%D8%FC%844%E5e%0DB%5D%7Ff%FD%3COMM"),
441
449
  P: -1084,
442
450
  R: 5
443
- });
451
+ };
452
+ aes256Dict = buildDict(dict3);
444
453
  aes256IsoDict = buildDict({
445
- Filter: _primitives.Name.get('Standard'),
454
+ Filter: _primitives.Name.get("Standard"),
446
455
  V: 5,
447
456
  Length: 256,
448
- O: unescape('X%E8%3E6%F5%1A%F5%D1%89%7B%DDH%C71%25%D9%1FJs%A7%7F%9E%B0M' + '-%A3W/%27Z%D9%8D%8E%E8%A9%D0%CA%D6%05%B9%1D%D0%B9.%0BL%87%' + '95'),
449
- U: unescape('%5E%E6%CDK%A6c%FAL%DB%80%11U9%11%21%A4%96.g%B0%A0%9C%BB%E9' + '%A6%DF%A3%FD%93%EB_%B8S%F5%92e%C6%F7%22%C6%BF%0B%10%5E%ED%' + 'D8%14%AF'),
450
- OE: unescape('%D1I%E0Mg%9B%C9%B5%BED%DF%14%3EZ8%D2%05%F0%B2%80%EE%7CD%F' + 'E%FD%F4%3El%D0%87%0A%FB'),
451
- UE: unescape('y%D0%02%B5%E6Y%9C%3C%FD%8F%D4%1CT%B4%C4%B1%AD%80%DDk.%14%' + '5E%BA%873_%18%14%DF%FE%24'),
452
- Perms: unescape('l%AD%0F%A0%EBM%86WM%3E%CB%B5%E0X%C97'),
457
+ O: unescape("X%E8%3E6%F5%1A%F5%D1%89%7B%DDH%C71%25%D9%1FJs%A7%7F%9E%B0M" + "-%A3W/%27Z%D9%8D%8E%E8%A9%D0%CA%D6%05%B9%1D%D0%B9.%0BL%87%" + "95"),
458
+ U: unescape("%5E%E6%CDK%A6c%FAL%DB%80%11U9%11%21%A4%96.g%B0%A0%9C%BB%E9" + "%A6%DF%A3%FD%93%EB_%B8S%F5%92e%C6%F7%22%C6%BF%0B%10%5E%ED%" + "D8%14%AF"),
459
+ OE: unescape("%D1I%E0Mg%9B%C9%B5%BED%DF%14%3EZ8%D2%05%F0%B2%80%EE%7CD%F" + "E%FD%F4%3El%D0%87%0A%FB"),
460
+ UE: unescape("y%D0%02%B5%E6Y%9C%3C%FD%8F%D4%1CT%B4%C4%B1%AD%80%DDk.%14%" + "5E%BA%873_%18%14%DF%FE%24"),
461
+ Perms: unescape("l%AD%0F%A0%EBM%86WM%3E%CB%B5%E0X%C97"),
453
462
  P: -1084,
454
463
  R: 6
455
464
  });
456
465
  aes256BlankDict = buildDict({
457
- Filter: _primitives.Name.get('Standard'),
466
+ Filter: _primitives.Name.get("Standard"),
458
467
  V: 5,
459
468
  Length: 256,
460
- O: unescape('%B8p%04%C3g%26%FCW%CCN%D4%16%A1%E8%950YZ%C9%9E%B1-%97%F3%F' + 'E%03%13%19ffZn%8F%F5%EB%EC%CC5sV%10e%CEl%B5%E9G%C1'),
461
- U: unescape('%83%D4zi%F1O0%961%12%CC%82%CB%CA%BF5y%FD%21%EB%E4%D1%B5%1D' + '%D6%FA%14%F3%BE%8Fqs%EF%88%DE%E2%E8%DC%F55%E4%B8%16%C8%14%' + '8De%1E'),
462
- OE: unescape('%8F%19%E8%D4%27%D5%07%CA%C6%A1%11%A6a%5Bt%F4%DF%0F%84%29%' + '0F%E4%EFF7%5B%5B%11%A0%8F%17e'),
463
- UE: unescape('%81%F5%5D%B0%28%81%E4%7F_%7C%8F%85b%A0%7E%10%D0%88lx%7B%7' + 'EJ%5E%912%B6d%12%27%05%F6'),
464
- Perms: unescape('%86%1562%0D%AE%A2%FB%5D%3B%22%3Dq%12%B2H'),
469
+ O: unescape("%B8p%04%C3g%26%FCW%CCN%D4%16%A1%E8%950YZ%C9%9E%B1-%97%F3%F" + "E%03%13%19ffZn%8F%F5%EB%EC%CC5sV%10e%CEl%B5%E9G%C1"),
470
+ U: unescape("%83%D4zi%F1O0%961%12%CC%82%CB%CA%BF5y%FD%21%EB%E4%D1%B5%1D" + "%D6%FA%14%F3%BE%8Fqs%EF%88%DE%E2%E8%DC%F55%E4%B8%16%C8%14%" + "8De%1E"),
471
+ OE: unescape("%8F%19%E8%D4%27%D5%07%CA%C6%A1%11%A6a%5Bt%F4%DF%0F%84%29%" + "0F%E4%EFF7%5B%5B%11%A0%8F%17e"),
472
+ UE: unescape("%81%F5%5D%B0%28%81%E4%7F_%7C%8F%85b%A0%7E%10%D0%88lx%7B%7" + "EJ%5E%912%B6d%12%27%05%F6"),
473
+ Perms: unescape("%86%1562%0D%AE%A2%FB%5D%3B%22%3Dq%12%B2H"),
465
474
  P: -1084,
466
475
  R: 5
467
476
  });
468
477
  aes256IsoBlankDict = buildDict({
469
- Filter: _primitives.Name.get('Standard'),
478
+ Filter: _primitives.Name.get("Standard"),
470
479
  V: 5,
471
480
  Length: 256,
472
- O: unescape('%F7%DB%99U%A6M%ACk%AF%CF%D7AFw%E9%C1%91%CBDgI%23R%CF%0C%15' + 'r%D74%0D%CE%E9%91@%E4%98QF%BF%88%7Ej%DE%AD%8F%F4@%C1'),
473
- U: unescape('%1A%A9%DC%918%83%93k%29%5B%117%B16%DB%E8%8E%FE%28%E5%89%D4' + '%0E%AD%12%3B%7DN_6fez%8BG%18%05YOh%7DZH%A3Z%87%17*'),
474
- OE: unescape('%A4a%88%20h%1B%7F%CD%D5%CAc%D8R%83%E5%D6%1C%D2%98%07%984%' + 'BA%AF%1B%B4%7FQ%F8%1EU%7D'),
475
- UE: unescape('%A0%0AZU%27%1D%27%2C%0B%FE%0E%A2L%F9b%5E%A1%B9%D6v7b%B26%' + 'A9N%99%F1%A4Deq'),
476
- Perms: unescape('%03%F2i%07%0D%C3%F9%F2%28%80%B7%F5%DD%D1c%EB'),
481
+ O: unescape("%F7%DB%99U%A6M%ACk%AF%CF%D7AFw%E9%C1%91%CBDgI%23R%CF%0C%15" + "r%D74%0D%CE%E9%91@%E4%98QF%BF%88%7Ej%DE%AD%8F%F4@%C1"),
482
+ U: unescape("%1A%A9%DC%918%83%93k%29%5B%117%B16%DB%E8%8E%FE%28%E5%89%D4" + "%0E%AD%12%3B%7DN_6fez%8BG%18%05YOh%7DZH%A3Z%87%17*"),
483
+ OE: unescape("%A4a%88%20h%1B%7F%CD%D5%CAc%D8R%83%E5%D6%1C%D2%98%07%984%" + "BA%AF%1B%B4%7FQ%F8%1EU%7D"),
484
+ UE: unescape("%A0%0AZU%27%1D%27%2C%0B%FE%0E%A2L%F9b%5E%A1%B9%D6v7b%B26%" + "A9N%99%F1%A4Deq"),
485
+ Perms: unescape("%03%F2i%07%0D%C3%F9%F2%28%80%B7%F5%DD%D1c%EB"),
477
486
  P: -1084,
478
487
  R: 6
479
488
  });
480
489
  done();
481
490
  });
482
491
  afterAll(function () {
483
- fileId1 = fileId2 = dict1 = dict2 = null;
492
+ fileId1 = fileId2 = dict1 = dict2 = dict3 = null;
484
493
  aes256Dict = aes256IsoDict = aes256BlankDict = aes256IsoBlankDict = null;
485
494
  });
486
- describe('#ctor', function () {
487
- describe('AES256 Revision 5', function () {
488
- it('should accept user password', function (done) {
489
- ensurePasswordCorrect(done, aes256Dict, fileId1, 'user');
495
+ describe("#ctor", function () {
496
+ describe("AES256 Revision 5", function () {
497
+ it("should accept user password", function (done) {
498
+ ensurePasswordCorrect(done, aes256Dict, fileId1, "user");
490
499
  });
491
- it('should accept owner password', function (done) {
492
- ensurePasswordCorrect(done, aes256Dict, fileId1, 'owner');
500
+ it("should accept owner password", function (done) {
501
+ ensurePasswordCorrect(done, aes256Dict, fileId1, "owner");
493
502
  });
494
- it('should not accept blank password', function (done) {
503
+ it("should not accept blank password", function (done) {
495
504
  ensurePasswordNeeded(done, aes256Dict, fileId1);
496
505
  });
497
- it('should not accept wrong password', function (done) {
498
- ensurePasswordIncorrect(done, aes256Dict, fileId1, 'wrong');
506
+ it("should not accept wrong password", function (done) {
507
+ ensurePasswordIncorrect(done, aes256Dict, fileId1, "wrong");
499
508
  });
500
- it('should accept blank password', function (done) {
509
+ it("should accept blank password", function (done) {
501
510
  ensurePasswordCorrect(done, aes256BlankDict, fileId1);
502
511
  });
503
512
  });
504
- describe('AES256 Revision 6', function () {
505
- it('should accept user password', function (done) {
506
- ensurePasswordCorrect(done, aes256IsoDict, fileId1, 'user');
513
+ describe("AES256 Revision 6", function () {
514
+ it("should accept user password", function (done) {
515
+ ensurePasswordCorrect(done, aes256IsoDict, fileId1, "user");
507
516
  });
508
- it('should accept owner password', function (done) {
509
- ensurePasswordCorrect(done, aes256IsoDict, fileId1, 'owner');
517
+ it("should accept owner password", function (done) {
518
+ ensurePasswordCorrect(done, aes256IsoDict, fileId1, "owner");
510
519
  });
511
- it('should not accept blank password', function (done) {
520
+ it("should not accept blank password", function (done) {
512
521
  ensurePasswordNeeded(done, aes256IsoDict, fileId1);
513
522
  });
514
- it('should not accept wrong password', function (done) {
515
- ensurePasswordIncorrect(done, aes256IsoDict, fileId1, 'wrong');
523
+ it("should not accept wrong password", function (done) {
524
+ ensurePasswordIncorrect(done, aes256IsoDict, fileId1, "wrong");
516
525
  });
517
- it('should accept blank password', function (done) {
526
+ it("should accept blank password", function (done) {
518
527
  ensurePasswordCorrect(done, aes256IsoBlankDict, fileId1);
519
528
  });
520
529
  });
521
- it('should accept user password', function (done) {
522
- ensurePasswordCorrect(done, dict1, fileId1, '123456');
530
+ it("should accept user password", function (done) {
531
+ ensurePasswordCorrect(done, dict1, fileId1, "123456");
523
532
  });
524
- it('should accept owner password', function (done) {
525
- ensurePasswordCorrect(done, dict1, fileId1, '654321');
533
+ it("should accept owner password", function (done) {
534
+ ensurePasswordCorrect(done, dict1, fileId1, "654321");
526
535
  });
527
- it('should not accept blank password', function (done) {
536
+ it("should not accept blank password", function (done) {
528
537
  ensurePasswordNeeded(done, dict1, fileId1);
529
538
  });
530
- it('should not accept wrong password', function (done) {
531
- ensurePasswordIncorrect(done, dict1, fileId1, 'wrong');
539
+ it("should not accept wrong password", function (done) {
540
+ ensurePasswordIncorrect(done, dict1, fileId1, "wrong");
532
541
  });
533
- it('should accept blank password', function (done) {
542
+ it("should accept blank password", function (done) {
534
543
  ensurePasswordCorrect(done, dict2, fileId2);
535
544
  });
536
545
  });
546
+ describe("Encrypt and decrypt", function () {
547
+ it("should encrypt and decrypt using ARCFour", function (done) {
548
+ dict3.CF = buildDict({
549
+ Identity: buildDict({
550
+ CFM: _primitives.Name.get("V2")
551
+ })
552
+ });
553
+ const dict = buildDict(dict3);
554
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "hello world");
555
+ done();
556
+ });
557
+ it("should encrypt and decrypt using AES128", function (done) {
558
+ dict3.CF = buildDict({
559
+ Identity: buildDict({
560
+ CFM: _primitives.Name.get("AESV2")
561
+ })
562
+ });
563
+ const dict = buildDict(dict3);
564
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "a");
565
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aa");
566
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aaaaaaaaaaaaaaaa");
567
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aaaaaaaaaaaaaaaaaaa");
568
+ done();
569
+ });
570
+ it("should encrypt and decrypt using AES256", function (done) {
571
+ dict3.CF = buildDict({
572
+ Identity: buildDict({
573
+ CFM: _primitives.Name.get("AESV3")
574
+ })
575
+ });
576
+ const dict = buildDict(dict3);
577
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aaaa");
578
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aaaaa");
579
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aaaaaaaaaaaaaaaa");
580
+ ensureEncryptDecryptIsIdentity(dict, fileId1, "user", "aaaaaaaaaaaaaaaaaaaaaa");
581
+ done();
582
+ });
583
+ });
537
584
  });