Chapter 3. Adding Hardware Security with the CryptoCape

This chapter continues our custom security hardware journey by using a BeagleBone Black (BBB) cape. In BeagleBone parlance, a cape is a daughterboard that attaches to the BBB. We'll briefly introduce hardware cryptographic devices and then explore the CryptoCape, which is a BBB cape containing numerous security features. We'll describe the process of creating your own cape using the CryptoCape as an example. This chapter introduces the crypto chips on the cape and shows you how to implement a biometric authentication device using the CryptoCape and a fingerprint scanner.

This chapter will discuss the following topics:

  • The pros and cons of hardware-based cryptography
  • An overview of the CryptoCape
  • How cape EEPROMs enable automatic hardware configuration on the BBB
  • How to use the CryptoCape's real-time clock
  • How to program an ATmega328p from BBB
  • How to implement a biometric authentication system

Exploring the differences between hardware and software cryptography

In the following sections, we'll discuss the advantages and disadvantages of using hardware-based cryptography. The remaining projects in the book will use embedded hardware cryptographic devices, so it's important to know their capabilities and their limitations. Refer to Chapter 1, Creating Your BeagleBone Black Development Environment, for additional resources on cryptography and terms used in this section.

Understanding the advantages of hardware-based cryptography

For the advantages of hardware cryptography, we'll focus on the embedded environment since that is the target use case of BBB. While chip manufacturers may provide a laundry list of advantages, there are two main categories: cryptographic acceleration and key isolation features.

Offloading computation to a separate processor

One advantage of using a dedicated cryptographic co-processor is to offload computation to reduce CPU usage. A typical example is using hardware to perform the Advanced Encryption Standard (AES) encryption and decryption operations in a Transport Layer Security (TLS) session.

TLS is most commonly used in conjunction with the Hypertext Transfer Protocol Secure (HTTPS) protocol. You use HTTPS every time you buy something online to protect your credit card information. Depending on your browser, you may notice a lock icon or a green bar to indicate when a web page is served over HTTPS. In a TLS session, the client, your browser, and the server will negotiate to use the same symmetric key. While there are several symmetric ciphers that can be negotiated, AES is one of the preferred choices.

Note

While some sites automatically redirect you to the HTTPS version of the site, often you must manually specify this. Remembering to type https:// is often annoying but fortunately there is a cross-browser plugin that will automatically redirect you to the HTTPS site, if there is one. The plugin is called HTTPS Everywhere and it is maintained by the Electronic Frontier Foundation. Information and links to download the free software are located at https://www.eff.org/https-everywhere.

In the crypto accelerator role, a cryptographic co-processor would perform the encryption and decryption of each TLS record. This offloads the main CPU to handle the processing of the network traffic and perform the intended application. The BBB actually has such a cryptographic co-processor. Texas Instruments (TI) crypto performance page for the AM335x, the processor on the BBB, shows the results of their benchmark tests with OpenSSL. Using AES with a 256 bit key size and operating on blocks of 8192 bytes, the measured throughput of data was 8129.19 kB/sec without using crypto acceleration. This test resulted in a CPU usage of 69 percent. However, using the crypto co-processor on the AM335x, they measured a throughput of 24376.66 kB/sec with a CPU usage of 41 percent. That's almost a 200 percent gain in throughput performance and a 40 percent drop in CPU usage!

Note

More information on the crypto accelerators on the AM335x can be found on TI Crypto Performance page at http://processors.wiki.ti.com/index.php/AM335x_Crypto_Performance.

If your embedded application's purpose is to perform a computationally intense calculation, using a cryptographic co-processor designed to offload the crypto processing can save your CPU cycles for your main program.

Protecting keys through physical isolation

A major advantage of using hardware cryptography devices is that keys can be generated internal to the device and are designed to be difficult to remove. In the web server world, these devices are called Hardware Security Modules (HSMs). In April 2014, a major vulnerability was announced that affected the OpenSSL software, colloquially called heartbleed. The vulnerability was not a cryptographic one per se, but rather the result of a programming error called a buffer overrun. This vulnerability is unfortunately common in the C programming language, in which OpenSSL is written, because of the lack of automatic array bounds checking. It was possible for a client to exploit this error and view internal memory of the server, potentially discovering sensitive information. The code to fix this problem was shorter than this paragraph.

Note

The following xkcd comic provides a succinct and amusing explanation of the heartbleed bug:

https://xkcd.com/1354/

The scale and severity of this vulnerability cannot be overstated. The most damaging attack is if the server's private key was leaked. Knowing the private key, an attacker can impersonate the server, and clients could willingly disclose private information to the impostor. However, on a server with a HSM, the heartbleed vulnerability was more limited. Sensitive information, such as session cookies, would still have leaked via the software exploit. Yet the server's private key, which remains in the HSM, would not have leaked.

Since the hardware cryptographic co-processor runs as a physically separate machine, it is very difficult for software exploits running on the main processor to disclose secrets in the hardware module. In the embedded world, there are several chips that perform this key isolation feature.

Understanding the disadvantages of hardware crypto devices

Adding hardware cryptographic devices doesn't automatically make your project secure. In the following sections, we'll discuss some of the downsides to using cryptographic hardware and some of the concerns you would need to resolve when using them in your project.

Lacking cryptographic flexibility

A hardware cryptographic device is generally not configurable. This is usually by design but the implication is that it is difficult, if not impossible, to alter the cryptographic behavior of the device. If you select a chip that performs encryption with a limited key size, you will not be able to upgrade the device with a stronger key size later. It is generally easier to update software-based encryption systems.

Exposing hardware-specific attack vectors

While an isolated crypto processor may reduce attacks or exploits from the software, it often allows more sophisticated hardware-based attacks. There are three categories of hardware-based attacks: noninvasive, invasive, and semi-invasive (Skoroboga, 2011). Noninvasive attacks treat the chip as a black box and attempt to manipulate the surrounding environment to perform an exploit. Successful non-invasive attacks include performing a Differential Power Analysis (DPA) to monitor the chip as it performs an encryption algorithm. By measuring the power usage during the encryption operation, it is possible to see the key through distinct power signatures. An invasive attack usually involves physically destroying the chip in some manner to gain access to its internals. Semi-invasive attacks may involve some sort of laser imaging to observe or interfere with the chip.

Note

To perform a glitch attack, an attack attempts to manipulate the executing instruction by injecting a fault (Bar-El, 2004). Colin O'Flynn, a security researcher, has a concise and clear example of how a glitch attack can cause a password-checking microprocessor to fail: https://www.youtube.com/watch?v=Ruphw9-8JWE&list=UUqc9MJwX_R1pQC6A353JmJg.

Obfuscating implementation details

A final consideration is that while chip vendors may publish the interface to their device, the internals are often proprietary. This is similar to a software vendor who publishes the software programming interface, but provides only the compiled binary and not the source code. In this case, the chip is treated as a black box, and without a mechanism to verify the device, you have to trust that it is operating correctly. As cryptographic libraries are ported to unique microcontrollers by the open source community, this situation will hopefully improve.

Summarizing the hardware versus software debate

So, which is the better route? As with most complex technologies the correct answer is: it depends. For a truly embedded system, one that can't spare even a few extra bytes, a hardware security chip may be your only option if you can't upgrade your microprocessor. Also, if there is a high threat of leaking your key due to a software vulnerability, then the separate crypto co-processor might help you. However, if an attacker can gain physical access to your device, then they might be able to extract the key with hardware-based attacks. Lastly, if transparency is paramount for you to verify the lack or existence of backdoors, then only fully open source software and hardware devices will satisfy you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.237.164