mirror of
https://github.com/php-win-ext/libssh2.git
synced 2026-03-24 09:02:12 +01:00
upgraded to libssh2 1.6.0
This commit is contained in:
493
NEWS
493
NEWS
@@ -1,5 +1,294 @@
|
||||
Changelog for the libssh2 project. Generated with git2news.pl
|
||||
|
||||
Version 1.6.0 (5 Jun 2015)
|
||||
|
||||
Daniel Stenberg (5 Jun 2015)
|
||||
- RELEASE-NOTES: synced with 858930cae5c6a
|
||||
|
||||
Marc Hoersken (19 May 2015)
|
||||
- wincng.c: fixed indentation
|
||||
|
||||
- [sbredahl brought this change]
|
||||
|
||||
wincng.c: fixed memleak in (block) cipher destructor
|
||||
|
||||
Alexander Lamaison (6 May 2015)
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
libssh2_channel_open: more detailed error message
|
||||
|
||||
The error message returned by libssh2_channel_open in case of a server side channel open failure is now more detailed and includes the four standard error conditions in RFC 4254.
|
||||
|
||||
- [Hannes Domani brought this change]
|
||||
|
||||
kex: fix libgcrypt memory leaks of bignum
|
||||
|
||||
Fixes #168.
|
||||
|
||||
Marc Hoersken (3 Apr 2015)
|
||||
- configure.ac: check for SecureZeroMemory for clear memory feature
|
||||
|
||||
- Revert "wincng.c: fix clear memory feature compilation with mingw"
|
||||
|
||||
This reverts commit 2d2744efdd0497b72b3e1ff6e732aa4c0037fc43.
|
||||
|
||||
Autobuilds show that this did not solve the issue.
|
||||
And it seems like RtlFillMemory is defined to memset,
|
||||
which would be optimized out by some compilers.
|
||||
|
||||
- wincng.c: fix clear memory feature compilation with mingw
|
||||
|
||||
Alexander Lamaison (1 Apr 2015)
|
||||
- [LarsNordin-LNdata brought this change]
|
||||
|
||||
Enable use of OpenSSL that doesn't have DSA.
|
||||
|
||||
Added #if LIBSSH2_DSA for all DSA functions.
|
||||
|
||||
- [LarsNordin-LNdata brought this change]
|
||||
|
||||
Use correct no-blowfish #define with OpenSSL.
|
||||
|
||||
The OpenSSL define is OPENSSL_NO_BF, not OPENSSL_NO_BLOWFISH.
|
||||
|
||||
Marc Hoersken (25 Mar 2015)
|
||||
- configure: error if explicitly enabled clear-memory is not supported
|
||||
|
||||
This takes 22bd8d81d8fab956085e2079bf8c29872455ce59 and
|
||||
b8289b625e291bbb785ed4add31f4759241067f3 into account,
|
||||
but still makes it enabled by default if it is supported
|
||||
and error out in case it is unsupported and was requested.
|
||||
|
||||
Daniel Stenberg (25 Mar 2015)
|
||||
- configure: make clear-memory default but only WARN if backend unsupported
|
||||
|
||||
... instead of previous ERROR.
|
||||
|
||||
Marc Hoersken (24 Mar 2015)
|
||||
- wincng.h: fix warning about computed return value not being used
|
||||
|
||||
- nonblocking examples: fix warning about unused tvdiff on Mac OS X
|
||||
|
||||
Daniel Stenberg (24 Mar 2015)
|
||||
- openssl: fix compiler warnings
|
||||
|
||||
- cofigure: fix --disable-clear-memory check
|
||||
|
||||
Marc Hoersken (23 Mar 2015)
|
||||
- scp.c: improved command length calculation
|
||||
|
||||
Reduced number of calls to strlen, because shell_quotearg already
|
||||
returns the length of the resulting string (e.q. quoted path)
|
||||
which we can add to the existing and known cmd_len.
|
||||
Removed obsolete call to memset again, because we can put a final
|
||||
NULL-byte at the end of the string using the calculated length.
|
||||
|
||||
- scp.c: improved and streamlined formatting
|
||||
|
||||
- scp.c: fix that scp_recv may transmit not initialised memory
|
||||
|
||||
- scp.c: fix that scp_send may transmit not initialised memory
|
||||
|
||||
Fixes ticket 244. Thanks Torsten.
|
||||
|
||||
- kex: do not ignore failure of libssh2_sha1_init()
|
||||
|
||||
Based upon 43b730ce56f010e9d33573fcb020df49798c1ed8.
|
||||
Fixes ticket 290. Thanks for the suggestion, mstrsn.
|
||||
|
||||
- wincng.h: fix return code of libssh2_md5_init()
|
||||
|
||||
- openssl.c: fix possible segfault in case EVP_DigestInit fails
|
||||
|
||||
- wincng.c: fix possible use of uninitialized variables
|
||||
|
||||
- wincng.c: fix unused argument warning if clear memory is not enabled
|
||||
|
||||
- wincng: Added explicit clear memory feature to WinCNG backend
|
||||
|
||||
This re-introduces the original feature proposed during
|
||||
the development of the WinCNG crypto backend. It still needs
|
||||
to be added to libssh2 itself and probably other backends.
|
||||
|
||||
Memory is cleared using the function SecureZeroMemory which is
|
||||
available on Windows systems, just like the WinCNG backend.
|
||||
|
||||
- wincng.c: fixed mixed line-endings
|
||||
|
||||
- wincng.c: fixed use of invalid parameter types in a8d14c5dcf
|
||||
|
||||
- wincng.c: only try to load keys corresponding to the algorithm
|
||||
|
||||
- wincng.c: moved PEM headers into definitions
|
||||
|
||||
- wincng.h: fixed invalid parameter name
|
||||
|
||||
- wincng: fixed mismatch with declarations in crypto.h
|
||||
|
||||
- userauth.c: fixed warning C6001: using uninitialized sig and sig_len
|
||||
|
||||
- pem.c: fixed warning C6269: possible incorrect order of operations
|
||||
|
||||
- wincng: add support for authentication keys to be passed in memory
|
||||
|
||||
Based upon 18cfec8336e and daa2dfa2db.
|
||||
|
||||
- pem.c: add _libssh2_pem_parse_memory to parse PEM from memory
|
||||
|
||||
Requirement to implement 18cfec8336e for Libgcrypt and WinCNG.
|
||||
|
||||
- pem.c: fix copy and paste mistake from 55d030089b8
|
||||
|
||||
- userauth.c: fix another possible dereference of a null pointer
|
||||
|
||||
- userauth.c: fix possible dereference of a null pointer
|
||||
|
||||
- pem.c: reduce number of calls to strlen in readline
|
||||
|
||||
Alexander Lamaison (17 Mar 2015)
|
||||
- [Will Cosgrove brought this change]
|
||||
|
||||
Initialise HMAC_CTX in more places.
|
||||
|
||||
Missed a couple more places we init ctx to avoid openssl threading crash.
|
||||
|
||||
- Build build breakage in WinCNG backend caused when adding libssh2_userauth_publickey_frommemory.
|
||||
|
||||
The new feature isn't implemented for the WinCNG backend currently, but the WinCNG backend didn't contain any implementation of the required backend functions - even ones that returns an error. That caused link errors.
|
||||
|
||||
This change fixes the problem by providing an implementation of the backend functions that returns an error.
|
||||
|
||||
- Fix breakage in WinCNG backend caused by introducing libssh2_hmac_ctx_init.
|
||||
|
||||
The macro was defined to nothing for the libgcrypt backend, but not for WinCNG. This brings the latter into line with the former.
|
||||
|
||||
Daniel Stenberg (15 Mar 2015)
|
||||
- userauth_publickey_frommemory.3: add AVAILABILITY
|
||||
|
||||
... it will be added in 1.6.0
|
||||
|
||||
- libssh2: next version will be called 1.6.0
|
||||
|
||||
... since we just added a new function.
|
||||
|
||||
- docs: add libssh2_userauth_publickey_frommemory.3 to dist
|
||||
|
||||
The function and man page were added in commit 18cfec8336e
|
||||
|
||||
- [Jakob Egger brought this change]
|
||||
|
||||
direct_tcpip: Fixed channel write
|
||||
|
||||
There were 3 bugs in this loop:
|
||||
1) Started from beginning after partial writes
|
||||
2) Aborted when 0 bytes were sent
|
||||
3) Ignored LIBSSH2_ERROR_EAGAIN
|
||||
|
||||
See also:
|
||||
https://trac.libssh2.org/ticket/281
|
||||
https://trac.libssh2.org/ticket/293
|
||||
|
||||
Alexander Lamaison (15 Mar 2015)
|
||||
- [Will Cosgrove brought this change]
|
||||
|
||||
Must init HMAC_CTX before using it.
|
||||
|
||||
Must init ctx before using it or openssl will reuse the hmac which is not thread safe and causes a crash.
|
||||
Added libssh2_hmac_ctx_init macro.
|
||||
|
||||
- Add continuous integration configurations.
|
||||
|
||||
Linux-based CI is done by Travis CI. Windows-based CI is done by Appveyor.
|
||||
|
||||
- [David Calavera brought this change]
|
||||
|
||||
Allow authentication keys to be passed in memory.
|
||||
|
||||
All credits go to Joe Turpin, I'm just reaplying and cleaning his patch:
|
||||
http://www.libssh2.org/mail/libssh2-devel-archive-2012-01/0015.shtml
|
||||
|
||||
* Use an unimplemented error for extracting keys from memory with libgcrypt.
|
||||
|
||||
Daniel Stenberg (14 Mar 2015)
|
||||
- docs: include the renamed INSTALL* files in dist
|
||||
|
||||
Alexander Lamaison (13 Mar 2015)
|
||||
- Prevent collisions between CMake and Autotools in examples/ and tests/.
|
||||
|
||||
- Avoid clash between CMake build and Autotools.
|
||||
|
||||
Autotools expects a configuration template file at src/libssh2_config.h.in, which buildconf generates. But the CMake build system has its CMake-specific version of the file at this path. This means that, if you don't run buildconf, the Autotools build will fail because it configured the wrong header template.
|
||||
|
||||
See https://github.com/libssh2/libssh2/pull/8.
|
||||
|
||||
- Merge pull request #8 from alamaison/cmake
|
||||
|
||||
CMake build system.
|
||||
|
||||
- CMake build system.
|
||||
|
||||
Tested:
|
||||
- Windows:
|
||||
- Visual C++ 2005/2008/2010/2012/2013/MinGW-w64
|
||||
- static/shared
|
||||
- 32/64-bit
|
||||
- OpenSSL/WinCNG
|
||||
- Without zlib
|
||||
- Linux:
|
||||
- GCC 4.6.3/Clang 3.4
|
||||
- static/shared
|
||||
- 32/64-bit
|
||||
- OpenSSL/Libgcrypt
|
||||
- With/Without zlib
|
||||
- MacOS X
|
||||
- AppleClang 6.0.0
|
||||
- static
|
||||
- 64-bit
|
||||
- OpenSSL
|
||||
- Without zlib
|
||||
|
||||
Conflicts:
|
||||
README
|
||||
|
||||
- Man man syntax tests fail gracefully if man version is not suitable.
|
||||
|
||||
- Return valid code from test fixture on failure.
|
||||
|
||||
The sshd test fixture was returning -1 if an error occurred, but negative error codes aren't technically valid (google it). Bash on Windows converted them to 0 which made setup failure look as though all tests were passing.
|
||||
|
||||
- Let mansyntax.sh work regardless of where it is called from.
|
||||
|
||||
Daniel Stenberg (12 Mar 2015)
|
||||
- [Viktor Szakáts brought this change]
|
||||
|
||||
mingw build: allow to pass custom CFLAGS
|
||||
|
||||
Allow to pass custom `CFLAGS` options via environment variable
|
||||
`LIBSSH2_CFLAG_EXTRAS`. Default and automatically added options of
|
||||
`GNUmakefile` have preference over custom ones. This addition is useful
|
||||
for passing f.e. custom CPU tuning or LTO optimization (`-flto
|
||||
-ffat-lto-objects`) options. The only current way to do this is to edit
|
||||
`GNUmakefile`. This patch makes it unnecessary.
|
||||
|
||||
This is a mirror of similar libcurl patch:
|
||||
https://github.com/bagder/curl/pull/136
|
||||
|
||||
- [Will Cosgrove brought this change]
|
||||
|
||||
userauth: Fixed prompt text no longer being copied to the prompts struct
|
||||
|
||||
Regression from 031566f9c
|
||||
|
||||
- README: update the git repo locations
|
||||
|
||||
- wait_socket: wrong use of difftime()
|
||||
|
||||
With reversed arguments it would always return a negative value...
|
||||
|
||||
Bug: https://github.com/bagder/libssh2/issues/1
|
||||
|
||||
- bump: start working toward 1.5.1 now
|
||||
|
||||
Version 1.5.0 (11 Mar 2015)
|
||||
|
||||
Daniel Stenberg (11 Mar 2015)
|
||||
@@ -4933,207 +5222,3 @@ Daniel Stenberg (18 Jul 2009)
|
||||
- Ben Kibbey fixed the hostline() when parsing lines using only one hostname
|
||||
|
||||
- Merge branch 'master' of ssh://bagder@git.stuge.se/var/lib/git/libssh2
|
||||
|
||||
- Provide a libssh2_scp_send() API for files larger than 4GB (32bit size)
|
||||
|
||||
- Olivier Hervieu provided this x11 forwarding example. This is the version
|
||||
after my initial cleanup that I posted to the list on May 26th 2009. It still
|
||||
has a few ugly spots that should be cleaned up, but until then it's will at
|
||||
least be found in the repo. For this reason I don't add this to the makefile.
|
||||
|
||||
- New man page for libssh2_session_hostkey(3). We probably need to improve this
|
||||
to also return the type of the key.
|
||||
|
||||
- Add check for and use of the _REENTRANT define for Solaris so that libssh2
|
||||
is then properly thread-safe on that OS. These autuconf macros are straight
|
||||
from the cURL project and were mostly written by Yang Tse. They were only
|
||||
very slightly edited by me when imported to here.
|
||||
|
||||
- [Tor Arntsen brought this change]
|
||||
|
||||
Ignore generated files
|
||||
|
||||
- use the correct #if condition for strtoll(), pointed out in bug report
|
||||
|
||||
- define the HAVE_LIBSSH2_KNOWNHOST_API to the version number 1.1.1 to make apps
|
||||
know that when this define exists, the API exists. And the version number can
|
||||
be used for run-time checks. 1.1.1 is not likely to be the release version as
|
||||
I think we'll go with 1.2 instead but 1.1.1 OR LATER should still work.
|
||||
|
||||
- libssh2_knownhost_add() got an additional argument: 'store' so that an
|
||||
application can get a pointer back to the internal representation of the host
|
||||
it just added. Useful for example when the app wants to add a host, and then
|
||||
convert that exact same host to a line for storing in a known host file.
|
||||
'store' can also be set to NULL to simple not care.
|
||||
|
||||
- Added a call to libssh2_knownhost_writefile()
|
||||
|
||||
Updated to the slightly modified libssh2_knownhost_check() proto
|
||||
|
||||
- "struct libssh2_knownhost" is now part of the internal struct for each known
|
||||
host so we now only return pointers to structs instead of having the app
|
||||
allocate a full struct
|
||||
|
||||
I moved the private struct definition into knownhosts.c instead of exposing it
|
||||
wider in libssh2_priv.h
|
||||
|
||||
I thus modified the proto for two functions that previously used 'struct
|
||||
libssh2_knownhost *' to receive data.
|
||||
|
||||
- when a host is added, we must make sure the app also provides a key *type* even
|
||||
though we don't use the type in this function
|
||||
|
||||
- Added man pages for the two newest members of the knownhosts API family:
|
||||
libssh2_knownhost_readline() and libssh2_knownhost_writeline()
|
||||
|
||||
- introducing libssh2_knownhost_writeline() and some cleanups to use more
|
||||
defined error codes instead of the simplified -1 previously used a little too
|
||||
much here
|
||||
|
||||
- I think *readline() makes a better name
|
||||
|
||||
- clarify that the key "string" needs to be zero terminated too
|
||||
|
||||
- introducing libssh2_knownhost_read() that makes libssh2 read a single given
|
||||
line
|
||||
const'ified a few args to libssh2_knownhost_add() as well
|
||||
|
||||
- fix a warning for a comparison mixing signed and unsigned types
|
||||
|
||||
- After review/feedback/discussions on the mailing list. Rename two functions:
|
||||
|
||||
s/libssh2_knownhost_parsefile/libssh2_knownhost_readfile
|
||||
s/libssh2_knownhost_dumpfile/libssh2_knownhost_writefile
|
||||
|
||||
- define removed
|
||||
|
||||
- LIBSSH2_KNOWNHOST_TYPE_DEFAULT is not a good idea, scrap it
|
||||
|
||||
- Added the initial man pages for the 7 new functions for known host handling
|
||||
|
||||
- first shot at implementing libssh2_knownhost_dumpfile() and some minor
|
||||
cleanups
|
||||
|
||||
- introducing libssh2_knownhost_get() to the public API
|
||||
|
||||
- clarified a comment
|
||||
|
||||
- slighty better behavior and comments
|
||||
|
||||
- remove include since we don't use struct iovec in this file
|
||||
|
||||
- These examples no longer need to explictly set the socket to non-blocking state
|
||||
as libssh2 itself will always do that by itself.
|
||||
|
||||
- add myself as copyright owner
|
||||
|
||||
- mention conversion of code to the new linked list code
|
||||
|
||||
- remove #if 0'ed code
|
||||
|
||||
- clarify the fix, as it wasn't a leak
|
||||
|
||||
- spell fix a comment
|
||||
|
||||
- Added some clarifying comments on how the 'sftpInit_sftp' and
|
||||
'sftpInit_channel' struct fields within the session struct are used. And made
|
||||
sure to clear them both correctly when sftp_init() returns instead of at
|
||||
shutdown time, as it must not touch them at shutdown time. This should make it
|
||||
possible to properly make more than one SFTP handle.
|
||||
|
||||
- no need for LIBSSH2_ERROR_MEMORY when LIBSSH2_ERROR_ALLOC already exist!
|
||||
added my own copyright line too now
|
||||
|
||||
- use LIBSSH2_ERROR_ALLOC instead of introducing a new error code
|
||||
|
||||
- clear session->sftpInit_sftp unconditionally
|
||||
|
||||
- Fix my recent session->sftpInit_sftp fix which wasn't correct. The memory area
|
||||
does not need to be freed (it already gets freed) but clearing the pointer is
|
||||
a good idea. And it should be done _after_ the channel_free() call.
|
||||
|
||||
- add an assert to help debugging
|
||||
|
||||
- Without CVS we must not use cvs tools to generate the changelog. I'm not
|
||||
confident enough with git to attempt to make one so I'll just make a dummy for
|
||||
now.
|
||||
|
||||
- - Anonymous bug report #2795816 revealed that libssh2_sftp_shutdown() did not
|
||||
properly free/cleanup the SFTP handle so libssh2 leaked memory and caused
|
||||
an assert() on subsequent libssh2_sftp_init() calls on the same session.
|
||||
|
||||
- Fix _libssh2_channel_write(): fixed the write loop to also read from the
|
||||
transport layer better, to avoid draining the window size when sending large
|
||||
packets. I also fixed the return code for it to return the number of bytes
|
||||
handled in this single invoke (and not the cumulative amount).
|
||||
|
||||
- First, only try to send max packet size *4 to channel write, as trying to send
|
||||
much larger packages only cause internal problems and much larger allocations.
|
||||
|
||||
Also fix sftp_write() when _libssh2_channel_write() returns that a packet was
|
||||
only partially sent as that is not an error.
|
||||
|
||||
Fixed a few error messages to more accurately point out the problem
|
||||
|
||||
- If recv() returns something less than the full buffer we know we're done for
|
||||
now, so skip looping and doing another read that then simply will cause an
|
||||
EAGAIN as it may trick the user into believing things that aren't true.
|
||||
|
||||
daniel (14 May 2009)
|
||||
- remove the old style as it makes little sense to mention here anymore
|
||||
|
||||
Daniel Stenberg (12 May 2009)
|
||||
- typo
|
||||
|
||||
- comment typo and some indent fixes
|
||||
|
||||
- Partial fix based on the patch and discussions in #2788319
|
||||
|
||||
- clear the passed in struct when the entry has been removed to help prevent
|
||||
mistakes due to re-use
|
||||
|
||||
- use a better example file name for the known_hosts file
|
||||
|
||||
- split out the knownhost code from hostkey.c into its own separate source file
|
||||
now: knownhost.c
|
||||
|
||||
- this was never supposed to be added for real
|
||||
|
||||
- My knownhost work as of right now. It works at least partly. More tests and
|
||||
tweaks will come.
|
||||
|
||||
- get host, user, password and command from the command line
|
||||
|
||||
- Added ssh2_exec as a new example, showing how to run a command remotely with
|
||||
libssh2
|
||||
|
||||
- bug #2785173 pointed out that we really must call _libssh2_transport_read()
|
||||
in loops until it returns < 0 when we call it, as if we just call it once we
|
||||
may drain the socket for data and then leave unused in-memory data that we
|
||||
won't detect because the socket is back to idle...
|
||||
|
||||
- Markus posted a bug report about a bad 0-return from libssh2_channel_read:
|
||||
http://libssh2.haxx.se/mail/libssh2-devel-archive-2009-04/0076.shtml
|
||||
|
||||
And it was indeed a bad loop that terminated too early due to a receveived
|
||||
close packet.
|
||||
|
||||
- remove pointless sleeps
|
||||
|
||||
- edited
|
||||
|
||||
- libssh2_poll() and libssh2_poll_channel_read() are now considered and
|
||||
documented deprecated and they will be removed at next soname bump. It also
|
||||
saves us from fixing some rather quirky bugs in libssh2_poll()...
|
||||
|
||||
Guenter Knauf (9 Apr 2009)
|
||||
- some minor Makefile tweaks; mainly for crosscompiling.
|
||||
|
||||
Daniel Stenberg (6 Apr 2009)
|
||||
- Jussi Mononen pointed out we used an unsigned variable to store negative
|
||||
values in, when a plain int is much better anyway since it matches the return
|
||||
type.
|
||||
|
||||
- and we're now on the 1.1.1 track
|
||||
|
||||
- release 1.1
|
||||
|
||||
8
README
8
README
@@ -10,8 +10,10 @@ Mailing list: http://cool.haxx.se/mailman/listinfo/libssh2-devel
|
||||
|
||||
License: see COPYING
|
||||
|
||||
Source code: https://github.com/bagder/libssh2
|
||||
Source code: https://github.com/libssh2/libssh2
|
||||
|
||||
Web site source code: https://github.com/bagder/libssh2-www
|
||||
Web site source code: https://github.com/libssh2/www
|
||||
|
||||
Installation instructions are in docs/INSTALL
|
||||
Installation instructions are in:
|
||||
- docs/INSTALL_CMAKE for CMake
|
||||
- docs/INSTALL_AUTOTOOLS for Autotools
|
||||
|
||||
106
RELEASE-NOTES
106
RELEASE-NOTES
@@ -1,83 +1,45 @@
|
||||
libssh2 1.5.0
|
||||
libssh2 1.6.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o Added Windows Cryptography API: Next Generation based backend
|
||||
o Added CMake build system
|
||||
o Added libssh2_userauth_publickey_frommemory()
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o Security Advisory for CVE-2015-1782, using SSH_MSG_KEXINIT data unbounded
|
||||
o missing _libssh2_error in _libssh2_channel_write
|
||||
o knownhost: Fix DSS keys being detected as unknown.
|
||||
o knownhost: Restore behaviour of `libssh2_knownhost_writeline` with short buffer.
|
||||
o libssh2.h: on Windows, a socket is of type SOCKET, not int
|
||||
o libssh2_priv.h: a 1 bit bit-field should be unsigned
|
||||
o windows build: do not export externals from static library
|
||||
o Fixed two potential use-after-frees of the payload buffer
|
||||
o Fixed a few memory leaks in error paths
|
||||
o userauth: Fixed an attempt to free from stack on error
|
||||
o agent_list_identities: Fixed memory leak on OOM
|
||||
o knownhosts: Abort if the hosts buffer is too small
|
||||
o sftp_close_handle: ensure the handle is always closed
|
||||
o channel_close: Close the channel even in the case of errors
|
||||
o docs: added missing libssh2_session_handshake.3 file
|
||||
o docs: fixed a bunch of typos
|
||||
o userauth_password: pass on the underlying error code
|
||||
o _libssh2_channel_forward_cancel: accessed struct after free
|
||||
o _libssh2_packet_add: avoid using uninitialized memory
|
||||
o _libssh2_channel_forward_cancel: avoid memory leaks on error
|
||||
o _libssh2_channel_write: client spins on write when window full
|
||||
o windows build: fix build errors
|
||||
o publickey_packet_receive: avoid junk in returned pointers
|
||||
o channel_receive_window_adjust: store windows size always
|
||||
o userauth_hostbased_fromfile: zero assign to avoid uninitialized use
|
||||
o configure: change LIBS not LDFLAGS when checking for libs
|
||||
o agent_connect_unix: make sure there's a trailing zero
|
||||
o MinGW build: Fixed redefine warnings.
|
||||
o sftpdir.c: added authentication method detection.
|
||||
o Watcom build: added support for WinCNG build.
|
||||
o configure.ac: replace AM_CONFIG_HEADER with AC_CONFIG_HEADERS
|
||||
o sftp_statvfs: fix for servers not supporting statfvs extension
|
||||
o knownhost.c: use LIBSSH2_FREE macro instead of free
|
||||
o Fixed compilation using mingw-w64
|
||||
o knownhost.c: fixed that 'key_type_len' may be used uninitialized
|
||||
o configure: Display individual crypto backends on separate lines
|
||||
o examples on Windows: check for WSAStartup return code
|
||||
o examples on Windows: check for socket return code
|
||||
o agent.c: check return code of MapViewOfFile
|
||||
o kex.c: fix possible NULL pointer de-reference with session->kex
|
||||
o packet.c: fix possible NULL pointer de-reference within listen_state
|
||||
o tests on Windows: check for WSAStartup return code
|
||||
o userauth.c: improve readability and clarity of for-loops
|
||||
o examples on Windows: use native SOCKET-type instead of int
|
||||
o packet.c: i < 256 was always true and i would overflow to 0
|
||||
o kex.c: make sure mlist is not set to NULL
|
||||
o session.c: check return value of session_nonblock in debug mode
|
||||
o session.c: check return value of session_nonblock during startup
|
||||
o userauth.c: make sure that sp_len is positive and avoid overflows
|
||||
o knownhost.c: fix use of uninitialized argument variable wrote
|
||||
o openssl: initialise the digest context before calling EVP_DigestInit()
|
||||
o libssh2_agent_init: init ->fd to LIBSSH2_INVALID_SOCKET
|
||||
o configure.ac: Add zlib to Requires.private in libssh2.pc if using zlib
|
||||
o configure.ac: Rework crypto library detection
|
||||
o configure.ac: Reorder --with-* options in --help output
|
||||
o configure.ac: Call zlib zlib and not libz in text but keep option names
|
||||
o Fix non-autotools builds: Always define the LIBSSH2_OPENSSL CPP macro
|
||||
o sftp: seek: Don't flush buffers on same offset
|
||||
o sftp: statvfs: Along error path, reset the correct 'state' variable.
|
||||
o sftp: Add support for fsync (OpenSSH extension).
|
||||
o _libssh2_channel_read: fix data drop when out of window
|
||||
o comp_method_zlib_decomp: Improve buffer growing algorithm
|
||||
o _libssh2_channel_read: Honour window_size_initial
|
||||
o window_size: redid window handling for flow control reasons
|
||||
o knownhosts: handle unknown key types
|
||||
|
||||
o wait_socket: wrong use of difftime() [1]
|
||||
o userauth: Fixed prompt text no longer being copied to the prompts struct
|
||||
o mingw build: allow to pass custom CFLAGS
|
||||
o Let mansyntax.sh work regardless of where it is called from
|
||||
o Init HMAC_CTX before using it
|
||||
o direct_tcpip: Fixed channel write
|
||||
o WinCNG: fixed backend breakage
|
||||
o OpenSSL: caused by introducing libssh2_hmac_ctx_init
|
||||
o userauth.c: fix possible dereferences of a null pointer
|
||||
o wincng: Added explicit clear memory feature to WinCNG backend
|
||||
o openssl.c: fix possible segfault in case EVP_DigestInit fails
|
||||
o wincng: fix return code of libssh2_md5_init()
|
||||
o kex: do not ignore failure of libssh2_sha1_init()
|
||||
o scp: fix that scp_send may transmit not initialised memory [3]
|
||||
o scp.c: improved command length calculation
|
||||
o nonblocking examples: fix warning about unused tvdiff on Mac OS X
|
||||
o configure: make clear-memory default but WARN if backend unsupported
|
||||
o OpenSSL: Enable use of OpenSSL that doesn't have DSA
|
||||
o OpenSSL: Use correct no-blowfish #define
|
||||
o kex: fix libgcrypt memory leaks of bignum [2]
|
||||
o libssh2_channel_open: more detailed error message
|
||||
o wincng: fixed memleak in (block) cipher destructor
|
||||
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alexander Lamaison, Bob Kast, Dan Fandrich, Daniel Stenberg, Guenter Knauf,
|
||||
Kamil Dudka, Leif Salomonsson, Marc Hörsken, Mark McPherson,
|
||||
Matthias Kerestesch, Mikhail Gusarov, Peter Stuge, Richard W.M. Jones,
|
||||
Salvador Fandino, Seth Willits, Mariusz Ziulek
|
||||
Alexander Lamaison, Daniel Stenberg, David Calavera, Hannes Domani,
|
||||
Jakob Egger, Joe Turpin, Marc Hoersken, Viktor Szakáts, Will Cosgrove,
|
||||
(9 contributors)
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
||||
[1] = https://github.com/bagder/libssh2/issues/1
|
||||
[2] = https://trac.libssh2.org/ticket/168
|
||||
[3] = https://trac.libssh2.org/ticket/244
|
||||
|
||||
98
configure
vendored
98
configure
vendored
@@ -815,6 +815,7 @@ with_libz_prefix
|
||||
enable_crypt_none
|
||||
enable_mac_none
|
||||
enable_gex_new
|
||||
enable_clear_memory
|
||||
enable_debug
|
||||
enable_hidden_symbols
|
||||
enable_examples_build
|
||||
@@ -1466,6 +1467,7 @@ Optional Features:
|
||||
--enable-mac-none Permit "none" MAC -- NOT RECOMMENDED
|
||||
--disable-gex-new Disable "new" diffie-hellman-group-exchange-sha1
|
||||
method
|
||||
--disable-clear-memory Disable clearing of memory before being freed
|
||||
--enable-debug Enable pedantic and debug options
|
||||
--disable-debug Disable debug options
|
||||
--enable-hidden-symbols Hide internal symbols in library
|
||||
@@ -1904,6 +1906,52 @@ $as_echo "$ac_res" >&6; }
|
||||
|
||||
} # ac_fn_c_check_func
|
||||
|
||||
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
|
||||
# ---------------------------------------------
|
||||
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
|
||||
# accordingly.
|
||||
ac_fn_c_check_decl ()
|
||||
{
|
||||
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
|
||||
as_decl_name=`echo $2|sed 's/ *(.*//'`
|
||||
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
|
||||
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
|
||||
if eval \${$3+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
$4
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#ifndef $as_decl_name
|
||||
#ifdef __cplusplus
|
||||
(void) $as_decl_use;
|
||||
#else
|
||||
(void) $as_decl_name;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
eval "$3=yes"
|
||||
else
|
||||
eval "$3=no"
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
eval ac_res=\$$3
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
||||
$as_echo "$ac_res" >&6; }
|
||||
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
||||
|
||||
} # ac_fn_c_check_decl
|
||||
|
||||
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
|
||||
# -------------------------------------------------------
|
||||
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
|
||||
@@ -13515,6 +13563,7 @@ fi
|
||||
|
||||
|
||||
found_crypto=none
|
||||
support_clear_memory=no
|
||||
|
||||
# Look for OpenSSL
|
||||
if test "$found_crypto" = "none" && test "$use_openssl" != "no"; then
|
||||
@@ -15862,6 +15911,20 @@ fi
|
||||
|
||||
done
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "SecureZeroMemory" "ac_cv_have_decl_SecureZeroMemory" "
|
||||
#include <windows.h>
|
||||
|
||||
"
|
||||
if test "x$ac_cv_have_decl_SecureZeroMemory" = xyes; then :
|
||||
ac_have_decl=1
|
||||
else
|
||||
ac_have_decl=0
|
||||
fi
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_DECL_SECUREZEROMEMORY $ac_have_decl
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
|
||||
@@ -15873,6 +15936,9 @@ $as_echo "#define LIBSSH2_WINCNG 1" >>confdefs.h
|
||||
LIBS="$LIBS -lcrypt32"
|
||||
fi
|
||||
found_crypto="Windows Cryptography API: Next Generation"
|
||||
if test "$ac_cv_have_decl_SecureZeroMemory" = "yes"; then
|
||||
support_clear_memory=yes
|
||||
fi
|
||||
fi
|
||||
if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
WINCNG_TRUE=
|
||||
@@ -16463,6 +16529,36 @@ $as_echo "#define LIBSSH2_DH_GEX_NEW 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
# Check whether --enable-clear-memory was given.
|
||||
if test "${enable_clear_memory+set}" = set; then :
|
||||
enableval=$enable_clear_memory; CLEAR_MEMORY=$enableval
|
||||
fi
|
||||
|
||||
if test "$CLEAR_MEMORY" != "no"; then
|
||||
if test "$support_clear_memory" = "yes"; then
|
||||
|
||||
$as_echo "#define LIBSSH2_CLEAR_MEMORY 1" >>confdefs.h
|
||||
|
||||
enable_clear_memory=yes
|
||||
else
|
||||
if test "$CLEAR_MEMORY" = "yes"; then
|
||||
as_fn_error $? "secure clearing/zeroing of memory is not supported by the selected crypto backend" "$LINENO" 5
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: secure clearing/zeroing of memory is not supported by the selected crypto backend" >&5
|
||||
$as_echo "$as_me: WARNING: secure clearing/zeroing of memory is not supported by the selected crypto backend" >&2;}
|
||||
fi
|
||||
enable_clear_memory=unsupported
|
||||
fi
|
||||
else
|
||||
if test "$support_clear_memory" = "yes"; then
|
||||
enable_clear_memory=no
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: secure clearing/zeroing of memory is not supported by the selected crypto backend" >&5
|
||||
$as_echo "$as_me: WARNING: secure clearing/zeroing of memory is not supported by the selected crypto backend" >&2;}
|
||||
enable_clear_memory=unsupported
|
||||
fi
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable pedantic and debug compiler options" >&5
|
||||
$as_echo_n "checking whether to enable pedantic and debug compiler options... " >&6; }
|
||||
# Check whether --enable-debug was given.
|
||||
@@ -19789,6 +19885,7 @@ fi
|
||||
Compiler flags: ${CFLAGS}
|
||||
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||
Crypto library: ${found_crypto}
|
||||
Clear memory: $enable_clear_memory
|
||||
Debug build: $enable_debug
|
||||
Build examples: $build_examples
|
||||
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
|
||||
@@ -19803,6 +19900,7 @@ $as_echo "$as_me: summary of build options:
|
||||
Compiler flags: ${CFLAGS}
|
||||
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||
Crypto library: ${found_crypto}
|
||||
Clear memory: $enable_clear_memory
|
||||
Debug build: $enable_debug
|
||||
Build examples: $build_examples
|
||||
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
|
||||
|
||||
32
configure.ac
32
configure.ac
@@ -97,6 +97,7 @@ AC_ARG_WITH(libz,
|
||||
use_libz=$withval,use_libz=auto)
|
||||
|
||||
found_crypto=none
|
||||
support_clear_memory=no
|
||||
|
||||
# Look for OpenSSL
|
||||
if test "$found_crypto" = "none" && test "$use_openssl" != "no"; then
|
||||
@@ -141,6 +142,9 @@ if test "$found_crypto" = "none" && test "$use_wincng" != "no"; then
|
||||
AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [
|
||||
#include <windows.h>
|
||||
])
|
||||
AC_CHECK_DECLS([SecureZeroMemory], [], [], [
|
||||
#include <windows.h>
|
||||
])
|
||||
fi
|
||||
if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_WINCNG, 1, [Use Windows CNG])
|
||||
@@ -150,6 +154,9 @@ if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
LIBS="$LIBS -lcrypt32"
|
||||
fi
|
||||
found_crypto="Windows Cryptography API: Next Generation"
|
||||
if test "$ac_cv_have_decl_SecureZeroMemory" = "yes"; then
|
||||
support_clear_memory=yes
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(WINCNG, test "$ac_cv_libbcrypt" = "yes")
|
||||
|
||||
@@ -197,6 +204,30 @@ if test "$GEX_NEW" != "no"; then
|
||||
AC_DEFINE(LIBSSH2_DH_GEX_NEW, 1, [Enable newer diffie-hellman-group-exchange-sha1 syntax])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(clear-memory,
|
||||
AC_HELP_STRING([--disable-clear-memory],[Disable clearing of memory before being freed]),
|
||||
[CLEAR_MEMORY=$enableval])
|
||||
if test "$CLEAR_MEMORY" != "no"; then
|
||||
if test "$support_clear_memory" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_CLEAR_MEMORY, 1, [Enable clearing of memory before being freed])
|
||||
enable_clear_memory=yes
|
||||
else
|
||||
if test "$CLEAR_MEMORY" = "yes"; then
|
||||
AC_MSG_ERROR([secure clearing/zeroing of memory is not supported by the selected crypto backend])
|
||||
else
|
||||
AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend])
|
||||
fi
|
||||
enable_clear_memory=unsupported
|
||||
fi
|
||||
else
|
||||
if test "$support_clear_memory" = "yes"; then
|
||||
enable_clear_memory=no
|
||||
else
|
||||
AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend])
|
||||
enable_clear_memory=unsupported
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl ************************************************************
|
||||
dnl option to switch on compiler debug options
|
||||
dnl
|
||||
@@ -362,6 +393,7 @@ AC_MSG_NOTICE([summary of build options:
|
||||
Compiler flags: ${CFLAGS}
|
||||
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||
Crypto library: ${found_crypto}
|
||||
Clear memory: $enable_clear_memory
|
||||
Debug build: $enable_debug
|
||||
Build examples: $build_examples
|
||||
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
|
||||
|
||||
174
docs/INSTALL_CMAKE
Normal file
174
docs/INSTALL_CMAKE
Normal file
@@ -0,0 +1,174 @@
|
||||
License: see COPYING
|
||||
|
||||
Source code: https://github.com/libssh2/libssh2
|
||||
|
||||
Web site source code: https://github.com/libssh2/www
|
||||
|
||||
Installation instructions are in docs/INSTALL
|
||||
=======
|
||||
To build libssh2 you will need CMake v2.8 or later [1] and one of the
|
||||
following cryptography libraries:
|
||||
|
||||
* OpenSSL
|
||||
* Libgcrypt
|
||||
* WinCNG
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
|
||||
If you are happy with the default options, make a new build directory,
|
||||
change to it, configure the build environment and build the project:
|
||||
|
||||
mkdir bin
|
||||
cd bin
|
||||
cmake ..
|
||||
cmake --build .
|
||||
|
||||
libssh2 will be built as a static library and will use any
|
||||
cryptography library available. The library binary will be put in
|
||||
`bin/src`, with the examples in `bin/example` and the tests in
|
||||
`bin/tests`.
|
||||
|
||||
Customising the build
|
||||
---------------------
|
||||
|
||||
Of course, you might want to customise the build options. You can
|
||||
pass the options to CMake on the command line:
|
||||
|
||||
cmake -D<option>=<value> ..
|
||||
|
||||
The following options are available:
|
||||
|
||||
* `BUILD_SHARED_LIBS=OFF`
|
||||
|
||||
Determines whether libssh2 is built as a static library or as a
|
||||
shared library (.dll/.so). Can be `ON` or `OFF`.
|
||||
|
||||
* `CRYPTO_BACKEND=`
|
||||
|
||||
Chooses a specific cryptography library to use for cryptographic
|
||||
operations. Can be `OpenSSL` (http://www.openssl.org),
|
||||
`Libgcrypt` (http://www.gnupg.org/), `WinCNG` (Windows Vista+) or
|
||||
blank to use any library available.
|
||||
|
||||
CMake will attempt to locate the libraries automatically. See [2]
|
||||
for more information.
|
||||
|
||||
* `ENABLE_ZLIB_COMPRESSION=OFF`
|
||||
|
||||
Will use zlib (http://www.zlib.org) for payload compression. Can
|
||||
be `ON` or `OFF`.
|
||||
|
||||
* `ENABLE_CRYPT_NONE=OFF`
|
||||
|
||||
The SSH2 Transport allows for unencrypted data transmission using
|
||||
the "none" cipher. Because this is such a huge security hole, it
|
||||
is typically disabled on SSH2 implementations and is disabled in
|
||||
libssh2 by default as well.
|
||||
|
||||
Enabling this option will allow for "none" as a negotiable method,
|
||||
however it still requires that the method be advertized by the
|
||||
remote end and that no more-preferable methods are available.
|
||||
|
||||
* `ENABLE_MAC_NONE=OFF`
|
||||
|
||||
The SSH2 Transport also allows implementations to forego a message
|
||||
authentication code. While this is less of a security risk than
|
||||
using a "none" cipher, it is still not recommended as disabling
|
||||
MAC hashes removes a layer of security.
|
||||
|
||||
Enabling this option will allow for "none" as a negotiable method,
|
||||
however it still requires that the method be advertized by the
|
||||
remote end and that no more-preferable methods are available.
|
||||
|
||||
* `ENABLE_GEX_NEW=ON`
|
||||
|
||||
The diffie-hellman-group-exchange-sha1 (dh-gex) key exchange
|
||||
method originally defined an exchange negotiation using packet
|
||||
type 30 to request a generation pair based on a single target
|
||||
value. Later refinement of dh-gex provided for range and target
|
||||
values. By default libssh2 will use the newer range method.
|
||||
|
||||
If you experience trouble connecting to an old SSH server using
|
||||
dh-gex, try this option to fallback on the older more reliable
|
||||
method.
|
||||
|
||||
* `ENABLE_DEBUG_LOGGING=ON` in Debug, `=OFF` in Release
|
||||
|
||||
Will enable the libssh2_trace() function for showing debug traces.
|
||||
|
||||
Build tools
|
||||
-----------
|
||||
|
||||
The previous examples used CMake to start the build using:
|
||||
|
||||
cmake --build .
|
||||
|
||||
Alternatively, once CMake has configured your project, you can just
|
||||
use your own build tool, e.g GNU make, Visual Studio, etc., from that
|
||||
point onwards.
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
To test the build, run the appropriate test target for your build
|
||||
system. For example:
|
||||
|
||||
cmake --build . --target test
|
||||
or
|
||||
cmake --build . --target RUN_TESTS
|
||||
|
||||
How do I use libssh2 in my project if my project doesn't use CMake?
|
||||
-------------------------------------------------------------------
|
||||
|
||||
If you are not using CMake for your own project, install libssh2
|
||||
|
||||
cmake <libssh2 source location>
|
||||
cmake --build .
|
||||
cmake --build . --target install
|
||||
or
|
||||
cmake --build . --target INSTALL
|
||||
|
||||
and then specify the install location to your project in the normal
|
||||
way for your build environment. If you don't like the default install
|
||||
location, add `-DCMAKE_INSTALL_PREFIX=<chosen prefix>` when initially
|
||||
configuring the project.
|
||||
|
||||
How can I use libssh2 in my project if it also uses CMake?
|
||||
----------------------------------------------------------
|
||||
|
||||
If your own project also uses CMake, you don't need to worry about
|
||||
setting it up with libssh2's location. Just add just the following
|
||||
lines and CMake will find libssh2 on your system, set up the necessary
|
||||
paths and link the library with your binary.
|
||||
|
||||
find_package(Libssh2 REQUIRED CONFIG)
|
||||
target_link_libraries(my_project_target Libssh2::libssh2)
|
||||
|
||||
Of course, you still have to make libssh2 available on your system
|
||||
first. You can install it in the traditional way shown above, but you
|
||||
don't have to. Instead you can just build it, which will export its
|
||||
location to the user package registry [3] where `find_package` will
|
||||
find it.
|
||||
|
||||
You can even combine the two steps using a so-called 'superbuild'
|
||||
project [4] that downloads, builds and exports libssh2, and then
|
||||
builds your project:
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
Libssh2
|
||||
URL <libssh2 download location>
|
||||
URL_HASH SHA1=<libssh2 archive SHA1>
|
||||
INSTALL_COMMAND "")
|
||||
|
||||
ExternalProject_Add(
|
||||
MyProject DEPENDS Libssh2
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
INSTALL_COMMAND "")
|
||||
|
||||
[1] http://www.cmake.org/cmake/resources/software.html
|
||||
[2] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
|
||||
[3] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-registry
|
||||
[4] http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html
|
||||
@@ -1,6 +1,7 @@
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL HACKING TODO AUTHORS
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
@@ -168,4 +169,5 @@ dist_man_MANS = \
|
||||
libssh2_userauth_publickey.3 \
|
||||
libssh2_userauth_publickey_fromfile.3 \
|
||||
libssh2_userauth_publickey_fromfile_ex.3 \
|
||||
libssh2_userauth_publickey_frommemory.3 \
|
||||
libssh2_version.3
|
||||
|
||||
@@ -81,7 +81,7 @@ build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = docs
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(dist_man_MANS) AUTHORS INSTALL TODO
|
||||
$(dist_man_MANS) AUTHORS TODO
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
@@ -288,7 +288,9 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL HACKING TODO AUTHORS
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
libssh2_agent_disconnect.3 \
|
||||
@@ -455,6 +457,7 @@ dist_man_MANS = \
|
||||
libssh2_userauth_publickey.3 \
|
||||
libssh2_userauth_publickey_fromfile.3 \
|
||||
libssh2_userauth_publickey_fromfile_ex.3 \
|
||||
libssh2_userauth_publickey_frommemory.3 \
|
||||
libssh2_version.3
|
||||
|
||||
all: all-am
|
||||
|
||||
56
docs/libssh2_userauth_publickey_frommemory.3
Normal file
56
docs/libssh2_userauth_publickey_frommemory.3
Normal file
@@ -0,0 +1,56 @@
|
||||
.TH libssh2_userauth_publickey_frommemory 3 "1 Sep 2014" "libssh2 1.5" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_userauth_publickey_frommemory - authenticate a session with a public key, read from memory
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
.nf
|
||||
int libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
size_t username_len,
|
||||
const char *publickeydata,
|
||||
size_t publickeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
.SH DESCRIPTION
|
||||
This function allows to authenticate a session with a public key read from memory.
|
||||
It's only supported when libssh2 is backed by OpenSSL.
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIusername\fP - Remote user name to authenticate as.
|
||||
|
||||
\fIusername_len\fP - Length of username.
|
||||
|
||||
\fIpublickeydata\fP - Buffer containing the contents of a public key file.
|
||||
|
||||
\fIpublickeydata_len\fP - Length of public key data.
|
||||
|
||||
\fIprivatekeydata\fP - Buffer containing the contents of a private key file.
|
||||
|
||||
\fIprivatekeydata_len\fP - Length of private key data.
|
||||
|
||||
\fIpassphrase\fP - Passphrase to use when decoding private key file.
|
||||
|
||||
Attempt public key authentication using a PEM encoded private key file stored in memory.
|
||||
.SH RETURN VALUE
|
||||
Return 0 on success or negative on failure. It returns
|
||||
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
|
||||
|
||||
\fILIBSSH2_ERROR_SOCKET_TIMEOUT\fP -
|
||||
|
||||
\fILIBSSH2_ERROR_PUBLICKEY_UNVERIFIED\fP - The username/public key
|
||||
combination was invalid.
|
||||
|
||||
\fILIBSSH2_ERROR_AUTHENTICATION_FAILED\fP - Authentication using the supplied
|
||||
public key was not accepted.
|
||||
.SH AVAILABILITY
|
||||
libssh2_userauth_publickey_frommemory was added in libssh2 1.6.0
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
||||
@@ -15,10 +15,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
@@ -272,14 +275,17 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
wr = 0;
|
||||
do {
|
||||
i = libssh2_channel_write(channel, buf, len);
|
||||
while(wr < len) {
|
||||
i = libssh2_channel_write(channel, buf + wr, len - wr);
|
||||
if (LIBSSH2_ERROR_EAGAIN == i) {
|
||||
continue;
|
||||
}
|
||||
if (i < 0) {
|
||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||
goto shutdown;
|
||||
}
|
||||
wr += i;
|
||||
} while(i > 0 && wr < len);
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
len = libssh2_channel_read(channel, buf, sizeof(buf));
|
||||
|
||||
@@ -51,6 +51,12 @@
|
||||
/* use Ioctlsocket() for non-blocking sockets */
|
||||
#undef HAVE_IOCTLSOCKET_CASE
|
||||
|
||||
/* Define if you have the bcrypt library. */
|
||||
#undef HAVE_LIBBCRYPT
|
||||
|
||||
/* Define if you have the crypt32 library. */
|
||||
#undef HAVE_LIBCRYPT32
|
||||
|
||||
/* Define if you have the gcrypt library. */
|
||||
#undef HAVE_LIBGCRYPT
|
||||
|
||||
@@ -69,6 +75,12 @@
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the <ntdef.h> header file. */
|
||||
#undef HAVE_NTDEF_H
|
||||
|
||||
/* Define to 1 if you have the <ntstatus.h> header file. */
|
||||
#undef HAVE_NTSTATUS_H
|
||||
|
||||
/* use O_NONBLOCK for non-blocking sockets */
|
||||
#undef HAVE_O_NONBLOCK
|
||||
|
||||
@@ -138,6 +150,9 @@
|
||||
/* to make a symbol visible */
|
||||
#undef LIBSSH2_API
|
||||
|
||||
/* Enable clearing of memory before being freed */
|
||||
#undef LIBSSH2_CLEAR_MEMORY
|
||||
|
||||
/* Enable "none" cipher -- NOT RECOMMENDED */
|
||||
#undef LIBSSH2_CRYPT_NONE
|
||||
|
||||
@@ -156,6 +171,9 @@
|
||||
/* Use OpenSSL */
|
||||
#undef LIBSSH2_OPENSSL
|
||||
|
||||
/* Use Windows CNG */
|
||||
#undef LIBSSH2_WINCNG
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
@@ -38,12 +38,14 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* diff in ms */
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
|
||||
{
|
||||
@@ -87,11 +89,13 @@ int main(int argc, char *argv[])
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
long time_ms;
|
||||
#endif
|
||||
int rc;
|
||||
int total = 0;
|
||||
long time_ms;
|
||||
int spin = 0;
|
||||
off_t got=0;
|
||||
|
||||
@@ -149,7 +153,9 @@ int main(int argc, char *argv[])
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&start, NULL);
|
||||
#endif
|
||||
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
@@ -252,11 +258,15 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
#endif
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
|
||||
@@ -39,12 +39,14 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* diff in ms */
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
|
||||
{
|
||||
@@ -86,11 +88,13 @@ int main(int argc, char *argv[])
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/TEST";
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
long time_ms;
|
||||
#endif
|
||||
int rc;
|
||||
int total = 0;
|
||||
long time_ms;
|
||||
int spin = 0;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
@@ -151,7 +155,9 @@ int main(int argc, char *argv[])
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&start, NULL);
|
||||
#endif
|
||||
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
@@ -254,10 +260,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
} while (1);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&end, NULL);
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
#endif
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
|
||||
@@ -29,10 +29,13 @@
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -31,10 +31,13 @@
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -16,10 +16,13 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
@@ -28,6 +31,12 @@
|
||||
#define INADDR_NONE (in_addr_t)~0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
# ifdef HAVE__SNPRINTF
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "/home/username/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
|
||||
@@ -15,10 +15,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2009, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009-2012 Daniel Stenberg
|
||||
* Copyright (c) 2009-2015 Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson <simon@josefsson.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -40,18 +40,18 @@
|
||||
#ifndef LIBSSH2_H
|
||||
#define LIBSSH2_H 1
|
||||
|
||||
#define LIBSSH2_COPYRIGHT "2004-2014 The libssh2 project and its contributors."
|
||||
#define LIBSSH2_COPYRIGHT "2004-2015 The libssh2 project and its contributors."
|
||||
|
||||
/* We use underscore instead of dash when appending DEV in dev versions just
|
||||
to make the BANNER define (used by src/session.c) be a valid SSH
|
||||
banner. Release versions have no appended strings and may of course not
|
||||
have dashes either. */
|
||||
#define LIBSSH2_VERSION "1.5.0"
|
||||
#define LIBSSH2_VERSION "1.6.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 5
|
||||
#define LIBSSH2_VERSION_MINOR 6
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libssh2 version number, meant for easier
|
||||
@@ -69,7 +69,7 @@
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBSSH2_VERSION_NUM 0x010500
|
||||
#define LIBSSH2_VERSION_NUM 0x010600
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -80,7 +80,7 @@
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
*/
|
||||
#define LIBSSH2_TIMESTAMP "Wed Mar 11 07:08:36 UTC 2015"
|
||||
#define LIBSSH2_TIMESTAMP "Fri Jun 12 06:58:26 UTC 2015"
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
@@ -114,7 +114,7 @@ extern "C" {
|
||||
# endif /* LIBSSH2_WIN32 */
|
||||
#endif /* LIBSSH2_API */
|
||||
|
||||
#if defined(LIBSSH2_DARWIN)
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
# include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
@@ -576,6 +576,16 @@ libssh2_userauth_hostbased_fromfile_ex(LIBSSH2_SESSION *session,
|
||||
(username), \
|
||||
(unsigned int)strlen(username))
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
size_t username_len,
|
||||
const char *publickeyfiledata,
|
||||
size_t publickeyfiledata_len,
|
||||
const char *privatekeyfiledata,
|
||||
size_t privatekeyfiledata_len,
|
||||
const char *passphrase);
|
||||
|
||||
/*
|
||||
* response_callback is provided with filled by library prompts array,
|
||||
* but client must allocate and fill individual responses. Responses
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
# compiler: $LTCC
|
||||
# compiler flags: $LTCFLAGS
|
||||
# linker: $LD (gnu? $with_gnu_ld)
|
||||
# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.7
|
||||
# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11
|
||||
# automake: $automake_version
|
||||
# autoconf: $autoconf_version
|
||||
#
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
PROGRAM=libtool
|
||||
PACKAGE=libtool
|
||||
VERSION="2.4.2 Debian-2.4.2-1.7"
|
||||
VERSION="2.4.2 Debian-2.4.2-1.11"
|
||||
TIMESTAMP=""
|
||||
package_revision=1.3337
|
||||
|
||||
|
||||
@@ -266,8 +266,28 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
|
||||
}
|
||||
|
||||
if (session->open_data[0] == SSH_MSG_CHANNEL_OPEN_FAILURE) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||
"Channel open failure");
|
||||
unsigned int reason_code = _libssh2_ntohu32(session->open_data + 5);
|
||||
switch (reason_code) {
|
||||
case SSH_OPEN_ADMINISTRATIVELY_PROHIBITED:
|
||||
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||
"Channel open failure (admininstratively prohibited)");
|
||||
break;
|
||||
case SSH_OPEN_CONNECT_FAILED:
|
||||
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||
"Channel open failure (connect failed)");
|
||||
break;
|
||||
case SSH_OPEN_UNKNOWN_CHANNELTYPE:
|
||||
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||
"Channel open failure (unknown channel type)");
|
||||
break;
|
||||
case SSH_OPEN_RESOURCE_SHORTAGE:
|
||||
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||
"Channel open failure (resource shortage)");
|
||||
break;
|
||||
default:
|
||||
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
|
||||
"Channel open failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
src/crypto.h
16
src/crypto.h
@@ -80,6 +80,10 @@ int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
||||
size_t hash_len,
|
||||
unsigned char **signature,
|
||||
size_t *signature_len);
|
||||
int _libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned const char *passphrase);
|
||||
|
||||
#if LIBSSH2_DSA
|
||||
int _libssh2_dsa_new(libssh2_dsa_ctx ** dsa,
|
||||
@@ -102,6 +106,10 @@ int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
|
||||
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
const unsigned char *hash,
|
||||
unsigned long hash_len, unsigned char *sig);
|
||||
int _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned const char *passphrase);
|
||||
#endif
|
||||
|
||||
int _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
@@ -120,6 +128,14 @@ int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
|
||||
void _libssh2_init_aes_ctr(void);
|
||||
|
||||
|
||||
@@ -130,6 +130,38 @@ hostkey_method_ssh_rsa_initPEM(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* hostkey_method_ssh_rsa_initPEMFromMemory
|
||||
*
|
||||
* Load a Private Key from a memory
|
||||
*/
|
||||
static int
|
||||
hostkey_method_ssh_rsa_initPEMFromMemory(LIBSSH2_SESSION * session,
|
||||
const char *privkeyfiledata,
|
||||
size_t privkeyfiledata_len,
|
||||
unsigned const char *passphrase,
|
||||
void **abstract)
|
||||
{
|
||||
libssh2_rsa_ctx *rsactx;
|
||||
int ret;
|
||||
|
||||
if (*abstract) {
|
||||
hostkey_method_ssh_rsa_dtor(session, abstract);
|
||||
*abstract = NULL;
|
||||
}
|
||||
|
||||
ret = _libssh2_rsa_new_private_frommemory(&rsactx, session,
|
||||
privkeyfiledata,
|
||||
privkeyfiledata_len, passphrase);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*abstract = rsactx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* hostkey_method_ssh_rsa_sign
|
||||
*
|
||||
@@ -208,6 +240,7 @@ static const LIBSSH2_HOSTKEY_METHOD hostkey_method_ssh_rsa = {
|
||||
MD5_DIGEST_LENGTH,
|
||||
hostkey_method_ssh_rsa_init,
|
||||
hostkey_method_ssh_rsa_initPEM,
|
||||
hostkey_method_ssh_rsa_initPEMFromMemory,
|
||||
hostkey_method_ssh_rsa_sig_verify,
|
||||
hostkey_method_ssh_rsa_signv,
|
||||
NULL, /* encrypt */
|
||||
@@ -305,6 +338,38 @@ hostkey_method_ssh_dss_initPEM(LIBSSH2_SESSION * session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* hostkey_method_ssh_dss_initPEMFromMemory
|
||||
*
|
||||
* Load a Private Key from memory
|
||||
*/
|
||||
static int
|
||||
hostkey_method_ssh_dss_initPEMFromMemory(LIBSSH2_SESSION * session,
|
||||
const char *privkeyfiledata,
|
||||
size_t privkeyfiledata_len,
|
||||
unsigned const char *passphrase,
|
||||
void **abstract)
|
||||
{
|
||||
libssh2_dsa_ctx *dsactx;
|
||||
int ret;
|
||||
|
||||
if (*abstract) {
|
||||
hostkey_method_ssh_dss_dtor(session, abstract);
|
||||
*abstract = NULL;
|
||||
}
|
||||
|
||||
ret = _libssh2_dsa_new_private_frommemory(&dsactx, session,
|
||||
privkeyfiledata,
|
||||
privkeyfiledata_len, passphrase);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*abstract = dsactx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* libssh2_hostkey_method_ssh_dss_sign
|
||||
*
|
||||
@@ -391,6 +456,7 @@ static const LIBSSH2_HOSTKEY_METHOD hostkey_method_ssh_dss = {
|
||||
MD5_DIGEST_LENGTH,
|
||||
hostkey_method_ssh_dss_init,
|
||||
hostkey_method_ssh_dss_initPEM,
|
||||
hostkey_method_ssh_dss_initPEMFromMemory,
|
||||
hostkey_method_ssh_dss_sig_verify,
|
||||
hostkey_method_ssh_dss_signv,
|
||||
NULL, /* encrypt */
|
||||
@@ -434,7 +500,9 @@ libssh2_hostkey_hash(LIBSSH2_SESSION * session, int hash_type)
|
||||
break;
|
||||
#endif /* LIBSSH2_MD5 */
|
||||
case LIBSSH2_HOSTKEY_HASH_SHA1:
|
||||
return (char *) session->server_hostkey_sha1;
|
||||
return (session->server_hostkey_sha1_valid)
|
||||
? (char *) session->server_hostkey_sha1
|
||||
: NULL;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
|
||||
27
src/kex.c
27
src/kex.c
@@ -96,7 +96,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
exchange_state->ctx = _libssh2_bn_ctx_new();
|
||||
exchange_state->x = _libssh2_bn_init(); /* Random from client */
|
||||
exchange_state->e = _libssh2_bn_init(); /* g^x mod p */
|
||||
exchange_state->f = _libssh2_bn_init(); /* g^(Random from server) mod p */
|
||||
exchange_state->f = _libssh2_bn_init_from_bin(); /* g^(Random from server) mod p */
|
||||
exchange_state->k = _libssh2_bn_init(); /* The shared secret: f^x mod p */
|
||||
|
||||
/* Zero the whole thing out */
|
||||
@@ -221,7 +221,8 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
if (libssh2_md5_init(&fingerprint_ctx)) {
|
||||
libssh2_md5_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_md5_final(fingerprint_ctx, session->server_hostkey_md5);
|
||||
libssh2_md5_final(fingerprint_ctx,
|
||||
session->server_hostkey_md5);
|
||||
session->server_hostkey_md5_valid = TRUE;
|
||||
}
|
||||
else {
|
||||
@@ -245,10 +246,16 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
{
|
||||
libssh2_sha1_ctx fingerprint_ctx;
|
||||
|
||||
libssh2_sha1_init(&fingerprint_ctx);
|
||||
libssh2_sha1_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_sha1_final(fingerprint_ctx, session->server_hostkey_sha1);
|
||||
if (libssh2_sha1_init(&fingerprint_ctx)) {
|
||||
libssh2_sha1_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_sha1_final(fingerprint_ctx,
|
||||
session->server_hostkey_sha1);
|
||||
session->server_hostkey_sha1_valid = TRUE;
|
||||
}
|
||||
else {
|
||||
session->server_hostkey_sha1_valid = FALSE;
|
||||
}
|
||||
}
|
||||
#ifdef LIBSSH2DEBUG
|
||||
{
|
||||
@@ -708,7 +715,7 @@ kex_method_diffie_hellman_group1_sha1_key_exchange(LIBSSH2_SESSION *session,
|
||||
|
||||
if (key_state->state == libssh2_NB_state_idle) {
|
||||
/* g == 2 */
|
||||
key_state->p = _libssh2_bn_init(); /* SSH2 defined value (p_value) */
|
||||
key_state->p = _libssh2_bn_init_from_bin(); /* SSH2 defined value (p_value) */
|
||||
key_state->g = _libssh2_bn_init(); /* SSH2 defined value (2) */
|
||||
|
||||
/* Initialize P and G */
|
||||
@@ -783,7 +790,7 @@ kex_method_diffie_hellman_group14_sha1_key_exchange(LIBSSH2_SESSION *session,
|
||||
int ret;
|
||||
|
||||
if (key_state->state == libssh2_NB_state_idle) {
|
||||
key_state->p = _libssh2_bn_init(); /* SSH2 defined value (p_value) */
|
||||
key_state->p = _libssh2_bn_init_from_bin(); /* SSH2 defined value (p_value) */
|
||||
key_state->g = _libssh2_bn_init(); /* SSH2 defined value (2) */
|
||||
|
||||
/* g == 2 */
|
||||
@@ -827,8 +834,8 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
int rc;
|
||||
|
||||
if (key_state->state == libssh2_NB_state_idle) {
|
||||
key_state->p = _libssh2_bn_init();
|
||||
key_state->g = _libssh2_bn_init();
|
||||
key_state->p = _libssh2_bn_init_from_bin();
|
||||
key_state->g = _libssh2_bn_init_from_bin();
|
||||
/* Ask for a P and G pair */
|
||||
#ifdef LIBSSH2_DH_GEX_NEW
|
||||
key_state->request[0] = SSH_MSG_KEX_DH_GEX_REQUEST;
|
||||
|
||||
@@ -417,8 +417,9 @@ knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
plain input to produce a hash to compare with the
|
||||
stored hash.
|
||||
*/
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||
libssh2_hmac_ctx ctx;
|
||||
libssh2_hmac_ctx_init(ctx);
|
||||
|
||||
if(SHA_DIGEST_LENGTH != node->name_len) {
|
||||
/* the name hash length must be the sha1 size or
|
||||
|
||||
@@ -149,6 +149,17 @@ _libssh2_dsa_new(libssh2_dsa_ctx ** dsactx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
"Unable to extract private key from memory: "
|
||||
"Method unimplemented in libgcrypt backend");
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
@@ -251,6 +262,17 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
"Unable to extract private key from memory: "
|
||||
"Method unimplemented in libgcrypt backend");
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
@@ -566,6 +588,21 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase)
|
||||
{
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
"Unable to extract public key from private key in memory: "
|
||||
"Method unimplemented in libgcrypt backend");
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
|
||||
@@ -60,7 +60,10 @@
|
||||
(gcry_randomize ((buf), (len), GCRY_STRONG_RANDOM), 1)
|
||||
|
||||
#define libssh2_sha1_ctx gcry_md_hd_t
|
||||
#define libssh2_sha1_init(ctx) gcry_md_open (ctx, GCRY_MD_SHA1, 0);
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
#define libssh2_sha1_init(ctx) \
|
||||
(GPG_ERR_NO_ERROR == gcry_md_open (ctx, GCRY_MD_SHA1, 0))
|
||||
#define libssh2_sha1_update(ctx, data, len) \
|
||||
gcry_md_write (ctx, (unsigned char *) data, len)
|
||||
#define libssh2_sha1_final(ctx, out) \
|
||||
@@ -82,6 +85,7 @@
|
||||
gcry_md_hash_buffer (GCRY_MD_MD5, out, message, len)
|
||||
|
||||
#define libssh2_hmac_ctx gcry_md_hd_t
|
||||
#define libssh2_hmac_ctx_init(ctx)
|
||||
#define libssh2_hmac_sha1_init(ctx, key, keylen) \
|
||||
gcry_md_open (ctx, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC), \
|
||||
gcry_md_setkey (*ctx, key, keylen)
|
||||
@@ -145,6 +149,7 @@
|
||||
#define _libssh2_bn_ctx_new() 0
|
||||
#define _libssh2_bn_ctx_free(bnctx) ((void)0)
|
||||
#define _libssh2_bn_init() gcry_mpi_new(0)
|
||||
#define _libssh2_bn_init_from_bin() NULL /* because gcry_mpi_scan() creates a new bignum */
|
||||
#define _libssh2_bn_rand(bn, bits, top, bottom) gcry_mpi_randomize (bn, bits, GCRY_WEAK_RANDOM)
|
||||
#define _libssh2_bn_mod_exp(r, a, p, m, ctx) gcry_mpi_powm (r, a, p, m)
|
||||
#define _libssh2_bn_set_word(bn, val) gcry_mpi_set_ui(bn, val)
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `SecureZeroMemory', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_SECUREZEROMEMORY
|
||||
|
||||
/* disabled non-blocking sockets */
|
||||
#undef HAVE_DISABLED_NONBLOCKING
|
||||
|
||||
@@ -150,6 +154,9 @@
|
||||
/* to make a symbol visible */
|
||||
#undef LIBSSH2_API
|
||||
|
||||
/* Enable clearing of memory before being freed */
|
||||
#undef LIBSSH2_CLEAR_MEMORY
|
||||
|
||||
/* Enable "none" cipher -- NOT RECOMMENDED */
|
||||
#undef LIBSSH2_CRYPT_NONE
|
||||
|
||||
|
||||
@@ -600,6 +600,7 @@ struct _LIBSSH2_SESSION
|
||||
int server_hostkey_md5_valid;
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH];
|
||||
int server_hostkey_sha1_valid;
|
||||
|
||||
/* (remote as source of data -- packet_read ) */
|
||||
libssh2_endpoint_data remote;
|
||||
@@ -854,6 +855,9 @@ struct _LIBSSH2_HOSTKEY_METHOD
|
||||
size_t hostkey_data_len, void **abstract);
|
||||
int (*initPEM) (LIBSSH2_SESSION * session, const char *privkeyfile,
|
||||
unsigned const char *passphrase, void **abstract);
|
||||
int (*initPEMFromMemory) (LIBSSH2_SESSION * session,
|
||||
const char *privkeyfiledata, size_t privkeyfiledata_len,
|
||||
unsigned const char *passphrase, void **abstract);
|
||||
int (*sig_verify) (LIBSSH2_SESSION * session, const unsigned char *sig,
|
||||
size_t sig_len, const unsigned char *m,
|
||||
size_t m_len, void **abstract);
|
||||
@@ -1023,6 +1027,11 @@ int _libssh2_pem_parse(LIBSSH2_SESSION * session,
|
||||
const char *headerbegin,
|
||||
const char *headerend,
|
||||
FILE * fp, unsigned char **data, unsigned int *datalen);
|
||||
int _libssh2_pem_parse_memory(LIBSSH2_SESSION * session,
|
||||
const char *headerbegin,
|
||||
const char *headerend,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned char **data, unsigned int *datalen);
|
||||
int _libssh2_pem_decode_sequence(unsigned char **data, unsigned int *datalen);
|
||||
int _libssh2_pem_decode_integer(unsigned char **data, unsigned int *datalen,
|
||||
unsigned char **i, unsigned int *ilen);
|
||||
|
||||
@@ -113,6 +113,7 @@ mac_method_hmac_sha1_hash(LIBSSH2_SESSION * session,
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
libssh2_hmac_ctx_init(ctx);
|
||||
libssh2_hmac_sha1_init(&ctx, *abstract, 20);
|
||||
libssh2_hmac_update(ctx, seqno_buf, 4);
|
||||
libssh2_hmac_update(ctx, packet, packet_len);
|
||||
@@ -185,6 +186,7 @@ mac_method_hmac_md5_hash(LIBSSH2_SESSION * session, unsigned char *buf,
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
libssh2_hmac_ctx_init(ctx);
|
||||
libssh2_hmac_md5_init(&ctx, *abstract, 16);
|
||||
libssh2_hmac_update(ctx, seqno_buf, 4);
|
||||
libssh2_hmac_update(ctx, packet, packet_len);
|
||||
@@ -257,6 +259,7 @@ mac_method_hmac_ripemd160_hash(LIBSSH2_SESSION * session,
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
libssh2_hmac_ctx_init(ctx);
|
||||
libssh2_hmac_ripemd160_init(&ctx, *abstract, 20);
|
||||
libssh2_hmac_update(ctx, seqno_buf, 4);
|
||||
libssh2_hmac_update(ctx, packet, packet_len);
|
||||
|
||||
141
src/openssl.c
141
src/openssl.c
@@ -387,6 +387,28 @@ passphrase_cb(char *buf, int size, int rwflag, char *passphrase)
|
||||
typedef void * (*pem_read_bio_func)(BIO *, void **, pem_password_cb *,
|
||||
void * u);
|
||||
|
||||
static int
|
||||
read_private_key_from_memory(void ** key_ctx,
|
||||
pem_read_bio_func read_private_key,
|
||||
const char * filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
BIO * bp;
|
||||
|
||||
*key_ctx = NULL;
|
||||
|
||||
bp = BIO_new_mem_buf((char *)filedata, filedata_len);
|
||||
if (!bp) {
|
||||
return -1;
|
||||
}
|
||||
*key_ctx = read_private_key(bp, NULL, (pem_password_cb *) passphrase_cb,
|
||||
(void *) passphrase);
|
||||
|
||||
BIO_free(bp);
|
||||
return (*key_ctx) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int
|
||||
read_private_key_from_file(void ** key_ctx,
|
||||
pem_read_bio_func read_private_key,
|
||||
@@ -409,6 +431,22 @@ read_private_key_from_file(void ** key_ctx,
|
||||
return (*key_ctx) ? 0 : -1;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
pem_read_bio_func read_rsa =
|
||||
(pem_read_bio_func) &PEM_read_bio_RSAPrivateKey;
|
||||
(void) session;
|
||||
|
||||
_libssh2_init_if_needed();
|
||||
|
||||
return read_private_key_from_memory((void **) rsa, read_rsa,
|
||||
filedata, filedata_len, passphrase);
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
@@ -425,6 +463,22 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
||||
}
|
||||
|
||||
#if LIBSSH2_DSA
|
||||
int
|
||||
_libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
pem_read_bio_func read_dsa =
|
||||
(pem_read_bio_func) &PEM_read_bio_DSAPrivateKey;
|
||||
(void) session;
|
||||
|
||||
_libssh2_init_if_needed();
|
||||
|
||||
return read_private_key_from_memory((void **) dsa, read_dsa,
|
||||
filedata, filedata_len, passphrase);
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
@@ -523,9 +577,10 @@ libssh2_sha1(const unsigned char *message, unsigned long len,
|
||||
EVP_MD_CTX ctx;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
EVP_DigestInit(&ctx, EVP_get_digestbyname("sha1"));
|
||||
EVP_DigestUpdate(&ctx, message, len);
|
||||
EVP_DigestFinal(&ctx, out, NULL);
|
||||
if (EVP_DigestInit(&ctx, EVP_get_digestbyname("sha1"))) {
|
||||
EVP_DigestUpdate(&ctx, message, len);
|
||||
EVP_DigestFinal(&ctx, out, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@@ -542,9 +597,10 @@ libssh2_md5(const unsigned char *message, unsigned long len,
|
||||
EVP_MD_CTX ctx;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
EVP_DigestInit(&ctx, EVP_get_digestbyname("md5"));
|
||||
EVP_DigestUpdate(&ctx, message, len);
|
||||
EVP_DigestFinal(&ctx, out, NULL);
|
||||
if (EVP_DigestInit(&ctx, EVP_get_digestbyname("md5"))) {
|
||||
EVP_DigestUpdate(&ctx, message, len);
|
||||
EVP_DigestFinal(&ctx, out, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char *
|
||||
@@ -600,6 +656,7 @@ gen_publickey_from_rsa(LIBSSH2_SESSION *session, RSA *rsa,
|
||||
return key;
|
||||
}
|
||||
|
||||
#if LIBSSH2_DSA
|
||||
static unsigned char *
|
||||
gen_publickey_from_dsa(LIBSSH2_SESSION* session, DSA *dsa,
|
||||
size_t *key_len)
|
||||
@@ -638,6 +695,7 @@ gen_publickey_from_dsa(LIBSSH2_SESSION* session, DSA *dsa,
|
||||
*key_len = (size_t)(p - key);
|
||||
return key;
|
||||
}
|
||||
#endif /* LIBSSH_DSA */
|
||||
|
||||
static int
|
||||
gen_publickey_from_rsa_evp(LIBSSH2_SESSION *session,
|
||||
@@ -693,6 +751,7 @@ gen_publickey_from_rsa_evp(LIBSSH2_SESSION *session,
|
||||
"Unable to allocate memory for private key data");
|
||||
}
|
||||
|
||||
#if LIBSSH2_DSA
|
||||
static int
|
||||
gen_publickey_from_dsa_evp(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
@@ -746,6 +805,7 @@ gen_publickey_from_dsa_evp(LIBSSH2_SESSION *session,
|
||||
LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for private key data");
|
||||
}
|
||||
#endif /* LIBSSH_DSA */
|
||||
|
||||
int
|
||||
_libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
@@ -799,10 +859,12 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
session, method, method_len, pubkeydata, pubkeydata_len, pk);
|
||||
break;
|
||||
|
||||
#if LIBSSH2_DSA
|
||||
case EVP_PKEY_DSA :
|
||||
st = gen_publickey_from_dsa_evp(
|
||||
session, method, method_len, pubkeydata, pubkeydata_len, pk);
|
||||
break;
|
||||
#endif /* LIBSSH_DSA */
|
||||
|
||||
default :
|
||||
st = _libssh2_error(session,
|
||||
@@ -817,4 +879,71 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
return st;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase)
|
||||
{
|
||||
int st;
|
||||
BIO* bp;
|
||||
EVP_PKEY* pk;
|
||||
|
||||
_libssh2_debug(session,
|
||||
LIBSSH2_TRACE_AUTH,
|
||||
"Computing public key from private key.");
|
||||
|
||||
bp = BIO_new_mem_buf((char *)privatekeydata, privatekeydata_len);
|
||||
if (!bp) {
|
||||
return -1;
|
||||
}
|
||||
if (!EVP_get_cipherbyname("des")) {
|
||||
/* If this cipher isn't loaded it's a pretty good indication that none
|
||||
* are. I have *NO DOUBT* that there's a better way to deal with this
|
||||
* ($#&%#$(%$#( Someone buy me an OpenSSL manual and I'll read up on
|
||||
* it.
|
||||
*/
|
||||
OpenSSL_add_all_ciphers();
|
||||
}
|
||||
BIO_reset(bp);
|
||||
pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, (void*)passphrase);
|
||||
BIO_free(bp);
|
||||
|
||||
if (pk == NULL) {
|
||||
return _libssh2_error(session,
|
||||
LIBSSH2_ERROR_FILE,
|
||||
"Unable to extract public key "
|
||||
"from private key file: "
|
||||
"Wrong passphrase or invalid/unrecognized "
|
||||
"private key file format");
|
||||
}
|
||||
|
||||
switch (pk->type) {
|
||||
case EVP_PKEY_RSA :
|
||||
st = gen_publickey_from_rsa_evp(session, method, method_len,
|
||||
pubkeydata, pubkeydata_len, pk);
|
||||
break;
|
||||
#if LIBSSH2_DSA
|
||||
case EVP_PKEY_DSA :
|
||||
st = gen_publickey_from_dsa_evp(session, method, method_len,
|
||||
pubkeydata, pubkeydata_len, pk);
|
||||
break;
|
||||
#endif /* LIBSSH_DSA */
|
||||
default :
|
||||
st = _libssh2_error(session,
|
||||
LIBSSH2_ERROR_FILE,
|
||||
"Unable to extract public key "
|
||||
"from private key file: "
|
||||
"Unsupported private key file format");
|
||||
break;
|
||||
}
|
||||
|
||||
EVP_PKEY_free(pk);
|
||||
return st;
|
||||
}
|
||||
|
||||
#endif /* LIBSSH2_OPENSSL */
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
# define LIBSSH2_AES 0
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_NO_BLOWFISH
|
||||
#ifdef OPENSSL_NO_BF
|
||||
# define LIBSSH2_BLOWFISH 0
|
||||
#else
|
||||
# define LIBSSH2_BLOWFISH 1
|
||||
@@ -107,6 +107,8 @@
|
||||
#define _libssh2_random(buf, len) RAND_bytes ((buf), (len))
|
||||
|
||||
#define libssh2_sha1_ctx EVP_MD_CTX
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
int libssh2_sha1_init(libssh2_sha1_ctx *ctx);
|
||||
#define libssh2_sha1_update(ctx, data, len) EVP_DigestUpdate(&(ctx), data, len)
|
||||
#define libssh2_sha1_final(ctx, out) EVP_DigestFinal(&(ctx), out, NULL)
|
||||
@@ -121,6 +123,8 @@ int libssh2_md5_init(libssh2_md5_ctx *);
|
||||
void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char *out);
|
||||
|
||||
#define libssh2_hmac_ctx HMAC_CTX
|
||||
#define libssh2_hmac_ctx_init(ctx) \
|
||||
HMAC_CTX_init(&ctx)
|
||||
#define libssh2_hmac_sha1_init(ctx, key, keylen) \
|
||||
HMAC_Init(ctx, key, keylen, EVP_sha1())
|
||||
#define libssh2_hmac_md5_init(ctx, key, keylen) \
|
||||
@@ -171,6 +175,7 @@ void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char
|
||||
#define _libssh2_bn_ctx_new() BN_CTX_new()
|
||||
#define _libssh2_bn_ctx_free(bnctx) BN_CTX_free(bnctx)
|
||||
#define _libssh2_bn_init() BN_new()
|
||||
#define _libssh2_bn_init_from_bin() _libssh2_bn_init()
|
||||
#define _libssh2_bn_rand(bn, bits, top, bottom) BN_rand(bn, bits, top, bottom)
|
||||
#define _libssh2_bn_mod_exp(r, a, p, m, ctx) BN_mod_exp(r, a, p, m, ctx)
|
||||
#define _libssh2_bn_set_word(bn, val) BN_set_word(bn, val)
|
||||
|
||||
115
src/pem.c
115
src/pem.c
@@ -41,15 +41,56 @@
|
||||
static int
|
||||
readline(char *line, int line_size, FILE * fp)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (!line) {
|
||||
return -1;
|
||||
}
|
||||
if (!fgets(line, line_size, fp)) {
|
||||
return -1;
|
||||
}
|
||||
if (*line && line[strlen(line) - 1] == '\n') {
|
||||
line[strlen(line) - 1] = '\0';
|
||||
|
||||
if (*line) {
|
||||
len = strlen(line);
|
||||
if (len > 0 && line[len - 1] == '\n') {
|
||||
line[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
if (*line && line[strlen(line) - 1] == '\r') {
|
||||
line[strlen(line) - 1] = '\0';
|
||||
|
||||
if (*line) {
|
||||
len = strlen(line);
|
||||
if (len > 0 && line[len - 1] == '\r') {
|
||||
line[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
readline_memory(char *line, size_t line_size,
|
||||
const char *filedata, size_t filedata_len,
|
||||
size_t *filedata_offset)
|
||||
{
|
||||
size_t off, len;
|
||||
|
||||
off = *filedata_offset;
|
||||
|
||||
for (len = 0; off + len < filedata_len && len < line_size; len++) {
|
||||
if (filedata[off + len] == '\n' ||
|
||||
filedata[off + len] == '\r') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (len) {
|
||||
memcpy(line, filedata + off, len);
|
||||
*filedata_offset += len;
|
||||
}
|
||||
|
||||
line[len] = '\0';
|
||||
*filedata_offset += 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -119,6 +160,72 @@ _libssh2_pem_parse(LIBSSH2_SESSION * session,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_pem_parse_memory(LIBSSH2_SESSION * session,
|
||||
const char *headerbegin,
|
||||
const char *headerend,
|
||||
const char *filedata, size_t filedata_len,
|
||||
unsigned char **data, unsigned int *datalen)
|
||||
{
|
||||
char line[LINE_SIZE];
|
||||
char *b64data = NULL;
|
||||
unsigned int b64datalen = 0;
|
||||
size_t off = 0;
|
||||
int ret;
|
||||
|
||||
do {
|
||||
*line = '\0';
|
||||
|
||||
if (readline_memory(line, LINE_SIZE, filedata, filedata_len, &off)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (strcmp(line, headerbegin) != 0);
|
||||
|
||||
*line = '\0';
|
||||
|
||||
do {
|
||||
if (*line) {
|
||||
char *tmp;
|
||||
size_t linelen;
|
||||
|
||||
linelen = strlen(line);
|
||||
tmp = LIBSSH2_REALLOC(session, b64data, b64datalen + linelen);
|
||||
if (!tmp) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
memcpy(tmp + b64datalen, line, linelen);
|
||||
b64data = tmp;
|
||||
b64datalen += linelen;
|
||||
}
|
||||
|
||||
*line = '\0';
|
||||
|
||||
if (readline_memory(line, LINE_SIZE, filedata, filedata_len, &off)) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
} while (strcmp(line, headerend) != 0);
|
||||
|
||||
if (!b64data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (libssh2_base64_decode(session, (char**) data, datalen,
|
||||
b64data, b64datalen)) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
if (b64data) {
|
||||
LIBSSH2_FREE(session, b64data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
read_asn1_length(const unsigned char *data,
|
||||
unsigned int datalen, unsigned int *len)
|
||||
|
||||
29
src/scp.c
29
src/scp.c
@@ -295,14 +295,16 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
}
|
||||
|
||||
snprintf((char *)session->scpRecv_command,
|
||||
session->scpRecv_command_len, "scp -%sf ", sb?"p":"");
|
||||
session->scpRecv_command_len,
|
||||
"scp -%sf ", sb?"p":"");
|
||||
|
||||
cmd_len = strlen((char *)session->scpRecv_command);
|
||||
cmd_len += shell_quotearg(path,
|
||||
&session->scpRecv_command[cmd_len],
|
||||
session->scpRecv_command_len - cmd_len);
|
||||
|
||||
(void) shell_quotearg(path,
|
||||
&session->scpRecv_command[cmd_len],
|
||||
session->scpRecv_command_len - cmd_len);
|
||||
|
||||
session->scpRecv_command[cmd_len] = '\0';
|
||||
session->scpRecv_command_len = cmd_len + 1;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
||||
"Opening channel for SCP receive");
|
||||
@@ -790,22 +792,25 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
|
||||
session->scpSend_command =
|
||||
LIBSSH2_ALLOC(session, session->scpSend_command_len);
|
||||
|
||||
if (!session->scpSend_command) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate a command buffer for scp session");
|
||||
"Unable to allocate a command buffer for "
|
||||
"SCP session");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf((char *)session->scpSend_command, session->scpSend_command_len,
|
||||
snprintf((char *)session->scpSend_command,
|
||||
session->scpSend_command_len,
|
||||
"scp -%st ", (mtime || atime)?"p":"");
|
||||
|
||||
cmd_len = strlen((char *)session->scpSend_command);
|
||||
cmd_len += shell_quotearg(path,
|
||||
&session->scpSend_command[cmd_len],
|
||||
session->scpSend_command_len - cmd_len);
|
||||
|
||||
(void)shell_quotearg(path,
|
||||
&session->scpSend_command[cmd_len],
|
||||
session->scpSend_command_len - cmd_len);
|
||||
|
||||
session->scpSend_command[session->scpSend_command_len - 1] = '\0';
|
||||
session->scpSend_command[cmd_len] = '\0';
|
||||
session->scpSend_command_len = cmd_len + 1;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
||||
"Opening channel for SCP send");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009-2011 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2015 by Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson <simon@josefsson.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -601,7 +601,7 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time)
|
||||
(seconds_to_next == 0 ||
|
||||
seconds_to_next > session->api_timeout)) {
|
||||
time_t now = time (NULL);
|
||||
elapsed_ms = (long)(1000*difftime(start_time, now));
|
||||
elapsed_ms = (long)(1000*difftime(now, start_time));
|
||||
if (elapsed_ms > session->api_timeout) {
|
||||
session->err_code = LIBSSH2_ERROR_TIMEOUT;
|
||||
return LIBSSH2_ERROR_TIMEOUT;
|
||||
|
||||
243
src/userauth.c
243
src/userauth.c
@@ -442,6 +442,76 @@ libssh2_userauth_password_ex(LIBSSH2_SESSION *session, const char *username,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
memory_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *pubkeyfiledata,
|
||||
size_t pubkeyfiledata_len)
|
||||
{
|
||||
unsigned char *pubkey = NULL, *sp1, *sp2, *tmp;
|
||||
size_t pubkey_len = pubkeyfiledata_len;
|
||||
unsigned int tmp_len;
|
||||
|
||||
if (pubkeyfiledata_len <= 1) {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Invalid data in public key file");
|
||||
}
|
||||
|
||||
pubkey = LIBSSH2_ALLOC(session, pubkeyfiledata_len);
|
||||
if (!pubkey) {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for public key data");
|
||||
}
|
||||
|
||||
memcpy(pubkey, pubkeyfiledata, pubkeyfiledata_len);
|
||||
|
||||
/*
|
||||
* Remove trailing whitespace
|
||||
*/
|
||||
while (pubkey_len && isspace(pubkey[pubkey_len - 1]))
|
||||
pubkey_len--;
|
||||
|
||||
if (!pubkey_len) {
|
||||
LIBSSH2_FREE(session, pubkey);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Missing public key data");
|
||||
}
|
||||
|
||||
if ((sp1 = memchr(pubkey, ' ', pubkey_len)) == NULL) {
|
||||
LIBSSH2_FREE(session, pubkey);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Invalid public key data");
|
||||
}
|
||||
|
||||
sp1++;
|
||||
|
||||
if ((sp2 = memchr(sp1, ' ', pubkey_len - (sp1 - pubkey - 1))) == NULL) {
|
||||
/* Assume that the id string is missing, but that it's okay */
|
||||
sp2 = pubkey + pubkey_len;
|
||||
}
|
||||
|
||||
if (libssh2_base64_decode(session, (char **) &tmp, &tmp_len,
|
||||
(char *) sp1, sp2 - sp1)) {
|
||||
LIBSSH2_FREE(session, pubkey);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Invalid key data, not base64 encoded");
|
||||
}
|
||||
|
||||
/* Wasting some bytes here (okay, more than some), but since it's likely
|
||||
* to be freed soon anyway, we'll just avoid the extra free/alloc and call
|
||||
* it a wash
|
||||
*/
|
||||
*method = pubkey;
|
||||
*method_len = sp1 - pubkey - 1;
|
||||
|
||||
*pubkeydata = tmp;
|
||||
*pubkeydata_len = tmp_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* file_read_publickey
|
||||
*
|
||||
@@ -547,7 +617,43 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
memory_read_privatekey(LIBSSH2_SESSION * session,
|
||||
const LIBSSH2_HOSTKEY_METHOD ** hostkey_method,
|
||||
void **hostkey_abstract,
|
||||
const unsigned char *method, int method_len,
|
||||
const char *privkeyfiledata, size_t privkeyfiledata_len,
|
||||
const char *passphrase)
|
||||
{
|
||||
const LIBSSH2_HOSTKEY_METHOD **hostkey_methods_avail =
|
||||
libssh2_hostkey_methods();
|
||||
|
||||
*hostkey_method = NULL;
|
||||
*hostkey_abstract = NULL;
|
||||
while (*hostkey_methods_avail && (*hostkey_methods_avail)->name) {
|
||||
if ((*hostkey_methods_avail)->initPEMFromMemory
|
||||
&& strncmp((*hostkey_methods_avail)->name, (const char *) method,
|
||||
method_len) == 0) {
|
||||
*hostkey_method = *hostkey_methods_avail;
|
||||
break;
|
||||
}
|
||||
hostkey_methods_avail++;
|
||||
}
|
||||
if (!*hostkey_method) {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE,
|
||||
"No handler for specified private key");
|
||||
}
|
||||
|
||||
if ((*hostkey_method)->
|
||||
initPEMFromMemory(session, privkeyfiledata, privkeyfiledata_len,
|
||||
(unsigned char *) passphrase,
|
||||
hostkey_abstract)) {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Unable to initialize private key from file");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* libssh2_file_read_privatekey
|
||||
* Read a PEM encoded private key from an id_??? style file
|
||||
@@ -595,6 +701,42 @@ struct privkey_file {
|
||||
const char *passphrase;
|
||||
};
|
||||
|
||||
static int
|
||||
sign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
||||
const unsigned char *data, size_t data_len, void **abstract)
|
||||
{
|
||||
struct privkey_file *pk_file = (struct privkey_file *) (*abstract);
|
||||
const LIBSSH2_HOSTKEY_METHOD *privkeyobj;
|
||||
void *hostkey_abstract;
|
||||
struct iovec datavec;
|
||||
int rc;
|
||||
|
||||
rc = memory_read_privatekey(session, &privkeyobj, &hostkey_abstract,
|
||||
session->userauth_pblc_method,
|
||||
session->userauth_pblc_method_len,
|
||||
pk_file->filename,
|
||||
strlen(pk_file->filename),
|
||||
pk_file->passphrase);
|
||||
if(rc)
|
||||
return rc;
|
||||
|
||||
datavec.iov_base = (void *)data;
|
||||
datavec.iov_len = data_len;
|
||||
|
||||
if (privkeyobj->signv(session, sig, sig_len, 1, &datavec,
|
||||
&hostkey_abstract)) {
|
||||
if (privkeyobj->dtor) {
|
||||
privkeyobj->dtor(session, abstract);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (privkeyobj->dtor) {
|
||||
privkeyobj->dtor(session, &hostkey_abstract);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sign_fromfile(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
||||
const unsigned char *data, size_t data_len, void **abstract)
|
||||
@@ -648,9 +790,9 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
||||
|
||||
if (session->userauth_host_state == libssh2_NB_state_idle) {
|
||||
const LIBSSH2_HOSTKEY_METHOD *privkeyobj;
|
||||
unsigned char *pubkeydata, *sig;
|
||||
unsigned char *pubkeydata, *sig = NULL;
|
||||
size_t pubkeydata_len = 0;
|
||||
size_t sig_len;
|
||||
size_t sig_len = 0;
|
||||
void *abstract;
|
||||
unsigned char buf[5];
|
||||
struct iovec datavec[4];
|
||||
@@ -742,7 +884,9 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
||||
datavec[2].iov_base = (void *)session->userauth_host_packet;
|
||||
datavec[2].iov_len = session->userauth_host_packet_len;
|
||||
|
||||
if (privkeyobj->signv(session, &sig, &sig_len, 3, datavec, &abstract)) {
|
||||
if (privkeyobj && privkeyobj->signv &&
|
||||
privkeyobj->signv(session, &sig, &sig_len, 3,
|
||||
datavec, &abstract)) {
|
||||
LIBSSH2_FREE(session, session->userauth_host_method);
|
||||
session->userauth_host_method = NULL;
|
||||
LIBSSH2_FREE(session, session->userauth_host_packet);
|
||||
@@ -753,7 +897,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (privkeyobj->dtor) {
|
||||
if (privkeyobj && privkeyobj->dtor) {
|
||||
privkeyobj->dtor(session, &abstract);
|
||||
}
|
||||
|
||||
@@ -1215,6 +1359,65 @@ _libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
||||
"username/public key combination");
|
||||
}
|
||||
|
||||
/*
|
||||
* userauth_publickey_frommemory
|
||||
* Authenticate using a keypair from memory
|
||||
*/
|
||||
static int
|
||||
userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
size_t username_len,
|
||||
const char *publickeydata,
|
||||
size_t publickeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase)
|
||||
{
|
||||
unsigned char *pubkeydata = NULL;
|
||||
size_t pubkeydata_len = 0;
|
||||
struct privkey_file privkey_file;
|
||||
void *abstract = &privkey_file;
|
||||
int rc;
|
||||
|
||||
privkey_file.filename = privatekeydata;
|
||||
privkey_file.passphrase = passphrase;
|
||||
|
||||
if (session->userauth_pblc_state == libssh2_NB_state_idle) {
|
||||
if (publickeydata_len && publickeydata) {
|
||||
rc = memory_read_publickey(session, &session->userauth_pblc_method,
|
||||
&session->userauth_pblc_method_len,
|
||||
&pubkeydata, &pubkeydata_len,
|
||||
publickeydata, publickeydata_len);
|
||||
if(rc)
|
||||
return rc;
|
||||
}
|
||||
else if (privatekeydata_len && privatekeydata) {
|
||||
/* Compute public key from private key. */
|
||||
if (_libssh2_pub_priv_keyfilememory(session,
|
||||
&session->userauth_pblc_method,
|
||||
&session->userauth_pblc_method_len,
|
||||
&pubkeydata, &pubkeydata_len,
|
||||
privatekeydata, privatekeydata_len,
|
||||
passphrase))
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Unable to extract public key "
|
||||
"from private key.");
|
||||
}
|
||||
else {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Invalid data in public and private key.");
|
||||
}
|
||||
}
|
||||
|
||||
rc = _libssh2_userauth_publickey(session, username, username_len,
|
||||
pubkeydata, pubkeydata_len,
|
||||
sign_frommemory, &abstract);
|
||||
if(pubkeydata)
|
||||
LIBSSH2_FREE(session, pubkeydata);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* userauth_publickey_fromfile
|
||||
* Authenticate using a keypair found in the named files
|
||||
@@ -1267,6 +1470,36 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* libssh2_userauth_publickey_frommemory
|
||||
* Authenticate using a keypair from memory
|
||||
*/
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
const char *user,
|
||||
size_t user_len,
|
||||
const char *publickeyfiledata,
|
||||
size_t publickeyfiledata_len,
|
||||
const char *privatekeyfiledata,
|
||||
size_t privatekeyfiledata_len,
|
||||
const char *passphrase)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if(NULL == passphrase)
|
||||
/* if given a NULL pointer, make it point to a zero-length
|
||||
string to save us from having to check this all over */
|
||||
passphrase="";
|
||||
|
||||
BLOCK_ADJUST(rc, session,
|
||||
userauth_publickey_frommemory(session, user, user_len,
|
||||
publickeyfiledata,
|
||||
publickeyfiledata_len,
|
||||
privatekeyfiledata,
|
||||
privatekeyfiledata_len,
|
||||
passphrase));
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* libssh2_userauth_publickey_fromfile_ex
|
||||
* Authenticate using a keypair found in the named files
|
||||
*/
|
||||
@@ -1540,6 +1773,8 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
|
||||
"keyboard-interactive prompt message");
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(session->userauth_kybd_prompts[i].text, s,
|
||||
session->userauth_kybd_prompts[i].length);
|
||||
s += session->userauth_kybd_prompts[i].length;
|
||||
|
||||
/* boolean echo[1] */
|
||||
|
||||
476
src/wincng.c
476
src/wincng.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Marc Hoersken <info@marc-hoersken.de>
|
||||
* Copyright (C) 2013-2015 Marc Hoersken <info@marc-hoersken.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -67,6 +67,11 @@
|
||||
#include <wincrypt.h>
|
||||
#endif
|
||||
|
||||
#define PEM_RSA_HEADER "-----BEGIN RSA PRIVATE KEY-----"
|
||||
#define PEM_RSA_FOOTER "-----END RSA PRIVATE KEY-----"
|
||||
#define PEM_DSA_HEADER "-----BEGIN DSA PRIVATE KEY-----"
|
||||
#define PEM_DSA_FOOTER "-----END DSA PRIVATE KEY-----"
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
@@ -280,6 +285,24 @@ _libssh2_wincng_random(void *buf, int len)
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_libssh2_wincng_safe_free(void *buf, int len)
|
||||
{
|
||||
#ifndef LIBSSH2_CLEAR_MEMORY
|
||||
(void)len;
|
||||
#endif
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
#ifdef LIBSSH2_CLEAR_MEMORY
|
||||
if (len > 0)
|
||||
SecureZeroMemory(buf, len);
|
||||
#endif
|
||||
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
@@ -322,7 +345,7 @@ _libssh2_wincng_hash_init(_libssh2_wincng_hash_ctx *ctx,
|
||||
pbHashObject, dwHashObject,
|
||||
key, keylen, 0);
|
||||
if (!BCRYPT_SUCCESS(ret)) {
|
||||
free(pbHashObject);
|
||||
_libssh2_wincng_safe_free(pbHashObject, dwHashObject);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -355,11 +378,11 @@ _libssh2_wincng_hash_final(_libssh2_wincng_hash_ctx *ctx,
|
||||
ret = BCryptFinishHash(ctx->hHash, hash, ctx->cbHash, 0);
|
||||
|
||||
BCryptDestroyHash(ctx->hHash);
|
||||
ctx->hHash = NULL;
|
||||
|
||||
if (ctx->pbHashObject)
|
||||
free(ctx->pbHashObject);
|
||||
|
||||
memset(ctx, 0, sizeof(_libssh2_wincng_hash_ctx));
|
||||
_libssh2_wincng_safe_free(ctx->pbHashObject, ctx->dwHashObject);
|
||||
ctx->pbHashObject = NULL;
|
||||
ctx->dwHashObject = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -403,11 +426,11 @@ void
|
||||
_libssh2_wincng_hmac_cleanup(_libssh2_wincng_hash_ctx *ctx)
|
||||
{
|
||||
BCryptDestroyHash(ctx->hHash);
|
||||
ctx->hHash = NULL;
|
||||
|
||||
if (ctx->pbHashObject)
|
||||
free(ctx->pbHashObject);
|
||||
|
||||
memset(ctx, 0, sizeof(_libssh2_wincng_hash_ctx));
|
||||
_libssh2_wincng_safe_free(ctx->pbHashObject, ctx->dwHashObject);
|
||||
ctx->pbHashObject = NULL;
|
||||
ctx->dwHashObject = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -449,17 +472,17 @@ _libssh2_wincng_key_sha1_verify(_libssh2_wincng_key_ctx *ctx,
|
||||
_libssh2_wincng.hAlgHashSHA1,
|
||||
hash, hashlen);
|
||||
|
||||
free(data);
|
||||
_libssh2_wincng_safe_free(data, datalen);
|
||||
|
||||
if (ret) {
|
||||
free(hash);
|
||||
_libssh2_wincng_safe_free(hash, hashlen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
datalen = sig_len;
|
||||
data = malloc(datalen);
|
||||
if (!data) {
|
||||
free(hash);
|
||||
_libssh2_wincng_safe_free(hash, hashlen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -474,8 +497,8 @@ _libssh2_wincng_key_sha1_verify(_libssh2_wincng_key_ctx *ctx,
|
||||
ret = BCryptVerifySignature(ctx->hKey, pPaddingInfo,
|
||||
hash, hashlen, data, datalen, flags);
|
||||
|
||||
free(hash);
|
||||
free(data);
|
||||
_libssh2_wincng_safe_free(hash, hashlen);
|
||||
_libssh2_wincng_safe_free(data, datalen);
|
||||
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
@@ -513,24 +536,62 @@ _libssh2_wincng_load_private(LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const char *passphrase,
|
||||
unsigned char **ppbEncoded,
|
||||
unsigned long *pcbEncoded)
|
||||
unsigned long *pcbEncoded,
|
||||
int tryLoadRSA, int tryLoadDSA)
|
||||
{
|
||||
unsigned char *data;
|
||||
unsigned int datalen;
|
||||
int ret;
|
||||
unsigned char *data = NULL;
|
||||
unsigned int datalen = 0;
|
||||
int ret = -1;
|
||||
|
||||
ret = _libssh2_wincng_load_pem(session, filename, passphrase,
|
||||
"-----BEGIN RSA PRIVATE KEY-----",
|
||||
"-----END RSA PRIVATE KEY-----",
|
||||
&data, &datalen);
|
||||
|
||||
if (ret) {
|
||||
if (ret && tryLoadRSA) {
|
||||
ret = _libssh2_wincng_load_pem(session, filename, passphrase,
|
||||
"-----BEGIN DSA PRIVATE KEY-----",
|
||||
"-----END DSA PRIVATE KEY-----",
|
||||
PEM_RSA_HEADER, PEM_RSA_FOOTER,
|
||||
&data, &datalen);
|
||||
}
|
||||
|
||||
if (ret && tryLoadDSA) {
|
||||
ret = _libssh2_wincng_load_pem(session, filename, passphrase,
|
||||
PEM_DSA_HEADER, PEM_DSA_FOOTER,
|
||||
&data, &datalen);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
*ppbEncoded = data;
|
||||
*pcbEncoded = datalen;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
_libssh2_wincng_load_private_memory(LIBSSH2_SESSION *session,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase,
|
||||
unsigned char **ppbEncoded,
|
||||
unsigned long *pcbEncoded,
|
||||
int tryLoadRSA, int tryLoadDSA)
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
unsigned int datalen = 0;
|
||||
int ret = -1;
|
||||
|
||||
(void)passphrase;
|
||||
|
||||
if (ret && tryLoadRSA) {
|
||||
ret = _libssh2_pem_parse_memory(session,
|
||||
PEM_RSA_HEADER, PEM_RSA_FOOTER,
|
||||
privatekeydata, privatekeydata_len,
|
||||
&data, &datalen);
|
||||
}
|
||||
|
||||
if (ret && tryLoadDSA) {
|
||||
ret = _libssh2_pem_parse_memory(session,
|
||||
PEM_DSA_HEADER, PEM_DSA_FOOTER,
|
||||
privatekeydata, privatekeydata_len,
|
||||
&data, &datalen);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
*ppbEncoded = data;
|
||||
*pcbEncoded = datalen;
|
||||
@@ -568,7 +629,7 @@ _libssh2_wincng_asn_decode(unsigned char *pbEncoded,
|
||||
pbEncoded, cbEncoded, 0, NULL,
|
||||
pbDecoded, &cbDecoded);
|
||||
if (!ret) {
|
||||
free(pbDecoded);
|
||||
_libssh2_wincng_safe_free(pbDecoded, cbDecoded);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -639,7 +700,7 @@ _libssh2_wincng_asn_decode_bn(unsigned char *pbEncoded,
|
||||
*ppbDecoded = pbDecoded;
|
||||
*pcbDecoded = cbDecoded;
|
||||
}
|
||||
free(pbInteger);
|
||||
_libssh2_wincng_safe_free(pbInteger, cbInteger);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -684,10 +745,10 @@ _libssh2_wincng_asn_decode_bns(unsigned char *pbEncoded,
|
||||
*pcbCount = length;
|
||||
} else {
|
||||
for (length = 0; length < index; length++) {
|
||||
if (rpbDecoded[length]) {
|
||||
free(rpbDecoded[length]);
|
||||
rpbDecoded[length] = NULL;
|
||||
}
|
||||
_libssh2_wincng_safe_free(rpbDecoded[length],
|
||||
rcbDecoded[length]);
|
||||
rpbDecoded[length] = NULL;
|
||||
rcbDecoded[length] = 0;
|
||||
}
|
||||
free(rpbDecoded);
|
||||
free(rcbDecoded);
|
||||
@@ -700,7 +761,7 @@ _libssh2_wincng_asn_decode_bns(unsigned char *pbEncoded,
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
free(pbDecoded);
|
||||
_libssh2_wincng_safe_free(pbDecoded, cbDecoded);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -846,7 +907,7 @@ _libssh2_wincng_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
ret = BCryptImportKeyPair(_libssh2_wincng.hAlgRSA, NULL, lpszBlobType,
|
||||
&hKey, key, keylen, 0);
|
||||
if (!BCRYPT_SUCCESS(ret)) {
|
||||
free(key);
|
||||
_libssh2_wincng_safe_free(key, keylen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -854,7 +915,7 @@ _libssh2_wincng_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
*rsa = malloc(sizeof(libssh2_rsa_ctx));
|
||||
if (!(*rsa)) {
|
||||
BCryptDestroyKey(hKey);
|
||||
free(key);
|
||||
_libssh2_wincng_safe_free(key, keylen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -865,32 +926,25 @@ _libssh2_wincng_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
static int
|
||||
_libssh2_wincng_rsa_new_private_parse(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
unsigned char *pbEncoded,
|
||||
unsigned long cbEncoded)
|
||||
{
|
||||
BCRYPT_KEY_HANDLE hKey;
|
||||
unsigned char *pbEncoded, *pbStructInfo;
|
||||
unsigned long cbEncoded, cbStructInfo;
|
||||
unsigned char *pbStructInfo;
|
||||
unsigned long cbStructInfo;
|
||||
int ret;
|
||||
|
||||
(void)session;
|
||||
|
||||
ret = _libssh2_wincng_load_private(session, filename,
|
||||
(const char *)passphrase,
|
||||
&pbEncoded, &cbEncoded);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = _libssh2_wincng_asn_decode(pbEncoded, cbEncoded,
|
||||
PKCS_RSA_PRIVATE_KEY,
|
||||
&pbStructInfo, &cbStructInfo);
|
||||
|
||||
free(pbEncoded);
|
||||
_libssh2_wincng_safe_free(pbEncoded, cbEncoded);
|
||||
|
||||
if (ret) {
|
||||
return -1;
|
||||
@@ -901,7 +955,7 @@ _libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
LEGACY_RSAPRIVATE_BLOB, &hKey,
|
||||
pbStructInfo, cbStructInfo, 0);
|
||||
if (!BCRYPT_SUCCESS(ret)) {
|
||||
free(pbStructInfo);
|
||||
_libssh2_wincng_safe_free(pbStructInfo, cbStructInfo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -909,7 +963,7 @@ _libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
*rsa = malloc(sizeof(libssh2_rsa_ctx));
|
||||
if (!(*rsa)) {
|
||||
BCryptDestroyKey(hKey);
|
||||
free(pbStructInfo);
|
||||
_libssh2_wincng_safe_free(pbStructInfo, cbStructInfo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -918,6 +972,31 @@ _libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
(*rsa)->cbKeyObject = cbStructInfo;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
|
||||
int
|
||||
_libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded;
|
||||
unsigned long cbEncoded;
|
||||
int ret;
|
||||
|
||||
(void)session;
|
||||
|
||||
ret = _libssh2_wincng_load_private(session, filename,
|
||||
(const char *)passphrase,
|
||||
&pbEncoded, &cbEncoded, 1, 0);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _libssh2_wincng_rsa_new_private_parse(rsa, session,
|
||||
pbEncoded, cbEncoded);
|
||||
#else
|
||||
(void)rsa;
|
||||
(void)filename;
|
||||
@@ -929,6 +1008,41 @@ _libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded;
|
||||
unsigned long cbEncoded;
|
||||
int ret;
|
||||
|
||||
(void)session;
|
||||
|
||||
ret = _libssh2_wincng_load_private_memory(session, filedata, filedata_len,
|
||||
(const char *)passphrase,
|
||||
&pbEncoded, &cbEncoded, 1, 0);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _libssh2_wincng_rsa_new_private_parse(rsa, session,
|
||||
pbEncoded, cbEncoded);
|
||||
#else
|
||||
(void)rsa;
|
||||
(void)filedata;
|
||||
(void)filedata_len;
|
||||
(void)passphrase;
|
||||
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
"Unable to extract private key from memory: "
|
||||
"Method unsupported in Windows CNG backend");
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_rsa_sha1_verify(libssh2_rsa_ctx *rsa,
|
||||
const unsigned char *sig,
|
||||
@@ -983,7 +1097,7 @@ _libssh2_wincng_rsa_sha1_sign(LIBSSH2_SESSION *session,
|
||||
ret = STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
free(data);
|
||||
_libssh2_wincng_safe_free(data, datalen);
|
||||
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
@@ -995,12 +1109,10 @@ _libssh2_wincng_rsa_free(libssh2_rsa_ctx *rsa)
|
||||
return;
|
||||
|
||||
BCryptDestroyKey(rsa->hKey);
|
||||
rsa->hKey = NULL;
|
||||
|
||||
if (rsa->pbKeyObject)
|
||||
free(rsa->pbKeyObject);
|
||||
|
||||
memset(rsa, 0, sizeof(libssh2_rsa_ctx));
|
||||
free(rsa);
|
||||
_libssh2_wincng_safe_free(rsa->pbKeyObject, rsa->cbKeyObject);
|
||||
_libssh2_wincng_safe_free(rsa, sizeof(libssh2_rsa_ctx));
|
||||
}
|
||||
|
||||
|
||||
@@ -1094,7 +1206,7 @@ _libssh2_wincng_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
ret = BCryptImportKeyPair(_libssh2_wincng.hAlgDSA, NULL, lpszBlobType,
|
||||
&hKey, key, keylen, 0);
|
||||
if (!BCRYPT_SUCCESS(ret)) {
|
||||
free(key);
|
||||
_libssh2_wincng_safe_free(key, keylen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1102,7 +1214,7 @@ _libssh2_wincng_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
*dsa = malloc(sizeof(libssh2_dsa_ctx));
|
||||
if (!(*dsa)) {
|
||||
BCryptDestroyKey(hKey);
|
||||
free(key);
|
||||
_libssh2_wincng_safe_free(key, keylen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1113,30 +1225,23 @@ _libssh2_wincng_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded, **rpbDecoded;
|
||||
unsigned long cbEncoded, *rcbDecoded, index, length;
|
||||
static int
|
||||
_libssh2_wincng_dsa_new_private_parse(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
unsigned char *pbEncoded,
|
||||
unsigned long cbEncoded)
|
||||
{
|
||||
unsigned char **rpbDecoded;
|
||||
unsigned long *rcbDecoded, index, length;
|
||||
int ret;
|
||||
|
||||
(void)session;
|
||||
|
||||
ret = _libssh2_wincng_load_private(session, filename,
|
||||
(const char *)passphrase,
|
||||
&pbEncoded, &cbEncoded);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = _libssh2_wincng_asn_decode_bns(pbEncoded, cbEncoded,
|
||||
&rpbDecoded, &rcbDecoded, &length);
|
||||
|
||||
free(pbEncoded);
|
||||
_libssh2_wincng_safe_free(pbEncoded, cbEncoded);
|
||||
|
||||
if (ret) {
|
||||
return -1;
|
||||
@@ -1155,16 +1260,38 @@ _libssh2_wincng_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
}
|
||||
|
||||
for (index = 0; index < length; index++) {
|
||||
if (rpbDecoded[index]) {
|
||||
free(rpbDecoded[index]);
|
||||
rpbDecoded[index] = NULL;
|
||||
}
|
||||
_libssh2_wincng_safe_free(rpbDecoded[index], rcbDecoded[index]);
|
||||
rpbDecoded[index] = NULL;
|
||||
rcbDecoded[index] = 0;
|
||||
}
|
||||
|
||||
free(rpbDecoded);
|
||||
free(rcbDecoded);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
|
||||
int
|
||||
_libssh2_wincng_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded;
|
||||
unsigned long cbEncoded;
|
||||
int ret;
|
||||
|
||||
ret = _libssh2_wincng_load_private(session, filename,
|
||||
(const char *)passphrase,
|
||||
&pbEncoded, &cbEncoded, 0, 1);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _libssh2_wincng_dsa_new_private_parse(dsa, session,
|
||||
pbEncoded, cbEncoded);
|
||||
#else
|
||||
(void)dsa;
|
||||
(void)filename;
|
||||
@@ -1176,6 +1303,39 @@ _libssh2_wincng_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_dsa_new_private_frommemory(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded;
|
||||
unsigned long cbEncoded;
|
||||
int ret;
|
||||
|
||||
ret = _libssh2_wincng_load_private_memory(session, filedata, filedata_len,
|
||||
(const char *)passphrase,
|
||||
&pbEncoded, &cbEncoded, 0, 1);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _libssh2_wincng_dsa_new_private_parse(dsa, session,
|
||||
pbEncoded, cbEncoded);
|
||||
#else
|
||||
(void)dsa;
|
||||
(void)filedata;
|
||||
(void)filedata_len;
|
||||
(void)passphrase;
|
||||
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
"Unable to extract private key from memory: "
|
||||
"Method unsupported in Windows CNG backend");
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_dsa_sha1_verify(libssh2_dsa_ctx *dsa,
|
||||
const unsigned char *sig_fixed,
|
||||
@@ -1216,14 +1376,14 @@ _libssh2_wincng_dsa_sha1_sign(libssh2_dsa_ctx *dsa,
|
||||
memcpy(sig_fixed, sig, siglen);
|
||||
}
|
||||
|
||||
free(sig);
|
||||
_libssh2_wincng_safe_free(sig, siglen);
|
||||
} else
|
||||
ret = STATUS_NO_MEMORY;
|
||||
} else
|
||||
ret = STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
free(data);
|
||||
_libssh2_wincng_safe_free(data, datalen);
|
||||
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
@@ -1235,12 +1395,10 @@ _libssh2_wincng_dsa_free(libssh2_dsa_ctx *dsa)
|
||||
return;
|
||||
|
||||
BCryptDestroyKey(dsa->hKey);
|
||||
dsa->hKey = NULL;
|
||||
|
||||
if (dsa->pbKeyObject)
|
||||
free(dsa->pbKeyObject);
|
||||
|
||||
memset(dsa, 0, sizeof(libssh2_dsa_ctx));
|
||||
free(dsa);
|
||||
_libssh2_wincng_safe_free(dsa->pbKeyObject, dsa->cbKeyObject);
|
||||
_libssh2_wincng_safe_free(dsa, sizeof(libssh2_dsa_ctx));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1250,6 +1408,7 @@ _libssh2_wincng_dsa_free(libssh2_dsa_ctx *dsa)
|
||||
* Windows CNG backend: Key functions
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
static unsigned long
|
||||
_libssh2_wincng_pub_priv_write(unsigned char *key,
|
||||
unsigned long offset,
|
||||
@@ -1265,33 +1424,26 @@ _libssh2_wincng_pub_priv_write(unsigned char *key,
|
||||
return offset;
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase)
|
||||
static int
|
||||
_libssh2_wincng_pub_priv_keyfile_parse(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
unsigned char *pbEncoded,
|
||||
unsigned long cbEncoded)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded, **rpbDecoded;
|
||||
unsigned long cbEncoded, *rcbDecoded;
|
||||
unsigned char **rpbDecoded;
|
||||
unsigned long *rcbDecoded;
|
||||
unsigned char *key = NULL, *mth = NULL;
|
||||
unsigned long keylen = 0, mthlen = 0;
|
||||
unsigned long index, offset, length;
|
||||
int ret;
|
||||
|
||||
ret = _libssh2_wincng_load_private(session, privatekey, passphrase,
|
||||
&pbEncoded, &cbEncoded);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = _libssh2_wincng_asn_decode_bns(pbEncoded, cbEncoded,
|
||||
&rpbDecoded, &rcbDecoded, &length);
|
||||
|
||||
free(pbEncoded);
|
||||
_libssh2_wincng_safe_free(pbEncoded, cbEncoded);
|
||||
|
||||
if (ret) {
|
||||
return -1;
|
||||
@@ -1364,10 +1516,9 @@ _libssh2_wincng_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
|
||||
|
||||
for (index = 0; index < length; index++) {
|
||||
if (rpbDecoded[index]) {
|
||||
free(rpbDecoded[index]);
|
||||
rpbDecoded[index] = NULL;
|
||||
}
|
||||
_libssh2_wincng_safe_free(rpbDecoded[index], rcbDecoded[index]);
|
||||
rpbDecoded[index] = NULL;
|
||||
rcbDecoded[index] = 0;
|
||||
}
|
||||
|
||||
free(rpbDecoded);
|
||||
@@ -1387,6 +1538,32 @@ _libssh2_wincng_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
|
||||
int
|
||||
_libssh2_wincng_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded;
|
||||
unsigned long cbEncoded;
|
||||
int ret;
|
||||
|
||||
ret = _libssh2_wincng_load_private(session, privatekey, passphrase,
|
||||
&pbEncoded, &cbEncoded, 1, 1);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _libssh2_wincng_pub_priv_keyfile_parse(session, method, method_len,
|
||||
pubkeydata, pubkeydata_len,
|
||||
pbEncoded, cbEncoded);
|
||||
#else
|
||||
(void)method;
|
||||
(void)method_len;
|
||||
@@ -1401,6 +1578,45 @@ _libssh2_wincng_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_wincng_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase)
|
||||
{
|
||||
#ifdef HAVE_LIBCRYPT32
|
||||
unsigned char *pbEncoded;
|
||||
unsigned long cbEncoded;
|
||||
int ret;
|
||||
|
||||
ret = _libssh2_wincng_load_private_memory(session, privatekeydata,
|
||||
privatekeydata_len, passphrase,
|
||||
&pbEncoded, &cbEncoded, 1, 1);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _libssh2_wincng_pub_priv_keyfile_parse(session, method, method_len,
|
||||
pubkeydata, pubkeydata_len,
|
||||
pbEncoded, cbEncoded);
|
||||
#else
|
||||
(void)method;
|
||||
(void)method_len;
|
||||
(void)pubkeydata_len;
|
||||
(void)pubkeydata;
|
||||
(void)privatekeydata;
|
||||
(void)privatekeydata_len;
|
||||
(void)passphrase;
|
||||
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
"Unable to extract public key from private key in memory: "
|
||||
"Method unsupported in Windows CNG backend");
|
||||
#endif /* HAVE_LIBCRYPT32 */
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
/*
|
||||
@@ -1463,10 +1679,10 @@ _libssh2_wincng_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
ret = BCryptImportKey(*type.phAlg, NULL, BCRYPT_KEY_DATA_BLOB, &hKey,
|
||||
pbKeyObject, dwKeyObject, key, keylen, 0);
|
||||
|
||||
free(key);
|
||||
_libssh2_wincng_safe_free(key, keylen);
|
||||
|
||||
if (!BCRYPT_SUCCESS(ret)) {
|
||||
free(pbKeyObject);
|
||||
_libssh2_wincng_safe_free(pbKeyObject, dwKeyObject);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1474,7 +1690,7 @@ _libssh2_wincng_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
pbIV = malloc(dwBlockLength);
|
||||
if (!pbIV) {
|
||||
BCryptDestroyKey(hKey);
|
||||
free(pbKeyObject);
|
||||
_libssh2_wincng_safe_free(pbKeyObject, dwKeyObject);
|
||||
return -1;
|
||||
}
|
||||
dwIV = dwBlockLength;
|
||||
@@ -1533,7 +1749,7 @@ _libssh2_wincng_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
||||
memcpy(block, pbOutput, cbOutput);
|
||||
}
|
||||
|
||||
free(pbOutput);
|
||||
_libssh2_wincng_safe_free(pbOutput, cbOutput);
|
||||
} else
|
||||
ret = STATUS_NO_MEMORY;
|
||||
}
|
||||
@@ -1545,13 +1761,15 @@ void
|
||||
_libssh2_wincng_cipher_dtor(_libssh2_cipher_ctx *ctx)
|
||||
{
|
||||
BCryptDestroyKey(ctx->hKey);
|
||||
ctx->hKey = NULL;
|
||||
|
||||
if (ctx->pbKeyObject) {
|
||||
free(ctx->pbKeyObject);
|
||||
ctx->pbKeyObject = NULL;
|
||||
}
|
||||
_libssh2_wincng_safe_free(ctx->pbKeyObject, ctx->dwKeyObject);
|
||||
ctx->pbKeyObject = NULL;
|
||||
ctx->dwKeyObject = 0;
|
||||
|
||||
memset(ctx, 0, sizeof(_libssh2_cipher_ctx));
|
||||
_libssh2_wincng_safe_free(ctx->pbIV, ctx->dwBlockLength);
|
||||
ctx->pbIV = NULL;
|
||||
ctx->dwBlockLength = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1585,6 +1803,12 @@ _libssh2_wincng_bignum_resize(_libssh2_bn *bn, unsigned long length)
|
||||
if (length == bn->length)
|
||||
return 0;
|
||||
|
||||
#ifdef LIBSSH2_CLEAR_MEMORY
|
||||
if (bn->bignum && bn->length > 0 && length < bn->length) {
|
||||
SecureZeroMemory(bn->bignum + length, bn->length - length);
|
||||
}
|
||||
#endif
|
||||
|
||||
bignum = realloc(bn->bignum, length);
|
||||
if (!bignum)
|
||||
return -1;
|
||||
@@ -1692,7 +1916,7 @@ _libssh2_wincng_bignum_mod_exp(_libssh2_bn *r,
|
||||
r->bignum, r->length, &offset,
|
||||
BCRYPT_PAD_NONE);
|
||||
|
||||
free(bignum);
|
||||
_libssh2_wincng_safe_free(bignum, length);
|
||||
|
||||
if (BCRYPT_SUCCESS(ret)) {
|
||||
_libssh2_wincng_bignum_resize(r, offset);
|
||||
@@ -1706,7 +1930,7 @@ _libssh2_wincng_bignum_mod_exp(_libssh2_bn *r,
|
||||
BCryptDestroyKey(hKey);
|
||||
}
|
||||
|
||||
free(key);
|
||||
_libssh2_wincng_safe_free(key, keylen);
|
||||
|
||||
return BCRYPT_SUCCESS(ret) ? 0 : -1;
|
||||
}
|
||||
@@ -1784,6 +2008,10 @@ _libssh2_wincng_bignum_from_bin(_libssh2_bn *bn, unsigned long len,
|
||||
if (offset > 0) {
|
||||
memmove(bn->bignum, bn->bignum + offset, length);
|
||||
|
||||
#ifdef LIBSSH2_CLEAR_MEMORY
|
||||
SecureZeroMemory(bn->bignum + length, offset);
|
||||
#endif
|
||||
|
||||
bignum = realloc(bn->bignum, length);
|
||||
if (bignum) {
|
||||
bn->bignum = bignum;
|
||||
@@ -1805,11 +2033,11 @@ _libssh2_wincng_bignum_free(_libssh2_bn *bn)
|
||||
{
|
||||
if (bn) {
|
||||
if (bn->bignum) {
|
||||
free(bn->bignum);
|
||||
_libssh2_wincng_safe_free(bn->bignum, bn->length);
|
||||
bn->bignum = NULL;
|
||||
}
|
||||
bn->length = 0;
|
||||
free(bn);
|
||||
_libssh2_wincng_safe_free(bn, sizeof(_libssh2_bn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
50
src/wincng.h
50
src/wincng.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Marc Hoersken <info@marc-hoersken.de>
|
||||
* Copyright (C) 2013-2015 Marc Hoersken <info@marc-hoersken.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -122,8 +122,8 @@ typedef struct __libssh2_wincng_hash_ctx {
|
||||
|
||||
#define libssh2_sha1_ctx _libssh2_wincng_hash_ctx
|
||||
#define libssh2_sha1_init(ctx) \
|
||||
_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashSHA1, \
|
||||
SHA_DIGEST_LENGTH, NULL, 0)
|
||||
(_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashSHA1, \
|
||||
SHA_DIGEST_LENGTH, NULL, 0) == 0)
|
||||
#define libssh2_sha1_update(ctx, data, datalen) \
|
||||
_libssh2_wincng_hash_update(&ctx, (unsigned char *) data, datalen)
|
||||
#define libssh2_sha1_final(ctx, hash) \
|
||||
@@ -134,8 +134,8 @@ typedef struct __libssh2_wincng_hash_ctx {
|
||||
|
||||
#define libssh2_md5_ctx _libssh2_wincng_hash_ctx
|
||||
#define libssh2_md5_init(ctx) \
|
||||
_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashMD5, \
|
||||
MD5_DIGEST_LENGTH, NULL, 0)
|
||||
(_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHashMD5, \
|
||||
MD5_DIGEST_LENGTH, NULL, 0) == 0)
|
||||
#define libssh2_md5_update(ctx, data, datalen) \
|
||||
_libssh2_wincng_hash_update(&ctx, (unsigned char *) data, datalen)
|
||||
#define libssh2_md5_final(ctx, hash) \
|
||||
@@ -149,6 +149,7 @@ typedef struct __libssh2_wincng_hash_ctx {
|
||||
*/
|
||||
|
||||
#define libssh2_hmac_ctx _libssh2_wincng_hash_ctx
|
||||
#define libssh2_hmac_ctx_init(ctx)
|
||||
#define libssh2_hmac_sha1_init(ctx, key, keylen) \
|
||||
_libssh2_wincng_hash_init(ctx, _libssh2_wincng.hAlgHmacSHA1, \
|
||||
SHA_DIGEST_LENGTH, key, keylen)
|
||||
@@ -190,6 +191,10 @@ typedef struct __libssh2_wincng_key_ctx {
|
||||
e1, e1_len, e2, e2_len, c, c_len)
|
||||
#define _libssh2_rsa_new_private(rsactx, s, filename, passphrase) \
|
||||
_libssh2_wincng_rsa_new_private(rsactx, s, filename, passphrase)
|
||||
#define _libssh2_rsa_new_private_frommemory(rsactx, s, filedata, \
|
||||
filedata_len, passphrase) \
|
||||
_libssh2_wincng_rsa_new_private_frommemory(rsactx, s, filedata, \
|
||||
filedata_len, passphrase)
|
||||
#define _libssh2_rsa_sha1_sign(s, rsactx, hash, hash_len, sig, sig_len) \
|
||||
_libssh2_wincng_rsa_sha1_sign(s, rsactx, hash, hash_len, sig, sig_len)
|
||||
#define _libssh2_rsa_sha1_verify(rsactx, sig, sig_len, m, m_len) \
|
||||
@@ -206,8 +211,12 @@ typedef struct __libssh2_wincng_key_ctx {
|
||||
g, g_len, y, y_len, x, x_len) \
|
||||
_libssh2_wincng_dsa_new(dsactx, p, p_len, q, q_len, \
|
||||
g, g_len, y, y_len, x, x_len)
|
||||
#define _libssh2_dsa_new_private(rsactx, s, filename, passphrase) \
|
||||
_libssh2_wincng_dsa_new_private(rsactx, s, filename, passphrase)
|
||||
#define _libssh2_dsa_new_private(dsactx, s, filename, passphrase) \
|
||||
_libssh2_wincng_dsa_new_private(dsactx, s, filename, passphrase)
|
||||
#define _libssh2_dsa_new_private_frommemory(dsactx, s, filedata, \
|
||||
filedata_len, passphrase) \
|
||||
_libssh2_wincng_dsa_new_private_frommemory(dsactx, s, filedata, \
|
||||
filedata_len, passphrase)
|
||||
#define _libssh2_dsa_sha1_sign(dsactx, hash, hash_len, sig) \
|
||||
_libssh2_wincng_dsa_sha1_sign(dsactx, hash, hash_len, sig)
|
||||
#define _libssh2_dsa_sha1_verify(dsactx, sig, m, m_len) \
|
||||
@@ -221,6 +230,10 @@ typedef struct __libssh2_wincng_key_ctx {
|
||||
|
||||
#define _libssh2_pub_priv_keyfile(s, m, m_len, p, p_len, pk, pw) \
|
||||
_libssh2_wincng_pub_priv_keyfile(s, m, m_len, p, p_len, pk, pw)
|
||||
#define _libssh2_pub_priv_keyfilememory(s, m, m_len, p, p_len, \
|
||||
pk, pk_len, pw) \
|
||||
_libssh2_wincng_pub_priv_keyfilememory(s, m, m_len, p, p_len, \
|
||||
pk, pk_len, pw)
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
@@ -303,6 +316,8 @@ _libssh2_bn *_libssh2_wincng_bignum_init(void);
|
||||
|
||||
#define _libssh2_bn_init() \
|
||||
_libssh2_wincng_bignum_init()
|
||||
#define _libssh2_bn_init_from_bin() \
|
||||
_libssh2_bn_init()
|
||||
#define _libssh2_bn_rand(bn, bits, top, bottom) \
|
||||
_libssh2_wincng_bignum_rand(bn, bits, top, bottom)
|
||||
#define _libssh2_bn_mod_exp(r, a, p, m, ctx) \
|
||||
@@ -381,6 +396,12 @@ _libssh2_wincng_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase);
|
||||
int
|
||||
_libssh2_wincng_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase);
|
||||
int
|
||||
_libssh2_wincng_rsa_sha1_verify(libssh2_rsa_ctx *rsa,
|
||||
const unsigned char *sig,
|
||||
unsigned long sig_len,
|
||||
@@ -415,6 +436,12 @@ _libssh2_wincng_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
const char *filename,
|
||||
const unsigned char *passphrase);
|
||||
int
|
||||
_libssh2_wincng_dsa_new_private_frommemory(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase);
|
||||
int
|
||||
_libssh2_wincng_dsa_sha1_verify(libssh2_dsa_ctx *dsa,
|
||||
const unsigned char *sig_fixed,
|
||||
const unsigned char *m,
|
||||
@@ -436,6 +463,15 @@ _libssh2_wincng_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
int
|
||||
_libssh2_wincng_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
|
||||
int
|
||||
_libssh2_wincng_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
|
||||
@@ -6,14 +6,15 @@ set -e
|
||||
# Run syntax checks for all manpages in the documentation tree.
|
||||
#
|
||||
|
||||
srcdir=${srcdir:-$PWD}
|
||||
srcdir="`cd $(dirname $0);pwd`"
|
||||
mandir=${srcdir}/../docs
|
||||
|
||||
#
|
||||
# Only test if suitable man is available
|
||||
#
|
||||
if ! man --help | grep -q warnings; then
|
||||
exit 77
|
||||
echo "man version not suitable, skipping tests"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ec=0
|
||||
|
||||
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Create a session instance and start it up
|
||||
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
||||
session = libssh2_session_init();
|
||||
if (libssh2_session_startup(session, sock)) {
|
||||
fprintf(stderr, "Failure establishing SSH session\n");
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* At this point we havn't authenticated,
|
||||
|
||||
@@ -9,17 +9,12 @@
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../zlib-1.2.7
|
||||
ZLIB_PATH = ../../zlib-1.2.8
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8x
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
ifndef ARCH
|
||||
ARCH = w32
|
||||
OPENSSL_PATH = ../../openssl-0.9.8zc
|
||||
endif
|
||||
|
||||
# Edit the path below to point to your Distribution folder.
|
||||
@@ -34,6 +29,9 @@ DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-$(ARCH)
|
||||
endif
|
||||
DEVLARC = $(DEVLDIR).zip
|
||||
|
||||
# Project root
|
||||
PROOT = ..
|
||||
|
||||
# Edit the vars below to change target settings.
|
||||
TARGET = libssh2
|
||||
WWWURL = http://www.libssh2.org/
|
||||
@@ -95,14 +93,24 @@ else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
|
||||
# Set environment var ARCH to your architecture to override autodetection.
|
||||
ifndef ARCH
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
|
||||
ARCH = w64
|
||||
else
|
||||
ARCH = w32
|
||||
endif
|
||||
else
|
||||
ARCH = w32
|
||||
endif
|
||||
endif
|
||||
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
CFLAGS = $(LIBSSH2_CFLAG_EXTRAS) $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
|
||||
ifeq ($(CC),mwcc)
|
||||
LD = mwld
|
||||
@@ -129,13 +137,26 @@ LIBEXT = a
|
||||
RANLIB = $(CROSSPREFIX)ranlib
|
||||
#LDLIBS += -lwsock32
|
||||
LDLIBS += -lws2_32
|
||||
RCFLAGS = -I. -I ../include -O coff -i
|
||||
RCFLAGS = -I $(PROOT)/include -O coff
|
||||
CFLAGS += -fno-builtin
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CFLAGS += -Wall # -pedantic
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
RCFLAGS += -F pe-x86-64
|
||||
else
|
||||
CFLAGS += -m32
|
||||
RCFLAGS += -F pe-i386
|
||||
endif
|
||||
endif
|
||||
|
||||
INCLUDES = -I. -I../include
|
||||
INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
|
||||
|
||||
ifdef WITH_WINCNG
|
||||
CFLAGS += -DLIBSSH2_WINCNG
|
||||
LDLIBS += -lbcrypt -lcrypt32
|
||||
else
|
||||
CFLAGS += -DLIBSSH2_OPENSSL
|
||||
ifndef OPENSSL_INCLUDE
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
|
||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
|
||||
@@ -164,6 +185,7 @@ ifdef LINK_OPENSSL_STATIC
|
||||
else
|
||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef WITH_ZLIB
|
||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
||||
@@ -177,15 +199,22 @@ endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
vpath %.c . ../src
|
||||
vpath %.c $(PROOT)/src
|
||||
|
||||
ifdef WITH_WINCNG
|
||||
include $(PROOT)/Makefile.WinCNG.inc
|
||||
else
|
||||
include $(PROOT)/Makefile.OpenSSL.inc
|
||||
endif
|
||||
|
||||
# include Makefile.inc to get CSOURCES define
|
||||
include ../Makefile.inc
|
||||
include $(PROOT)/Makefile.inc
|
||||
|
||||
OBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
|
||||
OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
|
||||
OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res
|
||||
|
||||
|
||||
all: lib dll
|
||||
|
||||
dll: prebuild $(TARGET).dll
|
||||
@@ -202,38 +231,38 @@ $(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/version.inc: ../get_ver.awk ../include/libssh2.h $(OBJDIR)
|
||||
$(OBJDIR)/version.inc: $(PROOT)/get_ver.awk $(PROOT)/include/libssh2.h $(OBJDIR)
|
||||
@echo Creating $@
|
||||
@$(AWK) -f $^ > $@
|
||||
|
||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@$(call MKDIR, $(DISTDIR)/bin)
|
||||
@$(call CP, ../AUTHORS, $(DISTDIR))
|
||||
@$(call CP, ../COPYING, $(DISTDIR))
|
||||
@$(call CP, ../INSTALL, $(DISTDIR))
|
||||
@$(call CP, ../README, $(DISTDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call CP, $(TARGET).dll, $(DISTDIR)/bin)
|
||||
@$(call COPY, $(PROOT)/AUTHORS, $(DISTDIR))
|
||||
@$(call COPY, $(PROOT)/COPYING, $(DISTDIR))
|
||||
@$(call COPY, $(PROOT)/INSTALL, $(DISTDIR))
|
||||
@$(call COPY, $(PROOT)/README, $(DISTDIR))
|
||||
@$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call COPY, $(TARGET).dll, $(DISTDIR)/bin)
|
||||
@echo Creating $(DISTARC)
|
||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||
|
||||
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||||
@$(call MKDIR, $(DEVLDIR)/bin)
|
||||
@$(call MKDIR,$(DEVLDIR)/include)
|
||||
@$(call MKDIR, $(DEVLDIR)/include)
|
||||
@$(call MKDIR, $(DEVLDIR)/win32)
|
||||
@$(call CP, ../AUTHORS, $(DEVLDIR))
|
||||
@$(call CP, ../COPYING, $(DEVLDIR))
|
||||
@$(call CP, ../INSTALL, $(DEVLDIR))
|
||||
@$(call CP, ../README, $(DEVLDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DEVLDIR))
|
||||
@$(call CP, $(TARGET).dll, $(DEVLDIR)/bin)
|
||||
@$(call CP, ../include/*.h, $(DEVLDIR)/include)
|
||||
@$(call CP, libssh2_config.h, $(DEVLDIR)/include)
|
||||
@$(call CP, *.$(LIBEXT), $(DEVLDIR)/win32)
|
||||
@$(call COPY, $(PROOT)/AUTHORS, $(DEVLDIR))
|
||||
@$(call COPY, $(PROOT)/COPYING, $(DEVLDIR))
|
||||
@$(call COPY, $(PROOT)/INSTALL, $(DEVLDIR))
|
||||
@$(call COPY, $(PROOT)/README, $(DEVLDIR))
|
||||
@$(call COPY, $(PROOT)/RELEASE-NOTES, $(DEVLDIR))
|
||||
@$(call COPY, $(TARGET).dll, $(DEVLDIR)/bin)
|
||||
@$(call COPY, $(PROOT)/include/*.h, $(DEVLDIR)/include)
|
||||
@$(call COPY, libssh2_config.h, $(DEVLDIR)/include)
|
||||
@$(call COPY, *.$(LIBEXT), $(DEVLDIR)/win32)
|
||||
@echo Creating $(DEVLARC)
|
||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||
|
||||
distclean: clean
|
||||
distclean vclean: clean
|
||||
$(call RMDIR, $(DISTDIR))
|
||||
$(call DEL, $(DISTARC))
|
||||
|
||||
@@ -277,7 +306,7 @@ $(TARGET).dll $(TARGET)dll.a: $(OBJL)
|
||||
|
||||
$(OBJDIR)/%.res: %.rc
|
||||
@echo Creating $@
|
||||
@$(RC) $(RCFLAGS) $< -o $@
|
||||
@$(RC) $(RCFLAGS) -i $< -o $@
|
||||
|
||||
|
||||
$(DISTDIR)/readme.txt: GNUmakefile
|
||||
|
||||
@@ -64,22 +64,24 @@ CFLAGS += -d_WIN32_WINNT=0x0501 -dENABLE_IPV6
|
||||
!ifdef %zlib_root
|
||||
ZLIB_ROOT = $(%zlib_root)
|
||||
!else
|
||||
ZLIB_ROOT = ..\..\zlib-1.2.7
|
||||
ZLIB_ROOT = ..\..\zlib-1.2.8
|
||||
!endif
|
||||
|
||||
!ifdef %openssl_root
|
||||
OPENSSL_ROOT = $(%openssl_root)
|
||||
!else
|
||||
OPENSSL_ROOT = ..\..\openssl-0.9.8x
|
||||
OPENSSL_ROOT = ..\..\openssl-0.9.8zc
|
||||
!endif
|
||||
|
||||
#!ifdef %use_zlib
|
||||
CFLAGS += -dHAVE_ZLIB_H -dHAVE_LIBZ -I$(ZLIB_ROOT)
|
||||
#!endif
|
||||
!ifdef %use_zlib
|
||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB -I$(ZLIB_ROOT)
|
||||
!endif
|
||||
|
||||
#!ifdef %use_ssl
|
||||
CFLAGS += -wcd=138 -dUSE_OPENSSL -dUSE_SSLEAY -I$(OPENSSL_ROOT)\inc32
|
||||
#!endif
|
||||
!ifdef %use_wincng
|
||||
CFLAGS += -DLIBSSH2_WINCNG
|
||||
!else
|
||||
CFLAGS += -wcd=138 -dLIBSSH2_OPENSSL -I$(OPENSSL_ROOT)\inc32
|
||||
!endif
|
||||
|
||||
!ifdef %use_watt32
|
||||
CFLAGS += -dUSE_WATT32 -I$(%watt_root)\inc
|
||||
@@ -93,6 +95,11 @@ LIB_ARG = $(OBJ_BASE)\stat\wlib.arg
|
||||
!ifndef %MAKEFLAGS
|
||||
!error You MUST call wmake with the -u switch!
|
||||
!else
|
||||
!ifdef %use_wincng
|
||||
!include ..\Makefile.WinCNG.inc
|
||||
!else
|
||||
!include ..\Makefile.OpenSSL.inc
|
||||
!endif
|
||||
!include ..\Makefile.inc
|
||||
!endif
|
||||
|
||||
@@ -165,12 +172,16 @@ $(LINK_ARG): $(__MAKEFILES__)
|
||||
!else
|
||||
@%append $^@ library ws2_32.lib
|
||||
!endif
|
||||
#!ifdef %use_zlib
|
||||
@%append $^@ library $(ZLIB_ROOT)\zlib.lib
|
||||
#!endif
|
||||
#!ifdef %use_ssl
|
||||
@%append $^@ library $(OPENSSL_ROOT)\out32\libeay32.lib, $(OPENSSL_ROOT)\out32\ssleay32.lib
|
||||
#!endif
|
||||
!ifdef %use_zlib
|
||||
@%append $^@ library '$(ZLIB_ROOT)\zlib.lib'
|
||||
!endif
|
||||
!ifdef %use_wincng
|
||||
@%append $^@ library bcrypt.lib
|
||||
@%append $^@ library crypt32.lib
|
||||
!else
|
||||
@%append $^@ library '$(OPENSSL_ROOT)\out32\libeay32.lib'
|
||||
@%append $^@ library '$(OPENSSL_ROOT)\out32\ssleay32.lib'
|
||||
!endif
|
||||
|
||||
$(LIB_ARG): $(__MAKEFILES__)
|
||||
%create $^@
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
|
||||
# Tweak these for your system
|
||||
OPENSSLINC=..\openssl-0.9.8x\inc32
|
||||
OPENSSLLIB=..\openssl-0.9.8x\out32dll
|
||||
!if "$(OPENSSLINC)" == ""
|
||||
OPENSSLINC=..\openssl-0.9.8zc\inc32
|
||||
!endif
|
||||
|
||||
ZLIBINC=-DLIBSSH2_HAVE_ZLIB=1 /I..\zlib-1.2.7
|
||||
ZLIBLIB=..\zlib-1.2.7
|
||||
!if "$(OPENSSLLIB)" == ""
|
||||
OPENSSLLIB=..\openssl-0.9.8zc\out32dll
|
||||
!endif
|
||||
|
||||
!if "$(ZLIBINC)" == ""
|
||||
ZLIBINC=..\zlib-1.2.8
|
||||
!endif
|
||||
|
||||
!if "$(ZLIBLIB)" == ""
|
||||
ZLIBLIB=..\zlib-1.2.8
|
||||
!endif
|
||||
|
||||
!if "$(TARGET)" == ""
|
||||
TARGET=Release
|
||||
@@ -15,15 +25,29 @@ SUFFIX=_debug
|
||||
CPPFLAGS=/Od /MDd
|
||||
DLLFLAGS=/DEBUG /LDd
|
||||
!else
|
||||
CPPFLAGS=/Og /Oi /O2 /Oy /GF /Y- /MD /DNDEBUG
|
||||
CPPFLAGS=/Oi /O2 /Oy /GF /Y- /MD /DNDEBUG
|
||||
DLLFLAGS=/DEBUG /LD
|
||||
!endif
|
||||
|
||||
CPPFLAGS=/nologo /GL /Zi /EHsc $(CPPFLAGS) /Iwin32 /Iinclude /I$(OPENSSLINC) $(ZLIBINC) -DLIBSSH2_WIN32
|
||||
CPPFLAGS=/nologo /GL /Zi /EHsc $(CPPFLAGS) /Iwin32 /Iinclude
|
||||
|
||||
!if "$(WITH_WINCNG)" == "1"
|
||||
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_WINCNG
|
||||
# LIBS=bcrypt.lib crypt32.lib
|
||||
!else
|
||||
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_OPENSSL /I$(OPENSSLINC)
|
||||
LIBS=$(LIBS) $(OPENSSLLIB)\libeay32.lib $(OPENSSLLIB)\ssleay32.lib
|
||||
!endif
|
||||
|
||||
!if "$(WITH_ZLIB)" == "1"
|
||||
CPPFLAGS=$(CPPFLAGS) /DLIBSSH2_HAVE_ZLIB /I$(ZLIBINC)
|
||||
LIBS=$(LIBS) $(ZLIBLIB)\zlib.lib
|
||||
!endif
|
||||
|
||||
CFLAGS=$(CPPFLAGS)
|
||||
RCFLAGS=/Iinclude
|
||||
DLLFLAGS=$(CFLAGS) $(DLLFLAGS)
|
||||
LIBS=$(OPENSSLLIB)\libeay32.lib $(OPENSSLLIB)\ssleay32.lib ws2_32.lib user32.lib $(ZLIBLIB)\zlib.lib
|
||||
LIBS=$(LIBS) ws2_32.lib user32.lib advapi32.lib gdi32.lib
|
||||
|
||||
INTDIR=$(TARGET)\$(SUBDIR)
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# Microsoft Developer Studio Project File - Name="libssh2" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
# only OpenSSL and WinCNG are supported with this build system
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=libssh2 - Win32 Debug
|
||||
CFG=libssh2 - Win32 OpenSSL Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
@@ -18,10 +19,14 @@ CFG=libssh2 - Win32 Debug
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "libssh2 - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 LIB Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL LIB Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG LIB Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
@@ -32,7 +37,7 @@ CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "libssh2 - Win32 DLL Release"
|
||||
!IF "$(CFG)" == "libssh2 - Win32 OpenSSL DLL Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
@@ -45,8 +50,8 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "Release_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
@@ -59,7 +64,7 @@ LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /map /debug /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 DLL Debug"
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL DLL Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
@@ -72,8 +77,8 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "Debug_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /WX /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
@@ -87,7 +92,7 @@ LINK32=link.exe
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Release"
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL LIB Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
@@ -99,8 +104,8 @@ LINK32=link.exe
|
||||
# PROP Output_Dir "Release_lib"
|
||||
# PROP Intermediate_Dir "Release_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -111,7 +116,7 @@ LIB32=link.exe -lib
|
||||
# ADD LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Release_lib\libssh2.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Debug"
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
@@ -123,8 +128,110 @@ LIB32=link.exe -lib
|
||||
# PROP Output_Dir "Debug_lib"
|
||||
# PROP Intermediate_Dir "Debug_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug_lib\libssh2d.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_dll"
|
||||
# PROP BASE Intermediate_Dir "Release_dll"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_dll"
|
||||
# PROP Intermediate_Dir "Release_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib crypt32.lib bcrypt.lib /nologo /dll /map /debug /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG DLL Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug_dll"
|
||||
# PROP BASE Intermediate_Dir "Debug_dll"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_dll"
|
||||
# PROP Intermediate_Dir "Debug_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /WX /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib crypt32.lib bcrypt.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_lib"
|
||||
# PROP BASE Intermediate_Dir "Release_lib"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_lib"
|
||||
# PROP Intermediate_Dir "Release_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Release_lib\libssh2.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug_lib"
|
||||
# PROP BASE Intermediate_Dir "Debug_lib"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_lib"
|
||||
# PROP Intermediate_Dir "Debug_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -138,10 +245,14 @@ LIB32=link.exe -lib
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "libssh2 - Win32 DLL Release"
|
||||
# Name "libssh2 - Win32 DLL Debug"
|
||||
# Name "libssh2 - Win32 LIB Release"
|
||||
# Name "libssh2 - Win32 LIB Debug"
|
||||
# Name "libssh2 - Win32 OpenSSL DLL Release"
|
||||
# Name "libssh2 - Win32 OpenSSL DLL Debug"
|
||||
# Name "libssh2 - Win32 OpenSSL LIB Release"
|
||||
# Name "libssh2 - Win32 OpenSSL LIB Debug"
|
||||
# Name "libssh2 - Win32 WinCNG DLL Release"
|
||||
# Name "libssh2 - Win32 WinCNG DLL Debug"
|
||||
# Name "libssh2 - Win32 WinCNG LIB Release"
|
||||
# Name "libssh2 - Win32 WinCNG LIB Debug"
|
||||
|
||||
# Begin Group "Source Files"
|
||||
|
||||
@@ -184,10 +295,6 @@ SOURCE=..\src\knownhost.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\libgcrypt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\mac.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -234,6 +341,10 @@ SOURCE=..\src\userauth.c
|
||||
|
||||
SOURCE=..\src\version.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\wincng.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
@@ -252,10 +363,6 @@ SOURCE=..\src\crypto.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\libgcrypt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\libssh2_config.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -294,6 +401,10 @@ SOURCE=..\src\transport.h
|
||||
|
||||
SOURCE=..\src\userauth.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\wincng.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -16,16 +16,15 @@
|
||||
#define HAVE_INTTYPES_H
|
||||
#define HAVE_SYS_TIME_H
|
||||
#define HAVE_GETTIMEOFDAY
|
||||
#endif
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#define HAVE_LIBCRYPT32
|
||||
#define HAVE_WINSOCK2_H
|
||||
#define HAVE_IOCTLSOCKET
|
||||
#define HAVE_SELECT
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#if _MSC_VER < 1500
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
@@ -33,8 +32,10 @@
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#else
|
||||
#ifndef __MINGW32__
|
||||
#define strncasecmp strnicmp
|
||||
#define strcasecmp stricmp
|
||||
#endif /* __MINGW32__ */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Enable newer diffie-hellman-group-exchange-sha1 syntax */
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# Microsoft Developer Studio Project File - Name="libssh2" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
# only OpenSSL and WinCNG are supported with this build system
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=libssh2 - Win32 Debug
|
||||
CFG=libssh2 - Win32 OpenSSL Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
@@ -18,10 +19,14 @@ CFG=libssh2 - Win32 Debug
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "libssh2 - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 LIB Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL LIB Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 OpenSSL LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG DLL Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG LIB Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "libssh2 - Win32 WinCNG LIB Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
@@ -32,7 +37,7 @@ CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "libssh2 - Win32 DLL Release"
|
||||
!IF "$(CFG)" == "libssh2 - Win32 OpenSSL DLL Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
@@ -45,8 +50,8 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "Release_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
@@ -59,7 +64,7 @@ LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /map /debug /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 DLL Debug"
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL DLL Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
@@ -72,8 +77,8 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "Debug_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /WX /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
@@ -87,7 +92,7 @@ LINK32=link.exe
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Release"
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL LIB Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
@@ -99,8 +104,8 @@ LINK32=link.exe
|
||||
# PROP Output_Dir "Release_lib"
|
||||
# PROP Intermediate_Dir "Release_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -111,7 +116,7 @@ LIB32=link.exe -lib
|
||||
# ADD LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Release_lib\libssh2.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Debug"
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 OpenSSL LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
@@ -123,8 +128,110 @@ LIB32=link.exe -lib
|
||||
# PROP Output_Dir "Debug_lib"
|
||||
# PROP Intermediate_Dir "Debug_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug_lib\libssh2d.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_dll"
|
||||
# PROP BASE Intermediate_Dir "Release_dll"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_dll"
|
||||
# PROP Intermediate_Dir "Release_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib crypt32.lib bcrypt.lib /nologo /dll /map /debug /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG DLL Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug_dll"
|
||||
# PROP BASE Intermediate_Dir "Debug_dll"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_dll"
|
||||
# PROP Intermediate_Dir "Debug_dll"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /WX /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib crypt32.lib bcrypt.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_lib"
|
||||
# PROP BASE Intermediate_Dir "Release_lib"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_lib"
|
||||
# PROP Intermediate_Dir "Release_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Release_lib\libssh2.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 WinCNG LIB Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug_lib"
|
||||
# PROP BASE Intermediate_Dir "Debug_lib"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_lib"
|
||||
# PROP Intermediate_Dir "Debug_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -138,8 +245,12 @@ LIB32=link.exe -lib
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "libssh2 - Win32 DLL Release"
|
||||
# Name "libssh2 - Win32 DLL Debug"
|
||||
# Name "libssh2 - Win32 LIB Release"
|
||||
# Name "libssh2 - Win32 LIB Debug"
|
||||
# Name "libssh2 - Win32 OpenSSL DLL Release"
|
||||
# Name "libssh2 - Win32 OpenSSL DLL Debug"
|
||||
# Name "libssh2 - Win32 OpenSSL LIB Release"
|
||||
# Name "libssh2 - Win32 OpenSSL LIB Debug"
|
||||
# Name "libssh2 - Win32 WinCNG DLL Release"
|
||||
# Name "libssh2 - Win32 WinCNG DLL Debug"
|
||||
# Name "libssh2 - Win32 WinCNG LIB Release"
|
||||
# Name "libssh2 - Win32 WinCNG LIB Debug"
|
||||
|
||||
|
||||
@@ -9,24 +9,22 @@
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../../zlib-1.2.7
|
||||
ZLIB_PATH = ../../../zlib-1.2.8
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8x
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8zc
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
ifndef ARCH
|
||||
ARCH = w32
|
||||
endif
|
||||
# Project root
|
||||
PROOT = ../..
|
||||
|
||||
# Edit the var below to enable static linking of libssh2 and libz
|
||||
LINK_STATIC = 1
|
||||
|
||||
# Edit the vars below to change target settings.
|
||||
SAMPLES = ../../example
|
||||
SAMPLES = $(PROOT)/example
|
||||
TARGETS := $(filter-out x11.exe,$(patsubst $(SAMPLES)/%.c,%.exe,$(strip $(wildcard $(SAMPLES)/*.c))))
|
||||
WWWURL = http://www.libssh2.org/
|
||||
DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
|
||||
@@ -86,14 +84,24 @@ else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
|
||||
# Set environment var ARCH to your architecture to override autodetection.
|
||||
ifndef ARCH
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
|
||||
ARCH = w64
|
||||
else
|
||||
ARCH = w32
|
||||
endif
|
||||
else
|
||||
ARCH = w32
|
||||
endif
|
||||
endif
|
||||
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
|
||||
ifeq ($(CC),mwcc)
|
||||
LD = mwld
|
||||
@@ -118,13 +126,21 @@ ARFLAGS = -cq
|
||||
LIBEXT = a
|
||||
#LDLIBS += -lwsock32
|
||||
LDLIBS += -lws2_32
|
||||
RCFLAGS = -O coff -i
|
||||
RCFLAGS = -I $(PROOT)/include -O coff
|
||||
CFLAGS += -fno-builtin
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CFLAGS += -Wall #-Wno-unused #-pedantic
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
RCFLAGS += -F pe-x86-64
|
||||
else
|
||||
CFLAGS += -m32
|
||||
RCFLAGS += -F pe-i386
|
||||
endif
|
||||
endif
|
||||
|
||||
INCLUDES = -I.. -I../../include
|
||||
LIBPATH += -L..
|
||||
INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
|
||||
LIBPATH += -L$(PROOT)/win32
|
||||
|
||||
ifdef LINK_STATIC
|
||||
LDLIBS += -llibssh2
|
||||
@@ -132,6 +148,11 @@ else
|
||||
LDLIBS += -llibssh2dll
|
||||
endif
|
||||
|
||||
ifdef WITH_WINCNG
|
||||
# CFLAGS += -DLIBSSH2_WINCNG
|
||||
LDLIBS += -lbcrypt -lcrypt32
|
||||
else
|
||||
# CFLAGS += -DLIBSSH2_OPENSSL
|
||||
ifndef OPENSSL_INCLUDE
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
|
||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
|
||||
@@ -162,6 +183,7 @@ else
|
||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef WITH_ZLIB
|
||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
||||
@@ -175,7 +197,7 @@ endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
vpath %.c ../../example
|
||||
vpath %.c $(PROOT)/example
|
||||
|
||||
.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res
|
||||
|
||||
@@ -188,9 +210,9 @@ $(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR)
|
||||
$(OBJDIR)/version.inc: $(PROOT)/include/libssh2.h $(OBJDIR)
|
||||
@echo Creating $@
|
||||
@$(AWK) -f ../../get_ver.awk $< > $@
|
||||
@$(AWK) -f $(PROOT)/get_ver.awk $< > $@
|
||||
|
||||
objclean:
|
||||
$(call RMDIR, $(OBJDIR))
|
||||
@@ -208,7 +230,7 @@ $(OBJDIR):
|
||||
|
||||
$(OBJDIR)/%.res: $(OBJDIR)/%.rc
|
||||
@echo Creating $@
|
||||
@$(RC) $(RCFLAGS) $< -o $@
|
||||
@$(RC) $(RCFLAGS) -i $< -o $@
|
||||
|
||||
$(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
|
||||
@echo $(DL)1 VERSIONINFO$(DL) > $@
|
||||
|
||||
Reference in New Issue
Block a user