Rev 9987 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9987 | Rev 9990 | ||
---|---|---|---|
Line 60... | Line 60... | ||
60 | 60 | ||
61 | lea ecx, [ebx+sshlib_connection.rx_crypt_ctx] |
61 | lea ecx, [ebx+sshlib_connection.rx_crypt_ctx] |
62 | lea edx, [ebx+sshlib_connection.rx_enc_key+256/8] |
62 | lea edx, [ebx+sshlib_connection.rx_enc_key+256/8] |
63 | lea esi, [ebx+sshlib_connection.rx_buffer] |
63 | lea esi, [ebx+sshlib_connection.rx_buffer] |
64 | lea edi, [data_length] |
64 | lea edi, [data_length] |
Line 65... | Line 65... | ||
65 | invoke chacha20_oneshot, ecx, edx, eax, 0, esi, 4, edi |
65 | invoke chacha20.oneshot, ecx, edx, eax, 0, esi, 4, edi |
66 | 66 | ||
67 | mov eax, [data_length] |
67 | mov eax, [data_length] |
68 | bswap eax |
68 | bswap eax |
Line 92... | Line 92... | ||
92 | mov ebx, [con_ptr] |
92 | mov ebx, [con_ptr] |
93 | lea eax, [ebx+sshlib_connection.rx_crypt_ctx] |
93 | lea eax, [ebx+sshlib_connection.rx_crypt_ctx] |
94 | lea esi, [ebx+sshlib_connection.rx_enc_key] |
94 | lea esi, [ebx+sshlib_connection.rx_enc_key] |
95 | lea edx, [mac_otk] |
95 | lea edx, [mac_otk] |
96 | lea ecx, [iv] |
96 | lea ecx, [iv] |
97 | invoke chacha20_oneshot, eax, esi, ecx, 0, null_bytes, 64, edx |
97 | invoke chacha20.oneshot, eax, esi, ecx, 0, null_bytes, 64, edx |
Line 98... | Line 98... | ||
98 | 98 | ||
99 | ; Calculate the MAC |
99 | ; Calculate the MAC |
100 | lea esi, [ebx+sshlib_connection.rx_mac_ctx] |
100 | lea esi, [ebx+sshlib_connection.rx_mac_ctx] |
101 | lea edi, [ebx+sshlib_connection.rx_buffer] |
101 | lea edi, [ebx+sshlib_connection.rx_buffer] |
102 | mov ecx, [data_length] |
102 | mov ecx, [data_length] |
103 | add ecx, 4 |
103 | add ecx, 4 |
104 | lea edx, [mac_otk] |
104 | lea edx, [mac_otk] |
105 | push ecx |
105 | push ecx |
106 | invoke poly1305_oneshot, esi, edi, ecx, edx, 256/8 |
106 | invoke poly1305.oneshot, esi, edi, ecx, edx, 256/8 |
Line 107... | Line 107... | ||
107 | pop ecx |
107 | pop ecx |
108 | 108 | ||
109 | ; Compare in constant time |
109 | ; Compare in constant time |
Line 124... | Line 124... | ||
124 | jne .mac_fail |
124 | jne .mac_fail |
Line 125... | Line 125... | ||
125 | 125 | ||
126 | ; Decrypt the payload |
126 | ; Decrypt the payload |
127 | lea eax, [ebx+sshlib_connection.rx_crypt_ctx] |
127 | lea eax, [ebx+sshlib_connection.rx_crypt_ctx] |
128 | lea edi, [ebx+sshlib_connection.rx_buffer+4] |
128 | lea edi, [ebx+sshlib_connection.rx_buffer+4] |
Line 129... | Line 129... | ||
129 | invoke chacha20_update, eax, edi, [data_length], edi |
129 | invoke chacha20.update, eax, edi, [data_length], edi |
130 | 130 | ||
131 | ; Put decrypted length in rx buffer |
131 | ; Put decrypted length in rx buffer |
Line 238... | Line 238... | ||
238 | pop dword[eax+12] |
238 | pop dword[eax+12] |
Line 239... | Line 239... | ||
239 | 239 | ||
240 | lea esi, [ebx+sshlib_connection.tx_crypt_ctx] |
240 | lea esi, [ebx+sshlib_connection.tx_crypt_ctx] |
241 | lea edx, [ebx+sshlib_connection.tx_enc_key+256/8] |
241 | lea edx, [ebx+sshlib_connection.tx_enc_key+256/8] |
242 | lea edi, [ebx+sshlib_connection.tx_buffer] |
242 | lea edi, [ebx+sshlib_connection.tx_buffer] |
Line 243... | Line 243... | ||
243 | invoke chacha20_oneshot, esi, edx, eax, 0, edi, 4, edi |
243 | invoke chacha20.oneshot, esi, edx, eax, 0, edi, 4, edi |
244 | 244 | ||
245 | ; Calculate the OTK |
245 | ; Calculate the OTK |
246 | lea eax, [iv] |
246 | lea eax, [iv] |
247 | lea edx, [ebx+sshlib_connection.tx_enc_key] |
247 | lea edx, [ebx+sshlib_connection.tx_enc_key] |
Line 248... | Line 248... | ||
248 | lea edi, [mac_otk] |
248 | lea edi, [mac_otk] |
249 | invoke chacha20_oneshot, esi, edx, eax, 0, null_bytes, 64, edi |
249 | invoke chacha20.oneshot, esi, edx, eax, 0, null_bytes, 64, edi |
250 | 250 | ||
251 | ; Encrypt the payload |
251 | ; Encrypt the payload |
252 | lea edi, [ebx+sshlib_connection.tx_buffer+4] |
252 | lea edi, [ebx+sshlib_connection.tx_buffer+4] |
Line 253... | Line 253... | ||
253 | mov eax, [packet_size] |
253 | mov eax, [packet_size] |
254 | sub eax, 4 |
254 | sub eax, 4 |
255 | invoke chacha20_update, esi, edi, eax, edi |
255 | invoke chacha20.update, esi, edi, eax, edi |
256 | 256 | ||
257 | ; Calculate the MAC |
257 | ; Calculate the MAC |
Line 258... | Line 258... | ||
258 | lea esi, [ebx+sshlib_connection.tx_mac_ctx] |
258 | lea esi, [ebx+sshlib_connection.tx_mac_ctx] |
259 | lea edi, [ebx+sshlib_connection.tx_buffer] |
259 | lea edi, [ebx+sshlib_connection.tx_buffer] |
260 | lea edx, [mac_otk] |
260 | lea edx, [mac_otk] |
261 | invoke poly1305_oneshot, esi, edi, [packet_size], edx, 256/8 |
261 | invoke poly1305.oneshot, esi, edi, [packet_size], edx, 256/8 |