tag:ericfay.me,2014:/feedEric Fay2014-01-23T19:50:15-08:00Eric Fayhttp://ericfay.meSvbtle.comtag:ericfay.me,2014:Post/tales-from-the-cryptography-the-terrifying-math-explained-part-12014-01-23T19:50:15-08:002014-01-23T19:50:15-08:00Tales from the Cryptography: The Terrifying Math Explained - Part 1<p>Most <a href="http://en.wikipedia.org/wiki/Public-key_cryptography" rel="nofollow">public key cryptosystems</a> are mathematically hard and hard on the eyes. If you visit some of the Wikipedia pages for these cryptosystems, your eyes may start to get sore from looking at the intense mathematical equations. In this multipart series of blog posts, I will go over some popular public key cryptosystems and present the hard mathematical problems behind them at an accessible level.</p>
<p>
First up is RSA. RSA is named after the designers of the algorithm: Ron Rivest, Adi Shamir and Leonard Adleman. First published in 1977, the trio’s system is still widely in use to this day. RSA consists of three phases: key generation, encryption, and decryption. In the key generation phase, the public and private keys are created. The encryption phase takes in a plaintext message, uses the recipient’s public key, and returns a <a href="http://en.wikipedia.org/wiki/Ciphertext" rel="nofollow">cipher text</a>. The decryption phase takes in a cipher text, uses the recipient’s private key, and returns a plain text message. Each of these phases revolves around rigorous mathematical problems.</p>
<h2>Key Generation</h2>
<p>
For the purpose of this example, our public key will consist of two values (N and E). Our private key will also consist of two values (N and D). The first step of the key generation phase is to pick two different prime numbers. In our running example, we will choose the values:</p>
<p>P=11 and Q = 17<br>
The next step is to calculate N - which is simply just the product of P*Q.<br>
N=P*Q<br>
N = 11*17 = 187<br>
We must then calculate Euler’s totient function (φ) for N. Put more clearly, find the product of (P-1)*(Q-1).<br>
φ(N) = (P − 1)(Q − 1)<br>
φ(N) = (11 − 1)(17 − 1)<br>
φ(N) = 160<br>
</p>
<p>To choose E, we must pick an integer such that 1 < E < 160 that is coprime to 160. Meaning to pick E, we must satisfy two conditions. First, E must be greater than one but less than our φ(N) value (160). Secondly, E must also be coprime to 160. In order to be “coprime,” the greatest common divisor (gcd) of φ(N) and E must equal one. </p>
<p>Let’s try 23. It satisfies our first condition as 23 is greater than 1 and also less than 160. Let’s check the second condition. Since 1 is in fact the largest divisor common to 160 and 23, we have satisfied both conditions.</p>
<p>E = 23<br></p>
<p>The last value that we need to compute is D. D is the modular multiplicative inverse of E (mod φ(N)). Now I know that may have been a confusing sentence, so let me try to clarify. In order to compute D, we will have to find 23<sup>-1</sup> = D (mod 160) which is the same as 23D= 1 mod(160). Simply put, we must find a number (D) that when multiplied by 23 and modulus divided by 160 will have a remainder of 1. The most basic way to determine D is to iterate the value of D from 0 onward until our conditions are satisfied. There are more efficient ways of performing this calculation, see <a href="http://en.wikipedia.org/wiki/Modular_multiplicative_inverse#Extended_Euclidean_algorithm" rel="nofollow">Extended Euclidean algorithm</a>. In our case, 7 will satisfy these conditions.</p>
<p>D*23 (mod 160) = 1<br>
7 * 23 = 161<br>
161 mod 160 = 1<br>
D = 7<br></p>
<p>As a quick overview, we now have our public key (N and E) and our private key (N and D).<br> </p>
<h2>Encryption</h2>
<p>We have just completed the key generation phase. Now, we have all the components needed to encrypt and decrypt a message. The encryption and decryption used in RSA are performed by using modular exponentiations. A modular exponentiations takes the form below:<br></p>
<p>C = b<sup>e</sup> (mod n)<br></p>
<p>This function may sound/look intimidating at first, but it is a simple function at heart. Take an integer B and raise it to the E<sup>th</sup> power, then modulus divide by n. Back to our example, we will pick a plaintext message of 42 to encrypt. So we have M=42. The output of this step, C, will be our ciphertext. Our encryption function is just like the modular exponentiation example above. It will be in the form.</p>
<p>C = M<sup>E</sup> (mod n)<br>
We just need to substitute our values from the running example. This will give us.<br>
C = 42<sup>23</sup> (mod 187)<br>
C=168<br></p>
<h2>Decryption</h2>
<p>Now, if we want to decrypt this message, we will do another modular exponentiation in the form:<br></p>
<p>M = C<sup>D</sup> (mod n)<br>
Again, we just substitute our values. This will give us:<br>
M = 168<sup>7</sup> (mod 187)<br>
M= 42<br></p>
<p>And just like that we have our original message back. Pretty cool, right?<br></p>
<h2>Closing Remarks</h2>
<p>As I mentioned before, public key cryptosystems are centered around mathematically hard problems to provide security. The mathematically hard problem that RSA revolves around is large integer factorization. In RSA, the large integer is the public key N. It is very difficult to find the factors that multiply together to get the large integer unless you know the recipient’s private key. It is very important to note that in practice these numbers are much larger than in our example. It is very typical for key sizes to range from 1,024 to 4,096 bits in length, making for much larger calculations than our example. To show how hard this integer factorization problem is, the best known <a href="http://en.wikipedia.org/wiki/Cryptanalysis" rel="nofollow">cryptanalysis</a> of RSA occurred in 2009 when several researchers “factored a 232-digit number (768 bit length), utilizing hundreds of machines over a span of 2 years” [1]</p><p>
Any suggestions, questions or corrections, leave a comment below. Also, if you feel that I could have explained something more clearly, don’t hesitate to let me know.</p>
<hr><p>
Works Cited
[1] Kleinjung, et al (2010-02-18). <a href="http://eprint.iacr.org/2010/006.pdf" rel="nofollow">Factorization of a 768-bit RSA modulus</a>
</p>
tag:ericfay.me,2014:Post/introduction-to-password-strength2014-01-14T19:57:23-08:002014-01-14T19:57:23-08:00Introduction to Password Strength<p>Between the vast number of services we log into and log out of every day, it’s often hard for us to remember that the strength of the passwords we use is a very important aspect of keeping passwords secure. </p>
<p>The strength of a password is typically determined by:</p>
<ul>
<li>length</li>
<li>avoidance of dictionary words</li>
<li>avoidance of relevant user information (first name, last name, birth date)</li>
<li>avoidance of common patterns</li>
<li>the combination of the following “character types”</li>
<ul>
<li>lowercase letters</li>
<li>uppercase letters</li>
<li>numbers</li>
<li>special characters</li>
</ul>
</ul>
<p>The mixture of different character types makes up what’s called the “keyspace”. The keyspace can be computed through the formula C<sup>N</sup>, C being the number of possible characters and N being the length of the password. To determine the keyspace of the “oh, so common” example, ‘password’, we would use the above formula C<sup>N</sup>. This example uses only lowercase letters which would bring the C in the formula to 26, i.e. the number of all possible lowercase letters [a-z]. The exponent N is simply the length of the password ‘password’ which in this case equals 8. For our example, the formula turns out to be <a href="http://www.wolframalpha.com/input/?i=26%5E8" rel="nofollow">26<sup>8</sup></a> or roughly 208 billion.</p>
<p>So this means that for an attacker to perform a brute force attack, i.e. trying every single possibility in the keyspace, they would need to try roughly 208 billion possibilities. At first glance you may be thinking, “Oh, that sounds like a pretty secure number to me.” But in reality, it really isn’t.</p>
<p>There are many advanced programs and techniques that are used to speed up the password cracking process including: GPU based cracking, rainbow table assisted cracking, cloud based cracking, and statistical pattern assisted cracking. Using GPU base cracking, a single <a href="http://www.amd.com/us/products/desktop/graphics/7000/7970/Pages/radeon-7970.aspx" rel="nofollow">AMD Radeon HD 7970</a> can reach speeds of up to 8.2 billion passwords per second. [1] If an attacker were to use the brute force method he or she would crack our example “password” in just less than 26 seconds.</p>
<p>Following the above guideline for password strength is paramount to keeping your passwords secure against the multitude of password cracking attacks. The length aspect of the password strength guideline has been explained when using the C<sup>N</sup> formula. Increasing password length increases the exponent in the keyspace formula, thus increasing the keyspace. Avoiding dictionary words when creating a password is another factor in keeping passwords secure. Following this aspect deters the threat of a <a href="http://en.wikipedia.org/wiki/Dictionary_attack" rel="nofollow"> Dictionary Attack</a> on your password. Using information about yourself in a password also makes the password insecure. Attackers may be able to glean information off of public mediums (Facebook, Google+, Twitter, etc.) or even possibly <a href="http://en.wikipedia.org/wiki/Social_engineering_(security)" rel="nofollow">social engineer</a> you into revealing some information they could potentially use to crack your password. There are specific password cracking programs that statistically analyze password dumps looking for common patterns. These programs then proceed to make use of these patterns when the cracking process begins, making the process much more efficient. Using a combination of different character types increases the keyspace of a password. The “password” example used only lower case letters makes the C in the C<sup>N</sup> formula 26. Using all of the character types brings this number up to 95. (26 from the lower case letters, 26 from the uppercase letters, 10 from the numbers and 33 from the special characters)</p>
<p>A few last notes about general password security before we end this discussion on password strength.</p>
<p>There is a seemingly age old argument of <a href="http://www.codinghorror.com/blog/2005/07/passwords-vs-pass-phrases.html" rel="nofollow">passwords vs. passphrases</a>. That is, use a long, easier to remember passphrase compared to a more compact, but difficult to remember password. An example of a passphrase can be the name of your favorite book, “So Long, and Thanks for All the Fish” which would have a keyspace of <a href="http://www.wolframalpha.com/input/?i=85%5E36" rel="nofollow">85<sup>36</sup></a> or roughly around 2 duovigintillion (I swear it’s a real thing). Whereas, an example of a password could be ‘xYaQxrz8!’, which would have a keyspace of <a href="http://www.wolframalpha.com/input/?i=95%5E9" rel="nofollow">95<sup>9</sup></a> or roughly 630 quadrillion. I’ll let you pick sides.</p>
<p>I stated earlier in this post that today we tend to need passwords for many services. One of the fastest ways to decrease your password security, regardless of a vast keyspace, is reusing passwords for different services. Unfortunately, if you reuse passwords and one of your services gets compromised, that service’s user/password database may get leaked. When this happens, you run the risk of someone using that password information to access your other services.</p>
<p>Thanks for taking the time to read, leave a comment below.</p>
<p></p><hr>
<p>Works Cited
Gibson, D. (2011). CompTIA Security+: Get Certified Get Ahead: SY0-301 Study Guide. CreateSpace Independent Publishing Platform.
Goodin, D. (2012, Aug 20). Why passwords have never been weaker and crackers have never been stronger. Retrieved from arstechnica: http://arstechnica.com/security/2012/08/passwords-under-assault/
</p>
tag:ericfay.me,2014:Post/hello-world2014-01-14T19:54:15-08:002014-01-14T19:54:15-08:00Hello World! Redux<p>This is my first post in quite some time. As you can see, the site looks a little bit different. I recently received an invitation to blog on Svbtle and thought since my site was aging that I’d give it a try. Hoping to post more regularly as this new year begins. I also plan on blogging more than just information security topics this year. Looking to break into some posts on information retrieval, search, big data and a few other topics. I’ll be posting up the old blog posts in case anyone is looking for them. I’m very excited to kick this new blog off, cya soon.</p>