Update ntlmclient dependency

This commit is contained in:
Edward Thomson
2024-10-18 21:57:23 +01:00
parent 3594a54b55
commit 6c70f24d89
7 changed files with 53 additions and 31 deletions

View File

@@ -37,3 +37,4 @@ else()
endif()
add_library(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
set_target_properties(ntlmclient PROPERTIES C_STANDARD 90)

View File

@@ -26,18 +26,18 @@
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(CRYPT_OPENSSL_DYNAMIC)
static inline HMAC_CTX *HMAC_CTX_new(void)
NTLM_INLINE(HMAC_CTX *) HMAC_CTX_new(void)
{
return calloc(1, sizeof(HMAC_CTX));
}
static inline int HMAC_CTX_reset(HMAC_CTX *ctx)
NTLM_INLINE(int) HMAC_CTX_reset(HMAC_CTX *ctx)
{
ntlm_memzero(ctx, sizeof(HMAC_CTX));
return 1;
}
static inline void HMAC_CTX_free(HMAC_CTX *ctx)
NTLM_INLINE(void) HMAC_CTX_free(HMAC_CTX *ctx)
{
free(ctx);
}
@@ -48,7 +48,7 @@ static inline void HMAC_CTX_free(HMAC_CTX *ctx)
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x03050000fL) || \
defined(CRYPT_OPENSSL_DYNAMIC)
static inline void HMAC_CTX_cleanup(HMAC_CTX *ctx)
NTLM_INLINE(void) HMAC_CTX_cleanup(HMAC_CTX *ctx)
{
NTLM_UNUSED(ctx);
}

View File

@@ -43,7 +43,7 @@ static bool supports_unicode(ntlm_client *ntlm)
false : true;
}
static inline bool increment_size(size_t *out, size_t incr)
NTLM_INLINE(bool) increment_size(size_t *out, size_t incr)
{
if (SIZE_MAX - *out < incr) {
*out = (size_t)-1;
@@ -272,7 +272,7 @@ int ntlm_client_set_timestamp(ntlm_client *ntlm, uint64_t timestamp)
return 0;
}
static inline bool write_buf(
NTLM_INLINE(bool) write_buf(
ntlm_client *ntlm,
ntlm_buf *out,
const unsigned char *buf,
@@ -291,7 +291,7 @@ static inline bool write_buf(
return true;
}
static inline bool write_byte(
NTLM_INLINE(bool) write_byte(
ntlm_client *ntlm,
ntlm_buf *out,
uint8_t value)
@@ -305,7 +305,7 @@ static inline bool write_byte(
return true;
}
static inline bool write_int16(
NTLM_INLINE(bool) write_int16(
ntlm_client *ntlm,
ntlm_buf *out,
uint16_t value)
@@ -320,7 +320,7 @@ static inline bool write_int16(
return true;
}
static inline bool write_int32(
NTLM_INLINE(bool) write_int32(
ntlm_client *ntlm,
ntlm_buf *out,
uint32_t value)
@@ -337,7 +337,7 @@ static inline bool write_int32(
return true;
}
static inline bool write_version(
NTLM_INLINE(bool) write_version(
ntlm_client *ntlm,
ntlm_buf *out,
ntlm_version *version)
@@ -348,7 +348,7 @@ static inline bool write_version(
write_int32(ntlm, out, version->reserved);
}
static inline bool write_bufinfo(
NTLM_INLINE(bool) write_bufinfo(
ntlm_client *ntlm,
ntlm_buf *out,
size_t len,
@@ -369,7 +369,7 @@ static inline bool write_bufinfo(
write_int32(ntlm, out, (uint32_t)offset);
}
static inline bool read_buf(
NTLM_INLINE(bool) read_buf(
unsigned char *out,
ntlm_client *ntlm,
ntlm_buf *message,
@@ -386,7 +386,7 @@ static inline bool read_buf(
return true;
}
static inline bool read_byte(
NTLM_INLINE(bool) read_byte(
uint8_t *out,
ntlm_client *ntlm,
ntlm_buf *message)
@@ -400,7 +400,7 @@ static inline bool read_byte(
return true;
}
static inline bool read_int16(
NTLM_INLINE(bool) read_int16(
uint16_t *out,
ntlm_client *ntlm,
ntlm_buf *message)
@@ -418,7 +418,7 @@ static inline bool read_int16(
return true;
}
static inline bool read_int32(
NTLM_INLINE(bool) read_int32(
uint32_t *out,
ntlm_client *ntlm,
ntlm_buf *message)
@@ -438,7 +438,7 @@ static inline bool read_int32(
return true;
}
static inline bool read_int64(
NTLM_INLINE(bool) read_int64(
uint64_t *out,
ntlm_client *ntlm,
ntlm_buf *message)
@@ -462,7 +462,7 @@ static inline bool read_int64(
return true;
}
static inline bool read_version(
NTLM_INLINE(bool) read_version(
ntlm_version *out,
ntlm_client *ntlm,
ntlm_buf *message)
@@ -473,7 +473,7 @@ static inline bool read_version(
read_int32(&out->reserved, ntlm, message);
}
static inline bool read_bufinfo(
NTLM_INLINE(bool) read_bufinfo(
uint16_t *out_len,
uint32_t *out_offset,
ntlm_client *ntlm,
@@ -486,7 +486,7 @@ static inline bool read_bufinfo(
read_int32(out_offset, ntlm, message);
}
static inline bool read_string_unicode(
NTLM_INLINE(bool) read_string_unicode(
char **out,
ntlm_client *ntlm,
ntlm_buf *message,
@@ -504,7 +504,7 @@ static inline bool read_string_unicode(
return ret;
}
static inline bool read_string_ascii(
NTLM_INLINE(bool) read_string_ascii(
char **out,
ntlm_client *ntlm,
ntlm_buf *message,
@@ -526,7 +526,7 @@ static inline bool read_string_ascii(
return true;
}
static inline bool read_string(
NTLM_INLINE(bool) read_string(
char **out,
ntlm_client *ntlm,
ntlm_buf *message,
@@ -539,7 +539,7 @@ static inline bool read_string(
return read_string_ascii(out, ntlm, message, string_len);
}
static inline bool read_target_info(
NTLM_INLINE(bool) read_target_info(
char **server_out,
char **domain_out,
char **server_dns_out,
@@ -965,7 +965,7 @@ static void des_key_from_password(
generate_odd_parity(out);
}
static inline bool generate_lm_hash(
NTLM_INLINE(bool) generate_lm_hash(
ntlm_des_block out[2],
ntlm_client *ntlm,
const char *password)

View File

@@ -12,6 +12,7 @@
#include "ntlm.h"
#include "unicode.h"
#include "compat.h"
#include "util.h"
typedef unsigned int UTF32; /* at least 32 bits */
typedef unsigned short UTF16; /* at least 16 bits */
@@ -180,7 +181,7 @@ static ConversionResult ConvertUTF16toUTF8 (
* definition of UTF-8 goes up to 4-byte sequences.
*/
static inline bool isLegalUTF8(const UTF8 *source, int length) {
NTLM_INLINE(bool) isLegalUTF8(const UTF8 *source, int length) {
UTF8 a;
const UTF8 *srcptr = source+length;
switch (length) {
@@ -288,7 +289,7 @@ typedef enum {
unicode_builtin_utf16_to_8
} unicode_builtin_encoding_direction;
static inline bool unicode_builtin_encoding_convert(
NTLM_INLINE(bool) unicode_builtin_encoding_convert(
char **converted,
size_t *converted_len,
ntlm_client *ntlm,

View File

@@ -14,6 +14,7 @@
#include "ntlmclient.h"
#include "unicode.h"
#include "ntlm.h"
#include "util.h"
#include "compat.h"
typedef enum {
@@ -40,7 +41,7 @@ bool ntlm_unicode_init(ntlm_client *ntlm)
return true;
}
static inline bool unicode_iconv_encoding_convert(
NTLM_INLINE(bool) unicode_iconv_encoding_convert(
char **converted,
size_t *converted_len,
ntlm_client *ntlm,

View File

@@ -43,6 +43,14 @@
#pragma warning(disable : 4820)
#endif
#if defined(__cplusplus)
#if defined(_MSC_VER)
#define utf8_cplusplus _MSVC_LANG
#else
#define utf8_cplusplus __cplusplus
#endif
#endif
#include <stddef.h>
#include <stdlib.h>
@@ -67,7 +75,7 @@ typedef int32_t utf8_int32_t;
#endif
#endif
#ifdef __cplusplus
#ifdef utf8_cplusplus
extern "C" {
#endif
@@ -96,13 +104,13 @@ extern "C" {
#error Non clang, non gcc, non MSVC, non tcc compiler found!
#endif
#ifdef __cplusplus
#ifdef utf8_cplusplus
#define utf8_null NULL
#else
#define utf8_null 0
#endif
#if (defined(__cplusplus) && __cplusplus >= 201402L)
#if defined(utf8_cplusplus) && utf8_cplusplus >= 201402L && (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER >= 1910))
#define utf8_constexpr14 constexpr
#define utf8_constexpr14_impl constexpr
#else
@@ -111,7 +119,7 @@ extern "C" {
#define utf8_constexpr14_impl
#endif
#if defined(__cplusplus) && __cplusplus >= 202002L
#if defined(utf8_cplusplus) && utf8_cplusplus >= 202002L
using utf8_int8_t = char8_t; /* Introduced in C++20 */
#else
typedef char utf8_int8_t;
@@ -1693,7 +1701,7 @@ utf8rcodepoint(const utf8_int8_t *utf8_restrict str,
#undef utf8_constexpr14
#undef utf8_null
#ifdef __cplusplus
#ifdef utf8_cplusplus
} /* extern "C" */
#endif

View File

@@ -9,6 +9,17 @@
#ifndef PRIVATE_UTIL_H__
#define PRIVATE_UTIL_H__
#include <stddef.h>
#include <stdint.h>
#if defined(_MSC_VER)
# define NTLM_INLINE(type) static __inline type
#elif defined(__GNUC__)
# define NTLM_INLINE(type) static __inline__ type
#else
# define NTLM_INLINE(type) static type
#endif
extern void ntlm_memzero(void *data, size_t size);
extern uint64_t ntlm_htonll(uint64_t value);