From: rtrimana Date: Mon, 8 Aug 2016 23:02:28 +0000 (-0700) Subject: Adding checks to slots range when reading X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=commitdiff_plain;h=fd4dfb7fb1099d8617c86398c5ca349e5e583643 Adding checks to slots range when reading --- diff --git a/doc/iotcloud.tex b/doc/iotcloud.tex index 876935a..b85fc02 100644 --- a/doc/iotcloud.tex +++ b/doc/iotcloud.tex @@ -350,7 +350,6 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \begin{algorithmic}[1] \Function{AddCRLivEnt}{$CR_{s_{live}},cr_s$} -%\State $cr_s \gets GetCR(de_s)$ \State $cr_t \gets GetLiveCR(CR_{s_{live}},cr_s)$ \If{$cr_t = \emptyset$} \State $CR_{s_{live}} \gets CR_{s_{live}} \cup \{cr_s\}$\Comment{First occurrence} @@ -427,6 +426,28 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \EndProcedure \end{algorithmic} +\begin{algorithmic}[1] +\Procedure{CheckSlotsRange}{$|SL_s|,s_{s_{min}},s_{s_{max}}$} +\State $sz_{SL} \gets s_{s_{max}} - s_{s_{min}} + 1$ +\If{$sz_{SL} \neq |SL_s|$} + \State \Call{Error}{'Sequence numbers range does not match slots set'} +\EndIf +\State $s_{min} \gets MinLastSeqN(MS)$ +\State $s_{max} \gets MaxLastSeqN(MS)$ +\If{$s_{s_{min}} \leq s_{min}$} + \State \Call{Error}{'Server sent old slot'} +\EndIf +\If{$s_{s_{max}} > s_{max}$} + \State \Call{Error}{'Server sent out-of-range slot'} +\EndIf +\State $s_{self} \gets MS_s[id_{self}]$ +\State $sz_{expected} \gets s_{max} - s_{self} + 1$ +\If{$sz_{SL} \neq sz_{expected}$} + \State \Call{Error}{'Actual number of slots does not match expected'} +\EndIf +\EndProcedure +\end{algorithmic} + \begin{algorithmic}[1] \Function{StoreLastSlot}{$MS_s,sl_l,s_s,sv_s,id_s$} \State $s_{min} \gets MinLastSeqN(MS_s)$ @@ -459,7 +480,6 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \begin{algorithmic}[1] \Procedure{ProcessSL}{$SL_g$} \State $MS_g \gets \emptyset$ -%\State $SM_{curr} \gets \emptyset$ \State $\tuple{s_{g_{min}},sv_{g_{min}}} \gets MinSlot(SL_g)$ \State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$ \For{$s_g \gets s_{g_{min}}$ \textbf{to} $s_{g_{max}}$}\Comment{Process slots @@ -467,7 +487,6 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \State $\tuple{s_g,sv_g} \gets Slot(SL_g,s_g)$ \State $Dat_g \gets Decrypt(SK,sv_g)$ \State $id_g \gets GetMacId(Dat_g)$ - %\State $SM_{curr} \gets SM_{curr} \cup \{\tuple{s_g,id_g}\}$ \State $SM \gets SM \cup \{\tuple{s_g,id_g}\}$ \State $s_{g_{in}} \gets GetSeqN(Dat_g)$ \If{$s_g \neq s_{g_{in}}$} @@ -476,7 +495,7 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \State $DE_g \gets GetDatEnt(Dat_g)$ \State $hmac_{p_{stored}} \gets GetPrevHmac(Dat_g)$ \If{$\neg \Call{ValidPrevHmac}{s_g,DE_g,hmac_{p_g},hmac_{p_{stored}}}$} - \State \Call{ReportError}{'Invalid previous HMAC value'} + \State \Call{Error}{'Invalid previous HMAC value'} \EndIf \State $hmac_{c_g} \gets GetCurrHmac(Dat_g)$ \If{$\neg \Call{ValidHmac}{DE_g,SK,hmac_{c_g}}$} @@ -504,19 +523,18 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \ForAll{$de_{g_{cr}} \in DE_{g_{cr}}$} \State $cr_g \gets GetCR(de_{g_{cr}})$ \State $\Call{CheckCollision}{MS,SM,cr_g}$ - %\State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},de_{g_{cr}}}$ \State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},cr_g}$ \EndFor \EndIf \State $sl_{last} \gets \Call{StoreLastSlot}{MS,sl_{last},s_g,sv_g,id_g}$ \State $DT \gets \Call{UpdateDT}{DT,DE_g,LV,s_g}$ \EndFor -%\State $SM \gets SM_{curr}$ \If{$m + |SL_g| \leq max_g$}\Comment{Check actual size against $max_g$} \State $m \gets m + |SL_g|$ \Else \State \Call{Error}{'Actual $SL$ size on server exceeds $max_g$'} \EndIf +\State $\Call{CheckSlotsRange}{SL_g,s_{g_{min}},s_{g_{max}}}$ \State $\Call{CheckLastSeqN}{MS_g,MS}$ \State $\Call{UpdateSSLivEnt}{SS_{live},MS}$ \State $\Call{UpdateCRLivEnt}{CR_{live},MS}$ @@ -543,10 +561,6 @@ $MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \subsubsection{Writing Slots} \textbf{States} \\ \textit{$cp$ = data entry $DE$ maximum size/capacity} \\ -%\textit{$cr_p$ = saved cr entry $\tuple{s,id}$ on client if there is a collision -%(sent in the following slot)} \\ -%\textit{$cr_{p_{last}}$ = saved cr entry $\tuple{s,id}$ on client if there is a -%collision in reinserting the last slot (sent in the following slot)} \\ \textit{$ck_p$ = counter of $kv \in KV$ for putting pairs (initially 0)} \\ \textit{$ck_g$ = counter of $kv \in KV$ for getting pairs (initially 0)} \\ \textit{$cs_p$ = counter of $ss \in SS$ for putting pairs (initially 0)} \\ @@ -639,6 +653,9 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \begin{algorithmic}[1] \Function{HandleCollision}{$SL_s,s_s$} +\If{$SL_s = \emptyset$} + \State \Call{Error}{'No slots received from server'} +\EndIf \State $\tuple{s_{col},sv_{col}} \gets GetColSeqN(SL_s,s_s)$ \State $Dat_{col} \gets Decrypt(SK,sv_{col})$ \State $id_{col} \gets GetMacId(Dat_{col})$