Loop/Architecture/Context: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 8: Line 8:
This section explains the means by which this achieved at the level of information flow. Details are provided in the sections below.
This section explains the means by which this achieved at the level of information flow. Details are provided in the sections below.


When a Loop client logs into the FxA server, it will obtain a user-specific symmetric key, '''kB''', and an OAuth application identifier. The key '''kB''' is wrapped with the user's account login password. Upon obtaining the key, the user unwraps '''kB''', combines it with the application identifier, and applies HKDF to obtain a new key, '''kBr'''.
When a Loop client logs into the FxA server, it will obtain a user-specific symmetric key, '''kB''', and an OAuth application identifier. The key '''kB''' is wrapped with the user's account login password. Upon obtaining the key, the user unwraps '''kB''', combines it with the application identifier, and applies HKDF to obtain a new key, '''kBr'''. We then take this '''kBr''' and combine it with a name for our specific usage ("metadata") to create a new key, '''kRWrapper''', used to wrap the Room Context Keys ('''kR''', described below)


When a client creates a new room, it first generates a new symmetric room key, '''kR'''. It then derives a room metadata-specific key, '''kRm''', via HKDF and the application name "metadata". The room context information is serialized as a JSON object, and encrypted using '''kRm'''. The client also wraps '''kR''' with '''kB'''. The encrypted context information and the wrapped room key '''kR''' are sent to the Loop server as part of the room creation request; these are stored as part of the room's information.
When a client creates a new room, it first generates a new symmetric room key, '''kR'''. The room context information is serialized as a JSON object, and encrypted using '''kR'''. The client also wraps '''kR''' with '''kRWrapper'''. The encrypted context information and the wrapped room key '''wrap(kR)''' are sent to the Loop server as part of the room creation request; these are stored as part of the room's information.


Upon receipt of the resulting room URL from the server, the client appends the room metadata key '''kRm''' to the URL as a URL fragment before storing it locally.
Upon receipt of the resulting room URL from the server, the client appends the room metadata key '''kR''' to the URL as a URL fragment before storing it locally.


Because all desktop clients can constitute their '''kBr''' upon logging in to FxA, any room context retrieved from the Loop server can be decoded by unwrapping the '''kR''' received as part of the room information, deriving the room metadata key '''kRm''' from it, and using it to decrypt the context.
Because all desktop clients can constitute their '''kBr''' upon logging in to FxA, any room context retrieved from the Loop server can be decoded by unwrapping the '''kR''' received as part of the room information and using it to decrypt the context.


Standalone clients receive the room metadata key '''kRm''' in the fragment portion of the URL that was provided to them as the means of joining the room. Upon retrieving the encrypted room context information from the server, they use this '''kRm''' to decode the room context information and display it to the user.
Standalone clients receive the room metadata key '''kR''' in the fragment portion of the URL that was provided to them as the means of joining the room. Upon retrieving the encrypted room context information from the server, they use this '''kR''' to decode the room context information and display it to the user.


<center>[[File:Loop-keys.png|Information flow in Loop key handling]]</center>
<center>[[File:Loop-keys.png|Information flow in Loop key handling]]</center>
Line 33: Line 33:
Where IV is 12 bytes in length, and tag is 16 bytes (128 bits) in length.
Where IV is 12 bytes in length, and tag is 16 bytes (128 bits) in length.


Encryption consists of selecting a random 12-byte IV value. This IV, the plaintext JSON representation of the room context fields, and '''kRm''' are used as input to the AES-GCM encryption algorithm, which is configured to generate a 128-bit validation tag. The IV is then concatenated with the ciphertext and the validation tag. The resulting bytestring is Base64 encoded, and included as the "context.value" field in the appropriate Loop Server API call, alongside the wrapped room key '''kR''' and the algorithm name ("AES-GCM").
Encryption consists of selecting a random 12-byte IV value. This IV, the plaintext JSON representation of the room context fields, and '''kR''' are used as input to the AES-GCM encryption algorithm, which is configured to generate a 128-bit validation tag. The IV is then concatenated with the ciphertext and the validation tag. The resulting bytestring is Base64 encoded, and included as the "context.value" field in the appropriate Loop Server API call, alongside the wrapped room key '''wrap(kR)''' and the algorithm name ("AES-GCM").


Decryption consists of Base64 decoding the "context" field, splitting off the first 12 bytes for use as an IV, and splitting off the final 16 bytes as the validation tag. These are then used as input to the AES-GCM decryption algorithm (along with '''kRm'''), the output of which is a JSON object containing fields that correspond to the various room context information fields.
Decryption consists of Base64 decoding the "context" field, splitting off the first 12 bytes for use as an IV, and splitting off the final 16 bytes as the validation tag. These are then used as input to the AES-GCM decryption algorithm (along with '''kR'''), the output of which is a JSON object containing fields that correspond to the various room context information fields.


The "key" field is encrypted, formatted, and decrypted similarly, but using '''kBr''' rather than '''kRm''' as the encryption key, and using '''kR''' as the cleartext.
The "key" field is encrypted, formatted, and decrypted similarly, but using '''kBr''' rather than '''kR''' as the encryption key, and using '''kR''' as the cleartext.


== Loop Server API Changes ==
== Loop Server API Changes ==
Confirmed users
632

edits

Navigation menu