summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorDaniel Lowrey <rdlowrey@php.net>2015-02-28 15:32:15 -0500
committerDaniel Lowrey <rdlowrey@php.net>2015-02-28 17:41:29 -0500
commit13acb7ec653c543c56437ed417c3889fbf54f608 (patch)
treece4f370ed06d601b6964ac3ba6aeb73b530da2fb /main
parent3ff36c265fce0ec5375e1917764db4fca88eb1ae (diff)
downloadphp-git-13acb7ec653c543c56437ed417c3889fbf54f608.tar.gz
Add stream_socket_crypto_info() function
Diffstat (limited to 'main')
-rw-r--r--main/streams/php_stream_transport.h16
-rw-r--r--main/streams/transports.c19
2 files changed, 34 insertions, 1 deletions
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index fc070ce74d..a47f669f98 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -183,15 +183,28 @@ typedef enum {
STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5))
} php_stream_xport_crypt_method_t;
+typedef enum {
+ STREAM_CRYPTO_INFO_CIPHER_NAME = 1,
+ STREAM_CRYPTO_INFO_CIPHER_BITS = 2,
+ STREAM_CRYPTO_INFO_CIPHER_VERSION = 4,
+ STREAM_CRYPTO_INFO_CIPHER = 5,
+ STREAM_CRYPTO_INFO_PROTOCOL = 8,
+ STREAM_CRYPTO_INFO_ALPN_PROTOCOL = 16,
+ STREAM_CRYPTO_INFO_ALL = 63
+} php_stream_xport_crypt_info_t;
+
/* These functions provide crypto support on the underlying transport */
BEGIN_EXTERN_C()
PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream);
PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate);
+PHPAPI int php_stream_xport_crypto_info(php_stream *stream, zend_long infotype, zval *zresult);
END_EXTERN_C()
typedef struct _php_stream_xport_crypto_param {
struct {
+ zval *zresult;
+ int infotype;
php_stream *session;
int activate;
php_stream_xport_crypt_method_t method;
@@ -201,7 +214,8 @@ typedef struct _php_stream_xport_crypto_param {
} outputs;
enum {
STREAM_XPORT_CRYPTO_OP_SETUP,
- STREAM_XPORT_CRYPTO_OP_ENABLE
+ STREAM_XPORT_CRYPTO_OP_ENABLE,
+ STREAM_XPORT_CRYPTO_OP_INFO
} op;
} php_stream_xport_crypto_param;
diff --git a/main/streams/transports.c b/main/streams/transports.c
index b86019bf5d..edc142853e 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -390,6 +390,25 @@ PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate)
return ret;
}
+PHPAPI int php_stream_xport_crypto_info(php_stream *stream, zend_long infotype, zval *zresult)
+{
+ php_stream_xport_crypto_param param;
+ int ret;
+
+ memset(&param, 0, sizeof(param));
+ param.op = STREAM_XPORT_CRYPTO_OP_INFO;
+ param.inputs.zresult = zresult;
+ param.inputs.infotype = infotype;
+
+ ret = php_stream_set_option(stream, PHP_STREAM_OPTION_CRYPTO_API, 0, &param);
+
+ if (ret != PHP_STREAM_OPTION_RETURN_OK) {
+ php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ }
+
+ return ret;
+}
+
/* Similar to recv() system call; read data from the stream, optionally
* peeking, optionally retrieving OOB data */
PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen,