-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhandshake.v
208 lines (151 loc) · 5.15 KB
/
handshake.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
From Ornamental Require Import Ornaments.
(*
* This is a test from a user that ensures record projections lift correctly.
*)
Set DEVOID search prove equivalence.
Set DEVOID lift type.
Set Preprocess default opaque.
Module Handshake.
Definition handshake : Type
:= (bool * bool).
End Handshake.
Module HandshakePP.
Preprocess Module Handshake as HandshakePP.
End HandshakePP.
Import HandshakePP.
Module HandshakeRecord.
Record Handshake :=
MkHandshake
{
handshakeType : bool;
messageNumber : bool;
}.
Scheme Induction for Handshake Sort Prop.
Scheme Induction for Handshake Sort Type.
Scheme Induction for Handshake Sort Set.
Definition get_handshake_type (h : HandshakePP.handshake) : bool :=
fst h.
Definition get_message_number (h : HandshakePP.handshake) : bool :=
snd h.
End HandshakeRecord.
Preprocess Module HandshakeRecord as HandshakeRecordPP.
Module HandshakeLift.
Lift HandshakePP.handshake
HandshakeRecordPP.Handshake
in HandshakeRecordPP.get_handshake_type
as getHandshakeType.
Lift HandshakePP.handshake
HandshakeRecordPP.Handshake
in HandshakeRecordPP.get_message_number
as getMessageNumber.
End HandshakeLift.
Module Connection.
Definition connection : Type
:= (bool (* client_auth_flag *)
* (bool (* corked *)
* (bool (* corked_io *)
* (Handshake.handshake
* (bool (* is_caching_enabled *)
* (bool (* key_exchange_eph *)
* (bool (* mode *)
* (bool (* resume_from_cache *)
* nat (* server_can_send_ocsp *)
)
)
)
)
)
)
)
)
.
End Connection.
Module ConnectionPP.
Preprocess Module Connection as ConnectionPP.
End ConnectionPP.
Import ConnectionPP.
Module ConnectionRecord.
Record Connection :=
MkConnection
{
clientAuthFlag : bool;
corked : bool;
corkedIO : bool;
handshake : HandshakeRecord.Handshake;
isCachingEnabled : bool;
keyExchangeEPH : bool;
mode : bool;
resumeFromCache : bool;
serverCanSendOCSP : nat;
}.
Scheme Induction for Connection Sort Prop.
Scheme Induction for Connection Sort Type.
Scheme Induction for Connection Sort Set.
Definition get_client_auth_flag (c : Connection.connection) : bool :=
fst c.
Definition get_corked (c : Connection.connection) : bool :=
fst (snd c).
Definition get_corked_IO (c : Connection.connection) : bool :=
fst (snd (snd c)).
Definition get_handshake (c : Connection.connection) : Handshake.handshake :=
fst (snd (snd (snd c))).
Definition get_is_caching_enabled (c : Connection.connection) : bool :=
fst (snd (snd (snd (snd c)))).
Definition get_key_exchange_EPH (c : Connection.connection) : bool :=
fst (snd (snd (snd (snd (snd c))))).
Definition get_mode (c : Connection.connection) : bool :=
fst (snd (snd (snd (snd (snd (snd c)))))).
Definition get_resume_from_cache (c : Connection.connection) : bool :=
fst (snd (snd (snd (snd (snd (snd (snd c))))))).
Definition get_server_can_send_ocsp (c : Connection.connection) : nat :=
snd (snd (snd (snd (snd (snd (snd (snd c))))))).
End ConnectionRecord.
Preprocess Module ConnectionRecord as ConnectionRecordPP0.
Print ConnectionRecordPP0.
Lift Module HandshakePP.handshake
HandshakeRecordPP.Handshake
in ConnectionRecordPP0
as ConnectionRecordPP1.
(* We need to be able to talk about the type that is just like ConnectionPP.connection, but with
HandshakePP.handshake replaced with HandshakeRecordPP.Handshake.
*)
Lift Handshake.handshake
HandshakeRecordPP.Handshake
in ConnectionPP.connection
as ConnectionPPHandshakeRecordPP. (* used to be connectionPP *)
Check (ConnectionRecordPP1.get_corked : ConnectionPPHandshakeRecordPP -> bool).
Lift HandshakeRecord.Handshake
HandshakeRecordPP.Handshake
in ConnectionRecordPP1.Connection
as connectionRecordPP.
Print ConnectionRecordPP1.Connection.
Print ConnectionRecordPP1.
Print ConnectionPPHandshakeRecordPP.
Print connectionRecordPP.
Print ConnectionRecordPP1.
Find ornament ConnectionPPHandshakeRecordPP connectionRecordPP.
(* Problem 1: all liftings appear to fail here *)
Lift Module
ConnectionPPHandshakeRecordPP (* used to be connectionPP *)
connectionRecordPP (* used to be connectionRecordPP *)
in ConnectionRecordPP1
as ConnectionRecordPP.
(* Trying one field manually: *)
Lift HandshakePP.handshake
HandshakeRecordPP.Handshake
in ConnectionRecordPP0.get_corked
as getCorked0.
Check (getCorked0 : ConnectionPPHandshakeRecordPP -> bool).
(* indeed it ought to be the same: *)
Lemma check1 : getCorked0 = ConnectionRecordPP1.get_corked.
Proof.
reflexivity.
Qed.
(*
this fails here, but in my original file, it succeeds, and I'm having trouble
figuring out where I must have made a mistake...
*)
Lift ConnectionPPHandshakeRecordPP
connectionRecordPP
in getCorked0
as getCorked.