diff --git a/src/context.rs b/src/context.rs index be6fa89..ca642c3 100644 --- a/src/context.rs +++ b/src/context.rs @@ -8,6 +8,67 @@ macro_rules! data_ctx_from_iter { }; } +/// The context in which some data is encrypted. +/// +/// The main purpose of encrypting data before storing it in the database is to preserve data +/// confidentiality even if an attacker gains access to the database. In order to check whether or +/// not the encryption is efficient, we must therefore consider the database as compromised. A +/// typical scenario is to have an application that encrypts data given by the user before storing +/// it and decrypts it before displaying it back to the user. In this scenario, an user should +/// access its own data only. +/// +/// In such a scenario, if the application does not include adequate protections, an attacker +/// having access to the database and having a legitimate user account can trick the application +/// into decrypting and displaying the data of other users. This can be done in several ways. A +/// first way of doing it, is by copying and pasting the victim's encrypted data, at cell level, +/// into the attacker's own data cell. A second way of doing it is for the attacker to edit the +/// list of users having access to the victim's data by adding himself. There may be others way to +/// edit the database in such a way that the application is tricked into thinking the attacker's +/// user account has a legitimate access to the victim's data. This is one of the many forms of the +/// [confused deputy problem](https://en.wikipedia.org/wiki/Confused_deputy_problem). +/// +/// In order to solve this vulnerability, a solution is to use additional authenticated data (AAD) +/// which is a feature commonly provided by modern authenticated encryption schemes. Such a feature +/// allows, on encryption, to provide some data that will be used during the computation of the +/// encrypted data's checksum. The exact same AAD must be given upon decryption, otherwise the +/// checksum will be invalid and the decryption process will not take place, resulting in an error. +/// To use this feature to solve the confused deputy problem, you must therefore use the +/// appropriate data in the AAD, which Coffio presents you under the name of DataContext. +/// +///