Skip to content

Commit c1a7836

Browse files
authored
fix wampcra auth with salt (#2121)
1 parent f722a22 commit c1a7836

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crossbar/router/auth/wampcra.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,19 @@ def _compute_challenge(self, user):
6262
}
6363
challenge: str = json.dumps(challenge_obj, ensure_ascii=False)
6464
secret = user['secret'].encode('utf8')
65-
signature = auth.compute_wcs(secret, challenge.encode('utf8')).decode('ascii')
6665

6766
# extra data to send to client in CHALLENGE
6867
extra = {'challenge': challenge}
6968

7069
# when using salted passwords, provide the client with
7170
# the salt and then PBKDF2 parameters used
72-
if 'salt' in user:
71+
if 'salt' in user and 'iterations' in user and 'keylen' in user:
7372
extra['salt'] = user['salt']
74-
extra['iterations'] = user.get('iterations', 1000)
75-
extra['keylen'] = user.get('keylen', 32)
73+
extra['iterations'] = user['iterations']
74+
extra['keylen'] = user['keylen']
75+
secret = auth.derive_key(secret, extra['salt'], extra['iterations'], extra['keylen'])
76+
77+
signature = auth.compute_wcs(secret, challenge.encode('utf8')).decode('ascii')
7678

7779
return extra, signature
7880

0 commit comments

Comments
 (0)