mirror of
https://github.com/libssh2/libssh2.git
synced 2026-01-06 14:21:57 +03:00
tidy-up: drop duplicate newlines, fix non-ASCII chars, other formatting, check in CI
Closes #1766
This commit is contained in:
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -87,6 +87,9 @@ jobs:
|
||||
shellcheck --version
|
||||
ci/shellcheck.sh
|
||||
|
||||
- name: 'spacecheck'
|
||||
run: ci/spacecheck.pl
|
||||
|
||||
- name: 'cmakelint'
|
||||
run: |
|
||||
source ~/venv/bin/activate
|
||||
|
||||
@@ -6,4 +6,4 @@ Redistribution and use in source and binary forms, with or without modification,
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -767,7 +767,6 @@ AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
|
||||
esac
|
||||
])
|
||||
|
||||
|
||||
dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
|
||||
dnl -------------------------------------------------
|
||||
dnl This macro ensures that configuration tests done
|
||||
@@ -787,7 +786,6 @@ cat >>confdefs.h <<_EOF
|
||||
_EOF
|
||||
])
|
||||
|
||||
|
||||
dnl CURL_CONFIGURE_REENTRANT
|
||||
dnl -------------------------------------------------
|
||||
dnl This first checks if the preprocessor _REENTRANT
|
||||
@@ -931,7 +929,6 @@ m4_case([$1],
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl LIBSSH2_CHECK_OPTION_WERROR
|
||||
dnl -------------------------------------------------
|
||||
dnl Verify if configure has been invoked with option
|
||||
|
||||
@@ -1165,7 +1165,6 @@ sub scanfile {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($errors || $warnings || $verbose) {
|
||||
printf "checksrc: %d errors and %d warnings\n", $errors, $warnings;
|
||||
if($suppressed) {
|
||||
|
||||
177
ci/spacecheck.pl
Executable file
177
ci/spacecheck.pl
Executable file
@@ -0,0 +1,177 @@
|
||||
#!/usr/bin/env perl
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) Viktor Szakats
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @tabs = (
|
||||
"Makefile\\.[a-z]+\$",
|
||||
"m4/lib-.+\\.m4\$",
|
||||
);
|
||||
|
||||
my @mixed_eol = (
|
||||
);
|
||||
|
||||
my @need_crlf = (
|
||||
);
|
||||
|
||||
my @double_empty_lines = (
|
||||
);
|
||||
|
||||
my @non_ascii = (
|
||||
"AUTHORS",
|
||||
"RELEASE-NOTES",
|
||||
);
|
||||
|
||||
sub fn_match {
|
||||
my ($filename, @masklist) = @_;
|
||||
|
||||
foreach my $mask (@masklist) {
|
||||
if($filename =~ $mask) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub eol_detect {
|
||||
my ($content) = @_;
|
||||
|
||||
my $cr = () = $content =~ /\r/g;
|
||||
my $lf = () = $content =~ /\n/g;
|
||||
|
||||
if($cr > 0 && $lf == 0) {
|
||||
return "cr";
|
||||
}
|
||||
elsif($cr == 0 && $lf > 0) {
|
||||
return "lf";
|
||||
}
|
||||
elsif($cr == 0 && $lf == 0) {
|
||||
return "bin";
|
||||
}
|
||||
elsif($cr == $lf) {
|
||||
return "crlf";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
my $issues = 0;
|
||||
|
||||
open(my $git_ls_files, '-|', 'git ls-files') or die "Failed running git ls-files: $!";
|
||||
while(my $filename = <$git_ls_files>) {
|
||||
chomp $filename;
|
||||
|
||||
open(my $fh, '<', $filename) or die "Cannot open '$filename': $!";
|
||||
my $content = do { local $/; <$fh> };
|
||||
close $fh;
|
||||
|
||||
my @err = ();
|
||||
|
||||
if(!fn_match($filename, @tabs) &&
|
||||
$content =~ /\t/) {
|
||||
push @err, "content: has tab";
|
||||
}
|
||||
|
||||
my $eol = eol_detect($content);
|
||||
|
||||
if($eol eq "") {
|
||||
push @err, "content: has mixed EOL types";
|
||||
}
|
||||
|
||||
if($eol ne "crlf" &&
|
||||
fn_match($filename, @need_crlf)) {
|
||||
push @err, "content: must use CRLF EOL for this file type";
|
||||
}
|
||||
|
||||
if($eol ne "lf" && $content ne "" &&
|
||||
!fn_match($filename, @need_crlf)) {
|
||||
push @err, "content: must use LF EOL for this file type";
|
||||
}
|
||||
|
||||
if($content =~ /[ \t]\n/) {
|
||||
my $line;
|
||||
for my $l (split(/\n/, $content)) {
|
||||
$line++;
|
||||
if($l =~ /[ \t]$/) {
|
||||
push @err, "line $line: trailing whitespace";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($content ne "" &&
|
||||
$content !~ /\n\z/) {
|
||||
push @err, "content: has no EOL at EOF";
|
||||
}
|
||||
|
||||
if($content =~ /\n\n\z/ ||
|
||||
$content =~ /\r\n\r\n\z/) {
|
||||
push @err, "content: has multiple EOL at EOF";
|
||||
}
|
||||
|
||||
if($content =~ /\n\n\n\n/ ||
|
||||
$content =~ /\r\n\r\n\r\n\r\n/) {
|
||||
push @err, "content: has 3 or more consecutive empty lines";
|
||||
}
|
||||
|
||||
if(!fn_match($filename, @double_empty_lines)) {
|
||||
if($content =~ /\n\n\n/ ||
|
||||
$content =~ /\r\n\r\n\r\n/) {
|
||||
push @err, "content: has 2 consecutive empty lines";
|
||||
}
|
||||
}
|
||||
|
||||
if($content =~ /([\x00-\x08\x0b\x0c\x0e-\x1f\x7f])/) {
|
||||
push @err, "content: has binary contents";
|
||||
}
|
||||
|
||||
if(!fn_match($filename, @non_ascii) &&
|
||||
($content =~ /([\x80-\xff]+)/)) {
|
||||
my $non = $1;
|
||||
my $hex;
|
||||
for my $e (split(//, $non)) {
|
||||
$hex .= sprintf("%s%02x", $hex ? " ": "", ord($e));
|
||||
}
|
||||
my $line;
|
||||
for my $l (split(/\n/, $content)) {
|
||||
$line++;
|
||||
if($l =~ /([\x80-\xff]+)/) {
|
||||
push @err, "line $line: has non-ASCII: '$non' ($hex)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(@err) {
|
||||
$issues++;
|
||||
foreach my $err (@err) {
|
||||
print "$filename: $err\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
close $git_ls_files;
|
||||
|
||||
if($issues) {
|
||||
exit 1;
|
||||
}
|
||||
@@ -334,7 +334,6 @@ esac], [build_examples='yes'])
|
||||
AC_MSG_RESULT($build_examples)
|
||||
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
|
||||
|
||||
|
||||
# Build OSS fuzzing targets?
|
||||
AC_ARG_ENABLE([ossfuzzers],
|
||||
[AS_HELP_STRING([--enable-ossfuzzers],
|
||||
@@ -342,13 +341,11 @@ AC_ARG_ENABLE([ossfuzzers],
|
||||
[have_ossfuzzers=yes], [have_ossfuzzers=no])
|
||||
AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$have_ossfuzzers" = "xyes"])
|
||||
|
||||
|
||||
# Set the correct flags for the given fuzzing engine.
|
||||
AC_SUBST([LIB_FUZZING_ENGINE])
|
||||
AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"])
|
||||
AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"])
|
||||
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h unistd.h sys/uio.h])
|
||||
AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h])
|
||||
|
||||
@@ -12,7 +12,6 @@ This document lists the entities that must/may be defined in the header file.
|
||||
Procedures listed as "void" may indeed have a result type: the void indication
|
||||
indicates the libssh2 core modules never use the function result.
|
||||
|
||||
|
||||
0) Build system.
|
||||
|
||||
Adding a crypto backend to the autotools build system (./configure) is easy:
|
||||
@@ -80,7 +79,6 @@ Must return 1 for success and 0 for failure.
|
||||
void _libssh2_hmac_cleanup(libssh2_hmac_ctx *ctx);
|
||||
Releases the HMAC computation context at ctx.
|
||||
|
||||
|
||||
3) Hash algorithms.
|
||||
|
||||
3.1) SHA-1
|
||||
@@ -303,7 +301,6 @@ Setup the HMAC computation context ctx for an HMAC-RIPEMD-160 computation using
|
||||
the keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
Returns 1 for success and 0 for failure.
|
||||
|
||||
|
||||
4) Bidirectional key ciphers.
|
||||
|
||||
_libssh2_cipher_ctx
|
||||
@@ -409,7 +406,6 @@ _libssh2_cipher_3des
|
||||
TripleDES-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
|
||||
5) Diffie-Hellman support.
|
||||
|
||||
LIBSSH2_DH_GEX_MINGROUP
|
||||
@@ -456,7 +452,6 @@ context creation. The result is stored in `secret'.
|
||||
void libssh2_dh_dtor(_libssh2_dh_ctx *dhctx)
|
||||
Destroys Diffie-Hellman context at `dhctx' and resets its storage.
|
||||
|
||||
|
||||
6) Big numbers.
|
||||
Positive multi-byte integers support is sufficient.
|
||||
|
||||
@@ -514,7 +509,6 @@ Converts the absolute value of bn into big-endian form and store it at
|
||||
val. val must point to _libssh2_bn_bytes(bn) bytes of memory.
|
||||
Returns the length of the big-endian number.
|
||||
|
||||
|
||||
7) Private key algorithms.
|
||||
Format of an RSA public key:
|
||||
a) "ssh-rsa".
|
||||
@@ -570,7 +564,6 @@ Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
|
||||
7.1) RSA
|
||||
LIBSSH2_RSA
|
||||
#define as 1 if the crypto library supports RSA, else 0.
|
||||
@@ -717,7 +710,6 @@ LIBSSH2_DSA
|
||||
#define as 1 if the crypto library supports DSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
|
||||
libssh2_dsa_ctx
|
||||
Type of a DSA computation context. Generally a struct.
|
||||
|
||||
@@ -777,7 +769,6 @@ This procedure is already prototyped in crypto.h.
|
||||
void _libssh2_dsa_free(libssh2_dsa_ctx *dsactx);
|
||||
Releases the DSA computation context at dsactx.
|
||||
|
||||
|
||||
7.3) ECDSA
|
||||
LIBSSH2_ECDSA
|
||||
#define as 1 if the crypto library supports ECDSA, else 0.
|
||||
@@ -883,13 +874,11 @@ This procedure is already prototyped in crypto.h.
|
||||
void _libssh2_ecdsa_free(libssh2_ecdsa_ctx *ecdsactx);
|
||||
Releases the ECDSA computation context at ecdsactx.
|
||||
|
||||
|
||||
7.4) ED25519
|
||||
LIBSSH2_ED25519
|
||||
#define as 1 if the crypto library supports ED25519, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
|
||||
libssh2_ed25519_ctx
|
||||
Type of an ED25519 computation context. Generally a struct.
|
||||
|
||||
@@ -962,7 +951,6 @@ This procedure is already prototyped in crypto.h.
|
||||
void _libssh2_ed25519_free(libssh2_ed25519_ctx *ed25519ctx);
|
||||
Releases the ED25519 computation context at ed25519ctx.
|
||||
|
||||
|
||||
8) Miscellaneous
|
||||
|
||||
void libssh2_prepare_iovec(struct iovec *vector, unsigned int len);
|
||||
|
||||
@@ -78,7 +78,6 @@ static void remove_node(struct chan_X11_list *elem)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void session_shutdown(LIBSSH2_SESSION *session)
|
||||
{
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This is a true OS/400 implementation, not a PASE implementation (for PASE,
|
||||
@@ -21,7 +20,6 @@ transcoding procedures may be used.
|
||||
Crypto API is provided by the IBM QC3 API library. It supports RSA and EC,
|
||||
but not DSA.
|
||||
|
||||
|
||||
Standard compilation environment does support neither autotools nor make;
|
||||
in fact, very few common utilities are available. As a consequence, the
|
||||
libssh2_config.h has been coded manually and the compilation scripts are
|
||||
@@ -29,8 +27,6 @@ a set of shell scripts stored in subdirectory os400.
|
||||
|
||||
The test environment is currently not supported on OS/400.
|
||||
|
||||
|
||||
|
||||
Compiling on OS/400:
|
||||
|
||||
These instructions target people who knows about OS/400, compiling, IFS and
|
||||
@@ -82,8 +78,6 @@ _ Source file LIBSSH2RPG. It contains all the ILE/RPG /INCLUDE members
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file LIBSSH2RPG. These are
|
||||
ILE/RPG translations of the corresponding C header files.
|
||||
|
||||
|
||||
|
||||
Special programming consideration:
|
||||
|
||||
QADRT being used, the following points must be considered:
|
||||
@@ -98,8 +92,6 @@ _ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
|
||||
_ Do not use original source include files unless you know what you are doing.
|
||||
Use the installed members instead (in /QSYS.LIB/LIBSSH2.LIB/H.FILE).
|
||||
|
||||
|
||||
|
||||
String transcoding support:
|
||||
|
||||
To help passing arbitrarily encoded string arguments and/or receiving string
|
||||
@@ -157,8 +149,6 @@ in case of error.
|
||||
|
||||
Please take care to never mix different sessions into the same cache.
|
||||
|
||||
|
||||
|
||||
ILE/RPG support:
|
||||
|
||||
Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
#define CCSID_UTF8 1208
|
||||
#define CCSID_UTF16BE 13488
|
||||
#define STRING_GRANULE 256
|
||||
@@ -64,18 +62,14 @@
|
||||
realloc((p), (sz)))
|
||||
#define FREE(s, p) ((s)? LIBSSH2_FREE((s), (p)): free(p))
|
||||
|
||||
|
||||
struct _libssh2_string_cache {
|
||||
libssh2_string_cache * next;
|
||||
char string[1];
|
||||
};
|
||||
|
||||
|
||||
static const QtqCode_T utf8code = { CCSID_UTF8 };
|
||||
|
||||
|
||||
static ssize_t
|
||||
terminator_size(unsigned short ccsid)
|
||||
static ssize_t terminator_size(unsigned short ccsid)
|
||||
{
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
|
||||
@@ -11,7 +11,6 @@ setenv()
|
||||
export "${1?}"
|
||||
}
|
||||
|
||||
|
||||
case "${SCRIPTDIR}" in
|
||||
/*) ;;
|
||||
*) SCRIPTDIR="$(pwd)/${SCRIPTDIR}"
|
||||
@@ -75,7 +74,6 @@ export LIBSSH2_VERSION_NUM LIBSSH2_TIMESTAMP
|
||||
|
||||
LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Procedures.
|
||||
@@ -99,7 +97,6 @@ action_needed()
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
# canonicalize_path path
|
||||
#
|
||||
# Return canonicalized path as:
|
||||
@@ -134,7 +131,6 @@ canonicalize_path()
|
||||
echo "/$(expr "${R}" : '^\(.*\)/')"
|
||||
}
|
||||
|
||||
|
||||
# make_module module_name source_name [additional_definitions]
|
||||
#
|
||||
# Compile source name into ASCII module if needed.
|
||||
@@ -199,7 +195,6 @@ make_module()
|
||||
LINK=YES
|
||||
}
|
||||
|
||||
|
||||
# Determine DB2 object name from IFS name.
|
||||
|
||||
db2_name()
|
||||
@@ -217,7 +212,6 @@ db2_name()
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Copy stream replacing version info.
|
||||
|
||||
versioned_copy()
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
|
||||
typedef struct _libssh2_string_cache libssh2_string_cache;
|
||||
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_from_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
|
||||
@@ -204,7 +204,6 @@
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
/* Remap zlib procedures to ASCII versions. */
|
||||
#pragma map(inflateInit_, "_libssh2_os400_inflateInit_")
|
||||
|
||||
@@ -1602,7 +1602,6 @@
|
||||
d typemask value like(libssh2_Cint)
|
||||
d store * libssh2_knownhost *
|
||||
|
||||
|
||||
* libssh2_knownhost_check
|
||||
*
|
||||
* Check a host and its associated key against the collection of known
|
||||
|
||||
@@ -9,7 +9,6 @@ SCRIPTDIR=$(dirname "${0}")
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/include" || exit 1
|
||||
|
||||
|
||||
# Create the OS/400 source program file for the header files.
|
||||
|
||||
SRCPF="${LIBIFSNAME}/H.FILE"
|
||||
@@ -20,7 +19,6 @@ then CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Create the IFS directory for the header files.
|
||||
|
||||
IFSINCLUDE="${IFSDIR}/include"
|
||||
@@ -29,7 +27,6 @@ if action_needed "${IFSINCLUDE}"
|
||||
then mkdir -p "${IFSINCLUDE}"
|
||||
fi
|
||||
|
||||
|
||||
copy_hfile()
|
||||
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@ SCRIPTDIR=$(dirname "${0}")
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/os400/libssh2rpg" || exit 1
|
||||
|
||||
|
||||
# Create the OS/400 source program file for the ILE/RPG header files.
|
||||
|
||||
SRCPF="${LIBIFSNAME}/LIBSSH2RPG.FILE"
|
||||
@@ -20,7 +19,6 @@ then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBSSH2RPG) RCDLEN(112)"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Map file names to DB2 name syntax.
|
||||
|
||||
for HFILE in *.rpgle *.rpgle.in
|
||||
@@ -37,7 +35,6 @@ done > tmpsubstfile1
|
||||
|
||||
sort -r tmpsubstfile1 | sed 's/^[^ ]*[ ]*//' > tmpsubstfile2
|
||||
|
||||
|
||||
change_include()
|
||||
|
||||
{
|
||||
@@ -49,7 +46,6 @@ change_include()
|
||||
-e '}'
|
||||
}
|
||||
|
||||
|
||||
# Create the IFS directory for the ILE/RPG header files.
|
||||
|
||||
RPGIFSDIR="${IFSDIR}/include/libssh2rpg"
|
||||
|
||||
@@ -9,7 +9,6 @@ SCRIPTDIR=$(dirname "${0}")
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/src" || exit 1
|
||||
|
||||
|
||||
# Function to extract external prototypes from header files.
|
||||
# Input: concatenated header files.
|
||||
# Output: external prototypes, one per (long) line.
|
||||
@@ -45,7 +44,6 @@ then rm -f modasa.mih
|
||||
ln -s '/QSYS.LIB/QSYSINC.LIB/MIH.FILE/MODASA.MBR' modasa.mih
|
||||
fi
|
||||
|
||||
|
||||
# Create and compile the identification source file.
|
||||
|
||||
{
|
||||
@@ -58,7 +56,6 @@ make_module OS400 os400.c
|
||||
LINK= # No need to rebuild service program yet.
|
||||
MODULES=
|
||||
|
||||
|
||||
# Generate the procedures implementing macros.
|
||||
|
||||
if action_needed macros.c "${TOPDIR}/os400/macros.h"
|
||||
@@ -95,7 +92,6 @@ sed -e ':begin' \
|
||||
< Makefile.inc > tmpscript.sh
|
||||
. ./tmpscript.sh
|
||||
|
||||
|
||||
# Compile the sources into modules.
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
@@ -107,7 +103,6 @@ do MODULE=$(db2_name "${SRC}")
|
||||
make_module "${MODULE}" "${SRC}"
|
||||
done
|
||||
|
||||
|
||||
# If needed, (re)create the static binding directory.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
||||
@@ -134,7 +129,6 @@ then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# The exportation file for service program creation must be in a DB2
|
||||
# source file, so make sure it exists.
|
||||
|
||||
@@ -144,7 +138,6 @@ then CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Gather the list of symbols to export.
|
||||
|
||||
EXPORTS=$(cat "${TOPDIR}"/include/*.h "${TOPDIR}/os400/macros.h" \
|
||||
@@ -170,7 +163,6 @@ then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBSSH2_${SONAME}')" \
|
||||
echo ' ENDPGMEXP' >> "${BSF}"
|
||||
fi
|
||||
|
||||
|
||||
# Build the service program if needed.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
|
||||
@@ -194,7 +186,6 @@ then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
|
||||
LINK=YES
|
||||
fi
|
||||
|
||||
|
||||
# If needed, (re)create the dynamic binding directory.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
||||
|
||||
@@ -11,26 +11,20 @@ SCRIPTDIR=$(dirname "${0}")
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}" || exit 1
|
||||
|
||||
|
||||
# Create the OS/400 library if it does not exist.
|
||||
|
||||
if action_needed "${LIBIFSNAME}"
|
||||
then CMD="CRTLIB LIB(${TARGETLIB}) TEXT('libssh2: SSH2 protocol API')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Create the DOCS source file if it does not exist.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/DOCS.FILE"
|
||||
then CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(240)"
|
||||
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Copy some documentation files if needed.
|
||||
|
||||
for TEXT in "${TOPDIR}/COPYING" "${SCRIPTDIR}/README400" \
|
||||
"${TOPDIR}/NEWS" "${TOPDIR}/README" "${TOPDIR}/docs/AUTHORS" \
|
||||
"${TOPDIR}/docs/BINDINGS.md"
|
||||
@@ -43,18 +37,14 @@ do MEMBER="${LIBIFSNAME}/DOCS.FILE/$(db2_name "${TEXT}").MBR"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Create the RPGXAMPLES source file if it does not exist.
|
||||
|
||||
if action_needed "${LIBIFSNAME}/RPGXAMPLES.FILE"
|
||||
then CMD="CRTSRCPF FILE(${TARGETLIB}/RPGXAMPLES) RCDLEN(240)"
|
||||
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ILE/RPG examples')"
|
||||
system "${CMD}"
|
||||
fi
|
||||
|
||||
|
||||
# Copy RPG examples if needed.
|
||||
|
||||
for EXAMPLE in "${SCRIPTDIR}/rpg-examples"/*
|
||||
do MEMBER="$(basename "${EXAMPLE}")"
|
||||
IFSMEMBER="${LIBIFSNAME}/RPGXAMPLES.FILE/$(db2_name "${MEMBER}").MBR"
|
||||
@@ -73,9 +63,7 @@ do MEMBER="$(basename "${EXAMPLE}")"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Build in each directory.
|
||||
|
||||
for SUBDIR in include rpg src
|
||||
do "${SCRIPTDIR}/make-${SUBDIR}.sh"
|
||||
done
|
||||
|
||||
@@ -65,7 +65,6 @@
|
||||
# include <zlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
*** QADRT OS/400 ASCII runtime defines only the most used procedures, but
|
||||
*** a lot of them are not supported. This module implements
|
||||
@@ -75,7 +74,6 @@
|
||||
|
||||
#pragma convert(37) /* Restore EBCDIC. */
|
||||
|
||||
|
||||
static int
|
||||
convert_sockaddr(struct sockaddr_storage *dstaddr,
|
||||
const struct sockaddr *srcaddr, int srclen)
|
||||
@@ -112,7 +110,6 @@ convert_sockaddr(struct sockaddr_storage *dstaddr,
|
||||
return srclen;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_libssh2_os400_connect(int sd, struct sockaddr *destaddr, int addrlen)
|
||||
{
|
||||
@@ -127,7 +124,6 @@ _libssh2_os400_connect(int sd, struct sockaddr *destaddr, int addrlen)
|
||||
return connect(sd, (struct sockaddr *) &laddr, i);
|
||||
}
|
||||
|
||||
|
||||
#ifdef LIBSSH2_HAVE_ZLIB
|
||||
int
|
||||
_libssh2_os400_inflateInit_(z_streamp strm,
|
||||
|
||||
@@ -30,4 +30,3 @@ void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m,
|
||||
u_char *c, u_int bytes);
|
||||
|
||||
#endif /* CHACHA_H */
|
||||
|
||||
|
||||
@@ -1516,7 +1516,6 @@ libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel, int single_connection,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* _libssh2_channel_process_startup
|
||||
*
|
||||
@@ -1647,7 +1646,6 @@ libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* libssh2_channel_set_blocking
|
||||
*
|
||||
@@ -2056,7 +2054,6 @@ libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* _libssh2_channel_read
|
||||
*
|
||||
|
||||
@@ -96,7 +96,6 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
|
||||
uint32_t packet_size,
|
||||
const unsigned char *message, size_t message_len);
|
||||
|
||||
|
||||
/*
|
||||
* _libssh2_channel_process_startup
|
||||
*
|
||||
|
||||
@@ -98,8 +98,6 @@ comp_method_none_decomp(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_COMP_METHOD comp_method_none = {
|
||||
"none",
|
||||
0, /* not really compressing */
|
||||
@@ -136,8 +134,6 @@ comp_method_zlib_free(voidpf opaque, voidpf address)
|
||||
LIBSSH2_FREE(session, address);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* libssh2_comp_method_zlib_init
|
||||
* All your bandwidth are belong to us (so save some)
|
||||
*/
|
||||
@@ -322,7 +318,6 @@ comp_method_zlib_decomp(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* libssh2_comp_method_zlib_dtor
|
||||
* All done, no more compression for you
|
||||
*/
|
||||
|
||||
@@ -420,7 +420,6 @@ crypt_init_chacha20_poly(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
crypt_encrypt_chacha20_poly_buffer(LIBSSH2_SESSION * session,
|
||||
unsigned int seqno,
|
||||
|
||||
@@ -293,7 +293,6 @@ _libssh2_ed25519_new_private_frommemory_sk(libssh2_ed25519_ctx **ed_ctx,
|
||||
|
||||
#endif /* LIBSSH2_ED25519 */
|
||||
|
||||
|
||||
int _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
_libssh2_cipher_type(algo),
|
||||
unsigned char *iv,
|
||||
@@ -321,7 +320,6 @@ int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
|
||||
|
||||
int _libssh2_sk_pub_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
|
||||
@@ -347,7 +347,6 @@ hostkey_method_ssh_rsa_sha2_256_signv(LIBSSH2_SESSION * session,
|
||||
*
|
||||
* Verify signature created by remote
|
||||
*/
|
||||
|
||||
static int
|
||||
hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session,
|
||||
const unsigned char *sig,
|
||||
@@ -369,7 +368,6 @@ hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session,
|
||||
sig_len, m, m_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* hostkey_method_ssh_rsa_sha2_512_signv
|
||||
*
|
||||
@@ -419,7 +417,6 @@ hostkey_method_ssh_rsa_sha2_512_signv(LIBSSH2_SESSION * session,
|
||||
|
||||
#endif /* LIBSSH2_RSA_SHA2 */
|
||||
|
||||
|
||||
/*
|
||||
* hostkey_method_ssh_rsa_dtor
|
||||
*
|
||||
@@ -963,7 +960,6 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
||||
return _libssh2_ecdsa_verify(ctx, r, r_len, s, s_len, m, m_len);
|
||||
}
|
||||
|
||||
|
||||
#define LIBSSH2_HOSTKEY_METHOD_EC_SIGNV_HASH(digest_type) \
|
||||
do { \
|
||||
unsigned char hash[SHA##digest_type##_DIGEST_LENGTH]; \
|
||||
@@ -993,7 +989,6 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
||||
signature, signature_len); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* hostkey_method_ecdsa_signv
|
||||
*
|
||||
@@ -1296,7 +1291,6 @@ hostkey_method_ssh_ed25519_signv(LIBSSH2_SESSION * session,
|
||||
datavec[0].iov_len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* hostkey_method_ssh_ed25519_dtor
|
||||
*
|
||||
@@ -1342,7 +1336,6 @@ static const LIBSSH2_HOSTKEY_METHOD hostkey_method_ssh_ed25519_cert = {
|
||||
|
||||
#endif /* LIBSSH2_ED25519 */
|
||||
|
||||
|
||||
static const LIBSSH2_HOSTKEY_METHOD *hostkey_methods[] = {
|
||||
#if LIBSSH2_ECDSA
|
||||
&hostkey_method_ecdsa_ssh_nistp256,
|
||||
|
||||
49
src/kex.c
49
src/kex.c
@@ -227,7 +227,6 @@ static void _libssh2_sha_algo_value_hash(int sha_algo,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
diffie_hellman_state_cleanup(LIBSSH2_SESSION * session,
|
||||
kmdhgGPshakex_state_t *exchange_state)
|
||||
@@ -281,7 +280,6 @@ kex_diffie_hellman_cleanup(LIBSSH2_SESSION * session,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* @function diffie_hellman_sha_algo
|
||||
* @abstract Diffie Hellman Key Exchange, Group Agnostic,
|
||||
@@ -511,7 +509,7 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
||||
"Server's MD5 Fingerprint: %s", fingerprint));
|
||||
}
|
||||
#endif /* LIBSSH2DEBUG */
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
#endif /* !LIBSSH2_MD5 */
|
||||
|
||||
{
|
||||
libssh2_sha1_ctx fingerprint_ctx;
|
||||
@@ -570,7 +568,6 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
||||
}
|
||||
#endif /* LIBSSH2DEBUG */
|
||||
|
||||
|
||||
if(!session->hostkey) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"hostkey is NULL");
|
||||
@@ -1022,8 +1019,6 @@ clean_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group1_sha1_key_exchange
|
||||
* Diffie-Hellman Group1 (Actually Group2) Key Exchange using SHA1
|
||||
*/
|
||||
@@ -1092,7 +1087,6 @@ clean_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group14_key_exchange
|
||||
* Diffie-Hellman Group14 Key Exchange with hash function callback
|
||||
*/
|
||||
@@ -1189,8 +1183,6 @@ clean_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group14_sha1_key_exchange
|
||||
* Diffie-Hellman Group14 Key Exchange using SHA1
|
||||
*/
|
||||
@@ -1206,8 +1198,6 @@ kex_method_diffie_hellman_group14_sha1_key_exchange(LIBSSH2_SESSION *session,
|
||||
diffie_hellman_sha_algo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group14_sha256_key_exchange
|
||||
* Diffie-Hellman Group14 Key Exchange using SHA256
|
||||
*/
|
||||
@@ -1574,8 +1564,6 @@ dh_gex_clean_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
||||
* Diffie-Hellman Group Exchange Key Exchange using SHA256
|
||||
* Negotiates random(ish) group for secret derivation
|
||||
@@ -1840,7 +1828,6 @@ kex_session_ecdh_curve_type(const char *name, libssh2_curve_type *out_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ecdh_exchange_state_cleanup(LIBSSH2_SESSION * session,
|
||||
kmdhgGPshakex_state_t *exchange_state)
|
||||
@@ -1856,7 +1843,6 @@ ecdh_exchange_state_cleanup(LIBSSH2_SESSION * session,
|
||||
exchange_state->state = libssh2_NB_state_idle;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
kex_method_ecdh_cleanup
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
@@ -1883,11 +1869,9 @@ kex_method_ecdh_cleanup
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ecdh_sha2_nistp
|
||||
* Elliptic Curve Diffie Hellman Key Exchange
|
||||
*/
|
||||
|
||||
static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
||||
unsigned char *data, size_t data_len,
|
||||
unsigned char *public_key,
|
||||
@@ -1961,7 +1945,7 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
||||
"Server's MD5 Fingerprint: %s", fingerprint));
|
||||
}
|
||||
#endif /* LIBSSH2DEBUG */
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
#endif /* !LIBSSH2_MD5 */
|
||||
|
||||
{
|
||||
libssh2_sha1_ctx fingerprint_ctx;
|
||||
@@ -2489,7 +2473,6 @@ ecdh_clean_exit:
|
||||
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
|
||||
#if LIBSSH2_ED25519
|
||||
|
||||
static void
|
||||
@@ -2627,7 +2610,7 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
"Server's MD5 Fingerprint: %s", fingerprint));
|
||||
}
|
||||
#endif /* LIBSSH2DEBUG */
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
#endif /* !LIBSSH2_MD5 */
|
||||
|
||||
{
|
||||
libssh2_sha1_ctx fingerprint_ctx;
|
||||
@@ -3127,10 +3110,8 @@ clean_exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#endif /* LIBSSH2_ED25519 */
|
||||
|
||||
|
||||
#define LIBSSH2_KEX_METHOD_FLAG_REQ_ENC_HOSTKEY 0x0001
|
||||
#define LIBSSH2_KEX_METHOD_FLAG_REQ_SIGN_HOSTKEY 0x0002
|
||||
|
||||
@@ -3299,8 +3280,6 @@ kex_method_strlen(const LIBSSH2_COMMON_METHOD ** method)
|
||||
return len - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_method_list
|
||||
* Generate formatted preference list in buf
|
||||
*/
|
||||
@@ -3326,8 +3305,6 @@ kex_method_list(unsigned char *buf, uint32_t list_strlen,
|
||||
return list_strlen + 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define LIBSSH2_METHOD_PREFS_LEN(prefvar, defaultvar) \
|
||||
(uint32_t)((prefvar) ? strlen(prefvar) : \
|
||||
kex_method_strlen((const LIBSSH2_COMMON_METHOD**)(defaultvar)))
|
||||
@@ -3575,10 +3552,7 @@ _libssh2_kex_agree_instr(unsigned char *haystack, size_t haystack_len,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_get_method_by_name
|
||||
*/
|
||||
/* kex_get_method_by_name */
|
||||
static const LIBSSH2_COMMON_METHOD *
|
||||
kex_get_method_by_name(const char *name, size_t name_len,
|
||||
const LIBSSH2_COMMON_METHOD ** methodlist)
|
||||
@@ -3593,8 +3567,6 @@ kex_get_method_by_name(const char *name, size_t name_len,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_agree_hostkey
|
||||
* Agree on a Hostkey which works with this kex
|
||||
*/
|
||||
@@ -3670,8 +3642,6 @@ static int kex_agree_hostkey(LIBSSH2_SESSION * session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_agree_kex_hostkey
|
||||
* Agree on a Key Exchange method and a hostkey encoding type
|
||||
*/
|
||||
@@ -3752,8 +3722,6 @@ static int kex_agree_kex_hostkey(LIBSSH2_SESSION * session, unsigned char *kex,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_agree_crypt
|
||||
* Agree on a cipher algo
|
||||
*/
|
||||
@@ -3809,8 +3777,6 @@ static int kex_agree_crypt(LIBSSH2_SESSION * session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_agree_mac
|
||||
* Agree on a message authentication hash
|
||||
*/
|
||||
@@ -3872,8 +3838,6 @@ static int kex_agree_mac(LIBSSH2_SESSION * session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* kex_agree_comp
|
||||
* Agree on a compression scheme
|
||||
*/
|
||||
@@ -3927,7 +3891,6 @@ static int kex_agree_comp(LIBSSH2_SESSION *session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* TODO: When in server mode we need to turn this logic on its head
|
||||
* The Client gets to make the final call on "agreed methods"
|
||||
*/
|
||||
@@ -4042,8 +4005,6 @@ static int kex_agree_methods(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* _libssh2_kex_exchange
|
||||
* Exchange keys
|
||||
* Returns 0 on success, non-zero on failure
|
||||
@@ -4186,8 +4147,6 @@ _libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* libssh2_session_method_pref
|
||||
* Set preferred method
|
||||
*/
|
||||
|
||||
@@ -301,7 +301,6 @@ error:
|
||||
* The keylen parameter may be omitted (zero) if the key is provided as a
|
||||
* NULL-terminated base64-encoded string.
|
||||
*/
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
const char *host, const char *salt,
|
||||
@@ -312,7 +311,6 @@ libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
0, typemask, store);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* libssh2_knownhost_addc
|
||||
*
|
||||
@@ -339,7 +337,6 @@ libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
* The keylen parameter may be omitted (zero) if the key is provided as a
|
||||
* NULL-terminated base64-encoded string.
|
||||
*/
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_knownhost_addc(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
const char *host, const char *salt,
|
||||
@@ -580,7 +577,6 @@ libssh2_knownhost_checkp(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
typemask, ext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* libssh2_knownhost_del
|
||||
*
|
||||
@@ -633,7 +629,6 @@ libssh2_knownhost_free(LIBSSH2_KNOWNHOSTS *hosts)
|
||||
LIBSSH2_FREE(hosts->session, hosts);
|
||||
}
|
||||
|
||||
|
||||
/* old style plain text: [name]([,][name])*
|
||||
|
||||
for the sake of simplicity, we add them as separate hosts with the same
|
||||
@@ -977,7 +972,6 @@ libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
* Returns a negative value for error or number of successfully added hosts.
|
||||
*
|
||||
*/
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
const char *filename, int type)
|
||||
@@ -1263,7 +1257,6 @@ libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* libssh2_knownhost_get
|
||||
*
|
||||
|
||||
@@ -187,7 +187,6 @@
|
||||
#define _libssh2_cipher_chacha20 \
|
||||
_libssh2_gcry_ciphermode(GCRY_CIPHER_CHACHA20, GCRY_CIPHER_MODE_STREAM)
|
||||
|
||||
|
||||
#define _libssh2_cipher_dtor(ctx) gcry_cipher_close(*(ctx))
|
||||
|
||||
#define _libssh2_bn struct gcry_mpi
|
||||
|
||||
@@ -734,7 +734,7 @@ struct _LIBSSH2_SESSION
|
||||
#if LIBSSH2_MD5
|
||||
unsigned char server_hostkey_md5[MD5_DIGEST_LENGTH];
|
||||
int server_hostkey_md5_valid;
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
#endif /* !LIBSSH2_MD5 */
|
||||
unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH];
|
||||
int server_hostkey_sha1_valid;
|
||||
|
||||
@@ -1206,7 +1206,6 @@ ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer,
|
||||
#define LIBSSH2_DEFAULT_READ_TIMEOUT 60 /* generic timeout in seconds used when
|
||||
waiting for more data to arrive */
|
||||
|
||||
|
||||
int _libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
|
||||
key_exchange_state_t * state);
|
||||
|
||||
|
||||
26
src/mac.c
26
src/mac.c
@@ -64,9 +64,6 @@ mac_none_MAC(LIBSSH2_SESSION * session, unsigned char *buf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static LIBSSH2_MAC_METHOD mac_method_none = {
|
||||
"none",
|
||||
0,
|
||||
@@ -92,8 +89,6 @@ mac_method_common_init(LIBSSH2_SESSION * session, unsigned char *key,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* mac_method_common_dtor
|
||||
* Cleanup simple mac methods
|
||||
*/
|
||||
@@ -108,8 +103,6 @@ mac_method_common_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if LIBSSH2_HMAC_SHA512
|
||||
/* mac_method_hmac_sha512_hash
|
||||
* Calculate hash using full sha512 value
|
||||
@@ -143,8 +136,6 @@ mac_method_hmac_sha2_512_hash(LIBSSH2_SESSION * session,
|
||||
return !res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_sha2_512 = {
|
||||
"hmac-sha2-512",
|
||||
64,
|
||||
@@ -167,8 +158,6 @@ static const LIBSSH2_MAC_METHOD mac_method_hmac_sha2_512_etm = {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if LIBSSH2_HMAC_SHA256
|
||||
/* mac_method_hmac_sha256_hash
|
||||
* Calculate hash using full sha256 value
|
||||
@@ -202,8 +191,6 @@ mac_method_hmac_sha2_256_hash(LIBSSH2_SESSION * session,
|
||||
return !res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_sha2_256 = {
|
||||
"hmac-sha2-256",
|
||||
32,
|
||||
@@ -226,9 +213,6 @@ static const LIBSSH2_MAC_METHOD mac_method_hmac_sha2_256_etm = {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* mac_method_hmac_sha1_hash
|
||||
* Calculate hash using full sha1 value
|
||||
*/
|
||||
@@ -261,8 +245,6 @@ mac_method_hmac_sha1_hash(LIBSSH2_SESSION * session,
|
||||
return !res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_sha1 = {
|
||||
"hmac-sha1",
|
||||
20,
|
||||
@@ -304,8 +286,6 @@ mac_method_hmac_sha1_96_hash(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_sha1_96 = {
|
||||
"hmac-sha1-96",
|
||||
12,
|
||||
@@ -349,8 +329,6 @@ mac_method_hmac_md5_hash(LIBSSH2_SESSION * session, unsigned char *buf,
|
||||
return !res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_md5 = {
|
||||
"hmac-md5",
|
||||
16,
|
||||
@@ -382,8 +360,6 @@ mac_method_hmac_md5_96_hash(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_md5_96 = {
|
||||
"hmac-md5-96",
|
||||
12,
|
||||
@@ -429,8 +405,6 @@ mac_method_hmac_ripemd160_hash(LIBSSH2_SESSION * session,
|
||||
return !res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const LIBSSH2_MAC_METHOD mac_method_hmac_ripemd160 = {
|
||||
"hmac-ripemd160",
|
||||
20,
|
||||
|
||||
@@ -186,7 +186,6 @@ _libssh2_mbedtls_cipher_dtor(_libssh2_cipher_ctx *ctx)
|
||||
mbedtls_cipher_free(ctx);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_hash_init(mbedtls_md_context_t *ctx,
|
||||
mbedtls_md_type_t mdtype,
|
||||
@@ -374,7 +373,6 @@ _libssh2_mbedtls_bignum_random(_libssh2_bn *bn, int bits, int top, int bottom)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: RSA functions
|
||||
@@ -926,7 +924,6 @@ void _libssh2_init_aes_ctr(void)
|
||||
/* no implementation */
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: Diffie-Hellman functions
|
||||
@@ -1026,7 +1023,6 @@ failed:
|
||||
* Creates a new public key given an octal string, length and type
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdsa_curve_name_with_octal_new(libssh2_ecdsa_ctx **ctx,
|
||||
const unsigned char *k,
|
||||
@@ -1066,7 +1062,6 @@ failed:
|
||||
* Computes the shared secret K given a local private key,
|
||||
* remote public key and length
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdh_gen_k(_libssh2_bn **k,
|
||||
_libssh2_ec_key *privkey,
|
||||
@@ -1123,7 +1118,6 @@ cleanup:
|
||||
* Verifies the ECDSA signature of a hashed message
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdsa_verify(libssh2_ecdsa_ctx *ctx,
|
||||
const unsigned char *r, size_t r_len,
|
||||
@@ -1293,7 +1287,6 @@ int mbedtls_pk_load_file(const char *path, unsigned char **buf, size_t *n);
|
||||
* Creates a new private key given a file path and password
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdsa_new_private(libssh2_ecdsa_ctx **ctx,
|
||||
LIBSSH2_SESSION *session,
|
||||
@@ -1330,7 +1323,6 @@ cleanup:
|
||||
* Creates a new private key given a file data and password
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx **ctx,
|
||||
LIBSSH2_SESSION *session,
|
||||
@@ -1401,7 +1393,6 @@ done:
|
||||
* Computes the ECDSA signature of a previously-hashed message
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdsa_sign(LIBSSH2_SESSION *session,
|
||||
libssh2_ecdsa_ctx *ctx,
|
||||
@@ -1461,7 +1452,6 @@ cleanup:
|
||||
* returns key curve type that maps to libssh2_curve_type
|
||||
*
|
||||
*/
|
||||
|
||||
libssh2_curve_type
|
||||
_libssh2_mbedtls_ecdsa_get_curve_type(libssh2_ecdsa_ctx *ctx)
|
||||
{
|
||||
@@ -1473,7 +1463,6 @@ _libssh2_mbedtls_ecdsa_get_curve_type(libssh2_ecdsa_ctx *ctx)
|
||||
* returns 0 for success, key curve type that maps to libssh2_curve_type
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_mbedtls_ecdsa_curve_type_from_name(const char *name,
|
||||
libssh2_curve_type *out_type)
|
||||
@@ -1509,13 +1498,11 @@ _libssh2_mbedtls_ecdsa_free(libssh2_ecdsa_ctx *ctx)
|
||||
}
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
|
||||
/* _libssh2_supported_key_sign_algorithms
|
||||
*
|
||||
* Return supported key hash algo upgrades, see crypto.h
|
||||
*
|
||||
*/
|
||||
|
||||
const char *
|
||||
_libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
|
||||
unsigned char *key_method,
|
||||
|
||||
@@ -104,7 +104,6 @@
|
||||
|
||||
#define EC_MAX_POINT_LEN ((528 * 2 / 8) + 1)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: Generic functions
|
||||
@@ -120,7 +119,6 @@
|
||||
|
||||
#define libssh2_prepare_iovec(vec, len) /* Empty. */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: HMAC functions
|
||||
@@ -128,7 +126,6 @@
|
||||
|
||||
#define libssh2_hmac_ctx mbedtls_md_context_t
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: SHA1 functions
|
||||
@@ -145,7 +142,6 @@
|
||||
#define libssh2_sha1(data, datalen, hash) \
|
||||
_libssh2_mbedtls_hash(data, datalen, MBEDTLS_MD_SHA1, hash)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: SHA256 functions
|
||||
@@ -162,7 +158,6 @@
|
||||
#define libssh2_sha256(data, datalen, hash) \
|
||||
_libssh2_mbedtls_hash(data, datalen, MBEDTLS_MD_SHA256, hash)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: SHA384 functions
|
||||
@@ -179,7 +174,6 @@
|
||||
#define libssh2_sha384(data, datalen, hash) \
|
||||
_libssh2_mbedtls_hash(data, datalen, MBEDTLS_MD_SHA384, hash)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: SHA512 functions
|
||||
@@ -196,7 +190,6 @@
|
||||
#define libssh2_sha512(data, datalen, hash) \
|
||||
_libssh2_mbedtls_hash(data, datalen, MBEDTLS_MD_SHA512, hash)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: MD5 functions
|
||||
@@ -241,7 +234,6 @@
|
||||
#define _libssh2_rsa_sha2_sign(s, rsactx, hash, hash_len, sig, sig_len) \
|
||||
_libssh2_mbedtls_rsa_sha2_sign(s, rsactx, hash, hash_len, sig, sig_len)
|
||||
|
||||
|
||||
#define _libssh2_rsa_sha1_verify(rsactx, sig, sig_len, m, m_len) \
|
||||
_libssh2_mbedtls_rsa_sha1_verify(rsactx, sig, sig_len, m, m_len)
|
||||
|
||||
@@ -251,7 +243,6 @@
|
||||
#define _libssh2_rsa_free(rsactx) \
|
||||
_libssh2_mbedtls_rsa_free(rsactx)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: ECDSA structures
|
||||
@@ -282,7 +273,6 @@ typedef enum {
|
||||
# define _libssh2_ec_key void
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: ECDSA functions
|
||||
@@ -325,7 +315,6 @@ typedef enum {
|
||||
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: Key functions
|
||||
@@ -342,7 +331,6 @@ typedef enum {
|
||||
_libssh2_mbedtls_sk_pub_keyfilememory(s, m, m_len, p, p_len, alg, app, \
|
||||
f, kh, kh_len, pk, pk_len, pw)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: Cipher Context structure
|
||||
@@ -367,7 +355,6 @@ typedef enum {
|
||||
#define _libssh2_cipher_3des MBEDTLS_CIPHER_DES_EDE3_CBC
|
||||
#define _libssh2_cipher_chacha20 MBEDTLS_CIPHER_CHACHA20_POLY1305
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: Cipher functions
|
||||
@@ -380,7 +367,6 @@ typedef enum {
|
||||
#define _libssh2_cipher_dtor(ctx) \
|
||||
_libssh2_mbedtls_cipher_dtor(ctx)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: BigNumber Support
|
||||
@@ -409,7 +395,6 @@ typedef enum {
|
||||
#define _libssh2_bn_free(bn) \
|
||||
_libssh2_mbedtls_bignum_free(bn)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: Diffie-Hellman support.
|
||||
@@ -431,7 +416,6 @@ typedef enum {
|
||||
_libssh2_dh_secret(dhctx, secret, f, p)
|
||||
#define libssh2_dh_dtor(dhctx) _libssh2_dh_dtor(dhctx)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* mbedTLS backend: forward declarations
|
||||
|
||||
23
src/misc.c
23
src/misc.c
@@ -223,8 +223,7 @@ _libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* libssh2_ntohu32
|
||||
*/
|
||||
/* libssh2_ntohu32 */
|
||||
uint32_t
|
||||
_libssh2_ntohu32(const unsigned char *buf)
|
||||
{
|
||||
@@ -234,9 +233,7 @@ _libssh2_ntohu32(const unsigned char *buf)
|
||||
| ((uint32_t)buf[3]);
|
||||
}
|
||||
|
||||
|
||||
/* _libssh2_ntohu64
|
||||
*/
|
||||
/* _libssh2_ntohu64 */
|
||||
libssh2_uint64_t
|
||||
_libssh2_ntohu64(const unsigned char *buf)
|
||||
{
|
||||
@@ -250,8 +247,7 @@ _libssh2_ntohu64(const unsigned char *buf)
|
||||
| ((libssh2_uint64_t)buf[7]);
|
||||
}
|
||||
|
||||
/* _libssh2_htonu32
|
||||
*/
|
||||
/* _libssh2_htonu32 */
|
||||
void
|
||||
_libssh2_htonu32(unsigned char *buf, uint32_t value)
|
||||
{
|
||||
@@ -261,16 +257,14 @@ _libssh2_htonu32(unsigned char *buf, uint32_t value)
|
||||
buf[3] = value & 0xFF;
|
||||
}
|
||||
|
||||
/* _libssh2_store_u32
|
||||
*/
|
||||
/* _libssh2_store_u32 */
|
||||
void _libssh2_store_u32(unsigned char **buf, uint32_t value)
|
||||
{
|
||||
_libssh2_htonu32(*buf, value);
|
||||
*buf += sizeof(uint32_t);
|
||||
}
|
||||
|
||||
/* _libssh2_store_u64
|
||||
*/
|
||||
/* _libssh2_store_u64 */
|
||||
void _libssh2_store_u64(unsigned char **buf, libssh2_uint64_t value)
|
||||
{
|
||||
unsigned char *ptr = *buf;
|
||||
@@ -287,8 +281,7 @@ void _libssh2_store_u64(unsigned char **buf, libssh2_uint64_t value)
|
||||
*buf += sizeof(libssh2_uint64_t);
|
||||
}
|
||||
|
||||
/* _libssh2_store_str
|
||||
*/
|
||||
/* _libssh2_store_str */
|
||||
int _libssh2_store_str(unsigned char **buf, const char *str, size_t len)
|
||||
{
|
||||
uint32_t len_stored = (uint32_t)len;
|
||||
@@ -303,8 +296,7 @@ int _libssh2_store_str(unsigned char **buf, const char *str, size_t len)
|
||||
return len_stored == len;
|
||||
}
|
||||
|
||||
/* _libssh2_store_bignum2_bytes
|
||||
*/
|
||||
/* _libssh2_store_bignum2_bytes */
|
||||
int _libssh2_store_bignum2_bytes(unsigned char **buf,
|
||||
const unsigned char *bytes,
|
||||
size_t len)
|
||||
@@ -840,7 +832,6 @@ int _libssh2_get_boolean(struct string_buf *buf, unsigned char *out)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
*out = buf->dataptr[0] == 0 ? 0 : 1;
|
||||
buf->dataptr += 1;
|
||||
return 0;
|
||||
|
||||
@@ -732,7 +732,6 @@ _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
|
||||
* returns key curve type that maps to libssh2_curve_type
|
||||
*
|
||||
*/
|
||||
|
||||
libssh2_curve_type
|
||||
_libssh2_ecdsa_get_curve_type(libssh2_ecdsa_ctx *ec_ctx)
|
||||
{
|
||||
@@ -762,7 +761,6 @@ _libssh2_ecdsa_get_curve_type(libssh2_ecdsa_ctx *ec_ctx)
|
||||
* returns 0 for success, key curve type that maps to libssh2_curve_type
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_ecdsa_curve_type_from_name(const char *name,
|
||||
libssh2_curve_type *out_type)
|
||||
@@ -794,7 +792,6 @@ _libssh2_ecdsa_curve_type_from_name(const char *name,
|
||||
* Creates a new public key given an octal string, length and type
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_ecdsa_curve_name_with_octal_new(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
const unsigned char *k,
|
||||
@@ -2091,7 +2088,6 @@ int _libssh2_ecdsa_new_private_frommemory_sk(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
|
||||
#if LIBSSH2_ED25519
|
||||
|
||||
int
|
||||
@@ -2161,7 +2157,6 @@ clean_exit:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
gen_publickey_from_ed_evp(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
@@ -2230,7 +2225,6 @@ fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
gen_publickey_from_ed25519_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
struct string_buf *decrypted,
|
||||
@@ -2753,7 +2747,6 @@ _libssh2_ed25519_new_public(libssh2_ed25519_ctx ** ed_ctx,
|
||||
}
|
||||
#endif /* LIBSSH2_ED25519 */
|
||||
|
||||
|
||||
#if LIBSSH2_RSA
|
||||
int
|
||||
_libssh2_rsa_sha2_sign(LIBSSH2_SESSION * session,
|
||||
@@ -3860,7 +3853,6 @@ fail:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
@@ -4054,7 +4046,6 @@ _libssh2_ecdsa_new_private_sk(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* _libssh2_ecdsa_create_key
|
||||
*
|
||||
@@ -4364,7 +4355,6 @@ clean_exit:
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
#if LIBSSH2_ED25519
|
||||
@@ -4492,7 +4482,6 @@ clean_exit:
|
||||
return (rc == 1) ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_libssh2_ed25519_verify(libssh2_ed25519_ctx *ctx, const uint8_t *s,
|
||||
size_t s_len, const uint8_t *m, size_t m_len)
|
||||
@@ -5184,7 +5173,6 @@ _libssh2_bn_from_bin(_libssh2_bn *bn, size_t len, const unsigned char *val)
|
||||
* Return supported key hash algo upgrades, see crypto.h
|
||||
*
|
||||
*/
|
||||
|
||||
const char *
|
||||
_libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
|
||||
unsigned char *key_method,
|
||||
|
||||
@@ -155,7 +155,6 @@
|
||||
# define LIBSSH2_ED25519 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
# define LIBSSH2_MD5 0
|
||||
#else
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
#ifdef OS400_DEBUG
|
||||
/* In debug mode, all system library errors cause an exception. */
|
||||
#define set_EC_length(ec, length) ((ec).Bytes_Provided = \
|
||||
@@ -59,13 +58,11 @@
|
||||
#define set_EC_length(ec, length) ((ec).Bytes_Provided = (length))
|
||||
#endif
|
||||
|
||||
|
||||
/* Ensure va_list operations are not on an array. */
|
||||
typedef struct {
|
||||
va_list list;
|
||||
} valiststr;
|
||||
|
||||
|
||||
typedef int (*loadkeyproc)(LIBSSH2_SESSION *session,
|
||||
const unsigned char *data, unsigned int datalen,
|
||||
const unsigned char *passphrase, void *loadkeydata);
|
||||
@@ -77,7 +74,6 @@ typedef struct {
|
||||
unsigned int length;
|
||||
} loadpubkeydata;
|
||||
|
||||
|
||||
/* Support for ASN.1 elements. */
|
||||
|
||||
typedef struct {
|
||||
@@ -117,7 +113,6 @@ static int sshdsapubkey(LIBSSH2_SESSION *session, char **sshpubkey,
|
||||
static unsigned char OID_dhKeyAgreement[] =
|
||||
{9, 40 + 2, 0x86, 0x48, 0x86, 0xF7, 0x0D, 1, 3, 1};
|
||||
|
||||
|
||||
/* PKCS#5 support. */
|
||||
|
||||
typedef struct pkcs5params pkcs5params;
|
||||
@@ -293,7 +288,6 @@ static const pkcs5algo * kdf2prftable[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* Public key extraction support. */
|
||||
static struct {
|
||||
unsigned char *oid;
|
||||
@@ -322,7 +316,6 @@ static const char endrsaprivkeyhdr[] = "-----END RSA PRIVATE KEY-----";
|
||||
static const char fopenrmode[] = "r";
|
||||
static const char fopenrbmode[] = "rb";
|
||||
|
||||
|
||||
/* The rest of character literals in this module are in EBCDIC. */
|
||||
#pragma convert(37)
|
||||
|
||||
@@ -354,7 +347,6 @@ static asn1Element lastbytebitcount = {
|
||||
(char *) &zero, NULL, (char *) &zero + 1
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: big numbers support.
|
||||
@@ -517,7 +509,6 @@ _libssh2_bn_from_bn(_libssh2_bn *to, _libssh2_bn *from)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: ASN.1 support.
|
||||
@@ -897,7 +888,6 @@ rsaprivatekeyinfo(asn1Element *privkey)
|
||||
return privkeyinfo;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: crypto context support.
|
||||
@@ -1187,7 +1177,6 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
||||
return errcode.Bytes_Available ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: RSA support.
|
||||
@@ -1292,7 +1281,6 @@ _libssh2_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: Diffie-Hellman support.
|
||||
@@ -1388,7 +1376,6 @@ _libssh2_os400qc3_dh_dtor(_libssh2_dh_ctx *dhctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: PKCS#5 supplement.
|
||||
@@ -2512,7 +2499,6 @@ _libssh2_os400qc3_rsa_signv(LIBSSH2_SESSION *session,
|
||||
* Return supported key hash algo upgrades, see crypto.h
|
||||
*
|
||||
*/
|
||||
|
||||
const char *
|
||||
_libssh2_supported_key_sign_algorithms(LIBSSH2_SESSION *session,
|
||||
unsigned char *key_method,
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
|
||||
#include <qc3cci.h>
|
||||
|
||||
|
||||
/* Redefine character/string literals as always EBCDIC. */
|
||||
#undef Qc3_Alg_Token
|
||||
#define Qc3_Alg_Token "\xC1\xD3\xC7\xC4\xF0\xF1\xF0\xF0" /* ALGD0100 */
|
||||
@@ -350,7 +349,6 @@ typedef struct { /* Diffie-Hellman context. */
|
||||
_libssh2_os400qc3_dh_secret(dhctx, secret, f, p)
|
||||
#define libssh2_dh_dtor(dhctx) _libssh2_os400qc3_dh_dtor(dhctx)
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* OS/400 QC3 crypto-library backend: Support procedure prototypes.
|
||||
|
||||
@@ -930,7 +930,6 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
(int)len, data + 5, want_reply));
|
||||
}
|
||||
|
||||
|
||||
if(want_reply) {
|
||||
static const unsigned char packet =
|
||||
SSH_MSG_REQUEST_FAILURE;
|
||||
@@ -1195,7 +1194,6 @@ libssh2_packet_add_jump_point1:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(want_reply) {
|
||||
unsigned char packet[5];
|
||||
libssh2_packet_add_jump_point4:
|
||||
|
||||
@@ -109,7 +109,6 @@ poly1305_donna_16bytes:
|
||||
h3 += ((uint32_t)((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff);
|
||||
h4 += (t3 >> 8) | (1 << 24);
|
||||
|
||||
|
||||
poly1305_donna_mul:
|
||||
t[0] = mul32x32_64(h0, r0) + mul32x32_64(h1, s4) + mul32x32_64(h2, s3) +
|
||||
mul32x32_64(h3, s2) + mul32x32_64(h4, s1);
|
||||
|
||||
@@ -573,8 +573,6 @@ libssh2_publickey_init(LIBSSH2_SESSION *session)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* libssh2_publickey_add_ex
|
||||
*
|
||||
|
||||
@@ -854,7 +854,6 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
|
||||
session->startup_service_length =
|
||||
_libssh2_ntohu32(session->startup_data + 1);
|
||||
|
||||
|
||||
if((session->startup_service_length != (sizeof("ssh-userauth") - 1))
|
||||
|| strncmp("ssh-userauth",
|
||||
(const char *) session->startup_data + 5,
|
||||
@@ -1490,7 +1489,6 @@ libssh2_session_get_blocking(LIBSSH2_SESSION * session)
|
||||
return session->api_block_mode;
|
||||
}
|
||||
|
||||
|
||||
/* libssh2_session_set_timeout
|
||||
*
|
||||
* Set a session's timeout (in msec) for blocking mode,
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
} while(!rc); \
|
||||
} while(0)
|
||||
|
||||
|
||||
int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t entry_time);
|
||||
|
||||
/* this is the lib-internal set blocking function */
|
||||
|
||||
@@ -452,7 +452,6 @@ static void sftp_packetlist_flush(LIBSSH2_SFTP_HANDLE *handle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* sftp_packet_ask
|
||||
*
|
||||
@@ -1136,9 +1135,9 @@ libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* *******************************
|
||||
/*******************************
|
||||
* SFTP File and Directory Ops *
|
||||
******************************* */
|
||||
*******************************/
|
||||
|
||||
/* sftp_open
|
||||
*/
|
||||
@@ -2424,7 +2423,6 @@ libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *hnd)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* sftp_fstat
|
||||
* Get or Set stat on a file
|
||||
*/
|
||||
@@ -2549,7 +2547,6 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* libssh2_sftp_seek64
|
||||
* Set the read/write pointer to an arbitrary position within the file
|
||||
*/
|
||||
@@ -3481,7 +3478,6 @@ libssh2_sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* sftp_mkdir
|
||||
* Create an SFTP directory
|
||||
*/
|
||||
|
||||
@@ -117,13 +117,11 @@ debugdump(LIBSSH2_SESSION * session,
|
||||
#define debugdump(a,x,y,z) do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
/* decrypt() decrypts 'len' bytes from 'source' to 'dest' in units of
|
||||
* blocksize.
|
||||
*
|
||||
* returns 0 on success and negative on failure
|
||||
*/
|
||||
|
||||
static int
|
||||
decrypt(LIBSSH2_SESSION * session, unsigned char *source,
|
||||
unsigned char *dest, ssize_t len, int firstlast)
|
||||
@@ -348,7 +346,6 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
|
||||
return session->fullpacket_packet_type;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* _libssh2_transport_read
|
||||
*
|
||||
@@ -524,7 +521,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
fields */
|
||||
|
||||
/* packet length is not encrypted in encode-then-mac mode
|
||||
and we donøt need to decrypt first block */
|
||||
and we do not need to decrypt first block */
|
||||
ssize_t required_size = etm ? 4 : blocksize;
|
||||
|
||||
/* No payload package area allocated yet. To know the
|
||||
@@ -532,7 +529,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
blocksize data. */
|
||||
|
||||
if(numbytes < required_size) {
|
||||
/* we can't act on anything less than blocksize, but this
|
||||
/* we cannot act on anything less than blocksize, but this
|
||||
check is only done for the initial block since once we have
|
||||
got the start of a block we can in fact deal with fractions
|
||||
*/
|
||||
@@ -1111,7 +1108,6 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
data_len += data2_len; /* use the combined length */
|
||||
}
|
||||
|
||||
|
||||
/* RFC4253 says: Note that the length of the concatenation of
|
||||
'packet_length', 'padding_length', 'payload', and 'random padding'
|
||||
MUST be a multiple of the cipher block size or 8, whichever is
|
||||
|
||||
@@ -289,8 +289,6 @@ libssh2_userauth_authenticated(LIBSSH2_SESSION * session)
|
||||
return (session->state & LIBSSH2_STATE_AUTHENTICATED) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* userauth_password
|
||||
* Plain ol' login
|
||||
*/
|
||||
@@ -2112,8 +2110,6 @@ libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* userauth_keyboard_interactive
|
||||
*
|
||||
|
||||
152
src/wincng.c
152
src/wincng.c
@@ -247,8 +247,7 @@
|
||||
#define PKCS_RSA_PRIVATE_KEY ((LPCSTR)(size_t)43)
|
||||
#endif
|
||||
|
||||
static int
|
||||
_libssh2_wincng_bignum_resize(_libssh2_bn* bn, ULONG length);
|
||||
static int _libssh2_wincng_bignum_resize(_libssh2_bn* bn, ULONG length);
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
@@ -341,8 +340,7 @@ _libssh2_wincng_parse_ecdsa_privatekey(OUT _libssh2_wincng_ecdsa_key **key,
|
||||
|
||||
struct _libssh2_wincng_ctx _libssh2_wincng;
|
||||
|
||||
void
|
||||
_libssh2_wincng_init(void)
|
||||
void _libssh2_wincng_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -523,8 +521,7 @@ _libssh2_wincng_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_libssh2_wincng_free(void)
|
||||
void _libssh2_wincng_free(void)
|
||||
{
|
||||
#if LIBSSH2_ECDSA
|
||||
unsigned int curve;
|
||||
@@ -581,8 +578,7 @@ _libssh2_wincng_free(void)
|
||||
memset(&_libssh2_wincng, 0, sizeof(_libssh2_wincng));
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_random(void *buf, size_t len)
|
||||
int _libssh2_wincng_random(void *buf, size_t len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -595,8 +591,7 @@ _libssh2_wincng_random(void *buf, size_t len)
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_libssh2_wincng_safe_free(void *buf, size_t len)
|
||||
static void _libssh2_wincng_safe_free(void *buf, size_t len)
|
||||
{
|
||||
if(!buf)
|
||||
return;
|
||||
@@ -610,9 +605,8 @@ _libssh2_wincng_safe_free(void *buf, size_t len)
|
||||
/* Copy a big endian set of bits from src to dest.
|
||||
* if the size of src is smaller than dest then pad the "left" (MSB)
|
||||
* end with zeroes and copy the bits into the "right" (LSB) end. */
|
||||
static void
|
||||
memcpy_with_be_padding(unsigned char *dest, ULONG dest_len,
|
||||
unsigned char *src, ULONG src_len)
|
||||
static void memcpy_with_be_padding(unsigned char *dest, ULONG dest_len,
|
||||
unsigned char *src, ULONG src_len)
|
||||
{
|
||||
if(dest_len > src_len) {
|
||||
memset(dest, 0, dest_len - src_len);
|
||||
@@ -625,10 +619,9 @@ memcpy_with_be_padding(unsigned char *dest, ULONG dest_len,
|
||||
* Windows CNG backend: Hash functions
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_hash_init(_libssh2_wincng_hash_ctx *ctx,
|
||||
BCRYPT_ALG_HANDLE hAlg, ULONG hashlen,
|
||||
unsigned char *key, ULONG keylen)
|
||||
int _libssh2_wincng_hash_init(_libssh2_wincng_hash_ctx *ctx,
|
||||
BCRYPT_ALG_HANDLE hAlg, ULONG hashlen,
|
||||
unsigned char *key, ULONG keylen)
|
||||
{
|
||||
BCRYPT_HASH_HANDLE hHash;
|
||||
unsigned char *pbHashObject;
|
||||
@@ -656,7 +649,6 @@ _libssh2_wincng_hash_init(_libssh2_wincng_hash_ctx *ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = BCryptCreateHash(hAlg, &hHash,
|
||||
pbHashObject, dwHashObject,
|
||||
key, keylen, 0);
|
||||
@@ -665,7 +657,6 @@ _libssh2_wincng_hash_init(_libssh2_wincng_hash_ctx *ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ctx->hHash = hHash;
|
||||
ctx->pbHashObject = pbHashObject;
|
||||
ctx->dwHashObject = dwHashObject;
|
||||
@@ -686,9 +677,8 @@ _libssh2_wincng_hash_update(_libssh2_wincng_hash_ctx *ctx,
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_hash_final(_libssh2_wincng_hash_ctx *ctx,
|
||||
unsigned char *hash)
|
||||
int _libssh2_wincng_hash_final(_libssh2_wincng_hash_ctx *ctx,
|
||||
unsigned char *hash)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -704,10 +694,9 @@ _libssh2_wincng_hash_final(_libssh2_wincng_hash_ctx *ctx,
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_hash(const unsigned char *data, ULONG datalen,
|
||||
BCRYPT_ALG_HANDLE hAlg,
|
||||
unsigned char *hash, ULONG hashlen)
|
||||
int _libssh2_wincng_hash(const unsigned char *data, ULONG datalen,
|
||||
BCRYPT_ALG_HANDLE hAlg,
|
||||
unsigned char *hash, ULONG hashlen)
|
||||
{
|
||||
_libssh2_wincng_hash_ctx ctx;
|
||||
int ret;
|
||||
@@ -721,7 +710,6 @@ _libssh2_wincng_hash(const unsigned char *data, ULONG datalen,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: HMAC functions
|
||||
@@ -800,20 +788,18 @@ void _libssh2_hmac_cleanup(libssh2_hmac_ctx *ctx)
|
||||
ctx->dwHashObject = 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: Key functions
|
||||
*/
|
||||
|
||||
static int
|
||||
_libssh2_wincng_key_sha_verify(_libssh2_wincng_key_ctx *ctx,
|
||||
ULONG hashlen,
|
||||
const unsigned char *sig,
|
||||
ULONG sig_len,
|
||||
const unsigned char *m,
|
||||
ULONG m_len,
|
||||
ULONG flags)
|
||||
static int _libssh2_wincng_key_sha_verify(_libssh2_wincng_key_ctx *ctx,
|
||||
ULONG hashlen,
|
||||
const unsigned char *sig,
|
||||
ULONG sig_len,
|
||||
const unsigned char *m,
|
||||
ULONG m_len,
|
||||
ULONG flags)
|
||||
{
|
||||
BCRYPT_PKCS1_PADDING_INFO paddingInfoPKCS1;
|
||||
BCRYPT_ALG_HANDLE hAlgHash;
|
||||
@@ -890,14 +876,13 @@ _libssh2_wincng_key_sha_verify(_libssh2_wincng_key_ctx *ctx,
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
static int
|
||||
_libssh2_wincng_load_pem(LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase,
|
||||
const char *headerbegin,
|
||||
const char *headerend,
|
||||
unsigned char **data,
|
||||
size_t *datalen)
|
||||
static int _libssh2_wincng_load_pem(LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase,
|
||||
const char *headerbegin,
|
||||
const char *headerend,
|
||||
unsigned char **data,
|
||||
size_t *datalen)
|
||||
{
|
||||
FILE *fp;
|
||||
int ret;
|
||||
@@ -916,13 +901,12 @@ _libssh2_wincng_load_pem(LIBSSH2_SESSION *session,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
_libssh2_wincng_load_private(LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase,
|
||||
unsigned char **ppbEncoded,
|
||||
size_t *pcbEncoded,
|
||||
int tryLoadRSA, int tryLoadDSA)
|
||||
static int _libssh2_wincng_load_private(LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase,
|
||||
unsigned char **ppbEncoded,
|
||||
size_t *pcbEncoded,
|
||||
int tryLoadRSA, int tryLoadDSA)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
size_t datalen = 0;
|
||||
@@ -948,14 +932,13 @@ _libssh2_wincng_load_private(LIBSSH2_SESSION *session,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
_libssh2_wincng_load_private_memory(LIBSSH2_SESSION *session,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const unsigned char *passphrase,
|
||||
unsigned char **ppbEncoded,
|
||||
size_t *pcbEncoded,
|
||||
int tryLoadRSA, int tryLoadDSA)
|
||||
static int _libssh2_wincng_load_private_memory(LIBSSH2_SESSION *session,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const unsigned char *passphrase,
|
||||
unsigned char **ppbEncoded,
|
||||
size_t *pcbEncoded,
|
||||
int tryLoadRSA, int tryLoadDSA)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
size_t datalen = 0;
|
||||
@@ -985,12 +968,11 @@ _libssh2_wincng_load_private_memory(LIBSSH2_SESSION *session,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
_libssh2_wincng_asn_decode(unsigned char *pbEncoded,
|
||||
DWORD cbEncoded,
|
||||
LPCSTR lpszStructType,
|
||||
unsigned char **ppbDecoded,
|
||||
DWORD *pcbDecoded)
|
||||
static int _libssh2_wincng_asn_decode(unsigned char *pbEncoded,
|
||||
DWORD cbEncoded,
|
||||
LPCSTR lpszStructType,
|
||||
unsigned char **ppbDecoded,
|
||||
DWORD *pcbDecoded)
|
||||
{
|
||||
unsigned char *pbDecoded = NULL;
|
||||
DWORD cbDecoded = 0;
|
||||
@@ -1018,7 +1000,6 @@ _libssh2_wincng_asn_decode(unsigned char *pbEncoded,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
*ppbDecoded = pbDecoded;
|
||||
*pcbDecoded = cbDecoded;
|
||||
|
||||
@@ -1057,7 +1038,6 @@ _libssh2_wincng_bn_ltob(unsigned char *pbInput,
|
||||
pbOutput[index + offset] = pbInput[length - index];
|
||||
}
|
||||
|
||||
|
||||
*ppbOutput = pbOutput;
|
||||
*pcbOutput = cbOutput;
|
||||
|
||||
@@ -1178,7 +1158,6 @@ _libssh2_wincng_bn_size(const unsigned char *bignum, ULONG length)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if LIBSSH2_RSA
|
||||
/*******************************************************************/
|
||||
/*
|
||||
@@ -1229,7 +1208,6 @@ _libssh2_wincng_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
|
||||
memset(rsakey, 0, keylen);
|
||||
|
||||
|
||||
/* https://msdn.microsoft.com/library/windows/desktop/aa375531.aspx */
|
||||
rsakey->BitLength = mlen * 8;
|
||||
rsakey->cbPublicExp = elen;
|
||||
@@ -1305,7 +1283,6 @@ _libssh2_wincng_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
rsakey->cbPrime2 = 0;
|
||||
}
|
||||
|
||||
|
||||
ret = BCryptImportKeyPair(_libssh2_wincng.hAlgRSA, NULL, lpszBlobType,
|
||||
&hKey, (PUCHAR)rsakey, keylen, 0);
|
||||
if(!BCRYPT_SUCCESS(ret)) {
|
||||
@@ -1313,7 +1290,6 @@ _libssh2_wincng_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
*rsa = malloc(sizeof(libssh2_rsa_ctx));
|
||||
if(!(*rsa)) {
|
||||
BCryptDestroyKey(hKey);
|
||||
@@ -1352,7 +1328,6 @@ _libssh2_wincng_rsa_new_private_parse(libssh2_rsa_ctx **rsa,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ret = BCryptImportKeyPair(_libssh2_wincng.hAlgRSA, NULL,
|
||||
LEGACY_RSAPRIVATE_BLOB, &hKey,
|
||||
pbStructInfo, cbStructInfo, 0);
|
||||
@@ -1361,7 +1336,6 @@ _libssh2_wincng_rsa_new_private_parse(libssh2_rsa_ctx **rsa,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
*rsa = malloc(sizeof(libssh2_rsa_ctx));
|
||||
if(!(*rsa)) {
|
||||
BCryptDestroyKey(hKey);
|
||||
@@ -1616,7 +1590,6 @@ _libssh2_wincng_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
|
||||
memset(dsakey, 0, keylen);
|
||||
|
||||
|
||||
/* https://msdn.microsoft.com/library/windows/desktop/aa833126.aspx */
|
||||
dsakey->cbKey = length;
|
||||
|
||||
@@ -1667,7 +1640,6 @@ _libssh2_wincng_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
dsakey->dwMagic = BCRYPT_DSA_PUBLIC_MAGIC;
|
||||
}
|
||||
|
||||
|
||||
ret = BCryptImportKeyPair(_libssh2_wincng.hAlgDSA, NULL, lpszBlobType,
|
||||
&hKey, (PUCHAR)dsakey, keylen, 0);
|
||||
if(!BCRYPT_SUCCESS(ret)) {
|
||||
@@ -1675,7 +1647,6 @@ _libssh2_wincng_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
*dsa = malloc(sizeof(libssh2_dsa_ctx));
|
||||
if(!(*dsa)) {
|
||||
BCryptDestroyKey(hKey);
|
||||
@@ -1712,7 +1683,6 @@ _libssh2_wincng_dsa_new_private_parse(libssh2_dsa_ctx **dsa,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(length == 6) {
|
||||
ret = _libssh2_wincng_dsa_new(dsa,
|
||||
rpbDecoded[1], rcbDecoded[1],
|
||||
@@ -1870,7 +1840,6 @@ _libssh2_wincng_dsa_free(libssh2_dsa_ctx *dsa)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: ECDSA helper functions
|
||||
@@ -2238,7 +2207,6 @@ _libssh_wincng_reverse_bytes(IN PUCHAR buffer,
|
||||
/*
|
||||
* Windows CNG backend: ECDSA functions
|
||||
*/
|
||||
|
||||
void
|
||||
_libssh2_wincng_ecdsa_free(IN _libssh2_wincng_ecdsa_key *key)
|
||||
{
|
||||
@@ -2250,14 +2218,12 @@ _libssh2_wincng_ecdsa_free(IN _libssh2_wincng_ecdsa_key *key)
|
||||
free(key);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* _libssh2_ecdsa_create_key
|
||||
*
|
||||
* Creates a local private ECDH key based on input curve
|
||||
* and returns the public key in uncompressed point encoding.
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_ecdh_create_key(IN LIBSSH2_SESSION *session,
|
||||
OUT _libssh2_wincng_ecdsa_key **privatekey,
|
||||
@@ -2349,7 +2315,6 @@ cleanup:
|
||||
*
|
||||
* Creates an ECDSA public key from an uncompressed point.
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_ecdsa_curve_name_with_octal_new(
|
||||
OUT _libssh2_wincng_ecdsa_key **key,
|
||||
@@ -2409,7 +2374,6 @@ cleanup:
|
||||
* Computes the shared secret K given a local private key,
|
||||
* remote public key and length
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_ecdh_gen_k(OUT _libssh2_bn **secret,
|
||||
IN _libssh2_wincng_ecdsa_key *privatekey,
|
||||
@@ -2555,7 +2519,6 @@ _libssh2_wincng_ecdsa_curve_type_from_name(IN const char *name,
|
||||
* Verifies the ECDSA signature of a hashed message
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_ecdsa_verify(IN _libssh2_wincng_ecdsa_key *key,
|
||||
IN const unsigned char *r,
|
||||
@@ -2658,7 +2621,6 @@ cleanup:
|
||||
* Creates a new private key given a file path and password
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_ecdsa_new_private(OUT _libssh2_wincng_ecdsa_key **key,
|
||||
IN LIBSSH2_SESSION *session,
|
||||
@@ -2942,10 +2904,9 @@ _libssh2_wincng_ecdsa_new_private_frommemory(
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = _libssh2_wincng_parse_ecdsa_privatekey(
|
||||
key,
|
||||
privatekey,
|
||||
privatekey_len);
|
||||
result = _libssh2_wincng_parse_ecdsa_privatekey(key,
|
||||
privatekey,
|
||||
privatekey_len);
|
||||
|
||||
cleanup:
|
||||
if(result != LIBSSH2_ERROR_NONE) {
|
||||
@@ -2964,7 +2925,6 @@ cleanup:
|
||||
* Computes the ECDSA signature of a previously-hashed message
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_ecdsa_sign(IN LIBSSH2_SESSION *session,
|
||||
IN _libssh2_wincng_ecdsa_key *key,
|
||||
@@ -3072,7 +3032,6 @@ cleanup:
|
||||
* returns key curve type that maps to libssh2_curve_type
|
||||
*
|
||||
*/
|
||||
|
||||
libssh2_curve_type
|
||||
_libssh2_wincng_ecdsa_get_curve_type(IN _libssh2_wincng_ecdsa_key *key)
|
||||
{
|
||||
@@ -3127,7 +3086,6 @@ _libssh2_wincng_pub_priv_keyfile_parse(LIBSSH2_SESSION *session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(length == 9) { /* private RSA key */
|
||||
mthlen = 7;
|
||||
mth = LIBSSH2_ALLOC(session, mthlen);
|
||||
@@ -3138,7 +3096,6 @@ _libssh2_wincng_pub_priv_keyfile_parse(LIBSSH2_SESSION *session,
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
||||
keylen = 4 + mthlen + 4 + rcbDecoded[2] + 4 + rcbDecoded[1];
|
||||
key = LIBSSH2_ALLOC(session, keylen);
|
||||
if(key) {
|
||||
@@ -3155,7 +3112,6 @@ _libssh2_wincng_pub_priv_keyfile_parse(LIBSSH2_SESSION *session,
|
||||
else {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
}
|
||||
else if(length == 6) { /* private DSA key */
|
||||
mthlen = 7;
|
||||
@@ -3198,7 +3154,6 @@ _libssh2_wincng_pub_priv_keyfile_parse(LIBSSH2_SESSION *session,
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
||||
for(index = 0; index < length; index++) {
|
||||
_libssh2_wincng_safe_free(rpbDecoded[index], rcbDecoded[index]);
|
||||
rpbDecoded[index] = NULL;
|
||||
@@ -3208,7 +3163,6 @@ _libssh2_wincng_pub_priv_keyfile_parse(LIBSSH2_SESSION *session,
|
||||
free(rpbDecoded);
|
||||
free(rcbDecoded);
|
||||
|
||||
|
||||
if(ret) {
|
||||
if(mth)
|
||||
LIBSSH2_FREE(session, mth);
|
||||
@@ -3343,7 +3297,6 @@ _libssh2_wincng_sk_pub_keyfilememory(LIBSSH2_SESSION *session,
|
||||
/*
|
||||
* Windows CNG backend: Cipher functions
|
||||
*/
|
||||
|
||||
int
|
||||
_libssh2_wincng_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
_libssh2_cipher_type(type),
|
||||
@@ -3380,7 +3333,6 @@ _libssh2_wincng_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
keylen = (ULONG)sizeof(BCRYPT_KEY_DATA_BLOB_HEADER) +
|
||||
type.dwKeyLength;
|
||||
header = (BCRYPT_KEY_DATA_BLOB_HEADER *)malloc(keylen);
|
||||
@@ -3389,7 +3341,6 @@ _libssh2_wincng_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
header->dwMagic = BCRYPT_KEY_DATA_BLOB_MAGIC;
|
||||
header->dwVersion = BCRYPT_KEY_DATA_BLOB_VERSION1;
|
||||
header->cbKeyData = type.dwKeyLength;
|
||||
@@ -3544,7 +3495,6 @@ _libssh2_wincng_cipher_dtor(_libssh2_cipher_ctx *ctx)
|
||||
ctx->dwCtrLength = 0;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: BigNumber functions
|
||||
@@ -3653,7 +3603,6 @@ _libssh2_wincng_bignum_mod_exp(_libssh2_bn *r,
|
||||
if(!rsakey)
|
||||
return -1;
|
||||
|
||||
|
||||
/* https://msdn.microsoft.com/library/windows/desktop/aa375531.aspx */
|
||||
rsakey->Magic = BCRYPT_RSAPUBLIC_MAGIC;
|
||||
rsakey->BitLength = m->length * 8;
|
||||
@@ -3815,7 +3764,6 @@ _libssh2_wincng_bignum_free(_libssh2_bn *bn)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: Diffie-Hellman support.
|
||||
|
||||
@@ -142,7 +142,6 @@ struct _libssh2_wincng_ctx {
|
||||
|
||||
extern struct _libssh2_wincng_ctx _libssh2_wincng;
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: Generic functions
|
||||
@@ -158,7 +157,6 @@ extern struct _libssh2_wincng_ctx _libssh2_wincng;
|
||||
|
||||
#define libssh2_prepare_iovec(vec, len) /* Empty. */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: Hash structure
|
||||
@@ -240,7 +238,6 @@ typedef struct __libssh2_wincng_hash_ctx {
|
||||
|
||||
#define libssh2_hmac_ctx _libssh2_wincng_hash_ctx
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: Key Context structure
|
||||
@@ -252,7 +249,6 @@ typedef struct __libssh2_wincng_key_ctx {
|
||||
DWORD cbKeyObject;
|
||||
} _libssh2_wincng_key_ctx;
|
||||
|
||||
|
||||
/*
|
||||
* Windows CNG backend: RSA functions
|
||||
*/
|
||||
@@ -303,7 +299,6 @@ typedef struct __libssh2_wincng_key_ctx {
|
||||
#define _libssh2_dsa_free(dsactx) \
|
||||
_libssh2_wincng_dsa_free(dsactx)
|
||||
|
||||
|
||||
/*
|
||||
* Windows CNG backend: ECDSA functions
|
||||
*/
|
||||
@@ -359,7 +354,6 @@ _libssh2_wincng_ecdsa_free(libssh2_ecdsa_ctx* ctx);
|
||||
#define _libssh2_ecdsa_free(ecdsactx) \
|
||||
_libssh2_wincng_ecdsa_free(ecdsactx)
|
||||
|
||||
|
||||
/*
|
||||
* Windows CNG backend: Key functions
|
||||
*/
|
||||
@@ -437,7 +431,6 @@ struct _libssh2_wincng_cipher_type {
|
||||
#define _libssh2_bn_ctx_new() 0 /* not used */
|
||||
#define _libssh2_bn_ctx_free(bnctx) ((void)0) /* not used */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
* Windows CNG backend: BigNumber structure
|
||||
|
||||
@@ -46,7 +46,6 @@ COPY sshd_config /tmp/etc/ssh/sshd_config
|
||||
RUN cat /tmp/etc/ssh/sshd_config >> /etc/ssh/sshd_config
|
||||
RUN echo 'TrustedUserCAKeys /etc/ssh/ca_user_keys.pub' >> /etc/ssh/sshd_config
|
||||
|
||||
|
||||
# SSH login fix. Otherwise user is kicked off after login
|
||||
RUN sed 's/session\s*required\s*pam_loginuid.so/session optional pam_loginuid.so/g' -i /etc/pam.d/sshd
|
||||
|
||||
|
||||
@@ -242,7 +242,6 @@ void stop_session_fixture(void)
|
||||
stop_openssh_fixture();
|
||||
}
|
||||
|
||||
|
||||
/* Return a static string that contains a file path relative to the srcdir
|
||||
* variable, if found.
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,6 @@ $!
|
||||
$exit
|
||||
$endsubroutine
|
||||
|
||||
|
||||
$Make: subroutine
|
||||
$!
|
||||
$ set noon
|
||||
@@ -65,7 +64,6 @@ $ delete objdir:'what'.obj;*
|
||||
$exit
|
||||
$endsubroutine
|
||||
|
||||
|
||||
$Init:
|
||||
$!
|
||||
$!
|
||||
|
||||
@@ -45,7 +45,6 @@ fpcopy(char *output, char *input, int len)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------*/
|
||||
/* give part of ilename in partname. See code for proper
|
||||
value of i ( 0 = node, 1 = dev, 2 = dir, 3 = name etc.
|
||||
@@ -146,7 +145,6 @@ int find_file(char *filename, char *gevonden, int *findex)
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------*/
|
||||
|
||||
manPtr addman(manPtr *manroot, char *filename)
|
||||
@@ -414,7 +412,6 @@ int convertman(char *filespec, FILE *hlp, int base_level, int add_parentheses)
|
||||
|
||||
*h = 0;
|
||||
|
||||
|
||||
if(return_status & 2) {
|
||||
fprintf(hlp, "%s\n\n", uit);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
by Jose Baars. This file will be installed as
|
||||
libssh2*.release_notes by the product install kit.
|
||||
|
||||
|
||||
LIBSSH2
|
||||
-------
|
||||
|
||||
@@ -39,7 +38,6 @@ multiple libraries including zlib.
|
||||
Install
|
||||
-------
|
||||
|
||||
|
||||
The kit will install gnv$libssh2.exe in a directory tree that might
|
||||
already be available on your system if you have installed other gnv*
|
||||
libraries or utilities.
|
||||
@@ -81,7 +79,6 @@ and 'YES' to either or both the following questions:
|
||||
|
||||
Do you want the complete libssh2 source tree ? [NO]
|
||||
|
||||
|
||||
Post installation tasks
|
||||
-----------------------
|
||||
|
||||
@@ -114,7 +111,6 @@ library provided in the source backup saveset. Both an uppercase and a
|
||||
mixed case object library, called libssh2.olb and libssh2_asis.olb
|
||||
are provided.
|
||||
|
||||
|
||||
Compiling and linking against libssh2
|
||||
-------------------------------------
|
||||
|
||||
@@ -138,9 +134,6 @@ $ cc/include=dev:[gnv.usr.include.libssh2] xxx.c/names=shortened
|
||||
$ link/opt=sys$input: xxx.obj
|
||||
gnv$libssh2/share
|
||||
|
||||
|
||||
|
||||
|
||||
Building gnv$libssh2
|
||||
====================
|
||||
|
||||
@@ -152,7 +145,6 @@ link against that. To check out new features, statically linking against
|
||||
the object library is probably more practical, to avoid compatibility
|
||||
issues.
|
||||
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
@@ -248,7 +240,6 @@ the complete libssh2 directory is made available in
|
||||
By restoring this backup saveset, you end up with the same
|
||||
set of files as by the direct download from libssh2.org.
|
||||
|
||||
|
||||
Building the library
|
||||
--------------------
|
||||
|
||||
@@ -263,8 +254,6 @@ command:
|
||||
|
||||
This should produce libssh2_x_y_z.exe in this same vms directory.
|
||||
|
||||
|
||||
|
||||
Building the examples
|
||||
---------------------
|
||||
|
||||
@@ -293,7 +282,6 @@ the procedure like so:
|
||||
The procedure defines a process logical gnv$libssh2 pointing to the shared
|
||||
image library in the directory, which obviously will not survive a logout.
|
||||
|
||||
|
||||
Building the help library
|
||||
-------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user