Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: crypto with core modules only

by haukex (Archbishop)
on Aug 31, 2018 at 14:04 UTC ( [id://1221452]=note: print w/replies, xml ) Need Help??


in reply to Re^3: crypto with core modules only
in thread crypto with core modules only

more update: flipping half the bits with xor is analytically breakable for repeated use on same document where changes are small. modulo solution does not have same weakness.

... but both you and tobyink were discussing a one-time pad. AFAIK, repetition is a common way to break encryption schemes and it's a substantial part of how the Enigma machine was broken. Although I'm not an expert and open to being proven wrong, I'd be willing to bet the modulo solution is breakable in a similar way to XOR if the pad is re-used.

Replies are listed 'Best First'.
Re^5: crypto with core modules only
by marto (Cardinal) on Aug 31, 2018 at 14:07 UTC
      This is about using the same key on multiple messages. In these ancient times, one machine had to issue keys to users independently of these users then needing them to encrypt something. An organisational problem rather than a problem of the algorithm. Today it is simple enough that the program encrypts and generates the key in one run. Although as we can see from the amount of confusion in this thread -- even intelligent people have difficulty understanding what is breakable or not and why. My impression is that the OTP had a bad rep. from these incidents. Even more confusing for many is of course: why the more recent use of number theory (modulo) in also public key encryption as opposed to using XOR? I have tried to explain it from my own perspective because I can find no similar explanations online - just more confusing posts in other sites. In one case I saw a lengthy answer to this very question on stack-exchange that failed to even try to actually answer the question but waffled about what was popular with cryptographers instead.
Re^5: crypto with core modules only
by tobyink (Canon) on Sep 02, 2018 at 15:51 UTC

    I haven't fully figured out a proof, but my intuition is that the following statement is true:

    Encrypting each byte with modulo arithmetic is secure if and only if encrypting each byte with xor is secure.

    They're both plaintext byte + key byte → cyphertext byte mappings such that if you know any two of the bytes, the third can be calculated deterministically with no outside factors. I'm pretty sure that any algorithms where that is true are essentially equivalent from a security standpoint.

    Xor is just fast and trivially easy to implement in Perl.

    Encode (plaintext is the string "txt" and key is the string "key"):

    $ perl -MMIME::Base64=encode_base64 -E'say encode_base64(shift^shift)' + txt key Hx0N

    Decode: (cyphertext is "Hx0N" and the key is still the string "key")

    $ perl -MMIME::Base64=decode_base64 -E'say decode_base64(shift)^shift' + Hx0N key txt
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1221452]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found