add targetinfo and comerr error codes
This commit is contained in:
@@ -84,7 +84,7 @@ test_parse(void)
|
||||
flags = NTLM_NEG_UNICODE | NTLM_NEG_NTLM | NTLM_TARGET_DOMAIN;
|
||||
type2.flags = flags;
|
||||
|
||||
memset(type2.challange, 0x7f, sizeof(type2.challange));
|
||||
memset(type2.challenge, 0x7f, sizeof(type2.challenge));
|
||||
type2.targetname = rk_UNCONST(target);
|
||||
type2.targetinfo.data = NULL;
|
||||
type2.targetinfo.length = 0;
|
||||
@@ -118,7 +118,7 @@ test_parse(void)
|
||||
heim_ntlm_nt_key(password, &key);
|
||||
|
||||
heim_ntlm_calculate_ntlm1(key.data, key.length,
|
||||
type2.challange,
|
||||
type2.challenge,
|
||||
&type3.ntlm);
|
||||
free(key.data);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ test_parse(void)
|
||||
flags = NTLM_NEG_UNICODE | NTLM_NEG_NTLM | NTLM_TARGET_DOMAIN;
|
||||
type2.flags = flags;
|
||||
|
||||
memset(type2.challange, 0x7f, sizeof(type2.challange));
|
||||
memset(type2.challenge, 0x7f, sizeof(type2.challenge));
|
||||
type2.targetname = rk_UNCONST(target);
|
||||
type2.targetinfo.data = "\x00\x00";
|
||||
type2.targetinfo.length = 2;
|
||||
@@ -186,7 +186,7 @@ test_keys(void)
|
||||
*password = "test1234",
|
||||
*target = "TESTNT";
|
||||
const unsigned char
|
||||
serverchallange[8] = "\x67\x7f\x1c\x55\x7a\x5e\xe9\x6c";
|
||||
serverchallenge[8] = "\x67\x7f\x1c\x55\x7a\x5e\xe9\x6c";
|
||||
struct ntlm_buf infotarget, infotarget2, answer, key;
|
||||
unsigned char ntlmv2[16], ntlmv2_1[16];
|
||||
int ret;
|
||||
@@ -209,7 +209,7 @@ test_keys(void)
|
||||
key.length,
|
||||
username,
|
||||
target,
|
||||
serverchallange,
|
||||
serverchallenge,
|
||||
&infotarget,
|
||||
ntlmv2,
|
||||
&answer);
|
||||
@@ -221,7 +221,7 @@ test_keys(void)
|
||||
username,
|
||||
target,
|
||||
0,
|
||||
serverchallange,
|
||||
serverchallenge,
|
||||
&answer,
|
||||
&infotarget2,
|
||||
ntlmv2_1);
|
||||
@@ -261,7 +261,7 @@ test_ntlm2_session_resp(void)
|
||||
|
||||
const unsigned char client_nonce[8] =
|
||||
"\xff\xff\xff\x00\x11\x22\x33\x44";
|
||||
const unsigned char server_challange[8] =
|
||||
const unsigned char server_challenge[8] =
|
||||
"\x01\x23\x45\x67\x89\xab\xcd\xef";
|
||||
|
||||
const unsigned char ntlm_hash[16] =
|
||||
@@ -269,7 +269,7 @@ test_ntlm2_session_resp(void)
|
||||
"\x1d\x33\xb7\x48\x5a\x2e\xd8\x08";
|
||||
|
||||
ret = heim_ntlm_calculate_ntlm2_sess(client_nonce,
|
||||
server_challange,
|
||||
server_challenge,
|
||||
ntlm_hash,
|
||||
&lm,
|
||||
&ntlm);
|
||||
@@ -288,10 +288,45 @@ test_ntlm2_session_resp(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_targetinfo(void)
|
||||
{
|
||||
struct ntlm_targetinfo ti;
|
||||
struct ntlm_buf buf;
|
||||
const char *dnsservername = "dnsservername";
|
||||
int ret;
|
||||
|
||||
memset(&ti, 0, sizeof(ti));
|
||||
|
||||
ti.dnsservername = rk_UNCONST(dnsservername);
|
||||
ti.avflags = 1;
|
||||
ret = heim_ntlm_encode_targetinfo(&ti, 1, &buf);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
memset(&ti, 0, sizeof(ti));
|
||||
|
||||
ret = heim_ntlm_decode_targetinfo(&buf, 1, &ti);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ti.dnsservername == NULL ||
|
||||
strcmp(ti.dnsservername, dnsservername) != 0)
|
||||
errx(1, "ti.dnshostname != %s", dnsservername);
|
||||
if (ti.avflags != 1)
|
||||
errx(1, "ti.avflags != 1");
|
||||
|
||||
heim_ntlm_free_targetinfo(&ti);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int verbose_flag = 0;
|
||||
static int version_flag = 0;
|
||||
static int help_flag = 0;
|
||||
|
||||
static struct getargs args[] = {
|
||||
{"verbose", 0, arg_flag, &verbose_flag, "verbose printing", NULL },
|
||||
{"version", 0, arg_flag, &version_flag, "print version", NULL },
|
||||
{"help", 0, arg_flag, &help_flag, NULL, NULL }
|
||||
};
|
||||
@@ -325,12 +360,21 @@ main(int argc, char **argv)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
printf("test_parse\n");
|
||||
if (verbose_flag)
|
||||
printf("test_parse\n");
|
||||
|
||||
ret += test_parse();
|
||||
printf("test_keys\n");
|
||||
if (verbose_flag)
|
||||
printf("test_keys\n");
|
||||
|
||||
ret += test_keys();
|
||||
printf("test_ntlm2_session_resp\n");
|
||||
if (verbose_flag)
|
||||
printf("test_ntlm2_session_resp\n");
|
||||
ret += test_ntlm2_session_resp();
|
||||
|
||||
return 0;
|
||||
if (verbose_flag)
|
||||
printf("test_targetinfo\n");
|
||||
ret += test_targetinfo();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user