Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
9.8 KiB

  1. /*****************************************************************/ /** Microsoft Windows 2000 **/ /** Copyright (C) Microsoft Corp., 1991-1998 **/ /*****************************************************************/ /*****************************************************************/ /** Microsoft Windows **/ /** Copyright (C) Microsoft Corp., 1991-1995 **/ /*****************************************************************/ /*****************************************************************/ /** Microsoft Windows for Workgroups **/ /** Copyright (C) Microsoft Corp., 1991-1992 **/ /*****************************************************************/ /********************************************************************/ /** Microsoft LAN Manager **/ /** Copyright(c) Microsoft Corp., 1987-1991 **/ /********************************************************************/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "USRPWST3.h" // --------------------------------------------------------------------------- // � EncryptStdBlock() // --------------------------------------------------------------------------- // Routine Description: // // Takes a block key encrypts the standard text block with it. // The resulting encrypted block is returned. // This is a One-Way-Function - the key cannot be recovered from the // encrypted data block. // // Arguments: // // BlockKey - The key to use to encrypt the standard text block. // // CypherBlock - The encrypted data is returned here // // Return Values: // // TRUE - The encryption was successful. // The result is in CypherBlock // // FALSE - Something failed. The CypherBlock is undefined. bool EncryptStdBlock( IN PBLOCK_KEY BlockKey, OUT PCYPHER_BLOCK CypherBlock ) { unsigned Result; char StdEncrPwd[] = "KGS!@#$%"; Result = DES_ECB_LM((DWORD)ENCR_KEY, (const char *)BlockKey, (unsigned char *)StdEncrPwd, (unsigned char *)CypherBlock ); if (Result == CRYPT_OK) { return(TRUE); } else { return(FALSE); } } // --------------------------------------------------------------------------- // � CalculateLmOwfPassword() // --------------------------------------------------------------------------- // Routine Description: // // Takes the passed LmPassword and performs a one-way-function on it. // The current implementation does this by using the password as a key // to encrypt a known block of text. // // Arguments: // // LmPassword - The password to perform the one-way-function on. // // LmOwfPassword - The hashed password is returned here // // Return Values: // // BOOL - The function was completed successfully. The hashed // password is in LmOwfPassword. // // FALSE - Something failed. The LmOwfPassword is undefined. bool CalculateLmOwfPassword( IN PLM_PASSWORD LmPassword, OUT PLM_OWF_PASSWORD LmOwfPassword ) { bool Status; BLOCK_KEY Key[2]; PCHAR pKey; // Copy the password into our key buffer and zero pad to fill the 2 keys pKey = (PCHAR)(&Key[0]); while (*LmPassword && (pKey < (PCHAR)(&Key[2]))) { *pKey++ = *LmPassword++; } while (pKey < (PCHAR)(&Key[2])) { *pKey++ = 0; } // Use the keys to encrypt the standard text Status = EncryptStdBlock(&Key[0], &(LmOwfPassword->data[0])); if (!Status) { return(Status); } //***************************************************** //BUGBUG: Alignment work-around needed for 68K, may not //work under PowerPC! //***************************************************** PBLOCK_KEY pK = (PBLOCK_KEY)(((PUCHAR)&Key[1])-1); Status = EncryptStdBlock(pK /*&Key[1]*/, &(LmOwfP