annotate scripts/minifier/otr/dep/crypto.js @ 144:455f0d305b87

screenshots(0.7): added 2 screenshots for jp (shell + commands list)
author Goffi <goffi@goffi.org>
date Mon, 24 Jun 2019 08:40:00 +0200
parents 1596660ddf72
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1 ;(function (root, factory) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
3 if (typeof define === "function" && define.amd) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
4 define(factory)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
5 } else if (typeof module !== 'undefined' && module.exports) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
6 module.exports = factory()
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
7 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
8 root.CryptoJS = factory()
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
9 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
10
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
11 }(this, function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
12
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
13 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
14 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
15 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
16 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
17 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
18 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
19 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
20 * CryptoJS core components.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
21 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
22 var CryptoJS = CryptoJS || (function (Math, undefined) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
23 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
24 * CryptoJS namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
25 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
26 var C = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
27
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
28 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
29 * Library namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
30 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
31 var C_lib = C.lib = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
32
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
33 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
34 * Base object for prototypal inheritance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
35 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
36 var Base = C_lib.Base = (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
37 function F() {}
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
38
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
39 return {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
40 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
41 * Creates a new object that inherits from this object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
42 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
43 * @param {Object} overrides Properties to copy into the new object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
44 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
45 * @return {Object} The new object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
46 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
47 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
48 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
49 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
50 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
51 * var MyType = CryptoJS.lib.Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
52 * field: 'value',
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
53 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
54 * method: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
55 * }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
56 * });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
57 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
58 extend: function (overrides) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
59 // Spawn
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
60 F.prototype = this;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
61 var subtype = new F();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
62
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
63 // Augment
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
64 if (overrides) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
65 subtype.mixIn(overrides);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
66 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
67
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
68 // Create default initializer
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
69 if (!subtype.hasOwnProperty('init')) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
70 subtype.init = function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
71 subtype.$super.init.apply(this, arguments);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
72 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
73 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
74
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
75 // Initializer's prototype is the subtype object
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
76 subtype.init.prototype = subtype;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
77
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
78 // Reference supertype
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
79 subtype.$super = this;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
80
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
81 return subtype;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
82 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
83
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
84 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
85 * Extends this object and runs the init method.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
86 * Arguments to create() will be passed to init().
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
87 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
88 * @return {Object} The new object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
89 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
90 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
91 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
92 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
93 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
94 * var instance = MyType.create();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
95 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
96 create: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
97 var instance = this.extend();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
98 instance.init.apply(instance, arguments);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
99
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
100 return instance;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
101 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
102
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
103 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
104 * Initializes a newly created object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
105 * Override this method to add some logic when your objects are created.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
106 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
107 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
108 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
109 * var MyType = CryptoJS.lib.Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
110 * init: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
111 * // ...
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
112 * }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
113 * });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
114 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
115 init: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
116 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
117
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
118 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
119 * Copies properties into this object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
120 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
121 * @param {Object} properties The properties to mix in.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
122 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
123 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
124 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
125 * MyType.mixIn({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
126 * field: 'value'
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
127 * });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
128 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
129 mixIn: function (properties) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
130 for (var propertyName in properties) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
131 if (properties.hasOwnProperty(propertyName)) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
132 this[propertyName] = properties[propertyName];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
133 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
134 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
135
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
136 // IE won't copy toString using the loop above
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
137 if (properties.hasOwnProperty('toString')) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
138 this.toString = properties.toString;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
139 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
140 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
141
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
142 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
143 * Creates a copy of this object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
144 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
145 * @return {Object} The clone.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
146 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
147 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
148 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
149 * var clone = instance.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
150 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
151 clone: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
152 return this.init.prototype.extend(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
153 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
154 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
155 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
156
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
157 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
158 * An array of 32-bit words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
159 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
160 * @property {Array} words The array of 32-bit words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
161 * @property {number} sigBytes The number of significant bytes in this word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
162 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
163 var WordArray = C_lib.WordArray = Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
164 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
165 * Initializes a newly created word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
166 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
167 * @param {Array} words (Optional) An array of 32-bit words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
168 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
169 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
170 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
171 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
172 * var wordArray = CryptoJS.lib.WordArray.create();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
173 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
174 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
175 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
176 init: function (words, sigBytes) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
177 words = this.words = words || [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
178
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
179 if (sigBytes != undefined) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
180 this.sigBytes = sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
181 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
182 this.sigBytes = words.length * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
183 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
184 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
185
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
186 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
187 * Converts this word array to a string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
188 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
189 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
190 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
191 * @return {string} The stringified word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
192 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
193 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
194 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
195 * var string = wordArray + '';
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
196 * var string = wordArray.toString();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
197 * var string = wordArray.toString(CryptoJS.enc.Utf8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
198 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
199 toString: function (encoder) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
200 return (encoder || Hex).stringify(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
201 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
202
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
203 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
204 * Concatenates a word array to this word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
205 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
206 * @param {WordArray} wordArray The word array to append.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
207 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
208 * @return {WordArray} This word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
209 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
210 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
211 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
212 * wordArray1.concat(wordArray2);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
213 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
214 concat: function (wordArray) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
215 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
216 var thisWords = this.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
217 var thatWords = wordArray.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
218 var thisSigBytes = this.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
219 var thatSigBytes = wordArray.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
220
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
221 // Clamp excess bits
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
222 this.clamp();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
223
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
224 // Concat
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
225 if (thisSigBytes % 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
226 // Copy one byte at a time
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
227 for (var i = 0; i < thatSigBytes; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
228 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
229 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
230 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
231 } else if (thatWords.length > 0xffff) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
232 // Copy one word at a time
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
233 for (var i = 0; i < thatSigBytes; i += 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
234 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
235 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
236 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
237 // Copy all words at once
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
238 thisWords.push.apply(thisWords, thatWords);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
239 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
240 this.sigBytes += thatSigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
241
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
242 // Chainable
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
243 return this;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
244 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
245
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
246 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
247 * Removes insignificant bits.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
248 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
249 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
250 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
251 * wordArray.clamp();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
252 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
253 clamp: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
254 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
255 var words = this.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
256 var sigBytes = this.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
257
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
258 // Clamp
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
259 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
260 words.length = Math.ceil(sigBytes / 4);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
261 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
262
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
263 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
264 * Creates a copy of this word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
265 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
266 * @return {WordArray} The clone.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
267 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
268 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
269 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
270 * var clone = wordArray.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
271 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
272 clone: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
273 var clone = Base.clone.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
274 clone.words = this.words.slice(0);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
275
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
276 return clone;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
277 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
278
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
279 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
280 * Creates a word array filled with random bytes.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
281 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
282 * @param {number} nBytes The number of random bytes to generate.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
283 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
284 * @return {WordArray} The random word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
285 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
286 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
287 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
288 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
289 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
290 * var wordArray = CryptoJS.lib.WordArray.random(16);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
291 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
292 random: function (nBytes) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
293 var words = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
294 for (var i = 0; i < nBytes; i += 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
295 words.push((Math.random() * 0x100000000) | 0);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
296 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
297
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
298 return new WordArray.init(words, nBytes);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
299 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
300 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
301
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
302 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
303 * Encoder namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
304 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
305 var C_enc = C.enc = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
306
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
307 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
308 * Hex encoding strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
309 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
310 var Hex = C_enc.Hex = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
311 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
312 * Converts a word array to a hex string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
313 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
314 * @param {WordArray} wordArray The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
315 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
316 * @return {string} The hex string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
317 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
318 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
319 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
320 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
321 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
322 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
323 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
324 stringify: function (wordArray) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
325 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
326 var words = wordArray.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
327 var sigBytes = wordArray.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
328
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
329 // Convert
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
330 var hexChars = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
331 for (var i = 0; i < sigBytes; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
332 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
333 hexChars.push((bite >>> 4).toString(16));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
334 hexChars.push((bite & 0x0f).toString(16));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
335 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
336
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
337 return hexChars.join('');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
338 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
339
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
340 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
341 * Converts a hex string to a word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
342 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
343 * @param {string} hexStr The hex string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
344 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
345 * @return {WordArray} The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
346 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
347 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
348 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
349 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
350 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
351 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
352 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
353 parse: function (hexStr) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
354 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
355 var hexStrLength = hexStr.length;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
356
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
357 // Convert
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
358 var words = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
359 for (var i = 0; i < hexStrLength; i += 2) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
360 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
361 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
362
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
363 return new WordArray.init(words, hexStrLength / 2);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
364 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
365 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
366
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
367 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
368 * Latin1 encoding strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
369 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
370 var Latin1 = C_enc.Latin1 = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
371 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
372 * Converts a word array to a Latin1 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
373 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
374 * @param {WordArray} wordArray The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
375 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
376 * @return {string} The Latin1 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
377 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
378 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
379 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
380 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
381 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
382 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
383 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
384 stringify: function (wordArray) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
385 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
386 var words = wordArray.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
387 var sigBytes = wordArray.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
388
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
389 // Convert
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
390 var latin1Chars = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
391 for (var i = 0; i < sigBytes; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
392 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
393 latin1Chars.push(String.fromCharCode(bite));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
394 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
395
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
396 return latin1Chars.join('');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
397 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
398
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
399 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
400 * Converts a Latin1 string to a word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
401 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
402 * @param {string} latin1Str The Latin1 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
403 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
404 * @return {WordArray} The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
405 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
406 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
407 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
408 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
409 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
410 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
411 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
412 parse: function (latin1Str) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
413 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
414 var latin1StrLength = latin1Str.length;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
415
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
416 // Convert
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
417 var words = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
418 for (var i = 0; i < latin1StrLength; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
419 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
420 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
421
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
422 return new WordArray.init(words, latin1StrLength);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
423 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
424 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
425
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
426 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
427 * UTF-8 encoding strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
428 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
429 var Utf8 = C_enc.Utf8 = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
430 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
431 * Converts a word array to a UTF-8 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
432 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
433 * @param {WordArray} wordArray The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
434 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
435 * @return {string} The UTF-8 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
436 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
437 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
438 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
439 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
440 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
441 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
442 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
443 stringify: function (wordArray) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
444 try {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
445 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
446 } catch (e) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
447 throw new Error('Malformed UTF-8 data');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
448 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
449 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
450
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
451 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
452 * Converts a UTF-8 string to a word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
453 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
454 * @param {string} utf8Str The UTF-8 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
455 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
456 * @return {WordArray} The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
457 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
458 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
459 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
460 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
461 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
462 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
463 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
464 parse: function (utf8Str) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
465 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
466 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
467 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
468
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
469 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
470 * Abstract buffered block algorithm template.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
471 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
472 * The property blockSize must be implemented in a concrete subtype.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
473 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
474 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
475 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
476 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
477 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
478 * Resets this block algorithm's data buffer to its initial state.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
479 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
480 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
481 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
482 * bufferedBlockAlgorithm.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
483 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
484 reset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
485 // Initial values
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
486 this._data = new WordArray.init();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
487 this._nDataBytes = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
488 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
489
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
490 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
491 * Adds new data to this block algorithm's buffer.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
492 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
493 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
494 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
495 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
496 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
497 * bufferedBlockAlgorithm._append('data');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
498 * bufferedBlockAlgorithm._append(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
499 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
500 _append: function (data) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
501 // Convert string to WordArray, else assume WordArray already
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
502 if (typeof data == 'string') {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
503 data = Utf8.parse(data);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
504 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
505
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
506 // Append
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
507 this._data.concat(data);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
508 this._nDataBytes += data.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
509 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
510
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
511 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
512 * Processes available data blocks.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
513 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
514 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
515 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
516 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
517 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
518 * @return {WordArray} The processed data.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
519 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
520 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
521 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
522 * var processedData = bufferedBlockAlgorithm._process();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
523 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
524 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
525 _process: function (doFlush) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
526 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
527 var data = this._data;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
528 var dataWords = data.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
529 var dataSigBytes = data.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
530 var blockSize = this.blockSize;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
531 var blockSizeBytes = blockSize * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
532
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
533 // Count blocks ready
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
534 var nBlocksReady = dataSigBytes / blockSizeBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
535 if (doFlush) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
536 // Round up to include partial blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
537 nBlocksReady = Math.ceil(nBlocksReady);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
538 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
539 // Round down to include only full blocks,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
540 // less the number of blocks that must remain in the buffer
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
541 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
542 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
543
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
544 // Count words ready
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
545 var nWordsReady = nBlocksReady * blockSize;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
546
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
547 // Count bytes ready
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
548 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
549
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
550 // Process blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
551 if (nWordsReady) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
552 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
553 // Perform concrete-algorithm logic
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
554 this._doProcessBlock(dataWords, offset);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
555 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
556
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
557 // Remove processed words
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
558 var processedWords = dataWords.splice(0, nWordsReady);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
559 data.sigBytes -= nBytesReady;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
560 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
561
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
562 // Return processed words
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
563 return new WordArray.init(processedWords, nBytesReady);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
564 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
565
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
566 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
567 * Creates a copy of this object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
568 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
569 * @return {Object} The clone.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
570 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
571 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
572 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
573 * var clone = bufferedBlockAlgorithm.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
574 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
575 clone: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
576 var clone = Base.clone.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
577 clone._data = this._data.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
578
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
579 return clone;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
580 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
581
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
582 _minBufferSize: 0
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
583 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
584
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
585 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
586 * Abstract hasher template.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
587 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
588 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
589 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
590 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
591 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
592 * Configuration options.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
593 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
594 cfg: Base.extend(),
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
595
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
596 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
597 * Initializes a newly created hasher.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
598 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
599 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
600 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
601 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
602 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
603 * var hasher = CryptoJS.algo.SHA256.create();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
604 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
605 init: function (cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
606 // Apply config defaults
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
607 this.cfg = this.cfg.extend(cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
608
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
609 // Set initial values
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
610 this.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
611 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
612
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
613 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
614 * Resets this hasher to its initial state.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
615 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
616 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
617 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
618 * hasher.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
619 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
620 reset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
621 // Reset data buffer
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
622 BufferedBlockAlgorithm.reset.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
623
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
624 // Perform concrete-hasher logic
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
625 this._doReset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
626 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
627
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
628 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
629 * Updates this hasher with a message.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
630 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
631 * @param {WordArray|string} messageUpdate The message to append.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
632 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
633 * @return {Hasher} This hasher.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
634 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
635 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
636 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
637 * hasher.update('message');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
638 * hasher.update(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
639 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
640 update: function (messageUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
641 // Append
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
642 this._append(messageUpdate);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
643
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
644 // Update the hash
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
645 this._process();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
646
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
647 // Chainable
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
648 return this;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
649 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
650
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
651 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
652 * Finalizes the hash computation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
653 * Note that the finalize operation is effectively a destructive, read-once operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
654 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
655 * @param {WordArray|string} messageUpdate (Optional) A final message update.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
656 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
657 * @return {WordArray} The hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
658 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
659 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
660 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
661 * var hash = hasher.finalize();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
662 * var hash = hasher.finalize('message');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
663 * var hash = hasher.finalize(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
664 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
665 finalize: function (messageUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
666 // Final message update
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
667 if (messageUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
668 this._append(messageUpdate);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
669 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
670
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
671 // Perform concrete-hasher logic
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
672 var hash = this._doFinalize();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
673
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
674 return hash;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
675 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
676
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
677 blockSize: 512/32,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
678
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
679 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
680 * Creates a shortcut function to a hasher's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
681 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
682 * @param {Hasher} hasher The hasher to create a helper for.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
683 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
684 * @return {Function} The shortcut function.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
685 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
686 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
687 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
688 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
689 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
690 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
691 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
692 _createHelper: function (hasher) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
693 return function (message, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
694 return new hasher.init(cfg).finalize(message);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
695 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
696 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
697
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
698 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
699 * Creates a shortcut function to the HMAC's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
700 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
701 * @param {Hasher} hasher The hasher to use in this HMAC helper.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
702 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
703 * @return {Function} The shortcut function.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
704 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
705 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
706 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
707 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
708 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
709 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
710 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
711 _createHmacHelper: function (hasher) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
712 return function (message, key) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
713 return new C_algo.HMAC.init(hasher, key).finalize(message);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
714 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
715 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
716 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
717
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
718 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
719 * Algorithm namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
720 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
721 var C_algo = C.algo = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
722
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
723 return C;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
724 }(Math));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
725
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
726 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
727 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
728 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
729 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
730 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
731 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
732 (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
733 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
734 var C = CryptoJS;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
735 var C_lib = C.lib;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
736 var WordArray = C_lib.WordArray;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
737 var C_enc = C.enc;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
738
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
739 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
740 * Base64 encoding strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
741 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
742 var Base64 = C_enc.Base64 = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
743 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
744 * Converts a word array to a Base64 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
745 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
746 * @param {WordArray} wordArray The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
747 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
748 * @return {string} The Base64 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
749 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
750 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
751 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
752 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
753 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
754 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
755 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
756 stringify: function (wordArray) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
757 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
758 var words = wordArray.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
759 var sigBytes = wordArray.sigBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
760 var map = this._map;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
761
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
762 // Clamp excess bits
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
763 wordArray.clamp();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
764
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
765 // Convert
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
766 var base64Chars = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
767 for (var i = 0; i < sigBytes; i += 3) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
768 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
769 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
770 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
771
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
772 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
773
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
774 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
775 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
776 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
777 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
778
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
779 // Add padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
780 var paddingChar = map.charAt(64);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
781 if (paddingChar) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
782 while (base64Chars.length % 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
783 base64Chars.push(paddingChar);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
784 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
785 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
786
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
787 return base64Chars.join('');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
788 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
789
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
790 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
791 * Converts a Base64 string to a word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
792 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
793 * @param {string} base64Str The Base64 string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
794 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
795 * @return {WordArray} The word array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
796 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
797 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
798 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
799 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
800 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
801 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
802 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
803 parse: function (base64Str) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
804 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
805 var base64StrLength = base64Str.length;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
806 var map = this._map;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
807
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
808 // Ignore padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
809 var paddingChar = map.charAt(64);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
810 if (paddingChar) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
811 var paddingIndex = base64Str.indexOf(paddingChar);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
812 if (paddingIndex != -1) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
813 base64StrLength = paddingIndex;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
814 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
815 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
816
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
817 // Convert
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
818 var words = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
819 var nBytes = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
820 for (var i = 0; i < base64StrLength; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
821 if (i % 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
822 var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
823 var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
824 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
825 nBytes++;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
826 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
827 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
828
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
829 return WordArray.create(words, nBytes);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
830 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
831
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
832 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
833 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
834 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
835
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
836 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
837 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
838 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
839 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
840 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
841 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
842 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
843 * Cipher core components.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
844 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
845 CryptoJS.lib.Cipher || (function (undefined) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
846 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
847 var C = CryptoJS;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
848 var C_lib = C.lib;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
849 var Base = C_lib.Base;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
850 var WordArray = C_lib.WordArray;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
851 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
852 var C_enc = C.enc;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
853 var Utf8 = C_enc.Utf8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
854 var Base64 = C_enc.Base64;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
855 var C_algo = C.algo;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
856 var EvpKDF = C_algo.EvpKDF;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
857
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
858 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
859 * Abstract base cipher template.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
860 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
861 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
862 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
863 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
864 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
865 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
866 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
867 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
868 * Configuration options.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
869 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
870 * @property {WordArray} iv The IV to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
871 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
872 cfg: Base.extend(),
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
873
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
874 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
875 * Creates this cipher in encryption mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
876 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
877 * @param {WordArray} key The key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
878 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
879 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
880 * @return {Cipher} A cipher instance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
881 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
882 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
883 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
884 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
885 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
886 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
887 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
888 createEncryptor: function (key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
889 return this.create(this._ENC_XFORM_MODE, key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
890 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
891
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
892 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
893 * Creates this cipher in decryption mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
894 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
895 * @param {WordArray} key The key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
896 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
897 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
898 * @return {Cipher} A cipher instance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
899 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
900 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
901 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
902 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
903 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
904 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
905 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
906 createDecryptor: function (key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
907 return this.create(this._DEC_XFORM_MODE, key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
908 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
909
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
910 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
911 * Initializes a newly created cipher.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
912 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
913 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
914 * @param {WordArray} key The key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
915 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
916 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
917 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
918 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
919 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
920 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
921 init: function (xformMode, key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
922 // Apply config defaults
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
923 this.cfg = this.cfg.extend(cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
924
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
925 // Store transform mode and key
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
926 this._xformMode = xformMode;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
927 this._key = key;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
928
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
929 // Set initial values
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
930 this.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
931 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
932
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
933 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
934 * Resets this cipher to its initial state.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
935 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
936 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
937 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
938 * cipher.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
939 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
940 reset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
941 // Reset data buffer
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
942 BufferedBlockAlgorithm.reset.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
943
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
944 // Perform concrete-cipher logic
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
945 this._doReset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
946 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
947
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
948 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
949 * Adds data to be encrypted or decrypted.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
950 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
951 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
952 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
953 * @return {WordArray} The data after processing.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
954 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
955 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
956 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
957 * var encrypted = cipher.process('data');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
958 * var encrypted = cipher.process(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
959 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
960 process: function (dataUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
961 // Append
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
962 this._append(dataUpdate);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
963
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
964 // Process available blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
965 return this._process();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
966 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
967
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
968 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
969 * Finalizes the encryption or decryption process.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
970 * Note that the finalize operation is effectively a destructive, read-once operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
971 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
972 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
973 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
974 * @return {WordArray} The data after final processing.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
975 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
976 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
977 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
978 * var encrypted = cipher.finalize();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
979 * var encrypted = cipher.finalize('data');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
980 * var encrypted = cipher.finalize(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
981 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
982 finalize: function (dataUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
983 // Final data update
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
984 if (dataUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
985 this._append(dataUpdate);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
986 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
987
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
988 // Perform concrete-cipher logic
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
989 var finalProcessedData = this._doFinalize();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
990
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
991 return finalProcessedData;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
992 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
993
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
994 keySize: 128/32,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
995
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
996 ivSize: 128/32,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
997
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
998 _ENC_XFORM_MODE: 1,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
999
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1000 _DEC_XFORM_MODE: 2,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1001
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1002 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1003 * Creates shortcut functions to a cipher's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1004 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1005 * @param {Cipher} cipher The cipher to create a helper for.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1006 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1007 * @return {Object} An object with encrypt and decrypt shortcut functions.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1008 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1009 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1010 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1011 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1012 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1013 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1014 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1015 _createHelper: (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1016 function selectCipherStrategy(key) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1017 if (typeof key == 'string') {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1018 return PasswordBasedCipher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1019 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1020 return SerializableCipher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1021 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1022 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1023
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1024 return function (cipher) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1025 return {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1026 encrypt: function (message, key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1027 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1028 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1029
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1030 decrypt: function (ciphertext, key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1031 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1032 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1033 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1034 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1035 }())
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1036 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1037
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1038 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1039 * Abstract base stream cipher template.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1040 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1041 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1042 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1043 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1044 _doFinalize: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1045 // Process partial blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1046 var finalProcessedBlocks = this._process(!!'flush');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1047
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1048 return finalProcessedBlocks;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1049 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1050
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1051 blockSize: 1
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1052 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1053
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1054 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1055 * Mode namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1056 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1057 var C_mode = C.mode = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1058
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1059 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1060 * Abstract base block cipher mode template.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1061 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1062 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1063 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1064 * Creates this mode for encryption.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1065 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1066 * @param {Cipher} cipher A block cipher instance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1067 * @param {Array} iv The IV words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1068 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1069 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1070 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1071 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1072 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1073 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1074 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1075 createEncryptor: function (cipher, iv) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1076 return this.Encryptor.create(cipher, iv);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1077 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1078
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1079 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1080 * Creates this mode for decryption.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1081 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1082 * @param {Cipher} cipher A block cipher instance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1083 * @param {Array} iv The IV words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1084 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1085 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1086 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1087 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1088 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1089 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1090 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1091 createDecryptor: function (cipher, iv) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1092 return this.Decryptor.create(cipher, iv);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1093 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1094
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1095 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1096 * Initializes a newly created mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1097 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1098 * @param {Cipher} cipher A block cipher instance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1099 * @param {Array} iv The IV words.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1100 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1101 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1102 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1103 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1104 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1105 init: function (cipher, iv) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1106 this._cipher = cipher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1107 this._iv = iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1108 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1109 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1110
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1111 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1112 * Cipher Block Chaining mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1113 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1114 var CBC = C_mode.CBC = (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1115 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1116 * Abstract base CBC mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1117 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1118 var CBC = BlockCipherMode.extend();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1119
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1120 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1121 * CBC encryptor.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1122 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1123 CBC.Encryptor = CBC.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1124 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1125 * Processes the data block at offset.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1126 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1127 * @param {Array} words The data words to operate on.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1128 * @param {number} offset The offset where the block starts.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1129 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1130 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1131 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1132 * mode.processBlock(data.words, offset);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1133 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1134 processBlock: function (words, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1135 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1136 var cipher = this._cipher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1137 var blockSize = cipher.blockSize;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1138
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1139 // XOR and encrypt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1140 xorBlock.call(this, words, offset, blockSize);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1141 cipher.encryptBlock(words, offset);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1142
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1143 // Remember this block to use with next block
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1144 this._prevBlock = words.slice(offset, offset + blockSize);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1145 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1146 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1147
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1148 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1149 * CBC decryptor.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1150 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1151 CBC.Decryptor = CBC.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1152 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1153 * Processes the data block at offset.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1154 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1155 * @param {Array} words The data words to operate on.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1156 * @param {number} offset The offset where the block starts.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1157 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1158 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1159 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1160 * mode.processBlock(data.words, offset);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1161 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1162 processBlock: function (words, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1163 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1164 var cipher = this._cipher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1165 var blockSize = cipher.blockSize;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1166
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1167 // Remember this block to use with next block
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1168 var thisBlock = words.slice(offset, offset + blockSize);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1169
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1170 // Decrypt and XOR
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1171 cipher.decryptBlock(words, offset);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1172 xorBlock.call(this, words, offset, blockSize);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1173
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1174 // This block becomes the previous block
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1175 this._prevBlock = thisBlock;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1176 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1177 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1178
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1179 function xorBlock(words, offset, blockSize) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1180 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1181 var iv = this._iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1182
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1183 // Choose mixing block
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1184 if (iv) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1185 var block = iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1186
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1187 // Remove IV for subsequent blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1188 this._iv = undefined;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1189 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1190 var block = this._prevBlock;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1191 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1192
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1193 // XOR blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1194 for (var i = 0; i < blockSize; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1195 words[offset + i] ^= block[i];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1196 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1197 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1198
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1199 return CBC;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1200 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1201
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1202 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1203 * Padding namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1204 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1205 var C_pad = C.pad = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1206
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1207 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1208 * PKCS #5/7 padding strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1209 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1210 var Pkcs7 = C_pad.Pkcs7 = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1211 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1212 * Pads data using the algorithm defined in PKCS #5/7.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1213 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1214 * @param {WordArray} data The data to pad.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1215 * @param {number} blockSize The multiple that the data should be padded to.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1216 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1217 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1218 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1219 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1220 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1221 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1222 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1223 pad: function (data, blockSize) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1224 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1225 var blockSizeBytes = blockSize * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1226
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1227 // Count padding bytes
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1228 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1229
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1230 // Create padding word
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1231 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1232
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1233 // Create padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1234 var paddingWords = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1235 for (var i = 0; i < nPaddingBytes; i += 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1236 paddingWords.push(paddingWord);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1237 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1238 var padding = WordArray.create(paddingWords, nPaddingBytes);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1239
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1240 // Add padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1241 data.concat(padding);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1242 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1243
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1244 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1245 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1246 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1247 * @param {WordArray} data The data to unpad.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1248 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1249 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1250 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1251 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1252 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1253 * CryptoJS.pad.Pkcs7.unpad(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1254 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1255 unpad: function (data) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1256 // Get number of padding bytes from last byte
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1257 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1258
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1259 // Remove padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1260 data.sigBytes -= nPaddingBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1261 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1262 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1263
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1264 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1265 * Abstract base block cipher template.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1266 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1267 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1268 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1269 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1270 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1271 * Configuration options.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1272 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1273 * @property {Mode} mode The block mode to use. Default: CBC
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1274 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1275 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1276 cfg: Cipher.cfg.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1277 mode: CBC,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1278 padding: Pkcs7
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1279 }),
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1280
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1281 reset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1282 // Reset cipher
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1283 Cipher.reset.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1284
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1285 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1286 var cfg = this.cfg;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1287 var iv = cfg.iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1288 var mode = cfg.mode;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1289
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1290 // Reset block mode
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1291 if (this._xformMode == this._ENC_XFORM_MODE) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1292 var modeCreator = mode.createEncryptor;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1293 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1294 var modeCreator = mode.createDecryptor;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1295
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1296 // Keep at least one block in the buffer for unpadding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1297 this._minBufferSize = 1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1298 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1299 this._mode = modeCreator.call(mode, this, iv && iv.words);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1300 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1301
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1302 _doProcessBlock: function (words, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1303 this._mode.processBlock(words, offset);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1304 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1305
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1306 _doFinalize: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1307 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1308 var padding = this.cfg.padding;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1309
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1310 // Finalize
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1311 if (this._xformMode == this._ENC_XFORM_MODE) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1312 // Pad data
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1313 padding.pad(this._data, this.blockSize);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1314
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1315 // Process final blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1316 var finalProcessedBlocks = this._process(!!'flush');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1317 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1318 // Process final blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1319 var finalProcessedBlocks = this._process(!!'flush');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1320
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1321 // Unpad data
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1322 padding.unpad(finalProcessedBlocks);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1323 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1324
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1325 return finalProcessedBlocks;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1326 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1327
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1328 blockSize: 128/32
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1329 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1330
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1331 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1332 * A collection of cipher parameters.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1333 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1334 * @property {WordArray} ciphertext The raw ciphertext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1335 * @property {WordArray} key The key to this ciphertext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1336 * @property {WordArray} iv The IV used in the ciphering operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1337 * @property {WordArray} salt The salt used with a key derivation function.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1338 * @property {Cipher} algorithm The cipher algorithm.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1339 * @property {Mode} mode The block mode used in the ciphering operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1340 * @property {Padding} padding The padding scheme used in the ciphering operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1341 * @property {number} blockSize The block size of the cipher.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1342 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1343 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1344 var CipherParams = C_lib.CipherParams = Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1345 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1346 * Initializes a newly created cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1347 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1348 * @param {Object} cipherParams An object with any of the possible cipher parameters.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1349 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1350 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1351 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1352 * var cipherParams = CryptoJS.lib.CipherParams.create({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1353 * ciphertext: ciphertextWordArray,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1354 * key: keyWordArray,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1355 * iv: ivWordArray,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1356 * salt: saltWordArray,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1357 * algorithm: CryptoJS.algo.AES,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1358 * mode: CryptoJS.mode.CBC,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1359 * padding: CryptoJS.pad.PKCS7,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1360 * blockSize: 4,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1361 * formatter: CryptoJS.format.OpenSSL
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1362 * });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1363 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1364 init: function (cipherParams) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1365 this.mixIn(cipherParams);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1366 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1367
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1368 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1369 * Converts this cipher params object to a string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1370 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1371 * @param {Format} formatter (Optional) The formatting strategy to use.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1372 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1373 * @return {string} The stringified cipher params.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1374 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1375 * @throws Error If neither the formatter nor the default formatter is set.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1376 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1377 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1378 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1379 * var string = cipherParams + '';
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1380 * var string = cipherParams.toString();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1381 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1382 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1383 toString: function (formatter) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1384 return (formatter || this.formatter).stringify(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1385 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1386 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1387
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1388 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1389 * Format namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1390 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1391 var C_format = C.format = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1392
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1393 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1394 * OpenSSL formatting strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1395 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1396 var OpenSSLFormatter = C_format.OpenSSL = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1397 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1398 * Converts a cipher params object to an OpenSSL-compatible string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1399 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1400 * @param {CipherParams} cipherParams The cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1401 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1402 * @return {string} The OpenSSL-compatible string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1403 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1404 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1405 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1406 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1407 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1408 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1409 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1410 stringify: function (cipherParams) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1411 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1412 var ciphertext = cipherParams.ciphertext;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1413 var salt = cipherParams.salt;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1414
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1415 // Format
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1416 if (salt) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1417 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1418 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1419 var wordArray = ciphertext;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1420 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1421
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1422 return wordArray.toString(Base64);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1423 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1424
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1425 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1426 * Converts an OpenSSL-compatible string to a cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1427 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1428 * @param {string} openSSLStr The OpenSSL-compatible string.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1429 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1430 * @return {CipherParams} The cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1431 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1432 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1433 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1434 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1435 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1436 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1437 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1438 parse: function (openSSLStr) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1439 // Parse base64
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1440 var ciphertext = Base64.parse(openSSLStr);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1441
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1442 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1443 var ciphertextWords = ciphertext.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1444
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1445 // Test for salt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1446 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1447 // Extract salt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1448 var salt = WordArray.create(ciphertextWords.slice(2, 4));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1449
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1450 // Remove salt from ciphertext
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1451 ciphertextWords.splice(0, 4);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1452 ciphertext.sigBytes -= 16;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1453 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1454
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1455 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1456 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1457 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1458
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1459 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1460 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1461 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1462 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1463 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1464 * Configuration options.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1465 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1466 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1467 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1468 cfg: Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1469 format: OpenSSLFormatter
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1470 }),
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1471
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1472 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1473 * Encrypts a message.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1474 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1475 * @param {Cipher} cipher The cipher algorithm to use.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1476 * @param {WordArray|string} message The message to encrypt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1477 * @param {WordArray} key The key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1478 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1479 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1480 * @return {CipherParams} A cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1481 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1482 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1483 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1484 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1485 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1486 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1487 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1488 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1489 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1490 encrypt: function (cipher, message, key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1491 // Apply config defaults
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1492 cfg = this.cfg.extend(cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1493
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1494 // Encrypt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1495 var encryptor = cipher.createEncryptor(key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1496 var ciphertext = encryptor.finalize(message);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1497
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1498 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1499 var cipherCfg = encryptor.cfg;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1500
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1501 // Create and return serializable cipher params
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1502 return CipherParams.create({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1503 ciphertext: ciphertext,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1504 key: key,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1505 iv: cipherCfg.iv,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1506 algorithm: cipher,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1507 mode: cipherCfg.mode,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1508 padding: cipherCfg.padding,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1509 blockSize: cipher.blockSize,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1510 formatter: cfg.format
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1511 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1512 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1513
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1514 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1515 * Decrypts serialized ciphertext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1516 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1517 * @param {Cipher} cipher The cipher algorithm to use.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1518 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1519 * @param {WordArray} key The key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1520 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1521 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1522 * @return {WordArray} The plaintext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1523 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1524 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1525 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1526 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1527 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1528 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1529 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1530 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1531 decrypt: function (cipher, ciphertext, key, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1532 // Apply config defaults
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1533 cfg = this.cfg.extend(cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1534
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1535 // Convert string to CipherParams
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1536 ciphertext = this._parse(ciphertext, cfg.format);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1537
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1538 // Decrypt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1539 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1540
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1541 return plaintext;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1542 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1543
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1544 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1545 * Converts serialized ciphertext to CipherParams,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1546 * else assumed CipherParams already and returns ciphertext unchanged.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1547 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1548 * @param {CipherParams|string} ciphertext The ciphertext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1549 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1550 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1551 * @return {CipherParams} The unserialized ciphertext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1552 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1553 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1554 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1555 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1556 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1557 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1558 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1559 _parse: function (ciphertext, format) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1560 if (typeof ciphertext == 'string') {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1561 return format.parse(ciphertext, this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1562 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1563 return ciphertext;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1564 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1565 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1566 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1567
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1568 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1569 * Key derivation function namespace.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1570 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1571 var C_kdf = C.kdf = {};
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1572
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1573 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1574 * OpenSSL key derivation function.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1575 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1576 var OpenSSLKdf = C_kdf.OpenSSL = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1577 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1578 * Derives a key and IV from a password.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1579 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1580 * @param {string} password The password to derive from.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1581 * @param {number} keySize The size in words of the key to generate.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1582 * @param {number} ivSize The size in words of the IV to generate.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1583 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1584 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1585 * @return {CipherParams} A cipher params object with the key, IV, and salt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1586 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1587 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1588 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1589 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1590 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1591 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1592 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1593 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1594 execute: function (password, keySize, ivSize, salt) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1595 // Generate random salt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1596 if (!salt) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1597 salt = WordArray.random(64/8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1598 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1599
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1600 // Derive key and IV
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1601 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1602
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1603 // Separate key and IV
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1604 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1605 key.sigBytes = keySize * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1606
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1607 // Return params
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1608 return CipherParams.create({ key: key, iv: iv, salt: salt });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1609 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1610 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1611
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1612 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1613 * A serializable cipher wrapper that derives the key from a password,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1614 * and returns ciphertext as a serializable cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1615 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1616 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1617 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1618 * Configuration options.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1619 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1620 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1621 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1622 cfg: SerializableCipher.cfg.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1623 kdf: OpenSSLKdf
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1624 }),
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1625
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1626 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1627 * Encrypts a message using a password.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1628 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1629 * @param {Cipher} cipher The cipher algorithm to use.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1630 * @param {WordArray|string} message The message to encrypt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1631 * @param {string} password The password.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1632 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1633 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1634 * @return {CipherParams} A cipher params object.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1635 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1636 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1637 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1638 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1639 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1640 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1641 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1642 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1643 encrypt: function (cipher, message, password, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1644 // Apply config defaults
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1645 cfg = this.cfg.extend(cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1646
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1647 // Derive key and other params
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1648 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1649
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1650 // Add IV to config
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1651 cfg.iv = derivedParams.iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1652
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1653 // Encrypt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1654 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1655
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1656 // Mix in derived params
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1657 ciphertext.mixIn(derivedParams);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1658
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1659 return ciphertext;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1660 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1661
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1662 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1663 * Decrypts serialized ciphertext using a password.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1664 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1665 * @param {Cipher} cipher The cipher algorithm to use.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1666 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1667 * @param {string} password The password.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1668 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1669 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1670 * @return {WordArray} The plaintext.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1671 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1672 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1673 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1674 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1675 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1676 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1677 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1678 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1679 decrypt: function (cipher, ciphertext, password, cfg) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1680 // Apply config defaults
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1681 cfg = this.cfg.extend(cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1682
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1683 // Convert string to CipherParams
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1684 ciphertext = this._parse(ciphertext, cfg.format);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1685
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1686 // Derive key and other params
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1687 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1688
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1689 // Add IV to config
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1690 cfg.iv = derivedParams.iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1691
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1692 // Decrypt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1693 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1694
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1695 return plaintext;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1696 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1697 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1698 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1699
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1700 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1701 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1702 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1703 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1704 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1705 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1706 (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1707 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1708 var C = CryptoJS;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1709 var C_lib = C.lib;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1710 var BlockCipher = C_lib.BlockCipher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1711 var C_algo = C.algo;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1712
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1713 // Lookup tables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1714 var SBOX = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1715 var INV_SBOX = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1716 var SUB_MIX_0 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1717 var SUB_MIX_1 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1718 var SUB_MIX_2 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1719 var SUB_MIX_3 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1720 var INV_SUB_MIX_0 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1721 var INV_SUB_MIX_1 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1722 var INV_SUB_MIX_2 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1723 var INV_SUB_MIX_3 = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1724
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1725 // Compute lookup tables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1726 (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1727 // Compute double table
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1728 var d = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1729 for (var i = 0; i < 256; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1730 if (i < 128) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1731 d[i] = i << 1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1732 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1733 d[i] = (i << 1) ^ 0x11b;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1734 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1735 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1736
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1737 // Walk GF(2^8)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1738 var x = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1739 var xi = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1740 for (var i = 0; i < 256; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1741 // Compute sbox
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1742 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1743 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1744 SBOX[x] = sx;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1745 INV_SBOX[sx] = x;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1746
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1747 // Compute multiplication
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1748 var x2 = d[x];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1749 var x4 = d[x2];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1750 var x8 = d[x4];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1751
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1752 // Compute sub bytes, mix columns tables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1753 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1754 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1755 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1756 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1757 SUB_MIX_3[x] = t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1758
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1759 // Compute inv sub bytes, inv mix columns tables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1760 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1761 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1762 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1763 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1764 INV_SUB_MIX_3[sx] = t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1765
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1766 // Compute next counter
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1767 if (!x) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1768 x = xi = 1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1769 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1770 x = x2 ^ d[d[d[x8 ^ x2]]];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1771 xi ^= d[d[xi]];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1772 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1773 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1774 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1775
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1776 // Precomputed Rcon lookup
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1777 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1778
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1779 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1780 * AES block cipher algorithm.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1781 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1782 var AES = C_algo.AES = BlockCipher.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1783 _doReset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1784 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1785 var key = this._key;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1786 var keyWords = key.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1787 var keySize = key.sigBytes / 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1788
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1789 // Compute number of rounds
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1790 var nRounds = this._nRounds = keySize + 6
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1791
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1792 // Compute number of key schedule rows
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1793 var ksRows = (nRounds + 1) * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1794
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1795 // Compute key schedule
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1796 var keySchedule = this._keySchedule = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1797 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1798 if (ksRow < keySize) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1799 keySchedule[ksRow] = keyWords[ksRow];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1800 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1801 var t = keySchedule[ksRow - 1];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1802
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1803 if (!(ksRow % keySize)) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1804 // Rot word
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1805 t = (t << 8) | (t >>> 24);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1806
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1807 // Sub word
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1808 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1809
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1810 // Mix Rcon
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1811 t ^= RCON[(ksRow / keySize) | 0] << 24;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1812 } else if (keySize > 6 && ksRow % keySize == 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1813 // Sub word
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1814 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1815 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1816
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1817 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1818 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1819 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1820
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1821 // Compute inv key schedule
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1822 var invKeySchedule = this._invKeySchedule = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1823 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1824 var ksRow = ksRows - invKsRow;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1825
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1826 if (invKsRow % 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1827 var t = keySchedule[ksRow];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1828 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1829 var t = keySchedule[ksRow - 4];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1830 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1831
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1832 if (invKsRow < 4 || ksRow <= 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1833 invKeySchedule[invKsRow] = t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1834 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1835 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1836 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1837 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1838 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1839 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1840
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1841 encryptBlock: function (M, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1842 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1843 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1844
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1845 decryptBlock: function (M, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1846 // Swap 2nd and 4th rows
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1847 var t = M[offset + 1];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1848 M[offset + 1] = M[offset + 3];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1849 M[offset + 3] = t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1850
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1851 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1852
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1853 // Inv swap 2nd and 4th rows
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1854 var t = M[offset + 1];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1855 M[offset + 1] = M[offset + 3];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1856 M[offset + 3] = t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1857 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1858
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1859 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1860 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1861 var nRounds = this._nRounds;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1862
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1863 // Get input, add round key
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1864 var s0 = M[offset] ^ keySchedule[0];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1865 var s1 = M[offset + 1] ^ keySchedule[1];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1866 var s2 = M[offset + 2] ^ keySchedule[2];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1867 var s3 = M[offset + 3] ^ keySchedule[3];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1868
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1869 // Key schedule row counter
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1870 var ksRow = 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1871
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1872 // Rounds
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1873 for (var round = 1; round < nRounds; round++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1874 // Shift rows, sub bytes, mix columns, add round key
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1875 var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1876 var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1877 var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1878 var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1879
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1880 // Update state
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1881 s0 = t0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1882 s1 = t1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1883 s2 = t2;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1884 s3 = t3;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1885 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1886
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1887 // Shift rows, sub bytes, add round key
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1888 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1889 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1890 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1891 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1892
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1893 // Set output
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1894 M[offset] = t0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1895 M[offset + 1] = t1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1896 M[offset + 2] = t2;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1897 M[offset + 3] = t3;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1898 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1899
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1900 keySize: 256/32
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1901 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1902
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1903 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1904 * Shortcut functions to the cipher's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1905 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1906 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1907 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1908 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1909 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1910 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1911 C.AES = BlockCipher._createHelper(AES);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1912 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1913
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1914 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1915 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1916 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1917 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1918 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1919 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1920 (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1921 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1922 var C = CryptoJS;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1923 var C_lib = C.lib;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1924 var WordArray = C_lib.WordArray;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1925 var Hasher = C_lib.Hasher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1926 var C_algo = C.algo;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1927
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1928 // Reusable object
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1929 var W = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1930
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1931 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1932 * SHA-1 hash algorithm.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1933 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1934 var SHA1 = C_algo.SHA1 = Hasher.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1935 _doReset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1936 this._hash = new WordArray.init([
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1937 0x67452301, 0xefcdab89,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1938 0x98badcfe, 0x10325476,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1939 0xc3d2e1f0
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1940 ]);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1941 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1942
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1943 _doProcessBlock: function (M, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1944 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1945 var H = this._hash.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1946
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1947 // Working variables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1948 var a = H[0];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1949 var b = H[1];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1950 var c = H[2];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1951 var d = H[3];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1952 var e = H[4];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1953
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1954 // Computation
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1955 for (var i = 0; i < 80; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1956 if (i < 16) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1957 W[i] = M[offset + i] | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1958 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1959 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1960 W[i] = (n << 1) | (n >>> 31);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1961 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1962
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1963 var t = ((a << 5) | (a >>> 27)) + e + W[i];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1964 if (i < 20) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1965 t += ((b & c) | (~b & d)) + 0x5a827999;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1966 } else if (i < 40) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1967 t += (b ^ c ^ d) + 0x6ed9eba1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1968 } else if (i < 60) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1969 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1970 } else /* if (i < 80) */ {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1971 t += (b ^ c ^ d) - 0x359d3e2a;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1972 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1973
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1974 e = d;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1975 d = c;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1976 c = (b << 30) | (b >>> 2);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1977 b = a;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1978 a = t;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1979 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1980
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1981 // Intermediate hash value
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1982 H[0] = (H[0] + a) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1983 H[1] = (H[1] + b) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1984 H[2] = (H[2] + c) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1985 H[3] = (H[3] + d) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1986 H[4] = (H[4] + e) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1987 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1988
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1989 _doFinalize: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1990 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1991 var data = this._data;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1992 var dataWords = data.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1993
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1994 var nBitsTotal = this._nDataBytes * 8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1995 var nBitsLeft = data.sigBytes * 8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1996
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1997 // Add padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1998 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1999 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2000 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2001 data.sigBytes = dataWords.length * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2002
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2003 // Hash final blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2004 this._process();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2005
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2006 // Return final computed hash
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2007 return this._hash;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2008 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2009
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2010 clone: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2011 var clone = Hasher.clone.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2012 clone._hash = this._hash.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2013
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2014 return clone;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2015 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2016 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2017
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2018 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2019 * Shortcut function to the hasher's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2020 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2021 * @param {WordArray|string} message The message to hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2022 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2023 * @return {WordArray} The hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2024 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2025 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2026 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2027 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2028 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2029 * var hash = CryptoJS.SHA1('message');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2030 * var hash = CryptoJS.SHA1(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2031 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2032 C.SHA1 = Hasher._createHelper(SHA1);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2033
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2034 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2035 * Shortcut function to the HMAC's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2036 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2037 * @param {WordArray|string} message The message to hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2038 * @param {WordArray|string} key The secret key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2039 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2040 * @return {WordArray} The HMAC.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2041 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2042 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2043 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2044 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2045 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2046 * var hmac = CryptoJS.HmacSHA1(message, key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2047 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2048 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2049 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2050
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2051 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2052 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2053 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2054 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2055 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2056 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2057 (function (Math) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2058 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2059 var C = CryptoJS;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2060 var C_lib = C.lib;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2061 var WordArray = C_lib.WordArray;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2062 var Hasher = C_lib.Hasher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2063 var C_algo = C.algo;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2064
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2065 // Initialization and round constants tables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2066 var H = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2067 var K = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2068
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2069 // Compute constants
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2070 (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2071 function isPrime(n) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2072 var sqrtN = Math.sqrt(n);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2073 for (var factor = 2; factor <= sqrtN; factor++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2074 if (!(n % factor)) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2075 return false;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2076 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2077 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2078
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2079 return true;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2080 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2081
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2082 function getFractionalBits(n) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2083 return ((n - (n | 0)) * 0x100000000) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2084 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2085
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2086 var n = 2;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2087 var nPrime = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2088 while (nPrime < 64) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2089 if (isPrime(n)) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2090 if (nPrime < 8) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2091 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2092 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2093 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2094
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2095 nPrime++;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2096 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2097
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2098 n++;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2099 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2100 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2101
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2102 // Reusable object
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2103 var W = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2104
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2105 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2106 * SHA-256 hash algorithm.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2107 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2108 var SHA256 = C_algo.SHA256 = Hasher.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2109 _doReset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2110 this._hash = new WordArray.init(H.slice(0));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2111 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2112
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2113 _doProcessBlock: function (M, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2114 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2115 var H = this._hash.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2116
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2117 // Working variables
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2118 var a = H[0];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2119 var b = H[1];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2120 var c = H[2];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2121 var d = H[3];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2122 var e = H[4];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2123 var f = H[5];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2124 var g = H[6];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2125 var h = H[7];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2126
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2127 // Computation
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2128 for (var i = 0; i < 64; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2129 if (i < 16) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2130 W[i] = M[offset + i] | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2131 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2132 var gamma0x = W[i - 15];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2133 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2134 ((gamma0x << 14) | (gamma0x >>> 18)) ^
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2135 (gamma0x >>> 3);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2136
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2137 var gamma1x = W[i - 2];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2138 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2139 ((gamma1x << 13) | (gamma1x >>> 19)) ^
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2140 (gamma1x >>> 10);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2141
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2142 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2143 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2144
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2145 var ch = (e & f) ^ (~e & g);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2146 var maj = (a & b) ^ (a & c) ^ (b & c);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2147
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2148 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2149 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2150
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2151 var t1 = h + sigma1 + ch + K[i] + W[i];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2152 var t2 = sigma0 + maj;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2153
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2154 h = g;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2155 g = f;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2156 f = e;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2157 e = (d + t1) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2158 d = c;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2159 c = b;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2160 b = a;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2161 a = (t1 + t2) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2162 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2163
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2164 // Intermediate hash value
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2165 H[0] = (H[0] + a) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2166 H[1] = (H[1] + b) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2167 H[2] = (H[2] + c) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2168 H[3] = (H[3] + d) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2169 H[4] = (H[4] + e) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2170 H[5] = (H[5] + f) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2171 H[6] = (H[6] + g) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2172 H[7] = (H[7] + h) | 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2173 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2174
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2175 _doFinalize: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2176 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2177 var data = this._data;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2178 var dataWords = data.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2179
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2180 var nBitsTotal = this._nDataBytes * 8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2181 var nBitsLeft = data.sigBytes * 8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2182
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2183 // Add padding
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2184 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2185 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2186 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2187 data.sigBytes = dataWords.length * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2188
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2189 // Hash final blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2190 this._process();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2191
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2192 // Return final computed hash
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2193 return this._hash;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2194 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2195
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2196 clone: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2197 var clone = Hasher.clone.call(this);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2198 clone._hash = this._hash.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2199
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2200 return clone;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2201 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2202 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2203
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2204 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2205 * Shortcut function to the hasher's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2206 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2207 * @param {WordArray|string} message The message to hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2208 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2209 * @return {WordArray} The hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2210 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2211 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2212 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2213 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2214 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2215 * var hash = CryptoJS.SHA256('message');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2216 * var hash = CryptoJS.SHA256(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2217 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2218 C.SHA256 = Hasher._createHelper(SHA256);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2219
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2220 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2221 * Shortcut function to the HMAC's object interface.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2222 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2223 * @param {WordArray|string} message The message to hash.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2224 * @param {WordArray|string} key The secret key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2225 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2226 * @return {WordArray} The HMAC.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2227 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2228 * @static
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2229 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2230 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2231 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2232 * var hmac = CryptoJS.HmacSHA256(message, key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2233 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2234 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2235 }(Math));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2236
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2237 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2238 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2239 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2240 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2241 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2242 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2243 (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2244 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2245 var C = CryptoJS;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2246 var C_lib = C.lib;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2247 var Base = C_lib.Base;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2248 var C_enc = C.enc;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2249 var Utf8 = C_enc.Utf8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2250 var C_algo = C.algo;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2251
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2252 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2253 * HMAC algorithm.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2254 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2255 var HMAC = C_algo.HMAC = Base.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2256 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2257 * Initializes a newly created HMAC.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2258 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2259 * @param {Hasher} hasher The hash algorithm to use.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2260 * @param {WordArray|string} key The secret key.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2261 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2262 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2263 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2264 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2265 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2266 init: function (hasher, key) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2267 // Init hasher
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2268 hasher = this._hasher = new hasher.init();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2269
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2270 // Convert string to WordArray, else assume WordArray already
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2271 if (typeof key == 'string') {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2272 key = Utf8.parse(key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2273 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2274
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2275 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2276 var hasherBlockSize = hasher.blockSize;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2277 var hasherBlockSizeBytes = hasherBlockSize * 4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2278
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2279 // Allow arbitrary length keys
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2280 if (key.sigBytes > hasherBlockSizeBytes) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2281 key = hasher.finalize(key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2282 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2283
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2284 // Clamp excess bits
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2285 key.clamp();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2286
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2287 // Clone key for inner and outer pads
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2288 var oKey = this._oKey = key.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2289 var iKey = this._iKey = key.clone();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2290
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2291 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2292 var oKeyWords = oKey.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2293 var iKeyWords = iKey.words;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2294
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2295 // XOR keys with pad constants
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2296 for (var i = 0; i < hasherBlockSize; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2297 oKeyWords[i] ^= 0x5c5c5c5c;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2298 iKeyWords[i] ^= 0x36363636;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2299 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2300 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2301
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2302 // Set initial values
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2303 this.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2304 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2305
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2306 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2307 * Resets this HMAC to its initial state.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2308 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2309 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2310 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2311 * hmacHasher.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2312 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2313 reset: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2314 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2315 var hasher = this._hasher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2316
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2317 // Reset
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2318 hasher.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2319 hasher.update(this._iKey);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2320 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2321
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2322 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2323 * Updates this HMAC with a message.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2324 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2325 * @param {WordArray|string} messageUpdate The message to append.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2326 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2327 * @return {HMAC} This HMAC instance.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2328 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2329 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2330 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2331 * hmacHasher.update('message');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2332 * hmacHasher.update(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2333 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2334 update: function (messageUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2335 this._hasher.update(messageUpdate);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2336
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2337 // Chainable
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2338 return this;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2339 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2340
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2341 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2342 * Finalizes the HMAC computation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2343 * Note that the finalize operation is effectively a destructive, read-once operation.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2344 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2345 * @param {WordArray|string} messageUpdate (Optional) A final message update.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2346 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2347 * @return {WordArray} The HMAC.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2348 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2349 * @example
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2350 *
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2351 * var hmac = hmacHasher.finalize();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2352 * var hmac = hmacHasher.finalize('message');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2353 * var hmac = hmacHasher.finalize(wordArray);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2354 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2355 finalize: function (messageUpdate) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2356 // Shortcut
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2357 var hasher = this._hasher;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2358
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2359 // Compute HMAC
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2360 var innerHash = hasher.finalize(messageUpdate);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2361 hasher.reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2362 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2363
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2364 return hmac;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2365 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2366 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2367 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2368
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2369 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2370 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2371 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2372 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2373 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2374 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2375 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2376 * A noop padding strategy.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2377 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2378 CryptoJS.pad.NoPadding = {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2379 pad: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2380 },
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2381
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2382 unpad: function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2383 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2384 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2385
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2386 /*
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2387 CryptoJS v3.1.2
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2388 code.google.com/p/crypto-js
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2389 (c) 2009-2013 by Jeff Mott. All rights reserved.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2390 code.google.com/p/crypto-js/wiki/License
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2391 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2392 /**
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2393 * Counter block mode.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2394 */
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2395 CryptoJS.mode.CTR = (function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2396 var CTR = CryptoJS.lib.BlockCipherMode.extend();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2397
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2398 var Encryptor = CTR.Encryptor = CTR.extend({
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2399 processBlock: function (words, offset) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2400 // Shortcuts
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2401 var cipher = this._cipher
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2402 var blockSize = cipher.blockSize;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2403 var iv = this._iv;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2404 var counter = this._counter;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2405
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2406 // Generate keystream
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2407 if (iv) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2408 counter = this._counter = iv.slice(0);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2409
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2410 // Remove IV for subsequent blocks
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2411 this._iv = undefined;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2412 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2413 var keystream = counter.slice(0);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2414 cipher.encryptBlock(keystream, 0);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2415
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2416 // Increment counter
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2417 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2418
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2419 // Encrypt
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2420 for (var i = 0; i < blockSize; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2421 words[offset + i] ^= keystream[i];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2422 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2423 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2424 });
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2425
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2426 CTR.Decryptor = Encryptor;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2427
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2428 return CTR;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2429 }());
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2430
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2431
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2432 return CryptoJS
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2433
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2434 }))