473,587 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Password authentication systems

This may only be tangentially related to Python, but since I am coding
a password authentication system in Python, I thought I would ask here.

In Linux (and presumably other *NIX systems that support it), when
shadow passwords are enabled, the actual password is not stored.
Instead an encrypted version is stored. Then, to authenticate the
password, the system re-encrypts the user's input to see if it matches
the stored, encrypted version.

Presumably, this is done using the crypt() system call (and,
fortunuately, Python has a builtin crypt module!). Presumably, as
well, this is at least somewhat secure, assuming a source of
cryptographic randomness to use to choose the salt. Are SHA1 and MD5
suitable for this sort of thing as well, or would I need to move to
something more "industrial strength" from, say, the pyCrypto module if
I wanted to avoid a dependency on the crypt module?

Aug 10 '06 #1
9 2828
ne*******@gmail .com writes:
Presumably, this is done using the crypt() system call (and,
fortunuately, Python has a builtin crypt module!). Presumably, as
well, this is at least somewhat secure, assuming a source of
cryptographic randomness to use to choose the salt. Are SHA1 and MD5
suitable for this sort of thing as well, or would I need to move to
something more "industrial strength" from, say, the pyCrypto module if
I wanted to avoid a dependency on the crypt module?
The salt doesn't really have to be cryptographical ly random.
There are two main issues:

1) Unix password hashing uses several different algorithms depending
on version and configuration. Do you need to interoperate, or are you
just trying to do something similar?

2) Even with salting, computers are fast enough thse days to run
dictionary searches against unkeyed hashed passwords, so Unix now uses
a non-publicly-readable shadow password file. You're best off hashing
with an actual secret key, if you have a way to maintain one. I'd
suggest using the hmac module:

hash = hmac.new(secret _key, password).hexdi gest()

will give you a hex digit string; or if you prefer, you could use
..digest() instead of .hexdigest() and base64 encode it if you want
printable output. Keep in mind, though, that if the secret key leaks,
you effectively have an unsalted hash. You could add a salt if
you want (untested):

import os
salt = os.urandom(8) # 8 random bytes
hash = (salt, hmac.new(secret _key, salt + password).diges t())

note that the salt and hash are both binary. You may want to encode
them (e.g. base64) if you need printable chars.
Aug 10 '06 #2
First, I'd just like to say, wow, and thanks to both you and Sybren for
your fast responses. :) Twenty minutes is less time than it takes to
get an answer from some companies paid tech support. ;)

Paul Rubin wrote:
There are two main issues:

1) Unix password hashing uses several different algorithms depending
on version and configuration. Do you need to interoperate, or are you
just trying to do something similar?

2) Even with salting, computers are fast enough thse days to run
dictionary searches against unkeyed hashed passwords, so Unix now uses
a non-publicly-readable shadow password file. You're best off hashing
with an actual secret key, if you have a way to maintain one. I'd
suggest using the hmac module:
To answer your questions, 1. there's no need for any sort of
interoperabilit y. Otherwise, the obvious thing to do is to look up the
particular system(s) I needed to interoperate with and find out what
algorithm(s) are used there. This is a password authentication system
intended for a game server (a MUD/MMOG, in fact). The real limiting
factor here is that I want to keep the server accessible via pure
telnet protocol. Otherwise, using SSH would make sense.

For my particular use case, simply using crypt() or MD5 or SHA1 would
certainly be adequate, as I don't intend to charge money for people to
play on my particular server. But, there is always the possibility that
someone might want to do so, and, when money is involved, it always
pays to be extra careful. (Of course I do realize that it would make
sense to have any credit-card verification system isolated on a
separate server entirely, not accessible to the internet, simply so
that if the game server is compromised, it's much harder to get credit
card details. But, I digress.)

I had considered the hmac module. The thing that bugs me about it is
that I'd have to keep this secret key around someplace accessible to
the server. Most likely, this means storing it in a file. I'd guess
that if someone could steal a file containing all my users' passwords,
then they could also access this (since the server itself would need
access.) Essentially, I guess it's an issue with maintaining the
secret key that I haven't fully considered yet.

Aug 10 '06 #3
ne*******@gmail .com writes:
This is a password authentication system
intended for a game server (a MUD/MMOG, in fact). The real limiting
factor here is that I want to keep the server accessible via pure
telnet protocol. Otherwise, using SSH would make sense.
If you're going to broadcast passwords in the clear over the network,
that's a pretty big leak as well, that obscuring the stored
server-side checksums won't help with. Will the game players use a
special client program? If yes, use SRP (http://srp.stanford.edu).
This has already been implemented in Python several times.
I had considered the hmac module. The thing that bugs me about it is
that I'd have to keep this secret key around someplace accessible to
the server. Most likely, this means storing it in a file.
Yeah, this issue is traditionally a nuisance, especially if the server
has to restart itself after a crash. If you start the server
manually, you can type in a passphrase.
Aug 10 '06 #4

Paul Rubin wrote:
ne*******@gmail .com writes:
I had considered the hmac module. The thing that bugs me about it is
that I'd have to keep this secret key around someplace accessible to
the server. Most likely, this means storing it in a file.

Yeah, this issue is traditionally a nuisance, especially if the server
has to restart itself after a crash. If you start the server
manually, you can type in a passphrase.
Ah, yes, I see I failed to mention that I would like the server to at
least try and restart itself after a crash. Hence, my earlier
apprehension at using a stored secret key.

I realize that having the players communicate with the server via plain
telnet is a huge security hole. For a commercial server, I'd probably
do things differently, but, again, for a free game server, the idea is
to allow players with ordinary telnet or MUD clients to connect without
problems.

My goal is to keep user passwords as safe as possible, assuming someone
did decide to steal the password files. I'm willing to punt versus
attacks that will intercept the password between the player and the
server in order to allow the player to connect with a non-custom
client. This requirement might evolve in the future, but, for now,
that's how I'm envisioning things.

Aug 11 '06 #5
ne*******@gmail .com writes:
My goal is to keep user passwords as safe as possible, assuming someone
did decide to steal the password files.
How often will new accounts be added? I have an idea I might try to
code up.
Aug 11 '06 #6

Paul Rubin wrote:
ne*******@gmail .com writes:
My goal is to keep user passwords as safe as possible, assuming someone
did decide to steal the password files.

How often will new accounts be added? I have an idea I might try to
code up.
Frequently, I hope. Realistically, when I open my personal MUD server,
what I expect is an initial flurry of new accounts (say, up to 100 a
day, just to overestimate), then slowing down to a steadier state
(again, say 10 per day, to overestimate).

I'm curious about this idea, in any case. :-) If you decide to "code
it up," that's great... otherwise, I'd appreciate if you emailed me to
discuss it away from comp.lang.pytho n.

Thanks!

Aug 11 '06 #7
ne*******@gmail .com wrote:
This may only be tangentially related to Python, but since I am coding
a password authentication system in Python, I thought I would ask here.

In Linux (and presumably other *NIX systems that support it), when
shadow passwords are enabled, the actual password is not stored.
Instead an encrypted version is stored. Then, to authenticate the
password, the system re-encrypts the user's input to see if it matches
the stored, encrypted version.
Correct me if I'm wrong, but I believe that all Linux passwords are
encrypted whether you enable shadow passwords or not. I believe that when
you enable shadow passwords, the encrypted passwords are stored in a file
other than 'passwd'. Is this not correct?

Aug 11 '06 #8
AlbaClause <yo*@cogeco.caw rites:
Correct me if I'm wrong, but I believe that all Linux passwords are
encrypted whether you enable shadow passwords or not. I believe that when
you enable shadow passwords, the encrypted passwords are stored in a file
other than 'passwd'. Is this not correct?
Yes.
Aug 11 '06 #9
Enabling shadow passwords stores them in /etc/shadow which is not world
readable unlike /etc/passwd. They would be encrytped regardless of the
file they are in.
AlbaClause wrote:
ne*******@gmail .com wrote:

>This may only be tangentially related to Python, but since I am coding
a password authentication system in Python, I thought I would ask here.

In Linux (and presumably other *NIX systems that support it), when
shadow passwords are enabled, the actual password is not stored.
Instead an encrypted version is stored. Then, to authenticate the
password, the system re-encrypts the user's input to see if it matches
the stored, encrypted version.


Correct me if I'm wrong, but I believe that all Linux passwords are
encrypted whether you enable shadow passwords or not. I believe that when
you enable shadow passwords, the encrypted passwords are stored in a file
other than 'passwd'. Is this not correct?

Aug 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3196
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a password (plain text): 1) Validate that the password is correct for that user *without actually logging in*. 2) If the password is valid, return a...
7
2916
by: jrefactors | last post by:
I want to ask how password is stored and how to check the authentication? I have heard password is never encrypted and decrypted, but it is hashed. For example, consider a simple email logon authentication in a hash table: Key: my email address Value: hash_function(my plan text password)
3
7116
by: Oren | last post by:
Hi, Is there a way to hide the connection information of linked SQL Server tables from users? It's easy to open a system table and find the connection info, and if the username and password are saved with this info, anyone could potentially access this information. Much thanks, Oren
5
4501
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and password would be different than the one the user enters for ASP.NET forms authentication. The ID/password in question is used by the application,...
4
2308
by: Zachary Hilbun | last post by:
I need to write an ASP that requires a user to give a User Name and Password to run it. Whenever I've used this on the Web it displays a standard dialog and then offers to save the User Name and Password on my computer so that I don't have to enter it again. How is it that this standard dialog is displayed? Does the ASP (in my case C#) do...
2
4484
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? I'm trying to figure out the best way to handle domain users to log into an .asp application tied with SQL Server 2000 on the back end since I keep...
3
2709
by: Noel S Pamfree | last post by:
Problem 1 ======= I need to create a page for a friend who operates a school website. She needs to set up a page so that only the Governors can access it. I thought I'd try to use JavaScript to prompt for a password. (I am only an amateur at writing JavaScript). It works fine in my tests when using Firefox but when I load the page in...
9
15507
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and check the password. The thing is I can't access the password attribute to compare with the user's password provided.
1
1527
by: rajendran1983 | last post by:
I have windows XP pro systems with network having workgroup. i dont have domain. If am accesing a system from my workgroup its opening without prompting for username and password. I just want to set Username and password authentication whenever an user accessing a system in LAN.Can anyone help me to solve this?
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.