Research Article

C-Lock: Local Network Resilient Port Knocking System Based on TOTP

Algorithm 1

Port generation algorithm.
Initialization
1: tSlot ← epochT imestamp()//30           {//means integer division}
2: totp ← hotp(tSlot, sk)           {e.g.123456}
Strategy A
1: forn ←0to 3 do
2:begin
3:aux ← hotp(n, totp)
4:port[n]  (aux%65534) +1           {0 < port<65535}
5:end
Strategy B
1: mask ← 0xC030           {0xC030 = 49200}
2:paux[0]  (totp//1e4)           {e.g.12}
3:paux[1]  (totp//1e2)  (paux[0]1e2)           {e.g.34}
4:paux[2]  (totp)  (paux[1]1e2)  (paux[0]1e4)           {e.g.56}
5: forn ←0to 3 do
6:begin
7:port[n] ← mask + paux[n]         {port[0] = 0xC030+12 = 49212}
8:end