Encryption and its bits. How to explain?

4

I have this table of encryption taken from a book, however I did not understand how it works.

  • Why is the number of alternative keys 2 raised to 32? Why does each bit fit 0 and 1?
  • Why is the number needed to decrypt the number of bits minus 1?
  • What would be 26 characters (permutation)
  • Something to add?

I need quick help, please answer my question.

Encryption and the time needed to decrypt them. source: (STALLINGS, 2008, p.21)

Source: STALLINGS, William. Cryptography and network security - principles and practices.

    
asked by anonymous 09.06.2015 / 19:53

2 answers

6

Why does each bit fit 0 and 1?

In the binary system, one bit ( bi nary digi ) can assume only two values.

They are being represented by 0 and 1, but this is just a convention. In some contexts they can be interpreted as logical values (true / false, yes / no), algebraic signals (+/-), on / off states, or any other attribute with two values, two values, because of the nature of the bi system.

Why the number of alternative keys is 2 raised to 32?

First, understand "alternative" as "possibility" (which is one of the definitions for this word in the dictionary, and it seems to me much more didactic).

The calculation of possibilities is approached in mathematics in the study of combinatorics. As the value of the bits can repeat in the key, it is a arrangement with repetition , which is given by:

  

n , where n is the total of elements and r is the number of elements chosen .

Since a bit can assume two values, there are two possibilities in that position of the key, therefore, two elements to be counted (n = 2) in the combination study. In a 32-bit key, there are 32 elements chosen: r = 32.

Therefore:

  • Possibilities in a 1 bit key: 2 1 = 2 (0, 1)
  • Possibilities in a 2-bit key: 2 2 = 4 (00, 01, 10, 11)
  • Possibilities in a 32-bit key: 2 32

Why is the number of attempts required 2 r-1 ?

Because 2 r-1 is half the number of possibilities 2 r . Since we can find the key in the first, last, or any attempt, we use the average number of attempts, which, rounding up, is half the possibilities. The ctgPi answer explains this in much more detail.

What would be the 26 characters (permutation)?

Instead of measuring the key in bits, as it did on the other lines, this time it measures in characters. To calculate the possibilities of 26-character keys (each character being any of the 26 letters of the alphabet), use n! , in this case, 26! . This is a simple permutation .

    
10.06.2015 / 00:52
6

Answering the question of why the number of attempts to decrypt is half the number of possibilities, suppose you assemble a giant deck, where one decryption key is written on one side of each card, and the other is written "Yes" or "no" depending on whether the key is the right key or not.

If you have N cards and you know that the opponent has chosen the key fairly randomly, the winning card will have equal probability in each of the N positions (i.e. 1 / N). If you number cards from the top to bottom of the deck from 1 to N, the number of attempts you have to make to find the right key is the number of that card: if the key is the 17th card in the pack, you will make 17 attempts until you find the right key.

But we do not know what the right letter is; we want to know what the average number of attempts we have to make to find the right letter. With probability 1 / N this number is 1 (when the right key is the first card in the pack); with probability 1 / N this number is 2 (when the right key is the second card in the deck); ...; with probability 1 / N this number is N (when the right key is the last card in the pack).

So the average number of attempts you have to make is

  1/N * 1 + 1/N * 2 + 1/N * 3 + … + 1/N * (N-1) + 1/N * N =
= 1/N (1 + 2 + 3 + … + (N-1) + N) =
= 1/N * N * (N+1) / 2 =
= (N+1) / 2

For these algorithms that we are talking about, N is huge; this +1 is one in billions. So it is a very good approximation to say that the average number of attempts is N / 2.

The whole discussion above assumes that the password is indeed random, but the fact is that in practice things do not work that way - people choose birthday dates, phone numbers, ... as passwords.

To help protect users in these cases, it's popular to use a key stretching function , such as bcrypt , scrypt or PBKDF2: these functions are complicated hash functions (like any hash function) and faces (unlike MD5 and SHA - *).

The idea is that you generate a random string s and use f(s, x) to encrypt the file (where x is the password that the user will decorate); you save% with% open, along with the encrypted file. The idea is that if you know eg that the user has chosen s as an eight-digit number, if you encrypt the file naively, your opponent only needs to make, on average, 5 * 10 ^ 7 decrypts to open the file your file.

When you have a key stretching function , you place your opponent against the wall: calculating x is very costly; he continues to open his file after 5 * 10 ^ 7 attempts, but each of these attempts is much more costly (usually this cost is adjustable, but for "civil" applications the crowd usually adjusts to f(s, x) to take a second to be calculated on a modern computer).

The other option is to ignore the existence of f(s, x) and try to find the encryption key directly, but this is impractical if you are using an algorithm with a 128-bit key, for example .

    
10.06.2015 / 04:22