2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Guenther Deschner 2008.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 /*******************************************************************
23 inits a samr_GroupInfoAll structure.
24 ********************************************************************/
26 void init_samr_group_info1(struct samr_GroupInfoAll *r,
30 const char *description)
32 DEBUG(5, ("init_samr_group_info1\n"));
34 init_lsa_String(&r->name, name);
35 r->attributes = attributes;
36 r->num_members = num_members;
37 init_lsa_String(&r->description, description);
40 /*******************************************************************
41 inits a lsa_String structure
42 ********************************************************************/
44 void init_samr_group_info2(struct lsa_String *r, const char *group_name)
46 DEBUG(5, ("init_samr_group_info2\n"));
48 init_lsa_String(r, group_name);
51 /*******************************************************************
52 inits a samr_GroupInfoAttributes structure.
53 ********************************************************************/
55 void init_samr_group_info3(struct samr_GroupInfoAttributes *r,
58 DEBUG(5, ("init_samr_group_info3\n"));
60 r->attributes = attributes;
63 /*******************************************************************
64 inits a lsa_String structure
65 ********************************************************************/
67 void init_samr_group_info4(struct lsa_String *r, const char *description)
69 DEBUG(5, ("init_samr_group_info4\n"));
71 init_lsa_String(r, description);
74 /*******************************************************************
75 inits a samr_GroupInfoAll structure.
76 ********************************************************************/
78 void init_samr_group_info5(struct samr_GroupInfoAll *r,
82 const char *description)
84 DEBUG(5, ("init_samr_group_info5\n"));
86 init_lsa_String(&r->name, name);
87 r->attributes = attributes;
88 r->num_members = num_members;
89 init_lsa_String(&r->description, description);
92 /*******************************************************************
93 inits a samr_AliasInfoAll structure.
94 ********************************************************************/
96 void init_samr_alias_info1(struct samr_AliasInfoAll *r,
99 const char *description)
101 DEBUG(5, ("init_samr_alias_info1\n"));
103 init_lsa_String(&r->name, name);
104 r->num_members = num_members;
105 init_lsa_String(&r->description, description);
108 /*******************************************************************
109 inits a lsa_String structure.
110 ********************************************************************/
112 void init_samr_alias_info3(struct lsa_String *r,
113 const char *description)
115 DEBUG(5, ("init_samr_alias_info3\n"));
117 init_lsa_String(r, description);
120 /*************************************************************************
121 inits a samr_CryptPasswordEx structure
122 *************************************************************************/
124 void init_samr_CryptPasswordEx(const char *pwd,
125 DATA_BLOB *session_key,
126 struct samr_CryptPasswordEx *pwd_buf)
128 /* samr_CryptPasswordEx */
131 struct MD5Context md5_ctx;
132 uint8_t confounder[16];
133 DATA_BLOB confounded_session_key = data_blob(NULL, 16);
135 encode_pw_buffer(pwbuf, pwd, STR_UNICODE);
137 generate_random_buffer((uint8_t *)confounder, 16);
140 MD5Update(&md5_ctx, confounder, 16);
141 MD5Update(&md5_ctx, session_key->data,
142 session_key->length);
143 MD5Final(confounded_session_key.data, &md5_ctx);
145 SamOEMhashBlob(pwbuf, 516, &confounded_session_key);
146 memcpy(&pwbuf[516], confounder, 16);
148 memcpy(pwd_buf->data, pwbuf, sizeof(pwbuf));
149 data_blob_free(&confounded_session_key);
152 /*************************************************************************
153 inits a samr_CryptPassword structure
154 *************************************************************************/
156 void init_samr_CryptPassword(const char *pwd,
157 DATA_BLOB *session_key,
158 struct samr_CryptPassword *pwd_buf)
160 /* samr_CryptPassword */
162 encode_pw_buffer(pwd_buf->data, pwd, STR_UNICODE);
163 SamOEMhashBlob(pwd_buf->data, 516, session_key);