rugged 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -6
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +93 -42
- data/vendor/libgit2/include/git2/blob.h +14 -2
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +14 -4
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +34 -19
- data/vendor/libgit2/include/git2/errors.h +6 -6
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +2 -2
- data/vendor/libgit2/include/git2/odb.h +29 -0
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +6 -2
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/tree.h +0 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +25 -4
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +16 -7
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +84 -39
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +42 -37
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +11 -5
- data/vendor/libgit2/src/blob.c +35 -24
- data/vendor/libgit2/src/branch.c +69 -17
- data/vendor/libgit2/src/buffer.c +334 -25
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +48 -26
- data/vendor/libgit2/src/cherrypick.c +6 -2
- data/vendor/libgit2/src/clone.c +41 -47
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +25 -2
- data/vendor/libgit2/src/config.c +37 -15
- data/vendor/libgit2/src/config_cache.c +5 -3
- data/vendor/libgit2/src/config_file.c +16 -8
- data/vendor/libgit2/src/config_parse.c +4 -6
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +6 -3
- data/vendor/libgit2/src/diff.c +11 -8
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +2 -6
- data/vendor/libgit2/src/diff_generate.c +46 -17
- data/vendor/libgit2/src/diff_print.c +19 -6
- data/vendor/libgit2/src/diff_stats.c +7 -5
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +24 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +5 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +206 -110
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +5 -5
- data/vendor/libgit2/src/futils.h +1 -1
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +106 -70
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +31 -29
- data/vendor/libgit2/src/integer.h +64 -2
- data/vendor/libgit2/src/iterator.c +36 -24
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +70 -30
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +11 -3
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +471 -10
- data/vendor/libgit2/src/midx.h +28 -1
- data/vendor/libgit2/src/mwindow.c +103 -59
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +127 -3
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +22 -14
- data/vendor/libgit2/src/odb.c +285 -48
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +28 -18
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +5 -4
- data/vendor/libgit2/src/pack-objects.c +54 -48
- data/vendor/libgit2/src/pack.c +329 -119
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +2 -1
- data/vendor/libgit2/src/path.c +98 -53
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +8 -8
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +11 -3
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +93 -49
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +121 -69
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +76 -41
- data/vendor/libgit2/src/refspec.c +32 -12
- data/vendor/libgit2/src/remote.c +272 -102
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +176 -103
- data/vendor/libgit2/src/repository.h +12 -1
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +6 -2
- data/vendor/libgit2/src/revparse.c +14 -9
- data/vendor/libgit2/src/revwalk.c +32 -15
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +3 -1
- data/vendor/libgit2/src/status.c +7 -4
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +128 -62
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +4 -6
- data/vendor/libgit2/src/tag.c +47 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +19 -8
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +53 -26
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +3 -3
- data/vendor/libgit2/src/transports/smart.c +12 -7
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +41 -31
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +53 -129
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +22 -24
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +7 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +27 -16
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +32 -16
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -369
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
|
@@ -9,13 +9,82 @@
|
|
|
9
9
|
#ifndef PRIVATE_CRYPT_OPENSSL_H__
|
|
10
10
|
#define PRIVATE_CRYPT_OPENSSL_H__
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
#ifndef CRYPT_OPENSSL_DYNAMIC
|
|
13
|
+
# include <openssl/des.h>
|
|
14
|
+
# include <openssl/hmac.h>
|
|
15
|
+
#endif
|
|
13
16
|
|
|
14
17
|
/* OpenSSL 1.1.0 uses opaque structs, we'll reuse these. */
|
|
15
|
-
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
|
|
18
|
+
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
19
|
+
# define HMAC_CTX struct hmac_ctx_st
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
#ifdef CRYPT_OPENSSL_DYNAMIC
|
|
23
|
+
typedef unsigned char DES_cblock[8];
|
|
24
|
+
typedef unsigned char const_DES_cblock[8];
|
|
25
|
+
|
|
26
|
+
typedef unsigned long DES_LONG;
|
|
27
|
+
|
|
28
|
+
typedef struct DES_ks {
|
|
29
|
+
union {
|
|
30
|
+
DES_cblock cblock;
|
|
31
|
+
DES_LONG deslong[2];
|
|
32
|
+
} ks[16];
|
|
33
|
+
} DES_key_schedule;
|
|
34
|
+
|
|
35
|
+
#define DES_ENCRYPT 1
|
|
36
|
+
|
|
37
|
+
typedef void EVP_MD;
|
|
38
|
+
typedef void ENGINE;
|
|
39
|
+
typedef void EVP_PKEY_CTX;
|
|
40
|
+
|
|
41
|
+
#define HMAC_MAX_MD_CBLOCK 128
|
|
42
|
+
|
|
43
|
+
typedef struct env_md_ctx_st EVP_MD_CTX;
|
|
44
|
+
struct env_md_ctx_st {
|
|
45
|
+
const EVP_MD *digest;
|
|
46
|
+
ENGINE *engine;
|
|
47
|
+
unsigned long flags;
|
|
48
|
+
void *md_data;
|
|
49
|
+
EVP_PKEY_CTX *pctx;
|
|
50
|
+
int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
typedef struct hmac_ctx_st {
|
|
54
|
+
const EVP_MD *md;
|
|
55
|
+
EVP_MD_CTX md_ctx;
|
|
56
|
+
EVP_MD_CTX i_ctx;
|
|
57
|
+
EVP_MD_CTX o_ctx;
|
|
58
|
+
unsigned int key_length;
|
|
59
|
+
unsigned char key[HMAC_MAX_MD_CBLOCK];
|
|
60
|
+
} HMAC_CTX;
|
|
19
61
|
#endif
|
|
20
62
|
|
|
63
|
+
struct ntlm_crypt_ctx {
|
|
64
|
+
HMAC_CTX *hmac;
|
|
65
|
+
|
|
66
|
+
void *openssl_handle;
|
|
67
|
+
|
|
68
|
+
void (*des_ecb_encrypt_fn)(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks, int enc);
|
|
69
|
+
int (*des_set_key_fn)(const_DES_cblock *key, DES_key_schedule *schedule);
|
|
70
|
+
|
|
71
|
+
unsigned long (*err_get_error_fn)(void);
|
|
72
|
+
const char *(*err_lib_error_string_fn)(unsigned long e);
|
|
73
|
+
|
|
74
|
+
const EVP_MD *(*evp_md5_fn)(void);
|
|
75
|
+
|
|
76
|
+
HMAC_CTX *(*hmac_ctx_new_fn)(void);
|
|
77
|
+
int (*hmac_ctx_reset_fn)(HMAC_CTX *ctx);
|
|
78
|
+
void (*hmac_ctx_free_fn)(HMAC_CTX *ctx);
|
|
79
|
+
void (*hmac_ctx_cleanup_fn)(HMAC_CTX *ctx);
|
|
80
|
+
|
|
81
|
+
int (*hmac_init_ex_fn)(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl);
|
|
82
|
+
int (*hmac_update_fn)(HMAC_CTX *ctx, const unsigned char *data, size_t len);
|
|
83
|
+
int (*hmac_final_fn)(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
|
|
84
|
+
|
|
85
|
+
unsigned char *(*md4_fn)(const unsigned char *d, size_t n, unsigned char *md);
|
|
86
|
+
|
|
87
|
+
int (*rand_bytes_fn)(unsigned char *buf, int num);
|
|
88
|
+
};
|
|
89
|
+
|
|
21
90
|
#endif /* PRIVATE_CRYPT_OPENSSL_H__ */
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
#include <stdlib.h>
|
|
10
10
|
#include <stdint.h>
|
|
11
11
|
#include <string.h>
|
|
12
|
-
#include <assert.h>
|
|
13
12
|
#include <errno.h>
|
|
14
13
|
#include <ctype.h>
|
|
15
14
|
#include <unistd.h>
|
|
@@ -24,6 +23,18 @@
|
|
|
24
23
|
#include "compat.h"
|
|
25
24
|
#include "util.h"
|
|
26
25
|
|
|
26
|
+
#define NTLM_ASSERT_ARG(expr) do { \
|
|
27
|
+
if (!(expr)) \
|
|
28
|
+
return NTLM_CLIENT_ERROR_INVALID_INPUT; \
|
|
29
|
+
} while(0)
|
|
30
|
+
|
|
31
|
+
#define NTLM_ASSERT(ntlm, expr) do { \
|
|
32
|
+
if (!(expr)) { \
|
|
33
|
+
ntlm_client_set_errmsg(ntlm, "internal error: " #expr); \
|
|
34
|
+
return -1; \
|
|
35
|
+
} \
|
|
36
|
+
} while(0)
|
|
37
|
+
|
|
27
38
|
unsigned char ntlm_client_signature[] = NTLM_SIGNATURE;
|
|
28
39
|
|
|
29
40
|
static bool supports_unicode(ntlm_client *ntlm)
|
|
@@ -52,17 +63,20 @@ ntlm_client *ntlm_client_init(ntlm_client_flags flags)
|
|
|
52
63
|
|
|
53
64
|
ntlm->flags = flags;
|
|
54
65
|
|
|
55
|
-
if ((ntlm->hmac_ctx = ntlm_hmac_ctx_init()) == NULL ||
|
|
56
|
-
(ntlm->unicode_ctx = ntlm_unicode_ctx_init(ntlm)) == NULL) {
|
|
57
|
-
ntlm_hmac_ctx_free(ntlm->hmac_ctx);
|
|
58
|
-
ntlm_unicode_ctx_free(ntlm->unicode_ctx);
|
|
59
|
-
free(ntlm);
|
|
60
|
-
return NULL;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
66
|
return ntlm;
|
|
64
67
|
}
|
|
65
68
|
|
|
69
|
+
#define ENSURE_INITIALIZED(ntlm) \
|
|
70
|
+
do { \
|
|
71
|
+
if (!(ntlm)->unicode_initialized) \
|
|
72
|
+
(ntlm)->unicode_initialized = ntlm_unicode_init((ntlm)); \
|
|
73
|
+
if (!(ntlm)->crypt_initialized) \
|
|
74
|
+
(ntlm)->crypt_initialized = ntlm_crypt_init((ntlm)); \
|
|
75
|
+
if (!(ntlm)->unicode_initialized || \
|
|
76
|
+
!(ntlm)->crypt_initialized) \
|
|
77
|
+
return -1; \
|
|
78
|
+
} while(0)
|
|
79
|
+
|
|
66
80
|
void ntlm_client_set_errmsg(ntlm_client *ntlm, const char *errmsg)
|
|
67
81
|
{
|
|
68
82
|
ntlm->state = NTLM_STATE_ERROR;
|
|
@@ -71,7 +85,9 @@ void ntlm_client_set_errmsg(ntlm_client *ntlm, const char *errmsg)
|
|
|
71
85
|
|
|
72
86
|
const char *ntlm_client_errmsg(ntlm_client *ntlm)
|
|
73
87
|
{
|
|
74
|
-
|
|
88
|
+
if (!ntlm)
|
|
89
|
+
return "internal error";
|
|
90
|
+
|
|
75
91
|
return ntlm->errmsg ? ntlm->errmsg : "no error";
|
|
76
92
|
}
|
|
77
93
|
|
|
@@ -81,7 +97,7 @@ int ntlm_client_set_version(
|
|
|
81
97
|
uint8_t minor,
|
|
82
98
|
uint16_t build)
|
|
83
99
|
{
|
|
84
|
-
|
|
100
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
85
101
|
|
|
86
102
|
ntlm->host_version.major = major;
|
|
87
103
|
ntlm->host_version.minor = minor;
|
|
@@ -93,20 +109,25 @@ int ntlm_client_set_version(
|
|
|
93
109
|
return 0;
|
|
94
110
|
}
|
|
95
111
|
|
|
112
|
+
#define reset(ptr) do { free(ptr); ptr = NULL; } while(0)
|
|
113
|
+
|
|
114
|
+
static void free_hostname(ntlm_client *ntlm)
|
|
115
|
+
{
|
|
116
|
+
reset(ntlm->hostname);
|
|
117
|
+
reset(ntlm->hostdomain);
|
|
118
|
+
reset(ntlm->hostname_utf16);
|
|
119
|
+
ntlm->hostname_utf16_len = 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
96
122
|
int ntlm_client_set_hostname(
|
|
97
123
|
ntlm_client *ntlm,
|
|
98
124
|
const char *hostname,
|
|
99
125
|
const char *domain)
|
|
100
126
|
{
|
|
101
|
-
|
|
127
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
128
|
+
ENSURE_INITIALIZED(ntlm);
|
|
102
129
|
|
|
103
|
-
|
|
104
|
-
free(ntlm->hostdomain);
|
|
105
|
-
free(ntlm->hostname_utf16);
|
|
106
|
-
|
|
107
|
-
ntlm->hostname = NULL;
|
|
108
|
-
ntlm->hostdomain = NULL;
|
|
109
|
-
ntlm->hostname_utf16 = NULL;
|
|
130
|
+
free_hostname(ntlm);
|
|
110
131
|
|
|
111
132
|
if (hostname && (ntlm->hostname = strdup(hostname)) == NULL) {
|
|
112
133
|
ntlm_client_set_errmsg(ntlm, "out of memory");
|
|
@@ -121,7 +142,7 @@ int ntlm_client_set_hostname(
|
|
|
121
142
|
if (hostname && supports_unicode(ntlm) && !ntlm_unicode_utf8_to_16(
|
|
122
143
|
&ntlm->hostname_utf16,
|
|
123
144
|
&ntlm->hostname_utf16_len,
|
|
124
|
-
ntlm
|
|
145
|
+
ntlm,
|
|
125
146
|
hostname,
|
|
126
147
|
strlen(hostname)))
|
|
127
148
|
return -1;
|
|
@@ -137,25 +158,20 @@ static void free_credentials(ntlm_client *ntlm)
|
|
|
137
158
|
if (ntlm->password_utf16)
|
|
138
159
|
ntlm_memzero(ntlm->password_utf16, ntlm->password_utf16_len);
|
|
139
160
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
ntlm->
|
|
151
|
-
ntlm->
|
|
152
|
-
ntlm->
|
|
153
|
-
ntlm->
|
|
154
|
-
|
|
155
|
-
ntlm->username_utf16 = NULL;
|
|
156
|
-
ntlm->username_upper_utf16 = NULL;
|
|
157
|
-
ntlm->userdomain_utf16 = NULL;
|
|
158
|
-
ntlm->password_utf16 = NULL;
|
|
161
|
+
reset(ntlm->username);
|
|
162
|
+
reset(ntlm->username_upper);
|
|
163
|
+
reset(ntlm->userdomain);
|
|
164
|
+
reset(ntlm->password);
|
|
165
|
+
|
|
166
|
+
reset(ntlm->username_utf16);
|
|
167
|
+
reset(ntlm->username_upper_utf16);
|
|
168
|
+
reset(ntlm->userdomain_utf16);
|
|
169
|
+
reset(ntlm->password_utf16);
|
|
170
|
+
|
|
171
|
+
ntlm->username_utf16_len = 0;
|
|
172
|
+
ntlm->username_upper_utf16_len = 0;
|
|
173
|
+
ntlm->userdomain_utf16_len = 0;
|
|
174
|
+
ntlm->password_utf16_len = 0;
|
|
159
175
|
}
|
|
160
176
|
|
|
161
177
|
int ntlm_client_set_credentials(
|
|
@@ -164,7 +180,8 @@ int ntlm_client_set_credentials(
|
|
|
164
180
|
const char *domain,
|
|
165
181
|
const char *password)
|
|
166
182
|
{
|
|
167
|
-
|
|
183
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
184
|
+
ENSURE_INITIALIZED(ntlm);
|
|
168
185
|
|
|
169
186
|
free_credentials(ntlm);
|
|
170
187
|
|
|
@@ -185,7 +202,7 @@ int ntlm_client_set_credentials(
|
|
|
185
202
|
if (!ntlm_unicode_utf8_to_16(
|
|
186
203
|
&ntlm->username_utf16,
|
|
187
204
|
&ntlm->username_utf16_len,
|
|
188
|
-
ntlm
|
|
205
|
+
ntlm,
|
|
189
206
|
ntlm->username,
|
|
190
207
|
strlen(ntlm->username)))
|
|
191
208
|
return -1;
|
|
@@ -193,7 +210,7 @@ int ntlm_client_set_credentials(
|
|
|
193
210
|
if (!ntlm_unicode_utf8_to_16(
|
|
194
211
|
&ntlm->username_upper_utf16,
|
|
195
212
|
&ntlm->username_upper_utf16_len,
|
|
196
|
-
ntlm
|
|
213
|
+
ntlm,
|
|
197
214
|
ntlm->username_upper,
|
|
198
215
|
strlen(ntlm->username_upper)))
|
|
199
216
|
return -1;
|
|
@@ -202,7 +219,7 @@ int ntlm_client_set_credentials(
|
|
|
202
219
|
if (domain && supports_unicode(ntlm) && !ntlm_unicode_utf8_to_16(
|
|
203
220
|
&ntlm->userdomain_utf16,
|
|
204
221
|
&ntlm->userdomain_utf16_len,
|
|
205
|
-
ntlm
|
|
222
|
+
ntlm,
|
|
206
223
|
ntlm->userdomain,
|
|
207
224
|
strlen(ntlm->userdomain)))
|
|
208
225
|
return -1;
|
|
@@ -212,7 +229,8 @@ int ntlm_client_set_credentials(
|
|
|
212
229
|
|
|
213
230
|
int ntlm_client_set_target(ntlm_client *ntlm, const char *target)
|
|
214
231
|
{
|
|
215
|
-
|
|
232
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
233
|
+
ENSURE_INITIALIZED(ntlm);
|
|
216
234
|
|
|
217
235
|
free(ntlm->target);
|
|
218
236
|
free(ntlm->target_utf16);
|
|
@@ -229,7 +247,7 @@ int ntlm_client_set_target(ntlm_client *ntlm, const char *target)
|
|
|
229
247
|
if (supports_unicode(ntlm) && !ntlm_unicode_utf8_to_16(
|
|
230
248
|
&ntlm->target_utf16,
|
|
231
249
|
&ntlm->target_utf16_len,
|
|
232
|
-
ntlm
|
|
250
|
+
ntlm,
|
|
233
251
|
ntlm->target,
|
|
234
252
|
strlen(ntlm->target)))
|
|
235
253
|
return -1;
|
|
@@ -240,14 +258,16 @@ int ntlm_client_set_target(ntlm_client *ntlm, const char *target)
|
|
|
240
258
|
|
|
241
259
|
int ntlm_client_set_nonce(ntlm_client *ntlm, uint64_t nonce)
|
|
242
260
|
{
|
|
243
|
-
|
|
261
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
262
|
+
|
|
244
263
|
ntlm->nonce = nonce;
|
|
245
264
|
return 0;
|
|
246
265
|
}
|
|
247
266
|
|
|
248
267
|
int ntlm_client_set_timestamp(ntlm_client *ntlm, uint64_t timestamp)
|
|
249
268
|
{
|
|
250
|
-
|
|
269
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
270
|
+
|
|
251
271
|
ntlm->timestamp = timestamp;
|
|
252
272
|
return 0;
|
|
253
273
|
}
|
|
@@ -475,7 +495,7 @@ static inline bool read_string_unicode(
|
|
|
475
495
|
size_t out_len;
|
|
476
496
|
int ret = ntlm_unicode_utf16_to_8(out,
|
|
477
497
|
&out_len,
|
|
478
|
-
ntlm
|
|
498
|
+
ntlm,
|
|
479
499
|
(char *)&message->buf[message->pos],
|
|
480
500
|
string_len);
|
|
481
501
|
|
|
@@ -593,7 +613,9 @@ int ntlm_client_negotiate(
|
|
|
593
613
|
size_t hostname_offset = 0;
|
|
594
614
|
uint32_t flags = 0;
|
|
595
615
|
|
|
596
|
-
|
|
616
|
+
NTLM_ASSERT_ARG(out);
|
|
617
|
+
NTLM_ASSERT_ARG(out_len);
|
|
618
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
597
619
|
|
|
598
620
|
*out = NULL;
|
|
599
621
|
*out_len = 0;
|
|
@@ -676,20 +698,22 @@ int ntlm_client_negotiate(
|
|
|
676
698
|
return -1;
|
|
677
699
|
|
|
678
700
|
if (hostname_len > 0) {
|
|
679
|
-
|
|
701
|
+
NTLM_ASSERT(ntlm, hostname_offset == ntlm->negotiate.pos);
|
|
702
|
+
|
|
680
703
|
if (!write_buf(ntlm, &ntlm->negotiate,
|
|
681
704
|
(const unsigned char *)ntlm->hostname, hostname_len))
|
|
682
705
|
return -1;
|
|
683
706
|
}
|
|
684
707
|
|
|
685
708
|
if (domain_len > 0) {
|
|
686
|
-
|
|
709
|
+
NTLM_ASSERT(ntlm, domain_offset == ntlm->negotiate.pos);
|
|
710
|
+
|
|
687
711
|
if (!write_buf(ntlm, &ntlm->negotiate,
|
|
688
712
|
(const unsigned char *)ntlm->hostdomain, domain_len))
|
|
689
713
|
return -1;
|
|
690
714
|
}
|
|
691
715
|
|
|
692
|
-
|
|
716
|
+
NTLM_ASSERT(ntlm, ntlm->negotiate.pos == ntlm->negotiate.len);
|
|
693
717
|
|
|
694
718
|
ntlm->state = NTLM_STATE_CHALLENGE;
|
|
695
719
|
|
|
@@ -711,7 +735,10 @@ int ntlm_client_set_challenge(
|
|
|
711
735
|
uint32_t name_offset, info_offset = 0;
|
|
712
736
|
bool unicode, has_target_info = false;
|
|
713
737
|
|
|
714
|
-
|
|
738
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
739
|
+
NTLM_ASSERT_ARG(challenge_msg || !challenge_msg_len);
|
|
740
|
+
|
|
741
|
+
ENSURE_INITIALIZED(ntlm);
|
|
715
742
|
|
|
716
743
|
if (ntlm->state != NTLM_STATE_NEGOTIATE &&
|
|
717
744
|
ntlm->state != NTLM_STATE_CHALLENGE) {
|
|
@@ -940,6 +967,7 @@ static void des_key_from_password(
|
|
|
940
967
|
|
|
941
968
|
static inline bool generate_lm_hash(
|
|
942
969
|
ntlm_des_block out[2],
|
|
970
|
+
ntlm_client *ntlm,
|
|
943
971
|
const char *password)
|
|
944
972
|
{
|
|
945
973
|
/* LM encrypts this known plaintext using the password as a key */
|
|
@@ -968,8 +996,8 @@ static inline bool generate_lm_hash(
|
|
|
968
996
|
des_key_from_password(&key1, keystr1, keystr1_len);
|
|
969
997
|
des_key_from_password(&key2, keystr2, keystr2_len);
|
|
970
998
|
|
|
971
|
-
return ntlm_des_encrypt(&out[0], &plaintext, &key1) &&
|
|
972
|
-
ntlm_des_encrypt(&out[1], &plaintext, &key2);
|
|
999
|
+
return ntlm_des_encrypt(&out[0], ntlm, &plaintext, &key1) &&
|
|
1000
|
+
ntlm_des_encrypt(&out[1], ntlm, &plaintext, &key2);
|
|
973
1001
|
}
|
|
974
1002
|
|
|
975
1003
|
static void des_keys_from_lm_hash(ntlm_des_block out[3], ntlm_des_block lm_hash[2])
|
|
@@ -994,16 +1022,16 @@ static bool generate_lm_response(ntlm_client *ntlm)
|
|
|
994
1022
|
ntlm_des_block *challenge = (ntlm_des_block *)&ntlm->challenge.nonce;
|
|
995
1023
|
|
|
996
1024
|
/* Generate the LM hash from the password */
|
|
997
|
-
if (!generate_lm_hash(lm_hash, ntlm->password))
|
|
1025
|
+
if (!generate_lm_hash(lm_hash, ntlm, ntlm->password))
|
|
998
1026
|
return false;
|
|
999
1027
|
|
|
1000
1028
|
/* Convert that LM hash to three DES keys */
|
|
1001
1029
|
des_keys_from_lm_hash(key, lm_hash);
|
|
1002
1030
|
|
|
1003
1031
|
/* Finally, encrypt the challenge with each of these keys */
|
|
1004
|
-
if (!ntlm_des_encrypt(&lm_response[0], challenge, &key[0]) ||
|
|
1005
|
-
!ntlm_des_encrypt(&lm_response[1], challenge, &key[1]) ||
|
|
1006
|
-
!ntlm_des_encrypt(&lm_response[2], challenge, &key[2]))
|
|
1032
|
+
if (!ntlm_des_encrypt(&lm_response[0], ntlm, challenge, &key[0]) ||
|
|
1033
|
+
!ntlm_des_encrypt(&lm_response[1], ntlm, challenge, &key[1]) ||
|
|
1034
|
+
!ntlm_des_encrypt(&lm_response[2], ntlm, challenge, &key[2]))
|
|
1007
1035
|
return false;
|
|
1008
1036
|
|
|
1009
1037
|
memcpy(&ntlm->lm_response[0], lm_response[0], 8);
|
|
@@ -1022,12 +1050,13 @@ static bool generate_ntlm_hash(
|
|
|
1022
1050
|
if (ntlm->password && !ntlm_unicode_utf8_to_16(
|
|
1023
1051
|
&ntlm->password_utf16,
|
|
1024
1052
|
&ntlm->password_utf16_len,
|
|
1025
|
-
ntlm
|
|
1053
|
+
ntlm,
|
|
1026
1054
|
ntlm->password,
|
|
1027
1055
|
strlen(ntlm->password)))
|
|
1028
1056
|
return false;
|
|
1029
1057
|
|
|
1030
1058
|
return ntlm_md4_digest(out,
|
|
1059
|
+
ntlm,
|
|
1031
1060
|
(const unsigned char *)ntlm->password_utf16,
|
|
1032
1061
|
ntlm->password_utf16_len);
|
|
1033
1062
|
}
|
|
@@ -1048,9 +1077,9 @@ static bool generate_ntlm_response(ntlm_client *ntlm)
|
|
|
1048
1077
|
des_key_from_password(&key[2], &ntlm_hash[14], 2);
|
|
1049
1078
|
|
|
1050
1079
|
/* Finally, encrypt the challenge with each of these keys */
|
|
1051
|
-
if (!ntlm_des_encrypt(&ntlm_response[0], challenge, &key[0]) ||
|
|
1052
|
-
!ntlm_des_encrypt(&ntlm_response[1], challenge, &key[1]) ||
|
|
1053
|
-
!ntlm_des_encrypt(&ntlm_response[2], challenge, &key[2]))
|
|
1080
|
+
if (!ntlm_des_encrypt(&ntlm_response[0], ntlm, challenge, &key[0]) ||
|
|
1081
|
+
!ntlm_des_encrypt(&ntlm_response[1], ntlm, challenge, &key[1]) ||
|
|
1082
|
+
!ntlm_des_encrypt(&ntlm_response[2], ntlm, challenge, &key[2]))
|
|
1054
1083
|
return false;
|
|
1055
1084
|
|
|
1056
1085
|
memcpy(&ntlm->ntlm_response[0], ntlm_response[0], 8);
|
|
@@ -1081,16 +1110,15 @@ static bool generate_ntlm2_hash(
|
|
|
1081
1110
|
target_len = ntlm->target_utf16_len;
|
|
1082
1111
|
}
|
|
1083
1112
|
|
|
1084
|
-
if (!
|
|
1085
|
-
!
|
|
1086
|
-
!ntlm_hmac_md5_update(ntlm
|
|
1087
|
-
!
|
|
1088
|
-
!ntlm_hmac_md5_final(out, &out_len, ntlm->hmac_ctx)) {
|
|
1113
|
+
if (!ntlm_hmac_md5_init(ntlm, ntlm_hash, sizeof(ntlm_hash)) ||
|
|
1114
|
+
!ntlm_hmac_md5_update(ntlm, username, username_len) ||
|
|
1115
|
+
!ntlm_hmac_md5_update(ntlm, target, target_len) ||
|
|
1116
|
+
!ntlm_hmac_md5_final(out, &out_len, ntlm)) {
|
|
1089
1117
|
ntlm_client_set_errmsg(ntlm, "failed to create HMAC-MD5");
|
|
1090
1118
|
return false;
|
|
1091
1119
|
}
|
|
1092
1120
|
|
|
1093
|
-
|
|
1121
|
+
NTLM_ASSERT(ntlm, out_len == NTLM_NTLM2_HASH_LEN);
|
|
1094
1122
|
return true;
|
|
1095
1123
|
}
|
|
1096
1124
|
|
|
@@ -1103,18 +1131,15 @@ static bool generate_ntlm2_challengehash(
|
|
|
1103
1131
|
{
|
|
1104
1132
|
size_t out_len = 16;
|
|
1105
1133
|
|
|
1106
|
-
if (!
|
|
1107
|
-
!
|
|
1108
|
-
|
|
1109
|
-
!
|
|
1110
|
-
(const unsigned char *)&ntlm->challenge.nonce, 8) ||
|
|
1111
|
-
!ntlm_hmac_md5_update(ntlm->hmac_ctx, blob, blob_len) ||
|
|
1112
|
-
!ntlm_hmac_md5_final(out, &out_len, ntlm->hmac_ctx)) {
|
|
1134
|
+
if (!ntlm_hmac_md5_init(ntlm, ntlm2_hash, NTLM_NTLM2_HASH_LEN) ||
|
|
1135
|
+
!ntlm_hmac_md5_update(ntlm, (const unsigned char *)&ntlm->challenge.nonce, 8) ||
|
|
1136
|
+
!ntlm_hmac_md5_update(ntlm, blob, blob_len) ||
|
|
1137
|
+
!ntlm_hmac_md5_final(out, &out_len, ntlm)) {
|
|
1113
1138
|
ntlm_client_set_errmsg(ntlm, "failed to create HMAC-MD5");
|
|
1114
1139
|
return false;
|
|
1115
1140
|
}
|
|
1116
1141
|
|
|
1117
|
-
|
|
1142
|
+
NTLM_ASSERT(ntlm, out_len == 16);
|
|
1118
1143
|
return true;
|
|
1119
1144
|
}
|
|
1120
1145
|
|
|
@@ -1127,19 +1152,15 @@ static bool generate_lm2_response(ntlm_client *ntlm,
|
|
|
1127
1152
|
|
|
1128
1153
|
local_nonce = ntlm_htonll(ntlm->nonce);
|
|
1129
1154
|
|
|
1130
|
-
if (!
|
|
1131
|
-
!
|
|
1132
|
-
|
|
1133
|
-
!
|
|
1134
|
-
(const unsigned char *)&ntlm->challenge.nonce, 8) ||
|
|
1135
|
-
!ntlm_hmac_md5_update(ntlm->hmac_ctx,
|
|
1136
|
-
(const unsigned char *)&local_nonce, 8) ||
|
|
1137
|
-
!ntlm_hmac_md5_final(lm2_challengehash, &lm2_len, ntlm->hmac_ctx)) {
|
|
1155
|
+
if (!ntlm_hmac_md5_init(ntlm, ntlm2_hash, NTLM_NTLM2_HASH_LEN) ||
|
|
1156
|
+
!ntlm_hmac_md5_update(ntlm, (const unsigned char *)&ntlm->challenge.nonce, 8) ||
|
|
1157
|
+
!ntlm_hmac_md5_update(ntlm, (const unsigned char *)&local_nonce, 8) ||
|
|
1158
|
+
!ntlm_hmac_md5_final(lm2_challengehash, &lm2_len, ntlm)) {
|
|
1138
1159
|
ntlm_client_set_errmsg(ntlm, "failed to create HMAC-MD5");
|
|
1139
1160
|
return false;
|
|
1140
1161
|
}
|
|
1141
1162
|
|
|
1142
|
-
|
|
1163
|
+
NTLM_ASSERT(ntlm, lm2_len == 16);
|
|
1143
1164
|
|
|
1144
1165
|
memcpy(&ntlm->lm_response[0], lm2_challengehash, 16);
|
|
1145
1166
|
memcpy(&ntlm->lm_response[16], &local_nonce, 8);
|
|
@@ -1163,7 +1184,7 @@ static bool generate_nonce(ntlm_client *ntlm)
|
|
|
1163
1184
|
if (ntlm->nonce)
|
|
1164
1185
|
return true;
|
|
1165
1186
|
|
|
1166
|
-
if (!ntlm_random_bytes(
|
|
1187
|
+
if (!ntlm_random_bytes(buf, ntlm, 8))
|
|
1167
1188
|
return false;
|
|
1168
1189
|
|
|
1169
1190
|
memcpy(&ntlm->nonce, buf, sizeof(uint64_t));
|
|
@@ -1233,7 +1254,11 @@ int ntlm_client_response(
|
|
|
1233
1254
|
uint32_t flags = 0;
|
|
1234
1255
|
bool unicode;
|
|
1235
1256
|
|
|
1236
|
-
|
|
1257
|
+
NTLM_ASSERT_ARG(out);
|
|
1258
|
+
NTLM_ASSERT_ARG(out_len);
|
|
1259
|
+
NTLM_ASSERT_ARG(ntlm);
|
|
1260
|
+
|
|
1261
|
+
ENSURE_INITIALIZED(ntlm);
|
|
1237
1262
|
|
|
1238
1263
|
*out = NULL;
|
|
1239
1264
|
*out_len = 0;
|
|
@@ -1356,7 +1381,7 @@ int ntlm_client_response(
|
|
|
1356
1381
|
!write_buf(ntlm, &ntlm->response, session, session_len))
|
|
1357
1382
|
return -1;
|
|
1358
1383
|
|
|
1359
|
-
|
|
1384
|
+
NTLM_ASSERT(ntlm, ntlm->response.pos == ntlm->response.len);
|
|
1360
1385
|
|
|
1361
1386
|
ntlm->state = NTLM_STATE_COMPLETE;
|
|
1362
1387
|
|
|
@@ -1368,41 +1393,48 @@ int ntlm_client_response(
|
|
|
1368
1393
|
|
|
1369
1394
|
void ntlm_client_reset(ntlm_client *ntlm)
|
|
1370
1395
|
{
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
ntlm_unicode_ctx *unicode_ctx;
|
|
1374
|
-
|
|
1375
|
-
assert(ntlm);
|
|
1396
|
+
if (!ntlm)
|
|
1397
|
+
return;
|
|
1376
1398
|
|
|
1377
|
-
|
|
1378
|
-
free(ntlm->challenge.target_info);
|
|
1379
|
-
free(ntlm->challenge.target);
|
|
1380
|
-
free(ntlm->challenge.target_domain);
|
|
1381
|
-
free(ntlm->challenge.target_domain_dns);
|
|
1382
|
-
free(ntlm->challenge.target_server);
|
|
1383
|
-
free(ntlm->challenge.target_server_dns);
|
|
1384
|
-
free(ntlm->response.buf);
|
|
1399
|
+
ntlm->state = NTLM_STATE_NEGOTIATE;
|
|
1385
1400
|
|
|
1386
|
-
|
|
1387
|
-
free(ntlm->hostname_utf16);
|
|
1388
|
-
free(ntlm->hostdomain);
|
|
1401
|
+
free_hostname(ntlm);
|
|
1389
1402
|
|
|
1390
|
-
|
|
1391
|
-
free(ntlm->target_utf16);
|
|
1403
|
+
memset(&ntlm->host_version, 0, sizeof(ntlm_version));
|
|
1392
1404
|
|
|
1393
|
-
|
|
1405
|
+
reset(ntlm->target);
|
|
1406
|
+
reset(ntlm->target_utf16);
|
|
1407
|
+
ntlm->target_utf16_len = 0;
|
|
1394
1408
|
|
|
1395
1409
|
free_credentials(ntlm);
|
|
1396
1410
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
unicode_ctx = ntlm->unicode_ctx;
|
|
1411
|
+
ntlm->nonce = 0;
|
|
1412
|
+
ntlm->timestamp = 0;
|
|
1400
1413
|
|
|
1401
|
-
memset(ntlm, 0,
|
|
1414
|
+
memset(ntlm->lm_response, 0, NTLM_LM_RESPONSE_LEN);
|
|
1415
|
+
ntlm->lm_response_len = 0;
|
|
1402
1416
|
|
|
1403
|
-
ntlm->
|
|
1404
|
-
ntlm->
|
|
1405
|
-
|
|
1417
|
+
memset(ntlm->ntlm_response, 0, NTLM_NTLM_RESPONSE_LEN);
|
|
1418
|
+
ntlm->ntlm_response_len = 0;
|
|
1419
|
+
|
|
1420
|
+
reset(ntlm->ntlm2_response);
|
|
1421
|
+
ntlm->ntlm2_response_len = 0;
|
|
1422
|
+
|
|
1423
|
+
reset(ntlm->negotiate.buf);
|
|
1424
|
+
ntlm->negotiate.pos = 0;
|
|
1425
|
+
ntlm->negotiate.len = 0;
|
|
1426
|
+
|
|
1427
|
+
reset(ntlm->response.buf);
|
|
1428
|
+
ntlm->response.pos = 0;
|
|
1429
|
+
ntlm->response.len = 0;
|
|
1430
|
+
|
|
1431
|
+
free(ntlm->challenge.target_info);
|
|
1432
|
+
free(ntlm->challenge.target);
|
|
1433
|
+
free(ntlm->challenge.target_domain);
|
|
1434
|
+
free(ntlm->challenge.target_domain_dns);
|
|
1435
|
+
free(ntlm->challenge.target_server);
|
|
1436
|
+
free(ntlm->challenge.target_server_dns);
|
|
1437
|
+
memset(&ntlm->challenge, 0, sizeof(ntlm_challenge));
|
|
1406
1438
|
}
|
|
1407
1439
|
|
|
1408
1440
|
void ntlm_client_free(ntlm_client *ntlm)
|
|
@@ -1410,10 +1442,10 @@ void ntlm_client_free(ntlm_client *ntlm)
|
|
|
1410
1442
|
if (!ntlm)
|
|
1411
1443
|
return;
|
|
1412
1444
|
|
|
1413
|
-
|
|
1445
|
+
ntlm_crypt_shutdown(ntlm);
|
|
1446
|
+
ntlm_unicode_shutdown(ntlm);
|
|
1414
1447
|
|
|
1415
|
-
|
|
1416
|
-
ntlm_unicode_ctx_free(ntlm->unicode_ctx);
|
|
1448
|
+
ntlm_client_reset(ntlm);
|
|
1417
1449
|
|
|
1418
1450
|
free(ntlm);
|
|
1419
1451
|
}
|