Source
...
Target
Commits (15)
  • Robert Sprowson's avatar
    Fix for null pointer assignment · ea7965b5
    Robert Sprowson authored
    Can't zero the t2flags having just set hServer to NULL.
    
    Version 2.49. Tagged as 'LanManFS-2_49'
    ea7965b5
  • ROOL's avatar
    Be more efficient with buffers · 44df7e69
    ROOL authored
    Take note of, and use, the MaxBufferSize that the server tells us during negotiation rather than a fixed value.
    If the server doesn't say, use 1k as the default as before.
    Submission from Colin Granville.
    
    Version 2.50. Tagged as 'LanManFS-2_50'
    44df7e69
  • Robert Sprowson's avatar
    Build fix · cf8805b3
    Robert Sprowson authored
    RES_PATH needs the component name too.
    
    Version 2.51. Tagged as 'LanManFS-2_51'
    cf8805b3
  • Robert Sprowson's avatar
    Build fix · 68b81856
    Robert Sprowson authored
    RES_PATH needs the component name too.
    
    Version 2.51. Tagged as 'LanManFS-2_51'
    68b81856
  • ROOL's avatar
    Add support for NTLM authenticated logins · f1009949
    ROOL authored
    SMB.c:
    Line 875 don't free chain pB that early it is (and was being) used later on.
    Fixes to correct which SMB_RxWords the Sesskey and bloblen are retrieved from, for each of the dialects supported.
    Call the new auth code when the protocol flags require it.
    Don't uppercase passwords all the time, the server may require case sensitivity.
    md5c.c/md4c.c:
    Verbatim copies of the RSA reference implementations of MD4 and MD5 from the respective RFC's.
    Auth.c:
    Implementation of the hash/mash/reply that Microsoft requires. Define AUTHTEST of this file to build a simple application that verifies the algorithms.
    
    Tested against a Win7 install, inspecting in Wireshark that the passwords are no longer sent in the clear.
    Implements ticket #332.
    Submission from Colin Granville.
    
    Version 2.52. Tagged as 'LanManFS-2_52'
    f1009949
  • Robert Sprowson's avatar
    Fix for garbled translation · d06e3e50
    Robert Sprowson authored
    One too many %s's in the code, one too few in the messages file. This resulted in diagnostics messages (eg. at the bottom of *ListFS) to show a %s that hadn't got substituted.
    
    Version 2.53. Tagged as 'LanManFS-2_53'
    d06e3e50
  • Robert Sprowson's avatar
    Fix for buffer overrun · a596ce3c
    Robert Sprowson authored
    The PRM entry for Free reason 1 is very vague, it requires the length of the drive name including a terminator, not strlen() of the drive name. Free uses this directly to allocate RMA to copy into (though for drive names that aren't a multiple of 8 we're saved by OS_Module rounding up claims).
    Also use Free SWI values from headers rather than defining them again locally.
    
    Version 2.54. Tagged as 'LanManFS-2_54'
    a596ce3c
  • Jeffrey Lee's avatar
    Don't pass silly error numbers to MsgTrans · b826b8ec
    Jeffrey Lee authored
    Detail:
      c/LanMan - Don't pass silly error numbers to MessageTrans_ErrorLookup - the kernel will now fault them.
    Admin:
      Tested on Raspberry Pi 3
      Fixes "bad error pointer" message when e.g. failing to log on to a share:
      https://www.riscosopen.org/forum/forums/4/topics/5264
    
    
    Version 2.55. Tagged as 'LanManFS-2_55'
    b826b8ec
  • ROOL's avatar
    [419] LanManFS does not see all visible files · e6ff7fc3
    ROOL authored
    Detail:
      When the number of files read from the server didn't fit in the OS_GBPB buffer, continuation of the enumeration would fail.
      Resume key *and* filename used when resuming a directory enumeration to the same directory.
    Admin:
      Submission from Colin Granville.
    
    Version 2.56. Tagged as 'LanManFS-2_56'
    e6ff7fc3
  • Robert Sprowson's avatar
    Fix out-by-1 error reporting monitor name · 9904c568
    Robert Sprowson authored
    For *OPT1,2 the FS is supposed to report the leafname. LanManFS uses strrchr() to find the dot but hadn't incremented past it when returning the pointer.
    
    Version 2.57. Tagged as 'LanManFS-2_57'
    9904c568
  • Robert Sprowson's avatar
    Correction to configure syntax help · f5f7b48f
    Robert Sprowson authored
    The args to LMTransport are mandatory, so should be in <> brackets rather than [].
    
    Version 2.58. Tagged as 'LanManFS-2_58'
    f5f7b48f
  • Robert Sprowson's avatar
    Fix for truncating writes to servers that declare MaxBufferSize >= 64k smb.c,... · e6b73849
    Robert Sprowson authored
    Fix for truncating writes to servers that declare MaxBufferSize >= 64k smb.c, lines 2726 onwards: when chopping up the next buffer, make sure the size sent still fits in the SMB_COM_WRITE count field (16 bits). For completeness, make sure the estimate of bytes remaining is similarly saturated too.
    
    smb.c, lines 2711-2713: cifs-v1-spec-02 section 5.27 says the server always expects to receive up to 65535 bytes, so this test should not be subject to the negotiated MaxBufferSize, and is expected to often exceed it. Currently we use 32k, if this is ever increased we really ought to take into account MaxRawSize that the server tells us.
    
    Tested with a handful of files of power-of-2 sizes and odd sizes. Inspection in Wireshark looks OK. Variation of a diagnosis by Will Ling https://www.riscosopen.org/forum/forums/4/topics/8966
    
    Version 2.59. Tagged as 'LanManFS-2_59'
    e6b73849
  • John Ballance's avatar
    Resolved issue where RISC OS name '1 2/3' gets wrongly translated. · 98a15172
    John Ballance authored
    Detail:
    The translate routine that converts contentious characters in a RiscOS
    file name to equivalent DOS ones was being invoked a second time. Normally
    this wouldn't be critical, but a / in riscos was converted to the . in DOS,
    correctly , then converted back again. This error mode with more than one
    contentious character in (particularly) a directory name had recently
    come to light.
    Admin:
    Tested by building a RiscOS rom image on a pc based LanManFS mount without
    errors.
    
    Version 2.60. Tagged as 'LanManFS-2_60'
    98a15172
  • John Ballance's avatar
    Resolved issue where RISC OS name '1 2/3' gets wrongly translated. · 7587ab10
    John Ballance authored
    Detail:
    The translate routine that converts contentious characters in  a RiscOS
    file name to equivalent DOS ones was being invoked a second time. Normally
    this wouldn't be critical, but a / in riscos was converted to the . in DOS,
    correctly , then converted back again. This error mode with more than one
    contentious character in (particularly) a directory name had recently
    come to light.
    Admin:
    Tested by building a RiscOS rom image on a pc based LanManFS mount without
    errors.
    
    Version 2.60. Tagged as 'LanManFS-2_60'
    7587ab10
  • Robert Sprowson's avatar
    Name resolution, wildcarded FSEntry_File 5 & 9, and buffer overrun fixes · 517c6bdb
    Robert Sprowson authored
    Make SMB_RxWords a bit bigger per static anaylsis
      https://www.riscosopen.org/forum/forums/4/topics/9503
    when LONGNAMES is undefined, since NT LM 0.12 dialect is allowed at the same time as short names.
    
    A change to name translation in LanManFS-2_60 broke all forms of nested contentious name resolution, ie. where a leafname containing a contentious character was itself in a directory containing one.
    The cited problem names ('1 2/3' and '1 /s') can both be resolved at one level only, no 2nd pass is required. The resolution function walks along the elements of the path one at a time to reach the leaf (ie. no element is processed twice). A test case has been created to allow some regression testing when making future changes in this area.
    
    When building tboxlibint
      Copy h.* <Lib$Dir>.tboxlibint.h.*
    when the directory is empty FileSwitch checks the destination ending in ...\h\* which the short names translation would error with ENOWILDCARD, but the long names translation attempts to resolve it by finding the trailing '\' and appending a '*' (ie. not doing anything), this returns no results and is passed back unfaulted. The special check in fsentry_file() for ENOWILDCARD for the two ReadCatalogueInformation thus doesn't trigger, and an attempt to FileGetAttribs() is made on the still wildcarded path. This is rejected by the server when in SMB_GetAttribsX2() does a TRANSACT2_QUERYPATHINFORMATION, which expects a non wildcarded object (on Windows servers at least), propagating an error back up to the user.
    This stopped a ROM build from completing the exports phase via LanManFS on a Windows share.
    
    Const-ify a few things.
    
    Changed files
      Xlate.c: Revert change from revision 1.21, return ENOWILDCARD when appropriate.
      SMC.c: Increase MAX_WCT buffer size to 17.
      UK/CmdHelp: Add some missing chevrons round the command syntax for required parameters.
      test/Contentious: Test case for nested contentious character resolution code.
    
    Version 2.61. Tagged as 'LanManFS-2_61'
    517c6bdb
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
*,ffb gitlab-language=bbcbasic linguist-language=bbcbasic linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
......@@ -18,14 +18,13 @@
COMPONENT = LanManFS
OBJS = Xlate Transact Stats SMB RPC Printers Omni NetBIOS NBIP \
NameCache Logon LLC LanMan CoreFn buflib Attr \
Interface MyResObj
Interface Auth md5c md4c MyResObj
CINCLUDES = -ITCPIPLibs:,C:
HDRS =
CMHGFILE = Lanman_MH
CMHGDEPENDS = LanMan LLC Logon NBIP Omni
LIBS = ${NET4LIBS} ${ASMUTILS}
RES_PATH = ThirdParty.OmniClient.LanManFS
RES_OBJ =
RES_PATH = ThirdParty.OmniClient
CUSTOMRES = custom
CDEFINES = -DCOMPAT_INET4 -DLONGNAMES ${OPTIONS}
CFLAGS = -Wp
......@@ -38,11 +37,15 @@ endif
include CModule
#
# Static dependencies
#
o.MyResObj od.MyResObj: LocalRes:ROM.Sprites ${MERGEDMSGS}PP ${DIRS}
${RESGEN} ${RES_AREA} $@ ${MERGEDMSGS}PP ${RES_PATH}.Messages LocalRes:ROM.Sprites ${RES_PATH}.Sprites
${RESGEN} ${RES_AREA} $@ ${MERGEDMSGS}PP ${RES_PATH}.${TARGET}.Messages LocalRes:ROM.Sprites ${RES_PATH}.${TARGET}.Sprites
${MERGEDMSGS}PP: ${MERGEDMSGS}
${MERGEDMSGS}PP: LocalRes:Messages LocalRes:CmdHelp
${MKDIR} ${MERGEDRDIR}${SEP}${TARGET}
${FAPPEND} ${MERGEDMSGS} LocalRes:Messages LocalRes:CmdHelp
${INSERTVERSION} ${MERGEDMSGS} > $@
# Dynamic dependencies:
No preview for this file type
......@@ -34,8 +34,8 @@ D01:EnumShares call on %s
D02:Can't find master browser or DC for %s
D03:EnumServers could not log on to %s
D04:EnumShares call on %s
D05:LogonUser connect to DC failed, user name
D06:NetGetUserInfo call failed, user name
D05:LogonUser connect to DC failed, user name %s
D06:NetGetUserInfo call failed, user name %s
NameL:----Longest-----
NameO:OmniClient
NameH:Machine name
......
/* (2.48)
/* (2.61)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.48
#define Module_MajorVersion_CMHG 2.61
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 14 Mar 2015
#define Module_Date_CMHG 03 Jan 2018
#define Module_MajorVersion "2.48"
#define Module_Version 248
#define Module_MajorVersion "2.61"
#define Module_Version 261
#define Module_MinorVersion ""
#define Module_Date "14 Mar 2015"
#define Module_Date "03 Jan 2018"
#define Module_ApplicationDate "14-Mar-15"
#define Module_ApplicationDate "03-Jan-18"
#define Module_ComponentName "LanManFS"
#define Module_ComponentPath "castle/RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.48"
#define Module_HelpVersion "2.48 (14 Mar 2015)"
#define Module_LibraryVersionInfo "2:48"
#define Module_FullVersion "2.61"
#define Module_HelpVersion "2.61 (03 Jan 2018)"
#define Module_LibraryVersionInfo "2:61"
/*
* Copyright(c)2015, Colin Granville
* Allrightsreserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of RISC OS Open Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include "DebugLib/DebugLib.h"
#include "Auth.h"
#include "global.h"
#include "md4.h"
#include "md5.h"
/* Based on code from RFC2104 */
typedef struct
{
MD5_CTX MD5ctx;
unsigned char k_opad[64];/* outer padding -
* key XORd with opad
*/
} HMAC_MD5_CTX;
static void HMAC_MD5Init( HMAC_MD5_CTX *ctx, unsigned char *key, int key_len )
{
unsigned char k_ipad[65]; /* inner padding -
* key XORd with ipad
*/
unsigned char tk[16];
int i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
MD5_CTX tctx;
MD5Init( &tctx );
MD5Update( &tctx, key, key_len );
MD5Final( tk, &tctx );
key = tk;
key_len = 16;
}
/*
* the HMAC_MD5 transform looks like:
*
* MD5(K XOR opad, MD5(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* start out by storing key in pads */
memset( k_ipad, 0, sizeof k_ipad );
memset( ctx->k_opad, 0, sizeof ctx->k_opad );
memcpy( k_ipad, key, key_len );
memcpy( ctx->k_opad, key, key_len );
/* XOR key with ipad and opad values */
for (i = 0; i < 64; i++) {
k_ipad[i] ^= 0x36;
ctx->k_opad[i] ^= 0x5c;
}
/* perform inner MD5 */
MD5Init( &ctx->MD5ctx ); /* init context for 1st pass */
MD5Update( &ctx->MD5ctx, k_ipad, 64 ); /* start with inner pad */
}
static void HMAC_MD5Update( HMAC_MD5_CTX *ctx, unsigned char *text, int text_len )
{
MD5Update( &ctx->MD5ctx, text, text_len ); /* then text of datagram */
}
static void HMAC_MD5Final( unsigned char digest[16], HMAC_MD5_CTX* ctx )
{
/* finish up 1st pass */
MD5Final( digest, &ctx->MD5ctx );
/* perform outer MD5 */
MD5Init( &ctx->MD5ctx ); /* init context for 2nd pass */
MD5Update( &ctx->MD5ctx, ctx->k_opad, 64 ); /* start with outer pad */
MD5Update( &ctx->MD5ctx, digest, 16 ); /* then results of 1st hash */
MD5Final( digest, &ctx->MD5ctx ); /* finish up 2nd pass */
}
/*
* Simplified RISCOS string to UTF16 conversion.
* sizeof out must be >= size * 2 or (size + 1) * 2 if
* US_ADD_ZERO flag used.
*/
#define US_UPPERCASE 1
#define US_ADD_ZERO 2
static void UnicodeString( unsigned int flags, const char *s, size_t size, unsigned short *out )
{
size_t i;
if (out == 0) return;
for (i = 0; i < size; i++) {
out[i] = (flags & US_UPPERCASE) ? toupper( s[i] ) : s[i];
}
if (flags & US_ADD_ZERO) out[i] = 0;
}
static void Auth_NTOWFv1( const char *password, size_t pass_size, unsigned char digestout[16] )
{
unsigned short ustr[pass_size + 1]; /* 1 added because 0 size causes crash */
MD4_CTX ctx;
MD4Init( &ctx );
UnicodeString( 0, password, pass_size, ustr );
if (pass_size)
{
MD4Update( &ctx, (void *)ustr, pass_size * sizeof(unsigned short) );
}
MD4Final(digestout,&ctx);
}
void Auth_LMOWFv2( const char *password, size_t pass_size,
const char *username, size_t user_size,
const char *userdomain, size_t dom_size,
unsigned char digestout[16] )
{
size_t max_size = user_size;
unsigned short ustr[max_size + 1]; /* 1 added because 0 size causes crash */
Auth_NTOWFv1( password, pass_size, digestout );
if (dom_size > max_size) max_size = dom_size;
HMAC_MD5_CTX ctx;
HMAC_MD5Init( &ctx, digestout, 16 );
UnicodeString( US_UPPERCASE, username, user_size, ustr );
HMAC_MD5Update( &ctx, (void *)ustr, user_size * sizeof(unsigned short) );
UnicodeString( 0, userdomain, dom_size, ustr );
HMAC_MD5Update( &ctx, (void *)ustr, dom_size * sizeof(unsigned short) );
HMAC_MD5Final( digestout, &ctx );
}
void Auth_LMv2ChallengeResponse( unsigned char lmowfv2digest[16],
unsigned char serverchallenge[8],
unsigned char responseout[24])
{
size_t i;
unsigned char *clientchallenge = responseout + 16;
HMAC_MD5_CTX ctx;
/* Create random clientchallenge */
srand( (unsigned int)time( NULL ) );
for (i = 0; i < 8; i++)
{
#ifdef AUTHTEST
clientchallenge[i] = 0xAA;
#else
clientchallenge[i] = (unsigned char)rand();
#endif
}
HMAC_MD5Init( &ctx, lmowfv2digest, 16 );
HMAC_MD5Update( &ctx, (void *)serverchallenge, 8 );
HMAC_MD5Update( &ctx, (void *)clientchallenge, 8 );
HMAC_MD5Final( responseout, &ctx );
}
static unsigned long long SMBTime( void )
{
unsigned long long tm = time( NULL );
tm = (tm + 11644473600ull -2*24*3600) * 10000000;
return tm;
}
void Auth_NTv2ChallengeResponse( unsigned char ntowfv2digest[16],
unsigned char serverchallenge[8],
const char *servername, /* ASCII */
const char *domain, /* ASCII */
unsigned char responseout[128],
unsigned short *responseoutsize )
{
unsigned char *clientchallenge = responseout + 16;
unsigned long long tm;
size_t i, size;
HMAC_MD5_CTX ctx;
*responseoutsize = 0;
*clientchallenge++ = 1;
*clientchallenge++ = 1;
memset( clientchallenge, 0, 6 );
clientchallenge += 6;
tm = SMBTime();
#ifdef AUTHTEST
memset( clientchallenge, 0, sizeof(tm) );
#else
memcpy( clientchallenge, &tm, sizeof(tm) );
#endif
clientchallenge += sizeof(tm);
/* Create random clientchallenge */
srand( (unsigned int)time( NULL ) );
for (i = 0; i < 8; i++)
{
#ifdef AUTHTEST
*clientchallenge++ = 0xaa;
#else
*clientchallenge++ = (unsigned char)rand();
#endif
}
memset( clientchallenge, 0, 4 );
clientchallenge += 4;
/* Set domain */
size = strlen( domain );
if (clientchallenge + size * 2 + 4 > responseout + 128 - 8) return;
*clientchallenge++ = 2;
*clientchallenge++ = 0;
*clientchallenge++ = size * 2;
*clientchallenge++ = 0;
UnicodeString( 0, domain, size, (unsigned short *)clientchallenge );
clientchallenge += size * 2;
/* Set server */
size = strlen( servername );
if (clientchallenge + size * 2 + 4 > responseout + 128 - 8) return;
*clientchallenge++ = 1;
*clientchallenge++ = 0;
*clientchallenge++ = size * 2;
*clientchallenge++ = 0;
UnicodeString( 0, servername, size, (unsigned short *)clientchallenge );
clientchallenge += size * 2;
/* End of list */
*clientchallenge++ = 0;
*clientchallenge++ = 0;
*clientchallenge++ = 0;
*clientchallenge++ = 0;
memset( clientchallenge, 0, 4 );
clientchallenge += 4;
*responseoutsize = clientchallenge - responseout;
HMAC_MD5Init( &ctx, ntowfv2digest, 16 );
HMAC_MD5Update( &ctx, (void *)serverchallenge, 8 );
HMAC_MD5Update( &ctx, (void *)(responseout + 16), *responseoutsize - 16 );
HMAC_MD5Final( responseout, &ctx );
}
#ifdef AUTHTEST
#define MDPrint(digest) PrintHex((digest),16)
static void PrintHex( void *d, size_t len )
{
size_t i;
unsigned char *data = (unsigned char *)d;
for (i = 0; i < len; i++) {
printf( "%02x", data[i] );
}
printf( "\n" );
}
int main( void )
{
unsigned char digest[16];
MD5_CTX context;
MD4_CTX context4;
HMAC_MD5_CTX hctx;
unsigned char lmv2response[24];
unsigned long long tm;
unsigned char ntv2response[128];
unsigned short ntsize;
MD5Init( &context );
MD5Update( &context, (void *)"test", 4 );
MD5Final( digest, &context );
MDPrint( digest );
MD5Init( &context );
MD5Update( &context, (void *)"te", 2 );
MD5Update( &context, (void *)"st", 2 );
MD5Final( digest, &context );
MDPrint( digest );
MD4Init( &context4 );
MD4Update( &context4, (void *)"test", 4 );
MD4Final( digest, &context4 );
MDPrint( digest );
MD4Init( &context4 );
MD4Update( &context4, (void *)"te", 2 );
MD4Update( &context4, (void *)"st", 2 );
MD4Final( digest, &context4 );
MDPrint( digest );
/* RFC2202 test cases */
HMAC_MD5Init( &hctx, (void *)"Jefe", 4 );
HMAC_MD5Update( &hctx, (void *)"what do ya want for nothing?", 28 );
HMAC_MD5Final( digest, &hctx );
MDPrint( digest );
HMAC_MD5Init( &hctx, (void *)"Jefe", 4 );
HMAC_MD5Update( &hctx, (void*)"what", 4 );
HMAC_MD5Update( &hctx, (void *)" do ya want for nothing?", 24 );
HMAC_MD5Final( digest, &hctx );
MDPrint( digest );
/* Value below verified from [MS-NLMP].pdf 4.2.4.1.1 */
Auth_NTOWFv2( "Password", 8, "User", 4, "Domain", 6, digest );
MDPrint( digest );
/* Value below verified from [MS-NLMP].pdf 4.2.2.1.2 */
Auth_NTOWFv1( "Password", 8, digest );
MDPrint( digest );
/* Value below verified from [MS-NLMP].pdf 4.2.4.1.1 */
Auth_LMOWFv2( "Password", 8, "User", 4, "Domain", 6, digest );
MDPrint( digest );
/* Value below verified from [MS-NLMP].pdf 4.2.4.2.1 */
Auth_LMv2ChallengeResponse( digest, (void *)"\x01\x23\x45\x67\x89\xab\xcd\xef", lmv2response );
printHex( lmv2response, 24 );
/* Value below verified from [MS-NLMP].pdf 4.2.4.2.2 */
tm = SMBTime();
printHex( &tm, 8 );
Auth_NTv2ChallengeResponse( digest, (void *)"\x01\x23\x45\x67\x89\xab\xcd\xef", "Server",
"Domain", ntv2response, &ntsize );
printHex( ntv2response, ntsize );
printf( "%d\n", ntsize );
return 0;
}
#endif
......@@ -140,8 +140,10 @@ err_t MsgSetOSError (_kernel_oserror *err)
_kernel_oserror *MsgError(int which)
{
char token[12];
_kernel_oserror *e;
struct {
int errnum;
char errmess[8];
} token;
if (which == OK) return NULL; /* No error */
......@@ -152,22 +154,17 @@ _kernel_oserror *MsgError(int which)
which = EHOWDTHATHAPPEN;
}
sprintf(token, "@@@@E%02u", which);
e = _swix(MessageTrans_ErrorLookup, _INR(0,3),
token, msg_struct, &msg_buff, sizeof(msg_buff));
if (e->errnum == 0x40404040)
sprintf(token.errmess, "E%02u", which);
if ((which == EDIRNOTEMPTY) || (which == ENOACCESS))
{
/* Same error number out as went in, looked up OK */
if ((which == EDIRNOTEMPTY) || (which == ENOACCESS))
{
/* Fudge for Filer_Action which expects a FileCore
* style specific error return code
*/
which = ErrorNumber_DirNotEmpty;
}
msg_buff.errnum = Our_Error_Base + which;
/* Fudge for Filer_Action which expects a FileCore
* style specific error return code
*/
which = ErrorNumber_DirNotEmpty;
}
return(e);
token.errnum = Our_Error_Base + which;
return _swix(MessageTrans_ErrorLookup, _INR(0,3),
&token, msg_struct, &msg_buff, sizeof(msg_buff));
}
/* ------------------ */
......@@ -710,7 +707,7 @@ static _kernel_oserror *Cmd_LMTransport ( const char *args )
{
/* This is a *Configure/Status command handler */
char *argv[1];
char *tp1 = "IP";
static const char *tp1 = "IP";
#ifdef NO_NETBEUI
if (args == arg_CONFIGURE_SYNTAX || args == arg_STATUS)
......@@ -719,10 +716,10 @@ static _kernel_oserror *Cmd_LMTransport ( const char *args )
return NULL;
}
#else
char *tp0 = "NetBEUI";
static const char *tp0 = "NetBEUI";
if ( args == arg_CONFIGURE_SYNTAX ) /* Show 'Configure' options */
{
printf("LMTransport [%s | %s]\n", tp0, tp1);
printf("LMTransport <%s | %s>\n", tp0, tp1);
return NULL;
}
else if ( args == arg_STATUS ) /* Show FS status */
......
......@@ -62,11 +62,6 @@
#define INFO_STR_LEN 64
/* Length of info string kept about servers & mounts */
/* SWI definitions */
#define SWI_Free_Register 0x444C0
#define SWI_Free_Deregister 0x444C1
/* ------------------------ */
/* Information on a known mount path or printer name.
......@@ -1218,7 +1213,7 @@ _kernel_oserror *Omni_FreeOp_SWI (_kernel_swi_regs *R )
char *s = (char *)(R->r[3]);
char *d = (char *)(R->r[2]);
sprintf ( d, FilingSystemName "::%s", s );
R->r[0] = strlen(d);
R->r[0] = strlen(d) + 1 /* Terminator */;
return NULL;
}
......@@ -1335,9 +1330,9 @@ static void Omni_Free_Register(bool OnNotOff)
R.r[2] = 0; /* R12 value, don't care */
if ( OnNotOff )
_kernel_swi ( SWI_Free_Register, &R, &R );
_kernel_swi ( Free_Register, &R, &R );
else
_kernel_swi ( SWI_Free_Deregister, &R, &R );
_kernel_swi ( Free_DeRegister, &R, &R );
}
/* Omni_StartUp() ---------------------------------*/
......
......@@ -71,9 +71,9 @@ static err_t debug_err ( err_t res, debug_errs_t token, char *name )
{
sprintf(text, "D%02u", token);
strcpy(text, MsgLookup(text));
strcat(text, ": %s"); /* Append the error */
RPC_ErrorCount++;
sprintf( RPC_DebugMsg, "%s %s: %s",
text, name, MsgError(res)->errmess );
sprintf( RPC_DebugMsg, text, name, MsgError(res)->errmess );
}
return res;
}
......
......@@ -94,6 +94,7 @@
#include "LMVars.h"
#include "Attr.h" /* For InvalidateDrive */
#include "Xlate.h" /* For string functions */
#include "Auth.h"
/* Definitions ===================================================== */
......@@ -104,10 +105,11 @@
/* Tuning parameters */
#define FILE_BLOCK_SIZE 1024
#define RDRAW_BLOCK_SIZE 32768
#define WRRAW_BLOCK_SIZE 16384
#define PRN_BLOCK_SIZE 1024
#define MAX_RX_BLOCK_SIZE (3*1452) /* Windows clients' default, see [MS-CIFS].pdf note 91 (p709) */
#define MAX_CORE_TX_BLOCK_SIZE 1024 /* Core dialect doesn't send MaxBufferSize value */
#define RDRAW_BLOCK_SIZE 32768
#define WRRAW_BLOCK_SIZE 16384
#define PRN_BLOCK_SIZE 1024
/* This structure relies on Norcroft C packing the bytes & words
properly!
......@@ -137,12 +139,12 @@ typedef struct
/* Maximum number of word params - 14 is used by Transact */
#ifdef LONGNAMES
/* Transact2 (LONGNAMES build only) requires 14 plus setup words
/* Transact2 (LONGNAMES build only) requires extra setup words.
* The NT LM 0.12 negprot response requires 17.
*/
#define MAX_WCT (17+(MAX_SETUPWORDS)+1)
#else
#define MAX_WCT 14
#define MAX_WCT 17
#endif
/* Max number of significant characters in a shared drive
......@@ -281,6 +283,7 @@ struct ActiveServer
BYTE *blob;
char servname[NAME_LIMIT]; /* upper case */
char username[NAME_LIMIT]; /* case preserved */
unsigned int maxTxBufferSize; /* maximum SMB message size the server can receive */
};
typedef struct ActiveServer *hSERVER;
......@@ -442,11 +445,11 @@ static BUFCHAIN AddUnicodeStringToChain ( BUFCHAIN pB, char *str )
/* --------------------- */
static BUFCHAIN MkDataString ( BUFCHAIN pB, int type, char *ptr )
static BUFCHAIN MkDataString ( BUFCHAIN pB, int type, const char *ptr )
{
BYTE hdrblk[4];
pB = AddChain ( pB, ptr, strlen(ptr)+1 );
pB = AddChain ( pB, (void *)ptr, strlen(ptr)+1 );
if ( pB == NULL ) return NULL;
......@@ -817,7 +820,7 @@ static err_t SMB_WriteRaw ( hSHARE hS, int fid, uint offset,
* call this function to find out which protocol was accepted. The
* offsets within the array of each string are vital to SMB_Negotiate.
*/
static char *dialects[] = {
static const char *dialects[] = {
"PC NETWORK PROGRAM 1.0",
"DOS LM1.2X002",
"LM1.2X002",
......@@ -827,7 +830,7 @@ static char *dialects[] = {
#define DIALECT_BASIC 0
#define DIALECT_LM12X002 1
#define DIALECT_NT 3
static char *SMB_Dialect(unsigned int num)
static const char *SMB_Dialect(unsigned int num)
{
if (num <= MAX_DIALECT) return dialects[num];
return "";
......@@ -856,18 +859,6 @@ static err_t SMB_Negotiate( hSHARE hS )
if ( res != OK )
return res;
#ifdef DEBUG
debug1("Data length on negprot is %d\n", ChainLen(pB));
{
static char buf[4096];
void *ptr = SMB_RxWords;
int len = ChainLen(pB);
GetData(pB, buf, len);
DumpBuffer(buf, len);
DumpStruct(ptr, (SMB_RxWords[0] >= DIALECT_NT) ? dvs_NTnegprot : dvs_negprot);
}
#endif
FreeChain(pB);
debug1("Negotiated protocol `%s'\n", SMB_Dialect(SMB_RxWords[0]));
hS->hServer->prot = SMB_RxWords[0];
......@@ -875,6 +866,7 @@ static err_t SMB_Negotiate( hSHARE hS )
{
if (SMB_RxWords[0] >= DIALECT_NT) {
/* grr - different response format */
hS->hServer->maxTxBufferSize = (SMB_RxWords[3] >> 8) | (SMB_RxWords[4] << 8) | (SMB_RxWords[5] << 24);
hS->hServer->ProtFlags = PROT_RWMULTI + PROT_SETDATETIME +
(SMB_RxWords[9] & 0x100 ? PROT_READRAW+PROT_WRITERAW : 0 ) +
(SMB_RxWords[1] & 1 ? PROT_USERLOGON : 0 ) +
......@@ -890,14 +882,17 @@ static err_t SMB_Negotiate( hSHARE hS )
debug0("No extended security - no GUID in the data block\n");
}
hS->hServer->bloblen = SMB_RxWords[16] >> 8;
hS->hServer->Sesskey = (SMB_RxWords[7] >> 8) | (SMB_RxWords[8] << 8) | (SMB_RxWords[9] << 24);
}
else {
hS->hServer->bloblen = SMB_RxWords[11];
hS->hServer->maxTxBufferSize = SMB_RxWords[2];
hS->hServer->ProtFlags = PROT_RWMULTI + PROT_SETDATETIME +
(SMB_RxWords[1] & 1 ? PROT_USERLOGON : 0 ) +
(SMB_RxWords[1] & 2 ? PROT_ENCRYPT : 0 ) +
(SMB_RxWords[5] & 1 ? PROT_READRAW : 0 ) +
(SMB_RxWords[5] & 2 ? PROT_WRITERAW : 0 );
hS->hServer->bloblen = SMB_RxWords[11];
hS->hServer->Sesskey = SMB_RxWords[6] | (SMB_RxWords[7] << 16);
}
hS->hServer->SMB_flg = SMB_CASELESS;
#ifdef LONGNAMES
......@@ -905,7 +900,6 @@ static err_t SMB_Negotiate( hSHARE hS )
hS->hServer->SMB_flg2 = SMB_KNOWS_LONG_NAMES; /* | SMB_IS_LONG_NAME;*/
hS->hServer->t2flags = T2FLAGS_LONGNAMES;
#endif
hS->hServer->Sesskey = SMB_RxWords[6] | (SMB_RxWords[7] << 16);
if (hS->hServer->bloblen > 0) {
free(hS->hServer->blob);
hS->hServer->blob = malloc(hS->hServer->bloblen);
......@@ -919,6 +913,7 @@ static err_t SMB_Negotiate( hSHARE hS )
}
else
{
hS->hServer->maxTxBufferSize = MAX_CORE_TX_BLOCK_SIZE;
hS->hServer->ProtFlags = PROT_SETDATETIME;
hS->hServer->SMB_flg = 0;
#ifdef LONGNAMES
......@@ -926,6 +921,7 @@ static err_t SMB_Negotiate( hSHARE hS )
hS->hServer->SMB_flg2 = 0;
#endif
}
FreeChain(pB);
debug1("%s-level security\n", hS->hServer->ProtFlags & PROT_USERLOGON ? "User" : "Share");
return OK;
}
......@@ -941,8 +937,8 @@ static err_t SMB_SessSetup ( hSHARE hS, char *userid, char *passwd )
SMB_TxWords[0] = 0x00FF; /* No additional command */
SMB_TxWords[1] = 0; /* Offset to next cmd */
SMB_TxWords[2] = 4096; /* Our buffer size */
SMB_TxWords[3] = 0; /* Max pending requests */
SMB_TxWords[2] = MAX_RX_BLOCK_SIZE; /* Maximum SMB message size we can receive */
SMB_TxWords[3] = 1; /* Max pending requests */
SMB_TxWords[4] = 0; /* First & only VC */
SMB_TxWords[5] = hS->hServer->Sesskey & 0xFFFF;
SMB_TxWords[6] = hS->hServer->Sesskey >> 16;
......@@ -973,17 +969,49 @@ static err_t SMB_SessSetup ( hSHARE hS, char *userid, char *passwd )
}
else {
/* Server does not support extended security */
SMB_TxWords[7] = strlen ( passwd );
SMB_TxWords[8] = 0;
SMB_TxWords[9] = SMB_TxWords[10] = 0; /* Reserved */
SMB_TxWords[11] = SMB_TxWords[12] = 0; /* client capabilities */
pB = AddChain(NULL, "CIFS", sizeof("CIFS"));
if (pB) pB = AddChain(pB, "\0RISCOS", sizeof("\0RISCOS"));
if (pB) pB = AddChain(pB, userid, strlen(userid) + 1);
if (pB) pB = AddChain(pB, passwd, strlen(passwd));
if (pB) pB = DumpChain(pB);
if (pB == NULL)
return EOUTOFMEM;
if (hS->hServer->ProtFlags & PROT_ENCRYPT)
{
unsigned char lmowfv2digest[16];
unsigned char challengeResponse[24];
if (strlen( passwd ) != 0)
{
Auth_LMOWFv2( (const char *)passwd, strlen( passwd ),
(const char *)userid, strlen( userid ),
(const char *)userid, 0, /* no domain */
lmowfv2digest );
Auth_LMv2ChallengeResponse( lmowfv2digest, (void *)hS->hServer->blob, challengeResponse );
SMB_TxWords[7] = sizeof(challengeResponse);
}
else
{
SMB_TxWords[7] = 0;
}
SMB_TxWords[8] = 0;
SMB_TxWords[9] = SMB_TxWords[10] = 0; /* Reserved */
SMB_TxWords[11] = SMB_TxWords[12] = 0; /* client capabilities */
pB = AddChain( NULL, "CIFS", sizeof("CIFS") );
if (pB) pB = AddChain( pB, "\0RISCOS", sizeof("\0RISCOS") );
if (pB) pB = AddChain( pB, userid, strlen(userid) + 1 );
if (pB && (SMB_TxWords[7] != 0)) pB = AddChain( pB, challengeResponse, sizeof(challengeResponse) );
if (pB) pB = DumpChain( pB );
if (pB == NULL)
return EOUTOFMEM;
}
else
{
SMB_TxWords[7] = strlen ( passwd );
SMB_TxWords[8] = 0;
SMB_TxWords[9] = SMB_TxWords[10] = 0; /* Reserved */
SMB_TxWords[11] = SMB_TxWords[12] = 0; /* client capabilities */
pB = AddChain( NULL, "CIFS", sizeof("CIFS") );
if (pB) pB = AddChain( pB, "\0RISCOS", sizeof("\0RISCOS") );
if (pB) pB = AddChain( pB, userid, strlen(userid) + 1 );
if (pB) pB = AddChain( pB, passwd, strlen(passwd) );
if (pB) pB = DumpChain( pB );
if (pB == NULL)
return EOUTOFMEM;
}
res = Do_SMB ( hS, SMBsesssetup, 13, pB, NULL );
}
if ( res != OK )
......@@ -1209,6 +1237,9 @@ static hSERVER AllocServer ( void )
hS->flags = ALLOCATED;
hS->hSession = 0;
hS->blob = 0;
#ifdef LONGNAMES
hS->t2flags = 0;
#endif
return hS;
}
......@@ -1229,9 +1260,6 @@ static hSHARE AllocShare ( void )
hS->hServer = NULL;
hS->Tid=0;
hS->Datasize=0;
#ifdef LONGNAMES
hS->hServer->t2flags = 0;
#endif
return hS;
}
......@@ -1591,7 +1619,7 @@ err_t SMB_CreateShare ( int sharetype_in,
hShare->hServer = hServ;
hShare->sharetype = sharetype_in;
strcpy ( hShare->sharename, uc_sharename );
strcpyn_upper ( hShare->password, password_in, NAME_LIMIT );
strcpyn ( hShare->password, password_in, NAME_LIMIT );
Xlt_Jumble(hShare->password);
done |= ALLOC_SHARE;
}
......@@ -1616,7 +1644,7 @@ err_t SMB_CreateShare ( int sharetype_in,
{
/* Set up new server details */
strcpyn_upper ( hServ->username, username_in, NAME_LIMIT );
strcpyn_upper ( hServ->password, password_in, NAME_LIMIT );
strncpy ( hServ->password, password_in, NAME_LIMIT );
Xlt_Jumble(hServ->password);
res = ConnectServer ( hShare );
......@@ -2132,6 +2160,7 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
int n_read = 0;
int eos;
int i;
DWORD actual_resume_key;
const int first_flags = ffirst_RETURN_KEYS;
const int stuck_flags = ffirst_RETURN_KEYS | fnext_CONTINUE;
const int next_flags = ffirst_RETURN_KEYS;
......@@ -2182,6 +2211,7 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
con->dir_handle_valid = true;
con->resume_fake = 0;
con->resume_key_stuck = false;
con->resume_file_name[0] = 0;
debug1("SMB_ReadDirEntriesX2 -> new dir handle %x\n", con->dir_handle);
}
else {
......@@ -2191,15 +2221,9 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
Transact_addword(&con->tp, con->dir_handle); /* findnext_DirHandle */
Transact_addword(&con->tp, count); /* findnext_SearchCount */
Transact_addword(&con->tp, 1); /* Search level */
Transact_addlong(&con->tp, con->resume_key); /* Resume key from previous */
if (con->resume_key_stuck) {
Transact_addword(&con->tp, stuck_flags); /* Set continuation bit as NTFS maintains the position */
}
else {
Transact_addword(&con->tp, next_flags); /* Jump to place using the resume key */
con->resume_key_encountered = true;
}
Transact_addstring(&con->tp, ""); /* no name needed */
Transact_addlong(&con->tp, con->actual_resume_key); /* Resume key from previous */
Transact_addword(&con->tp, next_flags); /* Jump to place using the resume key */
Transact_addstring(&con->tp, con->resume_file_name);
debug1("SMB_ReadDirEntriesX2 -> continue with key %08x\n", con->resume_key);
res = SMB_Transact2(hS, &con->tp);
if (res != OK)
......@@ -2235,6 +2259,8 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
continue;
}
actual_resume_key = next_resume_key;
/* Workaround for NTFS always returning zero */
con->resume_key_stuck = (next_resume_key == 0) ? true : false;
if (con->resume_key_stuck) next_resume_key = con->resume_fake;
......@@ -2243,7 +2269,16 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
if ( con->resume_key_encountered ) {
debug1("SMB_ReadDirEntriesX2 -> call back with key %08x\n", next_resume_key);
res = dirfn(p, 1, &taken, private);
if (taken) con->resume_key = next_resume_key;
if (taken) {
con->resume_key = next_resume_key;
con->actual_resume_key = actual_resume_key;
memcpy(con->resume_file_name, p + 23, length + 1);
}
else {
con->resume_fake--;
}
if (res != OK) {
/* Entry expander must have run out of space! */
debug0("SMB_ReadDirEntriesX2 -> caller ran out of space (or could be name xlate code)\n");
......@@ -2252,6 +2287,8 @@ static err_t SMB_ReadDirEntriesX2 ( hSHARE hS, char *path, int count,
}
else {
debug2("SMB_ReadDirEntriesX2 -> awaiting key %08x (got %08x)\n", con->resume_key, next_resume_key);
con->actual_resume_key = actual_resume_key;
memcpy(con->resume_file_name, p + 23, length + 1);
if ( next_resume_key == con->resume_key )
con->resume_key_encountered = true;
}
......@@ -2565,7 +2602,7 @@ err_t SMB_Read ( int FH, uint offset, uint len, BYTE *where,
if ( hS->hServer->ProtFlags & PROT_READRAW )
{
while ( len_left > FILE_BLOCK_SIZE )
while ( len_left > MAX_RX_BLOCK_SIZE )
{
n_read = SMB_ReadRaw ( hS, fid, offset, len_left, where );
if ( n_read == 0 ) /* Didn't work? Find out why */
......@@ -2582,7 +2619,7 @@ err_t SMB_Read ( int FH, uint offset, uint len, BYTE *where,
while ( len_left > 0 )
{
SMB_TxWords[0] = fid;
SMB_TxWords[1] = min(len_left,FILE_BLOCK_SIZE);
SMB_TxWords[1] = min(len_left, MAX_RX_BLOCK_SIZE);
SMB_TxWords[2] = offset & 0xFFFF;
SMB_TxWords[3] = (offset >> 16 );
SMB_TxWords[4] = (len_left);
......@@ -2611,7 +2648,7 @@ err_t SMB_Read ( int FH, uint offset, uint len, BYTE *where,
FreeChain(pB_res);
if ( n_read < FILE_BLOCK_SIZE ) /* Reached end of file */
if ( n_read < MAX_RX_BLOCK_SIZE ) /* Reached end of file */
break;
}
......@@ -2651,7 +2688,7 @@ err_t SMB_Write ( int FH, uint offset, uint len, BYTE *where,
uint *pOutLen )
{
BUFCHAIN pB;
uint len_left, n_written;
uint len_left, n_written, n_count;
int fid;
hSHARE hS;
......@@ -2668,9 +2705,9 @@ err_t SMB_Write ( int FH, uint offset, uint len, BYTE *where,
if ( hS->hServer->ProtFlags & PROT_WRITERAW )
{
while ( len_left > FILE_BLOCK_SIZE )
while ( len_left >= WRRAW_BLOCK_SIZE )
{
n_written = min(len_left,WRRAW_BLOCK_SIZE);
n_written = WRRAW_BLOCK_SIZE;
res = SMB_WriteRaw ( hS, fid, offset, n_written, where );
if ( res != OK )
goto finish;
......@@ -2683,14 +2720,14 @@ err_t SMB_Write ( int FH, uint offset, uint len, BYTE *where,
while ( len_left > 0 )
{
n_written = min(len_left,FILE_BLOCK_SIZE);
n_count = min(0xFFFF, min(len_left, hS->hServer->maxTxBufferSize));
SMB_TxWords[0] = fid;
SMB_TxWords[1] = n_written;
SMB_TxWords[2] = offset & 0xFFFF;
SMB_TxWords[3] = (offset >> 16 );
SMB_TxWords[4] = (len_left);
SMB_TxWords[1] = n_count;
SMB_TxWords[2] = (WORD)offset;
SMB_TxWords[3] = (WORD)(offset >> 16);
SMB_TxWords[4] = min(0xFFFF, len_left); /* Estimate of remainder */
pB = MkDataBlock ( NULL, DATA_BLOCK, where, n_written, true );
pB = MkDataBlock ( NULL, DATA_BLOCK, where, n_count, true );
if ( pB == NULL )
{
res = EOUTOFMEM;
......@@ -2706,7 +2743,7 @@ err_t SMB_Write ( int FH, uint offset, uint len, BYTE *where,
where += n_written;
offset += n_written;
if ( n_written < FILE_BLOCK_SIZE ) /* End of data */
if ( n_written < n_count ) /* Server has insufficient resources */
break;
}
......
......@@ -938,6 +938,7 @@ static err_t Xlt_NameROtoDOSX2_sub ( char *dst, char *src, int level )
*/
static err_t Xlt_NameROtoDOSX2 ( char *dst, char *src )
{
if (strchr(src, '*') != NULL) return ENOWILDCARD; /* As per nameROtoDOS() */
return Xlt_NameROtoDOSX2_sub(dst, src, 0);
}
......@@ -1012,13 +1013,13 @@ err_t Xlt_ConvertPath ( char *name_in, char *name_out )
/* --------------------------- */
/* Gets a leaf name from a DOS name */
/* Gets a leaf name from a RISC OS name */
char *Xlt_GetRISCOSLeafName ( char *name_in )
{
char *tmp;
tmp = strrchr ( name_in, '.' );
return ( tmp == NULL ) ? name_in : tmp;
return ( tmp == NULL ) ? name_in : tmp + 1;
}
/* Directory entry conversion ================================== */
......
/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
*/
/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD4 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD4 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#include "global.h"
#include "md4.h"
/* Constants for MD4Transform routine.
*/
#define S11 3
#define S12 7
#define S13 11
#define S14 19
#define S21 3
#define S22 5
#define S23 9
#define S24 13
#define S31 3
#define S32 9
#define S33 11
#define S34 15
static void MD4Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD4_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
static void MD4_memset PROTO_LIST ((POINTER, int, unsigned int));
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G and H are basic MD4 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
/* Rotation is separate from addition to prevent recomputation */
#define FF(a, b, c, d, x, s) { \
(a) += F ((b), (c), (d)) + (x); \
(a) = ROTATE_LEFT ((a), (s)); \
}
#define GG(a, b, c, d, x, s) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \
(a) = ROTATE_LEFT ((a), (s)); \
}
#define HH(a, b, c, d, x, s) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \
(a) = ROTATE_LEFT ((a), (s)); \
}
/* MD4 initialization. Begins an MD4 operation, writing a new context.
*/
void MD4Init (context)
MD4_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD4 block update operation. Continues an MD4 message-digest
operation, processing another message block, and updating the
context.
*/
void MD4Update (context, input, inputLen)
MD4_CTX *context; /* context */
unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
MD4_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD4Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD4Transform (context->state, &input[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
MD4_memcpy
((POINTER)&context->buffer[index], (POINTER)&input[i],
inputLen-i);
}
/* MD4 finalization. Ends an MD4 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void MD4Final (digest, context)
unsigned char digest[16]; /* message digest */
MD4_CTX *context; /* context */
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD4Update (context, PADDING, padLen);
/* Append length (before padding) */
MD4Update (context, bits, 8);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information.
*/
MD4_memset ((POINTER)context, 0, sizeof (*context));
}
/* MD4 basic transformation. Transforms state based on block.
*/
static void MD4Transform (state, block)
UINT4 state[4];
unsigned char block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11); /* 1 */
FF (d, a, b, c, x[ 1], S12); /* 2 */
FF (c, d, a, b, x[ 2], S13); /* 3 */
FF (b, c, d, a, x[ 3], S14); /* 4 */
FF (a, b, c, d, x[ 4], S11); /* 5 */
FF (d, a, b, c, x[ 5], S12); /* 6 */
FF (c, d, a, b, x[ 6], S13); /* 7 */
FF (b, c, d, a, x[ 7], S14); /* 8 */
FF (a, b, c, d, x[ 8], S11); /* 9 */
FF (d, a, b, c, x[ 9], S12); /* 10 */
FF (c, d, a, b, x[10], S13); /* 11 */
FF (b, c, d, a, x[11], S14); /* 12 */
FF (a, b, c, d, x[12], S11); /* 13 */
FF (d, a, b, c, x[13], S12); /* 14 */
FF (c, d, a, b, x[14], S13); /* 15 */
FF (b, c, d, a, x[15], S14); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 0], S21); /* 17 */
GG (d, a, b, c, x[ 4], S22); /* 18 */
GG (c, d, a, b, x[ 8], S23); /* 19 */
GG (b, c, d, a, x[12], S24); /* 20 */
GG (a, b, c, d, x[ 1], S21); /* 21 */
GG (d, a, b, c, x[ 5], S22); /* 22 */
GG (c, d, a, b, x[ 9], S23); /* 23 */
GG (b, c, d, a, x[13], S24); /* 24 */
GG (a, b, c, d, x[ 2], S21); /* 25 */
GG (d, a, b, c, x[ 6], S22); /* 26 */
GG (c, d, a, b, x[10], S23); /* 27 */
GG (b, c, d, a, x[14], S24); /* 28 */
GG (a, b, c, d, x[ 3], S21); /* 29 */
GG (d, a, b, c, x[ 7], S22); /* 30 */
GG (c, d, a, b, x[11], S23); /* 31 */
GG (b, c, d, a, x[15], S24); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 0], S31); /* 33 */
HH (d, a, b, c, x[ 8], S32); /* 34 */
HH (c, d, a, b, x[ 4], S33); /* 35 */
HH (b, c, d, a, x[12], S34); /* 36 */
HH (a, b, c, d, x[ 2], S31); /* 37 */
HH (d, a, b, c, x[10], S32); /* 38 */
HH (c, d, a, b, x[ 6], S33); /* 39 */
HH (b, c, d, a, x[14], S34); /* 40 */
HH (a, b, c, d, x[ 1], S31); /* 41 */
HH (d, a, b, c, x[ 9], S32); /* 42 */
HH (c, d, a, b, x[ 5], S33); /* 43 */
HH (b, c, d, a, x[13], S34); /* 44 */
HH (a, b, c, d, x[ 3], S31); /* 45 */
HH (d, a, b, c, x[11], S32); /* 46 */
HH (c, d, a, b, x[ 7], S33); /* 47 */
HH (b, c, d, a, x[15], S34); /* 48 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.
*/
MD4_memset ((POINTER)x, 0, sizeof (x));
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)
UINT4 *output;
unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
static void MD4_memcpy (output, input, len)
POINTER output;
POINTER input;
unsigned int len;
{
unsigned int i;
for (i = 0; i < len; i++)
output[i] = input[i];
}
/* Note: Replace "for loop" with standard memset if possible.
*/
static void MD4_memset (output, value, len)
POINTER output;
int value;
unsigned int len;
{
unsigned int i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
}
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#include "global.h"
#include "md5.h"
/* Constants for MD5Transform routine.
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void MD5Init (context)
MD5_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
*/
void MD5Update (context, input, inputLen)
MD5_CTX *context; /* context */
unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, index, partLen;
if (inputLen == 0 || input == 0) return;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state, &input[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)&input[i],
inputLen-i);
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void MD5Final (digest, context)
unsigned char digest[16]; /* message digest */
MD5_CTX *context; /* context */
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
MD5Update (context, bits, 8);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)context, 0, sizeof (*context));
}
/* MD5 basic transformation. Transforms state based on block.
*/
static void MD5Transform (state, block)
UINT4 state[4];
unsigned char block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)x, 0, sizeof (x));
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)
UINT4 *output;
unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
static void MD5_memcpy (output, input, len)
POINTER output;
POINTER input;
unsigned int len;
{
unsigned int i;
for (i = 0; i < len; i++)
output[i] = input[i];
}
/* Note: Replace "for loop" with standard memset if possible.
*/
static void MD5_memset (output, value, len)
POINTER output;
int value;
unsigned int len;
{
unsigned int i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
}
/*
* Copyright (c) 2015, Colin Granville
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of RISC OS Open Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AUTH_H
#define AUTH_H
void Auth_LMOWFv2( const char *password, size_t pass_size,
const char *username, size_t user_size,
const char *userdomain, size_t dom_size,
unsigned char digestout[16] );
void Auth_LMv2ChallengeResponse(unsigned char lmowfv2digest[16],
unsigned char serverchallenge[8],
unsigned char responseout[24]);
#define Auth_NTOWFv2 Auth_LMOWFv2
/* responseoutsize = 0 if response out is not big enough - should never happen */
void Auth_NTv2ChallengeResponse( unsigned char ntowfv2digest[16],
unsigned char serverchallenge[8],
const char *servername, /* ASCII */
const char *domain, /* ASCII */
unsigned char responseout[128],
unsigned short *responseoutsize );
#endif
......@@ -34,7 +34,8 @@ typedef struct {
bool resume_key_encountered;
WORD dir_handle;
bool dir_handle_valid;
DWORD actual_resume_key;
char resume_file_name[DOS_NAME_LEN];
/* Cached state for short names */
BYTE resume_state[SEARCH_ST_SIZE];
} Transact_SearchContext;
......
/* GLOBAL.H - RSAREF types and constants
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/* PROTOTYPES should be set to one if and only if the compiler supports
function argument prototyping.
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags.
*/
#ifndef PROTOTYPES
#define PROTOTYPES 1
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
*/
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
/* MD4.H - header file for MD4C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD4 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD4 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/* MD4 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD4_CTX;
void MD4Init PROTO_LIST ((MD4_CTX *));
void MD4Update PROTO_LIST
((MD4_CTX *, unsigned char *, unsigned int));
void MD4Final PROTO_LIST ((unsigned char [16], MD4_CTX *));
/* MD5.H - header file for MD5C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/* MD5 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
void MD5Init PROTO_LIST ((MD5_CTX *));
void MD5Update PROTO_LIST
((MD5_CTX *, unsigned char *, unsigned int));
void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
File added