![]() |
home | contact us | about us | |
| DES, TripleDES and BlowFish in Silverlight (by Lou Brown, last updated 4-MAR-2011) The Brief Anyone wanting to implement DES or TripleDES encryption in Silverlight is going to get a surprise. The reduced .Net library for Silverlight 4 does not contain a cryptography provider for either. You can use AES instead, which is supported on all .Net platforms, but if you are being fed DES or TripleDES encrypted data from a service that is out of your reach, the lack of any DES support is a problem. BlowFish on the other hand was never supported in .Net, which is a shame because it is simpler and quicker than DES and TripleDES, and has a maximum key length of 56 bytes, compared to the shorter 8 bytes for DES and 24 bytes for TripleDES. (DES had United States government approval a long time ago, whereas Richard Nixon never gave his opinion of BlowFish.) BlowFish, DES and TripleDES have something in common - they have no known crack. There are some methods of attacking DES that reduce a brute force attack by a log or two, and there are some weak and semi-weak keys to avoid, but if you want to crack DES, TripleDES or BlowFish, something like a brute force attack is the only way. DES has a feeble key length of 8 bytes, and recently DES was cracked using a brute force attack in 24 hours by an array of FPGAs. But by extending the key length to 24 bytes with TripleDES, this again puts your data out of reach or prying eyes for the next few years. Class Libraries The algorithms are implemented as two .Net classes - DESCryptography and BlowFishCryptography. Both classes were developed on Windows 7 and VS2010 using .Net 4 and Silverlight 4.
DESCryptography The DESCryptography class matches the output of .Net's TripleDESCryptoServiceProvider and DESCryptoServiceProvider, assuming you have not changed the DES default padding mode. The default padding mode used by .Net adds a number of bytes to the end of the plaintext before encrypting, to bring the length of the plaintext up to a factor of the DES block length, 8 bytes. If the plaintext is already a factor of 8 bytes, another 8 bytes are added. So encrypting 8 bytes produces 16, and decrypting 16 bytes produces 8. For each block that is encrypted, the block is first XORed with the previous block. Applying this succession method reduces the possibility of a pattern appearing in the cyphertext. The following is a summary of the structures and functions:
The functions MakeGoodDesKey and MakeGoodTripleDesKey are for converting a source of key data, such as a string or a series of numbers, into a valid key. These functions do not use any random number generation, so the resulting key can consistently be recreated from the binary source. BlowFishCryptography The BlowFishCryptogaphy class is similar in functionality to the DES class, except there is a choice of encryption functions, BlowFish and BlowFishWithPadding. The following is a summary of the functions:
Code Example The following code snippet takes a buffer of random bytes and encrypts it using DES.
Here are the source files again.
Development note: The DESCryptography and BlowFishCryptogaphy classes are not specific to any application, so I've placed them in the BroccoliProducts namespace. You are free to copy or modify the code samples. MORE INFORMATION The DES Algorithm Illustrated by J. Orlin Grabbe MSDN - DESCryptoServiceProvider Wikipedia - DES Wikipedia - BlowFish |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
© 1998-2012 Broccoli Products Ltd Reg Number: 2895355 Reg Office: 27 Old Gloucester Street, London. WC1N 3AX |
Privacy Policy Copyright Notice Liability Disclaimer Contact Us |
|