renaming sync.fsm into devicegroup.fsm
authorVolker Birk <vb@pep-project.org>
Sat, 09 Jul 2016 11:38:20 +0200
changeset 8093a8dced942e3
parent 808 e5f072423edc
child 810 0c07d4583315
renaming sync.fsm into devicegroup.fsm
sync/Makefile
sync/devicegroup.fsm
sync/sync.fsm
     1.1 --- a/sync/Makefile	Sat Jul 09 11:35:23 2016 +0200
     1.2 +++ b/sync/Makefile	Sat Jul 09 11:38:20 2016 +0200
     1.3 @@ -4,10 +4,10 @@
     1.4  
     1.5  skeleton: .skeletons
     1.6  
     1.7 -.skeletons: sync.fsm gen_actions_skeleton.ysl2 fsm.yml2 functions.ysl2
     1.8 +.skeletons: devicegroup.fsm gen_actions_skeleton.ysl2 fsm.yml2 functions.ysl2
     1.9  	$(YML2PROC) -y gen_actions_skeleton.ysl2 $< -o $@
    1.10  
    1.11 -.statemachines: sync.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2
    1.12 +.statemachines: devicegroup.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2
    1.13  	$(YML2PROC) -y gen_statemachine.ysl2 $< -o $@
    1.14  
    1.15  .PHONY: clean
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/sync/devicegroup.fsm	Sat Jul 09 11:38:20 2016 +0200
     2.3 @@ -0,0 +1,87 @@
     2.4 +// DeviceGroup protocol for p≡p
     2.5 +
     2.6 +// Copyleft (c) 2016, p≡p foundation
     2.7 +
     2.8 +// Written by Volker Birk
     2.9 +
    2.10 +include ./fsm.yml2
    2.11 +
    2.12 +protocol DeviceGroup {
    2.13 +    // all messages have a timestamp, time out and are removed after timeout
    2.14 +
    2.15 +    fsm DeviceState filename=sync {
    2.16 +        state InitState {
    2.17 +            on Init {
    2.18 +                if (storedGroupKeys)
    2.19 +                    go Grouped;
    2.20 +                go Sole;
    2.21 +            }
    2.22 +        }
    2.23 +
    2.24 +        state Sole {
    2.25 +            on KeyGen
    2.26 +                do sendBeacon;
    2.27 +            on CannotDecrypt
    2.28 +                do sendBeacon;  // cry, baby
    2.29 +            on Beacon(Identity partner) // this event will not happen for already
    2.30 +                                        // rejected partners
    2.31 +                do sendHandshakeRequest(partner);
    2.32 +            on HandshakeRequest(Identity partner) {
    2.33 +                do sendHandshakeRequest(partner);
    2.34 +                go HandshakingSole(partner);
    2.35 +            }
    2.36 +        }
    2.37 +
    2.38 +        state HandshakingSole(Identity partner) {
    2.39 +            on Init
    2.40 +                do showHandshake(partner);
    2.41 +            on HandshakeRejected(Identity partner) {
    2.42 +                do reject(partner);             // sends Reject to partner and
    2.43 +                                                // stores rejection of partner
    2.44 +                go Sole;
    2.45 +            }
    2.46 +            on HandshakeAccepted(Identity partner) {
    2.47 +                if keyElectionWon(partner) {    // an already existing group
    2.48 +                                                // always wins
    2.49 +                    ownGroupKeys;
    2.50 +                    sendGroupKeys(partner);
    2.51 +                    go Grouped;
    2.52 +                }
    2.53 +                go WaitForGroupKeys(Identity partner);
    2.54 +            }
    2.55 +        }
    2.56 +    
    2.57 +        state WaitForGroupKeys(Identity partner) {
    2.58 +            on GroupKeys(Identity partner, Stringlist keys) {
    2.59 +                do storeGroupKeys(partner, keys);
    2.60 +                go Grouped;
    2.61 +            }
    2.62 +            on Cancel go Sole;
    2.63 +            on Reject(Identity partner) {
    2.64 +                do reject(partner);
    2.65 +                go Sole;
    2.66 +            }
    2.67 +        }
    2.68 +
    2.69 +        state Grouped {
    2.70 +            on KeyGen
    2.71 +                do sendGroupKeys; // always send all keys
    2.72 +            on HandshakeRequest(Identity partner) {
    2.73 +                do sendHandshakeRequest(partner);
    2.74 +                do showHandshake(partner);
    2.75 +            }
    2.76 +            on HandshakeRejected(Identity partner)
    2.77 +                do reject(partner);
    2.78 +            on HandshakeAccepted(Identity partner)
    2.79 +                do sendGroupKeys(partner);
    2.80 +            on Reject(Identity partner)
    2.81 +                do reject partner;
    2.82 +        }
    2.83 +
    2.84 +        tag InitState 0;
    2.85 +        tag Beacon 1;
    2.86 +        tag HandshakeRequest 2;
    2.87 +        tag GroupKeys 3;
    2.88 +    }
    2.89 +}
    2.90 +
     3.1 --- a/sync/sync.fsm	Sat Jul 09 11:35:23 2016 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,87 +0,0 @@
     3.4 -// DeviceGroup protocol for p≡p
     3.5 -
     3.6 -// Copyleft (c) 2016, p≡p foundation
     3.7 -
     3.8 -// Written by Volker Birk
     3.9 -
    3.10 -include ./fsm.yml2
    3.11 -
    3.12 -protocol DeviceGroup {
    3.13 -    // all messages have a timestamp, time out and are removed after timeout
    3.14 -
    3.15 -    fsm DeviceState filename=sync {
    3.16 -        state InitState {
    3.17 -            on Init {
    3.18 -                if (storedGroupKeys)
    3.19 -                    go Grouped;
    3.20 -                go Sole;
    3.21 -            }
    3.22 -        }
    3.23 -
    3.24 -        state Sole {
    3.25 -            on KeyGen
    3.26 -                do sendBeacon;
    3.27 -            on CannotDecrypt
    3.28 -                do sendBeacon;  // cry, baby
    3.29 -            on Beacon(Identity partner) // this event will not happen for already
    3.30 -                                        // rejected partners
    3.31 -                do sendHandshakeRequest(partner);
    3.32 -            on HandshakeRequest(Identity partner) {
    3.33 -                do sendHandshakeRequest(partner);
    3.34 -                go HandshakingSole(partner);
    3.35 -            }
    3.36 -        }
    3.37 -
    3.38 -        state HandshakingSole(Identity partner) {
    3.39 -            on Init
    3.40 -                do showHandshake(partner);
    3.41 -            on HandshakeRejected(Identity partner) {
    3.42 -                do reject(partner);             // sends Reject to partner and
    3.43 -                                                // stores rejection of partner
    3.44 -                go Sole;
    3.45 -            }
    3.46 -            on HandshakeAccepted(Identity partner) {
    3.47 -                if keyElectionWon(partner) {    // an already existing group
    3.48 -                                                // always wins
    3.49 -                    ownGroupKeys;
    3.50 -                    sendGroupKeys(partner);
    3.51 -                    go Grouped;
    3.52 -                }
    3.53 -                go WaitForGroupKeys(Identity partner);
    3.54 -            }
    3.55 -        }
    3.56 -    
    3.57 -        state WaitForGroupKeys(Identity partner) {
    3.58 -            on GroupKeys(Identity partner, Stringlist keys) {
    3.59 -                do storeGroupKeys(partner, keys);
    3.60 -                go Grouped;
    3.61 -            }
    3.62 -            on Cancel go Sole;
    3.63 -            on Reject(Identity partner) {
    3.64 -                do reject(partner);
    3.65 -                go Sole;
    3.66 -            }
    3.67 -        }
    3.68 -
    3.69 -        state Grouped {
    3.70 -            on KeyGen
    3.71 -                do sendGroupKeys; // always send all keys
    3.72 -            on HandshakeRequest(Identity partner) {
    3.73 -                do sendHandshakeRequest(partner);
    3.74 -                do showHandshake(partner);
    3.75 -            }
    3.76 -            on HandshakeRejected(Identity partner)
    3.77 -                do reject(partner);
    3.78 -            on HandshakeAccepted(Identity partner)
    3.79 -                do sendGroupKeys(partner);
    3.80 -            on Reject(Identity partner)
    3.81 -                do reject partner;
    3.82 -        }
    3.83 -
    3.84 -        tag InitState 0;
    3.85 -        tag Beacon 1;
    3.86 -        tag HandshakeRequest 2;
    3.87 -        tag GroupKeys 3;
    3.88 -    }
    3.89 -}
    3.90 -