Friday, January 5, 2018

CyberSecurity: Cryptography

The term cryptography has its Greek roots in two words: kryptos, which means hidden; and graphein, which means to write. The Merriam-Webster Dictionary defines cryptography as the process of writing or reading secret messages or codes. And it's been expanded into the practice and study of techniques of secret code. Cryptanalysis, another related term, refers to the analysis and cracking of codes through weaknesses or other means. Cryptology, yet another term, is used by some as a synonym for cryptography. Others define it as the study of coding and patterns, basically making it an umbrella term for cryptography and cryptanalysis. Let's use a term that comes up a lot today in computing, which puts the previous terms into action: Encryption. It comes from the terms en, to make; and crypt, hidden. When do we use encryption? When we're turning on our cell phones. When you check your email or you do anything online that requires you to log in. When you're using secure Wi-Fi. When you use your debit cards and credit cards. When you're driving with your E-ZPass. Of course, there are many more examples, including when your computer is not in use, protecting the files on your laptop should it get into the wrong hands. In other words, we really use encryption all the time. We use encryption to protect the confidentiality of our sensitive data while it's being transmitted and stored. If someone should see our unencrypted data, they'll be able to understand it. If someone should see our encrypted data, they will not be able to understand it. What's involved? Plaintext -- anything in its original bit stream: Images, sounds, or any other type of file in your machine. Algorithm or cipher, a mathematical function that converts the plaintext into jumbled output known as ciphertext. Ciphertext, the result -- the jumbled message that, while it can be read, can't be understood. And the key, a string of ones and zeros used as an input to the algorithm in addition to the plaintext. An algorithm by itself is not sufficient. What this would look like is plaintext fed into an algorithm, producing ciphertext as the output. Algorithms are well-known and are never secret, as we'll discuss shortly. What's to stop anyone from simply putting the ciphertext back into the algorithm to produce the original plaintext? Nothing, of course. The secrecy, the confidentiality lies in the key -- another input to the algorithm besides the plaintext. Now there are two inputs to the algorithm: The plaintext and the key. Out pops the ciphertext again; however, without the key needed for decryption, one can't simply feed the ciphertext back into the algorithm to produce the plaintext. The secrecy, the confidentiality lies with the key. Algorithms are well-known, and they are never secret; keys are guarded and kept secret. Confidentiality depends fully on the key.

Confidentiality is based on the secrecy of a key, not an algorithm.

 >> Kerckhoff's principle believes only secrecy of the key provides security. Shannon's maxim states the enemy knows the system. It's very hard to keep the details of a popular algorithm secret. Thinking you're achieving security like this is called security through obscurity. It's when you rely on the secrecy of the design and the implementation of a system as your security. There could be many vulnerabilities in such a system, but if no one knows about a system or its flaws, according to security through obscurity, attacks can be prevented. Sounds like an ostrich sticking his head in the sand. To really make a robust encryption algorithm, you've got to throw it out into the public and let lots of cryptographers to try to find flaws. Keeping it secret and doing all that work yourself is not the same. Now, by pure logic, if the only way to make an algorithm secure is to let people poke and prod at it, it can't be secret. What if the algorithm was compromised? Every single location the algorithm was implemented would need to be changed. That's hard to do. It's easier to replace a key than an algorithm. So if you suspect that a key is compromised, you can just select a different key. In fact, you can even switch keys over specific time intervals to limit the impact of any potential leak. Switching encryption algorithms every year, on the other hand, is not as practical.

the differences between symmetric and asymmetric encryption and the tradeoffs they have in speed, scalability, and security. We'll also see examples of common encryption algorithms.
 >> Encryption comes in two forms, as do the keys. Symmetric encryption uses one key, the same key for encrypting and decrypting. It's very fast, but there's a key distribution security problem: How do you distribute a secure key over an insecure medium? If a man in the middle gets the key as it's transmitted, that person can use it to decrypt and maybe even change and re-encrypt the messages that flow between two parties. One might think an out of band method by calling someone with the key or emailing it would address the issue, but that's not scalable. Older symmetric encryption algorithms include DES, 3DES, and RC4. Advanced Encryption Standard, AES, is the government-adopted and worldwide symmetric encryption algorithm used today. Asymmetric encryption uses two keys, one called a public key, the other one called a private key. There's no key distribution security problem, but asymmetric encryption is much slower than symmetric encryption. When you encrypt with the public key, the ciphertext can only be decrypted with the private key. When you encrypt with a private key, the ciphertext can only be decrypted with the public key. We'll see examples of each in a little bit. RSA -- named after its inventors Rivest, Shamir, and Adleman -- is the most widely used asymmetric encryption algorithm. It's used for SSL/TLS -- secure sockets layer/transport layer security -- for protecting information you transmit and receive over the Internet, for instance, when you do your online banking or simply log into a website.

Hashing algorithms are one-way mathematical functions that transform data. Hashing guarantees the integrity of data that has been transmitted or stored.

 >> Hashing has to do with integrity. Integrity that messages that are sent are the messages that are received. Hashing makes sure no bits have been changed either accidentally or maliciously in transit. Hashing algorithms have a few characteristics. Variable-length input, fixed-length output. You could see the Declaration of Independence into a hashing algorithm or just your name. In each case, you'll wind up with the same sized output hash, also called a message digest. If one bit in the input changes, the resultant hash is completely different. You can't go back. Let's say you take a banana, some strawberries, milk, vanilla syrup, and more and put it in a blender. While enjoying your smoothie, you think to yourself, I wish I could have that banana back. Sorry, you can't get the banana back. You might know the process of taking a banana out of a smoothie and reconstructing it, but it doesn't mean that it could be done. Quick, think of two numbers that multiply together to get 100, 25 times 4, 50 times 2, 20 times 5, 10 times 10. Well I was actually thinking of 100 times 1. You don't know what two numbers I picked and subsequently threw away. Hashing involves doing some calculations and throwing away the inputs, doing some more math, throwing away more inputs in the same process. Hashes are called one-way functions because it's not feasible to try all possible combinations in a realistic amount of time to go back the other way. While it might be easy to go through old numbers that multiply together to get a hundred when multiple rounds are used and one output is at the end, how can you go back, trying all possible combinations. Let's say I multiply that 100 by 8. Now we've got 800, and now you have two rounds of inputs to get back to the original factors of 100. Besides. I'm only using multiplication. Hashing algorithms of course are much more mathematically intensive. If you've ever downloaded a file from the internet, you might have seen its hash next to the link you clicked. If you run your downloaded file through the same hashing algorithm and get the same message digest, you know that you got the file intact and that no bits were changed accidentally or maliciously in transit. Hashing is also used to protect the confidentiality of password databases from both systems administrators with prying eyes and hackers, who steal password databases. Passwords should always be stored in hashed format. This means someone who looks at or steals a password database will see the password hashes instead of the plain text passwords. When you log into a local machine or remote machine, you enter your password, which is subsequently hashed and compared to the store hash on the authenticating system. The same thing happens when you enter your pin at the ATM. Recent data breaches have brought to light the fact that some entities were storing passwords in plain text. A security 101 no, no. Yes. Storing the hashes provides confidentiality of the passwords compared to storing the plain text versions. Yes, hashes are the outputs of one-way functions and can't be reversed into their original plain text versions. However, stolen password hashes can be attacked to derive the plain text passwords by multiple methods including a brute force attack, a dictionary-based attack, and an attack involving a rainbow table. We'll explore these methods in a future course. We'll also explore salt, which defeats attacks using precomputed dictionaries and rainbow tables. The weakness of a hashing algorithm or when a hashing algorithm should be retired is when it becomes easy to find multiple inputs that produce the same outpatient message digest. This has been the case for both MD5 and more recently SHA-1. SHA-256 is the hashing algorithm in great usage today. The output of 256 bits, which is why this version of SHA-2 is called SHA-256 makes it more secure. SHA-1 by comparison just used 160 bits.

A Certificate Authority (or CA) is an organization that issues digital certificates. They are trusted third-parties by both websites and customers.

 >> A certificate authority or CA is a corporation that issues digital certificates. An individual doing banking online would surely want to use encryption. That person certainly doesn't want his or her identity stolen. An organization like Citibank wants to use encryption, too. Their motivation is more along the lines of not wanting to get sued. Citibank will look to a CA to be their digital notary public. A CA is a trusted third party. Both Citibank and its customers need to trust CA for the system to work. Symantec, Comodo, and GoDaddy are the top three certificate authorities today. First, the CA makes sure that the company is legit. Because if the CA authenticates a company that proves to be nefarious, the CA's reputation is at stake. In our story, Citibank gives the CA their public key but keeps their private key secret. The CA constructs a digital certificate, signs it, and gives it to Citibank to put in the root of their web server. When a customer goes to the bank's website, Citibank presents this digital certificate to the customer.

No comments:

Post a Comment