summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/bonafide/_srp.py
diff options
context:
space:
mode:
authorThais Siqueira <thais.siqueira@gmail.com>2017-03-02 16:23:17 -0300
committerRuben Pollan <meskio@sindominio.net>2017-03-30 17:00:06 +0200
commitcaed945c7c85800d7467f52471509afc21a6f071 (patch)
tree4b1c3167e49044f14c0192e842bfd30fc92e8912 /src/leap/bitmask/bonafide/_srp.py
parentbd853141a23055cf2d1e0a4ae1712577024f9b84 (diff)
[feature] Creates methods for update recovery code.
Related with: https://github.com/pixelated/pixelated-user-agent/issues/924 with @aarni Signed-off-by: Ruben Pollan <meskio@sindominio.net>
Diffstat (limited to 'src/leap/bitmask/bonafide/_srp.py')
-rw-r--r--src/leap/bitmask/bonafide/_srp.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/leap/bitmask/bonafide/_srp.py b/src/leap/bitmask/bonafide/_srp.py
index 3939c5ac..1ec40d82 100644
--- a/src/leap/bitmask/bonafide/_srp.py
+++ b/src/leap/bitmask/bonafide/_srp.py
@@ -144,7 +144,7 @@ class SRPSignupMechanism(object):
class SRPPasswordChangeMechanism(object):
"""
- Implement a protocol-agnostic SRP passord change mechanism.
+ Implement a protocol-agnostic SRP password change mechanism.
"""
def get_password_params(self, username, password):
@@ -155,6 +155,20 @@ class SRPPasswordChangeMechanism(object):
return user_data
+class SRPRecoveryCodeUpdateMechanism(object):
+
+ """
+ Implement a protocol-agnostic SRP recovery code update mechanism.
+ """
+
+ def get_recovery_code_params(self, username, recovery_code):
+ salt, verifier = _get_salt_verifier(username, recovery_code)
+ user_data = {
+ 'user[recovery_code_salt]': binascii.hexlify(salt),
+ 'user[recovery_code_verifier]': binascii.hexlify(verifier)}
+ return user_data
+
+
def _get_salt_verifier(username, password):
return srp.create_salted_verification_key(bytes(username), bytes(password),
srp.SHA256, srp.NG_1024)