Cryptography...

Status
Not open for further replies.

lobobo

Ars Scholae Palatinae
778
Hello all,

How secure can a homemade cryptographic method be? For example, if someone makes a method which takes in a string as input and outputs another string in which the letters have been shifted once to the next (A becomes B), this could be broken relatively easily...

...but what about methods that are a bit more complicated? Is there some kind of rule by which you can judge how effective homemade cyptographic methods are?
 
The sole exception being a one-time pad hooked to a true random number generator (think: normalized data from an actual physical Geiger counter & glowing rock).

The Code Book by Simon Singh covers the evolution of cryptography through history from a non-programming perspective. It covers why, exactly, making something up is difficult - because it discusses the flaws of each method as you go along.
 

Apteris

Ars Tribunus Angusticlavius
9,590
Subscriptor
lobobo":o6tchfha said:
Is there some kind of rule by which you can judge how effective homemade cyptographic methods are?
Yes. The rule is, how hard would it be for a smart modern day cryptographer with various amounts of money at his disposal to crack your encryption.

For home made encryption, the answer is generally "not".

But yeah, go ahead and write what you wish. Pick up a copy of Applied Cryptography by Schneier for solid information.

You've already thought about the Caesar cipher. For your next one, how about a cipher where letter one is displaced by one amount, letter two is displaced by a different amount, etc. No Googling! :)
 

lobobo

Ars Scholae Palatinae
778
You've already thought about the Caesar cipher. For your next one, how about a cipher where letter one is displaced by one amount, letter two is displaced by a different amount, etc. No Googling!
I've actually thought up a list of over a dozen crazy things to be done to a string to modify it. I was wondering how someone can reverse it as it seemed to be a bit much...
 
D

Deleted member 43669

Guest
Lots of seemingly strong cryptosystems have been proven to be weak.

The only thing you can say about how strong a crypto is, is that it hasn't been broken yet. You cannot really analyze a cryptographic algorithm and say this is grade-76 strong. You can only measure how much effort has gone into breaking it without succeeding, but even then, someone could come tomorrow and bring an innovative algorithm to break it, using something no-one has thought of yet. Yes, you could calculate how long would it take to bruteforce a key (and that being a long time is a requirement!), but that's only a single measure.

The standard advice is to pick up what's widely regarded as the strongest algorithm in whatever specialty you need (symmetric, asymmetric, etc.), follow all the recommendations about working with it securely and run with it. It's not difficult, and it will probably be much more than enough.

On the other hand, thinking about crypto is very fun, so don't stop doing that!
 

norton_I

Ars Tribunus Angusticlavius
6,172
Subscriptor++
Unfortunately, I don't know of any good books like applied cryptography that focus on cryptanalysis. However, _The Design of Rijndael_ describes the development process that led to the Rijndael cipher that became AES. Read it, and realize that you have to be at that level to usefully design a cipher. In short, there are some incredibly powerful code breaking techniques that can find weakness in absurdly complex codes. People who have been doing this their whole lives still make mistakes. Most widely used ciphers including AES have some discovered weakness that was not known at the time they became widespread. Usually this is of the form of an attack against a reduced number of rounds, or an attack that is only a slight or impractical improvement over a brute force key search.

So, the end of the story is that you should not design your own algorithms. Only under special circumstances should you implement a well-known algorithm. In general you should use the standard software engineering practice of using the highest level abstraction that is available to you--that dramatically reduces the likelihood that you will inappropriately use a (mostly) secure algorithm in an insecure fashion.
 
If you're sticking to "play" cryptology, there are some simple tests for how difficult it would be for someone to crack your code by hand.

The first level would be letter frequency. E is the most common letter, and that information alone can break simple substitutions in nothing flat. So the goal to prevent that is to make your encoded message have equal numbers of every symbol.

The second level is digraphs: "Th" is pretty darn common as "the", there are tables of digraph frequency, and so even after you've flattened your 'single letter occurance' pattern, you end up with patterns in the pairs of letter - so now eradicate that set of patterns.

And it continues to trigraphs: "and", "the", etc.

So, for a simple contest between friends or intellectual exercise, the goal is to have no discernable patterns in the encoded message. Every symbol that appears should be very close to the mean symbol appearance count. Every pair of symbols should be very close to the mean for every pair of symbols.

Similarly, every word should end up with a "flat" distribution in the encoded message. If you encoded "frog" forty-seven times, you should get roughly flat levels of each symbol, each digraph, and each trigraph.

But if you're just doing this for fun, look up "Playfair Cypher", it's obscure enough that your buddies won't know it at a glance, fast enough to actually perform by hand, and difficult enough that it takes real work to decypher (if you don't know the method in advance.)
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Assuming your looking at things sufficiently simple to do by hand a rather nice one, designed to be implementable by hand and with great means of destroying the private key (54 card pickup) is Solitaire. Also known as Pontifex in thanks to the name used in the book it was developed for.

There are some good tools available to test the output for obvious flaws, as already mentioned the result should be indistinguishable from a (good) random number generator's output so the battery of statistical tests to check them can be applied.

These will only test for obvious ones though, and if you are only using them you will eventually hit on the idea of just using a pseudo random number generator and xoring the stream with that. Care must be taken here because there are many pitfalls that the tests above will not pick up which are immediately obvious to a crypto expert.

I whole heartedly agree that you should read Simon Singh's book. I found it an absorbing introduction to the subject from a historical perspective.
 

Apteris

Ars Tribunus Angusticlavius
9,590
Subscriptor
DrPizza":zlmj5b38 said:
Even implementing a pre-existing algorithm correctly (i.e. so that you do not accidentally weaken it through e.g. timing attacks) is hard work.
Ah yes, this point wasn't made explicitly. OP: you will often read, on the Internet and elsewhere, how you shouldn't write your own crypto. This doesn't mean you shouldn't study it--most people will agree that some knowledge of cryptography is essential, and you won't really understand how a cipher works until you program it yourself.

What you are supposed to avoid is writing your own cryptography when in a commercial setting. When you work for a software firm, there should be no reason for you to implement encryption by yourself, because people with more experience than you (or me, or 99% of all programmers really) have already spent more time than will be available to you on implementing encryption in virtually every language you care about.

aes_act_3_scene_02_agreement_576.png
 

Bryophyte

Wise, Aged Ars Veteran
188
My applied cryptography professor told the class many times, "If you're thinking about implementing your own cryptosystem, stop and use AES." Now obviously AES is not the right tool for all security jobs, and he said similar things about established cryptographic hash functions etc.

The point is, don't do it. It's a waste of time to reinvent that particular wheel and potentially a costly mistake.
 

pyu

Ars Praefectus
5,108
Subscriptor
If you plan to do it just for fun, go ahead. I think everyone has done rot13 once. (Yes, rot13 is a cipher, admittedly somewhat simplistic example since no one uses it for real security anymore.)

If you doing it for something at work, consult management or the senior tech lead. If security is a concern, there should be guidelines in place. Usually encryption is part of the whole package.
 

drogin

Ars Tribunus Angusticlavius
8,283
Subscriptor++
I have an interesting tale about fake cryptographers and how easy it is to break someone's "cipher" when they try and be tricky.

I was a lowly undergrad working at a materials science research facility at the Air Force Research Labs. We were developing some structural analysis code and thought, "Hey! It would be great if we could use some already existing material databases in our code so we don't have to generate them ourselves!"

So, we got a couple from various sources and merged them up. There was one hold-out. NASA. They had a competing tool and didn't want to share their materials database. Eventually, they ran out of excuses and were forced to hand it over.

My boss came in one morning with a CD-ROM and was pissed because he couldn't read the text files on it. Turns out the people as NASA had turned over the files, but they appeared to be gibberish. We compared them to the files that their code installed and realized that they were the same. Therefore the files were just in some alien format that their code knew about.

My boss asked me to see if we could extract the information as the dicks at NASA kept up their story that they complied with the request to the letter.

So, my first thought was: "Is this file just compressed?". I ran it through a couple of archive tools and couldn't find a commonly used format that would read the files.

Next, I thought: "Shit. It's encrypted...".

So, having just read through some of Applied Cryptography I started hacking together some code. I wrote a simple program to read in the file and then and tell me how often each byte was being used.

I took the output of the program and looked at it for about an hour. Eventually I noticed there were some very high counts all clustered together (i.e. lots of repetition). So, I thought about the problem logically using what I knew about the file. What would be in there? Well, it was scientific data about materials so I concluded the most common characters would be numbers, commas, periods, e, and a few more characters.

So, I took out a chart that showed the ASCII character set and compared it to my program's output. It took a while, but I noticed that the cluster lined up with some of my assumed common characters...except backwards. On slightly more than a hunch I wrote a program that shifted each byte by it's opposite on the ASCII character table.

Two things happened:

1. The true contents of the file appeared.
2. I got a chubby.

The moral of the story is that even really smart people can't make good crypto, because they think that crypto is about being tricky. It isn't. It is about being mathematically difficult to reverse and computationally expensive. Hopefully so expensive that it would take alien technology to process the algorithm.
 
Status
Not open for further replies.