├── README.md ├── benchmark └── urandom_test.sh ├── images ├── WindTerm_icon_1024x1024.png └── screenshots │ ├── SplitView.png │ ├── WindTerm.png │ ├── WindTerm_DigeWhite_Theme.png │ └── readme.md └── src ├── LICENSE ├── Onigmo ├── .editorconfig ├── .gitignore ├── AUTHORS ├── COPYING ├── HISTORY ├── INSTALL ├── Makefile.am ├── Makefile.in ├── README ├── README.ja ├── aclocal.m4 ├── compile ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.in ├── depcomp ├── doc │ ├── API │ ├── API.ja │ ├── FAQ │ ├── FAQ.ja │ ├── RE │ ├── RE.ja │ └── UnicodeProps.txt ├── enc │ ├── ascii.c │ ├── big5.c │ ├── cp1251.c │ ├── cp932.c │ ├── euc_jp.c │ ├── euc_kr.c │ ├── euc_tw.c │ ├── gb18030.c │ ├── iso8859_1.c │ ├── iso8859_10.c │ ├── iso8859_11.c │ ├── iso8859_13.c │ ├── iso8859_14.c │ ├── iso8859_15.c │ ├── iso8859_16.c │ ├── iso8859_2.c │ ├── iso8859_3.c │ ├── iso8859_4.c │ ├── iso8859_5.c │ ├── iso8859_6.c │ ├── iso8859_7.c │ ├── iso8859_8.c │ ├── iso8859_9.c │ ├── koi8.c │ ├── koi8_r.c │ ├── mktable.c │ ├── sjis.c │ ├── unicode.c │ ├── unicode │ │ ├── casefold.h │ │ └── name2ctype.h │ ├── utf16_be.c │ ├── utf16_le.c │ ├── utf32_be.c │ ├── utf32_le.c │ └── utf8.c ├── index.html ├── index_ja.html ├── install-sh ├── ltmain.sh ├── m4 │ ├── libtool.m4 │ ├── ltoptions.m4 │ ├── ltsugar.m4 │ ├── ltversion.m4 │ └── lt~obsolete.m4 ├── missing ├── onig-config.in ├── onig.py ├── oniggnu.h ├── onigposix.h ├── oniguruma.h ├── oniguruma.pc.in ├── regcomp.c ├── regenc.c ├── regenc.h ├── regerror.c ├── regexec.c ├── regext.c ├── reggnu.c ├── regint.h ├── regparse.c ├── regparse.h ├── regposerr.c ├── regposix.c ├── regsyntax.c ├── regtrav.c ├── regversion.c ├── sample │ ├── Makefile.am │ ├── Makefile.in │ ├── crnl.c │ ├── encode.c │ ├── listcap.c │ ├── names.c │ ├── posix.c │ ├── simple.c │ ├── sql.c │ └── syntax.c ├── st.c ├── st.h ├── test.rb ├── testc.c ├── testconv.rb ├── testconvu.rb ├── testpy.py ├── testu.c ├── tool │ ├── .gitignore │ ├── CaseFolding.py │ ├── convert-name2ctype.sh │ └── enc-unicode.rb └── win32 │ ├── Makefile │ ├── config.h │ ├── makedef.py │ ├── onig.rc │ └── testc.c ├── Protocols ├── Protocol.h ├── TelnetProtocol.cpp └── TelnetProtocol.h ├── Pty ├── ConPty.cpp ├── ConPty.h ├── Pty.cpp ├── Pty.h ├── UnixPty.cpp ├── UnixPty.h ├── WinPty.cpp ├── WinPty.h └── ptyqt LICENSE ├── README.md ├── Utility ├── CircularBuffer.h ├── Cryptographic.cpp ├── Cryptographic.h ├── MemoryPointer.h ├── ScopeGuard.h ├── Spin.h ├── ThreadLocal.cpp └── ThreadLocal.h ├── Widgets ├── PopupWidget.cpp ├── PopupWidget.h ├── ScrollBar.cpp ├── ScrollBar.h ├── Splitter.cpp └── Splitter.h └── libssh ├── .arcconfig ├── .gitlab-ci.yml ├── AUTHORS ├── BSD ├── CMakeLists.txt ├── COPYING ├── CPackConfig.cmake ├── CTestConfig.cmake ├── ChangeLog ├── CompilerChecks.cmake ├── ConfigureChecks.cmake ├── DefineOptions.cmake ├── INSTALL ├── README ├── README.CodingStyle ├── README.mbedtls ├── README.md ├── SubmittingPatches ├── cmake ├── Modules │ ├── AddCCompilerFlag.cmake │ ├── AddCMockaTest.cmake │ ├── COPYING-CMAKE-SCRIPTS │ ├── CheckCCompilerFlagSSP.cmake │ ├── DefineCMakeDefaults.cmake │ ├── DefineCompilerFlags.cmake │ ├── DefinePlatformDefaults.cmake │ ├── ExtractSymbols.cmake │ ├── FindABIMap.cmake │ ├── FindArgp.cmake │ ├── FindCMocka.cmake │ ├── FindGCrypt.cmake │ ├── FindGSSAPI.cmake │ ├── FindMbedTLS.cmake │ ├── FindNSIS.cmake │ ├── FindNaCl.cmake │ ├── GenerateMap.cmake │ ├── GetFilesList.cmake │ └── MacroEnsureOutOfSourceBuild.cmake └── Toolchain-cross-m32.cmake ├── config.h.cmake ├── doc ├── CMakeLists.txt ├── authentication.dox ├── command.dox ├── curve25519-sha256@libssh.org.txt ├── forwarding.dox ├── guided_tour.dox ├── introduction.dox ├── linking.dox ├── mainpage.dox ├── scp.dox ├── sftp.dox ├── shell.dox ├── tbd.dox ├── that_style │ ├── LICENSE │ ├── README.md │ ├── header.html │ ├── img │ │ ├── doc.svg │ │ ├── folderclosed.svg │ │ ├── folderopen.svg │ │ ├── mag_glass.svg │ │ ├── nav_edge_inter.svg │ │ ├── nav_edge_left.svg │ │ ├── nav_edge_right.svg │ │ ├── splitbar_handle.svg │ │ ├── sync_off.png │ │ └── sync_on.png │ ├── js │ │ └── striped_bg.js │ └── that_style.css └── threading.dox ├── examples ├── CMakeLists.txt ├── authentication.c ├── connect_ssh.c ├── examples_common.h ├── exec.c ├── keygen.c ├── knownhosts.c ├── libssh_scp.c ├── libsshpp.cpp ├── libsshpp_noexcept.cpp ├── proxy.c ├── samplesftp.c ├── samplesshd-cb.c ├── samplesshd-kbdint.c ├── scp_download.c ├── senddata.c ├── ssh_client.c ├── ssh_server_fork.c ├── sshd_direct-tcpip.c └── sshnetcat.c ├── include ├── CMakeLists.txt └── libssh │ ├── CMakeLists.txt │ ├── agent.h │ ├── auth.h │ ├── bignum.h │ ├── bind.h │ ├── bind_config.h │ ├── blf.h │ ├── buffer.h │ ├── bytearray.h │ ├── callbacks.h │ ├── chacha.h │ ├── channels.h │ ├── config.h │ ├── config_parser.h │ ├── crypto.h │ ├── curve25519.h │ ├── dh-gex.h │ ├── dh.h │ ├── ecdh.h │ ├── ed25519.h │ ├── fe25519.h │ ├── ge25519.h │ ├── gssapi.h │ ├── kex.h │ ├── keys.h │ ├── knownhosts.h │ ├── legacy.h │ ├── libcrypto.h │ ├── libgcrypt.h │ ├── libmbedcrypto.h │ ├── libssh.h │ ├── libssh_version.h.cmake │ ├── libsshpp.hpp │ ├── messages.h │ ├── misc.h │ ├── options.h │ ├── packet.h │ ├── pcap.h │ ├── pki.h │ ├── pki_priv.h │ ├── poll.h │ ├── poly1305.h │ ├── priv.h │ ├── sc25519.h │ ├── scp.h │ ├── server.h │ ├── session.h │ ├── sftp.h │ ├── sftp_priv.h │ ├── socket.h │ ├── ssh2.h │ ├── string.h │ ├── threads.h │ ├── token.h │ └── wrapper.h ├── libssh.pc.cmake ├── src ├── ABI │ ├── current │ ├── libssh-4.5.0.symbols │ ├── libssh-4.5.1.symbols │ ├── libssh-4.6.0.symbols │ ├── libssh-4.7.0.symbols │ ├── libssh-4.7.1.symbols │ ├── libssh-4.7.2.symbols │ ├── libssh-4.7.3.symbols │ ├── libssh-4.7.4.symbols │ ├── libssh-4.8.0.symbols │ ├── libssh-4.8.1.symbols │ ├── libssh-4.8.2.symbols │ ├── libssh-4.8.3.symbols │ ├── libssh-4.8.4.symbols │ ├── libssh-4.8.5.symbols │ └── libssh-4.8.6.symbols ├── CMakeLists.txt ├── agent.c ├── auth.c ├── base64.c ├── bignum.c ├── bind.c ├── bind_config.c ├── buffer.c ├── callbacks.c ├── chachapoly.c ├── channels.c ├── client.c ├── config.c ├── config_parser.c ├── connect.c ├── connector.c ├── curve25519.c ├── dh-gex.c ├── dh.c ├── dh_crypto.c ├── dh_key.c ├── ecdh.c ├── ecdh_crypto.c ├── ecdh_gcrypt.c ├── ecdh_mbedcrypto.c ├── error.c ├── external │ ├── bcrypt_pbkdf.c │ ├── blowfish.c │ ├── chacha.c │ ├── curve25519_ref.c │ ├── ed25519.c │ ├── fe25519.c │ ├── ge25519.c │ ├── ge25519_base.data │ ├── poly1305.c │ └── sc25519.c ├── gcrypt_missing.c ├── getpass.c ├── gssapi.c ├── gzip.c ├── init.c ├── kdf.c ├── kex.c ├── known_hosts.c ├── knownhosts.c ├── legacy.c ├── libcrypto-compat.c ├── libcrypto-compat.h ├── libcrypto.c ├── libgcrypt.c ├── libmbedcrypto.c ├── libssh.map ├── log.c ├── match.c ├── mbedcrypto_missing.c ├── messages.c ├── misc.c ├── options.c ├── packet.c ├── packet_cb.c ├── packet_crypt.c ├── pcap.c ├── pki.c ├── pki_container_openssh.c ├── pki_crypto.c ├── pki_ed25519.c ├── pki_ed25519_common.c ├── pki_gcrypt.c ├── pki_mbedcrypto.c ├── poll.c ├── scp.c ├── server.c ├── session.c ├── sftp.c ├── sftpserver.c ├── socket.c ├── string.c ├── threads.c ├── threads │ ├── libcrypto.c │ ├── libgcrypt.c │ ├── mbedtls.c │ ├── noop.c │ ├── pthread.c │ └── winlocks.c ├── token.c └── wrapper.c └── tests ├── CMakeLists.txt ├── authentication.c ├── benchmarks ├── CMakeLists.txt ├── bench1.sh ├── bench2.sh ├── bench_raw.c ├── bench_scp.c ├── bench_sftp.c ├── benchmarks.c ├── benchmarks.h └── latency.c ├── chmodtest.c ├── chroot_wrapper.c ├── client ├── CMakeLists.txt ├── torture_algorithms.c ├── torture_auth.c ├── torture_client_config.c ├── torture_client_global_requests.c ├── torture_connect.c ├── torture_forward.c ├── torture_hostkey.c ├── torture_knownhosts.c ├── torture_knownhosts_verify.c ├── torture_proxycommand.c ├── torture_rekey.c ├── torture_request_env.c ├── torture_scp.c ├── torture_session.c ├── torture_sftp_benchmark.c ├── torture_sftp_canonicalize_path.c ├── torture_sftp_dir.c ├── torture_sftp_ext.c ├── torture_sftp_fsync.c └── torture_sftp_read.c ├── cmdline.c ├── connection.c ├── ctest-default.cmake ├── etc ├── group.in ├── hosts.in ├── pam.d │ └── sshd.in ├── pam_matrix_passdb.in ├── passwd.in └── shadow.in ├── fuzz ├── CMakeLists.txt └── ssh_server_fuzzer.cpp ├── generate.py ├── keys ├── certauth │ ├── id_rsa │ ├── id_rsa-cert.pub │ └── id_rsa.pub ├── id_ecdsa ├── id_ecdsa.pub ├── id_ed25519 ├── id_ed25519.pub ├── id_rsa ├── id_rsa.pub ├── ssh_host_dsa_key ├── ssh_host_dsa_key.pub ├── ssh_host_ecdsa_key ├── ssh_host_ecdsa_key.pub ├── ssh_host_key ├── ssh_host_key.pub ├── ssh_host_rsa_key ├── ssh_host_rsa_key.pub └── user_ca ├── pkd ├── CMakeLists.txt ├── pkd_client.h ├── pkd_daemon.c ├── pkd_daemon.h ├── pkd_hello.c ├── pkd_keyutil.c ├── pkd_keyutil.h ├── pkd_util.c └── pkd_util.h ├── server ├── CMakeLists.txt ├── test_server │ ├── CMakeLists.txt │ ├── default_cb.c │ ├── default_cb.h │ ├── main.c │ ├── test_server.c │ └── test_server.h ├── torture_server.c ├── torture_server_auth_kbdint.c └── torture_server_config.c ├── sftp_stress └── main.c ├── ssh_ping.c ├── test_exec.c ├── test_pcap.c ├── test_socket.c ├── test_ssh_bind_accept_fd.c ├── test_tunnel.c ├── tests.h ├── tests_config.h.cmake ├── torture.c ├── torture.h ├── torture_cmocka.c ├── torture_cmocka.h ├── torture_key.c ├── torture_key.h ├── torture_pki.c ├── torture_pki.h ├── unittests ├── CMakeLists.txt ├── torture_bind_config.c ├── torture_buffer.c ├── torture_bytearray.c ├── torture_callbacks.c ├── torture_channel.c ├── torture_config.c ├── torture_crypto.c ├── torture_hashes.c ├── torture_init.c ├── torture_isipaddr.c ├── torture_keyfiles.c ├── torture_knownhosts_parsing.c ├── torture_list.c ├── torture_misc.c ├── torture_moduli.c ├── torture_options.c ├── torture_packet.c ├── torture_packet_filter.c ├── torture_pki.c ├── torture_pki_dsa.c ├── torture_pki_ecdsa.c ├── torture_pki_ed25519.c ├── torture_pki_rsa.c ├── torture_push_pop_dir.c ├── torture_rand.c ├── torture_server_x11.c ├── torture_session_keys.c ├── torture_temp_dir.c ├── torture_temp_file.c ├── torture_threads_buffer.c ├── torture_threads_crypto.c ├── torture_threads_init.c ├── torture_threads_pki_rsa.c └── torture_tokens.c └── valgrind.supp /benchmark/urandom_test.sh: -------------------------------------------------------------------------------- 1 | # Generate 100MB data. 2 | if [ ! -f "./benchmark_randomdata" ];then 3 | cat /dev/urandom | base64 | dd of=./benchmark_randomdata bs=1024 count=100KB 4 | fi 5 | echo "Benchmark Result:" 6 | { time dd if=./benchmark_randomdata bs=10240; } 7 | -------------------------------------------------------------------------------- /images/WindTerm_icon_1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/images/WindTerm_icon_1024x1024.png -------------------------------------------------------------------------------- /images/screenshots/SplitView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/images/screenshots/SplitView.png -------------------------------------------------------------------------------- /images/screenshots/WindTerm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/images/screenshots/WindTerm.png -------------------------------------------------------------------------------- /images/screenshots/WindTerm_DigeWhite_Theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/images/screenshots/WindTerm_DigeWhite_Theme.png -------------------------------------------------------------------------------- /images/screenshots/readme.md: -------------------------------------------------------------------------------- 1 | Screenshots of WSL and SplitView. 2 | -------------------------------------------------------------------------------- /src/Onigmo/.editorconfig: -------------------------------------------------------------------------------- 1 | ; see: http://editorconfig.org/ 2 | 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [**.[ch]] 11 | indent_style = tab 12 | indent_size = 2 13 | tab_width = 8 14 | 15 | [**.py] 16 | indent_style = space 17 | indent_size = 4 18 | 19 | [**.rb] 20 | indent_style = space 21 | indent_size = 2 22 | tab_width = 8 23 | 24 | [win32/*] 25 | end_of_line = crlf 26 | 27 | [win32/*.py] 28 | end_of_line = lf 29 | -------------------------------------------------------------------------------- /src/Onigmo/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore dot-files, binary files and backup files 2 | .* 3 | *.o 4 | *.lo 5 | *.so 6 | *.a 7 | *.la 8 | *.obj 9 | *.def 10 | *.dll 11 | *.exe 12 | *.exp 13 | *.lib 14 | *.pyc 15 | *.bak 16 | *.BAK 17 | *~ 18 | *.swp 19 | *.orig 20 | *.rej 21 | *.RES 22 | *.res 23 | 24 | # don't want to ignore 25 | !.gitignore 26 | !.editorconfig 27 | 28 | # working dirs 29 | .deps 30 | .libs 31 | 32 | # autotools generated files 33 | /autom4te.cache 34 | /config.h 35 | /config.log 36 | /config.status 37 | /libtool 38 | /onig-config 39 | /oniguruma.pc 40 | /Makefile 41 | /sample/Makefile 42 | /stamp-h1 43 | 44 | # generated executable files 45 | /enc/mktable 46 | /sample/crnl 47 | /sample/encode 48 | /sample/listcap 49 | /sample/names 50 | /sample/posix 51 | /sample/simple 52 | /sample/sql 53 | /sample/syntax 54 | /testc 55 | /testcu 56 | /testp 57 | 58 | # tag files 59 | tags 60 | TAGS 61 | 62 | # GNU global files 63 | GPATH 64 | GRTAGS 65 | GSYMS 66 | GTAGS 67 | -------------------------------------------------------------------------------- /src/Onigmo/AUTHORS: -------------------------------------------------------------------------------- 1 | kentkt AT csc DOT jp (K.Takata) 2 | sndgk393 AT ybb DOT ne DOT jp (K.Kosako) 3 | -------------------------------------------------------------------------------- /src/Onigmo/doc/FAQ: -------------------------------------------------------------------------------- 1 | FAQ 2011/09/18 2 | 3 | 1. Longest match 4 | 5 | You can execute longest match by using ONIG_OPTION_FIND_LONGEST option 6 | in onig_new(). 7 | 8 | 9 | 2. Thread safe 10 | 11 | In order to make thread safe, which of (A) or (B) must be done. 12 | 13 | (A) Onigmo Layer 14 | 15 | Define the macro below in oniguruma/regint.h. 16 | 17 | USE_MULTI_THREAD_SYSTEM 18 | THREAD_ATOMIC_START 19 | THREAD_ATOMIC_END 20 | THREAD_PASS 21 | 22 | THREAD_SYSTEM_INIT 23 | THREAD_SYSTEM_END 24 | 25 | 26 | (B) Application Layer 27 | 28 | The plural threads should not do simultaneously that making 29 | new regexp objects or re-compiling objects or freeing objects, 30 | even if these objects are differ. 31 | 32 | 33 | 3. CR + LF 34 | 35 | DOS newline (CR (0x0c) + LF (0x0a) sequence) 36 | 37 | Enable the following line in regenc.h, and use ONIG_OPTION_NEWLINE_CRLF 38 | option in onig_new(). 39 | 40 | /* #define USE_CRNL_AS_LINE_TERMINATOR */ 41 | 42 | 43 | 4. Mailing list 44 | 45 | There is no mailing list about Onigmo/Oniguruma. 46 | 47 | // END 48 | -------------------------------------------------------------------------------- /src/Onigmo/enc/cp932.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | cp932.c - Onigmo (Oniguruma-mod) (regular expression library) 3 | **********************************************************************/ 4 | /*- 5 | * Copyright (c) 2002-2009 K.Kosako 6 | * Copyright (c) 2011 K.Takata 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #define ENC_CP932 32 | #include "sjis.c" 33 | -------------------------------------------------------------------------------- /src/Onigmo/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /src/Onigmo/onig-config.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2006 K.Kosako (sndgk393 AT ybb DOT ne DOT jp) 3 | 4 | ONIG_VERSION=@PACKAGE_VERSION@ 5 | 6 | show_usage() 7 | { 8 | cat < 6 | * Copyright (c) 2011-2013 K.Takata 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #include "config.h" 32 | #include "oniguruma.h" 33 | #include 34 | 35 | extern const char* 36 | onig_version(void) 37 | { 38 | static char s[12]; 39 | 40 | sprintf(s, "%d.%d.%d", 41 | ONIGURUMA_VERSION_MAJOR, 42 | ONIGURUMA_VERSION_MINOR, 43 | ONIGURUMA_VERSION_TEENY); 44 | return s; 45 | } 46 | 47 | extern const char* 48 | onig_copyright(void) 49 | { 50 | static char s[80]; 51 | 52 | sprintf(s, "Onigmo %d.%d.%d : Copyright (C) 2002-2009 K.Kosako, " 53 | "2011-2013 K.Takata", 54 | ONIGURUMA_VERSION_MAJOR, 55 | ONIGURUMA_VERSION_MINOR, 56 | ONIGURUMA_VERSION_TEENY); 57 | return s; 58 | } 59 | -------------------------------------------------------------------------------- /src/Onigmo/sample/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = encode listcap names posix simple sql syntax crnl 2 | 3 | libname = $(top_builddir)/libonig.la 4 | LDADD = $(libname) 5 | INCLUDES = -I$(top_srcdir) -I$(includedir) 6 | 7 | encode_SOURCES = encode.c 8 | listcap_SOURCES = listcap.c 9 | names_SOURCES = names.c 10 | posix_SOURCES = posix.c 11 | simple_SOURCES = simple.c 12 | sql_SOURCES = sql.c 13 | syntax_SOURCES = syntax.c 14 | 15 | 16 | sampledir = $(top_builddir)/sample 17 | 18 | test: encode listcap names posix simple sql syntax 19 | @$(sampledir)/encode 20 | @$(sampledir)/listcap 21 | @$(sampledir)/names 22 | @$(sampledir)/posix 23 | @$(sampledir)/simple 24 | @$(sampledir)/sql 25 | @$(sampledir)/syntax 26 | -------------------------------------------------------------------------------- /src/Onigmo/sample/names.c: -------------------------------------------------------------------------------- 1 | /* 2 | * names.c -- example of group name callback. 3 | */ 4 | #include 5 | #include 6 | #include "oniguruma.h" 7 | 8 | static int 9 | name_callback(const UChar* name, const UChar* name_end, 10 | int ngroup_num, int* group_nums, 11 | regex_t* reg, void* arg) 12 | { 13 | int i, gn, ref; 14 | char* s; 15 | OnigRegion *region = (OnigRegion* )arg; 16 | 17 | for (i = 0; i < ngroup_num; i++) { 18 | gn = group_nums[i]; 19 | ref = onig_name_to_backref_number(reg, name, name_end, region); 20 | s = (ref == gn ? "*" : ""); 21 | fprintf(stderr, "%s (%d): ", name, gn); 22 | fprintf(stderr, "(%ld-%ld) %s\n", (int)region->beg[gn], (int)region->end[gn], s); 23 | } 24 | return 0; /* 0: continue */ 25 | } 26 | 27 | extern int main(int argc, char* argv[]) 28 | { 29 | OnigPosition r; 30 | OnigPosition start, range, end; 31 | regex_t* reg; 32 | OnigErrorInfo einfo; 33 | OnigRegion *region; 34 | 35 | static UChar* pattern = (UChar* )"(?a*)(?b*)(?c*)"; 36 | static UChar* str = (UChar* )"aaabbbbcc"; 37 | OnigIterator it = {onig_default_charat, str}; 38 | 39 | r = onig_new(®, pattern, pattern + strlen((char* )pattern), 40 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); 41 | if (r != ONIG_NORMAL) { 42 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 43 | onig_error_code_to_str(s, r, &einfo); 44 | fprintf(stderr, "ERROR: %s\n", s); 45 | return -1; 46 | } 47 | 48 | fprintf(stderr, "number of names: %d\n", onig_number_of_names(reg)); 49 | 50 | region = onig_region_new(); 51 | 52 | end = strlen((char* )str); 53 | start = 0; 54 | range = end; 55 | r = onig_search(&it, reg, 0, end, start, range, region, ONIG_OPTION_NONE); 56 | if (r >= 0) { 57 | fprintf(stderr, "match at %d\n\n", r); 58 | r = onig_foreach_name(reg, name_callback, (void* )region); 59 | } 60 | else if (r == ONIG_MISMATCH) { 61 | fprintf(stderr, "search fail\n"); 62 | } 63 | else { /* error */ 64 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 65 | onig_error_code_to_str(s, r); 66 | return -1; 67 | } 68 | 69 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */); 70 | onig_free(reg); 71 | onig_end(); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /src/Onigmo/sample/simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | * simple.c 3 | */ 4 | #include 5 | #include 6 | #include "oniguruma.h" 7 | 8 | extern int main(int argc, char* argv[]) 9 | { 10 | OnigPosition r; 11 | OnigPosition start, range, end; 12 | regex_t* reg; 13 | OnigErrorInfo einfo; 14 | OnigRegion *region; 15 | 16 | static UChar* pattern = (UChar* )"a(.*)b|[e-f]+"; 17 | static UChar* str = (UChar* )"zzzzaffffffffb"; 18 | OnigIterator it = {onig_default_charat, str}; 19 | 20 | r = onig_new(®, pattern, pattern + strlen((char* )pattern), 21 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); 22 | if (r != ONIG_NORMAL) { 23 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 24 | onig_error_code_to_str(s, r, &einfo); 25 | fprintf(stderr, "ERROR: %s\n", s); 26 | return -1; 27 | } 28 | 29 | region = onig_region_new(); 30 | 31 | end = strlen((char* )str); 32 | start = 0; 33 | range = end; 34 | r = onig_search(&it, reg, 0, end, start, range, region, ONIG_OPTION_NONE); 35 | if (r >= 0) { 36 | int i; 37 | 38 | fprintf(stderr, "match at %d\n", r); 39 | for (i = 0; i < region->num_regs; i++) { 40 | fprintf(stderr, "%d: (%ld-%ld)\n", i, (int)region->beg[i], (int)region->end[i]); 41 | } 42 | } 43 | else if (r == ONIG_MISMATCH) { 44 | fprintf(stderr, "search fail\n"); 45 | } 46 | else { /* error */ 47 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 48 | onig_error_code_to_str(s, r); 49 | fprintf(stderr, "ERROR: %s\n", s); 50 | return -1; 51 | } 52 | 53 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */); 54 | onig_free(reg); 55 | onig_end(); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /src/Onigmo/sample/sql.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sql.c 3 | */ 4 | #include 5 | #include 6 | #include "oniguruma.h" 7 | 8 | extern int main(int argc, char* argv[]) 9 | { 10 | static OnigSyntaxType SQLSyntax; 11 | 12 | OnigPosition r; 13 | OnigPosition start, range, end; 14 | regex_t* reg; 15 | OnigErrorInfo einfo; 16 | OnigRegion *region; 17 | 18 | static UChar* pattern = (UChar* )"\\_%\\\\__zz"; 19 | static UChar* str = (UChar* )"a_abcabcabc\\ppzz"; 20 | OnigIterator it = {onig_default_charat, str}; 21 | 22 | onig_set_syntax_op (&SQLSyntax, ONIG_SYN_OP_VARIABLE_META_CHARACTERS); 23 | onig_set_syntax_op2 (&SQLSyntax, 0); 24 | onig_set_syntax_behavior(&SQLSyntax, 0); 25 | onig_set_syntax_options (&SQLSyntax, ONIG_OPTION_MULTILINE); 26 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ESCAPE, (OnigCodePoint )'\\'); 27 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR, (OnigCodePoint )'_'); 28 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYTIME, 29 | ONIG_INEFFECTIVE_META_CHAR); 30 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ZERO_OR_ONE_TIME, 31 | ONIG_INEFFECTIVE_META_CHAR); 32 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ONE_OR_MORE_TIME, 33 | ONIG_INEFFECTIVE_META_CHAR); 34 | onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR_ANYTIME, 35 | (OnigCodePoint )'%'); 36 | 37 | r = onig_new(®, pattern, pattern + strlen((char* )pattern), 38 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, &SQLSyntax, &einfo); 39 | if (r != ONIG_NORMAL) { 40 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 41 | onig_error_code_to_str(s, r, &einfo); 42 | fprintf(stderr, "ERROR: %s\n", s); 43 | return -1; 44 | } 45 | 46 | region = onig_region_new(); 47 | 48 | end = strlen((char* )str); 49 | start = 0; 50 | range = end; 51 | r = onig_search(&it, reg, 0, end, start, range, region, ONIG_OPTION_NONE); 52 | if (r >= 0) { 53 | int i; 54 | 55 | fprintf(stderr, "match at %d\n", r); 56 | for (i = 0; i < region->num_regs; i++) { 57 | fprintf(stderr, "%d: (%ld-%ld)\n", i, (int)region->beg[i], (int)region->end[i]); 58 | } 59 | } 60 | else if (r == ONIG_MISMATCH) { 61 | fprintf(stderr, "search fail\n"); 62 | } 63 | else { /* error */ 64 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 65 | onig_error_code_to_str(s, r); 66 | fprintf(stderr, "ERROR: %s\n", s); 67 | return -1; 68 | } 69 | 70 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */); 71 | onig_free(reg); 72 | onig_end(); 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /src/Onigmo/sample/syntax.c: -------------------------------------------------------------------------------- 1 | /* 2 | * syntax.c 3 | */ 4 | #include 5 | #include 6 | #include "oniguruma.h" 7 | 8 | extern int exec(OnigSyntaxType* syntax, 9 | char* apattern, char* astr) 10 | { 11 | OnigPosition r; 12 | OnigPosition start, range, end; 13 | regex_t* reg; 14 | OnigErrorInfo einfo; 15 | OnigRegion *region; 16 | UChar* pattern = (UChar* )apattern; 17 | UChar* str = (UChar* )astr; 18 | OnigIterator it = {onig_default_charat, str}; 19 | 20 | r = onig_new(®, pattern, pattern + strlen((char* )pattern), 21 | ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo); 22 | if (r != ONIG_NORMAL) { 23 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 24 | onig_error_code_to_str(s, r, &einfo); 25 | fprintf(stderr, "ERROR: %s\n", s); 26 | return -1; 27 | } 28 | 29 | region = onig_region_new(); 30 | 31 | end = strlen((char* )str); 32 | start = 0; 33 | range = end; 34 | r = onig_search(&it, reg, 0, end, start, range, region, ONIG_OPTION_NONE); 35 | if (r >= 0) { 36 | int i; 37 | 38 | fprintf(stderr, "match at %d\n", r); 39 | for (i = 0; i < region->num_regs; i++) { 40 | fprintf(stderr, "%d: (%ld-%ld)\n", i, (int)region->beg[i], (int)region->end[i]); 41 | } 42 | } 43 | else if (r == ONIG_MISMATCH) { 44 | fprintf(stderr, "search fail\n"); 45 | } 46 | else { /* error */ 47 | char s[ONIG_MAX_ERROR_MESSAGE_LEN]; 48 | onig_error_code_to_str(s, r); 49 | fprintf(stderr, "ERROR: %s\n", s); 50 | return -1; 51 | } 52 | 53 | onig_region_free(region, 1 /* 1:free self, 0:free contents only */); 54 | onig_free(reg); 55 | onig_end(); 56 | return 0; 57 | } 58 | 59 | extern int main(int argc, char* argv[]) 60 | { 61 | int r; 62 | 63 | r = exec(ONIG_SYNTAX_PERL, 64 | "\\p{XDigit}\\P{XDigit}\\p{^XDigit}\\P{^XDigit}\\p{XDigit}", 65 | "bgh3a"); 66 | 67 | r = exec(ONIG_SYNTAX_JAVA, 68 | "\\p{XDigit}\\P{XDigit}[a-c&&b-g]", "bgc"); 69 | 70 | r = exec(ONIG_SYNTAX_ASIS, 71 | "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$", 72 | "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$"); 73 | onig_end(); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /src/Onigmo/st.h: -------------------------------------------------------------------------------- 1 | /* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */ 2 | 3 | /* @(#) st.h 5.1 89/12/14 */ 4 | 5 | #ifndef ST_INCLUDED 6 | 7 | #define ST_INCLUDED 8 | 9 | typedef uintptr_t st_data_t; 10 | #define ST_DATA_T_DEFINED 11 | 12 | typedef struct st_table st_table; 13 | 14 | struct st_hash_type { 15 | int (*compare)(); 16 | int (*hash)(); 17 | }; 18 | 19 | struct st_table { 20 | struct st_hash_type *type; 21 | int num_bins; 22 | int num_entries; 23 | struct st_table_entry **bins; 24 | }; 25 | 26 | #define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0) 27 | 28 | enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK}; 29 | 30 | #ifndef _ 31 | # define _(args) args 32 | #endif 33 | #ifndef ANYARGS 34 | # ifdef __cplusplus 35 | # define ANYARGS ... 36 | # else 37 | # define ANYARGS 38 | # endif 39 | #endif 40 | 41 | st_table *st_init_table _((struct st_hash_type *)); 42 | st_table *st_init_table_with_size _((struct st_hash_type *, int)); 43 | st_table *st_init_numtable _((void)); 44 | st_table *st_init_numtable_with_size _((int)); 45 | st_table *st_init_strtable _((void)); 46 | st_table *st_init_strtable_with_size _((int)); 47 | int st_delete _((st_table *, st_data_t *, st_data_t *)); 48 | int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t)); 49 | int st_insert _((st_table *, st_data_t, st_data_t)); 50 | int st_lookup _((st_table *, st_data_t, st_data_t *)); 51 | int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t)); 52 | void st_add_direct _((st_table *, st_data_t, st_data_t)); 53 | void st_free_table _((st_table *)); 54 | void st_cleanup_safe _((st_table *, st_data_t)); 55 | st_table *st_copy _((st_table *)); 56 | 57 | #define ST_NUMCMP ((int (*)()) 0) 58 | #define ST_NUMHASH ((int (*)()) -2) 59 | 60 | #define st_numcmp ST_NUMCMP 61 | #define st_numhash ST_NUMHASH 62 | 63 | #endif /* ST_INCLUDED */ 64 | -------------------------------------------------------------------------------- /src/Onigmo/test.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/Onigmo/test.rb -------------------------------------------------------------------------------- /src/Onigmo/testc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/Onigmo/testc.c -------------------------------------------------------------------------------- /src/Onigmo/tool/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore UCD files 2 | Blocks.txt 3 | CaseFolding.txt 4 | DerivedAge.txt 5 | DerivedCoreProperties.txt 6 | PropList.txt 7 | PropertyAliases.txt 8 | PropertyValueAliases.txt 9 | Scripts.txt 10 | UnicodeData.txt 11 | 12 | # ignore generated files 13 | casefold.h 14 | name2ctype.h 15 | name2ctype.kwd 16 | -------------------------------------------------------------------------------- /src/Onigmo/tool/convert-name2ctype.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Convert name2ctype.kwd to name2ctype.h using GNU gperf. 4 | # 5 | # Usage: 6 | # convert-name2ctype.sh name2ctype.kwd > name2ctype.h 7 | 8 | NAME2CTYPE_OPTIONS='-7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p' 9 | 10 | # undef USE_UNICODE_PROPERTIES 11 | sed '/^#ifdef USE_UNICODE_PROPERTIES/,/^#endif/d' $1 | gperf ${NAME2CTYPE_OPTIONS} > name2ctype-1.h 12 | # define USE_UNICODE_PROPERTIES 13 | sed '/^\(#ifdef USE_UNICODE_PROPERTIES\|#endif\)/d' $1 | gperf ${NAME2CTYPE_OPTIONS} > name2ctype-2.h 14 | # merge them 15 | diff -DUSE_UNICODE_PROPERTIES name2ctype-1.h name2ctype-2.h 16 | rm name2ctype-1.h name2ctype-2.h 17 | -------------------------------------------------------------------------------- /src/Onigmo/win32/config.h: -------------------------------------------------------------------------------- 1 | #define STDC_HEADERS 1 2 | #define HAVE_SYS_TYPES_H 1 3 | #define HAVE_SYS_STAT_H 1 4 | #define HAVE_STDLIB_H 1 5 | #define HAVE_STRING_H 1 6 | #define HAVE_MEMORY_H 1 7 | #define HAVE_FLOAT_H 1 8 | #define HAVE_OFF_T 1 9 | #define SIZEOF_INT 4 10 | #define SIZEOF_SHORT 2 11 | #define SIZEOF_LONG 4 12 | #define SIZEOF_LONG_LONG 0 13 | #define SIZEOF___INT64 8 14 | #define SIZEOF_OFF_T 4 15 | #define SIZEOF_VOIDP 4 16 | #define SIZEOF_FLOAT 4 17 | #define SIZEOF_DOUBLE 8 18 | #define HAVE_PROTOTYPES 1 19 | #define TOKEN_PASTE(x,y) x##y 20 | #define HAVE_STDARG_PROTOTYPES 1 21 | #ifndef NORETURN 22 | #if _MSC_VER > 1100 23 | #define NORETURN(x) __declspec(noreturn) x 24 | #else 25 | #define NORETURN(x) x 26 | #endif 27 | #endif 28 | #define HAVE_DECL_SYS_NERR 1 29 | #define HAVE_LIMITS_H 1 30 | #define HAVE_FCNTL_H 1 31 | #define HAVE_SYS_UTIME_H 1 32 | #if _MSC_VER >= 1600 33 | #define HAVE_STDINT_H 1 34 | #endif 35 | #define uid_t int 36 | #define gid_t int 37 | #define HAVE_STRUCT_STAT_ST_RDEV 1 38 | #define HAVE_ST_RDEV 1 39 | #define GETGROUPS_T int 40 | #define RETSIGTYPE void 41 | #define HAVE_ALLOCA 1 42 | #define HAVE_DUP2 1 43 | #define HAVE_MEMCMP 1 44 | #define HAVE_MEMMOVE 1 45 | #define HAVE_MKDIR 1 46 | #define HAVE_STRCASECMP 1 47 | #define HAVE_STRNCASECMP 1 48 | #define HAVE_STRERROR 1 49 | #define HAVE_STRFTIME 1 50 | #define HAVE_STRCHR 1 51 | #define HAVE_STRSTR 1 52 | #define HAVE_STRTOD 1 53 | #define HAVE_STRTOL 1 54 | #define HAVE_STRTOUL 1 55 | #define HAVE_FLOCK 1 56 | #define HAVE_VSNPRINTF 1 57 | #define HAVE_FINITE 1 58 | #define HAVE_FMOD 1 59 | #define HAVE_FREXP 1 60 | #define HAVE_HYPOT 1 61 | #define HAVE_MODF 1 62 | #define HAVE_WAITPID 1 63 | #define HAVE_CHSIZE 1 64 | #define HAVE_TIMES 1 65 | #define HAVE__SETJMP 1 66 | #define HAVE_TELLDIR 1 67 | #define HAVE_SEEKDIR 1 68 | #define HAVE_MKTIME 1 69 | #define HAVE_COSH 1 70 | #define HAVE_SINH 1 71 | #define HAVE_TANH 1 72 | #define HAVE_EXECVE 1 73 | #define HAVE_TZNAME 1 74 | #define HAVE_DAYLIGHT 1 75 | #define SETPGRP_VOID 1 76 | #define inline __inline 77 | #define NEED_IO_SEEK_BETWEEN_RW 1 78 | #define RSHIFT(x,y) ((x)>>(int)y) 79 | #define FILE_COUNT _cnt 80 | #define FILE_READPTR _ptr 81 | #define DEFAULT_KCODE KCODE_NONE 82 | #define DLEXT ".so" 83 | #define DLEXT2 ".dll" 84 | -------------------------------------------------------------------------------- /src/Onigmo/win32/makedef.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | import re 5 | 6 | header_files = ( 7 | "oniguruma.h", "regenc.h", 8 | "oniggnu.h", "onigposix.h" 9 | ) 10 | 11 | exclude_symbols = ( 12 | "OnigEncodingKOI8", 13 | 14 | # USE_UPPER_CASE_TABLE 15 | "OnigEncAsciiToUpperCaseTable", 16 | "OnigEncISO_8859_1_ToUpperCaseTable", 17 | 18 | # USE_RECOMPILE_API 19 | "onig_recompile", 20 | "onig_recompile_deluxe", 21 | "re_recompile_pattern", 22 | 23 | # USE_VARIABLE_META_CHARS 24 | #"onig_set_meta_char", 25 | 26 | # USE_CAPTURE_HISTORY 27 | #"onig_get_capture_tree", 28 | ) 29 | 30 | symbols = set() 31 | 32 | rx1 = re.compile("(ONIG_EXTERN.*)$") 33 | rx2 = re.compile(r"(\w+)( +PV?_\(\(.*\)\)|\[.*\])?;\s*(/\*.*\*/)?$") 34 | for filename in header_files: 35 | with open(filename, "r") as f: 36 | while True: 37 | line = f.readline() 38 | if not line: 39 | break 40 | m = rx1.match(line) 41 | if not m: 42 | continue 43 | s = m.group(1) 44 | if s[-1] != ';': 45 | s += ' ' + f.readline() 46 | m2 = rx2.search(s) 47 | if m2 and (not m2.group(1) in exclude_symbols): 48 | symbols.add(m2.group(1)) 49 | 50 | print('EXPORTS') 51 | for s in sorted(symbols): 52 | print('\t' + s) 53 | -------------------------------------------------------------------------------- /src/Onigmo/win32/testc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/Onigmo/win32/testc.c -------------------------------------------------------------------------------- /src/Protocols/Protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PROTOCOL_H 18 | #define PROTOCOL_H 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | class Protocol 25 | { 26 | public: 27 | Protocol(void) = default; 28 | virtual ~Protocol(void) = default; 29 | 30 | QByteArray name() const { return m_name; } 31 | 32 | protected: 33 | QByteArray m_name; 34 | }; 35 | 36 | #endif // PROTOCOL_H -------------------------------------------------------------------------------- /src/Pty/ConPty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CONPTY_H 18 | #define CONPTY_H 19 | 20 | #pragma once 21 | 22 | #include "Pty.h" 23 | 24 | #ifdef Q_OS_WIN 25 | #include 26 | #endif // Q_OS_WIN 27 | 28 | class PipeThread; 29 | 30 | class ConPty 31 | : public Pty 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | ConPty(QObject *parent = nullptr); 37 | virtual ~ConPty(); 38 | 39 | void appendBuffer(const QByteArray &buffer); 40 | bool createProcess(QString command, const QString &arguments, 41 | const QString &workingDirectory, const QStringList &environment, 42 | qint16 rows, qint16 columns) final; 43 | static bool isAvailable(); 44 | QByteArray readAll() final; 45 | bool resizeWindow(qint16 rows, qint16 columns) final; 46 | qint64 write(const QByteArray &text) final; 47 | 48 | private: 49 | HRESULT createPseudoConsoleAndPipes(HPCON *phPC, HANDLE *phPipeIn, HANDLE *phPipeOut, qint16 rows, qint16 columns); 50 | HRESULT initStartupInfoAttachedToPseudoConsole(STARTUPINFOEX *pStartupInfo, HPCON hPC); 51 | void stop(); 52 | 53 | private: 54 | Q_DISABLE_COPY(ConPty) 55 | 56 | QByteArray m_buffer; 57 | PipeThread *m_pipeThread; 58 | 59 | HANDLE m_inPipe; 60 | HANDLE m_outPipe; 61 | HPCON m_ptyHandler; 62 | std::unique_ptr m_processInformation; 63 | std::unique_ptr m_startupInfo; 64 | }; 65 | 66 | #endif // CONPTY_H -------------------------------------------------------------------------------- /src/Pty/Pty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PTY_H 18 | #define PTY_H 19 | 20 | #include 21 | 22 | #include "Public/Spin.h" 23 | 24 | class QWinEventNotifier; 25 | 26 | class Pty 27 | : public QObject 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | Pty(); 33 | virtual ~Pty() = default; 34 | 35 | virtual bool createProcess(QString command, const QString &arguments, 36 | const QString &workingDirectory, const QStringList &environment, 37 | qint16 rows, qint16 columns) = 0; 38 | int errorCode() const { return m_errorCode; } 39 | QString errorString(); 40 | virtual QByteArray readAll() = 0; 41 | virtual bool resizeWindow(qint16 rows, qint16 columns) = 0; 42 | void setErrorCode(int errorCode); 43 | void setErrorString(const QString &errorString); 44 | virtual qint64 write(const QByteArray &text) = 0; 45 | 46 | protected: 47 | #ifdef Q_OS_WIN 48 | void installWinProcessEventNotifier(void *handle); 49 | void uninstallWinProcessEventNotifier(void *handle); 50 | #endif 51 | 52 | Q_SIGNALS: 53 | void errorOccurred(); 54 | void readyRead(); 55 | 56 | protected: 57 | SpinMutex m_mutex; 58 | 59 | qint16 m_columns; 60 | qint16 m_rows; 61 | 62 | private: 63 | Q_DISABLE_COPY(Pty) 64 | 65 | int m_errorCode; 66 | QString m_errorString; 67 | 68 | #ifdef Q_OS_WIN 69 | QWinEventNotifier *m_winProcessEventNotifier; 70 | #endif 71 | }; 72 | 73 | #endif // PTY_H 74 | -------------------------------------------------------------------------------- /src/Pty/UnixPty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef UNIXPTY_H 17 | #define UNIXPTY_H 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #ifdef Q_OS_UNIX 24 | 25 | #include "Pty.h" 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | class ShellProcess 32 | : public QProcess 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | ShellProcess(); 38 | 39 | private: 40 | void setupChildProcess() final; 41 | 42 | private: 43 | int m_handleMaster; 44 | int m_handleSlave; 45 | QString m_handleSlaveName; 46 | 47 | private: 48 | friend class UnixPty; 49 | }; 50 | 51 | class UnixPty 52 | : public Pty 53 | { 54 | public: 55 | UnixPty(QObject *parent = nullptr); 56 | virtual ~UnixPty(); 57 | 58 | bool createProcess(QString command, const QString &arguments, 59 | const QString &workingDirectory, const QProcessEnvironment &environment, 60 | int rows, int columns) final; 61 | static bool isAvailable(); 62 | bool resizeWindow(int rows, int columns) final; 63 | QByteArray readAll() final; 64 | qint64 write(const QByteArray &text) final; 65 | 66 | private: 67 | void moveToThread(QThread *targetThread); 68 | void setError(const char *error); 69 | bool setTerminalAttributes(struct ::termios *ttmode); 70 | void stop(); 71 | bool terminalAttributes(struct ::termios *ttmode); 72 | 73 | private: 74 | qint64 m_pid; 75 | ShellProcess m_shellProcess; 76 | QSocketNotifier *m_readMasterNotify; 77 | 78 | char *m_buffer; 79 | QByteArray m_shellReadBuffer; 80 | }; 81 | 82 | #endif // Q_OS_UNIX 83 | #endif // UNIXPTY_H 84 | -------------------------------------------------------------------------------- /src/Pty/WinPty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef WINPTY_H 18 | #define WINPTY_H 19 | 20 | #pragma once 21 | 22 | #include "Pty.h" 23 | 24 | #ifdef Q_OS_WIN 25 | #include 26 | #endif // Q_OS_WIN 27 | 28 | #include "winpty_api.h" 29 | 30 | class QLocalSocket; 31 | 32 | class WinPty 33 | : public Pty 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | WinPty(QObject *parent = nullptr); 39 | virtual ~WinPty(); 40 | 41 | bool createProcess(QString command, const QString &arguments, 42 | const QString &workingDirectory, const QStringList &environment, 43 | qint16 rows, qint16 columns) final; 44 | static bool isAvailable(); 45 | QByteArray readAll() final; 46 | bool resizeWindow(qint16 rows, qint16 columns) final; 47 | qint64 write(const QByteArray &text) final; 48 | 49 | private: 50 | void stop(); 51 | 52 | private: 53 | Q_DISABLE_COPY(WinPty) 54 | 55 | winpty_t *m_ptyHandler; 56 | HANDLE m_innerHandle; 57 | std::unique_ptr m_inSocket; 58 | std::unique_ptr m_outSocket; 59 | }; 60 | 61 | #endif // WINPTY_H -------------------------------------------------------------------------------- /src/Pty/ptyqt LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Vitaly Petrov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | **Important: WindTerm is a partial open source project, and the source will be gradually opened.** 2 | 3 | **All released source codes (except thirdparty directory) are provided under the terms of Apache-2.0 license.** 4 | 5 | # Components 6 | 7 | Below is a list of (some) WindTerm components in alphabetical order, along with a brief description of each. 8 | 9 | ## Libssh 10 | 11 | An improved version based on libssh 0.95. Add support for pageant, external socket, and hmac-md5-96, hmac-sha1-96-etm@openssh.com, hmac-sha1-96, hmac-md5-96-etm@openssh.com. 12 | 13 | ## Onigmo 14 | 15 | An improved version based on Onigmo 5.13.5. In particular, **the addition of iterator makes it possible to match gap buffer or nonadjacent memory blocks.** Please refer to the sample files for how to use. 16 | 17 | ## Pty 18 | 19 | An improved version based on [ptyqt](https://github.com/kafeg/ptyqt). **Almost all the code was rewritten to make the pty more robust and stable.** 20 | 21 | ## Protocol/TelentProtocol.h/cpp 22 | 23 | An implementation of Telnet protocol. 24 | 25 | ## Utility/CircularBuffer.h 26 | 27 | A quick circular buffer template class. 28 | 29 | ## Utility/Cryptographic.h/cpp 30 | 31 | A very safe encryption class using the PBKDF2-algorithm as defined in RFC 8018. WindTerm uses this class together with the user's master password to protect user data, including passwords, private keys and so on. 32 | 33 | ## Utility/MemoryPointer.h 34 | 35 | A smart memory pointer. 36 | 37 | ## Utility/ScopeGuard.h 38 | 39 | A class of which the sole purpose is to run the function f in its destructor. This is useful for guaranteeing your cleanup code is executed. 40 | 41 | ## Utility/Spin.h 42 | 43 | A high-performance spin mutex and locker. 44 | 45 | ## Utility/ThreadLocal.h/cpp 46 | 47 | A high-performance thread local storage. 48 | 49 | ## Widgets/PopupWidget.h/cpp 50 | 51 | A popup widget. 52 | 53 | ## Widgets/Scrollbar.h/cpp 54 | 55 | A scrollbar supports 64-bit ranges. 56 | 57 | ## Widgets/Splitter.h/cpp 58 | 59 | A convenient splitter for showing and hiding widgets. -------------------------------------------------------------------------------- /src/Utility/Cryptographic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CRYPTOGRAPHIC_H 18 | #define CRYPTOGRAPHIC_H 19 | 20 | #pragma once 21 | 22 | class QByteArray; 23 | 24 | class Cryptographic { 25 | public: 26 | Cryptographic() = default; 27 | 28 | static QByteArray decrypt(const QByteArray &data, const QByteArray &pbkdf2); 29 | static QByteArray encrypt(const QByteArray &data, const QByteArray &pbkdf2); 30 | static QByteArray pbkdf2(const QByteArray &password, const QByteArray &salt); 31 | static QByteArray salt(); 32 | 33 | private: 34 | static QByteArray doCrypt(QByteArray data, const QByteArray &key, const QByteArray &iv, int enc); 35 | static QByteArray iv(const QByteArray &pbkdf2); 36 | static QByteArray key(const QByteArray &pbkdf2); 37 | }; 38 | 39 | #endif // CRYPTOGRAPHIC_H -------------------------------------------------------------------------------- /src/Utility/ScopeGuard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SCOPEGUARD_H 18 | #define SCOPEGUARD_H 19 | 20 | class ScopeGuard { 21 | typedef std::function GuardFunction; 22 | 23 | public: 24 | ScopeGuard(GuardFunction acquire, GuardFunction release) 25 | : m_active(true) 26 | , m_release(std::move(release)) 27 | { 28 | acquire(); 29 | } 30 | 31 | ~ScopeGuard() { 32 | if (m_active) { 33 | m_release(); 34 | } 35 | } 36 | 37 | ScopeGuard() = delete; 38 | ScopeGuard(const ScopeGuard &) = delete; 39 | ScopeGuard &operator=(const ScopeGuard &) = delete; 40 | 41 | ScopeGuard(ScopeGuard &&other) 42 | : m_active(other.m_active) 43 | , m_release(std::move(other.m_release)) 44 | { 45 | other.cancel(); 46 | } 47 | 48 | void cancel() { 49 | m_active = false; 50 | } 51 | 52 | private: 53 | bool m_active; 54 | GuardFunction m_release; 55 | }; 56 | 57 | #endif // SCOPEGUARD_H 58 | -------------------------------------------------------------------------------- /src/Utility/Spin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SPIN_H 18 | #define SPIN_H 19 | 20 | #pragma once 21 | 22 | #include 23 | #include 24 | 25 | class SpinMutex { 26 | public: 27 | SpinMutex() { 28 | unlock(); 29 | } 30 | 31 | void yield(size_t nCount) { 32 | if (nCount < 2) { 33 | } else if (nCount < 16) { 34 | std::this_thread::yield(); 35 | } else if (nCount < 32) { 36 | std::this_thread::sleep_for(std::chrono::nanoseconds(100)); 37 | } else { 38 | std::this_thread::sleep_for(std::chrono::microseconds(10)); 39 | } 40 | } 41 | 42 | void lock() { 43 | for (size_t i = 0; !try_lock(); i++) { 44 | yield(i); 45 | } 46 | } 47 | 48 | void unlock() { 49 | flag.clear(std::memory_order_release); 50 | } 51 | 52 | bool try_lock() { 53 | return flag.test_and_set(std::memory_order_acquire) == false; 54 | } 55 | 56 | private: 57 | SpinMutex(const SpinMutex &) = delete; 58 | SpinMutex &operator=(const SpinMutex &) = delete; 59 | 60 | std::atomic_flag flag; 61 | }; 62 | 63 | template 64 | class ThreadLocker { 65 | public: 66 | ThreadLocker(LockType& m_, bool bLock_ = true) : m(m_), bLock(bLock_) { 67 | if (bLock) m.lock(); 68 | } 69 | 70 | ~ThreadLocker() { 71 | if (bLock) m.unlock(); 72 | } 73 | 74 | private: 75 | LockType& m; 76 | bool bLock; 77 | }; 78 | 79 | #endif // SPIN_H -------------------------------------------------------------------------------- /src/Utility/ThreadLocal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "ThreadLocal.h" 18 | 19 | #include 20 | 21 | void ThreadLocalWatcher::stopWatchCurrentThread() { 22 | QThread::currentThread()->disconnect(this); 23 | } 24 | 25 | void ThreadLocalWatcher::watchCurrentThread() { 26 | boost::thread::id id = boost::this_thread::get_id(); 27 | 28 | connect(QThread::currentThread(), &QThread::finished, this, [this, id]() { 29 | clear(id); 30 | }); 31 | } -------------------------------------------------------------------------------- /src/Widgets/PopupWidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef POPUPWIDGET_H 18 | #define POPUPWIDGET_H 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | class PopupWidget : public QFrame 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit PopupWidget(QWidget *parent = nullptr); 30 | virtual ~PopupWidget(); 31 | 32 | enum Area { LeftArea, MiddleArea, RightArea, TopArea, BottomArea }; 33 | 34 | public: 35 | void setCentralWidget(QWidget *widget); 36 | void show(Area hArea, Area vArea); 37 | 38 | private: 39 | void createLayout(); 40 | bool eventFilter(QObject *watched, QEvent *event) override; 41 | void mousePressEvent(QMouseEvent *event) override; 42 | 43 | private: 44 | Q_DISABLE_COPY(PopupWidget) 45 | }; 46 | 47 | #endif // POPUPWIDGET_H -------------------------------------------------------------------------------- /src/Widgets/ScrollBar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SCROLLBAR_H 18 | #define SCROLLBAR_H 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | class ScrollBar : public QScrollBar 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit ScrollBar(Qt::Orientation orientation, QWidget *parent = nullptr); 30 | virtual ~ScrollBar() = default; 31 | 32 | qint64 maximum() const { return m_maximum; } 33 | qint64 minimum() const { return m_minimum; } 34 | bool setMaximum(qint64 maximum); 35 | bool setMinimum(qint64 minimum); 36 | bool setPage(int page); 37 | bool setRange(qint64 minimum, qint64 maximum); 38 | bool setSingleStep(int singleStep); 39 | bool setValue(qint64 value); 40 | qint64 value() const { return m_value; } 41 | 42 | private: 43 | void createConnections(); 44 | 45 | Q_SIGNALS: 46 | void pageChanged(int page) const; 47 | void rangeChanged(qint64 minimum, qint64 maximum) const; 48 | void singleStepChanged(int singleStep) const; 49 | void valueChanged(qint64 value, qint64 oldValue) const; 50 | 51 | private: 52 | Q_DISABLE_COPY(ScrollBar) 53 | 54 | qint64 m_maximum; 55 | qint64 m_minimum; 56 | qint64 m_value; 57 | }; 58 | 59 | #endif // SCROLLBAR_H -------------------------------------------------------------------------------- /src/Widgets/Splitter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, WindTerm. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SPLITTER_H 18 | #define SPLITTER_H 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | extern const char* const SPLITTER_RATIO; 25 | 26 | class Splitter : public QSplitter 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit Splitter(QWidget *parent = 0); 32 | ~Splitter(); 33 | 34 | void showIndex(int index); 35 | void hideIndex(int index); 36 | bool isIndexVisible(int index); 37 | void setIndexVisible(int index, bool visible); 38 | 39 | void setMainIndex(int mainIndex); 40 | 41 | protected: 42 | bool eventFilter(QObject *obj, QEvent *event); 43 | 44 | QSplitterHandle *createHandle(); 45 | 46 | Q_SIGNALS: 47 | void showIndexRequested(int index); 48 | void hideIndexRequested(int index); 49 | 50 | private: 51 | Q_DISABLE_COPY(Splitter) 52 | 53 | int m_mainIndex; 54 | }; 55 | 56 | #endif // SPLITTER_H -------------------------------------------------------------------------------- /src/libssh/.arcconfig: -------------------------------------------------------------------------------- 1 | { 2 | "phabricator.uri" : "https://bugs.libssh.org/", 3 | "history.immutable": true 4 | } 5 | -------------------------------------------------------------------------------- /src/libssh/AUTHORS: -------------------------------------------------------------------------------- 1 | Author(s): 2 | Aris Adamantiadis (project initiator) 3 | 4 | Andreas Schneider (developer) 5 | 6 | Nick Zitzmann (mostly client SFTP stuff) 7 | 8 | Norbert Kiesel (getaddrinfo and other patches) 9 | 10 | Jean-Philippe Garcia Ballester (Port to libgcrypt and configure.in voodoo, debian packaging) 11 | 12 | Contributor(s): 13 | 14 | Laurent Bigonville (debian packaging) 15 | 16 | -------------------------------------------------------------------------------- /src/libssh/BSD: -------------------------------------------------------------------------------- 1 | Some parts are under the BSDv2 License : 2 | 3 | 4 | Copyright (c) 2000 Markus Friedl. All rights reserved. 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | -------------------------------------------------------------------------------- /src/libssh/CPackConfig.cmake: -------------------------------------------------------------------------------- 1 | ### GENERAL SETTINGS 2 | set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) 3 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The SSH Library") 4 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") 5 | set(CPACK_PACKAGE_VENDOR "The SSH Library Development Team") 6 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) 7 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") 8 | 9 | set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) 10 | 11 | # SOURCE GENERATOR 12 | set(CPACK_SOURCE_GENERATOR "TXZ") 13 | set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]git/;/[.]clangd/;.gitignore;/build*;/obj*;tags;cscope.*;compile_commands.json;.*\.patch") 14 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") 15 | 16 | ### NSIS INSTALLER 17 | if (WIN32) 18 | set(CPACK_GENERATOR "ZIP") 19 | 20 | ### nsis generator 21 | find_package(NSIS) 22 | if (NSIS_MAKE) 23 | set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS") 24 | set(CPACK_NSIS_DISPLAY_NAME "The SSH Library") 25 | set(CPACK_NSIS_COMPRESSOR "/SOLID zlib") 26 | set(CPACK_NSIS_MENU_LINKS "https://www.libssh.org/" "libssh homepage") 27 | endif (NSIS_MAKE) 28 | endif (WIN32) 29 | 30 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "libssh") 31 | 32 | set(CPACK_PACKAGE_FILE_NAME ${APPLICATION_NAME}-${CPACK_PACKAGE_VERSION}) 33 | 34 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") 35 | set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers") 36 | set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION 37 | "Libraries used to build programs which use libssh") 38 | set(CPACK_COMPONENT_HEADERS_DESCRIPTION 39 | "C/C++ header files for use with libssh") 40 | set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) 41 | set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") 42 | set(CPACK_COMPONENT_HEADERS_GROUP "Development") 43 | 44 | include(CPack) 45 | -------------------------------------------------------------------------------- /src/libssh/CTestConfig.cmake: -------------------------------------------------------------------------------- 1 | set(UPDATE_TYPE "true") 2 | 3 | set(CTEST_PROJECT_NAME "libssh") 4 | set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") 5 | 6 | set(CTEST_DROP_METHOD "https") 7 | set(CTEST_DROP_SITE "test.libssh.org") 8 | set(CTEST_DROP_LOCATION "/submit.php?project=libssh") 9 | set(CTEST_DROP_SITE_CDASH TRUE) 10 | -------------------------------------------------------------------------------- /src/libssh/DefineOptions.cmake: -------------------------------------------------------------------------------- 1 | option(WITH_GSSAPI "Build with GSSAPI support" ON) 2 | option(WITH_ZLIB "Build with ZLIB support" ON) 3 | option(WITH_SFTP "Build with SFTP support" ON) 4 | option(WITH_SERVER "Build with SSH server support" ON) 5 | option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF) 6 | option(WITH_DEBUG_PACKET "Build with packet debug output" OFF) 7 | option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON) 8 | option(WITH_GCRYPT "Compile against libgcrypt" OFF) 9 | option(WITH_MBEDTLS "Compile against libmbedtls" OFF) 10 | option(WITH_BLOWFISH_CIPHER "Compile with blowfish support" OFF) 11 | option(WITH_PCAP "Compile with Pcap generation support" ON) 12 | option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF) 13 | option(BUILD_SHARED_LIBS "Build shared libraries" ON) 14 | option(UNIT_TESTING "Build with unit tests" OFF) 15 | option(CLIENT_TESTING "Build with client tests; requires openssh" OFF) 16 | option(SERVER_TESTING "Build with server tests; requires openssh and dropbear" OFF) 17 | option(WITH_BENCHMARKS "Build benchmarks tools" OFF) 18 | option(WITH_EXAMPLES "Build examples" ON) 19 | option(WITH_NACL "Build with libnacl (curve25519)" ON) 20 | option(WITH_SYMBOL_VERSIONING "Build with symbol versioning" ON) 21 | option(WITH_ABI_BREAK "Allow ABI break" OFF) 22 | option(WITH_GEX "Enable DH Group exchange mechanisms" ON) 23 | option(FUZZ_TESTING "Build with fuzzer for the server" OFF) 24 | option(PICKY_DEVELOPER "Build with picky developer flags" OFF) 25 | 26 | if (WITH_ZLIB) 27 | set(WITH_LIBZ ON) 28 | else (WITH_ZLIB) 29 | set(WITH_LIBZ OFF) 30 | endif (WITH_ZLIB) 31 | 32 | if (WITH_BENCHMARKS) 33 | set(UNIT_TESTING ON) 34 | set(CLIENT_TESTING ON) 35 | endif() 36 | 37 | if (UNIT_TESTING OR CLIENT_TESTING OR SERVER_TESTING) 38 | set(BUILD_STATIC_LIB ON) 39 | endif() 40 | 41 | if (WITH_NACL) 42 | set(WITH_NACL ON) 43 | endif (WITH_NACL) 44 | 45 | if (WITH_ABI_BREAK) 46 | set(WITH_SYMBOL_VERSIONING ON) 47 | endif (WITH_ABI_BREAK) 48 | 49 | if (NOT GLOBAL_BIND_CONFIG) 50 | set(GLOBAL_BIND_CONFIG "/etc/ssh/libssh_server_config") 51 | endif (NOT GLOBAL_BIND_CONFIG) 52 | 53 | if (NOT GLOBAL_CLIENT_CONFIG) 54 | set(GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config") 55 | endif (NOT GLOBAL_CLIENT_CONFIG) 56 | -------------------------------------------------------------------------------- /src/libssh/README: -------------------------------------------------------------------------------- 1 | _ _ _ _ 2 | (_) (_) (_) (_) 3 | (_) _ (_) _ _ _ _ _ (_) _ 4 | (_) (_) (_)(_) _ (_)(_) (_)(_) (_)(_) _ 5 | (_) (_) (_) (_) _ (_) _ (_) (_) (_) 6 | (_) (_) (_)(_)(_) (_)(_) (_)(_) (_) (_).org 7 | 8 | The SSH library 9 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 | 11 | 1* Why ? 12 | -_-_-_-_-_ 13 | 14 | Why not ? :) I've began to work on my own implementation of the ssh protocol 15 | because i didn't like the currently public ones. 16 | Not any allowed you to import and use the functions as a powerful library, 17 | and so i worked on a library-based SSH implementation which was non-existing 18 | in the free and open source software world. 19 | 20 | 21 | 2* How/Who ? 22 | -_-_-_-_-_-_-_ 23 | 24 | If you downloaded this file, you must know what it is : a library for 25 | accessing ssh client services through C libraries calls in a simple manner. 26 | Everybody can use this software under the terms of the LGPL - see the COPYING 27 | file 28 | 29 | If you ask yourself how to compile libssh, please read INSTALL before anything. 30 | 31 | 3* Where ? 32 | -_-_-_-_-_-_ 33 | 34 | https://www.libssh.org 35 | 36 | 4* Contributing 37 | -_-_-_-_-_-_-_-_-_ 38 | 39 | Please read the file 'SubmittingPatches' next to this README file. It explains 40 | our copyright policy and how you should send patches for upstream inclusion. 41 | 42 | Have fun and happy libssh hacking! 43 | 44 | The libssh Team 45 | -------------------------------------------------------------------------------- /src/libssh/README.mbedtls: -------------------------------------------------------------------------------- 1 | mbedTLS and libssh in multithreaded applications 2 | ================================================== 3 | 4 | To use libssh with mbedTLS in a multithreaded application, mbedTLS has to be 5 | built with threading support enabled. 6 | 7 | If threading support is not available and multi threading is used, ssh_init 8 | will fail. 9 | 10 | More information about building mbedTLS with threading support can be found 11 | in the mbedTLS documentation. 12 | -------------------------------------------------------------------------------- /src/libssh/README.md: -------------------------------------------------------------------------------- 1 | [![pipeline status](https://gitlab.com/libssh/libssh-mirror/badges/master/pipeline.svg)](https://gitlab.com/libssh/libssh-mirror/commits/master) 2 | 3 | ``` 4 | _ _ _ _ 5 | (_) (_) (_) (_) 6 | (_) _ (_) _ _ _ _ _ (_) _ 7 | (_) (_) (_)(_) _ (_)(_) (_)(_) (_)(_) _ 8 | (_) (_) (_) (_) _ (_) _ (_) (_) (_) 9 | (_) (_) (_)(_)(_) (_)(_) (_)(_) (_) (_).org 10 | 11 | The SSH library 12 | 13 | ``` 14 | 15 | # Why? 16 | 17 | Why not ? :) I've began to work on my own implementation of the ssh protocol 18 | because i didn't like the currently public ones. 19 | Not any allowed you to import and use the functions as a powerful library, 20 | and so i worked on a library-based SSH implementation which was non-existing 21 | in the free and open source software world. 22 | 23 | 24 | # How/Who? 25 | 26 | If you downloaded this file, you must know what it is : a library for 27 | accessing ssh client services through C libraries calls in a simple manner. 28 | Everybody can use this software under the terms of the LGPL - see the COPYING 29 | file 30 | 31 | If you ask yourself how to compile libssh, please read INSTALL before anything. 32 | 33 | # Where ? 34 | 35 | https://www.libssh.org 36 | 37 | # Contributing 38 | 39 | Please read the file 'SubmittingPatches' next to this README file. It explains 40 | our copyright policy and how you should send patches for upstream inclusion. 41 | 42 | Have fun and happy libssh hacking! 43 | 44 | The libssh Team 45 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/AddCCompilerFlag.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # add_c_compiler_flag("-Werror" SUPPORTED_CFLAGS) 3 | # 4 | # Copyright (c) 2018 Andreas Schneider 5 | # 6 | # Redistribution and use is allowed according to the terms of the BSD license. 7 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 8 | 9 | include(CheckCCompilerFlag) 10 | 11 | macro(add_c_compiler_flag _COMPILER_FLAG _OUTPUT_VARIABLE) 12 | string(TOUPPER ${_COMPILER_FLAG} _COMPILER_FLAG_NAME) 13 | string(REGEX REPLACE "^-" "" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}") 14 | string(REGEX REPLACE "(-|=|\ )" "_" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}") 15 | 16 | check_c_compiler_flag("${_COMPILER_FLAG}" WITH_${_COMPILER_FLAG_NAME}_FLAG) 17 | if (WITH_${_COMPILER_FLAG_NAME}_FLAG) 18 | #string(APPEND ${_OUTPUT_VARIABLE} "${_COMPILER_FLAG} ") 19 | list(APPEND ${_OUTPUT_VARIABLE} ${_COMPILER_FLAG}) 20 | endif() 21 | endmacro() 22 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/COPYING-CMAKE-SCRIPTS: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/CheckCCompilerFlagSSP.cmake: -------------------------------------------------------------------------------- 1 | # - Check whether the C compiler supports a given flag in the 2 | # context of a stack checking compiler option. 3 | 4 | # CHECK_C_COMPILER_FLAG_SSP(FLAG VARIABLE) 5 | # 6 | # FLAG - the compiler flag 7 | # VARIABLE - variable to store the result 8 | # 9 | # This actually calls check_c_source_compiles. 10 | # See help for CheckCSourceCompiles for a listing of variables 11 | # that can modify the build. 12 | 13 | # Copyright (c) 2006, Alexander Neundorf, 14 | # 15 | # Redistribution and use is allowed according to the terms of the BSD license. 16 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 17 | 18 | # Requires cmake 3.10 19 | #include_guard(GLOBAL) 20 | include(CheckCSourceCompiles) 21 | 22 | macro(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT) 23 | set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 24 | set(CMAKE_REQUIRED_FLAGS "${_FLAG}") 25 | 26 | check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT}) 27 | 28 | set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") 29 | endmacro(CHECK_C_COMPILER_FLAG_SSP) 30 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/DefineCMakeDefaults.cmake: -------------------------------------------------------------------------------- 1 | # Always include srcdir and builddir in include path 2 | # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in 3 | # about every subdir 4 | # since cmake 2.4.0 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | # Put the include dirs which are in the source or build tree 8 | # before all other include dirs, so the headers in the sources 9 | # are prefered over the already installed ones 10 | # since cmake 2.4.1 11 | set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) 12 | 13 | # Use colored output 14 | # since cmake 2.4.0 15 | set(CMAKE_COLOR_MAKEFILE ON) 16 | 17 | # Create the compile command database for clang by default 18 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 19 | 20 | # Always build with -fPIC 21 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 22 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/DefinePlatformDefaults.cmake: -------------------------------------------------------------------------------- 1 | # Set system vars 2 | 3 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 4 | set(LINUX TRUE) 5 | endif(CMAKE_SYSTEM_NAME MATCHES "Linux") 6 | 7 | if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 8 | set(FREEBSD TRUE) 9 | set(BSD TRUE) 10 | endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 11 | 12 | if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") 13 | set(OPENBSD TRUE) 14 | set(BSD TRUE) 15 | endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") 16 | 17 | if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") 18 | set(NETBSD TRUE) 19 | set(BSD TRUE) 20 | endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD") 21 | 22 | if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") 23 | set(SOLARIS TRUE) 24 | endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") 25 | 26 | if (CMAKE_SYSTEM_NAME MATCHES "OS2") 27 | set(OS2 TRUE) 28 | endif (CMAKE_SYSTEM_NAME MATCHES "OS2") 29 | 30 | if (CMAKE_SYSTEM_NAME MATCHES "Darwin") 31 | set (OSX TRUE) 32 | endif (CMAKE_SYSTEM_NAME MATCHES "Darwin") 33 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/FindArgp.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find ARGP 2 | # Once done this will define 3 | # 4 | # ARGP_ROOT_DIR - Set this variable to the root installation of ARGP 5 | # 6 | # Read-Only variables: 7 | # ARGP_FOUND - system has ARGP 8 | # ARGP_INCLUDE_DIR - the ARGP include directory 9 | # ARGP_LIBRARIES - Link these to use ARGP 10 | # ARGP_DEFINITIONS - Compiler switches required for using ARGP 11 | # 12 | #============================================================================= 13 | # Copyright (c) 2011-2016 Andreas Schneider 14 | # 15 | # Distributed under the OSI-approved BSD License (the "License"); 16 | # see accompanying file Copyright.txt for details. 17 | # 18 | # This software is distributed WITHOUT ANY WARRANTY; without even the 19 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | # See the License for more information. 21 | #============================================================================= 22 | # 23 | 24 | set(_ARGP_ROOT_HINTS 25 | ) 26 | 27 | set(_ARGP_ROOT_PATHS 28 | "$ENV{PROGRAMFILES}/argp" 29 | ) 30 | 31 | find_path(ARGP_ROOT_DIR 32 | NAMES 33 | include/argp.h 34 | HINTS 35 | ${_ARGP_ROOT_HINTS} 36 | PATHS 37 | ${_ARGP_ROOT_PATHS} 38 | ) 39 | mark_as_advanced(ARGP_ROOT_DIR) 40 | 41 | find_path(ARGP_INCLUDE_DIR 42 | NAMES 43 | argp.h 44 | PATHS 45 | ${ARGP_ROOT_DIR}/include 46 | ) 47 | 48 | find_library(ARGP_LIBRARY 49 | NAMES 50 | argp 51 | PATHS 52 | ${ARGP_ROOT_DIR}/lib 53 | ) 54 | 55 | if (ARGP_LIBRARY) 56 | set(ARGP_LIBRARIES 57 | ${ARGP_LIBRARIES} 58 | ${ARGP_LIBRARY} 59 | ) 60 | endif (ARGP_LIBRARY) 61 | 62 | include(FindPackageHandleStandardArgs) 63 | find_package_handle_standard_args(ARGP DEFAULT_MSG ARGP_LIBRARIES ARGP_INCLUDE_DIR) 64 | 65 | # show the ARGP_INCLUDE_DIR and ARGP_LIBRARIES variables only in the advanced view 66 | mark_as_advanced(ARGP_INCLUDE_DIR ARGP_LIBRARIES) 67 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/FindCMocka.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find CMocka 2 | # Once done this will define 3 | # 4 | # CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka 5 | # 6 | # Read-Only variables: 7 | # CMOCKA_FOUND - system has CMocka 8 | # CMOCKA_INCLUDE_DIR - the CMocka include directory 9 | # CMOCKA_LIBRARIES - Link these to use CMocka 10 | # CMOCKA_DEFINITIONS - Compiler switches required for using CMocka 11 | # 12 | #============================================================================= 13 | # Copyright (c) 2011-2012 Andreas Schneider 14 | # 15 | # Distributed under the OSI-approved BSD License (the "License"); 16 | # see accompanying file Copyright.txt for details. 17 | # 18 | # This software is distributed WITHOUT ANY WARRANTY; without even the 19 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | # See the License for more information. 21 | #============================================================================= 22 | # 23 | 24 | set(_CMOCKA_ROOT_HINTS 25 | ) 26 | 27 | set(_CMOCKA_ROOT_PATHS 28 | "$ENV{PROGRAMFILES}/cmocka" 29 | ) 30 | 31 | find_path(CMOCKA_ROOT_DIR 32 | NAMES 33 | include/cmocka.h 34 | HINTS 35 | ${_CMOCKA_ROOT_HINTS} 36 | PATHS 37 | ${_CMOCKA_ROOT_PATHS} 38 | ) 39 | mark_as_advanced(CMOCKA_ROOT_DIR) 40 | 41 | find_path(CMOCKA_INCLUDE_DIR 42 | NAMES 43 | cmocka.h 44 | PATHS 45 | ${CMOCKA_ROOT_DIR}/include 46 | ) 47 | 48 | find_library(CMOCKA_LIBRARY 49 | NAMES 50 | cmocka 51 | PATHS 52 | ${CMOCKA_ROOT_DIR}/lib 53 | ) 54 | 55 | if (CMOCKA_LIBRARY) 56 | set(CMOCKA_LIBRARIES 57 | ${CMOCKA_LIBRARIES} 58 | ${CMOCKA_LIBRARY} 59 | ) 60 | endif (CMOCKA_LIBRARY) 61 | 62 | include(FindPackageHandleStandardArgs) 63 | find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR) 64 | 65 | # show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view 66 | mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES) 67 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/FindNSIS.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find NSIS 2 | # Once done this will define 3 | # 4 | # NSIS_ROOT_PATH - Set this variable to the root installation of NSIS 5 | # 6 | # Read-Only variables: 7 | # 8 | # NSIS_FOUND - system has NSIS 9 | # NSIS_MAKE - NSIS creator executable 10 | # 11 | #============================================================================= 12 | # Copyright (c) 2010-2013 Andreas Schneider 13 | # 14 | # Distributed under the OSI-approved BSD License (the "License"); 15 | # see accompanying file Copyright.txt for details. 16 | # 17 | # This software is distributed WITHOUT ANY WARRANTY; without even the 18 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | # See the License for more information. 20 | #============================================================================= 21 | # 22 | 23 | if (WIN32) 24 | set(_x86 "(x86)") 25 | 26 | set(_NSIS_ROOT_PATHS 27 | "$ENV{ProgramFiles}/NSIS" 28 | "$ENV{ProgramFiles${_x86}}/NSIS" 29 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS;Default]") 30 | 31 | find_path(NSIS_ROOT_PATH 32 | NAMES 33 | Include/Library.nsh 34 | PATHS 35 | ${_NSIS_ROOT_PATHS} 36 | ) 37 | mark_as_advanced(NSIS_ROOT_PATH) 38 | endif (WIN32) 39 | 40 | find_program(NSIS_MAKE 41 | NAMES 42 | makensis 43 | PATHS 44 | ${NSIS_ROOT_PATH} 45 | ) 46 | 47 | include(FindPackageHandleStandardArgs) 48 | find_package_handle_standard_args(NSIS DEFAULT_MSG NSIS_MAKE) 49 | 50 | if (NSIS_MAKE) 51 | set(NSIS_FOUND TRUE) 52 | endif (NSIS_MAKE) 53 | 54 | mark_as_advanced(NSIS_MAKE) 55 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/FindNaCl.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find NaCl 2 | # Once done this will define 3 | # 4 | # NACL_FOUND - system has NaCl 5 | # NACL_INCLUDE_DIRS - the NaCl include directory 6 | # NACL_LIBRARIES - Link these to use NaCl 7 | # NACL_DEFINITIONS - Compiler switches required for using NaCl 8 | # 9 | # Copyright (c) 2010 Andreas Schneider 10 | # Copyright (c) 2013 Aris Adamantiadis 11 | # 12 | # Redistribution and use is allowed according to the terms of the New 13 | # BSD license. 14 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 15 | # 16 | 17 | 18 | if (NACL_LIBRARIES AND NACL_INCLUDE_DIRS) 19 | # in cache already 20 | set(NACL_FOUND TRUE) 21 | else (NACL_LIBRARIES AND NACL_INCLUDE_DIRS) 22 | 23 | find_path(NACL_INCLUDE_DIR 24 | NAMES 25 | nacl/crypto_box_curve25519xsalsa20poly1305.h 26 | PATHS 27 | /usr/include 28 | /usr/local/include 29 | /opt/local/include 30 | /sw/include 31 | ) 32 | 33 | find_library(NACL_LIBRARY 34 | NAMES 35 | nacl 36 | PATHS 37 | /usr/lib 38 | /usr/local/lib 39 | /opt/local/lib 40 | /sw/lib 41 | ) 42 | 43 | set(NACL_INCLUDE_DIRS 44 | ${NACL_INCLUDE_DIR} 45 | ) 46 | 47 | if (NACL_LIBRARY) 48 | set(NACL_LIBRARIES 49 | ${NACL_LIBRARIES} 50 | ${NACL_LIBRARY} 51 | ) 52 | endif (NACL_LIBRARY) 53 | 54 | include(FindPackageHandleStandardArgs) 55 | find_package_handle_standard_args(NaCl DEFAULT_MSG NACL_LIBRARIES NACL_INCLUDE_DIRS) 56 | 57 | # show the NACL_INCLUDE_DIRS and NACL_LIBRARIES variables only in the advanced view 58 | mark_as_advanced(NACL_INCLUDE_DIRS NACL_LIBRARIES) 59 | 60 | endif (NACL_LIBRARIES AND NACL_INCLUDE_DIRS) 61 | 62 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/GetFilesList.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 Anderson Toshiyuki Sasaki 3 | # 4 | # Redistribution and use is allowed according to the terms of the New 5 | # BSD license. 6 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 7 | # 8 | 9 | #.rst: 10 | # GetFilesList 11 | # ------------ 12 | # 13 | # This is a helper script for FindABImap.cmake. 14 | # 15 | # Search in the provided directories for files matching the provided pattern. 16 | # The list of files is then written to the output file. 17 | # 18 | # Expected defined variables 19 | # -------------------------- 20 | # 21 | # ``DIRECTORIES``: 22 | # Required, expects a list of directories paths. 23 | # 24 | # ``FILES_PATTERNS``: 25 | # Required, expects a list of patterns to be used to search files 26 | # 27 | # ``OUTPUT_PATH``: 28 | # Required, expects the output file path. 29 | 30 | if (NOT DEFINED DIRECTORIES) 31 | message(SEND_ERROR "DIRECTORIES not defined") 32 | endif() 33 | 34 | if (NOT DEFINED FILES_PATTERNS) 35 | message(SEND_ERROR "FILES_PATTERNS not defined") 36 | endif() 37 | 38 | if (NOT DEFINED OUTPUT_PATH) 39 | message(SEND_ERROR "OUTPUT_PATH not defined") 40 | endif() 41 | 42 | string(REPLACE " " ";" DIRECTORIES_LIST "${DIRECTORIES}") 43 | string(REPLACE " " ";" FILES_PATTERNS_LIST "${FILES_PATTERNS}") 44 | 45 | # Create the list of expressions for the files 46 | set(glob_expressions) 47 | foreach(dir ${DIRECTORIES_LIST}) 48 | foreach(exp ${FILES_PATTERNS_LIST}) 49 | list(APPEND glob_expressions 50 | "${dir}/${exp}" 51 | ) 52 | endforeach() 53 | endforeach() 54 | 55 | # Create the list of files 56 | file(GLOB files ${glob_expressions}) 57 | 58 | # Write to the output 59 | file(WRITE ${OUTPUT_PATH} "${files}") 60 | -------------------------------------------------------------------------------- /src/libssh/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake: -------------------------------------------------------------------------------- 1 | # - MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 2 | # MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 3 | 4 | # Copyright (c) 2006, Alexander Neundorf, 5 | # 6 | # Redistribution and use is allowed according to the terms of the BSD license. 7 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 8 | 9 | macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage) 10 | 11 | string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource) 12 | if (_insource) 13 | message(SEND_ERROR "${_errorMessage}") 14 | message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.") 15 | endif (_insource) 16 | 17 | endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD) 18 | -------------------------------------------------------------------------------- /src/libssh/cmake/Toolchain-cross-m32.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_FLAGS "-m32" CACHE STRING "C compiler flags" FORCE) 2 | set(CMAKE_CXX_FLAGS "-m32" CACHE STRING "C++ compiler flags" FORCE) 3 | 4 | set(LIB32 /usr/lib) # Fedora 5 | 6 | if(EXISTS /usr/lib32) 7 | set(LIB32 /usr/lib32) # Arch, Solus 8 | endif() 9 | 10 | set(CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE) 11 | set(CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE) 12 | 13 | # this is probably unlikely to be needed, but just in case 14 | set(CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE) 15 | set(CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE) 16 | set(CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE) 17 | 18 | # on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have 19 | # to include the regular system .pc files as well (at the end), because some 20 | # are not always present in the 32 bit directory 21 | if(EXISTS ${LIB32}/pkgconfig) 22 | set(ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig) 23 | endiF() 24 | -------------------------------------------------------------------------------- /src/libssh/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Build the documentation 3 | # 4 | if (${CMAKE_VERSION} VERSION_GREATER "3.8.99") 5 | 6 | find_package(Doxygen) 7 | 8 | if (DOXYGEN_FOUND) 9 | set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME}) 10 | set(DOXYGEN_PROJECT_NUMBER ${PROJECT_VERSION}) 11 | set(DOXYGEN_PROJECT_BRIEF "The SSH library") 12 | 13 | set(DOXYGEN_TAB_SIZE 4) 14 | set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES) 15 | set(DOXYGEN_MARKDOWN_SUPPORT YES) 16 | set(DOXYGEN_FULL_PATH_NAMES NO) 17 | 18 | set(DOXYGEN_PREDEFINED DOXYGEN 19 | WITH_SERVER 20 | WITH_SFTP 21 | PRINTF_ATTRIBUTE(x,y)) 22 | 23 | set(DOXYGEN_EXCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/that_style) 24 | set(DOXYGEN_HTML_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/that_style/header.html) 25 | set(DOXYGEN_HTML_EXTRA_STYLESHEET ${CMAKE_CURRENT_SOURCE_DIR}/that_style/that_style.css) 26 | set(DOXYGEN_HTML_EXTRA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/nav_edge_left.svg 27 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/nav_edge_right.svg 28 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/nav_edge_inter.svg 29 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/sync_off.png 30 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/sync_on.png 31 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/splitbar_handle.svg 32 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/doc.svg 33 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/mag_glass.svg 34 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/folderclosed.svg 35 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/folderopen.svg 36 | ${CMAKE_CURRENT_SOURCE_DIR}/that_style/js/striped_bg.js) 37 | 38 | # This updates the Doxyfile if we do changes here 39 | set(_doxyfile_template "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in") 40 | set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.docs") 41 | configure_file("${_doxyfile_template}" "${_target_doxyfile}") 42 | 43 | doxygen_add_docs(docs 44 | ${CMAKE_SOURCE_DIR}/include/libssh 45 | ${CMAKE_SOURCE_DIR}/src 46 | ${CMAKE_CURRENT_SOURCE_DIR}) 47 | endif() # DOXYGEN_FOUND 48 | 49 | endif() # CMAKE_VERSION 50 | -------------------------------------------------------------------------------- /src/libssh/doc/introduction.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page libssh_tutorial The Tutorial 3 | @section introduction Introduction 4 | 5 | libssh is a C library that enables you to write a program that uses the 6 | SSH protocol. With it, you can remotely execute programs, transfer 7 | files, or use a secure and transparent tunnel for your remote programs. 8 | The SSH protocol is encrypted, ensures data integrity, and provides strong 9 | means of authenticating both the server of the client. The library hides 10 | a lot of technical details from the SSH protocol, but this does not 11 | mean that you should not try to know about and understand these details. 12 | 13 | libssh is a Free Software / Open Source project. The libssh library 14 | is distributed under LGPL license. The libssh project has nothing to do with 15 | "libssh2", which is a completely different and independent project. 16 | 17 | libssh can run on top of either libgcrypt or libcrypto, 18 | two general-purpose cryptographic libraries. 19 | 20 | This tutorial concentrates for its main part on the "client" side of libssh. 21 | To learn how to accept incoming SSH connections (how to write a SSH server), 22 | you'll have to jump to the end of this document. 23 | 24 | This tutorial describes libssh version 0.5.0. This version is a little different 25 | from the 0.4.X series. However, the examples should work with 26 | little changes on versions like 0.4.2 and later. 27 | 28 | 29 | Table of contents: 30 | 31 | @subpage libssh_tutor_guided_tour 32 | 33 | @subpage libssh_tutor_authentication 34 | 35 | @subpage libssh_tutor_shell 36 | 37 | @subpage libssh_tutor_command 38 | 39 | @subpage libssh_tutor_sftp 40 | 41 | @subpage libssh_tutor_scp 42 | 43 | @subpage libssh_tutor_forwarding 44 | 45 | @subpage libssh_tutor_threads 46 | 47 | @subpage libssh_tutor_todo 48 | 49 | */ 50 | -------------------------------------------------------------------------------- /src/libssh/doc/linking.dox: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | @page libssh_linking The Linking HowTo 4 | 5 | @section dynamic Dynamic Linking 6 | 7 | On UNIX and Windows systems its the same, you need at least the libssh.h 8 | header file and the libssh shared library. 9 | 10 | @section static Static Linking 11 | 12 | @warning The libssh library is licensed under the LGPL! Make sure you 13 | understand what this means to your codebase if you want to distribute 14 | binaries and link statically against LGPL code! 15 | 16 | On UNIX systems linking against the static version of the library is the 17 | same as linking against the shared library. Both have the same name. Some 18 | build system require to use the full path to the static library. 19 | 20 | To be able to compile the application you're developing you need to either pass 21 | LIBSSH_STATIC as a define in the compiler command line or define it before you 22 | include libssh.h. This is required cause the dynamic library needs to specify 23 | the dllimport attribute. 24 | 25 | @code 26 | #define LIBSSH_STATIC 1 27 | #include 28 | @endcode 29 | 30 | If you're are statically linking with OpenSSL, read the "Linking your 31 | application" section in the NOTES.[OS] in the OpenSSL source tree! 32 | 33 | */ 34 | -------------------------------------------------------------------------------- /src/libssh/doc/tbd.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page libssh_tutor_todo To be done 3 | 4 | *** To be written *** 5 | 6 | @section sshd Writing a libssh-based server 7 | 8 | *** To be written *** 9 | 10 | @section cpp The libssh C++ wrapper 11 | 12 | *** To be written *** 13 | 14 | */ 15 | -------------------------------------------------------------------------------- /src/libssh/doc/that_style/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jan-Lukas Wynen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/libssh/doc/that_style/README.md: -------------------------------------------------------------------------------- 1 | # that style 2 | A plain, more modern HTML style for Doxygen 3 | 4 | ## Requirements 5 | - Doxygen (tested with version 1.8.13) 6 | - *optional*: a sass/scss compiler if you want to modify the style 7 | 8 | ## Simple usage 9 | Tell Doxygen about the files for that style as shown in [doxyfile.conf](doxyfile.conf). You might need to adjust the 10 | paths depending on where you installed that style. 11 | When you run Doxygen, all files are copied into to generated HTML folder. So you don't need to keep the originals around 12 | unless you want to re-generate the documentation. 13 | 14 | ## Advanced 15 | that style uses a custom javascript to hack some nice stripes into some tables. It has to be loaded from HTML. Hence you need 16 | to use the provided custom header. Since its default content may change when Doxygen is updated, there might be syntax error in 17 | the generated HTML. If this is the case, you can remove the custom header (adjust your doxyfile.conf). This has no 18 | disadvantages other than removing the stripes. 19 | 20 | [that_style.css](that_style.css) was generated from the scss files in the folder [sass](sass). If you want to change the style, 21 | use those files in order to have better control. For instance, you can easily change most colors by modifying the variables 22 | in the beginning of [that_style.scss](sass/that_style.scss). 23 | -------------------------------------------------------------------------------- /src/libssh/doc/that_style/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: $title 9 | $title 10 | 11 | 12 | 13 | $treeview 14 | $search 15 | $mathjax 16 | 17 | 18 | $extrastylesheet 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
33 |
$projectname 34 |  $projectnumber 35 |
36 |
$projectbrief
37 |
42 |
$projectbrief
43 |
$searchbox
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /src/libssh/doc/that_style/img/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/libssh/doc/that_style/img/sync_off.png -------------------------------------------------------------------------------- /src/libssh/doc/that_style/img/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/libssh/doc/that_style/img/sync_on.png -------------------------------------------------------------------------------- /src/libssh/doc/that_style/js/striped_bg.js: -------------------------------------------------------------------------------- 1 | // Adds extra CSS classes "even" and "odd" to .memberdecls to allow 2 | // striped backgrounds. 3 | function MemberDeclsStriper () { 4 | var counter = 0; 5 | 6 | this.stripe = function() { 7 | $(".memberdecls tbody").children().each(function(i) { 8 | 9 | // reset counter at every heading -> always start with even 10 | if ($(this).is(".heading")) { 11 | counter = 0; 12 | } 13 | 14 | // add extra classes 15 | if (counter % 2 == 1) { 16 | $(this).addClass("odd"); 17 | } 18 | else { 19 | $(this).addClass("even"); 20 | } 21 | 22 | // advance counter at every separator 23 | // this is the only way to reliably detect which table rows belong together 24 | if ($(this).is('[class^="separator"]')) { 25 | counter++; 26 | } 27 | }); 28 | } 29 | } 30 | 31 | // execute the function 32 | $(document).ready(new MemberDeclsStriper().stripe); 33 | -------------------------------------------------------------------------------- /src/libssh/doc/threading.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @page libssh_tutor_threads Chapter 8: Threads with libssh 3 | @section threads_with_libssh How to use libssh with threads 4 | 5 | libssh may be used in multithreaded applications, but under several conditions : 6 | - Your system must support libpthread or, in Windows environment, 7 | CriticalSection based mutex control. 8 | - Since version 0.8.0, threads initialization is called automatically in the 9 | library constructor if libssh is dynamically linked. This means it is no 10 | longer necessary to call ssh_init()/ssh_finalize(). 11 | - If libssh is statically linked, threading must be initialized by calling 12 | ssh_init() before using any of libssh provided functions. This initialization 13 | must be done outside of any threading context. Don't forget to call 14 | ssh_finalize() to avoid memory leak 15 | - At all times, you may use different sessions inside threads, make parallel 16 | connections, read/write on different sessions and so on. You *cannot* use a 17 | single session (or channels for a single session) in several threads at the same 18 | time. This will most likely lead to internal state corruption. This limitation is 19 | being worked out and will maybe disappear later. 20 | 21 | @subsection threads_init Initialization of threads 22 | 23 | Since version 0.8.0, it is no longer necessary to call ssh_init()/ssh_finalize() 24 | if libssh is dynamically linked. 25 | 26 | If libssh is statically linked, call ssh_init() before using any of libssh 27 | provided functions. 28 | 29 | @subsection threads_pthread Using libpthread with libssh 30 | 31 | Since version 0.8.0, libpthread is the default threads library used by libssh. 32 | 33 | To use libpthread, simply link it to you application. 34 | 35 | If you are using libssh statically linked, don't forget to call ssh_init() 36 | before using any of libssh provided functions (and ssh_finalize() in the end). 37 | 38 | @subsection threads_other Using another threading library 39 | 40 | Since version 0.8.0, libssh does not support custom threading libraries. 41 | The change makes sense since the newer versions for libcrypto (OpenSSL) and 42 | libgcrypt don't support custom threading libraries. 43 | 44 | The default used threading library is libpthread. 45 | Alternatively, in Windows environment, CriticalSection based mutex control can 46 | be used. 47 | 48 | If your system does not support libpthread nor CriticalSection based mutex 49 | control, unfortunately, you cannot use libssh in multithreaded scenarios. 50 | 51 | Good luck ! 52 | */ 53 | -------------------------------------------------------------------------------- /src/libssh/examples/connect_ssh.c: -------------------------------------------------------------------------------- 1 | /* 2 | * connect_ssh.c 3 | * This file contains an example of how to connect to a 4 | * SSH server using libssh 5 | */ 6 | 7 | /* 8 | Copyright 2009 Aris Adamantiadis 9 | 10 | This file is part of the SSH Library 11 | 12 | You are free to copy this file, modify it in any way, consider it being public 13 | domain. This does not apply to the rest of the library though, but it is 14 | allowed to cut-and-paste working code from this file to any license of 15 | program. 16 | The goal is to show the API in action. It's not a reference on how terminal 17 | clients must be made or how a client should react. 18 | */ 19 | 20 | #include 21 | #include "examples_common.h" 22 | #include 23 | 24 | ssh_session connect_ssh(const char *host, const char *user,int verbosity){ 25 | ssh_session session; 26 | int auth=0; 27 | 28 | session=ssh_new(); 29 | if (session == NULL) { 30 | return NULL; 31 | } 32 | 33 | if(user != NULL){ 34 | if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) { 35 | ssh_free(session); 36 | return NULL; 37 | } 38 | } 39 | 40 | if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) { 41 | ssh_free(session); 42 | return NULL; 43 | } 44 | ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); 45 | if(ssh_connect(session)){ 46 | fprintf(stderr,"Connection failed : %s\n",ssh_get_error(session)); 47 | ssh_disconnect(session); 48 | ssh_free(session); 49 | return NULL; 50 | } 51 | if(verify_knownhost(session)<0){ 52 | ssh_disconnect(session); 53 | ssh_free(session); 54 | return NULL; 55 | } 56 | auth=authenticate_console(session); 57 | if(auth==SSH_AUTH_SUCCESS){ 58 | return session; 59 | } else if(auth==SSH_AUTH_DENIED){ 60 | fprintf(stderr,"Authentication failed\n"); 61 | } else { 62 | fprintf(stderr,"Error while authenticating : %s\n",ssh_get_error(session)); 63 | } 64 | ssh_disconnect(session); 65 | ssh_free(session); 66 | return NULL; 67 | } 68 | -------------------------------------------------------------------------------- /src/libssh/examples/examples_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2009 Aris Adamantiadis 3 | 4 | This file is part of the SSH Library 5 | 6 | You are free to copy this file, modify it in any way, consider it being public 7 | domain. This does not apply to the rest of the library though, but it is 8 | allowed to cut-and-paste working code from this file to any license of 9 | program. 10 | The goal is to show the API in action. It's not a reference on how terminal 11 | clients must be made or how a client should react. 12 | */ 13 | #ifndef EXAMPLES_COMMON_H_ 14 | #define EXAMPLES_COMMON_H_ 15 | 16 | #include 17 | 18 | /** Zero a structure */ 19 | #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) 20 | 21 | int authenticate_console(ssh_session session); 22 | int authenticate_kbdint(ssh_session session, const char *password); 23 | int verify_knownhost(ssh_session session); 24 | ssh_session connect_ssh(const char *hostname, const char *user, int verbosity); 25 | 26 | #endif /* EXAMPLES_COMMON_H_ */ 27 | -------------------------------------------------------------------------------- /src/libssh/examples/exec.c: -------------------------------------------------------------------------------- 1 | /* simple exec example */ 2 | #include 3 | 4 | #include 5 | #include "examples_common.h" 6 | 7 | int main(void) { 8 | ssh_session session; 9 | ssh_channel channel; 10 | char buffer[256]; 11 | int rbytes, wbytes, total = 0; 12 | int rc; 13 | 14 | session = connect_ssh("localhost", NULL, 0); 15 | if (session == NULL) { 16 | ssh_finalize(); 17 | return 1; 18 | } 19 | 20 | channel = ssh_channel_new(session);; 21 | if (channel == NULL) { 22 | ssh_disconnect(session); 23 | ssh_free(session); 24 | ssh_finalize(); 25 | return 1; 26 | } 27 | 28 | rc = ssh_channel_open_session(channel); 29 | if (rc < 0) { 30 | goto failed; 31 | } 32 | 33 | rc = ssh_channel_request_exec(channel, "lsof"); 34 | if (rc < 0) { 35 | goto failed; 36 | } 37 | 38 | rbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); 39 | if (rbytes <= 0) { 40 | goto failed; 41 | } 42 | 43 | do { 44 | wbytes = fwrite(buffer + total, 1, rbytes, stdout); 45 | if (wbytes <= 0) { 46 | goto failed; 47 | } 48 | 49 | total += wbytes; 50 | 51 | /* When it was not possible to write the whole buffer to stdout */ 52 | if (wbytes < rbytes) { 53 | rbytes -= wbytes; 54 | continue; 55 | } 56 | 57 | rbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); 58 | total = 0; 59 | } while (rbytes > 0); 60 | 61 | if (rbytes < 0) { 62 | goto failed; 63 | } 64 | 65 | ssh_channel_send_eof(channel); 66 | ssh_channel_close(channel); 67 | ssh_channel_free(channel); 68 | ssh_disconnect(session); 69 | ssh_free(session); 70 | ssh_finalize(); 71 | 72 | return 0; 73 | failed: 74 | ssh_channel_close(channel); 75 | ssh_channel_free(channel); 76 | ssh_disconnect(session); 77 | ssh_free(session); 78 | ssh_finalize(); 79 | 80 | return 1; 81 | } 82 | -------------------------------------------------------------------------------- /src/libssh/examples/keygen.c: -------------------------------------------------------------------------------- 1 | /* keygen.c 2 | * Sample implementation of ssh-keygen using libssh 3 | */ 4 | 5 | /* 6 | Copyright 2019 Red Hat, Inc. 7 | 8 | Author: Jakub Jelen 9 | 10 | This file is part of the SSH Library 11 | 12 | You are free to copy this file, modify it in any way, consider it being public 13 | domain. This does not apply to the rest of the library though, but it is 14 | allowed to cut-and-paste working code from this file to any license of 15 | program. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | int main(void) 22 | { 23 | ssh_key key = NULL; 24 | int rv; 25 | 26 | /* Generate a new ED25519 private key file */ 27 | rv = ssh_pki_generate(SSH_KEYTYPE_ED25519, 0, &key); 28 | if (rv != SSH_OK) { 29 | fprintf(stderr, "Failed to generate private key"); 30 | return -1; 31 | } 32 | 33 | /* Write it to a file testkey in the current dirrectory */ 34 | rv = ssh_pki_export_privkey_file(key, NULL, NULL, NULL, "testkey"); 35 | if (rv != SSH_OK) { 36 | fprintf(stderr, "Failed to write private key file"); 37 | return -1; 38 | } 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/libssh/examples/libsshpp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Aris Adamantiadis 3 | 4 | This file is part of the SSH Library 5 | 6 | You are free to copy this file, modify it in any way, consider it being public 7 | domain. This does not apply to the rest of the library though, but it is 8 | allowed to cut-and-paste working code from this file to any license of 9 | program. 10 | */ 11 | 12 | /* This file demonstrates the use of the C++ wrapper to libssh */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | int main(int argc, const char **argv){ 19 | ssh::Session session; 20 | try { 21 | if(argc>1) 22 | session.setOption(SSH_OPTIONS_HOST,argv[1]); 23 | else 24 | session.setOption(SSH_OPTIONS_HOST,"localhost"); 25 | session.connect(); 26 | session.userauthPublickeyAuto(); 27 | session.disconnect(); 28 | } catch (ssh::SshException e){ 29 | std::cout << "Error during connection : "; 30 | std::cout << e.getError() << std::endl; 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libssh/examples/libsshpp_noexcept.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Aris Adamantiadis 3 | 4 | This file is part of the SSH Library 5 | 6 | You are free to copy this file, modify it in any way, consider it being public 7 | domain. This does not apply to the rest of the library though, but it is 8 | allowed to cut-and-paste working code from this file to any license of 9 | program. 10 | */ 11 | 12 | /* This file demonstrates the use of the C++ wrapper to libssh 13 | * specifically, without C++ exceptions 14 | */ 15 | 16 | #include 17 | #define SSH_NO_CPP_EXCEPTIONS 18 | #include 19 | 20 | int main(int argc, const char **argv){ 21 | ssh::Session session,s2; 22 | int err; 23 | if(argc>1) 24 | err=session.setOption(SSH_OPTIONS_HOST,argv[1]); 25 | else 26 | err=session.setOption(SSH_OPTIONS_HOST,"localhost"); 27 | if(err==SSH_ERROR) 28 | goto error; 29 | err=session.connect(); 30 | if(err==SSH_ERROR) 31 | goto error; 32 | err=session.userauthPublickeyAuto(); 33 | if(err==SSH_ERROR) 34 | goto error; 35 | 36 | return 0; 37 | error: 38 | std::cout << "Error during connection : "; 39 | std::cout << session.getError() << std::endl; 40 | return 1; 41 | } 42 | -------------------------------------------------------------------------------- /src/libssh/examples/senddata.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include "examples_common.h" 5 | 6 | #define LIMIT 0x100000000UL 7 | 8 | int main(void) { 9 | ssh_session session; 10 | ssh_channel channel; 11 | char buffer[1024*1024]; 12 | int rc; 13 | uint64_t total=0; 14 | uint64_t lastshown=4096; 15 | session = connect_ssh("localhost", NULL, 0); 16 | if (session == NULL) { 17 | return 1; 18 | } 19 | 20 | channel = ssh_channel_new(session);; 21 | if (channel == NULL) { 22 | ssh_disconnect(session); 23 | return 1; 24 | } 25 | 26 | rc = ssh_channel_open_session(channel); 27 | if (rc < 0) { 28 | ssh_channel_close(channel); 29 | ssh_disconnect(session); 30 | return 1; 31 | } 32 | 33 | rc = ssh_channel_request_exec(channel, "cat > /dev/null"); 34 | if (rc < 0) { 35 | ssh_channel_close(channel); 36 | ssh_disconnect(session); 37 | return 1; 38 | } 39 | 40 | 41 | while ((rc = ssh_channel_write(channel, buffer, sizeof(buffer))) > 0) { 42 | total += rc; 43 | if(total/2 >= lastshown){ 44 | printf("written %llx\n", (long long unsigned int) total); 45 | lastshown=total; 46 | } 47 | if(total > LIMIT) 48 | break; 49 | } 50 | 51 | if (rc < 0) { 52 | printf("error : %s\n",ssh_get_error(session)); 53 | ssh_channel_close(channel); 54 | ssh_disconnect(session); 55 | return 1; 56 | } 57 | 58 | ssh_channel_send_eof(channel); 59 | ssh_channel_close(channel); 60 | 61 | ssh_disconnect(session); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /src/libssh/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libssh-headers-x C) 2 | 3 | add_subdirectory(libssh) 4 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libssh-headers C) 2 | 3 | set(libssh_HDRS 4 | callbacks.h 5 | libssh.h 6 | ssh2.h 7 | legacy.h 8 | libsshpp.hpp 9 | ) 10 | 11 | if (WITH_SFTP) 12 | set(libssh_HDRS 13 | ${libssh_HDRS} 14 | sftp.h 15 | ) 16 | endif (WITH_SFTP) 17 | 18 | if (WITH_SERVER) 19 | set(libssh_HDRS 20 | ${libssh_HDRS} 21 | server.h 22 | ) 23 | endif (WITH_SERVER) 24 | 25 | install( 26 | FILES 27 | ${libssh_HDRS} 28 | DESTINATION 29 | ${CMAKE_INSTALL_INCLUDEDIR}/${APPLICATION_NAME} 30 | COMPONENT 31 | headers 32 | ) 33 | 34 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libssh_version.h.cmake 35 | ${libssh_BINARY_DIR}/include/libssh/libssh_version.h 36 | @ONLY) 37 | install(FILES ${libssh_BINARY_DIR}/include/libssh/libssh_version.h 38 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${APPLICATION_NAME} 39 | COMPONENT headers) 40 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/bignum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2014 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef BIGNUM_H_ 22 | #define BIGNUM_H_ 23 | 24 | #include "libssh/libcrypto.h" 25 | #include "libssh/libgcrypt.h" 26 | #include "libssh/libmbedcrypto.h" 27 | 28 | bignum ssh_make_string_bn(ssh_string string); 29 | ssh_string ssh_make_bignum_string(bignum num); 30 | void ssh_print_bignum(const char *which, const_bignum num); 31 | 32 | 33 | #endif /* BIGNUM_H_ */ 34 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/bind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2010 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef BIND_H_ 22 | #define BIND_H_ 23 | 24 | #include "libssh/priv.h" 25 | #include "libssh/kex.h" 26 | #include "libssh/session.h" 27 | 28 | struct ssh_bind_struct { 29 | struct ssh_common_struct common; /* stuff common to ssh_bind and ssh_session */ 30 | struct ssh_bind_callbacks_struct *bind_callbacks; 31 | void *bind_callbacks_userdata; 32 | 33 | struct ssh_poll_handle_struct *poll; 34 | /* options */ 35 | char *wanted_methods[SSH_KEX_METHODS]; 36 | char *banner; 37 | char *ecdsakey; 38 | char *dsakey; 39 | char *rsakey; 40 | char *ed25519key; 41 | ssh_key ecdsa; 42 | ssh_key dsa; 43 | ssh_key rsa; 44 | ssh_key ed25519; 45 | char *bindaddr; 46 | socket_t bindfd; 47 | unsigned int bindport; 48 | int blocking; 49 | int toaccept; 50 | bool config_processed; 51 | char *config_dir; 52 | char *pubkey_accepted_key_types; 53 | }; 54 | 55 | struct ssh_poll_handle_struct *ssh_bind_get_poll(struct ssh_bind_struct 56 | *sshbind); 57 | 58 | 59 | #endif /* BIND_H_ */ 60 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/bind_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bind_config.h - Parse the SSH server configuration file 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2019 by Red Hat, Inc. 7 | * 8 | * Author: Anderson Toshiyuki Sasaki 9 | * 10 | * The SSH Library is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or (at your 13 | * option) any later version. 14 | * 15 | * The SSH Library is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with the SSH Library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | #ifndef BIND_CONFIG_H_ 27 | #define BIND_CONFIG_H_ 28 | 29 | #include "libssh/server.h" 30 | 31 | enum ssh_bind_config_opcode_e { 32 | /* Known but not allowed in Match block */ 33 | BIND_CFG_NOT_ALLOWED_IN_MATCH = -4, 34 | /* Unknown opcode */ 35 | BIND_CFG_UNKNOWN = -3, 36 | /* Known and not applicable to libssh */ 37 | BIND_CFG_NA = -2, 38 | /* Known but not supported by current libssh version */ 39 | BIND_CFG_UNSUPPORTED = -1, 40 | BIND_CFG_INCLUDE, 41 | BIND_CFG_HOSTKEY, 42 | BIND_CFG_LISTENADDRESS, 43 | BIND_CFG_PORT, 44 | BIND_CFG_LOGLEVEL, 45 | BIND_CFG_CIPHERS, 46 | BIND_CFG_MACS, 47 | BIND_CFG_KEXALGORITHMS, 48 | BIND_CFG_MATCH, 49 | BIND_CFG_PUBKEY_ACCEPTED_KEY_TYPES, 50 | BIND_CFG_HOSTKEY_ALGORITHMS, 51 | 52 | BIND_CFG_MAX /* Keep this one last in the list */ 53 | }; 54 | 55 | /* @brief Parse configuration file and set the options to the given ssh_bind 56 | * 57 | * @params[in] sshbind The ssh_bind context to be configured 58 | * @params[in] filename The path to the configuration file 59 | * 60 | * @returns 0 on successful parsing the configuration file, -1 on error 61 | */ 62 | int ssh_bind_config_parse_file(ssh_bind sshbind, const char *filename); 63 | 64 | #endif /* BIND_CONFIG_H_ */ 65 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/chacha.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: chacha.h,v 1.3 2014/05/02 03:27:54 djm Exp $ */ 2 | 3 | /* 4 | chacha-merged.c version 20080118 5 | D. J. Bernstein 6 | Public domain. 7 | */ 8 | 9 | #ifndef CHACHA_H 10 | #define CHACHA_H 11 | 12 | struct chacha_ctx { 13 | uint32_t input[16]; 14 | }; 15 | 16 | #define CHACHA_MINKEYLEN 16 17 | #define CHACHA_NONCELEN 8 18 | #define CHACHA_CTRLEN 8 19 | #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) 20 | #define CHACHA_BLOCKLEN 64 21 | 22 | void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits) 23 | #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE 24 | __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))) 25 | #endif 26 | ; 27 | void chacha_ivsetup(struct chacha_ctx *x, const uint8_t *iv, const uint8_t *ctr) 28 | #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE 29 | __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN))) 30 | __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN))) 31 | #endif 32 | ; 33 | void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m, 34 | uint8_t *c, uint32_t bytes) 35 | #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE 36 | __attribute__((__bounded__(__buffer__, 2, 4))) 37 | __attribute__((__bounded__(__buffer__, 3, 4))) 38 | #endif 39 | ; 40 | 41 | #endif /* CHACHA_H */ 42 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * config.h - parse the ssh config file 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2009-2018 by Andreas Schneider 7 | * 8 | * The SSH Library is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * The SSH Library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with the SSH Library; see the file COPYING. If not, write to 20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 21 | * MA 02111-1307, USA. 22 | */ 23 | 24 | #ifndef LIBSSH_CONFIG_H_ 25 | #define LIBSSH_CONFIG_H_ 26 | 27 | 28 | enum ssh_config_opcode_e { 29 | /* Unknown opcode */ 30 | SOC_UNKNOWN = -3, 31 | /* Known and not applicable to libssh */ 32 | SOC_NA = -2, 33 | /* Known but not supported by current libssh version */ 34 | SOC_UNSUPPORTED = -1, 35 | SOC_HOST, 36 | SOC_MATCH, 37 | SOC_HOSTNAME, 38 | SOC_PORT, 39 | SOC_USERNAME, 40 | SOC_IDENTITY, 41 | SOC_CIPHERS, 42 | SOC_MACS, 43 | SOC_COMPRESSION, 44 | SOC_TIMEOUT, 45 | SOC_PROTOCOL, 46 | SOC_STRICTHOSTKEYCHECK, 47 | SOC_KNOWNHOSTS, 48 | SOC_PROXYCOMMAND, 49 | SOC_PROXYJUMP, 50 | SOC_GSSAPISERVERIDENTITY, 51 | SOC_GSSAPICLIENTIDENTITY, 52 | SOC_GSSAPIDELEGATECREDENTIALS, 53 | SOC_INCLUDE, 54 | SOC_BINDADDRESS, 55 | SOC_GLOBALKNOWNHOSTSFILE, 56 | SOC_LOGLEVEL, 57 | SOC_HOSTKEYALGORITHMS, 58 | SOC_KEXALGORITHMS, 59 | SOC_GSSAPIAUTHENTICATION, 60 | SOC_KBDINTERACTIVEAUTHENTICATION, 61 | SOC_PASSWORDAUTHENTICATION, 62 | SOC_PUBKEYAUTHENTICATION, 63 | SOC_PUBKEYACCEPTEDTYPES, 64 | SOC_REKEYLIMIT, 65 | 66 | SOC_MAX /* Keep this one last in the list */ 67 | }; 68 | #endif /* LIBSSH_CONFIG_H_ */ 69 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/config_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * config_parser.h - Common configuration file parser functions 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2019 by Red Hat, Inc. 7 | * 8 | * Author: Anderson Toshiyuki Sasaki 9 | * 10 | * The SSH Library is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or (at your 13 | * option) any later version. 14 | * 15 | * The SSH Library is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with the SSH Library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | #ifndef CONFIG_PARSER_H_ 27 | #define CONFIG_PARSER_H_ 28 | 29 | char *ssh_config_get_cmd(char **str); 30 | 31 | char *ssh_config_get_token(char **str); 32 | 33 | long ssh_config_get_long(char **str, long notfound); 34 | 35 | const char *ssh_config_get_str_tok(char **str, const char *def); 36 | 37 | int ssh_config_get_yesno(char **str, int notfound); 38 | 39 | /* @brief Parse SSH URI in format [user@]host[:port] from the given string 40 | * 41 | * @param[in] tok String to parse 42 | * @param[out] username Pointer to the location, where the new username will 43 | * be stored or NULL if we do not care about the result. 44 | * @param[out] hostname Pointer to the location, where the new hostname will 45 | * be stored or NULL if we do not care about the result. 46 | * @param[out] port Pointer to the location, where the new port will 47 | * be stored or NULL if we do not care about the result. 48 | * 49 | * @returns SSH_OK if the provided string is in format of SSH URI, 50 | * SSH_ERROR on failure 51 | */ 52 | int ssh_config_parse_uri(const char *tok, 53 | char **username, 54 | char **hostname, 55 | char **port); 56 | 57 | #endif /* LIBSSH_CONFIG_H_ */ 58 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/curve25519.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2013 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef CURVE25519_H_ 22 | #define CURVE25519_H_ 23 | 24 | #include "config.h" 25 | #include "libssh.h" 26 | 27 | #ifdef WITH_NACL 28 | 29 | #include 30 | #define CURVE25519_PUBKEY_SIZE crypto_scalarmult_curve25519_BYTES 31 | #define CURVE25519_PRIVKEY_SIZE crypto_scalarmult_curve25519_SCALARBYTES 32 | #define crypto_scalarmult_base crypto_scalarmult_curve25519_base 33 | #define crypto_scalarmult crypto_scalarmult_curve25519 34 | #else 35 | 36 | #define CURVE25519_PUBKEY_SIZE 32 37 | #define CURVE25519_PRIVKEY_SIZE 32 38 | int crypto_scalarmult_base(unsigned char *q, const unsigned char *n); 39 | int crypto_scalarmult(unsigned char *q, const unsigned char *n, const unsigned char *p); 40 | #endif /* WITH_NACL */ 41 | 42 | #ifdef HAVE_ECC 43 | #define HAVE_CURVE25519 1 44 | #endif 45 | 46 | typedef unsigned char ssh_curve25519_pubkey[CURVE25519_PUBKEY_SIZE]; 47 | typedef unsigned char ssh_curve25519_privkey[CURVE25519_PRIVKEY_SIZE]; 48 | 49 | 50 | int ssh_client_curve25519_init(ssh_session session); 51 | 52 | #ifdef WITH_SERVER 53 | void ssh_server_curve25519_init(ssh_session session); 54 | #endif /* WITH_SERVER */ 55 | 56 | #endif /* CURVE25519_H_ */ 57 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/dh-gex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2016 by Aris Adamantiadis 5 | * 6 | * The SSH Library is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2.1 of the License, or (at your 9 | * option) any later version. 10 | * 11 | * The SSH Library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with the SSH Library; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 19 | * MA 02111-1307, USA. 20 | */ 21 | 22 | 23 | #ifndef SRC_DH_GEX_H_ 24 | #define SRC_DH_GEX_H_ 25 | 26 | int ssh_client_dhgex_init(ssh_session session); 27 | 28 | #ifdef WITH_SERVER 29 | void ssh_server_dhgex_init(ssh_session session); 30 | #endif /* WITH_SERVER */ 31 | 32 | #endif /* SRC_DH_GEX_H_ */ 33 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/ecdh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2011 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef ECDH_H_ 22 | #define ECDH_H_ 23 | 24 | #include "config.h" 25 | #include "libssh/callbacks.h" 26 | 27 | #ifdef HAVE_LIBCRYPTO 28 | #ifdef HAVE_OPENSSL_ECDH_H 29 | 30 | #ifdef HAVE_ECC 31 | #define HAVE_ECDH 1 32 | #endif 33 | 34 | #endif /* HAVE_OPENSSL_ECDH_H */ 35 | #endif /* HAVE_LIBCRYPTO */ 36 | 37 | #ifdef HAVE_GCRYPT_ECC 38 | #define HAVE_ECDH 1 39 | #endif 40 | 41 | #ifdef HAVE_LIBMBEDCRYPTO 42 | #define HAVE_ECDH 1 43 | #endif 44 | 45 | extern struct ssh_packet_callbacks_struct ssh_ecdh_client_callbacks; 46 | /* Backend-specific functions. */ 47 | int ssh_client_ecdh_init(ssh_session session); 48 | int ecdh_build_k(ssh_session session); 49 | 50 | #ifdef WITH_SERVER 51 | extern struct ssh_packet_callbacks_struct ssh_ecdh_server_callbacks; 52 | void ssh_server_ecdh_init(ssh_session session); 53 | SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init); 54 | #endif /* WITH_SERVER */ 55 | 56 | #endif /* ECDH_H_ */ 57 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/ge25519.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ge25519.h,v 1.3 2013/12/09 11:03:45 markus Exp $ */ 2 | 3 | /* 4 | * Public Domain, Authors: Daniel J. Bernstein, Niels Duif, Tanja Lange, 5 | * Peter Schwabe, Bo-Yin Yang. 6 | * Copied from supercop-20130419/crypto_sign/ed25519/ref/ge25519.h 7 | */ 8 | 9 | #ifndef GE25519_H 10 | #define GE25519_H 11 | 12 | #include "fe25519.h" 13 | #include "sc25519.h" 14 | 15 | #define ge25519 crypto_sign_ed25519_ref_ge25519 16 | #define ge25519_base crypto_sign_ed25519_ref_ge25519_base 17 | #define ge25519_unpackneg_vartime crypto_sign_ed25519_ref_unpackneg_vartime 18 | #define ge25519_pack crypto_sign_ed25519_ref_pack 19 | #define ge25519_isneutral_vartime crypto_sign_ed25519_ref_isneutral_vartime 20 | #define ge25519_double_scalarmult_vartime crypto_sign_ed25519_ref_double_scalarmult_vartime 21 | #define ge25519_scalarmult_base crypto_sign_ed25519_ref_scalarmult_base 22 | 23 | typedef struct 24 | { 25 | fe25519 x; 26 | fe25519 y; 27 | fe25519 z; 28 | fe25519 t; 29 | } ge25519; 30 | 31 | extern const ge25519 ge25519_base; 32 | 33 | int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]); 34 | 35 | void ge25519_pack(unsigned char r[32], const ge25519 *p); 36 | 37 | int ge25519_isneutral_vartime(const ge25519 *p); 38 | 39 | void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const sc25519 *s1, const ge25519 *p2, const sc25519 *s2); 40 | 41 | void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/gssapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2013 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef GSSAPI_H_ 22 | #define GSSAPI_H_ 23 | 24 | #include "config.h" 25 | #include "session.h" 26 | 27 | /* all OID begin with the tag identifier + length */ 28 | #define SSH_OID_TAG 06 29 | 30 | typedef struct ssh_gssapi_struct *ssh_gssapi; 31 | 32 | #ifdef WITH_SERVER 33 | int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids); 34 | SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server); 35 | SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic); 36 | #endif /* WITH_SERVER */ 37 | 38 | SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token); 39 | SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client); 40 | SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response); 41 | 42 | 43 | int ssh_gssapi_auth_mic(ssh_session session); 44 | 45 | #endif /* GSSAPI_H */ 46 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/kex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2009 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef KEX_H_ 22 | #define KEX_H_ 23 | 24 | #include "libssh/priv.h" 25 | #include "libssh/callbacks.h" 26 | 27 | #define SSH_KEX_METHODS 10 28 | 29 | struct ssh_kex_struct { 30 | unsigned char cookie[16]; 31 | char *methods[SSH_KEX_METHODS]; 32 | }; 33 | 34 | SSH_PACKET_CALLBACK(ssh_packet_kexinit); 35 | 36 | int ssh_send_kex(ssh_session session, int server_kex); 37 | void ssh_list_kex(struct ssh_kex_struct *kex); 38 | int ssh_set_client_kex(ssh_session session); 39 | int ssh_kex_select_methods(ssh_session session); 40 | int ssh_verify_existing_algo(enum ssh_kex_types_e algo, const char *name); 41 | char *ssh_keep_known_algos(enum ssh_kex_types_e algo, const char *list); 42 | char *ssh_keep_fips_algos(enum ssh_kex_types_e algo, const char *list); 43 | char **ssh_space_tokenize(const char *chain); 44 | int ssh_get_kex1(ssh_session session); 45 | char *ssh_find_matching(const char *in_d, const char *what_d); 46 | const char *ssh_kex_get_supported_method(uint32_t algo); 47 | const char *ssh_kex_get_default_methods(uint32_t algo); 48 | const char *ssh_kex_get_fips_methods(uint32_t algo); 49 | const char *ssh_kex_get_description(uint32_t algo); 50 | char *ssh_client_select_hostkeys(ssh_session session); 51 | int ssh_send_rekex(ssh_session session); 52 | int server_set_kex(ssh_session session); 53 | int ssh_make_sessionid(ssh_session session); 54 | /* add data for the final cookie */ 55 | int ssh_hashbufin_add_cookie(ssh_session session, unsigned char *cookie); 56 | int ssh_hashbufout_add_cookie(ssh_session session); 57 | int ssh_generate_session_keys(ssh_session session); 58 | 59 | #endif /* KEX_H_ */ 60 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/keys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2009 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef KEYS_H_ 22 | #define KEYS_H_ 23 | 24 | #include "config.h" 25 | #include "libssh/libssh.h" 26 | #include "libssh/wrapper.h" 27 | 28 | struct ssh_public_key_struct { 29 | int type; 30 | const char *type_c; /* Don't free it ! it is static */ 31 | #if defined(HAVE_LIBGCRYPT) 32 | gcry_sexp_t dsa_pub; 33 | gcry_sexp_t rsa_pub; 34 | #elif defined(HAVE_LIBCRYPTO) 35 | DSA *dsa_pub; 36 | RSA *rsa_pub; 37 | #elif defined(HAVE_LIBMBEDCRYPTO) 38 | mbedtls_pk_context *rsa_pub; 39 | void *dsa_pub; 40 | #endif 41 | }; 42 | 43 | struct ssh_private_key_struct { 44 | int type; 45 | #if defined(HAVE_LIBGCRYPT) 46 | gcry_sexp_t dsa_priv; 47 | gcry_sexp_t rsa_priv; 48 | #elif defined(HAVE_LIBCRYPTO) 49 | DSA *dsa_priv; 50 | RSA *rsa_priv; 51 | #elif defined(HAVE_LIBMBEDCRYPTO) 52 | mbedtls_pk_context *rsa_priv; 53 | void *dsa_priv; 54 | #endif 55 | }; 56 | 57 | const char *ssh_type_to_char(int type); 58 | int ssh_type_from_name(const char *name); 59 | 60 | ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s); 61 | 62 | #endif /* KEYS_H_ */ 63 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/knownhosts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 20014 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | 22 | #ifndef SSH_KNOWNHOSTS_H_ 23 | #define SSH_KNOWNHOSTS_H_ 24 | 25 | struct ssh_list *ssh_known_hosts_get_algorithms(ssh_session session); 26 | char *ssh_known_hosts_get_algorithms_names(ssh_session session); 27 | enum ssh_known_hosts_e 28 | ssh_session_get_known_hosts_entry_file(ssh_session session, 29 | const char *filename, 30 | struct ssh_knownhosts_entry **pentry); 31 | 32 | #endif /* SSH_KNOWNHOSTS_H_ */ 33 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/libssh_version.h.cmake: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2020 by Heiko Thiery 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _LIBSSH_VERSION_H 22 | #define _LIBSSH_VERSION_H 23 | 24 | /* libssh version macros */ 25 | #define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c)) 26 | #define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c 27 | #define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c) 28 | 29 | /* libssh version */ 30 | #define LIBSSH_VERSION_MAJOR @libssh_VERSION_MAJOR@ 31 | #define LIBSSH_VERSION_MINOR @libssh_VERSION_MINOR@ 32 | #define LIBSSH_VERSION_MICRO @libssh_VERSION_PATCH@ 33 | 34 | #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \ 35 | LIBSSH_VERSION_MINOR, \ 36 | LIBSSH_VERSION_MICRO) 37 | #define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \ 38 | LIBSSH_VERSION_MINOR, \ 39 | LIBSSH_VERSION_MICRO) 40 | 41 | #endif /* _LIBSSH_VERSION_H */ 42 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2011 Andreas Schneider 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _OPTIONS_H 22 | #define _OPTIONS_H 23 | 24 | int ssh_config_parse_file(ssh_session session, const char *filename); 25 | int ssh_options_set_algo(ssh_session session, 26 | enum ssh_kex_types_e algo, 27 | const char *list); 28 | int ssh_options_apply(ssh_session session); 29 | 30 | #endif /* _OPTIONS_H */ 31 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2009 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef PCAP_H_ 22 | #define PCAP_H_ 23 | 24 | #include "config.h" 25 | #include "libssh/libssh.h" 26 | 27 | #ifdef WITH_PCAP 28 | typedef struct ssh_pcap_context_struct* ssh_pcap_context; 29 | 30 | int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len); 31 | 32 | ssh_pcap_context ssh_pcap_context_new(ssh_session session); 33 | void ssh_pcap_context_free(ssh_pcap_context ctx); 34 | 35 | enum ssh_pcap_direction{ 36 | SSH_PCAP_DIR_IN, 37 | SSH_PCAP_DIR_OUT 38 | }; 39 | void ssh_pcap_context_set_file(ssh_pcap_context, ssh_pcap_file); 40 | int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, void *data, 41 | uint32_t len, uint32_t origlen); 42 | 43 | 44 | #endif /* WITH_PCAP */ 45 | #endif /* PCAP_H_ */ 46 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/poly1305.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Public Domain poly1305 from Andrew Moon 3 | * poly1305-donna-unrolled.c from https://github.com/floodyberry/poly1305-donna 4 | */ 5 | 6 | #ifndef POLY1305_H 7 | #define POLY1305_H 8 | 9 | #define POLY1305_KEYLEN 32 10 | #define POLY1305_TAGLEN 16 11 | 12 | void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen, 13 | const uint8_t key[POLY1305_KEYLEN]) 14 | #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE 15 | __attribute__((__bounded__(__minbytes__, 1, POLY1305_TAGLEN))) 16 | __attribute__((__bounded__(__buffer__, 2, 3))) 17 | __attribute__((__bounded__(__minbytes__, 4, POLY1305_KEYLEN))) 18 | #endif 19 | ; 20 | 21 | #endif /* POLY1305_H */ 22 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/scp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2003-2009 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef _SCP_H 22 | #define _SCP_H 23 | 24 | enum ssh_scp_states { 25 | SSH_SCP_NEW, //Data structure just created 26 | SSH_SCP_WRITE_INITED, //Gave our intention to write 27 | SSH_SCP_WRITE_WRITING,//File was opened and currently writing 28 | SSH_SCP_READ_INITED, //Gave our intention to read 29 | SSH_SCP_READ_REQUESTED, //We got a read request 30 | SSH_SCP_READ_READING, //File is opened and reading 31 | SSH_SCP_ERROR, //Something bad happened 32 | SSH_SCP_TERMINATED //Transfer finished 33 | }; 34 | 35 | struct ssh_scp_struct { 36 | ssh_session session; 37 | int mode; 38 | int recursive; 39 | ssh_channel channel; 40 | char *location; 41 | enum ssh_scp_states state; 42 | uint64_t filelen; 43 | uint64_t processed; 44 | enum ssh_scp_request_types request_type; 45 | char *request_name; 46 | char *warning; 47 | int request_mode; 48 | }; 49 | 50 | int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len); 51 | int ssh_scp_integer_mode(const char *mode); 52 | char *ssh_scp_string_mode(int mode); 53 | int ssh_scp_response(ssh_scp scp, char **response); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/sftp_priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2003-2008 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef SFTP_PRIV_H 22 | #define SFTP_PRIV_H 23 | 24 | sftp_packet sftp_packet_read(sftp_session sftp); 25 | ssize_t sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload); 26 | void sftp_packet_free(sftp_packet packet); 27 | int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr); 28 | sftp_attributes sftp_parse_attr(sftp_session session, 29 | ssh_buffer buf, 30 | int expectname); 31 | 32 | #endif /* SFTP_PRIV_H */ 33 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2009 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef STRING_H_ 22 | #define STRING_H_ 23 | #include "libssh/priv.h" 24 | 25 | /* must be 32 bits number + immediately our data */ 26 | #ifdef _MSC_VER 27 | #pragma pack(1) 28 | #endif 29 | struct ssh_string_struct { 30 | uint32_t size; 31 | unsigned char data[1]; 32 | } 33 | #if defined(__GNUC__) 34 | __attribute__ ((packed)) 35 | #endif 36 | #ifdef _MSC_VER 37 | #pragma pack() 38 | #endif 39 | ; 40 | 41 | #endif /* STRING_H_ */ 42 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2010 by Aris Adamantiadis 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef THREADS_H_ 22 | #define THREADS_H_ 23 | 24 | #include 25 | #include 26 | 27 | #if HAVE_PTHREAD 28 | 29 | #include 30 | #define SSH_MUTEX pthread_mutex_t 31 | 32 | #if defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) 33 | #define SSH_MUTEX_STATIC_INIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP 34 | #else 35 | #define SSH_MUTEX_STATIC_INIT PTHREAD_MUTEX_INITIALIZER 36 | #endif 37 | 38 | #elif (defined _WIN32) || (defined _WIN64) 39 | 40 | #include 41 | #include 42 | #define SSH_MUTEX CRITICAL_SECTION * 43 | #define SSH_MUTEX_STATIC_INIT NULL 44 | 45 | #else 46 | 47 | # define SSH_MUTEX void * 48 | #define SSH_MUTEX_STATIC_INIT NULL 49 | 50 | #endif 51 | 52 | int ssh_threads_init(void); 53 | void ssh_threads_finalize(void); 54 | const char *ssh_threads_get_type(void); 55 | 56 | void ssh_mutex_lock(SSH_MUTEX *mutex); 57 | void ssh_mutex_unlock(SSH_MUTEX *mutex); 58 | 59 | struct ssh_threads_callbacks_struct *ssh_threads_get_default(void); 60 | int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks); 61 | void crypto_thread_finalize(void); 62 | 63 | #endif /* THREADS_H_ */ 64 | -------------------------------------------------------------------------------- /src/libssh/include/libssh/token.h: -------------------------------------------------------------------------------- 1 | /* 2 | * token.h - Tokens list handling 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2019 by Red Hat, Inc. 7 | * 8 | * Author: Anderson Toshiyuki Sasaki 9 | * 10 | * The SSH Library is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or (at your 13 | * option) any later version. 14 | * 15 | * The SSH Library is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with the SSH Library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 23 | * MA 02111-1307, USA. 24 | */ 25 | 26 | #ifndef TOKEN_H_ 27 | #define TOKEN_H_ 28 | 29 | struct ssh_tokens_st { 30 | char *buffer; 31 | char **tokens; 32 | }; 33 | 34 | struct ssh_tokens_st *ssh_tokenize(const char *chain, char separator); 35 | 36 | void ssh_tokens_free(struct ssh_tokens_st *tokens); 37 | 38 | char *ssh_find_matching(const char *available_d, 39 | const char *preferred_d); 40 | 41 | char *ssh_find_all_matching(const char *available_d, 42 | const char *preferred_d); 43 | 44 | char *ssh_remove_duplicates(const char *list); 45 | 46 | char *ssh_append_without_duplicates(const char *list, 47 | const char *appended_list); 48 | #endif /* TOKEN_H_ */ 49 | -------------------------------------------------------------------------------- /src/libssh/libssh.pc.cmake: -------------------------------------------------------------------------------- 1 | Name: ${PROJECT_NAME} 2 | Description: The SSH Library 3 | Version: ${PROJECT_VERSION} 4 | Libs: -L${CMAKE_INSTALL_FULL_LIBDIR} -lssh 5 | Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} 6 | 7 | -------------------------------------------------------------------------------- /src/libssh/src/ABI/current: -------------------------------------------------------------------------------- 1 | 4.8.6 -------------------------------------------------------------------------------- /src/libssh/src/ABI/libssh-4.5.1.symbols: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/libssh/src/ABI/libssh-4.5.1.symbols -------------------------------------------------------------------------------- /src/libssh/src/libcrypto-compat.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBCRYPTO_COMPAT_H 2 | #define LIBCRYPTO_COMPAT_H 3 | 4 | #include 5 | #if OPENSSL_VERSION_NUMBER < 0x10100000L 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); 16 | int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); 17 | int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); 18 | void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); 19 | void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); 20 | void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp); 21 | 22 | void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); 23 | int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); 24 | void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key); 25 | int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); 26 | 27 | void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); 28 | int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); 29 | 30 | void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); 31 | int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); 32 | 33 | int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); 34 | EVP_MD_CTX *EVP_MD_CTX_new(void); 35 | void EVP_MD_CTX_free(EVP_MD_CTX *ctx); 36 | 37 | int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx); 38 | 39 | HMAC_CTX *HMAC_CTX_new(void); 40 | int HMAC_CTX_reset(HMAC_CTX *ctx); 41 | void HMAC_CTX_free(HMAC_CTX *ctx); 42 | 43 | void DH_get0_pqg(const DH *dh, 44 | const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); 45 | int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); 46 | void DH_get0_key(const DH *dh, 47 | const BIGNUM **pub_key, const BIGNUM **priv_key); 48 | int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); 49 | 50 | const char *OpenSSL_version(int type); 51 | unsigned long OpenSSL_version_num(void); 52 | 53 | #endif /* OPENSSL_VERSION_NUMBER */ 54 | 55 | #endif /* LIBCRYPTO_COMPAT_H */ 56 | -------------------------------------------------------------------------------- /src/libssh/src/threads/mbedtls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2018 by Anderson Toshiyuki Sasaki 5 | * 6 | * The SSH Library is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2.1 of the License, or (at your 9 | * option) any later version. 10 | * 11 | * The SSH Library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with the SSH Library; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 19 | * MA 02111-1307, USA. 20 | */ 21 | 22 | #include "config.h" 23 | #include "libssh/crypto.h" 24 | #include "libssh/threads.h" 25 | #include 26 | 27 | #include 28 | 29 | int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks) 30 | { 31 | int cmp; 32 | 33 | if (user_callbacks == NULL) { 34 | return SSH_OK; 35 | } 36 | 37 | cmp = strcmp(user_callbacks->type, "threads_noop"); 38 | if (cmp == 0) { 39 | return SSH_OK; 40 | } 41 | #ifdef MBEDTLS_THREADING_ALT 42 | else { 43 | if (user_callbacks != NULL) { 44 | crypto_thread_finalize(); 45 | } 46 | 47 | mbedtls_threading_set_alt(user_callbacks->mutex_init, 48 | user_callbacks->mutex_destroy, 49 | user_callbacks->mutex_lock, 50 | user_callbacks->mutex_unlock); 51 | } 52 | #elif defined MBEDTLS_THREADING_PTHREAD 53 | return SSH_OK; 54 | #else 55 | return SSH_ERROR; 56 | #endif 57 | } 58 | 59 | void crypto_thread_finalize(void) 60 | { 61 | #ifdef MBEDTLS_THREADING_ALT 62 | mbedtls_threading_free_alt(); 63 | #endif 64 | return; 65 | } 66 | -------------------------------------------------------------------------------- /src/libssh/src/threads/noop.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2018 by Anderson Toshiyuki Sasaki 5 | * 6 | * The SSH Library is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2.1 of the License, or (at your 9 | * option) any later version. 10 | * 11 | * The SSH Library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with the SSH Library; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 19 | * MA 02111-1307, USA. 20 | */ 21 | 22 | #include "config.h" 23 | #include "libssh/threads.h" 24 | #include 25 | 26 | static int threads_noop(void **lock) 27 | { 28 | (void)lock; 29 | 30 | return 0; 31 | } 32 | 33 | static unsigned long threads_id_noop (void) 34 | { 35 | return 1; 36 | } 37 | 38 | static struct ssh_threads_callbacks_struct ssh_threads_noop = 39 | { 40 | .type = "threads_noop", 41 | .mutex_init = threads_noop, 42 | .mutex_destroy = threads_noop, 43 | .mutex_lock = threads_noop, 44 | .mutex_unlock = threads_noop, 45 | .thread_id = threads_id_noop 46 | }; 47 | 48 | /* Threads interface implementation */ 49 | 50 | #if !(HAVE_PTHREAD) && !(defined _WIN32 || defined _WIN64) 51 | void ssh_mutex_lock(SSH_MUTEX *mutex) 52 | { 53 | (void) mutex; 54 | 55 | return; 56 | } 57 | 58 | void ssh_mutex_unlock(SSH_MUTEX *mutex) 59 | { 60 | (void) mutex; 61 | 62 | return; 63 | } 64 | 65 | struct ssh_threads_callbacks_struct *ssh_threads_get_default(void) 66 | { 67 | return &ssh_threads_noop; 68 | } 69 | #endif 70 | 71 | struct ssh_threads_callbacks_struct *ssh_threads_get_noop(void) 72 | { 73 | return &ssh_threads_noop; 74 | } 75 | -------------------------------------------------------------------------------- /src/libssh/tests/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libssh-benchmarks C) 2 | 3 | set(benchmarks_SRCS 4 | bench_scp.c bench_sftp bench_raw.c benchmarks.c latency.c 5 | ) 6 | 7 | include_directories(${libssh_BINARY_DIR}) 8 | 9 | add_executable(benchmarks ${benchmarks_SRCS}) 10 | 11 | target_link_libraries(benchmarks ssh::ssh) 12 | -------------------------------------------------------------------------------- /src/libssh/tests/benchmarks/bench1.sh: -------------------------------------------------------------------------------- 1 | export CIPHER=aes128-cbc 2 | export DEST=localhost 3 | 4 | echo "Upload raw SSH statistics" 5 | echo "local machine: `uname -a`" 6 | echo "Cipher : $CIPHER ; Destination : $DEST (`ssh $DEST uname -a`)" 7 | echo "Local ssh version: `ssh -V 2>&1`" 8 | echo "Ping latency to $DEST": 9 | ping -q -c 1 -n $DEST 10 | echo "Destination $DEST SSHD vesion : `echo | nc $DEST 22 | head -n1`" 11 | echo "ssh login latency :`(time -f user:%U ssh $DEST 'id > /dev/null') 2>&1`" 12 | ./generate.py | dd bs=4096 count=100000 | time ssh -c $CIPHER $DEST "dd bs=4096 of=/dev/null" 2>&1 13 | 14 | -------------------------------------------------------------------------------- /src/libssh/tests/benchmarks/bench2.sh: -------------------------------------------------------------------------------- 1 | export CIPHER=aes128-cbc 2 | export DEST=localhost 3 | 4 | echo "Upload raw SSH statistics" 5 | echo "local machine: `uname -a`" 6 | echo "Cipher : $CIPHER ; Destination : $DEST (`ssh $DEST uname -a`)" 7 | echo "Local ssh version: `samplessh -V 2>&1`" 8 | echo "Ping latency to $DEST": 9 | ping -q -c 1 -n $DEST 10 | echo "Destination $DEST SSHD vesion : `echo | nc $DEST 22 | head -n1`" 11 | echo "ssh login latency :`(time -f user:%U samplessh $DEST 'id > /dev/null') 2>&1`" 12 | ./generate.py | dd bs=4096 count=100000 | strace samplessh -c $CIPHER $DEST "dd bs=4096 of=/dev/null" 2>&1 13 | 14 | -------------------------------------------------------------------------------- /src/libssh/tests/chmodtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include "examples_common.h" 5 | #include 6 | 7 | int main(void) { 8 | ssh_session session; 9 | sftp_session sftp; 10 | char buffer[1024*1024]; 11 | int rc; 12 | 13 | session = connect_ssh("localhost", NULL, 0); 14 | if (session == NULL) { 15 | return 1; 16 | } 17 | 18 | sftp=sftp_new(session); 19 | sftp_init(sftp); 20 | rc=sftp_rename(sftp,"/tmp/test","/tmp/test"); 21 | rc=sftp_rename(sftp,"/tmp/test","/tmp/test"); 22 | rc=sftp_chmod(sftp,"/tmp/test",0644); 23 | if (rc < 0) { 24 | printf("error : %s\n",ssh_get_error(sftp)); 25 | 26 | ssh_disconnect(session); 27 | return 1; 28 | } 29 | 30 | ssh_disconnect(session); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libssh/tests/chroot_wrapper.c: -------------------------------------------------------------------------------- 1 | /* silent gcc */ 2 | int chroot(const char *); 3 | 4 | int chroot(const char *path) 5 | { 6 | (void)path; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/libssh/tests/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(clienttests C) 2 | 3 | find_package(socket_wrapper) 4 | 5 | set(LIBSSH_CLIENT_TESTS 6 | torture_algorithms 7 | torture_client_config 8 | torture_connect 9 | torture_hostkey 10 | torture_auth 11 | torture_rekey 12 | torture_forward 13 | torture_knownhosts 14 | torture_knownhosts_verify 15 | torture_proxycommand 16 | torture_session 17 | torture_request_env 18 | torture_client_global_requests) 19 | 20 | find_program(SCP_EXECUTABLE NAMES scp) 21 | if (SCP_EXECUTABLE) 22 | set(LIBSSH_CLIENT_TESTS 23 | ${LIBSSH_CLIENT_TESTS} 24 | torture_scp) 25 | endif() 26 | 27 | if (DEFAULT_C_NO_DEPRECATION_FLAGS) 28 | set_source_files_properties(torture_knownhosts.c 29 | PROPERTIES 30 | COMPILE_FLAGS ${DEFAULT_C_NO_DEPRECATION_FLAGS}) 31 | endif() 32 | 33 | if (WITH_SFTP) 34 | if (WITH_BENCHMARKS) 35 | set(SFTP_BENCHMARK_TESTS 36 | torture_sftp_benchmark) 37 | endif() 38 | set(LIBSSH_CLIENT_TESTS 39 | ${LIBSSH_CLIENT_TESTS} 40 | torture_sftp_ext 41 | torture_sftp_canonicalize_path 42 | torture_sftp_dir 43 | torture_sftp_read 44 | torture_sftp_fsync 45 | ${SFTP_BENCHMARK_TESTS}) 46 | endif (WITH_SFTP) 47 | 48 | foreach(_CLI_TEST ${LIBSSH_CLIENT_TESTS}) 49 | add_cmocka_test(${_CLI_TEST} 50 | SOURCES ${_CLI_TEST}.c 51 | COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} 52 | LINK_LIBRARIES ${TORTURE_LIBRARY} 53 | ) 54 | 55 | if (OSX) 56 | set_property( 57 | TEST 58 | ${_CLI_TEST} 59 | PROPERTY 60 | ENVIRONMENT DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${SOCKET_WRAPPER_LIBRARY}) 61 | else () 62 | set_property( 63 | TEST 64 | ${_CLI_TEST} 65 | PROPERTY 66 | ENVIRONMENT ${TORTURE_ENVIRONMENT}) 67 | endif() 68 | endforeach() 69 | -------------------------------------------------------------------------------- /src/libssh/tests/client/torture_sftp_ext.c: -------------------------------------------------------------------------------- 1 | #define LIBSSH_STATIC 2 | 3 | #include "config.h" 4 | 5 | #include "torture.h" 6 | #include "sftp.c" 7 | 8 | static void torture_sftp_ext_new(void **state) { 9 | sftp_ext x; 10 | 11 | (void) state; 12 | 13 | x = sftp_ext_new(); 14 | assert_non_null(x); 15 | assert_int_equal(x->count, 0); 16 | assert_null(x->name); 17 | assert_null(x->data); 18 | 19 | sftp_ext_free(x); 20 | } 21 | 22 | int torture_run_tests(void) { 23 | int rc; 24 | struct CMUnitTest tests[] = { 25 | cmocka_unit_test(torture_sftp_ext_new), 26 | }; 27 | 28 | ssh_init(); 29 | 30 | torture_filter_tests(tests); 31 | rc = cmocka_run_group_tests(tests, NULL, NULL); 32 | ssh_finalize(); 33 | 34 | return rc; 35 | } 36 | -------------------------------------------------------------------------------- /src/libssh/tests/cmdline.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "torture.h" 3 | 4 | #ifdef HAVE_ARGP_H 5 | #include 6 | 7 | const char *argp_program_version = "libssh test 0.2"; 8 | const char *argp_program_bug_address = ""; 9 | 10 | static char **cmdline; 11 | 12 | /* Program documentation. */ 13 | static char doc[] = "libssh test test"; 14 | 15 | /* The options we understand. */ 16 | static struct argp_option options[] = { 17 | { 18 | .name = "verbose", 19 | .key = 'v', 20 | .arg = NULL, 21 | .flags = 0, 22 | .doc = "Make libssh test more verbose", 23 | .group = 0 24 | }, 25 | {NULL, 0, NULL, 0, NULL, 0} 26 | }; 27 | 28 | /* Parse a single option. */ 29 | static error_t parse_opt (int key, char *arg, struct argp_state *state) { 30 | /* Get the input argument from argp_parse, which we 31 | * know is a pointer to our arguments structure. 32 | */ 33 | struct argument_s *arguments = state->input; 34 | 35 | /* arg is currently not used */ 36 | (void) arg; 37 | 38 | switch (key) { 39 | case 'v': 40 | arguments->verbose++; 41 | break; 42 | case ARGP_KEY_ARG: 43 | /* End processing here. */ 44 | arguments->pattern = state->argv[state->next - 1]; 45 | cmdline = &state->argv [state->next - 1]; 46 | state->next = state->argc; 47 | break; 48 | default: 49 | return ARGP_ERR_UNKNOWN; 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | /* Our argp parser. */ 56 | /* static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL}; */ 57 | static struct argp argp = {options, parse_opt, NULL, doc, NULL, NULL, NULL}; 58 | #endif /* HAVE_ARGP_H */ 59 | 60 | void torture_cmdline_parse(int argc, char **argv, struct argument_s *arguments) { 61 | /* 62 | * Parse our arguments; every option seen by parse_opt will 63 | * be reflected in arguments. 64 | */ 65 | #ifdef HAVE_ARGP_H 66 | argp_parse(&argp, argc, argv, 0, 0, arguments); 67 | #else 68 | (void) argc; 69 | (void) argv; 70 | (void) arguments; 71 | #endif /* HAVE_ARGP_H */ 72 | } 73 | -------------------------------------------------------------------------------- /src/libssh/tests/connection.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed in public domain. You can do whatever you want 3 | with its content. 4 | */ 5 | 6 | #include 7 | #include 8 | #include "tests.h" 9 | SSH_OPTIONS *set_opts(int argc, char **argv){ 10 | SSH_OPTIONS *options=ssh_options_new(); 11 | char *host=NULL; 12 | if(ssh_options_getopt(options,&argc, argv)){ 13 | fprintf(stderr,"error parsing command line :%s\n",ssh_get_error(options)); 14 | return NULL; 15 | } 16 | int i; 17 | while((i=getopt(argc,argv,""))!=-1){ 18 | switch(i){ 19 | default: 20 | fprintf(stderr,"unknown option %c\n",optopt); 21 | } 22 | } 23 | if(optind < argc) 24 | host=argv[optind++]; 25 | if(host==NULL){ 26 | fprintf(stderr,"must provide an host name\n"); 27 | return NULL; 28 | } 29 | ssh_options_set_host(options,host); 30 | return options; 31 | } 32 | -------------------------------------------------------------------------------- /src/libssh/tests/etc/group.in: -------------------------------------------------------------------------------- 1 | users:x:9000: 2 | sshd:x:65531: 3 | nobody:x:65533: 4 | nogroup:x:65534:nobody 5 | root:x:65532: 6 | -------------------------------------------------------------------------------- /src/libssh/tests/etc/hosts.in: -------------------------------------------------------------------------------- 1 | 127.0.0.10 server.libssh.site 2 | 127.0.0.21 client.libssh.site 3 | -------------------------------------------------------------------------------- /src/libssh/tests/etc/pam.d/sshd.in: -------------------------------------------------------------------------------- 1 | auth required @PAM_WRAPPER_MODULE_DIR@/pam_matrix.so passdb=@CMAKE_CURRENT_BINARY_DIR@/etc/pam_matrix_passdb 2 | account required @PAM_WRAPPER_MODULE_DIR@/pam_matrix.so passdb=@CMAKE_CURRENT_BINARY_DIR@/etc/pam_matrix_passdb 3 | password required @PAM_WRAPPER_MODULE_DIR@/pam_matrix.so passdb=@CMAKE_CURRENT_BINARY_DIR@/etc/pam_matrix_passdb 4 | session required @PAM_WRAPPER_MODULE_DIR@/pam_matrix.so passdb=@CMAKE_CURRENT_BINARY_DIR@/etc/pam_matrix_passdb 5 | -------------------------------------------------------------------------------- /src/libssh/tests/etc/pam_matrix_passdb.in: -------------------------------------------------------------------------------- 1 | bob:secret:sshd 2 | alice:secret:sshd 3 | -------------------------------------------------------------------------------- /src/libssh/tests/etc/passwd.in: -------------------------------------------------------------------------------- 1 | bob:x:5000:9000:bob gecos:@HOMEDIR@/bob:/bin/sh 2 | alice:x:5001:9000:alice gecos:@HOMEDIR@/alice:/bin/sh 3 | sshd:x:65530:65531:sshd:@HOMEDIR@:/sbin/nologin 4 | nobody:x:65533:65534:nobody gecos:@HOMEDIR@:/bin/false 5 | root:x:65534:65532:root gecos:@HOMEDIR@:/bin/false 6 | @LOCAL_USER@:x:@LOCAL_UID@:9000:local user:@HOMEDIR@:/bin/false 7 | -------------------------------------------------------------------------------- /src/libssh/tests/etc/shadow.in: -------------------------------------------------------------------------------- 1 | alice:$6$0jWkA8VP$MvBUvtGy38jWCZ5KtqnZEKQWXvvImDkDhDQII1kTqtAp3/xH31b71c.AjGkBFle.2QwCJQH7OzB/NXiMprusr/::0::::: 2 | bob:$6$0jWkA8VP$MvBUvtGy38jWCZ5KtqnZEKQWXvvImDkDhDQII1kTqtAp3/xH31b71c.AjGkBFle.2QwCJQH7OzB/NXiMprusr/::0::::: 3 | -------------------------------------------------------------------------------- /src/libssh/tests/fuzz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(fuzzing CXX) 2 | 3 | if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 4 | add_executable(ssh_server_fuzzer ssh_server_fuzzer.cpp) 5 | set_target_properties(ssh_server_fuzzer 6 | PROPERTIES 7 | COMPILE_FLAGS "-fsanitize=fuzzer" 8 | LINK_FLAGS "-fsanitize=fuzzer") 9 | endif() 10 | -------------------------------------------------------------------------------- /src/libssh/tests/generate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import os 3 | a="" 4 | for i in xrange(4096): 5 | a+=chr(i % 256); 6 | while True: 7 | try: 8 | os.write(1,a) 9 | except: 10 | exit(0) 11 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/certauth/id_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEiwIBAAKB/QMTSsCQqarOIauonYgjAt8E+lgSWBU/43ITyDDzLM4IS4wCcqXB 3 | 1Fagz386FU1B2AcUqlPZ1+7RlaXkqgKr4nGHv00U/GG+YAUgUAw1G12kI4cvrnWr 4 | FIXwcq+VTJNej5pHxEqcRLw7ZBorpqm2UsY5KLr5R3uMNap7koj1Hbt9lKsvfDn6 5 | HjM4qY0ygx8hxf/4wCzIh5V4k9/UAMkqI2CM9c3yEE2aWh/4MDOnAFj+0T2sMAo8 6 | jyOZ6v+W7hmEtsUc9mEv+5B+hhVeYO/RwxketJAQRPYDSPSi1mjtv9fnzGk15q/l 7 | Hb2V/HP/pyIpao19A4daR0a4ia9Hk4UCAwEAAQKB/QKEaPxjrKzlWoQSWRdUaQY5 8 | Idyy7yw9hiMa9BK1COh/u66XVlY86Fwb9puR5Fu/WF67WIuX1PpizJXkLBBRtuDs 9 | lvY2BjrPQ/MONtc3JPYp4vbFXYxtAzh6zrTPhMVfcjV7Jr1XWZ+lEVOmhR2G4gvk 10 | P2WDozIKWub3jMLTt4afgHCGaKfKEUpKjFkiAalz8oLVv8qV1FVPPDT2PWeKMuE3 11 | XfoN7YUaP6+aPlNnjIv/3BDsrPsiKZ+AKXcERdPvVQa/LypzW08cqC6sIJKWVmQI 12 | 3KgoYs9VvbDXfQ8jKfcsTApZkSDaLX6tf3Ei+76R0lbV4L1rpypa25qj9YECfwHP 13 | N+v/6yObJFL5/1rEuT7CFbfP8g5J8qUVufcPRKv//ChluLuWNxgLJmIv2ZffWwhe 14 | GKHlT98QPgFvsMSOyLeut4beZYKDSeVNvEt9eCBjOax2jOBGo3hv8j/Fs8yAfZOV 15 | Ardv2qUszubM+DVwjJzb3vaZyEesRucJISqkJeUCfwGzGdMp0LXrZ7aaQGgHj/P2 16 | DKGq0E2gnj/EBapatjxKm4hMRn/vkTWjCDCryTnvJqkW/00tr4GqWXoeilBFD270 17 | RcvbOe9LQmGlHIYzgwc5nfLDBQyeNnHRmkeD9LQRUfdTdHj4jf+35pHlsVUT0Rnl 18 | IMNoRA6V07bySFdI3SECfiF+1rbrxuhaCRIA0Ax3pL0eGuuTgksAm8VlbCMTgSiC 19 | kF1CrXXgSAHOZb02C9Bf4cwEFfjh/KxM/4eXDa+Rfg7JQJxmVLivqEAlxIOvIxBp 20 | xDnSWAljmrrllozyQnBsJDbbOm6BLf5+e5wIuryHvnP7vHNEU0J24g/78PxrrQJ/ 21 | AVD4OzYzUfESzbUBFJBmyIZSmhJ0aOpwJOpniNvgLymI8zI/l22uhF/TQ/6HRbsV 22 | sfcBmoA7YKzRx2ZHsIsLvN6p/4u1fsJGkuERCk5yt/HDhfPLwU321IeEeMaVia+w 23 | T1/u4JF/SADhLTU69az3UJrHmQ7zRmh7I0DZDeB8gQJ+XqIqutPeerNtbqMjXGW8 24 | TdpqZAzAQAv6dPgaH0W0OzJe2hP9uy0D84H5f8Im/irJh/AXo/QL3obXqopyeLf0 25 | HfcUUnEZEBPlqsirZFtPClD+HL6Orf1je0oVV/aQssPkQl6/aXBNd+kS27U3NBML 26 | LmRhC4+Q+/M5MlRggLtn 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/certauth/id_rsa-cert.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAgHZLan4ufbTFWr8Hl/8JvZTLYa0eNNm2qov9zPlK7qfwAAAADAQABAAAA/QMTSsCQqarOIauonYgjAt8E+lgSWBU/43ITyDDzLM4IS4wCcqXB1Fagz386FU1B2AcUqlPZ1+7RlaXkqgKr4nGHv00U/GG+YAUgUAw1G12kI4cvrnWrFIXwcq+VTJNej5pHxEqcRLw7ZBorpqm2UsY5KLr5R3uMNap7koj1Hbt9lKsvfDn6HjM4qY0ygx8hxf/4wCzIh5V4k9/UAMkqI2CM9c3yEE2aWh/4MDOnAFj+0T2sMAo8jyOZ6v+W7hmEtsUc9mEv+5B+hhVeYO/RwxketJAQRPYDSPSi1mjtv9fnzGk15q/lHb2V/HP/pyIpao19A4daR0a4ia9Hk4UAAAAAAAAAAAAAAAEAAAATdG9ydHVyZV9hdXRoX2NhcmxvcwAAAAkAAAAFYWxpY2UAAAAAAAAAAP//////////AAAAAAAAAIIAAAAVcGVybWl0LVgxMS1mb3J3YXJkaW5nAAAAAAAAABdwZXJtaXQtYWdlbnQtZm9yd2FyZGluZwAAAAAAAAAWcGVybWl0LXBvcnQtZm9yd2FyZGluZwAAAAAAAAAKcGVybWl0LXB0eQAAAAAAAAAOcGVybWl0LXVzZXItcmMAAAAAAAAAAAAAARcAAAAHc3NoLXJzYQAAAAMBAAEAAAEBAKcDafm8fNluz8a9GQaWgk1XUJcchLleeubTke6xQlJbI+rcjWIIwd1gDuh7Mdr0YIVhsh6dpg/L4bpRJBGNhDPxK8BmjTpIU14lKxrWQAirHN09P2QGtGtgrf09lA+xhV9E+pkF2Zz6PCt/P3sgUQnJcwjjsWhMaSASrt67fPanH+10hnfgjkevkMMHGJxmLiOW7JFQkd9I+gHHKEXs6Q9fhtiStzr3WN4hAPG5uXrnRZgseAV9p3TFPMEgUTpdRvnkOnkCBF169KiyjU97QgoXHExWk/rrgsJtgrTou/qRyi18WWm9S1HXLHyNOgZxKirmxLNPC9dIcJBD1kDWG8UAAAEPAAAAB3NzaC1yc2EAAAEAhNLOXT0jyz/Web0HUyrtPCvUZsLkDyBWCNoNTfsxGVoYsE4WCpNwqQO1A4NT5AtIE+R7rn9wfjvXM7sYh6hJyq3HVEWhts1SkQVU7sQBrImTIrj2cWKR3gmQ+ehsgNFGhcFZTK77ugw1fMfzZRvKVTkRWhe6v92wQOtkoINtf3f1fK6xY+vLwAA/E4VdaRJmhwAaNpy3PfMAJytkCLjcjUSWHYDha4hs98/EBPduGNNNiZdyG7lcpSvvq9HBDxzOiHBa/We9m38/Dk4TNVkZ/wrtBFQxH75if6SgGa/feGJrKQHBru7sPh8dO4R1AmZaoLmRzMnzZOtB0oEXmBqHmw== libssh_torture_auth 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/certauth/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAA/QMTSsCQqarOIauonYgjAt8E+lgSWBU/43ITyDDzLM4IS4wCcqXB1Fagz386FU1B2AcUqlPZ1+7RlaXkqgKr4nGHv00U/GG+YAUgUAw1G12kI4cvrnWrFIXwcq+VTJNej5pHxEqcRLw7ZBorpqm2UsY5KLr5R3uMNap7koj1Hbt9lKsvfDn6HjM4qY0ygx8hxf/4wCzIh5V4k9/UAMkqI2CM9c3yEE2aWh/4MDOnAFj+0T2sMAo8jyOZ6v+W7hmEtsUc9mEv+5B+hhVeYO/RwxketJAQRPYDSPSi1mjtv9fnzGk15q/lHb2V/HP/pyIpao19A4daR0a4ia9Hk4U= libssh_torture_auth 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/id_ecdsa: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MHcCAQEEIHbL0nzpzLS3ImIlhEffbDzPlIw/tn5QcfB64PbSiBl6oAoGCCqGSM49 3 | AwEHoUQDQgAERzA8X8OP7C3W/e1UNLh+21xIZVBiQ7i4Qb4xoOebRWuwzitEZon/ 4 | 8Dz+VpE29krJgCagqSt5RLllOx8eS2i8fw== 5 | -----END EC PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/id_ecdsa.pub: -------------------------------------------------------------------------------- 1 | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEcwPF/Dj+wt1v3tVDS4fttcSGVQYkO4uEG+MaDnm0VrsM4rRGaJ//A8/laRNvZKyYAmoKkreUS5ZTsfHktovH8= comment 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/id_ed25519: -------------------------------------------------------------------------------- 1 | -----BEGIN OPENSSH PRIVATE KEY----- 2 | b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW 3 | QyNTUxOQAAACCLo6vx1lX6ZZoe05lWTkuwrJUZN0T8hEer5UF9KPhOVgAAAKg+IRNSPiET 4 | UgAAAAtzc2gtZWQyNTUxOQAAACCLo6vx1lX6ZZoe05lWTkuwrJUZN0T8hEer5UF9KPhOVg 5 | AAAED2zFg52qYItoZaSUnir4VKubTxJveL9D2oWK7Prg/O24ujq/HWVfplmh7TmVZOS7Cs 6 | lRk3RPyER6vlQX0o+E5WAAAAHmpqZWxlbkB0NDcwcy5qamVsZW4ucmVkaGF0LmNvbQECAw 7 | QFBgc= 8 | -----END OPENSSH PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/id_ed25519.pub: -------------------------------------------------------------------------------- 1 | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIujq/HWVfplmh7TmVZOS7CslRk3RPyER6vlQX0o+E5W jjelen@t470s.jjelen.redhat.com 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/id_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEAs/fIz+Gy89XjUhXebNq2rs1K0RJEZXDbfcofb13ESDJ9fSbd 3 | +RlCUM6i+foEVV23xWdands2Bkn72tGinJadIgOWU+koxp+gRmtJLE/ONiAKJQqR 4 | K3eOJNBH6At96NMqJ4Gwv56G4W68uPgDwUVQwVIc6Ec6Rypiz7DE+S++gSvBQIVU 5 | Qt7XkPcXOyN5zuj5qDhZM4l6V7Og9LWj4/2IF5acvKjfIMpeqmnp9z6BTYZQtuQU 6 | 6b1VuEYhXyvM6LkMwndsVGh46kDKMmRQhyA8A6qvLAliMMq88k5gR4AeJeTnqDR/ 7 | Q120I6PMqYNl6TLTk8/KonOOPDR/XXGb3iF67wIDAQABAoIBAAVoL2dXf5nl1jOU 8 | Jp+cnpp33oSTiOyHTIDl/rXI2mnU4oJNFaQzRxPIcYsTIOgzrZ7HsShG+sOLm36C 9 | h+EugUARXYXd3nTBPP6AoK0tJKPpqIReYegtal7exxpIphrFpWGUeuv25lSFkDP6 10 | d5pp67gzMF0mLrEOq/NTe0eFULLuwa6+IKXU7deiU90pzi4jrjcIWNoGHSw1YYAZ 11 | TC8KAxA/tYH9myya5krRCjA9B345DJ9Wd71wX+RZNgbSkIri/6dDTtvsYvqcQKo0 12 | OZ3MUDJnKmkfPLP84qZPRoEwUI1gts1WUdoNK6LK7yOJmPL5FMyTwZx3XtDw3gAv 13 | TVhI7ikCgYEA5Ay0TCySPQAaC14WtjgIAmTa19mAtOFpbRxToi40WjXk3R6mMqyp 14 | biAcNecdZRC6zzgAUp8g1O3Yc1d9fG/3FpM5eUbIer7mMLTRuQQysoJY2Ayw9OEA 15 | qPHS/K6LPOD09aZo14fRUqVO8rwMbHtq2yhH8p3FM8WZRe5ms8zpyLUCgYEAygZ3 16 | RTMWbgcGdNoaPa5Ms9KRqAxKJLin2fE99KowZeJfvZN24sXExawQdy4BKVYT0H6e 17 | MNEIPiEBVA4a1GDk/tyOrEt684IsidROngJaGbqb+SYm6feQAioYu0wkG/I2hS12 18 | /Z/aK6wFz5hWzBv/YvJqC7xD1YwZm1QXDyAiL5MCgYAXz8fHqGPAoNEXXMSsVB9p 19 | +JPtM9W/jUXP0cRdy8tFnBkAiaG66tJqIEoxyqcEFYIb/vHxrpHkCc2vBXSh2KMJ 20 | JWg75IssXeB1N3wqgGi2wOt7659SgmfqPA3WunbpbWfGepC56IGPypj6uW3mqeBX 21 | b9ZLW/PqWviNF757iarjfQKBgGxKBPqRxM8bcumF0xUG7dRh5XN3ivKeDFL1Tels 22 | pF6odftPJSWvLqdqcLUBctvuaNaUWEUAdvOei3C70sPOYFEAdnWCTBhkyWzj4XQu 23 | /I7YCS0Gt0soSQfv+qvCx4Q3U+QVF7ghTDemkMLS/IuR4lXubMt3kcDQxRUOgQG5 24 | jrmDAoGALauF7ZyzEnQgsgMVzfm9znl5I2aIsLgdsAv3lINVrvtTKhddp7cdd+2j 25 | dwZlaMnLET/3MY/Cvf13vEsS+bdNXjsdQidqBL8pe5PXY/pafBhtduQuvGzlHJA5 26 | CEBnwB0SdtsXbzSpOAPZqea4Nz9MkQ8LMsINdPpxCuFhjeYa9Ow= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCz98jP4bLz1eNSFd5s2rauzUrREkRlcNt9yh9vXcRIMn19Jt35GUJQzqL5+gRVXbfFZ1qd2zYGSfva0aKclp0iA5ZT6SjGn6BGa0ksT842IAolCpErd44k0EfoC33o0yongbC/nobhbry4+APBRVDBUhzoRzpHKmLPsMT5L76BK8FAhVRC3teQ9xc7I3nO6PmoOFkziXpXs6D0taPj/YgXlpy8qN8gyl6qaen3PoFNhlC25BTpvVW4RiFfK8zouQzCd2xUaHjqQMoyZFCHIDwDqq8sCWIwyrzyTmBHgB4l5OeoNH9DXbQjo8ypg2XpMtOTz8qic448NH9dcZveIXrv asn@krikkit.cryptomilk.site 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_dsa_key: -------------------------------------------------------------------------------- 1 | -----BEGIN DSA PRIVATE KEY----- 2 | MIIBuwIBAAKBgQD7vBS+d/eJP6wK2VQw+8AIfgCw9IR50utLRkkrWbfDdiM7V+fp 3 | tJYKCyqZT9j9ANhqicB2tuqAI6WJBZMaGekxWfI30JxPkHZrrwbdFzlRbjav07lg 4 | IKqWgcz81iVPmfn5savEoobiSFjJNMmYcizjKZgGmyNUzlJjzF7u5qD08wIVAPFp 5 | 6VKuv8VxNjENciUZCdEDRW/lAoGBAN/BFSBRSP9frsHID6e2NeKHqs8JDUWhCTE9 6 | /WQKqUUbxO2UU98CfHuf1mNlaSsrOxaBdvTeURcZZc1svhyGr1VG+NbNTDDlzTgA 7 | UlrzNML61TYcFXQVxgifUy+Tmh8FRGCa6Ko/EsX4ZWLTto5w1u5cPpgzSbLMco9T 8 | AeeNLgYNAoGAJRuawWN3+NezI7+bBe42Kjg4gVUlpS+8TTlYFbwrM1Esab7gvxHB 9 | /b2apbk9xIAkkqsnb+EPrXTLUdE2Y7XkEuGLLSTus2UlZKobBGBX/Ioysg5W9Fk/ 10 | 2MhI4YssRb2alar8d+gmAHPaT+D+NDd90PBfY3HqcXFEK+eDTWo1JNICFBLdsuoO 11 | 6pObeFSOYbr38kJzZ0xG 12 | -----END DSA PRIVATE KEY----- 13 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_dsa_key.pub: -------------------------------------------------------------------------------- 1 | ssh-dss AAAAB3NzaC1kc3MAAACBAPu8FL5394k/rArZVDD7wAh+ALD0hHnS60tGSStZt8N2IztX5+m0lgoLKplP2P0A2GqJwHa26oAjpYkFkxoZ6TFZ8jfQnE+QdmuvBt0XOVFuNq/TuWAgqpaBzPzWJU+Z+fmxq8SihuJIWMk0yZhyLOMpmAabI1TOUmPMXu7moPTzAAAAFQDxaelSrr/FcTYxDXIlGQnRA0Vv5QAAAIEA38EVIFFI/1+uwcgPp7Y14oeqzwkNRaEJMT39ZAqpRRvE7ZRT3wJ8e5/WY2VpKys7FoF29N5RFxllzWy+HIavVUb41s1MMOXNOABSWvM0wvrVNhwVdBXGCJ9TL5OaHwVEYJroqj8SxfhlYtO2jnDW7lw+mDNJssxyj1MB540uBg0AAACAJRuawWN3+NezI7+bBe42Kjg4gVUlpS+8TTlYFbwrM1Esab7gvxHB/b2apbk9xIAkkqsnb+EPrXTLUdE2Y7XkEuGLLSTus2UlZKobBGBX/Ioysg5W9Fk/2MhI4YssRb2alar8d+gmAHPaT+D+NDd90PBfY3HqcXFEK+eDTWo1JNI= asn@magrathea 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_ecdsa_key: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MHcCAQEEIB9v2n1oaXvBECf0gDPxTibeUPvvkI1anNWDAIkNjs5JoAoGCCqGSM49 3 | AwEHoUQDQgAEqkTqNu7gRegPJRy0WiseJz9NAdBimzyNSzNwI5eAkEqv9D6Y95KL 4 | 7DBEnDQ2p08iOLw+vN1PKHsCM7b/ONbYVg== 5 | -----END EC PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_ecdsa_key.pub: -------------------------------------------------------------------------------- 1 | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKpE6jbu4EXoDyUctForHic/TQHQYps8jUszcCOXgJBKr/Q+mPeSi+wwRJw0NqdPIji8PrzdTyh7AjO2/zjW2FY= asn@magrathea 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingToolbox/WindTerm/a8336c1d1e3dd1a981500dae8ef9eb42066de95f/src/libssh/tests/keys/ssh_host_key -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_key.pub: -------------------------------------------------------------------------------- 1 | 2048 65537 25221975523736997039149017470335977198642717886559395625730372192276493838727011206749822289920387480933533054627057418868711378045090730895752530916661328094497437687453813456961487210492465678475508526337829331199296553120728607984859224949182503917312492825658971738208505685553964707412720244524969161284321098487507924676797222812771309962906894332072854924265623785469343453142982185436565166155021228521252914913227554455102103918367844210755391318078654400527927267478149210805219779896806429660492177158822689909493046725157917529664436252598971135251689616517266344945600782273453037452082373553352939812279 asn@magrathea 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_rsa_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAqzabeU0oKbHDwdlqindABvtzgWCvXdHJ+d2Ew6te2LXjkwju 3 | y7u6B7y63NZRy57ccrE4YSeWItVoZn+DWN+guU354Ss/tzQ9/thUmLrvtKNvJwuF 4 | F5Ch7Q4BsrXGsb2GSv+7W5tpx3yAqH1TvKQj/MmQVX+/9KtXEnh7/vpiCqoOXQAR 5 | zvIIQxoo1aUQBHAkRW7Yw0Ds7AjC9uV1ns4xdBXPQmDk23pWvCq7E+7rOEbKRrjj 6 | lApS4lJYy0oEXsFdqUPd+PtT1gG0nIElHFQtsTgUvwYQmJEzrBxv41odwRvxbMjg 7 | THPr4SLRRRSuPwICWyvxqPpa7EsfMBnbPEIUzQIDAQABAoIBAEUO15MLvgFjRDQy 8 | P7jt9JNcZPBwUQukjLUN1nkd7Dm407wAxGDErXplc3GTuJZK01wngzgcwX/3WA7P 9 | q+jy+l8DxqA904tPtRnPo/+elwTjTvgOu3YPzmBRX/n3O9eBPGOP1sBSZU4jN7m+ 10 | I0JZanKR0nfJ+WD0o0A9/LWRxG3MFIntBamtT6pgee8sAu44IvW0o7tHJabMq02J 11 | Z/ndrJmox34wq6SMFANax+N1x9sZa60bL7gEoDWQJNKOaMrbtOaIoTGFIc4hFqoA 12 | SzjNqcGsHPWs44cw0mNkUGq37jEvaCwzAp+U80ma1skBhXuJL9sQOxl1v5qW91c/ 13 | Cnm5WYECgYEA4DPvqbLt+VdyTtmCQ370yiCk4OPPMPzbM65IVKgQL/rN6HdNShTO 14 | uLF6P8XC8vNP2OSydJeFt+kMKd7E/4o5LfvEqUGXZJDkB7fLjrOjyZU3bxtIx95x 15 | qYGWRcWbd3sHzlBJGuFVSE7GREE+lqhkSu4ry4l/GAKxSymAXgGd/9ECgYEAw37L 16 | ppZIavcLE2rZgXHoqMiJzeGzsidJbkHss4k7ubLe8vyBMiv0HC2anxPa2+yNWuF2 17 | +pEr84bllh149VKeild24UEBAR2w/P41ggWqiUP7PKllh+huWzG4+KNFbfUP4dd0 18 | 4LkVgfsCz32qD8qxXNCxJCZ8H2fmjKsYw/oCID0CgYAiuSh3GdUtdtOnTpyUI4d5 19 | /pBKnD2skpzIZkehhN3s8GUPidqYjJxvkl0in1hQFErbhp/02rrE/vz5Rx0vjpLI 20 | gmO06wmtc5s9bsPB+CR3xfpt5MXi3pqv6/gAGli3qoBM/bY0yY1Rw5GFZK1y2+Wc 21 | jUKPJV5fs5sNzwGojYuQ4QKBgQCNNgqOo2Fd+mLCvNyt1wTy3iBEWfL+DcjJ3s7G 22 | hKtioKTQqbn87qjercZRf/sH/t/ANLpHlhNETj2KaHGV6v7f+PvDC7xY/QR6SnmG 23 | GOetTTCuCcJwIGGOd+UfnHgrS+gT/xjKtoalpBXMoP31eDkTTR+XeEESQm/TTkeO 24 | UAm3FQKBgD8Y7CLHpyZZ+eOnxRSPU4m4AWAEp7JOwHDRWWQeUornrXDYgD87d2M9 25 | iIAEuOzNggA56Nm3AzBOPRj4HkBh57ToVKPswHwB0oWvrtSjpLkkU6q8xRG3XuJD 26 | 2AskDaZONzIDoJGfZ3+W7YbKELK7DPtFXL15sOfBmpoEkI9RA5vM 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/ssh_host_rsa_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrNpt5TSgpscPB2WqKd0AG+3OBYK9d0cn53YTDq17YteOTCO7Lu7oHvLrc1lHLntxysThhJ5Yi1Whmf4NY36C5TfnhKz+3ND3+2FSYuu+0o28nC4UXkKHtDgGytcaxvYZK/7tbm2nHfICofVO8pCP8yZBVf7/0q1cSeHv++mIKqg5dABHO8ghDGijVpRAEcCRFbtjDQOzsCML25XWezjF0Fc9CYOTbela8KrsT7us4RspGuOOUClLiUljLSgRewV2pQ934+1PWAbScgSUcVC2xOBS/BhCYkTOsHG/jWh3BG/FsyOBMc+vhItFFFK4/AgJbK/Go+lrsSx8wGds8QhTN asn@magrathea 2 | -------------------------------------------------------------------------------- /src/libssh/tests/keys/user_ca: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEApwNp+bx82W7Pxr0ZBpaCTVdQlxyEuV565tOR7rFCUlsj6tyN 3 | YgjB3WAO6Hsx2vRghWGyHp2mD8vhulEkEY2EM/ErwGaNOkhTXiUrGtZACKsc3T0/ 4 | ZAa0a2Ct/T2UD7GFX0T6mQXZnPo8K38/eyBRCclzCOOxaExpIBKu3rt89qcf7XSG 5 | d+COR6+QwwcYnGYuI5bskVCR30j6AccoRezpD1+G2JK3OvdY3iEA8bm5eudFmCx4 6 | BX2ndMU8wSBROl1G+eQ6eQIEXXr0qLKNT3tCChccTFaT+uuCwm2CtOi7+pHKLXxZ 7 | ab1LUdcsfI06BnEqKubEs08L10hwkEPWQNYbxQIDAQABAoIBACW2AaHgS5iVCtln 8 | LVVterKX+pyEVfu9N6cTMqpg4AbUiYGol0wBijTAUd1wo8s6zuiPLLb5BdwfPzLg 9 | y3IjMCzCUgy5mz4Dwr9JSThgFElgyb2y7LNbSDXOuLqrwtjgTqs6WhNfXMmzPw7b 10 | Rqw4mdPJ5u2k7BQO3NXfIhks4ISYzpzNAwj1a2NMphvkZyvfRnWiQ0pvEXQCxwuR 11 | 74iGpPFeyFjjku/O4TiHZllPmDdD3ERalkf8RIudQ5gcbL4fRoONTzfZHtmARWoP 12 | Jury4Zfr5b3VGSnkUDaGlzilXvBusAZOCaaU7chvOPVjXMbSAUEpFBmnRHk5dfrH 13 | fCXECcECgYEA0KMtV3IzwMToVdvzcMQc1ovDvKZAQPneLTxFgNpOeycOhzulzY9p 14 | 3fRi5QUOA/Ff+LcCL86APqwoEYe4bgam6mwGFFhv1usf4ulbLNk8ZeR51CG6emPt 15 | tLpg6PThxhMnNpu+StrBAOxeo9pZGd+Plt6d4vfoalOHVkPlSv7OC9kCgYEAzO1I 16 | HuZAQkVdKLGuZlf8E4VEaiMBKdl5+H+8w9peOOax6nqAIrwp2d0aZ52LDjwg7d3C 17 | eSmxu0U1jsbzexVVePr/NmdJOu3+gB0GvlzRjS1xT+MCZIye5a7Nxc7lBp5rFmgV 18 | dJTA6XXRoykinZIxz068SHqtNhNOzO4hUmPDN80CgYAlxOR4aBwmUX8dy+uOBnKS 19 | BEsy44XOPW2TEs4iPWLnuHJQ2ONzCvtHSu58NyYKYK/W/opOzTs6HUBDrCYfBOVC 20 | mrufA0N7zKTBFy2COPFOIMZNOK3haiWmCfdxNKOKj/0RTbBtLJyz5hZb4zMuE+KS 21 | lUpPxEE2vlhJrZDcurPiQQKBgQCIEqMKCX/vwVlLlTglsxSp7ZrxEw9Jt6O68y7n 22 | qc9Y3y6ScQc2iVUM2jkXRlA4goqnB9KDW8EthZY7mTXBq/fWXmwqtsi0faW5cgyx 23 | SLbIlL0h+63yEEHOZ5UxXOFM1NJszW45vDCglOBABCd9E79JVZHGWtc7CfUQNKsh 24 | pybQnQKBgHbPnITR7esVQYLq3PHSsdOdkFiiVf3D7wHiNZcXWjJvUqMF4tH5XAzY 25 | QafKqKk0FzO92ZOhQeB5xauFY5wzsa+Xl8cQkyvtWngFIKbWydEehZWVgXcedxEC 26 | xjbZWKmsYDqBYi3bw9Dxb0AvT+kDtq0Azi8QTDAvRwylvtkYj/V8 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /src/libssh/tests/pkd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(pkd C) 2 | 3 | if (WITH_SERVER AND UNIX AND NOT WIN32) 4 | 5 | include_directories(${libssh_SOURCE_DIR}/include 6 | ${libssh_BINARY_DIR}/include 7 | ${CMOCKA_INCLUDE_DIR} 8 | ${ZLIB_INCLUDE_DIR} 9 | ${CMAKE_BINARY_DIR} 10 | ${libssh_SOURCE_DIR}/src 11 | ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | set(pkd_hello_src 14 | pkd_daemon.c 15 | pkd_hello.c 16 | pkd_keyutil.c 17 | pkd_util.c 18 | ) 19 | 20 | set(pkd_libs 21 | ${CMOCKA_LIBRARY} 22 | ssh::static 23 | ${ARGP_LIBRARIES} 24 | pthread 25 | ) 26 | 27 | add_executable(pkd_hello ${pkd_hello_src}) 28 | target_compile_options(pkd_hello PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) 29 | target_link_libraries(pkd_hello ${pkd_libs}) 30 | 31 | # 32 | # pkd_hello_i1 runs only one iteration per algorithm combination for 33 | # sake of speeding up overall test run time. More iterations can be 34 | # specified with `-i` and may be helpful for chasing down bugs that 35 | # are not 100% reproducible. 36 | # 37 | add_test(pkd_hello_i1 ${CMAKE_CURRENT_BINARY_DIR}/pkd_hello -e -o -i1 -w /tmp/pkd_socket_wrapper_XXXXXX) 38 | 39 | # 40 | # pkd_hello_rekey is used to test server-side implementation of rekeying. 41 | # 42 | add_test(pkd_hello_rekey ${CMAKE_CURRENT_BINARY_DIR}/pkd_hello -t torture_pkd_openssh_rsa_rsa_default -i1 --rekey=16 -v -v -v -w /tmp/pkd_socket_wrapper_XXXXXX) 43 | 44 | # 45 | # Configure environment for cwrap socket wrapper. 46 | # 47 | find_package(socket_wrapper 1.1.5 REQUIRED) 48 | if (OSX) 49 | set(PKD_ENVIRONMENT "DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${SOCKET_WRAPPER_LIBRARY}") 50 | else () 51 | set(PKD_ENVIRONMENT "LD_PRELOAD=${SOCKET_WRAPPER_LIBRARY}") 52 | endif () 53 | message(STATUS "PKD_ENVIRONMENT=${PKD_ENVIRONMENT}") 54 | set_property(TEST pkd_hello_i1 PROPERTY ENVIRONMENT ${PKD_ENVIRONMENT}) 55 | 56 | endif (WITH_SERVER AND UNIX AND NOT WIN32) 57 | -------------------------------------------------------------------------------- /src/libssh/tests/pkd/pkd_daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pkd_daemon.h -- tests use this interface to start, stop pkd 3 | * instances and get results 4 | * 5 | * (c) 2014 Jon Simons 6 | */ 7 | 8 | #ifndef __PKD_DAEMON_H__ 9 | #define __PKD_DAEMON_H__ 10 | 11 | #include "config.h" 12 | 13 | enum pkd_hostkey_type_e { 14 | PKD_RSA, 15 | #ifdef HAVE_DSA 16 | PKD_DSA, 17 | #endif 18 | PKD_ED25519, 19 | PKD_ECDSA 20 | }; 21 | 22 | struct pkd_daemon_args { 23 | enum pkd_hostkey_type_e type; 24 | const char *hostkeypath; 25 | 26 | struct { 27 | const uint8_t *buf; 28 | size_t len; 29 | } payload; 30 | 31 | uint64_t rekey_data_limit; 32 | 33 | struct { 34 | int list; 35 | 36 | int log_stdout; 37 | int log_stderr; 38 | int libssh_log_level; 39 | 40 | const char *testname; 41 | const char *testmatch; 42 | unsigned int iterations; 43 | 44 | struct { 45 | char *mkdtemp_str; 46 | } socket_wrapper; 47 | } opts; 48 | }; 49 | 50 | struct pkd_result { 51 | int ok; 52 | }; 53 | 54 | int pkd_start(struct pkd_daemon_args *args); 55 | void pkd_stop(struct pkd_result *out); 56 | 57 | #endif /* __PKD_DAEMON_H__ */ 58 | -------------------------------------------------------------------------------- /src/libssh/tests/pkd/pkd_keyutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pkd_keyutil.h -- 3 | * 4 | * (c) 2014 Jon Simons 5 | */ 6 | 7 | #ifndef __PKD_KEYUTIL_H__ 8 | #define __PKD_KEYUTIL_H__ 9 | 10 | #include "config.h" 11 | 12 | /* Server keys. */ 13 | #ifdef HAVE_DSA 14 | #define LIBSSH_DSA_TESTKEY "libssh_testkey.id_dsa" 15 | #endif 16 | #define LIBSSH_RSA_TESTKEY "libssh_testkey.id_rsa" 17 | #define LIBSSH_ED25519_TESTKEY "libssh_testkey.id_ed25519" 18 | #define LIBSSH_ECDSA_256_TESTKEY "libssh_testkey.id_ecdsa256" 19 | #define LIBSSH_ECDSA_384_TESTKEY "libssh_testkey.id_ecdsa384" 20 | #define LIBSSH_ECDSA_521_TESTKEY "libssh_testkey.id_ecdsa521" 21 | 22 | #ifdef HAVE_DSA 23 | void setup_dsa_key(void); 24 | #endif 25 | void setup_rsa_key(void); 26 | void setup_ed25519_key(void); 27 | void setup_ecdsa_keys(void); 28 | #ifdef HAVE_DSA 29 | void cleanup_dsa_key(void); 30 | #endif 31 | void cleanup_rsa_key(void); 32 | void cleanup_ed25519_key(void); 33 | void cleanup_ecdsa_keys(void); 34 | 35 | /* Client keys. */ 36 | #ifdef HAVE_DSA 37 | #define OPENSSH_DSA_TESTKEY "openssh_testkey.id_dsa" 38 | #endif 39 | #define OPENSSH_RSA_TESTKEY "openssh_testkey.id_rsa" 40 | #define OPENSSH_ECDSA256_TESTKEY "openssh_testkey.id_ecdsa256" 41 | #define OPENSSH_ECDSA384_TESTKEY "openssh_testkey.id_ecdsa384" 42 | #define OPENSSH_ECDSA521_TESTKEY "openssh_testkey.id_ecdsa521" 43 | #define OPENSSH_ED25519_TESTKEY "openssh_testkey.id_ed25519" 44 | #define OPENSSH_CA_TESTKEY "libssh_testkey.ca" 45 | 46 | #define DROPBEAR_RSA_TESTKEY "dropbear_testkey.id_rsa" 47 | 48 | void setup_openssh_client_keys(void); 49 | void cleanup_openssh_client_keys(void); 50 | 51 | void setup_dropbear_client_rsa_key(void); 52 | void cleanup_dropbear_client_rsa_key(void); 53 | 54 | #define cleanup_file(name) do {\ 55 | if (access((name), F_OK) != -1) {\ 56 | unlink((name));\ 57 | }} while (0) 58 | 59 | #define cleanup_key(name) do {\ 60 | cleanup_file((name));\ 61 | cleanup_file((name ".pub"));\ 62 | cleanup_file((name "-cert.pub"));\ 63 | } while (0) 64 | 65 | #endif /* __PKD_KEYUTIL_H__ */ 66 | -------------------------------------------------------------------------------- /src/libssh/tests/pkd/pkd_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pkd_keyutil.h -- 3 | * 4 | * (c) 2014 Jon Simons 5 | */ 6 | 7 | #ifndef __PKD_UTIL_H__ 8 | #define __PKD_UTIL_H__ 9 | 10 | int system_checked(const char *cmd); 11 | 12 | /* Is client 'X' enabled? */ 13 | int is_openssh_client_enabled(void); 14 | int is_dropbear_client_enabled(void); 15 | 16 | #endif /* __PKD_UTIL_H__ */ 17 | -------------------------------------------------------------------------------- /src/libssh/tests/server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(servertests C) 2 | 3 | if (WITH_SERVER AND UNIX AND NOT WIN32) 4 | 5 | find_package(socket_wrapper) 6 | 7 | add_subdirectory(test_server) 8 | 9 | set(LIBSSH_SERVER_TESTS 10 | torture_server 11 | torture_server_auth_kbdint 12 | torture_server_config 13 | ) 14 | 15 | include_directories(${libssh_SOURCE_DIR}/include 16 | ${libssh_BINARY_DIR}/include 17 | ${libssh_BINARY_DIR} 18 | test_server) 19 | 20 | if (ARGP_INCLUDE_DIR) 21 | include_directories(${ARGP_INCLUDE_DIR}) 22 | endif () 23 | 24 | foreach(_SRV_TEST ${LIBSSH_SERVER_TESTS}) 25 | add_cmocka_test(${_SRV_TEST} 26 | SOURCES ${_SRV_TEST}.c 27 | COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} 28 | LINK_LIBRARIES ${TORTURE_LIBRARY} testserver util 29 | ) 30 | 31 | if (OSX) 32 | set_property( 33 | TEST 34 | ${_SRV_TEST} 35 | PROPERTY 36 | ENVIRONMENT DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${SOCKET_WRAPPER_LIBRARY}) 37 | else () 38 | set_property( 39 | TEST 40 | ${_SRV_TEST} 41 | PROPERTY 42 | ENVIRONMENT ${TORTURE_ENVIRONMENT}) 43 | endif() 44 | endforeach() 45 | 46 | endif (WITH_SERVER AND UNIX AND NOT WIN32) 47 | -------------------------------------------------------------------------------- /src/libssh/tests/server/test_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_server C) 2 | 3 | if (WITH_SERVER AND UNIX AND NOT WIN32) 4 | 5 | find_package(socket_wrapper) 6 | 7 | set(server_SRCS 8 | main.c 9 | ) 10 | 11 | add_library(testserver STATIC 12 | test_server.c 13 | default_cb.c) 14 | 15 | set(LIBSSH_SERVER_TESTS 16 | # torture_server_kbdint 17 | ) 18 | 19 | include_directories(${libssh_SOURCE_DIR}/include 20 | ${libssh_BINARY_DIR}/include 21 | ${libssh_BINARY_DIR}) 22 | 23 | if (ARGP_INCLUDE_DIR) 24 | include_directories(${ARGP_INCLUDE_DIR}) 25 | endif () 26 | 27 | if (UNIX AND NOT WIN32) 28 | add_executable(test_server ${server_SRCS}) 29 | target_compile_options(test_server PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) 30 | target_link_libraries(test_server 31 | testserver 32 | ssh::ssh 33 | ${ARGP_LIBRARY} 34 | util) 35 | endif () 36 | 37 | endif (WITH_SERVER AND UNIX AND NOT WIN32) 38 | -------------------------------------------------------------------------------- /src/libssh/tests/server/test_server/test_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2018 by Red Hat, Inc. 5 | * 6 | * Author: Anderson Toshiyuki Sasaki 7 | * 8 | * The SSH Library is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * The SSH Library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with the SSH Library; see the file COPYING. If not, write to 20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 21 | * MA 02111-1307, USA. 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | struct server_state_st { 34 | /* Arguments */ 35 | char *address; 36 | int port; 37 | 38 | char *ecdsa_key; 39 | char *dsa_key; 40 | char *ed25519_key; 41 | char *rsa_key; 42 | char *host_key; 43 | 44 | int verbosity; 45 | int auth_methods; 46 | bool with_pcap; 47 | 48 | char *pcap_file; 49 | 50 | char *expected_username; 51 | char *expected_password; 52 | 53 | char *config_file; 54 | bool parse_global_config; 55 | 56 | /* State */ 57 | int max_tries; 58 | int error; 59 | 60 | struct ssh_server_callbacks_struct *server_cb; 61 | struct ssh_channel_callbacks_struct *channel_cb; 62 | 63 | /* Callback to handle the session, should block until disconnected */ 64 | void (*handle_session)(ssh_event event, 65 | ssh_session session, 66 | struct server_state_st *state); 67 | }; 68 | 69 | /*TODO: Add documentation */ 70 | void free_server_state(struct server_state_st *state); 71 | 72 | /*TODO: Add documentation */ 73 | int run_server(struct server_state_st *state); 74 | 75 | /*TODO: Add documentation */ 76 | pid_t fork_run_server(struct server_state_st *state); 77 | -------------------------------------------------------------------------------- /src/libssh/tests/ssh_ping.c: -------------------------------------------------------------------------------- 1 | /* ssh_ping.c */ 2 | /* 3 | Copyright 2018 Red Hat, Inc 4 | 5 | Author: Jakub Jelen 6 | 7 | This file is part of the SSH Library 8 | 9 | You are free to copy this file, modify it in any way, consider it being public 10 | domain. This does not apply to the rest of the library though, but it is 11 | allowed to cut-and-paste working code from this file to any license of 12 | program. 13 | The goal is to show the API in action. It's not a reference on how terminal 14 | clients must be made or how a client should react. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | int main(int argc, char **argv) 22 | { 23 | const char *banner = NULL; 24 | ssh_session session = NULL; 25 | int rc = 1; 26 | 27 | if (argc < 1 || argv[1] == NULL) { 28 | fprintf(stderr, "Error: Need an argument (hostname)\n"); 29 | goto out; 30 | } 31 | 32 | session = ssh_new(); 33 | if (session == NULL) { 34 | goto out; 35 | } 36 | 37 | rc = ssh_options_set(session, SSH_OPTIONS_HOST, argv[1]); 38 | if (rc < 0) { 39 | goto out; 40 | } 41 | 42 | /* The automatic username is not available under uid wrapper */ 43 | rc = ssh_options_set(session, SSH_OPTIONS_USER, "ping"); 44 | if (rc < 0) { 45 | goto out; 46 | } 47 | 48 | rc = ssh_connect(session); 49 | if (rc != SSH_OK) { 50 | fprintf(stderr, "Connection failed : %s\n", ssh_get_error(session)); 51 | goto out; 52 | } 53 | 54 | banner = ssh_get_serverbanner(session); 55 | if (banner == NULL) { 56 | fprintf(stderr, "Did not receive SSH banner\n"); 57 | goto out; 58 | } 59 | 60 | printf("OK: %s\n", banner); 61 | rc = 0; 62 | 63 | out: 64 | ssh_free(session); 65 | return rc; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/libssh/tests/test_exec.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed in public domain. You can do whatever you want 3 | with its content. 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include "tests.h" 9 | 10 | void do_connect(SSH_SESSION *session) { 11 | char buf[4096] = {0}; 12 | CHANNEL *channel; 13 | 14 | int error = ssh_connect(session); 15 | if (error != SSH_OK) { 16 | fprintf(stderr,"Error at connection: %s\n", ssh_get_error(session)); 17 | return; 18 | } 19 | printf("Connected\n"); 20 | 21 | ssh_session_is_known_server(session); 22 | 23 | error = authenticate(session); 24 | if(error != SSH_AUTH_SUCCESS) { 25 | fprintf(stderr,"Error at authentication: %s\n", ssh_get_error(session)); 26 | return; 27 | } 28 | printf("Authenticated\n"); 29 | channel = ssh_channel_new(session); 30 | ssh_channel_open_session(channel); 31 | printf("Execute 'ls' on the channel\n"); 32 | error = ssh_channel_request_exec(channel, "ls"); 33 | if(error != SSH_OK){ 34 | fprintf(stderr, "Error executing command: %s\n", ssh_get_error(session)); 35 | return; 36 | } 37 | printf("--------------------output----------------------\n"); 38 | while (ssh_channel_read(channel, buf, sizeof(buf), 0)) { 39 | printf("%s", buf); 40 | } 41 | printf("\n"); 42 | printf("---------------------end------------------------\n"); 43 | ssh_channel_send_eof(channel); 44 | fprintf(stderr, "Exit status: %d\n", ssh_channel_get_exit_status(channel)); 45 | 46 | printf("\nChannel test finished\n"); 47 | ssh_channel_close(channel); 48 | ssh_channel_free(channel); 49 | } 50 | 51 | int main(int argc, char **argv){ 52 | SSH_OPTIONS *options=set_opts(argc, argv); 53 | SSH_SESSION *session=ssh_new(); 54 | if(options==NULL){ 55 | return 1; 56 | } 57 | ssh_set_options(session,options); 58 | do_connect(session); 59 | ssh_disconnect(session); 60 | ssh_finalize(); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /src/libssh/tests/test_pcap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SSH Library 3 | * 4 | * Copyright (c) 2009 by Aris Adamantiadis 5 | * 6 | * The SSH Library is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2.1 of the License, or (at your 9 | * option) any later version. 10 | * 11 | * The SSH Library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with the SSH Library; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 19 | * MA 02111-1307, USA. 20 | */ 21 | 22 | /* Simple test for the pcap functions */ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | int main(int argc, char **argv){ 33 | ssh_pcap_file pcap; 34 | ssh_pcap_context ctx; 35 | ssh_buffer buffer=ssh_buffer_new(); 36 | char *str="Hello, this is a test string to test the capabilities of the" 37 | "pcap file writer."; 38 | printf("Simple pcap tester\n"); 39 | pcap=ssh_pcap_file_new(); 40 | if(ssh_pcap_file_open(pcap,"test.cap") != SSH_OK){ 41 | printf("error happened\n"); 42 | return EXIT_FAILURE; 43 | } 44 | buffer_add_data(buffer,str,strlen(str)); 45 | ctx=ssh_pcap_context_new(NULL); 46 | ssh_pcap_context_set_file(ctx,pcap); 47 | ssh_pcap_context_write(ctx,SSH_PCAP_DIR_OUT,str,strlen(str),strlen(str)); 48 | 49 | return EXIT_SUCCESS; 50 | } 51 | -------------------------------------------------------------------------------- /src/libssh/tests/test_tunnel.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed in public domain. You can do whatever you want 3 | with its content. 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include "tests.h" 9 | #define ECHO_PORT 7 10 | void do_connect(SSH_SESSION *session){ 11 | int error=ssh_connect(session); 12 | if(error != SSH_OK){ 13 | fprintf(stderr,"Error at connection :%s\n",ssh_get_error(session)); 14 | return; 15 | } 16 | printf("Connected\n"); 17 | ssh_session_is_known_server(session); 18 | // we don't care what happens here 19 | error=authenticate(session); 20 | if(error != SSH_AUTH_SUCCESS){ 21 | fprintf(stderr,"Error at authentication :%s\n",ssh_get_error(session)); 22 | return; 23 | } 24 | printf("Authenticated\n"); 25 | CHANNEL *channel=ssh_channel_new(session); 26 | error=ssh_channel_open_forward(channel,"localhost",ECHO_PORT,"localhost",42); 27 | if(error!=SSH_OK){ 28 | fprintf(stderr,"Error when opening forward:%s\n",ssh_get_error(session)); 29 | return; 30 | } 31 | printf("Forward opened\n"); 32 | int i=0; 33 | char string[20]; 34 | char buffer[20]; 35 | for(i=0;i<2000;++i){ 36 | sprintf(string,"%d\n",i); 37 | ssh_channel_write(channel,string,strlen(string)); 38 | do { 39 | error=ssh_channel_poll(channel,0); 40 | //if(error < strlen(string)) 41 | //usleep(10); 42 | } while(error < strlen(string) && error >= 0); 43 | if(error>0){ 44 | error=ssh_channel_read_nonblocking(channel,buffer,strlen(string),0); 45 | if(error>=0){ 46 | if(memcmp(buffer,string,strlen(string))!=0){ 47 | fprintf(stderr,"Problem with answer: wanted %s got %s\n",string,buffer); 48 | } else { 49 | printf("."); 50 | fflush(stdout); 51 | } 52 | } 53 | 54 | } 55 | if(error==-1){ 56 | fprintf(stderr,"Channel reading error : %s\n",ssh_get_error(session)); 57 | break; 58 | } 59 | } 60 | printf("\nChannel test finished\n"); 61 | ssh_channel_close(channel); 62 | ssh_channel_free(channel); 63 | } 64 | 65 | int main(int argc, char **argv){ 66 | SSH_OPTIONS *options=set_opts(argc, argv); 67 | SSH_SESSION *session=ssh_new(); 68 | if(options==NULL){ 69 | return 1; 70 | } 71 | ssh_set_options(session,options); 72 | do_connect(session); 73 | ssh_disconnect(session); 74 | ssh_finalize(); 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /src/libssh/tests/tests.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is distributed in public domain. You can do whatever you want 3 | with its content. 4 | */ 5 | #include 6 | int authenticate (SSH_SESSION *session); 7 | SSH_OPTIONS *set_opts(int argc, char **argv); 8 | 9 | -------------------------------------------------------------------------------- /src/libssh/tests/torture_cmocka.h: -------------------------------------------------------------------------------- 1 | /* 2 | * torture.c - torture library for testing libssh 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2018 by Andreas Schneider 7 | * 8 | * The SSH Library is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * The SSH Library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with the SSH Library; see the file COPYING. If not, write to 20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 21 | * MA 02111-1307, USA. 22 | */ 23 | 24 | #ifndef _TORTURE_CMOCKA_H 25 | #define _TORTURE_CMOCKA_H 26 | 27 | #include "libssh/session.h" 28 | 29 | void _assert_ssh_return_code(ssh_session session, 30 | int rc, 31 | const char * const file, 32 | const int line); 33 | 34 | #define assert_ssh_return_code(session, rc) \ 35 | _assert_ssh_return_code((session), (rc), __FILE__, __LINE__) 36 | 37 | void _assert_ssh_return_code_equal(ssh_session session, 38 | int rc, 39 | int expected_rc, 40 | const char * const file, 41 | const int line); 42 | 43 | #define assert_ssh_return_code_equal(session, rc, expected_rc) \ 44 | _assert_ssh_return_code_equal((session), (rc), (expected_rc), __FILE__, __LINE__) 45 | 46 | void _assert_ssh_return_code_not_equal(ssh_session session, 47 | int rc, 48 | int expected_rc, 49 | const char * const file, 50 | const int line); 51 | 52 | #define assert_ssh_return_code_not_equal(session, rc, unexpected_rc) \ 53 | _assert_ssh_return_code_not_equal((session), (rc), (unexpected_rc), __FILE__, __LINE__) 54 | 55 | #endif /* _TORTURE_CMOCKA_H */ 56 | -------------------------------------------------------------------------------- /src/libssh/tests/torture_key.h: -------------------------------------------------------------------------------- 1 | /* 2 | * torture_key.h - torture library for testing libssh 3 | * 4 | * This file is part of the SSH Library 5 | * 6 | * Copyright (c) 2008-2009 by Andreas Schneider 7 | * 8 | * The SSH Library is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * The SSH Library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | * License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with the SSH Library; see the file COPYING. If not, write to 20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 21 | * MA 02111-1307, USA. 22 | */ 23 | 24 | #ifndef _TORTURE_KEY_H 25 | #define _TORTURE_KEY_H 26 | 27 | #include 28 | 29 | #define TORTURE_TESTKEY_PASSWORD "libssh-rocks" 30 | 31 | /* Return the encrypted private key in a new OpenSSH format */ 32 | const char *torture_get_openssh_testkey(enum ssh_keytypes_e type, 33 | bool with_passphrase); 34 | 35 | /* Return the private key in the legacy PEM format */ 36 | const char *torture_get_testkey(enum ssh_keytypes_e type, 37 | bool with_passphrase); 38 | const char *torture_get_testkey_passphrase(void); 39 | 40 | const char *torture_get_testkey_pub(enum ssh_keytypes_e type); 41 | 42 | #endif /* _TORTURE_KEY_H */ 43 | -------------------------------------------------------------------------------- /src/libssh/tests/torture_pki.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef HAVE_UNISTD_H 11 | #include 12 | #elif (defined _WIN32) || (defined _WIN64) 13 | #include 14 | #define read _read 15 | #define open _open 16 | #define write _write 17 | #define close _close 18 | #endif 19 | 20 | #include "torture_pki.h" 21 | 22 | char *torture_pki_read_file(const char *filename) 23 | { 24 | char *key; 25 | int fd; 26 | int size; 27 | int rc; 28 | struct stat sb; 29 | 30 | if (filename == NULL || filename[0] == '\0') { 31 | return NULL; 32 | } 33 | 34 | fd = open(filename, O_RDONLY); 35 | if (fd < 0) { 36 | return NULL; 37 | } 38 | 39 | rc = fstat(fd, &sb); 40 | if (rc != 0) { 41 | close(fd); 42 | return NULL; 43 | } 44 | 45 | key = malloc(sb.st_size + 1); 46 | if (key == NULL) { 47 | close(fd); 48 | return NULL; 49 | } 50 | 51 | size = read(fd, key, sb.st_size); 52 | close(fd); 53 | if (size != sb.st_size) { 54 | free(key); 55 | return NULL; 56 | } 57 | 58 | key[size] = '\0'; 59 | return key; 60 | } 61 | 62 | int torture_read_one_line(const char *filename, char *buffer, size_t len) 63 | { 64 | FILE *fp; 65 | size_t nmemb; 66 | 67 | fp = fopen(filename, "r"); 68 | if (fp == NULL) { 69 | return -1; 70 | } 71 | 72 | nmemb = fread(buffer, len - 2, 1, fp); 73 | if (nmemb != 0 || ferror(fp)) { 74 | fclose(fp); 75 | return -1; 76 | } 77 | buffer[len - 1] = '\0'; 78 | 79 | fclose(fp); 80 | 81 | return 0; 82 | } 83 | 84 | /** 85 | * @internal 86 | * 87 | * Returns the character len of a public key string, omitting the comment part 88 | */ 89 | size_t torture_pubkey_len(const char *pubkey) 90 | { 91 | const char *ptr; 92 | 93 | ptr = strchr(pubkey, ' '); 94 | if (ptr != NULL) { 95 | ptr = strchr(ptr + 1, ' '); 96 | if (ptr != NULL) { 97 | return ptr - pubkey; 98 | } 99 | } 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /src/libssh/tests/torture_pki.h: -------------------------------------------------------------------------------- 1 | char *torture_pki_read_file(const char *filename); 2 | int torture_read_one_line(const char *filename, char *buffer, size_t len); 3 | size_t torture_pubkey_len(const char *pubkey); 4 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_channel.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #define LIBSSH_STATIC 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "torture.h" 11 | #include "channels.c" 12 | 13 | static void torture_channel_select(void **state) 14 | { 15 | fd_set readfds; 16 | int fd; 17 | int rc; 18 | int i; 19 | 20 | (void)state; /* unused */ 21 | 22 | ZERO_STRUCT(readfds); 23 | 24 | fd = open("/dev/null", 0); 25 | assert_true(fd > 2); 26 | 27 | FD_ZERO(&readfds); 28 | FD_SET(fd, &readfds); 29 | 30 | for (i = 0; i < 10; i++) { 31 | ssh_channel cin[1] = { NULL, }; 32 | ssh_channel cout[1] = { NULL, }; 33 | struct timeval tv = { .tv_sec = 0, .tv_usec = 1000 }; 34 | 35 | rc = ssh_select(cin, cout, fd + 1, &readfds, &tv); 36 | assert_int_equal(rc, SSH_OK); 37 | } 38 | 39 | close(fd); 40 | } 41 | 42 | int torture_run_tests(void) { 43 | int rc; 44 | struct CMUnitTest tests[] = { 45 | cmocka_unit_test(torture_channel_select), 46 | }; 47 | 48 | ssh_init(); 49 | torture_filter_tests(tests); 50 | rc = cmocka_run_group_tests(tests, NULL, NULL); 51 | ssh_finalize(); 52 | 53 | return rc; 54 | } 55 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_init.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #define LIBSSH_STATIC 4 | 5 | #include 6 | #include "torture.h" 7 | #include "libssh/libssh.h" 8 | 9 | static void torture_ssh_init(void **state) { 10 | int rc; 11 | 12 | (void) state; 13 | 14 | rc = ssh_init(); 15 | assert_int_equal(rc, SSH_OK); 16 | rc = ssh_finalize(); 17 | assert_int_equal(rc, SSH_OK); 18 | } 19 | 20 | static void torture_ssh_init_after_finalize(void **state) { 21 | 22 | int rc; 23 | 24 | (void) state; 25 | 26 | rc = ssh_init(); 27 | assert_int_equal(rc, SSH_OK); 28 | rc = ssh_finalize(); 29 | assert_int_equal(rc, SSH_OK); 30 | rc = ssh_init(); 31 | assert_int_equal(rc, SSH_OK); 32 | rc = ssh_finalize(); 33 | assert_int_equal(rc, SSH_OK); 34 | } 35 | 36 | static void torture_is_ssh_initialized(UNUSED_PARAM(void **state)) { 37 | 38 | int rc; 39 | bool initialized = false; 40 | 41 | /* Make sure the library is not initialized */ 42 | while (is_ssh_initialized()) { 43 | rc = ssh_finalize(); 44 | assert_return_code(rc, errno); 45 | } 46 | 47 | rc = ssh_init(); 48 | assert_return_code(rc, errno); 49 | initialized = is_ssh_initialized(); 50 | assert_true(initialized); 51 | rc = ssh_finalize(); 52 | assert_return_code(rc, errno); 53 | initialized = is_ssh_initialized(); 54 | assert_false(initialized); 55 | } 56 | 57 | int torture_run_tests(void) { 58 | int rc; 59 | struct CMUnitTest tests[] = { 60 | cmocka_unit_test(torture_ssh_init), 61 | cmocka_unit_test(torture_ssh_init_after_finalize), 62 | cmocka_unit_test(torture_is_ssh_initialized), 63 | }; 64 | 65 | torture_filter_tests(tests); 66 | rc = cmocka_run_group_tests(tests, NULL, NULL); 67 | 68 | return rc; 69 | } 70 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_isipaddr.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #define LIBSSH_STATIC 4 | 5 | #include "torture.h" 6 | 7 | #include "misc.c" 8 | #include "error.c" 9 | 10 | /* 11 | * Test the behavior of ssh_is_ipaddr() 12 | */ 13 | static void torture_ssh_is_ipaddr(void **state) 14 | { 15 | (void)state; 16 | 17 | assert_int_equal(ssh_is_ipaddr("127.0.0.1"),1); 18 | assert_int_equal(ssh_is_ipaddr("0.0.0.0"),1); 19 | assert_int_equal(ssh_is_ipaddr("1.1.1.1"),1); 20 | assert_int_equal(ssh_is_ipaddr("255.255.255.255"),1); 21 | assert_int_equal(ssh_is_ipaddr("128.128.128.128"),1); 22 | assert_int_equal(ssh_is_ipaddr("1.10.100.1"),1); 23 | assert_int_equal(ssh_is_ipaddr("0.1.10.100"),1); 24 | 25 | assert_int_equal(ssh_is_ipaddr("2001:0db8:85a3:0000:0000:8a2e:0370:7334"),1); 26 | assert_int_equal(ssh_is_ipaddr("fe80:0000:0000:0000:0202:b3ff:fe1e:8329"),1); 27 | assert_int_equal(ssh_is_ipaddr("fe80:0:0:0:202:b3ff:fe1e:8329"),1); 28 | assert_int_equal(ssh_is_ipaddr("fe80::202:b3ff:fe1e:8329"),1); 29 | assert_int_equal(ssh_is_ipaddr("::1"),1); 30 | 31 | assert_int_equal(ssh_is_ipaddr("::ffff:192.0.2.128"),1); 32 | 33 | assert_int_equal(ssh_is_ipaddr("0.0.0.0.0"),0); 34 | assert_int_equal(ssh_is_ipaddr("0.0.0.0.a"),0); 35 | assert_int_equal(ssh_is_ipaddr("a.0.0.0"),0); 36 | assert_int_equal(ssh_is_ipaddr("0a.0.0.0.0"),0); 37 | assert_int_equal(ssh_is_ipaddr(""),0); 38 | assert_int_equal(ssh_is_ipaddr("0.0.0."),0); 39 | assert_int_equal(ssh_is_ipaddr("0.0"),0); 40 | assert_int_equal(ssh_is_ipaddr("0"),0); 41 | 42 | /* 43 | * FIXME: Temporary workaround for Wine bug 44 | */ 45 | #ifndef _WIN32 46 | assert_int_equal(ssh_is_ipaddr("255.255.255"),0); 47 | #endif 48 | 49 | assert_int_equal(ssh_is_ipaddr("2001:0db8:85a3:0000:0000:8a2e:0370:7334:1002"), 0); 50 | assert_int_equal(ssh_is_ipaddr("fe80:x:202:b3ff:fe1e:8329"), 0); 51 | assert_int_equal(ssh_is_ipaddr("fe80:x:202:b3ff:fe1e:8329"), 0); 52 | assert_int_equal(ssh_is_ipaddr(":1"), 0); 53 | } 54 | 55 | int torture_run_tests(void) { 56 | int rc; 57 | struct CMUnitTest tests[] = { 58 | cmocka_unit_test(torture_ssh_is_ipaddr) 59 | }; 60 | 61 | ssh_init(); 62 | torture_filter_tests(tests); 63 | rc = cmocka_run_group_tests(tests, NULL, NULL); 64 | ssh_finalize(); 65 | return rc; 66 | } 67 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_push_pop_dir.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include "torture.h" 4 | #define LIBSSH_STATIC 5 | 6 | const char template[] = "temp_dir_XXXXXX"; 7 | 8 | static int setup(void **state) 9 | { 10 | char *temp_dir = NULL; 11 | 12 | temp_dir = torture_make_temp_dir(template); 13 | assert_non_null(temp_dir); 14 | 15 | *state = (void *)temp_dir; 16 | 17 | return 0; 18 | } 19 | 20 | static int teardown(void **state) 21 | { 22 | char *temp_dir = *((char **)state); 23 | 24 | torture_rmdirs((const char *)temp_dir); 25 | 26 | free(temp_dir); 27 | 28 | return 0; 29 | } 30 | 31 | static void torture_back_and_forth(void **state) 32 | { 33 | char *temp_dir = *((char **)state); 34 | char *cwd = NULL; 35 | char *after_change = NULL; 36 | char *after_changing_back = NULL; 37 | int rc = 0; 38 | 39 | cwd = torture_get_current_working_dir(); 40 | assert_non_null(cwd); 41 | 42 | printf("Current dir: %s\n", cwd); 43 | 44 | rc = torture_change_dir(temp_dir); 45 | assert_int_equal(rc, 0); 46 | 47 | after_change = torture_get_current_working_dir(); 48 | assert_non_null(after_change); 49 | 50 | printf("Current dir after change: %s\n", after_change); 51 | 52 | rc = torture_change_dir(cwd); 53 | assert_int_equal(rc, 0); 54 | 55 | after_changing_back = torture_get_current_working_dir(); 56 | assert_non_null(after_changing_back); 57 | 58 | printf("Back to dir: %s\n", after_changing_back); 59 | 60 | SAFE_FREE(cwd); 61 | SAFE_FREE(after_change); 62 | SAFE_FREE(after_changing_back); 63 | } 64 | 65 | int torture_run_tests(void) 66 | { 67 | int rc; 68 | struct CMUnitTest tests[] = { 69 | cmocka_unit_test_setup_teardown(torture_back_and_forth, 70 | setup, teardown), 71 | }; 72 | 73 | torture_filter_tests(tests); 74 | rc = cmocka_run_group_tests(tests, NULL, NULL); 75 | 76 | return rc; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_rand.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #define LIBSSH_STATIC 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "torture.h" 9 | 10 | #ifdef HAVE_LIBGCRYPT 11 | #define NUM_LOOPS 1000 12 | #else 13 | /* openssl is much faster */ 14 | #define NUM_LOOPS 20000 15 | #endif 16 | #define NUM_THREADS 100 17 | 18 | static int setup(void **state) { 19 | int rc; 20 | 21 | (void) state; 22 | 23 | ssh_threads_set_callbacks(ssh_threads_get_pthread()); 24 | rc = ssh_init(); 25 | if (rc != SSH_OK) { 26 | return -1; 27 | } 28 | 29 | return 0; 30 | } 31 | 32 | static int teardown(void **state) { 33 | (void) state; 34 | 35 | ssh_finalize(); 36 | 37 | return 0; 38 | } 39 | 40 | static void *torture_rand_thread(void *threadid) { 41 | char buffer[12]; 42 | int i; 43 | int ok; 44 | 45 | (void) threadid; 46 | 47 | buffer[0] = buffer[1] = buffer[10] = buffer[11] = 'X'; 48 | for(i = 0; i < NUM_LOOPS; ++i) { 49 | ok = ssh_get_random(&buffer[2], i % 8 + 1, 0); 50 | assert_true(ok); 51 | } 52 | 53 | pthread_exit(NULL); 54 | } 55 | 56 | static void torture_rand_threading(void **state) { 57 | pthread_t threads[NUM_THREADS]; 58 | int i; 59 | int err; 60 | 61 | (void) state; 62 | 63 | for(i = 0; i < NUM_THREADS; ++i) { 64 | err = pthread_create(&threads[i], NULL, torture_rand_thread, NULL); 65 | assert_int_equal(err, 0); 66 | } 67 | for(i = 0; i < NUM_THREADS; ++i) { 68 | err=pthread_join(threads[i], NULL); 69 | assert_int_equal(err, 0); 70 | } 71 | } 72 | 73 | int torture_run_tests(void) { 74 | int rc; 75 | struct CMUnitTest tests[] = { 76 | cmocka_unit_test_setup_teardown(torture_rand_threading, setup, teardown), 77 | }; 78 | 79 | torture_filter_tests(tests); 80 | rc = cmocka_run_group_tests(tests, NULL, NULL); 81 | 82 | return rc; 83 | } 84 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_temp_dir.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include "torture.h" 4 | #define LIBSSH_STATIC 5 | 6 | const char template[] = "temp_dir_XXXXXX"; 7 | 8 | static int setup(void **state) 9 | { 10 | char *temp_dir = NULL; 11 | 12 | temp_dir = torture_make_temp_dir(template); 13 | assert_non_null(temp_dir); 14 | 15 | *state = (void *)temp_dir; 16 | 17 | return 0; 18 | } 19 | 20 | static int teardown(void **state) 21 | { 22 | char *temp_dir = *((char **)state); 23 | 24 | torture_rmdirs((const char *)temp_dir); 25 | 26 | free(temp_dir); 27 | 28 | return 0; 29 | } 30 | 31 | 32 | static void torture_create_temp_dir(void **state) 33 | { 34 | char *temp_dir = *((char **)state); 35 | 36 | printf("Created temp dir: %s\n", temp_dir); 37 | } 38 | 39 | int torture_run_tests(void) 40 | { 41 | int rc; 42 | struct CMUnitTest tests[] = { 43 | cmocka_unit_test_setup_teardown(torture_create_temp_dir, setup, teardown), 44 | }; 45 | 46 | torture_filter_tests(tests); 47 | rc = cmocka_run_group_tests(tests, NULL, NULL); 48 | 49 | return rc; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/libssh/tests/unittests/torture_temp_file.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include "torture.h" 4 | #define LIBSSH_STATIC 5 | 6 | const char template[] = "temp_file_XXXXXX"; 7 | 8 | static int setup(void **state) 9 | { 10 | char *file_name = NULL; 11 | 12 | file_name = torture_create_temp_file(template); 13 | assert_non_null(file_name); 14 | 15 | *state = (void *)file_name; 16 | 17 | return 0; 18 | } 19 | 20 | static int teardown(void **state) 21 | { 22 | int rc; 23 | char *file_name = *((char **)state); 24 | 25 | assert_non_null(file_name); 26 | 27 | rc = unlink(file_name); 28 | assert_int_equal(rc, 0); 29 | 30 | SAFE_FREE(file_name); 31 | 32 | return 0; 33 | } 34 | 35 | 36 | static void torture_temp_file(void **state) 37 | { 38 | char *file_name = *((char **)state); 39 | FILE *fp = NULL; 40 | 41 | assert_non_null(file_name); 42 | 43 | fp = fopen(file_name, "r"); 44 | assert_non_null(fp); 45 | 46 | fclose(fp); 47 | 48 | printf("Created temp file: %s\n", file_name); 49 | } 50 | 51 | int torture_run_tests(void) 52 | { 53 | int rc; 54 | struct CMUnitTest tests[] = { 55 | cmocka_unit_test_setup_teardown(torture_temp_file, setup, teardown), 56 | }; 57 | 58 | torture_filter_tests(tests); 59 | rc = cmocka_run_group_tests(tests, NULL, NULL); 60 | 61 | return rc; 62 | } 63 | 64 | --------------------------------------------------------------------------------