LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-22-2006, 11:56 PM   #1
rrajguru
LQ Newbie
 
Registered: May 2006
Posts: 3

Rep: Reputation: 0
3DES lib for Linux


Hi,

We want to use 3DES API's in my C application for 3DES encrytion and decryption.
Where can I find free downloadable 3DES lib for linux and information about its API's which I can use in my C applications ???

Any pointers on this will be of great help to us

Thanks in advance for your help

Thanks
Rajesh
 
Old 05-23-2006, 12:18 AM   #2
pronoy
Member
 
Registered: Mar 2005
Location: india
Distribution: FC4, Debian Etch
Posts: 67

Rep: Reputation: Disabled
check crypto library (libcrypto.so)
 
Old 05-23-2006, 06:14 AM   #3
rrajguru
LQ Newbie
 
Registered: May 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Hi,

If possible , can you pl let me know the link form where I can download this and also get information on the API's used in this ?

Thanks
Rajesh
 
Old 05-23-2006, 07:01 AM   #4
pronoy
Member
 
Registered: Mar 2005
Location: india
Distribution: FC4, Debian Etch
Posts: 67

Rep: Reputation: Disabled
Sorry, I don't remember it now.
Search with google.
For implementation, you have to check how other modules like strongswan or openssl uses it
 
Old 05-30-2006, 01:10 AM   #5
rrajguru
LQ Newbie
 
Registered: May 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Hi,

I was trying to do some encryption decryption job using openssl's 3DES library. But while decrypting I am getting first 8 bytes
as junk. Here is a small program to demonstrate it. Can you please tell me what is wrong with me?

Do I need to do the encryption decryption job in 8byte blocks (using a loop)?

/* Linux extreem-machine 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003
i686 i686 i386 GNU/Linux*/
/* openssl-devel-0.9.7a-22.1 */
/* 3des.c - */
/*gcc -lssl 3des.c -o 3des*/
#include <openssl/des.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
/*Parity bits must be set*/
DES_cblock cb1 = {0xAE, 0x23, 0x01, 0x5B, 0xB3, 0x25, 0x49, 0xA1};
DES_cblock cb2 = {0xAE, 0x23, 0x01, 0x5B, 0xB3, 0x25, 0x49, 0xA1};
DES_cblock cb3 = {0xAE, 0x23, 0x01, 0x5B, 0xB3, 0x25, 0x49, 0xA1};

DES_key_schedule ks1;
DES_key_schedule ks2;
DES_key_schedule ks3 ;

DES_cblock cblock = {0xAE, 0x23, 0x01, 0x5B, 0xB3, 0x25, 0x49, 0xA1};//{'3','D','E','S','-','K','E','Y'};

char string[]="Welcome to the new world __ thanks to the 3DES encryption"
"\nNot so good but not so BAD also"
"\nTHIS IS A PLAIN TEXT"
"\nThis is a plain text\n";
char cipher[1024];
char text[1024];
int crypto_len = 0;

DES_set_odd_parity(&cblock);
if(DES_set_key_checked(&cb1, &ks1) || DES_set_key_checked(&cb2, &ks2) || DES_set_key_checked(&cb3, &ks3))
{
printf("Key error, exiting ....\n");
return 1;
}

memset(text,'\0', 1024);
memset(cipher, '\0', 1024);

crypto_len= ((strlen(string) + 7)/ 8)*8;
DES_ede3_cbc_encrypt (string, cipher, strlen(string), &ks1,&ks2,&ks3, &cblock,1);
DES_ede3_cbc_encrypt (cipher, text, crypto_len, &ks1,&ks2,&ks3,&cblock,0);

//printf(cipher);
printf(text);

}

Any pointers on this willbe of great help

Thanks
Regards,
Rajesh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Locking in" Glibc (replace prob /lib/ld-linux.so.2 with /tools/lib/ld-linux.so.2 irfanali Linux From Scratch 11 06-29-2006 10:19 AM
Register lib files in linux redhat_zephyr Linux - Newbie 3 10-22-2004 07:17 AM
Compromised? Files "/usr/lib.hwm", "/usr/lib.pwd", "/usr/lib.pwi" Klaus Pforte Linux - Security 4 09-28-2004 11:33 PM
Moving from dynamic lib (Windows) to linux simbo Linux - Newbie 1 02-25-2004 10:59 PM
/lib/ld-linux.so.2: version 'GLIBC_PRIVATE' not found error nienamusa Red Hat 0 02-04-2004 09:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration