corrade-nucleus-nucleons – Blame information for rev 4

Subversion Repositories:
Rev:
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 (Math) {
8 // Shortcuts
9 var C = CryptoJS;
10 var C_lib = C.lib;
11 var WordArray = C_lib.WordArray;
12 var Hasher = C_lib.Hasher;
13 var C_algo = C.algo;
14  
15 // Initialization and round constants tables
16 var H = [];
17 var K = [];
18  
19 // Compute constants
20 (function () {
21 function isPrime(n) {
22 var sqrtN = Math.sqrt(n);
23 for (var factor = 2; factor <= sqrtN; factor++) {
24 if (!(n % factor)) {
25 return false;
26 }
27 }
28  
29 return true;
30 }
31  
32 function getFractionalBits(n) {
33 return ((n - (n | 0)) * 0x100000000) | 0;
34 }
35  
36 var n = 2;
37 var nPrime = 0;
38 while (nPrime < 64) {
39 if (isPrime(n)) {
40 if (nPrime < 8) {
41 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
42 }
43 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
44  
45 nPrime++;
46 }
47  
48 n++;
49 }
50 }());
51  
52 // Reusable object
53 var W = [];
54  
55 /**
56 * SHA-256 hash algorithm.
57 */
58 var SHA256 = C_algo.SHA256 = Hasher.extend({
59 _doReset: function () {
60 this._hash = new WordArray.init(H.slice(0));
61 },
62  
63 _doProcessBlock: function (M, offset) {
64 // Shortcut
65 var H = this._hash.words;
66  
67 // Working variables
68 var a = H[0];
69 var b = H[1];
70 var c = H[2];
71 var d = H[3];
72 var e = H[4];
73 var f = H[5];
74 var g = H[6];
75 var h = H[7];
76  
77 // Computation
78 for (var i = 0; i < 64; i++) {
79 if (i < 16) {
80 W[i] = M[offset + i] | 0;
81 } else {
82 var gamma0x = W[i - 15];
83 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
84 ((gamma0x << 14) | (gamma0x >>> 18)) ^
85 (gamma0x >>> 3);
86  
87 var gamma1x = W[i - 2];
88 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
89 ((gamma1x << 13) | (gamma1x >>> 19)) ^
90 (gamma1x >>> 10);
91  
92 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
93 }
94  
95 var ch = (e & f) ^ (~e & g);
96 var maj = (a & b) ^ (a & c) ^ (b & c);
97  
98 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
99 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
100  
101 var t1 = h + sigma1 + ch + K[i] + W[i];
102 var t2 = sigma0 + maj;
103  
104 h = g;
105 g = f;
106 f = e;
107 e = (d + t1) | 0;
108 d = c;
109 c = b;
110 b = a;
111 a = (t1 + t2) | 0;
112 }
113  
114 // Intermediate hash value
115 H[0] = (H[0] + a) | 0;
116 H[1] = (H[1] + b) | 0;
117 H[2] = (H[2] + c) | 0;
118 H[3] = (H[3] + d) | 0;
119 H[4] = (H[4] + e) | 0;
120 H[5] = (H[5] + f) | 0;
121 H[6] = (H[6] + g) | 0;
122 H[7] = (H[7] + h) | 0;
123 },
124  
125 _doFinalize: function () {
126 // Shortcuts
127 var data = this._data;
128 var dataWords = data.words;
129  
130 var nBitsTotal = this._nDataBytes * 8;
131 var nBitsLeft = data.sigBytes * 8;
132  
133 // Add padding
134 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
135 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
136 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
137 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; data.sigBytes = dataWords.length * 4;
138  
139 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; // Hash final blocks
140 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; this._process();
141  
142 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; // Return final computed hash
143 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; return this._hash;
144 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; },
145  
146 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; clone: function () {
147 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; var clone = Hasher.clone.call(this);
148 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; clone._hash = this._hash.clone();
149  
150 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; return clone;
151 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; }
152 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; });
153  
154 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; /**
155 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * Shortcut function to the hasher's object interface.
156 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
157 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @param {WordArray|string} message The message to hash.
158 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
159 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @return {WordArray} The hash.
160 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
161 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @static
162 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
163 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @example
164 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
165 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * var hash = CryptoJS.SHA256('message');
166 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * var hash = CryptoJS.SHA256(wordArray);
167 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; */
168 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; C.SHA256 = Hasher._createHelper(SHA256);
169  
170 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; /**
171 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * Shortcut function to the HMAC's object interface.
172 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
173 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @param {WordArray|string} message The message to hash.
174 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @param {WordArray|string} key The secret key.
175 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
176 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @return {WordArray} The HMAC.
177 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
178 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @static
179 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
180 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * @example
181 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; *
182 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; * var hmac = CryptoJS.HmacSHA256(message, key);
183 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; */
184 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal; C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
185 << 4) + 15] = nBitsTotal;< 4) + 15] = nBitsTotal;}(Math));