r14542: Remove librpc, libndr and libnbt from includes.h
[samba.git] / source4 / librpc / ndr / ndr_obfuscate.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    libndr obfuscate support (MAPI)
5
6    Copyright (C) Stefan Metzmacher 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "librpc/ndr/libndr.h"
25
26 /*
27   handle obfuscated subcontext buffers, which in midl land are user-marshalled, but
28   we use magic in pidl to make them easier to cope with
29 */
30 NTSTATUS ndr_pull_obfuscation_start(struct ndr_pull *ndr, uint8_t salt)
31 {
32         uint32_t i;
33
34         for (i=0; i<ndr->data_size; i++) {
35                 ndr->data[i] ^= salt;
36         }
37
38         return NT_STATUS_OK;
39 }
40
41 NTSTATUS ndr_pull_obfuscation_end(struct ndr_pull *ndr, uint8_t salt)
42 {
43         return NT_STATUS_OK;
44 }
45
46 NTSTATUS ndr_push_obfuscation_start(struct ndr_push *ndr, uint8_t salt)
47 {
48         return NT_STATUS_OK;
49 }
50
51 /*
52   push a obfuscated subcontext
53 */
54 NTSTATUS ndr_push_obfuscation_end(struct ndr_push *ndr, uint8_t salt)
55 {
56         uint32_t i;
57
58         for (i=0; i<ndr->offset; i++) {
59                 ndr->data[i] ^= salt;
60         }
61
62         return NT_STATUS_OK;
63 }