def getSharedSecret(self, composite): """Return a shared secret. @param composite: Public key of the other party. @type composite: Union[six.integer_types] @rtype: Union[six.integer_types] """ warnings.warn("Method 'getSharedSecret' is deprecated in favor of '_get_shared_secret'.", DeprecationWarning) return cryptutil.bytes_to_int(self._get_shared_secret(composite))
def getSharedSecret(self, composite): """Return a shared secret. @param composite: Public key of the other party. @type composite: Union[six.integer_types] @rtype: Union[six.integer_types] """ warnings.warn( "Method 'getSharedSecret' is deprecated in favor of 'get_shared_secret'.", DeprecationWarning) return cryptutil.bytes_to_int(self.get_shared_secret(composite))
def test_getSharedSecret(self): # Test the deprecated method consumer_dh = DiffieHellman.fromDefaults() self.setup_keys(consumer_dh, self.consumer_public_key, self.consumer_private_key) warning_msg = "Method 'getSharedSecret' is deprecated in favor of 'get_shared_secret'." with ShouldWarn(DeprecationWarning(warning_msg)): warnings.simplefilter('always') self.assertEqual( consumer_dh.getSharedSecret(self.server_public_key), bytes_to_int(self.shared_secret))
def test_conversions(self): for string, number in self.cases: self.assertEqual(cryptutil.bytes_to_int(string), number) self.assertEqual(cryptutil.int_to_bytes(number), string)