Subversion Repositories Kolibri OS

Rev

Rev 9990 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;    ssh.asm - SSH client for KolibriOS
  2. ;
  3. ;    Copyright (C) 2015-2024 Jeffrey Amelynck
  4. ;
  5. ;    This program is free software: you can redistribute it and/or modify
  6. ;    it under the terms of the GNU General Public License as published by
  7. ;    the Free Software Foundation, either version 3 of the License, or
  8. ;    (at your option) any later version.
  9. ;
  10. ;    This program is distributed in the hope that it will be useful,
  11. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;    GNU General Public License for more details.
  14. ;
  15. ;    You should have received a copy of the GNU General Public License
  16. ;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. format binary as ""
  19.  
  20. __DEBUG__               = 1
  21. __DEBUG_LEVEL__         = 2             ; 1: Everything, including sensitive information, 2: Debugging, 3: Errors only
  22.  
  23. BUFFERSIZE              = 64*1024       ; Must be at least 32K according rfc4253#section-6.1
  24. PACKETSIZE              = 32*1024       ; Must be at least 32K according rfc4253#section-6.1
  25. MAX_BITS                = 8192
  26.  
  27. DH_PRIVATE_KEY_SIZE     = 256
  28. MAX_INPUT_LENGTH        = 255
  29. MAX_USERNAME_LENGTH     = 256
  30. MAX_PASSWORD_LENGTH     = 256
  31. MAX_HOSTNAME_LENGTH     = 4096
  32. MAX_PUBLIC_KEY_SIZE     = 4096
  33.  
  34. use32
  35.  
  36.         db      'MENUET01'      ; signature
  37.         dd      1               ; header version
  38.         dd      start           ; entry point
  39.         dd      i_end           ; initialized size
  40.         dd      mem+65536       ; required memory
  41.         dd      mem+65536       ; stack pointer
  42.         dd      params          ; parameters
  43.         dd      0               ; path
  44.  
  45. include '../../macros.inc'
  46. ;include '../../struct.inc'
  47. purge mov,add,sub
  48. include '../../proc32.inc'
  49. include '../../dll.inc'
  50. include '../../debug-fdo.inc'
  51. include '../../network.inc'
  52. include '../../develop/libraries/libcrash/libcrash.inc'
  53.  
  54. ; macros for network byte order
  55. macro dd_n op {
  56.    dd 0 or (((op) and 0FF000000h) shr 24) or \
  57.            (((op) and 000FF0000h) shr  8) or \
  58.            (((op) and 00000FF00h) shl  8) or \
  59.            (((op) and 0000000FFh) shl 24)
  60. }
  61.  
  62. macro dw_n op {
  63.    dw 0 or (((op) and 0FF00h) shr 8) or \
  64.            (((op) and 000FFh) shl 8)
  65. }
  66.  
  67. macro str string {
  68.     local .start, .stop
  69.  
  70.     dd_n (.stop-.start)
  71.  
  72.     .start db string
  73.     .stop:
  74. }
  75.  
  76. proc dump_hex _ptr, _length
  77. if __DEBUG_LEVEL__ <= 1
  78.         pushad
  79.  
  80.         mov     esi, [_ptr]
  81.         mov     ecx, [_length]
  82.   .next_dword:
  83.         lodsd
  84.         bswap   eax
  85.         DEBUGF  1,'%x', eax
  86.         loop    .next_dword
  87.         DEBUGF  1,'\n'
  88.  
  89.         popad
  90. end if
  91.         ret
  92. endp
  93.  
  94. macro DEBUGM l, s, m {
  95. if __DEBUG__
  96.         DEBUGF  l, s
  97.   if l >=__DEBUG_LEVEL__
  98.         stdcall mpint_print, m
  99.   end if
  100. end if
  101. }
  102.  
  103. include 'mpint.inc'
  104. include 'seed.inc'
  105. include 'random.inc'
  106.  
  107. include 'sshlib.inc'
  108.  
  109. include 'sshlib_mcodes.inc'
  110. include 'sshlib_transport.inc'
  111. include 'sshlib_transport_hmac.inc'
  112. include 'sshlib_transport_hmac_etm.inc'
  113. include 'sshlib_transport_polychacha.inc'
  114. include 'sshlib_connection.inc'
  115. include 'sshlib_dh_gex.inc'
  116. include 'sshlib_host.inc'
  117. include 'sshlib_channel.inc'
  118. include 'sshlib_userauth.inc'
  119.  
  120. include 'encodings.inc'         ; Unfortunately, we dont have UTF-8 capable console yet :(
  121.  
  122. start:
  123.         mcall   68, 11          ; Init heap
  124.  
  125.         DEBUGF  2, "SSH: Loading libraries\n"
  126.         stdcall dll.Load, @IMPORT
  127.         test    eax, eax
  128.         jnz     main.fail
  129.  
  130.         DEBUGF  2, "SSH: Init PRNG\n"
  131.         call    create_seed
  132.         call    init_random
  133.  
  134.         DEBUGF  2, "SSH: Init Console\n"
  135.         invoke  con_start, 1
  136.         invoke  con_init, 80, 25, 80, 250, title
  137.  
  138.         cmp     byte[params], 0
  139.         jne     main.connect
  140.  
  141. main:
  142.         invoke  con_cls
  143. ; Welcome user
  144.         invoke  con_write_asciiz, str1a
  145.   .prompt:
  146.         invoke  con_write_asciiz, str1b
  147. ; Reset window title
  148.         invoke  con_set_title, title
  149. ; Write prompt
  150.         invoke  con_write_asciiz, str2
  151. ; read string
  152.         mov     esi, params
  153.         invoke  con_gets, esi, MAX_HOSTNAME_LENGTH
  154. ; check for exit
  155.         test    eax, eax
  156.         jz      .done
  157.         cmp     byte[esi], 10
  158.         jz      .done
  159.  
  160.   .connect:
  161.         stdcall sshlib_connect, ssh_con, params
  162.         cmp     eax, 0
  163.         jg      .prompt
  164.         jl      .error
  165.  
  166.   .login:
  167.         mcall   68, 12, (MAX_USERNAME_LENGTH + MAX_PASSWORD_LENGTH)
  168.         test    eax, eax
  169.         jz      .done   ; ERR_NOMEM
  170.         mov     esi, eax
  171.         lea     edi, [eax + MAX_USERNAME_LENGTH]
  172.  
  173. ; Get username
  174.         invoke  con_write_asciiz, str12
  175.         invoke  con_gets, esi, MAX_USERNAME_LENGTH
  176.         test    eax, eax
  177. ;;        jz      .con_closed_must_clear
  178.  
  179. ; Get password
  180.         invoke  con_write_asciiz, str13a
  181.         invoke  con_gets, edi, MAX_PASSWORD_LENGTH
  182.         test    eax, eax
  183. ;;        jz      .con_closed_must_clear
  184.         invoke  con_write_asciiz, str13b
  185.  
  186. ; Authenticate
  187.         stdcall sshlib_userauth_password, ssh_con, esi, edi
  188. ; Clear and free username and password
  189.   .clear:
  190.         push    eax
  191.         mov     edx, edi
  192.         xor     eax, eax
  193.         mov     ecx, (MAX_USERNAME_LENGTH + MAX_PASSWORD_LENGTH)/4
  194.         rep     stosd
  195.         mcall   68, 13, edx
  196.         pop     eax
  197.  
  198.         cmp     eax, 0
  199.         jg      .login          ; Authentication failed
  200.         jl      .error          ; An error occured
  201.  
  202. ; Open a channel
  203.         stdcall sshlib_chan_open, ssh_con
  204.         cmp     eax, 0
  205.         jg      .prompt         ; Authentication failed
  206.         jl      .error          ; An error occured
  207.  
  208. ; Start console input handler thread without deactivating the current window
  209. ; Get active window ID
  210.         mcall   18, 7
  211.         push    eax
  212. ; Create thread
  213.         mcall   51, 1, con_in_thread, mem + 2048
  214. ; Activate window with given ID
  215.         pop     ecx
  216.         mcall   18, 3
  217.  
  218.   .loop:
  219.         invoke  con_get_flags
  220.         test    eax, 0x200                      ; console window closed?
  221.         jnz     .con_closed
  222.  
  223.         stdcall sshlib_msg_handler, ssh_con, 0
  224.         cmp     eax, 0
  225.         jle     .check_err
  226.  
  227.         cmp     [ssh_con.rx_buffer.message_code], SSH_MSG_CHANNEL_DATA
  228.         jne     .dump
  229.  
  230.         mov     eax, dword[ssh_con.rx_buffer.message_code+5]
  231.         bswap   eax
  232.         DEBUGF  1, 'SSH: got %u bytes of data !\n', eax
  233.  
  234.         lea     esi, [ssh_con.rx_buffer.message_code+5+4]
  235.         lea     edx, [esi+eax]
  236.         lea     edi, [ssh_con.rx_buffer]
  237.   @@:
  238.         call    get_byte_utf8
  239.         stosb
  240.         cmp     esi, edx
  241.         jb      @r
  242.         xor     al, al
  243.         stosb
  244.  
  245.         lea     esi, [ssh_con.rx_buffer]
  246.         DEBUGF  3, 'SSH msg: %s\n', esi
  247.  
  248.         invoke  con_write_asciiz, esi
  249.         jmp     .loop
  250.  
  251.   .dump:
  252.         DEBUGF  3, "SSH: Unsupported message: "
  253.         lea     esi, [ssh_con.rx_buffer.message_code]
  254.         mov     ecx, eax
  255.         pusha
  256.   @@:
  257.         lodsb
  258.         DEBUGF  3, "%x ", eax:2
  259.         dec     ecx
  260.         jnz     @r
  261.         popa
  262.         DEBUGF  3, "\n"
  263.         jmp     .loop
  264.  
  265.   .check_err:
  266.         jz      .err_conn_closed
  267.         cmp     ebx, EWOULDBLOCK
  268.         je      .loop
  269.         jmp     .err_sock
  270.  
  271.   .con_closed:
  272.         ; Send close message on the active channel
  273.         stdcall sshlib_send_packet, ssh_con, ssh_msg_channel_close, ssh_msg_channel_close.length, 0
  274.         jmp     .done
  275.  
  276.   .error:
  277.  
  278. ; TODO: proper cleanup after error
  279.  
  280.         cmp     eax, SSHLIB_ERR_NOMEM
  281.         je      .done
  282.         cmp     eax, SSHLIB_ERR_SOCKET
  283.         je      .err_sock
  284.         cmp     eax, SSHLIB_ERR_PROTOCOL
  285.         je      .err_proto
  286.         cmp     eax, SSHLIB_ERR_HOSTNAME
  287.         je      .err_hostname
  288.         cmp     eax, SSHLIB_ERR_HKEY_VERIFY_FAIL
  289.         je      .err_hostkey_fail
  290.         cmp     eax, SSHLIB_ERR_HKEY_SIGNATURE
  291.         je      .err_hostkey_signature
  292.         cmp     eax, SSHLIB_ERR_HKEY_PUBLIC_KEY
  293.         je      .err_hostkey
  294.  
  295.         jmp     .done
  296.  
  297.  
  298.   .err_proto:
  299. ;        lea     eax, [ssh_con.rx_buffer]
  300. ;        int3
  301.         invoke  con_write_asciiz, str7
  302.         jmp     .prompt
  303.  
  304.   .err_sock:
  305.         invoke  con_write_asciiz, str6
  306.  
  307.         mov     eax, str14
  308.         cmp     ebx, ETIMEDOUT
  309.         je      .err_sock_detail
  310.         mov     eax, str15
  311.         cmp     ebx, ECONNREFUSED
  312.         je      .err_sock_detail
  313.         mov     eax, str16
  314.         cmp     ebx, ECONNRESET
  315.         je      .err_sock_detail
  316.         mov     eax, str17
  317.   .err_sock_detail:
  318.         invoke  con_write_asciiz, eax
  319.         jmp     .prompt
  320.  
  321.   .err_hostname:
  322.         invoke  con_write_asciiz, str10
  323.         jmp     .prompt
  324.  
  325.   .err_conn_closed:
  326.         invoke  con_write_asciiz, str11
  327.         jmp     .prompt
  328.  
  329.   .err_hostkey:
  330.         invoke  con_write_asciiz, str19
  331.         jmp     .prompt
  332.  
  333.   .err_hostkey_signature:
  334.         invoke  con_write_asciiz, str20
  335.         jmp     .prompt
  336.  
  337.   .err_hostkey_fail:
  338.         invoke  con_write_asciiz, str21
  339.         jmp     .prompt
  340.  
  341.   .done:
  342.         invoke  con_exit, 1
  343.   .exit:
  344.         DEBUGF  3, "SSH: Exiting\n"
  345.         mcall   close, [ssh_con.socketnum]
  346.   .fail:
  347.         mcall   -1
  348.  
  349.  
  350. proc sshlib_callback_connecting, con_ptr, connstring_sz
  351.  
  352.         invoke  con_write_asciiz, str3
  353.         mov     eax, [con_ptr]
  354.         lea     eax, [eax+sshlib_connection.hostname_sz]
  355.         invoke  con_write_asciiz, eax
  356.         invoke  con_write_asciiz, str8
  357.         invoke  con_write_asciiz, [connstring_sz]
  358.         invoke  con_write_asciiz, str9
  359.  
  360.         ret
  361. endp
  362.  
  363.  
  364. proc sshlib_callback_hostkey_problem, con_ptr, problem_type, hostkey_sz
  365.  
  366.         cmp     [problem_type], SSHLIB_HOSTKEY_PROBLEM_UNKNOWN
  367.         je      .unknown
  368.         cmp     [problem_type], SSHLIB_HOSTKEY_PROBLEM_MISMATCH
  369.         je      .mismatch
  370.  
  371.         mov     eax, -1
  372.         ret
  373.  
  374.   .unknown:
  375.         invoke  con_write_asciiz, str22
  376.         jmp     .ask
  377.  
  378.   .mismatch:
  379.         invoke  con_write_asciiz, str23
  380. ;        jmp     .ask
  381.   .ask:
  382.         invoke  con_write_asciiz, str24a
  383.         invoke  con_write_asciiz, [hostkey_sz]
  384.         invoke  con_write_asciiz, str24b
  385.   .getansw:
  386.         invoke  con_getch2
  387.         or      al, 0x20        ; convert to lowercase
  388.         cmp     al, 'a'
  389.         je      .accept
  390.         cmp     al, 'c'
  391.         je      .once
  392.         cmp     al, 'x'
  393.         je      .refuse
  394.         jmp     .getansw
  395.  
  396.   .accept:
  397.         mov     eax, SSHLIB_HOSTKEY_ACCEPT
  398.         ret
  399.   .once:
  400.         mov     eax, SSHLIB_HOSTKEY_ONCE
  401.         ret
  402.   .refuse:
  403.         mov     eax, SSHLIB_HOSTKEY_REFUSE
  404.         ret
  405.  
  406. endp
  407.  
  408.  
  409.  
  410. align 16
  411. con_in_thread:
  412.  
  413.   .loop:
  414. ; TODO: check if channel is still open somehow
  415.  
  416.         invoke  con_get_input, keyb_input, MAX_INPUT_LENGTH
  417.         test    eax, eax
  418.         jz      .no_input
  419.  
  420.         mov     ecx, eax
  421.         mov     esi, keyb_input
  422.         mov     edi, ssh_msg_channel_data.data
  423.         call    recode_to_utf8
  424.  
  425.         lea     eax, [edi - ssh_msg_channel_data.data]
  426.         lea     ecx, [edi - ssh_msg_channel_data]
  427.         bswap   eax
  428.         mov     [ssh_msg_channel_data.len], eax
  429.         stdcall sshlib_send_packet, ssh_con, ssh_msg_channel_data, ecx, 0
  430.         cmp     eax, 0
  431.         jle     .exit
  432.  
  433.   .no_input:
  434.         invoke  con_get_flags
  435.         test    eax, 0x200                      ; con window closed?
  436.         jz      .loop
  437.  
  438.   .exit:
  439.         mcall   -1
  440.  
  441.  
  442. ; data
  443. title   db 'Secure Shell',0
  444. str1a   db 'SSHv2 client for KolibriOS',10,0
  445. str1b   db 10,'Please enter URL of SSH server (hostname:port)',10,0
  446. str2    db '> ',0
  447. str3    db 'Connecting to ',0
  448. str4    db 10,0
  449. str6    db 10, 27, '[2J',27,'[mA network error has occured.',10,0
  450. str7    db 10, 27, '[2J',27,'[mAn SSH protocol error has occured.',10,0
  451. str8    db ' (',0
  452. str9    db ')',10,0
  453. str10   db 'Host does not exist.',10,10,0
  454. str11   db 10, 27, '[2J',27,'[mThe remote host closed the connection.',10,0
  455. str12   db 'Login as: ',0
  456. str13a  db 'Password: ', 27, '[?25l', 27, '[30;40m', 0
  457. str13b  db 10, 27, '[?25h', 27, '[0m', 27, '[2J', 0
  458. str14   db 'The connection timed out',10,0
  459. str15   db 'The connection was refused',10,0
  460. str16   db 'The connection was reset',10,0
  461. str17   db 'No details available',10,0
  462. ;str18   db 'User authentication failed',10,0;;;;
  463. str19   db "The remote host's public key is invalid.", 10, 0
  464. str20   db "The remote host's signature is invalid.", 10, 0
  465. str21   db "The remote host failed to verify it's own public key.", 10, 0
  466. str22   db "The host key for the server was not found in the cache.", 10
  467.         db "There is no guarantee to the servers identity !",10, 0
  468.  
  469. str23   db "The host key provided by the host does not match the cached one.", 10
  470.         db "This may indicate that the remote server has been compromised!", 10, 0
  471.  
  472. str24a  db 10, "The remote host key is: ", 10, 0
  473. str24b  db 10, 10, "If you trust this host, press A to accept and store the (new) key.", 10
  474.         db "Press C to connect to the host but don't store the (new) key.", 10
  475.         db "Press X to abort.", 10, 0
  476.  
  477.  
  478. ssh_ident_ha:
  479.         dd_n (ssh_msg_ident.length-2)
  480. ssh_msg_ident:
  481.         db "SSH-2.0-KolibriOS_SSH_0.12",13,10
  482.   .length = $ - ssh_msg_ident
  483.  
  484.  
  485. ssh_msg_kex:
  486.         db SSH_MSG_KEXINIT
  487.   .cookie:
  488.         rd 4
  489.   .kex_algorithms:
  490.         str "diffie-hellman-group-exchange-sha256"
  491.   .server_host_key_algorithms:
  492.         str "rsa-sha2-512,rsa-sha2-256"                                 ;ssh-rsa,ssh-dss
  493.   .encryption_algorithms_client_to_server:
  494.         str "chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc"       ;aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc ?
  495.   .encryption_algorithms_server_to_client:
  496.         str "chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc"       ;aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc ?
  497.   .mac_algorithms_client_to_server:
  498.         str "hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512"
  499.   .mac_algorithms_server_to_client:
  500.         str "hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512"
  501.   .compression_algorithms_client_to_server:
  502.         str "none"                                                      ;zlib ?
  503.   .compression_algorithms_server_to_client:
  504.         str "none"                                                      ;zlib ?
  505.   .languages_client_to_server:
  506.         str ""
  507.   .languages_server_to_client:
  508.         str ""
  509.   .first_kex_packet_follows:
  510.         db 0
  511.   .reserved:
  512.         dd_n 0
  513.   .length = $ - ssh_msg_kex
  514.  
  515.  
  516. ssh_msg_gex_req:
  517.         db SSH_MSG_KEX_DH_GEX_REQUEST
  518.         dd_n 4096/4                      ; DH GEX min
  519.         dd_n 4096/2                      ; DH GEX number of bits
  520.         dd_n 4096                        ; DH GEX Max
  521.   .length = $ - ssh_msg_gex_req
  522.  
  523.  
  524. ssh_msg_new_keys:
  525.         db SSH_MSG_NEWKEYS
  526.   .length = $ - ssh_msg_new_keys
  527.  
  528.  
  529. ssh_msg_request_service:
  530.         db SSH_MSG_SERVICE_REQUEST
  531.         str "ssh-userauth"              ; Service name
  532.   .length = $ - ssh_msg_request_service
  533.  
  534.  
  535. ssh_msg_channel_open:
  536.         db SSH_MSG_CHANNEL_OPEN
  537.         str "session"
  538.         dd_n 0                          ; Sender channel
  539.         dd_n BUFFERSIZE                 ; Initial window size
  540.         dd_n PACKETSIZE                 ; maximum packet size
  541.   .length = $ - ssh_msg_channel_open
  542.  
  543.  
  544. ssh_msg_channel_close:
  545.         db SSH_MSG_CHANNEL_CLOSE
  546.         dd_n 0                          ; Sender channel
  547.   .length = $ - ssh_msg_channel_close
  548.  
  549.  
  550. ssh_msg_channel_request:
  551.         db SSH_MSG_CHANNEL_REQUEST
  552.         dd_n 0                          ; Recipient channel
  553.         str "pty-req"
  554.         db 1                            ; Bool: want reply
  555.         str "xterm"
  556.         dd_n 80                         ; terminal width (rows)
  557.         dd_n 25                         ; terminal height (rows)
  558.         dd_n 80*8                       ; terminal width (pixels)
  559.         dd_n 25*16                      ; terminal height (pixels)
  560.  
  561.         dd_n 0                          ; list of supported opcodes
  562.   .length = $ - ssh_msg_channel_request
  563.  
  564.  
  565. ssh_msg_shell_request:
  566.         db SSH_MSG_CHANNEL_REQUEST
  567.         dd_n 0                          ; Recipient channel
  568.         str "shell"
  569.         db 1                            ; Bool: want reply
  570.   .length = $ - ssh_msg_shell_request
  571.  
  572.  
  573. ssh_msg_channel_data:
  574.         db SSH_MSG_CHANNEL_DATA
  575.         dd_n 0                          ; Sender channel
  576.   .len  dd ?
  577.   .data rb 4*MAX_INPUT_LENGTH + 1
  578.  
  579.  
  580. ssh_msg_channel_window_adjust:
  581.         db SSH_MSG_CHANNEL_WINDOW_ADJUST
  582.         dd_n 0                          ; Sender channel
  583.   .wnd  dd ?
  584.   .length = $ - ssh_msg_channel_window_adjust
  585.  
  586.  
  587. include_debug_strings
  588.  
  589. align 4
  590. @IMPORT:
  591.  
  592. library network, 'network.obj', \
  593.         console, 'console.obj', \
  594.         libcrash, 'libcrash.obj', \
  595.         libini, 'libini.obj'
  596.  
  597. import  network, \
  598.         getaddrinfo, 'getaddrinfo', \
  599.         freeaddrinfo, 'freeaddrinfo', \
  600.         inet_ntoa, 'inet_ntoa'
  601.  
  602. import  console, \
  603.         con_start, 'START', \
  604.         con_init, 'con_init', \
  605.         con_write_asciiz, 'con_write_asciiz', \
  606.         con_exit, 'con_exit', \
  607.         con_gets, 'con_gets', \
  608.         con_cls, 'con_cls', \
  609.         con_getch2, 'con_getch2', \
  610.         con_get_flags, 'con_get_flags', \
  611.         con_set_title, 'con_set_title', \
  612.         con_get_input, 'con_get_input'
  613.  
  614. import  libcrash, \
  615.         crash.init, "lib_init", \
  616.         crash.hash, "crash_hash", \
  617.         crash.mac, "crash_mac", \
  618.         crash.crypt, "crash_crypt", \
  619.         crash.hash_oneshot, "crash_hash_oneshot", \
  620.         crash.mac_oneshot, "crash_mac_oneshot", \
  621.         crash.crypt_oneshot, "crash_crypt_oneshot", \
  622.         \
  623.         crc32.init, "crc32_init", \
  624.         crc32.update, "crc32_update", \
  625.         crc32.finish, "crc32_finish", \
  626.         crc32.oneshot, "crc32_oneshot", \
  627.         md5.init, "md5_init", \
  628.         md5.update, "md5_update", \
  629.         md5.finish, "md5_finish", \
  630.         md5.oneshot, "md5_oneshot", \
  631.         sha1.init, "sha1_init", \
  632.         sha1.update, "sha1_update", \
  633.         sha1.finish, "sha1_finish", \
  634.         sha1.oneshot, "sha1_oneshot", \
  635.         sha2_224.init, "sha2_224_init", \
  636.         sha2_224.update, "sha2_224_update", \
  637.         sha2_224.finish, "sha2_224_finish", \
  638.         sha2_224.oneshot, "sha2_224_oneshot", \
  639.         sha2_256.init, "sha2_256_init", \
  640.         sha2_256.update, "sha2_256_update", \
  641.         sha2_256.finish, "sha2_256_finish", \
  642.         sha2_256.oneshot, "sha2_256_oneshot", \
  643.         sha2_384.init, "sha2_384_init", \
  644.         sha2_384.update, "sha2_384_update", \
  645.         sha2_384.finish, "sha2_384_finish", \
  646.         sha2_384.oneshot, "sha2_384_oneshot", \
  647.         sha2_512.init, "sha2_512_init", \
  648.         sha2_512.update, "sha2_512_update", \
  649.         sha2_512.finish, "sha2_512_finish", \
  650.         sha2_512.oneshot, "sha2_512_oneshot", \
  651.         sha3_224.init, "sha3_224_init", \
  652.         sha3_224.update, "sha3_224_update", \
  653.         sha3_224.finish, "sha3_224_finish", \
  654.         sha3_224.oneshot, "sha3_224_oneshot", \
  655.         sha3_256.init, "sha3_256_init", \
  656.         sha3_256.update, "sha3_256_update", \
  657.         sha3_256.finish, "sha3_256_finish", \
  658.         sha3_256.oneshot, "sha3_256_oneshot", \
  659.         sha3_384.init, "sha3_384_init", \
  660.         sha3_384.update, "sha3_384_update", \
  661.         sha3_384.finish, "sha3_384_finish", \
  662.         sha3_384.oneshot, "sha3_384_oneshot", \
  663.         sha3_512.init, "sha3_512_init", \
  664.         sha3_512.update, "sha3_512_update", \
  665.         sha3_512.finish, "sha3_512_finish", \
  666.         sha3_512.oneshot, "sha3_512_oneshot", \
  667.         \
  668.         poly1305.init, "poly1305_init", \
  669.         poly1305.update, "poly1305_update", \
  670.         poly1305.finish, "poly1305_finish", \
  671.         poly1305.oneshot, "poly1305_oneshot", \
  672.         hmac_sha2_256.init, "hmac_sha2_256_init", \
  673.         hmac_sha2_256.update, "hmac_sha2_256_update", \
  674.         hmac_sha2_256.finish, "hmac_sha2_256_finish", \
  675.         hmac_sha2_256.oneshot, "hmac_sha2_256_oneshot", \
  676.         hmac_sha2_512.init, "hmac_sha2_512_init", \
  677.         hmac_sha2_512.update, "hmac_sha2_512_update", \
  678.         hmac_sha2_512.finish, "hmac_sha2_512_finish", \
  679.         hmac_sha2_512.oneshot, "hmac_sha2_512_oneshot", \
  680.         \
  681.         chacha20.init, "chacha20_init", \
  682.         chacha20.update, "chacha20_update", \
  683.         chacha20.finish, "chacha20_finish", \
  684.         chacha20.oneshot, "chacha20_oneshot", \
  685.         aes256ctr.init, "aes256ctr_init", \
  686.         aes256ctr.update, "aes256ctr_update", \
  687.         aes256ctr.finish, "aes256ctr_finish", \
  688.         aes256ctr.oneshot, "aes256ctr_oneshot", \
  689.         aes256cbc.init, "aes256cbc_init", \
  690.         aes256cbc.update, "aes256cbc_update", \
  691.         aes256cbc.finish, "aes256cbc_finish", \
  692.         aes256cbc.oneshot, "aes256cbc_oneshot"
  693.  
  694. import  libini, \
  695.         ini_get_str, 'ini_get_str', \
  696.         ini_set_str, 'ini_set_str'
  697.  
  698. IncludeIGlobals
  699.  
  700. i_end:
  701.  
  702. IncludeUGlobals
  703.  
  704. align 16
  705. params          rb MAX_HOSTNAME_LENGTH
  706.  
  707. align 16
  708. ssh_con         sshlib_connection
  709.  
  710. align 16
  711. ssh_chan        sshlib_channel
  712.  
  713. keyb_input      rb MAX_INPUT_LENGTH
  714.  
  715. mem:
  716.