473,769 Members | 3,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need Tripple DES encryption algorithm in C

Hello C

I have a project that requires a calculated "key" to be used in a security
access application. The customer supplies a secret 8 byte number that gets
combined with the serial number of the access card to provide a unique
access key for that card.

They've specified that the encryption method (called "diversificatio n") is
something called Tripple DES. I'm not a crypto weenie, just a software guy.
My research on this has led me to block diagrams of the process but no code
examples on how to impliment Tripple DES.

Does anybody know of public domain code for Tripple DES in C?

Thanks
Mar 23 '07 #1
3 10495
On 23 Mar, 11:33, "Dave Cullen" <nos...@mail.co mwrote:
>
They've specified that the encryption method (called "diversificatio n") is
something called Tripple DES. I'm not a crypto weenie, just a software guy.
My research on this has led me to block diagrams of the process but no code
examples on how to impliment Tripple DES.

Does anybody know of public domain code for Tripple DES in C?
The correct place for this would be sci.crypt, but here's the basics.

The underlying encryption algorithm is called "DES", or "Data
Encryption Standard" - see http://en.wikipedia.org/wiki/Data_Encryption_Standard.

Triple DES is simply DES applied three times - see http://en.wikipedia.org/wiki/Triple_DES.

You need three keys; the normal way of doing 3DES is:

C = E(K3, D(K2, E(K1, P)))

which means encrypt the plaintext using key 1, then decrypt the result
using key 2, then encrypt the result of that using key 3

The main reason for the middle step being a decryption, by the way, is
that if you used the same key for K1, K2, and K3, the result would be
identical to normal single DES encryption, which makes it a doddle to
implement both in the same hardware.

The usually accepted method for obtaining the keys is to hash the
passphrase (or in your case the generated access key) using the
algorithm specified in RFC2898 (see http://tools.ietf.org/html/rfc2898).

To be perfectly honest, if the data you are protecting is important or
valuable, you _really_ should get someone experienced in cryptography
to do this stuff for you; it can be extraordinarily difficult to do
crypto correctly and securely. And if the data is not that important
or valuable, why on earth are you using 3DES?!

Best of luck :)

Mar 23 '07 #2
On Mar 23, 12:33 pm, "Dave Cullen" <nos...@mail.co mwrote:
Hello C
Hello,
Does anybody know of public domain code for Tripple DES in C?
The OpenSSL library supports that!
>
Thanks

Mar 23 '07 #3
Dave Cullen wrote:
Hello C

I have a project that requires a calculated "key" to be used in a security
access application. The customer supplies a secret 8 byte number that gets
combined with the serial number of the access card to provide a unique
access key for that card.

They've specified that the encryption method (called "diversificatio n") is
something called Tripple DES. I'm not a crypto weenie, just a software guy.
My research on this has led me to block diagrams of the process but no code
examples on how to impliment Tripple DES.

Does anybody know of public domain code for Tripple DES in C?
For starters, get a crypto book (include lot of C code):

http://www.schneier.com/book-applied.html

"just a software guy" is hardly the right person to implement this. If
you have DES source code, it's trivial to implement 3DES.

The point about key diversification , is that the whole system will not
be broken if a card/token is cracked.

--
Tor
Mar 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

113
12352
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same algorithm work with strings that may or may not be unicode 3) Number of bytes back must either be <= number of _TCHARs in * sizeof(_TCHAR), or the relation between output size and input size can be calculated simply. Has to take into account the...
7
2245
by: Alan Silver | last post by:
Hello, I am writing a page where sensitive data is collected (over SSL) and stored in a database. I have been looking at the .NET encryption classes, but am a bit confused as to which is best for my purposes. There seem to be quite a few different ways of doing it, and I'm not sure what's most suitable for me. Anyone any suggestions? I only need to be able to store the data in such a way that someone without access to my (to see how...
1
8138
by: Peter | last post by:
Has anyone made a simple tripple des encryption function? I'm looking for a function to pass a string into with a password and generate an encrypted output. That's it. IE. Public Function EncryptMe (StringtoEncrypt, Password)as string End Function Public Function DecryptMe (StringtoDecrypt, Password)as string
3
2305
by: Mike | last post by:
Hi, I have been experimenting with the RijndaelManaged Cryptography class in C# and have stumbled upon a "peculiarity". Following code is standalone Console App that demonstrates using System; using System.Text; using System.IO;
10
2280
by: Nemok | last post by:
Hi, I am trying to write an additive encryption algorithm in C++ that will encrypt a text by adding a random numer to each character in a string. The code looks similar to this: for(int i=0;i<=tlength-1;i++)///tlength is the length of the string to encrypt { ctext+=x+i;/////x is a random number and ctext is a char*
1
1345
by: JJ | last post by:
I have a list of contacts in a webpage and the list is created throught the repeater controls. During ItemDataBound event of the repeater, I encrypt the ID of the contacts. When user double clicks on the contact, encrypted ID of the doubled-clicked contact is sent as a querystring (no postback, thru javascript) to the detailed page (so that users cannot type in plain text id and have access to contacts that they are not entitled to),...
11
5049
by: John Williams | last post by:
I've written a simple program to do XOR encryption as my first foray into understanding how encryption works. The code compiles fine, however it segmentation faults on every run. using gdb to debug it let me narrow the problem down to the Cipher function I think it faults at line 84 or 85. The program makes it's first read/cipher/write pass without issue but the second pass kills it. Using gdb to print the variables left showed me the...
8
2745
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't understand why it is doing this. Below is my code, I would be greatfull if someone can guide me through the right path or even help me solve this issue. Problem: The old tool which was written in VB6 works perfect. But I needed to convert this to C#...
22
7695
by: j1mb0jay | last post by:
I have had to create a simple string encryption program for coursework, I have completed the task and now have to do a write up on how it could be improved at a later date. If you could look through the code and point me in the correct direction one would be very grateful. Example Input : j1mb0jay Example Output 1 : rZHKZbYZWn/4UgL9mAjN2DUz7X/UpcpRxXM9SO1QkvkOe5nOPEKnZldpsB7uHUNZ Example Output 2 :...
0
9589
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
9423
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
10211
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...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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
7408
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
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.