コード例 #1
0
ファイル: util.py プロジェクト: pombreda/dist-packages
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
コード例 #2
0
ファイル: util.py プロジェクト: hwchen/secretstorage
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
コード例 #3
0
ファイル: test_dhcrypto.py プロジェクト: hwchen/secretstorage
	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)
コード例 #4
0
ファイル: test_dhcrypto.py プロジェクト: hwchen/secretstorage
	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)