corrade-nucleus-nucleons – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
2 | office | 1 | /* |
2 | CryptoJS v3.1.2 |
||
3 | code.google.com/p/crypto-js |
||
4 | (c) 2009-2013 by Jeff Mott. All rights reserved. |
||
5 | code.google.com/p/crypto-js/wiki/License |
||
6 | */ |
||
7 | (function (undefined) { |
||
8 | // Shortcuts |
||
9 | var C = CryptoJS; |
||
10 | var C_lib = C.lib; |
||
11 | var Base = C_lib.Base; |
||
12 | var X32WordArray = C_lib.WordArray; |
||
13 | |||
14 | /** |
||
15 | * x64 namespace. |
||
16 | */ |
||
17 | var C_x64 = C.x64 = {}; |
||
18 | |||
19 | /** |
||
20 | * A 64-bit word. |
||
21 | */ |
||
22 | var X64Word = C_x64.Word = Base.extend({ |
||
23 | /** |
||
24 | * Initializes a newly created 64-bit word. |
||
25 | * |
||
26 | * @param {number} high The high 32 bits. |
||
27 | * @param {number} low The low 32 bits. |
||
28 | * |
||
29 | * @example |
||
30 | * |
||
31 | * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); |
||
32 | */ |
||
33 | init: function (high, low) { |
||
34 | this.high = high; |
||
35 | this.low = low; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Bitwise NOTs this word. |
||
40 | * |
||
41 | * @return {X64Word} A new x64-Word object after negating. |
||
42 | * |
||
43 | * @example |
||
44 | * |
||
45 | * var negated = x64Word.not(); |
||
46 | */ |
||
47 | // not: function () { |
||
48 | // var high = ~this.high; |
||
49 | // var low = ~this.low; |
||
50 | |||
51 | // return X64Word.create(high, low); |
||
52 | // }, |
||
53 | |||
54 | /** |
||
55 | * Bitwise ANDs this word with the passed word. |
||
56 | * |
||
57 | * @param {X64Word} word The x64-Word to AND with this word. |
||
58 | * |
||
59 | * @return {X64Word} A new x64-Word object after ANDing. |
||
60 | * |
||
61 | * @example |
||
62 | * |
||
63 | * var anded = x64Word.and(anotherX64Word); |
||
64 | */ |
||
65 | // and: function (word) { |
||
66 | // var high = this.high & word.high; |
||
67 | // var low = this.low & word.low; |
||
68 | |||
69 | // return X64Word.create(high, low); |
||
70 | // }, |
||
71 | |||
72 | /** |
||
73 | * Bitwise ORs this word with the passed word. |
||
74 | * |
||
75 | * @param {X64Word} word The x64-Word to OR with this word. |
||
76 | * |
||
77 | * @return {X64Word} A new x64-Word object after ORing. |
||
78 | * |
||
79 | * @example |
||
80 | * |
||
81 | * var ored = x64Word.or(anotherX64Word); |
||
82 | */ |
||
83 | // or: function (word) { |
||
84 | // var high = this.high | word.high; |
||
85 | // var low = this.low | word.low; |
||
86 | |||
87 | // return X64Word.create(high, low); |
||
88 | // }, |
||
89 | |||
90 | /** |
||
91 | * Bitwise XORs this word with the passed word. |
||
92 | * |
||
93 | * @param {X64Word} word The x64-Word to XOR with this word. |
||
94 | * |
||
95 | * @return {X64Word} A new x64-Word object after XORing. |
||
96 | * |
||
97 | * @example |
||
98 | * |
||
99 | * var xored = x64Word.xor(anotherX64Word); |
||
100 | */ |
||
101 | // xor: function (word) { |
||
102 | // var high = this.high ^ word.high; |
||
103 | // var low = this.low ^ word.low; |
||
104 | |||
105 | // return X64Word.create(high, low); |
||
106 | // }, |
||
107 | |||
108 | /** |
||
109 | * Shifts this word n bits to the left. |
||
110 | * |
||
111 | * @param {number} n The number of bits to shift. |
||
112 | * |
||
113 | * @return {X64Word} A new x64-Word object after shifting. |
||
114 | * |
||
115 | * @example |
||
116 | * |
||
117 | * var shifted = x64Word.shiftL(25); |
||
118 | */ |
||
119 | // shiftL: function (n) { |
||
120 | // if (n < 32) { |
||
121 | // var high = (this.high << n) | (this.low >>> (32 - n)); |
||
122 | // var low = this.low << n; |
||
123 | // } else { |
||
124 | // var high = this.low << (n - 32); |
||
125 | // var low = 0; |
||
126 | // } |
||
127 | |||
128 | // return X64Word.create(high, low); |
||
129 | // }, |
||
130 | |||
131 | /** |
||
132 | * Shifts this word n bits to the right. |
||
133 | * |
||
134 | * @param {number} n The number of bits to shift. |
||
135 | * |
||
136 | * @return {X64Word} A new x64-Word object after shifting. |
||
137 | * |
||
138 | * @example |
||
139 | * |
||
140 | * var shifted = x64Word.shiftR(7); |
||
141 | */ |
||
142 | // shiftR: function (n) { |
||
143 | // if (n < 32) { |
||
144 | // var low = (this.low >>> n) | (this.high << (32 - n)); |
||
145 | // var high = this.high >>> n; |
||
146 | // } else { |
||
147 | // var low = this.high >>> (n - 32); |
||
148 | // var high = 0; |
||
149 | // } |
||
150 | |||
151 | // return X64Word.create(high, low); |
||
152 | // }, |
||
153 | |||
154 | /** |
||
155 | * Rotates this word n bits to the left. |
||
156 | * |
||
157 | * @param {number} n The number of bits to rotate. |
||
158 | * |
||
159 | * @return {X64Word} A new x64-Word object after rotating. |
||
160 | * |
||
161 | * @example |
||
162 | * |
||
163 | * var rotated = x64Word.rotL(25); |
||
164 | */ |
||
165 | // rotL: function (n) { |
||
166 | // return this.shiftL(n).or(this.shiftR(64 - n)); |
||
167 | // }, |
||
168 | |||
169 | /** |
||
170 | * Rotates this word n bits to the right. |
||
171 | * |
||
172 | * @param {number} n The number of bits to rotate. |
||
173 | * |
||
174 | * @return {X64Word} A new x64-Word object after rotating. |
||
175 | * |
||
176 | * @example |
||
177 | * |
||
178 | * var rotated = x64Word.rotR(7); |
||
179 | */ |
||
180 | // rotR: function (n) { |
||
181 | // return this.shiftR(n).or(this.shiftL(64 - n)); |
||
182 | // }, |
||
183 | |||
184 | /** |
||
185 | * Adds this word with the passed word. |
||
186 | * |
||
187 | * @param {X64Word} word The x64-Word to add with this word. |
||
188 | * |
||
189 | * @return {X64Word} A new x64-Word object after adding. |
||
190 | * |
||
191 | * @example |
||
192 | * |
||
193 | * var added = x64Word.add(anotherX64Word); |
||
194 | */ |
||
195 | // add: function (word) { |
||
196 | // var low = (this.low + word.low) | 0; |
||
197 | // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; |
||
198 | // var high = (this.high + word.high + carry) | 0; |
||
199 | |||
200 | // return X64Word.create(high, low); |
||
201 | // } |
||
202 | }); |
||
203 | |||
204 | /** |
||
205 | * An array of 64-bit words. |
||
206 | * |
||
207 | * @property {Array} words The array of CryptoJS.x64.Word objects. |
||
208 | * @property {number} sigBytes The number of significant bytes in this word array. |
||
209 | */ |
||
210 | var X64WordArray = C_x64.WordArray = Base.extend({ |
||
211 | /** |
||
212 | * Initializes a newly created word array. |
||
213 | * |
||
214 | * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. |
||
215 | * @param {number} sigBytes (Optional) The number of significant bytes in the words. |
||
216 | * |
||
217 | * @example |
||
218 | * |
||
219 | * var wordArray = CryptoJS.x64.WordArray.create(); |
||
220 | * |
||
221 | * var wordArray = CryptoJS.x64.WordArray.create([ |
||
222 | * CryptoJS.x64.Word.create(0x00010203, 0x04050607), |
||
223 | * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) |
||
224 | * ]); |
||
225 | * |
||
226 | * var wordArray = CryptoJS.x64.WordArray.create([ |
||
227 | * CryptoJS.x64.Word.create(0x00010203, 0x04050607), |
||
228 | * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) |
||
229 | * ], 10); |
||
230 | */ |
||
231 | init: function (words, sigBytes) { |
||
232 | words = this.words = words || []; |
||
233 | |||
234 | if (sigBytes != undefined) { |
||
235 | this.sigBytes = sigBytes; |
||
236 | } else { |
||
237 | this.sigBytes = words.length * 8; |
||
238 | } |
||
239 | }, |
||
240 | |||
241 | /** |
||
242 | * Converts this 64-bit word array to a 32-bit word array. |
||
243 | * |
||
244 | * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. |
||
245 | * |
||
246 | * @example |
||
247 | * |
||
248 | * var x32WordArray = x64WordArray.toX32(); |
||
249 | */ |
||
250 | toX32: function () { |
||
251 | // Shortcuts |
||
252 | var x64Words = this.words; |
||
253 | var x64WordsLength = x64Words.length; |
||
254 | |||
255 | // Convert |
||
256 | var x32Words = []; |
||
257 | for (var i = 0; i < x64WordsLength; i++) { |
||
258 | var x64Word = x64Words[i]; |
||
259 | x32Words.push(x64Word.high); |
||
260 | x32Words.push(x64Word.low); |
||
261 | } |
||
262 | |||
263 | return X32WordArray.create(x32Words, this.sigBytes); |
||
264 | }, |
||
265 | |||
266 | /** |
||
267 | * Creates a copy of this word array. |
||
268 | * |
||
269 | * @return {X64WordArray} The clone. |
||
270 | * |
||
271 | * @example |
||
272 | * |
||
273 | * var clone = x64WordArray.clone(); |
||
274 | */ |
||
275 | clone: function () { |
||
276 | var clone = Base.clone.call(this); |
||
277 | |||
278 | // Clone "words" array |
||
279 | var words = clone.words = this.words.slice(0); |
||
280 | |||
281 | // Clone each X64Word object |
||
282 | var wordsLength = words.length; |
||
283 | for (var i = 0; i < wordsLength; i++) { |
||
284 | words[i] = words[i].clone(); |
||
285 | } |
||
286 | |||
287 | return clone; |
||
288 | } |
||
289 | }); |
||
290 | }()); |