pgp file. About the data compression procedure in PGP. How to read a received encrypted message with a signature

"A paranoid is a person who understands something about what is happening"

William Burroughs

Why is this necessary?

Electronic messages (E-mail, ICQ) can easily be read and copied by anyone who has access to the Internet provider's server or to the computers through which these messages pass.

As a result of the fight against terrorism and money laundering, many countries, including Ukraine, have adopted laws that oblige Internet providers to archive all correspondence of their clients. Intelligence agencies of major states regularly scan emails in search of suspicious keywords and phrases. Here are just a few of these government programs: the international ECHELON system (USA and others), the Carnivore project (USA), SORM and SORM-2 systems (Russia).

Intelligence agents or other interested parties can not only intercept any of your messages, but also change its content, and then send it as if nothing had happened to it. The return address and service headers of the letter are easily forged and modified. Scientific and technological progress has made it easier to monitor electronic correspondence, but the same progress allows this correspondence to be reliably protected.

Accordingly, if you are the owner of an offshore company or are planning to register an offshore company, you should pay Special attention protection of confidentiality of correspondence.

How to protect yourself?

There are many data protection tools available on the Internet. It is not easy to understand this diversity. Here are some simple tips:

  1. Choose programs that have been around for as long as possible.
  2. Give preference to programs whose source code is open source.
  3. The strength of a program should be based on the inability to guess the key, and not on the secrecy of the encryption algorithm.
  4. Try to find as many reviews as possible from uninterested people about the program.

Cryptography is very conservative. New encryption tools are not considered reliable until they have been carefully taken apart by professional cryptanalysts. To do this, they must have access to the source code of these programs. Developers of commercial programs do not publish this code for fear that competitors will use their ideas. Therefore, programs with closed source code are not trusted by specialists. The danger of using such programs is that hypothetically, behind the closed code, the developers may hide a secret “backdoor” - the ability to crack the code without even knowing the password. It is for these reasons that it is much preferable to use open source programs for encryption purposes.

The most common means of protecting information in recent years has been programs to implement the PGP (Pretty Good Privacy) encryption standard. The stability of PGP is based on some fundamental unsolved mathematical problems.

The creator of the first PGP program, Philip Zimmerman, publicly published its code in 1991. Since then, the program has been repeatedly examined by top-class cryptanalysts, and not one of them has found any weaknesses in the encryption methods used. If you follow simple rules, it is almost impossible to hack it.

Over time, this project was commercialized. In 2010, Symantec Corporation bought PGP from its developers for $300 million and has since offered users commercial versions of the program with expanded functionality. We strongly do not recommend using commercial version PGP, since its source code is, of course, already closed.

Alternatively, back in 1999, the Free Foundation software a free implementation of PGP encryption called GnuPG was created. This program is open source and fully compatible with other versions of PGP. The GnuPG project is in the process of development and a group of enthusiastic developers continues to work on its improvement to this day.

You can download the GnuPG distribution package from the following links:

  • Windows version - Gpg4Win
  • Version for Mac OS - GPG Suite
  • Version for Android - GPG Guardian project
  • Versions for others operating systems- on the GnuPG website

PGP encryption principle

PGP encryption is based on the principle of asymmetric cryptography. Briefly this means the following. A message encrypted with one key can only be decrypted with another, related key. These two keys form a pair - public and secret. Each participant in the correspondence has such a pair of keys. The main advantage of PGP is that users do not need to share secret keys with each other to exchange encrypted messages.

Although the key that encrypts the text of the message is accessible to outsiders, it cannot be used to decrypt the message. This key is called public. Users can openly send each other their public keys over the Internet. At the same time, there is no risk of unauthorized access to their confidential correspondence.

The secret key is carefully protected from outsiders. Using the private key, the recipient decrypts messages that were encrypted with his public key. But even after obtaining the secret key, the enemy will not be able to use it without knowing the password.

Let's illustrate how PGP works

1. Both interlocutors installed the program and each of them generated a pair of keys - one public and one secret.

2. After which Alice and Boris exchange their public keys via an open channel. As a result, each interlocutor receives the following set of keys:

3. Alice writes a message, encrypts it with Boris’s public key and sends it to the recipient. Boris receives an encrypted message and opens it with his secret key:

4. Boris writes a response, encrypts it with Alice’s public key and sends it to Alice. Alice receives the encrypted answer and opens it with her secret key:

What does PGP do?

PGP encryption solves three problems of confidential information exchange:

  1. Protects the text of messages from strangers. That is, only a person who has a secret key and knows the password can read the message.
  2. Confirms integrity to the recipient incoming message. That is, it gives confidence that the content of the message has not changed during transmission.
  3. Confirms the identity of the sender. The electronic signature built into PGP uniquely identifies the sender, since only he has access to the secret key and knows the password.

How does PGP work?

Before encrypting a message, the sender determines the recipient. The program finds the recipient's public key (for this it must be in the public key file on the sender's computer).

Before encryption, PGP compresses the message text. This speeds up transmission and increases encryption strength. Then a so-called session (one-time) key is generated, which is a long random number. The message text is encrypted using the session key. The message text is encrypted using a symmetric encryption algorithm. This algorithm uses a single key for encryption and decryption. Therefore, to decrypt the message, the recipient must also have this session key. However, it is not secure to send this key in clear text, so it is encrypted with the recipient's public key. The encrypted session key is sent to the recipient along with the ciphertext. The need to use a symmetric encryption algorithm is due to its high speed.

Messages are decrypted in reverse order. On the recipient's computer, the program uses his private key to decrypt the session key. Using this key, the text of the message is decrypted.

Keys

A key is a number that a program uses to encrypt and decrypt text. The key size is measured in bits. The larger the key, the more difficult it is to crack (pick up). Today, in public cryptography, keys with a length of 2048 bits or more are considered secure.

Despite the fact that the public and private keys are interconnected, you can obtain the private key by having public key, very difficult. This is possible if the key length is short and the enemy has high-power computers. Therefore, it is important to choose the keys big size. On the other hand, a key that is too long slows down the decryption of messages. Therefore, the golden mean should be observed. It is quite enough if the selection takes several tens or hundreds of years. At the current level of development of computer technology, keys with a length of 2048 - 4096 bits are almost impossible to crack.

The keys are stored on your computer's hard drive in two files: one for public keys and one for private keys. These files are called "bundles" of keys (Keyrings). The public keys of your correspondents will be “clung” to a bunch of public keys. Your private keys are stored in a private key file. It must be stored especially carefully. If you lose your private key, you will not be able to decrypt information addressed to you that was encrypted with your public key.

Digital signature

A digital signature allows the recipient to verify the identity of the sender of the message. It performs the same function as a regular signature. However, a regular signature can be forged. It is almost impossible to forge a digital signature.

Message integrity confirmation - hash function

Along the way from the sender to the recipient, the contents of the message may change. The program provides message integrity checking. For this, a so-called hash function is used. This is an algorithm for converting text of an arbitrary size into some small number. This transformation is completely unambiguous, that is, with any change in the data, even by one bit, the result of the hash function will also change.

Before encrypting a message, the program calculates its hash function and encrypts it with a secret key. The result of encryption is the digital signature. The digital signature is transmitted by the email program along with the text. The program on the recipient's computer decrypts the hash function and then calculates the hash function of the message text. If the hash function received from the sender and calculated on site coincide, this means that the message has not changed along the way. Next, the message text is decrypted using the recipient's secret key.

The program then checks which of the public keys is suitable for decrypting the result of the hash function. If this turns out to be the sender's key, then the recipient can be sure that the message was signed by the owner of the secret key or the person to whom this key and password became available.

It is not possible to extract a signature from one document and attach it to another, or to change the content of a message so that it still matches the digital signature. Any change to a signed document will be immediately detected when the signature is verified.

Password

PGP encryption provides another layer of security. To use a secret key, it is not enough to have access to the secret key file. To do this you need to know the password.

In PGP implementations, a password is called a "passphrase", although it can also consist of one word. However, remember that using passwords that are too short significantly increases the risk of them being hacked.

There are three most popular password cracking methods:

  1. Dictionary Attack Method- sequential search of all words of the language in different registers.
  2. Brute Force method- sequential search of all possible combinations of all symbols.
  3. "Wrench" method(other names: the “rubber hose” method (Rubber-hose Cryptanalysis), “thermorectal cryptanalysis”, “gangster cryptanalysis”) - the use of the weakest link in the information security system, which is the human factor, to crack a password. Using this method, the “cryptanalyst” resorts to threats, torture, blackmail, extortion, bribery and other improper measures to influence the person who knows the password. This can be illustrated with a cartoon:

(cartoon source: xkcd.com)

A description of countermeasures to the "wrench" method is beyond the scope of this article. Physical security professionals can help you with these questions. But to combat the first two methods, it is enough to follow simple rules for choosing a password:

Do not do it:

  • Use words that can be found in the dictionary of any known language.
  • Use dates of birth, surnames and first names of relatives, names of pets and other easy-to-guess character sets.
  • Use meaningful words from one language typed on a keyboard layout for another language.
  • Write down the password (especially in personal notebooks or leave it near the computer).

Desirable:

  • Choose a password length of more than 8 characters (if it consists of a random set of alphanumeric characters and punctuation marks).
  • When using meaningful words in your password, increase its length to 16-20 characters. There should be several words.
  • When using meaningful words, make mistakes in them, insert punctuation marks, change case.

You must remember the password. If you forget it, you will never be able to recover the information encrypted with this key. Without knowing the password, your private key is completely useless.

There is one very good method for generating and remembering long, complex passwords: we take any poem we have memorized (or the words of a popular song) and use the first letters of each word, typed in the English keyboard layout, as a password.

For example, let's take an excerpt from Emil Verhaeren's poem "The Sword":

With mockery of my barren pride
Someone predicted to me, holding a sword in his hand:
A nonentity, with an empty and cold soul,
You will mourn the past in anguish.

Now switch the keyboard layout to English language and, repeating to ourselves the memorized poem, we type the first letters of each word (while looking at the Russian letters of the keyboard):

snnmgbmnpdmvrnsdpihtbpovt

As a result, our password will be the following typed sequence of characters:

cyyvu,vyglvdhyclgb)