I need some suggestions about the use of the CRC in my application. I need to be sure about the BIOS run by the CPU. I have a FPGA between the BIOS flash and the CPU that sniff every read performed by the CPU on the BIOS memory. The initial idea was to compute the SHA1 of the data stream to authenticate and to be sure about the correctness of the BIOS. The resulting digest is stored inside the bitstream of the FPGA. Is it enough safe to use the CRC in this application ?


No, it is not safe to authenticate the BIOS in that way. CRC should be used as checksum only, i.e. to avoid random bit flips. For larger random changes you should use CRC32 at the minimum.

If you want to protect against malicious change you need a cryptographically secure hash. the reason for this is that any attacker can create a malicious BIOS that calculates to a particular CRC.

SHA-1 is under attack although it is not broken yet. If it is broken, it will be broken exactly for the purpose you are using the hash though. So it is better to upgrade to SHA-256 and/or SHA-512 (whichever is faster on your machine).

Note that cryptographic hash functions do not take a key. So for authentication you need additional measures. You could rely on signature generation (e.g. PKCS#1 v1.5 padding + modular exponentiation for RSA) or - for symmetric keys - a HMAC. Both of these rely on an underlying hash function for security. With HMAC you could use SHA-1 by the way.

As lightweight software hash Blake2b is often mentioned here, but this requires a bigger understanding of hash functions. If possible stay with SHA-2.

|improve this answer|||||
  • $\begingroup$ Actually I already perform an HMAC with a SHA1 but in my opinion, for my application, It's useless if I store the digest inside FPGA. My only purpose is to be sure that the CPU run only my BIOS and not a modified BIOS. Let me clarify, I don't want to perform the CRC of the BIOS memory flash, I want to perform the CRC of the stream of data that CPU reads from the BIOS memory flash ( they are linked through a SPI bus ). Analyzing the bus SPI, I saw that there are several and unpredictable ( for my knowledge ) jumps inside the memory. Is it so simple to make a modified BIOS that has the same CRC? $\endgroup$ – haster8558 Jul 2 '15 at 7:50
  • 1
    $\begingroup$ @haster8558, If there's any part of the BIOS where you can put arbitrary data it's trivial to create another with the same CRC. $\endgroup$ – otus Jul 2 '15 at 8:01
  • $\begingroup$ A CRC is enough to protect against random changes. What you seem to be protecting against is a system where a lot of data may be changed in one go, without an attacker being able to chose the input of the checksum. In that case a large CRC could be possible. Assuming that the CRC32 is randomly distributed you would get a change of 1 in $2^{32}$ (or 1 in 4 bilion) that the CRC verifies for incorrect input. $\endgroup$ – Maarten Bodewes Jul 2 '15 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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