Deleted Added
full compact
chap_ms.c (98243) chap_ms.c (134789)
1/*-
2 * Copyright (c) 1997 Gabor Kincses <gabor@acm.org>
3 * 1997 - 2001 Brian Somers <brian@Awfulhak.org>
4 * based on work by Eric Rosenquist
5 * Strata Software Limited.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 1997 Gabor Kincses <gabor@acm.org>
3 * 1997 - 2001 Brian Somers <brian@Awfulhak.org>
4 * based on work by Eric Rosenquist
5 * Strata Software Limited.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/usr.sbin/ppp/chap_ms.c 98243 2002-06-15 08:03:30Z brian $
29 * $FreeBSD: head/usr.sbin/ppp/chap_ms.c 134789 2004-09-05 01:46:52Z brian $
30 */
31
32#include <ctype.h>
33#ifdef __FreeBSD__
34#include <openssl/des.h>
35#include <sha.h>
36#else
37#include <sys/types.h>

--- 107 unchanged lines hidden (view full) ---

145{
146 MD4_CTX MD4context;
147
148 MD4Init(&MD4context);
149 MD4Update(&MD4context, hash, 16);
150 MD4Final(hashhash, &MD4context);
151}
152
30 */
31
32#include <ctype.h>
33#ifdef __FreeBSD__
34#include <openssl/des.h>
35#include <sha.h>
36#else
37#include <sys/types.h>

--- 107 unchanged lines hidden (view full) ---

145{
146 MD4_CTX MD4context;
147
148 MD4Init(&MD4context);
149 MD4Update(&MD4context, hash, 16);
150 MD4Final(hashhash, &MD4context);
151}
152
153void
153static void
154ChallengeHash(char *PeerChallenge, char *AuthenticatorChallenge,
154ChallengeHash(char *PeerChallenge, char *AuthenticatorChallenge,
155 char *UserName, int UserNameLen, char *Challenge)
155 char *UserName, char *Challenge)
156{
157 SHA_CTX Context;
158 char Digest[SHA_DIGEST_LENGTH];
159 char *Name;
160
161 Name = strrchr(UserName, '\\');
162 if(NULL == Name)
163 Name = UserName;

--- 7 unchanged lines hidden (view full) ---

171 SHA1_Update(&Context, Name, strlen(Name));
172
173 SHA1_Final(Digest, &Context);
174 memcpy(Challenge, Digest, 8);
175}
176
177void
178GenerateNTResponse(char *AuthenticatorChallenge, char *PeerChallenge,
156{
157 SHA_CTX Context;
158 char Digest[SHA_DIGEST_LENGTH];
159 char *Name;
160
161 Name = strrchr(UserName, '\\');
162 if(NULL == Name)
163 Name = UserName;

--- 7 unchanged lines hidden (view full) ---

171 SHA1_Update(&Context, Name, strlen(Name));
172
173 SHA1_Final(Digest, &Context);
174 memcpy(Challenge, Digest, 8);
175}
176
177void
178GenerateNTResponse(char *AuthenticatorChallenge, char *PeerChallenge,
179 char *UserName, int UserNameLen, char *Password,
179 char *UserName, char *Password,
180 int PasswordLen, char *Response)
181{
182 char Challenge[8];
183 char PasswordHash[16];
184
180 int PasswordLen, char *Response)
181{
182 char Challenge[8];
183 char PasswordHash[16];
184
185 ChallengeHash(PeerChallenge, AuthenticatorChallenge, UserName, UserNameLen,
186 Challenge);
185 ChallengeHash(PeerChallenge, AuthenticatorChallenge, UserName, Challenge);
187 NtPasswordHash(Password, PasswordLen, PasswordHash);
188 ChallengeResponse(Challenge, PasswordHash, Response);
189}
190
191#ifndef __FreeBSD__
192#define LENGTH 20
193static char *
194SHA1_End(SHA_CTX *ctx, char *buf)

--- 15 unchanged lines hidden (view full) ---

210 return buf;
211}
212#endif
213
214void
215GenerateAuthenticatorResponse(char *Password, int PasswordLen,
216 char *NTResponse, char *PeerChallenge,
217 char *AuthenticatorChallenge, char *UserName,
186 NtPasswordHash(Password, PasswordLen, PasswordHash);
187 ChallengeResponse(Challenge, PasswordHash, Response);
188}
189
190#ifndef __FreeBSD__
191#define LENGTH 20
192static char *
193SHA1_End(SHA_CTX *ctx, char *buf)

--- 15 unchanged lines hidden (view full) ---

209 return buf;
210}
211#endif
212
213void
214GenerateAuthenticatorResponse(char *Password, int PasswordLen,
215 char *NTResponse, char *PeerChallenge,
216 char *AuthenticatorChallenge, char *UserName,
218 int UserNameLen, char *AuthenticatorResponse)
217 char *AuthenticatorResponse)
219{
220 SHA_CTX Context;
221 char PasswordHash[16];
222 char PasswordHashHash[16];
223 char Challenge[8];
224 u_char Digest[SHA_DIGEST_LENGTH];
225 int i;
226

--- 22 unchanged lines hidden (view full) ---

249 */
250 HashNtPasswordHash(PasswordHash, PasswordHashHash);
251
252 SHA1_Init(&Context);
253 SHA1_Update(&Context, PasswordHashHash, 16);
254 SHA1_Update(&Context, NTResponse, 24);
255 SHA1_Update(&Context, Magic1, 39);
256 SHA1_Final(Digest, &Context);
218{
219 SHA_CTX Context;
220 char PasswordHash[16];
221 char PasswordHashHash[16];
222 char Challenge[8];
223 u_char Digest[SHA_DIGEST_LENGTH];
224 int i;
225

--- 22 unchanged lines hidden (view full) ---

248 */
249 HashNtPasswordHash(PasswordHash, PasswordHashHash);
250
251 SHA1_Init(&Context);
252 SHA1_Update(&Context, PasswordHashHash, 16);
253 SHA1_Update(&Context, NTResponse, 24);
254 SHA1_Update(&Context, Magic1, 39);
255 SHA1_Final(Digest, &Context);
257 ChallengeHash(PeerChallenge, AuthenticatorChallenge, UserName, UserNameLen,
258 Challenge);
256 ChallengeHash(PeerChallenge, AuthenticatorChallenge, UserName, Challenge);
259 SHA1_Init(&Context);
260 SHA1_Update(&Context, Digest, 20);
261 SHA1_Update(&Context, Challenge, 8);
262 SHA1_Update(&Context, Magic2, 41);
263
264 /*
265 * Encode the value of 'Digest' as "S=" followed by
266 * 40 ASCII hexadecimal digits and return it in

--- 151 unchanged lines hidden ---
257 SHA1_Init(&Context);
258 SHA1_Update(&Context, Digest, 20);
259 SHA1_Update(&Context, Challenge, 8);
260 SHA1_Update(&Context, Magic2, 41);
261
262 /*
263 * Encode the value of 'Digest' as "S=" followed by
264 * 40 ASCII hexadecimal digits and return it in

--- 151 unchanged lines hidden ---