@@ -44,7 +44,7 @@ def initialize(info = {})
44
44
# Setting up variables and calling cipher inits with file paths from configuration
45
45
#
46
46
def setup_ciphers
47
- @state = :idState
47
+ @state = :id_state
48
48
@buffer = ''
49
49
@inbuffer = ''
50
50
@encryption_queue = [ ]
@@ -73,12 +73,12 @@ def send_recv(packet_payload)
73
73
begin
74
74
# send the first message
75
75
id
76
- # Condition to get out of the while loop: ackState to false. Unsafe? Maybe a timeout?
76
+ # Condition to get out of the while loop: ack_state to false. Unsafe? Maybe a timeout?
77
77
while @keep_reading_socket
78
78
process_data ( sock . get_once )
79
79
end
80
80
rescue Errno ::ECONNRESET
81
- if @state == :metakeyState
81
+ if @state == :metakey_state
82
82
fail 'Server reset the connection. Probably rejecting ' \
83
83
'the private key and/or client name (e.g. client name not associated ' \
84
84
'with client public key on server side). ' \
@@ -138,15 +138,15 @@ def process_data(data)
138
138
@inbuffer += data
139
139
end
140
140
case @state
141
- when :idState
141
+ when :id_state
142
142
if line?
143
143
data = read_line
144
144
vprint_status ( "Received ID from server: [#{ data [ 0 ..30 ] } ]" )
145
- @state = :metakeyState
145
+ @state = :metakey_state
146
146
# next expected state
147
147
metakey
148
148
end
149
- when :metakeyState
149
+ when :metakey_state
150
150
if line?
151
151
data = read_line
152
152
vprint_status ( "Received Metakey from server: [#{ data [ 0 ..30 ] } ...]" )
@@ -174,10 +174,10 @@ def process_data(data)
174
174
# don't forget, it *does* matter if you do a
175
175
# @bf_dec_cipher.reset or not, we're in OFB mode. DON'T.
176
176
vprint_status ( 'Metakey handshake/exchange completed' )
177
- @state = :challengeState
177
+ @state = :challenge_state
178
178
challenge
179
179
end
180
- when :challengeState
180
+ when :challenge_state
181
181
need_len = 2 * @client_key_len + 3
182
182
if @inbuffer . length >= need_len
183
183
data = pop_inbuffer_and_decrypt ( need_len )
@@ -188,25 +188,25 @@ def process_data(data)
188
188
challenge2 = data [ 1 ] [ 0 ...2 * @client_key_len ]
189
189
challenge2 = [ challenge2 ] . pack ( 'H*' )
190
190
fail "Error in protocol. challenge2 length should be #{ @client_key_len } ." unless challenge2 . length == @client_key_len
191
- @state = :challengeReplyState
191
+ @state = :challenge_reply_state
192
192
challenge_reply ( challenge2 )
193
193
end
194
- when :challengeReplyState
194
+ when :challenge_reply_state
195
195
need_len = 43
196
196
if @inbuffer . length >= need_len
197
197
data = pop_inbuffer_and_decrypt ( need_len )
198
198
vprint_status ( "Received challenge reply from server:" \
199
199
" [#{ data . unpack ( 'H*' ) [ 0 ] [ 0 ..30 ] } ...]" )
200
- @state = :ackState
200
+ @state = :ack_state
201
201
ack
202
202
end
203
- when :ackState
203
+ when :ack_state
204
204
need_len = 12
205
205
if @inbuffer . length >= need_len
206
206
data = pop_inbuffer_and_decrypt ( need_len )
207
207
vprint_status ( "Received ack (server accepted challenge response):" \
208
208
"[#{ data . unpack ( 'H*' ) [ 0 ] [ 0 ..30 ] } ...]" )
209
- @state = :doneState
209
+ @state = :done_state
210
210
send_packet
211
211
end
212
212
end
0 commit comments