Ejemplo n.º 1
0
    def test_encode_int(self):

        self.assertEqual(encode_int(0), b'AA==')
        self.assertEqual(encode_int(2**24 - 1), b'////')

        self.assertRaises(ValueError, encode_int, -1)
        self.assertRaises(TypeError, encode_int, '')
        self.assertRaises(TypeError, encode_int, None)
Ejemplo n.º 2
0
    def test_encode_int(self):

        self.assertEqual(encode_int(0), b"AA==")
        self.assertEqual(encode_int(2 ** 24 - 1), b"////")

        self.assertRaises(ValueError, encode_int, -1)
        self.assertRaises(TypeError, encode_int, "")
        self.assertRaises(TypeError, encode_int, None)
Ejemplo n.º 3
0
    def fingerprint(self):
        """The identity fingerprint
        
        A bytes string that is a hash of the public components of the keys.
        """
        if self._fp is None: # Lazy hashing
            h = hashlib.sha256()
            h.update(encode_int(self._rsa_key.n))
            h.update(encode_int(self._rsa_key.e))
            h.update(encode_int(self._dsa_key.y))
            h.update(encode_int(self._dsa_key.g))
            h.update(encode_int(self._dsa_key.p))
            self._fp = h.digest()[-Identity._FINGERPRINT_LENGTH_BYTES:]

        return self._fp