Skip to content

Commit

Permalink
* move pycrypto version info gathering to protocol
Browse files Browse the repository at this point in the history
* show it in session info

git-svn-id: https://xpra.org/svn/Xpra/trunk@4511 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 16, 2013
1 parent 275e2e1 commit e74e6d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
19 changes: 14 additions & 5 deletions src/xpra/client/gtk_base/session_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from xpra.scripts.config import python_platform
from xpra.log import Logger
from xpra.gtk_common.gtk_util import add_close_accel, label, title_box, set_tooltip_text, TableBuilder, imagebutton
from xpra.net.protocol import get_network_caps
log = Logger()

N_SAMPLES = 20 #how many sample points to show on the graphs
Expand Down Expand Up @@ -618,11 +619,19 @@ def set_sound_info(label, details, supported, prop):
compression_str = " + ".join([x for x in ("zcompress", "lz4", "bencode", "rencode") if protocol_state.get(x, False)==True])
compression_str += ", level %s" % level
self.compression_label.set_text(compression_str)
suffix = ""
if c.info.lower()=="ssh":
suffix = " (%s)" % c.info
self.input_encryption_label.set_text((p.cipher_in_name or "None")+suffix)
self.output_encryption_label.set_text((p.cipher_out_name or "None")+suffix)

def enclabel(label, cipher):
if not cipher:
info = "None"
else:
info = str(cipher)
if c.info.lower()=="ssh":
info += " (%s)" % c.info
if get_network_caps().get("pycrypto.fastmath", False):
info += " (fastmath available)"
label.set_text(info)
enclabel(self.input_encryption_label, p.cipher_in_name)
enclabel(self.output_encryption_label, p.cipher_out_name)
return True


Expand Down
22 changes: 20 additions & 2 deletions src/xpra/net/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
from xpra.net.bencode import bencode, bdecode
from xpra.simple_stats import std_unit, std_unit_dec

try:
from Crypto.Cipher import AES
from Crypto.Protocol.KDF import PBKDF2
except Exception, e:
AES = None
PBKDF2 = None
debug("pycrypto is missing: %s", e)


from zlib import compress, decompress, decompressobj
try:
Expand Down Expand Up @@ -114,6 +122,17 @@ def get_network_caps():
"rencode" : use_rencode,
"lz4" : use_lz4,
}
try:
import Crypto
caps["pycrypto.version"] = Crypto.__version__
try:
from Crypto.PublicKey import _fastmath
except:
_fastmath = None
caps["pycrypto.fastmath"] = _fastmath is not None
except:
pass

if has_rencode:
caps["rencode.version"] = rencode_version
return caps
Expand Down Expand Up @@ -249,8 +268,7 @@ def get_cipher(self, ciphername, iv, password, key_salt, iterations):
assert iterations>=100
assert ciphername=="AES"
assert password and iv
from Crypto.Cipher import AES
from Crypto.Protocol.KDF import PBKDF2
assert (AES and PBKDF2), "pycrypto is missing!"
#stretch the password:
block_size = 32 #fixme: can we derive this?
secret = PBKDF2(password, key_salt, dkLen=block_size, count=iterations)
Expand Down
5 changes: 0 additions & 5 deletions src/xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ def get_server_info(prefix=""):
info[prefix+x] = getattr(os, "get%s" % x)()
except:
pass
try:
import Crypto
info[prefix+"pycrypto.version"] = Crypto.__version__
except:
pass
info.update(get_platform_info(prefix))
add_version_info(info, prefix)
return info
Expand Down

0 comments on commit e74e6d7

Please sign in to comment.