2

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?

2
  • "Does the choice of SHA-2 library for Bitcoin?" Does it what? Is there a grammatical error in that sentence? Commented Dec 19, 2012 at 0:45
  • @HighlyIrregular Oops & TY. I missed a word while typing on my cell phone. Incomplete sentences seem to Commented Dec 19, 2012 at 1:01

2 Answers 2

2

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.

2
  • Would upvote if you said why FIPS-140 is less desirable. Commented Dec 19, 2012 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". Commented Dec 19, 2012 at 3:51
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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