Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'key.': 0.07; 'bytes,': 0.09; 'cipher': 0.09; 'craft': 0.09; 'substitution': 0.09; 'cc:addr:python-list': 0.10; '(but': 0.15; 'thu,': 0.15; 'ciphers': 0.16; 'cleartext': 0.16; 'different,': 0.16; 'executed,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'symmetric': 0.16; 'wrote:': 0.16; 'bytes': 0.18; 'input': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'produces': 0.22; 'suppose': 0.22; 'bit': 0.23; '2015': 0.23; 'unlike': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; "i'm": 0.29; 'key,': 0.29; 'pile': 0.29; 'that.': 0.30; 'maybe': 0.31; "can't": 0.32; 'anyone': 0.32; 'getting': 0.33; 'point': 0.33; 'though.': 0.33; 'file': 0.34; 'received:google.com': 0.34; 'that,': 0.34; 'wrong': 0.35; 'could': 0.35; 'propose': 0.35; 'something': 0.35; "isn't": 0.35; 'but': 0.36; 'being': 0.36; 'subject:: ': 0.37; 'desired': 0.37; 'starting': 0.38; 'someone': 0.38; 'pm,': 0.39; 'submit': 0.39; 'your': 0.60; 'back': 0.61; 'behavior': 0.61; 'is.': 0.63; 'safe': 0.63; 'encrypted': 0.66; 'subject:Data': 0.66; 'aiui': 0.84; 'chrisa': 0.84; 'one;': 0.84; 'stronger.': 0.84; 'to:none': 0.90 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=LggIU3w5uWhcG4Cj/1lfV15s7X9rGuDdTCwHb6dSiNs=; b=VpPsXXOVp9TBK8JYMHuTCRiCFluzMvLpc5w2QyR+q7pS7Sa2C7RD5jn1tDhilrjRry kii7EA1orkNnNb2h9y+RonZ8ieNiI7JciE824IigPpLSb2Qg+MwMwhN5+CyrW4ORGpa2 Ux5qzsTPWun6d6DHObvoGm3dU7RATDWGrtmhu2sQT7XH9tVV/2APQyRN4X86hz67m2SE 8TCW7dMijKVfkFoINhLir9+Fv6Olbbaqafbz4RtfewB3ZuVkDdiw6WKVJ8yIV1HRm/gt Zb0zYDM/MJSYDtFWnvKmf4A4VkUsQw8fnSZ/CR7pQSCOUWyi5WUa2XW/aKMKV9F+OvRi yqCg== MIME-Version: 1.0 X-Received: by 10.50.2.3 with SMTP id 3mr2957512igq.34.1435226240882; Thu, 25 Jun 2015 02:57:20 -0700 (PDT) In-Reply-To: References: <558b7e85$0$1648$c3e8da3$5496439d@news.astraweb.com> <558bc912$0$2899$c3e8da3$76491128@news.astraweb.com> Date: Thu, 25 Jun 2015 19:57:20 +1000 Subject: Re: Pure Python Data Mangling or Encrypting From: Chris Angelico Cc: "comp.lang.python" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435226250 news.xs4all.nl 2968 [2001:888:2000:d::a6]:35163 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:93126 On Thu, Jun 25, 2015 at 7:41 PM, Devin Jeanpierre wrote: >> I know that the OP doesn't propose using ROT-13, but a classical >> substitution cipher isn't that much stronger. > > Yes, it is. It requires the attacker being able to see something about > the ciphertext, unlike ROT13. But it is reasonable to suppose that > maybe the attacker can trigger the file getting executed, at which > point maybe you can deduce from the behavior what the starting bytes > are...? > If a symmetric cipher is being used and the key is known, anyone can simply perform a decryption operation on the desired bytes, get back a pile of meaningless encrypted junk, and submit that. When it's encrypted with the same key, voila! The cleartext will reappear. Asymmetric ciphers are a bit different, though. AIUI you can't perform a decryption without the private key, whereas you can encrypt with only the public key. So you ought to be safe on that one; the only way someone could deliberately craft input that, when encrypted with your public key, produces a specific set of bytes, would be to brute-force it. (But I might be wrong on that. I'm no crypto expert.) ChrisA