Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

I'm implementing part of the Bitcoin client in C# and noticed that I have the choice between FIPS 140-2 and non certified versions of SHA256. Supposedly both versions give the same hash.

Does the choice of SHA-2 library matter for Bitcoin? Does the FIPS-2 library exist in Mono and mobile devices?

share|improve this question
    
"Does the choice of SHA-2 library for Bitcoin?" Does it what? Is there a grammatical error in that sentence? –  Highly Irregular Dec 19 '12 at 0:45
    
@HighlyIrregular Oops & TY. I missed a word while typing on my cell phone. Incomplete sentences seem to –  makerofthings7 Dec 19 '12 at 1:01
add comment

2 Answers

You should basically never choose FIPS-140 unless you have no choice. FIPS-140 compliance is provided primarily for people who must comply with FIPS-140 for regulatory or policy reasons.

Note that that's not to say FIPS-140 validation is bad. It's great. If it finds bugs or problems, that's a pure win. If you have a choice between an implementation that has been FIPS validated and one that has not, the former is the better choice. But that has nothing to do with whether you enable FIPS-140 modes.

Your implementation has been FIPS validated. Don't brain damage it.

share|improve this answer
    
Would upvote if you said why FIPS-140 is less desirable. –  Highly Irregular Dec 19 '12 at 0:47
1  
Too many reasons. For one thing, say you find a bug in your FIPS validated code. Do you pay $35,000 to fix it (since you'll need a new validation) or do you leave the bug in? And FIPS requires you to break things that are perfectly capable of working. Also, FIPS modes are maintained under the assumption that nobody will ever enable them. They're only there so that you can put a checkmark in the "FIPS validated" box. If you enable FIPS mode and something doesn't work and you file a bug report, you will be told "disable FIPS mode". –  David Schwartz Dec 19 '12 at 3:51
add comment

Here are some performance stats I've come up with so far for my C# implementation:

A single ECC public key (after the ECC operation) can have the Base58Checked algorithm applied at this rate

   Algorithm                             Time for 100,000 Base58Check(byte[] key)
   ------------------------------       ---------------------------------------------
   SHA256Managed()                       4500ms
   SHA256CryptoServiceProvider()         3640ms  <--- CSP FIPS version

So yes, the FIPS validated version is faster & likely better.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.