133
edits
(Re-authentication) |
(→Architecture Designs: add disconnect and reconnection description) |
||
| (12 intermediate revisions by the same user not shown) | |||
| Line 22: | Line 22: | ||
# Peer authentication | # Peer authentication | ||
# Control event processing | # Control event processing | ||
Any error occurs will close connection between server and client, reconnection is required. Server side error will sends message back to client to let user know what happen on Fennec. | |||
=== Peer authentication === | === Peer authentication === | ||
| Line 33: | Line 35: | ||
# Client computes J-PAKE round 1 and sends the result to server. | # Client computes J-PAKE round 1 and sends the result to server. | ||
# Server generates PIN code and show on screen, computes J-PAKE round 1 and sends the result to client. | # Server generates PIN code and show on screen, computes J-PAKE round 1 and sends the result to client. | ||
# User enter PIN code, client computs J-PAKE round 2 with PIN code attached first 12 characters of server's TLS certificate fingerprint as weak secret. | |||
# User enter PIN code, client computs J-PAKE round 2 with PIN code attached first 12 characters as weak secret. | |||
# Client sends round 2 result to server. | # Client sends round 2 result to server. | ||
# Server computes J-PAKE round 2 with PIN code attached first 12 characters of server's TLS certificate fingerprint as weak secret. | |||
# Server dismisses PIN code notification on screen, sends round 2 result to client. | # Server dismisses PIN code notification on screen, sends round 2 result to client. | ||
# Both client and server compute J-PAKE final round, gets AES and HMAC key. | # Both client and server compute J-PAKE final round, gets AES and HMAC key. | ||
| Line 54: | Line 56: | ||
# Client computes J-PAKE round 1 and sends the result to server. | # Client computes J-PAKE round 1 and sends the result to server. | ||
# Server computes J-PAKE round 1 and sends the result to client. | # Server computes J-PAKE round 1 and sends the result to client. | ||
# Client and server computes J-PAKE round 2 with previous AES key value as weak secret. | # Client and server computes J-PAKE round 2 with first 4 characters of previous AES key value attached first 12 characters of server's TLS certificate fingerprint as weak secret. | ||
# Client sends round 2 result to server. | # Client sends round 2 result to server. | ||
# Server sends round 2 result to client. | # Server sends round 2 result to client. | ||
| Line 67: | Line 69: | ||
=== Control event processing === | === Control event processing === | ||
Control page provides: 1) a virtual touchpad, 2) a virtual vertical scrollbar, 3) 3 function keys. Every touch, swipe or click will be generated to an event in JSON format | Control page provides: 1) a virtual touchpad, 2) a virtual vertical scrollbar, 3) 3 function keys. Every touch, swipe or click will be generated to an event in JSON format then send to TV. Following describes how control event is sent and processed: | ||
[[File:RemoteControl ControlEventProcessing.png]] | [[File:RemoteControl ControlEventProcessing.png]] | ||
# User operates control page. | # User operates control page. | ||
# Client generates | # Client generates and sends the event in JSON format. | ||
# | # Server parses the event to JSON object, dispatch to client.sjs. | ||
# 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 | === Data used in JPAKE authentication === | ||
==== Singer ID for JPAKE round 1 & 2: ==== | |||
* TV: server | |||
* Fennec addon: client | |||
==== Weak secret: ==== | |||
* TV: concatenate PIN and first 12 characters of TLS server cert SHA 256 fingerprint | |||
* Fennec addon: concatenate user input PIN and first 12 characters connected TLS server cert SHA 256 fingerprint | |||
==== HMAC Input for JAPKE final: ==== | |||
We use "AES_256_CBC-HMAC256", as aHkdfInfo, includes the full crypto spec, should be the same in both TV and fennec addon | |||
==== Key confirmation: ==== | |||
Double hash of AES key: | |||
# AES | ## TV converts AES key to array buffer | ||
# | ## Sign AES key array buffer, get signature 1 (array buffer) | ||
# | ## Sign signature 1, get signature 2 | ||
## Convert signature 2 to base 64, send to Fennec addon | |||
## Fennec addon do the same as TV from step 1 to 4 | |||
## Compare received base 64 string of self and TV's signature 2 | |||
Single hash of AES key: | |||
## Fennec addon converts AES key to array buffer | |||
## Sign AES key array buffer, get signature 1 (array buffer) | |||
## Convert signature 1 to base 64, send to TV | |||
## TV use HMAC key, received signature, AES key array buffer to verify if the signature is valid. | |||
==== | === Authentication and Event Protocol === | ||
==== Request handshake ==== | |||
Request | Request | ||
{ | { | ||
action: ' | type: 'auth' | ||
action: 'request_handshake' | |||
detail: { | |||
id: <id assigned by server, optional> | |||
} | |||
} | } | ||
Response | Response | ||
{ | { | ||
type: 'auth' | |||
action: 'response_handshake' | |||
detail: 1 or 2, 1 for 1st handshake, 2 for 2nd handshake | |||
} | } | ||
==== | ==== J-PAKE key exchange ==== | ||
Client send round 1 | |||
{ | { | ||
action: ' | type: 'auth' | ||
action: 'jpake_client_1', | |||
detail: { | |||
gx1: gx1.value, | |||
gx2: gx2.value, | |||
zkp_x1: { gr: gv1.value, b: r1.value, id: 'client' }, | |||
zkp_x2: { gr: gv2.value, b: r2.value, id: 'client' } | |||
} | |||
} | } | ||
Server reply round 1 | |||
{ | { | ||
type: 'auth' | |||
action: 'jpake_server_1', | |||
detail: { | |||
gx1: gx1.value, | |||
gx2: gx2.value, | |||
zkp_x1: { gr: gv1.value, b: r1.value, id: 'server' }, | |||
zkp_x2: { gr: gv2.value, b: r2.value, id: 'server' } | |||
} | |||
} | } | ||
Client send round 2 | |||
{ | { | ||
type: 'auth' | |||
action: 'jpake_client_2', | |||
detail: { | |||
A: A.value, | |||
zkp_A: { gr: gvA.value, b: rA.value, id: 'client' } | |||
} | |||
} | } | ||
Server reply round 2 | |||
{ | { | ||
type: 'auth' | |||
action: 'jpake_server_2', | |||
detail: { | |||
A: A.value, | |||
zkp_A: { gr: gvA.value, b: rA.value, id: 'server' } | |||
} | |||
} | } | ||
==== | ==== Key confirmation ==== | ||
Server key confirmation | |||
{ | { | ||
action: ' | type: 'auth' | ||
action: 'server_key_confirm' | |||
detail: { | |||
signature: <double signature of AES key by HMAC key, in base64> | |||
} | |||
} | } | ||
Client key confirmation | |||
{ | { | ||
type: 'auth' | |||
action: 'client_key_confirmation' | |||
detail: { | |||
signature: <signature of AES key by HMAC key, in base64> | |||
} | |||
action: ' | |||
} | } | ||
Server finish handshake | |||
{ | { | ||
type: 'auth' | |||
action: 'finish_handshake' | |||
detail: { | |||
id: <id assigned by server, optional> | |||
} | |||
} | } | ||
==== Touch Events ==== | ==== Touch Events ==== | ||
{ | { | ||
type: 'touchstart', | type: 'command' | ||
action: 'touchstart', | |||
detail: { | detail: { | ||
width: <touch panel width, integer, in pixels>, | width: <touch panel width, integer, in pixels>, | ||
| Line 187: | Line 204: | ||
{ | { | ||
type: 'touchmove', | type: 'command' | ||
action: 'touchmove', | |||
detail: { | detail: { | ||
dx: <dx between current point and starting point, integer, in pixels>, | dx: <dx between current point and starting point, integer, in pixels>, | ||
| Line 197: | Line 215: | ||
{ | { | ||
type: 'touchend', | type: 'command' | ||
action: 'touchend', | |||
detail: { | detail: { | ||
dx: <same as "touchmove">, | dx: <same as "touchmove">, | ||
| Line 214: | Line 233: | ||
{ | { | ||
type: 'keypress', | type: 'command' | ||
action: 'keypress', | |||
detail: <KeyEvent constant, string, sush as "DOM_VK_RETURN"> | detail: <KeyEvent constant, string, sush as "DOM_VK_RETURN"> | ||
} | } | ||
| Line 221: | Line 241: | ||
{ | { | ||
type: 'textinput', | type: 'command' | ||
action: 'textinput', | |||
detail: { | detail: { | ||
clear: <whether to clear the entire string in the current focused input field, boolean>, | clear: <whether to clear the entire string in the current focused input field, boolean>, | ||
| Line 229: | Line 250: | ||
} | } | ||
==== | ==== Server reply error ==== | ||
{ | { | ||
type: | type: common, or the event type sent from client | ||
error: <error message of exception or root cause> | |||
} | } | ||
== Bug Status == | == Bug Status == | ||
edits