summaryrefslogtreecommitdiff
authorMichael Krelin <hacker@klever.net>2014-06-30 18:29:31 (UTC)
committer Michael Krelin <hacker@klever.net>2014-06-30 18:29:31 (UTC)
commit9d4ae3e240e8d82a5e500c1bfbf3b4e8a43c62c6 (patch) (unidiff)
tree9c8068f07b59aaedd72393090a4f68e9dfc58c3e
parentc392fe28606eefa0c814e5c25d641f5ffe623186 (diff)
downloadclipperz-9d4ae3e240e8d82a5e500c1bfbf3b4e8a43c62c6.zip
clipperz-9d4ae3e240e8d82a5e500c1bfbf3b4e8a43c62c6.tar.gz
clipperz-9d4ae3e240e8d82a5e500c1bfbf3b4e8a43c62c6.tar.bz2
adjust SRP to match clipper change
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--backend/node/src/clipperz.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/backend/node/src/clipperz.js b/backend/node/src/clipperz.js
index 37b9cae..72b6c9f 100644
--- a/backend/node/src/clipperz.js
+++ b/backend/node/src/clipperz.js
@@ -44,12 +44,14 @@ function clipperz_store(PG) {
44 rv.prototype.__proto__ = express_store.prototype; 44 rv.prototype.__proto__ = express_store.prototype;
45 return rv; 45 return rv;
46} 46}
47 47
48var srp_g = BIGNUM(2); 48var srp_g = BIGNUM(2);
49var srp_n = BIGNUM("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3",16); 49var srp_n = BIGNUM("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3",16);
50var srp_k = BIGNUM("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e",16);
51var srp_hn = "597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529";
50var n123 = '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00'; 52var n123 = '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00';
51 53
52 54
53var CLIPPERZ = module.exports = function(CONFIG) { 55var CLIPPERZ = module.exports = function(CONFIG) {
54 56
55 var LOGGER = CONFIG.logger||{trace:function(){}}; 57 var LOGGER = CONFIG.logger||{trace:function(){}};
@@ -172,25 +174,30 @@ var CLIPPERZ = module.exports = function(CONFIG) {
172 },function(e,r) { 174 },function(e,r) {
173 if(e) return cb(e); 175 if(e) return cb(e);
174 req.session.C = ppp.C; req.session.A = ppp.A; 176 req.session.C = ppp.C; req.session.A = ppp.A;
175 req.session.s = r.u.u_srp_s; req.session.v = r.u.u_srp_v; 177 req.session.s = r.u.u_srp_s; req.session.v = r.u.u_srp_v;
176 req.session.u = r.u.u_id; 178 req.session.u = r.u.u_id;
177 req.session.b = clipperz_random(); 179 req.session.b = clipperz_random();
178 req.session.B = BIGNUM(req.session.v,16).add(srp_g.powm(BIGNUM(req.session.b,16),srp_n)).toString(16); 180 req.session.B = srp_k.mul(BIGNUM(req.session.v,16)).add(srp_g.powm(BIGNUM(req.session.b,16),srp_n)).toString(16);
179 var rv = {s:req.session.s,B:req.session.B} 181 var rv = {s:req.session.s,B:req.session.B}
180 if(r.otp && r.otp.otp_ref) rv.oneTimePassword=r.otp.otp_ref; 182 if(r.otp && r.otp.otp_ref) rv.oneTimePassword=r.otp.otp_ref;
181 res.res(rv); 183 res.res(rv);
182 }); 184 });
183 185
184 case 'credentialCheck': 186 case 'credentialCheck':
185 var u = clipperz_hash(BIGNUM(req.session.B,16).toString(10)); 187 var u = clipperz_hash(BIGNUM(req.session.A,16).toString(10)+BIGNUM(req.session.B,16).toString(10));
186 var A = BIGNUM(req.session.A,16); 188 var A = BIGNUM(req.session.A,16);
187 var S = A.mul(BIGNUM(req.session.v,16).powm(BIGNUM(u,16),srp_n)).powm( 189 var S = A.mul(BIGNUM(req.session.v,16).powm(BIGNUM(u,16),srp_n)).powm(BIGNUM(req.session.b,16),srp_n);
188 BIGNUM(req.session.b,16), srp_n);
189 var K = clipperz_hash(S.toString(10)); 190 var K = clipperz_hash(S.toString(10));
190 var M1 = clipperz_hash(A.toString(10)+BIGNUM(req.session.B,16).toString(10)+K.toString(16)); 191 var M1 = clipperz_hash(
192 srp_hn
193 +clipperz_hash(req.session.C)
194 +BIGNUM(req.session.s,16).toString(10)
195 +A.toString(10)
196 +BIGNUM(req.session.B,16).toString(10)
197 +K );
191 if(M1!=ppp.M1) return res.res({error:'?'}); 198 if(M1!=ppp.M1) return res.res({error:'?'});
192 req.session.K = K; 199 req.session.K = K;
193 var M2 = clipperz_hash(A.toString(10)+M1+K.toString(16)); 200 var M2 = clipperz_hash(A.toString(10)+M1+K.toString(16));
194 return res.res({M2:M2,connectionId:'',loginInfo:{latest:{},current:{}},offlineCopyNeeded:false,lock:'----'}); 201 return res.res({M2:M2,connectionId:'',loginInfo:{latest:{},current:{}},offlineCopyNeeded:false,lock:'----'});
195 202
196 case 'oneTimePassword': return PG.Q( 203 case 'oneTimePassword': return PG.Q(