Esempio n. 1
0
 def test_MD5HashA1(self, _algorithm='md5', _hash=md5.md5):
     """
     L{calcHA1} accepts the C{'md5'} algorithm and returns an MD5 hash of
     its parameters, excluding the nonce and cnonce.
     """
     nonce = 'abc123xyz'
     hashA1 = calcHA1(_algorithm, self.username, self.realm, self.password,
                      nonce, self.cnonce)
     a1 = '%s:%s:%s' % (self.username, self.realm, self.password)
     expected = _hash(a1).hexdigest()
     self.assertEqual(hashA1, expected)
Esempio n. 2
0
 def test_MD5HashA1(self, _algorithm='md5', _hash=md5.md5):
     """
     L{calcHA1} accepts the C{'md5'} algorithm and returns an MD5 hash of
     its parameters, excluding the nonce and cnonce.
     """
     nonce = 'abc123xyz'
     hashA1 = calcHA1(_algorithm, self.username, self.realm, self.password,
                      nonce, self.cnonce)
     a1 = '%s:%s:%s' % (self.username, self.realm, self.password)
     expected = _hash(a1).hexdigest()
     self.assertEqual(hashA1, expected)
Esempio n. 3
0
    def getDigestResponse(self, challenge, ncount):
        """
        Calculate the response for the given challenge
        """
        nonce = challenge.get('nonce')
        algo = challenge.get('algorithm').lower()
        qop = challenge.get('qop')

        ha1 = calcHA1(
            algo, self.username, self.realm, self.password, nonce, self.cnonce)
        ha2 = calcHA2(algo, "GET", self.uri, qop, None)
        expected = calcResponse(ha1, ha2, algo, nonce, ncount, self.cnonce, qop)
        return expected
Esempio n. 4
0
 def test_MD5SessionHashA1(self):
     """
     L{calcHA1} accepts the C{'md5-sess'} algorithm and returns an MD5 hash
     of its parameters, including the nonce and cnonce.
     """
     nonce = 'xyz321abc'
     hashA1 = calcHA1('md5-sess', self.username, self.realm, self.password,
                      nonce, self.cnonce)
     a1 = '%s:%s:%s' % (self.username, self.realm, self.password)
     ha1 = md5.md5(a1).digest()
     a1 = '%s:%s:%s' % (ha1, nonce, self.cnonce)
     expected = md5.md5(a1).hexdigest()
     self.assertEqual(hashA1, expected)
Esempio n. 5
0
 def test_MD5SessionHashA1(self):
     """
     L{calcHA1} accepts the C{'md5-sess'} algorithm and returns an MD5 hash
     of its parameters, including the nonce and cnonce.
     """
     nonce = 'xyz321abc'
     hashA1 = calcHA1('md5-sess', self.username, self.realm, self.password,
                      nonce, self.cnonce)
     a1 = '%s:%s:%s' % (self.username, self.realm, self.password)
     ha1 = md5.md5(a1).digest()
     a1 = '%s:%s:%s' % (ha1, nonce, self.cnonce)
     expected = md5.md5(a1).hexdigest()
     self.assertEqual(hashA1, expected)
Esempio n. 6
0
    def getDigestResponse(self, challenge, ncount):
        """
        Calculate the response for the given challenge
        """
        nonce = challenge.get('nonce')
        algo = challenge.get('algorithm').lower()
        qop = challenge.get('qop')

        ha1 = calcHA1(algo, self.username, self.realm, self.password, nonce,
                      self.cnonce)
        ha2 = calcHA2(algo, "GET", self.uri, qop, None)
        expected = calcResponse(ha1, ha2, algo, nonce, ncount, self.cnonce,
                                qop)
        return expected