2004-03-02 05:57:35 +01:00
|
|
|
/*
|
|
|
|
* secur32 private definitions.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Juan Lang
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-02 05:57:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SECUR32_PRIV_H__
|
|
|
|
#define __SECUR32_PRIV_H__
|
|
|
|
|
2005-10-30 20:06:24 +01:00
|
|
|
#include <sys/types.h>
|
2011-03-14 00:58:40 +01:00
|
|
|
#include <limits.h>
|
2018-02-14 14:13:09 +01:00
|
|
|
#include "wine/heap.h"
|
2005-08-30 10:55:20 +02:00
|
|
|
#include "wine/list.h"
|
2011-03-14 00:58:40 +01:00
|
|
|
#include "schannel.h"
|
2005-08-30 10:55:20 +02:00
|
|
|
|
2004-03-02 05:57:35 +01:00
|
|
|
typedef struct _SecureProvider
|
|
|
|
{
|
2005-08-30 10:55:20 +02:00
|
|
|
struct list entry;
|
2005-05-13 19:44:47 +02:00
|
|
|
BOOL loaded;
|
2004-03-02 05:57:35 +01:00
|
|
|
PWSTR moduleName;
|
|
|
|
HMODULE lib;
|
|
|
|
SecurityFunctionTableA fnTableA;
|
|
|
|
SecurityFunctionTableW fnTableW;
|
|
|
|
} SecureProvider;
|
|
|
|
|
|
|
|
typedef struct _SecurePackage
|
|
|
|
{
|
2005-08-30 10:55:20 +02:00
|
|
|
struct list entry;
|
2004-03-02 05:57:35 +01:00
|
|
|
SecPkgInfoW infoW;
|
|
|
|
SecureProvider *provider;
|
|
|
|
} SecurePackage;
|
|
|
|
|
2005-10-30 20:06:24 +01:00
|
|
|
typedef enum _helper_mode {
|
|
|
|
NTLM_SERVER,
|
|
|
|
NTLM_CLIENT,
|
|
|
|
NUM_HELPER_MODES
|
|
|
|
} HelperMode;
|
|
|
|
|
2006-08-17 02:11:39 +02:00
|
|
|
typedef struct tag_arc4_info {
|
|
|
|
unsigned char x, y;
|
|
|
|
unsigned char state[256];
|
|
|
|
} arc4_info;
|
|
|
|
|
2005-10-30 20:06:24 +01:00
|
|
|
typedef struct _NegoHelper {
|
|
|
|
pid_t helper_pid;
|
|
|
|
HelperMode mode;
|
|
|
|
int pipe_in;
|
|
|
|
int pipe_out;
|
2006-11-29 10:58:02 +01:00
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int micro;
|
2005-10-30 20:06:24 +01:00
|
|
|
char *com_buf;
|
|
|
|
int com_buf_size;
|
|
|
|
int com_buf_offset;
|
2006-08-12 19:19:49 +02:00
|
|
|
BYTE *session_key;
|
2010-05-11 21:28:42 +02:00
|
|
|
ULONG neg_flags;
|
2006-08-17 02:11:39 +02:00
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
ULONG seq_num;
|
|
|
|
arc4_info *a4i;
|
|
|
|
} ntlm;
|
2006-11-08 21:53:23 +01:00
|
|
|
struct {
|
|
|
|
BYTE *send_sign_key;
|
|
|
|
BYTE *send_seal_key;
|
|
|
|
BYTE *recv_sign_key;
|
|
|
|
BYTE *recv_seal_key;
|
|
|
|
ULONG send_seq_no;
|
|
|
|
ULONG recv_seq_no;
|
|
|
|
arc4_info *send_a4i;
|
|
|
|
arc4_info *recv_a4i;
|
|
|
|
} ntlm2;
|
2006-08-17 02:11:39 +02:00
|
|
|
} crypt;
|
2005-10-30 20:06:24 +01:00
|
|
|
} NegoHelper, *PNegoHelper;
|
|
|
|
|
2012-05-10 13:06:20 +02:00
|
|
|
typedef struct _NtlmCredentials
|
|
|
|
{
|
|
|
|
HelperMode mode;
|
|
|
|
|
|
|
|
/* these are all in the Unix codepage */
|
|
|
|
char *username_arg;
|
|
|
|
char *domain_arg;
|
|
|
|
char *password; /* not nul-terminated */
|
|
|
|
int pwlen;
|
|
|
|
int no_cached_credentials; /* don't try to use cached Samba credentials */
|
|
|
|
} NtlmCredentials, *PNtlmCredentials;
|
|
|
|
|
2006-11-08 12:10:37 +01:00
|
|
|
typedef enum _sign_direction {
|
|
|
|
NTLM_SEND,
|
|
|
|
NTLM_RECV
|
|
|
|
} SignDirection;
|
|
|
|
|
2005-05-13 19:44:47 +02:00
|
|
|
/* Allocates space for and initializes a new provider. If fnTableA or fnTableW
|
2008-07-02 17:18:49 +02:00
|
|
|
* is non-NULL, assumes the provider is built-in, and if moduleName is non-NULL,
|
|
|
|
* means must load the LSA/user mode functions tables from external SSP/AP module.
|
2005-05-13 19:44:47 +02:00
|
|
|
* Otherwise moduleName must not be NULL.
|
|
|
|
* Returns a pointer to the stored provider entry, for use adding packages.
|
|
|
|
*/
|
2006-01-24 14:00:32 +01:00
|
|
|
SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
|
2011-04-21 11:37:02 +02:00
|
|
|
const SecurityFunctionTableW *fnTableW, PCWSTR moduleName) DECLSPEC_HIDDEN;
|
2005-05-13 19:44:47 +02:00
|
|
|
|
|
|
|
/* Allocates space for and adds toAdd packages with the given provider.
|
|
|
|
* provider must not be NULL, and either infoA or infoW may be NULL, but not
|
|
|
|
* both.
|
|
|
|
*/
|
|
|
|
void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
|
2011-04-21 11:37:02 +02:00
|
|
|
const SecPkgInfoA *infoA, const SecPkgInfoW *infoW) DECLSPEC_HIDDEN;
|
2005-05-13 19:44:47 +02:00
|
|
|
|
2004-03-02 05:57:35 +01:00
|
|
|
/* Tries to find the package named packageName. If it finds it, implicitly
|
|
|
|
* loads the package if it isn't already loaded.
|
|
|
|
*/
|
2011-04-21 11:37:02 +02:00
|
|
|
SecurePackage *SECUR32_findPackageW(PCWSTR packageName) DECLSPEC_HIDDEN;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
|
|
|
/* Tries to find the package named packageName. (Thunks to _findPackageW)
|
|
|
|
*/
|
2011-04-21 11:37:02 +02:00
|
|
|
SecurePackage *SECUR32_findPackageA(PCSTR packageName) DECLSPEC_HIDDEN;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
|
|
|
/* A few string helpers; will return NULL if str is NULL. Free return with
|
2007-12-05 21:52:20 +01:00
|
|
|
* HeapFree */
|
2011-04-21 11:37:02 +02:00
|
|
|
PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str) DECLSPEC_HIDDEN;
|
|
|
|
PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str) DECLSPEC_HIDDEN;
|
2004-03-02 05:57:35 +01:00
|
|
|
|
2005-05-13 19:44:47 +02:00
|
|
|
/* Initialization functions for built-in providers */
|
2011-04-21 11:37:02 +02:00
|
|
|
void SECUR32_initSchannelSP(void) DECLSPEC_HIDDEN;
|
|
|
|
void SECUR32_initNegotiateSP(void) DECLSPEC_HIDDEN;
|
|
|
|
void SECUR32_initNTLMSP(void) DECLSPEC_HIDDEN;
|
2018-02-01 11:04:33 +01:00
|
|
|
void load_auth_packages(void) DECLSPEC_HIDDEN;
|
2005-05-13 19:44:47 +02:00
|
|
|
|
2008-09-22 22:14:04 +02:00
|
|
|
/* Cleanup functions for built-in providers */
|
2011-04-21 11:37:02 +02:00
|
|
|
void SECUR32_deinitSchannelSP(void) DECLSPEC_HIDDEN;
|
2008-09-22 22:14:04 +02:00
|
|
|
|
2005-10-30 20:06:24 +01:00
|
|
|
/* Functions from dispatcher.c used elsewhere in the code */
|
|
|
|
SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
|
2011-04-21 11:37:02 +02:00
|
|
|
char * const argv[]) DECLSPEC_HIDDEN;
|
2005-10-30 20:06:24 +01:00
|
|
|
|
|
|
|
SECURITY_STATUS run_helper(PNegoHelper helper, char *buffer,
|
2011-04-21 11:37:02 +02:00
|
|
|
unsigned int max_buflen, int *buflen) DECLSPEC_HIDDEN;
|
2005-10-30 20:06:24 +01:00
|
|
|
|
2011-04-21 11:37:02 +02:00
|
|
|
void cleanup_helper(PNegoHelper helper) DECLSPEC_HIDDEN;
|
2005-10-30 20:06:24 +01:00
|
|
|
|
2011-04-21 11:37:02 +02:00
|
|
|
void check_version(PNegoHelper helper) DECLSPEC_HIDDEN;
|
2005-10-30 20:06:24 +01:00
|
|
|
|
2005-09-21 13:43:52 +02:00
|
|
|
/* Functions from base64_codec.c used elsewhere */
|
2010-04-19 10:15:15 +02:00
|
|
|
SECURITY_STATUS encodeBase64(PBYTE in_buf, int in_len, char* out_buf,
|
2011-04-21 11:37:02 +02:00
|
|
|
int max_len, int *out_len) DECLSPEC_HIDDEN;
|
2005-09-21 13:43:52 +02:00
|
|
|
|
2006-08-17 02:11:39 +02:00
|
|
|
SECURITY_STATUS decodeBase64(char *in_buf, int in_len, BYTE *out_buf,
|
2011-04-21 11:37:02 +02:00
|
|
|
int max_len, int *out_len) DECLSPEC_HIDDEN;
|
2005-09-21 13:43:52 +02:00
|
|
|
|
2006-08-17 02:11:39 +02:00
|
|
|
/* Functions from util.c */
|
2011-04-21 11:37:02 +02:00
|
|
|
SECURITY_STATUS SECUR32_CreateNTLM1SessionKey(PBYTE password, int len, PBYTE session_key) DECLSPEC_HIDDEN;
|
|
|
|
SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper) DECLSPEC_HIDDEN;
|
|
|
|
arc4_info *SECUR32_arc4Alloc(void) DECLSPEC_HIDDEN;
|
|
|
|
void SECUR32_arc4Init(arc4_info *a4i, const BYTE *key, unsigned int keyLen) DECLSPEC_HIDDEN;
|
|
|
|
void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length) DECLSPEC_HIDDEN;
|
|
|
|
void SECUR32_arc4Cleanup(arc4_info *a4i) DECLSPEC_HIDDEN;
|
2006-08-17 02:11:39 +02:00
|
|
|
|
2006-08-12 19:19:49 +02:00
|
|
|
/* NTLMSSP flags indicating the negotiated features */
|
|
|
|
#define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
|
|
|
|
#define NTLMSSP_NEGOTIATE_OEM 0x00000002
|
|
|
|
#define NTLMSSP_REQUEST_TARGET 0x00000004
|
|
|
|
#define NTLMSSP_NEGOTIATE_SIGN 0x00000010
|
|
|
|
#define NTLMSSP_NEGOTIATE_SEAL 0x00000020
|
|
|
|
#define NTLMSSP_NEGOTIATE_DATAGRAM_STYLE 0x00000040
|
|
|
|
#define NTLMSSP_NEGOTIATE_LM_SESSION_KEY 0x00000080
|
|
|
|
#define NTLMSSP_NEGOTIATE_NTLM 0x00000200
|
|
|
|
#define NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED 0x00001000
|
|
|
|
#define NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED 0x00002000
|
|
|
|
#define NTLMSSP_NEGOTIATE_LOCAL_CALL 0x00004000
|
|
|
|
#define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
|
|
|
|
#define NTLMSSP_NEGOTIATE_TARGET_TYPE_DOMAIN 0x00010000
|
|
|
|
#define NTLMSSP_NEGOTIATE_TARGET_TYPE_SERVER 0x00020000
|
|
|
|
#define NTLMSSP_NEGOTIATE_NTLM2 0x00080000
|
|
|
|
#define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
|
|
|
|
#define NTLMSSP_NEGOTIATE_128 0x20000000
|
|
|
|
#define NTLMSSP_NEGOTIATE_KEY_EXCHANGE 0x40000000
|
|
|
|
#define NTLMSSP_NEGOTIATE_56 0x80000000
|
2011-03-14 00:58:40 +01:00
|
|
|
|
2012-05-10 13:06:20 +02:00
|
|
|
|
2011-03-14 00:58:40 +01:00
|
|
|
/* schannel internal interface */
|
|
|
|
typedef struct schan_imp_session_opaque *schan_imp_session;
|
2013-03-25 13:55:20 +01:00
|
|
|
|
|
|
|
typedef struct schan_credentials
|
|
|
|
{
|
|
|
|
ULONG credential_use;
|
|
|
|
void *credentials;
|
2013-03-27 12:22:23 +01:00
|
|
|
DWORD enabled_protocols;
|
2013-03-25 13:55:20 +01:00
|
|
|
} schan_credentials;
|
2011-03-14 00:58:40 +01:00
|
|
|
|
|
|
|
struct schan_transport;
|
|
|
|
|
2011-10-03 20:22:50 +02:00
|
|
|
struct schan_buffers
|
|
|
|
{
|
|
|
|
SIZE_T offset;
|
|
|
|
SIZE_T limit;
|
|
|
|
const SecBufferDesc *desc;
|
|
|
|
int current_buffer_idx;
|
|
|
|
BOOL allow_buffer_resize;
|
|
|
|
int (*get_next_buffer)(const struct schan_transport *, struct schan_buffers *);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct schan_transport
|
|
|
|
{
|
|
|
|
struct schan_context *ctx;
|
|
|
|
struct schan_buffers in;
|
|
|
|
struct schan_buffers out;
|
|
|
|
};
|
|
|
|
|
|
|
|
char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s, SIZE_T *count) DECLSPEC_HIDDEN;
|
2011-04-21 11:37:02 +02:00
|
|
|
extern int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
|
|
|
|
extern int schan_push(struct schan_transport *t, const void *buff, size_t *buff_len) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
|
2011-04-21 11:37:02 +02:00
|
|
|
extern schan_imp_session schan_session_for_transport(struct schan_transport* t) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
|
|
|
|
/* schannel implementation interface */
|
2013-03-25 13:55:20 +01:00
|
|
|
extern BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cred) DECLSPEC_HIDDEN;
|
2011-04-21 11:37:02 +02:00
|
|
|
extern void schan_imp_dispose_session(schan_imp_session session) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
extern void schan_imp_set_session_transport(schan_imp_session session,
|
2011-04-21 11:37:02 +02:00
|
|
|
struct schan_transport *t) DECLSPEC_HIDDEN;
|
2013-06-13 15:50:38 +02:00
|
|
|
extern void schan_imp_set_session_target(schan_imp_session session, const char *target) DECLSPEC_HIDDEN;
|
2011-04-21 11:37:02 +02:00
|
|
|
extern SECURITY_STATUS schan_imp_handshake(schan_imp_session session) DECLSPEC_HIDDEN;
|
|
|
|
extern unsigned int schan_imp_get_session_cipher_block_size(schan_imp_session session) DECLSPEC_HIDDEN;
|
2011-10-03 20:22:48 +02:00
|
|
|
extern unsigned int schan_imp_get_max_message_size(schan_imp_session session) DECLSPEC_HIDDEN;
|
2017-04-24 17:31:44 +02:00
|
|
|
extern ALG_ID schan_imp_get_key_signature_algorithm(schan_imp_session session) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
extern SECURITY_STATUS schan_imp_get_connection_info(schan_imp_session session,
|
2011-04-21 11:37:02 +02:00
|
|
|
SecPkgContext_ConnectionInfo *info) DECLSPEC_HIDDEN;
|
2021-01-28 18:02:39 +01:00
|
|
|
extern SECURITY_STATUS schan_imp_get_unique_channel_binding(schan_imp_session session,
|
|
|
|
SecPkgContext_Bindings *bindings) DECLSPEC_HIDDEN;
|
2013-01-21 15:03:36 +01:00
|
|
|
extern SECURITY_STATUS schan_imp_get_session_peer_certificate(schan_imp_session session, HCERTSTORE,
|
2011-04-21 11:37:02 +02:00
|
|
|
PCCERT_CONTEXT *cert) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
extern SECURITY_STATUS schan_imp_send(schan_imp_session session, const void *buffer,
|
2011-09-05 19:32:06 +02:00
|
|
|
SIZE_T *length) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
extern SECURITY_STATUS schan_imp_recv(schan_imp_session session, void *buffer,
|
2011-09-05 19:32:06 +02:00
|
|
|
SIZE_T *length) DECLSPEC_HIDDEN;
|
2019-02-07 10:52:11 +01:00
|
|
|
extern BOOL schan_imp_allocate_certificate_credentials(schan_credentials *, const CERT_CONTEXT *) DECLSPEC_HIDDEN;
|
2013-03-25 13:55:20 +01:00
|
|
|
extern void schan_imp_free_certificate_credentials(schan_credentials*) DECLSPEC_HIDDEN;
|
2013-03-28 12:05:59 +01:00
|
|
|
extern DWORD schan_imp_enabled_protocols(void) DECLSPEC_HIDDEN;
|
2011-04-21 11:37:02 +02:00
|
|
|
extern BOOL schan_imp_init(void) DECLSPEC_HIDDEN;
|
|
|
|
extern void schan_imp_deinit(void) DECLSPEC_HIDDEN;
|
2020-04-09 17:25:32 +02:00
|
|
|
extern void schan_imp_set_application_protocols(schan_imp_session, unsigned char *, unsigned int) DECLSPEC_HIDDEN;
|
|
|
|
extern SECURITY_STATUS schan_imp_get_application_protocol(schan_imp_session,
|
|
|
|
SecPkgContext_ApplicationProtocol *) DECLSPEC_HIDDEN;
|
2011-03-14 00:58:40 +01:00
|
|
|
|
2004-03-02 05:57:35 +01:00
|
|
|
#endif /* ndef __SECUR32_PRIV_H__ */
|