-rw-r--r-- | backend/node/src/clipperz.js | 17 |
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 | |||
@@ -47,6 +47,8 @@ function clipperz_store(PG) { | |||
47 | 47 | ||
48 | var srp_g = BIGNUM(2); | 48 | var srp_g = BIGNUM(2); |
49 | var srp_n = BIGNUM("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3",16); | 49 | var srp_n = BIGNUM("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3",16); |
50 | var srp_k = BIGNUM("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e",16); | ||
51 | var srp_hn = "597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529"; | ||
50 | var n123 = '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00'; | 52 | var n123 = '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00'; |
51 | 53 | ||
52 | 54 | ||
@@ -175,19 +177,24 @@ var CLIPPERZ = module.exports = function(CONFIG) { | |||
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)); |