anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

client_architecture.tex (11607B)


      1 \subsection{Client architecture}
      2 
      3 The Anastasis client architecture consists of two main components. A client
      4 API which communicates with the server and a command line application
      5 which interacts with the user. The structure of these two components
      6 is shown in Figure~\ref{fig:anastasis:client}.
      7 
      8 \begin{figure}[H]
      9 	\centering
     10 	\includegraphics[scale=0.6]{images/client_api.png}
     11 	\caption{Anastasis client architecture}
     12 	\label{fig:anastasis:client}
     13 \end{figure}
     14 
     15 The Anastasis client implementation includes three distinctive APIs: a
     16 {\em Crypto API} which provides the different cryptographic functions,
     17 a {\em Service API} which sends the request to the server and the {\em
     18   Client API} which manages the main data structures and provides an
     19 abstraction for the application.
     20 
     21 \subsubsection{Crypto API}
     22 
     23 The most important data structures in the crypto API are the following:
     24 
     25 \begin{itemize}
     26   \item
     27 The kdf\_id is a hash code which was generated with Argon2. The
     28 entropy source is the user's unforgettable secret. The kdf\_id is used
     29 to create various key's, for more details see Chapter~\ref{chap:design}.
     30 
     31 \begin{lstlisting}
     32 struct kdf_id
     33 {
     34   Hashcode; //512-bit
     35 }
     36 \end{lstlisting}
     37 
     38 \item
     39 The account\_private\_key is used to sign the data and check the signature later. It is a 256-bit EdDSA private key. It is generated with the kdf\_id as entropy source.
     40 \begin{lstlisting}
     41 struct account_private_key
     42 {
     43   eddsa_private_key;
     44 }
     45 \end{lstlisting}
     46 
     47 \item
     48 The account\_public\_key is used as the user identification on the different providers. It is generated from the private\_key.
     49 \begin{lstlisting}
     50 struct account_public_key
     51 {
     52   eddsa_public_key;
     53 }
     54 \end{lstlisting}
     55 
     56 \item
     57 The truth\_key is a randomly generated AES-256 GCM key. It is used to encrypt the user specify data in the truth object.
     58 \begin{lstlisting}
     59 struct truth_key
     60 {
     61   key; //256-bit
     62 }
     63 \end{lstlisting}
     64 
     65 \item
     66 The truth\_seed is a randomly generated nonce with a size of 32 Bytes. It is used to derive a truth\_private\_key
     67 and is stored within an encrypted recovery document.
     68 \begin{lstlisting}
     69 struct truth_seed
     70 {
     71   nonce; //256-bit
     72 }
     73 \end{lstlisting}
     74 
     75 \item
     76 The truth\_private\_key is used to sign the encrypted key share and the encrypted authentication data. It is a 256-bit EdDSA private key. It is generated with the truth seed as entropy source.
     77 \begin{lstlisting}
     78 struct truth_private_key
     79 {
     80    eddsa_private_key;
     81 }
     82 \end{lstlisting}
     83 
     84 The truth\_public\_key is used as the user identification on the different providers in case of uploaded truths. It is generated from the truth private key.
     85  \begin{lstlisting}
     86 struct truth_public_key
     87 {
     88   eddsa_public_key;
     89 }
     90 \end{lstlisting}
     91 
     92 
     93 \item
     94 Anastasis needs different symmetric keys to encrypt data for example, the recovery document. These symmetric keys are all 256-bit large hashcodes. These symmetric keys are generated through the key routine defined in Implementation Key usage.
     95 \begin{lstlisting}
     96 struct symmetric_key
     97 {
     98   hashcode; //256-bit
     99 }
    100 \end{lstlisting}
    101 
    102 \item
    103 Each policy has a separate policy\_key. The key is used to encrypt the master\_key.
    104 The policy\_key is also a AES-256 GCM key. It is generated through the combination of a set of key\_shares.
    105 \begin{lstlisting}
    106 struct policy_key
    107 {
    108   hashcode; //256-bit
    109 }
    110 \end{lstlisting}
    111 
    112 \item
    113 Every truth object contains a key\_share. A key\_share is a 256-bit random generated bit sequence.
    114 \begin{lstlisting}
    115 struct key_share
    116 {
    117   hashcode; //256-bit
    118 }
    119 \end{lstlisting}
    120 
    121 \item
    122 Before every encryption a random 256-bit large nonce is generated. This gives the encryption algorithm a random factor.
    123 \begin{lstlisting}
    124 struct nonce
    125 {
    126   hashcode; //256-bit
    127 }
    128 \end{lstlisting}
    129 
    130 \item
    131 To use AES-256 GCM an IV must be generated. It is generated with an HKDF over a salt the kdf\_id and a symmetric key.
    132 \begin{lstlisting}
    133 struct iv
    134 {
    135   hashcode; //128-bit
    136 }
    137 \end{lstlisting}
    138 
    139 \item
    140 The aes\_tag is generated after each encryption, it is later used to check the integrity of the data.
    141 \begin{lstlisting}
    142 struct aes_tag
    143 {
    144   hashcode; //128-bit
    145 }
    146 \end{lstlisting}
    147 \end{itemize}
    148 
    149 The functions of the crypto API basically provide the canonical set of
    150 cryptographic operations (hash, encrypt, decrypt, etc.)  over these
    151 basic data structures.
    152 
    153 
    154 \subsubsection{Client API}
    155 
    156 The most important data structures in the client API are the following:
    157 
    158 \begin{itemize}
    159   \item
    160 The secret share data structure is used to upload a new recovery document.
    161 \begin{lstlisting}
    162 struct secret_share
    163 {
    164   kdf_id;
    165   last_etag;
    166   policies;
    167   core_secret;
    168 }
    169 \end{lstlisting}
    170 \begin{itemize}
    171 \item kdf\_id: is used to compute the account public and private key. The hash is 512bit large.
    172 \item last\_etag: this hash is sent with the recovery document. The server will check the hash if the document on the server is the same. This prevents unnecessary uploads. The hash is 512-bit large.
    173 \item policies: is a list of all generated policies the user wants to combine into a recovery document.
    174 \item core\_secret: is the user provided core secret. This is just a binary blob so Anastasis does not have a restriction for the user secret. This could be a for example a private key or a password the user wants to backup.
    175 \end{itemize}
    176 
    177   \item
    178 The recovery information data structure holds a recovery document. It is downloaded within the recovery process and stored inside a recovery data structure.
    179 \begin{lstlisting}
    180 struct recovery_information
    181 {
    182   struct decryptption_policies;
    183   struct challenges;
    184   version;
    185   salt;
    186 }
    187 \end{lstlisting}
    188 \begin{itemize}
    189 \item decryption\_policies: holds all available policies within the downloaded recovery document.
    190 \item challenges: holds all available authentication methods within the recovery document.
    191 \item version: the version of the downloaded recovery document is stored here.
    192 \item salt: this is the salt used for the generation of the policy keys. The salt is a 512-bit value.
    193 \end{itemize}
    194 
    195 \item
    196 The recovery data structure is generated at the start of a secret recovery. It contains all available policies and lists which challenges are solved. Through this
    197 struct the client can check if a policy was solved completely.
    198 \begin{lstlisting}
    199 struct recovery
    200 {
    201   kdf_id;
    202   version;
    203   provider_url;
    204   salt;
    205   solved_challenges;
    206   struct recovery_information;
    207 }
    208 \end{lstlisting}
    209 \begin{itemize}
    210 \item kdf\_id: is used to compute the account public and private key. The hash is 512bit large.
    211 \item version: hold the user desired version he wishes to download. This can be null then the client downloads the latest version.
    212 \item provider\_url: the client will download the recovery document from this provider url.
    213 \item salt: this is the salt of the provider specified in provider\_url.
    214 \item solved\_challenges: this is a list of all solved challenges. This list is updated after each successful authentication. This allows the client to check if a policy is solved.
    215 \item recovery\_information: as previously mentioned this data structure holds the downloaded recover document to process within the recovery
    216 \end{itemize}
    217 
    218 \item
    219 A truth data structure is used to upload a new authentication method to a provider. It is identified by the TRUTH\_PUB which the user creates through a HKDF over the truth\_seed. The truth data structure is only used for the secret share process and not for the recovery.
    220 \begin{lstlisting}
    221 struct truth
    222 {
    223   truth_seed;
    224   method;
    225   mime_type;
    226   encrypted_truth;
    227   encrypted_key_share;
    228 }
    229 \end{lstlisting}
    230 \begin{itemize}
    231 \item truth\_seed: the truth\_seed is the identification of the truth object.
    232 It is used as entropy source to generate the TRUTH\_PUB, which later identificates the truth object. The truth objects are not linked to the user. A list of these truth\_seeds are stored inside the recovery document, with this the user data is more anonymous.
    233 \item method: this defines which method the user chose to configure, for example SMS, email, secure question.
    234 \item mime\_type: this defines in which format the truth was safed, for example jpeg, png, txt, json.
    235 \item encrypted\_truth: the encrypted truth holds the authentication specific data. It holds for example the hashed answer and the question. It is encrypted with the specific truth\_key which is stored inside the recovery\_document.
    236 \item encrypted\_key\_share: this is the key\_share protected by this truth. It is encrypted with a key which was derived with the kdf\_id of the user. The server will later send this key\_share to the user upon successful authentication.
    237 \end{itemize}
    238 \newpage
    239 \item
    240 The policy data structure is used to create new policies to combine them into the recovery document. The policy data structure is only used for the secret share process.
    241 \begin{lstlisting}
    242 struct policy
    243 {
    244  truths;
    245  policy_key;
    246  salt;
    247 }
    248 \end{lstlisting}
    249 \begin{itemize}
    250 \item truths: every policy has a set of truths which need to be solved to recover the policy\_key
    251 \item policy\_key: the policy\_key is created through the combination of the different key\_shares within each of the truth objects. It is later used to encrypt the master\_key.
    252 \item salt: defines the salt used to create the policy\_key.
    253 \end{itemize}
    254 
    255 \item
    256 The decryption\_policy data structure is used in the recovery process. It has slightly different values as the policy structure.
    257 \begin{lstlisting}
    258 struct decryption_policy
    259 {
    260   truth_seeds;
    261   encrypted_master_key;
    262   salt;
    263 }
    264 \end{lstlisting}
    265 \begin{itemize}
    266 \item truth\_seeds: is a list of truth\_seeds which need to be solved to recreate the policy key. Each truth\_seed has a corresponding challenge.
    267 \item encrypted\_master\_key: holds an encrypted version of the master\_key which was used to encrypt the core secret. In every policy lies the same master\_key which was encrypted by the specific policy\_key.
    268 \item salt: defines the salt which was used to create this policy\_key.
    269 \end{itemize}
    270 \newpage
    271 \item
    272 The challenge data structure is used for the several key\_share lookups.
    273 We named the process of authentication on the providers as challenges.
    274 It has slightly different variables as the truth data structure.
    275 \begin{lstlisting}
    276 struct challenge
    277 {
    278   truth_seed;
    279   url;
    280   truth_key;
    281   method;
    282   key_share;
    283   instructions;
    284 }
    285 \end{lstlisting}
    286 \begin{itemize}
    287 \item truth\_seed: Entropy source to generate the TRUTH\_PUB, which identifies the challenge on the server.
    288 \item url: defines the provider URL on which the truth was stored.
    289 \item truth\_key: this key is sent to the server within the authentication procedure. The server can decrypt the truth with this key to start the authentication.
    290 \item method: defines the method of this challenge, for example email, SMS, secure question.
    291 \item key\_share: After each successful authentication the key\_share which was sent by the server will be saved within this variable. It is later used to recreate a policy\_key.
    292 \item instructions: this contains a string with the instructions for the user. This could for example be:” What is your favourite colour?” or” An SMS was sent to the number +41...... please provide the pin”.
    293 \end{itemize}
    294 \end{itemize}
    295 
    296 The functions of the client API basically provide a way to
    297 backup a core secret by providing user's identity attributes,
    298 the secret and constructing the policies, as well as a way
    299 to recover a core secred by providing the user's identity
    300 attributes and then satisfying the authentication challenges.
    301 
    302 
    303 \subsubsection{Service API}
    304 
    305 The service API is responsible for sending the requests to the REST
    306 API of the server. The client has implemented functions for every
    307 endpoint.
    308 For more details see REST API documentation in
    309 appendix~\ref{appendix_server_api}.