How to Protect the Confidentiality of a Message
The article explains how easy it is to encrypt data with the exponential function and how difficult it is to decrypt it with the logarithmic function. Cryptography aims to:
Make it easy for us to both encrypt and decrypt.
And for our attackers to make it difficult.
Modular arithmetic
The best way to introduce modular arithmetic is to think of a clock. The numbers go from 1 to 12, but when it gets to "13 o'clock", it is 1 o'clock:
If we call the space from 1 to 12 Modulus with length n = 12, we can write:
13 ≡1 module 12
“13 hours are equivalent to 1 modulo 12”
25 ≡1 mod 12
“The 25 hours are equivalent to 1 module 12”
14≡ 2 modulus 12
“The 14 hours are equivalent to the 2 modulo 12”
Definition of the modular format: D ≡ R modulo n; where:
D, R, n belong to integers.
R (Remainder), is less than n, and results from dividing D/n.
Example1: Determine the value of R in:
40 ≡ R modulus 17
Step 1: Split 40/17
Step 2: Select the remainder R = 6
Step 3: Write in modular format: 40 ≡ 6 mod 17
Step 4: The result reads “40 equals 6 in modulo 17”
Example 2: Determine the value of R in:
83 ≡ R modulus 51
Step 1: Split 83/51
Step 2: Select the remainder R = 32
Step 3: write in modular format: 83 ≡ 32 mod 51
Step 4: The result reads “83 equals 32 in modulo 51”
Exponential operation in modular format
Definition of the exponential function Y = bX, where b= base and X= exponent. In modular format it would be:
Y = bX modulo n.
If Y = C, b=m, X=e we will have the modular format:
C= me mod n.
Where C must be less than n, and C = is the remainder of dividing me/ n
Example 1: Determine the value of C in:
C ≡ 53 mod 13
Step 1: 53= (5)(5)(5) = 125
Step 2: Split 125/13
Step 3: Select the remainder C = 8
Step 4: write in modular format: 8 ≡ 53 mod 13
Step 5: The result reads “8 equals 53 in modulo 13”.
Example 2: Determine the value of C in:
C ≡ 1005 modulus 211
Step 1: 1005= 10,000,000,000 (ten billion)
Step 2: Split 10,000,000,000/211
Step 3: Select the remainder C = 196
Step 4: Write in modular format: 196 ≡ 1005 mod 211
Step 5: The result reads “196 equals 1005 in modulus 211”
Remark: in module 211, instead of using the number ten billion, I can use 196, which simplifies the math for me (but not for an attacker).
Cryptography protects confidentiality with modular mathematics
We will now apply modular mathematics to send an encrypted message. We will use two exponential functions in modular format:
function to encrypt: C = me modulo n
function to decipher m = Cd modulo n, where:
“m” is the message to send, also called plain text.
“C” is the encrypted message, called ciphertext.
“e” exponent, it must be a prime number and can be known by everyone (which we will call the public key)
“d” exponent, it is the multiplicative inverse of “e,” it must be a secret number (we will call it the private key), obtained with the extended Euclidean algorithm (advanced mathematical method).
“n” is a number that selects the one that encodes and must meet certain requirements.
Example of a confidentiality protocol
Step 1: Roberto wants to send a message (m) to his friend Antonella but let no one else know that the time of the meeting will be at 4:00 p.m. (16:00 p.m.).
Step 2: With her previously agreed to use the functions:
To encrypt or encrypt with the function C = me module n
To decrypt the message with the function m = Cd modulo n
Step 3: Roberto receives from Antonella the public key e = 17 and the module n = 589. Antonella holds the private key “d.”
Step 4: Simultaneously generate the public key "e" and the private key "d" by advanced and very secure methods, but in our example, we obtain it from the online site: Modular Inverse
Modulus 540 results from applying Euler's totient function to n=589 (explained in later articles).
Result = 413, it is the multiplicative inverse of e = 17
Step 5: Encryption of the message m= 16 hours with the public key 17
C = me modulo n
C = 1617 modulo 589
Entering the data on the online site: Modular Exponentiation
It turns out C = 101.
Step 6: So, Roberto sends Antonella the ciphertext C = 101.
Step 7: Decryption of the text C with the private key d= 413, Antonella receives C = 101 and calculates m:
m = Cd mod n
m = 101413 mod 589
Step 8: On the website we enter the data:
The message m = 16 turns out, Antonella knows that the meeting will be at 4 in the afternoon.
Conclusions:
Transmitting data between the components of a computer system infrastructure, such as a local network (LAN) or external network (Internet), such as servers, clients, routers, etc. encryption is the guarantee that third parties, even if they have access, will not know the message.
The study of cryptography will help you to know the security of your information system. This is a simplified example for educational purposes, in practice, cryptography has powerful algorithms.
In the following article, we will study how cryptography deals with the authentication of a message, that is, if the sender is who he/she should be.