Design Article
Cryptography for embedded systems - Part 2: To optimize or not to optimize...
Timothy Stapko
6/14/2010 2:13 PM EDT
12.3 To Optimize or Not to Optimize...
So far in this chapter we have focused on the choice of a single class of algorithms, hashes, as a way to get the most performance out of our security. While hashes are extremely useful for a wide variety of applications, they really cannot provide the same level of data protection
that a "true" cryptographic algorithm, such as AES, can provide.
One of the problems with hashes is that they produce a fixed-size output for arbitrary-length data. It doesn't take much thought to realize that if the message is larger than the size of the hash (and maybe even if it is smaller), some information is lost in processing. While hashes can work to give you a guarantee (large or small) that the data is intact and represents the original information, they cannot be used (at least directly) to encode the data such that it is extremely difficult for an attacker to get at it, but also can be decoded back into the original information given the proper "key."
Hashes are, by nature, one-way operations, there is no way to build the original data from a hash value (in general, anywayyou may be able to guess at it if the message was small enough). To be able to effectively communicate information securely, it is vital that the data remains intact, albeit obfuscated, in the encrypted message. For this we need "true" cryptography as is found with symmetric and asymmetric encryption algorithms.
We talked about encryption algorithms and what they do in previous chapters, so we will not go into too much detail about symmetric and asymmetric cryptographic algorithms here, but the important things to remember are the essential properties of the different classes of algorithms. For your reference, we summarize the useful properties (and consequences of using) each of the classes of algorithms:
• Hashesfast, efficient algorithms generally useful for verifying the integrity of data but provide no means to otherwise protect information.
• Symmetricfast (relatively slow compared to hashes in general though), general-purpose encryption algorithms. The problem is that the keys need to be shared between receiver and sender somehow (and that sharing obviously cannot be done using a symmetric algorithmkeys must be shared physically or using another method).
• Asymmetricslow, special-purpose algorithms that provide the useful ability to facilitate communications without having to share secret keys (public-keys obviously need to be shared, but that's generally pretty easy).
The rest of this chapter will cover the basics for optimizing cryptography for embedded applications. We covered hashing above because those algorithms are already very fast and can be used to provide a small level of security (assuming you don't care about eavesdroppers, anyway). The other cryptographic algorithms (symmetric and asymmetric) are much slower in general, and their relative performance may affect embedded applications significantly. With hashes out of the way, we can focus on the slower algorithms and just what we can do to make them a little faster.



