I've also packaged some cryptography-enabled packages for Red Hat Linux, such as Lynx with SSL. These are all based on freely-available source code.
I've benchmarked the code on a 10 MHz Microchip PIC16F84 and a 50 MHz Scenix SX28AC, because these were the parts readily available to me. Some midrange PIC devices are now rated to run at 20 MHz, and high-end PICs to 33 MHz. Scenix does not currently offer parts with data EEPROM, but their parts are fully pipelined, so they run almost four times as fast as a PIC at the same clock rate.
|Function||Performance on 20 MHz Microchip PIC16F84A|
|cycle count||time||bits per second|
|Key Setup||156||31.2 uS||n/a|
|Encryption||5694||1.14 mS||56.2 Kb/s|
|Decryption||5784||1.16 mS||55.3 Kb/s|
The code size is 434 words, plus a 256-word table to store the S-boxes, for a total of 690 words. Some savings can be realized if it is not necessary to have both encryption and decryption functions available.
The code uses 20 bytes of RAM internally. 8 bytes are used to store the key reorganized into a different format for more efficient access; if these bytes are used for other purposes between DES calls, it will be necessary to call the key setup function again before calling the encryption or decryption functions. The remaining 12 bytes are used as scratch space during the encryption and decryption processes, and need not be preserved between calls.
In addition, the key setup, encrypt, and decrypt routines each expect the caller to provide a pointer to 8 bytes of RAM used for the key, plaintext, and/or ciphertext.
The DESPICable source code is available under the terms of the Free Software Foundation's General Public License, Version 2. If you agree to the terms of the license, you may download a copy in .tgz format:
Al Lovrich and Mark Palmer of Microchip have written a DES implementation for the PIC17 series. They have not made the code available online due to US export restrictions, but it is described in Microchip Application Note AN583:
|Function||Performance on 25 MHz Microchip PIC17C42|
|program words||cycle count||time||bits per second|
|Key management and subkey generation||382||2729||436 uS||n/a|
|Encryption||798||7714||1.234 mS||51.8 Kb/s|
I haven't seen their code, but from the description in the application note it seems that they must devote a lot of RAM to subkeys. I structured my code to avoid ever having to store subkeys.
Bruce Schneier wrote about SKIPJACK in the July 15, 1998 issue of Crypto-Gram.
A 256 word table and a 1 word jump instruction are needed for either encryption or decryption. In addition to the 10 bytes of key and 8 bytes of data, only 2 temporary registers are used.
|Function|| code (14-bit words),|
not including the common 257 words
|Performance on 20 MHz Microchip PIC16F84A||Performance on 50 MHz Scenix SX|
|cycle count||time||bits per second||cycle count||time||bits per second|
|Encryption - using subroutine for half-G()||61||2952||590 us||108.4 Kb/s||3208||64.2 us||997.5 Kb/s|
|Encryption - using inline half-G()||73||2696||539 us||118.7 Kb/s|
|Decryption - using subroutine for half-G^-1()||62||2953||591 us||108.4 Kb/s||3209||64.2 us||997.5 Kb/s|
|Decryption - using inline half-G()||74||2697||539 us||118.6 Kb/s|
The code could easily be altered to directly access the key from EEPROM on a suitable PIC (such as a PIC16F84), saving 10 bytes of RAM.
The SKIPJACK source code is available under the terms of the Free Software Foundation's General Public License, Version 2. If you agree to the terms of the license, you may download a copy in .tgz format:
"The fact that a medium of expression has a functional capacity should not preclude constitutional protection."
Last updated August 21, 2003
Copyright 1998, 1999, 2000, 2001, 2002, 2003 Eric Smith