Archive for July, 2008

AutoKey in Haskell

Friday, July 11th, 2008

Yesterday I tried programming Haskell. Looking for something simple, I decided on an AutoKey cipher implementation. Despite a lot of problems dealing with file I/O and stumbling through a number of other subtleties of the language, I am pretty happy with the result.

My impression of Haskell is that it is a very powerful language after you have mastered it. It has many features and the separation between real world/state and purity are great.

Of course, it has a few downsides too. The lazy evaluation sometimes makes it difficult to visualize how its all working. The lack of proceduralism can make finding/fixing bugs kind of difficult, but this might be a side effect of inexperience. I imagine there are some good tools that could help, but the debugging strategies I learned with a language like C are not always applicable.

Here’s some sample output for encryption and decryption:

[rick@copernicus ~/workspace/AutoKey/bin]$ ./theResult e lorem malus
LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISICING ELIT, SED DO
EIUSMOD TEMPOR INCIDIDUNT UT LABORE ET DOLORE MAGNA ALIQUA. UT ENIM AD
MINIM VENIAM, QUIS NOSTRUD EXERCITATION ULLAMCO LABORIS NISI UT ALIQUIP
EX EA COMMODO CONSEQUAT. DUIS AUTE IRURE DOLOR IN REPREHENDERIT IN
VOLUPTATE VELIT ESSE CILLUM DOLORE EU FUGIAT NULLA PARIATUR. EXCEPTEUR
SINT OCCAECAT CUPIDATAT NON PROIDENT, SUNT IN CULPA QUI OFFICIA DESERUNT
MOLLIT ANIM ID EST LABORUM.

XOCYE TDJYY LDDID VWE ODWB, VOZWXEHRLYT THBJZSLKXVY MNQG, YIO LH
WMXVASL NWYDRK MZRWUQQWVW CW FNUIKP EU RFPSKH ALUEE MLODUA. FB UHIG TH
ZQZIP HMAQMH, UHQS ZEMBJHR WQVLFMQEKKWG UETOZWZ WANQFTS OWJQ MG IDQKNIA
MN YI RSJQOFC OABVSSINL. HKCS TXNM AROKI LFFFV LB CSGZRYICUIYMG LR
MWECCOOEY KXLBX ZWDM VMDDYO LZWIDH SF TLKMUY HATLT CUCTAIUI. MXVYGXBWV
HBRN FUKNXQCV CYRIWCNPB QOG PKBWQTEH, AXRG BF WHEXN SOT DFVCKWF IMUMRXRL
QFFYBF OYTU BD RAF TDFGKFM.

[rick@copernicus ~/workspace/AutoKey/bin]$ ./theResult d xocye malus
XOCYE TDJYY LDDID VWE ODWB, VOZWXEHRLYT THBJZSLKXVY MNQG, YIO LH
WMXVASL NWYDRK MZRWUQQWVW CW FNUIKP EU RFPSKH ALUEE MLODUA. FB UHIG TH
ZQZIP HMAQMH, UHQS ZEMBJHR WQVLFMQEKKWG UETOZWZ WANQFTS OWJQ MG IDQKNIA
MN YI RSJQOFC OABVSSINL. HKCS TXNM AROKI LFFFV LB CSGZRYICUIYMG LR
MWECCOOEY KXLBX ZWDM VMDDYO LZWIDH SF TLKMUY HATLT CUCTAIUI. MXVYGXBWV
HBRN FUKNXQCV CYRIWCNPB QOG PKBWQTEH, AXRG BF WHEXN SOT DFVCKWF IMUMRXRL
QFFYBF OYTU BD RAF TDFGKFM.

LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISICING ELIT, SED DO
EIUSMOD TEMPOR INCIDIDUNT UT LABORE ET DOLORE MAGNA ALIQUA. UT ENIM AD
MINIM VENIAM, QUIS NOSTRUD EXERCITATION ULLAMCO LABORIS NISI UT ALIQUIP
EX EA COMMODO CONSEQUAT. DUIS AUTE IRURE DOLOR IN REPREHENDERIT IN
VOLUPTATE VELIT ESSE CILLUM DOLORE EU FUGIAT NULLA PARIATUR. EXCEPTEUR
SINT OCCAECAT CUPIDATAT NON PROIDENT, SUNT IN CULPA QUI OFFICIA DESERUNT
MOLLIT ANIM ID EST LABORUM.

I’ve made the code available on my projects page. Comments are welcomed. Enjoy.

How secret is your secret ballot? Part 3 of 3: Surveillance

Thursday, July 10th, 2008

This article is cross-posted from the punchscan blog. Leave your comments over there.

Both part 1 and 2 dealt with interface problems between the voter and a paper ballot, machine, or computer that records her vote. For this last segment, Surveillance, we discuss the ways the voter can be watched to determine her choices. Because the attacker or a device must be present to carry out these attacks, they are generally considered more expensive to carry out than what we have discussed so far.

Using the same strategy as seen in the previous segment, we will start with simple examples of this attack, move on to more elaborate examples, and end our discussion with how you could defend against these attacks. Again, as we’ve already seen, different flavors of these attacks may or may not require voter cooperation to work.

Simple Surveillance

The simplest paper ballot scenario is the following: the local union boss sits in the polling place. You flash your ballot to him as you take it from the booth to the ballot box or scanner. He checks your name off on his list.

Another, that works for DREs as well, is to take a cell phone picture or video of your ballot just before or as you are casting it. If the DRE has an audio interface, you may also be able to hook up an audio recorder and record your vote casting experience on tape.

Another class is the “over the shoulder” attack. The voter or poll workers may or may not have to cooperate for it to work. In some cases you may be able to succeed at a significant distance.

Hacking the Machine

The optical scanner or computer (or even lever machine), by definition, records voter choices. It could be modified to keep a serial record this input. The attacker can record the serialization to each voter by recording the order of who uses the machine, and retrieve the record after the election.

Because of the trail it would leave, this class of attacks is undesirable. However, our current testing practices and laws are such that this information might be public record, as seen in Ohio after the 2006 election.

Going High Tech

Mini wireless spy cameras sell for as low as $70, possibly lower. That is well within the range of affordability. In addition, the relative predictability of how polling places are set up means the cameras could be there days before the election begins. A bag or pen equipped with this technology would have no problem recording voter choices.

The camera does not have to be limited to the visible light spectrum. An infrared or other kind of camera might be much easier to hide. In some cases, your body might not be enough to block its vision.

It may not even need to be a camera. Sensors or microphones in the polling booth might be enough to correlate voter choices. You can recover typed text using audio, it’s not a huge jump to do it for voting.

TEMPEST Attacks

A TEMPEST attack is one which records electronic emanations that reveal information being processed by the computer. A dutch group created a great video showing how this works. Take a look:

My favorite TEMPEST hack, from what I have seen, is an MP3 player for CRT monitors. Just tune your AM radio and enjoy.

Defeating Surveillance

In general, it’s an arms race. As technology progresses and becomes ever more affordable, the situation gets worse. Unless you can strip each voter and scan for optical eye and other types of implants, election officials will eventually lose.

The strategy here should be to drive up costs and take precautions. Make machines that meet the TEMPEST standards. Go to each polling place and do a scan for wireless emissions. Look for cameras and sensors when you set up the polling place. Do not allow voters to take cell phone cameras or bags into the voting booth. As long as it is prohibitively expensive, the laws are harsh, and there is the threat of being caught, it is hopefully not worth it.