Example #1
0
def _EXP(n, p):
    '''
    .. note:: See tor-spec Section 5.1.4 for why this is an adequate
    replacement for checking that none of the EXP() operations produced
    the point at infinity.

    :returns: **str** result
    '''
    ret = bindings.crypto_scalarmult(bytes(n), bytes(PublicKey(p)))
    bad = util.constantStrAllZero(ret)
    return (ret, bad)
Example #2
0
    def _scalarMult(self, base):
        '''Perform base**self._secret_key.

        Set self.is_bad if the result is all zeros.

        .. note:: See tor-spec Section 5.1.4 for why this is an adequate
        replacement for checking that none of the EXP() operations produced
        the point at infinity.

        :returns: **str** result
        '''
        # args are: exponent, base
        ret = bindings.crypto_scalarmult(bytes(self._secret_key),
                                         bytes(PublicKey(base)))
        self.is_bad |= util.constantStrAllZero(ret)
        return ret
Example #3
0
    def _scalarMult(self, base):
        '''Perform base**self._secret_key.

        Set self.is_bad if the result is all zeros.

        .. note:: See tor-spec Section 5.1.4 for why this is an adequate
        replacement for checking that none of the EXP() operations produced
        the point at infinity.

        :returns: **str** result
        '''
        # args are: exponent, base
        ret = bindings.crypto_scalarmult(bytes(self._secret_key),
                                         bytes(PublicKey(base)))
        self.is_bad |= util.constantStrAllZero(ret)
        return ret
Example #4
0
 def test_constantStrAllZero_no(self):
     self.assertFalse(
         util.constantStrAllZero('\x00' * 37 + '\x01' + '\x00' * 19))
Example #5
0
 def test_constantStrAllZero_yes(self):
     self.assertTrue(util.constantStrAllZero('\x00' * 5446))
Example #6
0
 def test_constantStrAllZero(self, mock_cse):
     ret = util.constantStrAllZero('\x00')
     mock_cse.assert_called_once_with('\x00', '\x00')
     self.assertEqual(ret, 'ret')
Example #7
0
 def test_constantStrAllZero_no(self):
     self.assertFalse(util.constantStrAllZero('\x00'*37 + '\x01' + '\x00'*19))
Example #8
0
 def test_constantStrAllZero_yes(self):
     self.assertTrue(util.constantStrAllZero('\x00'*5446))
Example #9
0
 def test_constantStrAllZero(self, mock_cse):
     ret = util.constantStrAllZero('\x00')
     mock_cse.assert_called_once_with('\x00', '\x00')
     self.assertEqual(ret, 'ret')