1
1

58 Коммитов

Автор SHA1 Сообщение Дата
Viktor Szakats
ed2c3c8d28 add OpenSSL-1.1.0-pre2 compatibility
Closes #70
2016-01-17 17:10:45 +01:00
Viktor Szakats
73930e6577 add OpenSSL 1.1.0-pre1 compatibility
* close https://github.com/libssh2/libssh2/issues/69
* sync a declaration with the rest of similar ones
* handle EVP_MD_CTX_new() returning NULL with OpenSSL 1.1.0
* fix potential memory leak with OpenSSL 1.1.0 in
  _libssh2_*_init() functions, when EVP_MD_CTX_new() succeeds,
  but EVP_DigestInit() fails.
2016-01-17 17:10:32 +01:00
Will Cosgrove
fc4a969a05 kex: Added diffie-hellman-group-exchange-sha256 support
... and fixed HMAC_Init depricated usage

Closes #48
2015-09-29 09:43:30 +02:00
Kamil Dudka
418be878ad openssl: fix memleak in _libssh2_dsa_sha1_verify() 2015-06-12 12:05:27 +02:00
Daniel Stenberg
e9536edede openssl: make libssh2_sha1 return error code
- use the internal prefix _libssh2_ for non-exported functions

- removed libssh2_md5() since it wasn't used

Reported-by: Kamil Dudka
2015-06-12 10:53:18 +02:00
LarsNordin-LNdata
e113202098 Enable use of OpenSSL that doesn't have DSA.
Added #if LIBSSH2_DSA for all DSA functions.
2015-04-01 23:04:16 +01:00
Daniel Stenberg
31a5986c6d openssl: fix compiler warnings 2015-03-24 08:40:43 +01:00
Marc Hoersken
84590bc78f openssl.c: fix possible segfault in case EVP_DigestInit fails 2015-03-23 22:07:39 +01:00
David Calavera
18cfec8336 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.
2015-03-14 23:54:49 +00:00
Marc Hoersken
b20bfeb3e5 openssl: Check for LIBSSH2_OPENSSL in order to compile with openssl 2014-04-25 13:40:44 +02:00
Mark McPherson
61df22c460 openssl: initialise the digest context before calling EVP_DigestInit()
When using the OpenSSL libraries in FIPS mode, the function call
EVP_DigestInit() is actually #defined to FIPS_digestinit().
Unfortunately wheres EVP_DigestInit() initialises the context and then
calls EVP_DigestInit_ex(), this function assumes that the context has
been pre-initialised and crashes when it isn't.

Bug: https://trac.libssh2.org/ticket/279

Fixes #279
2013-11-21 11:35:12 +01:00
Peter Stuge
d512b25f69 Clean up crypto library abstraction in build system and source code
libssh2 used to explicitly check for libgcrypt and default to OpenSSL.

Now all possible crypto libraries are checked for explicitly, making
the addition of further crypto libraries both simpler and cleaner.
2013-09-15 20:56:54 +02:00
Peter Stuge
a5bf809b80 Revert "Added Windows Cryptography API: Next Generation based backend"
This reverts commit d385230e15715e67796f16f3e65fd899f21a638b.
2013-09-15 13:32:38 +02:00
Marc Hoersken
d385230e15 Added Windows Cryptography API: Next Generation based backend 2013-09-07 22:38:14 +02:00
Kamil Dudka
e2bb780d77 openssl: do not leak memory when handling errors
,.. in aes_ctr_init().  Detected by Coverity.
2012-10-08 14:30:40 +02:00
Kamil Dudka
5d567faecc crypt: use hard-wired cipher block sizes consistently 2012-09-17 09:48:07 +02:00
Kamil Dudka
bfbb5a4dc7 openssl: do not ignore failure of EVP_CipherInit() 2012-09-17 09:48:07 +02:00
Paul Howarth
f4f2298ef3 aes: the init function fails when OpenSSL has AES support
The internal init function only worked fine when the configure script
didn't detect the OpenSSL AES_CTR function!

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0111.shtml
Reported by: Paul Howarth
2012-03-18 15:24:35 +01:00
Steven Dake
5672e8f4cf Add comment indicating a resource leak is not really a resource leak
While possibly obvious to those investigating the code, coverity complains
about this out of scope leak.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:25:46 +01:00
Peter Krempa
209de22299 userauth: Provide more informations if ssh pub key extraction fails
If the function that extracts/computes the public key from a private key
fails the errors it reports were masked by the function calling it. This
patch modifies the key extraction function to return errors using
_libssh_error() function.  The error messages are tweaked to contain
reference to the failed operaton in addition to the reason.

 * AUTHORS: - add my name
 * libgcrypt.c: _libssh2_pub_priv_keyfile(): - return a more verbose
                                               error using
                                               _libssh2_error() func.
 * openssl.c: - modify call graph of _libssh2_pub_priv_keyfile() to use
                _libssh2_error for error reporting();
 * userauth.c: - tweak functions calling _libssh2_pub_priv_keyfile() not
                 to shadow error messages
2011-12-19 23:18:46 +01:00
Daniel Stenberg
ee07785a1e OpenSSL EVP: fix threaded use of structs
Make sure we don't clear or reset static structs after first init so
that they work fine even when used from multiple threads. Init the
structs in the global init.

Help and assistance by: John Engstrom

Fixes #229 (again)
2011-09-29 22:42:16 +02:00
Daniel Stenberg
24afd0fc72 openssl: don't init static structs differently
make_ctr_evp() is changed to take a struct pointer, and then each
_libssh2_EVP_aes_[keylen]_ctr function is made to pass in their own
static struct

Reported by: John Engstrom
Fixes #229
2011-09-28 22:26:47 +02:00
Guenter Knauf
7de77e94bf Fixed aes_ctr_do_cipher() signature. 2011-08-29 13:27:46 +02:00
Guenter Knauf
aa4f861643 Expanded tabs to spaces. 2010-12-22 14:27:55 +01:00
Mark Smith
5b1a7ec2f1 userauth: derive publickey from private
Pass a NULL pointer for the publickey parameter of
libssh2_userauth_publickey_fromfile and
libssh2_userauth_hostbased_fromfile functions.  In this case, the
functions recompute the public key from the private key file data.

This is work done by Jean-Louis CHARTON
<Jean-Louis.CHARTON@oikialog.com>, then adapted by Mark Smith and
slightly edited further by me Daniel.

WARNING: this does leave the feature NOT WORKING when libssh2 is built
to use libgcrypt instead of OpenSSL simply due to lack of
implementation.
2010-12-18 23:38:08 +01:00
Alfred Gebert
92d308c157 fix memory leaks (two times cipher_data) for each sftp session 2010-10-27 23:17:16 +02:00
Lars Nordin
1d83b520b4 openssl: make use of the EVP interface
Make use of the EVP interface for the AES-funktion. Using this method
supports the use of different ENGINES in OpenSSL for the AES function
(and the direct call to the AES_encrypt should not be used according to
openssl.org)
2010-06-27 22:23:50 +02:00
Daniel Stenberg
c3bcdd88a4 cleanups: better binary packet gen, size_t fixes and PACKET_* removal
I'll introduce a new internal function set named

 _libssh2_store_u32
 _libssh2_store_u64
 _libssh2_store_str

That can be used all through the library to build binary outgoing
packets.  Using these instead of the current approach removes
hundreds of lines from the library while at the same time greatly
enhances readability. I've not yet fully converted everything to
use these functions.

I've converted LOTS of 'unsigned long' to 'size_t' where
data/string lengths are dealt with internally. This is The Right
Thing and it will help us make the transition to our
size_t-polished API later on as well.

I'm removing the PACKET_* error codes. They were originally
introduced as a set of separate error codes from the transport
layer, but having its own set of errors turned out to be very
awkward and they were then converted into a set of #defines that
simply maps them to the global libssh2 error codes instead. Now,
I'l take the next logical step and simply replace the PACKET_*
defines with the actual LIBSSH2_ERROR_* defines. It will increase
readability and decrease confusion.

I also separated packet stuff into its own packet.h header file.
2010-04-17 13:18:15 +02:00
Simon Josefsson
77fa740674 Fix OpenSSL AES-128-CTR detection.
Patch from Paul Howarth <paul@city-fan.org>.
2010-04-14 14:04:45 +02:00
Simon Josefsson
d00283927f Fix namespace pollution. 2010-03-19 09:14:21 +01:00
Simon Josefsson
9ea5b0625e Add global init/exit points, to do crypto initialization in one place.
By Lars Nordin.
2010-03-19 09:05:52 +01:00
Simon Josefsson
0ef84144ac Revert #ifdef change that pulled in AES-CTR code when explicitly disabled. 2010-03-01 13:09:18 +01:00
Daniel Stenberg
ef27023eb9 fix #ifdefs 2010-03-01 11:42:38 +01:00
Simon Josefsson
a925bdd5bb Improve AES-CTR check. 2010-03-01 11:38:50 +01:00
Simon Josefsson
2de339b2f7 Use AES-CTR from OpenSSL when available.
Reported by Lars Nordin <Lars.Nordin@SDlabs.se>.
2010-03-01 10:34:00 +01:00
Simon Josefsson
c46cbd46e2 Make it possible to disable DSA.
Patch from Lars Nordin <Lars.Nordin@SDlabs.se>.
2010-03-01 10:30:22 +01:00
Dan Fandrich
69c876e210 Allow compiling with OpenSSL when AES isn't available. 2010-02-10 14:49:17 -08:00
Simon Josefsson
12433b4511 Silence compiler warnings.
Based on patch by Kamil Dudka <kdudka@redhat.com> in
<http://www.mail-archive.com/libssh2-devel@cool.haxx.se/msg00796.html>.
2009-12-16 16:14:55 +01:00
Simon Josefsson
b4c0821332 Silence warning about unused function parameter.
Reported by Steven Van Ingelgem <steven@vaningelgem.be>.
2009-12-14 15:50:41 +01:00
Peter Stuge
1aba38cd7d Fix padding in ssh-dss signature blob encoding
DSA signatures consist of two 160-bit integers called r and s. In ssh-dss
signature blobs r and s are stored directly after each other in binary
representation, making up a 320-bit (40 byte) string. (See RFC4253 p14.)

The crypto wrappers in libssh2 would either pack r and s incorrectly, or
fail, when at least one integer was small enough to be stored in 19 bytes
or less.

The patch ensures that r and s are always stored as two 160 bit numbers.
2009-12-06 08:07:40 +01:00
Simon Josefsson
ebbd7c879b Support AES-Counter ciphers. 2009-11-16 16:04:00 +01:00
Dan Fandrich
1418993a0f Some platforms need sys/socket.h included before netinet/in.h.
Fixed an unused variable compiler warning.
2009-09-16 07:49:32 -07:00
Guenter Knauf
7c32c84d0e removed conditional sources from Makefile.inc
added ifdef blocks to libgcrypt.c, pem.c, openssl.c
2009-09-07 18:10:49 +02:00
Alexander Lamaison
0d6aaa1f56 Pass private-key to OpenSSL as a filename with BIO_new_file().
This keeps all FILE* handling on the OpenSSL side of the DLL boundary avoiding crashes on Windows while removing the need for libssh2 to read the private key file into memory.  This is now done by OpenSSL which is likely to do a better job of it.
2009-09-02 14:59:40 +01:00
Steven Van Ingelgem
28b179ecf2 Suppress signed/unsigned comparison warning. 2009-08-16 23:14:20 +01:00
Alexander Lamaison
231a97a95f Replaced calls to OpenSSL FILE-pointer functions.
Passing a FILE* argument across a DLL boundary causes problems on Windows.  Instead the keys are read into memory by libssh2 and passed to the OpenSSL functions as BIO* arguments.
2009-08-02 23:20:20 +01:00
Daniel Stenberg
210459db4b re-indented the source code with this script:
indent \
--braces-on-if-line \
--braces-after-struct-decl-line \
--space-after-cast \
--line-length 79 \
--comment-line-length 79 \
--cuddle-else \
--no-tabs \
--tab-size 8 \
--indent-level 4 \
--no-space-after-for \
--space-after-if \
--space-after-while \
--no-space-after-function-call-names \
*.[ch]
2007-08-06 20:48:04 +00:00
James Housley
412b25d971 Initially the libssh2 code was indented with tabs of 4 spaces. Some of
the recent commits converted the tabs to 4 spaces, which matched the
initial indent size.  Other commits converted the tabs to 8 spaces, this
didn't match.

All the code has been converted to 4 space indents.  No changes to line
lengths or actual code was performed.  This is in preperation to my up
coming non-blocking work so my commits should only be code changes and
line lengths in the code I am working on.
2007-05-28 17:56:08 +00:00
Daniel Stenberg
ba9f0b2ce6 Dan Fandrich fixed another memory leak, this time in the OpenSSL interface
code:

It's not clear to me whether all the BN_news in _libssh2_rsa_new need to
be cleaned up, too.  The OpenSSL docs for RSA_free implies that you don't
need to, and valgrind doesn't complain, so it's probably OK as is.
2007-03-15 21:37:43 +00:00
Daniel Stenberg
75ceed5776 Dan Fandrich patch:
1 - let libssh2 compile with OpenSSL 0.9.6b.  This is due to 'crypt' is found
in one of its header files and EVP_MAX_BLOCK_LENGTH not being found.

2 - The EXEEXT patch is because automake 1.7 doesn't support it, and recent
automakes add it automatically
2007-03-14 21:59:12 +00:00