Example #1
0
    def makeVerifier(username, password, bits):
        """Create a verifier entry which can be stored in a VerifierDB.

        :type username: str
        :param username: The username for this verifier.  Must be less
            than 256 characters in length.

        :type password: str
        :param password: The password for this verifier.

        :type bits: int
        :param bits: This values specifies which SRP group parameters
            to use.  It must be one of (1024, 1536, 2048, 3072, 4096, 6144,
            8192).  Larger values are more secure but slower.  2048 is a
            good compromise between safety and speed.

        :rtype: tuple
        :returns: A tuple which may be stored in a VerifierDB.
        """
        if isinstance(username, str):
            usernameBytes = bytearray(username, "utf-8")
        else:
            usernameBytes = bytearray(username)
        if isinstance(password, str):
            passwordBytes = bytearray(password, "utf-8")
        else:
            passwordBytes = bytearray(password)
        return mathtls.makeVerifier(usernameBytes, passwordBytes, bits)
Example #2
0
    def makeVerifier(username, password, bits):
        """Create a verifier entry which can be stored in a VerifierDB.

        @type username: str
        @param username: The username for this verifier.  Must be less
        than 256 characters in length.

        @type password: str
        @param password: The password for this verifier.

        @type bits: int
        @param bits: This values specifies which SRP group parameters
        to use.  It must be one of (1024, 1536, 2048, 3072, 4096, 6144,
        8192).  Larger values are more secure but slower.  2048 is a
        good compromise between safety and speed.

        @rtype: tuple
        @return: A tuple which may be stored in a VerifierDB.
        """
        if isinstance(username, str):
            usernameBytes = bytearray(username, "utf-8")
        else:
            usernameBytes = bytearray(username)
        if isinstance(password, str):
            passwordBytes = bytearray(password, "utf-8")
        else:
            passwordBytes = bytearray(password)
        return mathtls.makeVerifier(usernameBytes, passwordBytes, bits)
Example #3
0
 def set_from_password(self, password, srp_group=1024):
     self.srp_group = srp_group
     N, g, s, v = mathtls.makeVerifier(self.user.username,
                                       password,
                                       self.srp_group)
     self.srpN = b64encode(mathtls.numberToString(N))
     self.srpg = str(g)
     self.verifier = b64encode(mathtls.numberToString(v))
     self.salt = b64encode(s)
Example #4
0
    def makeVerifier(username, password, bits):
        """Create a verifier entry which can be stored in a VerifierDB.

        @type username: str
        @param username: The username for this verifier.  Must be less
        than 256 characters in length.

        @type password: str
        @param password: The password for this verifier.

        @type bits: int
        @param bits: This values specifies which SRP group parameters
        to use.  It must be one of (1024, 1536, 2048, 3072, 4096, 6144,
        8192).  Larger values are more secure but slower.  2048 is a
        good compromise between safety and speed.

        @rtype: tuple
        @return: A tuple which may be stored in a VerifierDB.
        """
        return mathtls.makeVerifier(username, password, bits)