[tor-commits] [flashproxy/master] Encode to UTF-8 before encryption.

dcf at torproject.org dcf at torproject.org
Fri Sep 28 06:11:19 UTC 2012


commit d97e41a5baf4874f19bcd7a9f69a35cfc14ae102
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Sep 19 13:58:19 2012 -0700

    Encode to UTF-8 before encryption.
    
    Otherwise the M2Crypto encryption seems to expand each character to 4
    bytes; i.e., u"client" becomes
    "c\x00\x00\x00l\x00\x00\x00i\x00\x00\x00e\x00\x00\x00n\x00\x00\x00t\x00\x00\x00"
    after decryption.
---
 flashproxy-reg-email |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/flashproxy-reg-email b/flashproxy-reg-email
index babcc85..debe16d 100755
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@ -238,7 +238,7 @@ try:
             spec = "[" + spec + "]"
         options.remote_addr = parse_addr_spec(spec, *options.remote_addr)
 
-    body_plain = "client=%s" % format_addr(options.remote_addr)
+    body_plain = (u"client=%s" % format_addr(options.remote_addr)).encode("utf-8")
     rsa = RSA.load_pub_key_bio(BIO.MemoryBuffer(FACILITATOR_PUBKEY_PEM))
     body_crypt = rsa.public_encrypt(body_plain, RSA.pkcs1_oaep_padding)
     body = body_crypt.encode("base64")





More information about the tor-commits mailing list