diff options
Diffstat (limited to 'ProtocolBuffers.hs')
-rw-r--r-- | ProtocolBuffers.hs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/ProtocolBuffers.hs b/ProtocolBuffers.hs index 6d02096..53dfca0 100644 --- a/ProtocolBuffers.hs +++ b/ProtocolBuffers.hs @@ -40,7 +40,9 @@ data MessageP a data ActivityP a = ActivityP { activityP :: Required 6 (Message a) - , prevAtivityP :: Optional 7 (Message HashP) + -- This is not included, because the hash is never actually sent + -- over the wire! + -- , prevAtivityP :: Optional 7 (Message HashP) , elapsedTimeP :: Required 8 (Message ElapsedTimeP) , activitySignatureP :: Required 9 (Message SignatureP) } @@ -63,12 +65,6 @@ data ControlActionP { sessionKeyRejectedP :: Required 15 (Message PublicKeyP) } deriving (Generic) -data HashP = HashP - { hashMethodP :: Required 16 (Value B.ByteString) - , hashValueP :: Required 17 (Value B.ByteString) - } - deriving (Generic) - data SignatureP = Ed25519SignatureP { ed25519SignatureP :: Required 18 (Value B.ByteString) } @@ -141,13 +137,12 @@ instance ProtocolBuffer (ActivityP p) (T.Activity t) => ProtocolBuffer (MessageP instance ProtocolBuffer p t => ProtocolBuffer (ActivityP p) (T.Activity t) where toProtocolBuffer t = ActivityP { activityP = putField $ toProtocolBuffer $ T.activity t - , prevAtivityP = putField $ fmap toProtocolBuffer $ T.prevActivity t , elapsedTimeP = putField $ toProtocolBuffer $ T.elapsedTime t , activitySignatureP = putField $ toProtocolBuffer $ T.activitySignature t } fromProtocolBuffer p = T.Activity { T.activity = fromProtocolBuffer $ getField $ activityP p - , T.prevActivity = fmap fromProtocolBuffer $ getField $ prevAtivityP p + , T.prevActivity = Nothing -- not sent over the wire , T.elapsedTime = fromProtocolBuffer $ getField $ elapsedTimeP p , T.activitySignature = fromProtocolBuffer $ getField $ activitySignatureP p } @@ -180,21 +175,6 @@ instance ProtocolBuffer ControlActionP T.ControlAction where fromProtocolBuffer p@(SessionKeyRejectedP {}) = T.SessionKeyRejected $ fromProtocolBuffer $ getField $ sessionKeyRejectedP p -instance ProtocolBuffer HashP T.Hash where - toProtocolBuffer t = HashP - { hashMethodP = putField $ case T.hashMethod t of - T.SHA256 -> "2" - T.SHA3 -> "3" - , hashValueP = putField $ val $ T.hashValue t - } - fromProtocolBuffer p = T.Hash - { T.hashMethod = case getField (hashMethodP p) of - "2" -> T.SHA256 - "3" -> T.SHA3 - _ -> T.SHA256 - , T.hashValue = Val $ getField $ hashValueP p - } - instance ProtocolBuffer SignatureP T.Signature where toProtocolBuffer (T.Ed25519Signature t) = Ed25519SignatureP { ed25519SignatureP = putField $ val t } @@ -252,8 +232,6 @@ instance Encode ControlP instance Decode ControlP instance Encode ControlActionP instance Decode ControlActionP -instance Encode HashP -instance Decode HashP instance Encode SignatureP instance Decode SignatureP instance Encode PublicKeyP |