summaryrefslogtreecommitdiff
path: root/paramiko/ber.py
diff options
context:
space:
mode:
authorScott Maxwell <scott@codecobblers.com>2013-10-30 17:09:34 -0700
committerScott Maxwell <scott@codecobblers.com>2013-10-30 17:09:34 -0700
commit0e4ce3762a5b25c5d3eb89335495d3bb9054e3e7 (patch)
treea77bfec4e3a29e9827d4e75de932e34947536181 /paramiko/ber.py
parent339d73cc13765bea4dd5b683ca14b02c9baa589f (diff)
downloadparamiko-0e4ce3762a5b25c5d3eb89335495d3bb9054e3e7.tar.gz
Fix message sending
Create constants for byte messages, implement asbytes so many methods can take Message and key objects directly and split get_string into get_text and get_binary. Also, change int handling to use mpint with a flag whenever the int is greater than 32 bits.
Diffstat (limited to 'paramiko/ber.py')
-rw-r--r--paramiko/ber.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/paramiko/ber.py b/paramiko/ber.py
index f3b4b37e..45372fc4 100644
--- a/paramiko/ber.py
+++ b/paramiko/ber.py
@@ -30,13 +30,16 @@ class BER(object):
Robey's tiny little attempt at a BER decoder.
"""
- def __init__(self, content=''):
- self.content = content
+ def __init__(self, content=bytes()):
+ self.content = b(content)
self.idx = 0
- def __str__(self):
+ def asbytes(self):
return self.content
+ def __str__(self):
+ return self.asbytes()
+
def __repr__(self):
return 'BER(\'' + repr(self.content) + '\')'
@@ -126,5 +129,5 @@ class BER(object):
b = BER()
for item in data:
b.encode(item)
- return str(b)
+ return b.asbytes()
encode_sequence = staticmethod(encode_sequence)