Encryption: transforming readable (original) data to unreadable (coded) format by rule. IN case of texts, the coded text is called ciphertext.
Decryption: transforming unreadable (coded) data to readable (decoded) format by rule.
Cracking: decoding the coded data without knowing the coding-decoding rule.
General process of data transfer:
key generation
key-sharing
encryption
communication
decryption
A symmetric encryption is any technique where the same key is used to both encrypt and decrypt the data.
Invented by Julius Caesar (Roman Empire).
The letters of the alphabet are shifted by a given number. The last letters will shift to the first letters.
This technique means a conversion table must be established.
EXAMPLE FOR A SHIFT-4 CAESER CIPHER CODING TABLE:
If the shift value is not known, cracking is possible with:
frequency analysis
known plaintext
brute force
Frequency analysis: we can analyze the frequency of the characters in the message, corresponding to the popularity level of letters in the given language. E.g. in English the letter E is the most popular, therefore in the coded text the most popular letters should be marked as connection to E.
Known plaintext: if we already know some part of the plaintext, we can connect those letters with the originals, and it will be easier to crack the rest of the encrypted version. E.g. if messages in time start with the same pattern (weather report), the shift can be determined by finding the weather report format.
Brute force: there are only 25 possible shifts, it is possible to break the code by trying shift values on the first words.
Invented by Giovan Battista Bellaso in the mid 1500s, considered especially strong at the time.
Uses an entire word as the shift key, plus a so-called Vigenère table (normal alphabet on x and y axises).
the key is repeated through the length of the original text
one axis is marked as actual original letter, one axis is marked as actual key character
the coded character can be found on the xy coordinates.
EXAMPLE FOR PREPARATION OF ORIGINAL TEXT AND KEYWORD:
EXAMPLE FOR THE VIGENÈRE TABLE:
If x axis is for finding letters of the original text, and y is for finding letters of the coded text:
(V, C) = X
(E, H) = L
(R, E) = V
...
(E, E) = I
(S, E) = W
Results the same if we change the axises.
For decryption, after filling the key onto the full length of the coded text, we do backward the process: on an axis we find the actual keyword letter, and in the values we find the actual coded letter, and the actual original letter will be on the other axis.
Cracking was hard with the three techniques due to having infinite amount of possible keywords, and because there are no standard repeated connections between the original and coded letters. Now, it is possible to use brute force and trying a whole vocabulary as keyword.
One of the most common encryption standards is AES-128, a block cipher approved by governments and used often for secure file transfer:
the key is always 128 bits long (there are 2^128 possible keys)
requires applying a sequence of 10 mathematical operations for each bit of the key
If a computer can calculate around 145 * 10^15 operations per second, a full brute force (in case the last variation is the real key) would take 500 trillion years.
In the age of AIs and the incoming age of quantum computers this time will be greatly reduced.
In symmetric world, the sender and the receiver should use the same key which means the key must be sent before the data or being available in a public space. In such cases hackers can have access to the key easily.
The asymmetric techique uses different keys for encoding and decoding, allowing safe data transfer.
The public key encryption is an asymmetric technique.
The used keys:
created by multiplying together two random, incredibly large primes
key length is greater or equal with 2048 bits
the key is usually stored as text by using Base64 character coding, therefore the number of characters will be greater than the number of digits
Transfer steps:
the sender and the receiver generate their own code pair: a public and a private key
they exchange their public keys
the sender encrypts the data using the receiver's public key and a mathematical operation
the sender sends the coded data
the receiver decrypts the data using its own private key
The whole process is a one-way method, it is impossible to decode the data along steps backward, and only the receiver's private key can decode it.
TLS superseded the older SSL protocol, so the terms TLS and SSL are often used interchangeably.
It is a protocol which adds a layer of security on top of the TCP/IP transport protocols. Uses both symmetric encryption and public key encryption, and adds additional security features (e.g. authentication, message tampering detection). Increases latency in internet communications but the security benefits are often worth.
Step when the sender is a client, the receiver is a server:
3-way TCP handshake
TLS initiation: client notifies the server about TLS and its version and encryption techniques
server confirmation of protocol: if the server can communicate via TLS, responds with a confirmation and a digital certificate containing its public key
certificate verification: client verifies the certificate
shared key generation: client sends pre-master key, encrypted with the server's public key, and remembers the shared key locally; also sends "Finished" message, already encrypted with the shared key
server confirmation of shared key: if the client's message was successfully decodable, sends its own "Finished" message with encrypted contents
client sends secure data: using symmetric encryption and the shared key
In case the server is unable to communicate using the desired protocol, or or the server certificate is unacceptable, or the "Finished" message is undecryptable by either side, the connection or session will be dropped.
Oftentimes, the same client needs to send data to a server multiple times, like when a user fills out forms on multiple pages of a website. In that case, the computers can use an abbreviated process to establish the secure session.
TLS is used with HTTPS (HTTP over TLS), FTPS (FTP over TLS), secure email sending.
When an URL is used without marking the protocol, and if the server supports TLS, usually will offer secure channel by default.
When a website does not provide trusted certificate, the browser shows a warning page.
In HTTPS, the URLs and data are readable only by the browser and the server.
Equals with public key certificate, identity certificate; proves the ownership of an encryption key (the public key sent to client upon communication). When the client receives it, it contains:
domain name
public key
certificate authority
In case of MITM (man-in-the-middle) attack, the attacker will send the public key to the client which means from that point all the data sent by the client will be understood by the attacker. The certificate will prove that the public key belongs to a real entity.
In TLS, clients trust a digital certificate if it was generated by institutions known as certificate authorities. The certificate authority verifies their ownership of the domain, signs the certificate with their own name and public key, and provides the signed certificate back to the server.
There are multiple levels of certificate authorities: the root certificate authority and intermediate certificate authority. The root CA only issues digital certificates for intermediate CAs. The intermediate CAs can either issue digital certificates for another intermediate CA, or for a server directly. If a root CA discovers that an intermediate CA has been compromised by an attacker, they invalidate the certificates from that CA but continue trusting the certificates from their other intermediate CAs.
Browsers and OSs actively maintain a list of trustworthy certificate authorities.
The certificate-system is a trust-model:
the user trusts the browser
the browser trusts the certificate authority
the authority trust the website