Monday, February 21, 2011

What are some best practices for handling sensitive information?

I'm currently creating an application for a customer that will allow them to automatically bill their customers credit cards.

I'm curious as to what are some best practices to safely store and access the credit card information, and for that matter, any other sensitive information, like social security numbers, account numbers and so on.

I'm assuming encryption of some type will be employed, but before I dig in too deep I wanted to see how others are handling these types of requirements.

Not that it matters, but we are designing the software using Microsoft SQL Server for the database, and using C# and ASP.NET.

From stackoverflow
  • Read the PCI requirements. Everything will be there.

    Actually, you must follow them.

    mattruma : Can you elaborate some more ... maybe provide some links?
    mannu : Of course. :) The credit card companies united in an effort against fraud. Now, everyone who handles credit cards needs to follow these requirements. You can read a little about it here: http://biztechmagazine.com/article.asp?item_id=354
    James Schek : http://www.pcistandard.com/requirements.html
  • Don't - I mean, do you really need to?

    mattruma : I wish it was that easy ... but we have to.
    Simon Gibbs : There is a strong market of third party payment services who can receive the details for you and simply send a you a message when payment has been made. There are alternates like PayPal and you can protect the data with MD5 or SHA1 - discarding trivia such as the exact string of digits.
  • 1 - don't even collect SSNs unless you really need them. And unless you're a bank or the government, chances are you don't.

    2 - don't collect other sensitive info unless you really need to

    3 - use whatever controls are appropriate (separate machine for the database, firewalled, access controlled, etc) for the stuff youdo really need to keep.

  • Different PCI standards compliance is required for different applications. If your application simply collects CC numbers and then submits them to a 3rd party PCI compliant payment gateway, your compliance requirements aren't too bad - provided you don't store the card number or CVV.

    In terms of logging, you should "gut" the credit card number, e.g. retain the first 6 digits and last 3 digits but obscure the intermediate digits. Do not log CVV at all.

    The PCI standard documents go into great detail, but it all depends on the requirements of your application as to what level of compliance you require.

  • Use aggressive standards to secure the host system both in terms of OS and physical security, such as the NSA guidelines.

    Put the database on a separate system from the web server or other functions to prevent physical access and permission escalation exploits.

    Program defensively to avoid SQL injection attacks and similar exploits.

    When developing, program with security in mind first. Coming back afterwards and applying security will be difficult and error prone.

    Try to separate the various parts of the application... i.e. don't use the same viewer or controller for "public" access and "private" access.

    Be aware of and comply with all local laws regarding handling of this data... There are a lot of them out there.

    Keep a supply of envelopes around to notify your customers in the event of a breach. If you lose information for 26 million customers, you might not be able to acquire enough envelopes to meet the legal timeframe for notifying them of a breach.

  • Be intimate with the OWASP threats and know precisely how to counter them in your application and framework. It's hard to believe how many people embrace goofy half-solutions to SQL Injection and cross-site Scripting attacks.

How to let PHP to create subdomain automatically for each user?

Hi,

How do I create subdomain like http://user.mywebsite.com ? Do i have to access htaccess somehow? Is it actually simply possible to create it via pure php code or I need to use some external script-server side language?

To those who answered: Well, then, should i ask my hosting if they provide some sort of DNS access??

From stackoverflow
  • In addition to configuration changes on your WWW server to handle the new subdomain, your code would need to be making changes to your DNS records. So, unless you're running your own BIND (or similar), you'll need to figure out how to access your name server provider's configuration. If they don't offer some sort of API, this might get tricky.

    Update: yes, I would check with your registrar if they're also providing the name server service (as is often the case). I've never explored this option before but I suspect most of the consumer registrars do not. I Googled for GoDaddy APIs and GoDaddy DNS APIs but wasn't able to turn anything up, so I guess the best option would be to check out the online help with your provider, and if that doesn't answer the question, get a hold of their support staff.

  • You could [potentially] do a rewrite of the URL, but yes: you have to have control of your DNS settings so that when a user is added it gets its own subdomain.

  • You're looking to create a custom A record.

    I'm pretty sure that you can use wildcards when specifying A records which would let you do something like this:

    *.mywebsite.com       IN  A       127.0.0.1
    

    127.0.0.1 would be the IP address of your webserver. The method of actually adding the record will depend on your host.


    Doing it like http://mywebsite.com/user would be a lot easier to set up if it's an option.

    Then you could just add a .htaccess file that looks like this:

    Options +FollowSymLinks
    
    RewriteEngine On
    RewriteRule ^([aA-zZ])$  dostuff.php?username=$1
    

    In the above, usernames are limited to the characters a-z


    The rewrite rule for grabbing the subdomain would look like this:

    RewriteCond %{HTTP_HOST} ^(^.*)\.mywebsite.com
    RewriteRule (.*)  dostuff.php?username=%1
    
    Skuta : I've offered the second option to customer, but he prefers the subdomai - it really looks better though
    theraccoonbear : Unless each subdomain is served off of a different server, I would thing creating Canonical Name (CNAME) records would be a better plan. http://en.wikipedia.org/wiki/List_of_DNS_record_types
    Mark Biek : The subdomain does look nice. It's going to be a lot more work to set up though because you'll have to make sure that all subdomain requests get handled properly. This isn't terrible with Apache but might be tricky in a hosted environment.
    Mark Biek : @theraccoonbear Assuming you can use wildcards with CNAME as well, that's a thought.
    Skuta : Does it actually mean that PHP code would have to add a new Rewriterule to htacccess only?
    Mark Biek : If you get the DNS and rewrite rules set up properly, you'll just be passing whatever the current username is into PHP as a GET variable. Then you can handle it from there however you want.
    Mark Biek : PHP shouldn't have to worry about adding anything. It just deals with what gets fed to it.
    Skuta : Mark, I tried to put that "http://mywebsite.com/user into .htaccess however the website did not display. I guess something went wrong with hosting ^^ Some "IIS Password" problem.
    Mark Biek : I should have been more specific. .htaccess is for Apache, not IIS. I'm not sure how url rewriting is handled with IIS but I believe there have been some questions about there on SO.
    Skuta : I've contacted hosting, they said I got to pay some little fee to transfer web from IIS to Linux server ^^
  • If you use Cpanel, this is a very good tutorial.

  • I do it a little different from Mark. I pass the entire domain and grab the subdomain in php.

    RewriteCond {REQUEST_URI} !\.(png|gif|jpg)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?uri=$1&hostName=%{HTTP_HOST}
    

    This ignores images and maps everything else to my index.php file. So if I go to

    http://fred.mywebsite.com/album/Dance/now
    

    I get back

    http://fred.mywebsite.com/index.php?uri=album/Dance/now&hostName=fred.mywebsite.com
    

    Then in my index.php code i just explode my username off of the hostName. This gives me nice pretty SEO URLs.

  • Don't fuss around with .htaccess files when you can use Apache mass virtual hosting.

    From the documentation:

    #include part of the server name in the filenames VirtualDocumentRoot /www/hosts/%2/docs

    In a way it's the reverse of your question: every 'subdomain' is a user. If the user does not exist, you get an 404.

    The only drawback is that the environment variable DOCUMENT_ROOT is not correctly set to the used subdirectory, but the default document_root in de htconfig.

    Skuta : I am not really sure how to use that.. and in the end, why not to mess up with htaccess?
  • We setup wildcard DNS like they explained above. So the a record is *.yourname.com

    Then all of the subdomains are actually going to the same place, but php treats each subdomain as a different account.

    We use the following code: $url=$_SERVER["REQUEST_URL"]; $account=str_replace(".yourdomain.com","",$url);

    This code just sets the $account variable the same as the subdomain. You could then retrieve their files and other information based on their account.

    This probably isn't as efficient as the ways they list above, but if you don't have access to BIND and/or limited .htaccess this method should work (as long as your host will setup the wildcard for you).

    We actually use this method to connect to the customers database for a multi-company e-commerce application, but it may work for you as well.

  • Hi,

    In case you have a cpanel based account, then you can easily create subdomain using php. Here is the link that shows how to create subdomain using PHP.

    http://php-tutor.com/creating-subdomains-automatically/

    This site has more quick php tutorials to various other whm and cpanel functionalies so you can check them out too...

  • The feature you are after is called Wildcard Subdomains. It allows you not have to setup DNS for each subdomain, and instead use apache rewrites for the redirection. You can find a nice tutorial here, but there are thousands of tutorials out there. Here is the necessary code from that tutorial:

    <VirtualHost 111.22.33.55>
        DocumentRoot /www/subdomain
        ServerName www.domain.tld
        ServerAlias *.domain.tld
    </VirtualHost>
    

    However as it required the use of VirtualHosts it must be set in the server's httpd.conf file, instead of a local .htaccess.

    balupton : Why the down vote?
  • wo, is there a way to create subdomains only through a php file ?

    like create a function call createsubdomain($username) or something?

    that would really be helpful in the sense that as soon as a user registers himself on a website, he gets to access hisname.thewebsite.com to access his full profile

    thanks for replues

    equatorlounge.wordpress.com

Why does this remote script cause IE6 to hang?

Please take a look at the html listed below and let me know why IE6 freezes when trying to load the remote script (located at 'http://code.katzenbach.com/Default.aspx'). The script returns JSONP and executes the 'callbackFunction' listed in the header. When it runs correctly, you'll see a pop-up alert showing numbers 1-500. This works fine in FF3 and IE7. I can't understand why it fails in Internet Explorer 6 -the processor gets pegged and everything hangs.

Run it yourself and let me know if you experience the same problem. I've been staring at this problem all day. Thanks for your help.

Andrew

<html>
<head>
    <script type="text/javascript">
    function callbackFunction(Result)
    {
        alert(Result) ;
    }
    </script>
    <script type="text/javascript" src="http://code.katzenbach.com/Default.aspx?callback=callbackFunction&test=true&c=500"></script>
</head>
<body>
Here
</body>
</html>
From stackoverflow
  • How is the script called ?-)

    anschoewe : It's called on load. The 'callbackFunction' function is called when the source of the remote script returns.
  • The return is of the external script is:

    callbackFunction(["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","137","138","139","140","141","142","143","144","145","146","147","148","149","150","151","152","153","154","155","156","157","158","159","160","161","162","163","164","165","166","167","168","169","170","171","172","173","174","175","176","177","178","179","180","181","182","183","184","185","186","187","188","189","190","191","192","193","194","195","196","197","198","199","200","201","202","203","204","205","206","207","208","209","210","211","212","213","214","215","216","217","218","219","220","221","222","223","224","225","226","227","228","229","230","231","232","233","234","235","236","237","238","239","240","241","242","243","244","245","246","247","248","249","250","251","252","253","254","255","256","257","258","259","260","261","262","263","264","265","266","267","268","269","270","271","272","273","274","275","276","277","278","279","280","281","282","283","284","285","286","287","288","289","290","291","292","293","294","295","296","297","298","299","300","301","302","303","304","305","306","307","308","309","310","311","312","313","314","315","316","317","318","319","320","321","322","323","324","325","326","327","328","329","330","331","332","333","334","335","336","337","338","339","340","341","342","343","344","345","346","347","348","349","350","351","352","353","354","355","356","357","358","359","360","361","362","363","364","365","366","367","368","369","370","371","372","373","374","375","376","377","378","379","380","381","382","383","384","385","386","387","388","389","390","391","392","393","394","395","396","397","398","399","400","401","402","403","404","405","406","407","408","409","410","411","412","413","414","415","416","417","418","419","420","421","422","423","424","425","426","427","428","429","430","431","432","433","434","435","436","437","438","439","440","441","442","443","444","445","446","447","448","449","450","451","452","453","454","455","456","457","458","459","460","461","462","463","464","465","466","467","468","469","470","471","472","473","474","475","476","477","478","479","480","481","482","483","484","485","486","487","488","489","490","491","492","493","494","495","496","497","498","499"])
    

    Why do you want to alert this?
    What problem are you trying to solve?

    anschoewe : This was my simplest test to demonstrate the problem I was encountering. I'm actually using the remote script for something else. You'll notice, if you shorten the count to 10, it works (c=10)
    nickf : please try to actually answer the problem rather than pick apart the example given! obviously everyone posts a trivial example of their problem so that people can understand it easier.
    roosteronacid : @nickf: I am not trying to be offensive. And no--it's not obvious that everyone dumbs down their code. Not to me at least.
    anschoewe : I will be using a remote script like this to display search results in our site (the results are coming from a different site). A remote script like this returning json is perfect because I can then use jQuery to render the response.
  • If you go directly to the script (http://code.katzenbach.com/Default.aspx?callback=callbackFunction&test=true&c=500), you'll see the file (unknown mime type) is not being processed. This is likely due to a problem with your server setup. It doesn't seem to know how to process .aspx and in instead trying to stream out the file.

    anschoewe : I'm not sure I follow. This is an asp.net project. It creates a string of numbers and sends it back from the code-behind page. Response.ContentType = "application/json;"; string s = jsonpCallback + "(" + ser1.Serialize(results) + ")"; Response.Write(s); Response.Flush(); Response.Close();
    Diodeus : Ah, I was trying to scoop it as regular HTML, just to see what it was sending back. I usually don't encode as application/json to make it easier to debug.
  • I took a look with Fiddler and IE6 and was unable to see anything out of the ordinary (besides the fact that it freezes the browser).

    The request to http://code.katzenbach.com/Default.aspx?callback=callbackFunction&test=true&c=500 does get made and returns 2909 bytes.

    I'd suggest three things:

    1. Remove one of the semi-colons from your Content-Type: application/json;; charset=utf-8 or maybe remove both semi-colons and charset=utf-8 entirely (just to test)
    2. Send a newline character after you're done sending the final ) of callbackFunction
    3. Change it to Content-Type: text/javascript because you really are returning Javascript to the browser, and the other content type might be confusing IE6 (although it is very unlikely).

    I'm thinking 1. is most likely. There may be a parsing bug in IE6 that causes it to go into an endless loop when it encounters two semi-colons. Because otherwise there simply isn't any reason why what you are doing should not work.

    It also might be worthwhile to try a different MIME type as a test.

    anschoewe : I appreciate the thoughtful ideas, but they didn't worked. I changed the content type (and removed the extra ';'), but it had no affect. I also tried changing (and removing) and character-encoding but it had no affect. If you change the last parameter of the javascript src to 100, it works. hmmm.

Is there a Java standard "both null or equal" static method?

To save some typing and clarify my code, is there a standard version of the following method?

public static boolean bothNullOrEqual(Object x, Object y) {
  return ( x == null ? y == null : x.equals(y) );
}
From stackoverflow
  • I know it can be done in VB - http://www.csidata.com/custserv/onlinehelp/VBSdocs/vbs428.htm, it's the EQV operator.

    It can be done in Perl, and C++ would view (X==Y) fine if both are NULL.

    Based on this page from the Java tutorial from Sun, http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html, it appears to not be possible.

    Chris Conway : In what sense is it "not possible"? It's quite possible: the above method is perfectly legal. The question is whether it's implemented in the JDK.
    Michael Myers : I think maybe he's talking about operator overloading?
    finnw : Your C++ example is not equivalent to the Java version. X and Y could be non-null and point to objects with equal content, and (X==Y) would return false.
  • No. I've seen people suggesting putting a similar method in a utility class, but it isn't in the standard library (the Object class seems like a good place, but who am I to suggest it?).

  • if by some chance you are have access to the Jakarta Commons library there is ObjectUtils.equals() and lots of other useful functions.

    EDIT: misread the question initially

  • No. I've written my own on every project I've been on I think.

  • Can someone say where such a thing is useful ?

    Michael Myers : It just allows you to skip null checks in your equals() method.
    Neil Williams : Only if you only ever use the bothNullOrEqual function... what if you use equals directly in one place?
    Bobby Jack : It does seem strange that you'd want the same behaviour if two objects were equal OR were both NULL ...
    newacct : If you are implementing a Collection, your .contains() method, when given "o" needs to test "if this collection contains at least one element e such that (o==null ? e==null : o.equals(e))." Similarly, your .remove() method has to remove such an element.
  • I have this method.

    For the sake of saving character calories, its named eq.

Vista Window Focus Problem

I have an application that manages patient demographic information. Along with this data a user can scan a picture of a patient and assign that picture to a patient. When the user clicks the scan button a separate application is opened as a dialog in order to scan the image. When running this on XP everything worked fine. The imaging application loaded up fine and gained focus. On Vista however occasionally the imaging application will not gain focus and will popup behind the main application. When running full screen or through 2008 Application Server you cannot see the application, you only get a locked screen and it appears nothing has happened. Is there any way to change the window focus management on Vista to work the way XP did? I'm looking for a way to solve this without making changes to the actual application if possible.

From stackoverflow
  • You could iterate through all top level HWNDs and identify the scanning application via its window class, then send an appropriate message to raise the window.

  • I think you will have to make changes to your application to allow the imaging application to take the focus. I'm going to assume that your application launches the imaging application through ShellExecute or CreateProcess. If so, you can get the process handle of the launched process either through SHELLEXECUTEINFO.hProcess (for ShellExecute) or PROCESS_INFORMATION.hProcess (for CreateProcess). Immediately after launching the imaging application call the AllowSetForegroundWindow API:

    AllowSetForegroundWindow(GetProcessId(hProcess));
    

    This will allow the imaging application to place its main window/dialog in the foreground when it's starting up.

  • You could try the following steps:
    1. Right Click on the exe
    2. Select Properties
    3. Select the Compatibility Tab
    4. Check the Run this program in campatibility mode for:
    5. Select Windows XP (Service Pack 2)

    John Chuckran : I am unable to do this because this application must be able to run from a network drive and you cannot enable compatibility mode on applications stored on a network drive.
  • I don't believe this is Vista vs XP related. I think that simply this imaging app takes longer to start on Vista. Since Windows 2000, the window manager has prevented background applications stealing the foreground. When an application is launched, it has a window of opportunity to create and show a window that will take the foreground. If it takes too long, the window manager thinks that the current window should keep the foreground, and inhibits the other app taking the foreground when it does finally launch.

    I can't think of any specific way to avoid this... other than using FindWindow to search for the other apps window after launching the app. When you eventually find it, call SetForegroundWindow on it to bring it to the foreground.

    John Chuckran : Since the main window thread is locked when the Imaging App is opened it should not prevent the stealing of focus. This was true in XP so it does not happen at all on XP. Vista's DWM is generally better than XP because it treats windows as containers, it just causes problems in this scenario.
    Chris Becke : I have no idea what you mean by "locked" in this context. The window manager doesnt care if the thread that owns the foreground is pumping messages. The no-steal-foreground does not rely on the current foreground window owning thread pumping messages to inhibit foreground theft.
    John Chuckran : Sorry I meant to use the word "Blocked". As in the window does not accept any input until the dialog is closed.
    Chris Becke : You have disabled the application window before launching the imaging application? Disabled windows cannot have foreground activation, so disabling the window will cause the window manager to try and find another window to give the foreground to - a random enabled top level window will be chosen.
    Chris Becke : Create a dialog with no controls just showing the text "Launching Imaging..." on it. Create this dialog modally when launching imaging - it will disable your main frame window, but keep foreground activation on the current thread so the launched app should retain the ability to take foreground.

How to Digitally "Sign" a document

I don't like paper documents. I like everything stored on a server. I'd like to avoid printing, signing, and scanning, if possible.

How do I get signatures from people to sign-off on forms and still keep it digital?

The purpose of signing is to prove that certain departments have OK'd the document. Most of these people are non-technical.

The ideal is that each person would open the document and type in their name and close the document. The problem is that how do I know that Fred didn't sign for Ralph.

From stackoverflow
  • There are myriad approaches discussed in Schneier's Applied Cryptography.

    Much of what you're looking for comes down to a Digital Signature Algorithm (DSA) - of which NIST has one, asymetric encryption algorithms can provide, etc.

    The simple route would be to collect delivery and read receipts on email, but that's not fool-proof.

  • There's two ways to take this question:

    • What technical means can I use to obtain digital signatures?
    • Which means of obtaining digital signatures can I use that will hold up against (insert internal review process here)?

    If they're just for your own records, then the second question isn't important. Otherwise your organization's auditing department is going to have a say.

  • The term "signature" is used a little loosely in this context. It doesn't mean someone using handwriting to sign their name - it means having a person leave some sort of digital data that proves they approved the document.

    Adobe Acrobat has the ability to do digital signatures.

  • Do you have control over the people you're interacting with such that you could make them create GPG keys and use them to sign documents? If so, problem solved.

  • The question you need to ask is "what purpose does a physical signature serve?" A "digital signature" serves different purposes than a physical one. And a physical signature looses pretty much all its value on a scanned document.

    What you probably want is just a way for people to say "yes, I am OK with this". In that case, you just need a web site they can log into and check a box.

    Robert : Realtors have been using faxed copies of signatures to sell houses. I think a "digital signature" is legally binding. Is that what you mean by a signature's value?
    Neall : A faxed copy of a signature is not a "digital signature" - it's just a picture of a signature. Digital signatures are verifiable cryptographic hashes based on asymmetric keys.
  • Each person who might sign a digital document needs a public/private key pair assigned to them, that cannot be forged.

    Then you've got to find a way to keep each person's private key secure - how can that person use it, but nobody else? There is a lot of creative work going on in this area right now. Some of it requires each person to carry a hardware key (card, thumb drive, whatever) which must be used to sign each document. Sometimes the private keys are stored in a database and the signer must provide a password to sign a document.

    A key pair is applied to a document by creating a hash of the document and then encrypting the hash using the private key. The encrypted hash is the 'digital signature' and is attached to the document. Since nobody other than the signer can use the private key (supposedly) you know that the signature is authentic.

    You can verify the signature by decrypting the hash using the public key, which is available to everyone. If the decrypted hash does not match, then either the document was modified after it was signed, or it was signed by someone else.

  • one thing we've been looking into is using the little touch pad on laptops for getting customer signatures. When you think about it, it's not much different than the little thing you use to sign for UPS deliveries. We've found a few APIs floating around with little effort so far.

  • There is software for adding a digital security component to a handwritten signature. The signature is captured using some sort of touchpad device, and stored in the document. Then the software digitally signs the entire document including the signature graphic, to prove that the document was not changed since the signature was applied.

  • Now that you've clarified what you need, I think the best solution is to:

    1. Make a web site
    2. Give people unique log-ins with passwords
    3. Allow them to view the documents
    4. Have a form where they check a box that says "I agree to such-and-such"

    You'll probably also want to include the idea of "groups" so you can expose certain documents to just "The Acme Co. Shipping Dept." and allow any member of that group to sign-off on those documents.

  • There are legal regulations defining what qualifies as a digital signature (electronic signature, or "eSignature"). In the USA, there is an act called "Uniform Electronic Transactions Act" (UETA), describing how a digital signature is defined and used in legal context.

    Basically, the following components may be involved:

    • An electronic document, representing the form with legal obligations when signature is applied.
    • A digital signal (picture, sound, etc.) applied additionally to the above document, serving as a signature, i.e. legally accepted proof of approving the document. (The most straight-forward example is applying a transparent picture of a person's hand-written signature onto a PDF document.)
    • A digital certificate key pair (with validation from approved Certificate Authorities) to "tamper seal" the document. Using the private key to "sign" the document, legal authorities can use the public key to verify the integrity of the document.
    • A "vault" system to store the tamper-sealed document for later legal inquiries.

    One may argue that not all of the steps are necessary; however, in certain industries, step 3 and 4 are required by legal regulations, as these are designated to prevent forgery or spoofing. As a result, step 3 is most likely perform by / with a Notary, and sometimes performed together with step 2.

    For step 2 and 3, APIs and examples are available on the internet. Adobe PDF's API can deal with both steps, and some open-source components can deal with individual steps. One such example of using an open-source component, iTextSharp, is in CodeProject: E-signing PDF documents with iTextSharp. For more information about eSignature in general, please look at the Wikipedia page Electronic Signature.

  • Having been searching for a system to this, I've just found docshaker.com on killerstartups. It pretty much allow you to do as you've just described Neall.

What is the strongest hashing algorithm commonly available today?

I'm building a web application and would like to use the strongest hashing algorithm possible for passwords. What are the differences, if any, between sha512, whirlpool, ripemd160 and tiger192,4? Which one would be considered cryptographically stronger?

From stackoverflow
  • bCrypt - Why would be a very long explanation, for which I recommend Enough With The Rainbow Tables: What You Need To Know About Secure Password Schemes

    Basically, it's secure, it's slow, it's already implemented.

  • Mathematically, no idea. Though, I suppose, the general rule is the longer the final hash, the better -- assuming you can store the difference over a smaller hash.

    Determining collisions is also helpful. And, with that, I'd say your choice of the algorithms you listed.

    TrickyNixon : "the general rule is the longer the final hash, the better". That's very faulty reasoning. I could hash may password as "drowssap" with a zillion random characters after it -- that's a very poor hash. Strength is better determined by the computational complexity.
  • Here's a good post on coding horror about storing passwords. In short, he suggests bcrypt or SHA-2 with a random unique salt.

  • David, those are all plenty strong functions. Even the much-ballyhooed MD5 collisions are not of the password-cracking variety, they just generate two different strings with the same MD5 (a very different proposition from finding a string that generates a given MD5 value).

    If you are concerned about the security of the passwords, you need to worry about the protocols used to store them, the protocols used to recover passwords forgotten by users, and all the other possible avenues of attack. Those options are used far more often to crack passwords than brute-force crtyptanalysis.

    Do use a salt, though.

    But first read the article AviewAnew posted

  • If you are actually concerned about the security of your system (as opposed to the quite academic strength of algorithms) then you should go with a proven and mature implementation instead of nitpicking algorithms.

    I would recommend Ulrich Drepper's SHA-crypt implementation. This implementation uses SHA-512, a 16 character long salt, is peer reviewed and scheduled to go into all major Linux distributions via glibc 2.7.


    P.S.: Once you have reached this level of security, you'll be visited by the black helicopters anyways.