const char *server,
const char *setup_creds_as,
uint16_t sec_chan,
- const unsigned char *trust_passwd,
+ const uint8_t *trust_passwd,
BOOL *retry)
{
struct in_addr dest_ip;
struct in_addr *ip,
const char *setup_creds_as,
uint16_t sec_chan,
- const unsigned char *trust_passwd)
+ const uint8_t *trust_passwd)
{
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
BOOL retry = True;
const char *domain,
const char *setup_creds_as,
uint16_t sec_chan,
- unsigned char *trust_passwd,
+ uint8_t *trust_passwd,
time_t last_change_time)
{
struct in_addr dc_ip;
auth_serversupplied_info **server_info,
const char *server, const char *setup_creds_as,
uint16_t sec_chan,
- unsigned char trust_passwd[16],
+ uint8_t trust_passwd[16],
time_t last_change_time)
{
fstring remote_machine;
{
NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
char *password_server;
- unsigned char trust_passwd[16];
+ uint8_t trust_passwd[16];
time_t last_change_time;
const char *domain = lp_workgroup();
auth_serversupplied_info **server_info)
{
NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
- unsigned char trust_md4_password[16];
+ uint8_t trust_md4_password[16];
char *trust_password;
time_t last_change_time;
DOM_SID sid;
auth_serversupplied_info **server_info)
{
struct cli_state *cli;
- static unsigned char badpass[24];
+ static uint8_t badpass[24];
static fstring baduser;
static BOOL tested_password_server = False;
static BOOL bad_password_server = False;
{
char lm_pwd[16];
char nt_pwd[16];
- unsigned char local_lm_response[24];
- unsigned char local_nt_response[24];
- unsigned char key[16];
+ uint8_t local_lm_response[24];
+ uint8_t local_nt_response[24];
+ uint8_t key[16];
ZERO_STRUCT(key);
memcpy(key, dc_sess_key, 8);
#endif
if (lm_interactive_pwd)
- SMBOWFencrypt((const unsigned char *)lm_pwd, chal, local_lm_response);
+ SMBOWFencrypt((const uint8_t *)lm_pwd, chal, local_lm_response);
if (nt_interactive_pwd)
- SMBOWFencrypt((const unsigned char *)nt_pwd, chal, local_nt_response);
+ SMBOWFencrypt((const uint8_t *)nt_pwd, chal, local_nt_response);
/* Password info paranoia */
ZERO_STRUCT(key);
DEBUG(5,("make_user_info_for_reply: User passwords not in encrypted format.\n"));
if (plaintext_password.data) {
- unsigned char local_lm_response[24];
+ uint8_t local_lm_response[24];
#ifdef DEBUG_PASSWORD
DEBUG(10,("Unencrypted password (len %d):\n",plaintext_password.length));
struct passwd *pw;
sec_passwd_rec_t passwd_rec;
sec_login_auth_src_t auth_src = sec_login_auth_src_network;
- unsigned char dce_errstr[dce_c_error_string_len];
+ uint8_t dce_errstr[dce_c_error_string_len];
gid_t egid;
if (dcelogin_atmost_once)
}
sec_key_mgmt_get_key(rpc_c_authn_dce_secret, NULL,
- (unsigned char *)pw->pw_name,
+ (uint8_t *)pw->pw_name,
sec_c_key_version_none,
(void **)&key, &err);
if (err != error_status_ok)
}
}
- if (sec_login_setup_identity((unsigned char *)user,
+ if (sec_login_setup_identity((uint8_t *)user,
sec_login_no_flags,
&my_dce_sec_context, &err) == 0)
{
set_effective_gid(pw->pw_gid);
set_effective_uid(pw->pw_uid);
- if (sec_login_setup_identity((unsigned char *)user,
+ if (sec_login_setup_identity((uint8_t *)user,
sec_login_no_flags,
&my_dce_sec_context, &err) == 0)
{
{
error_status_t err;
int err2;
- unsigned char dce_errstr[dce_c_error_string_len];
+ uint8_t dce_errstr[dce_c_error_string_len];
sec_login_purge_context(&my_dce_sec_context, &err);
if (err != error_status_ok)
static int tarhandle;
static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime,
- const char *amode, unsigned char ftype);
+ const char *amode, uint8_t ftype);
static void do_atar(char *rname,char *lname,file_info *finfo1);
static void do_tar(file_info *finfo);
static void oct_it(uint64_t value, int ndgs, char *p);
Write a tar header to buffer
****************************************************************************/
static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime,
- const char *amode, unsigned char ftype)
+ const char *amode, uint8_t ftype)
{
union hblock hb;
int i, chk, l;
uint32_t afpi_Version; /* Must be 0x00010000 */
uint32_t afpi_Reserved1;
uint32_t afpi_BackupTime; /* Backup time for the file/dir */
- unsigned char afpi_FinderInfo[AFP_FinderSize]; /* Finder Info (32 bytes) */
- unsigned char afpi_ProDosInfo[6]; /* ProDos Info (6 bytes) # */
- unsigned char afpi_Reserved2[6];
+ uint8_t afpi_FinderInfo[AFP_FinderSize]; /* Finder Info (32 bytes) */
+ uint8_t afpi_ProDosInfo[6]; /* ProDos Info (6 bytes) # */
+ uint8_t afpi_Reserved2[6];
} AfpInfo;
typedef struct _SambaAfpInfo
You do this:
-#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
+#define CVAL(buf,pos) (((uint8_t *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
#define CAREFUL_ALIGNMENT 1
#endif
-#define CVAL(buf,pos) ((unsigned)(((const unsigned char *)(buf))[pos]))
-#define CVAL_NC(buf,pos) (((unsigned char *)(buf))[pos]) /* Non-const version of CVAL */
+#define CVAL(buf,pos) ((unsigned)(((const uint8_t *)(buf))[pos]))
+#define CVAL_NC(buf,pos) (((uint8_t *)(buf))[pos]) /* Non-const version of CVAL */
#define PVAL(buf,pos) (CVAL(buf,pos))
#define SCVAL(buf,pos,val) (CVAL_NC(buf,pos) = (val))
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
-#define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(unsigned char)((val)&0xFF),CVAL_NC(buf,pos+1)=(unsigned char)((val)>>8))
+#define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(uint8_t)((val)&0xFF),CVAL_NC(buf,pos+1)=(uint8_t)((val)>>8))
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
#define SVALS(buf,pos) ((int16_t)SVAL(buf,pos))
#define IVALS(buf,pos) ((int32_t)IVAL(buf,pos))
struct MD5Context {
uint32_t buf[4];
uint32_t bits[2];
- unsigned char in[64];
+ uint8_t in[64];
};
void MD5Init(struct MD5Context *context);
-void MD5Update(struct MD5Context *context, unsigned char const *buf,
+void MD5Update(struct MD5Context *context, uint8_t const *buf,
unsigned len);
-void MD5Final(unsigned char digest[16], struct MD5Context *context);
+void MD5Final(uint8_t digest[16], struct MD5Context *context);
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
#if 0
//FIXME
typedef struct ace_struct_s {
- unsigned char type, flags;
+ uint8_t type, flags;
unsigned int perms; /* Perhaps a better def is in order */
DOM_SID *trustee;
} ACE;
/* A netbios node status array element. */
struct node_status {
char name[16];
- unsigned char type;
- unsigned char flags;
+ uint8_t type;
+ uint8_t flags;
};
#include "rpc_secdes.h"
X[j] = 0;
}
-static void copy64(uint32_t *M, const unsigned char *in)
+static void copy64(uint32_t *M, const uint8_t *in)
{
int i;
(in[i*4+1]<<8) | (in[i*4+0]<<0);
}
-static void copy4(unsigned char *out, uint32_t x)
+static void copy4(uint8_t *out, uint32_t x)
{
out[0] = x&0xFF;
out[1] = (x>>8)&0xFF;
}
/* produce a md4 message digest from data of length n bytes */
-void mdfour(unsigned char *out, const unsigned char *in, int n)
+void mdfour(uint8_t *out, const uint8_t *in, int n)
{
- unsigned char buf[128];
+ uint8_t buf[128];
uint32_t M[16];
uint32_t b = n * 8;
int i;
/*
* Note: this code is harmless on little-endian machines.
*/
-static void byteReverse(unsigned char *buf, unsigned longs)
+static void byteReverse(uint8_t *buf, unsigned longs)
{
uint32_t t;
do {
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
-void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
+void MD5Update(struct MD5Context *ctx, uint8_t const *buf, unsigned len)
{
register uint32_t t;
/* Handle any leading odd-sized chunks */
if (t) {
- unsigned char *p = (unsigned char *) ctx->in + t;
+ uint8_t *p = (uint8_t *) ctx->in + t;
t = 64 - t;
if (len < t) {
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
-void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
+void MD5Final(uint8_t digest[16], struct MD5Context *ctx)
{
unsigned int count;
- unsigned char *p;
+ uint8_t *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
((uint32_t *) ctx->in)[15] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- byteReverse((unsigned char *) ctx->buf, 4);
+ byteReverse((uint8_t *) ctx->buf, 4);
memmove(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
#include "includes.h"
-static unsigned char hash[258];
+static uint8_t hash[258];
static uint32_t counter;
-static unsigned char *reseed_data;
+static uint8_t *reseed_data;
static size_t reseed_data_size;
/****************************************************************
Copy any user given reseed data.
*****************************************************************/
-void set_rand_reseed_data(unsigned char *data, size_t len)
+void set_rand_reseed_data(uint8_t *data, size_t len)
{
SAFE_FREE(reseed_data);
reseed_data_size = 0;
- reseed_data = (unsigned char *)memdup(data, len);
+ reseed_data = (uint8_t *)memdup(data, len);
if (reseed_data)
reseed_data_size = len;
}
Setup the seed.
*****************************************************************/
-static void seed_random_stream(unsigned char *seedval, size_t seedlen)
+static void seed_random_stream(uint8_t *seedval, size_t seedlen)
{
- unsigned char j = 0;
+ uint8_t j = 0;
size_t ind;
for (ind = 0; ind < 256; ind++)
- hash[ind] = (unsigned char)ind;
+ hash[ind] = (uint8_t)ind;
for( ind = 0; ind < 256; ind++) {
- unsigned char tc;
+ uint8_t tc;
j += (hash[ind] + seedval[ind%seedlen]);
Get datasize bytes worth of random data.
*****************************************************************/
-static void get_random_stream(unsigned char *data, size_t datasize)
+static void get_random_stream(uint8_t *data, size_t datasize)
{
- unsigned char index_i = hash[256];
- unsigned char index_j = hash[257];
+ uint8_t index_i = hash[256];
+ uint8_t index_j = hash[257];
size_t ind;
for( ind = 0; ind < datasize; ind++) {
- unsigned char tc;
- unsigned char t;
+ uint8_t tc;
+ uint8_t t;
index_i++;
index_j += hash[index_i];
Note that the hash is not initialised.
*****************************************************************/
-static void do_filehash(const char *fname, unsigned char *the_hash)
+static void do_filehash(const char *fname, uint8_t *the_hash)
{
- unsigned char buf[1011]; /* deliberate weird size */
- unsigned char tmp_md4[16];
+ uint8_t buf[1011]; /* deliberate weird size */
+ uint8_t tmp_md4[16];
int fd, n;
fd = sys_open(fname,O_RDONLY,0);
static int do_reseed(BOOL use_fd, int fd)
{
- unsigned char seed_inbuf[40];
+ uint8_t seed_inbuf[40];
uint32_t v1, v2; struct timeval tval; pid_t mypid;
if (use_fd) {
Interface to the (hopefully) good crypto random number generator.
********************************************************************/
-void generate_random_buffer( unsigned char *out, int len, BOOL do_reseed_now)
+void generate_random_buffer( uint8_t *out, int len, BOOL do_reseed_now)
{
static BOOL done_reseed = False;
static int urand_fd = -1;
- unsigned char md4_buf[64];
- unsigned char tmp_buf[16];
- unsigned char *p;
+ uint8_t md4_buf[64];
+ uint8_t tmp_buf[16];
+ uint8_t *p;
if(!done_reseed || do_reseed_now) {
urand_fd = do_reseed(True, urand_fd);
char **outbuf, size_t *outbytesleft)
{
while (*inbytesleft >= 1 && *outbytesleft >= 2) {
- const unsigned char *c = (const unsigned char *)*inbuf;
- unsigned char *uc = (unsigned char *)*outbuf;
+ const uint8_t *c = (const uint8_t *)*inbuf;
+ uint8_t *uc = (uint8_t *)*outbuf;
int len = 1;
if ((c[0] & 0x80) == 0) {
char **outbuf, size_t *outbytesleft)
{
while (*inbytesleft >= 2 && *outbytesleft >= 1) {
- unsigned char *c = (unsigned char *)*outbuf;
- const unsigned char *uc = (const unsigned char *)*inbuf;
+ uint8_t *c = (uint8_t *)*outbuf;
+ const uint8_t *uc = (const uint8_t *)*inbuf;
int len=1;
if (uc[1] & 0xf8) {
{
const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int bit_offset, byte_offset, idx, i, n;
- unsigned char *d = (unsigned char *)s;
+ uint8_t *d = (uint8_t *)s;
char *p;
n=i=0;
{
const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int bit_offset, byte_offset, idx, i;
- const unsigned char *d = (const unsigned char *)buf;
+ const uint8_t *d = (const uint8_t *)buf;
int bytes = (len*8 + 5)/6;
char *out;
int ldb_should_b64_encode(const struct ldb_val *val)
{
int i;
- unsigned char *p = val->data;
+ uint8_t *p = val->data;
if (val->length == 0 || p[0] == ' ' || p[0] == ':') {
return 1;
#define LTDB_PACKING_FORMAT_NODN 0x26011966
/* use a portable integer format */
-static void put_uint32(unsigned char *p, int ofs, unsigned int val)
+static void put_uint32(uint8_t *p, int ofs, unsigned int val)
{
p += ofs;
p[0] = val&0xFF;
p[3] = (val>>24) & 0xFF;
}
-static unsigned int pull_uint32(unsigned char *p, int ofs)
+static unsigned int pull_uint32(uint8_t *p, int ofs)
{
p += ofs;
return p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24);
asciip = ret;
for (i=0; i<reg_val_size(v); i++) {
int str_rem = reg_val_size(v) * 3 - (asciip - ret);
- asciip += snprintf(asciip, str_rem, "%02x", *(unsigned char *)(reg_val_data_blk(v)+i));
+ asciip += snprintf(asciip, str_rem, "%02x", *(uint8_t *)(reg_val_data_blk(v)+i));
if (i < reg_val_size(v) && str_rem > 0)
*asciip = ' '; asciip++;
}
/*
* Store a SID at the location provided
*/
-static int nt_store_SID(REG_HANDLE *regf, DOM_SID *sid, unsigned char *locn)
+static int nt_store_SID(REG_HANDLE *regf, DOM_SID *sid, uint8_t *locn)
{
int i;
- unsigned char *p = locn;
+ uint8_t *p = locn;
if (!regf || !sid || !locn) return 0;
}
-static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, unsigned char *locn)
+static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, uint8_t *locn)
{
int size = 0;
SEC_ACE *reg_ace = (SEC_ACE *)locn;
- unsigned char *p;
+ uint8_t *p;
if (!regf || !ace || !locn) return 0;
/* Deal with the length when we have stored the SID */
- p = (unsigned char *)®_ace->info.mask;
+ p = (uint8_t *)®_ace->info.mask;
SIVAL(p, 0, ace->info.mask); p += 4;
size += 8; /* Size of the fixed header */
- p = (unsigned char *)®_ace->size;
+ p = (uint8_t *)®_ace->size;
SSVAL(p, 0, size);
/*
* Store an ACL at the location provided
*/
-static int nt_store_acl(REG_HANDLE *regf, SEC_ACL *acl, unsigned char *locn) {
+static int nt_store_acl(REG_HANDLE *regf, SEC_ACL *acl, uint8_t *locn) {
int size = 0, i;
- unsigned char *p = locn, *s;
+ uint8_t *p = locn, *s;
if (!regf || !acl || !locn) return 0;
{
struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE));
int i = 0, rc;
- unsigned char ch;
+ uint8_t ch;
cl->len = INIT_ALLOC;
* Sec Desc print functions
*/
-char *str_type(unsigned char type);
+char *str_type(uint8_t type);
static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name)
{
#ifdef REPLACE_INET_NTOA
char *rep_inet_ntoa(struct in_addr ip)
{
- unsigned char *p = (unsigned char *)&ip.s_addr;
+ uint8_t *p = (uint8_t *)&ip.s_addr;
static char buf[18];
slprintf(buf, 17, "%d.%d.%d.%d",
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
}
break;
case DP_S_MIN:
- if (isdigit((unsigned char)ch)) {
+ if (isdigit((uint8_t)ch)) {
min = 10*min + char_to_int (ch);
ch = *format++;
} else if (ch == '*') {
}
break;
case DP_S_MAX:
- if (isdigit((unsigned char)ch)) {
+ if (isdigit((uint8_t)ch)) {
if (max < 0)
max = 0;
max = 10*max + char_to_int (ch);
TDB_CONTEXT *tdb;
struct stat st;
int rev = 0, locked = 0;
- unsigned char *vp;
+ uint8_t *vp;
u32 vertest;
if (!(tdb = calloc(1, sizeof *tdb))) {
}
rev = (tdb->flags & TDB_CONVERT);
}
- vp = (unsigned char *)&tdb->header.version;
+ vp = (uint8_t *)&tdb->header.version;
vertest = (((u32)vp[0]) << 24) | (((u32)vp[1]) << 16) |
(((u32)vp[2]) << 8) | (u32)vp[3];
tdb->flags |= (vertest==TDB_VERSION) ? TDB_BIGENDIAN : 0;
static void print_data(TDB_DATA d)
{
- unsigned char *p = d.dptr;
+ uint8_t *p = d.dptr;
int len = d.dsize;
while (len--) {
if (isprint(*p) && !strchr("\"\\", *p)) {
static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state);
-static void print_asc(unsigned char *buf,int len)
+static void print_asc(uint8_t *buf,int len)
{
int i;
printf("%c",isprint(buf[i])?buf[i]:'.');
}
-static void print_data(unsigned char *buf,int len)
+static void print_data(uint8_t *buf,int len)
{
int i=0;
if (len<=0) return;
}
-void print_asc(int level, const unsigned char *buf,int len)
+void print_asc(int level, const uint8_t *buf,int len)
{
int i;
for (i=0;i<len;i++)
void dump_data(int level, const char *buf1,int len)
{
- const unsigned char *buf = (const unsigned char *)buf1;
+ const uint8_t *buf = (const uint8_t *)buf1;
int i=0;
if (len<=0) return;
{
/* Static buffers we will return. */
FILE *fp = (FILE *)vp;
- unsigned char c;
- unsigned char *p;
+ uint8_t c;
+ uint8_t *p;
size_t linebuf_len;
if (fp == NULL)
continue;
}
- p = (unsigned char *) strchr_m(linebuf, ':');
+ p = (uint8_t *) strchr_m(linebuf, ':');
if (p == NULL)
{
DEBUG(0, ("getfileline: malformed line entry (no :)\n"));
****************************************************************************/
BOOL send_nbt_keepalive(int sock_fd)
{
- unsigned char buf[4];
+ uint8_t buf[4];
buf[0] = SMBkeepalive;
buf[1] = buf[2] = buf[3] = 0;
supported multi-byte character sets are ascii-compatible
(ie. they match for the first 128 chars) */
- while (*s && !(((unsigned char)s[0]) & 0x7F)) {
- *s = tolower((unsigned char)*s);
+ while (*s && !(((uint8_t)s[0]) & 0x7F)) {
+ *s = tolower((uint8_t)*s);
s++;
}
supported multi-byte character sets are ascii-compatible
(ie. they match for the first 128 chars) */
- while (*s && !(((unsigned char)s[0]) & 0x7F)) {
- *s = toupper((unsigned char)*s);
+ while (*s && !(((uint8_t)s[0]) & 0x7F)) {
+ *s = toupper((uint8_t)*s);
s++;
}
return 0;
}
- while (*s && !(((unsigned char)s[0]) & 0x7F)) {
+ while (*s && !(((uint8_t)s[0]) & 0x7F)) {
s++;
count++;
}
return NULL;
for (j=i=0;i<len;i++) {
s[j] = '\\';
- s[j+1] = hex[((unsigned char)buf[i]) >> 4];
- s[j+2] = hex[((unsigned char)buf[i]) & 0xF];
+ s[j+1] = hex[((uint8_t)buf[i]) >> 4];
+ s[j+2] = hex[((uint8_t)buf[i]) & 0xF];
j += 3;
}
s[j] = 0;
{
size_t i;
size_t num_chars = 0;
- unsigned char lonybble, hinybble;
+ uint8_t lonybble, hinybble;
const char *hexchars = "0123456789ABCDEF";
char *p1 = NULL, *p2 = NULL;
{
int bit_offset, byte_offset, idx, i, n;
DATA_BLOB decoded = data_blob(s, strlen(s)+1);
- unsigned char *d = decoded.data;
+ uint8_t *d = decoded.data;
char *p;
n=i=0;
char *result = malloc(output_len); /* get us plenty of space */
while (len-- && out_cnt < (data.length * 2) - 5) {
- int c = (unsigned char) *(data.data++);
+ int c = (uint8_t) *(data.data++);
bits += c;
char_count++;
if (char_count == 3) {
return EOF;
}
- ret = *(unsigned char *)(f->next);
+ ret = *(uint8_t *)(f->next);
f->next++;
f->bufused--;
return ret;
for (i=0; values[i]; i++) {
printf("%s: ", field);
for (j=0; j<values[i]->bv_len; j++) {
- printf("%02X", (unsigned char)values[i]->bv_val[j]);
+ printf("%02X", (uint8_t)values[i]->bv_val[j]);
}
printf("\n");
}
DATA_BLOB *user_sess_key,
DATA_BLOB *lm_sess_key)
{
- static const unsigned char zeros[8];
+ static const uint8_t zeros[8];
if (nt_pw == NULL) {
DEBUG(3,("ntlm_password_check: NO NT password stored for user %s.\n",
username));
DEBUG(4,("ntlm_password_check: checking plaintext passwords for user %s\n",
username));
if (nt_pw && nt_response->length) {
- unsigned char pwhash[16];
+ uint8_t pwhash[16];
mdfour(pwhash, nt_response->data, nt_response->length);
if (memcmp(pwhash, nt_pw, sizeof(pwhash)) == 0) {
return NT_STATUS_OK;
/* Only the fisrt 14 chars are considered, password need not be null terminated. */
/* we *might* need to upper-case the string here */
- E_P16((const unsigned char *)dospwd, p16);
+ E_P16((const uint8_t *)dospwd, p16);
if (memcmp(p16, lm_pw, sizeof(p16)) == 0) {
return NT_STATUS_OK;
char recv_sign_key[16];
char recv_seal_key[16];
- unsigned char send_sign_hash[258];
- unsigned char send_seal_hash[258];
- unsigned char recv_sign_hash[258];
- unsigned char recv_seal_hash[258];
+ uint8_t send_sign_hash[258];
+ uint8_t send_seal_hash[258];
+ uint8_t recv_sign_hash[258];
+ uint8_t recv_seal_hash[258];
/* ntlmv1 */
- unsigned char ntlmssp_hash[258];
+ uint8_t ntlmssp_hash[258];
/* it turns out that we don't always get the
response in at the time we want to process it.
#define SRV_SIGN "session key to server-to-client signing key magic constant"
#define SRV_SEAL "session key to server-to-client sealing key magic constant"
-static void NTLMSSPcalc_ap( unsigned char *hash, unsigned char *data, int len)
+static void NTLMSSPcalc_ap( uint8_t *hash, uint8_t *data, int len)
{
- unsigned char index_i = hash[256];
- unsigned char index_j = hash[257];
+ uint8_t index_i = hash[256];
+ uint8_t index_j = hash[257];
int ind;
for (ind = 0; ind < len; ind++)
{
- unsigned char tc;
- unsigned char t;
+ uint8_t tc;
+ uint8_t t;
index_i++;
index_j += hash[index_i];
hash[257] = index_j;
}
-static void calc_hash(unsigned char hash[258], const char *key, size_t key_len)
+static void calc_hash(uint8_t hash[258], const char *key, size_t key_len)
{
- unsigned char j = 0;
+ uint8_t j = 0;
int ind;
for (ind = 0; ind < 256; ind++)
{
- hash[ind] = (unsigned char)ind;
+ hash[ind] = (uint8_t)ind;
}
for (ind = 0; ind < 256; ind++)
{
- unsigned char tc;
+ uint8_t tc;
j += (hash[ind] + key[ind%key_len]);
-static void calc_ntlmv2_hash(unsigned char hash[258], unsigned char subkey[16],
+static void calc_ntlmv2_hash(uint8_t hash[258], uint8_t subkey[16],
DATA_BLOB session_key,
const char *constant)
{
*/
NTSTATUS ntlmssp_sign_init(NTLMSSP_STATE *ntlmssp_state)
{
- unsigned char p24[24];
+ uint8_t p24[24];
ZERO_STRUCT(p24);
DEBUG(3, ("NTLMSSP Sign/Seal - Initialising with flags:\n"));
****************************************************************************/
NTSTATUS cli_locktype(struct cli_tree *tree, int fnum,
uint32_t offset, uint32_t len, int timeout,
- unsigned char locktype)
+ uint8_t locktype)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
************************************************************/
static void cli_request_simple_sign_outgoing_message(struct cli_request *req)
{
- unsigned char calc_md5_mac[16];
+ uint8_t calc_md5_mac[16];
struct MD5Context md5_ctx;
struct smb_basic_signing_context *data = req->transport->negotiate.sign_info.signing_context;
static BOOL cli_request_simple_check_incoming_message(struct cli_request *req)
{
BOOL good;
- unsigned char calc_md5_mac[16];
- unsigned char server_sent_mac[8];
- unsigned char sequence_buf[8];
+ uint8_t calc_md5_mac[16];
+ uint8_t server_sent_mac[8];
+ uint8_t sequence_buf[8];
struct MD5Context md5_ctx;
struct smb_basic_signing_context *data = req->transport->negotiate.sign_info.signing_context;
const size_t offset_end_of_sig = (HDR_SS_FIELD + 8);
permute(out, rl, perm6, 64);
}
-static void str_to_key(const unsigned char *str,unsigned char *key)
+static void str_to_key(const uint8_t *str,uint8_t *key)
{
int i;
}
-void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw)
+void smbhash(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw)
{
int i;
char outb[64];
char inb[64];
char keyb[64];
- unsigned char key2[8];
+ uint8_t key2[8];
str_to_key(key, key2);
}
}
-void E_P16(const unsigned char *p14,unsigned char *p16)
+void E_P16(const uint8_t *p14,uint8_t *p16)
{
unsigned const char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
smbhash(p16, sp8, p14, 1);
smbhash(p16+8, sp8, p14+7, 1);
}
-void E_P24(const unsigned char *p21, const unsigned char *c8, unsigned char *p24)
+void E_P24(const uint8_t *p21, const uint8_t *c8, uint8_t *p24)
{
smbhash(p24, c8, p21, 1);
smbhash(p24+8, c8, p21+7, 1);
smbhash(p24+16, c8, p21+14, 1);
}
-void D_P16(const unsigned char *p14, const unsigned char *in, unsigned char *out)
+void D_P16(const uint8_t *p14, const uint8_t *in, uint8_t *out)
{
smbhash(out, in, p14, 0);
smbhash(out+8, in+8, p14+7, 0);
}
-void E_old_pw_hash( unsigned char *p14, const unsigned char *in, unsigned char *out)
+void E_old_pw_hash( uint8_t *p14, const uint8_t *in, uint8_t *out)
{
smbhash(out, in, p14, 1);
smbhash(out+8, in+8, p14+7, 1);
}
-void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char *key)
+void cred_hash1(uint8_t *out, const uint8_t *in, const uint8_t *key)
{
- unsigned char buf[8];
+ uint8_t buf[8];
smbhash(buf, in, key, 1);
smbhash(out, buf, key+9, 1);
}
-void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw)
+void cred_hash2(uint8_t *out, const uint8_t *in, const uint8_t *key, int forw)
{
- unsigned char buf[8];
- unsigned char key2[8];
+ uint8_t buf[8];
+ uint8_t key2[8];
ZERO_STRUCT(key2);
smbhash(buf, in, key, forw);
key2[0] = key[7];
smbhash(out, buf, key2, forw);
}
-void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw)
+void cred_hash3(uint8_t *out, uint8_t *in, const uint8_t *key, int forw)
{
- unsigned char key2[8];
+ uint8_t key2[8];
ZERO_STRUCT(key2);
smbhash(out, in, key, forw);
key2[0] = key[7];
}
-void SamOEMhashBlob(unsigned char *data, int len, const DATA_BLOB *key)
+void SamOEMhashBlob(uint8_t *data, int len, const DATA_BLOB *key)
{
- unsigned char s_box[256];
- unsigned char index_i = 0;
- unsigned char index_j = 0;
- unsigned char j = 0;
+ uint8_t s_box[256];
+ uint8_t index_i = 0;
+ uint8_t index_j = 0;
+ uint8_t j = 0;
int ind;
for (ind = 0; ind < 256; ind++) {
- s_box[ind] = (unsigned char)ind;
+ s_box[ind] = (uint8_t)ind;
}
for (ind = 0; ind < 256; ind++) {
- unsigned char tc;
+ uint8_t tc;
j += (s_box[ind] + key->data[ind%key->length]);
s_box[j] = tc;
}
for (ind = 0; ind < len; ind++) {
- unsigned char tc;
- unsigned char t;
+ uint8_t tc;
+ uint8_t t;
index_i++;
index_j += s_box[index_i];
a varient that assumes a 16 byte key. This should be removed
when the last user is gone
*/
-void SamOEMhash(unsigned char *data, const unsigned char keystr[16], int len)
+void SamOEMhash(uint8_t *data, const uint8_t keystr[16], int len)
{
DATA_BLOB key = data_blob(keystr, 16);
/* Calculate length in bytes */
len = strlen_w(wpwd) * sizeof(int16_t);
- mdfour(p16, (unsigned char *)wpwd, len);
+ mdfour(p16, (uint8_t *)wpwd, len);
ZERO_STRUCT(wpwd);
}
push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE);
/* Only the fisrt 14 chars are considered, password need not be null terminated. */
- E_P16((const unsigned char *)dospwd, p16);
+ E_P16((const uint8_t *)dospwd, p16);
if (strlen(dospwd) > 14) {
ret = False;
domain_byte_len = domain_byte_len - 2;
hmac_md5_init_limK_to_64(owf, 16, &ctx);
- hmac_md5_update((const unsigned char *)user, user_byte_len, &ctx);
- hmac_md5_update((const unsigned char *)domain, domain_byte_len, &ctx);
+ hmac_md5_update((const uint8_t *)user, user_byte_len, &ctx);
+ hmac_md5_update((const uint8_t *)domain, domain_byte_len, &ctx);
hmac_md5_final(kr_buf, &ctx);
#ifdef DEBUG_PASSWORD
hmac_md5_init_limK_to_64(kr, 16, &ctx);
hmac_md5_update(nt_resp, 16, &ctx);
- hmac_md5_final((unsigned char *)sess_key, &ctx);
+ hmac_md5_final((uint8_t *)sess_key, &ctx);
#ifdef DEBUG_PASSWORD
DEBUG(100, ("SMBsesskeygen_ntv2:\n"));
/* yes, this session key does not change - yes, this
is a problem - but it is 128 bits */
- mdfour((unsigned char *)sess_key, kr, 16);
+ mdfour((uint8_t *)sess_key, kr, 16);
#ifdef DEBUG_PASSWORD
DEBUG(100, ("SMBsesskeygen_ntv1:\n"));
memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len);
- generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, False);
+ generate_random_buffer((uint8_t *)buffer, 512 - new_pw_len, False);
/*
* The length of the new password is in the last 4 bytes of
static void calc_signature(uint8_t *buffer, size_t length,
DATA_BLOB *mac_key, uint8_t signature[8])
{
- unsigned char calc_md5_mac[16];
+ uint8_t calc_md5_mac[16];
struct MD5Context md5_ctx;
MD5Init(&md5_ctx);
*/
BOOL req_signing_check_incoming(struct request_context *req)
{
- unsigned char client_md5_mac[8], signature[8];
+ uint8_t client_md5_mac[8], signature[8];
switch (req->smb->signing.signing_state) {
case SMB_SIGNING_OFF:
static struct {
int fnum;
- unsigned char level;
+ uint8_t level;
int count;
} break_info;
}
for (i=0;i<len;i++) {
- unsigned char *v = (unsigned char *)data_out;
+ uint8_t *v = (uint8_t *)data_out;
if (v[i] != (i & 0xFF)) {
- printf("bad data 0x%x at %d\n", (unsigned char)data_out[i], i);
+ printf("bad data 0x%x at %d\n", (uint8_t)data_out[i], i);
return False;
}
}
SMBNTencrypt(samlogon_state->password, samlogon_state->chall.data,
nt_response.data);
- E_md4hash(samlogon_state->password, (unsigned char *)nt_hash);
- SMBsesskeygen_ntv1((const unsigned char *)nt_hash,
+ E_md4hash(samlogon_state->password, (uint8_t *)nt_hash);
+ SMBsesskeygen_ntv1((const uint8_t *)nt_hash,
session_key.data);
- E_deshash(samlogon_state->password, (unsigned char *)lm_hash);
+ E_deshash(samlogon_state->password, (uint8_t *)lm_hash);
nt_status = check_samlogon(samlogon_state,
BREAK_NONE,
return False;
}
- generate_random_buffer((unsigned char *)confounder, 16, False);
+ generate_random_buffer((uint8_t *)confounder, 16, False);
MD5Init(&ctx);
MD5Update(&ctx, confounder, 16);
return False;
}
- generate_random_buffer((unsigned char *)confounder, 16, False);
+ generate_random_buffer((uint8_t *)confounder, 16, False);
MD5Init(&ctx);
MD5Update(&ctx, confounder, 16);
ZERO_STRUCTP(ret);
do {
- unsigned len = (unsigned char)*p;
+ unsigned len = (uint8_t)*p;
p++;
if (len > 0 && len != 0xc0) {
int argc, const char **argv) {
fstring trust_passwd;
- unsigned char orig_trust_passwd_hash[16];
+ uint8_t orig_trust_passwd_hash[16];
NTSTATUS result;
fstrcpy(trust_passwd, lp_netbios_name());
/****************************************************************************
turn a node status flags field into a string
****************************************************************************/
-static char *node_status_flags(unsigned char flags)
+static char *node_status_flags(uint8_t flags)
{
static fstring ret;
fstrcpy(ret,"");
static const char *hex_challenge;
static const char *hex_lm_response;
static const char *hex_nt_response;
-static unsigned char *challenge;
+static uint8_t *challenge;
static size_t challenge_len;
-static unsigned char *lm_response;
+static uint8_t *lm_response;
static size_t lm_response_len;
-static unsigned char *nt_response;
+static uint8_t *nt_response;
static size_t nt_response_len;
static char *password;
Routine to set hex password characters into an allocated array.
**************************************************************/
-static void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer)
+static void hex_encode(const uint8_t *buff_in, size_t len, char **out_hex_buffer)
{
int i;
char *hex_buffer;
into a 16 byte array.
**************************************************************/
-static BOOL hex_decode(const char *hex_buf_in, unsigned char **out_buffer, size_t *size)
+static BOOL hex_decode(const char *hex_buf_in, uint8_t **out_buffer, size_t *size)
{
int i;
size_t hex_buf_in_len = strlen(hex_buf_in);
- unsigned char partial_byte_hex;
- unsigned char partial_byte;
+ uint8_t partial_byte_hex;
+ uint8_t partial_byte;
const char *hexchars = "0123456789ABCDEF";
char *p;
BOOL high = True;