Beispiel #1
0
def open_session(bus):
    """Returns a new Secret Service session."""
    service_obj = bus_get_object(bus, SECRETS, SS_PATH)
    service_iface = dbus.Interface(service_obj, SS_PREFIX + 'Service')
    session = Session()
    try:
        output, result = service_iface.OpenSession(
            ALGORITHM_DH,
            dbus.ByteArray(long_to_bytes(session.my_public_key)),
            signature='sv')
    except dbus.exceptions.DBusException as e:
        if e.get_dbus_name() != DBUS_NOT_SUPPORTED:
            raise
        output, result = service_iface.OpenSession(ALGORITHM_PLAIN,
                                                   '',
                                                   signature='sv')
        session.encrypted = False
    else:
        session.set_server_public_key(bytes_to_long(output))
    session.object_path = result
    return session
Beispiel #2
0
def open_session(bus):
	"""Returns a new Secret Service session."""
	service_obj = bus_get_object(bus, SECRETS, SS_PATH)
	service_iface = dbus.Interface(service_obj, SS_PREFIX+'Service')
	session = Session()
	try:
		output, result = service_iface.OpenSession(
			ALGORITHM_DH,
			dbus.ByteArray(long_to_bytes(session.my_public_key)),
			signature='sv'
		)
	except dbus.exceptions.DBusException as e:
		if e.get_dbus_name() != DBUS_NOT_SUPPORTED:
			raise
		output, result = service_iface.OpenSession(
			ALGORITHM_PLAIN,
			'',
			signature='sv'
		)
		session.encrypted = False
	else:
		session.set_server_public_key(bytes_to_long(output))
	session.object_path = result
	return session
Beispiel #3
0
	def test_array_to_long(self):
		self.assertEqual(bytes_to_long([1] + [0] * 8), 1 << 64)
		self.assertEqual(bytes_to_long(bytearray([1] + [0] * 8)), 1 << 64)
Beispiel #4
0
	def test_bytes_to_long(self):
		self.assertEqual(bytes_to_long(b'\x01'), 1)
		self.assertEqual(bytes_to_long(b'\x01\x02'), 258)
		self.assertEqual(bytes_to_long(b'\x01' + b'\x00' * 8), 1 << 64)