Explorar o código

crypto: TLS: introduce `check_pending`

The new `qcrypto_tls_session_check_pending` function allows the caller
to know if data have already been consumed from the backend and is
already available.

Signed-off-by: Antoine Damhet <antoine.damhet@shadow.tech>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Antoine Damhet %!s(int64=2) %!d(string=hai) anos
pai
achega
33ee0d8e2f
Modificáronse 2 ficheiros con 25 adicións e 0 borrados
  1. 14 0
      crypto/tlssession.c
  2. 11 0
      include/crypto/tlssession.h

+ 14 - 0
crypto/tlssession.c

@@ -493,6 +493,13 @@ qcrypto_tls_session_read(QCryptoTLSSession *session,
 }
 }
 
 
 
 
+size_t
+qcrypto_tls_session_check_pending(QCryptoTLSSession *session)
+{
+    return gnutls_record_check_pending(session->handle);
+}
+
+
 int
 int
 qcrypto_tls_session_handshake(QCryptoTLSSession *session,
 qcrypto_tls_session_handshake(QCryptoTLSSession *session,
                               Error **errp)
                               Error **errp)
@@ -615,6 +622,13 @@ qcrypto_tls_session_read(QCryptoTLSSession *sess,
 }
 }
 
 
 
 
+size_t
+qcrypto_tls_session_check_pending(QCryptoTLSSession *session)
+{
+    return 0;
+}
+
+
 int
 int
 qcrypto_tls_session_handshake(QCryptoTLSSession *sess,
 qcrypto_tls_session_handshake(QCryptoTLSSession *sess,
                               Error **errp)
                               Error **errp)

+ 11 - 0
include/crypto/tlssession.h

@@ -248,6 +248,17 @@ ssize_t qcrypto_tls_session_read(QCryptoTLSSession *sess,
                                  char *buf,
                                  char *buf,
                                  size_t len);
                                  size_t len);
 
 
+/**
+ * qcrypto_tls_session_check_pending:
+ * @sess: the TLS session object
+ *
+ * Check if there are unread data in the TLS buffers that have
+ * already been read from the underlying data source.
+ *
+ * Returns: the number of bytes available or zero
+ */
+size_t qcrypto_tls_session_check_pending(QCryptoTLSSession *sess);
+
 /**
 /**
  * qcrypto_tls_session_handshake:
  * qcrypto_tls_session_handshake:
  * @sess: the TLS session object
  * @sess: the TLS session object