Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9164 → Rev 9216

/programs/network/ssh/hmac_md5.inc
20,10 → 20,12
; To compute HMAC over the data `text' we perform
; H(K XOR opad, H(K XOR ipad, text))
 
MD5_BLOCK_SIZE = 64
 
struct hmac_md5_context
hash rb MD5_HASH_SIZE
ipad_ctx crash_ctx
opad_ctx crash_ctx
hash rb MD5_LEN
ipad_ctx rb LIBCRASH_CTX_LEN
opad_ctx rb LIBCRASH_CTX_LEN
ends
 
; We will precompute partial hashes of K XOR ipad and K XOR opad,
/programs/network/ssh/hmac_sha1.inc
20,10 → 20,12
; To compute HMAC over the data `text' we perform
; H(K XOR opad, H(K XOR ipad, text))
 
SHA1_BLOCK_SIZE = 64
 
struct hmac_sha1_context
hash rb SHA1_HASH_SIZE
ipad_ctx crash_ctx
opad_ctx crash_ctx
hash rb SHA1_LEN
ipad_ctx rb LIBCRASH_CTX_LEN
opad_ctx rb LIBCRASH_CTX_LEN
ends
 
; We will precompute partial hashes of K XOR ipad and K XOR opad,
/programs/network/ssh/hmac_sha256.inc
20,10 → 20,12
; To compute HMAC over the data `text' we perform
; H(K XOR opad, H(K XOR ipad, text))
 
SHA2_256_BLOCK_SIZE = 64
 
struct hmac_sha256_context
hash rb SHA256_HASH_SIZE
ipad_ctx crash_ctx
opad_ctx crash_ctx
hash rb SHA2_256_LEN
ipad_ctx rb LIBCRASH_CTX_LEN
opad_ctx rb LIBCRASH_CTX_LEN
ends
 
; We will precompute partial hashes of K XOR ipad and K XOR opad,
32,7 → 34,7
proc hmac_sha256_setkey ctx, key, key_length
 
locals
k_temp rb SHA256_BLOCK_SIZE
k_temp rb SHA2_256_BLOCK_SIZE
endl
 
pusha
39,7 → 41,7
 
; input esi = key, ecx=key_length
mov ecx, [key_length]
cmp ecx, SHA256_BLOCK_SIZE
cmp ecx, SHA2_256_BLOCK_SIZE
ja .hash_it
; Key is smaller then or equal to blocksize,
; copy key to ipad
46,7 → 48,7
mov esi, [key]
lea edi, [k_temp]
rep movsb
mov ecx, SHA256_BLOCK_SIZE
mov ecx, SHA2_256_BLOCK_SIZE
sub ecx, [key_length]
jz .finish
; append zeros to the key
56,21 → 58,21
 
; Given key is larger then key size, hash it
.hash_it:
invoke sha256_init, [ctx]
invoke sha256_update, [ctx], [key], [key_length]
invoke sha256_final, [ctx]
invoke sha2_256_init, [ctx]
invoke sha2_256_update, [ctx], [key], [key_length]
invoke sha2_256_finish, [ctx]
mov esi, [ctx]
lea edi, [k_temp]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
xor eax, eax
mov ecx, (SHA256_BLOCK_SIZE-SHA256_HASH_SIZE)/4
mov ecx, (SHA2_256_BLOCK_SIZE-SHA2_256_LEN)/4
rep stosd
 
.finish:
; xor ipad buffer with 0x36363...
lea esi, [k_temp]
mov ecx, SHA256_BLOCK_SIZE/4
mov ecx, SHA2_256_BLOCK_SIZE/4
@@:
xor dword[esi], 0x36363636 ; ipad constant
add esi, 4
80,19 → 82,19
; Init our hash with k_xor_ipad
mov ebx, [ctx]
lea edi, [ebx+hmac_sha256_context.ipad_ctx]
invoke sha256_init, edi
invoke sha2_256_init, edi
 
lea esi, [k_temp]
DEBUGF 1, "HASH: "
stdcall dump_hex, esi, SHA256_BLOCK_SIZE/4
stdcall dump_hex, esi, SHA2_256_BLOCK_SIZE/4
 
mov ebx, [ctx]
lea edi, [ebx+hmac_sha256_context.ipad_ctx]
invoke sha256_update, edi, esi, SHA256_BLOCK_SIZE
invoke sha2_256_update, edi, esi, SHA2_256_BLOCK_SIZE
 
; xor opad buffer with 0x5c5c5...
lea esi, [k_temp]
mov ecx, SHA256_BLOCK_SIZE/4
mov ecx, SHA2_256_BLOCK_SIZE/4
@@:
xor dword[esi], 0x36363636 xor 0x5c5c5c5c ; opad constant
add esi, 4
102,15 → 104,15
; Init our hash with k_xor_opad
mov ebx, [ctx]
lea edi, [ebx+hmac_sha256_context.opad_ctx]
invoke sha256_init, edi
invoke sha2_256_init, edi
 
lea esi, [k_temp]
DEBUGF 1, "HASH: "
stdcall dump_hex, esi, SHA256_BLOCK_SIZE/4
stdcall dump_hex, esi, SHA2_256_BLOCK_SIZE/4
 
mov ebx, [ctx]
lea edi, [ebx+hmac_sha256_context.opad_ctx]
invoke sha256_update, edi, esi, SHA256_BLOCK_SIZE
invoke sha2_256_update, edi, esi, SHA2_256_BLOCK_SIZE
 
popa
ret
124,8 → 126,8
proc hmac_sha256 ctx, _data, _length
 
locals
inner_ctx crash_ctx
outer_ctx crash_ctx
inner_ctx rb LIBCRASH_CTX_LEN
outer_ctx rb LIBCRASH_CTX_LEN
endl
 
pusha
138,30 → 140,30
mov esi, [ctx]
lea esi, [esi+hmac_sha256_context.ipad_ctx]
lea edi, [inner_ctx]
repeat (sizeof.crash_ctx)/4*2
repeat (LIBCRASH_CTX_LEN)/4*2
movsd
end repeat
 
; Append provided data to inner hash and finalize
lea ebx, [inner_ctx]
invoke sha256_update, ebx, [_data], [_length]
invoke sha2_256_update, ebx, [_data], [_length]
lea ebx, [inner_ctx]
invoke sha256_final, ebx
invoke sha2_256_finish, ebx
 
DEBUGF 1, "Inner Hash: "
lea esi, [inner_ctx.hash]
stdcall dump_hex, esi, SHA256_HASH_SIZE/4
lea esi, [inner_ctx]
stdcall dump_hex, esi, SHA2_256_LEN/4
 
; Calculate outer hash
lea ebx, [outer_ctx]
lea esi, [inner_ctx.hash]
invoke sha256_update, ebx, esi, SHA256_HASH_SIZE
lea esi, [inner_ctx]
invoke sha2_256_update, ebx, esi, SHA2_256_LEN
lea ebx, [outer_ctx]
invoke sha256_final, ebx
invoke sha2_256_finish, ebx
; Copy output hash to ctx structure ; FIXME
lea esi, [outer_ctx.hash]
lea esi, [outer_ctx]
mov edi, [ctx]
repeat SHA256_HASH_SIZE/4
repeat SHA2_256_LEN/4
movsd
end repeat
 
/programs/network/ssh/ssh.asm
49,7 → 49,7
include '../../dll.inc'
include '../../debug-fdo.inc'
include '../../network.inc'
include '../../develop/libraries/libcrash/trunk/libcrash.inc'
include '../../develop/libraries/libcrash/libcrash.inc'
 
; macros for network byte order
macro dd_n op {
621,18 → 621,18
con_get_input, 'con_get_input'
 
import libcrash, \
sha512_init, 'sha512_init', \
sha512_update, 'sha512_update', \
sha512_final, 'sha512_final',\
sha256_init, 'sha256_init', \
sha256_update, 'sha256_update', \
sha256_final, 'sha256_final',\
sha2_512_init, 'sha2_512_init', \
sha2_512_update, 'sha2_512_update', \
sha2_512_finish, 'sha2_512_finish',\
sha2_256_init, 'sha2_256_init', \
sha2_256_update, 'sha2_256_update', \
sha2_256_finish, 'sha2_256_finish',\
sha1_init, 'sha1_init', \
sha1_update, 'sha1_update', \
sha1_final, 'sha1_final', \
sha1_finish, 'sha1_finish', \
md5_init, 'md5_init', \
md5_update, 'md5_update', \
md5_final, 'md5_final'
md5_finish, 'md5_finish'
 
import libini, \
ini_get_str, 'ini_get_str', \
/programs/network/ssh/sshlib.inc
125,8 → 125,8
tx_buffer ssh_packet_header
rb PACKETSIZE-sizeof.ssh_packet_header
 
part_ex_hash_ctx crash_ctx
session_id rb SHA256_HASH_SIZE
part_ex_hash_ctx rb LIBCRASH_CTX_LEN
session_id rb SHA2_256_LEN
 
algo_kex dd ?
algo_hostkey dd ?
/programs/network/ssh/sshlib_connection.inc
109,9 → 109,9
jnz .err_sock
 
; Start calculating hash
invoke sha256_init, [ctx_ptr]
invoke sha2_256_init, [ctx_ptr]
; HASH: string V_C, the client's version string (CR and NL excluded)
invoke sha256_update, [ctx_ptr], ssh_ident_ha, ssh_msg_ident.length+4-2
invoke sha2_256_update, [ctx_ptr], ssh_ident_ha, ssh_msg_ident.length+4-2
 
; >> Send our identification string
DEBUGF 2, "Sending ID string\n"
138,7 → 138,7
bswap eax
sub edx, 4
mov dword[edx], eax
invoke sha256_update, [ctx_ptr], edx, ecx
invoke sha2_256_update, [ctx_ptr], edx, ecx
 
; >> Key Exchange init
mov eax, [con_ptr]
191,7 → 191,7
bswap eax
lea esi, [esi+sshlib_connection.tx_buffer+1]
mov dword[esi], eax
invoke sha256_update, [ctx_ptr], esi, edx
invoke sha2_256_update, [ctx_ptr], esi, edx
 
; << Check key exchange init of server
stdcall sshlib_recv_packet, [con_ptr], 0
269,7 → 269,7
bswap eax
lea esi, [esi+sshlib_connection.rx_buffer+1]
mov dword[esi], eax
invoke sha256_update, [ctx_ptr], esi, edx
invoke sha2_256_update, [ctx_ptr], esi, edx
 
; Exchange keys with the server
 
/programs/network/ssh/sshlib_dh_gex.inc
44,7 → 44,7
 
K_length dd ?
 
session_id_x rb SHA256_HASH_SIZE+1
session_id_x rb SHA2_256_LEN+1
 
str_K_S dd ? ; server public host key and certificates (K_S)
mpint_f_big dd ? ; pointer to original
54,7 → 54,7
 
; Allocate memory for temp variables
 
mov ecx, 7*(MAX_BITS/8+4) + 7*SHA256_HASH_SIZE + 2*sizeof.crash_ctx
mov ecx, 7*(MAX_BITS/8+4) + 7*SHA2_256_LEN + 2*LIBCRASH_CTX_LEN
mcall 68, 12
test eax, eax
jz .err_nomem
77,24 → 77,24
add eax, (MAX_BITS/8+4)
 
mov [k_h_ctx], eax
add eax, sizeof.crash_ctx
add eax, LIBCRASH_CTX_LEN
mov [temp_ctx], eax
add eax, sizeof.crash_ctx
add eax, LIBCRASH_CTX_LEN
 
mov [H], eax
add eax, SHA256_HASH_SIZE
add eax, SHA2_256_LEN
mov [rx_iv], eax
add eax, SHA256_HASH_SIZE
add eax, SHA2_256_LEN
mov [tx_iv], eax
add eax, SHA256_HASH_SIZE
add eax, SHA2_256_LEN
mov [rx_enc_key], eax
add eax, SHA256_HASH_SIZE
add eax, SHA2_256_LEN
mov [tx_enc_key], eax
add eax, SHA256_HASH_SIZE
add eax, SHA2_256_LEN
mov [rx_int_key], eax
add eax, SHA256_HASH_SIZE
add eax, SHA2_256_LEN
mov [tx_int_key], eax
; add eax, SHA256_HASH_SIZE
; add eax, SHA2_256_LEN
 
; Copy the partial exchange hash to our temporary one
 
101,7 → 101,7
mov esi, [con_ptr]
lea esi, [esi+sshlib_connection.part_ex_hash_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
 
;----------------------------------------------
201,13 → 201,13
add edx, 4
lea eax, [esi+edx]
mov [mpint_f_big], eax
invoke sha256_update, [temp_ctx], esi, edx
invoke sha2_256_update, [temp_ctx], esi, edx
 
;--------------------------------------------------------------------------
; HASH: uint32 min, minimal size in bits of an acceptable group
; uint32 n, preferred size in bits of the group the server will send
; uint32 max, maximal size in bits of an acceptable group
invoke sha256_update, [temp_ctx], ssh_msg_gex_req+sizeof.ssh_packet_header-ssh_packet_header.message_code, 12
invoke sha2_256_update, [temp_ctx], ssh_msg_gex_req+sizeof.ssh_packet_header-ssh_packet_header.message_code, 12
 
;----------------------------
; HASH: mpint p, safe prime
214,7 → 214,7
stdcall mpint_shrink, [mpint_p]
stdcall mpint_to_big_endian, [mpint_tmp], [mpint_p]
add eax, 4
invoke sha256_update, [temp_ctx], [mpint_tmp], eax
invoke sha2_256_update, [temp_ctx], [mpint_tmp], eax
 
;----------------------------------------
; HASH: mpint g, generator for subgroup
221,7 → 221,7
stdcall mpint_shrink, [mpint_g]
stdcall mpint_to_big_endian, [mpint_tmp], [mpint_g]
add eax, 4
invoke sha256_update, [temp_ctx], [mpint_tmp], eax
invoke sha2_256_update, [temp_ctx], [mpint_tmp], eax
 
;---------------------------------------------------
; HASH: mpint e, exchange value sent by the client
230,7 → 230,7
mov edx, [esi]
bswap edx
add edx, 4
invoke sha256_update, [temp_ctx], esi, edx
invoke sha2_256_update, [temp_ctx], esi, edx
 
;---------------------------------------------------
; HASH: mpint f, exchange value sent by the server
238,7 → 238,7
mov edx, [esi]
bswap edx
add edx, 4
invoke sha256_update, [temp_ctx], esi, edx
invoke sha2_256_update, [temp_ctx], esi, edx
 
stdcall mpint_to_little_endian, [mpint_f], [mpint_f_big]
mov esi, [mpint_f_big]
260,19 → 260,18
;-----------------------------------
; HASH: mpint K, the shared secret
add eax, 4
invoke sha256_update, [temp_ctx], [mpint_K_big], eax
invoke sha2_256_update, [temp_ctx], [mpint_K_big], eax
 
;-------------------------------
; Finalize the exchange hash (H)
invoke sha256_final, [temp_ctx]
invoke sha2_256_finish, [temp_ctx]
mov esi, [temp_ctx]
add esi, crash_ctx.hash
mov edi, [H]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Exchange hash H: "
stdcall dump_hex, [H], SHA256_HASH_SIZE/4
stdcall dump_hex, [H], SHA2_256_LEN/4
 
;--------------------------
; Set or get the session id
282,7 → 281,7
jae @f
 
; If first KEX, verify host public key
stdcall sshlib_host_verify, [con_ptr], [str_K_S], [str_s_of_H], [H], SHA256_HASH_SIZE
stdcall sshlib_host_verify, [con_ptr], [str_K_S], [str_s_of_H], [H], SHA2_256_LEN
test eax, eax
jnz .err
 
289,13 → 288,13
mov eax, [con_ptr]
mov esi, [H]
lea edi, [eax + sshlib_connection.session_id]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
@@:
 
lea esi, [eax + sshlib_connection.session_id]
lea edi, [session_id_x+1]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
 
304,12 → 303,12
 
; First, calculate partial hash of K and H so we can re-use it for every key.
 
invoke sha256_init, [k_h_ctx]
invoke sha2_256_init, [k_h_ctx]
 
mov ecx, [K_length]
add ecx, 4
invoke sha256_update, [k_h_ctx], [mpint_K_big], ecx
invoke sha256_update, [k_h_ctx], [H], SHA256_HASH_SIZE
invoke sha2_256_update, [k_h_ctx], [mpint_K_big], ecx
invoke sha2_256_update, [k_h_ctx], [H], SHA2_256_LEN
 
;---------------------------------------------------------------
; Initial IV client to server: HASH(K || H || "A" || session_id)
316,19 → 315,19
 
mov esi, [k_h_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
lea edx, [session_id_x]
mov byte[edx], 'A'
invoke sha256_update, [temp_ctx], edx, SHA256_HASH_SIZE+1
invoke sha256_final, [temp_ctx]
invoke sha2_256_update, [temp_ctx], edx, SHA2_256_LEN+1
invoke sha2_256_finish, [temp_ctx]
mov edi, [tx_iv]
mov esi, [temp_ctx]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Remote IV: "
stdcall dump_hex, [tx_iv], SHA256_HASH_SIZE/4
stdcall dump_hex, [tx_iv], SHA2_256_LEN/4
 
;---------------------------------------------------------------
; Initial IV server to client: HASH(K || H || "B" || session_id)
335,19 → 334,19
 
mov esi, [k_h_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
lea edx, [session_id_x]
mov byte[edx], 'B'
invoke sha256_update, [temp_ctx], edx, SHA256_HASH_SIZE+1
invoke sha256_final, [temp_ctx]
invoke sha2_256_update, [temp_ctx], edx, SHA2_256_LEN+1
invoke sha2_256_finish, [temp_ctx]
mov edi, [rx_iv]
mov esi, [temp_ctx]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Local IV: "
stdcall dump_hex, [rx_iv], SHA256_HASH_SIZE/4
stdcall dump_hex, [rx_iv], SHA2_256_LEN/4
 
;-------------------------------------------------------------------
; Encryption key client to server: HASH(K || H || "C" || session_id)
354,19 → 353,19
 
mov esi, [k_h_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
lea edx, [session_id_x]
mov byte[edx], 'C'
invoke sha256_update, [temp_ctx], edx, SHA256_HASH_SIZE+1
invoke sha256_final, [temp_ctx]
invoke sha2_256_update, [temp_ctx], edx, SHA2_256_LEN+1
invoke sha2_256_finish, [temp_ctx]
mov edi, [tx_enc_key]
mov esi, [temp_ctx]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Remote key: "
stdcall dump_hex, [tx_enc_key], SHA256_HASH_SIZE/4
stdcall dump_hex, [tx_enc_key], SHA2_256_LEN/4
 
;-------------------------------------------------------------------
; Encryption key server to client: HASH(K || H || "D" || session_id)
373,19 → 372,19
 
mov esi, [k_h_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
lea edx, [session_id_x]
mov byte[edx], 'D'
invoke sha256_update, [temp_ctx], edx, SHA256_HASH_SIZE+1
invoke sha256_final, [temp_ctx]
invoke sha2_256_update, [temp_ctx], edx, SHA2_256_LEN+1
invoke sha2_256_finish, [temp_ctx]
mov edi, [rx_enc_key]
mov esi, [temp_ctx]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Local key: "
stdcall dump_hex, [rx_enc_key], SHA256_HASH_SIZE/4
stdcall dump_hex, [rx_enc_key], SHA2_256_LEN/4
 
;------------------------------------------------------------------
; Integrity key client to server: HASH(K || H || "E" || session_id)
392,19 → 391,19
 
mov esi, [k_h_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
lea edx, [session_id_x]
mov byte[edx], 'E'
invoke sha256_update, [temp_ctx], edx, SHA256_HASH_SIZE+1
invoke sha256_final, [temp_ctx]
invoke sha2_256_update, [temp_ctx], edx, SHA2_256_LEN+1
invoke sha2_256_finish, [temp_ctx]
mov edi, [tx_int_key]
mov esi, [temp_ctx]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Remote Integrity key: "
stdcall dump_hex, [tx_int_key], SHA256_HASH_SIZE/4
stdcall dump_hex, [tx_int_key], SHA2_256_LEN/4
 
;------------------------------------------------------------------
; Integrity key server to client: HASH(K || H || "F" || session_id)
411,19 → 410,19
 
mov esi, [k_h_ctx]
mov edi, [temp_ctx]
mov ecx, sizeof.crash_ctx/4
mov ecx, LIBCRASH_CTX_LEN/4
rep movsd
lea edx, [session_id_x]
mov byte[edx], 'F'
invoke sha256_update, [temp_ctx], edx, SHA256_HASH_SIZE+1
invoke sha256_final, [temp_ctx]
invoke sha2_256_update, [temp_ctx], edx, SHA2_256_LEN+1
invoke sha2_256_finish, [temp_ctx]
mov edi, [rx_int_key]
mov esi, [temp_ctx]
mov ecx, SHA256_HASH_SIZE/4
mov ecx, SHA2_256_LEN/4
rep movsd
 
DEBUGF 1, "Local Integrity key: "
stdcall dump_hex, [rx_int_key] , SHA256_HASH_SIZE/4
stdcall dump_hex, [rx_int_key] , SHA2_256_LEN/4
 
;-------------------------------------
; << Parse Diffie-Hellman New Keys MSG
471,14 → 470,14
mov [ebx + sshlib_connection.tx_pad_proc], MBRandom
 
lea ecx, [ebx + sshlib_connection.rx_mac_ctx]
stdcall hmac_sha256_setkey, ecx, [rx_int_key], SHA256_HASH_SIZE
stdcall hmac_sha256_setkey, ecx, [rx_int_key], SHA2_256_LEN
mov [ebx + sshlib_connection.rx_mac_proc], hmac_sha256
mov [ebx + sshlib_connection.rx_mac_length], SHA256_HASH_SIZE
mov [ebx + sshlib_connection.rx_mac_length], SHA2_256_LEN
 
lea ecx, [ebx + sshlib_connection.tx_mac_ctx]
stdcall hmac_sha256_setkey, ecx, [tx_int_key], SHA256_HASH_SIZE
stdcall hmac_sha256_setkey, ecx, [tx_int_key], SHA2_256_LEN
mov [ebx + sshlib_connection.tx_mac_proc], hmac_sha256
mov [ebx + sshlib_connection.tx_mac_length], SHA256_HASH_SIZE
mov [ebx + sshlib_connection.tx_mac_length], SHA2_256_LEN
 
mov [ebx + sshlib_connection.status], SSHLIB_CON_STAT_KEX_DONE
xor eax, eax
486,7 → 485,7
.err:
push eax
xor eax, eax
mov ecx, (7*(MAX_BITS/8+4) + 7*SHA256_HASH_SIZE + 2*sizeof.crash_ctx)/4
mov ecx, (7*(MAX_BITS/8+4) + 7*SHA2_256_LEN + 2*LIBCRASH_CTX_LEN)/4
mov edi, [mpint_tmp]
rep stosd
 
/programs/network/ssh/sshlib_host.inc
134,11 → 134,11
 
DEBUGF 3, "SSH: Performing RSA verification\n"
 
mcall 68, 12, sizeof.crash_ctx + 5*(MAX_BITS/8+4)
mcall 68, 12, LIBCRASH_CTX_LEN + 5*(MAX_BITS/8+4)
test eax, eax
jz .err_nomem
mov [h_ctx], eax
add eax, sizeof.crash_ctx
add eax, LIBCRASH_CTX_LEN
mov [mpint_e], eax
add eax, MAX_BITS/8+4
mov [mpint_n], eax
211,7 → 211,7
; EMSA-PKCS1-v1_5
invoke sha1_init, [h_ctx]
invoke sha1_update, [h_ctx], [M], [message_len]
invoke sha1_final, [h_ctx]
invoke sha1_finish, [h_ctx]
 
mov edi, [EM_accent]
mov al, 0x00
219,7 → 219,7
mov al, 0x01
stosb
mov ecx, [k]
sub ecx, (rsa_sha1_T.len + 3 + SHA1_HASH_SIZE)
sub ecx, (rsa_sha1_T.len + 3 + SHA1_LEN)
jl .err_key
jz @f
mov al, 0xff
231,7 → 231,7
mov ecx, rsa_sha1_T.len
rep movsb
mov esi, [h_ctx]
mov ecx, SHA1_HASH_SIZE
mov ecx, SHA1_LEN
rep movsb
 
pop esi
243,9 → 243,9
push esi
 
; EMSA-PKCS1-v1_5
invoke sha256_init, [h_ctx]
invoke sha256_update, [h_ctx], [M], [message_len]
invoke sha256_final, [h_ctx]
invoke sha2_256_init, [h_ctx]
invoke sha2_256_update, [h_ctx], [M], [message_len]
invoke sha2_256_finish, [h_ctx]
 
mov edi, [EM_accent]
mov al, 0x00
253,7 → 253,7
mov al, 0x01
stosb
mov ecx, [k]
sub ecx, (rsa_sha256_T.len + 3 + SHA256_HASH_SIZE)
sub ecx, (rsa_sha256_T.len + 3 + SHA2_256_LEN)
jl .err_key
jz @f
mov al, 0xff
265,7 → 265,7
mov ecx, rsa_sha256_T.len
rep movsb
mov esi, [h_ctx]
mov ecx, SHA256_HASH_SIZE
mov ecx, SHA2_256_LEN
rep movsb
 
pop esi
277,9 → 277,9
push esi
 
; EMSA-PKCS1-v1_5
invoke sha512_init, [h_ctx]
invoke sha512_update, [h_ctx], [M], [message_len]
invoke sha512_final, [h_ctx]
invoke sha2_512_init, [h_ctx]
invoke sha2_512_update, [h_ctx], [M], [message_len]
invoke sha2_512_finish, [h_ctx]
 
mov edi, [EM_accent]
mov al, 0x00
287,7 → 287,7
mov al, 0x01
stosb
mov ecx, [k]
sub ecx, (rsa_sha512_T.len + 3 + SHA512_HASH_SIZE)
sub ecx, (rsa_sha512_T.len + 3 + SHA2_512_LEN)
jl .err_key
jz @f
mov al, 0xff
299,7 → 299,7
mov ecx, rsa_sha512_T.len
rep movsb
mov esi, [h_ctx]
mov ecx, SHA512_HASH_SIZE
mov ecx, SHA2_512_LEN
rep movsb
 
pop esi