Firefox OS/Remote Control: Difference between revisions

→‎Architecture Designs: Add notices of data encryption/decryption
(→‎Control event processing: Add steps of control event processing)
(→‎Architecture Designs: Add notices of data encryption/decryption)
Line 74: Line 74:
# Client.sjs decrypts event with symmetric key received in establish secure connection.
# Client.sjs decrypts event with symmetric key received in establish secure connection.
# Client.sjs parses event and dispatch to Gecko or Gaia system app.
# Client.sjs parses event and dispatch to Gecko or Gaia system app.
=== Data encryption/decryption ===
There are three kinds of data are encrypted while tranmission:
# Client polls '''UUID''' in establish secure connection stage
# Client sends '''PIN code''' in pin code pairing
# Client sends '''event''' in control event processing
As data are encrypted by symmetric key, AES-GCM, there are two things need noticed:
# AES-GCM need initialization vector(IV) to encrypt/decrypt. Currently, IV is random value for each data, length is 12 bytes. Encrypted data is appended after IV. Receiver needs to slice first 12 bytes as IV to decrypt.
# Each message type is string, use [https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encode TextEncoder.encode()] to encode as an UInt8Array, then encrypt to ArrayBuffer. Vice versa.
# Data encryption/decryption is asynchronous but HTTP request need response immediately. For UUID and PIN code case, remote control uses a ticket number to get status after decryption. But for event, we reduce polling result but use latest event's result instead.


=== Ajax Protocol ===
=== Ajax Protocol ===
133

edits