---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/support/browser-passwords-crypto/en/with-master.md
  - https://yandex.com/support/browser-passwords-crypto/ru/with-master.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/browser-passwords-crypto/en/llms.txt

# Encryption with a master password

## Security of the encryption key {#passwords-crypt}

The security of the encryption key is of primary concern for password protection. If an attacker discovers this key, it's easy to hack the entire password database, regardless of how sophisticated the encryption algorithm is. Therefore, the security of the [EncKey](*EncKey) is based on the following principles:

- [EncKey](*EncKey) is encrypted with the asymmetrical [RSA-OAEP](https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding) algorithm.
- In order for the browser to decrypt the [EncKey](*EncKey) , the user must enter the master password. The master password is known only to the owner of the passwords. It is not saved on the computer, so it can't be stolen from it. Immediately after decryption of the [EncKey](*EncKey), the entered master password is deleted from the computer's memory.
- The [EncKey](*EncKey) is not mathematically associated with the master password. This means that the resistance of [EncKey](*EncKey) to brute force attacks is constant (matching a random 256-bit number) and does not depend on the complexity of the master password (the length, use of dictionary words, or character set).


## Advantages of encryption with a master password {#advantages}

Encryption with a master password gives users the following benefits:

- An outsider who gets access to the computer will not be able to use the passwords.
- Loss or theft of the password database does not mean that all the passwords must be changed immediately.
- Neither Yandex nor anyone else will be able to access the passwords during syncing.
- Passwords in storage are more secure. Even if malware can steal the encryption key, it can't use it, because access to the key is locked by the master password.


{% note info %}

If the user has a master password, they can force changing the encryption password and re-encrypt all the passwords in the database. To do this, the user just needs to disable and re-enable the master password.

{% endnote %}


## Steps for encryption with a master password {#procedure}

### Encrypting the key and the password store {#key-crypto}


{% cut "How the key and passwords are encrypted in storage" %}

![](_image/crypto-scheme.png)

{% endcut %}


1. The user initiates the creation of a master password.
1. The browser uses the OS [random number generator](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) to create a 256-bit [EncKey](*EncKey).
1. For the [EncKey](*EncKey), the browser generates a random _key_id_ that is not mathematically associated with the [EncKey](*EncKey). The _key_id_ is stored in every entry in the password database. If the user enables password encryption on multiple unsynced devices, they might end up with several different [EncKey](*EncKey) keys. When syncing and combining the passwords, _key_id_ makes it clear what is encrypted by which key.
1. The browser uses the [EncKey](*EncKey) to encrypt passwords with the symmetric [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)-256 algorithm in [GCM](https://en.wikipedia.org/wiki/Galois/Counter_Mode) mode. The same key is used for decrypting the passwords from the storage.
1. For cryptographically secure protection of the [EncKey](*EncKey), the [RSA-OAEP](https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding) asymmetric encryption algorithm is used. To do this, the browser generates a key pair: public ([PubKey](*PubKey)) and private ([PrivKey](*PrivKey)). The [EncKey](*EncKey) is encrypted using the public key, and can only be decrypted using the private key ([PrivKey](*PrivKey)).
    
    {% note info %}
    
    Because the public key is used for encryption, the browser can:
    - [Change](#change) the master password without changing the [EncKey](*EncKey).
    - [Create](#restore-key) a copy of the [PrivKey](*PrivKey) with a different passphrase and use it for [backup access](#restore) to the storage.
    - Add passwords to the database without asking for the master password (for example, when [syncing](https://yandex.com/support/browser/device/sync.html) encrypted password storage with unencrypted storage, the unencrypted passwords can be encrypted using an additional generated _EncKey1_ key).
    
    {% endnote %}
    
1. To protect the [PrivKey](*PrivKey) from unauthorized use, it is encrypted with a passphrase using [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)-256-GCM.
1. The [UnlockKey](*UnlockKey) is used as the passphrase. To make this key cryptographically secure, the browser generates it from the master password, the _key_id_, and a salt with multiple hashing:
    1. Asks the user to enter the master password.
    1. Adds a [salt](https://en.wikipedia.org/wiki/Salt_(cryptography)) and the _key_id_ to the master password.
    1. Processes the result 100,500 times with the [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2)-HMAC-SHA256 hashing function.
  
  As a result, the master password chosen by the user is transformed into the 256-bit [UnlockKey](*UnlockKey). The resources required to hack this key are comparable to the resources needed to hack the [EncKey](*EncKey).
    
{% note info %}
    
    The field of crypto analysis continues to develop, and researchers are discovering faster ways to crack hashes. This is why the browser's hashing mechanism is not tied to a specific hardcoded function. If necessary, we can easily replace PBKDF2 with a more cryptographically secure function.
    
{% endnote %}
    


{% cut "Example of EncKey protection with a master password" %}


Public [EncKey](*EncKey):

```javascript
Mh6lu1xRuZFo/qJ2yktfJch2nAzlgY4+OPADyLQYfrkbR0hxae9M5nVdafthJa2QHG18sZbf2VOxveH87naRb3vq3oJykfxlVHX4bllYDCcLISzHZVnxF2yMM0r4BXl8Uq+nuINiWx8kaKtrULrdwnMGU6eOuOLZvv/wLDzQvz74iuQUgoR3NSpOByFnY/BkAmGWbQ5KXTYqqIcrcqkG1xb3EAQGEG8KGPtQsTvLsHL1QdjteMZ9CBBLAWjYd/kdrZsx+MU96XMEA+ViBU0ot35cAPVBeWgAyMZhvM9sYy4zB2HrCg+n14kSc85OjNEqAChQDeHVtcbBfyshnKB0Qg==
```

Public [PubKey](*PubKey):

```javascript
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyiZMYsF3r121EAqq9spGWDife8bUEr6eyAEP3ip2gm6KaNzkyPGiDXN0zIidMjHKBzxjymtyQyY29DM26w1DQUK6Bd8aNvPXayscHXOKkId7L7+D1qc3mm9FJ/03Yi+pOa4yxVItgUZs9kpyW2LI9begHn62n0d6khsu6A2Iws66rohSXjPo6J2zONpWVn/YNz4o8QyB4O12msEB2Uf+NSFJjqNFAMUmGdTfcpUZ5Qz6Q7V0i5CRgONn2GeqqEaHwa+judPGxrcL1QK3QZGhXChmzwGMAySdVWkwMbQxBMSKMRLbRhM0D19W00TdwYAMLbmX/E8Ekthx1L3WCK7Y1wIDAQAB
```

_EncKey*_ encrypted by the public key:

```javascript
VlZecAIaRweK2+ZnTAZzKskONjMGqqGWTli0Shr0zFcIQJwNaUSDTdflbSDEdR2KGh5HcShmRRaciQG0A59f8aBlYkoMEqLW+7Hoo1CJsunAxDioSoLf3YlpdfGto5
HFXsuoH1OcRTs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qp2Rdp9MU6bU6WgZCNDkTr+AvNpyQ1FmiO/gc6qyB93fe+2RvHHZJ0YXuSG4XDbbQ45rsoKwKBgQDQocPUFV7iLvawmr3qRa8Bn/+0WXHzzdf5Nm8i4iy
faaVdrpvuFl9eIkVGjfYO65jHA+93oru7gWsLg9EPDdBBuADWf1PlIZw1EsykPnRLMBuLQFiPmHZdZSMhNWQWy1T8EOnTsEp9KujerQ9Yk3Uhvln3DrzuWMilqJWj6YQyPwKBgQC9TXRApjBbTEtM/bnsFVTnrykxeh0LdzHaPlQDe7MsyH9iCtEoznK9cBbo93VFlW2NJdqCho
L6RxNDQTBIK+vDdiTbMswxg74CEL2WiZAJOIcs/XQvc5/XihpoNqPSg/V/jYAzfwNJT96cpcb6YewKN58RX1nqiLP2pzAqb/freQKBgCsFUGZJSdmGKaRdJFBMsju5jHbaAt9tUN241c3xqZXtqQXaXZkIz/2PP42+9EA7YLOZIiYfTmrp0vL66X8bMBh9It8YPmp/NcDT8ZLkt
gJTFzrtt9VUcQPtOQM+CTeSEiIwMqdOMO4CjSZttT5kmcCticuiJF9Zu3Y9fy3flzztAoGAMsTJRcyRe0qi0Z4nfpQkND6zPCUiTZwgvb51jQxapgWcR1NYRM0oAocqgftHGPXkxMUz+g08Mg+nzL4Vh8R6UQZE+k1LLOnLWpqRb9I23/hqudld5MJYq5e1tOJ8cwcJ+k6YRxN+
4qpW2qvQSH2g/rh+ynkHeQHxl9OAuRYTYNg=
```

Master password:

```javascript
password
```

Salt:

```javascript
/4dMZgU3GG5WfXMjYQbGNzKGxa/7RNFej43Nwx4mpws=
```

The [UnlockKey](*UnlockKey), which is the passphrase for the [PrivKey](*PrivKey):

```javascript
UfaND0ks2hulRHkLMGL9Zkpiu1gKBYJdYsqCVTnOIvs=
```

The _PrivKey*_ that was encrypted using the [UnlockKey](*UnlockKey):

```javascript
NphBZAm4mu2h4FoS21D6H6MNWxsk2YlD0+JbQQ2S2ujzgQpgF/lq52VU8OT039naB6MQRNxbGRL7G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BKr8APdZbrcGpyQOpR26+dZY+jxpa71Y55w3UwKVP50Df4VVo+ZWfHXI5Z0WW4XDfNe/cRp9aqBYlcCOT2dE67VjOgwVDYES7qiVe6g/fVNg6fLlr/44tqDhOF0Ty79T4URZrCnZPFgP+U4HR51o/v2c1sTIF/ON/FptgVgnKoNNIuFt6YCeEZ4sgd/zo83TkQuTd/
8RyCTof5aDpIlDkbEK+G/5e2vToze+PwvY30qV/EKk5GumoZsOvHzAl1dQpsJsINjN9aXcu7lJ+qH4e3M9VMCY5Ajlov5m3ni9tCnT/yF0il0tbOSQAESw/x/ZgsR2efvMfiGxX2KZ559nrOkk6RwKkkD/rl/hCarZ6rkAfbiuWl1Jl6g+mr+QIOPV+lV62VLagxQXLrjTuV05P
/8L8dVIEvyxa+vWZ6zoX5q4b0oJHglf+viGa2t18LugZ4lBU6djwNFNQJ08DYN9ttYAqY2gUN84b1HEr9Dp8rDIAg=
```


{% endcut %}


### Storing a site password {#saving}


{% cut "Flow for encrypting a new password" %}

![](_image/saving-pwd-crypto-scheme.png)

{% endcut %}


If the user needs to save a new site password, the browser decrypts the [EncKey](*EncKey), uses it to encrypt the new password, and sends the encrypted password to the password database.

To save the password in the database:

1. The user must save a new password.
1. The browser requests the master password ([mPwd](*mPwd)) from the user and [generates](#key-crypto) the [UnlockKey](*UnlockKey).
1. The browser uses the [UnlockKey](*UnlockKey) to retrieve the [PrivKey](*PrivKey).
1. The browser uses the [PrivKey](*PrivKey) to decrypt the [EncKey](*EncKey).
1. The browser uses the [EncKey](*EncKey) to encrypt the password and send it to the storage. After this, the master password and the password entered by the user are deleted from the computer's memory.

### Password decryption {#decrypto}


{% cut "Flow for decrypting a password" %}

![](_image/decrypto-scheme.png)

{% endcut %}


The [EncKey](*EncKey) is decrypted when the user needs to:

- Enter the password in a form on a site for authorization or to change the password.
- Open the password manager.

To get access to the password storage:

1. The browser requests the master password ([mPwd](*mPwd)) from the user and [generates](#key-crypto) the [UnlockKey](*UnlockKey).
1. The browser uses the [UnlockKey](*UnlockKey) to retrieve the [PrivKey](*PrivKey).
1. The browser uses the [PrivKey](*PrivKey) to decrypt the [EncKey](*EncKey).
1. The browser uses the [EncKey](*EncKey) to decrypt the password.

When you fill in an authorization form, the browser decrypts the password and inserts it into the form. Then it deletes the decrypted password from the computer's memory.


## Changing the master password {#change}


{% cut "Flow for changing the master password" %}

![](_image/change-pwd-scheme.png)

{% endcut %}


The [EncKey](*EncKey) is not mathematically associated with the master password, so to change the master password, just change the [UnlockKey](*UnlockKey) passphrase that locks the [PrivKey](*PrivKey). The [EncKey](*EncKey) doesn't need to be changed.


{% note info %}

There is no technical reason that prevents generating a new [EncKey](*EncKey), but it's inadvisable. By changing only the [UnlockKey](*UnlockKey), we avoid the difficult, risky and lengthy process of re-encrypting the entire password database, which would be inevitable if we changed the [EncKey](*EncKey).

{% endnote %}


**More information**
1. The browser prompts the user for the current master password ([mPwd](*mPwd)) and [generates](#key-crypto) the [UnlockKey](*UnlockKey).
1. The browser uses the [UnlockKey](*UnlockKey) to decrypt the [PrivKey](*PrivKey).
1. The browser asks the user for a new master password (_mPwdNew_).
1. The browser uses the new master password (_mPwdNew_) to generate a new key (_UnlockKeyNew_) and uses it to re-encrypt the [PrivKey](*PrivKey).


## Creating a recovery key {#restore-key}


{% cut "Flow for creating a recovery key" %}

![](_image/recovery-pwd-scheme.png)

{% endcut %}


**Why the recovery key is necessary**
:   The user might forget the master password. In this case, you need a way to restore access to the password store, but in a way that is not available to anyone except the user.
    
    The master password is only needed to decrypt the [PrivKey](*PrivKey), so to access the password store, it's enough to have a copy of the private key. The task of restoring the master password is simply a matter of securely storing a copy of the [PrivKey](*PrivKey).
    
    The recovery key ([RecoveryPrivKey](*RecoveryPrivKey)) is the copy of the private key. Some password protection systems offer the user to print out the recovery key (or QR code). We don't consider this approach to be secure enough, because the printout could be stolen or lost.
    
    Our solution is to encrypt the recovery key, store it on your device, and store the decryption key ([RecoveryUnlockKey](*RecoveryUnlockKey)) separately from it on the Yandex server. In order to get the key from the server, the user must verify their identity by manually entering the password to their Yandex [account](https://yandex.com/support/id/).
    
    Storing the recovery key and password separately means that the master password can be reset without introducing additional vulnerabilities. If the user forgot the master password, they can request the password from the recovery copy of the private key. The browser decrypts the [RecoveryPrivKey](*RecoveryPrivKey) and then encrypts it with a new master password invented by the user. Access to the password store is restored without having to change the [EncKey](*EncKey) and re-encrypt passwords.

**Stages of creating the recovery key**
  1. The user agrees to create a key for resetting the master password.
  1. The browser requests the master password ([mPwd](*mPwd)) from the user and [generates](#unlock-key-generation) the [UnlockKey](*UnlockKey).
  1. The browser uses the [UnlockKey](*UnlockKey) to decrypt the [PrivKey](*PrivKey).
  1. If the user is not logged in on Yandex, the browser asks them to log in.
  1. The browser generates a random 256-bit key ([RecoveryUnlockKey](*RecoveryUnlockKey)) and saves it in the user's [account](https://yandex.com/support/id/) on Yandex.
  1. The browser generates the [RecoveryPrivKey](*RecoveryPrivKey). To do this, it makes a copy of the decrypted [PrivKey](*PrivKey) and encrypts it using the [RecoveryUnlockKey](*RecoveryUnlockKey) as a passphrase.
  1. The browser stores the [RecoveryPrivKey](*RecoveryPrivKey) in the browser profile on the device. In the future, this key is stored only on the user's device and is not uploaded to Yandex servers during synchronization.
  1. To enable the user to recover access to passwords from other devices, the browser sends the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey) to all the user's devices during synchronization. This is a copy of the [RecoveryPrivKey](*RecoveryPrivKey) that is encrypted with the [UnlockKey](*UnlockKey).
  1. As soon as the user syncs another device with the Yandex server, the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey) is sent to this device and stored there in encrypted form.
  1. When the user enters the master password ([mPwd](*mPwd)) on another device for the first time after syncing, the additional encryption is removed from the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey). It is transformed to the [RecoveryPrivKey](*RecoveryPrivKey), which is protected by the [RecoveryUnlockKey](*RecoveryUnlockKey).
  1. The [RecoveryPrivKey](*RecoveryPrivKey) is stored on the device and never synced in unencrypted form. The user can use it to reset the old master password and create a new one after getting the [RecoveryUnlockKey](*RecoveryUnlockKey) from the account.


{% cut "Example of generating a recovery key" %}


Original private key ([PrivKey](*PrivKey)):

```javascript
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCu6h5dF90Ow7zwFE8KDbspsIbiAnlJJVdWE6BBSk9ecUnvlSeNZe/whbnvAkNF7o9wYstAdKUrKK3T+IJmgvhERgM
QoYlQZQmxm2EP9gsG84h0nWCVL82Sl1CA86Bt2Cr05UHGH9kWMC/FB7coPrURqXbMPtM0cwtWoIqzJJ6+EWkR/ucq8Bbrm9wnK1R3vFGXsFlTLWVmHEyY83gVnqwRR2u70b32j9qM91XevcRqWOYLNLIzio3FHTHuThsyy1cLYJsHPhc6ATqAKtYGcfWN4YPcIW7CG5uB3hFKi/
xGgOYxR38Ursw88rJqn1Od0QFpPLUxoPmXgydNYYIvE0iVAgMBAAECggEADWLWawpx/PjG41qyh9LwMWsUj4Rf8tScP/ali4mb1F74KRExozUbbT1Wsu9p5ZaxvIibBHZI06o7z16T4DOCu3reLi4mm5P373M0NOwAAQqvNTl8FD7BzUeuPggnDXD/LJnE9FwomXWbmkkSX86Yv
d7JvCzMrhVl1z3XD4msamA7VV/NdivL0Mn5cq5F2KGPLxqbH/nLCgxq4/Z0nAWIFJfGCx8C8sRALv2g7qK5PJVQ4VEttLpF6Qco31AwQQ0S2sWer+0y7m+GfZ+1tfdCE6ceZuEt4UsgF7q5at7lBfGHDdmH0F+sOYn+6+szJBPDLUFpO5d6udKGAiJZog23CwKBgQDWoJyFi/iQ
9ww2GzSanRDehNTLvNFqnDMGkrVNwAHhQ1FgXKDeW38ELPHQn21yt4GYzql/yHhS823ce7zLkHvKOcCfHWwHFfJimKqp2Rdp9MU6bU6WgZCNDkTr+AvNpyQ1FmiO/gc6qyB93fe+2RvHHZJ0YXuSG4XDbbQ45rsoKwKBgQDQocPUFV7iLvawmr3qRa8Bn/+0WXHzzdf5Nm8i4iy
faaVdrpvuFl9eIkVGjfYO65jHA+93oru7gWsLg9EPDdBBuADWf1PlIZw1EsykPnRLMBuLQFiPmHZdZSMhNWQWy1T8EOnTsEp9KujerQ9Yk3Uhvln3DrzuWMilqJWj6YQyPwKBgQC9TXRApjBbTEtM/bnsFVTnrykxeh0LdzHaPlQDe7MsyH9iCtEoznK9cBbo93VFlW2NJdqCho
L6RxNDQTBIK+vDdiTbMswxg74CEL2WiZAJOIcs/XQvc5/XihpoNqPSg/V/jYAzfwNJT96cpcb6YewKN58RX1nqiLP2pzAqb/freQKBgCsFUGZJSdmGKaRdJFBMsju5jHbaAt9tUN241c3xqZXtqQXaXZkIz/2PP42+9EA7YLOZIiYfTmrp0vL66X8bMBh9It8YPmp/NcDT8ZLkt
gJTFzrtt9VUcQPtOQM+CTeSEiIwMqdOMO4CjSZttT5kmcCticuiJF9Zu3Y9fy3flzztAoGAMsTJRcyRe0qi0Z4nfpQkND6zPCUiTZwgvb51jQxapgWcR1NYRM0oAocqgftHGPXkxMUz+g08Mg+nzL4Vh8R6UQZE+k1LLOnLWpqRb9I23/hqudld5MJYq5e1tOJ8cwcJ+k6YRxN+
4qpW2qvQSH2g/rh+ynkHeQHxl9OAuRYTYNg=
```

Recovery key ([RecoveryUnlockKey](*RecoveryUnlockKey)):

```javascript
d84eaaa2d1a44d7716b59129c9b48b0339b97eb3d3e28405a6e212b8fc82535c
```

Copy of the private key ([RecoveryPrivKey](*RecoveryPrivKey)), encrypted by the [RecoveryUnlockKey](*RecoveryUnlockKey):

```javascript
NJdSM0ZBf4IbLCcZIcCex/ul3UxkOVdl+05WyRg9yLwP97EKMzy4yMXvLLiq27H/xxfzkAs7DaYWSTqNyW/iGIidpUcyMKffM+P2i4vSjngTpVMQQl0ISQ1P2+Ym5dsUOtMHNh5SPQOVvcgZ0Nvq4GVVMVoX6HlnLsK3EmwBOmlMuuWhHbMPRaiJl4xCRZlmTQlRNbhSQEGNHkcDTPKUG4Li35OSKnZRO2WVUfdgNJ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a forgotten master password {#restore}


{% cut "Flow for resetting the master password" %}

![](_image/restore-mpwd-scheme.png)

{% endcut %}



{% note alert %}

The user can reset the master password only if a [recovery key](#restore-key) was previously created. They can reset the master password either on the device where the recovery key was created, or on a device where a copy of the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey) was received after syncing and decrypted (in other words, the user successfully entered the master password on this device at least once after syncing).

{% endnote %}


1. The user initiates the master password reset.
1. The browser asks the user for a new master password (_mPwdNew_).
1. If the user is not logged in on Yandex or logged in more than five minutes ago, the browser asks them to confirm their identity by entering the password from the Yandex account. This prevents a situation when someone else could use the device to reset the master password in the user's absence.
    
    {% note info %}
    
    For this authorization, the password can't be inserted automatically. If the user does not remember the password from their Yandex account, they will not be able to reset the master password until they [restore access](https://yandex.com/support/passport/support-restore.html) to the account.
    
    {% endnote %}
    
1. The browser asks Yandex.Passport for the [RecoveryUnlockKey](*RecoveryUnlockKey) and gets it if authorization was successful.
1. The browser uses the [RecoveryUnlockKey](*RecoveryUnlockKey) to decrypt the [RecoveryPrivKey](*RecoveryPrivKey). Then the [RecoveryUnlockKey](*RecoveryUnlockKey) is immediately deleted from the device's memory and from the user's [account](https://yandex.com/support/id/) on Yandex.
1. The browser uses the new master password (_mPwdNew_) to re-encrypt the [PrivKey](*PrivKey) and creates a new [UnlockKey](*UnlockKey).
1. The browser [generates](#restore-key) a new recovery key (_RecoveryPrivKeyNew_) and sends it to the Yandex server.


## Sync passwords {#synch}

### Syncing the password store {#sync-passwords}

When a password store is [synced](https://yandex.com/support/browser/device/sync.html) that has the private part protected by a master password, the following are sent to the server:

- The encrypted [EncKey](*EncKey).
- The public key ([PubKey](*PubKey)).
- The encrypted private key ([PrivKey](*PrivKey)).
- The password store with the private part (passwords and notes) encrypted.
- The encrypted recovery key ([EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey)), if it was [created](#restore-key).


{% note info %}

The [UnlockKey](*UnlockKey) is not sent to the server and is not stored on the computer. It is calculated each time the user enters the master password.

{% endnote %}


During the transfer from the device to the Yandex server and back, the data remains secure due to the following factors:

- The [HTTPS](https://en.wikipedia.org/wiki/HTTPS) protocol protects the data transmission overall.
- Use of [GСM](https://en.wikipedia.org/wiki/Galois/Counter_Mode) protects the public part of entries from substitution.
- The [encryption](#passwords-crypt) used by the browser protects the private part of the password store.
- The encryption key is protected by a master password, so no one (not even Yandex) can decrypt it.

Therefore, Yandex servers store the addresses of websites and usernames on these sites in unencrypted form, but passwords, notes, and [EncKey](*EncKey) encryption keys are stored in encrypted format. Additionally, information necessary to decrypt it is not uploaded to Yandex servers.

### Syncing the recovery key {#sync-recovery-key}

The recovery key ([RecoveryPrivKey](*RecoveryPrivKey)) is created on the device and stored on it in encrypted form. This key can't be simply left on the device where it was created, because the user could lose the device and would not be able to restore access to passwords. Creating a recovery key on each device manually is also not a good solution, because the user might end up with a device where they forgot to create the key. Transmitting the key to other devices via [synchronization](https://yandex.com/support/browser/device/sync.html) isn't safe, because the password for the key is stored on the Yandex server.

To solve all these problems, additional encryption is applied to the [RecoveryPrivKey](*RecoveryPrivKey) with the [UnlockKey](*UnlockKey). Decrypting the [UnlockKey](*UnlockKey) requires the master password, which isn't stored anywhere, so the resulting [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey) can be safely synced.

After synchronization, the additional encryption is removed on each synced device when the master password is first entered correctly with the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey). The restored [RecoveryPrivKey](*RecoveryPrivKey) remains encrypted by the [RecoveryUnlockKey](*RecoveryUnlockKey). The latter is stored in the user's account on Yandex and can be obtained only after the user manually enters the account password. A copy of the [RecoveryPrivKey](*RecoveryPrivKey) is stored in the browser profile on the device.

In this way, the user can restore the master password from any synced device if they entered the master password on the device at least once after synchronization. However, the recovery key remains secure during transmission over the network.

**Stages of encrypting the recovery key during synchronization**
  1. The browser creates a copy of the [RecoveryPrivKey](*RecoveryPrivKey) and encrypts it with the [UnlockKey](*UnlockKey).
  1. During synchronization, the resulting copy ([EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey)) is sent to the Yandex server.
  1. As soon as the user syncs another device with the Yandex server, the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey) is sent to this device and stored there in encrypted form.
  1. When the user enters the master password ([mPwd](*mPwd)) on another device for the first time after syncing, the additional encryption is removed from the [EncryptedRecoveryPrivKey](*EncryptedRecoveryPrivKey). It is transformed to the [RecoveryPrivKey](*RecoveryPrivKey), which is protected by the [RecoveryUnlockKey](*RecoveryUnlockKey).
  1. The [RecoveryPrivKey](*RecoveryPrivKey) is stored on the device and never synced in unencrypted form. By getting the [RecoveryUnlockKey](*RecoveryUnlockKey) from the account, the user can [reset](#restore) the old master password and create a new one.


[*EncKey]: The key for encrypting the password store.


[*mPwd]: The master password. The user must remember it and enter it every time they need to access site passwords.


[*PubKey]: The public key. Used for encrypting _EncKey_. Stored in plain text (unencrypted) format.


[*UnlockKey]: Key (passphrase) used for encrypting _PrivKey_. The result of repeated hashes of the master password. It is computed each time the master password is entered.


[*PrivKey]: Private key. Used for decrypting _EncKey_. It decrypts _EncKey_ and user passwords, so it is protected by a passphrase. _UnlockKey_ is used as the passphrase.


[*RecoveryUnlockKey]: The key that encrypts _RecoveryPrivKey_. Stored in the Yandex account.


[*EncryptedRecoveryPrivKey]: A copy of the _RecoveryPrivKey_ private key for resetting the master password. It is encrypted using _UnlockKey_. It is sent to the server for syncing with other devices.


[*RecoveryPrivKey]: A copy of the private key that decrypts _EncKey_. Used for resetting the master password. Stored on the device in encrypted format and requires _RecoveryUnlockKey_ for decryption. For transmission over the network, it is also encrypted with _UnlockKey_ during syncing.


