473,719 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Triple DES Algorithm in .NET

2 New Member
Hello to everyone,

Recently, I came across a scenario which required some data encryption routines applied to general binary files. I decided to use the managed code provided by .NET that implements the Triple Des algorithm (TripleDESCrypt oServiceProvide r object). Everything works fine as long as we stay within the .NET framework but what if the encryption or decryption routine is implemented on a different platform? (e.g. using Java's Cryptographic libraries). In that case, a file encrypted with a Java or Delphi platform is not easily decrypted with a C# e.g. routine of the .NET framework. For this reason I would like to know more about the actual implementation of the DES and Triple DES algorithms in .NET, from an algorithmic point of view (The algorithm uses some permutations, XOR operations, some bits of the key are ignored etc). Any kind of help would be highly appreciated.

Thank you,
Kyriakos Petrakos
Jan 30 '07 #1
3 7327
enreil
86 New Member
Kyriakos,

You can read more in-depth material about DES encryption here. As you already know triple DES is a based on DES, so once you know how DES functions, you should hopefully be able to make the jump to Triple DES, which you can read about here.

Hope that helps.

Hello to everyone,

Recently, I came across a scenario which required some data encryption routines applied to general binary files. I decided to use the managed code provided by .NET that implements the Triple Des algorithm (TripleDESCrypt oServiceProvide r object). Everything works fine as long as we stay within the .NET framework but what if the encryption or decryption routine is implemented on a different platform? (e.g. using Java's Cryptographic libraries). In that case, a file encrypted with a Java or Delphi platform is not easily decrypted with a C# e.g. routine of the .NET framework. For this reason I would like to know more about the actual implementation of the DES and Triple DES algorithms in .NET, from an algorithmic point of view (The algorithm uses some permutations, XOR operations, some bits of the key are ignored etc). Any kind of help would be highly appreciated.

Thank you,
Kyriakos Petrakos
Jan 30 '07 #2
kenobewan
4,871 Recognized Expert Specialist
Here is some info about how .net uses DES and 3DES:
machineKey Element (ASP.NET Settings Schema)
Jan 31 '07 #3
Kyriakos Petrakos
2 New Member
Enreil, Kenobewan, thank you for the really informative links. As one could see on the DES description, 3DES algorithm is virtually a three times application of the DES algorithm for each block of 8 bytes (64 bits). Assuming that 3DES takes as input a 192 bit key, it splits the key, generating 3 64 bits keys k1, k2, k3. After the splitting occurs, we have an iterative application of the following execution pattern for each 8-byte block of the original file, starting from the 1st (leftmost) block:

b1 = DES_Encrypt(k1, block); (1)
b2 = DES_Decrypt(k2, b1); (2)
b3 = DES_Encrypt(k3, b2); (3)

The resulting b3 is the encoded block corresponding to the initial "block" of bytes. The CBC version of the algorithm uses subsequently the b3 in order to encode the following pair of 8 bytes. The CBC version uses also an Initial Vector of 8 bytes in order to encode the leftmost 64 bits of the file, as the first 64 bits of the file do not have a previous "block". The question now is formulated as follows: Where exactly is the Initial Vector (IV) used in the .NET implementation? Each application of DES_Something in the lines (1),(2),(3) above requires an IV, assuming that we use the CBC version of the algorithm. Does line (2) uses the IV that we provide the general TripleDES algorithm or uses as IV the block already encrypted in line (1)? The MSDN description does not go so deep into the implementation of the algorithm and does not touch this one as well as similar matters (e.g. which IV is used when the second block of the file is encrypted? Do we continue to use the initial IV of the algorithm or we encode the second block based on the output of the first block)?

Thank you in advance,
Kyriakos Petrakos
Jan 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1981
by: Anthony Roberts | last post by:
property = re.compile("""(?P<name>+)="(?P<value>.*?)""""re.I) This doesn't work because the closing quote in my regex forms the first quote of a triple quote to end the string... property = re.compile("""(?P<name>+)=("(?P<value>.*?)")""", re.I) This mucks up stuff I want to do later. I've thought about it for a while, and except for changing it to a
1
2392
by: Edward C. Jones | last post by:
On 2003-09-04, Rasmus Fogh said: > I need a way of writing strings or arbitrary Python code that will > > a) allow the strings to be read again unchanged (like repr) > b) write multiline strings as multiline strings instead of escaping > the \n's. > > A repr function that output triple-quoted strings with explicit > (non-escaped) linebreaks would be perfect.
8
3230
by: Christoph Zwerschke | last post by:
I sometimes use triple quotes in order to produce snippets of multiline code, like that: if output == html: snip = '''<html> <head><title>Hello, World</title></head> <body bgcolor="aqua"><h1>What's up?</h1> </html>''' else: snip = 'Hello!'
11
2056
by: bearophile | last post by:
Hello, here are a four more questions (or suggestions) for the language (probably people have already discussed some of/all such things: I've seen the contracts for Python: http://www.wayforward.net/pycontract/ http://www.python.org/peps/pep-0316.html They look interesting and nice, how Python developers feel about accepting something like this in the standard language? (Maybe they are a bit complex).
7
3980
by: Brian van den Broek | last post by:
Hi all, I'm posting partly so my problem and solution might be more easily found by google, and partly out of mere curiosity. I've just spent a frustrating bit of time figuring out why pydoc didn't extract a description from my module docstrings. Even though I had a well formed docstring (one line, followed by a blank line, followed by the rest of the docstring), when I ran Module docs, my modules showed up as having "no description"....
3
2535
by: Michele Simionato | last post by:
I am getting trouble with nested triple quoted strings in doctest. For instance $ cat x.py """ >>> dummy = ''' something here ''' """
14
6109
by: dmh2000 | last post by:
I recently complained elsewhere that Python doesn't have multiline comments. i was told to use triple quoted strings to make multiline comments. My question is that since a triple quoted string is actually a language construct, does it use cause a runtime construction of a string which is then discarded, or is the runtime smart enough to see that it isn't used and so it doesn't construct it? example def fun(self):
15
2590
by: Andy Mabbett | last post by:
Google finds: Results 1 - 20 of about 34,000 linking to http://www.w3.org/WAI/WCAG1AAA-Conformance -- Andy Mabbett Say "NO!" to compulsory ID Cards: <http://www.no2id.net/> Free Our Data: <http://www.freeourdata.org.uk>
8
4272
by: Lawrence D'Oliveiro | last post by:
If triple-quoted strings had the Python-nature, then they would take indentation into account. Thus: """this is a multi-line string.""" would be equivalent to
0
8828
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8725
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6658
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5971
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2124
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.