return ParseExpr($e, $dlen, "r->");
}
-sub ParseCompressionPushStart($$$)
+sub ParseCompressionPushStart($$)
{
my $e = shift;
my $subndr = shift;
- my $ndr_flags = shift;
my $comndr = $subndr."_compressed";
pidl "{";
pidl "}";
}
-sub ParseCompressionPullStart($$$)
+sub ParseCompressionPullStart($$)
{
my $e = shift;
my $subndr = shift;
- my $ndr_flags = shift;
my $comndr = $subndr."_compressed";
my $alg = compression_alg($e);
my $dlen = compression_dlen($e);
pidl "}";
}
+sub ParseObfuscationPushStart($$)
+{
+ my $e = shift;
+ my $ndr = shift;
+
+ # nothing to do here
+
+ return $ndr;
+}
+
+sub ParseObfuscationPushEnd($$)
+{
+ my $e = shift;
+ my $ndr = shift;
+ my $obfuscation = util::has_property($e, "obfuscation");
+
+ pidl "NDR_CHECK(ndr_push_obfuscation($ndr, $obfuscation));";
+}
+
+sub ParseObfuscationPullStart($$)
+{
+ my $e = shift;
+ my $ndr = shift;
+ my $obfuscation = util::has_property($e, "obfuscation");
+
+ pidl "NDR_CHECK(ndr_pull_obfuscation($ndr, $obfuscation));";
+
+ return $ndr;
+}
+
+sub ParseObfuscationPullEnd($$)
+{
+ my $e = shift;
+ my $ndr = shift;
+
+ # nothing to do here
+}
+
sub ParseSubcontextPushStart($$)
{
my $e = shift;
my $ndr_flags = shift;
my $compression = util::has_property($e, "compression");
- my $retndr;
+ my $obfuscation = util::has_property($e, "obfuscation");
+ my $retndr = "_ndr_$e->{NAME}";
pidl "if (($ndr_flags) & NDR_SCALARS) {";
indent;
- pidl "struct ndr_push *_ndr_$e->{NAME};";
+ pidl "struct ndr_push *$retndr;";
pidl "";
- pidl "_ndr_$e->{NAME} = ndr_push_init_ctx(ndr);";
- pidl "if (!_ndr_$e->{NAME}) return NT_STATUS_NO_MEMORY;";
- pidl "_ndr_$e->{NAME}->flags = ndr->flags;";
+ pidl "$retndr = ndr_push_init_ctx(ndr);";
+ pidl "if (!$retndr) return NT_STATUS_NO_MEMORY;";
+ pidl "$retndr->flags = ndr->flags;";
pidl "";
-
- $retndr = "_ndr_$e->{NAME}";
if (defined $compression) {
- $retndr = ParseCompressionPushStart($e, $retndr, "NDR_SCALARS");
+ $retndr = ParseCompressionPushStart($e, $retndr);
}
-
+
+ if (defined $obfuscation) {
+ $retndr = ParseObfuscationPushStart($e, $retndr);
+ }
+
return $retndr
}
my $header_size = util::has_property($e, "subcontext");
my $size_is = util::has_property($e, "subcontext_size");
my $compression = util::has_property($e, "compression");
+ my $obfuscation = util::has_property($e, "obfuscation");
my $ndr = "_ndr_$e->{NAME}";
+ if (defined $obfuscation) {
+ ParseObfuscationPushEnd($e, $ndr);
+ }
+
if (defined $compression) {
ParseCompressionPushEnd($e, $ndr);
}
sub ParseSubcontextPullStart($$)
{
my $e = shift;
- my $ndr_flags = shift;
+ my $ndr_flags = shift;
my $header_size = util::has_property($e, "subcontext");
my $size_is = util::has_property($e, "subcontext_size");
- my $retndr = "_ndr_$e->{NAME}";
my $compression = util::has_property($e, "compression");
+ my $obfuscation = util::has_property($e, "obfuscation");
+ my $retndr = "_ndr_$e->{NAME}";
if (not defined($size_is)) {
$size_is = "-1";
indent;
pidl "struct ndr_pull *$retndr;";
pidl "NDR_ALLOC(ndr, $retndr);";
- pidl "NDR_CHECK(ndr_pull_subcontext_header(ndr, $header_size, $size_is, $retndr));";
+ pidl "NDR_CHECK(ndr_pull_subcontext_header(ndr, $header_size, $size_is, $retndr));";
if (defined $compression) {
- $retndr = ParseCompressionPullStart($e, $retndr, $ndr_flags);
+ $retndr = ParseCompressionPullStart($e, $retndr);
+ }
+
+ if (defined $obfuscation) {
+ $retndr = ParseObfuscationPullStart($e, $retndr);
}
return $retndr;
my $e = shift;
my $header_size = util::has_property($e, "subcontext");
my $size_is = util::has_property($e, "subcontext_size");
- my $subndr = "_ndr_$e->{NAME}";
my $compression = util::has_property($e, "compression");
+ my $obfuscation = util::has_property($e, "obfuscation");
+ my $ndr = "_ndr_$e->{NAME}";
+
+ if (defined $obfuscation) {
+ ParseObfuscationPullEnd($e, $ndr);
+ }
if (defined $compression) {
- ParseCompressionPullEnd($e, $subndr);
+ ParseCompressionPullEnd($e, $ndr);
}
my $advance;
if (defined ($size_is)) {
- $advance = "$size_is";
+ $advance = "$size_is";
} elsif ($header_size) {
- $advance = "$subndr->data_size";
+ $advance = "$ndr->data_size";
} else {
- $advance = "$subndr->offset";
+ $advance = "$ndr->offset";
}
pidl "NDR_CHECK(ndr_pull_advance(ndr, $advance));";
deindent;
--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+
+ libndr obfuscate support (MAPI)
+
+ Copyright (C) Stefan Metzmacher 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/*
+ handle obfuscated subcontext buffers, which in midl land are user-marshalled, but
+ we use magic in pidl to make them easier to cope with
+*/
+NTSTATUS ndr_pull_obfuscation(struct ndr_pull *ndr, uint8_t salt)
+{
+ uint32_t i;
+
+ for (i=0; i<ndr->data_size; i++) {
+ ndr->data[i] ^= salt;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/*
+ push a obfuscated subcontext
+*/
+NTSTATUS ndr_push_obfuscation(struct ndr_push *ndr, uint8_t salt)
+{
+ uint32_t i;
+
+ for (i=0; i<ndr->offset; i++) {
+ ndr->data[i] ^= salt;
+ }
+
+ return NT_STATUS_OK;
+}