2 Unix SMB/Netbios implementation.
4 code to manipulate domain credentials
5 Copyright (C) Andrew Tridgell 1997
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /****************************************************************************
26 setup the session key.
27 Input: 8 byte challenge block
28 8 byte server challenge block
29 16 byte md4 encrypted password
32 ****************************************************************************/
33 void cred_session_key(char *challenge
, char *srv_challenge
, char *pass
,
40 sum
[0] = IVAL(challenge
, 0) + IVAL(srv_challenge
, 0);
41 sum
[1] = IVAL(challenge
, 4) + IVAL(srv_challenge
, 4);
47 E1(pass
+9,buf
,session_key
);
51 /****************************************************************************
56 8 byte stored credential
61 ****************************************************************************/
62 void cred_create(char *session_key
, char *stored_cred
, UTIME timestamp
,
69 memcpy(timecred
, stored_cred
, 8);
70 SIVAL(timecred
, 0, IVAL(stored_cred
, 0) + timestamp
.time
);
72 E1(session_key
, timecred
, buf
);
74 key2
[0] = session_key
[7];
79 /****************************************************************************
80 check a supplied credential
83 8 byte received credential
85 8 byte stored credential
89 returns 1 if computed credential matches received credential
91 ****************************************************************************/
92 int cred_assert(char *cred
, char *session_key
, char *stored_cred
,
97 cred_create(session_key
, stored_cred
, timestamp
, cred2
);
99 return memcmp(cred
, cred2
, 8) == 0;