summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-06-18 13:27:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:44 -0500
commitd46b9aa96fa97be03e76dde29bf07fc273a0efd0 (patch)
tree4fe4ebb52e71559efbeb747111d465534b3b2967 /source4/torture
parent4e4c3d4bea5549eece6db05ac9f26344f3c476f7 (diff)
downloadsamba-d46b9aa96fa97be03e76dde29bf07fc273a0efd0.tar.gz
samba-d46b9aa96fa97be03e76dde29bf07fc273a0efd0.tar.bz2
samba-d46b9aa96fa97be03e76dde29bf07fc273a0efd0.zip
r1189: Now that we use a common 'base' return structure for the SamLogon
call, avoid code duplication in the torture suite. Andrew Bartlett (This used to be commit b6128c2a9d8e23dad0b14106f45a0638655d6cd7)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/netlogon.c62
1 files changed, 25 insertions, 37 deletions
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c
index a7012922dc..427701d2c9 100644
--- a/source4/torture/rpc/netlogon.c
+++ b/source4/torture/rpc/netlogon.c
@@ -300,6 +300,8 @@ static NTSTATUS check_samlogon(struct samlogon_state *samlogon_state,
struct netr_NetworkInfo ninfo;
for (i=0;i<ARRAY_SIZE(levels);i++) {
+ struct netr_SamBaseInfo *base;
+
printf("testing netr_LogonSamLogon with logon level %d\n", levels[i]);
samlogon_state->r.in.logon_level = levels[i];
@@ -374,60 +376,46 @@ static NTSTATUS check_samlogon(struct samlogon_state *samlogon_state,
/* find and decyrpt the session keys, return in parameters above */
if (r->in.validation_level == 2) {
+ base = &r->out.validation.sam2->base;
+ } else if (r->in.validation_level == 3) {
+ base = &r->out.validation.sam3->base;
+ } else if (r->in.validation_level == 6) {
+ base = &r->out.validation.sam6->base;
+ } else {
+ base = NULL;
+ }
+
+ if (r->in.validation_level != 6) {
static const char zeros[16];
- if (memcmp(r->out.validation.sam2->base.key.key, zeros,
- sizeof(r->out.validation.sam2->base.key.key)) != 0) {
+ if (memcmp(base->key.key, zeros,
+ sizeof(base->key.key)) != 0) {
creds_arcfour_crypt(&samlogon_state->creds,
- r->out.validation.sam2->base.key.key,
- sizeof(r->out.validation.sam2->base.key.key));
+ base->key.key,
+ sizeof(base->key.key));
}
if (user_session_key) {
- memcpy(user_session_key, r->out.validation.sam2->base.key.key, 16);
+ memcpy(user_session_key, base->key.key, 16);
}
- if (memcmp(r->out.validation.sam2->base.LMSessKey.key, zeros,
- sizeof(r->out.validation.sam2->base.LMSessKey.key)) != 0) {
+ if (memcmp(base->LMSessKey.key, zeros,
+ sizeof(base->LMSessKey.key)) != 0) {
creds_arcfour_crypt(&samlogon_state->creds,
- r->out.validation.sam2->base.LMSessKey.key,
- sizeof(r->out.validation.sam2->base.LMSessKey.key));
+ base->LMSessKey.key,
+ sizeof(base->LMSessKey.key));
}
if (lm_key) {
- memcpy(lm_key, r->out.validation.sam2->base.LMSessKey.key, 8);
- }
-
- } else if (r->in.validation_level == 3) {
- static const char zeros[16];
- if (memcmp(r->out.validation.sam3->base.key.key, zeros,
- sizeof(r->out.validation.sam3->base.key.key)) != 0) {
- creds_arcfour_crypt(&samlogon_state->creds,
- r->out.validation.sam3->base.key.key,
- sizeof(r->out.validation.sam3->base.key.key));
+ memcpy(lm_key, base->LMSessKey.key, 8);
}
-
- if (user_session_key) {
- memcpy(user_session_key, r->out.validation.sam3->base.key.key, 16);
- }
-
- if (memcmp(r->out.validation.sam3->base.LMSessKey.key, zeros,
- sizeof(r->out.validation.sam3->base.LMSessKey.key)) != 0) {
- creds_arcfour_crypt(&samlogon_state->creds,
- r->out.validation.sam3->base.LMSessKey.key,
- sizeof(r->out.validation.sam3->base.LMSessKey.key));
- }
-
- if (lm_key) {
- memcpy(lm_key, r->out.validation.sam3->base.LMSessKey.key, 8);
- }
- } else if (r->in.validation_level == 6) {
+ } else {
/* they aren't encrypted! */
if (user_session_key) {
- memcpy(user_session_key, r->out.validation.sam6->base.key.key, 16);
+ memcpy(user_session_key, base->key.key, 16);
}
if (lm_key) {
- memcpy(lm_key, r->out.validation.sam6->base.LMSessKey.key, 8);
+ memcpy(lm_key, base->LMSessKey.key, 8);
}
}
}