Alternatives to hardcoding a password into the source code

G

Gyruss

Dear all,

I've written an application that connects to a unix box from windows via
ssh. I use public/private key authentication to do so.

The private key is embedded in the application jar file. The private key is
password protected. The password for the private key is hard coded into the
source code.

Is there any sensible alternative to hard-coding the password into the
source code in this situation?

Cheers!
 
S

Sebastian Scheid

Gyruss said:
Dear all,

I've written an application that connects to a unix box from windows via
ssh. I use public/private key authentication to do so.

The private key is embedded in the application jar file. The private key
is
password protected. The password for the private key is hard coded into
the
source code.

Is there any sensible alternative to hard-coding the password into the
source code in this situation?

The only secure way I know is not to hardcode sensible data. The user of
your app has to enter the password. You cannot prevent anybody from
decompiling your code. Even an obfuscator does not protect you but only
makes it a little harder for the bad guy.

Perhaps a native compiler could help to make it more difficult (but not
impossible) to decompile your app. But that surely depends on the attacker's
skills.

Regards
Sebastian
 
C

Chris Uppal

Gyruss said:
I've written an application that connects to a unix box from windows via
ssh. I use public/private key authentication to do so.

The private key is embedded in the application jar file. The private key
is password protected. The password for the private key is hard coded
into the source code.

What exactly are you trying to protect ?

Your description is incomplete, but it sounds odd to me that you should be
using private/public key encryption for anything and distributing the /private/
key -- that's exactly what private/public key encryption is designed to avoid.

-- chris
 
L

Lucy

Gyruss said:
Dear all,

I've written an application that connects to a unix box from windows via
ssh. I use public/private key authentication to do so.

The private key is embedded in the application jar file. The private key is
password protected. The password for the private key is hard coded into the
source code.

Is there any sensible alternative to hard-coding the password into the
source code in this situation?

Cheers!
md5
 
W

Wibble

Gyruss said:
Dear all,

I've written an application that connects to a unix box from windows via
ssh. I use public/private key authentication to do so.

The private key is embedded in the application jar file. The private key is
password protected. The password for the private key is hard coded into the
source code.

Is there any sensible alternative to hard-coding the password into the
source code in this situation?

Cheers!
The usual pattern is to encode the password and store the encoded
password. Then check that the supplied plaintext password encodes to
the same string. You can put the encoded passwords into a file instead
of hardcoding into your program. The file needs to be read only.
 
K

Kenneth P. Turvey

Wibble said:
The usual pattern is to encode the password and store the encoded
password. Then check that the supplied plaintext password encodes to
the same string. You can put the encoded passwords into a file instead
of hardcoding into your program. The file needs to be read only.

I think you are misinterpreting what the OP said. He needs a way to unlock
(decrypt) the private key while the program is running. It sounds like he
needs to be able to do this without user intervention. Any method of doing
so is going to have security implications that aren't good.

The best way to handle this is probably to have someone enter the passphrase
when the program is started and have the program simply wait until it is
time to do something. It can run in the background as a daemon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top