Solved

Secure Handshake WIth Delphi & Indy

Posted on 2004-04-15
8
1,052 Views
Last Modified: 2010-04-05
Hi All,

What is the best way for a client to authenticate with a server using the TCP/IP components of Indy (standard TCP client and server components)?

The server has a list of users and passwords, the client software needs to authenticate through the server with that list. It is VITAL that any transmission that is captured between the client and server cannot be used to authenticate by someone else on the network (for example someone using a network tool to capture network traffic).

I am trying to get my head around how this would work with Indy / Delphi.

I have read one entry on experts exchange about "secure handshake with TCP/IP", but it looks like the way that is done is by sending a random string to the client in clear text, then the client hashes it and sends it back, and the server compares the hashed values. However, can't someone capture the first "random string" and then do the same hashing to "fake" a session?

Tough one for me :-)
0
Comment
Question by:EdgeMan
  • 4
  • 2
  • 2
8 Comments
 
LVL 7

Expert Comment

by:sftweng
ID: 10838662
Think in layers. TCP/IP establishes a session at a lower level than you desire. What you want is in a layer above the transport layer (TCP). By sending a userid/password pair in clear text within a TCP packet, you are exposed to someone "snooping".

You need a protected mechanism for authentication. This will involve encryption.

Encryption falls into two categories - symmetric and asymmetric.

With symmetric encryption, the sender and receiver share a secret, delivered ideally over a different channel (e.g., email). This is the realm of DES and XOR with a one-time pad.

Asymmetric encryption relies on "Public Key Encryption", in which each correspondent hold half of the answer - a private and a public key. Both are required to transform an encrypted message into clear text.

Emphasis in recent years has been on the latter end there are many ways of doing the necessary secured "handshaking". You could, for example, use PGP or a certificate from one of the 1st-line PKI (Public Key Infrastructure) companies, who establish a degree of "trust".

This is a very complex issue and I recommend that you adopt something very simple. You could go whole hog and try something like Microsoft's "Passport" but you're probably better off with something like PGP.

I'm afraid I can't put much more time into this particular posting but I'll try to expand on the topic a bit later. There is a PGP interface for Delphi and I'll find it for you.

Alan
0
 
LVL 7

Expert Comment

by:sftweng
ID: 10838990
I'm back but it's hard to know where to start. If you go to Google and enter the search term "+pgp +delphi", you'll find a number of Delphi interfaces to PGP, e.g., http://dmoz.org/Computers/Programming/Languages/Delphi/Cryptography/.

One of the principles of computer security is that nothing is ever absolutely secure. All one can do is raise the "work factor" in compromising a security system to be so high that a potential cracker would choose other mechanisms to break in - e.g., by bribing an employee of the target company.

You should do a risk assessment. What is the potential cost of compromised security? What damage could be done if a userid/password pair were to be discovered by a snooper?

Then you should estimate the probability of such an occurrence. Encryption can halp to decrease this probability.

The product of the two (damage cause by compromise) * (probability of compromise) is a good number to conside as worth expending on protecting your system (like buying insurance).

Without knowing more about your risk assessment, it's difficult to make specific recommendations, although there are now interfaces within most operating systems to provide a good degree of protection.

How much do you want to spend on this? (Rhetorical question).
0
 

Author Comment

by:EdgeMan
ID: 10839025
Good points.

The problem is that the system will transmit confidential information across the Internet. So, the more security the better.

What about if I deploy all client software with the public key of a keypair, the server will have the private key. That way I could send the authentication request from the client to the server encrypted. The problem is if the server needs to send some information back to the client software, I think (correct me if I am wrong) that the information from the server to the client can NOT be encrypted in this scenario because the client is unable to decrypt any information.

The plot thickens!
0
 
LVL 7

Expert Comment

by:sftweng
ID: 10839394
You might be able to tackle this from two different layers.

The first is with a virtual private network (VPN). This would be independent do anything you do with the application but might be beyond your control. If the client and server can be brought into a VPN, then your application software need not have any further protection (unless there's a threat on the LAN at either end).

Assuming that you cannot establish a VPN, a public key approach could work both ways. If you distribute your software with a pre-configured key pair, unique for each client, then your problem is solved because you will have established a trusted connection.

Alternatively, if you must create a key-pair dynamically, you have the choice of using a company that provides a PKI (public key infrastructure) or exchange keys through some other mechanism (say a hard-coded symmetric algorithm, using some characteristic derived by the client environment to build the PK key pair).

Once again, it all comes down to the work factor (risk).

In the deployment scenario you described, you could send an encryption key pair to the client using the server's keys, unique to the client and assumed for all reverse traffic.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10850010
Edgeman...

Wot r u trying to do ?

A Database Application that transfer data between client and server..?
some kind of a Client Server that ll connect to  a server and retrieve any kind of data ?
Or u just want to Connect to a server in a encrypted way .. ?

They all change the way u take ...

If u ll only connect to a server in a encrypted way .. u can use Ras to create a encrypted VPN connection ..
Or if u ll transfer data .. create a encrypted connection Again with ras and sedn ur data ..

or if u ll make an Database application .. Which collects and sends data to a specific server.. Use Midas type applications... It has its own Encrytion method..



0
 

Author Comment

by:EdgeMan
ID: 10853071
I need to transmit confidential information and files, so I could use Midas (DataSnap), although the file transfer would still need to be encrypted (files are not stored in a database on the server).

0
 
LVL 7

Accepted Solution

by:
sftweng earned 500 total points
ID: 10853196
You might like to visit: http://csrc.nist.gov/CryptoToolkit/

and consider using the AES algorithm: http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf

There's a Delphi implementation at: http://www.eldos.org/elaes/elaes.html

There are other implementations: search Google with "+aes +delphi"
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10854186
Ok..

make Connection via Encrypted VPN.

Use datasnap for DB Operations..

and with the encryption of the VPN everything thats is send by the server ll be secure ..And u dont ave to encrypt something with codes..

Best way is that ..

Install RAS on ur server.. Enable VPN Connections. Add Accounts.. And Create a Group for accounts.. Than Crate a Group policy for ur VPN Connection Accounts.. Set the parameters in this GP. Allow only Encrypted Connections..  

And Transfer wot ever u want in a secure way ..

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now