Skip to content

Commit

Permalink
Merge pull request #1 from keithduncan/sec-item-import
Browse files Browse the repository at this point in the history
Add SecureTransport support
  • Loading branch information
Keith Duncan committed Dec 1, 2014
2 parents 6a3b548 + 1f15d3a commit 5cd68b5
Show file tree
Hide file tree
Showing 11 changed files with 2,560 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.deps
.libs
.configure
*.lib
*.pdb
*.dll
Expand Down Expand Up @@ -33,4 +34,6 @@ mkinstalldirs
tags
libssh2.pc
TAGS
compile
test-driver
*~
2 changes: 2 additions & 0 deletions Makefile.SecureTransport.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CRYPTO_CSOURCES = securetransport.c
CRYPTO_HHEADERS = securetransport.h
29 changes: 24 additions & 5 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Web site: http://www.libssh2.org/

Mailing list: http://cool.haxx.se/mailman/listinfo/libssh2-devel

Configuring libssh2 from source
===============================

1. ./buildconf
2. ./configure, check --help for configuration options or see below
3. make all

Configuration options
=====================

Generic installation instructions are in INSTALL. Some ./configure
options deserve additional comments:

Expand Down Expand Up @@ -51,18 +61,18 @@ options deserve additional comments:
server using dh-gex, try this option to fallback on
the older more reliable method.

* --with-libgcrypt
* --without-libgcrypt
* --with-libgcrypt
* --without-libgcrypt
* --with-libgcrypt-prefix=DIR

libssh2 can use the Libgcrypt library
(http://www.gnupg.org/) for cryptographic operations.
Either Libgcrypt or OpenSSL is required.
One of Libgcrypt, OpenSSL or SecureTransport is required.

Configure will attempt to locate Libgcrypt
automatically.

If your installation of Libgcrypt is in another
If your installation of Libgcrypt is in another
location, specify it using --with-libgcrypt-prefix.

* --with-openssl
Expand All @@ -71,14 +81,23 @@ options deserve additional comments:

libssh2 can use the OpenSSL library
(http://www.openssl.org) for cryptographic operations.
Either Libgcrypt or OpenSSL is required.
One of Libgcrypt, OpenSSL or SecureTransport is required.

Configure will attempt to locate OpenSSL in the
default location.

If your installation of OpenSSL is in another
location, specify it using --with-libssl-prefix.

* --with-securetransport

libssh2 can use the Mac OS X Security.framework library
for cryptographic operations.
One of Libgcrypt, OpenSSL or SecureTransport is required.

Configure will attempt to locate Security.framework in the
default location.

* --with-libz
* --without-libz
* --with-libz-prefix=[DIR]
Expand Down
23 changes: 23 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ AC_ARG_WITH(openssl,
AC_ARG_WITH(libgcrypt,
AC_HELP_STRING([--with-libgcrypt],[Use libgcrypt for crypto]),
use_libgcrypt=$withval,use_libgcrypt=auto)
AC_ARG_WITH(securetransport,
AC_HELP_STRING([--with-securetransport],[Use Security.framework for crypto]),
use_securetransport=$withval,use_securetransport=auto)
AC_ARG_WITH(wincng,
AC_HELP_STRING([--with-wincng],[Use Windows CNG for crypto]),
use_wincng=$withval,use_wincng=auto)
Expand Down Expand Up @@ -128,6 +131,25 @@ if test "$ac_cv_libgcrypt" = "yes"; then
fi
AM_CONDITIONAL(LIBGCRYPT, test "$ac_cv_libgcrypt" = "yes")

# Look for Security.framework
if test "$found_crypto" = "none" && test "$use_securetransport" != "no"; then
save_LIBS="$LIBS"
LIBS="$LIBS -framework Security"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([],[])],
[cv_framework_securetransport=yes],
[cv_framework_securetransport=no])
LIBS="$save_libs"
fi
if test "$cv_framework_securetransport" = "yes"; then
AC_DEFINE([LIBSSH2_SECURETRANSPORT], 1, [Use SecureTransport])
LIBS="$LIBS -framework Security -framework CoreFoundation"
found_crypto=securetransport

AC_CHECK_FUNCS(SecRandomCopyBytes)
fi
AM_CONDITIONAL(SECURETRANSPORT, test "$cv_framework_securetransport" = "yes")

# Look for Windows Cryptography API: Next Generation
if test "$found_crypto" = "none" && test "$use_wincng" != "no"; then
AC_LIB_HAVE_LINKFLAGS([bcrypt], [], [
Expand Down Expand Up @@ -158,6 +180,7 @@ if test "$found_crypto" = "none"; then
AC_MSG_ERROR([No crypto library found!
Try --with-libssl-prefix=PATH
or --with-libgcrypt-prefix=PATH
or --with-securetransport on OS X
or --with-wincng on Windows\
])
fi
Expand Down
Loading

0 comments on commit 5cd68b5

Please sign in to comment.