Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8cda0f65c | ||
|
|
649a3b4fca | ||
|
|
a2b3b6b9e2 | ||
|
|
dfb3e86824 | ||
|
|
a81f0a8a5f | ||
|
|
5509ec3b35 | ||
|
|
67b1a2f3f4 |
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
|
||||
jobs:
|
||||
linux-tests:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
valgrind:
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
cat test-suite*.log || true
|
||||
|
||||
xssl-tests:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
xssl_versions:
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
cat test-suite*.log || true
|
||||
|
||||
release-test:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
name: Check if release would work
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -142,7 +142,7 @@ jobs:
|
||||
cat testerr.log || true
|
||||
|
||||
code-style:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
name: Check coding style
|
||||
continue-on-error: true
|
||||
steps:
|
||||
|
||||
@@ -18,9 +18,10 @@ PKG_PROG_PKG_CONFIG
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AS_CASE([$host_os],
|
||||
[dragonfly*], [PLATFORM="bsd"],
|
||||
[freebsd*], [PLATFORM="bsd"],
|
||||
[openbsd*], [PLATFORM="bsd"],
|
||||
[netbsd*], [PLATFORM="bsd"],
|
||||
[openbsd*], [PLATFORM="bsd"],
|
||||
[*nto*|*qnx*], [PLATFORM="qnx"],
|
||||
[*solaris*], [PLATFORM="solaris"],
|
||||
[*android*], [PLATFORM="android"],
|
||||
|
||||
@@ -30,12 +30,17 @@
|
||||
#include "snprintf.h"
|
||||
|
||||
/** handlers **/
|
||||
#if (__STDC_VERSION__ >= 202000L)
|
||||
typedef void *xmpp_void_handler;
|
||||
#else
|
||||
typedef int (*xmpp_void_handler)();
|
||||
#endif
|
||||
|
||||
typedef struct _xmpp_handlist_t xmpp_handlist_t;
|
||||
struct _xmpp_handlist_t {
|
||||
/* common members */
|
||||
int user_handler;
|
||||
int (*handler)();
|
||||
xmpp_void_handler handler;
|
||||
void *userdata;
|
||||
int enabled; /* handlers are added disabled and enabled after the
|
||||
* handler chain is processed to prevent stanzas from
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <sys/select.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#define _sleep(x) usleep((x)*1000)
|
||||
#define _sleep(x) usleep((x) * 1000)
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#ifndef ETIMEDOUT
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "common.h"
|
||||
#include "ostypes.h"
|
||||
|
||||
typedef int (*xmpp_void_handler)();
|
||||
|
||||
/* Remove item from the list pointed by head, but don't free it.
|
||||
* There can be a situation when user's handler deletes another handler which
|
||||
* is the previous in the list. handler_fire_stanza() and handler_fire_timed()
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#define PUT_32BIT_LSB_FIRST(cp, value) \
|
||||
do { \
|
||||
(cp)[0] = (value)&0xFF; \
|
||||
(cp)[0] = (value) & 0xFF; \
|
||||
(cp)[1] = ((value) >> 8) & 0xFF; \
|
||||
(cp)[2] = ((value) >> 16) & 0xFF; \
|
||||
(cp)[3] = ((value) >> 24) & 0xFF; \
|
||||
|
||||
@@ -68,9 +68,9 @@ struct _xmpp_rand_t {
|
||||
};
|
||||
|
||||
/* returns smallest number mupliple of y that not less than x */
|
||||
#define round_up(x, y) (((x) + (y)-1) / (y) * (y))
|
||||
#define round_up(x, y) (((x) + (y) - 1) / (y) * (y))
|
||||
/* returns smallest integer number that not less than x/y */
|
||||
#define div_round_up(x, y) (((x) + (y)-1) / (y))
|
||||
#define div_round_up(x, y) (((x) + (y) - 1) / (y))
|
||||
|
||||
/* adds two arrays as numbers in big-endian representation and stores
|
||||
* result in the first one.
|
||||
|
||||
@@ -630,7 +630,7 @@ static void netbuf_add_16bitnum(unsigned char *buf,
|
||||
|
||||
/* assuming big endian */
|
||||
*p++ = (num >> 8) & 0xff;
|
||||
*p++ = (num)&0xff;
|
||||
*p++ = (num) & 0xff;
|
||||
|
||||
*offset += 2;
|
||||
}
|
||||
|
||||
16
src/sha.h
16
src/sha.h
@@ -53,7 +53,7 @@ extern "C" {
|
||||
(y)[0] = (uint8_t)(((x) >> 24) & 255); \
|
||||
(y)[1] = (uint8_t)(((x) >> 16) & 255); \
|
||||
(y)[2] = (uint8_t)(((x) >> 8) & 255); \
|
||||
(y)[3] = (uint8_t)((x)&255); \
|
||||
(y)[3] = (uint8_t)((x) & 255); \
|
||||
} while (0)
|
||||
|
||||
#define LOAD32H(x, y) \
|
||||
@@ -72,7 +72,7 @@ extern "C" {
|
||||
(y)[4] = (uint8_t)(((x) >> 24) & 255); \
|
||||
(y)[5] = (uint8_t)(((x) >> 16) & 255); \
|
||||
(y)[6] = (uint8_t)(((x) >> 8) & 255); \
|
||||
(y)[7] = (uint8_t)((x)&255); \
|
||||
(y)[7] = (uint8_t)((x) & 255); \
|
||||
} while (0)
|
||||
|
||||
#define LOAD64H(x, y) \
|
||||
@@ -96,13 +96,13 @@ extern "C" {
|
||||
#define CONST64(n) n##ULL
|
||||
#endif
|
||||
|
||||
#define RORc(x, y) \
|
||||
(((((uint32_t)(x)&0xFFFFFFFFUL) >> (uint32_t)((y)&31)) | \
|
||||
((uint32_t)(x) << (uint32_t)((32 - ((y)&31)) & 31))) & \
|
||||
#define RORc(x, y) \
|
||||
(((((uint32_t)(x) & 0xFFFFFFFFUL) >> (uint32_t)((y) & 31)) | \
|
||||
((uint32_t)(x) << (uint32_t)((32 - ((y) & 31)) & 31))) & \
|
||||
0xFFFFFFFFUL)
|
||||
#define ROR64c(x, y) \
|
||||
(((((x)&CONST64(0xFFFFFFFFFFFFFFFF)) >> ((uint64_t)(y)&CONST64(63))) | \
|
||||
((x) << (((uint64_t)64 - ((y)&63)) & 63))) & \
|
||||
#define ROR64c(x, y) \
|
||||
(((((x) & CONST64(0xFFFFFFFFFFFFFFFF)) >> ((uint64_t)(y) & CONST64(63))) | \
|
||||
((x) << (((uint64_t)64 - ((y) & 63)) & 63))) & \
|
||||
CONST64(0xFFFFFFFFFFFFFFFF))
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define Ch(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define Maj(x, y, z) (((x | y) & z) | (x & y))
|
||||
#define S(x, n) RORc((x), (n))
|
||||
#define R(x, n) (((x)&0xFFFFFFFFUL) >> (n))
|
||||
#define R(x, n) (((x) & 0xFFFFFFFFUL) >> (n))
|
||||
#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
|
||||
#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
|
||||
#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
|
||||
|
||||
@@ -52,7 +52,7 @@ static const uint64_t K[80] = {
|
||||
#define Ch(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define Maj(x, y, z) (((x | y) & z) | (x & y))
|
||||
#define S(x, n) ROR64c(x, n)
|
||||
#define R(x, n) (((x)&CONST64(0xFFFFFFFFFFFFFFFF)) >> ((uint64_t)n))
|
||||
#define R(x, n) (((x) & CONST64(0xFFFFFFFFFFFFFFFF)) >> ((uint64_t)n))
|
||||
#define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
|
||||
#define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41))
|
||||
#define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7))
|
||||
|
||||
17
src/tls.c
17
src/tls.c
@@ -74,6 +74,23 @@ xmpp_conn_t *xmpp_tlscert_get_conn(const xmpp_tlscert_t *cert)
|
||||
return cert->conn;
|
||||
}
|
||||
|
||||
/** Get the userdata of a Strophe connection which is assigned to this
|
||||
* certificate.
|
||||
*
|
||||
* @param cert a Strophe TLS certificate object
|
||||
*
|
||||
* @return the userdata of a Strophe connection object where this certificate
|
||||
* originates from
|
||||
*
|
||||
* @ingroup TLS
|
||||
*/
|
||||
void *xmpp_tlscert_get_userdata(const xmpp_tlscert_t *cert)
|
||||
{
|
||||
if (cert->conn == NULL)
|
||||
return NULL;
|
||||
return cert->conn->userdata;
|
||||
}
|
||||
|
||||
/** Get the complete PEM of this certificate.
|
||||
*
|
||||
* @param cert a Strophe TLS certificate object
|
||||
|
||||
@@ -422,6 +422,8 @@ static int _tls_verify(gnutls_session_t session)
|
||||
return -1;
|
||||
}
|
||||
|
||||
tlscert->conn = tls->conn;
|
||||
|
||||
if (tls->conn->certfail_handler(tlscert, (char *)out.data) == 0) {
|
||||
xmpp_tlscert_free(tlscert);
|
||||
gnutls_x509_crt_deinit(cert);
|
||||
|
||||
@@ -540,6 +540,8 @@ static int _tls_verify(int preverify_ok, X509_STORE_CTX *x509_ctx)
|
||||
if (!tlscert)
|
||||
return 0;
|
||||
|
||||
tlscert->conn = conn;
|
||||
|
||||
strophe_debug(conn->ctx, "tls", "preverify_ok:%d\nSubject: %s\nIssuer: %s",
|
||||
preverify_ok, tlscert->elements[XMPP_CERT_SUBJECT],
|
||||
tlscert->elements[XMPP_CERT_ISSUER]);
|
||||
|
||||
@@ -642,6 +642,7 @@ void xmpp_ctx_set_timeout(xmpp_ctx_t *ctx, unsigned long timeout);
|
||||
|
||||
xmpp_ctx_t *xmpp_tlscert_get_ctx(const xmpp_tlscert_t *cert);
|
||||
xmpp_conn_t *xmpp_tlscert_get_conn(const xmpp_tlscert_t *cert);
|
||||
void *xmpp_tlscert_get_userdata(const xmpp_tlscert_t *cert);
|
||||
const char *xmpp_tlscert_get_pem(const xmpp_tlscert_t *cert);
|
||||
const char *xmpp_tlscert_get_dnsname(const xmpp_tlscert_t *cert, size_t n);
|
||||
const char *xmpp_tlscert_get_string(const xmpp_tlscert_t *cert,
|
||||
|
||||
Reference in New Issue
Block a user