With the help of Sergey Malahov I developed a unit by the name "SFTPServer.pas".
This unit provides all the code required to implement an SFTP sever using the Synapse library and the Cryptlib dll.
This unit works perfectly with an SFTP client based on the "SimpleSFTP.pas" unit that is part of the Synapse delivery.
However any attempt to communicate with the server using any other client fails.
In most cases the client authenticates and connects to the server and immediately disconnects.
I was testing with the following clients: Filezilla, PSFTP, WinSCP and "Core FTP LE".
All those clients are available for download from the net.
To my best understanding all those clients are based on "FreeSSH".
My personal feeling is that the problem lies in the Cryptlib library.
I contacted "Piter Gutmann" the author of cryptlib who suggested few modifications to the latest Cryptlib version (3.4.2.0).
Those changes improved the situation but did not solve the problem completely.
I am now offering this unit to the Synapse community in a hope that some one will be able to provide a solution.
Once a solution is found I will gladly contribute this unit to the synapse community for use by others.
Here are the changes that Peter Gutmann suggested to add to the cryptlib 3.4.2.0 code:
change the code at the start of processChannelRequest() at line 520 of session/ssh2_msgs.c to:
const REQUEST_TYPE_INFO *requestInfoPtr = NULL;
const BOOLEAN isChannelRequest = ( prevChannelNo == CRYPT_UNUSED ) ? TRUE : FALSE;
BYTE stringBuffer[ CRYPT_MAX_TEXTSIZE + 8 ];
BOOLEAN wantReply, requestOK = TRUE;
int stringLength, i, status;
assert( isWritePtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isWritePtr( stream, sizeof( STREAM ) ) );
REQUIRES(prevChannelNo == CRYPT_UNUSED || prevChannelNo >= 0 && prevChannelNo <= LONG_MAX);
Also in session/ssh2_chn.c in enqueueResponse(), line 1030, change the code there to:
REQUIRES((noParams==0 && channelNo==CRYPT_UNUSED)||(channelNo >= 0 && channelNo <= LONG_MAX));
Finally in session/ssh2.c in processBodyFunction(), line 990 if you change the code to:
DEBUG_PRINT(( "Read %s (%d) packet, length %d.\n",
getSSHPacketName( sshInfo->packetType ),
sshInfo->packetType, payloadLength ));
DEBUG_DUMP_DATA(sessionInfoPtr->receiveBuffer + sessionInfoPtr->receiveBufPos, payloadLength);
The following ZIP file contains:
- iSftpClient.exe - an SFTP client executable based on then "SimpleSFTP.pas" unit.
- SFTP_2000.exe - an SFTP Server executable based on my "SFTPServer.pas" unit.
- CL32.dll - a Modified Cryptlib DLL (V 3.4.2.0).
- All the *.pas files required to compile the server using Delphi-7.
http://www.pantaray.com/SFTP/SFTP_2000.zip
The sources for the cryptlib library can be downloaded from the following
link:
ftp://ftp.franken.de/pub/crypt/cryptlib/cl342.zip
For more information please email me at: itzik.mintz@pantaray.com