Why is the password not decrypting correctly?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

shaulbehr
Posts: 24
Joined: 15 May 2011, 11:00

Why is the password not decrypting correctly?

Postby shaulbehr » 22 May 2011, 11:41

I'm writing a server side extension with custom login code. Here's the code:

Code: Select all

String encPwd = (String) event            .getParameter(SFSEventParam.LOGIN_PASSWORD);
ISession session = (ISession) event.getParameter(SFSEventParam.SESSION);
encPwd = encPwd.toLowerCase();
String clearPwd = CryptoUtils.getClientPassword(session, encPwd);

But the value of clearPwd is not what I sent in - instead, it's a string that looks like some kind of hex number, and it changes with each new session, e.g. "f94f56419f6fd58a5d96b63246db2723"

What is more, I suspect something is very awry, because if you look at the interface definition in Javadocs you'll see:

Code: Select all

public static String getClientPassword(ISession session, String clearPass)

Why is the parameter called "clearPass"? Surely it should be called "encryptedPass"? The return value should be clearPass!

Am I wrong - or is this a bug?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 22 May 2011, 13:31

you can't decrypt the password, it's one way. You should use 'checkSecurePassword' to validate the received password
shaulbehr
Posts: 24
Joined: 15 May 2011, 11:00

Postby shaulbehr » 22 May 2011, 13:40

No, that doesn't work.
What if the password is hashed on my SQL database?
I want to be able to hash a password and compare it to the hash on my DB in order to validate.
What you're saying is that the incoming password is *also* hashed, meaning I cannot decrypt it, and if I need to validate it against another database, well, then that's just too bad.
Seriously? SFS was designed with this kind of "customizable" login in mind, such that you can't actually do a custom login?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 22 May 2011, 13:57

1. it does work since i'm using it.
2. checkSecurePassword was created to do just that what you are saying.
Compare the encrypted password received from the client against a password.
shaulbehr
Posts: 24
Joined: 15 May 2011, 11:00

Postby shaulbehr » 22 May 2011, 14:02

appels wrote:1. it does work since i'm using it.
2. checkSecurePassword was created to do just that what you are saying.
Compare the encrypted password received from the client against a password.

Sorry, my wording was ambiguous - I meant "No, that doesn't work [as a solution for me]."

Let me be clearer about my scenario: I have a hashed password in my MS-SQL database. Hashed, i.e. cannot be decrypted. In order to validate the password, I need to take the candidate password and hash it using the same hashing algorithm, then compare the hashes.

What you are saying is that this mode of login validation is not supported by SFS2X. Am I correct?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 22 May 2011, 14:05

I also have hashed passwords in my database, send the hash to SFS, use the command to compare the hash against the hash in the database.
shaulbehr
Posts: 24
Joined: 15 May 2011, 11:00

Postby shaulbehr » 22 May 2011, 14:22

appels wrote:I also have hashed passwords in my database, send the hash to SFS, use the command to compare the hash against the hash in the database.

How is that possible? How could SFS possibly know what algorithm I'm using to hash my passwords?
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 22 May 2011, 14:26

which encryption scheme are you using ?
shaulbehr
Posts: 24
Joined: 15 May 2011, 11:00

Postby shaulbehr » 22 May 2011, 14:36

appels wrote:which encryption scheme are you using ?

I use my own formula for encrypting passwords. Completely unique. That's why I would be pretty much stunned if SFS knew how to copy it! :wink:
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 22 May 2011, 14:41

I don't know the specifics on how the command works or what it supports but using MD5 works fine that way i explained.
shaulbehr
Posts: 24
Joined: 15 May 2011, 11:00

Postby shaulbehr » 22 May 2011, 15:21

In other words, SFS does not support custom hashing; you have to have access to the user's clear text password from your own database (i.e. no custom-hashed passwords), or you can't use SFS.

As it happens, I can work around that - but IMHO that's a very severe design limitation in SFS, and the programmers should seriously look at creating an interface that allows you to decrypt the incoming password into clear text.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 22 May 2011, 15:33

Hi. What about this:

1. In the client, instead of sending the clear password, you send the password hashed with your own scheme.
2. In the server-side, you get the password from the db and then you can already use the checkSecurePassword()
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 22 May 2011, 17:11

i'm a big noob when it comes to encryption but making it possible to decrypt a password seems like an open door to hacking to me. Which would be an even bigger flaw in the design. But i'm sure Lapo can chime in with more a more technical explanaition.
And indeed the way i explained before might also work for custom encryption but again...i'm not the expert.
Neznajka
Posts: 10
Joined: 14 Jun 2012, 09:12

Re: Why is the password not decrypting correctly?

Postby Neznajka » 20 Sep 2012, 12:32

you may send all parametres you need to encrypt in ISFSObject and then do encrypting password on server. if password is crypted corectly then all will be ok.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Why is the password not decrypting correctly?

Postby rjgtav » 23 Sep 2012, 22:55

Well, the only problem is that you're sending the "clear" password over the internet... That's why the API automatically hashes the password before sending it with the LoginRequest
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 81 guests